Commit 4a0c73c9 authored by catch's avatar catch

Issue #3084983 by plach, amateescu, catch, Berdir, xjm: Move all the code...

Issue #3084983 by plach, amateescu, catch, Berdir, xjm: Move all the code related to path aliases to a new (required) "path_alias" module

(cherry picked from commit 0a7bb284)
parent 9c1bbba3
......@@ -322,6 +322,9 @@ Page Cache
Path
- Nathaniel Catchpole 'catch' https://www.drupal.org/u/catch
Path Alias
- Nathaniel Catchpole 'catch' https://www.drupal.org/u/catch
Plugin
- Kris Vanderwater 'EclipseGc' https://www.drupal.org/u/eclipseGc
- Alex Bronstein 'effulgentsia' https://www.drupal.org/u/effulgentsia
......
......@@ -137,6 +137,7 @@
"drupal/options": "self.version",
"drupal/page_cache": "self.version",
"drupal/path": "self.version",
"drupal/path_alias": "self.version",
"drupal/quickedit": "self.version",
"drupal/rdf": "self.version",
"drupal/responsive_image": "self.version",
......
......@@ -762,8 +762,8 @@
* A typical service definition in a *.services.yml file looks like this:
* @code
* path.alias_manager:
* class: Drupal\Core\Path\AliasManager
* arguments: ['@path.crud', '@path.alias_whitelist', '@language_manager']
* class: Drupal\path_alias\AliasManager
* arguments: ['@path.crud', '@path_alias.whitelist', '@language_manager']
* @endcode
* Some services use other services as factories; a typical service definition
* is:
......
......@@ -461,14 +461,18 @@ services:
queue.database:
class: Drupal\Core\Queue\QueueDatabaseFactory
arguments: ['@database']
# @deprecated in Drupal 8.8.x and will be removed before 9.0.0. Use the
# "path_alias.whitelist" service instead.
# See https://www.drupal.org/node/3092086
path.alias_whitelist:
class: Drupal\Core\Path\AliasWhitelist
tags:
- { name: needs_destruction }
arguments: [path_alias_whitelist, '@cache.bootstrap', '@lock', '@state', '@path.alias_repository']
alias: path_alias.whitelist
deprecated: 'The "%alias_id%" service alias is deprecated. Use "path_alias.whitelist" instead. See https://drupal.org/node/3092086'
# @deprecated in Drupal 8.8.x and will be removed before 9.0.0. Use the
# "path_alias.manager" service instead.
# See https://www.drupal.org/node/3092086
path.alias_manager:
class: Drupal\Core\Path\AliasManager
arguments: ['@path.alias_repository', '@path.alias_whitelist', '@language_manager', '@cache.data']
arguments: ['@path_alias.repository', '@path_alias.whitelist', '@language_manager', '@cache.data']
path.current:
class: Drupal\Core\Path\CurrentPathStack
arguments: ['@request_stack']
......@@ -960,17 +964,12 @@ services:
arguments: ['@lock', '@plugin.manager.menu.link', '@database', '@database.replica_kill_switch']
tags:
- { name: event_subscriber }
path.alias_repository:
class: Drupal\Core\Path\AliasRepository
arguments: ['@database']
tags:
- { name: backend_overridable }
path.alias_storage:
class: Drupal\Core\Path\AliasStorage
arguments: ['@database', '@module_handler', '@entity_type.manager']
tags:
- { name: backend_overridable }
deprecated: The "%service_id%" service is deprecated. Use the "path.alias_repository" service instead, or the entity storage handler for the "path_alias" entity type for CRUD methods. See https://www.drupal.org/node/3013865
deprecated: The "%service_id%" service is deprecated. Use the "path_alias.repository" service instead, or the entity storage handler for the "path_alias" entity type for CRUD methods. See https://www.drupal.org/node/3013865
path.matcher:
class: Drupal\Core\Path\PathMatcher
arguments: ['@config.factory', '@current_route_match']
......@@ -1222,11 +1221,6 @@ services:
arguments: ['@maintenance_mode', '@config.factory', '@string_translation', '@url_generator', '@current_user', '@bare_html_page_renderer', '@messenger']
tags:
- { name: event_subscriber }
path_subscriber:
class: Drupal\Core\EventSubscriber\PathSubscriber
tags:
- { name: event_subscriber }
arguments: ['@path.alias_manager', '@path.current']
route_access_response_subscriber:
class: Drupal\Core\EventSubscriber\RouteAccessResponseSubscriber
tags:
......@@ -1357,12 +1351,6 @@ services:
arguments: ['@current_route_match']
tags:
- { name: route_processor_outbound, priority: 200 }
path_processor_alias:
class: Drupal\Core\PathProcessor\PathProcessorAlias
tags:
- { name: path_processor_inbound, priority: 100 }
- { name: path_processor_outbound, priority: 300 }
arguments: ['@path.alias_manager']
route_processor_csrf:
class: Drupal\Core\Access\RouteProcessorCsrf
tags:
......@@ -1755,3 +1743,34 @@ services:
pager.parameters:
class: Drupal\Core\Pager\PagerParameters
arguments: ['@request_stack']
# Path Alias services, defined here to be available even when "path_alias" is
# not enabled yet. These will replace the legacy core services, which are now
# deprecated and will be removed in Drupal 9.
# See https://www.drupal.org/node/3092086
# @todo Move these to "path_alias" once core fully supports it as an optional
# module. See https://www.drupal.org/node/3092090.
path_alias.subscriber:
class: Drupal\Core\EventSubscriber\PathSubscriber
tags:
- { name: event_subscriber }
arguments: ['@path.alias_manager', '@path.current']
path_alias.path_processor:
class: Drupal\Core\PathProcessor\PathProcessorAlias
tags:
- { name: path_processor_inbound, priority: 100 }
- { name: path_processor_outbound, priority: 300 }
arguments: ['@path.alias_manager']
path_alias.manager:
class: Drupal\Core\Path\AliasManager
arguments: ['@path_alias.repository', '@path_alias.whitelist', '@language_manager', '@cache.data']
path_alias.repository:
class: Drupal\Core\Path\AliasRepository
arguments: ['@database']
tags:
- { name: backend_overridable }
path_alias.whitelist:
class: Drupal\Core\Path\AliasWhitelist
tags:
- { name: needs_destruction }
arguments: [path_alias_whitelist, '@cache.bootstrap', '@lock', '@state', '@path_alias.repository']
......@@ -11,6 +11,11 @@
/**
* Provides a path subscriber that converts path aliases.
*
* @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0.
* Use \Drupal\path_alias\EventSubscriber\PathAliasSubscriber.
*
* @see https://www.drupal.org/node/3092086
*/
class PathSubscriber implements EventSubscriberInterface {
......@@ -39,6 +44,13 @@ class PathSubscriber implements EventSubscriberInterface {
public function __construct(AliasManagerInterface $alias_manager, CurrentPathStack $current_path) {
$this->aliasManager = $alias_manager;
$this->currentPath = $current_path;
// This is used as base class by the new class, so we do not trigger
// deprecation notices when that or any child class is instantiated.
$new_class = 'Drupal\path_alias\EventSubscriber\PathAliasSubscriber';
if (!is_a($this, $new_class) && class_exists($new_class)) {
@trigger_error('The \\' . __CLASS__ . ' class is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Instead, use \\' . $new_class . '. See https://drupal.org/node/3092086', E_USER_DEPRECATED);
}
}
/**
......
......@@ -7,9 +7,15 @@
use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Language\LanguageManagerInterface;
use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException;
/**
* The default alias manager implementation.
*
* @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0.
* Use \Drupal\path_alias\AliasManager.
*
* @see https://www.drupal.org/node/3092086
*/
class AliasManager implements AliasManagerInterface, CacheDecoratorInterface {
......@@ -115,12 +121,37 @@ class AliasManager implements AliasManagerInterface, CacheDecoratorInterface {
public function __construct($alias_repository, AliasWhitelistInterface $whitelist, LanguageManagerInterface $language_manager, CacheBackendInterface $cache) {
if (!$alias_repository instanceof AliasRepositoryInterface) {
@trigger_error('Passing the path.alias_storage service to AliasManager::__construct() is deprecated in drupal:8.8.0 and will be removed before drupal:9.0.0. Pass the new dependencies instead. See https://www.drupal.org/node/3013865.', E_USER_DEPRECATED);
$alias_repository = \Drupal::service('path.alias_repository');
$alias_repository = \Drupal::service('path_alias.repository');
}
$this->pathAliasRepository = $alias_repository;
$this->languageManager = $language_manager;
$this->whitelist = $whitelist;
$this->cache = $cache;
// This is used as base class by the new class, so we do not trigger
// deprecation notices when that or any child class is instantiated.
$new_class = 'Drupal\path_alias\AliasManager';
if (!is_a($this, $new_class) && class_exists($new_class)) {
@trigger_error('The \\' . __CLASS__ . ' class is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Instead, use \\' . $new_class . '. See https://drupal.org/node/3092086', E_USER_DEPRECATED);
// Despite being two different services, hence two different class
// instances, both the new and the legacy alias managers need to share the
// same internal state to keep the path/alias lookup optimizations
// working.
try {
$alias_manager = \Drupal::service('path_alias.manager');
if ($alias_manager instanceof $new_class) {
$synced_properties = ['cacheKey', 'langcodePreloaded', 'lookupMap', 'noAlias', 'noPath', 'preloadedPathLookups'];
foreach ($synced_properties as $property) {
$this->{$property} = &$alias_manager->{$property};
}
}
}
catch (ServiceCircularReferenceException $e) {
// This may happen during installation when "path_alias" has not swapped
// the alias manager class yet. Nothing to do in this case.
}
}
}
/**
......
......@@ -4,6 +4,11 @@
/**
* Find an alias for a path and vice versa.
*
* @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0.
* Use \Drupal\path_alias\AliasManagerInterface.
*
* @see https://www.drupal.org/node/3092086
*/
interface AliasManagerInterface {
......
......@@ -9,6 +9,11 @@
/**
* Provides the default path alias lookup operations.
*
* @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0.
* Use \Drupal\path_alias\AliasRepository.
*
* @see https://www.drupal.org/node/3092086
*/
class AliasRepository implements AliasRepositoryInterface {
......@@ -27,6 +32,13 @@ class AliasRepository implements AliasRepositoryInterface {
*/
public function __construct(Connection $connection) {
$this->connection = $connection;
// This is used as base class by the new class, so we do not trigger
// deprecation notices when that or any child class is instantiated.
$new_class = 'Drupal\path_alias\AliasRepository';
if (!is_a($this, $new_class) && class_exists($new_class)) {
@trigger_error('The \\' . __CLASS__ . ' class is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Instead, use \\' . $new_class . '. See https://drupal.org/node/3092086', E_USER_DEPRECATED);
}
}
/**
......
......@@ -5,15 +5,10 @@
/**
* Provides an interface for path alias lookup operations.
*
* The path alias repository service is only used internally in order to
* optimize alias lookup queries needed in the critical path of each request.
* However, it is not marked as an internal service because alternative storage
* backends still need to override it if they provide a different storage class
* for the PathAlias entity type.
* @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0.
* Use \Drupal\path_alias\AliasRepositoryInterface.
*
* Whenever you need to determine whether an alias exists for a system path, or
* whether a system path has an alias, the 'path.alias_manager' service should
* be used instead.
* @see https://www.drupal.org/node/3092086
*/
interface AliasRepositoryInterface {
......
......@@ -9,7 +9,7 @@
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Language\LanguageInterface;
@trigger_error('\Drupal\Core\Path\AliasStorage is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use the "path.alias_repository" service instead, or the entity storage handler for the "path_alias" entity type for CRUD methods. See https://www.drupal.org/node/3013865.', E_USER_DEPRECATED);
@trigger_error('\Drupal\Core\Path\AliasStorage is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use the "path_alias.repository" service instead, or the entity storage handler for the "path_alias" entity type for CRUD methods. See https://www.drupal.org/node/3013865.', E_USER_DEPRECATED);
/**
* Provides a class for CRUD operations on path aliases.
......@@ -19,7 +19,7 @@
* the same, and will both refer to the same internal system path.
*
* @deprecated \Drupal\Core\Path\AliasStorage is deprecated in drupal:8.8.0 and
* is removed from drupal:9.0.0. Use the "path.alias_repository" service
* is removed from drupal:9.0.0. Use the "path_alias.repository" service
* instead, or the entity storage handler for the "path_alias" entity type
* for CRUD methods.
*
......@@ -82,7 +82,7 @@ public function save($source, $alias, $langcode = LanguageInterface::LANGCODE_NO
}
if ($pid) {
/** @var \Drupal\Core\Path\PathAliasInterface $path_alias */
/** @var \Drupal\path_alias\PathAliasInterface $path_alias */
$path_alias = $this->getPathAliasEntityStorage()->load($pid);
$original_values = [
'source' => $path_alias->getPath(),
......@@ -142,7 +142,7 @@ public function load($conditions) {
->execute();
$entities = $this->getPathAliasEntityStorage()->loadMultiple($result);
/** @var \Drupal\Core\Path\PathAliasInterface $path_alias */
/** @var \Drupal\path_alias\PathAliasInterface $path_alias */
$path_alias = reset($entities);
if ($path_alias) {
return [
......@@ -326,6 +326,10 @@ public function getAliasesForAdminListing($header, $keys = NULL) {
* {@inheritdoc}
*/
public function pathHasMatchingAlias($initial_substring) {
if (!$this->moduleHandler->moduleExists('path_alias')) {
return FALSE;
}
$query = $this->getBaseQuery();
$query->addExpression(1);
......
......@@ -8,7 +8,7 @@
* Provides a class for CRUD operations on path aliases.
*
* @deprecated \Drupal\Core\Path\AliasStorage is deprecated in drupal:8.8.0 and
* is removed from drupal:9.0.0. Use the "path.alias_repository" service
* is removed from drupal:9.0.0. Use the "path_alias.repository" service
* instead, or the entity storage handler for the "path_alias" entity type
* for CRUD methods.
*
......
......@@ -10,6 +10,11 @@
/**
* Extends CacheCollector to build the path alias whitelist over time.
*
* @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0.
* Use \Drupal\path_alias\AliasWhitelist.
*
* @see https://www.drupal.org/node/3092086
*/
class AliasWhitelist extends CacheCollector implements AliasWhitelistInterface {
......@@ -54,9 +59,16 @@ public function __construct($cid, CacheBackendInterface $cache, LockBackendInter
if (!$alias_repository instanceof AliasRepositoryInterface) {
@trigger_error('Passing the path.alias_storage service to AliasWhitelist::__construct() is deprecated in drupal:8.8.0 and will be removed before drupal:9.0.0. Pass the new dependencies instead. See https://www.drupal.org/node/3013865.', E_USER_DEPRECATED);
$alias_repository = \Drupal::service('path.alias_repository');
$alias_repository = \Drupal::service('path_alias.repository');
}
$this->pathAliasRepository = $alias_repository;
// This is used as base class by the new class, so we do not trigger
// deprecation notices when that or any child class is instantiated.
$new_class = 'Drupal\path_alias\AliasWhitelist';
if (!is_a($this, $new_class) && class_exists($new_class)) {
@trigger_error('The \\' . __CLASS__ . ' class is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Instead, use \\' . $new_class . '. See https://drupal.org/node/3092086', E_USER_DEPRECATED);
}
}
/**
......
......@@ -7,9 +7,9 @@
/**
* Cache the alias whitelist.
*
* The whitelist contains the first element of the router paths of all
* aliases. For example, if /node/12345 has an alias then "node" is added to
* the whitelist. This optimization allows skipping the lookup for every
* /user/{user} path if "user" is not in the whitelist.
* @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0.
* Use \Drupal\path_alias\AliasWhitelistInterface.
*
* @see https://www.drupal.org/node/3092086
*/
interface AliasWhitelistInterface extends CacheCollectorInterface {}
......@@ -43,7 +43,7 @@ public static function create(ContainerInterface $container) {
* {@inheritdoc}
*/
public function validate($entity, Constraint $constraint) {
/** @var \Drupal\Core\Path\PathAliasInterface $entity */
/** @var \Drupal\path_alias\PathAliasInterface $entity */
$path = $entity->getPath();
$alias = $entity->getAlias();
$langcode = $entity->language()->getId();
......
......@@ -8,6 +8,11 @@
/**
* Processes the inbound path using path alias lookups.
*
* @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0.
* Use \Drupal\path_alias\PathProcessor\AliasPathProcessor.
*
* @see https://www.drupal.org/node/3092086
*/
class PathProcessorAlias implements InboundPathProcessorInterface, OutboundPathProcessorInterface {
......@@ -26,6 +31,13 @@ class PathProcessorAlias implements InboundPathProcessorInterface, OutboundPathP
*/
public function __construct(AliasManagerInterface $alias_manager) {
$this->aliasManager = $alias_manager;
// This is used as base class by the new class, so we do not trigger
// deprecation notices when that or any child class is instantiated.
$new_class = 'Drupal\path_alias\PathProcessor\AliasPathProcessor';
if (!is_a($this, $new_class) && class_exists($new_class)) {
@trigger_error('The \\' . __CLASS__ . ' class is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Instead, use \\' . $new_class . '. See https://drupal.org/node/3092086', E_USER_DEPRECATED);
}
}
/**
......
......@@ -490,8 +490,8 @@ protected function getRouteCollectionCacheId(Request $request) {
*/
protected function getCurrentLanguageCacheIdPart() {
// This must be in sync with the language logic in
// \Drupal\Core\PathProcessor\PathProcessorAlias::processInbound() and
// \Drupal\Core\Path\AliasManager::getPathByAlias().
// \Drupal\path_alias\PathProcessor\AliasPathProcessor::processInbound() and
// \Drupal\path_alias\AliasManager::getPathByAlias().
// @todo Update this if necessary in https://www.drupal.org/node/1125428.
return $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_URL)->getId();
}
......
......@@ -41,8 +41,8 @@ public function alter(ContainerBuilder $container) {
// manager. We do this by removing the tags that the compiler pass looks
// for. This means that the URL generator can safely be used during the
// database update process.
if ($container->hasDefinition('path_processor_alias')) {
$container->getDefinition('path_processor_alias')
if ($container->hasDefinition('path_alias.path_processor')) {
$container->getDefinition('path_alias.path_processor')
->clearTag('path_processor_inbound')
->clearTag('path_processor_outbound');
}
......
......@@ -24,6 +24,7 @@ class MigrateBlockContentTranslationTest extends MigrateDrupal6TestBase {
'block_content',
'content_translation',
'language',
'path_alias',
'statistics',
'taxonomy',
// Required for translation migrations.
......
......@@ -26,6 +26,7 @@ class MigrateBlockTest extends MigrateDrupal6TestBase {
'aggregator',
'book',
'forum',
'path_alias',
'statistics',
];
......
......@@ -28,6 +28,7 @@ class MigrateBlockContentTranslationTest extends MigrateDrupal7TestBase {
'config_translation',
'content_translation',
'language',
'path_alias',
'statistics',
'taxonomy',
// Required for translation migrations.
......
......@@ -25,6 +25,7 @@ class MigrateBlockTest extends MigrateDrupal7TestBase {
'node',
'text',
'filter',
'path_alias',
'user',
];
......
......@@ -90,7 +90,7 @@ public function testInstallUninstall() {
// Ensure that only core required modules and the install profile can not be uninstalled.
$validation_reasons = \Drupal::service('module_installer')->validateUninstall(array_keys($all_modules));
$this->assertEquals(['system', 'user', 'standard'], array_keys($validation_reasons));
$this->assertEquals(['path_alias', 'system', 'user', 'standard'], array_keys($validation_reasons));
$modules_to_uninstall = array_filter($all_modules, function ($module) use ($validation_reasons) {
// Filter required and not enabled modules.
......
......@@ -2,7 +2,7 @@
namespace Drupal\Tests\jsonapi\Functional;
use Drupal\Core\Path\Entity\PathAlias;
use Drupal\path_alias\Entity\PathAlias;
use Drupal\Core\Url;
/**
......
......@@ -7,7 +7,7 @@
use Drupal\Core\Url;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Path\PathAliasInterface;
use Drupal\path_alias\PathAliasInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\system\MenuInterface;
......
......@@ -21,7 +21,7 @@ class PathAliasMenuLinkContentTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['menu_link_content', 'system', 'link', 'test_page_test', 'user'];
public static $modules = ['menu_link_content', 'system', 'link', 'path_alias', 'test_page_test', 'user'];
/**
* {@inheritdoc}
......@@ -44,7 +44,7 @@ protected function setUp() {
public function register(ContainerBuilder $container) {
parent::register($container);
$definition = $container->getDefinition('path_processor_alias');
$definition = $container->getDefinition('path_alias.path_processor');
$definition
->addTag('path_processor_inbound', ['priority' => 100]);
}
......
langcode: en
status: true
dependencies: { }
dependencies:
module:
- path_alias
id: path_alias.path_alias
target_entity_type_id: path_alias
target_bundle: path_alias
......
......@@ -5,3 +5,5 @@ package: Core
version: VERSION
core: 8.x
configure: entity.path_alias.collection
dependencies:
- drupal:path_alias
......@@ -47,15 +47,19 @@ function path_help($route_name, RouteMatchInterface $route_match) {
* Implements hook_entity_type_alter().
*/
function path_entity_type_alter(array &$entity_types) {
// @todo Remove the conditional once core fully supports "path_alias" as an
// optional module. See https://drupal.org/node/3092090.
/** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
$entity_types['path_alias']->setFormClass('default', PathAliasForm::class);
$entity_types['path_alias']->setFormClass('delete', ContentEntityDeleteForm::class);
$entity_types['path_alias']->setHandlerClass('route_provider', ['html' => AdminHtmlRouteProvider::class]);
$entity_types['path_alias']->setListBuilderClass(PathAliasListBuilder::class);
$entity_types['path_alias']->setLinkTemplate('collection', '/admin/config/search/path');
$entity_types['path_alias']->setLinkTemplate('add-form', '/admin/config/search/path/add');
$entity_types['path_alias']->setLinkTemplate('edit-form', '/admin/config/search/path/edit/{path_alias}');
$entity_types['path_alias']->setLinkTemplate('delete-form', '/admin/config/search/path/delete/{path_alias}');
if (isset($entity_types['path_alias'])) {
$entity_types['path_alias']->setFormClass('default', PathAliasForm::class);
$entity_types['path_alias']->setFormClass('delete', ContentEntityDeleteForm::class);
$entity_types['path_alias']->setHandlerClass('route_provider', ['html' => AdminHtmlRouteProvider::class]);
$entity_types['path_alias']->setListBuilderClass(PathAliasListBuilder::class);
$entity_types['path_alias']->setLinkTemplate('collection', '/admin/config/search/path');
$entity_types['path_alias']->setLinkTemplate('add-form', '/admin/config/search/path/add');
$entity_types['path_alias']->setLinkTemplate('edit-form', '/admin/config/search/path/edit/{path_alias}');
$entity_types['path_alias']->setLinkTemplate('delete-form', '/admin/config/search/path/delete/{path_alias}');
}
}
/**
......
......@@ -15,7 +15,7 @@ class PathAliasForm extends ContentEntityForm {
/**
* The path_alias entity.
*
* @var \Drupal\Core\Path\PathAliasInterface
* @var \Drupal\path_alias\PathAliasInterface
*/
protected $entity;
......
......@@ -27,7 +27,7 @@ protected function computeValue() {
$entity = $this->getEntity();
if (!$entity->isNew()) {
/** @var \Drupal\Core\Path\AliasRepositoryInterface $path_alias_repository */
$path_alias_repository = \Drupal::service('path.alias_repository');
$path_alias_repository = \Drupal::service('path_alias.repository');
if ($path_alias = $path_alias_repository->lookupBySystemPath('/' . $entity->toUrl()->getInternalPath(), $this->getLangcode())) {
$value = [
......
......@@ -87,7 +87,7 @@ public static function validateFormElement(array &$element, FormStateInterface $
if (!empty($alias)) {
$form_state->setValueForElement($element['alias'], $alias);
/** @var \Drupal\Core\Path\PathAliasInterface $path_alias */
/** @var \Drupal\path_alias\PathAliasInterface $path_alias */
$path_alias = \Drupal::entityTypeManager()->getStorage('path_alias')->create([
'path' => $element['source']['#value'],
'alias' => $alias,
......
......@@ -326,7 +326,7 @@ public function testNodeAlias() {
// Delete the node and check that the path alias is also deleted.
$node5->delete();
$path_alias = \Drupal::service('path.alias_repository')->lookUpBySystemPath('/node/' . $node5->id(), $node5->language()->getId());
$path_alias = \Drupal::service('path_alias.repository')->lookUpBySystemPath('/node/' . $node5->id(), $node5->language()->getId());
$this->assertFalse($path_alias, 'Alias was successfully deleted when the referenced node was deleted.');
// Create sixth test node.
......
......@@ -2,7 +2,7 @@
namespace Drupal\Tests\path\Kernel\Migrate\d6;
use Drupal\Core\Path\PathAliasInterface;
use Drupal\path_alias\PathAliasInterface;
use Drupal\migrate\Plugin\MigrateIdMapInterface;
use Drupal\Core\Database\Database;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
......@@ -24,6 +24,7 @@ class MigrateUrlAliasTest extends MigrateDrupal6TestBase {
'language',
'content_translation',
'path',
'path_alias',
'menu_ui',
// Required for translation migrations.
'migrate_drupal_multilingual',
......@@ -57,7 +58,7 @@ protected function setUp() {
* The path alias ID.
* @param array $conditions
* The path conditions.
* @param \Drupal\Core\Path\PathAliasInterface $path_alias
* @param \Drupal\path_alias\PathAliasInterface $path_alias
* The path alias.
*/
private function assertPath($pid, $conditions, PathAliasInterface $path_alias) {
......
......@@ -13,6 +13,7 @@ class MigrateUrlAliasTest extends MigrateUrlAliasTestBase {
* {@inheritdoc}
*/
public static $modules = [
'path_alias',
'content_translation',
'migrate_drupal_multilingual',
];
......
......@@ -22,6 +22,7 @@ abstract class MigrateUrlAliasTestBase extends MigrateDrupal7TestBase {
'menu_ui',
'node',
'path',
'path_alias',
'text',
];
......
......@@ -19,7 +19,7 @@ class PathItemTest extends KernelTestBase {
*
* @var array
*/
public static $modules = ['path', 'node', 'user', 'system', 'language', 'content_translation'];
public static $modules = ['path', 'path_alias', 'node', 'user', 'system', 'language', 'content_translation'];
/**
* {@inheritdoc}
......@@ -45,7 +45,7 @@ protected function setUp() {
*/
public function testPathItem() {
/** @var \Drupal\Core\Path\AliasRepositoryInterface $alias_repository */
$alias_repository = \Drupal::service('path.alias_repository');
$alias_repository = \Drupal::service('path_alias.repository');
$node_storage = \Drupal::entityTypeManager()->getStorage('node');
......
......@@ -16,7 +16,7 @@ class PathLegacyRoutesKernelTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = ['path'];
protected static $modules = ['path', 'path_alias'];
/**
* @expectedDeprecation The 'path.admin_add' route is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use the 'entity.path_alias.add_form' route instead. See https://www.drupal.org/node/3013865
......