You are here

public function FetchEntityVariableAction::getAvailableEmptyVariables in Business Rules 2.x

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

Get the available empty variables for the context.

Parameters

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

Return value

array Array of available entities variables.

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

File

src/Plugin/BusinessRulesAction/FetchEntityVariableAction.php, line 79

Class

FetchEntityVariableAction
Class FetchEntityVariable.

Namespace

Drupal\business_rules\Plugin\BusinessRulesAction

Code

public 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() . ']';
    }
  }
  asort($output);
  return $output;
}