You are here

protected function SaveEntityVariableAction::getAvailableEmptyVariables in Business Rules 8

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

Get the available empty variables for the context.

Parameters

\Drupal\business_rules\Entity\Action $item: The action.

Return value

array Array of available variables.

1 call to SaveEntityVariableAction::getAvailableEmptyVariables()
SaveEntityVariableAction::getSettingsForm in src/Plugin/BusinessRulesAction/SaveEntityVariableAction.php
Return the form array.

File

src/Plugin/BusinessRulesAction/SaveEntityVariableAction.php, line 71

Class

SaveEntityVariableAction
Class SaveEntityVariableAction.

Namespace

Drupal\business_rules\Plugin\BusinessRulesAction

Code

protected function getAvailableEmptyVariables(Action $item) {
  $variables = Variable::loadMultiple();
  $output = [];

  /** @var \Drupal\business_rules\Entity\Variable $variable */
  foreach ($variables as $variable) {
    if ($item
      ->getTargetEntityType() == $variable
      ->getTargetEntityType() && $item
      ->getTargetBundle() == $variable
      ->getTargetBundle() && $variable
      ->getType() == 'entity_empty_variable') {
      $output[$variable
        ->id()] = $variable
        ->label() . ' [' . $variable
        ->id() . ']';
    }
  }
  return $output;
}