diff --git a/.gitignore b/.gitignore index 2cf7a3f..fe20083 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -composer.lock \ No newline at end of file +composer.lock +/nbproject diff --git a/Command/HelloCommand.php b/Command/HelloCommand.php new file mode 100644 index 0000000..5105341 --- /dev/null +++ b/Command/HelloCommand.php @@ -0,0 +1,37 @@ +<?php + +namespace Zikula\SpecModule\Command; + +use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; +use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Style\SymfonyStyle; + +class HelloCommand extends ContainerAwareCommand +{ + /** + * @var TranslatorInterface + */ + protected $translator; + + public function setContainer(ContainerInterface $container = null) + { + parent::setContainer($container); + $this->translator = $container->get('translator.default'); + } + + protected function configure() + { + $this + ->setName('specmodule:hello') + ->setDescription('Print hello message.') + ->setHelp('This command is just a test.'); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $io = new SymfonyStyle($input, $output); + $io->text($this->translator->__('Hello, world.')); + } +} diff --git a/ZikulaSpecModule.php b/ZikulaSpecModule.php index d960bf6..ff3657b 100644 --- a/ZikulaSpecModule.php +++ b/ZikulaSpecModule.php @@ -15,4 +15,14 @@ class ZikulaSpecModule extends AbstractModule { + /** + * This function is necesssary for console commands in Command/*Command.php + * to be recognized by app/console.php + * + * @return boolean + */ + protected function hasCommands() + { + return true; + } }