public function EntityTreeNodeMapper::loadEntitiesForTreeNodesWithoutAccessChecks in Entity Reference Hierarchy 3.x
Same name and namespace in other branches
- 8.2 src/Storage/EntityTreeNodeMapper.php \Drupal\entity_hierarchy\Storage\EntityTreeNodeMapper::loadEntitiesForTreeNodesWithoutAccessChecks()
Loads Drupal entities for given tree nodes.
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::loadEntitiesForTreeNodesWithoutAccessChecks
1 call to EntityTreeNodeMapper::loadEntitiesForTreeNodesWithoutAccessChecks()
- EntityTreeNodeMapper::loadAndAccessCheckEntitysForTreeNodes in src/
Storage/ EntityTreeNodeMapper.php - Loads Drupal entities for given tree nodes and checks access.
File
- src/
Storage/ EntityTreeNodeMapper.php, line 34
Class
- EntityTreeNodeMapper
- Takes an array of tree nodes & returns matching entities, keyed by tree node.
Namespace
Drupal\entity_hierarchy\StorageCode
public function loadEntitiesForTreeNodesWithoutAccessChecks($entity_type_id, array $nodes, RefinableCacheableDependencyInterface $cache = NULL) {
$entities = $this->entityTypeManager
->getStorage($entity_type_id)
->loadMultiple(array_map(function (Node $node) {
return $node
->getId();
}, $nodes));
$loadedEntities = new \SplObjectStorage();
foreach ($nodes as $node) {
$nodeId = $node
->getId();
$entity = isset($entities[$nodeId]) ? $entities[$nodeId] : FALSE;
if (!$entity || $entity
->getEntityType()
->hasKey('revision') && $node
->getRevisionId() != $entity
->getRevisionId()) {
// Bypass non default revisions and deleted items.
continue;
}
$loadedEntities[$node] = $entity;
if ($cache) {
$cache
->addCacheableDependency($entity);
}
}
return $loadedEntities;
}