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


PHP FormInterface::handleRequest方法代码示例

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


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

示例1: process

 /**
  * Prepare & process form
  *
  * @author Jeremie Samson <jeremie@ylly.fr>
  *
  * @return bool
  */
 public function process()
 {
     if ($this->request->isMethod('POST')) {
         $this->form->handleRequest($this->request);
         if ($this->form->isValid()) {
             /** @var ModelUser $user */
             $user = $this->form->getData();
             if (!$user->getFirstname() || !$user->getLastname() || !$user->getEmailGalaxy() || !$user->getSection()) {
                 $this->form->addError(new FormError('Missing parameter(s)'));
             } else {
                 if (!filter_var($user->getEmail(), FILTER_VALIDATE_EMAIL) || !filter_var($user->getEmailGalaxy(), FILTER_VALIDATE_EMAIL)) {
                     $error = new FormError('email invalid');
                     if (!filter_var($user->getEmail(), FILTER_VALIDATE_EMAIL)) {
                         $this->form->get('email')->addError($error);
                     }
                     if (!filter_var($user->getEmailGalaxy(), FILTER_VALIDATE_EMAIL)) {
                         $this->form->get('emailGalaxy')->addError($error);
                     }
                 } else {
                     $section_id = $this->em->getRepository('FaucondorBundle:Section')->find($user->getSection());
                     $section_code = $this->em->getRepository('FaucondorBundle:Section')->findOneBy(array("code" => $user->getSection()));
                     if (!$section_id && !$section_code) {
                         $this->form->get('section')->addError(new FormError('Section with id ' . $user->getSection() . ' not found'));
                     } else {
                         /** @var Section $section */
                         $section = $section_id ? $section_id : $section_code;
                         $this->onSuccess($user, $section);
                         return true;
                     }
                 }
             }
         }
     }
     return false;
 }
开发者ID:ESNFranceG33kTeam,项目名称:sf_faucondor,代码行数:42,代码来源:UserHandler.php

示例2: process

 /**
  * Prepare & process form
  *
  * @author Jeremie Samson <jeremie@ylly.fr>
  *
  * @return bool
  */
 public function process()
 {
     if ($this->request->isMethod('POST')) {
         $this->form->handleRequest($this->request);
         if ($this->form->isValid()) {
             /** @var ModelUserRole $model */
             $model = $this->form->getData();
             if (!$model->getUser() || !$model->getRole()) {
                 $this->form->addError(new FormError('Missing parameter(s)'));
             }
             /** @var User $user */
             $user = $this->em->getRepository('UserBundle:User')->find($model->getUser());
             /** @var Post $role */
             $role = $this->em->getRepository('FaucondorBundle:Post')->find($model->getRole());
             if (!$user) {
                 $this->form->get('user')->addError(new FormError('User with id ' . $model->getUser() . ' not found '));
             }
             if (!$role) {
                 $this->form->get('role')->addError(new FormError('Role with id ' . $model->getRole() . ' not found '));
             }
             $this->onSuccess($user, $role);
             return true;
         }
     }
     return false;
 }
开发者ID:ESNFranceG33kTeam,项目名称:sf_faucondor,代码行数:33,代码来源:UserRoleHandler.php

示例3: process

 /**
  * Process job configuration form.
  *
  * @param JobConfigurationInterface $configuration
  * @param Request $request
  *
  * @return bool
  */
 public function process(JobConfigurationInterface $configuration, Request $request)
 {
     $this->form->setData($configuration);
     $this->form->handleRequest($request);
     if ($this->form->isValid()) {
         $this->manager->add($configuration);
         return true;
     }
     return false;
 }
开发者ID:aistis-,项目名称:JobQueueBundle,代码行数:18,代码来源:JobConfigurationFormHandler.php

示例4: process

 /**
  * @param Order $entity
  *
  * @return bool True when successful processed, false otherwise
  */
 public function process(Order $entity)
 {
     $this->form->setData($entity);
     if ($this->form->handleRequest($this->requestStack->getCurrentRequest())->isValid()) {
         $em = $this->registry->getManagerForClass(Order::class);
         $em->persist($entity);
         $em->flush($entity);
         return true;
     }
     return false;
 }
开发者ID:rodolfobandeira,项目名称:AcmeTemporaryBundle,代码行数:16,代码来源:OrderHandler.php

示例5: uploadComposerAction

 /**
  * @param  Request      $request
  * @return JsonResponse
  */
 public function uploadComposerAction(Request $request)
 {
     $this->composerForm->handleRequest($request);
     if ($this->composerForm->isValid()) {
         $data = $this->composerForm->getData();
         $this->sonataNotificationsBackend->createAndPublish('upload.composer', array('body' => $data['body'], 'channelName' => $request->getSession()->get('channelName'), 'hasDevDependencies' => $data['hasDevDependencies']));
         return new JsonResponse(array('status' => 'ok'));
     }
     $errors = array_map(function (FormError $error) {
         return $error->getMessage();
     }, $this->composerForm->get('body')->getErrors());
     return new JsonResponse(array('status' => 'ko', 'message' => $errors));
 }
开发者ID:Omranic,项目名称:composer-service,代码行数:17,代码来源:ComposerController.php

示例6: process

 /**
  * {@inheritdoc}
  */
 public function process($object = null)
 {
     $this->setObject($object);
     if ($this->validateRequest()) {
         $this->form->handleRequest($this->request);
         if ($this->form->isValid()) {
             return $this->onSuccess();
         }
     } elseif (!is_null($this->getObject())) {
         $this->getForm()->setData($this->getObject());
     }
     return false;
 }
开发者ID:pigroupe,项目名称:SfynxCoreBundle,代码行数:16,代码来源:AbstractFormHandler.php

示例7: changePasswordAction

 public function changePasswordAction(Request $request)
 {
     $this->changePasswordForm->handleRequest($request);
     if ($this->changePasswordForm->isValid()) {
         $user = $this->tokenStorage->getToken()->getUser();
         $formData = $this->changePasswordForm->getData();
         $this->eventDispatcher->dispatch(AdminSecurityEvents::CHANGE_PASSWORD, new ChangePasswordEvent($user, $formData['plainPassword']));
         $request->getSession()->invalidate();
         $this->tokenStorage->setToken(null);
         $request->getSession()->getFlashBag()->set('success', 'admin.change_password_message.success');
         return new RedirectResponse($this->router->generate('fsi_admin_security_user_login'));
     }
     return $this->templating->renderResponse($this->changePasswordActionTemplate, array('form' => $this->changePasswordForm->createView()));
 }
开发者ID:szymach,项目名称:admin-security-bundle,代码行数:14,代码来源:AdminController.php

示例8: process

 public function process()
 {
     $request = $this->getCurrentRequest();
     if (null !== $request) {
         $this->form->setData(new Authorize($request->request->has('accepted'), $request->query->all()));
         if ('POST' === $request->getMethod()) {
             $this->form->handleRequest($request);
             if ($this->form->isValid()) {
                 $this->onSuccess();
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:lutskanu,项目名称:FOSOAuthServerBundle,代码行数:15,代码来源:AuthorizeFormHandler.php

示例9: process

 /**
  * @inheritDoc
  */
 public function process(Request $request)
 {
     // Checking if a form has been set
     if ($this->form == null) {
         return false;
     }
     // Processing the handling of the form
     $this->form->handleRequest($request);
     // Shortcuts of the callbacks
     $onBefore = $this->onBeforeCallback;
     $onSuccess = $this->onSuccessCallback;
     $onFailure = $this->onFailureCallback;
     $onAfter = $this->onAfterCallback;
     if ($onBefore != null) {
         $onBefore($this->form);
     }
     $processed = false;
     if ($this->form->isValid()) {
         if ($onSuccess != null) {
             $onSuccess($this->form);
         }
         $processed = true;
     } else {
         if ($onFailure != null) {
             $onFailure($this->form);
         }
     }
     if ($onAfter != null) {
         $onAfter($this->form);
     }
     return $processed;
 }
开发者ID:Raphy,项目名称:BlihWI,代码行数:35,代码来源:FormHandler.php

示例10: process

 /**
  * {@inheritdoc}
  */
 public function process(FormInterface $form, Request $request)
 {
     $valid = false;
     if ($request->isMethod('POST')) {
         $form->handleRequest($request);
         if ($form->isValid()) {
             $transUnit = $form->getData();
             $translations = $transUnit->filterNotBlankTranslations();
             // only keep translations with a content
             // link new translations to a file to be able to export them.
             foreach ($translations as $translation) {
                 if (!$translation->getFile()) {
                     $file = $this->fileManager->getFor(sprintf('%s.%s.yml', $transUnit->getDomain(), $translation->getLocale()), $this->rootDir . '/Resources/translations');
                     if ($file instanceof FileInterface) {
                         $translation->setFile($file);
                     }
                 }
             }
             if ($transUnit instanceof PropelTransUnit) {
                 // The setTranslations() method only accepts PropelCollections
                 $translations = new \PropelObjectCollection($translations);
             }
             $transUnit->setTranslations($translations);
             $this->storage->persist($transUnit);
             $this->storage->flush();
             $valid = true;
         }
     }
     return $valid;
 }
开发者ID:cybermo,项目名称:LexikTranslationBundle,代码行数:33,代码来源:TransUnitFormHandler.php

示例11: handle

 public function handle(FormInterface $form, Request $request)
 {
     $form->handleRequest($request);
     if (!$form->isValid()) {
         return false;
     }
     $data = $form->getData();
     if ($form->isSubmitted()) {
         $user = $this->userManager->findUserByEmail($data['email']);
         if (is_null($user)) {
             $form->addError(new FormError($this->translator->trans('security.resetting.request.errors.email_not_found')));
             return false;
         }
         if ($user->isPasswordRequestNonExpired($this->tokenTll)) {
             $form->addError(new FormError($this->translator->trans('security.resetting.request.errors.password_already_requested')));
             return false;
         }
         if ($user->getConfirmationToken() === null) {
             $user->setConfirmationToken($this->tokenGenerator->generateToken());
         }
         $user->setPasswordRequestedAt(new \DateTime());
         $this->userManager->resettingRequest($user);
     }
     return true;
 }
开发者ID:neandher,项目名称:Symfony-Multiple-Authentication,代码行数:25,代码来源:ResettingRequestFormHandler.php

示例12: handle

 /**
  * @param FormInterface $form
  * @param Request $request
  * @return bool
  */
 private function handle(FormInterface $form, Request $request)
 {
     $form->handleRequest($request);
     if ($form->isValid()) {
         return true;
     }
     return false;
 }
开发者ID:bigfishcmf,项目名称:bigfishcmf,代码行数:13,代码来源:ResourceFormHandler.php

示例13: handleEdit

 /**
  * @param Badge $badge
  *
  * @return bool True on successfull processing, false otherwise
  */
 public function handleEdit(Badge $badge, $badgeManager = null, $unawardBadge = false)
 {
     $this->form->setData($badge);
     /** @var BadgeRule[]|\Doctrine\Common\Collections\ArrayCollection $originalRules */
     $originalRules = $badge->getRules();
     if ($this->request->isMethod('POST')) {
         $this->form->handleRequest($this->request);
         if ($this->form->isValid()) {
             $this->handleUpload($this->form->get('file')->getData(), $badge);
             $badgeRules = $badge->getRules();
             $userBadges = $badge->getUserBadges();
             if (0 < count($userBadges) && $this->badgeManager->isRuleChanged($badgeRules, $originalRules)) {
                 /** @var \Doctrine\ORM\UnitOfWork $unitOfWork */
                 $unitOfWork = $this->entityManager->getUnitOfWork();
                 $newBadge = clone $badge;
                 $newBadge->setVersion($badge->getVersion() + 1);
                 $unitOfWork->refresh($badge);
                 $badge->setDeletedAt(new \DateTime());
                 $this->entityManager->persist($newBadge);
                 // If the new badge has to be revoked from users already awarded, skip the next part
                 if (!$unawardBadge) {
                     foreach ($userBadges as $userBadge) {
                         // Award new version to previous users
                         $badgeManager->addBadgeToUser($newBadge, $userBadge->getUser());
                     }
                 }
             } else {
                 // Compute which rules was deleted
                 foreach ($badgeRules as $rule) {
                     if ($originalRules->contains($rule)) {
                         $originalRules->removeElement($rule);
                     }
                 }
                 // Delete rules
                 foreach ($originalRules as $rule) {
                     $this->entityManager->remove($rule);
                 }
             }
             $this->entityManager->persist($badge);
             $this->entityManager->flush();
             return true;
         }
     }
     return false;
 }
开发者ID:claroline,项目名称:distribution,代码行数:50,代码来源:BadgeHandler.php

示例14: valid

 /**
  * @param Request $request
  * @param $form
  * @return FormView, bool
  */
 public function valid(Request $request, FormInterface $form)
 {
     $isValid = false;
     if ($request->getMethod() == 'POST') {
         $form->handleRequest($request);
         $isValid = $form->isValid();
     }
     return [$form->createView(), $isValid];
 }
开发者ID:pixocode,项目名称:noostache,代码行数:14,代码来源:Form.php

示例15: handle

 /**
  * @param FormInterface $form
  * @param Request       $request
  * @param array         $options
  *
  * @return bool
  */
 public function handle(FormInterface $form, Request $request, array $options = null)
 {
     $form->handleRequest($request);
     if (!$form->isValid()) {
         return false;
     }
     $this->handler->updateCredentials($form->getData()->getUser(), $form->getData()->getNewPassword());
     return true;
 }
开发者ID:jpsymfony,项目名称:REST-BEHAT,代码行数:16,代码来源:ChangePasswordFormHandler.php


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