You are here

public function Taxonomy::getEntityValues in Workbench Access 8

Retrieves the access control values from an entity.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: A Drupal entity, typically a node or a user.

Return value

array An simple array of section ids from the entity being checked.

Overrides AccessControlHierarchyInterface::getEntityValues

File

src/Plugin/AccessControlHierarchy/Taxonomy.php, line 262

Class

Taxonomy
Defines a hierarchy based on a Vocabulary.

Namespace

Drupal\workbench_access\Plugin\AccessControlHierarchy

Code

public function getEntityValues(EntityInterface $entity) {
  if (!$entity instanceof ContentEntityInterface) {
    return [];
  }
  $values = [];
  foreach (array_column($this
    ->getApplicableFields($entity
    ->getEntityTypeId(), $entity
    ->bundle()), 'field') as $field) {
    foreach ($entity
      ->get($field)
      ->getValue() as $item) {
      if (isset($item['target_id'])) {
        $values[] = $item['target_id'];
      }
    }
  }
  return $values;
}