Source of file RouterApacheDumperCommand.php
Size: 2,506 Bytes - Last Modified: 2013-07-17T08:22:21+02:00
/home/theseer/Downloads/Symfony/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/RouterApacheDumperCommand.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 | <?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\FrameworkBundle\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Routing\Matcher\Dumper\ApacheMatcherDumper; use Symfony\Component\Routing\RouterInterface; /** * RouterApacheDumperCommand. * * @author Fabien Potencier <fabien@symfony.com> */ class RouterApacheDumperCommand extends ContainerAwareCommand { /** * {@inheritdoc} */ public function isEnabled() { if (!$this->getContainer()->has('router')) { return false; } $router = $this->getContainer()->get('router'); if (!$router instanceof RouterInterface) { return false; } return parent::isEnabled(); } /** * {@inheritdoc} */ protected function configure() { $this ->setName('router:dump-apache') ->setDefinition(array( new InputArgument('script_name', InputArgument::OPTIONAL, 'The script name of the application\'s front controller.'), new InputOption('base-uri', null, InputOption::VALUE_REQUIRED, 'The base URI'), )) ->setDescription('Dumps all routes as Apache rewrite rules') ->setHelp(<<<EOF The <info>%command.name%</info> dumps all routes as Apache rewrite rules. These can then be used with the ApacheUrlMatcher to use Apache for route matching. <info>php %command.full_name%</info> EOF ) ; } /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $router = $this->getContainer()->get('router'); $dumpOptions = array(); if ($input->getArgument('script_name')) { $dumpOptions['script_name'] = $input->getArgument('script_name'); } if ($input->getOption('base-uri')) { $dumpOptions['base_uri'] = $input->getOption('base-uri'); } $dumper = new ApacheMatcherDumper($router->getRouteCollection()); $output->writeln($dumper->dump($dumpOptions), OutputInterface::OUTPUT_RAW); } } |