Пример #1
0
 protected function writeFileWatch(Watch $watcher, Generate\Collections $collections)
 {
     foreach ($collections->getFiles() as $file) {
         $watcher->watchDir(dirname($file));
         $watcher->watchFile($file);
     }
     $watcher->watchFile($this->config->getLoader());
     $watcher->watch();
 }
Пример #2
0
 protected function load()
 {
     if (!is_callable($this->callback)) {
         $cache = new Watch($this->temp . '.cache');
         if (!$cache->isWatching() || ($this->prod || $cache->hasChanged())) {
             $builder = $this->getValidatorCode();
             $builder->writeTo($this->temp);
         }
         $data = (require $this->temp);
         foreach ($data as $key => $value) {
             $this->{$key} = $value;
         }
         $cache->watchFiles($this->files);
         $cache->watchDirs($this->dirs);
         $cache->watch();
     }
 }
Пример #3
0
 public function generate()
 {
     $output = $this->getOutput();
     $cache = new Watch($output . '.cache');
     $dirs = array_unique($this->dirs);
     $files = array_unique($this->files);
     $files[] = $output;
     $dirs[] = __DIR__ . '/Filters';
     $cache->watchFiles($files);
     $cache->watchDirs($dirs);
     if (!$cache->hasChanged()) {
         return;
     }
     $annotations = new \Notoj\Filesystem(array_unique(array_merge($dirs, $files)));
     $compiler = new Compiler($this, $annotations);
     File::write($output, $compiler->getOutput());
     $cache->watchFiles($files)->watchDirs($dirs);
     $cache->watch();
     return $compiler->getOutput();
 }
Пример #4
0
 public function generate()
 {
     $output = $this->getOutput();
     if (empty($output)) {
         throw new \RuntimeException("You need to set an output file");
     }
     $cache = new Watch($output . '.cache');
     $dirs = $this->dirs;
     foreach ($this->files as $file) {
         $dirs[] = dirname($file);
     }
     $cache->watchFiles($this->files);
     $cache->watchDirs($dirs);
     if (!$cache->hasChanged()) {
         return;
     }
     $annotations = new Annotations();
     $isCached = $output && file_exists($output);
     $files = array();
     $dirs = array();
     foreach (array_unique($this->files) as $file) {
         $ann = new FileParser($file);
         $ann->getAnnotations($annotations);
         $files[] = $file;
         $dirs[] = dirname($file);
     }
     foreach (array_unique($this->dirs) as $dir) {
         $ann = new DirParser($dir);
         $ann->getAnnotations($annotations);
         $dirs[] = $dir;
         $files = array_merge($files, $ann->getFiles());
     }
     foreach ($files as $file) {
         $dirs[] = dirname($file);
     }
     $cache->watchFiles($files)->watchDirs($dirs);
     $cache->watch();
     foreach ($files as $file) {
         $dirs[] = dirname($file);
     }
     $compiler = new Compiler($this, $annotations);
     if (!empty($output)) {
         file_put_contents($output, $compiler->getOutput());
     }
     return $compiler->getOutput();
 }
Пример #5
0
 protected function load()
 {
     if (is_callable($this->callback)) {
         return;
     }
     $cache = new Watch($this->temp . '.cache');
     if ($cache->isWatching() && ($this->prod || !$cache->hasChanged())) {
         require $this->temp;
         return;
     }
     $builder = $this->getValidatorCode();
     $builder->writeTo($this->temp);
     require $this->temp;
     $cache->watchFiles($this->files);
     $cache->watchDirs($this->dirs);
     $cache->watch();
 }
Пример #6
0
 protected function generateIfNeeded()
 {
     if ($this->devel || !is_file($this->loader)) {
         Notoj::enableCache($this->loader . ".tmp");
         $watcher = new Watch($this->loader . ".lock");
         if ($watcher->hasChanged()) {
             new Generate($this, $watcher);
             $this->generate = true;
         }
     }
 }