/**
  * @param Input $input
  * @param Output $output
  * @return int
  */
 public function execute(Input $input, Output $output)
 {
     $path = $this->getContainer()->get('kernel')->getRootPath() . '/storage/templates';
     if (!file_exists($path)) {
         $output->writeln('done');
         return true;
     }
     $recursion = null;
     $recursion = function ($path) use(&$recursion) {
         $fp = opendir($path);
         while ($file = readdir($fp)) {
             if ('.' === $file || '..' === $file) {
                 continue;
             }
             $file = "{$path}/{$file}";
             if (is_dir($file)) {
                 $recursion($file);
                 rmdir($file);
             } else {
                 unlink($file);
             }
         }
         closedir($fp);
     };
     $output->write('Clearing template cache ... ');
     try {
         $recursion($path);
     } catch (\Exception $e) {
         $output->writeln('<error>failed</error>');
         return 0;
     }
     $output->writeln('<success>success</success>');
     return 1;
 }
예제 #2
0
 /**
  * @param Input $input
  * @param Output $output
  * @throws \Exception
  * @return void
  */
 public function execute(Input $input, Output $output)
 {
     $kernel = $this->getContainer()->singleton('kernel');
     $bundles = $kernel->getBundles();
     $web = 'public/bundles';
     $targetRootDir = $kernel->getRootPath() . '/../' . $web;
     $output->writeln('Trying to install assets as symbolic links.');
     foreach ($bundles as $bundle) {
         $originDir = $bundle->getRootPath() . DIRECTORY_SEPARATOR . 'Resources/assets';
         if (!file_exists($originDir)) {
             continue;
         }
         $targetDir = $targetRootDir . DIRECTORY_SEPARATOR . strtolower($bundle->getShortName());
         try {
             $this->symlink($originDir, $targetDir);
             $output->write('Installing assets for ');
             $output->write(sprintf('<success>%s</success>', $bundle->getName()));
             $output->write(' into ');
             $output->writeln($web . DIRECTORY_SEPARATOR . sprintf('<success>%s</success>', strtolower($bundle->getShortName())));
         } catch (\Exception $e) {
             throw $e;
         }
     }
 }
예제 #3
0
 /**
  * Format route output to command line.
  *
  * @param Route  $route
  * @param Output $output
  * @param        $type
  */
 public function formatOutput(Route $route, Output $output, $type = self::STYLE_DETAIL)
 {
     switch ($type) {
         case self::STYLE_DETAIL:
             $output->write('Route [');
             $output->write('<success>"' . $route->getName() . '"</success>');
             $output->writeln(']');
             $output->writeln("Path:\t\t" . str_replace('//', '/', $route->getPath()));
             $output->writeln("Method:\t\t" . $route->getMethod());
             $output->writeln("Format:\t\t" . implode(', ', $route->getFormats()));
             $output->writeln("Callback:\t" . (is_callable($route->getCallback()) ? 'Closure' : $route->getCallback()));
             $output->writeln("Defaults:\t" . implode(', ', $route->getDefaults()));
             $output->writeln("Requirements:\t" . implode(', ', $route->getRequirements()));
             $output->writeln("Path-Regex:\t" . $route->getPathRegex());
             $output->writeln('');
             break;
         case self::STYLE_LIST:
         default:
             $name = $route->getName();
             $method = $route->getMethod();
             $schema = $route->getScheme() ?? 'http';
             $path = $route->getPath();
             $output->write($name . str_repeat(' ', 25 - strlen($name)));
             $output->write($method . str_repeat(' ', 15 - strlen($method)));
             $output->write($schema . str_repeat(' ', 15 - strlen($schema)));
             $output->writeln($path);
     }
     return;
 }