CToolsPluginDiscovery.php in Service Container 7.2
File
src/Plugin/Discovery/CToolsPluginDiscovery.php
View source
<?php
namespace Drupal\service_container\Plugin\Discovery;
use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
use Drupal\Component\Plugin\Exception\PluginNotFoundException;
class CToolsPluginDiscovery implements DiscoveryInterface {
protected $pluginOwner;
protected $pluginType;
public function __construct($plugin_manager_definition) {
$this->pluginOwner = $plugin_manager_definition['owner'];
$this->pluginType = $plugin_manager_definition['type'];
}
public function getDefinitions() {
ctools_include('plugins');
return ctools_get_plugins($this->pluginOwner, $this->pluginType);
}
public function getDefinition($plugin_id, $exception_on_invalid = TRUE) {
ctools_include('plugins');
$definition = ctools_get_plugins($this->pluginOwner, $this->pluginType, $plugin_id);
if (!$definition && $exception_on_invalid) {
throw new PluginNotFoundException($plugin_id, sprintf('The "%s" plugin does not exist.', $plugin_id));
}
return $definition;
}
public function hasDefinition($plugin_id) {
return (bool) $this
->getDefinition($plugin_id, FALSE);
}
}