Exemplo n.º 1
0
 /**
  * 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());
 }
Exemplo n.º 2
0
 /**
  * get the events
  *
  * @return array
  */
 public function getEvents()
 {
     return null !== $this->getCache() ? $this->getCache() : EventReposity::getEvents();
 }
Exemplo n.º 3
0
 /**
  * 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();
     }
 }