Browse Source

No longer double negating conditions (#763)

pull/765/head
dannylamb 5 years ago committed by GitHub
parent
commit
c89ff9f16d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/Plugin/Condition/EntityBundle.php
  2. 2
      src/Plugin/Condition/MediaHasMimetype.php
  3. 4
      src/Plugin/Condition/NodeHadNamespace.php
  4. 3
      src/Plugin/Condition/NodeHasParent.php
  5. 9
      src/Plugin/Condition/NodeIsPublished.php

4
src/Plugin/Condition/EntityBundle.php

@ -61,11 +61,11 @@ class EntityBundle extends ConditionPluginBase {
if ($context->hasContextValue()) { if ($context->hasContextValue()) {
$entity = $context->getContextValue(); $entity = $context->getContextValue();
if (!empty($this->configuration['bundles'][$entity->bundle()])) { if (!empty($this->configuration['bundles'][$entity->bundle()])) {
return !$this->isNegated(); return TRUE;
} }
} }
} }
return $this->isNegated(); return FALSE;
} }
/** /**

2
src/Plugin/Condition/MediaHasMimetype.php

@ -152,7 +152,7 @@ class MediaHasMimetype extends ConditionPluginBase implements ContainerFactoryPl
foreach ($media as $medium) { foreach ($media as $medium) {
$file = $this->mediaSource->getSourceFile($medium); $file = $this->mediaSource->getSourceFile($medium);
if (in_array($file->getMimeType(), $mimetypes)) { if (in_array($file->getMimeType(), $mimetypes)) {
return $this->isNegated() ? FALSE : TRUE; return TRUE;
} }
} }
} }

4
src/Plugin/Condition/NodeHadNamespace.php

@ -154,12 +154,12 @@ class NodeHadNamespace extends ConditionPluginBase implements ContainerFactoryPl
foreach ($registered_namespaces as &$registered_namespace) { foreach ($registered_namespaces as &$registered_namespace) {
$registered_namespace = trim($registered_namespace); $registered_namespace = trim($registered_namespace);
if (in_array($namespace, $registered_namespaces)) { if (in_array($namespace, $registered_namespaces)) {
return $this->isNegated() ? FALSE : TRUE; return TRUE;
} }
} }
} }
return $this->isNegated() ? TRUE : FALSE; return FALSE;
} }
/** /**

3
src/Plugin/Condition/NodeHasParent.php

@ -145,12 +145,13 @@ class NodeHasParent extends ConditionPluginBase implements ContainerFactoryPlugi
$nids = $field->getValue(); $nids = $field->getValue();
foreach ($nids as $nid) { foreach ($nids as $nid) {
if ($nid['target_id'] == $this->configuration['parent_nid']) { if ($nid['target_id'] == $this->configuration['parent_nid']) {
return $this->isNegated() ? FALSE : TRUE; return TRUE;
} }
} }
} }
} }
} }
return FALSE;
} }
/** /**

9
src/Plugin/Condition/NodeIsPublished.php

@ -72,11 +72,12 @@ class NodeIsPublished extends ConditionPluginBase implements ContainerFactoryPlu
if (!$node && !$this->isNegated()) { if (!$node && !$this->isNegated()) {
return FALSE; return FALSE;
} }
if ($node->isPublished() && !$this->isNegated()) { elseif (!$node) {
return TRUE; return FALSE;
}
else {
return $node->isPublished();
} }
return FALSE;
} }
/** /**

Loading…
Cancel
Save