From 0dd92b54afafd40e90c6ba3ab59470eaece44b8d Mon Sep 17 00:00:00 2001 From: Luis Cordova Date: Sat, 18 Feb 2012 03:30:44 -0500 Subject: [PATCH 1/3] added command class to generate class map --- .../Command/ClassMapDumperCommand.php | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 src/Symfony/Bundle/FrameworkBundle/Command/ClassMapDumperCommand.php diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ClassMapDumperCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ClassMapDumperCommand.php new file mode 100644 index 0000000000000..906a0417d4c02 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ClassMapDumperCommand.php @@ -0,0 +1,63 @@ + + * + * 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; + +/** + * ClassMapDumperCommand. + * + * @author Luis Cordova + */ +class ClassMapDumperCommand extends ContainerAwareCommand +{ + /** + * @see Command + */ + protected function configure() + { + $this + ->setDefinition(array( + new InputArgument('dir', InputArgument::OPTIONAL, 'Directories or a single path to search in.'), + new InputOption('file', null, InputOption::VALUE_REQUIRED, 'The name of the class map file.'), + )) + ->setName('generate:class-map') + ->setDescription('Generates class map file') + ->setHelp(<<generate:class-map generates class map file. + + generate:class-map +EOF + ) + ; + } + + /** + * @see Command + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + if ($input->getArgument('dir')) { + $dir = $input->getArgument('dir'); + } + if ($input->getOption('file')) { + $file = $input->getOption('file'); + } + + $output->writeln('Class map has been generated.'); + } +} From 68a2ec22e43a1189f62f65608631b33d5a85f7b1 Mon Sep 17 00:00:00 2001 From: Luis Cordova Date: Sat, 18 Feb 2012 03:53:24 -0500 Subject: [PATCH 2/3] completed command call to generator --- .../FrameworkBundle/Command/ClassMapDumperCommand.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ClassMapDumperCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ClassMapDumperCommand.php index 906a0417d4c02..94c40849859a6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ClassMapDumperCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ClassMapDumperCommand.php @@ -15,8 +15,8 @@ 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; +use Symfony\Component\ClassLoader\ClassMapGenerator; +use Symfony\Component\Validator\Exception\InvalidOptionsException; /** * ClassMapDumperCommand. @@ -32,8 +32,8 @@ protected function configure() { $this ->setDefinition(array( - new InputArgument('dir', InputArgument::OPTIONAL, 'Directories or a single path to search in.'), - new InputOption('file', null, InputOption::VALUE_REQUIRED, 'The name of the class map file.'), + new InputArgument('dir', InputArgument::REQUIRED, 'Directories or a single path to search in.'), + new InputOption('file', null, InputOption::VALUE_REQUIRED, 'The name of the class map file.', 'classmap.php'), )) ->setName('generate:class-map') ->setDescription('Generates class map file') @@ -54,10 +54,13 @@ protected function execute(InputInterface $input, OutputInterface $output) if ($input->getArgument('dir')) { $dir = $input->getArgument('dir'); } + if ($input->getOption('file')) { $file = $input->getOption('file'); } + ClassMapGenerator::dump($dir, $file); + $output->writeln('Class map has been generated.'); } } From cd7d18655ea4c158e1ea8874470bdde577ddd924 Mon Sep 17 00:00:00 2001 From: Luis Cordova Date: Sat, 18 Feb 2012 04:10:25 -0500 Subject: [PATCH 3/3] removed unused use statement and added parameters on info command call --- .../Bundle/FrameworkBundle/Command/ClassMapDumperCommand.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ClassMapDumperCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ClassMapDumperCommand.php index 94c40849859a6..6590335fe04c9 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ClassMapDumperCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ClassMapDumperCommand.php @@ -16,7 +16,6 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\ClassLoader\ClassMapGenerator; -use Symfony\Component\Validator\Exception\InvalidOptionsException; /** * ClassMapDumperCommand. @@ -40,7 +39,7 @@ protected function configure() ->setHelp(<<generate:class-map generates class map file. - generate:class-map + generate:class-map dir file EOF ) ;