public function EntityTreeNodeMapper::loadAndAccessCheckEntitysForTreeNodes in Entity Reference Hierarchy 3.x
Same name and namespace in other branches
- 8.2 src/Storage/EntityTreeNodeMapper.php \Drupal\entity_hierarchy\Storage\EntityTreeNodeMapper::loadAndAccessCheckEntitysForTreeNodes()
Loads Drupal entities for given tree nodes and checks access.
Parameters
string $entity_type_id: Entity Type ID.
\PNX\NestedSet\Node[] $nodes: Tree node to load entity for.
\Drupal\Core\Cache\RefinableCacheableDependencyInterface $cache: (optional) Cache metadata.
Return value
\SplObjectStorage Map of entities keyed by node.
Overrides EntityTreeNodeMapperInterface::loadAndAccessCheckEntitysForTreeNodes
File
- src/
Storage/ EntityTreeNodeMapper.php, line 57
Class
- EntityTreeNodeMapper
- Takes an array of tree nodes & returns matching entities, keyed by tree node.
Namespace
Drupal\entity_hierarchy\StorageCode
public function loadAndAccessCheckEntitysForTreeNodes($entity_type_id, array $nodes, RefinableCacheableDependencyInterface $cache = NULL) {
$entities = $this
->loadEntitiesForTreeNodesWithoutAccessChecks($entity_type_id, $nodes, $cache);
foreach ($nodes as $node) {
if (!$entities
->offsetExists($node)) {
continue;
}
if (($entity = $entities
->offsetGet($node)) && !$entity
->access('view label')) {
// Check access.
$entities
->offsetUnset($node);
}
}
return $entities;
}