/**
  * Reference purchase summary
  *
  * @Route()
  * @Method({"GET", "POST"})
  * @Template()
  *
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function indexAction(Request $request)
 {
     $previouslyPostedData = null;
     // if we are not posting new data, and a request for $this->formType is stored in the session, prepopulate the form with the stored request
     $storedRequest = unserialize($request->getSession()->get($this->formType->getName()));
     if ($request->isMethod('GET') && $storedRequest instanceof Request) {
         $previouslyPostedData = $this->createForm($this->formType)->handleRequest($storedRequest)->getData();
     }
     $form = $this->createForm($this->formType, $previouslyPostedData);
     if ($request->isMethod('POST')) {
         $form->submit($request);
         if ($form->isValid()) {
             // Persist the case to IRIS
             /** @var ReferencingCase $case */
             $case = $form->getData()['case'];
             $this->irisEntityManager->persist($case);
             /** @var ReferencingApplication $application */
             foreach ($case->getApplications() as $application) {
                 // Always default
                 $application->setSignaturePreference(SignaturePreference::SCAN_DECLARATION);
                 $this->irisEntityManager->persist($application, array('caseId' => $case->getCaseId()));
                 // Persist each guarantor of the application
                 if (null !== $application->getGuarantors()) {
                     foreach ($application->getGuarantors() as $guarantor) {
                         $this->irisEntityManager->persist($guarantor, array('applicationId' => $application->getApplicationId()));
                     }
                 }
             }
             $request->getSession()->set('submitted-case', serialize($case));
             // Send the user to the success page
             return $this->redirect($this->generateUrl('barbon_hostedapi_agent_reference_newreference_tenancyagreement_index'), 301);
         }
     }
     return array('form' => $form->createView());
 }
 /**
  * Triggered on every request.
  *
  * @param GetResponseEvent $event
  *
  * @return void
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     if (!$event->isMasterRequest()) {
         // don't do anything if it's not the master request
         return;
     }
     $request = $event->getRequest();
     // if the request contains a key equal to the name of the form in this class...
     $acceptableContentTypes = array_map('strtolower', $request->getAcceptableContentTypes());
     if ($request->request->has($this->formType->getName()) && in_array('text/html', $acceptableContentTypes) && !$request->isXmlHttpRequest()) {
         // store the request so we can retrieve the posted form data later, if necessary
         $request->getSession()->set($this->formType->getName(), serialize($request));
         // whilst we are here, store the target URL of the form, in case we are redirected to login page
         // $request->getSession()->set('_security.asn_secured.target_path', $request->getUri());
     }
 }
Beispiel #3
0
 /**
  * {@inheritdoc}
  */
 public function resolveType(FormTypeInterface $type)
 {
     $typeExtensions = array();
     foreach ($this->extensions as $extension) {
         /* @var FormExtensionInterface $extension */
         $typeExtensions = array_merge($typeExtensions, $extension->getTypeExtensions($type->getName()));
     }
     $parent = $type->getParent() ? $this->getType($type->getParent()) : null;
     return new ResolvedFormType($type, $typeExtensions, $parent);
 }
Beispiel #4
0
 /**
  * {@inheritdoc}
  */
 public function getName()
 {
     return $this->innerType->getName();
 }
Beispiel #5
0
 /**
  * Wraps a type into a ResolvedFormTypeInterface implementation and connects
  * it with its parent type.
  *
  * @param FormTypeInterface $type The type to resolve.
  *
  * @return ResolvedFormTypeInterface The resolved type.
  */
 private function resolveAndAddType(FormTypeInterface $type)
 {
     $parentType = $type->getParent();
     if ($parentType instanceof FormTypeInterface) {
         $this->resolveAndAddType($parentType);
         $parentType = $parentType->getName();
     }
     $typeExtensions = array();
     foreach ($this->extensions as $extension) {
         /* @var FormExtensionInterface $extension */
         $typeExtensions = array_merge($typeExtensions, $extension->getTypeExtensions($type->getName()));
     }
     set_error_handler(array('Symfony\\Component\\Form\\Test\\DeprecationErrorHandler', 'handleBC'));
     $this->addType($this->resolvedTypeFactory->createResolvedType($type, $typeExtensions, $parentType ? $this->getType($parentType) : null));
     restore_error_handler();
 }
Beispiel #6
0
 private function validateFormTypeName(FormTypeInterface $type)
 {
     if (!preg_match('/^[a-z0-9_]*$/i', $type->getName())) {
         throw new FormException(sprintf('The "%s" form type name ("%s") is not valid. Names must only contain letters, numbers, and "_".', get_class($type), $type->getName()));
     }
 }
Beispiel #7
0
 /**
  * Wraps a type into a ResolvedFormTypeInterface implementation and connects
  * it with its parent type.
  *
  * @param FormTypeInterface $type The type to resolve.
  *
  * @return ResolvedFormTypeInterface The resolved type.
  */
 private function resolveAndAddType(FormTypeInterface $type)
 {
     $parentType = $type->getParent();
     if ($parentType instanceof FormTypeInterface) {
         $this->resolveAndAddType($parentType);
         $parentType = $parentType->getName();
     }
     $typeExtensions = array();
     foreach ($this->extensions as $extension) {
         $typeExtensions = array_merge($typeExtensions, $extension->getTypeExtensions($type->getName()));
     }
     $this->types[$type->getName()] = $this->resolvedTypeFactory->createResolvedType($type, $typeExtensions, $parentType ? $this->getType($parentType) : null);
 }
Beispiel #8
0
 /**
  * Loads the extensions for a given type.
  *
  * @param FormTypeInterface $type The type
  */
 private function loadTypeExtensions(FormTypeInterface $type)
 {
     $typeExtensions = array();
     foreach ($this->extensions as $extension) {
         $typeExtensions = array_merge($typeExtensions, $extension->getTypeExtensions($type->getName()));
     }
     $type->setExtensions($typeExtensions);
 }
 public function addType(FormTypeInterface $type)
 {
     $this->types[$type->getName()] = $type;
 }
 public function __construct(FormTypeInterface $type, $code = 0, $previous = null)
 {
     parent::__construct(sprintf('Circular reference detected in the "%s" type (defined in class "%s").', $type->getName(), get_class($type)), $code, $previous);
 }
Beispiel #11
0
 /**
  * {@inheritdoc}
  */
 public function getParent()
 {
     return $this->parentType->getName();
 }
 /**
  * @param string|\Symfony\Component\Form\FormTypeInterface $formType
  *
  * @return ConfigCache
  */
 protected function configCacheFor($formType)
 {
     $filename = $formType instanceof FormTypeInterface ? $formType->getName() : $formType;
     return new ConfigCache($this->cacheDirectory . '/' . $filename, $this->debug);
 }