.../src/Entity/MenuLinkContent.php | 5 +++- .../src/Form/MenuLinkContentForm.php | 28 ---------------------- core/modules/menu_ui/src/MenuForm.php | 2 +- 3 files changed, 5 insertions(+), 30 deletions(-) diff --git a/core/modules/menu_link_content/src/Entity/MenuLinkContent.php b/core/modules/menu_link_content/src/Entity/MenuLinkContent.php index 420ebca..b67db69 100644 --- a/core/modules/menu_link_content/src/Entity/MenuLinkContent.php +++ b/core/modules/menu_link_content/src/Entity/MenuLinkContent.php @@ -149,7 +149,10 @@ protected function getPluginDefinition() { $definition['menu_name'] = $this->getMenuName(); if ($url_object = $this->getUrlObject()) { - if ($url_object->isExternal()) { + $definition['url'] = NULL; + $definition['route_name'] = NULL; + $definition['route_parameters'] = []; + if (!$url_object->isRouted()) { $definition['url'] = $url_object->getUri(); } else { diff --git a/core/modules/menu_link_content/src/Form/MenuLinkContentForm.php b/core/modules/menu_link_content/src/Form/MenuLinkContentForm.php index d4180ed..a0e9a28 100644 --- a/core/modules/menu_link_content/src/Form/MenuLinkContentForm.php +++ b/core/modules/menu_link_content/src/Form/MenuLinkContentForm.php @@ -244,15 +244,6 @@ protected function actions(array $form, FormStateInterface $form_state) { /** * {@inheritdoc} */ - public function validate(array $form, FormStateInterface $form_state) { - $this->doValidate($form, $form_state); - - parent::validate($form, $form_state); - } - - /** - * {@inheritdoc} - */ public function buildEntity(array $form, FormStateInterface $form_state) { /** @var \Drupal\menu_link_content\MenuLinkContentInterface $entity */ $entity = parent::buildEntity($form, $form_state); @@ -287,23 +278,4 @@ public function save(array $form, FormStateInterface $form_state) { } } - /** - * Validates the form, both on the menu link edit and content menu link form. - * - * $form is not currently used, but passed here to match the normal form - * validation method signature. - * - * @param array $form - * A nested array form elements comprising the form. - * @param \Drupal\Core\Form\FormStateInterface $form_state - * The current state of the form. - */ - protected function doValidate(array $form, FormStateInterface $form_state) { - $extracted = $this->pathValidator->getUrlIfValid($form_state->getValue(['link', 0, 'uri'])); - - if (!$extracted) { - $form_state->setErrorByName('link][0][uri', $this->t("The path '@link_path' is either invalid or you do not have access to it.", array('@link_path' => $form_state->getValue(['link', 0, 'uri'])))); - } - } - } diff --git a/core/modules/menu_ui/src/MenuForm.php b/core/modules/menu_ui/src/MenuForm.php index b5aef7b..987858e 100644 --- a/core/modules/menu_ui/src/MenuForm.php +++ b/core/modules/menu_ui/src/MenuForm.php @@ -346,7 +346,7 @@ protected function buildOverviewTreeForm($tree, $delta) { if (!$link->isEnabled()) { $form[$id]['title']['#markup'] .= ' (' . $this->t('disabled') . ')'; } - elseif (($url = $link->getUrlObject()) && !$url->isExternal() && $url->getRouteName() == 'user.page') { + elseif (($url = $link->getUrlObject()) && $url->isRouted() && $url->getRouteName() == 'user.page') { $form[$id]['title']['#markup'] .= ' (' . $this->t('logged in users only') . ')'; }