You are here

static function RealisticDummyContent::entity_presave in Realistic Dummy Content 8

Implements hook_entity_insert().

1 call to RealisticDummyContent::entity_presave()
realistic_dummy_content_api_entity_presave in api/realistic_dummy_content_api.module
Implements hook_entity_insert().

File

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

Class

RealisticDummyContent

Namespace

Drupal\realistic_dummy_content_api\facade

Code

static function entity_presave(\Drupal\Core\Entity\EntityInterface $entity) {
  try {
    $type = $entity
      ->getEntityType();
    if (RealisticDummyContent::is_dummy($entity, $type)) {
      $candidate = $entity;
      RealisticDummyContent::improve_dummy_content($candidate, $type);
      RealisticDummyContent::validate($candidate, $type);
      $entity = $candidate;
    }
  } catch (\Exception $e) {
    drupal_set_message(t('realistic_dummy_content_api failed to modify dummy objects: message: @m', array(
      '@m' => $e
        ->getMessage(),
    )), 'error', FALSE);
  }
}