<?php
namespace App\Form\Flow;
// src/MyCompany/MyBundle/Form/CreateVehicleFlow.php
use Craue\FormFlowBundle\Form\FormFlow;
use Craue\FormFlowBundle\Form\FormFlowInterface;
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\FormFlowEvents;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use App\Form\InstallNeaSensorForm;
use App\Entity\Nea;
class InstallNeaFlow 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) {
/*if($this->determineCurrentStepNumber() && $this->determineCurrentStepNumber() == 3) {
$manualInspection = $event->getFormData();
for($i = 1; $i < 16; $i++) {
$methodName = 'getQ'.$i;
$options = parent::getFormOptions(1);
if($manualInspection->{$methodName}() == false) {
$manualInspection->setHasAnswersWithNo(true);
break;
}
}
}*/
}
protected function loadStepsConfig(): array {
return [
// Adresse
[
'label' => 'Adresse',
'form_type' => InstallNeaSensorForm::class,
],
// Typ der Netzersatzanlage
[
'label' => 'Typ der Netzersatzanlage',
'form_type' => InstallNeaSensorForm::class,
],
// Messpunkt Sammelstörung
[
'label' => 'Messpunkt für Sammelstörung',
'form_type' => InstallNeaSensorForm::class,
],
// Betriebsbereit vorhanden
[
'label' => 'Messpunkt für Betriebsbereit vorhanden',
'form_type' => InstallNeaSensorForm::class,
],
// Generatorbetrieb vorhanden
[
'label' => 'Messpunkt für Generatorbetrieb vorhanden (Aggregat)',
'form_type' => InstallNeaSensorForm::class,
'skip' => function($estimatedCurrentStepNumber, FormFlowInterface $flow) {
return $flow->getFormData()->getType() == Nea::NEA_TYPE_BATTERY;
},
],
// Netzbetrieb vorhanden
[
'label' => 'Messpunkt für Netzbetrieb vorhanden? (Aggregat)',
'form_type' => InstallNeaSensorForm::class,
'skip' => function($estimatedCurrentStepNumber, FormFlowInterface $flow) {
//return $estimatedCurrentStepNumber > 3 && ($flow->getFormData()->getType() != Nea::NEA_TYPE_BATTERY);
return ($flow->getFormData()->getType() == Nea::NEA_TYPE_BATTERY);
},
],
// Netzausfall vorhanden
[
'label' => 'Messpunkt für Netzausfall vorhanden? (Batterie)',
'form_type' => InstallNeaSensorForm::class,
'skip' => function($estimatedCurrentStepNumber, FormFlowInterface $flow) {
//return $estimatedCurrentStepNumber > 3 && ($flow->getFormData()->getType() != Nea::NEA_TYPE_BATTERY);
return ($flow->getFormData()->getType() != Nea::NEA_TYPE_BATTERY);
},
],
// Ladestörung vorhanden
[
'label' => 'Messpunkt für Ladestörung vorhanden? (Batterie)',
'form_type' => InstallNeaSensorForm::class,
'skip' => function($estimatedCurrentStepNumber, FormFlowInterface $flow) {
//return $estimatedCurrentStepNumber >= 5 && ($flow->getFormData()->getType() != Nea::NEA_TYPE_BATTERY);
return ($flow->getFormData()->getType() != Nea::NEA_TYPE_BATTERY);
},
],
// Wandlerstörung vorhanden
[
'label' => 'Messpunkt für Wandlerstörung vorhanden? (Batterie)',
'form_type' => InstallNeaSensorForm::class,
'skip' => function($estimatedCurrentStepNumber, FormFlowInterface $flow) {
//return $estimatedCurrentStepNumber >= 6 && ($flow->getFormData()->getType() != Nea::NEA_TYPE_BATTERY);
return ($flow->getFormData()->getType() != Nea::NEA_TYPE_BATTERY);
},
],
// Tiefentladeschutz vorhanden
[
'label' => 'Messpunkt für Tiefentladeschutz vorhanden? (Batterie)',
'form_type' => InstallNeaSensorForm::class,
'skip' => function($estimatedCurrentStepNumber, FormFlowInterface $flow) {
//return $estimatedCurrentStepNumber >= 8 && ($flow->getFormData()->getType() != Nea::NEA_TYPE_BATTERY);
return ($flow->getFormData()->getType() != Nea::NEA_TYPE_BATTERY);
},
],
// Funktionstest vorhanden
[
'label' => 'Messpunkt für Funktionstest vorhanden? (Batterie)',
'form_type' => InstallNeaSensorForm::class,
'skip' => function($estimatedCurrentStepNumber, FormFlowInterface $flow) {
//return $estimatedCurrentStepNumber >= 9 && ($flow->getFormData()->getType() != Nea::NEA_TYPE_BATTERY);
return ($flow->getFormData()->getType() != Nea::NEA_TYPE_BATTERY);
},
],
// Leckagemeldung vorhanden
[
'label' => 'Messpunkt für Leckagemeldung vorhanden? ', // (Batterie)
'form_type' => InstallNeaSensorForm::class,
'skip' => function($estimatedCurrentStepNumber, FormFlowInterface $flow) {
//return $estimatedCurrentStepNumber >= 10 && ($flow->getFormData()->getType() != Nea::NEA_TYPE_BATTERY);
return ($flow->getFormData()->getType() == Nea::NEA_TYPE_BATTERY);
},
],
// Tanksonden vorhanden
[
'label' => 'Sind Tanksonden vorhanden?',
'form_type' => InstallNeaSensorForm::class,
'skip' => function($estimatedCurrentStepNumber, FormFlowInterface $flow) {
return $flow->getFormData()->getType() == Nea::NEA_TYPE_BATTERY;
},
],
// Batterieunterspannung vorhanden
[
'label' => 'Messpunkt für Batterieunterspannung vorhanden',
'form_type' => InstallNeaSensorForm::class,
'skip' => function($estimatedCurrentStepNumber, FormFlowInterface $flow) {
return $flow->getFormData()->getType() == Nea::NEA_TYPE_BATTERY;
},
],
// Aggregat läuft vorhanden
[
'label' => 'Messpunkt für Aggregat läuft',
'form_type' => InstallNeaSensorForm::class,
'skip' => function($estimatedCurrentStepNumber, FormFlowInterface $flow) {
return $flow->getFormData()->getType() == Nea::NEA_TYPE_BATTERY;
},
],
];
}
}