You are here

private function BusinessRulesItemPluginBase::processTokenArraySetting in Business Rules 8

Same name and namespace in other branches
  1. 2.x src/Plugin/BusinessRulesItemPluginBase.php \Drupal\business_rules\Plugin\BusinessRulesItemPluginBase::processTokenArraySetting()

Helper function to process tokens if the setting is an array.

Parameters

array $setting: The setting array.

array $context: The context to replace the tokens.

\Drupal\business_rules\Events\BusinessRulesEvent $event: The Business Rules event.

1 call to BusinessRulesItemPluginBase::processTokenArraySetting()
BusinessRulesItemPluginBase::processTokens in src/Plugin/BusinessRulesItemPluginBase.php
Process the tokens on the settings property for the item.

File

src/Plugin/BusinessRulesItemPluginBase.php, line 218

Class

BusinessRulesItemPluginBase
Base Class for Business rules plugins.

Namespace

Drupal\business_rules\Plugin

Code

private function processTokenArraySetting(array &$setting, array $context, BusinessRulesEvent $event) {
  if (count($setting)) {
    foreach ($setting as $key => $value) {
      if (is_string($value)) {
        $variables = $event
          ->getArgument('variables');
        $value = $this
          ->processVariables($setting[$key], $variables);
        $setting[$key] = $this->util->token
          ->replace($value, $context, [
          'clear' => TRUE,
        ]);
      }
      elseif (is_array($value)) {
        $this
          ->processTokenArraySetting($setting[$key], $context, $event);
      }
    }
  }
}