You are here

public function UserVariableHasRole::getVariables in Business Rules 8

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

Return a variable set with all used variables on the item.

If you are using variables in a textfield, you can use the regex as the following:

preg_match_all(BusinessRulesItemPluginInterface::VARIABLE_REGEX, $text, $variables);

The $variables array will be filled with all used variables at index [1]

Parameters

\Drupal\business_rules\ItemInterface $item: The business rule item.

Return value

\Drupal\business_rules\VariablesSet The variableSet with all variables used on the Item.

Overrides BusinessRulesItemPluginBase::getVariables

File

src/Plugin/BusinessRulesCondition/UserVariableHasRole.php, line 92

Class

UserVariableHasRole
Class UserVariableHasRole.

Namespace

Drupal\business_rules\Plugin\BusinessRulesCondition

Code

public function getVariables(ItemInterface $item) {
  $variable_id = $item
    ->getSettings('user_variable');
  $variable = Variable::load($variable_id);
  $variableSet = new VariablesSet();
  $variableObject = new VariableObject($variable_id, NULL, $variable
    ->getType());
  $variableSet
    ->append($variableObject);
  return $variableSet;
}