-
Notifications
You must be signed in to change notification settings - Fork 118
Expand file tree
/
Copy pathRulesDefaultEventHandler.php
More file actions
41 lines (34 loc) · 1005 Bytes
/
RulesDefaultEventHandler.php
File metadata and controls
41 lines (34 loc) · 1005 Bytes
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
<?php
/**
* @file
* Contains \Drupal\rules\Core\RulesDefaultEventHandler.
*/
namespace Drupal\rules\Core;
use Drupal\Component\Plugin\Exception\ContextException;
use Drupal\Core\Plugin\PluginBase;
/**
* Default event handler class.
*/
class RulesDefaultEventHandler extends PluginBase implements RulesEventHandlerInterface {
/**
* {@inheritdoc}
*/
public function getContextDefinitions() {
$definition = $this->getPluginDefinition();
if ($this instanceof RulesConfigurableEventHandlerInterface) {
$this->refineContextDefinitions();
$definition = $this->getPluginDefinition();
}
return !empty($definition['context']) ? $definition['context'] : [];
}
/**
* {@inheritdoc}
*/
public function getContextDefinition($name) {
$definitions = $this->getContextDefinitions();
if (empty($definitions[$name])) {
throw new ContextException(sprintf("The %s context is not a valid context.", $name));
}
return $definitions[$name];
}
}