Пример #1
0
 public function newOperationByActivity(Activity $activity, $bundleName, $moduleIdentifier)
 {
     $operationModule = $this->getOperationModule($bundleName, $moduleIdentifier);
     $operation = new Operation();
     $operation->setName($activity->getName());
     $operation->setStartDate($activity->getStartDate());
     $operation->setEndDate($activity->getEndDate());
     $operation->setTriggerHook($activity->getTriggerHook());
     $operation->setActivity($activity);
     $activity->addOperation($operation);
     $operationModule->addOperation($operation);
     $operation->setOperationModule($operationModule);
     return $operation;
 }
Пример #2
0
 public function moveActivity(Activity $activity, $interval)
 {
     $hookService = $this->container->get($activity->getTriggerHook()->getServices()['entity']);
     $hook = $hookService->getHook($activity, Hook::MODE_MOVE);
     if ($hook->getStartDate() !== null) {
         $hook->setStartDate(new \DateTime($hook->getStartDate()->add($interval)->format(\DateTime::ISO8601)));
     }
     if ($hook->getEndDate() !== null) {
         $hook->setEndDate(new \DateTime($hook->getEndDate()->add($interval)->format(\DateTime::ISO8601)));
     }
     /** @var Activity $activity */
     $activity = $hookService->processHook($activity, $hook);
     $this->em->persist($activity);
     // Move all related Operations.
     $operations = $activity->getOperations();
     if ($operations->count()) {
         $operationService = $this->container->get('campaignchain.core.operation');
         foreach ($operations as $operation) {
             $operation = $operationService->moveOperation($operation, $interval);
             //$activity->addOperation($operation);
         }
     }
     $this->em->flush();
     return $activity;
 }