diff --git a/core/modules/menu_link_content/src/Entity/MenuLinkContent.php b/core/modules/menu_link_content/src/Entity/MenuLinkContent.php index 4707288..380a215 100644 --- a/core/modules/menu_link_content/src/Entity/MenuLinkContent.php +++ b/core/modules/menu_link_content/src/Entity/MenuLinkContent.php @@ -144,13 +144,11 @@ public function getChangedTime() { * @see \Drupal\Core\Menu\MenuLinkTree::$defaults */ protected function getPluginDefinition() { - $url_object = $this->getUrlObject(); - $definition = array(); $definition['class'] = 'Drupal\menu_link_content\Plugin\Menu\MenuLinkContent'; $definition['menu_name'] = $this->getMenuName(); - if ($url_object) { + if ($url_object = $this->getUrlObject()) { if ($url_object->isExternal()) { $definition['url'] = $url_object->getUri(); } diff --git a/core/modules/menu_link_content/src/MenuLinkContentAccessControlHandler.php b/core/modules/menu_link_content/src/MenuLinkContentAccessControlHandler.php index 419dc81..b5ae570 100644 --- a/core/modules/menu_link_content/src/MenuLinkContentAccessControlHandler.php +++ b/core/modules/menu_link_content/src/MenuLinkContentAccessControlHandler.php @@ -65,13 +65,10 @@ protected function checkAccess(EntityInterface $entity, $operation, $langcode, A // If there is a URL, this is an external link so always accessible. $access = AccessResult::allowed()->cachePerRole()->cacheUntilEntityChanges($entity); /** @var \Drupal\menu_link_content\MenuLinkContentInterface $entity */ - if ($entity->getUrlObject()->isRouted()) { - $url_object = $entity->getUrlObject(); - // We allow access, but only if the link is accessible as well. - if ($url_object->isRouted()) { - $link_access = $this->accessManager->checkNamedRoute($url_object->getRouteName(), $url_object->getRouteParameters(), $account, TRUE); - $access = $access->andIf($link_access); - } + // We allow access, but only if the link is accessible as well. + if (($url_object = $entity->getUrlObject()) && $url_object->isRouted()) { + $link_access = $this->accessManager->checkNamedRoute($url_object->getRouteName(), $url_object->getRouteParameters(), $account, TRUE); + $access = $access->andIf($link_access); } return $access; }