You are here

function ShortcutTestBase::getShortcutInformation in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/shortcut/src/Tests/ShortcutTestBase.php \Drupal\shortcut\Tests\ShortcutTestBase::getShortcutInformation()

Extracts information from shortcut set links.

Parameters

\Drupal\shortcut\ShortcutSetInterface $set: The shortcut set object to extract information from.

string $key: The array key indicating what information to extract from each link:

  • 'title': Extract shortcut titles.
  • 'link': Extract shortcut paths.
  • 'id': Extract the shortcut ID.

Return value

array Array of the requested information from each link.

4 calls to ShortcutTestBase::getShortcutInformation()
ShortcutLinksTest::testShortcutLinkAdd in core/modules/shortcut/src/Tests/ShortcutLinksTest.php
Tests that creating a shortcut works properly.
ShortcutLinksTest::testShortcutLinkChangePath in core/modules/shortcut/src/Tests/ShortcutLinksTest.php
Tests that changing the path of a shortcut link works.
ShortcutLinksTest::testShortcutLinkDelete in core/modules/shortcut/src/Tests/ShortcutLinksTest.php
Tests deleting a shortcut link.
ShortcutLinksTest::testShortcutLinkRename in core/modules/shortcut/src/Tests/ShortcutLinksTest.php
Tests that shortcut links can be renamed.

File

core/modules/shortcut/src/Tests/ShortcutTestBase.php, line 124
Contains \Drupal\shortcut\Tests\ShortcutTestBase.

Class

ShortcutTestBase
Defines base class for shortcut test cases.

Namespace

Drupal\shortcut\Tests

Code

function getShortcutInformation(ShortcutSetInterface $set, $key) {
  $info = array();
  \Drupal::entityManager()
    ->getStorage('shortcut')
    ->resetCache();
  foreach ($set
    ->getShortcuts() as $shortcut) {
    if ($key == 'link') {
      $info[] = $shortcut->link->uri;
    }
    else {
      $info[] = $shortcut->{$key}->value;
    }
  }
  return $info;
}