function ShortcutTestBase::getShortcutInformation
Same name in this branch
- 8.9.x core/modules/shortcut/tests/src/Functional/ShortcutTestBase.php \Drupal\Tests\shortcut\Functional\ShortcutTestBase::getShortcutInformation()
Same name in other branches
- 9 core/modules/shortcut/tests/src/Functional/ShortcutTestBase.php \Drupal\Tests\shortcut\Functional\ShortcutTestBase::getShortcutInformation()
- 10 core/modules/shortcut/tests/src/Functional/ShortcutTestBase.php \Drupal\Tests\shortcut\Functional\ShortcutTestBase::getShortcutInformation()
- 11.x core/modules/shortcut/tests/src/Functional/ShortcutTestBase.php \Drupal\Tests\shortcut\Functional\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.
File
-
core/
modules/ shortcut/ src/ Tests/ ShortcutTestBase.php, line 126
Class
- ShortcutTestBase
- Defines base class for shortcut test cases.
Namespace
Drupal\shortcut\TestsCode
public function getShortcutInformation(ShortcutSetInterface $set, $key) {
$info = [];
\Drupal::entityTypeManager()->getStorage('shortcut')
->resetCache();
foreach ($set->getShortcuts() as $shortcut) {
if ($key == 'link') {
$info[] = $shortcut->link->uri;
}
else {
$info[] = $shortcut->{$key}->value;
}
}
return $info;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.