Example #1
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $bbapp = $this->getContainer()->get('bbapp');
     $publicResourcesDir = $bbapp->getBaseDir() . '/public/ressources';
     $bbappResourcesDir = $bbapp->getBBDir() . '/Resources';
     $repoResourcesDir = $bbapp->getBaseRepository() . '/Ressources';
     Dir::copy($repoResourcesDir, $publicResourcesDir, 0755);
     Dir::copy($bbappResourcesDir, $publicResourcesDir, 0755);
     foreach ($bbapp->getBundles() as $bundle) {
         Dir::copy($bundle->getResourcesDir(), $publicResourcesDir, 0755);
     }
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $bbapp = $this->getContainer()->get('bbapp');
     $output->writeln(sprintf('Clearing the cache for the <info>%s</info> environment with debug <info>%s</info>', $bbapp->getEnvironment(), var_export($bbapp->isDebugMode(), true)));
     $cacheDir = $this->getContainer()->getParameter("bbapp.cache.dir");
     $oldCacheDir = $cacheDir . '_old';
     if (file_exists($oldCacheDir)) {
         Dir::delete($oldCacheDir);
     }
     Dir::move($cacheDir, $oldCacheDir);
     mkdir($cacheDir);
     if (file_exists($oldCacheDir)) {
         Dir::delete($oldCacheDir);
     }
 }
Example #3
0
 /**
  * Looks in $basedir for files with $extension
  * @param  string                                      $basedir
  * @param  string                                      $extension
  * @return array
  * @throws \BackBee\Exception\InvalidArgumentException Occures if $basedir is unreachable
  */
 public static function getFilesByExtension($basedir, $extension)
 {
     if (!is_readable($basedir)) {
         throw new InvalidArgumentException(sprintf('Cannot read the directory %s', $basedir));
     }
     $files = [];
     $parse_url = parse_url($basedir);
     if (false !== $parse_url && isset($parse_url['scheme'])) {
         foreach (Dir::getContent($basedir) as $file) {
             if (is_dir($file)) {
                 continue;
             }
             if ('' === $extension && false === strpos(basename($file), '.') || '' !== $extension && $extension === substr($file, -1 * strlen($extension))) {
                 $files[] = $basedir . DIRECTORY_SEPARATOR . $file;
             }
         }
     } else {
         $pattern = '';
         if (!empty($extension)) {
             foreach (str_split($extension) as $letter) {
                 $pattern .= '[' . strtolower($letter) . strtoupper($letter) . ']';
             }
             $pattern = $basedir . DIRECTORY_SEPARATOR . '*.' . $pattern;
             $files = glob($pattern);
         } else {
             $pattern = $basedir . DIRECTORY_SEPARATOR . '*';
             $allFiles = glob($pattern);
             foreach ($allFiles as $filePath) {
                 if (false === strrpos($filePath, '.')) {
                     $files[] = $filePath;
                 }
             }
             unset($allFiles);
         }
     }
     sort($files);
     return $files;
 }
Example #4
0
 /**
  * {@inheritDoc}
  */
 public function tearDown()
 {
     $this->isInitialised = false;
     if ($this->getConfig('deleteExtracted')) {
         Dir::delete($this->getConfig('extractedDir'));
     }
 }
Example #5
0
 public function testMove()
 {
     $directoryMode = 0777;
     mkdir($this->getFixturesFolder() . 'archive2');
     $this->assertTrue(Dir::move($this->getFixturesFolder() . 'archive2', $this->getFixturesFolder() . 'archive3', $directoryMode));
     Dir::delete($this->getFixturesFolder() . 'archive3');
 }