-
Notifications
You must be signed in to change notification settings - Fork 118
Expand file tree
/
Copy pathRulesReactionController.php
More file actions
37 lines (30 loc) · 1.11 KB
/
RulesReactionController.php
File metadata and controls
37 lines (30 loc) · 1.11 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
<?php
namespace Drupal\rules\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Config\Entity\ConfigEntityInterface;
/**
* Provides route controllers for Reaction Rules.
*/
class RulesReactionController extends ControllerBase {
/**
* Enables or disables a Rule.
*
* @param \Drupal\Core\Config\Entity\ConfigEntityInterface $rules_reaction_rule
* The rule entity.
* @param string $op
* The operation to perform, usually 'enable' or 'disable'.
*
* @return \Symfony\Component\HttpFoundation\RedirectResponse
* A redirect back to the rules list page.
*/
public function performReactionRuleOperation(ConfigEntityInterface $rules_reaction_rule, $op) {
$rules_reaction_rule->$op()->save();
if ($op == 'enable') {
drupal_set_message($this->t('The %label rule has been enabled.', ['%label' => $rules_reaction_rule->label()]));
}
elseif ($op == 'disable') {
drupal_set_message($this->t('The %label rule has been disabled.', ['%label' => $rules_reaction_rule->label()]));
}
return $this->redirect('entity.rules_reaction_rule.collection');
}
}