/**
  * handle
  *
  * @param \Docit\Core\Project $project
  */
 public function handle(Project $project, Menu $menu)
 {
     if (!$project->config('enable_phpdoc_hook', false)) {
         return;
     }
     $node = $menu->add('phpdoc', $project->config('phpdoc_hook_settings.menu_name'));
     $node->setMeta('icon', $project->config('phpdoc_hook_settings.menu_icon'));
     $node->setAttribute('href', route('docit.phpdoc', ['projectName' => $project->getName(), 'ref' => $project->getRef()]));
 }
예제 #2
0
 /**
  * Handle the hook.
  *
  * @param  \Docit\Core\Project $project
  * @return void
  */
 public function handle(Project $project)
 {
     if (!$project->config('enable_filesystem_hook')) {
         $project->setFiles(new LocalFilesystem());
     }
     $disk = $project->config('default_filesystem_disk');
     $settings = $project->config('filesystem_hook_settings');
     if (!isset($settings[$disk])) {
         return;
     }
     $files = $this->fsm->disk($disk);
     if (isset($files)) {
         $project->setFiles($files);
         $project->setPath($project->getName());
     }
 }
예제 #3
0
 public function getBranchesToSync()
 {
     $allowedBranches = $this->setting('sync.sync.branches');
     if (count($allowedBranches) === 0) {
         return [];
     }
     $branchesToSync = [];
     $branches = $this->github->repositories()->branches($this->setting('owner'), $this->setting('repository'));
     foreach ($branches as $branch) {
         $branchName = $branch['name'];
         if (!in_array('*', $allowedBranches, true) and !in_array($branchName, $allowedBranches, true)) {
             continue;
         }
         $sha = $branch['commit']['sha'];
         $cacheKey = md5($this->project->getName() . $branchName);
         $branch = $this->cache->get($cacheKey, false);
         $destinationPath = Path::join($this->project->getPath(), $branchName);
         if ($branch !== $sha or $branch === false or !$this->files->exists($destinationPath)) {
             $branchesToSync[] = $branchName;
         }
     }
     return $branchesToSync;
 }