trait DependencyHelperTrait in Dependency Calculation 8
Hierarchy
- trait \Drupal\Tests\depcalc\Kernel\DependencyHelperTrait
File
- tests/
src/ Kernel/ DependencyHelperTrait.php, line 10
Namespace
Drupal\Tests\depcalc\KernelView source
trait DependencyHelperTrait {
/**
* Calculates all the dependencies of a given entity.
*
* @var \Drupal\depcalc\DependencyCalculator
*/
protected $calculator;
/**
* Returns the list of entity dependencies.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity.
*
* @return array
* The list of UUIDs of dependencies (entities).
*
* @throws \Exception
*/
protected function getEntityDependencies(EntityInterface $entity) {
$wrapper = $this
->getDependentEntityWrapper($entity);
return array_keys($wrapper
->getDependencies());
}
/**
* Returns the list of module dependencies.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity object.
*
* @return array
* The list of UUIDs of entity dependencies.
*
* @throws \Exception
*/
protected function getModuleDependencies(EntityInterface $entity) {
$wrapper = $this
->getDependentEntityWrapper($entity);
return $wrapper
->getModuleDependencies();
}
/**
* Calculate entity dependencies and return the DependentEntityWrapper object.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity object.
*
* @return \Drupal\depcalc\DependentEntityWrapperInterface|null
* The DependentEntityWrapper object.
*
* @throws \Exception
*/
protected function getDependentEntityWrapper(EntityInterface $entity) : ?DependentEntityWrapperInterface {
$dependentEntityWrapper = new DependentEntityWrapper($entity);
$stack = new DependencyStack();
$this->calculator
->calculateDependencies($dependentEntityWrapper, $stack);
return $stack
->getDependency($entity
->uuid());
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencyHelperTrait:: |
protected | property | Calculates all the dependencies of a given entity. | |
DependencyHelperTrait:: |
protected | function | Calculate entity dependencies and return the DependentEntityWrapper object. | |
DependencyHelperTrait:: |
protected | function | Returns the list of entity dependencies. | |
DependencyHelperTrait:: |
protected | function | Returns the list of module dependencies. |