Further modules included.
[yaffs-website] / web / modules / contrib / drupalmoduleupgrader / src / Plugin / DMU / Fixer / NodeCollectorTrait.php
diff --git a/web/modules/contrib/drupalmoduleupgrader/src/Plugin/DMU/Fixer/NodeCollectorTrait.php b/web/modules/contrib/drupalmoduleupgrader/src/Plugin/DMU/Fixer/NodeCollectorTrait.php
new file mode 100644 (file)
index 0000000..7ae15b0
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\drupalmoduleupgrader\Plugin\DMU\Fixer\NodeCollectorTrait.
+ */
+
+namespace Drupal\drupalmoduleupgrader\Plugin\DMU\Fixer;
+
+/**
+ * Trait used by fixers which loop through existing indexer objects and do
+ * things with them.
+ */
+trait NodeCollectorTrait {
+
+  protected function getObjects() {
+    /** @var \Pharborist\NodeCollection $objects */
+    $objects = $this->target->getIndexer($this->configuration['type'])->get($this->configuration['id']);
+
+    if (isset($this->configuration['where'])) {
+      $where = $this->configuration['where'];
+      // If the first character of the filter is an exclamation point, negate it.
+      return ($where{0} == '!' ? $objects->not(subStr($where, 1)) : $objects->filter($where));
+    }
+    else {
+      return $objects;
+    }
+  }
+
+}