reverted: --- b/core/modules/locale/lib/Drupal/locale/ParamConverter/LocaleAdminPathEntityConverter.php +++ /dev/null @@ -1,54 +0,0 @@ -entityManager->getStorageController($entity_type)) { - // Enter the override-free context, so we can ensure no overrides are applied. - config_context_enter('config.context.free'); - $entity = $storage->load($value); - // Leave the override-free context. - config_context_leave(); - return $entity; - } - } - - /** - * {@inheritdoc} - * - * This converter applies only if the path is an admin path. - */ - public function applies($definition, $name, Route $route) { - if (parent::applies($definition, $name, $route)) { - // path_is_admin() needs the path without the leading slash. - $path = ltrim($route->getPath(), '/'); - return path_is_admin($path); - } - return FALSE; - } - -} diff -u b/core/modules/locale/locale.services.yml b/core/modules/locale/locale.services.yml --- b/core/modules/locale/locale.services.yml +++ b/core/modules/locale/locale.services.yml @@ -4,16 +4,11 @@ tags: - { name: event_subscriber } arguments: ['@language_manager', '@config.context'] - paramconverter.entity_admin: - class: Drupal\locale\ParamConverter\LocaleAdminPathEntityConverter + paramconverter.configentity_admin: + class: Drupal\locale\ParamConverter\LocaleAdminPathConfigEntityConverter tags: - { name: paramconverter, priority: 5 } arguments: ['@entity.manager'] - locale_config_subscriber: - class: Drupal\locale\LocaleConfigSubscriber - tags: - - { name: event_subscriber } - arguments: ['@language_manager', '@config.context'] locale.config.typed: class: Drupal\locale\LocaleConfigManager arguments: ['@config.storage', '@config.storage.schema', '@config.storage.installer', '@locale.storage'] only in patch2: unchanged: --- /dev/null +++ b/core/modules/locale/lib/Drupal/locale/ParamConverter/LocaleAdminPathConfigEntityConverter.php @@ -0,0 +1,67 @@ +entityManager->getStorageController($entity_type)) { + // Enter the override-free context, so we can ensure no overrides are + // applied. + config_context_enter('config.context.free'); + $entity = $storage->load($value); + // Leave the override-free context. + config_context_leave(); + return $entity; + } + } + + /** + * {@inheritdoc} + * + * This converter applies only if the path is an admin path. + * + * Due to this converter having a higher weight than the default + * EntityConverter, every time this method returns TRUE it takes over the + * route from EntityConverter. As we only allow a single converter per route + * argument, EntityConverter is ignored when this converter applies. + */ + public function applies($definition, $name, Route $route) { + if (parent::applies($definition, $name, $route)) { + // As we only want to override EntityConverter for ConfigEntities, find + // out whether the current entity is a ConfigEntity. + $entity_type = substr($definition['type'], strlen('entity:')); + $entity_type_info = entity_get_info($entity_type); + $reflection = new \ReflectionClass($entity_type_info['class']); + if ($reflection->implementsInterface('\Drupal\Core\Config\Entity\ConfigEntityInterface')) { + // path_is_admin() needs the path without the leading slash. + $path = ltrim($route->getPath(), '/'); + return path_is_admin($path); + } + } + return FALSE; + } + +}