src/Form/Flow/InstallNeaFlow.php line 35

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\InstallNeaSensorForm;
  16. use App\Entity\Nea;
  17. class InstallNeaFlow extends FormFlow implements EventSubscriberInterface {
  18.     public static function getSubscribedEvents(): array {
  19.         return [
  20.             FormFlowEvents::PRE_BIND => 'onPreBind',
  21.             FormFlowEvents::GET_STEPS => 'onGetSteps',
  22.             FormFlowEvents::POST_BIND_SAVED_DATA => 'onPostBindSavedData',
  23.             FormFlowEvents::POST_BIND_FLOW => 'onPostBindFlow',
  24.             FormFlowEvents::POST_BIND_REQUEST => 'onPostBindRequest',
  25.             FormFlowEvents::POST_VALIDATE => 'onPostValidate',
  26.         ];
  27.     }
  28.     public function onPreBind(PreBindEvent $event) {
  29.         // ...
  30.     }
  31.     public function onGetSteps(GetStepsEvent $event) {
  32.         // ...
  33.     }
  34.     public function onPostBindSavedData(PostBindSavedDataEvent $event) {
  35.         // ...
  36.     }
  37.     public function onPostBindFlow(PostBindFlowEvent $event) {
  38.         // ...
  39.     }
  40.     public function onPostBindRequest(PostBindRequestEvent $event) {
  41.         // ...
  42.     }
  43.     public function onPostValidate(PostValidateEvent $event) {
  44.         /*if($this->determineCurrentStepNumber() && $this->determineCurrentStepNumber() == 3) {
  45.             $manualInspection = $event->getFormData();
  46.             for($i = 1; $i < 16; $i++) {
  47.                 $methodName = 'getQ'.$i;
  48.                 $options = parent::getFormOptions(1);
  49.                 if($manualInspection->{$methodName}() == false) {
  50.                     $manualInspection->setHasAnswersWithNo(true);
  51.                     break;
  52.                 }
  53.             }
  54.         }*/
  55.     }
  56.     protected function loadStepsConfig(): array {
  57.         return [
  58.             // Adresse
  59.             [
  60.                 'label' => 'Adresse',
  61.                 'form_type' => InstallNeaSensorForm::class,
  62.             ],
  63.             // Typ der Netzersatzanlage
  64.             [
  65.                 'label' => 'Typ der Netzersatzanlage',
  66.                 'form_type' => InstallNeaSensorForm::class,
  67.             ],
  68.             // Messpunkt Sammelstörung
  69.             [
  70.                 'label' => 'Messpunkt für Sammelstörung',
  71.                 'form_type' => InstallNeaSensorForm::class,
  72.             ],
  73.             // Betriebsbereit vorhanden
  74.             [
  75.                 'label' => 'Messpunkt für Betriebsbereit vorhanden',
  76.                 'form_type' => InstallNeaSensorForm::class,
  77.             ],
  78.             // Generatorbetrieb vorhanden
  79.             [
  80.                 'label' => 'Messpunkt für Generatorbetrieb vorhanden (Aggregat)',
  81.                 'form_type' => InstallNeaSensorForm::class,
  82.                 'skip' => function($estimatedCurrentStepNumberFormFlowInterface $flow) {
  83.                     return $flow->getFormData()->getType() == Nea::NEA_TYPE_BATTERY;
  84.                 },
  85.             ],
  86.             // Netzbetrieb vorhanden
  87.             [
  88.                 'label' => 'Messpunkt für Netzbetrieb vorhanden? (Aggregat)',
  89.                 'form_type' => InstallNeaSensorForm::class,
  90.                 'skip' => function($estimatedCurrentStepNumberFormFlowInterface $flow) {
  91.                     //return $estimatedCurrentStepNumber > 3 && ($flow->getFormData()->getType() != Nea::NEA_TYPE_BATTERY);
  92.                     return ($flow->getFormData()->getType() == Nea::NEA_TYPE_BATTERY);
  93.                 },
  94.             ],
  95.             // Netzausfall vorhanden
  96.             [
  97.                 'label' => 'Messpunkt für Netzausfall vorhanden? (Batterie)',
  98.                 'form_type' => InstallNeaSensorForm::class,
  99.                 'skip' => function($estimatedCurrentStepNumberFormFlowInterface $flow) {
  100.                     //return $estimatedCurrentStepNumber > 3 && ($flow->getFormData()->getType() != Nea::NEA_TYPE_BATTERY);
  101.                     return ($flow->getFormData()->getType() != Nea::NEA_TYPE_BATTERY);
  102.                 },
  103.             ],
  104.             // Ladestörung vorhanden
  105.             [
  106.                 'label' => 'Messpunkt für Ladestörung vorhanden? (Batterie)',
  107.                 'form_type' => InstallNeaSensorForm::class,
  108.                 'skip' => function($estimatedCurrentStepNumberFormFlowInterface $flow) {
  109.                     //return $estimatedCurrentStepNumber >= 5 && ($flow->getFormData()->getType() != Nea::NEA_TYPE_BATTERY);
  110.                     return ($flow->getFormData()->getType() != Nea::NEA_TYPE_BATTERY);
  111.                 },
  112.             ],
  113.             // Wandlerstörung vorhanden
  114.             [
  115.                 'label' => 'Messpunkt für Wandlerstörung vorhanden? (Batterie)',
  116.                 'form_type' => InstallNeaSensorForm::class,
  117.                 'skip' => function($estimatedCurrentStepNumberFormFlowInterface $flow) {
  118.                     //return $estimatedCurrentStepNumber >= 6 && ($flow->getFormData()->getType() != Nea::NEA_TYPE_BATTERY);
  119.                     return ($flow->getFormData()->getType() != Nea::NEA_TYPE_BATTERY);
  120.                 },
  121.             ],
  122.             // Tiefentladeschutz vorhanden
  123.             [
  124.                 'label' => 'Messpunkt für Tiefentladeschutz vorhanden? (Batterie)',
  125.                 'form_type' => InstallNeaSensorForm::class,
  126.                 'skip' => function($estimatedCurrentStepNumberFormFlowInterface $flow) {
  127.                     //return $estimatedCurrentStepNumber >= 8 && ($flow->getFormData()->getType() != Nea::NEA_TYPE_BATTERY);
  128.                     return ($flow->getFormData()->getType() != Nea::NEA_TYPE_BATTERY);
  129.                 },
  130.             ],
  131.             // Funktionstest vorhanden
  132.             [
  133.                 'label' => 'Messpunkt für Funktionstest vorhanden? (Batterie)',
  134.                 'form_type' => InstallNeaSensorForm::class,
  135.                 'skip' => function($estimatedCurrentStepNumberFormFlowInterface $flow) {
  136.                     //return $estimatedCurrentStepNumber >= 9 && ($flow->getFormData()->getType() != Nea::NEA_TYPE_BATTERY);
  137.                     return ($flow->getFormData()->getType() != Nea::NEA_TYPE_BATTERY);
  138.                 },
  139.             ],
  140.             // Leckagemeldung vorhanden
  141.             [
  142.                 'label' => 'Messpunkt für Leckagemeldung vorhanden? '//  (Batterie)
  143.                 'form_type' => InstallNeaSensorForm::class,
  144.                 'skip' => function($estimatedCurrentStepNumberFormFlowInterface $flow) {
  145.                     //return $estimatedCurrentStepNumber >= 10 && ($flow->getFormData()->getType() != Nea::NEA_TYPE_BATTERY);
  146.                     return ($flow->getFormData()->getType() == Nea::NEA_TYPE_BATTERY);
  147.                 },
  148.             ],
  149.             // Tanksonden vorhanden
  150.             [
  151.                 'label' => 'Sind Tanksonden vorhanden?',
  152.                 'form_type' => InstallNeaSensorForm::class,
  153.                 'skip' => function($estimatedCurrentStepNumberFormFlowInterface $flow) {
  154.                     return $flow->getFormData()->getType() == Nea::NEA_TYPE_BATTERY;
  155.                 },
  156.             ],
  157.             // Batterieunterspannung vorhanden
  158.             [
  159.                 'label' => 'Messpunkt für Batterieunterspannung vorhanden',
  160.                 'form_type' => InstallNeaSensorForm::class,
  161.                 'skip' => function($estimatedCurrentStepNumberFormFlowInterface $flow) {
  162.                     return $flow->getFormData()->getType() == Nea::NEA_TYPE_BATTERY;
  163.                 },
  164.             ],
  165.             // Aggregat läuft vorhanden
  166.             [
  167.                 'label' => 'Messpunkt für Aggregat läuft',
  168.                 'form_type' => InstallNeaSensorForm::class,
  169.                 'skip' => function($estimatedCurrentStepNumberFormFlowInterface $flow) {
  170.                     return $flow->getFormData()->getType() == Nea::NEA_TYPE_BATTERY;
  171.                 },
  172.             ],
  173.         ];
  174.     }
  175. }