Same name and namespace in other branches
  1. 8.9.x core/lib/Drupal/Core/Condition/ConditionManager.php \Drupal\Core\Condition\ConditionManager
  2. 9 core/lib/Drupal/Core/Condition/ConditionManager.php \Drupal\Core\Condition\ConditionManager

A plugin manager for condition plugins.

Hierarchy

Expanded class hierarchy of ConditionManager

See also

\Drupal\Core\Condition\Attribute\Condition

\Drupal\Core\Condition\ConditionInterface

\Drupal\Core\Condition\ConditionPluginBase

Related topics

1 file declares its use of ConditionManager
FormController.php in core/modules/system/tests/modules/condition_test/src/FormController.php
1 string reference to 'ConditionManager'
core.services.yml in core/core.services.yml
core/core.services.yml
1 service uses ConditionManager
plugin.manager.condition in core/core.services.yml
Drupal\Core\Condition\ConditionManager

File

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

Namespace

Drupal\Core\Condition
View source
class ConditionManager extends DefaultPluginManager implements ExecutableManagerInterface, CategorizingPluginManagerInterface, FilteredPluginManagerInterface {
  use CategorizingPluginManagerTrait;
  use FilteredPluginManagerTrait;

  /**
   * Constructs a ConditionManager object.
   *
   * @param \Traversable $namespaces
   *   An object that implements \Traversable which contains the root paths
   *   keyed by the corresponding namespace to look for plugin implementations.
   * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
   *   Cache backend instance to use.
   * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
   *   The module handler to invoke the alter hook with.
   */
  public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
    $this
      ->alterInfo('condition_info');
    $this
      ->setCacheBackend($cache_backend, 'condition_plugins');
    parent::__construct('Plugin/Condition', $namespaces, $module_handler, ConditionInterface::class, Condition::class, 'Drupal\\Core\\Condition\\Annotation\\Condition');
  }

  /**
   * {@inheritdoc}
   */
  protected function getType() {
    return 'condition';
  }

  /**
   * {@inheritdoc}
   */
  public function createInstance($plugin_id, array $configuration = []) {
    $plugin = $this
      ->getFactory()
      ->createInstance($plugin_id, $configuration);
    return $plugin
      ->setExecutableManager($this);
  }

  /**
   * {@inheritdoc}
   */
  public function execute(ExecutableInterface $condition) {
    if ($condition instanceof ConditionInterface) {
      $result = $condition
        ->evaluate();
      return $condition
        ->isNegated() ? !$result : $result;
    }
    throw new ExecutableException("This manager object can only execute condition plugins");
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CategorizingPluginManagerTrait::getCategories public function
CategorizingPluginManagerTrait::getGroupedDefinitions public function
CategorizingPluginManagerTrait::getModuleExtensionList protected function Returns the module extension list used.
CategorizingPluginManagerTrait::getModuleHandler Deprecated public function Returns the module handler used.
CategorizingPluginManagerTrait::getProviderName protected function Gets the name of a provider.
CategorizingPluginManagerTrait::getSortedDefinitions public function
CategorizingPluginManagerTrait::processDefinitionCategory protected function Processes a plugin definition to ensure there is a category.
ConditionManager::createInstance public function Creates a plugin instance based on the provided ID and configuration. Overrides FactoryInterface::createInstance
ConditionManager::execute public function
ConditionManager::getType protected function A string identifying the plugin type. Overrides FilteredPluginManagerTrait::getType
ConditionManager::__construct public function Constructs a ConditionManager object.
ContextAwarePluginManagerTrait::contextHandler protected function Wraps the context handler. 1
ContextAwarePluginManagerTrait::getDefinitions abstract public function See \Drupal\Component\Plugin\Discovery\DiscoveryInterface::getDefinitions(). 1
ContextAwarePluginManagerTrait::getDefinitionsForContexts public function See \Drupal\Core\Plugin\Context\ContextAwarePluginManagerInterface::getDefinitionsForContexts().
DiscoveryInterface::getDefinition public function Gets a specific plugin definition. 2
DiscoveryInterface::hasDefinition public function Indicates if a specific plugin definition exists.
FilteredPluginManagerTrait::getFilteredDefinitions public function Implements \Drupal\Core\Plugin\FilteredPluginManagerInterface::getFilteredDefinitions().
FilteredPluginManagerTrait::moduleHandler protected function Wraps the module handler. 1
FilteredPluginManagerTrait::themeManager protected function Wraps the theme manager. 1
MapperInterface::getInstance public function Gets or creates a plugin instance that satisfies the given options. 2
StringTranslationTrait::$stringTranslation protected property The string translation service. 3
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 1
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.