Exemplo n.º 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);
 }
Exemplo n.º 2
0
 /**
  * @param FilesInterface       $files
  * @param DirectoriesInterface $directories
  */
 public function perform(FilesInterface $files, DirectoriesInterface $directories)
 {
     $cacheDirectory = $directories->directory('cache');
     if (!$files->exists($cacheDirectory)) {
         $this->writeln("Cache directory is missing, no cache to be cleaned.");
         return;
     }
     $this->isVerbosity() && $this->writeln("<info>Cleaning application runtime cache:</info>");
     foreach ($files->getFiles($cacheDirectory) as $filename) {
         $files->delete($filename);
         if ($this->isVerbosity()) {
             $this->writeln($files->relativePath($filename, $cacheDirectory));
         }
     }
     $this->writeln("<info>Runtime cache has been cleared.</info>");
 }
Exemplo n.º 3
0
 /**
  * @param ViewsConfig    $config
  * @param FilesInterface $files
  */
 public function perform(ViewsConfig $config, FilesInterface $files)
 {
     if (!$files->exists($config->cacheDirectory())) {
         $this->writeln("Cache directory is missing, no cache to be cleaned.");
         return;
     }
     $this->isVerbosity() && $this->writeln("<info>Clearing view cache:</info>");
     $cachedViews = $files->getFiles($config->cacheDirectory());
     foreach ($cachedViews as $filename) {
         $files->delete($filename);
         if ($this->isVerbosity()) {
             $this->writeln($files->relativePath($filename, $config->cacheDirectory()));
         }
     }
     if (empty($filename) && $this->isVerbosity()) {
         $this->writeln("No cached views were found.");
     }
     $this->writeln("<info>View cache has been cleared.</info>");
 }