Skip to content

Commit 26f2dcf

Browse files
author
Daniel Sasser
committed
WDC-16595 Updates based on code review;
- Replaced dropbutton with operation elements - Used new :placeholder for url placeholder values - Move expressionManager to class property
1 parent ef2f28c commit 26f2dcf

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

src/Form/Expression/ActionContainerForm.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ public function form(array $form, FormStateInterface $form_state) {
9191
'#attributes' => ['class' => ['action-weight']],
9292
];
9393

94-
// Operations (dropbutton) column.
94+
// Operations column.
9595
$rules_ui_handler = $this->getRulesUiHandler();
9696
$row['operations'] = [
9797
'data' => [
98-
'#type' => 'dropbutton',
98+
'#type' => 'operations',
9999
'#links' => [
100100
'edit' => [
101101
'title' => $this->t('Edit'),

src/Form/Expression/ConditionContainerForm.php

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ class ConditionContainerForm implements ExpressionFormInterface {
4545
*/
4646
protected $ruleExpression;
4747

48+
/**
49+
* The expression plugin manager service.
50+
*
51+
* @var \Drupal\rules\Engine\ExpressionManager
52+
*/
53+
protected $expressionManager;
54+
55+
4856
/**
4957
* Creates a new object of this class.
5058
*/
@@ -53,6 +61,7 @@ public function __construct(ConditionExpressionContainerInterface $condition_con
5361
$this->rulesUiHandler = $this->getRulesUiHandler();
5462
$this->component = $this->rulesUiHandler->getComponent();
5563
$this->ruleExpression = $this->component->getExpression();
64+
$this->expressionManager = \Drupal::service('plugin.manager.rules_expression');
5665
}
5766

5867
/**
@@ -67,12 +76,12 @@ public function form(array $form, FormStateInterface $form_state, $options = [])
6776
'#type' => 'container',
6877
'#id' => 'rules-plugin-add-help',
6978
'content' => array(
70-
'#markup' => t('You are about to add a new @plugin to the @config-plugin %label. Use indentation to make conditions a part of this logic group. See <a href="@url">the online documentation</a> for more information on condition sets.',
79+
'#markup' => t('You are about to add a new @plugin to the @config-plugin %label. Use indentation to make conditions a part of this logic group. See <a href=“:url">the online documentation</a> for more information on condition sets.',
7180
array(
7281
'@plugin' => $this->conditionContainer->getLabel(),
7382
'@config-plugin' => $config->bundle(),
7483
'%label' => $config->label(),
75-
'@url' => 'http://drupal.org/node/1300034',
84+
':url' => 'http://drupal.org/node/1300034',
7685
)
7786
),
7887
),
@@ -177,11 +186,11 @@ private function buildRow(&$form, FormStateInterface &$form_state, $condition, $
177186
'#attributes' => ['class' => ['condition-weight']],
178187
];
179188

180-
// Operations (dropbutton) column.
189+
// Operations column.
181190
$rules_ui_handler = $this->getRulesUiHandler();
182191
$row['operations'] = [
183192
'data' => [
184-
'#type' => 'dropbutton',
193+
'#type' => 'operations',
185194
'#links' => [
186195
'edit' => [
187196
'title' => $this->t('Edit'),
@@ -313,7 +322,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
313322
* The id key in the values.
314323
*
315324
* @return mixed
316-
* A heirarchical tree of values.
325+
* A hierarchical tree of values.
317326
*/
318327
private function buildElementTree($values, &$elements, $pidKey, $idKey = NULL) {
319328
$grouped = array();
@@ -352,13 +361,12 @@ private function buildElementTree($values, &$elements, $pidKey, $idKey = NULL) {
352361
*/
353362
private function mirrorElements($values) {
354363
$elements = NULL;
355-
$expressionManager = \Drupal::service('plugin.manager.rules_expression');
356364
foreach ($values as $uuid => $element) {
357365
$condition = $this->ruleExpression->getExpression($element['id']);
358366
$configuration = $condition->getConfiguration();
359367
unset($configuration['uuid']);
360368
$configuration['weight'] = $element['weight'];
361-
$elements[$uuid] = $expressionManager->createInstance($condition->getPluginId(), $configuration);
369+
$elements[$uuid] = $this->expressionManager->createInstance($condition->getPluginId(), $configuration);
362370
}
363371

364372
return $elements;

0 commit comments

Comments
 (0)