public function RngEntityModel::hook_entity_postsave in RNG - Events and Registrations 3.x
Same name and namespace in other branches
- 8.2 src/RngEntityModel.php \Drupal\rng\RngEntityModel::hook_entity_postsave()
- 8 src/RngEntityModel.php \Drupal\rng\RngEntityModel::hook_entity_postsave()
React to Drupal `hook_entity_insert` or `hook_entity_update` hooks.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity object for the entity that is already saved.
bool $update: Whether this entity is new.
See also
_rng_entity_postsave();
File
- src/
RngEntityModel.php, line 99
Class
- RngEntityModel
- Enforces RNG model relationships.
Namespace
Drupal\rngCode
public function hook_entity_postsave(EntityInterface $entity, $update = TRUE) {
if ($entity instanceof RuleInterface) {
$this
->postSaveRngRule($entity);
}
if ($entity instanceof RegistrationInterface) {
$operation_record = new RngOperationRecord();
$operation = $update ? 'update' : 'insert';
$operation_record
->setOperation($operation)
->setEntityTypeId($entity
->getEntityTypeId())
->setEntityId($entity
->id());
$this->operationRecords[] = $operation_record;
}
if ($this->eventManager
->isEvent($entity) && $update == FALSE) {
$event = $this->eventManager
->getMeta($entity);
$event
->createDefaultEventMessages();
}
}