protected function EntityReferenceHierarchy::getSiblingEntityWeights in Entity Reference Hierarchy 3.x
Same name and namespace in other branches
- 8.2 src/Plugin/Field/FieldType/EntityReferenceHierarchy.php \Drupal\entity_hierarchy\Plugin\Field\FieldType\EntityReferenceHierarchy::getSiblingEntityWeights()
Gets siblings.
Parameters
\Drupal\entity_hierarchy\Storage\NestedSetStorage $storage: Storage.
\PNX\NestedSet\Node $parentNode: Existing parent node.
\PNX\NestedSet\Node|\PNX\NestedSet\NodeKey $childNode: Child node.
Return value
\SplObjectStorage|bool Map of weights keyed by node or FALSE if no siblings.
1 call to EntityReferenceHierarchy::getSiblingEntityWeights()
- EntityReferenceHierarchy::postSave in src/
Plugin/ Field/ FieldType/ EntityReferenceHierarchy.php - Defines custom post-save behavior for field values.
File
- src/
Plugin/ Field/ FieldType/ EntityReferenceHierarchy.php, line 276
Class
- EntityReferenceHierarchy
- Plugin implementation of the 'entity_reference_hierarchy' field type.
Namespace
Drupal\entity_hierarchy\Plugin\Field\FieldTypeCode
protected function getSiblingEntityWeights(NestedSetStorage $storage, Node $parentNode, $childNode) {
if ($siblingNodes = array_filter($storage
->findChildren($parentNode
->getNodeKey()), function (Node $node) use ($childNode) {
if ($childNode instanceof NodeKey) {
// Exclude self and all revisions.
return $childNode
->getId() !== $node
->getNodeKey()
->getId();
}
// Exclude self and all revisions.
return $childNode
->getNodeKey()
->getId() !== $node
->getNodeKey()
->getId();
})) {
return $this
->loadSiblingEntityWeights($siblingNodes);
}
return FALSE;
}