You are here

static function RealisticDummyContent::realistic_dummy_content_api_dummy in Realistic Dummy Content 8

Implements hook_realistic_dummy_content_api_dummy().

2 calls to RealisticDummyContent::realistic_dummy_content_api_dummy()
RealisticDummyContentTest::testIsDummy in api/tests/src/Unit/facade/RealisticDummyContentTest.php
realistic_dummy_content_api_realistic_dummy_content_api_dummy in api/realistic_dummy_content_api.module
Implements hook_realistic_dummy_content_api_dummy().

File

api/src/facade/RealisticDummyContent.php, line 159
Define autoload class.

Class

RealisticDummyContent

Namespace

Drupal\realistic_dummy_content_api\facade

Code

static function 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\Component\Utility\Unicode::substr($entity->mail, strlen($entity->mail) - strlen($suffix)) == $suffix) {
        return TRUE;
      }
      break;
    default:
      break;
  }
  return $return;
}