本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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());
}
示例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;
}
示例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');
}
示例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;
}
示例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');
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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();
}