Version 1
[yaffs-website] / web / core / tests / Drupal / Tests / Core / Plugin / Discovery / TestDerivativeDiscoveryWithObject.php
diff --git a/web/core/tests/Drupal/Tests/Core/Plugin/Discovery/TestDerivativeDiscoveryWithObject.php b/web/core/tests/Drupal/Tests/Core/Plugin/Discovery/TestDerivativeDiscoveryWithObject.php
new file mode 100644 (file)
index 0000000..353b21d
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+
+namespace Drupal\Tests\Core\Plugin\Discovery;
+
+use Drupal\Component\Plugin\Derivative\DeriverInterface;
+
+/**
+ * Defines test derivative discovery using an object..
+ */
+class TestDerivativeDiscoveryWithObject implements DeriverInterface {
+
+  /**
+   * {@inheritdoc}
+   * @param string $derivative_id
+   * @param array $base_plugin_definition
+   * @return array
+   */
+  public function getDerivativeDefinition($derivative_id, $base_plugin_definition) {
+    $definitions = $this->getDerivativeDefinitions($base_plugin_definition);
+    return $definitions[$derivative_id];
+  }
+
+  /**
+   * {@inheritdoc}
+   * @param array $base_plugin_definition
+   * @return array
+   */
+  public function getDerivativeDefinitions($base_plugin_definition) {
+    $plugins = [];
+    for ($i = 0; $i < 2; $i++) {
+      $plugins['test_discovery_' . $i] = $base_plugin_definition;
+    }
+    return $plugins;
+  }
+
+}