コード例 #1
0
 /**
  * Controller generator test
  *
  * @param $module
  * @param $class_name
  * @param $routes
  * @param $test
  * @param $build_services
  * @param $class_machine_name
  *
  * @dataProvider commandData
  */
 public function testGenerateController($module, $class_name, $routes, $test, $build_services, $class_machine_name)
 {
     $generator = new ControllerGenerator();
     $this->getRenderHelper()->setSkeletonDirs($this->getSkeletonDirs());
     $this->getRenderHelper()->setTranslator($this->getTranslatorHelper());
     $generator->setHelperSet($this->getHelperSet());
     $generator->generate($module, $class_name, $routes, $test, $build_services, $class_machine_name);
     $files = [$generator->getSite()->getControllerPath($module) . '/' . $class_name . '.php', $generator->getSite()->getModulePath($module) . '/' . $module . '.routing.yml'];
     foreach ($files as $file) {
         $this->assertTrue(file_exists($file), sprintf('%s does not exist', $file));
     }
     if ($test) {
         $this->assertTrue(file_exists($generator->getSite()->getTestPath($module, 'Controller') . '/' . $class_name . 'Test.php'), sprintf('%s does not exist', $class_name . 'Test.php'));
     }
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $yes = $input->hasOption('yes') ? $input->getOption('yes') : false;
     // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
     if (!$this->confirmGeneration($io, $yes)) {
         return;
     }
     $learning = $input->hasOption('learning') ? $input->getOption('learning') : false;
     $module = $input->getOption('module');
     $class = $input->getOption('class');
     $routes = $input->getOption('routes');
     $test = $input->getOption('test');
     $services = $input->getOption('services');
     $routes = $this->inlineValueAsArray($routes);
     $input->setOption('routes', $routes);
     // @see use Drupal\Console\Command\Shared\ServicesTrait::buildServices
     $build_services = $this->buildServices($services);
     //$this->generator->setLearning($learning);
     $this->generator->generate($module, $class, $routes, $test, $build_services);
     // Run cache rebuild to see changes in Web UI
     $this->chainQueue->addCommand('router:rebuild', []);
 }