/**
  * Restore previously backed up paths.
  *
  * @see PathPreserver::backupSubpaths()
  */
 public function rollback()
 {
     if (empty($this->backups)) {
         return;
     }
     foreach ($this->backups as $original => $backup_location) {
         // Remove any code that was placed by the package at the place of
         // the original path.
         if (static::file_exists($original)) {
             if (is_dir($original)) {
                 $this->filesystem->emptyDirectory($original, false);
                 $this->filesystem->removeDirectory($original);
             } else {
                 $this->filesystem->remove($original);
             }
             $this->io->write(sprintf('<comment>Files of installed package were overwritten with preserved path %s!</comment>', $original), true);
         }
         $folder = dirname($original);
         $this->filesystem->ensureDirectoryExists($folder);
         // Make sure we can write the file to the folder.
         $this->makePathWritable($folder);
         $this->filesystem->rename($backup_location, $original);
         if ($this->filesystem->isDirEmpty(dirname($backup_location))) {
             $this->filesystem->removeDirectory(dirname($backup_location));
         }
     }
     // Restore all path permissions, that where set for the sake of moving
     // things around.
     $this->restorePathPermissions();
     // With a clean array, we can start over.
     $this->backups = array();
 }
Ejemplo n.º 2
0
 /**
  * Remove the paths.
  */
 public function remove()
 {
     foreach ($this->installPaths as $installPath) {
         $installPathNormalized = $this->filesystem->normalizePath($installPath);
         // Check if any path may be affected by modifying the install path.
         $relevant_paths = array();
         foreach ($this->removePaths as $path) {
             $normalizedPath = $this->filesystem->normalizePath($path);
             if (static::file_exists($path) && strpos($normalizedPath, $installPathNormalized) === 0) {
                 $relevant_paths[] = $normalizedPath;
             }
         }
         foreach ($relevant_paths as $original) {
             if (is_dir($original)) {
                 // Remove directory
                 $this->removeDirectoryRecursively($original);
             } else {
                 // Remove file
                 unlink($original);
             }
         }
     }
 }
Ejemplo n.º 3
0
 private function finalizePackage($package)
 {
     $fs = new FileSystem();
     $base = $this->getPackageBasePath($package);
     $fs->ensureDirectoryExists("{$base}/css");
     $compiler = new \lessc();
     $compiler->compileFile("{$base}/less/tiki.less", "{$base}/css/{$base}.css");
     // Clean-up undesired files
     $fs->remove("{$base}/dist");
     $fs->remove("{$base}/docs");
     $fs->remove("{$base}/grunt");
     $fs->remove("{$base}/js");
     $fs->remove("{$base}/test-infra");
 }
Ejemplo n.º 4
0
 private static function removeMultiple($base, array $files)
 {
     $fs = new FileSystem();
     foreach ($files as $file) {
         $path = $base . '/' . $file;
         if (file_exists($path) || is_dir($path)) {
             $fs->remove($path);
         }
     }
 }
 protected function afterDrupalRemoveGitDir(PackageEvent $event, IOInterface $io, PackageInterface $package)
 {
     $packagePath = $this->installer->getPackageBasePath($package);
     $gitPath = "{$packagePath}/.git";
     $file = new FileSystem();
     $file->removeDirectory($gitPath);
     $io->write("<info>Removed {$packagePath}/.git</info>");
 }
 protected function afterDrupalGitBackup(PackageEvent $event, PackageInterface $package)
 {
     if (!$this->git['path']) {
         return;
     }
     $packagePath = $this->installer->getPackageBasePath($package);
     $gitPath = "{$packagePath}/.git";
     $backupPath = $packagePath . '/' . $this->git['path'];
     if (file_exists($gitPath)) {
         $this->io->write("  - Moving <info>{$gitPath}</info> to <info>{$backupPath}</info>.");
         $file = new FileSystem();
         $file->removeDirectory($backupPath);
         $file->rename($gitPath, $backupPath);
     }
 }