diff --git a/core/includes/menu.inc b/core/includes/menu.inc index 731d185..18e6260 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -1133,7 +1133,7 @@ function menu_tree_output($tree) { } // Set a class if the link is in the active trail. $localized_attributes = $data['link']->localized_options->attributes; - if ($data['link']->in_active_trail->value) { + if ($data['link']->inActiveTrail()) { $class[] = 'active-trail'; $localized_attributes['class'][] = 'active-trail'; } @@ -1593,7 +1593,7 @@ function _menu_tree_check_access(&$tree) { foreach ($tree as $key => $v) { $item = &$tree[$key]['link']; _menu_link_translate($item); - if ($item->getAccess() || ($item->in_active_trail->value && strpos($item['href'], '%') !== FALSE)) { + if ($item->getAccess() || ($item->inActiveTrail() && strpos($item['href'], '%') !== FALSE)) { if ($tree[$key]['below']) { _menu_tree_check_access($tree[$key]['below']); } @@ -1923,7 +1923,7 @@ function menu_navigation_links($menu_name, $level = 0) { $l = $item['link']->localized_options->getValue(); $l['href'] = $item['link']['href']; $l['title'] = $item['link']['title']; - if ($item['link']->in_active_trail->value) { + if ($item['link']->inActiveTrail()) { $class = ' active-trail'; $l['attributes']['class'][] = 'active-trail'; } @@ -2500,7 +2500,7 @@ function menu_set_active_trail($new_trail = NULL) { while ($curr) { $link = $curr['link']; - if ($link->in_active_trail->value) { + if ($link->inActiveTrail()) { // Add the link to the trail, unless it links to its parent. if (!($link['type'] & MENU_LINKS_TO_PARENT)) { // The menu tree for the active trail may contain additional links @@ -2887,7 +2887,7 @@ function _menu_navigation_links_rebuild($menu) { $existing_item = NULL; } - if ($existing_item && $existing_item->customized->value) { + if ($existing_item && $existing_item->isCustomized()) { $parent_candidates[$existing_item->id()] = $existing_item; } else { @@ -2905,11 +2905,11 @@ function _menu_navigation_links_rebuild($menu) { // Updated and customized items whose router paths are gone need new ones. $menu_links = $menu_link_controller->loadUpdatedCustomized($paths); foreach ($menu_links as $menu_link) { - $router_path = _menu_find_router_path($menu_link->link_path->value); - if (!empty($router_path) && ($router_path != $menu_link->router_path->value || $menu_link->updated->value)) { + $router_path = _menu_find_router_path($menu_link->getLinkPath()); + if (!empty($router_path) && ($router_path != $menu_link->getRouterPath() || $menu_link->getChangedTime())) { // If the router path and the link path matches, it's surely a working // item, so we clear the updated flag. - $updated = $menu_link->updated->value && $router_path != $menu_link->link_path->value; + $updated = $menu_link->getChangedTime() && $router_path != $menu_link->getLinkPath(); $menu_link->router_path = $router_path; $menu_link->updated = (int) $updated; diff --git a/core/lib/Drupal/Core/Entity/Plugin/DataType/MapItem.php b/core/lib/Drupal/Core/Entity/Plugin/DataType/MapItem.php index b2e55ce..738eb2b 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/DataType/MapItem.php +++ b/core/lib/Drupal/Core/Entity/Plugin/DataType/MapItem.php @@ -19,7 +19,7 @@ * id = "map_field", * label = @Translation("Map field item"), * description = @Translation("An entity field containing a map value."), - * list_class = "\Drupal\Core\Entity\Field\Field" + * list_class = "\Drupal\Core\Entity\Field\FieldItemList" * ) */ class MapItem extends FieldItemBase { @@ -93,4 +93,4 @@ protected function valueToProperty($value, $name) { return \Drupal::typedData()->create($def, $value, $name, $this); } -} \ No newline at end of file +} diff --git a/core/modules/book/book.module b/core/modules/book/book.module index fd86043..a1273da 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -58,7 +58,7 @@ function book_entity_bundle_info() { function book_menu_link_load($entities) { foreach ($entities as $entity) { // Change the bundle of menu links related to a book. - if (strpos($entity->menu_name->value, 'book-toc-') === 0) { + if (strpos($entity->getMenuName(), 'book-toc-') === 0) { $entity->bundle = 'book-toc'; } } diff --git a/core/modules/book/lib/Drupal/book/BookBreadcrumbBuilder.php b/core/modules/book/lib/Drupal/book/BookBreadcrumbBuilder.php index 93d9e8e..c145bfd 100644 --- a/core/modules/book/lib/Drupal/book/BookBreadcrumbBuilder.php +++ b/core/modules/book/lib/Drupal/book/BookBreadcrumbBuilder.php @@ -85,8 +85,8 @@ public function build(array $attributes) { $depth = 1; while (!empty($book['p' . ($depth + 1)])) { if (!empty($menu_links[$book['p' . $depth]]) && ($menu_link = $menu_links[$book['p' . $depth]])) { - if ($this->accessManager->checkNamedRoute($menu_link->route_name->value, $menu_link->route_parameters[0]->getValue())) { - $links[] = $this->linkGenerator->generate($menu_link->label(), $menu_link->route_name->value, $menu_link->route_parameters[0]->getValue(), $menu_link->options[0]->getValue()); + if ($this->accessManager->checkNamedRoute($menu_link->getRouteName(), $menu_link->route_parameters[0]->getValue())) { + $links[] = $this->linkGenerator->generate($menu_link->label(), $menu_link->getRouteName(), $menu_link->route_parameters[0]->getValue(), $menu_link->options[0]->getValue()); } } $depth++; diff --git a/core/modules/menu/lib/Drupal/menu/Form/MenuLinkDeleteForm.php b/core/modules/menu/lib/Drupal/menu/Form/MenuLinkDeleteForm.php index 43db3a2..3c58a67 100644 --- a/core/modules/menu/lib/Drupal/menu/Form/MenuLinkDeleteForm.php +++ b/core/modules/menu/lib/Drupal/menu/Form/MenuLinkDeleteForm.php @@ -18,7 +18,7 @@ class MenuLinkDeleteForm extends EntityConfirmFormBase { * {@inheritdoc} */ public function getQuestion() { - return t('Are you sure you want to delete the custom menu link %item?', array('%item' => $this->entity->link_title->value)); + return t('Are you sure you want to delete the custom menu link %item?', array('%item' => $this->entity->getLinkTitle())); } /** @@ -28,7 +28,7 @@ public function getCancelRoute() { return array( 'route_name' => 'menu.menu_edit', 'route_parameters' => array( - 'menu' => $this->entity->menu_name->value, + 'menu' => $this->entity->getMenuName(), ), ); } diff --git a/core/modules/menu/lib/Drupal/menu/Form/MenuLinkResetForm.php b/core/modules/menu/lib/Drupal/menu/Form/MenuLinkResetForm.php index 6f41606..db2dcc0 100644 --- a/core/modules/menu/lib/Drupal/menu/Form/MenuLinkResetForm.php +++ b/core/modules/menu/lib/Drupal/menu/Form/MenuLinkResetForm.php @@ -18,7 +18,7 @@ class MenuLinkResetForm extends EntityConfirmFormBase { * {@inheritdoc} */ public function getQuestion() { - return t('Are you sure you want to reset the link %item to its default values?', array('%item' => $this->entity->link_title->value)); + return t('Are you sure you want to reset the link %item to its default values?', array('%item' => $this->entity->getLinkTitle())); } /** @@ -28,7 +28,7 @@ public function getCancelRoute() { return array( 'route_name' => 'menu.menu_edit', 'route_parameters' => array( - 'menu' => $this->entity->menu_name->value, + 'menu' => $this->entity->getMenuName(), ), ); } diff --git a/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php b/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php index e0ac0d7..f7ce4f8 100644 --- a/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php +++ b/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php @@ -448,7 +448,7 @@ public function testMenuBundles() { $unsaved_item = entity_create('menu_link', array('menu_name' => $menu->id(), 'link_title' => $this->randomName(16), 'link_path' => '')); $this->assertEqual($unsaved_item->bundle(), $menu->id(), 'Unsaved menu link bundle matches the menu'); - $this->assertEqual($unsaved_item->menu_name->value, $menu->id(), 'Unsaved menu link menu name matches the menu'); + $this->assertEqual($unsaved_item->getMenuName(), $menu->id(), 'Unsaved menu link menu name matches the menu'); } diff --git a/core/modules/menu_link/lib/Drupal/menu_link/Entity/MenuLink.php b/core/modules/menu_link/lib/Drupal/menu_link/Entity/MenuLink.php index 878ace8..29032a5 100644 --- a/core/modules/menu_link/lib/Drupal/menu_link/Entity/MenuLink.php +++ b/core/modules/menu_link/lib/Drupal/menu_link/Entity/MenuLink.php @@ -460,7 +460,7 @@ public function findParent(MenuLinkStorageControllerInterface $storage_controlle $parent = FALSE; $plid = $this->getParentLinkId(); - // This item is explicitely top-level, skip the rest of the parenting. + // This item is explicitly top-level, skip the rest of the parenting. if ($plid === 0) { return $parent; } @@ -626,7 +626,15 @@ public function setExpanded($expanded) { $this->set('expanded', $expanded ? 1 : 0); } - /**v + /** + * {@inheritdoc} + */ + public function inActiveTrail() { + return (bool) $this->get('in_active_trail')->value; + } + + /** + * {@inheritdoc} */ public function isExpanded() { return (bool) $this->get('expanded')->value; @@ -730,14 +738,30 @@ public function setRouteName($route_name) { return $this; } + /** + * Returns whether the menu link is accessible (old property). + * + * @return bool + * Returns TRUE if the link is accessible, FALSE if not. + */ public function getAccess() { return $this->get('access')->value; } + /** + * Set whether the menu link is accessible (old property). + * + * @param bool $access + * TRUE if the link is accessible, FALSE if not. + * + * @return \Drupal\menu_link\MenuLinkInterface + * The called menu link entity. + */ public function setAccess($access) { $this->set('access', $access); return $this; } + /** * {@inheritdoc} */ diff --git a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkAccessController.php b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkAccessController.php index e710775..8c3d9e3 100644 --- a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkAccessController.php +++ b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkAccessController.php @@ -27,11 +27,11 @@ protected function checkAccess(EntityInterface $entity, $operation, $langcode, A switch ($operation) { case 'reset': // Reset allowed for items defined via hook_menu() and customized. - return $entity->module->value == 'system' && $entity->customized->value; + return $entity->getModule() == 'system' && $entity->isCustomized(); case 'delete': // Only items created by the menu module can be deleted. - return $entity->module->value == 'menu' || $entity->updated->value == 1; + return $entity->getModule() == 'menu' || $entity->updated->value == 1; } } diff --git a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php index ab09332..8f2f742 100644 --- a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php +++ b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php @@ -80,7 +80,7 @@ public function form(array $form, array &$form_state) { $form['link_title'] = array( '#type' => 'textfield', '#title' => t('Menu link title'), - '#default_value' => $menu_link->link_title->value, + '#default_value' => $menu_link->getLinkTitle(), '#description' => t('The text to be used for this link in the menu.'), '#required' => TRUE, ); @@ -92,14 +92,14 @@ public function form(array $form, array &$form_state) { // We are not using url() when constructing this path because it would add // $base_path. - $path = $menu_link->link_path->value; + $path = $menu_link->getLinkPath(); if (isset($menu_link->options->query)) { $path .= '?' . $this->urlGenerator->httpBuildQuery($menu_link->options->query); } if (isset($menu_link->options->fragment)) { $path .= '#' . $menu_link->options->fragment; } - if ($menu_link->module->value == 'menu') { + if ($menu_link->getModule() == 'menu') { $form['link_path'] = array( '#type' => 'textfield', '#title' => t('Path'), @@ -113,7 +113,7 @@ public function form(array $form, array &$form_state) { $form['_path'] = array( '#type' => 'item', '#title' => t('Path'), - '#description' => l($menu_link->link_title->value, $menu_link->href, $menu_link['options']), + '#description' => l($menu_link->getLinkTitle(), $menu_link->href, $menu_link['options']), ); } @@ -127,19 +127,19 @@ public function form(array $form, array &$form_state) { $form['enabled'] = array( '#type' => 'checkbox', '#title' => t('Enabled'), - '#default_value' => !$menu_link->hidden->value, + '#default_value' => !$menu_link->isHidden(), '#description' => t('Menu links that are not enabled will not be listed in any menu.'), ); $form['expanded'] = array( '#type' => 'checkbox', '#title' => t('Show as expanded'), - '#default_value' => $menu_link->expanded->value, + '#default_value' => $menu_link->isExpanded(), '#description' => t('If selected and this menu link has children, the menu will always appear expanded.'), ); // Generate a list of possible parents (not including this link or descendants). $options = menu_parent_options(menu_get_menus(), $menu_link); - $default = $menu_link->menu_name->value . ':' . $menu_link->plid->target_id; + $default = $menu_link->getMenuName() . ':' . $menu_link->plid->target_id; if (!isset($options[$default])) { $default = 'tools:0'; } @@ -153,7 +153,7 @@ public function form(array $form, array &$form_state) { ); // Get number of items in menu so the weight selector is sized appropriately. - $delta = $this->menuLinkStorageController->countMenuLinks($menu_link->menu_name->value); + $delta = $this->menuLinkStorageController->countMenuLinks($menu_link->getMenuName()); $form['weight'] = array( '#type' => 'weight', '#title' => t('Weight'), @@ -175,7 +175,7 @@ public function form(array $form, array &$form_state) { // Without Language module menu links inherit the menu language and no // language selector is shown. else { - $default_langcode = ($menu_link->isNew() ? entity_load('menu', $menu_link->menu_name->value)->langcode : $menu_link->langcode->value); + $default_langcode = ($menu_link->isNew() ? entity_load('menu', $menu_link->getMenuName())->langcode : $menu_link->langcode->value); $language_show = FALSE; } @@ -244,7 +244,7 @@ public function buildEntity(array $form, array &$form_state) { $entity = parent::buildEntity($form, $form_state); // The value of "hidden" is the opposite of the value supplied by the // "enabled" checkbox. - $entity->hidden->value = (int) !$form_state['values']['enabled']; + $entity->setHidden((bool) !$form_state['values']['enabled']); $substrs = explode(':', $form_state['values']['parent']); $entity->setMenuName($substrs[0]); $entity->plid = intval($substrs[1]); diff --git a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkInterface.php b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkInterface.php index 3b307ba..9b74ddd 100644 --- a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkInterface.php +++ b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkInterface.php @@ -270,6 +270,14 @@ public function isExternal(); public function setCustomized($customized); /** + * Returns whether the menu link is in the active trail or not. + * + * @return bool + * TRUE if the menu link is in the active trail, FALSE if not. + */ + public function inActiveTrail(); + + /** * Returns whether the menu link is customized. * * @return string @@ -379,7 +387,7 @@ public function setRouteName($route_name); * The route parameters of this menu link. */ public function getRouteParams(); - + /** * Sets the route parameters associated with this menu link. * @@ -390,5 +398,4 @@ public function getRouteParams(); * The called menu link entity. */ public function setRouteParams($route_parameters); - } diff --git a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php index 7f691fb..9442cc8 100644 --- a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php +++ b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php @@ -166,10 +166,10 @@ protected function mapToStorageRecord(EntityInterface $entity) { foreach (array('options', 'route_parameters') as $property) { $record->$property = $entity->$property->getValue(); } - + return $record; } - + /** * Overrides DatabaseStorageController::save(). */ @@ -334,7 +334,7 @@ public function updateParentalStatus(EntityInterface $entity, $exclude = FALSE) // Check if at least one visible child exists in the table. $query = \Drupal::entityQuery($this->entityType); $query - ->condition('menu_name', $entity->menu_name->value) + ->condition('menu_name', $entity->getMenuName()) ->condition('hidden', 0) ->condition('plid', $entity->plid->target_id) ->count(); @@ -359,7 +359,7 @@ public function findChildrenRelativeDepth(EntityInterface $entity) { // make sense to convert to EFQ? $query = $this->database->select('menu_links'); $query->addField('menu_links', 'depth'); - $query->condition('menu_name', $entity->menu_name->value); + $query->condition('menu_name', $entity->getMenuName()); $query->orderBy('depth', 'DESC'); $query->range(0, 1); @@ -372,7 +372,7 @@ public function findChildrenRelativeDepth(EntityInterface $entity) { $max_depth = $query->execute()->fetchField(); - return ($max_depth > $entity->depth->value) ? $max_depth - $entity->depth->value : 0; + return ($max_depth > $entity->getDepth()) ? $max_depth - $entity->getDepth() : 0; } /** @@ -381,14 +381,14 @@ public function findChildrenRelativeDepth(EntityInterface $entity) { public function moveChildren(EntityInterface $entity) { $query = $this->database->update($this->entityInfo['base_table']); - $query->fields(array('menu_name' => $entity->menu_name->value)); + $query->fields(array('menu_name' => $entity->getMenuName())); $p = 'p1'; $expressions = array(); - for ($i = 1; $i <= $entity->depth->value; $p = 'p' . ++$i) { + for ($i = 1; $i <= $entity->getDepth(); $p = 'p' . ++$i) { $expressions[] = array($p, ":p_$i", array(":p_$i" => $entity->{$p}->value)); } - $j = $entity->original->depth->value + 1; + $j = $entity->original->getDepth() + 1; while ($i <= MENU_MAX_DEPTH && $j <= MENU_MAX_DEPTH) { $expressions[] = array('p' . $i++, 'p' . $j++, array()); } @@ -396,7 +396,7 @@ public function moveChildren(EntityInterface $entity) { $expressions[] = array('p' . $i++, 0, array()); } - $shift = $entity->depth->value - $entity->original->depth->value; + $shift = $entity->getDepth() - $entity->original->getDepth(); if ($shift > 0) { // The order of expressions must be reversed so the new values don't // overwrite the old ones before they can be used because "Single-table @@ -409,7 +409,7 @@ public function moveChildren(EntityInterface $entity) { } $query->expression('depth', 'depth + :depth', array(':depth' => $shift)); - $query->condition('menu_name', $entity->original->menu_name->value); + $query->condition('menu_name', $entity->original->getMenuName()); $p = 'p1'; for ($i = 1; $i <= MENU_MAX_DEPTH && $entity->original->{$p}->value; $p = 'p' . ++$i) { $query->condition($p, $entity->original->{$p}->value); @@ -436,7 +436,7 @@ public function countMenuLinks($menu_name) { * {@inheritdoc} */ public function getParentFromHierarchy(EntityInterface $entity) { - $parent_path = $entity->link_path->value; + $parent_path = $entity->getLinkPath(); do { $parent = FALSE; $parent_path = substr($parent_path, 0, strrpos($parent_path, '/')); @@ -447,7 +447,7 @@ public function getParentFromHierarchy(EntityInterface $entity) { ->condition('module', 'system') // We always respect the link's 'menu_name'; inheritance for router // items is ensured in _menu_router_build(). - ->condition('menu_name', $entity->menu_name->value) + ->condition('menu_name', $entity->getMenuName()) ->condition('link_path', $parent_path); $result = $query->execute(); diff --git a/core/modules/menu_link/menu_link.api.php b/core/modules/menu_link/menu_link.api.php index f5ec959..b6f42fb 100644 --- a/core/modules/menu_link/menu_link.api.php +++ b/core/modules/menu_link/menu_link.api.php @@ -49,17 +49,17 @@ function hook_menu_link_load($menu_links) { */ function hook_menu_link_presave(\Drupal\menu_link\Entity\MenuLink $menu_link) { // Make all new admin links hidden (a.k.a disabled). - if (strpos($menu_link->link_path->value, 'admin') === 0 && $menu_link->isNew()) { + if (strpos($menu_link->getLinkPath(), 'admin') === 0 && $menu_link->isNew()) { $menu_link->hidden = 1; } // Flag a link to be altered by hook_menu_link_load(). - if ($menu_link->link_path->value == 'devel/cache/clear') { + if ($menu_link->getLinkPath() == 'devel/cache/clear') { $menu_link->options['alter'] = TRUE; } // Flag a menu link to be altered by hook_menu_link_load(), but only if it is // derived from a menu router item; i.e., do not alter a custom menu link // pointing to the same path that has been created by a user. - if ($menu_link->link_path->value == 'user' && $menu_link->module == 'system') { + if ($menu_link->getLinkPath() == 'user' && $menu_link->getModule() == 'system') { $menu_link->options['alter'] = TRUE; } } @@ -82,7 +82,7 @@ function hook_menu_link_insert(\Drupal\menu_link\Entity\MenuLink $menu_link) { // In our sample case, we track menu items as editing sections // of the site. These are stored in our table as 'disabled' items. $record['mlid'] = $menu_link->id(); - $record['menu_name'] = $menu_link->menu_name->value; + $record['menu_name'] = $menu_link->getMenuName(); $record['status'] = 0; drupal_write_record('menu_example', $record); } @@ -104,9 +104,9 @@ function hook_menu_link_insert(\Drupal\menu_link\Entity\MenuLink $menu_link) { function hook_menu_link_update(\Drupal\menu_link\Entity\MenuLink $menu_link) { // If the parent menu has changed, update our record. $menu_name = db_query("SELECT menu_name FROM {menu_example} WHERE mlid = :mlid", array(':mlid' => $menu_link->id()))->fetchField(); - if ($menu_name != $menu_link->menu_name->value) { + if ($menu_name != $menu_link->getMenuName()) { db_update('menu_example') - ->fields(array('menu_name' => $menu_link->menu_name->value)) + ->fields(array('menu_name' => $menu_link->getMenuName())) ->condition('mlid', $menu_link->id()) ->execute(); } diff --git a/core/modules/menu_link/menu_link.module b/core/modules/menu_link/menu_link.module index fb0ac30..2c7cf3d 100755 --- a/core/modules/menu_link/menu_link.module +++ b/core/modules/menu_link/menu_link.module @@ -208,7 +208,7 @@ function menu_link_system_breadcrumb_alter(array &$breadcrumb, array $attributes $menu_link = $attributes['menu_link']; if (($menu_link instanceof MenuLinkInterface) && !$menu_link->isNew()) { // Add a link to the menu admin screen. - $menu = entity_load('menu', $menu_link->menu_name->value); + $menu = entity_load('menu', $menu_link->getMenuName()); $breadcrumb[] = Drupal::l($menu->label(), 'menu.menu_edit', array('menu' => $menu->id)); } } diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Form/LinkDelete.php b/core/modules/shortcut/lib/Drupal/shortcut/Form/LinkDelete.php index 6f0008f..f67f63f 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Form/LinkDelete.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Form/LinkDelete.php @@ -33,7 +33,7 @@ public function getFormID() { * {@inheritdoc} */ public function getQuestion() { - return t('Are you sure you want to delete the shortcut %title?', array('%title' => $this->menuLink->link_title->value)); + return t('Are you sure you want to delete the shortcut %title?', array('%title' => $this->menuLink->getLinkTitle())); } /** @@ -43,7 +43,7 @@ public function getCancelRoute() { return array( 'route_name' => 'shortcut.set_customize', 'route_parameters' => array( - 'shortcut_set' => str_replace('shortcut-', '', $this->menuLink->menu_name->value), + 'shortcut_set' => str_replace('shortcut-', '', $this->menuLink->getMenuName()), ), ); } @@ -69,9 +69,9 @@ public function buildForm(array $form, array &$form_state, MenuLink $menu_link = */ public function submitForm(array &$form, array &$form_state) { menu_link_delete($this->menuLink->id()); - $set_name = str_replace('shortcut-', '' , $this->menuLink->menu_name->value); + $set_name = str_replace('shortcut-', '' , $this->menuLink->getMenuName()); $form_state['redirect'] = 'admin/config/user-interface/shortcut/manage/' . $set_name; - drupal_set_message(t('The shortcut %title has been deleted.', array('%title' => $this->menuLink->link_title->value))); + drupal_set_message(t('The shortcut %title has been deleted.', array('%title' => $this->menuLink->getLinkTitle()))); } } diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Form/SetCustomize.php b/core/modules/shortcut/lib/Drupal/shortcut/Form/SetCustomize.php index 97aafee..21e82ef 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Form/SetCustomize.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Form/SetCustomize.php @@ -38,13 +38,13 @@ public function form(array $form, array &$form_state) { foreach ($this->entity->links as $link) { $mlid = $link->id(); $form['shortcuts']['links'][$mlid]['#attributes']['class'][] = 'draggable'; - $form['shortcuts']['links'][$mlid]['name']['#markup'] = l($link->link_title->value, $link->link_path->value); - $form['shortcuts']['links'][$mlid]['#weight'] = $link->weight->value; + $form['shortcuts']['links'][$mlid]['name']['#markup'] = l($link->getLinkTitle(), $link->getLinkPath()); + $form['shortcuts']['links'][$mlid]['#weight'] = $link->getWeight(); $form['shortcuts']['links'][$mlid]['weight'] = array( '#type' => 'weight', - '#title' => t('Weight for @title', array('@title' => $link->link_title->value)), + '#title' => t('Weight for @title', array('@title' => $link->getLinkTitle())), '#title_display' => 'invisible', - '#default_value' => $link->weight->value, + '#default_value' => $link->getWeight(), '#attributes' => array('class' => array('shortcut-weight')), ); diff --git a/core/modules/shortcut/shortcut.module b/core/modules/shortcut/shortcut.module index 355bc61..dcf9432 100644 --- a/core/modules/shortcut/shortcut.module +++ b/core/modules/shortcut/shortcut.module @@ -56,7 +56,7 @@ function shortcut_entity_bundle_info() { function shortcut_menu_link_load($entities) { foreach ($entities as $entity) { // Change the bundle of menu links related to a shortcut. - if (strpos($entity->menu_name->value, 'shortcut-') === 0) { + if (strpos($entity->getMenuName(), 'shortcut-') === 0) { $entity->bundle = 'shortcut'; } } @@ -219,8 +219,8 @@ function shortcut_link_access($menu_link) { */ function shortcut_menu_link_delete($menu_link) { // If the deleted menu link was in a shortcut set, remove it. - if (strpos($menu_link->menu_name->value, 'shortcut-') === 0) { - $shortcut = entity_load('shortcut_set', str_replace('shortcut-', '', $menu_link->menu_name->value)); + if (strpos($menu_link->getMenuName(), 'shortcut-') === 0) { + $shortcut = entity_load('shortcut_set', str_replace('shortcut-', '', $menu_link->getMenuName())); unset($shortcut->links[$menu_link->uuid()]); $shortcut->save(); } diff --git a/core/modules/system/lib/Drupal/system/SystemManager.php b/core/modules/system/lib/Drupal/system/SystemManager.php index 57d893f..f2e8973 100644 --- a/core/modules/system/lib/Drupal/system/SystemManager.php +++ b/core/modules/system/lib/Drupal/system/SystemManager.php @@ -198,7 +198,7 @@ public function getAdminBlock($item) { $menu_links = $this->menuLinkStorage->loadByProperties(array('router_path' => $item['path'], 'module' => 'system')); $menu_link = reset($menu_links); $item['mlid'] = $menu_link->id(); - $item['menu_name'] = $menu_link->menu_name->value; + $item['menu_name'] = $menu_link->getMenuName(); } if (isset($this->menuItems[$item['mlid']])) { diff --git a/core/modules/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php b/core/modules/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php index 86e1eb3..cba4e05 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php @@ -323,7 +323,7 @@ function testMenuName() { $menu_links = entity_load_multiple_by_properties('menu_link', array('router_path' => 'menu_name_test')); $menu_link = reset($menu_links); - $this->assertEqual($menu_link->menu_name->value, 'original', 'Menu name is "original".'); + $this->assertEqual($menu_link->getMenuName(), 'original', 'Menu name is "original".'); // Change the menu_name parameter in menu_test.module, then force a menu // rebuild. @@ -333,7 +333,7 @@ function testMenuName() { $menu_links = entity_load_multiple_by_properties('menu_link', array('router_path' => 'menu_name_test')); $menu_link = reset($menu_links); - $this->assertEqual($menu_link->menu_name->value, 'changed', 'Menu name was successfully changed after rebuild.'); + $this->assertEqual($menu_link->getMenuName(), 'changed', 'Menu name was successfully changed after rebuild.'); } /** @@ -364,7 +364,7 @@ function testMenuHidden() { $links = array(); foreach ($menu_links as $menu_link) { - $links[$menu_link->router_path->value] = $menu_link; + $links[$menu_link->getRouterPath()] = $menu_link; } $parent = $links['menu-test/hidden/menu']; @@ -416,7 +416,7 @@ function testMenuHidden() { $links = array(); foreach ($menu_links as $menu_link) { - $links[$menu_link->router_path->value] = $menu_link; + $links[$menu_link->getRouterPath()] = $menu_link; } $parent = $links['menu-test/hidden/block'];