You are here

public function BusinessRulesItemPluginBase::pregMatch in Business Rules 8

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

Extract the variables from the plugin settings.

Parameters

string $string: The string that can have the variable token: {{variable_id}}.

Return value

array Array with the variables names.

Throws

\Exception

Overrides BusinessRulesItemPluginInterface::pregMatch

2 calls to BusinessRulesItemPluginBase::pregMatch()
BusinessRulesItemPluginBase::getVariables in src/Plugin/BusinessRulesItemPluginBase.php
Return a variable set with all used variables on the item.
FillEntityVariableFields::getVariables in src/Plugin/BusinessRulesAction/FillEntityVariableFields.php
Return a variable set with all used variables on the item.

File

src/Plugin/BusinessRulesItemPluginBase.php, line 93

Class

BusinessRulesItemPluginBase
Base Class for Business rules plugins.

Namespace

Drupal\business_rules\Plugin

Code

public function pregMatch($string) {
  if (is_string($string)) {
    preg_match_all(self::VARIABLE_REGEX, $string, $variables);
    return $variables[1];
  }
  else {
    throw new \Exception('Only strings are acceptable to pregMatch variables');
  }
}