コード例 #1
0
ファイル: Generator.php プロジェクト: agpmedia/dispatcher
 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();
 }
コード例 #2
0
ファイル: Server.php プロジェクト: crodas/worker
 public function getServices()
 {
     $annotations = new Notoj\Annotations();
     foreach ($this->config->getDirectories() as $dir) {
         $dir = new Notoj\Dir($dir);
         $dir->getAnnotations($annotations);
     }
     $services = array();
     foreach ($annotations->get('Worker', true) as $worker) {
         foreach ($worker->get('Worker') as $args) {
             $name = current($args['args'] ?: []);
             if (empty($name)) {
                 continue;
             }
             $services[$name] = new Service($worker, $args['args'], $this);
         }
     }
     return $services;
 }
コード例 #3
0
ファイル: Init.php プロジェクト: agpmedia/validator
 protected function getAnnotations()
 {
     $parser = new DirParser($this->dir);
     $annotations = $parser->getAnnotations();
     return $annotations->get('Validate', 'Class');
 }
コード例 #4
0
ファイル: Collections.php プロジェクト: agpmedia/activemongo2
 protected function addDirs(array $dirs)
 {
     foreach ($dirs as $dir) {
         $dir = new NDir($dir);
         $dir->getAnnotations($this->annotations);
         $this->files = array_merge($this->files, $dir->getFiles());
     }
 }