/**
  * Loads fixtures.
  *
  * @param \Doctrine\Common\Persistence\ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $processSchedule = new ProcessSchedule();
     $processSchedule->setDayOfWeek(null);
     $processSchedule->setMonth(null);
     $processSchedule->setDayOfMonth(null);
     $processSchedule->setHour(null);
     $processSchedule->setMinute(null);
     $processSchedule->setType('collector.example.main');
     $manager->persist($processSchedule);
     $this->addReference('process-schedule-1', $processSchedule);
     $processSchedule = new ProcessSchedule();
     $processSchedule->setDayOfWeek(null);
     $processSchedule->setMonth(null);
     $processSchedule->setDayOfMonth(null);
     $processSchedule->setHour(15);
     $processSchedule->setMinute(10);
     $processSchedule->setType('worker.sugar_crm.main');
     $manager->persist($processSchedule);
     $this->addReference('process-schedule-2', $processSchedule);
     $manager->flush();
 }
 public function testGetParametersArray()
 {
     $processSchedule = new ProcessSchedule();
     $this->assertInternalType('array', $processSchedule->getParametersArray());
     $processSchedule->setParameters(json_encode(['some-key-1' => 'some-value-1', 'some-key-2' => 'some-value-2']));
     $this->assertCount(2, $processSchedule->getParametersArray());
     $this->assertContains('some-value-1', $processSchedule->getParametersArray());
     $this->assertContains('some-value-2', $processSchedule->getParametersArray());
     # for SQL types:
     //        $sql = 'SELECT somefield FROM sometable;';
     //
     //        $processSchedule->setType('collector.sql.main');
     //        $processSchedule->setParameters($sql);
     //
     //        $this->assertInternalType('array', $processSchedule->getParametersArray());
     //        $this->assertArrayHasKey('sql', $processSchedule->getParametersArray());
     //        $this->assertEquals($sql, $processSchedule->getParametersArray()['sql']);
 }
Exemplo n.º 3
0
 public function runScheduledProcess(ProcessSchedule $processSchedule)
 {
     $this->runProcess($processSchedule->getType(), $processSchedule->getParametersArray());
 }
 /**
  * @Route("/run/{id}", name="process_schedule_run")
  */
 public function runAction(ProcessSchedule $scheduledProcess)
 {
     $em = $this->getDoctrine()->getManager();
     $scheduledProcess->setLastRunAt(new \DateTime());
     $em->persist($scheduledProcess);
     $em->flush();
     $this->get('vr.plugin_manager')->runScheduledProcess($scheduledProcess);
     $this->get('session')->getFlashBag()->add('success', 'SQL has been executed.');
     return $this->redirectToRoute('process_schedule_list');
 }