Skip to content

Commit

Permalink
No longer double negating conditions (#763)
Browse files Browse the repository at this point in the history
  • Loading branch information
dannylamb authored Mar 12, 2020
1 parent 2a1024c commit c89ff9f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/Plugin/Condition/EntityBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ public function evaluate() {
if ($context->hasContextValue()) {
$entity = $context->getContextValue();
if (!empty($this->configuration['bundles'][$entity->bundle()])) {
return !$this->isNegated();
return TRUE;
}
}
}
return $this->isNegated();
return FALSE;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Plugin/Condition/MediaHasMimetype.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public function evaluate() {
foreach ($media as $medium) {
$file = $this->mediaSource->getSourceFile($medium);
if (in_array($file->getMimeType(), $mimetypes)) {
return $this->isNegated() ? FALSE : TRUE;
return TRUE;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Plugin/Condition/NodeHadNamespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,12 @@ protected function evaluateEntity(EntityInterface $entity) {
foreach ($registered_namespaces as &$registered_namespace) {
$registered_namespace = trim($registered_namespace);
if (in_array($namespace, $registered_namespaces)) {
return $this->isNegated() ? FALSE : TRUE;
return TRUE;
}
}
}

return $this->isNegated() ? TRUE : FALSE;
return FALSE;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/Plugin/Condition/NodeHasParent.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,13 @@ protected function evaluateEntity(EntityInterface $entity) {
$nids = $field->getValue();
foreach ($nids as $nid) {
if ($nid['target_id'] == $this->configuration['parent_nid']) {
return $this->isNegated() ? FALSE : TRUE;
return TRUE;
}
}
}
}
}
return FALSE;
}

/**
Expand Down
9 changes: 5 additions & 4 deletions src/Plugin/Condition/NodeIsPublished.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,12 @@ public function evaluate() {
if (!$node && !$this->isNegated()) {
return FALSE;
}
if ($node->isPublished() && !$this->isNegated()) {
return TRUE;
elseif (!$node) {
return FALSE;
}
else {
return $node->isPublished();
}

return FALSE;
}

/**
Expand Down

0 comments on commit c89ff9f

Please sign in to comment.