$this->getLangcode()]; $entity = $this->getEntity(); if (!$entity->isNew()) { $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; } } $this->list[0] = $this->createItem(0, $value); } /** * {@inheritdoc} */ public function defaultAccess($operation = 'view', AccountInterface $account = NULL) { if ($operation == 'view') { return AccessResult::allowed(); } return AccessResult::allowedIfHasPermissions($account, ['create url aliases', 'administer url aliases'], 'OR')->cachePerPermissions(); } /** * {@inheritdoc} */ public function delete() { // Delete all aliases associated with this entity in the current language. $entity = $this->getEntity(); $conditions = [ 'source' => '/' . $entity->toUrl()->getInternalPath(), 'langcode' => $entity->language()->getId(), ]; \Drupal::service('path.alias_storage')->delete($conditions); } }