public function BusinessRulesItemPluginBase::getVariables in Business Rules 2.x
Same name and namespace in other branches
- 8 src/Plugin/BusinessRulesItemPluginBase.php \Drupal\business_rules\Plugin\BusinessRulesItemPluginBase::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 BusinessRulesItemPluginInterface::getVariables
5 calls to BusinessRulesItemPluginBase::getVariables()
- AddRoleToUser::getVariables in src/
Plugin/ BusinessRulesAction/ AddRoleToUser.php - Return a variable set with all used variables on the item.
- CalculateValue::getVariables in src/
Plugin/ BusinessRulesAction/ CalculateValue.php - Return a variable set with all used variables on the item.
- FetchEntityVariableAction::getVariables in src/
Plugin/ BusinessRulesAction/ FetchEntityVariableAction.php - Return a variable set with all used variables on the item.
- RemoveUserRole::getVariables in src/
Plugin/ BusinessRulesAction/ RemoveUserRole.php - Return a variable set with all used variables on the item.
- SaveEntityVariableAction::getVariables in src/
Plugin/ BusinessRulesAction/ SaveEntityVariableAction.php - Return a variable set with all used variables on the item.
9 methods override BusinessRulesItemPluginBase::getVariables()
- AddRoleToUser::getVariables in src/
Plugin/ BusinessRulesAction/ AddRoleToUser.php - Return a variable set with all used variables on the item.
- CalculateValue::getVariables in src/
Plugin/ BusinessRulesAction/ CalculateValue.php - Return a variable set with all used variables on the item.
- FetchEntityVariableAction::getVariables in src/
Plugin/ BusinessRulesAction/ FetchEntityVariableAction.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.
- LoopThroughFieldVariable::getVariables in src/
Plugin/ BusinessRulesAction/ LoopThroughFieldVariable.php - Return a variable set with all used variables on the item.
File
- src/
Plugin/ BusinessRulesItemPluginBase.php, line 108
Class
- BusinessRulesItemPluginBase
- Base Class for Business rules plugins.
Namespace
Drupal\business_rules\PluginCode
public function getVariables(ItemInterface $item) {
$variableSet = new VariablesSet();
$settings = $item
->getSettings();
foreach ($settings as $setting) {
if (is_string($setting)) {
$variables = $this
->pregMatch($setting);
if (count($variables)) {
foreach ($variables as $variable_id) {
if (stristr($variable_id, '->') && !stristr($variable_id, '[')) {
$arr_temp = explode('->', $variable_id);
$variable_id = $arr_temp[0];
$variable = Variable::load($variable_id);
unset($arr_temp[0]);
}
elseif (stristr($variable_id, '[')) {
$arr_temp = explode('[', $variable_id);
$variable_id = $arr_temp[0];
$variable = Variable::load($variable_id);
unset($arr_temp[0]);
}
else {
$variable = Variable::load($variable_id);
}
if (!empty($variable)) {
$varObject = new VariableObject($variable_id, NULL, $variable
->getType());
$variableSet
->append($varObject);
}
}
}
}
}
return $variableSet;
}