public function syncRef($ref, $type) { $this->project->getFactory()->log('info', 'codex.hooks.git.syncer.sync.start', compact('ref', 'type')); $this->runHook('git:syncer:start', [$this, $ref, $type]); $owner = $this->setting('owner'); $repo = $this->setting('repository'); $docPath = $this->setting('sync.paths.docs'); $indexPath = $this->setting('sync.paths.docs'); $remote = $this->client($this->setting('remote')); $rfs = $remote->getFilesystem($repo, $owner, $ref); $files = $rfs->allFiles($this->setting('sync.paths.docs')); $indexExists = $rfs->exists(Path::join($this->setting('sync.paths.docs'), 'index.md')); $menuExists = $rfs->exists(Path::join($this->setting('sync.paths.docs'), 'menu.yml')); $a = 'b'; if (!$indexExists || !$menuExists) { return; } $destinationDir = Path::join($this->project->getPath(), $ref); $menuContent = $rfs->get($this->setting('sync.paths.menu')); //#base64_decode($menu[ 'content' ]); $menuArray = Yaml::parse($menuContent); $unfilteredPages = []; $this->extractDocumentsFromMenu($menuArray['menu'], $unfilteredPages); $this->ensureDirectory($destinationDir); foreach ($rfs->allFiles($this->setting('sync.paths.docs')) as $path) { $localPath = Path::makeRelative($path, $this->setting('sync.paths.docs')); $localPath = Path::join($destinationDir, $localPath); $dir = Path::getDirectory($localPath); $this->ensureDirectory($dir); $this->files->put($localPath, $rfs->get($path)); } if ($type === 'branch') { $branch = $remote->getBranch($this->setting('repository'), $ref, $this->setting('owner')); $this->cache->forever(md5($this->project->getName() . $branch['name']), $branch['sha']); } $this->runHook('git:syncer:done', [$this, $ref, $type]); $this->project->getFactory()->log('info', 'codex.hooks.git.syncer.sync.end', compact('ref', 'type')); }