You are here

protected function EntityHooks::getMicrositesForNodeAndField in Entity Reference Hierarchy 3.x

Same name and namespace in other branches
  1. 8.2 modules/entity_hierarchy_microsite/src/EntityHooks.php \Drupal\entity_hierarchy_microsite\EntityHooks::getMicrositesForNodeAndField()

Gets the possible microsites for a particular field and node.

Parameters

\Drupal\node\NodeInterface $node: Node.

string $field: Field name.

Return value

\Drupal\entity_hierarchy_microsite\Entity\MicrositeInterface[] Microsites the node belongs to with the given field.

2 calls to EntityHooks::getMicrositesForNodeAndField()
EntityHooks::onNodeDelete in modules/entity_hierarchy_microsite/src/EntityHooks.php
React to node delete.
EntityHooks::onNodeInsert in modules/entity_hierarchy_microsite/src/EntityHooks.php
React to node insert.

File

modules/entity_hierarchy_microsite/src/EntityHooks.php, line 122

Class

EntityHooks
Defines a class for entity hooks for the module.

Namespace

Drupal\entity_hierarchy_microsite

Code

protected function getMicrositesForNodeAndField(NodeInterface $node, string $field) : array {
  if (!$node
    ->hasField($field)) {
    return [];
  }
  if ($node
    ->get($field)
    ->isEmpty()) {
    return [];
  }
  return $this->childOfMicrositeLookup
    ->findMicrositesForNodeAndField($node, $field);
}