/**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $realCacheDir = $this->getConfig()->getCacheDir();
     $oldCacheDir = $realCacheDir . '_old';
     $filesystem = new Filesystem();
     if (!is_writable($realCacheDir)) {
         throw new \RuntimeException(sprintf('Unable to write in the "%s" directory', $realCacheDir));
     }
     if ($filesystem->exists($oldCacheDir)) {
         $filesystem->remove($oldCacheDir);
     }
     $output->writeln(sprintf('Clearing the cache for the <info>%s</info> environment with debug <info>%s</info>', $this->getConfig()->getEnv(), var_export($this->getConfig()->isDebug(), true)));
     $filesystem->clear($realCacheDir);
 }
 private function scanTemplates()
 {
     $templates = Filesystem::scanForFiles($this->getConfig()->getTwigBasePath(), '', 'twig');
     foreach ($templates as $template) {
         $resource = new TwigResource($this->twig()->getLoader(), $template);
         $this->am->addResource($resource, 'twig');
     }
 }
 private static function writeBootstrap($bootstrap, $extras, $webDirectory, $ciBasePath)
 {
     $template = self::getBootstrapConfigTemplate();
     $applicationDirectory = Filesystem::getRelativePath(realpath($extras['ci-app-dir']), $webDirectory);
     $systemDirectory = Filesystem::getRelativePath(realpath("{$ciBasePath}/system"), $webDirectory);
     $projectBasePath = Filesystem::getRelativePath(realpath("."), $webDirectory);
     $template = str_replace(array('{APPLICATION_ENV}', '{CI_SYSTEM_PATH}', '{APPLICATION_DIR}', '{CIX_SYSTEM_PATH}'), array(self::$environment, $systemDirectory, $applicationDirectory, $projectBasePath), $template);
     file_put_contents($bootstrap, $template);
 }