/**
  * Symfony controller action that takes the data posted by the editModalAction
  * and persists it.
  *
  * @param Request $request
  * @param $id
  * @return Response
  * @throws \Exception
  */
 public function editApiAction(Request $request, $id)
 {
     $responseData = array();
     $data = $request->get('campaignchain_core_activity');
     $activityService = $this->get('campaignchain.core.activity');
     $this->activity = $activityService->getActivity($id);
     $this->activity->setName($data['name']);
     if ($this->parameters['equals_operation']) {
         /** @var Operation $operation */
         $operation = $activityService->getOperation($id);
         // The activity equals the operation. Thus, we update the operation
         // with the same data.
         $operation->setName($data['name']);
         $this->operations[0] = $operation;
         if ($this->handler->hasContent('editModal')) {
             $content = $this->handler->processContent($this->operations[0], $data[$this->contentModuleFormName]);
         }
     } else {
         throw new \Exception('Multiple Operations for one Activity not implemented yet.');
     }
     $em = $this->getDoctrine()->getManager();
     $em->persist($this->activity);
     $em->persist($this->operations[0]);
     if ($this->handler->hasContent('editModal')) {
         $em->persist($content);
     }
     $hookService = $this->get('campaignchain.core.hook');
     $this->activity = $hookService->processHooks($this->parameters['bundle_name'], $this->parameters['module_identifier'], $this->activity, $data);
     $em->flush();
     $responseData['start_date'] = $responseData['end_date'] = $this->activity->getStartDate()->format(\DateTime::ISO8601);
     $serializer = $this->get('campaignchain.core.serializer.default');
     return new Response($serializer->serialize($responseData, 'json'));
 }
 public function processActivity(Activity $activity, $data)
 {
     $sid = $data['slideshow'];
     $title = $this->availableSlideshows[$sid]['title'];
     $activity->setName($title);
     return $activity;
 }
 public function processActivity(Activity $activity, $data)
 {
     $remoteNewsletter = $this->getRemoteNewsletter($data);
     $activity->setName($remoteNewsletter['title']);
     return $activity;
 }
 public function processActivity(Activity $activity, $data)
 {
     $activity->setName($this->remoteWebinar['subject']);
     $webinarStartDate = new \DateTime($this->remoteWebinar['times'][0]['startTime']);
     $activity->setStartDate($webinarStartDate);
     $webinarEndDate = new \DateTime($this->remoteWebinar['times'][0]['endTime']);
     $activity->setEndDate($webinarEndDate);
     $triggerHook = $this->hookService->getHook(self::TRIGGER_HOOK_IDENTIFIER);
     $activity->setTriggerHook($triggerHook);
     return $activity;
 }