src/Form/Flow/ElevatorAcquisitionFlow.php line 37

Open in your IDE?
  1. <?php
  2. namespace App\Form\Flow;
  3. // src/MyCompany/MyBundle/Form/CreateVehicleFlow.php
  4. use App\Form\ElevatorAcquisitionType;
  5. use Craue\FormFlowBundle\Event\GetStepsEvent;
  6. use Craue\FormFlowBundle\Event\PostBindFlowEvent;
  7. use Craue\FormFlowBundle\Event\PostBindRequestEvent;
  8. use Craue\FormFlowBundle\Event\PostBindSavedDataEvent;
  9. use Craue\FormFlowBundle\Event\PostValidateEvent;
  10. use Craue\FormFlowBundle\Event\PreBindEvent;
  11. use Craue\FormFlowBundle\Form\FormFlow;
  12. use Craue\FormFlowBundle\Form\FormFlowEvents;
  13. use Craue\FormFlowBundle\Form\FormFlowInterface;
  14. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  15. class ElevatorAcquisitionFlow extends FormFlow implements EventSubscriberInterface
  16. {
  17.     public static function getSubscribedEvents(): array {
  18.         return [
  19.             FormFlowEvents::PRE_BIND => 'onPreBind',
  20.             FormFlowEvents::GET_STEPS => 'onGetSteps',
  21.             FormFlowEvents::POST_BIND_SAVED_DATA => 'onPostBindSavedData',
  22.             FormFlowEvents::POST_BIND_FLOW => 'onPostBindFlow',
  23.             FormFlowEvents::POST_BIND_REQUEST => 'onPostBindRequest',
  24.             FormFlowEvents::POST_VALIDATE => 'onPostValidate',
  25.         ];
  26.     }
  27.     public function onPreBind(PreBindEvent $event)
  28.     {
  29.         // ...
  30.     }
  31.     public function onGetSteps(GetStepsEvent $event)
  32.     {
  33.         // ...
  34.     }
  35.     public function onPostBindSavedData(PostBindSavedDataEvent $event)
  36.     {
  37.         // ...
  38.     }
  39.     public function onPostBindFlow(PostBindFlowEvent $event)
  40.     {
  41.         // ...
  42.     }
  43.     public function onPostBindRequest(PostBindRequestEvent $event)
  44.     {
  45.         // ...
  46.     }
  47.     public function onPostValidate(PostValidateEvent $event) {}
  48.     protected function loadStepsConfig(): array {
  49.         return [
  50.             // Step 1: Info
  51.             [
  52.                 'label' => 'Allgemeine Gebäudeinformationen',
  53.                 'form_type' => ElevatorAcquisitionType::class,
  54.             ],
  55.             // Step 2: Info
  56.             [
  57.                 'label' => 'Informationen zum Aufzug',
  58.                 'form_type' => InstallSensorForm::class,
  59.             ],
  60.             // Step 3: Fahrt separate Messspunkte
  61.             [
  62.                 'label' => 'Allgemein',
  63.                 'form_type' => InstallSensorForm::class,
  64.                 'skip' => function ($estimatedCurrentStepNumberFormFlowInterface $flow) {
  65.                     return $estimatedCurrentStepNumber >= && !$flow->getFormData()->hasMultipleDriveMeasuringPoint();
  66.                 },
  67.             ],
  68.             // Step 4: Fahrt ein Messspunkt
  69.             [
  70.                 'label' => 'Kabinentür',
  71.                 'form_type' => InstallSensorForm::class,
  72.                 'skip' => function ($estimatedCurrentStepNumberFormFlowInterface $flow) {
  73.                     return $estimatedCurrentStepNumber >= && $flow->getFormData()->hasMultipleDriveMeasuringPoint();
  74.                 },
  75.             ],
  76.             // Step 5: Tür 1 separate Messspunkte
  77.             [
  78.                 'label' => 'Türantrieb',
  79.                 'form_type' => InstallSensorForm::class,
  80.                 'skip' => function ($estimatedCurrentStepNumberFormFlowInterface $flow) {
  81.                     return $estimatedCurrentStepNumber >= && (!$flow->getFormData()->hasMultipleDoorsMeasuringPoint() || !$flow->getFormData()->getDoorsHaveMeasuringPoint());
  82.                 },
  83.             ],
  84.             // Step 6: Tür 1 ein Messspunkt
  85.             [
  86.                 'label' => 'Fahrkorbdach',
  87.                 'form_type' => InstallSensorForm::class,
  88.                 'skip' => function ($estimatedCurrentStepNumberFormFlowInterface $flow) {
  89.                     return $estimatedCurrentStepNumber >= && ($flow->getFormData()->hasMultipleDoorsMeasuringPoint() || !$flow->getFormData()->getDoorsHaveMeasuringPoint());
  90.                 },
  91.             ],
  92.             // Step 7: Tür 2 separate Messspunkte
  93.             [
  94.                 'label' => 'Maschinenraum',
  95.                 'form_type' => InstallSensorForm::class,
  96.                 'skip' => function ($estimatedCurrentStepNumberFormFlowInterface $flow) {
  97.                     return $estimatedCurrentStepNumber >= && (!$flow->getFormData()->hasMultipleDoorsMeasuringPoint() && $flow->getFormData()->hasMultipleDoors()) || !$flow->getFormData()->hasMultipleDoors() || !$flow->getFormData()->getDoorsHaveMeasuringPoint();
  98.                 },
  99.             ],
  100.             // Step 8: Tür 2 ein Messspunkt
  101.             [
  102.                 'label' => 'Antrieb Seil',
  103.                 'form_type' => InstallSensorForm::class,
  104.                 'skip' => function ($estimatedCurrentStepNumberFormFlowInterface $flow) {
  105.                     if ($estimatedCurrentStepNumber >= 6) {
  106.                         if (!$flow->getFormData()->getDoorsHaveMeasuringPoint()) {
  107.                             return true;
  108.                         }
  109.                         if ($flow->getFormData()->hasMultipleDoorsMeasuringPoint()) {
  110.                             return true;
  111.                         }
  112.                         if (!$flow->getFormData()->hasMultipleDoors()) {
  113.                             return true;
  114.                         }
  115.                     } else {
  116.                         return true;
  117.                     }
  118.                     return false;
  119.                     // return $estimatedCurrentStepNumber >= 6 && ($flow->getFormData()->hasMultipleDoorsMeasuringPoint() || !$flow->getFormData()->hasMultipleDoors());
  120.                 },
  121.             ],
  122.             // Step 9: Sicherheitskreis vor den Türen
  123.             [
  124.                 'label' => 'Antrieb Hydraulik',
  125.                 'form_type' => InstallSensorForm::class,
  126.             ],
  127.             // Step 10: Sicherheitskreis nach den Türen
  128.             [
  129.                 'label' => 'Steuerung',
  130.                 'form_type' => InstallSensorForm::class,
  131.             ],
  132.             // Step 11: Sicherheitskreis Schachttüren
  133.             [
  134.                 'label' => 'Frequenzumrichter',
  135.                 'form_type' => InstallSensorForm::class,
  136.                 'skip' => function ($estimatedCurrentStepNumberFormFlowInterface $flow) {
  137.                     if ($estimatedCurrentStepNumber >= 11) {
  138.                         if (!$flow->getFormData()->getHasHoistwayDoor()) {
  139.                             return true;
  140.                         }
  141.                     } else {
  142.                         return true;
  143.                     }
  144.                     return false;
  145.                 },
  146.             ],
  147.             // Step 12: Sammelstörung
  148.             [
  149.                 'label' => 'Geschwindigkeitsbegrenzer',
  150.                 'form_type' => InstallSensorForm::class,
  151.                 'skip' => function ($estimatedCurrentStepNumberFormFlowInterface $flow) {
  152.                     if ($estimatedCurrentStepNumber >= 11) {
  153.                         if (!$flow->getFormData()->getHasCollectiveDisorder()) {
  154.                             return true;
  155.                         }
  156.                     }
  157.                     return false;
  158.                 },
  159.             ],
  160.             // Step 13: Inspektion
  161.             [
  162.                 'label' => 'Schachtgrube',
  163.                 'form_type' => InstallSensorForm::class,
  164.                 'skip' => function ($estimatedCurrentStepNumberFormFlowInterface $flow) {
  165.                     if ($estimatedCurrentStepNumber >= 11) {
  166.                         return true;
  167.                     }
  168.                     return false;
  169.                 },
  170.             ],
  171.             // Step 14: Kabinenlicht
  172.             [
  173.                 'label' => 'Schließung',
  174.                 'form_type' => InstallSensorForm::class,
  175.             ],
  176.             // Step 15: Netz
  177.             [
  178.                 'label' => 'Notruf',
  179.                 'form_type' => InstallSensorForm::class,
  180.             ],
  181.             // Step 16: AWM+ Netz
  182.             [
  183.                 'label' => 'Prüfbuch',
  184.                 'form_type' => InstallSensorForm::class,
  185.             ],
  186.             // Step 17: Dokumentation
  187.             [
  188.                 'label' => 'Generelle Bilder',
  189.                 'form_type' => InstallSensorForm::class,
  190.             ],
  191.             // Step 17: Dokumentation
  192.             [
  193.                 'label' => 'Wartungszustand',
  194.                 'form_type' => InstallSensorForm::class,
  195.             ],
  196.         ];
  197.     }
  198. }