class YamlDiscovery in Plug 7
Same name in this branch
- 7 lib/Drupal/Component/Discovery/YamlDiscovery.php \Drupal\Component\Discovery\YamlDiscovery
- 7 lib/Drupal/Core/Plugin/Discovery/YamlDiscovery.php \Drupal\Core\Plugin\Discovery\YamlDiscovery
Allows YAML files to define plugin definitions.
Hierarchy
- class \Drupal\Core\Plugin\Discovery\YamlDiscovery implements DiscoveryInterface uses DiscoveryTrait
Expanded class hierarchy of YamlDiscovery
1 file declares its use of YamlDiscovery
- FruitPluginManager.php in modules/plug_example/ src/ FruitPluginManager.php 
- Contains \Drupal\plug_example\FruitPluginManager.
File
- lib/Drupal/ Core/ Plugin/ Discovery/ YamlDiscovery.php, line 17 
- Contains \Drupal\Core\Plugin\Discovery\YamlDiscovery.
Namespace
Drupal\Core\Plugin\DiscoveryView source
class YamlDiscovery implements DiscoveryInterface {
  use DiscoveryTrait;
  /**
   * YAML file discovery and parsing handler.
   *
   * @var \Drupal\Component\Discovery\YamlDiscovery
   */
  protected $discovery;
  /**
   * Construct a YamlDiscovery object.
   *
   * @param string $name
   *   The file name suffix to use for discovery. E.g. 'test' will become
   *   'MODULE.test.yml'.
   * @param array $directories
   *   An array of directories to scan.
   */
  function __construct($name, array $directories) {
    $this->discovery = new ComponentYamlDiscovery($name, $directories);
  }
  /**
   * {@inheritdoc}
   */
  public function getDefinitions() {
    $plugins = $this->discovery
      ->findAll();
    // Flatten definitions into what's expected from plugins.
    $definitions = array();
    foreach ($plugins as $provider => $list) {
      foreach ($list as $id => $definition) {
        $definitions[$id] = $definition + array(
          'provider' => $provider,
          'id' => $id,
        );
      }
    }
    return $definitions;
  }
}Members
| Name   | Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| DiscoveryTrait:: | protected | function | Gets a specific plugin definition. | |
| DiscoveryTrait:: | public | function | 3 | |
| DiscoveryTrait:: | public | function | ||
| YamlDiscovery:: | protected | property | YAML file discovery and parsing handler. | |
| YamlDiscovery:: | public | function | Gets the definition of all plugins for this type. Overrides DiscoveryTrait:: | 1 | 
| YamlDiscovery:: | function | Construct a YamlDiscovery object. | 1 | 
