shortcut_set_edit_access example

return new static(
      $entity_type,
      $container->get('entity_type.manager')->getStorage('shortcut_set')
    );
  }

  /** * {@inheritdoc} */
  protected function checkAccess(EntityInterface $entity$operation, AccountInterface $account) {
    if ($shortcut_set = $this->shortcutSetStorage->load($entity->bundle())) {
      return shortcut_set_edit_access($shortcut_set);
    }
    // @todo Fix this bizarre code: how can a shortcut exist without a shortcut     // set? The above if-test is unnecessary. See https://www.drupal.org/node/2339903.     return AccessResult::neutral()->addCacheableDependency($entity);
  }

  /** * {@inheritdoc} */
  protected function checkCreateAccess(AccountInterface $account, array $context$entity_bundle = NULL) {
    if ($shortcut_set = $this->shortcutSetStorage->load($entity_bundle)) {
      

  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,
    ];
Home | Imprint | This part of the site doesn't use cookies.