public function addMessage(Event $event) { $message = $event->getParam('message'); if (!in_array($message->type, $this->filterTypes)) { $this->messages[] = $message; } }
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)); }
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)); }
/** * 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; }
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); } }
/** * 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); }
public function initialize(Event $event) { $this->eventManager = $event->getTarget()->getEventManager(); }
public function taskFooter(Event $event) { $task = $event->getTarget(); $task->info("Completed task {$task->getName()} {$this->elapsed()}"); }
public function executeTask(Event $event) { $task = $event->getTarget(); return $task->run($event); }
/** * 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); } }
public function injectPlugin(Event $event) { $event->getTarget()->addPlugin($this); }
protected function initialize(Event $event) { if (!$this->db instanceof Adapter && null !== $this->db) { $serviceManager = $event->getTarget()->getServiceManager(); $this->db = $serviceManager->get($this->db); } }
public function storeSchedule(Event $event) { $job = $event->getTarget(); $this->initialize($job->getServiceManager()); $schedule = $event->getParam('schedule'); $this->storeData($job, 'schedule', $schedule); }