You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

42 lines
1.1 KiB

<?php
namespace App\Form;
use App\Entity\Task;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Workflow\WorkflowInterface;
use Symfony\Component\DependencyInjection\Attribute\Target;
class TaskLifecycleType extends AbstractType
{
public function __construct(
private WorkflowInterface $taskLifecycleStateMachine,
) {
}
public function configureOptions(OptionsResolver $resolver): void
{
$choices = [];
$places = $this->taskLifecycleStateMachine->getDefinition()->getPlaces();
$metas = $this->taskLifecycleStateMachine->getMetadataStore();
foreach ($places as $place => $id) {
$meta = $metas->getPlaceMetadata($place);
if (isset($meta['title'])) {
$choices[$meta['title']] = $place;
}
}
$resolver->setDefaults([
'choices' => $choices,
]);
}
public function getParent(): string
{
return ChoiceType::class;
}
}