From 26f2dcfa5066cb390a56429e0b0c55fe2ecefc92 Mon Sep 17 00:00:00 2001 From: Daniel Sasser Date: Wed, 5 Oct 2016 15:55:49 -0700 Subject: [PATCH] WDC-16595 Updates based on code review; - Replaced dropbutton with operation elements - Used new :placeholder for url placeholder values - Move expressionManager to class property --- src/Form/Expression/ActionContainerForm.php | 4 ++-- .../Expression/ConditionContainerForm.php | 22 +++++++++++++------ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/Form/Expression/ActionContainerForm.php b/src/Form/Expression/ActionContainerForm.php index a9fee3d2..8c425225 100644 --- a/src/Form/Expression/ActionContainerForm.php +++ b/src/Form/Expression/ActionContainerForm.php @@ -91,11 +91,11 @@ public function form(array $form, FormStateInterface $form_state) { '#attributes' => ['class' => ['action-weight']], ]; - // Operations (dropbutton) column. + // Operations column. $rules_ui_handler = $this->getRulesUiHandler(); $row['operations'] = [ 'data' => [ - '#type' => 'dropbutton', + '#type' => 'operations', '#links' => [ 'edit' => [ 'title' => $this->t('Edit'), diff --git a/src/Form/Expression/ConditionContainerForm.php b/src/Form/Expression/ConditionContainerForm.php index 312820fc..379a6f6a 100644 --- a/src/Form/Expression/ConditionContainerForm.php +++ b/src/Form/Expression/ConditionContainerForm.php @@ -45,6 +45,14 @@ class ConditionContainerForm implements ExpressionFormInterface { */ protected $ruleExpression; + /** + * The expression plugin manager service. + * + * @var \Drupal\rules\Engine\ExpressionManager + */ + protected $expressionManager; + + /** * Creates a new object of this class. */ @@ -53,6 +61,7 @@ public function __construct(ConditionExpressionContainerInterface $condition_con $this->rulesUiHandler = $this->getRulesUiHandler(); $this->component = $this->rulesUiHandler->getComponent(); $this->ruleExpression = $this->component->getExpression(); + $this->expressionManager = \Drupal::service('plugin.manager.rules_expression'); } /** @@ -67,12 +76,12 @@ public function form(array $form, FormStateInterface $form_state, $options = []) '#type' => 'container', '#id' => 'rules-plugin-add-help', 'content' => array( - '#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 the online documentation for more information on condition sets.', + '#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 the online documentation for more information on condition sets.', array( '@plugin' => $this->conditionContainer->getLabel(), '@config-plugin' => $config->bundle(), '%label' => $config->label(), - '@url' => 'http://drupal.org/node/1300034', + ':url' => 'http://drupal.org/node/1300034', ) ), ), @@ -177,11 +186,11 @@ private function buildRow(&$form, FormStateInterface &$form_state, $condition, $ '#attributes' => ['class' => ['condition-weight']], ]; - // Operations (dropbutton) column. + // Operations column. $rules_ui_handler = $this->getRulesUiHandler(); $row['operations'] = [ 'data' => [ - '#type' => 'dropbutton', + '#type' => 'operations', '#links' => [ 'edit' => [ 'title' => $this->t('Edit'), @@ -313,7 +322,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { * The id key in the values. * * @return mixed - * A heirarchical tree of values. + * A hierarchical tree of values. */ private function buildElementTree($values, &$elements, $pidKey, $idKey = NULL) { $grouped = array(); @@ -352,13 +361,12 @@ private function buildElementTree($values, &$elements, $pidKey, $idKey = NULL) { */ private function mirrorElements($values) { $elements = NULL; - $expressionManager = \Drupal::service('plugin.manager.rules_expression'); foreach ($values as $uuid => $element) { $condition = $this->ruleExpression->getExpression($element['id']); $configuration = $condition->getConfiguration(); unset($configuration['uuid']); $configuration['weight'] = $element['weight']; - $elements[$uuid] = $expressionManager->createInstance($condition->getPluginId(), $configuration); + $elements[$uuid] = $this->expressionManager->createInstance($condition->getPluginId(), $configuration); } return $elements;