Example #1
0
 /**
  * Tears down the fixture, for example, closes a network connection.
  * This method is called after a test is executed.
  */
 protected function tearDown()
 {
     if (file_exists($this->rootPath)) {
         $filesystem = new \Composer\Util\Filesystem();
         $filesystem->removeDirectory($this->rootPath);
     }
     parent::tearDown();
 }
Example #2
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return bool
  */
 public function downloadMagento(InputInterface $input, OutputInterface $output)
 {
     try {
         $package = $this->createComposerPackageByConfig($this->config['magentoVersionData']);
         $this->config['magentoPackage'] = $package;
         if (file_exists($this->config['installationFolder'] . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'Mage.php')) {
             $output->writeln('<error>A magento installation already exists in this folder </error>');
             return false;
         }
         $composer = $this->getComposer($input, $output);
         $targetFolder = $this->getTargetFolderByType($composer, $package, $this->config['installationFolder']);
         $this->config['magentoPackage'] = $this->downloadByComposerConfig($input, $output, $package, $targetFolder, true);
         if ($this->isSourceTypeRepository($package->getSourceType())) {
             $filesystem = new \N98\Util\Filesystem();
             $filesystem->recursiveCopy($targetFolder, $this->config['installationFolder'], array('.git', '.hg'));
         } else {
             $filesystem = new \Composer\Util\Filesystem();
             $filesystem->copyThenRemove($this->config['installationFolder'] . '/_n98_magerun_download', $this->config['installationFolder']);
         }
         if (version_compare(PHP_VERSION, '5.4.0') >= 0) {
             // Patch installer
             $this->patchMagentoInstallerForPHP54($this->config['installationFolder']);
         }
     } catch (\Exception $e) {
         $output->writeln('<error>' . $e->getMessage() . '</error>');
         return false;
     }
     return true;
 }
 /**
  * Recursively removes the specified directory or file
  *
  * @param $dir
  */
 public static function rmdirRecursive($dir)
 {
     $fs = new \Composer\Util\Filesystem();
     if (is_dir($dir)) {
         $result = $fs->removeDirectory($dir);
     } else {
         @unlink($dir);
     }
     return;
 }
 /**
  * Recursively removes the specified directory or file
  *
  * @param $dir
  * @return bool
  */
 public static function rmdirRecursive($dir)
 {
     $fs = new \Composer\Util\Filesystem();
     return $fs->removeDirectory($dir);
     /*
     if (is_dir($dir) && ! is_link($dir)) {
     
         $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir),
                 \RecursiveIteratorIterator::CHILD_FIRST);
     
         foreach ($iterator as $item) {
             $path = (string) $item;
     
             if (!strcmp($path, '.') || !strcmp($path, '..')) {
                 continue;
             }
     
             if (is_dir($path)) {
                 self::rmdirRecursive($path);
             } else {
                 @unlink($path);
             }
         }
         $result = @rmdir($dir);
     } else {
         $result = @unlink($dir);
     }
     return $result;
     */
 }