Commit 377521e2 authored by alexpott's avatar alexpott

Issue #1990156 by damiankloip: Add a dedicated @Condition plugin annotation.

parent 79aa8a63
<?php
/**
* @file
* Contains \Drupal\Core\Condition\Annotation\Condition.
*/
namespace Drupal\Core\Condition\Annotation;
use Drupal\Component\Annotation\Plugin;
/**
* Defines a condition annotation object.
*
* @Annotation
*/
class Condition extends Plugin {
/**
* The condition plugin ID.
*
* @var string
*/
public $id;
/**
* The human-readable name of the condition.
*
* @ingroup plugin_translatable
*
* @var \Drupal\Core\Annotation\Translation
*/
public $label;
/**
* The name of the module providing the type.
*
* @var string
*/
public $module;
/**
* An array of contextual data.
*
* @var array
*/
public $condition = array();
}
......@@ -33,9 +33,13 @@ class ConditionManager extends DefaultPluginManager implements ExecutableManager
* The module handler to invoke the alter hook with.
*/
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, LanguageManager $language_manager, ModuleHandlerInterface $module_handler) {
parent::__construct('Condition', $namespaces);
$this->alterInfo($module_handler, 'condition_info');
$this->setCacheBackend($cache_backend, $language_manager, 'condition');
$annotation_namespaces = array(
'Drupal\Core\Condition\Annotation' => DRUPAL_ROOT . '/core/lib',
);
parent::__construct('Condition', $namespaces, $annotation_namespaces, 'Drupal\Core\Condition\Annotation\Condition');
}
/**
......
......@@ -8,17 +8,16 @@
namespace Drupal\language\Plugin\Condition;
use Drupal\Core\Condition\ConditionPluginBase;
use Drupal\Component\Annotation\Plugin;
use Drupal\Core\Condition\Annotation\Condition;
use Drupal\Core\Annotation\Translation;
use Drupal\Core\Language\Language as Lang;
/**
* Provides a 'Language' condition.
*
* @Plugin(
* @Condition(
* id = "language",
* label = @Translation("Language"),
* module = "language",
* context = {
* "language" = {
* "type" = "language"
......
......@@ -8,16 +8,15 @@
namespace Drupal\node\Plugin\Condition;
use Drupal\Core\Condition\ConditionPluginBase;
use Drupal\Component\Annotation\Plugin;
use Drupal\Core\Condition\Annotation\Condition;
use Drupal\Core\Annotation\Translation;
/**
* Provides a 'Node Type' condition.
*
* @Plugin(
* @Condition(
* id = "node_type",
* label = @Translation("Node Bundle"),
* module = "node",
* context = {
* "node" = {
* "type" = "entity",
......
......@@ -8,16 +8,15 @@
namespace Drupal\php\Plugin\Condition;
use Drupal\Core\Condition\ConditionPluginBase;
use Drupal\Component\Annotation\Plugin;
use Drupal\Core\Condition\Annotation\Condition;
use Drupal\Core\Annotation\Translation;
/**
* Provides a 'Php' condition.
*
* @Plugin(
* @Condition(
* id = "php",
* label = @Translation("PHP"),
* module = "php"
* label = @Translation("PHP")
* )
*/
class Php extends ConditionPluginBase {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment