class PathAliasStorage
Same name and namespace in other branches
- 11.x core/modules/path_alias/src/PathAliasStorage.php \Drupal\path_alias\PathAliasStorage
- 10 core/modules/path_alias/src/PathAliasStorage.php \Drupal\path_alias\PathAliasStorage
- 9 core/modules/path_alias/src/PathAliasStorage.php \Drupal\path_alias\PathAliasStorage
Defines the storage handler class for path_alias entities.
Hierarchy
- class \Drupal\Core\Entity\EntityHandlerBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait
- class \Drupal\Core\Entity\EntityStorageBase implements \Drupal\Core\Entity\EntityStorageInterface, \Drupal\Core\Entity\EntityHandlerInterface extends \Drupal\Core\Entity\EntityHandlerBase
- class \Drupal\Core\Entity\ContentEntityStorageBase implements \Drupal\Core\Entity\ContentEntityStorageInterface, \Drupal\Core\Entity\DynamicallyFieldableEntityStorageInterface uses \Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait extends \Drupal\Core\Entity\EntityStorageBase
- class \Drupal\Core\Entity\Sql\SqlContentEntityStorage implements \Drupal\Core\Entity\Sql\SqlEntityStorageInterface, \Drupal\Core\Entity\Schema\DynamicallyFieldableEntityStorageSchemaInterface, \Drupal\Core\Entity\EntityBundleListenerInterface extends \Drupal\Core\Entity\ContentEntityStorageBase
- class \Drupal\path_alias\PathAliasStorage extends \Drupal\Core\Entity\Sql\SqlContentEntityStorage
- class \Drupal\Core\Entity\Sql\SqlContentEntityStorage implements \Drupal\Core\Entity\Sql\SqlEntityStorageInterface, \Drupal\Core\Entity\Schema\DynamicallyFieldableEntityStorageSchemaInterface, \Drupal\Core\Entity\EntityBundleListenerInterface extends \Drupal\Core\Entity\ContentEntityStorageBase
- class \Drupal\Core\Entity\ContentEntityStorageBase implements \Drupal\Core\Entity\ContentEntityStorageInterface, \Drupal\Core\Entity\DynamicallyFieldableEntityStorageInterface uses \Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait extends \Drupal\Core\Entity\EntityStorageBase
- class \Drupal\Core\Entity\EntityStorageBase implements \Drupal\Core\Entity\EntityStorageInterface, \Drupal\Core\Entity\EntityHandlerInterface extends \Drupal\Core\Entity\EntityHandlerBase
Expanded class hierarchy of PathAliasStorage
1 file declares its use of PathAliasStorage
- system.install in core/
modules/ system/ system.install - Install, update and uninstall functions for the system module.
File
-
core/
modules/ path_alias/ src/ PathAliasStorage.php, line 11
Namespace
Drupal\path_aliasView source
class PathAliasStorage extends SqlContentEntityStorage {
/**
* {@inheritdoc}
*/
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,
]);
}
}
/**
* {@inheritdoc}
*/
public function createWithSampleValues($bundle = FALSE, array $values = []) {
$entity = parent::createWithSampleValues($bundle, [
'path' => '/<front>',
] + $values);
// Ensure the alias is only 255 characters long.
$entity->set('alias', substr('/' . $entity->get('alias')->value, 0, 255));
return $entity;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.