Пример #1
0
 /**
  * Scans the configured documentation root directory for projects and resolves them and puts them into the projects collection
  *
  * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
  */
 protected function findAndRegisterAll()
 {
     if (!$this->items->isEmpty()) {
         return;
     }
     $this->hookPoint('projects:resolve', [$this]);
     $finder = new Finder();
     $projects = $finder->in($this->getCodex()->getDocsPath())->files()->name('config.php')->depth('<= 1')->followLinks();
     foreach ($projects as $projectDir) {
         /** @var \SplFileInfo $projectDir */
         $name = Path::getDirectoryName($projectDir->getPath());
         $config = $this->getContainer()->make('fs')->getRequire($projectDir->getRealPath());
         $config = array_replace_recursive($this->getCodex()->config('default_project_config'), $config);
         /** @var \Codex\Projects\Project $project */
         $project = $this->getContainer()->make('codex.project', ['projects' => $this, 'name' => $name, 'config' => $config]);
         // This hook allows us to exclude projects from resolving, or do some other stuff
         $hook = $this->hookPoint('projects:resolving', [$project]);
         if ($hook === false) {
             continue;
         }
         $this->items->put($name, $project);
     }
     $this->hookPoint('projects:resolved', [$this]);
 }