mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
rewrite workflow and handle finalize differently
This commit is contained in:
@@ -17,6 +17,7 @@ use Chill\MainBundle\Workflow\EntityWorkflowManager;
|
||||
use Chill\MainBundle\Workflow\Helper\MetadataExtractor;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
use Symfony\Component\Workflow\Registry;
|
||||
use Symfony\Component\Workflow\Transition;
|
||||
use Twig\Environment;
|
||||
use Twig\Extension\RuntimeExtensionInterface;
|
||||
|
||||
@@ -46,6 +47,20 @@ class WorkflowTwigExtensionRuntime implements RuntimeExtensionInterface
|
||||
$this->normalizer = $normalizer;
|
||||
}
|
||||
|
||||
public function getTransitionByString(EntityWorkflow $entityWorkflow, string $key): ?Transition
|
||||
{
|
||||
$workflow = $this->registry->get($entityWorkflow, $entityWorkflow->getWorkflowName());
|
||||
$transitions = $workflow->getDefinition()->getTransitions();
|
||||
|
||||
foreach ($transitions as $transition) {
|
||||
if ($transition->getName() === $key) {
|
||||
return $transition;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function listWorkflows(Environment $environment, string $relatedEntityClass, int $relatedEntityId, array $options = []): string
|
||||
{
|
||||
$blankEntityWorkflow = new EntityWorkflow();
|
||||
|
Reference in New Issue
Block a user