class WorkflowCollector in Dependency Calculation 8
Subscribes to dependency collection to extract the entity form display.
Hierarchy
- class \Drupal\depcalc\EventSubscriber\DependencyCollector\BaseDependencyCollector implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
- class \Drupal\depcalc\EventSubscriber\DependencyCollector\WorkflowCollector
Expanded class hierarchy of WorkflowCollector
1 string reference to 'WorkflowCollector'
1 service uses WorkflowCollector
File
- src/
EventSubscriber/ DependencyCollector/ WorkflowCollector.php, line 14
Namespace
Drupal\depcalc\EventSubscriber\DependencyCollectorView source
class WorkflowCollector extends BaseDependencyCollector {
/**
* Moderation Information
*
* @var \Drupal\content_moderation\ModerationInformationInterface
*/
protected $moderationInfo;
/**
* EntityFormDisplayDependencyCollector constructor.
*
* @param \Drupal\content_moderation\ModerationInformationInterface|null $moderation_information
* The moderation information.
*/
public function __construct(ModerationInformationInterface $moderation_information = NULL) {
$this->moderationInfo = $moderation_information;
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[DependencyCalculatorEvents::CALCULATE_DEPENDENCIES][] = [
'onCalculateDependencies',
];
return $events;
}
/**
* Calculates the associated workflows.
*
* @param \Drupal\depcalc\Event\CalculateEntityDependenciesEvent $event
* The dependency calculation event.
*
* @throws \Exception
*/
public function onCalculateDependencies(CalculateEntityDependenciesEvent $event) {
if (!$this->moderationInfo) {
return;
}
if ($event
->getEntity() instanceof ContentEntityInterface) {
$workflow = $this->moderationInfo
->getWorkflowForEntity($event
->getEntity());
if ($workflow) {
$wrapper = new DependentEntityWrapper($workflow);
$local_dependencies = [];
$this
->mergeDependencies($wrapper, $event
->getStack(), $this
->getCalculator()
->calculateDependencies($wrapper, $event
->getStack(), $local_dependencies));
$event
->addDependency($wrapper);
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BaseDependencyCollector:: |
protected | function | Gets the dependency calculator. | |
BaseDependencyCollector:: |
protected | function | Properly adds dependencies and their modules to a wrapper object. | |
WorkflowCollector:: |
protected | property | Moderation Information | |
WorkflowCollector:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
WorkflowCollector:: |
public | function | Calculates the associated workflows. | |
WorkflowCollector:: |
public | function | EntityFormDisplayDependencyCollector constructor. |