You are here

function realistic_dummy_content_api_realistic_dummy_content_api_dummy in Realistic Dummy Content 7

Same name and namespace in other branches
  1. 8.2 api/realistic_dummy_content_api.module \realistic_dummy_content_api_realistic_dummy_content_api_dummy()
  2. 8 api/realistic_dummy_content_api.module \realistic_dummy_content_api_realistic_dummy_content_api_dummy()
  3. 7.2 api/realistic_dummy_content_api.module \realistic_dummy_content_api_realistic_dummy_content_api_dummy()
  4. 3.x api/realistic_dummy_content_api.module \realistic_dummy_content_api_realistic_dummy_content_api_dummy()

Implements hook_realistic_dummy_content_api_dummy().

1 call to realistic_dummy_content_api_realistic_dummy_content_api_dummy()
realistic_dummy_content_UnitTestCase::testModule in api/tests/realistic_dummy_content_api.unit.test

File

api/realistic_dummy_content_api.module, line 275
API code allowing other modules to generate realistic dummy content. See the Realistic Dummy Content module for an example of how to use.

Code

function realistic_dummy_content_api_realistic_dummy_content_api_dummy($entity, $type) {
  $return = FALSE;

  // Any entity with the devel_generate property set should be considered
  // dummy content. although not all dummy content has this flag set.
  // See https://drupal.org/node/2252965
  // See https://drupal.org/node/2257271
  if (isset($entity->devel_generate)) {
    return TRUE;
  }
  switch ($type) {
    case 'user':

      // devel_generate puts .invalid at the end of the generated user's
      // email address. This module should not be activated on a production
      // site, or else anyone can put ".invalid" at the end of their email
      // address and their profile's content will be overridden.
      $suffix = '.invalid';
      if (isset($entity->mail) && drupal_substr($entity->mail, strlen($entity->mail) - strlen($suffix)) == $suffix) {
        return TRUE;
      }
      break;
    default:
      break;
  }
  return $return;
}