Version 1
[yaffs-website] / web / modules / contrib / entityqueue / src / EntityQueueHandlerPluginCollection.php
diff --git a/web/modules/contrib/entityqueue/src/EntityQueueHandlerPluginCollection.php b/web/modules/contrib/entityqueue/src/EntityQueueHandlerPluginCollection.php
new file mode 100644 (file)
index 0000000..871552d
--- /dev/null
@@ -0,0 +1,67 @@
+<?php
+
+namespace Drupal\entityqueue;
+
+use Drupal\Component\Plugin\PluginManagerInterface;
+use Drupal\Core\Plugin\DefaultSingleLazyPluginCollection;
+
+/**
+ * Provides a container for lazily loading EntityQueueHandler plugins.
+ */
+class EntityQueueHandlerPluginCollection extends DefaultSingleLazyPluginCollection {
+
+  /**
+   * The entity queue that is using this plugin collection.
+   *
+   * @var \Drupal\entityqueue\Entity\EntityQueue
+   */
+  protected $queue;
+
+  /**
+   * Constructs a new EntityQueueHandlerPluginCollection.
+   *
+   * @param \Drupal\Component\Plugin\PluginManagerInterface $manager
+   *   The manager to be used for instantiating plugins.
+   * @param string $instance_id
+   *   The ID of the plugin instance.
+   * @param array $configuration
+   *   An array of configuration.
+   * @param \Drupal\entityqueue\EntityQueueInterface $queue
+   *   The entity queue using this plugin.
+   */
+  public function __construct(PluginManagerInterface $manager, $instance_id, array $configuration, EntityQueueInterface $queue) {
+    parent::__construct($manager, $instance_id, $configuration);
+
+    $this->queue = $queue;
+  }
+
+  /**
+   * {@inheritdoc}
+   *
+   * @return \Drupal\entityqueue\EntityQueueHandlerInterface
+   */
+  public function &get($instance_id) {
+    return parent::get($instance_id);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function initializePlugin($instance_id) {
+    parent::initializePlugin($instance_id);
+
+    $this->pluginInstances[$instance_id]->setQueue($this->queue);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function addInstanceId($id, $configuration = NULL) {
+    // @todo Open a core bug report, the parent class should take care of this..
+    $this->instanceId = $id;
+    $this->instanceIDs = array_filter($this->instanceIDs);
+
+    parent::addInstanceId($id, $configuration);
+  }
+
+}