You are here

function hook_realistic_dummy_content_api_dummy in Realistic Dummy Content 8

Same name and namespace in other branches
  1. 8.2 api/realistic_dummy_content_api.api.php \hook_realistic_dummy_content_api_dummy()
  2. 7.2 api/realistic_dummy_content_api.api.php \hook_realistic_dummy_content_api_dummy()
  3. 7 api/realistic_dummy_content_api.api.php \hook_realistic_dummy_content_api_dummy()
  4. 3.x api/realistic_dummy_content_api.api.php \hook_realistic_dummy_content_api_dummy()

hook_realistic_dummy_content_api_dummy().

Return whether or not an object of a given type is a dummy object or not. The motivation for this hook is for cases where you may not be using devel_generate for nodes, or whether you have a specific technique for determining whether or not a given object is dummy content or not.

Parameters

$entity: The object for a given type, for example this can be a user object or a node object.

$type: The type of the information to change, for example 'user' or 'node'.

Return value

Boolean value representing whether or not this object is a dummy object. FALSE means we were unable to ascertain that the entity is in fact a dummy object. Other modules which implement this hook might determine that this is a dummy object.

1 function implements hook_realistic_dummy_content_api_dummy()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

realistic_dummy_content_api_realistic_dummy_content_api_dummy in api/realistic_dummy_content_api.module
Implements hook_realistic_dummy_content_api_dummy().
1 invocation of hook_realistic_dummy_content_api_dummy()
RealisticDummyContent::is_dummy in api/src/facade/RealisticDummyContent.php
Checks if a given entity is dummy content.

File

api/realistic_dummy_content_api.api.php, line 90
Hook definitions. These functions are never called, and are included here for documentation purposes only.

Code

function hook_realistic_dummy_content_api_dummy($entity, $type) {
  $return = FALSE;
  switch ($type) {
    case 'node':
      if (isset($entity->devel_generate)) {
        return TRUE;
      }
      break;
    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 (drupal_substr($entity->mail, strlen($entity->mail) - strlen($suffix)) == $suffix) {
        return TRUE;
      }
      break;
    default:
      break;
  }
  return $return;
}