You are here

public function BusinessRulesItemBase::calculateDependencies in Business Rules 8

Same name and namespace in other branches
  1. 2.x src/Entity/BusinessRulesItemBase.php \Drupal\business_rules\Entity\BusinessRulesItemBase::calculateDependencies()

Calculates dependencies and stores them in the dependency property.

Return value

$this

Overrides ConfigEntityBase::calculateDependencies

See also

\Drupal\Core\Config\Entity\ConfigDependencyManager

2 calls to BusinessRulesItemBase::calculateDependencies()
Action::calculateDependencies in src/Entity/Action.php
Calculates dependencies and stores them in the dependency property.
Condition::calculateDependencies in src/Entity/Condition.php
Calculates dependencies and stores them in the dependency property.
2 methods override BusinessRulesItemBase::calculateDependencies()
Action::calculateDependencies in src/Entity/Action.php
Calculates dependencies and stores them in the dependency property.
Condition::calculateDependencies in src/Entity/Condition.php
Calculates dependencies and stores them in the dependency property.

File

src/Entity/BusinessRulesItemBase.php, line 332

Class

BusinessRulesItemBase
Class Item.

Namespace

Drupal\business_rules\Entity

Code

public function calculateDependencies() {
  parent::calculateDependencies();
  $plugin_type = $this->itemManager
    ->getDefinition($this
    ->getType());
  $reflection = new \ReflectionClass($plugin_type['class']);

  /** @var \Drupal\business_rules\Plugin\BusinessRulesItemPluginBase $defined_item */
  $defined_item = $reflection
    ->newInstance($plugin_type, $plugin_type['id'], $plugin_type);
  foreach ($defined_item
    ->getVariables($this)
    ->getVariablesIds() as $id) {

    /** @var \Drupal\business_rules\Entity\Variable $variable */
    if ($variable = Variable::load($id)) {
      $this
        ->addDependency('config', $variable
        ->getConfigDependencyName());
    }
  }
  return $this;
}