/** * Sınıfı başlatır ve bazı atamaları gerçekleştirir * @param int $version */ public function __construct(Container $container, $version = 1) { $this->setContainer($container); $this->runParentClass($version); static::$schedule = $schedule = new Cron(); $this->resolveCommands(); $this->schedule($schedule); static::$schedule->setCache(EventReposity::getEvents()); }
/** * get the events * * @return array */ public function getEvents() { return null !== $this->getCache() ? $this->getCache() : EventReposity::getEvents(); }
/** * run events * */ public function run() { $events = EventReposity::getBasicEvents(); $job = $this->getJob(); $manager = $this->getManager(); if (count($events)) { foreach ($events as $event) { if ($event instanceof TaskReposity) { $time = $event->getPattern(); list($min, $hour, $dayOfMonth, $month, $dayOfWeek) = explode(' ', $time); $job->setMinute($min)->setHour($hour)->setDayOfMonth($dayOfMonth)->setMonth($month)->setDayOfWeek($dayOfWeek); $job->setCommand($event->buildCommand()); $manager->addJob($job); } } $manager->write(); } }