当前位置: 首页>>代码示例>>PHP>>正文


PHP Form::getData方法代码示例

本文整理汇总了PHP中Symfony\Component\Form\Form::getData方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::getData方法的具体用法?PHP Form::getData怎么用?PHP Form::getData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Form\Form的用法示例。


在下文中一共展示了Form::getData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: processPaymentData

 /**
  * @param Form $form
  *
  * @return mixed
  * @throws \Exception
  * @throws \PaymentSuite\PaymentCoreBundle\Exception\PaymentException
  */
 private function processPaymentData(Form $form)
 {
     if ($form->isValid()) {
         $data = $form->getData();
         $paymentMethod = new AuthorizenetMethod();
         $paymentMethod->setCreditCartNumber($data['credit_cart'])->setCreditCartExpirationMonth($data['credit_cart_expiration_month'])->setCreditCartExpirationYear($data['credit_cart_expiration_year']);
         try {
             $this->get('authorizenet.manager')->processPayment($paymentMethod);
             $redirectUrl = $this->container->getParameter('authorizenet.success.route');
             $redirectAppend = $this->container->getParameter('authorizenet.success.order.append');
             $redirectAppendField = $this->container->getParameter('authorizenet.success.order.field');
         } catch (PaymentException $e) {
             /**
              * Must redirect to fail route
              */
             $redirectUrl = $this->container->getParameter('authorizenet.fail.route');
             $redirectAppend = $this->container->getParameter('authorizenet.fail.order.append');
             $redirectAppendField = $this->container->getParameter('authorizenet.fail.order.field');
             throw $e;
         }
     } else {
         /**
          * If form is not valid, fail return page
          */
         $redirectUrl = $this->container->getParameter('authorizenet.fail.route');
         $redirectAppend = $this->container->getParameter('authorizenet.fail.order.append');
         $redirectAppendField = $this->container->getParameter('authorizenet.fail.order.field');
     }
     $redirectData = $redirectAppend ? array($redirectAppendField => $this->get('payment.bridge')->getOrderId()) : array();
     $returnData['redirectUrl'] = $redirectUrl;
     $returnData['redirectData'] = $redirectData;
     return $returnData;
 }
开发者ID:hason,项目名称:paymentsuite,代码行数:40,代码来源:AuthorizenetController.php

示例2: onCreateSuccess

 protected function onCreateSuccess(Form $form)
 {
     $this->container->get('lichess_comment.authorname_persistence')->persistCommentInSession($form->getData());
     $response = parent::onCreateSuccess($form);
     $this->container->get('lichess_comment.authorname_persistence')->persistCommentInCookie($form->getData(), $response);
     return $response;
 }
开发者ID:hafeez3000,项目名称:lichess,代码行数:7,代码来源:CommentController.php

示例3: persistTranslations

 public function persistTranslations(Form $form, $class, $field, $id, $locales, $userLocale)
 {
     $translations = $form->getData();
     $em = $this->em;
     $repository = $em->getRepository($class);
     $entity = $repository->find($id);
     // loop on locales
     // parse form data
     // get data stored in db
     // set form data on object if needed
     foreach ($locales as $locale) {
         if (array_key_exists($locale, $translations) && $translations[$locale] !== NULL) {
             $entity->setTranslatableLocale($locale);
             $em->refresh($entity);
             $postedValue = $translations[$locale];
             $storedValue = $this->getField($entity, $field);
             if ($storedValue !== $postedValue) {
                 $this->setField($entity, $field, $postedValue);
                 $em->flush();
             }
         }
     }
     // switch entity locale back to user's locale
     $this->setEntityToUserLocale($entity, $userLocale);
 }
开发者ID:benedicthelfer,项目名称:translatable-form-field,代码行数:25,代码来源:TranslatableFieldManager.php

示例4: testRequestWithValidJsonShouldPopulateForm

 public function testRequestWithValidJsonShouldPopulateForm()
 {
     $request = $this->getRequest('{ "name": "test1" }');
     $this->form->handleRequest($request);
     $this->assertEquals(['name' => 'test1', 'lastname' => null], $this->form->getData());
     $this->assertEquals(['name' => 'test1', 'lastname' => null], $this->form->getNormData());
     $this->assertEquals(['name' => 'test1', 'lastname' => null], $this->form->getViewData());
 }
开发者ID:LinkValue,项目名称:JsonFormExtension-dev,代码行数:8,代码来源:FormTypeJsonExtensionIntegrationTest.php

示例5: process

 /**
  * @return boolean
  */
 public function process()
 {
     $this->form->submit($this->request);
     if ($this->form->isValid()) {
         $query = $this->form->getData()->getQuery();
         return true;
     }
     return false;
 }
开发者ID:radutopala,项目名称:BlogBundle,代码行数:12,代码来源:SearchHandler.php

示例6:

 /**
  * @param \Symfony\Component\Form\Form $form
  * @param \FSi\Bundle\AdminBundle\Admin\CRUD\FormElement $element
  * @param \FSi\Component\DataIndexer\DataIndexerInterface $dataIndexer
  * @param \Symfony\Component\HttpFoundation\Request $request
  */
 function it_have_array_data($form, $element, $dataIndexer, $request)
 {
     $form->createView()->willReturn('form_view');
     $form->getData()->willReturn(null);
     $this->handleRequest($request)->shouldReturn(null);
     $this->getData()->shouldBeArray();
     $this->getData()->shouldHaveKeyInArray('form');
     $this->getData()->shouldHaveKeyInArray('element');
     $form->getData()->willReturn(array('object'));
     $element->getDataIndexer()->willReturn($dataIndexer);
     $dataIndexer->getIndex(array('object'))->willReturn('id');
     $this->getData()->shouldHaveKeyInArray('id');
 }
开发者ID:kbedn,项目名称:admin-bundle,代码行数:19,代码来源:FormElementContextSpec.php

示例7: process

 /**
  * @return boolean
  */
 public function process()
 {
     $this->form->submit($this->request);
     if ($this->form->isValid()) {
         $entityModel = $this->form->getData();
         $this->entity->setContent($this->sanitizer->doClean($entityModel->getContent()));
         $this->entity->setUserName($this->sanitizer->doClean($entityModel->getUserName()));
         $this->entity->setUserEmail($this->sanitizer->doClean($entityModel->getUserEmail()));
         $this->entity->setUserWeb($this->sanitizer->doClean($entityModel->getUserWeb()));
         $this->em->persist($this->entity);
         $this->em->flush();
         return true;
     }
     return false;
 }
开发者ID:radutopala,项目名称:BlogBundle,代码行数:18,代码来源:CommentHandler.php

示例8: filterSetAction

 /**
  * @Route("/datapresentation/filter_set", name="datapresentation_filter_set")
  */
 public function filterSetAction(Request $request)
 {
     $this->init($request);
     $this->initForm();
     if ($this->form->isSubmitted() && $this->form->isValid()) {
         $filters = $this->form->getData();
         unset($filters['today']);
         $filtersString = serialize($filters);
         $cookie = new Cookie('filters', $filtersString, time() + 3600 * 24 * 7, '/');
         $response = new Response();
         $response->headers->setCookie($cookie);
         $response->send();
         $this->request->cookies->set('filters', $filtersString);
     }
     return $this->redirectToRoute('datapresentation');
 }
开发者ID:jarold87,项目名称:orcinus,代码行数:19,代码来源:DataPresentationController.php

示例9: checkFilters

 /**
  * checkFilters
  * 
  * Build filters form
  * If the method POST filters are constructed and written to the session
  * else if in session is a form of filter-it is Otherwise,
  * if there is a default filters-they are  
  * 
  * @param array $default (stand default filter (option))
  * @return 
  */
 protected function checkFilters($default = array())
 {
     if ($this->filter_fields) {
         $this->filter_form = $this->createForm(new BuilderFormFilterType($this->filter_fields));
         if (count($default)) {
             $this->filter_form->setData($default);
         }
         $method = $this->query instanceof NativeQuery ? 'buildNativeQuery' : 'buildQuery';
         if ($this->get('request')->getMethod() == 'POST') {
             $this->get('session')->remove('_filter_' . $this->get('request')->get('_route'));
             $this->get('session')->remove('_pager_' . $this->get('request')->get('_route'));
             $this->filter_form->bind($this->get('request'));
             $this->get('zk2_admin_panel.query_builder')->{$method}($this->filter_form, $this->query);
             $filterService = $this->get('zk2_admin_panel.form_filter_session');
             $filterService->serialize($this->filter_form->getData(), '_filter_' . $this->get('request')->get('_route'));
         } elseif ($this->get('session')->has('_filter_' . $this->get('request')->get('_route'))) {
             $filterService = $this->get('zk2_admin_panel.form_filter_session');
             $data = $filterService->unserialize('_filter_' . $this->get('request')->get('_route'), $this->em_name);
             $this->filter_form->setData($data);
             $this->get('zk2_admin_panel.query_builder')->{$method}($this->filter_form, $this->query);
         } elseif (count($default)) {
             $this->get('zk2_admin_panel.query_builder')->{$method}($this->filter_form, $this->query);
         }
     }
 }
开发者ID:zk2,项目名称:admin-panel-bundle,代码行数:36,代码来源:AdminPanelController.php

示例10: handle

 /**
  * {@inheritdoc}
  */
 public function handle(Form $form, $webSpaceKey, array $options = [])
 {
     $user = $form->getData();
     $user = $this->setUserData($form, $user);
     $this->entityManager->persist($user);
     $this->entityManager->flush();
     return $user;
 }
开发者ID:alexander-schranz,项目名称:sulu-website-user-bundle,代码行数:11,代码来源:ProfileHandler.php

示例11: processValidForm

 /**
  * @param Form    $form
  * @param Request $request
  *
  * @return bool
  */
 public function processValidForm(Form $form, Request $request)
 {
     $data = $form->getData();
     if ($data->hasExampleData() === true) {
         $data->addModule('Blog');
     }
     $request->getSession()->set('installation_data', $data);
     return true;
 }
开发者ID:forkcms,项目名称:forkcms,代码行数:15,代码来源:ModulesHandler.php

示例12: process

 public function process()
 {
     if ($this->form->isValid()) {
         if ('POST' == $this->request->getMethod()) {
             /** @var Apply $apply */
             $apply = $this->form->getData();
             $apply_email = $this->em->getRepository('ESNHRBundle:Apply')->findOneByEmail($apply->getEmail());
             $apply_name = $this->em->getRepository('ESNHRBundle:Apply')->findBy(array("firstname" => $apply->getFirstname(), "lastname" => $apply->getLastname()));
             if (!$apply_email && !$apply_name) {
                 $this->onSuccess($apply);
                 return true;
             } else {
                 $this->container->get('session')->getFlashBag()->add('error', 'Vous êtes déjà enregistré dans notre base de données, il est inutile de postuler plusieurs fois.');
             }
         }
     }
     return false;
 }
开发者ID:donatienthorez,项目名称:sf_erp_esn,代码行数:18,代码来源:ApplyHandler.php

示例13: let

 function let(ProductManager $productManager, ExecutionContextInterface $context, Form $form, ProductInterface $product, ProductValueInterface $value)
 {
     $this->beConstructedWith($productManager);
     $product->getValue('sku')->willReturn($value);
     $form->getData()->willReturn($product);
     $context->getPropertyPath()->willReturn(self::PROPERTY_PATH);
     $context->getRoot()->willReturn($form);
     $this->initialize($context);
 }
开发者ID:vpetrovych,项目名称:pim-community-dev,代码行数:9,代码来源:UniqueValueValidatorSpec.php

示例14: let

 function let(ProductRepositoryInterface $productRepository, UniqueValuesSet $uniqueValuesSet, ExecutionContextInterface $context, Form $form, ProductInterface $product, ProductValueInterface $value)
 {
     $this->beConstructedWith($productRepository, $uniqueValuesSet);
     $product->getValue('unique_attribute')->willReturn($value);
     $form->getData()->willReturn($product);
     $context->getPropertyPath()->willReturn(self::PROPERTY_PATH);
     $context->getRoot()->willReturn($form);
     $this->initialize($context);
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:9,代码来源:UniqueValueValidatorSpec.php

示例15: persistData

 /**
  * @param Form $form
  */
 protected function persistData(Form $form)
 {
     /** @var $userManager \FOS\UserBundle\Model\UserManagerInterface */
     $userManager = $this->get('fos_user.user_manager');
     $userManager->updateUser($form->getData());
     $objectManager = $this->getDoctrine()->getManager();
     $objectManager->persist($form->getData());
     $objectManager->flush();
 }
开发者ID:clastic,项目名称:clastic,代码行数:12,代码来源:UserController.php


注:本文中的Symfony\Component\Form\Form::getData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。