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 e6c9de1..d45e7d5 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 @@ -72,102 +72,6 @@ class MenuLink extends EntityNG implements \ArrayAccess, MenuLinkInterface { protected $oldRouterItem = array(); /** - * Properties of the old routing system. - * - * @todo Remove when we rip out the old routing system. - * - * @var int - */ - public $customized = 0; - - /** - * The first entity ID in the materialized path. - * - * @var int - * - * @todo Investigate whether the p1, p2, .. pX properties can be moved to a - * single array property. - */ - public $p1; - - /** - * The second entity ID in the materialized path. - * - * @var int - */ - public $p2; - - /** - * The third entity ID in the materialized path. - * - * @var int - */ - public $p3; - - /** - * The fourth entity ID in the materialized path. - * - * @var int - */ - public $p4; - - /** - * The fifth entity ID in the materialized path. - * - * @var int - */ - public $p5; - - /** - * The sixth entity ID in the materialized path. - * - * @var int - */ - public $p6; - - /** - * The seventh entity ID in the materialized path. - * - * @var int - */ - public $p7; - - /** - * The eighth entity ID in the materialized path. - * - * @var int - */ - public $p8; - - /** - * The ninth entity ID in the materialized path. - * - * @var int - */ - public $p9; - - /** - * The menu link modification timestamp. - * - * @var int - */ - public $updated = 0; - - /** - * The name of the route associated with this menu link, if any. - * - * @var string - */ - public $route_name; - - /** - * The parameters of the route associated with this menu link, if any. - * - * @var array - */ - public $route_parameters; - - /** * The route object associated with this menu link, if any. * * @var \Symfony\Component\Routing\Route @@ -770,4 +674,208 @@ public function setRouteName($route_name) { return $this; } + /** + * {@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; + } + } 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 8c43af8..6d9685c 100644 --- a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php +++ b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php @@ -446,203 +446,4 @@ public function getParentFromHierarchy(EntityInterface $entity) { return $parent; } - /** - * {@inheritdoc} - */ - public function baseFieldDefinitions() { - $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', - ); - - // @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; - } - }