/**
  * Check a given directory recursively if all files are writeable.
  *
  * @throws \Exception
  *
  * @return bool
  */
 protected function hasCorrectPermissionForUpdate() : bool
 {
     if (!$this->pathToUpdate) {
         throw new \Exception('No directory set for update. Please set the update with: setPathToUpdate(path).');
     }
     $collection = collect($this->pathToUpdate->files())->each(function ($file) {
         /* @var \SplFileInfo $file */
         if (!File::isWritable($file->getRealPath())) {
             event(new HasWrongPermissions($this));
             return false;
         }
     });
     return true;
 }
Ejemplo n.º 2
-1
 /**
  * @param SplFileInfo[] $fileList
  * @param string        $basePath
  *
  * @return string
  */
 public function mergeFiles($fileList, $basePath)
 {
     $imagePath = str_replace(dirname(RMP_MDOC_BASE_DIR), '', $basePath);
     $contents = '';
     foreach ($fileList->files() as $singleFile) {
         if (false == $singleFile instanceof SplFileInfo) {
             $singleFile = new SplFileInfo($singleFile->getRealPath(), $basePath, $basePath);
         }
         $this->setCurrentFile($singleFile);
         /** @var SplFileInfo $singleFile */
         $buffer = $singleFile->getContents() . PHP_EOL . PHP_EOL;
         $depth = max(0, substr_count(str_replace($basePath, '', $singleFile->getRealPath()), '/') - 1);
         $directory = $singleFile->getPath() . '/' . $singleFile->getBasename('.md');
         if (is_dir($directory)) {
             $featureFinder = new Finder();
             $featureFinder->in($directory)->name('*.feature')->depth(0);
             foreach ($featureFinder->files() as $feature) {
                 $buffer .= $this->parseFeature($feature);
             }
         }
         $link = ltrim('http://' . $_SERVER['HTTP_HOST'] . str_replace($_SERVER['DOCUMENT_ROOT'], '', $singleFile->getPath() . '/') . '/', '/');
         $buffer = str_replace('](./', '](' . $link, $buffer);
         // in between
         $buffer = str_replace("\n#", "\n#" . str_repeat('#', $depth), $buffer);
         // in beginning
         $buffer = preg_replace('/^#/', str_repeat('#', $depth + 1), $buffer);
         $buffer = preg_replace_callback('/\\s@import "([^"]*)"\\s/s', [$this, 'replaceFileImports'], $buffer);
         $contents .= $buffer;
     }
     return $contents;
 }