Browse Source

check that the underlying entity has the parent reference field before trying to get() it (#979)

Co-authored-by: Willow Gillingham <willow@born-digital.com>
master
Willow Gillingham 1 year ago committed by GitHub
parent
commit
988a1d989a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/Plugin/Condition/NodeHasParent.php

4
src/Plugin/Condition/NodeHasParent.php

@ -137,9 +137,9 @@ class NodeHasParent extends ConditionPluginBase implements ContainerFactoryPlugi
* TRUE if entity references the specified parent.
*/
protected function evaluateEntity(EntityInterface $entity) {
$parent_reference_field = $this->configuration['parent_reference_field'];
foreach ($entity->referencedEntities() as $referenced_entity) {
if ($entity->getEntityTypeID() == 'node' && $referenced_entity->getEntityTypeId() == 'node') {
$parent_reference_field = $this->configuration['parent_reference_field'];
if ($entity->getEntityTypeID() == 'node' && $referenced_entity->getEntityTypeId() == 'node' && $entity->hasField($parent_reference_field)) {
$field = $entity->get($parent_reference_field);
if (!$field->isEmpty()) {
$nids = $field->getValue();

Loading…
Cancel
Save