function DevelToolbarTest::getMenuLinkInfos

Same name in other branches
  1. 8.x-1.x tests/src/Functional/DevelToolbarTest.php \Drupal\Tests\devel\Functional\DevelToolbarTest::getMenuLinkInfos()
  2. 5.x tests/src/Functional/DevelToolbarTest.php \Drupal\Tests\devel\Functional\DevelToolbarTest::getMenuLinkInfos()

Helper function for retrieve the menu link informations.

Return value

array An array containing the menu link informations.

2 calls to DevelToolbarTest::getMenuLinkInfos()
DevelToolbarTest::testConfigurationForm in tests/src/Functional/DevelToolbarTest.php
Tests configuration form.
DevelToolbarTest::testToolbarIntegration in tests/src/Functional/DevelToolbarTest.php
Tests toolbar integration.

File

tests/src/Functional/DevelToolbarTest.php, line 252

Class

DevelToolbarTest
Tests devel toolbar module functionality.

Namespace

Drupal\Tests\devel\Functional

Code

protected function getMenuLinkInfos() {
    $parameters = new MenuTreeParameters();
    $parameters->onlyEnabledLinks()
        ->setTopLevelOnly();
    $tree = \Drupal::menuTree()->load('devel', $parameters);
    $links = [];
    foreach ($tree as $element) {
        $links[] = [
            'id' => $element->link
                ->getPluginId(),
            'title' => $element->link
                ->getTitle(),
            'url' => $element->link
                ->getUrlObject()
                ->toString(),
        ];
    }
    return $links;
}