/** * 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; }
/** * Process form * * @param CalendarEvent $entity * * @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'))) { $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); } $this->onSuccess($entity); return true; } } return false; }
/** * Process form * * @param CalendarEvent $entity * @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()) { // 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); } $this->onSuccess($entity, $originalChildren, $this->form->get('notifyInvitedUsers')->getData()); return true; } } return false; }
/** * 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); // 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); } $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; }
/** * 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()) { $phone = $this->request->query->get('phone'); if (!$phone) { $phone = $this->phoneProvider->getPhoneNumber($targetEntity); } $entity->setPhoneNumber($phone); } $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()) { // 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) { // if we don't have "contexts" form field // we should save association between activity and target manually $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; }