diff --git a/core/config/schema/core.menu.schema.yml b/core/config/schema/core.menu.schema.yml
index c2da5ef0d50a52718307350fac1c8a31bdf131b6..a1fc321dfc7d32ebcfad1160945b3e2dc20a57e8 100644
--- a/core/config/schema/core.menu.schema.yml
+++ b/core/config/schema/core.menu.schema.yml
@@ -22,6 +22,6 @@ menu_link.static.overrides:
expanded:
type: boolean
label: 'Expanded'
- hidden:
+ enabled:
type: boolean
- label: 'Hidden'
+ label: 'Enabled'
diff --git a/core/lib/Drupal/Core/Menu/Form/MenuLinkDefaultForm.php b/core/lib/Drupal/Core/Menu/Form/MenuLinkDefaultForm.php
index 865195d62f1d3e63b8f5bc4393d4eebf2ba82c59..f6ee14bef183c99443b8c69bb225d7bda66c28ac 100644
--- a/core/lib/Drupal/Core/Menu/Form/MenuLinkDefaultForm.php
+++ b/core/lib/Drupal/Core/Menu/Form/MenuLinkDefaultForm.php
@@ -124,7 +124,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
'#type' => 'checkbox',
'#title' => $this->t('Enable menu link'),
'#description' => $this->t('Menu links that are not enabled will not be listed in any menu.'),
- '#default_value' => !$this->menuLink->isHidden(),
+ '#default_value' => $this->menuLink->isEnabled(),
);
$form['expanded'] = array(
@@ -158,7 +158,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
*/
public function extractFormValues(array &$form, FormStateInterface $form_state) {
$new_definition = array();
- $new_definition['hidden'] = $form_state->getValue('enabled') ? 0 : 1;
+ $new_definition['enabled'] = $form_state->getValue('enabled') ? 1 : 0;
$new_definition['weight'] = (int) $form_state->getValue('weight');
$new_definition['expanded'] = $form_state->getValue('expanded') ? 1 : 0;
list($menu_name, $parent) = explode(':', $form_state->getValue('menu_parent'), 2);
diff --git a/core/lib/Drupal/Core/Menu/MenuLinkBase.php b/core/lib/Drupal/Core/Menu/MenuLinkBase.php
index 125bbf0545a4ef993f40615cddb82d8941a648c1..9636c72b82b105906c2e367935f8f19d0c95d590 100644
--- a/core/lib/Drupal/Core/Menu/MenuLinkBase.php
+++ b/core/lib/Drupal/Core/Menu/MenuLinkBase.php
@@ -61,8 +61,8 @@ public function getParent() {
/**
* {@inheritdoc}
*/
- public function isHidden() {
- return (bool) $this->pluginDefinition['hidden'];
+ public function isEnabled() {
+ return (bool) $this->pluginDefinition['enabled'];
}
/**
diff --git a/core/lib/Drupal/Core/Menu/MenuLinkDefault.php b/core/lib/Drupal/Core/Menu/MenuLinkDefault.php
index 5d0f8e2e0c906b244be55682d50a613644e20f56..c2241428ce5d5693dd1954e87ecd13be4cf053b5 100644
--- a/core/lib/Drupal/Core/Menu/MenuLinkDefault.php
+++ b/core/lib/Drupal/Core/Menu/MenuLinkDefault.php
@@ -23,7 +23,7 @@ class MenuLinkDefault extends MenuLinkBase implements ContainerFactoryPluginInte
'parent' => 1,
'weight' => 1,
'expanded' => 1,
- 'hidden' => 1,
+ 'enabled' => 1,
);
/**
diff --git a/core/lib/Drupal/Core/Menu/MenuLinkInterface.php b/core/lib/Drupal/Core/Menu/MenuLinkInterface.php
index 811dbf0e3133da06bb0213a0fbe637a62575aa36..2738f271c383dd52fddf86b68e2f298f58be3de9 100644
--- a/core/lib/Drupal/Core/Menu/MenuLinkInterface.php
+++ b/core/lib/Drupal/Core/Menu/MenuLinkInterface.php
@@ -64,12 +64,12 @@ public function getProvider();
public function getParent();
/**
- * Returns whether the menu link is hidden.
+ * Returns whether the menu link is enabled (not hidden).
*
* @return bool
- * TRUE for hidden, FALSE otherwise.
+ * TRUE for enabled, FALSE otherwise.
*/
- public function isHidden();
+ public function isEnabled();
/**
* Returns whether the child menu links should always been shown.
diff --git a/core/lib/Drupal/Core/Menu/MenuLinkManager.php b/core/lib/Drupal/Core/Menu/MenuLinkManager.php
index 1aa0070b10b043f9e751346c73ac2b63011e9340..a8e73e81980eb57505f84d79ce972461e00f4528 100644
--- a/core/lib/Drupal/Core/Menu/MenuLinkManager.php
+++ b/core/lib/Drupal/Core/Menu/MenuLinkManager.php
@@ -58,7 +58,7 @@ class MenuLinkManager implements MenuLinkManagerInterface {
// The default link options.
'options' => array(),
'expanded' => 0,
- 'hidden' => 0,
+ 'enabled' => 1,
// The name of the module providing this link.
'provider' => '',
'metadata' => array(),
diff --git a/core/lib/Drupal/Core/Menu/MenuLinkTree.php b/core/lib/Drupal/Core/Menu/MenuLinkTree.php
index e5d54fe4c1d3f7bd4529b5690b71b011c5e7d0cb..ddf924cec837105cb38efe682109934ae1418d89 100644
--- a/core/lib/Drupal/Core/Menu/MenuLinkTree.php
+++ b/core/lib/Drupal/Core/Menu/MenuLinkTree.php
@@ -205,7 +205,7 @@ public function build(array $tree) {
/** @var \Drupal\Core\Menu\MenuLinkInterface $link */
$link = $data->link;
// Generally we only deal with visible links, but just in case.
- if ($link->isHidden()) {
+ if (!$link->isEnabled()) {
continue;
}
// Set a class for the
-tag. Only set 'expanded' class if the link
diff --git a/core/lib/Drupal/Core/Menu/MenuParentFormSelector.php b/core/lib/Drupal/Core/Menu/MenuParentFormSelector.php
index 4164379dca1ee03141de5034f79c54fa2ce38ad7..e57b7e8a58ada89fd95795a4127d1b3f7987311f 100644
--- a/core/lib/Drupal/Core/Menu/MenuParentFormSelector.php
+++ b/core/lib/Drupal/Core/Menu/MenuParentFormSelector.php
@@ -143,7 +143,7 @@ protected function parentSelectOptionsTreeWalk(array $tree, $menu_name, $indent,
$link = $element->link;
if ($link->getPluginId() != $exclude) {
$title = $indent . ' ' . Unicode::truncate($link->getTitle(), 30, TRUE, FALSE);
- if ($link->isHidden()) {
+ if (!$link->isEnabled()) {
$title .= ' (' . $this->t('disabled') . ')';
}
$options[$menu_name . ':' . $link->getPluginId()] = $title;
diff --git a/core/lib/Drupal/Core/Menu/MenuTreeParameters.php b/core/lib/Drupal/Core/Menu/MenuTreeParameters.php
index c18ebb102eb2c12ec5963f2a32fac0c3d73e9a54..80383be0e0b0af4d8f0f09bf9640e3492400a246 100644
--- a/core/lib/Drupal/Core/Menu/MenuTreeParameters.php
+++ b/core/lib/Drupal/Core/Menu/MenuTreeParameters.php
@@ -184,12 +184,12 @@ public function addCondition($definition_field, $value, $operator = NULL) {
}
/**
- * Excludes hidden links.
+ * Excludes links that are not enabled.
*
* @return $this
*/
- public function excludeHiddenLinks() {
- $this->addCondition('hidden', 0);
+ public function onlyEnabledLinks() {
+ $this->addCondition('enabled', 1);
return $this;
}
diff --git a/core/lib/Drupal/Core/Menu/MenuTreeStorage.php b/core/lib/Drupal/Core/Menu/MenuTreeStorage.php
index 2f127efa8fd4f8f5f4dc32f798b28d4bb57b28ba..92775b4fd40f3737bbc03be9dedf36915895828f 100644
--- a/core/lib/Drupal/Core/Menu/MenuTreeStorage.php
+++ b/core/lib/Drupal/Core/Menu/MenuTreeStorage.php
@@ -94,7 +94,7 @@ class MenuTreeStorage implements MenuTreeStorageInterface {
'weight',
'options',
'expanded',
- 'hidden',
+ 'enabled',
'provider',
'metadata',
'class',
@@ -384,7 +384,7 @@ protected function preSave(array &$link, array $original) {
// and fill parents based on the parent link.
else {
// @todo We want to also check $original['has_children'] here, but that
- // will be 0 even if there are children if those are hidden.
+ // will be 0 even if there are children if those are not enabled.
// has_children is really just the rendering hint. So, we either need
// to define another column (has_any_children), or do the extra query.
// https://www.drupal.org/node/2302149
@@ -409,7 +409,7 @@ protected function preSave(array &$link, array $original) {
unset($fields['mlid']);
// Cast Booleans to int, if needed.
- $fields['hidden'] = (int) $fields['hidden'];
+ $fields['enabled'] = (int) $fields['enabled'];
$fields['expanded'] = (int) $fields['expanded'];
return $fields;
}
@@ -599,7 +599,7 @@ protected function updateParentalStatus(array $link) {
$query
->condition('menu_name', $link['menu_name'])
->condition('parent', $link['parent'])
- ->condition('hidden', 0);
+ ->condition('enabled', 1);
$parent_has_children = ((bool) $query->execute()->fetchField()) ? 1 : 0;
$this->connection->update($this->table, $this->options)
@@ -781,7 +781,7 @@ public function getExpanded($menu_name, array $parents) {
$query->condition('menu_name', $menu_name);
$query->condition('expanded', 1);
$query->condition('has_children', 1);
- $query->condition('hidden', 0);
+ $query->condition('enabled', 1);
$query->condition('parent', $parents, 'IN');
$query->condition('id', $parents, 'NOT IN');
$result = $this->safeExecuteSelect($query)->fetchAllKeyed(0, 0);
@@ -997,7 +997,7 @@ public function loadSubtreeData($id, $max_relative_depth = NULL) {
return $tree;
}
$parameters = new MenuTreeParameters();
- $parameters->setRoot($id)->excludeHiddenLinks();
+ $parameters->setRoot($id)->onlyEnabledLinks();
return $this->loadTreeData($root['menu_name'], $parameters);
}
@@ -1057,7 +1057,7 @@ public function getAllChildIds($id) {
*/
public function loadAllChildren($id, $max_relative_depth = NULL) {
$parameters = new MenuTreeParameters();
- $parameters->setRoot($id)->excludeRoot()->setMaxDepth($max_relative_depth)->excludeHiddenLinks();
+ $parameters->setRoot($id)->excludeRoot()->setMaxDepth($max_relative_depth)->onlyEnabledLinks();
$links = $this->loadLinks(NULL, $parameters);
foreach ($links as $id => $link) {
$links[$id] = $this->prepareLink($link);
@@ -1289,11 +1289,11 @@ protected static function schemaDefinition() {
'not null' => TRUE,
'default' => 'system',
),
- 'hidden' => array(
- 'description' => 'A flag for whether the link should be rendered in menus. (1 = a disabled menu item that may be shown on admin screens, 0 = a normal, visible link)',
+ 'enabled' => array(
+ 'description' => 'A flag for whether the link should be rendered in menus. (0 = a disabled menu item that may be shown on admin screens, 1 = a normal, visible link)',
'type' => 'int',
'not null' => TRUE,
- 'default' => 0,
+ 'default' => 1,
'size' => 'small',
),
'discovered' => array(
@@ -1324,7 +1324,7 @@ protected static function schemaDefinition() {
'serialize' => TRUE,
),
'has_children' => array(
- 'description' => 'Flag indicating whether any non-hidden links have this link as a parent (1 = children exist, 0 = no children).',
+ 'description' => 'Flag indicating whether any enabled links have this link as a parent (1 = enabled children exist, 0 = no enabled children).',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
diff --git a/core/lib/Drupal/Core/Menu/MenuTreeStorageInterface.php b/core/lib/Drupal/Core/Menu/MenuTreeStorageInterface.php
index 78028e146f255cb7d0e22fd2f6b121200bd4f515..9b7883cfa5aef3817af7d84fd5ac6c18b7c40b36 100644
--- a/core/lib/Drupal/Core/Menu/MenuTreeStorageInterface.php
+++ b/core/lib/Drupal/Core/Menu/MenuTreeStorageInterface.php
@@ -149,11 +149,11 @@ public function delete($id);
public function loadTreeData($menu_name, MenuTreeParameters $parameters);
/**
- * Loads all the visible menu links that are below the given ID.
+ * Loads all the enabled menu links that are below the given ID.
*
* The returned links are not ordered, and visible children will be included
- * even if they have a hidden parent or ancestor so would not normally appear
- * in a rendered tree.
+ * even if they have parent that is not enabled or ancestor so would not
+ * normally appear in a rendered tree.
*
* @param string $id
* The parent menu link ID.
@@ -161,7 +161,7 @@ public function loadTreeData($menu_name, MenuTreeParameters $parameters);
* The maximum relative depth of the children relative to the passed parent.
*
* @return array
- * An array of visible (not hidden) link definitions, keyed by ID.
+ * An array of enabled link definitions, keyed by ID.
*/
public function loadAllChildren($id, $max_relative_depth = NULL);
diff --git a/core/lib/Drupal/Core/Menu/StaticMenuLinkOverrides.php b/core/lib/Drupal/Core/Menu/StaticMenuLinkOverrides.php
index 8b79bffc253ce102ab3700442967b7cd62ccabf7..ebde906303446468c11897ea75b823684f01c94b 100644
--- a/core/lib/Drupal/Core/Menu/StaticMenuLinkOverrides.php
+++ b/core/lib/Drupal/Core/Menu/StaticMenuLinkOverrides.php
@@ -129,7 +129,7 @@ public function saveOverride($id, array $definition) {
'parent' => 1,
'weight' => 1,
'expanded' => 1,
- 'hidden' => 1,
+ 'enabled' => 1,
);
// Filter the overrides to only those that are expected.
$definition = array_intersect_key($definition, $expected);
diff --git a/core/lib/Drupal/Core/Menu/StaticMenuLinkOverridesInterface.php b/core/lib/Drupal/Core/Menu/StaticMenuLinkOverridesInterface.php
index 0ffb21a0fb225a96ffab476e27d88072488c121b..43c4416f12f9d1d0c6c1f7bd37d379ce2727ad94 100644
--- a/core/lib/Drupal/Core/Menu/StaticMenuLinkOverridesInterface.php
+++ b/core/lib/Drupal/Core/Menu/StaticMenuLinkOverridesInterface.php
@@ -32,7 +32,7 @@ public function reload();
* - weight
* - menu_name
* - expanded
- * - hidden
+ * - enabled
* or NULL if there is no override for the given ID.
*/
public function loadOverride($id);
@@ -77,7 +77,7 @@ public function loadMultipleOverrides(array $ids);
* - parent
* - weight
* - expanded
- * - hidden
+ * - enabled
*
* @return array
* A list of properties which got saved.
diff --git a/core/modules/book/book.links.menu.yml b/core/modules/book/book.links.menu.yml
index f7dbc18220e6625cb17217b1a32547b3824e79e2..0833dbd361434fe5a1c7e17f28fe52ae49668f4d 100644
--- a/core/modules/book/book.links.menu.yml
+++ b/core/modules/book/book.links.menu.yml
@@ -6,4 +6,4 @@ book.admin:
book.render:
title: Books
route_name: book.render
- hidden: 1
+ enabled: 0
diff --git a/core/modules/contact/contact.links.menu.yml b/core/modules/contact/contact.links.menu.yml
index 683be6386d0088b4d20c32bbe560a2a7b02887a2..8091f1fae17f310c53f3ff7500d79a716a47cf5d 100644
--- a/core/modules/contact/contact.links.menu.yml
+++ b/core/modules/contact/contact.links.menu.yml
@@ -7,4 +7,4 @@ contact.site_page:
title: Contact
route_name: contact.site_page
menu_name: footer
- hidden: 1
+ enabled: 0
diff --git a/core/modules/filter/filter.links.menu.yml b/core/modules/filter/filter.links.menu.yml
index e71db5015c33c9ed94a7ef29e5d3b6d0f22f7074..f689b2f08b44b202317eb26a2a0b5e1e82778b97 100644
--- a/core/modules/filter/filter.links.menu.yml
+++ b/core/modules/filter/filter.links.menu.yml
@@ -1,6 +1,6 @@
filter.tips_all:
title: 'Compose tips'
- hidden: 1
+ enabled: 0
route_name: filter.tips_all
filter.admin_overview:
title: 'Text formats'
diff --git a/core/modules/menu_link_content/src/Entity/MenuLinkContent.php b/core/modules/menu_link_content/src/Entity/MenuLinkContent.php
index 162fd51427babc04bc1a420601df86f42da42cc5..11f1d12c39281a5196a184242032285e84630794 100644
--- a/core/modules/menu_link_content/src/Entity/MenuLinkContent.php
+++ b/core/modules/menu_link_content/src/Entity/MenuLinkContent.php
@@ -157,8 +157,8 @@ public function getPluginId() {
/**
* {@inheritdoc}
*/
- public function isHidden() {
- return (bool) $this->get('hidden')->value;
+ public function isEnabled() {
+ return (bool) $this->get('enabled')->value;
}
/**
@@ -204,7 +204,7 @@ protected function getPluginDefinition() {
$definition['id'] = $this->getPluginId();
$definition['metadata'] = array('entity_id' => $this->id());
$definition['form_class'] = '\Drupal\menu_link_content\Form\MenuLinkContentForm';
- $definition['hidden'] = $this->isHidden() ? 1 : 0;
+ $definition['enabled'] = $this->isEnabled() ? 1 : 0;
$definition['expanded'] = $this->isExpanded() ? 1 : 0;
$definition['provider'] = 'menu_link_content';
$definition['discovered'] = 0;
@@ -366,13 +366,19 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
'weight' => 0,
));
- // @todo We manually create a form element for this, since the form logic is
- // is inverted to show enabled. Flip this to a status field and use the
- // normal entity Boolean widget. https://www.drupal.org/node/2305707
- $fields['hidden'] = BaseFieldDefinition::create('boolean')
- ->setLabel(t('Hidden'))
- ->setDescription(t('A flag for whether the link should be hidden in menus or rendered normally.'))
- ->setSetting('default_value', FALSE);
+ $fields['enabled'] = BaseFieldDefinition::create('boolean')
+ ->setLabel(t('Enabled'))
+ ->setDescription(t('A flag for whether the link should be enabled in menus or hidden.'))
+ ->setSetting('default_value', TRUE)
+ ->setDisplayOptions('view', array(
+ 'label' => 'hidden',
+ 'type' => 'boolean',
+ 'weight' => 0,
+ ))
+ ->setDisplayOptions('form', array(
+ 'settings' => array('display_label' => TRUE),
+ 'weight' => 0,
+ ));
$fields['langcode'] = BaseFieldDefinition::create('language')
->setLabel(t('Language code'))
diff --git a/core/modules/menu_link_content/src/Form/MenuLinkContentForm.php b/core/modules/menu_link_content/src/Form/MenuLinkContentForm.php
index 35f6d8e4bc4023ca2884f7423d9abe6dd2d96b02..ce2d81ddaf8ccc222d2d06b3acfbf645cc2c8a6b 100644
--- a/core/modules/menu_link_content/src/Form/MenuLinkContentForm.php
+++ b/core/modules/menu_link_content/src/Form/MenuLinkContentForm.php
@@ -213,7 +213,7 @@ protected function extractUrl($url) {
public function extractFormValues(array &$form, FormStateInterface $form_state) {
$new_definition = array();
$new_definition['expanded'] = !$form_state->isValueEmpty(array('expanded', 'value')) ? 1 : 0;
- $new_definition['hidden'] = $form_state->isValueEmpty('enabled') ? 1 : 0;
+ $new_definition['enabled'] = !$form_state->isValueEmpty(array('enabled', 'value')) ? 1 : 0;
list($menu_name, $parent) = explode(':', $form_state->getValue('menu_parent'), 2);
if (!empty($menu_name)) {
$new_definition['menu_name'] = $menu_name;
@@ -294,14 +294,6 @@ public function form(array $form, FormStateInterface $form_state) {
'#access' => !empty($language_configuration['language_show']),
);
- $form['enabled'] = array(
- '#type' => 'checkbox',
- '#title' => $this->t('Enable menu link'),
- '#description' => $this->t('Menu links that are not enabled will not be listed in any menu.'),
- '#default_value' => !$this->entity->isHidden(),
- '#weight' => 0,
- );
-
$default = $this->entity->getMenuName() . ':' . $this->entity->getParentId();
$form['menu_parent'] = $this->menuParentSelector->parentSelectElement($default, $this->entity->getPluginId());
$form['menu_parent']['#weight'] = 10;
@@ -342,7 +334,7 @@ public function buildEntity(array $form, FormStateInterface $form_state) {
$entity->parent->value = $new_definition['parent'];
$entity->menu_name->value = $new_definition['menu_name'];
- $entity->hidden->value = (bool) $new_definition['hidden'];
+ $entity->enabled->value = (bool) $new_definition['enabled'];
$entity->expanded->value = $new_definition['expanded'];
$entity->url->value = $new_definition['url'];
diff --git a/core/modules/menu_link_content/src/MenuLinkContentInterface.php b/core/modules/menu_link_content/src/MenuLinkContentInterface.php
index a5d0aca449757140636b9a32a646d087536c9e94..98922e9e1645dbc2d49312276816a4f8e4116db2 100644
--- a/core/modules/menu_link_content/src/MenuLinkContentInterface.php
+++ b/core/modules/menu_link_content/src/MenuLinkContentInterface.php
@@ -118,12 +118,12 @@ public function getDescription();
public function getPluginId();
/**
- * Returns whether the menu link is marked as hidden.
+ * Returns whether the menu link is marked as enabled.
*
* @return bool
- * TRUE if is not enabled, otherwise FALSE.
+ * TRUE if is enabled, otherwise FALSE.
*/
- public function isHidden();
+ public function isEnabled();
/**
* Returns whether the menu link is marked as always expanded.
diff --git a/core/modules/menu_link_content/src/Plugin/Menu/MenuLinkContent.php b/core/modules/menu_link_content/src/Plugin/Menu/MenuLinkContent.php
index 95228417382bf49e78650bb6d2d7c8784445a8b5..ea47019859ada0d15ffe211a6916e86d90cb7a13 100644
--- a/core/modules/menu_link_content/src/Plugin/Menu/MenuLinkContent.php
+++ b/core/modules/menu_link_content/src/Plugin/Menu/MenuLinkContent.php
@@ -37,7 +37,7 @@ class MenuLinkContent extends MenuLinkBase implements ContainerFactoryPluginInte
'parent' => 1,
'weight' => 1,
'expanded' => 1,
- 'hidden' => 1,
+ 'enabled' => 1,
'title' => 1,
'description' => 1,
'route_name' => 1,
diff --git a/core/modules/menu_ui/menu_ui.module b/core/modules/menu_ui/menu_ui.module
index 05310a2c32050c1c859e6f321819a83ebb91b2d1..07fcb8105187cdef4349757b3729cb76d0339a3c 100644
--- a/core/modules/menu_ui/menu_ui.module
+++ b/core/modules/menu_ui/menu_ui.module
@@ -197,7 +197,7 @@ function menu_ui_node_save(EntityInterface $node) {
if (trim($definition['title'])) {
if (!empty($definition['entity_id'])) {
$entity = entity_load('menu_link_content', $definition['entity_id']);
- $entity->hidden->value = 0;
+ $entity->enabled->value = 1;
$entity->title->value = trim($definition['title']);
$entity->description->value = trim($definition['description']);
$entity->menu_name->value = $definition['menu_name'];
@@ -214,7 +214,7 @@ function menu_ui_node_save(EntityInterface $node) {
'menu_name' => $definition['menu_name'],
'parent' => $definition['parent'],
'weight' => isset($definition['weight']) ? $definition['weight'] : 0,
- 'hidden' => 0,
+ 'enabled' => 1,
'bundle' => 'menu_link_content',
'langcode' => $node->getUntranslated()->language()->id,
));
diff --git a/core/modules/menu_ui/src/MenuForm.php b/core/modules/menu_ui/src/MenuForm.php
index 302a9e294eeb1a93f4b3d7c7a99eddd050ba7eac..2b3758f8dd442b9aaa62bcec8a30e0815b328a5b 100644
--- a/core/modules/menu_ui/src/MenuForm.php
+++ b/core/modules/menu_ui/src/MenuForm.php
@@ -265,9 +265,9 @@ protected function buildOverviewTreeForm($tree, $delta) {
if ($link) {
$id = 'menu_plugin_id:' . $link->getPluginId();
$form[$id]['#item'] = $element;
- $form[$id]['#attributes'] = $link->isHidden() ? array('class' => array('menu-disabled')) : array('class' => array('menu-enabled'));
+ $form[$id]['#attributes'] = $link->isEnabled() ? array('class' => array('menu-enabled')) : array('class' => array('menu-disabled'));
$form[$id]['title']['#markup'] = $this->linkGenerator->generateFromUrl($link->getTitle(), $link->getUrlObject(), $link->getOptions());
- if ($link->isHidden()) {
+ if (!$link->isEnabled()) {
$form[$id]['title']['#markup'] .= ' (' . $this->t('disabled') . ')';
}
elseif (($url = $link->getUrlObject()) && !$url->isExternal() && $url->getRouteName() == 'user.page') {
@@ -278,7 +278,7 @@ protected function buildOverviewTreeForm($tree, $delta) {
'#type' => 'checkbox',
'#title' => $this->t('Enable @title menu link', array('@title' => $link->getTitle())),
'#title_display' => 'invisible',
- '#default_value' => !$link->isHidden(),
+ '#default_value' => $link->isEnabled(),
);
$form[$id]['weight'] = array(
'#type' => 'weight',
@@ -378,13 +378,7 @@ protected function submitOverviewForm(array $complete_form, FormStateInterface $
// Update any fields that have changed in this menu item.
foreach ($fields as $field) {
if ($element[$field]['#value'] != $element[$field]['#default_value']) {
- // Hidden is a special case, the form value needs to be reversed.
- if ($field == 'enabled') {
- $updated_values['hidden'] = $element['enabled']['#value'] ? 0 : 1;
- }
- else {
- $updated_values[$field] = $element[$field]['#value'];
- }
+ $updated_values[$field] = $element[$field]['#value'];
}
}
if ($updated_values) {
diff --git a/core/modules/menu_ui/src/Tests/MenuTest.php b/core/modules/menu_ui/src/Tests/MenuTest.php
index ecec599ed518b17af8eaa392056e012589db749f..a97b8ab39d1f89e2930162f7dad7c3a8068a626f 100644
--- a/core/modules/menu_ui/src/Tests/MenuTest.php
+++ b/core/modules/menu_ui/src/Tests/MenuTest.php
@@ -400,7 +400,7 @@ function doMenuTests() {
$item5->save();
// Verify in the database.
- $this->assertMenuLink($item1->getPluginId(), array('hidden' => 0));
+ $this->assertMenuLink($item1->getPluginId(), array('enabled' => 1));
// Add an external link.
$item7 = $this->addMenuLink('', 'http://drupal.org', $menu_name);
@@ -529,7 +529,7 @@ function addMenuLink($parent = '', $path = '', $menu_name = 'tools', $exp
'url' => $path,
'title[0][value]' => $title,
'description[0][value]' => '',
- 'enabled' => 1,
+ 'enabled[value]' => 1,
'expanded[value]' => $expanded,
'menu_parent' => $menu_name . ':' . $parent,
'weight[0][value]' => $weight,
@@ -711,12 +711,12 @@ function toggleMenuLink(MenuLinkContent $item) {
*/
function disableMenuLink(MenuLinkContent $item) {
$mlid = $item->id();
- $edit['enabled'] = FALSE;
+ $edit['enabled[value]'] = FALSE;
$this->drupalPostForm("admin/structure/menu/item/$mlid/edit", $edit, t('Save'));
// Unlike most other modules, there is no confirmation message displayed.
// Verify in the database.
- $this->assertMenuLink($item->getPluginId(), array('hidden' => 1));
+ $this->assertMenuLink($item->getPluginId(), array('enabled' => 0));
}
/**
@@ -727,11 +727,11 @@ function disableMenuLink(MenuLinkContent $item) {
*/
function enableMenuLink(MenuLinkContent $item) {
$mlid = $item->id();
- $edit['enabled'] = TRUE;
+ $edit['enabled[value]'] = TRUE;
$this->drupalPostForm("admin/structure/menu/item/$mlid/edit", $edit, t('Save'));
// Verify in the database.
- $this->assertMenuLink($item->getPluginId(), array('hidden' => 0));
+ $this->assertMenuLink($item->getPluginId(), array('enabled' => 1));
}
/**
diff --git a/core/modules/menu_ui/src/Tests/MenuWebTestBase.php b/core/modules/menu_ui/src/Tests/MenuWebTestBase.php
index 60691974c1a3259d587fc3e2cde634b097309d89..38fb79901530e8ad5ef662f3076971d2b4c30f6a 100644
--- a/core/modules/menu_ui/src/Tests/MenuWebTestBase.php
+++ b/core/modules/menu_ui/src/Tests/MenuWebTestBase.php
@@ -68,6 +68,11 @@ function assertMenuLink($menu_plugin_id, array $expected_item) {
unset($expected_item['langcode']);
}
+ if (isset($expected_item['enabled']) && $entity) {
+ $this->assertEqual($entity->enabled->value, $expected_item['enabled']);
+ unset($expected_item['enabled']);
+ }
+
foreach ($expected_item as $key => $value) {
$this->assertTrue(isset($definition[$key]));
$this->assertEqual($definition[$key], $value);
diff --git a/core/modules/search/search.links.menu.yml b/core/modules/search/search.links.menu.yml
index da872a96f439982aeba1222fe2fe0ba5cd1c0f71..2bb0a1895e7602059e8a6a57d6e424b9e3b7ea0e 100644
--- a/core/modules/search/search.links.menu.yml
+++ b/core/modules/search/search.links.menu.yml
@@ -1,7 +1,7 @@
search.view:
title: Search
route_name: search.view
- hidden: 1
+ enabled: 0
search.settings:
title: 'Search pages'
parent: system.admin_config_search
diff --git a/core/modules/system/src/Controller/SystemController.php b/core/modules/system/src/Controller/SystemController.php
index c811e85c7267f713b54160816e81148b70b4227f..605b0a90d7d1a66e0988b40989bb615f420d1ee5 100644
--- a/core/modules/system/src/Controller/SystemController.php
+++ b/core/modules/system/src/Controller/SystemController.php
@@ -120,7 +120,7 @@ public function overview($link_id) {
}
// Load all menu links below it.
$parameters = new MenuTreeParameters();
- $parameters->setRoot($link_id)->excludeRoot()->setTopLevelOnly()->excludeHiddenLinks();
+ $parameters->setRoot($link_id)->excludeRoot()->setTopLevelOnly()->onlyEnabledLinks();
$tree = $this->menuLinkTree->load(NULL, $parameters);
$manipulators = array(
array('callable' => 'menu.default_tree_manipulators:checkAccess'),
diff --git a/core/modules/system/src/SystemManager.php b/core/modules/system/src/SystemManager.php
index 00f97aae4e9c1350fd706cd297456fefd1107730..d8786b2b641b2bf6894c81041e926a3281143b1c 100644
--- a/core/modules/system/src/SystemManager.php
+++ b/core/modules/system/src/SystemManager.php
@@ -217,7 +217,7 @@ public function getAdminBlock(MenuLinkInterface $instance) {
// Only find the children of this link.
$link_id = $instance->getPluginId();
$parameters = new MenuTreeParameters();
- $parameters->setRoot($link_id)->excludeRoot()->setTopLevelOnly()->excludeHiddenLinks();
+ $parameters->setRoot($link_id)->excludeRoot()->setTopLevelOnly()->onlyEnabledLinks();
$tree = $this->menuTree->load(NULL, $parameters);
$manipulators = array(
array('callable' => 'menu.default_tree_manipulators:checkAccess'),
diff --git a/core/modules/system/src/Tests/Menu/BreadcrumbTest.php b/core/modules/system/src/Tests/Menu/BreadcrumbTest.php
index 6661fb46156a733672a73ea6ce20a33cd1d52fb7..fe6a72e1488f829033297d4017d67c45342077a6 100644
--- a/core/modules/system/src/Tests/Menu/BreadcrumbTest.php
+++ b/core/modules/system/src/Tests/Menu/BreadcrumbTest.php
@@ -170,7 +170,7 @@ function testBreadCrumbs() {
'type' => $type,
'title' => $title,
'menu' => array(
- 'hidden' => 0,
+ 'enabled' => 1,
'title' => 'Parent ' . $title,
'description' => '',
'menu_name' => $menu,
@@ -243,6 +243,7 @@ function testBreadCrumbs() {
'title[0][value]' => "$name link",
'url' => "taxonomy/term/{$term->id()}",
'menu_parent' => "$menu:{$parent_mlid}",
+ 'enabled[value]' => 1,
);
$this->drupalPostForm("admin/structure/menu/manage/$menu/add", $edit, t('Save'));
$menu_links = entity_load_multiple_by_properties('menu_link_content', array('title' => $edit['title[0][value]'], 'route_name' => 'taxonomy.term_page', 'route_parameters' => serialize(array('taxonomy_term' => $term->id()))));
diff --git a/core/modules/system/src/Tests/Menu/MenuTreeStorageTest.php b/core/modules/system/src/Tests/Menu/MenuTreeStorageTest.php
index b1ebda653db1e6c39ad5a15a1d7c6acc20b82674..a923e9bf7473497ead6ad6b223f072fd11ad03cb 100644
--- a/core/modules/system/src/Tests/Menu/MenuTreeStorageTest.php
+++ b/core/modules/system/src/Tests/Menu/MenuTreeStorageTest.php
@@ -181,21 +181,21 @@ public function testMenuLinkMoving() {
}
/**
- * Tests with hidden child links.
+ * Tests with disabled child links.
*/
- public function testMenuHiddenChildLinks() {
+ public function testMenuDisabledChildLinks() {
// Add some links with parent on the previous one and test some values.
//
// - test1
- // -- test2 (hidden)
+ // -- test2 (disabled)
$this->addMenuLink('test1', '');
$this->assertMenuLink('test1', array('has_children' => 0, 'depth' => 1));
- $this->addMenuLink('test2', 'test1', '', array(), 'tools', array('hidden' => 1));
+ $this->addMenuLink('test2', 'test1', '', array(), 'tools', array('enabled' => 0));
// The 1st link does not have any visible children, so has_children is 0.
$this->assertMenuLink('test1', array('has_children' => 0, 'depth' => 1));
- $this->assertMenuLink('test2', array('has_children' => 0, 'depth' => 2, 'hidden' => 1), array('test1'));
+ $this->assertMenuLink('test2', array('has_children' => 0, 'depth' => 2, 'enabled' => 0), array('test1'));
// Add more links with parent on the previous one.
//