You are here

abstract class BaseDependencyCollector in Dependency Calculation 8

An abstract class with helpful methods for all dependency collectors.

Hierarchy

  • class \Drupal\depcalc\EventSubscriber\DependencyCollector\BaseDependencyCollector implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of BaseDependencyCollector

1 file declares its use of BaseDependencyCollector
LayoutBuilderDependencyCollectorBase.php in src/EventSubscriber/LayoutBuilderComponentDepencyCollector/LayoutBuilderDependencyCollectorBase.php

File

src/EventSubscriber/DependencyCollector/BaseDependencyCollector.php, line 12

Namespace

Drupal\depcalc\EventSubscriber\DependencyCollector
View source
abstract class BaseDependencyCollector implements EventSubscriberInterface {

  /**
   * Properly adds dependencies and their modules to a wrapper object.
   *
   * @param \Drupal\depcalc\DependentEntityWrapperInterface $wrapper
   *   The object to add dependencies to.
   * @param \Drupal\depcalc\DependencyStack $stack
   *   The stack with all loaded dependencies.
   * @param array $dependencies
   *   The list of dependencies to add to the wrapper.
   */
  protected function mergeDependencies(DependentEntityWrapperInterface $wrapper, DependencyStack $stack, array $dependencies) {
    $modules = !empty($dependencies['module']) ? $dependencies['module'] : [];
    unset($dependencies['module']);
    $wrapper
      ->addDependencies($stack, ...array_values($dependencies));
    if ($modules) {
      $wrapper
        ->addModuleDependencies($modules);
    }
  }

  /**
   * Gets the dependency calculator.
   *
   * @return \Drupal\depcalc\DependencyCalculator
   *   The dependency calculator.
   */
  protected function getCalculator() {
    return \Drupal::service('entity.dependency.calculator');
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BaseDependencyCollector::getCalculator protected function Gets the dependency calculator.
BaseDependencyCollector::mergeDependencies protected function Properly adds dependencies and their modules to a wrapper object.