<?php
namespace App\Form\Flow;
// src/MyCompany/MyBundle/Form/CreateVehicleFlow.php
use App\Form\ElevatorAcquisitionType;
use Craue\FormFlowBundle\Event\GetStepsEvent;
use Craue\FormFlowBundle\Event\PostBindFlowEvent;
use Craue\FormFlowBundle\Event\PostBindRequestEvent;
use Craue\FormFlowBundle\Event\PostBindSavedDataEvent;
use Craue\FormFlowBundle\Event\PostValidateEvent;
use Craue\FormFlowBundle\Event\PreBindEvent;
use Craue\FormFlowBundle\Form\FormFlow;
use Craue\FormFlowBundle\Form\FormFlowEvents;
use Craue\FormFlowBundle\Form\FormFlowInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class ElevatorAcquisitionFlow extends FormFlow implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array {
return [
FormFlowEvents::PRE_BIND => 'onPreBind',
FormFlowEvents::GET_STEPS => 'onGetSteps',
FormFlowEvents::POST_BIND_SAVED_DATA => 'onPostBindSavedData',
FormFlowEvents::POST_BIND_FLOW => 'onPostBindFlow',
FormFlowEvents::POST_BIND_REQUEST => 'onPostBindRequest',
FormFlowEvents::POST_VALIDATE => 'onPostValidate',
];
}
public function onPreBind(PreBindEvent $event)
{
// ...
}
public function onGetSteps(GetStepsEvent $event)
{
// ...
}
public function onPostBindSavedData(PostBindSavedDataEvent $event)
{
// ...
}
public function onPostBindFlow(PostBindFlowEvent $event)
{
// ...
}
public function onPostBindRequest(PostBindRequestEvent $event)
{
// ...
}
public function onPostValidate(PostValidateEvent $event) {}
protected function loadStepsConfig(): array {
return [
// Step 1: Info
[
'label' => 'Allgemeine Gebäudeinformationen',
'form_type' => ElevatorAcquisitionType::class,
],
// Step 2: Info
[
'label' => 'Informationen zum Aufzug',
'form_type' => InstallSensorForm::class,
],
// Step 3: Fahrt separate Messspunkte
[
'label' => 'Allgemein',
'form_type' => InstallSensorForm::class,
'skip' => function ($estimatedCurrentStepNumber, FormFlowInterface $flow) {
return $estimatedCurrentStepNumber >= 2 && !$flow->getFormData()->hasMultipleDriveMeasuringPoint();
},
],
// Step 4: Fahrt ein Messspunkt
[
'label' => 'Kabinentür',
'form_type' => InstallSensorForm::class,
'skip' => function ($estimatedCurrentStepNumber, FormFlowInterface $flow) {
return $estimatedCurrentStepNumber >= 3 && $flow->getFormData()->hasMultipleDriveMeasuringPoint();
},
],
// Step 5: Tür 1 separate Messspunkte
[
'label' => 'Türantrieb',
'form_type' => InstallSensorForm::class,
'skip' => function ($estimatedCurrentStepNumber, FormFlowInterface $flow) {
return $estimatedCurrentStepNumber >= 3 && (!$flow->getFormData()->hasMultipleDoorsMeasuringPoint() || !$flow->getFormData()->getDoorsHaveMeasuringPoint());
},
],
// Step 6: Tür 1 ein Messspunkt
[
'label' => 'Fahrkorbdach',
'form_type' => InstallSensorForm::class,
'skip' => function ($estimatedCurrentStepNumber, FormFlowInterface $flow) {
return $estimatedCurrentStepNumber >= 5 && ($flow->getFormData()->hasMultipleDoorsMeasuringPoint() || !$flow->getFormData()->getDoorsHaveMeasuringPoint());
},
],
// Step 7: Tür 2 separate Messspunkte
[
'label' => 'Maschinenraum',
'form_type' => InstallSensorForm::class,
'skip' => function ($estimatedCurrentStepNumber, FormFlowInterface $flow) {
return $estimatedCurrentStepNumber >= 6 && (!$flow->getFormData()->hasMultipleDoorsMeasuringPoint() && $flow->getFormData()->hasMultipleDoors()) || !$flow->getFormData()->hasMultipleDoors() || !$flow->getFormData()->getDoorsHaveMeasuringPoint();
},
],
// Step 8: Tür 2 ein Messspunkt
[
'label' => 'Antrieb Seil',
'form_type' => InstallSensorForm::class,
'skip' => function ($estimatedCurrentStepNumber, FormFlowInterface $flow) {
if ($estimatedCurrentStepNumber >= 6) {
if (!$flow->getFormData()->getDoorsHaveMeasuringPoint()) {
return true;
}
if ($flow->getFormData()->hasMultipleDoorsMeasuringPoint()) {
return true;
}
if (!$flow->getFormData()->hasMultipleDoors()) {
return true;
}
} else {
return true;
}
return false;
// return $estimatedCurrentStepNumber >= 6 && ($flow->getFormData()->hasMultipleDoorsMeasuringPoint() || !$flow->getFormData()->hasMultipleDoors());
},
],
// Step 9: Sicherheitskreis vor den Türen
[
'label' => 'Antrieb Hydraulik',
'form_type' => InstallSensorForm::class,
],
// Step 10: Sicherheitskreis nach den Türen
[
'label' => 'Steuerung',
'form_type' => InstallSensorForm::class,
],
// Step 11: Sicherheitskreis Schachttüren
[
'label' => 'Frequenzumrichter',
'form_type' => InstallSensorForm::class,
'skip' => function ($estimatedCurrentStepNumber, FormFlowInterface $flow) {
if ($estimatedCurrentStepNumber >= 11) {
if (!$flow->getFormData()->getHasHoistwayDoor()) {
return true;
}
} else {
return true;
}
return false;
},
],
// Step 12: Sammelstörung
[
'label' => 'Geschwindigkeitsbegrenzer',
'form_type' => InstallSensorForm::class,
'skip' => function ($estimatedCurrentStepNumber, FormFlowInterface $flow) {
if ($estimatedCurrentStepNumber >= 11) {
if (!$flow->getFormData()->getHasCollectiveDisorder()) {
return true;
}
}
return false;
},
],
// Step 13: Inspektion
[
'label' => 'Schachtgrube',
'form_type' => InstallSensorForm::class,
'skip' => function ($estimatedCurrentStepNumber, FormFlowInterface $flow) {
if ($estimatedCurrentStepNumber >= 11) {
return true;
}
return false;
},
],
// Step 14: Kabinenlicht
[
'label' => 'Schließung',
'form_type' => InstallSensorForm::class,
],
// Step 15: Netz
[
'label' => 'Notruf',
'form_type' => InstallSensorForm::class,
],
// Step 16: AWM+ Netz
[
'label' => 'Prüfbuch',
'form_type' => InstallSensorForm::class,
],
// Step 17: Dokumentation
[
'label' => 'Generelle Bilder',
'form_type' => InstallSensorForm::class,
],
// Step 17: Dokumentation
[
'label' => 'Wartungszustand',
'form_type' => InstallSensorForm::class,
],
];
}
}