/** * @param FormBlueprintInterface $form * @param \AV\Form\RequestHandler\RequestHandlerInterface|null $requestHandler * @param EntityProcessorInterface $entityProcessor * @param \AV\Form\Type\TypeHandler $typeHandler * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $eventDispatcher * @param RestoreDataHandlerInterface $restoreDataHandler */ public function __construct(FormBlueprintInterface $form, RequestHandlerInterface $requestHandler = null, EntityProcessorInterface $entityProcessor = null, TypeHandler $typeHandler = null, EventDispatcherInterface $eventDispatcher = null, RestoreDataHandlerInterface $restoreDataHandler = null) { $this->form = $form; if ($entityProcessor) { $this->entityProcessor = $entityProcessor; } else { $this->entityProcessor = new GetterSetterEntityProcessor(); } if ($requestHandler) { $this->requestHandler = $requestHandler; } else { $this->requestHandler = new StandardRequestHandler(); } if ($typeHandler) { $this->typeHandler = $typeHandler; } else { $this->typeHandler = new TypeHandler(); } if ($restoreDataHandler) { $this->restoreDataHandler = $restoreDataHandler; } if ($eventDispatcher) { $this->eventDispatcher = $eventDispatcher; $event = new FormHandlerConstructEvent($this, $this->form); $this->eventDispatcher->dispatch('form_handler.construct', $event); $this->form = $event->getFormBlueprint(); } $this->fields = $this->getDefaultOptions($form->getAll()); $this->data = $form->getDefaultData(); $this->method = $form->getMethod(); $this->action = $form->getAction(); $this->formName = $form->getName(); if ($this->hasFieldOfType('file')) { $this->encoding = 'multipart/form-data'; } }