Provides a container for lazily loading Action plugins.
Expanded class hierarchy of ActionBag
class ActionBag extends PluginBag {
/**
* The manager used to instantiate the plugins.
*
* @var \Drupal\Component\Plugin\PluginManagerInterface
*/
protected $manager;
/**
* Constructs a new ActionBag object.
*
* @param \Drupal\Component\Plugin\PluginManagerInterface $manager
* The manager to be used for instantiating plugins.
* @param array $instance_ids
* The ids of the plugin instances with which we are dealing.
* @param array $configuration
* An array of configuration.
*/
public function __construct(PluginManagerInterface $manager, array $instance_ids, array $configuration) {
$this->manager = $manager;
$this->instanceIDs = drupal_map_assoc($instance_ids);
$this->configuration = $configuration;
}
/**
* {@inheritdoc}
*/
protected function initializePlugin($instance_id) {
if (isset($this->pluginInstances[$instance_id])) {
return;
}
$this->pluginInstances[$instance_id] = $this->manager
->createInstance($instance_id, $this->configuration);
}
}
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ActionBag:: |
protected | property | The manager used to instantiate the plugins. | |
ActionBag:: |
protected | function |
Initializes a plugin and stores the result in $this->pluginInstances. Overrides PluginBag:: |
|
ActionBag:: |
public | function | Constructs a new ActionBag object. | |
PluginBag:: |
protected | property | Stores the IDs of all potential plugin instances. | |
PluginBag:: |
protected | property | Stores all instantiated plugins. | |
PluginBag:: |
public | function | Adds an instance ID to the array of available instance IDs. | |
PluginBag:: |
public | function | Clears all instantiated plugins. | 1 |
PluginBag:: |
public | function | Implements \Countable::count(). | |
PluginBag:: |
public | function | Implements \Iterator::current(). | |
PluginBag:: |
public | function | Retrieves a plugin instance, initializing it if necessary. | |
PluginBag:: |
public | function | Returns all instance IDs. | |
PluginBag:: |
public | function | Determines if a plugin instance exists. | |
PluginBag:: |
public | function | Implements \Iterator::key(). | |
PluginBag:: |
public | function | Implements \Iterator::next(). | |
PluginBag:: |
public | function | Removes an initialized plugin. | 1 |
PluginBag:: |
public | function | Implements \Iterator::rewind(). | |
PluginBag:: |
public | function | Stores an initialized plugin. | |
PluginBag:: |
public | function | Sets the instance IDs property. | |
PluginBag:: |
public | function | Implements \Iterator::valid(). |