ShortcutsBlock.php

Same filename in other branches
  1. 9 core/modules/shortcut/src/Plugin/Block/ShortcutsBlock.php
  2. 8.9.x core/modules/shortcut/src/Plugin/Block/ShortcutsBlock.php
  3. 11.x core/modules/shortcut/src/Plugin/Block/ShortcutsBlock.php

Namespace

Drupal\shortcut\Plugin\Block

File

core/modules/shortcut/src/Plugin/Block/ShortcutsBlock.php

View source
<?php

namespace Drupal\shortcut\Plugin\Block;

use Drupal\Core\Access\AccessResult;
use Drupal\Core\Block\Attribute\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;

/**
 * Provides a 'Shortcut' block.
 */
class ShortcutsBlock extends BlockBase {
    
    /**
     * {@inheritdoc}
     */
    public function build() {
        return [
            '#lazy_builder' => [
                'shortcut.lazy_builders:lazyLinks',
                [
                    FALSE,
                ],
            ],
            '#create_placeholder' => TRUE,
            '#cache' => [
                'keys' => [
                    'shortcut_set_block_links',
                ],
                'contexts' => [
                    'user',
                ],
            ],
        ];
    }
    
    /**
     * {@inheritdoc}
     */
    protected function blockAccess(AccountInterface $account) {
        return AccessResult::allowedIfHasPermission($account, 'access shortcuts');
    }

}

Classes

Title Deprecated Summary
ShortcutsBlock Provides a 'Shortcut' block.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.