src/Form/Flow/ManualInspectionFlow.php line 42

Open in your IDE?
  1. <?php
  2. namespace App\Form\Flow;
  3. // src/MyCompany/MyBundle/Form/CreateVehicleFlow.php
  4. use Craue\FormFlowBundle\Form\FormFlow;
  5. use Craue\FormFlowBundle\Form\FormFlowInterface;
  6. use Craue\FormFlowBundle\Event\GetStepsEvent;
  7. use Craue\FormFlowBundle\Event\PostBindFlowEvent;
  8. use Craue\FormFlowBundle\Event\PostBindRequestEvent;
  9. use Craue\FormFlowBundle\Event\PostBindSavedDataEvent;
  10. use Craue\FormFlowBundle\Event\PostValidateEvent;
  11. use Craue\FormFlowBundle\Event\PreBindEvent;
  12. use Craue\FormFlowBundle\Form\FormFlowEvents;
  13. use Symfony\Component\EventDispatcher\EventDispatcherInterface;
  14. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  15. use App\Form\ManualInspectionForm;
  16. class ManualInspectionFlow extends FormFlow implements EventSubscriberInterface {
  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.     public function onGetSteps(GetStepsEvent $event) {
  31.         // ...
  32.     }
  33.     public function onPostBindSavedData(PostBindSavedDataEvent $event) {
  34.         // ...
  35.     }
  36.     public function onPostBindFlow(PostBindFlowEvent $event) {
  37.         // ...
  38.     }
  39.     public function onPostBindRequest(PostBindRequestEvent $event) {
  40.         // ...
  41.     }
  42.     public function onPostValidate(PostValidateEvent $event) {
  43.         if($this->determineCurrentStepNumber() && $this->determineCurrentStepNumber() == 3) {
  44.             $manualInspection $event->getFormData();
  45.             for($i 1$i 16$i++) {
  46.                 $methodName 'getQ'.$i;
  47.                 $options parent::getFormOptions(1);
  48.                 if($manualInspection->{$methodName}() == false) {
  49.                     $manualInspection->setHasAnswersWithNo(true);
  50.                     break;
  51.                 }
  52.             }
  53.         }
  54.     }
  55.     protected function loadStepsConfig(): array {
  56.         return [
  57.             [
  58.                 'label' => 'Zugänge',
  59.                 'form_type' => ManualInspectionForm::class,
  60.             ],
  61.             // Step 2: Fahrt separate Messspunkte
  62.             [
  63.                 'label' => 'Anlage',
  64.                 'form_type' => ManualInspectionForm::class,
  65.             ],
  66.             // Step 3: Fahrt ein Messspunkt
  67.             [
  68.                 'label' => 'Dokumentation',
  69.                 'form_type' => ManualInspectionForm::class,
  70.             ],
  71.             // Step 4: Tür 1 separate Messspunkte
  72.             [
  73.                 'label' => 'Sonstiges und Bestätigung',
  74.                 'form_type' => ManualInspectionForm::class,
  75.             ],
  76.         ];
  77.     }
  78. }