當前位置: 首頁>>代碼示例>>PHP>>正文


PHP FormInterface::setData方法代碼示例

本文整理匯總了PHP中Symfony\Component\Form\FormInterface::setData方法的典型用法代碼示例。如果您正苦於以下問題:PHP FormInterface::setData方法的具體用法?PHP FormInterface::setData怎麽用?PHP FormInterface::setData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\Form\FormInterface的用法示例。


在下文中一共展示了FormInterface::setData方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: process

 /**
  * Process form
  *
  * @param  Call $entity
  *
  * @return bool  True on successful processing, false otherwise
  */
 public function process(Call $entity)
 {
     $targetEntityClass = $this->request->get('entityClass');
     $targetEntityId = $this->request->get('entityId');
     $options = [];
     if ($targetEntityClass && $this->request->getMethod() === 'GET') {
         $targetEntity = $this->entityRoutingHelper->getEntity($targetEntityClass, $targetEntityId);
         if (!$entity->getId()) {
             $entity->setPhoneNumber($this->phoneProvider->getPhoneNumber($targetEntity));
         }
         $options = ['phone_suggestions' => array_unique(array_map(function ($item) {
             return $item[0];
         }, $this->phoneProvider->getPhoneNumbers($targetEntity)))];
     }
     $this->form = $this->formFactory->createNamed($this->formName, $this->formType, $entity, $options);
     $this->form->setData($entity);
     if (in_array($this->request->getMethod(), array('POST', 'PUT'))) {
         $this->form->submit($this->request);
         if ($this->form->isValid()) {
             if ($targetEntityClass) {
                 $targetEntity = $this->entityRoutingHelper->getEntity($targetEntityClass, $targetEntityId);
                 $this->callActivityManager->addAssociation($entity, $targetEntity);
                 $phones = $this->phoneProvider->getPhoneNumbers($targetEntity);
                 foreach ($phones as $phone) {
                     if ($entity->getPhoneNumber() === $phone[0]) {
                         $this->callActivityManager->addAssociation($entity, $phone[1]);
                     }
                 }
             }
             $this->onSuccess($entity);
             return true;
         }
     }
     return false;
 }
開發者ID:rodolfobandeira,項目名稱:crm,代碼行數:42,代碼來源:CallHandler.php

示例2: process

 /**
  * Process form
  *
  * @param  CalendarEvent $entity
  * @throws \LogicException
  *
  * @return bool  True on successful processing, false otherwise
  */
 public function process(CalendarEvent $entity)
 {
     if (!$entity->getCalendar()) {
         if ($this->securityFacade->getLoggedUser() && $this->securityFacade->getOrganization()) {
             /** @var Calendar $defaultCalendar */
             $defaultCalendar = $this->manager->getRepository('OroCalendarBundle:Calendar')->findDefaultCalendar($this->securityFacade->getLoggedUser()->getId(), $this->securityFacade->getOrganization()->getId());
             $entity->setCalendar($defaultCalendar);
         } else {
             throw new \LogicException('Current user did not define');
         }
     }
     $this->form->setData($entity);
     if (in_array($this->request->getMethod(), array('POST', 'PUT'))) {
         $this->form->submit($this->request);
         if ($this->form->isValid()) {
             $targetEntityClass = $this->entityRoutingHelper->getEntityClassName($this->request);
             if ($targetEntityClass) {
                 $targetEntityId = $this->entityRoutingHelper->getEntityId($this->request);
                 $targetEntity = $this->entityRoutingHelper->getEntityReference($targetEntityClass, $targetEntityId);
                 $action = $this->entityRoutingHelper->getAction($this->request);
                 if ($action === 'activity') {
                     $this->activityManager->addActivityTarget($entity, $targetEntity);
                 }
                 if ($action === 'assign' && $targetEntity instanceof User && $targetEntityId !== $this->securityFacade->getLoggedUserId()) {
                     /** @var Calendar $defaultCalendar */
                     $defaultCalendar = $this->manager->getRepository('OroCalendarBundle:Calendar')->findDefaultCalendar($targetEntity->getId(), $targetEntity->getOrganization()->getId());
                     $entity->setCalendar($defaultCalendar);
                 }
             }
             $this->onSuccess($entity);
             return true;
         }
     }
     return false;
 }
開發者ID:xamin123,項目名稱:platform,代碼行數:43,代碼來源:CalendarEventHandler.php

示例3: process

 /**
  * Process form
  *
  * @param  CalendarEvent $entity
  *
  * @throws \LogicException
  *
  * @return bool  True on successful processing, false otherwise
  */
 public function process(CalendarEvent $entity)
 {
     $this->form->setData($entity);
     if (in_array($this->request->getMethod(), array('POST', 'PUT'))) {
         $originalChildren = new ArrayCollection();
         foreach ($entity->getChildEvents() as $childEvent) {
             $originalChildren->add($childEvent);
         }
         $this->form->submit($this->request);
         if ($this->form->isValid()) {
             $this->ensureCalendarSet($entity);
             $targetEntityClass = $this->entityRoutingHelper->getEntityClassName($this->request);
             if ($targetEntityClass) {
                 $targetEntityId = $this->entityRoutingHelper->getEntityId($this->request);
                 $targetEntity = $this->entityRoutingHelper->getEntityReference($targetEntityClass, $targetEntityId);
                 $action = $this->entityRoutingHelper->getAction($this->request);
                 if ($action === 'activity') {
                     $this->activityManager->addActivityTarget($entity, $targetEntity);
                 }
                 if ($action === 'assign' && $targetEntity instanceof User && $targetEntityId !== $this->securityFacade->getLoggedUserId()) {
                     /** @var Calendar $defaultCalendar */
                     $defaultCalendar = $this->manager->getRepository('OroCalendarBundle:Calendar')->findDefaultCalendar($targetEntity->getId(), $targetEntity->getOrganization()->getId());
                     $entity->setCalendar($defaultCalendar);
                 }
             }
             $this->onSuccess($entity, $originalChildren, $this->form->get('notifyInvitedUsers')->getData());
             return true;
         }
     }
     return false;
 }
開發者ID:northdakota,項目名稱:platform,代碼行數:40,代碼來源:CalendarEventHandler.php

示例4: process

 /**
  * Process form
  *
  * @param  EmailTemplate $entity
  *
  * @return bool True on successful processing, false otherwise
  */
 public function process(EmailTemplate $entity)
 {
     // always use default locale during template edit in order to allow update of default locale
     $entity->setLocale($this->defaultLocale);
     if ($entity->getId()) {
         // refresh translations
         $this->manager->refresh($entity);
     }
     $this->form->setData($entity);
     if (in_array($this->request->getMethod(), array('POST', 'PUT'))) {
         // deny to modify system templates
         if ($entity->getIsSystem() && !$entity->getIsEditable()) {
             $this->form->addError(new FormError($this->translator->trans('oro.email.handler.attempt_save_system_template')));
             return false;
         }
         $this->form->submit($this->request);
         if ($this->form->isValid()) {
             // mark an email template creating by an user as editable
             if (!$entity->getId()) {
                 $entity->setIsEditable(true);
             }
             $this->manager->persist($entity);
             $this->manager->flush();
             return true;
         }
     }
     return false;
 }
開發者ID:Maksold,項目名稱:platform,代碼行數:35,代碼來源:EmailTemplateHandler.php

示例5: process

 /**
  * Process form
  *
  * @param  Task $entity
  *
  * @return bool  True on successful processing, false otherwise
  */
 public function process(Task $entity)
 {
     $action = $this->entityRoutingHelper->getAction($this->request);
     $targetEntityClass = $this->entityRoutingHelper->getEntityClassName($this->request);
     $targetEntityId = $this->entityRoutingHelper->getEntityId($this->request);
     if ($targetEntityClass && !$entity->getId() && $this->request->getMethod() === 'GET' && $action === 'assign' && is_a($targetEntityClass, 'Oro\\Bundle\\UserBundle\\Entity\\User', true)) {
         $entity->setOwner($this->entityRoutingHelper->getEntity($targetEntityClass, $targetEntityId));
         FormUtils::replaceField($this->form, 'owner', ['read_only' => true]);
     }
     $this->form->setData($entity);
     if (in_array($this->request->getMethod(), array('POST', 'PUT'))) {
         $this->form->submit($this->request);
         if ($this->form->isValid()) {
             // TODO: should be refactored after finishing BAP-8722
             // Contexts handling should be moved to common for activities form handler
             if ($this->form->has('contexts')) {
                 $contexts = $this->form->get('contexts')->getData();
                 $this->activityManager->setActivityTargets($entity, $contexts);
             } elseif ($targetEntityClass && $action === 'activity') {
                 // if we don't have "contexts" form field
                 // we should save association between activity and target manually
                 $this->activityManager->addActivityTarget($entity, $this->entityRoutingHelper->getEntityReference($targetEntityClass, $targetEntityId));
             }
             $this->onSuccess($entity);
             return true;
         }
     }
     return false;
 }
開發者ID:antrampa,項目名稱:crm,代碼行數:36,代碼來源:TaskHandler.php

示例6: process

 /**
  * Process form
  *
  * @param  Issue $entity
  *
  * @return bool  True on successful processing, false otherwise
  */
 public function process(Issue $entity)
 {
     $action = $this->entityRoutingHelper->getAction($this->request);
     $targetEntityClass = $this->entityRoutingHelper->getEntityClassName($this->request);
     $targetEntityId = $this->entityRoutingHelper->getEntityId($this->request);
     if ($targetEntityClass && !$entity->getId() && $this->request->getMethod() === 'GET' && $action === 'assign' && is_a($targetEntityClass, 'Oro\\Bundle\\UserBundle\\Entity\\User', true)) {
         $entity->setAssignee($this->entityRoutingHelper->getEntity($targetEntityClass, $targetEntityId));
         FormUtils::replaceField($this->form, 'assignee', ['read_only' => true]);
     }
     $this->form->setData($entity);
     if (in_array($this->request->getMethod(), array('POST', 'PUT'))) {
         $this->form->submit($this->request);
         if ($this->form->isValid()) {
             /* if ($targetEntityClass && $action === 'activity') {
                    $this->activityManager->addActivityTarget(
                        $entity,
                        $this->entityRoutingHelper->getEntityReference($targetEntityClass, $targetEntityId)
                    );
                }*/
             $this->onSuccess($entity);
             return true;
         }
     }
     return false;
 }
開發者ID:sergeypererva,項目名稱:platform-application,代碼行數:32,代碼來源:IssueHandler.php

示例7: 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

示例8: process

 /**
  * @param Quote $quote
  * @return Order|null
  */
 public function process(Quote $quote)
 {
     $this->form->setData($quote);
     if ($this->request->isMethod('POST')) {
         $this->form->submit($this->request);
         if ($this->form->isValid()) {
             return $this->onSuccess($quote, $this->form->getData());
         }
     }
     return null;
 }
開發者ID:adam-paterson,項目名稱:orocommerce,代碼行數:15,代碼來源:QuoteToOrderHandler.php

示例9: process

 /**
  * @param ShoppingList $shoppingList
  * @return boolean
  */
 public function process(ShoppingList $shoppingList)
 {
     $this->form->setData($shoppingList);
     if (in_array($this->request->getMethod(), ['POST', 'PUT'], true)) {
         $this->form->submit($this->request);
         if ($this->form->isValid()) {
             return $this->onSuccess($shoppingList);
         }
     }
     return false;
 }
開發者ID:adam-paterson,項目名稱:orocommerce,代碼行數:15,代碼來源:ShoppingListCreateRfpHandler.php

示例10: 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

示例11: process

 /**
  * @param Channel $entity
  *
  * @return bool
  */
 public function process(Channel $entity)
 {
     $this->form->setData($entity);
     if (in_array($this->request->getMethod(), ['POST', 'PUT'])) {
         $this->form->submit($this->request);
         if (!$this->request->get(self::UPDATE_MARKER, false) && $this->form->isValid()) {
             $this->doSave($entity);
             return true;
         }
     }
     return false;
 }
開發者ID:dairdr,項目名稱:crm,代碼行數:17,代碼來源:ChannelHandler.php

示例12: process

 /**
  * Process method for handler
  * @param AttributeGroup $group
  *
  * @return boolean
  */
 public function process(AttributeGroup $group)
 {
     $this->form->setData($group);
     if ($this->request->isMethod('POST')) {
         $this->form->bind($this->request);
         if ($this->form->isValid()) {
             $this->onSuccess($group);
             return true;
         }
     }
     return false;
 }
開發者ID:javiersantos,項目名稱:pim-community-dev,代碼行數:18,代碼來源:AttributeGroupHandler.php

示例13: process

 /**
  * Process form
  *
  * @param AccountGroup $entity
  * @return bool  True on successful processing, false otherwise
  */
 public function process(AccountGroup $entity)
 {
     $this->form->setData($entity);
     if ($this->request->isMethod('POST')) {
         $this->form->submit($this->request);
         if ($this->form->isValid()) {
             $this->onSuccess($entity, $this->form->get('appendAccounts')->getData(), $this->form->get('removeAccounts')->getData());
             return true;
         }
     }
     return false;
 }
開發者ID:adam-paterson,項目名稱:orocommerce,代碼行數:18,代碼來源:AccountGroupHandler.php

示例14: process

 /**
  * Process form
  *
  * @param  Warehouse $warehouse
  * @return bool True on successfull processing, false otherwise
  */
 public function process(Warehouse $warehouse)
 {
     $this->form->setData($warehouse);
     if (in_array($this->request->getMethod(), array('POST', 'PUT'))) {
         $this->form->submit($this->request);
         if ($this->form->isValid()) {
             $this->onSuccess($warehouse);
             return true;
         }
     }
     return false;
 }
開發者ID:rockordier,項目名稱:festivalwarehousebundle,代碼行數:18,代碼來源:WarehouseHandler.php

示例15: process

 /**
  * Process method for handler
  * @param Channel $channel
  *
  * @return boolean
  */
 public function process(Channel $channel)
 {
     $this->form->setData($channel);
     if ($this->request->isMethod('POST')) {
         $this->form->bind($this->request);
         if ($this->form->isValid()) {
             $this->onSuccess($channel);
             return true;
         }
     }
     return false;
 }
開發者ID:javiersantos,項目名稱:pim-community-dev,代碼行數:18,代碼來源:ChannelHandler.php


注:本文中的Symfony\Component\Form\FormInterface::setData方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。