In comment #3 of #1748302: Lets generate kick-ass demo content!!!, in use hook_node_presave() and I use $node's ->devel_generate to determine if a node is dummy content. If it is I can make generated content more realistic.

The $user object does not have a ->devel_generate property, it would be nice to have this so we could intercept generated users in hook_user_presave(). This could be interesting for example if we have first and last name fields. By defaut devel_generate puts long strings in there. It would be more realistic to trim these to a 10-15 characters.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alberto56’s picture

Status: Active » Needs review
FileSize
662 bytes

Here's a patch I use for this.

alberto56’s picture

Without the dpm() in the code, it's better.

moshe weitzman’s picture

Looks reasonable. Do we need this in D8 as well?

alberto56’s picture

Actually I just noticed that D8 has this for users, in line 117 of devel_generate/lib/Drupal/devel_generate/Plugin/DevelGenerate/UserDevelGenerate.php

...
'devel_generate' => TRUE // A flag to let hook_user_* know that this is a generated user.
...

For nodes it's there as well, as it is in D7. In D8 it's on line 383 of devel_generate/lib/Drupal/devel_generate/Plugin/DevelGenerate/ContentDevelGenerate.php

...
$node->devel_generate = $results;
...
alberto56’s picture

One possible issue is that the devel_generate property is boolean for users and an array for nodes, in D8, and same for D7 with this patch.

alberto56’s picture

willzyx’s picture

Status: Needs review » Closed (outdated)

Closing for lack of activity. Feel free to reopen if the issue still exists

GaëlG’s picture

Version: 7.x-1.x-dev » 8.x-2.x-dev
Status: Closed (outdated) » Needs review
FileSize
691 bytes

Actually, D8 handles users but not terms. Here's a simple patch.

GaëlG’s picture

Title: Add $user->devel_generate so third parties can know it's generated content and modify it. » Let third parties know it's generated content and modify it.
amarphule’s picture

#8 applied clean and works for me on drupal-8.6.15.

GaëlG’s picture

Status: Needs review » Reviewed & tested by the community
moshe weitzman’s picture

Title: Let third parties know it's generated content and modify it. » Let third parties know it's generated content and modify it. (terms)
Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.