You are here

VocabularyListBuilder.php in Vocabulary Permissions Per Role 8

Namespace

Drupal\vppr

File

src/VocabularyListBuilder.php
View source
<?php

namespace Drupal\vppr;

use Drupal\taxonomy\VocabularyListBuilder as VocabularyListBuilderBase;

/**
 * Class VocabularyListBuilder.
 *
 * @package Drupal\vppr
 */
class VocabularyListBuilder extends VocabularyListBuilderBase {

  /**
   * Override Drupal\Core\Config\Entity\ConfigEntityListBuilder::load().
   */
  public function load() {
    $entities = parent::load();

    // Remove vocabularies the current user doesn't have any access for.
    foreach ($entities as $id => $entity) {
      if (!vppr_access('list terms', $id)) {
        unset($entities[$id]);
      }
    }
    return $entities;
  }

}

Classes

Namesort descending Description
VocabularyListBuilder Class VocabularyListBuilder.