-
Notifications
You must be signed in to change notification settings - Fork 118
Expand file tree
/
Copy pathExpressionManager.php
More file actions
87 lines (74 loc) · 2.01 KB
/
ExpressionManager.php
File metadata and controls
87 lines (74 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
/**
* @file
* Contains \Drupal\rules\Plugin\ExpressionManager.
*/
namespace Drupal\rules\Engine;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Plugin\DefaultPluginManager;
/**
* Plugin manager for all Rules expressions.
*
* @see \Drupal\rules\Engine\ExpressionInterface
*/
class ExpressionManager extends DefaultPluginManager implements ExpressionManagerInterface {
/**
* A map from class names to plugin ids.
*
* @var string[]
*/
protected $classNamePluginIdMap;
/**
* {@inheritdoc}
*/
public function __construct(\Traversable $namespaces, ModuleHandlerInterface $module_handler, $plugin_definition_annotation_name = 'Drupal\rules\Annotation\RulesExpression') {
$this->alterInfo('rules_expression');
parent::__construct('Plugin/RulesExpression', $namespaces, $module_handler, 'Drupal\rules\Engine\ExpressionInterface', $plugin_definition_annotation_name);
}
/**
* {@inheritdoc}
*/
public function createRule(array $configuration = []) {
return $this->createInstance('rules_rule', $configuration);
}
/**
* {@inheritdoc}
*/
public function createReactionRule(array $configuration = []) {
return $this->createInstance('rules_reaction_rule', $configuration);
}
/**
* {@inheritdoc}
*/
public function createAction($id) {
if (!is_string($id)) {
throw new \InvalidArgumentException(t('Rules Action IDs must be strings.'));
}
return $this->createInstance('rules_action', [
'action_id' => $id,
]);
}
/**
* {@inheritdoc}
*/
public function createCondition($id) {
if (!is_string($id)) {
throw new \InvalidArgumentException(t('Condition IDs must be strings.'));
}
return $this->createInstance('rules_condition', [
'condition_id' => $id,
]);
}
/**
* {@inheritdoc}
*/
public function createAnd() {
return $this->createInstance('rules_and');
}
/**
* {@inheritdoc}
*/
public function createOr() {
return $this->createInstance('rules_or');
}
}