Commit 84824ca9 authored by Manuel Adán's avatar Manuel Adán Committed by Manuel Adán
Browse files

Issue #2974582 by ndewhurst, manuel.adan: Better "Is Empty" Support

parent 25ad6454
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -129,7 +129,7 @@ class TokenMatcher extends ConditionPluginBase implements ContainerFactoryPlugin
    $form['check_empty'] = [
      '#type' => 'checkbox',
      '#title' => $this->t('Check if value is empty'),
      '#description' => $this->t('Just evaluates the replaced token as empty. Values such 0 or white spaces evaluates positive.'),
      '#description' => $this->t('Instead of comparing the source string with the expected value, check to see whether it evaluates to an empty/null/zero value (after replacing any tokens it contains).'),
      '#default_value' => $this->configuration['check_empty'],
    ];

@@ -172,8 +172,8 @@ class TokenMatcher extends ConditionPluginBase implements ContainerFactoryPlugin
   */
  public function evaluate() {
    $token_data = $this->getTokenData();
    $token_replaced = $this->token->replace($this->configuration['token_match'], $token_data);
    $value_replace = $this->token->replace($this->configuration['value_match'], $token_data);
    $token_replaced = $this->token->replace($this->configuration['token_match'], $token_data, ['clear' => TRUE]);
    $value_replace = $this->token->replace($this->configuration['value_match'], $token_data, ['clear' => TRUE]);
    if ($this->configuration['check_empty']) {
      return empty($token_replaced);
    }