diff --git a/core/includes/menu.inc b/core/includes/menu.inc index b07da4e..eea5c4d 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -2946,8 +2946,8 @@ function _menu_navigation_links_rebuild($menu) { // item, so we clear the updated flag. $updated = $menu_link->updated->value && $router_path != $menu_link->link_path->value; - $menu_link->router_path->value = $router_path; - $menu_link->updated->value = (int) $updated; + $menu_link->router_path = $router_path; + $menu_link->updated = (int) $updated; $menu_link_controller->save($menu_link); } } @@ -3104,15 +3104,14 @@ function _menu_router_build($callbacks, $save = FALSE) { // Look for wildcards in the form allowed to be used in PHP functions, // because we are using these to construct the load function names. if (preg_match('/^%(|' . DRUPAL_PHP_FUNCTION_PATTERN . ')$/', $part, $matches)) { + $match = TRUE; if (empty($matches[1])) { - $match = TRUE; $load_functions[$k] = NULL; } else { if (function_exists($matches[1] . '_to_arg')) { $to_arg_functions[$k] = $matches[1] . '_to_arg'; $load_functions[$k] = NULL; - $match = TRUE; } if (function_exists($matches[1] . '_load')) { $function = $matches[1] . '_load'; @@ -3120,7 +3119,6 @@ function _menu_router_build($callbacks, $save = FALSE) { // function when this menu path is checked, if 'load arguments' // exists. $load_functions[$k] = isset($item['load arguments']) ? array($function => $item['load arguments']) : $function; - $match = TRUE; } } } diff --git a/core/modules/menu/lib/Drupal/menu/Form/MenuLinkDeleteForm.php b/core/modules/menu/lib/Drupal/menu/Form/MenuLinkDeleteForm.php index 2815a91..87c03f0 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)); + return t('Are you sure you want to delete the custom menu link %item?', array('%item' => $this->entity->link_title->value)); } /** @@ -28,7 +28,7 @@ public function getCancelRoute() { return array( 'route_name' => 'menu.menu_edit', 'route_parameters' => array( - 'menu' => $this->entity->menu_name, + 'menu' => $this->entity->menu_name->value, ), ); } @@ -41,7 +41,7 @@ public function submit(array $form, array &$form_state) { $t_args = array('%title' => $this->entity->link_title); drupal_set_message(t('The menu link %title has been deleted.', $t_args)); watchdog('menu', 'Deleted menu link %title.', $t_args, WATCHDOG_NOTICE); - $form_state['redirect'] = 'admin/structure/menu/manage/' . $this->entity->menu_name; + $form_state['redirect'] = 'admin/structure/menu/manage/' . $this->entity->menu_name->value; } } diff --git a/core/modules/menu/lib/Drupal/menu/Form/MenuLinkResetForm.php b/core/modules/menu/lib/Drupal/menu/Form/MenuLinkResetForm.php index 5b79ef4..c6615e8 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)); + return t('Are you sure you want to reset the link %item to its default values?', array('%item' => $this->entity->link_title->value)); } /** @@ -28,7 +28,7 @@ public function getCancelRoute() { return array( 'route_name' => 'menu.menu_edit', 'route_parameters' => array( - 'menu' => $this->entity->menu_name, + 'menu' => $this->entity->menu_name->value, ), ); } @@ -53,7 +53,7 @@ public function getConfirmText() { public function submit(array $form, array &$form_state) { $new_menu_link = $this->entity->reset(); drupal_set_message(t('The menu link was reset to its default settings.')); - $form_state['redirect'] = 'admin/structure/menu/manage/' . $new_menu_link->menu_name; + $form_state['redirect'] = 'admin/structure/menu/manage/' . $new_menu_link->menu_name->value; } } diff --git a/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php b/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php index 6601fb3..03e4c6d 100644 --- a/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php +++ b/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php @@ -82,7 +82,7 @@ function testMenu() { $item = entity_load('menu_link', $item['mlid']); // Verify that a change to the description is saved. $description = $this->randomName(16); - $item->options->attributes['title'] = $description; + $item->options->attributes = array('title' => $description); $return_value = menu_link_save($item); // Save the menu link again to test the return value of the procedural save // helper. 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 90c352a..d6ddf85 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 @@ -9,13 +9,14 @@ use Drupal\Core\Annotation\Translation; use Drupal\Core\Entity\Annotation\EntityType; +use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityNG; use Drupal\Core\Entity\EntityStorageControllerInterface; +use Drupal\Core\TypedData\TypedDataInterface; use Drupal\menu_link\MenuLinkInterface; use Drupal\menu_link\MenuLinkStorageControllerInterface; use Symfony\Component\Routing\Route; use Symfony\Component\HttpFoundation\Request; -use Drupal\Core\Entity\Plugin\DataType\MapItem; /** * Defines the menu link entity class. @@ -218,18 +219,6 @@ public function offsetSet($offset, $value) { } } } - /* if (!isset($value)) { - $this->options->value->setValue(array()); - } - elseif (is_array($value)) { - $this->options->value->setValue($value); - } - elseif ($value instanceof MapItem) { - $this->options->value->setValue($value->getValue()); - } - else { - $this->options = $value; - }*/ } elseif ($this->getPropertyDefinition($offset)) { $this->{$offset} = $value; @@ -702,204 +691,204 @@ public function setRouteName($route_name) { * {@inheritdoc} */ public static function baseFieldDefinitions($entity_type) { - $properties['menu_name'] = array( - 'label' => t('Menu name'), - 'description' => t('The menu name. All links with the same menu name (such as "tools") are part of the same menu.'), - 'type' => 'string_field', - 'settings' => array( - 'default_value' => 'tools', - ), - ); - $properties['mlid'] = array( - 'label' => t('Menu link ID'), - 'description' => t('The menu link ID.'), - 'type' => 'integer_field', - 'read-only' => TRUE, - ); - $properties['uuid'] = array( - 'label' => t('UUID'), - 'description' => t('The menu link UUID.'), - 'type' => 'uuid_field', - 'read-only' => TRUE, - ); - $properties['plid'] = array( - 'label' => t('Parent ID'), - 'description' => t('The parent menu link ID.'), - 'type' => 'entity_reference_field', - 'settings' => array('target_type' => 'menu_link'), - ); - $properties['link_path'] = array( - 'label' => t('Link path'), - 'description' => t('The Drupal path or external path this link points to.'), - 'type' => 'string_field', - ); - $properties['router_path'] = array( - 'label' => t('Router path'), - 'description' => t('For links corresponding to a Drupal path (external = 0), this connects the link to a {menu_router}.path.'), - 'type' => 'string_field', - ); - $properties['langcode'] = array( - 'label' => t('Language code'), - 'description' => t('The menu link language code.'), - 'type' => 'language_field', - ); - $properties['link_title'] = array( - 'label' => t('Title'), - 'description' => t('The text displayed for the link, which may be modified by a title callback stored in {menu_router}.'), - 'type' => 'string_field', - 'settings' => array( - 'default_value' => '', - ), - ); - $properties['options'] = array( - 'label' => t('Options'), - 'description' => t('A serialized array of options to be passed to the url() or l() function, such as a query string or HTML attributes.'), - 'type' => 'map_field', - ); - $properties['module'] = array( - 'label' => t('Module'), - 'description' => t('The name of the module that generated this link.'), - 'type' => 'string_field', - 'settings' => array( - 'default_value' => 'menu', - ), - ); - $properties['hidden'] = array( - 'label' => t('Hidden'), - 'description' => t('A flag for whether the link should be rendered in menus. (1 = a disabled menu item that may be shown on admin screens, -1 = a menu callback, 0 = a normal, visible link).'), - 'type' => 'boolean_field', - 'settings' => array( - 'default_value' => 0, - ), - ); - $properties['external'] = array( - 'label' => t('External'), - 'description' => t('A flag to indicate if the link points to a full URL starting with a protocol, like http:// (1 = external, 0 = internal).'), - 'type' => 'boolean_field', - 'settings' => array( - 'default_value' => 0, - ), - ); - $properties['has_children'] = array( - 'label' => t('Has children'), - 'description' => t('Flag indicating whether any links have this link as a parent (1 = children exist, 0 = no children).'), - 'type' => 'boolean_field', - 'settings' => array( - 'default_value' => 0, - ), - ); - $properties['expanded'] = array( - 'label' => t('Expanded'), - 'description' => t('Flag for whether this link should be rendered as expanded in menus - expanded links always have their child links displayed, instead of only when the link is in the active trail (1 = expanded, 0 = not expanded).'), - 'type' => 'boolean_field', - 'settings' => array( - 'default_value' => 0, - ), - ); - $properties['weight'] = array( - 'label' => t('Weight'), - 'description' => t('Link weight among links in the same menu at the same depth.'), - 'type' => 'integer_field', - 'settings' => array( - 'default_value' => 0, - ), - ); - $properties['depth'] = array( - 'label' => t('Depth'), - 'description' => t('The depth relative to the top level. A link with plid == 0 will have depth == 1.'), - 'type' => 'integer_field', - ); - $properties['customized'] = array( - 'label' => t('Customized'), - 'description' => t('A flag to indicate that the user has manually created or edited the link (1 = customized, 0 = not customized).'), - 'type' => 'boolean_field', - 'settings' => array( - 'default_value' => 0, - ), - ); - // @todo Declaring these pX properties as integer for the moment, we need to - // investigate if using 'entity_reference_field' cripples performance. - $properties['p1'] = array( - 'label' => t('Parent 1'), - 'description' => t('The first mlid in the materialized path.'), - 'type' => 'integer_field', - ); - $properties['p2'] = array( - 'label' => t('Parent 2'), - 'description' => t('The second mlid in the materialized path.'), - 'type' => 'integer_field', - ); - $properties['p3'] = array( - 'label' => t('Parent 3'), - 'description' => t('The third mlid in the materialized path.'), - 'type' => 'integer_field', - ); - $properties['p4'] = array( - 'label' => t('Parent 4'), - 'description' => t('The fourth mlid in the materialized path.'), - 'type' => 'integer_field', - ); - $properties['p5'] = array( - 'label' => t('Parent 5'), - 'description' => t('The fifth mlid in the materialized path.'), - 'type' => 'integer_field', - ); - $properties['p6'] = array( - 'label' => t('Parent 6'), - 'description' => t('The sixth mlid in the materialized path.'), - 'type' => 'integer_field', - ); - $properties['p7'] = array( - 'label' => t('Parent 7'), - 'description' => t('The seventh mlid in the materialized path.'), - 'type' => 'integer_field', - ); - $properties['p8'] = array( - 'label' => t('Parent 8'), - 'description' => t('The eighth mlid in the materialized path.'), - 'type' => 'integer_field', - ); - $properties['p9'] = array( - 'label' => t('Parent 9'), - 'description' => t('The ninth mlid in the materialized path.'), - 'type' => 'integer_field', - ); - $properties['updated'] = array( - 'label' => t('Updated'), - 'description' => t('Flag that indicates that this link was generated during the update from Drupal 5.'), - 'type' => 'boolean_field', - ); - $properties['route_name'] = array( - 'label' => t('Route name'), - 'description' => t('The machine name of a defined Symfony Route this menu item represents.'), - 'type' => 'string_field', - ); - $properties['route_parameters'] = array( - 'label' => t('Route parameters'), - 'description' => t('A serialized array of route parameters of this menu link.'), - 'type' => 'map_field', - ); - - // @todo Most of these should probably go away. - $properties['access'] = array( - 'label' => t('(old router) Access'), - 'description' => t(''), - 'type' => 'boolean_field', - 'computed' => TRUE, - ); - $properties['in_active_trail'] = array( - 'label' => t('In active trail'), - 'description' => t(''), - 'type' => 'boolean_field', - 'computed' => TRUE, - ); - $properties['localized_options'] = array( - 'label' => t('Localized options'), - 'description' => t(''), - 'type' => 'map_field', - 'computed' => TRUE, - ); - return $properties; + $properties['menu_name'] = array( + 'label' => t('Menu name'), + 'description' => t('The menu name. All links with the same menu name (such as "tools") are part of the same menu.'), + 'type' => 'string_field', + 'settings' => array( + 'default_value' => 'tools', + ), + ); + $properties['mlid'] = array( + 'label' => t('Menu link ID'), + 'description' => t('The menu link ID.'), + 'type' => 'integer_field', + 'read-only' => TRUE, + ); + $properties['uuid'] = array( + 'label' => t('UUID'), + 'description' => t('The menu link UUID.'), + 'type' => 'uuid_field', + 'read-only' => TRUE, + ); + $properties['plid'] = array( + 'label' => t('Parent ID'), + 'description' => t('The parent menu link ID.'), + 'type' => 'entity_reference_field', + 'settings' => array('target_type' => 'menu_link'), + ); + $properties['link_path'] = array( + 'label' => t('Link path'), + 'description' => t('The Drupal path or external path this link points to.'), + 'type' => 'string_field', + ); + $properties['router_path'] = array( + 'label' => t('Router path'), + 'description' => t('For links corresponding to a Drupal path (external = 0), this connects the link to a {menu_router}.path.'), + 'type' => 'string_field', + ); + $properties['langcode'] = array( + 'label' => t('Language code'), + 'description' => t('The menu link language code.'), + 'type' => 'language_field', + ); + $properties['link_title'] = array( + 'label' => t('Title'), + 'description' => t('The text displayed for the link, which may be modified by a title callback stored in {menu_router}.'), + 'type' => 'string_field', + 'settings' => array( + 'default_value' => '', + ), + ); + $properties['options'] = array( + 'label' => t('Options'), + 'description' => t('A serialized array of options to be passed to the url() or l() function, such as a query string or HTML attributes.'), + 'type' => 'map_field', + ); + $properties['module'] = array( + 'label' => t('Module'), + 'description' => t('The name of the module that generated this link.'), + 'type' => 'string_field', + 'settings' => array( + 'default_value' => 'menu', + ), + ); + $properties['hidden'] = array( + 'label' => t('Hidden'), + 'description' => t('A flag for whether the link should be rendered in menus. (1 = a disabled menu item that may be shown on admin screens, -1 = a menu callback, 0 = a normal, visible link).'), + 'type' => 'boolean_field', + 'settings' => array( + 'default_value' => 0, + ), + ); + $properties['external'] = array( + 'label' => t('External'), + 'description' => t('A flag to indicate if the link points to a full URL starting with a protocol, like http:// (1 = external, 0 = internal).'), + 'type' => 'boolean_field', + 'settings' => array( + 'default_value' => 0, + ), + ); + $properties['has_children'] = array( + 'label' => t('Has children'), + 'description' => t('Flag indicating whether any links have this link as a parent (1 = children exist, 0 = no children).'), + 'type' => 'boolean_field', + 'settings' => array( + 'default_value' => 0, + ), + ); + $properties['expanded'] = array( + 'label' => t('Expanded'), + 'description' => t('Flag for whether this link should be rendered as expanded in menus - expanded links always have their child links displayed, instead of only when the link is in the active trail (1 = expanded, 0 = not expanded).'), + 'type' => 'boolean_field', + 'settings' => array( + 'default_value' => 0, + ), + ); + $properties['weight'] = array( + 'label' => t('Weight'), + 'description' => t('Link weight among links in the same menu at the same depth.'), + 'type' => 'integer_field', + 'settings' => array( + 'default_value' => 0, + ), + ); + $properties['depth'] = array( + 'label' => t('Depth'), + 'description' => t('The depth relative to the top level. A link with plid == 0 will have depth == 1.'), + 'type' => 'integer_field', + ); + $properties['customized'] = array( + 'label' => t('Customized'), + 'description' => t('A flag to indicate that the user has manually created or edited the link (1 = customized, 0 = not customized).'), + 'type' => 'boolean_field', + 'settings' => array( + 'default_value' => 0, + ), + ); + // @todo Declaring these pX properties as integer for the moment, we need to + // investigate if using 'entity_reference_field' cripples performance. + $properties['p1'] = array( + 'label' => t('Parent 1'), + 'description' => t('The first mlid in the materialized path.'), + 'type' => 'integer_field', + ); + $properties['p2'] = array( + 'label' => t('Parent 2'), + 'description' => t('The second mlid in the materialized path.'), + 'type' => 'integer_field', + ); + $properties['p3'] = array( + 'label' => t('Parent 3'), + 'description' => t('The third mlid in the materialized path.'), + 'type' => 'integer_field', + ); + $properties['p4'] = array( + 'label' => t('Parent 4'), + 'description' => t('The fourth mlid in the materialized path.'), + 'type' => 'integer_field', + ); + $properties['p5'] = array( + 'label' => t('Parent 5'), + 'description' => t('The fifth mlid in the materialized path.'), + 'type' => 'integer_field', + ); + $properties['p6'] = array( + 'label' => t('Parent 6'), + 'description' => t('The sixth mlid in the materialized path.'), + 'type' => 'integer_field', + ); + $properties['p7'] = array( + 'label' => t('Parent 7'), + 'description' => t('The seventh mlid in the materialized path.'), + 'type' => 'integer_field', + ); + $properties['p8'] = array( + 'label' => t('Parent 8'), + 'description' => t('The eighth mlid in the materialized path.'), + 'type' => 'integer_field', + ); + $properties['p9'] = array( + 'label' => t('Parent 9'), + 'description' => t('The ninth mlid in the materialized path.'), + 'type' => 'integer_field', + ); + $properties['updated'] = array( + 'label' => t('Updated'), + 'description' => t('Flag that indicates that this link was generated during the update from Drupal 5.'), + 'type' => 'boolean_field', + ); + $properties['route_name'] = array( + 'label' => t('Route name'), + 'description' => t('The machine name of a defined Symfony Route this menu item represents.'), + 'type' => 'string_field', + ); + $properties['route_parameters'] = array( + 'label' => t('Route parameters'), + 'description' => t('A serialized array of route parameters of this menu link.'), + 'type' => 'map_field', + ); + + // @todo Most of these should probably go away. + $properties['access'] = array( + 'label' => t('(old router) Access'), + 'description' => t(''), + 'type' => 'boolean_field', + 'computed' => TRUE, + ); + $properties['in_active_trail'] = array( + 'label' => t('In active trail'), + 'description' => t(''), + 'type' => 'boolean_field', + 'computed' => TRUE, + ); + $properties['localized_options'] = array( + 'label' => t('Localized options'), + 'description' => t(''), + 'type' => 'map_field', + 'computed' => TRUE, + ); + return $properties; } - + } 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 8060e58..7dbbbdb 100644 --- a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php +++ b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php @@ -124,14 +124,14 @@ 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->get('value')->getValue()), + '#description' => l($menu_link->link_title->value, $menu_link->href, $menu_link['options']), ); } $form['description'] = array( '#type' => 'textarea', '#title' => t('Description'), - '#default_value' => isset($menu_link->options->value['attributes']['title']) ? $menu_link->options->value['attributes']['title'] : '', + '#default_value' => isset($menu_link->options->attributes['title']) ? $menu_link->options->attributes['title'] : '', '#rows' => 1, '#description' => t('Shown when hovering over the menu link.'), ); 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 6d9685c..c221df5 100644 --- a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php +++ b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php @@ -176,7 +176,7 @@ public function save(EntityInterface $entity) { } if ($entity->isNew()) { - $entity->mlid->value = $this->database->insert($this->entityInfo['base_table'])->fields(array('menu_name' => 'tools'))->execute(); + $entity->mlid = $this->database->insert($this->entityInfo['base_table'])->fields(array('menu_name' => 'tools'))->execute(); $entity->enforceIsNew(); } diff --git a/core/modules/menu_link/menu_link.api.php b/core/modules/menu_link/menu_link.api.php index bfb8a2e..f5ec959 100644 --- a/core/modules/menu_link/menu_link.api.php +++ b/core/modules/menu_link/menu_link.api.php @@ -32,7 +32,7 @@ */ function hook_menu_link_load($menu_links) { foreach ($menu_links as $menu_link) { - if ($menu_link->href == 'devel/cache/clear') { + if ($menu_link->href->value == 'devel/cache/clear') { $menu_link->options['query'] = drupal_get_destination(); } } @@ -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, 'admin') === 0 && $menu_link->isNew()) { + if (strpos($menu_link->link_path->value, '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 == 'devel/cache/clear') { + if ($menu_link->link_path->value == '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 == 'user' && $menu_link->module == 'system') { + if ($menu_link->link_path->value == 'user' && $menu_link->module == '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; + $record['menu_name'] = $menu_link->menu_name->value; $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) { + if ($menu_name != $menu_link->menu_name->value) { db_update('menu_example') - ->fields(array('menu_name' => $menu_link->menu_name)) + ->fields(array('menu_name' => $menu_link->menu_name->value)) ->condition('mlid', $menu_link->id()) ->execute(); } diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Form/LinkDelete.php b/core/modules/shortcut/lib/Drupal/shortcut/Form/LinkDelete.php index a0012dc..6f0008f 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)); + return t('Are you sure you want to delete the shortcut %title?', array('%title' => $this->menuLink->link_title->value)); } /** @@ -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), + 'shortcut_set' => str_replace('shortcut-', '', $this->menuLink->menu_name->value), ), ); } @@ -68,10 +68,10 @@ public function buildForm(array $form, array &$form_state, MenuLink $menu_link = * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { - menu_link_delete($this->menuLink->mlid); - $set_name = str_replace('shortcut-', '' , $this->menuLink->menu_name); + menu_link_delete($this->menuLink->id()); + $set_name = str_replace('shortcut-', '' , $this->menuLink->menu_name->value); $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))); + drupal_set_message(t('The shortcut %title has been deleted.', array('%title' => $this->menuLink->link_title->value))); } } diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php b/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php index bd2d194..e14b042 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php @@ -92,7 +92,7 @@ function testShortcutLinkRename() { $new_link_name = $this->randomName(); $link = reset($set->links); - $this->drupalPostForm('admin/config/user-interface/shortcut/link/' . $link->mlid, array('shortcut_link[link_title]' => $new_link_name, 'shortcut_link[link_path]' => $link->link_path), t('Save')); + $this->drupalPostForm('admin/config/user-interface/shortcut/link/' . $link->id(), array('shortcut_link[link_title]' => $new_link_name, 'shortcut_link[link_path]' => $link->link_path), t('Save')); $saved_set = shortcut_set_load($set->id()); $titles = $this->getShortcutInformation($saved_set, 'link_title'); $this->assertTrue(in_array($new_link_name, $titles), 'Shortcut renamed: ' . $new_link_name); @@ -109,7 +109,7 @@ function testShortcutLinkChangePath() { $new_link_path = 'admin/config'; $link = reset($set->links); - $this->drupalPostForm('admin/config/user-interface/shortcut/link/' . $link->mlid, array('shortcut_link[link_title]' => $link->link_title, 'shortcut_link[link_path]' => $new_link_path), t('Save')); + $this->drupalPostForm('admin/config/user-interface/shortcut/link/' . $link->id(), array('shortcut_link[link_title]' => $link->link_title->value, 'shortcut_link[link_path]' => $new_link_path), t('Save')); $saved_set = shortcut_set_load($set->id()); $paths = $this->getShortcutInformation($saved_set, 'link_path'); $this->assertTrue(in_array($new_link_path, $paths), 'Shortcut path changed: ' . $new_link_path); @@ -123,10 +123,10 @@ function testShortcutLinkDelete() { $set = $this->set; $link = reset($set->links); - $this->drupalPostForm('admin/config/user-interface/shortcut/link/' . $link->mlid . '/delete', array(), 'Delete'); + $this->drupalPostForm('admin/config/user-interface/shortcut/link/' . $link->id() . '/delete', array(), 'Delete'); $saved_set = shortcut_set_load($set->id()); $mlids = $this->getShortcutInformation($saved_set, 'mlid'); - $this->assertFalse(in_array($link->mlid, $mlids), 'Successfully deleted a shortcut.'); + $this->assertFalse(in_array($link->id(), $mlids), 'Successfully deleted a shortcut.'); // Delete all the remaining shortcut menu links. foreach (array_filter($mlids) as $mlid) { diff --git a/core/modules/system/lib/Drupal/system/Controller/SystemController.php b/core/modules/system/lib/Drupal/system/Controller/SystemController.php index 470b5bb..2469157 100644 --- a/core/modules/system/lib/Drupal/system/Controller/SystemController.php +++ b/core/modules/system/lib/Drupal/system/Controller/SystemController.php @@ -78,7 +78,7 @@ public function overview() { $system_link = reset($system_link); $query = $this->queryFactory->get('menu_link') ->condition('link_path', 'admin/help', '<>') - ->condition('menu_name', $system_link->menu_name) + ->condition('menu_name', $system_link->getMenuName()) ->condition('plid', $system_link->id()) ->condition('hidden', 0); $result = $query->execute(); @@ -93,9 +93,13 @@ public function overview() { // or customized via menu module is used as title attribute. if (!empty($item['localized_options']['attributes']['title'])) { $item['description'] = $item['localized_options']['attributes']['title']; - unset($item['localized_options']['attributes']['title']); + unset($item->localized_options->attributes['title']); } - $block = $item; + $block = array( + 'title' => $item->getLinkTitle(), + 'description' => $item['description'], + 'position' => $item['position'], + ); $block['content'] = array( '#theme' => 'admin_block_content', '#content' => $this->systemManager->getAdminBlock($item), diff --git a/core/modules/system/lib/Drupal/system/SystemManager.php b/core/modules/system/lib/Drupal/system/SystemManager.php index 619642e..5c12997 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; + $item['menu_name'] = $menu_link->menu_name->value; } 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 06fc5b0..87b89eb 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, 'original', 'Menu name is "original".'); + $this->assertEqual($menu_link->menu_name->value, '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, 'changed', 'Menu name was successfully changed after rebuild.'); + $this->assertEqual($menu_link->menu_name->value, 'changed', 'Menu name was successfully changed after rebuild.'); } /** diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index a6beabc..305e9ac 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -334,7 +334,7 @@ function theme_admin_block_content($variables) { } $output .= '