ConditionManager::createInstance

public ConditionManager::createInstance($plugin_id, array $configuration = array())

Creates a pre-configured instance of a plugin.

Parameters

string $plugin_id: The ID of the plugin being instantiated.

array $configuration: An array of configuration relevant to the plugin instance.

Return value

object A fully configured plugin instance.

Throws

\Drupal\Component\Plugin\Exception\PluginException If the instance cannot be created, such as if the ID is invalid.

Overrides PluginManagerBase::createInstance

File

core/lib/Drupal/Core/Condition/ConditionManager.php, line 49

Class

ConditionManager
A plugin manager for condition plugins.

Namespace

Drupal\Core\Condition

Code

public function createInstance($plugin_id, array $configuration = array()) {
  $plugin = $this->getFactory()->createInstance($plugin_id, $configuration);

  // If we receive any context values via config set it into the plugin.
  if (!empty($configuration['context'])) {
    foreach ($configuration['context'] as $name => $context) {
      $plugin->setContextValue($name, $context);
    }
  }

  return $plugin->setExecutableManager($this);
}
doc_Drupal
2016-10-29 08:52:04
Comments
Leave a Comment

Please login to continue.