class ShortcutLazyBuilders in Drupal 8
Same name and namespace in other branches
- 9 core/modules/shortcut/src/ShortcutLazyBuilders.php \Drupal\shortcut\ShortcutLazyBuilders
- 10 core/modules/shortcut/src/ShortcutLazyBuilders.php \Drupal\shortcut\ShortcutLazyBuilders
Lazy builders for the shortcut module.
Hierarchy
- class \Drupal\shortcut\ShortcutLazyBuilders implements TrustedCallbackInterface
Expanded class hierarchy of ShortcutLazyBuilders
1 string reference to 'ShortcutLazyBuilders'
- shortcut.services.yml in core/
modules/ shortcut/ shortcut.services.yml - core/modules/shortcut/shortcut.services.yml
1 service uses ShortcutLazyBuilders
- shortcut.lazy_builders in core/
modules/ shortcut/ shortcut.services.yml - Drupal\shortcut\ShortcutLazyBuilders
File
- core/
modules/ shortcut/ src/ ShortcutLazyBuilders.php, line 12
Namespace
Drupal\shortcutView source
class ShortcutLazyBuilders implements TrustedCallbackInterface {
/**
* The renderer service.
*
* @var \Drupal\Core\Render\RendererInterface
*/
protected $renderer;
/**
* Constructs a new ShortcutLazyBuilders object.
*
* @param \Drupal\Core\Render\RendererInterface $renderer
* The renderer service.
*/
public function __construct(RendererInterface $renderer) {
$this->renderer = $renderer;
}
/**
* {@inheritdoc}
*/
public static function trustedCallbacks() {
return [
'lazyLinks',
];
}
/**
* #lazy_builder callback; builds shortcut toolbar links.
*
* @return array
* A renderable array of shortcut links.
*/
public function lazyLinks() {
$shortcut_set = shortcut_current_displayed_set();
$links = shortcut_renderable_links();
$configure_link = NULL;
if (shortcut_set_edit_access($shortcut_set)
->isAllowed()) {
$configure_link = [
'#type' => 'link',
'#title' => t('Edit shortcuts'),
'#url' => Url::fromRoute('entity.shortcut_set.customize_form', [
'shortcut_set' => $shortcut_set
->id(),
]),
'#options' => [
'attributes' => [
'class' => [
'edit-shortcuts',
],
],
],
];
}
$build = [
'shortcuts' => $links,
'configure' => $configure_link,
];
$this->renderer
->addCacheableDependency($build, $shortcut_set);
return $build;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ShortcutLazyBuilders:: |
protected | property | The renderer service. | |
ShortcutLazyBuilders:: |
public | function | #lazy_builder callback; builds shortcut toolbar links. | |
ShortcutLazyBuilders:: |
public static | function |
Lists the trusted callbacks provided by the implementing class. Overrides TrustedCallbackInterface:: |
|
ShortcutLazyBuilders:: |
public | function | Constructs a new ShortcutLazyBuilders object. | |
TrustedCallbackInterface:: |
constant | Untrusted callbacks throw exceptions. | ||
TrustedCallbackInterface:: |
constant | Untrusted callbacks trigger silenced E_USER_DEPRECATION errors. | ||
TrustedCallbackInterface:: |
constant | Untrusted callbacks trigger E_USER_WARNING errors. |