This commit is contained in:
2022-02-25 12:11:05 +01:00
parent 2b257cc402
commit 18836f312a
4 changed files with 14 additions and 20 deletions

View File

@@ -62,12 +62,8 @@ class WorkflowTwigExtensionRuntime implements RuntimeExtensionInterface
}
/**
* @param Environment $environment
* @param string $relatedEntityClass
* @param int $relatedEntityId
* @param array $options
* @param array{relatedEntityClass: string, relatedEntityId: int} $supplementaryRelated
* @return string
*
* @throws \Symfony\Component\Serializer\Exception\ExceptionInterface
* @throws \Twig\Error\LoaderError
* @throws \Twig\Error\RuntimeError
@@ -75,10 +71,10 @@ class WorkflowTwigExtensionRuntime implements RuntimeExtensionInterface
*/
public function listWorkflows(Environment $environment, string $relatedEntityClass, int $relatedEntityId, array $options = [], array $supplementaryRelated = []): string
{
list($blankEntityWorkflow, $workflowsAvailable, $entityWorkflows) = $this->getWorkflowsForRelated($relatedEntityClass, $relatedEntityId);
[$blankEntityWorkflow, $workflowsAvailable, $entityWorkflows] = $this->getWorkflowsForRelated($relatedEntityClass, $relatedEntityId);
foreach ($supplementaryRelated as $supplementary) {
list($supplementaryBlankEntityWorkflow, $supplementaryWorkflowsAvailable, $supplementaryEntityWorkflows)
[$supplementaryBlankEntityWorkflow, $supplementaryWorkflowsAvailable, $supplementaryEntityWorkflows]
= $this->getWorkflowsForRelated($supplementary['relatedEntityClass'], $supplementary['relatedEntityId']);
$entityWorkflows = array_merge($entityWorkflows, $supplementaryEntityWorkflows);
@@ -94,8 +90,6 @@ class WorkflowTwigExtensionRuntime implements RuntimeExtensionInterface
}
/**
* @param string $relatedEntityClass
* @param int $relatedEntityId
* @return array where keys are: {0: blankWorkflow, 1: entityWorkflows, 2: workflowList}
*/
private function getWorkflowsForRelated(string $relatedEntityClass, int $relatedEntityId): array
@@ -112,7 +106,8 @@ class WorkflowTwigExtensionRuntime implements RuntimeExtensionInterface
$blankEntityWorkflow,
$workflowsList,
$this->repository->findBy(
['relatedEntityClass' => $relatedEntityClass, 'relatedEntityId' => $relatedEntityId]),
['relatedEntityClass' => $relatedEntityClass, 'relatedEntityId' => $relatedEntityId]
),
];
}
}