diff --git a/core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php b/core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php index 266ee8e..000d50c 100644 --- a/core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php +++ b/core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php @@ -47,10 +47,10 @@ public function __construct(AccessManager $access_manager, AccountInterface $acc * Makes the resulting menu tree impossible to render cache, unless render * caching per user is acceptable. * - * @param \Drupal\Core\Menu\MenuLinkTreeElement[] $tree + * @param \Drupal\Core\Menu\MenuTreeElement[] $tree * The menu link tree to manipulate. * - * @return \Drupal\Core\Menu\MenuLinkTreeElement[] + * @return \Drupal\Core\Menu\MenuTreeElement[] * The manipulated menu link tree. */ public function checkAccess(array $tree) { @@ -98,10 +98,10 @@ protected function menuLinkCheckAccess(MenuLinkInterface $instance) { /** * Menu link tree manipulator that generates a unique index, and sorts by it. * - * @param \Drupal\Core\Menu\MenuLinkTreeElement[] $tree + * @param \Drupal\Core\Menu\MenuTreeElement[] $tree * The menu link tree to manipulate. * - * @return \Drupal\Core\Menu\MenuLinkTreeElement[] + * @return \Drupal\Core\Menu\MenuTreeElement[] * The manipulated menu link tree. */ public function generateIndexAndSort(array $tree) { @@ -125,10 +125,10 @@ public function generateIndexAndSort(array $tree) { /** * Menu link tree manipulator that flattens the tree to a single level. * - * @param \Drupal\Core\Menu\MenuLinkTreeElement[] $tree + * @param \Drupal\Core\Menu\MenuTreeElement[] $tree * The menu link tree to manipulate. * - * @return \Drupal\Core\Menu\MenuLinkTreeElement[] + * @return \Drupal\Core\Menu\MenuTreeElement[] * The manipulated menu link tree. */ public function flatten(array $tree) { @@ -144,12 +144,12 @@ public function flatten(array $tree) { /** * Menu link tree manipulator that extracts a subtree of the active trail. * - * @param \Drupal\Core\Menu\MenuLinkTreeElement[] $tree + * @param \Drupal\Core\Menu\MenuTreeElement[] $tree * The menu link tree to manipulate. * @param int $level * The level in the active trail to extract. * - * @return \Drupal\Core\Menu\MenuLinkTreeElement[] + * @return \Drupal\Core\Menu\MenuTreeElement[] * The manipulated menu link tree. */ public function extractSubtreeOfActiveTrail(array $tree, $level) { diff --git a/core/lib/Drupal/Core/Menu/MenuLinkTree.php b/core/lib/Drupal/Core/Menu/MenuLinkTree.php index 7ba6166..d8461fd 100644 --- a/core/lib/Drupal/Core/Menu/MenuLinkTree.php +++ b/core/lib/Drupal/Core/Menu/MenuLinkTree.php @@ -110,7 +110,7 @@ public function load($menu_name, MenuLinkTreeParameters $parameters) { */ protected function createInstances(&$tree) { foreach (array_keys($tree) as $id) { - // Upcast the MenuLinkTreeElement's "link" property from a definition to + // Upcast the MenuTreeElement's "link" property from a definition to // an instance. $tree[$id]->link = $this->menuLinkManager->createInstance($tree[$id]->link['id']); diff --git a/core/lib/Drupal/Core/Menu/MenuLinkTreeInterface.php b/core/lib/Drupal/Core/Menu/MenuLinkTreeInterface.php index f33a059..97958e0 100644 --- a/core/lib/Drupal/Core/Menu/MenuLinkTreeInterface.php +++ b/core/lib/Drupal/Core/Menu/MenuLinkTreeInterface.php @@ -69,7 +69,7 @@ public function getDefaultRenderedMenuTreeLinkParameters($menu_name); * @param \Drupal\Core\Menu\MenuLinkTreeParameters $parameters * The parameters to determine which menu links to be loaded into a tree. * - * @return \Drupal\Core\Menu\MenuLinkTreeElement[] + * @return \Drupal\Core\Menu\MenuTreeElement[] * A menu link tree. */ public function load($menu_name, MenuLinkTreeParameters $parameters); @@ -77,7 +77,7 @@ public function load($menu_name, MenuLinkTreeParameters $parameters); /** * Applies menu link tree manipulators to transform the given tree. * - * @param \Drupal\Core\Menu\MenuLinkTreeElement[] $tree + * @param \Drupal\Core\Menu\MenuTreeElement[] $tree * The menu tree to manipulate. * @param array $manipulators * The menu link tree manipulators to apply. Each is an array with keys: @@ -85,7 +85,7 @@ public function load($menu_name, MenuLinkTreeParameters $parameters); * by ControllerResolverInterface::getControllerFromDefinition() * - args: optional array of arguments to pass to the callable after $tree. * - * @return \Drupal\Core\Menu\MenuLinkTreeElement[] + * @return \Drupal\Core\Menu\MenuTreeElement[] * The manipulated menu link tree. */ public function transform(array $tree, array $manipulators); diff --git a/core/lib/Drupal/Core/Menu/MenuLinkTreeElement.php b/core/lib/Drupal/Core/Menu/MenuTreeElement.php similarity index 90% rename from core/lib/Drupal/Core/Menu/MenuLinkTreeElement.php rename to core/lib/Drupal/Core/Menu/MenuTreeElement.php index bbafaae..a285406 100644 --- a/core/lib/Drupal/Core/Menu/MenuLinkTreeElement.php +++ b/core/lib/Drupal/Core/Menu/MenuTreeElement.php @@ -2,7 +2,7 @@ /** * @file - * Contains \Drupal\Core\Menu\MenuLinkTreeElement. + * Contains \Drupal\Core\Menu\MenuTreeElement. */ namespace Drupal\Core\Menu; @@ -27,7 +27,7 @@ * * @see \Drupal\Core\Menu\MenuTreeStorage::loadTreeData() */ -class MenuLinkTreeElement { +class MenuTreeElement { /** * The menu link for this element in a menu link tree. @@ -42,7 +42,7 @@ class MenuLinkTreeElement { * (Children of a link are only loaded if a link is marked as "expanded" by * the query.) * - * @var \Drupal\Core\Menu\MenuLinkTreeElement[] + * @var \Drupal\Core\Menu\MenuTreeElement[] */ public $subtree; @@ -84,14 +84,14 @@ class MenuLinkTreeElement { public $options; /** - * Constructs a new MenuLinkTreeElement. + * Constructs a new MenuTreeElement. * * @param \Drupal\Core\Menu\MenuLinkInterface|array $link * The menu link for this element in the menu link tree. * @param bool $has_children * @param int $depth * @param bool $in_active_trail - * @param \Drupal\Core\Menu\MenuLinkTreeElement[] $subtree + * @param \Drupal\Core\Menu\MenuTreeElement[] $subtree * The children of this element in the menu link tree. */ public function __construct($link, $has_children, $depth, $in_active_trail, array $subtree) { @@ -111,11 +111,11 @@ public function __construct($link, $has_children, $depth, $in_active_trail, arra * Counts all menu links in the current subtree. * * @return int - * The number of menu links in this subtree (one plus the number of menu - * links in all descendants). + * The number of menu links in this subtree (one plus the number of elements + * in all descendants). */ public function count() { - $sum = function ($carry, MenuLinkTreeElement $element) { + $sum = function ($carry, MenuTreeElement $element) { return $carry + $element->count(); }; return 1 + array_reduce($this->subtree, $sum); diff --git a/core/lib/Drupal/Core/Menu/MenuTreeStorage.php b/core/lib/Drupal/Core/Menu/MenuTreeStorage.php index b9d7e27..2027fe5 100644 --- a/core/lib/Drupal/Core/Menu/MenuTreeStorage.php +++ b/core/lib/Drupal/Core/Menu/MenuTreeStorage.php @@ -1029,10 +1029,10 @@ protected function doBuildTreeData(array $links, array $parents = array(), $dept protected function treeDataRecursive(array &$links, array $parents, $depth) { $tree = array(); while ($tree_link_definition = array_pop($links)) { - // Build a MenuLinkTreeElement out of the menu link tree definition: + // Build a MenuTreeElement out of the menu link tree definition: // transform the menu link tree definition into a menu link definition and - // store tree metadata in MenuLinkTreeElement. - $tree[$tree_link_definition['id']] = new MenuLinkTreeElement( + // store tree metadata in MenuTreeElement. + $tree[$tree_link_definition['id']] = new MenuTreeElement( $this->prepareLink($tree_link_definition, TRUE), (bool) $tree_link_definition['has_children'], (int) $tree_link_definition['depth'], diff --git a/core/modules/menu_ui/src/MenuForm.php b/core/modules/menu_ui/src/MenuForm.php index 23a52ef..14e92b1 100644 --- a/core/modules/menu_ui/src/MenuForm.php +++ b/core/modules/menu_ui/src/MenuForm.php @@ -11,7 +11,7 @@ use Drupal\Core\Entity\EntityForm; use Drupal\Core\Entity\Query\QueryFactory; use Drupal\Core\Language\LanguageInterface; -use Drupal\Core\Menu\MenuLinkTreeElement; +use Drupal\Core\Menu\MenuTreeElement; use Drupal\Core\Menu\MenuLinkTreeInterface; use Drupal\Core\Menu\MenuLinkManagerInterface; use Drupal\Core\Menu\MenuLinkTreeParameters; @@ -217,7 +217,7 @@ protected function buildOverviewForm(array &$form, array &$form_state) { // Determine the delta; the number of weights to be made available. $count = function(array $tree) { - $sum = function ($carry, MenuLinkTreeElement $item) { + $sum = function ($carry, MenuTreeElement $item) { return $carry + $item->count(); }; return array_reduce($tree, $sum); diff --git a/core/modules/system/src/Tests/Menu/MenuLinkTreeTest.php b/core/modules/system/src/Tests/Menu/MenuLinkTreeTest.php index 3913cda..1e6b0bd 100644 --- a/core/modules/system/src/Tests/Menu/MenuLinkTreeTest.php +++ b/core/modules/system/src/Tests/Menu/MenuLinkTreeTest.php @@ -7,7 +7,7 @@ namespace Drupal\system\Tests\Menu; -use Drupal\Core\Menu\MenuLinkTreeElement; +use Drupal\Core\Menu\MenuTreeElement; use Drupal\Core\Menu\MenuLinkTreeParameters; use Drupal\simpletest\KernelTestBase; use Drupal\Tests\Core\Menu\MenuLinkMock; @@ -121,7 +121,7 @@ public function testCreateLinksInMenu() { $tree = $this->linkTree->load('mock', $parameters); $count = function(array $tree) { - $sum = function ($carry, MenuLinkTreeElement $item) { + $sum = function ($carry, MenuTreeElement $item) { return $carry + $item->count(); }; return array_reduce($tree, $sum); diff --git a/core/modules/toolbar/toolbar.module b/core/modules/toolbar/toolbar.module index ea1deec..9534718 100644 --- a/core/modules/toolbar/toolbar.module +++ b/core/modules/toolbar/toolbar.module @@ -429,10 +429,10 @@ function toolbar_prerender_toolbar_administration_tray(array $element) { /** * Menu link tree manipulator that adds toolbar-specific attributes. * - * @param \Drupal\Core\Menu\MenuLinkTreeElement[] $tree + * @param \Drupal\Core\Menu\MenuTreeElement[] $tree * The menu link tree to manipulate. * - * @return \Drupal\Core\Menu\MenuLinkTreeElement[] + * @return \Drupal\Core\Menu\MenuTreeElement[] * The manipulated menu link tree. */ function toolbar_menu_navigation_links(array $tree) { diff --git a/core/tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php b/core/tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php index 8962271..c4118fe 100644 --- a/core/tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php +++ b/core/tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php @@ -8,7 +8,7 @@ namespace Drupal\Tests\Core\Menu; use Drupal\Core\Menu\DefaultMenuLinkTreeManipulators; -use Drupal\Core\Menu\MenuLinkTreeElement; +use Drupal\Core\Menu\MenuTreeElement; use Drupal\Tests\UnitTestCase; /** @@ -103,17 +103,17 @@ protected function mockTree() { 8 => MenuLinkMock::create(array('id' => 'test.example8', 'route_name' => 'example8', 'title' => 'quxqux', 'parent' => '')), ); $this->originalTree = array(); - $this->originalTree[1] = new MenuLinkTreeElement($this->links[1], FALSE, 1, FALSE, array()); - $this->originalTree[2] = new MenuLinkTreeElement($this->links[2], TRUE, 1, FALSE, array( - 3 => new MenuLinkTreeElement($this->links[3], TRUE, 2, FALSE, array( - 4 => new MenuLinkTreeElement($this->links[4], FALSE, 3, FALSE, array()), + $this->originalTree[1] = new MenuTreeElement($this->links[1], FALSE, 1, FALSE, array()); + $this->originalTree[2] = new MenuTreeElement($this->links[2], TRUE, 1, FALSE, array( + 3 => new MenuTreeElement($this->links[3], TRUE, 2, FALSE, array( + 4 => new MenuTreeElement($this->links[4], FALSE, 3, FALSE, array()), )), )); - $this->originalTree[5] = new MenuLinkTreeElement($this->links[5], TRUE, 1, FALSE, array( - 7 => new MenuLinkTreeElement($this->links[7], FALSE, 2, FALSE, array()), + $this->originalTree[5] = new MenuTreeElement($this->links[5], TRUE, 1, FALSE, array( + 7 => new MenuTreeElement($this->links[7], FALSE, 2, FALSE, array()), )); - $this->originalTree[6] = new MenuLinkTreeElement($this->links[6], FALSE, 1, FALSE, array()); - $this->originalTree[8] = new MenuLinkTreeElement($this->links[8], FALSE, 1, FALSE, array()); + $this->originalTree[6] = new MenuTreeElement($this->links[6], FALSE, 1, FALSE, array()); + $this->originalTree[8] = new MenuTreeElement($this->links[8], FALSE, 1, FALSE, array()); } /** diff --git a/core/tests/Drupal/Tests/Core/Menu/MenuLinkTreeElementTest.php b/core/tests/Drupal/Tests/Core/Menu/MenuLinkTreeElementTest.php index 39cda99..705d2b7 100644 --- a/core/tests/Drupal/Tests/Core/Menu/MenuLinkTreeElementTest.php +++ b/core/tests/Drupal/Tests/Core/Menu/MenuLinkTreeElementTest.php @@ -7,7 +7,7 @@ namespace Drupal\Tests\Core\Menu; -use Drupal\Core\Menu\MenuLinkTreeElement; +use Drupal\Core\Menu\MenuTreeElement; use Drupal\Tests\UnitTestCase; /** @@ -16,7 +16,7 @@ * @group Drupal * @group Menu * - * @coversDefaultClass \Drupal\Core\Menu\MenuLinkTreeElement + * @coversDefaultClass \Drupal\Core\Menu\MenuTreeElement */ class MenuLinkTreeElementTest extends UnitTestCase { @@ -38,7 +38,7 @@ public static function getInfo() { */ public function testConstruction() { $link = array(); - $item = new MenuLinkTreeElement($link, FALSE, 3, FALSE, array()); + $item = new MenuTreeElement($link, FALSE, 3, FALSE, array()); $this->assertSame($link, $item->link); $this->assertSame(FALSE, $item->hasChildren); $this->assertSame(3, $item->depth); @@ -54,8 +54,8 @@ public function testConstruction() { public function testCount() { $link_1 = array(); $link_2 = array(); - $child_item = new MenuLinkTreeElement($link_2, FALSE, 2, FALSE, array()); - $parent_item = new MenuLinkTreeElement($link_1, FALSE, 2, FALSE, array($child_item)); + $child_item = new MenuTreeElement($link_2, FALSE, 2, FALSE, array()); + $parent_item = new MenuTreeElement($link_1, FALSE, 2, FALSE, array($child_item)); $this->assertSame(1, $child_item->count()); $this->assertSame(2, $parent_item->count()); }