protected function PathAliasStorage::invokeHook in Drupal 8
Invokes a hook on behalf of the entity.
Parameters
string $hook: One of 'create', 'presave', 'insert', 'update', 'predelete', 'delete', or 'revision_delete'.
\Drupal\Core\Entity\EntityInterface $entity: The entity object.
Overrides ContentEntityStorageBase::invokeHook
File
- core/
modules/ path_alias/ src/ PathAliasStorage.php, line 16
Class
- PathAliasStorage
- Defines the storage handler class for path_alias entities.
Namespace
Drupal\path_aliasCode
protected function invokeHook($hook, EntityInterface $entity) {
parent::invokeHook($hook, $entity);
// Invoke the deprecated hook_path_OPERATION() hooks.
if ($hook === 'insert' || $hook === 'update' || $hook === 'delete') {
$values = [
'pid' => $entity
->id(),
'source' => $entity
->getPath(),
'alias' => $entity
->getAlias(),
'langcode' => $entity
->language()
->getId(),
];
if ($hook === 'update') {
$values['original'] = [
'pid' => $entity
->id(),
'source' => $entity->original
->getPath(),
'alias' => $entity->original
->getAlias(),
'langcode' => $entity->original
->language()
->getId(),
];
}
$this
->moduleHandler()
->invokeAllDeprecated("It will be removed before Drupal 9.0.0. Use hook_ENTITY_TYPE_{$hook}() for the 'path_alias' entity type instead. See https://www.drupal.org/node/3013865.", 'path_' . $hook, [
$values,
]);
}
}