normalizer for entityworkflow

This commit is contained in:
2022-01-28 17:09:00 +01:00
parent da22532587
commit fdafe7c82b
4 changed files with 134 additions and 5 deletions

View File

@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\MainBundle\Workflow\Helper;
use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
use Chill\MainBundle\Entity\Workflow\EntityWorkflowStep;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Symfony\Component\Workflow\Registry;
use Symfony\Component\Workflow\WorkflowInterface;
@@ -51,16 +52,17 @@ class MetadataExtractor
return $workflowsList;
}
public function buildArrayPresentationForPlace(EntityWorkflow $entityWorkflow): array
public function buildArrayPresentationForPlace(EntityWorkflow $entityWorkflow, ?EntityWorkflowStep $step = null): array
{
$workflow = $this->registry->get($entityWorkflow, $entityWorkflow->getWorkflowName());
$step ??= $entityWorkflow->getCurrentStep();
$markingMetadata = $workflow->getMetadataStore()->getPlaceMetadata($entityWorkflow->getCurrentStep()->getCurrentStep());
$markingMetadata = $workflow->getMetadataStore()->getPlaceMetadata($step->getCurrentStep());
$text = array_key_exists('label', $markingMetadata) ?
$this->translatableStringHelper->localize($markingMetadata['label']) : $entityWorkflow->getCurrentStep()->getCurrentStep();
$this->translatableStringHelper->localize($markingMetadata['label']) : $step->getCurrentStep();
return ['name' => $entityWorkflow->getCurrentStep()->getCurrentStep(), 'text' => $text];
return ['name' => $step->getCurrentStep(), 'text' => $text];
}
public function buildArrayPresentationForWorkflow(WorkflowInterface $workflow): array