コード例 #1
0
ファイル: TaskHandler.php プロジェクト: antrampa/crm
 /**
  * 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;
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function startTracking(User $user, Task $task)
 {
     $tracker = $this->trackerRepository->retrieveUserTracker($user);
     if ($tracker && $tracker->getTask()->getId() === $task->getId()) {
         return;
     }
     if ($tracker) {
         // stop previous tracker
         $this->processStopTracking($tracker);
     }
     $tracker = $this->trackerFactory->create($user, $task);
     $this->trackerRepository->save($tracker);
 }
コード例 #3
0
ファイル: TaskHandler.php プロジェクト: rodolfobandeira/crm
 /**
  * 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()) {
             if ($targetEntityClass && $action === 'activity') {
                 $this->activityManager->addActivityTarget($entity, $this->entityRoutingHelper->getEntityReference($targetEntityClass, $targetEntityId));
             }
             $this->onSuccess($entity);
             return true;
         }
     }
     return false;
 }
コード例 #4
0
 /**
  * @Route("/update/{id}", name="orocrm_task_update", requirements={"id"="\d+"})
  * @Template
  * @Acl(
  *      id="orocrm_task_update",
  *      type="entity",
  *      class="OroCRMTaskBundle:Task",
  *      permission="EDIT"
  * )
  */
 public function updateAction(Task $task)
 {
     $formAction = $this->get('router')->generate('orocrm_task_update', ['id' => $task->getId()]);
     return $this->update($task, $formAction);
 }
コード例 #5
0
 /**
  * {@inheritdoc}
  */
 public function listAllFilteredByTask(Task $task)
 {
     return $this->findBy(['task' => $task->getId()]);
 }
コード例 #6
0
 /**
  * @return int
  */
 public function getId()
 {
     return $this->task->getId();
 }