diff core/lib/Drupal/Component/Plugin/Discovery/DiscoveryInterface.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children 129ea1e6d783
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryInterface.php	Wed Nov 29 16:09:58 2017 +0000
@@ -0,0 +1,50 @@
+<?php
+
+namespace Drupal\Component\Plugin\Discovery;
+
+/**
+ * An interface defining the minimum requirements of building a plugin
+ * discovery component.
+ *
+ * @ingroup plugin_api
+ */
+interface DiscoveryInterface {
+
+  /**
+   * Gets a specific plugin definition.
+   *
+   * @param string $plugin_id
+   *   A plugin id.
+   * @param bool $exception_on_invalid
+   *   (optional) If TRUE, an invalid plugin ID will throw an exception.
+   *
+   * @return mixed
+   *   A plugin definition, or NULL if the plugin ID is invalid and
+   *   $exception_on_invalid is FALSE.
+   *
+   * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
+   *   Thrown if $plugin_id is invalid and $exception_on_invalid is TRUE.
+   */
+  public function getDefinition($plugin_id, $exception_on_invalid = TRUE);
+
+  /**
+   * Gets the definition of all plugins for this type.
+   *
+   * @return mixed[]
+   *   An array of plugin definitions (empty array if no definitions were
+   *   found). Keys are plugin IDs.
+   */
+  public function getDefinitions();
+
+  /**
+   * Indicates if a specific plugin definition exists.
+   *
+   * @param string $plugin_id
+   *   A plugin ID.
+   *
+   * @return bool
+   *   TRUE if the definition exists, FALSE otherwise.
+   */
+  public function hasDefinition($plugin_id);
+
+}