Пример #1
0
 public function addMessage(Event $event)
 {
     $message = $event->getParam('message');
     if (!in_array($message->type, $this->filterTypes)) {
         $this->messages[] = $message;
     }
 }
Пример #2
0
 public function testHasFeature()
 {
     $storage = new StorageDb();
     $event = new Event();
     $event->setParam('feature', FeatureInterface::ENABLED);
     $this->assertFalse($storage->hasFeature($event));
     $event->setParam('feature', FeatureInterface::MANAGE_JOBS);
     $this->assertFalse($storage->hasFeature($event));
     $event->setParam('feature', FeatureInterface::REPORTING);
     $this->assertTrue($storage->hasFeature($event));
     $event->setParam('feature', FeatureInterface::SCHEDULE);
     $this->assertTrue($storage->hasFeature($event));
 }
Пример #3
0
 public function testHasFeature()
 {
     $loader = new LoaderDb();
     $event = new Event();
     $event->setParam('feature', FeatureInterface::ENABLED);
     $this->assertTrue($loader->hasFeature($event));
     $event->setParam('feature', FeatureInterface::MANAGE_JOBS);
     $this->assertTrue($loader->hasFeature($event));
     $event->setParam('feature', FeatureInterface::REPORTING);
     $this->assertTrue($loader->hasFeature($event));
     $event->setParam('feature', FeatureInterface::SCHEDULE);
     $this->assertTrue($loader->hasFeature($event));
     $event->setParam('feature', 'gndn');
     $this->assertFalse($loader->hasFeature($event));
 }
Пример #4
0
 /**
  * Handles job get report event by fetching messages from the log table
  * 
  * @param Event $event
  * @return \SporkTools\Core\Job\Report
  */
 public function report(Event $event)
 {
     $job = $event->getTarget();
     $serviceManager = $job->getServiceManager();
     $this->initialize($serviceManager);
     $report = new Report();
     $runId = $this->fetchLastBatchId($job);
     $select = new Select($this->table);
     $select->columns(array('message' => $this->columnMap['message'], 'type' => $this->columnMap['priority'], 'datetime' => $this->columnMap['timestamp']))->where->like($this->columnMap['message'], "% [{$runId}]");
     $results = $this->db->query($select->getSqlString($this->db->getPlatform()), Adapter::QUERY_MODE_EXECUTE);
     foreach ($results as $row) {
         $type = isset($this->typeMap[$row->type]) ? $this->typeMap[$row->type] : $row->type;
         $report->addMessage(new Message($row->message, $type, $row->datetime));
     }
     return $report;
 }
Пример #5
0
 public function log(Event $event)
 {
     $message = $event->getParam('message');
     if (in_array($message->type, $this->filterTypes)) {
         return;
     }
     switch ($message->type) {
         case 'error':
             $this->log->err($message->text . $this->postfix);
             break;
         case 'warning':
             $this->log->warn($message->text . $this->postfix);
             break;
         default:
             $this->log->info($message->text . $this->postfix);
     }
 }
Пример #6
0
 /**
  * Injects message plugin and database adapter when job is run
  *
  * @param Event $event            
  */
 public function initialize(Event $event)
 {
     $this->message = $event->getTarget()->getPlugin('SporkTools\\Core\\Job\\Plugin\\Message');
     parent::initialize($event);
 }
Пример #7
0
 public function initialize(Event $event)
 {
     $this->eventManager = $event->getTarget()->getEventManager();
 }
Пример #8
0
 public function taskFooter(Event $event)
 {
     $task = $event->getTarget();
     $task->info("Completed task {$task->getName()} {$this->elapsed()}");
 }
Пример #9
0
 public function executeTask(Event $event)
 {
     $task = $event->getTarget();
     return $task->run($event);
 }
Пример #10
0
 /**
  * Injects message plugin and database adapter when job is run
  * 
  * @param Event $event
  */
 public function initialize(Event $event)
 {
     if (!$this->db instanceof Adapter) {
         $this->db = $event->getTarget()->getServiceManager()->get($this->db);
     }
 }
Пример #11
0
 public function injectPlugin(Event $event)
 {
     $event->getTarget()->addPlugin($this);
 }
Пример #12
0
 protected function initialize(Event $event)
 {
     if (!$this->db instanceof Adapter && null !== $this->db) {
         $serviceManager = $event->getTarget()->getServiceManager();
         $this->db = $serviceManager->get($this->db);
     }
 }
Пример #13
0
 public function storeSchedule(Event $event)
 {
     $job = $event->getTarget();
     $this->initialize($job->getServiceManager());
     $schedule = $event->getParam('schedule');
     $this->storeData($job, 'schedule', $schedule);
 }