abstract class PluginManagerBase in Service Container 7.2
Same name in this branch
- 7.2 src/Plugin/PluginManagerBase.php \Drupal\service_container\Plugin\PluginManagerBase
- 7.2 lib/Drupal/Component/Plugin/PluginManagerBase.php \Drupal\Component\Plugin\PluginManagerBase
Same name and namespace in other branches
- 7 src/Plugin/PluginManagerBase.php \Drupal\service_container\Plugin\PluginManagerBase
Base class for plugin managers.
Hierarchy
- class \Drupal\service_container\Plugin\PluginManagerBase implements PluginManagerInterface
Expanded class hierarchy of PluginManagerBase
File
- src/
Plugin/ PluginManagerBase.php, line 17 - Contains \Drupal\service_container\Plugin\PluginManagerBase
Namespace
Drupal\service_container\PluginView source
abstract class PluginManagerBase implements PluginManagerInterface {
/**
* The object that discovers plugins managed by this manager.
*
* @var \Drupal\Component\Plugin\Discovery\DiscoveryInterface
*/
protected $discovery;
/**
* The object that instantiates plugins managed by this manager.
*
* @var \Drupal\Component\Plugin\Factory\FactoryInterface
*/
protected $factory;
/**
* {@inheritdoc}
*/
public function getDefinition($plugin_id, $exception_on_invalid = TRUE) {
return $this->discovery
->getDefinition($plugin_id, $exception_on_invalid);
}
/**
* {@inheritdoc}
*/
public function getDefinitions() {
return $this->discovery
->getDefinitions();
}
/**
* {@inheritdoc}
*/
public function hasDefinition($plugin_id) {
return (bool) $this->discovery
->hasDefinition($plugin_id);
}
/**
* {@inheritdoc}
*/
public function createInstance($plugin_id, array $configuration = array()) {
// If this PluginManager has fallback capabilities catch
// PluginNotFoundExceptions.
if ($this instanceof FallbackPluginManagerInterface) {
try {
return $this->factory
->createInstance($plugin_id, $configuration);
} catch (PluginNotFoundException $e) {
$fallback_id = $this
->getFallbackPluginId($plugin_id, $configuration);
return $this->factory
->createInstance($fallback_id, $configuration);
}
}
else {
return $this->factory
->createInstance($plugin_id, $configuration);
}
}
/**
* {@inheritdoc}
*/
public function getInstance(array $options) {
// 90% of core does not use the generic $mapper functionality, so use a
// sane default function.
if (isset($options['id'])) {
return $this
->createInstance($options['id']);
}
return FALSE;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PluginManagerBase:: |
protected | property | The object that discovers plugins managed by this manager. | |
PluginManagerBase:: |
protected | property | The object that instantiates plugins managed by this manager. | |
PluginManagerBase:: |
public | function |
Creates a pre-configured instance of a plugin. Overrides FactoryInterface:: |
|
PluginManagerBase:: |
public | function |
Gets a specific plugin definition. Overrides DiscoveryInterface:: |
|
PluginManagerBase:: |
public | function |
Gets the definition of all plugins for this type. Overrides DiscoveryInterface:: |
|
PluginManagerBase:: |
public | function |
Gets a preconfigured instance of a plugin. Overrides MapperInterface:: |
|
PluginManagerBase:: |
public | function |
Indicates if a specific plugin definition exists. Overrides DiscoveryInterface:: |