Source of file GeneratorCommand.php
Size: 2,040 Bytes - Last Modified: 2013-07-04T14:20:59+02:00
/home/theseer/Downloads/Symfony/vendor/sensio/generator-bundle/Sensio/Bundle/GeneratorBundle/Command/GeneratorCommand.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 | <?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 Sensio\Bundle\GeneratorBundle\Command; use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; use Sensio\Bundle\GeneratorBundle\Command\Helper\DialogHelper; use Sensio\Bundle\GeneratorBundle\Generator\Generator; /** * Base class for generator commands. * * @author Fabien Potencier <fabien@symfony.com> */ abstract class GeneratorCommand extends ContainerAwareCommand { private $generator; // only useful for unit tests public function setGenerator(Generator $generator) { $this->generator = $generator; } protected abstract function createGenerator(); protected function getGenerator($bundle = null) { if (null === $this->generator) { $this->generator = $this->createGenerator(); $this->generator->setSkeletonDirs($this->getSkeletonDirs($bundle)); } return $this->generator; } protected function getSkeletonDirs($bundle = null) { $skeletonDirs = array(); if (isset($bundle) && is_dir($dir = $bundle->getPath().'/Resources/SensioGeneratorBundle/skeleton')) { $skeletonDirs[] = $dir; } if (is_dir($dir = $this->getContainer()->get('kernel')->getRootdir().'/Resources/SensioGeneratorBundle/skeleton')) { $skeletonDirs[] = $dir; } $skeletonDirs[] = __DIR__.'/../Resources/skeleton'; $skeletonDirs[] = __DIR__.'/../Resources'; return $skeletonDirs; } protected function getDialogHelper() { $dialog = $this->getHelperSet()->get('dialog'); if (!$dialog || get_class($dialog) !== 'Sensio\Bundle\GeneratorBundle\Command\Helper\DialogHelper') { $this->getHelperSet()->set($dialog = new DialogHelper()); } return $dialog; } } |