/** * getFilePath * * @param $relativePath * @param null $fileName * @param string $ext * @return string */ public function getPath($relativePath, $fileName = null, $ext = '.php') { $path = Path::join($this->dir, $relativePath); return is_null($fileName) ? $path : Path::join($path, $fileName . $ext); }
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; }
/** * generateDirectoryStructure * * @param $destDir * @param array $dirs * @return $this */ public function generateDirectoryStructure($destDir, array $dirs = []) { foreach ($dirs as $dirPath) { $dirPath = Path::join($destDir, $dirPath); if (!$this->files->exists($dirPath)) { $this->files->makeDirectory($dirPath, 0755, true); } } return $this; }
/** * Returns the menu for this project * * @return \Docit\Core\Menus\Menu */ public function getDocumentsMenu() { $yaml = $this->files->get(Path::join($this->path, $this->ref, 'menu.yml')); $array = Yaml::parse($yaml); $this->factory->getMenus()->forget('project_sidebar_menu'); $menu = $this->resolveDocumentsMenu($array['menu']); $menu->setView('docit::menus/project-sidebar'); $this->runHook('project:documents-menu', [$this, $menu]); return $menu; }