You are here

public function Drupal7::entityIsDummy in Realistic Dummy Content 7.2

Same name and namespace in other branches
  1. 8.2 api/src/Framework/Drupal7.php \Drupal\realistic_dummy_content_api\Framework\Drupal7::entityIsDummy()

File

api/src/Framework/Drupal7.php, line 205

Class

Drupal7
Drupal 7-specific code.

Namespace

Drupal\realistic_dummy_content_api\Framework

Code

public function entityIsDummy($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) && $this
        ->drupalSubstr($entity->mail, strlen($entity->mail) - strlen($suffix)) == $suffix) {
        return TRUE;
      }
      break;
    default:
      break;
  }
  return $return;
}