X-Git-Url: https://yaffs.net/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fpath%2Fsrc%2FPlugin%2FField%2FFieldType%2FPathFieldItemList.php;h=1985499dee5278a4db62b9921fb6a31b025bfb4c;hb=1c1cb0980bfa6caf0c24cce671b6bb541dc87583;hp=41cc994412e2da6ca12a9a0ce161a3f4b0b03ddd;hpb=9424afc6c1f518c301bf87a23c047d1873435d05;p=yaffs-website diff --git a/web/core/modules/path/src/Plugin/Field/FieldType/PathFieldItemList.php b/web/core/modules/path/src/Plugin/Field/FieldType/PathFieldItemList.php index 41cc99441..1985499de 100644 --- a/web/core/modules/path/src/Plugin/Field/FieldType/PathFieldItemList.php +++ b/web/core/modules/path/src/Plugin/Field/FieldType/PathFieldItemList.php @@ -4,6 +4,7 @@ namespace Drupal\path\Plugin\Field\FieldType; use Drupal\Core\Access\AccessResult; use Drupal\Core\Field\FieldItemList; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\TypedData\ComputedItemListTrait; @@ -26,12 +27,18 @@ class PathFieldItemList extends FieldItemList { $entity = $this->getEntity(); if (!$entity->isNew()) { - // @todo Support loading language neutral aliases in - // https://www.drupal.org/node/2511968. - $alias = \Drupal::service('path.alias_storage')->load([ + $conditions = [ 'source' => '/' . $entity->toUrl()->getInternalPath(), 'langcode' => $this->getLangcode(), - ]); + ]; + $alias = \Drupal::service('path.alias_storage')->load($conditions); + if ($alias === FALSE) { + // Fall back to non-specific language. + if ($this->getLangcode() !== LanguageInterface::LANGCODE_NOT_SPECIFIED) { + $conditions['langcode'] = LanguageInterface::LANGCODE_NOT_SPECIFIED; + $alias = \Drupal::service('path.alias_storage')->load($conditions); + } + } if ($alias) { $value = $alias;