/** * {@inheritdoc} */ public function process(Request $request, $grantType = 'password') { $account = $this->records->getAccountByEmail($this->submittedForm->get('email')->getData()); if (!$account) { return null; } $oauth = $this->records->getOauthByGuid($account->getGuid()); $requestPassword = $this->submittedForm->get('password')->getData(); if ($this->isValidPassword($oauth, $requestPassword) === false) { return null; } $accessToken = $this->provider->getAccessToken('password', ['guid' => $account->getGuid()]); $this->session->addAccessToken('local', $accessToken)->createAuthorisation($account->getGuid()); $request->query->set('code', Uuid::uuid4()->toString()); try { parent::process($request, $grantType); $this->finish($request); $this->feedback->info('Login successful.'); } catch (DisabledAccountException $ex) { $this->session->addRedirect($this->urlGenerator->generate('authenticationLogin')); if ($this->session->getAuthorisation()) { $this->dispatchEvent(MembersEvents::MEMBER_LOGIN_FAILED_ACCOUNT_DISABLED, $this->session->getAuthorisation()); } } return $this->session->popRedirect()->getResponse(); }
/** * This method is here to make your life better, so overwrite it * * @param \Symfony\Component\Form\Form $form the valid form * @param \Taskeet\MainBundle\Entity\Event $Event your \Taskeet\MainBundle\Entity\Event object */ public function preSave(\Symfony\Component\Form\Form $form, \Taskeet\MainBundle\Entity\Event $Event) { if (!$form->get('reminder')->getData() instanceof DateTime && $form->get('reminder')->getData()) { $date = clone $form->get('startDate')->getData(); $date->sub(new DateInterval($form->get('reminder')->getData())); $Event->setReminder($date); } }
/** * @param Form $form * @param RuleAction $action * @return void */ public function formIsSubmitted(Form $form, RuleAction $action) { $params = $this->getParams($action); $category = $form->get('category')->getData(); $params['category_id'] = $category->getId(); $action->setRawParams($params); }
private function customValid(Form $form, $type) { switch ($type) { case 'page': if ($form->get('link')->isEmpty()) { $form->get('link')->addError(new FormError('Укажите имя для ссылки')); } break; case 'news': if ($form->get('title')->isEmpty()) { $form->get('title')->addError(new FormError('Укажите заголовок')); } if ($form->get('body')->isEmpty()) { $form->get('body')->addError(new FormError('Отсутствует превью')); } if ($form->get('preview')->isEmpty()) { $form->get('preview')->addError(new FormError('Отсутствует превью')); } if ($form->get('caption')->isEmpty() && !$form->get('link')->isEmpty()) { $form->get('caption')->addError(new FormError('Укажите источник')); } if (!$form->get('caption')->isEmpty() && $form->get('link')->isEmpty()) { $form->get('link')->addError(new FormError('Укажите ссылку на источник')); } break; default: break; } if ($form->get('datePublication')->isEmpty()) { $form->get('datePublication')->addError(new FormError('Укажите дату публикации')); } }
/** * This method is here to make your life better, so overwrite it * * @param \Symfony\Component\Form\Form $form the valid form * @param \Taskeet\MainBundle\Entity\Ticket $Ticket your \Taskeet\MainBundle\Entity\Ticket object */ public function postSave(\Symfony\Component\Form\Form $form, \Taskeet\MainBundle\Entity\Ticket $Ticket) { $proveedor = $this->container->get('security.acl.provider'); $idObjeto = ObjectIdentity::fromDomainObject($Ticket); //poniendo al usuario logueado como owner $this->setPermissions($proveedor, $idObjeto, $this->getUser(), MaskBuilder::MASK_OWNER); //si la tarea tiene asignado un empleado se le asigna el perm operator if ($assignedTo = $Ticket->getAssignedTo()) { $this->setPermissions($proveedor, $idObjeto, $assignedTo, MaskBuilder::MASK_EDIT); } if ($data = $form->get('repeat')->getData()) { $start = clone $form->get('startDate')->getData(); $end = clone $form->get('dueDate')->getData(); $ocurrences = $form->get('ocurrences')->getData(); $interval = new DateInterval($form->get('repeat')->getData()); $periodo = new \DatePeriod($start, $interval, $ocurrences, \DatePeriod::EXCLUDE_START_DATE); $em = $this->getDoctrine()->getManager(); foreach ($periodo as $key => $fecha) { $ticket = clone $Ticket; $ticket->setStartDate($fecha); $ticket->setDueDate($end->add($interval)); $ticket->setTitle(sprintf('%s-%s', $Ticket->getTitle(), $key)); $ticket->setSlug(sprintf('%s-%s', $Ticket->getSlug(), $key)); $this->saveObject($ticket); $idObjeto = ObjectIdentity::fromDomainObject($ticket); $this->setPermissions($proveedor, $idObjeto, $this->getUser(), MaskBuilder::MASK_OWNER); $this->setPermissions($proveedor, $idObjeto, $ticket->getAssignedTo(), MaskBuilder::MASK_EDIT); } } }
/** * Get the expiration time of the ban based on the fields of the form * * @param Form $form The form * @return \TimeDate|null */ private function getExpiration($form) { if ($form->get('automatic_expiration')->getData()) { return $form->get('expiration')->getData(); } else { return null; } }
/** * This method is here to make your life better, so overwrite it * * @param \Symfony\Component\Form\Form $form the valid form * @param \Taskeet\MainBundle\Entity\Event $Event your \Taskeet\MainBundle\Entity\Event object */ public function preSave(\Symfony\Component\Form\Form $form, \Taskeet\MainBundle\Entity\Event $Event) { $Event->setOwner($this->getUser()); if ($form->get('remind')->getData()) { $date = clone $form->get('startDate')->getData(); $date->sub(new DateInterval($form->get('remind')->getData())); $Event->setReminder($date); } }
/** * Handle the admin notes form * @param Form $form The form * @param Player $player The player in question * @param Player $me The currently logged in player * @return Form The updated form */ private function handleAdminNotesForm($form, $player, $me) { $notes = $form->get('notes')->getData(); if ($form->get('save_and_sign')->isClicked()) { $notes .= ' — ' . $me->getUsername() . ' on ' . TimeDate::now()->toRFC2822String(); } $player->setAdminNotes($notes); $this->getFlashBag()->add('success', "The admin notes for {$player->getUsername()} have been updated"); // Reset the form so that the user sees the updated admin notes return $this->creator->create(); }
/** * This method is here to make your life better, so overwrite it * * @param \Symfony\Component\Form\Form $form the valid form * @param \Taskeet\MainBundle\Entity\User $User your \Taskeet\MainBundle\Entity\User object */ public function preSave(\Symfony\Component\Form\Form $form, \Taskeet\MainBundle\Entity\User $User) { if ($form->get('password')->getData()) { $factory = $this->get('security.encoder_factory'); $encoder = $factory->getEncoder($User); $password = $encoder->encodePassword($form->get('password')->getData(), $User->getSalt()); $User->setPassword($password); } if ($this->get('security.context')->isGranted(array(new Expression('not hasRole("ROLE_ADMIN") and hasRole("ROLE_JEFE_DPTO")')))) { $dpto = $this->getEntityManager()->getRepository('TaskeetMainBundle:Department')->findOneByOwner($this->getUser()); $User->setDepartment($dpto); } }
protected function save(Form $form) { try { ShoppingFluxConfigQuery::setToken($form->get("token")->getData()); ShoppingFluxConfigQuery::setDefaultLangId($form->get("lang_id")->getData()); ShoppingFluxConfigQuery::setDeliveryModule($form->get("delivery_module_id")->getData()); ShoppingFluxConfigQuery::setProd($form->get("prod")->getData()); ShoppingFluxConfigQuery::setEcotaxRule($form->get("ecotax_id")->getData()); } catch (\Exception $e) { return "An error occured during the recording of the values (" . $e->getMessage() . ")"; } return true; }
protected function createFilterQuery(Form $form) { $qb = $this->getProfessionRepository()->createQueryBuilder('p')->select('p', 'pk')->leftJoin('p.professionkind', 'pk'); if ($form->get('name')->getNormData()) { $qb->andWhere('p.name LIKE :name'); $qb->setParameter('name', '%' . $form->get('name')->getNormData() . '%'); } if ($form->has('sort_field') && $form->get('sort_field')->getNormData()) { $qb->orderBy('p.' . $form->get('sort_field')->getNormData(), $form->get('sort_order')->getNormData()); } else { $qb->orderBy('p.id', 'ASC'); } return $qb->getQuery(); }
protected function createFilterQuery(Form $form) { $qb = $this->getTechnicalexaminationtypeRepository()->createQueryBuilder('tet'); if ($form->get('name')->getNormData()) { $qb->andWhere('tet.name LIKE :name'); $qb->setParameter('name', '%' . $form->get('name')->getNormData() . '%'); } if ($form->has('sort_field') && $form->get('sort_field')->getNormData()) { $qb->orderBy('tet.' . $form->get('sort_field')->getNormData(), $form->get('sort_order')->getNormData()); } else { $qb->orderBy('tet.id', 'ASC'); } return $qb->getQuery(); }
protected function createFilterQuery(Form $form) { $qb = $this->getEquipmentRepository()->createQueryBuilder('e')->select('e', 'enterp', 'subd', 'esg')->leftJoin('e.subdivision', 'subd')->leftJoin('subd.enterprise', 'enterp')->leftJoin('e.equipmentsubgroup', 'esg'); if ($form->get('name')->getNormData()) { $qb->andWhere('e.name LIKE :name'); $qb->setParameter('name', '%' . $form->get('name')->getNormData() . '%'); } if ($form->has('sort_field') && $form->get('sort_field')->getNormData()) { $qb->orderBy('e.' . $form->get('sort_field')->getNormData(), $form->get('sort_order')->getNormData()); } else { $qb->orderBy('e.id', 'ASC'); } return $qb->getQuery(); }
protected function createFilterQuery(Form $form) { $qb = $this->getUserRepository()->createQueryBuilder('u'); if ($form->get('email')->getNormData()) { $qb->andWhere('u.email LIKE :email'); $qb->setParameter('email', '%' . $form->get('email')->getNormData() . '%'); } if ($form->has('sort_field') && $form->get('sort_field')->getNormData()) { $qb->orderBy('u.' . $form->get('sort_field')->getNormData(), $form->get('sort_order')->getNormData()); } else { $qb->orderBy('u.id', 'ASC'); } return $qb->getQuery(); }
protected function createFilterQuery(Form $form) { $qb = $this->getTraumaRepository()->createQueryBuilder('t')->select('t', 'e', 'enterp')->leftJoin('t.employee', 'e')->leftJoin('e.enterprise', 'enterp'); if ($form->get('name')->getNormData()) { $qb->andWhere('t.name LIKE :name'); $qb->setParameter('name', '%' . $form->get('name')->getNormData() . '%'); } if ($form->has('sort_field') && $form->get('sort_field')->getNormData()) { $qb->orderBy('t.' . $form->get('sort_field')->getNormData(), $form->get('sort_order')->getNormData()); } else { $qb->orderBy('t.id', 'ASC'); } return $qb->getQuery(); }
protected function createFilterQuery(Form $form) { $qb = $this->getEquipmentgroupRepository()->createQueryBuilder('eg'); if ($form->get('name')->getNormData()) { $qb->andWhere('eg.name LIKE :name'); $qb->setParameter('name', '%' . $form->get('name')->getNormData() . '%'); } if ($form->has('sort_field') && $form->get('sort_field')->getNormData()) { $qb->orderBy('eg.' . $form->get('sort_field')->getNormData(), $form->get('sort_order')->getNormData()); } else { $qb->orderBy('eg.id', 'ASC'); } return $qb->getQuery(); }
protected function createFilterQuery(Form $form) { $qb = $this->getPageRepository()->createQueryBuilder('pk'); if ($form->get('title')->getNormData()) { $qb->andWhere('pk.title LIKE :title'); $qb->setParameter('title', '%' . $form->get('title')->getNormData() . '%'); } if ($form->has('sort_field') && $form->get('sort_field')->getNormData()) { $qb->orderBy('pk.' . $form->get('sort_field')->getNormData(), $form->get('sort_order')->getNormData()); } else { $qb->orderBy('pk.title', 'ASC'); } return $qb->getQuery(); }
/** * Get the selected product attribute values from the card add form. * * @param Form $form Cart add form. * * @return array A map of attribute ids => selected attribute value id. */ protected function getLegacyProductAttributesInForm(Form $form) { $product = ProductQuery::create()->findPk($form->get('product')->getData()); if (null === $product) { return []; } $legacyProductAttributes = []; foreach ($product->getTemplate()->getAttributes() as $attribute) { $legacyProductAttributeFieldKey = CartAddFormExtension::LEGACY_PRODUCT_ATTRIBUTE_FIELD_PREFIX . $attribute->getId(); if (null !== $form->get($legacyProductAttributeFieldKey)) { $legacyProductAttributes[$attribute->getId()] = $form->get($legacyProductAttributeFieldKey)->getData(); } } return $legacyProductAttributes; }
/** * This method is here to make your life better, so overwrite it * * @param \Symfony\Component\Form\Form $form the valid form * @param \Taskeet\MainBundle\Entity\Department $Department your \Taskeet\MainBundle\Entity\Department object */ public function preSave(\Symfony\Component\Form\Form $form, \Taskeet\MainBundle\Entity\Department $Department) { if ($Department->getOwner() != $form->get('owner')->getData()) { $proveedor = $this->container->get('security.acl.provider'); $idObjeto = ObjectIdentity::fromDomainObject($oferta); $idUsuario = UserSecurityIdentity::fromAccount($tienda); $acl = $proveedor->findAcl($idObjeto, array($idUsuario)); $aces = $acl->getObjectAces(); foreach ($aces as $index => $ace) { $acl->deleteObjectAce($index); } $proveedor->updateAcl($acl); } if ($form->get('parent')->getData() == $form->get('name')->getData()) { $Department->setParent(NULL); } }
/** * @param Form $form * @param RuleAction $action * @return void */ public function formIsSubmitted(Form $form, RuleAction $action) { $params = $this->getParams($action); $tags = $form->get('tags')->getData(); $params['tag_ids'] = array(); foreach ($tags as $tag) { $params['tag_ids'][] = $tag->getId(); } $action->setRawParams($params); }
protected function translationAfterFlushClb($response, $action, $row) { if (count($this->translationFields)) { $langs = $this->get('nyrocms')->getLocaleNames($row); $defaultLocale = $this->get('nyrocms')->getDefaultLocale($row); unset($langs[$defaultLocale]); $om = $this->get('nyrocms_db')->getObjectManager(); $propertyAccess = PropertyAccess::createPropertyAccessor(); foreach ($langs as $lg => $lang) { $row->setTranslatableLocale($lg); $om->refresh($row); foreach ($this->translationFields as $field => $options) { $fieldName = 'lang_' . $lg . '_' . $field; $propertyAccess->setValue($row, $field, $this->translationForm->get($fieldName)->getData()); } $om->flush(); } } }
/** * Build an absolute URL using the value of a form parameter. * * @param string $parameterName the form parameter name * @param string $default a default value for the form parameter. If not defined, the configured base URL is used. * @return string an absolute URL */ public function getFormDefinedUrl($parameterName, $default = null) { $formDefinedUrl = $this->form->get($parameterName)->getData(); if (empty($formDefinedUrl)) { if ($default === null) { $default = ConfigQuery::read('base_url', '/'); } $formDefinedUrl = $default; } return URL::getInstance()->absoluteUrl($formDefinedUrl); }
public function process() { if ($this->form->isValid()) { if ('POST' == $this->request->getMethod()) { $recruiters = $this->em->getRepository('ESNUserBundle:User')->findRecruiters(); /** @var ArrayCollection $recruiters_selected */ $recruiters_selected = $this->form->get('esner')->getData(); /** @var User $recruiter */ foreach ($recruiters as $recruiter) { if (!$recruiters_selected->contains($recruiter)) { $recruiter->removeRole(User::ROLE_RECRUITER); } } $this->onSuccess($recruiters_selected); $this->em->flush(); return true; } } return false; }
/** * Returns the absolute URL to redirect the user to if the form is successfully processed. * * @param string $default the default URL. If not given, the configured base URL is used. * * @return string an absolute URL */ public function getSuccessUrl($default = null) { $successUrl = $this->form->get('success_url')->getData(); if (empty($successUrl)) { if ($default === null) { $default = ConfigQuery::read('base_url', '/'); } $successUrl = $default; } return URL::getInstance()->absoluteUrl($successUrl); }
public function validate(Form $form) { if (!$form->has('uploadedProductImages')) { return TRUE; } if ($form->get('uploadedProductImages')->isRequired() && !array_filter($form->getData()->getUploadedProductImages())) { $form->get('uploadedProductImages')->addError(new FormError($this->_translator->trans('product.uploaded_product_images.not_blank', [], 'validators'))); return FALSE; } foreach ($form->getData()->getUploadedProductImages() as $uploadedProductImage) { $productImage = (new ProductImage())->setImageProductFile($uploadedProductImage); $errors = $this->_validator->validate($productImage); if (count($errors) === 0) { return TRUE; } foreach ($errors as $error) { $form->get('uploadedProductImages')->addError(new FormError($error->getMessage())); } return FALSE; } return TRUE; }
private function hasChild(\Symfony\Component\Form\Form $form, $name) { if ($form->has($name)) { // check duplicate name $child = $form->get($name); if (!$child->isValid()) { $this->clearError($child); } return true; } foreach ($form as $child) { if ($this->hasChild($child, $name)) { return true; } } return false; }
/** * Add coupon to cart * * @param Form $couponApplyFormType Coupon Apply type * * @return array * * @Route( * path = "/apply", * name = "store_coupon_apply", * methods = {"POST"} * ) * * @AnnotationForm( * class = "store_cart_coupon_form_type_coupon_apply", * name = "couponApplyFormType", * handleRequest = true, * ) */ public function applyAction(Form $couponApplyFormType) { $translator = $this->get('translator'); $couponCode = $couponApplyFormType->get('code')->getData(); /** * @var CartInterface $cart */ $cart = $this->get('elcodi.wrapper.cart')->get(); try { $this->get('elcodi.manager.cart_coupon')->addCouponByCode($cart, $couponCode); $message = $translator->trans('store.coupon.applied.message_ok'); $this->addFlash('info', $message); } catch (AbstractCouponException $e) { $message = $translator->trans('store.coupon.applied.message_ko'); $this->addFlash('error', $message); } return $this->redirectToRoute('store_cart_view'); }
protected function createFilterQuery(Form $form) { $qb = $this->getSubdivisionRepository()->createQueryBuilder('s')->select('s', 'sd')->leftJoin('s.enterprise', 'sd'); if ($form->get('name')->getNormData()) { $qb->andWhere('s.name LIKE :name'); $qb->setParameter('name', '%' . $form->get('name')->getNormData() . '%'); } if ($form->get('enterprise')->getNormData()) { $qb->andWhere('IDENTITY(s.enterprise) = :enterprise'); $qb->setParameter('enterprise', $form->get('enterprise')->getNormData()); } if ($form->has('sort_field') && $form->get('sort_field')->getNormData()) { $qb->orderBy('s.' . $form->get('sort_field')->getNormData(), $form->get('sort_order')->getNormData()); } else { $qb->orderBy('s.id', 'ASC'); } return $qb->getQuery(); }
private function getErrors(\Symfony\Component\Form\Form $form, array &$elements, array &$forms, array &$errors) { $name = array_shift($elements); if ($form->has($name)) { $child = $form->get($name); $forms[$name] = $child; $errors[$name] = $child->getErrors(); if (empty($elements)) { return $name; } return $this->getErrors($child, $elements, $forms, $errors); } else { if (count($forms)) { $last_name = null; foreach ($forms as $name => $child) { $last_name = $name; } return $last_name; } return null; } }
/** * @param Transaction $transaction * @param Form $form */ public function update(Transaction $transaction, Form $form) { $this->em->persist($transaction); // Original details $originalDetails = new ArrayCollection($this->em->getRepository('AppBundle:TransactionDetail')->findBy(array('transaction' => $transaction))); // Remove old details foreach ($originalDetails as $detail) { if (!$transaction->getDetails()->contains($detail)) { $this->em->remove($detail); } } $this->em->flush(); $copy = $form->get('copy')->getData(); if ($copy instanceof UploadedFile) { // Remove copy $old = $this->em->getRepository('AppBundle:TransactionCopy')->findBy(['transaction' => $transaction]); foreach ($old as $o) { $this->copyDelete($o); } // Add copy $this->copyAdd($transaction, $copy); } }