Exemple #1
0
 /**
  * {@inheritdoc}
  */
 public function publish($filename, $destination, $merge = self::FOLLOW, $mode = FilesInterface::READONLY)
 {
     if (!$this->files->isFile($filename)) {
         throw new PublishException("Given '{$filename}' is not valid file.");
     }
     //wtf? always empty
     if (empty($relativeFilename)) {
         $relativeFilename = $this->files->normalizePath($this->files->relativePath($filename, $this->directories->directory('root')));
     }
     //wtf?
     if (empty($relativeDestination)) {
         $relativeDestination = $this->files->relativePath($destination, $this->directories->directory('root'));
     }
     if ($this->files->exists($destination)) {
         if ($this->files->md5($destination) == $this->files->md5($filename)) {
             $this->logger()->debug("File '{relativeFilename}' already published and latest version.", compact('relativeFilename', 'destination'));
             //Nothing to do
             return;
         }
         if ($merge == self::FOLLOW) {
             //We are not allowed to replace file
             $this->logger()->warning("File '{relativeFilename}' already published and can not be replaced.", compact('relativeFilename', 'destination'));
             return;
         }
     }
     $this->logger()->info("Publish file '{relativeFilename}' to '{relativeDestination}'.", compact('relativeFilename', 'relativeDestination'));
     $this->ensureDirectory(dirname($destination), $mode);
     $this->files->copy($filename, $destination);
     $this->files->setPermissions($destination, $mode);
 }
Exemple #2
0
 /**
  * @param DirectoriesInterface $directories
  * @param FilesInterface       $files
  */
 protected function ensurePermissions(DirectoriesInterface $directories, FilesInterface $files)
 {
     $this->writeln("<info>Verifying runtime directory existence and file permissions...</info>");
     $runtime = $directories->directory('runtime');
     if (!$files->exists(directory('runtime'))) {
         $files->ensureDirectory(directory('runtime'));
         $this->writeln("Runtime data directory was created.");
         return;
     }
     foreach ($files->getFiles(directory('runtime')) as $filename) {
         //Both file and it's directory must be writable
         $files->setPermissions($filename, FilesInterface::RUNTIME);
         $files->setPermissions(dirname($filename), FilesInterface::RUNTIME);
     }
     $this->writeln("Runtime directory permissions were updated.");
 }