PluginManagerBase.php in Service Container 7
File
src/Plugin/PluginManagerBase.php
View source
<?php
namespace Drupal\service_container\Plugin;
use Drupal\Component\Plugin\Exception\PluginNotFoundException;
use Drupal\Component\Plugin\FallbackPluginManagerInterface;
use Drupal\Component\Plugin\PluginManagerInterface;
abstract class PluginManagerBase implements PluginManagerInterface {
protected $discovery;
protected $factory;
public function getDefinition($plugin_id, $exception_on_invalid = TRUE) {
return $this->discovery
->getDefinition($plugin_id, $exception_on_invalid);
}
public function getDefinitions() {
return $this->discovery
->getDefinitions();
}
public function hasDefinition($plugin_id) {
return (bool) $this->discovery
->hasDefinition($plugin_id);
}
public function createInstance($plugin_id, array $configuration = array()) {
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);
}
}
public function getInstance(array $options) {
if (isset($options['id'])) {
return $this
->createInstance($options['id']);
}
return FALSE;
}
}