/**
  * Executes the cache clear.
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     call_user_func(function () {
         $classLoader = (require \WFP2Environment::getRootPath() . 'vendor/autoload.php');
         (new \TYPO3\CMS\Backend\Console\Application($classLoader))->run();
     });
 }
 /**
  * Executes the cache clear.
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->writeSection($output, 'Controller generation');
     $extensionName = $input->getOption('extension');
     $controllerName = $input->getArgument('controller_name');
     if (!$extensionName) {
         throw new \RuntimeException('Parameter extension is required');
     }
     $path = \WFP2Environment::getExtPath() . $extensionName . DIRECTORY_SEPARATOR;
     if (!is_dir($path)) {
         throw new \RuntimeException('Path ' . $path . ' does not exists');
     }
     $classesPath = $path . 'Classes' . DIRECTORY_SEPARATOR;
     if (!is_dir($classesPath)) {
         mkdir($classesPath);
     }
     $controllerPath = $classesPath . 'Controller' . DIRECTORY_SEPARATOR;
     if (!is_dir($controllerPath)) {
         mkdir($controllerPath);
     }
     if (strpos($controllerName, 'Controller') === false) {
         $controllerName .= 'Controller';
     }
     $output->writeln('Create new controller ' . $controllerName);
     /* @var $dialog \Symfony\Component\Console\Helper\DialogHelper */
     $dialog = $this->getHelper('dialog');
     $actionContent = array();
     while ($dialog->askConfirmation($output, 'generate action? [y/n]')) {
         $actionNameRaw = $actionName = $dialog->ask($output, 'Please insert your action name: ');
         if (strpos($actionName, 'Action') === false) {
             $actionName .= 'Action';
         }
         $templatePath = $this->mkdir($path . 'Resources/Private/Templates/' . $input->getArgument('controller_name'));
         $templateName = ucfirst(strtolower($actionNameRaw)) . '.html';
         $this->renderFile('view.html', $templatePath . $templateName, array('controller' => $controllerName, 'action' => $actionName));
         $actionContent[] = $this->render('action.php', array('actionname' => $actionName, 'view' => str_replace(\WFP2Environment::getExtPath(), '', $templatePath . $templateName)));
     }
     $this->renderFile('controller.php', $controllerPath . $controllerName . '.php', array('name' => $controllerName, 'namespace' => $this->generateNamespaceForExtensionName($extensionName) . '\\Controller', 'body' => implode(PHP_EOL, $actionContent)));
     $errors = array();
     $this->writeGeneratorSummery($output, $errors);
 }
 /**
  * Executes the cache clear.
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('Clear the cache for ' . \WFP2Environment::getWebPath(true));
 }
예제 #4
0
 /**
  * Renders a file.
  * @param string $template
  * @param string $target
  * @param array $parameters
  * @return void
  */
 protected function renderFile($template, $target, array $parameters = array())
 {
     $parameters['generator.file'] = str_replace(\WFP2Environment::getRootPath(), '', $target);
     $source = $this->render($template, $parameters);
     if (file_put_contents($target, $source) === false) {
         throw new \RuntimeException('File ' . $target . ' was not written');
     }
 }
예제 #5
0
 /**
  * Returns the skeleton path.
  * @return string
  */
 protected function getSkeletonPath()
 {
     return realpath(sprintf('%s/wfp2_console/skeleton/%s/', \WFP2Environment::getExtPath(), $this->generatorName)) . DIRECTORY_SEPARATOR;
 }
 /**
  * Gets the extension path.
  * @param DialogHelper    $dialogHelper
  * @param OutputInterface $output
  * @return string
  */
 private function getExtensionPath(DialogHelper $dialogHelper, OutputInterface $output)
 {
     return $dialogHelper->askAndValidate($output, $this->createQuestion('Enter your package name'), function ($answer) {
         if (is_dir(\WFP2Environment::getExtPath() . $answer)) {
             throw new \RuntimeException('Extension ' . $answer . ' already exists');
         }
         return \WFP2Environment::getExtPath() . $answer;
     });
 }