protected function execute(InputInterface $input, OutputInterface $output)
 {
     # MVC object
     $mvc = MVCStore::retrieve('mvc');
     if ($input->getArgument('folder') == 'web') {
         $input->setArgument('folder', dirname($mvc->getAppDir()) . '/web');
     }
     $folderArg = rtrim($input->getArgument('folder'), '/');
     if (!is_dir($folderArg)) {
         throw new \InvalidArgumentException(sprintf('The target directory "%s" does not exist.', $input->getArgument('folder')));
     }
     $modulesPath = $folderArg . '/modules/';
     @mkdir($modulesPath);
     if ($input->getOption('symlinks')) {
         $output->writeln('Trying to install assets as <comment>symbolic links</comment>.');
     } else {
         $output->writeln('Installing assets as <comment>hard copies</comment>.');
     }
     foreach ($mvc->getModules() as $module) {
         if (is_dir($originDir = $module->getPath() . '/Resources/public')) {
             $targetDir = $modulesPath . preg_replace('/module$/', '', strtolower($module->getName()));
             $output->writeln(sprintf('Installing assets for <comment>%s</comment> into <comment>%s</comment>', $module->getNamespace(), $targetDir));
             if (!$this->recursiveRemoveDir($targetDir)) {
                 $output->writeln(sprintf('Could\'t been removed the dir "%s".', $targetDir));
             }
             if ($input->getOption('symlinks')) {
                 #link($originDir, $targetDir);
                 @symlink($originDir, $targetDir);
             } else {
                 $this->resourceCopy($originDir, $targetDir);
             }
         }
     }
 }
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     # static mvc
     $mvc = MVCStore::retrieve('mvc');
     # get helper set
     $questionHelper = $this->getQuestionHelper();
     $output->writeln(array('', 'This command helps you generate your App models.', '', 'First, you need to give the model type you want to generate', '', 'Second, you need to give the model/entity name you want to generate.', 'You must use the shortcut notation like <comment>AppModule:Post</comment>.', ''));
     $modulesNames = array_keys($mvc->getModules());
     $modelTypes = array('dbal', 'orm', 'pdo');
     $question = new Question(sprintf('The Model type: <info>[%s]</info> ', $input->getOption('type')), $input->getOption('type'));
     $question->setAutocompleterValues($modelTypes);
     $modelType = $questionHelper->ask($input, $output, $question);
     # Sets type
     $input->setOption('type', $modelType);
     while (true) {
         $question = new Question(sprintf('The Model/Entity shortcut name: <info>[%s]</info> ', $input->getOption('name')), $input->getOption('name'));
         $question->setValidator(array('InstallerModule\\Command\\Validators', 'validateEntityName'));
         $question->setAutocompleterValues($modulesNames);
         $modelName = $questionHelper->ask($input, $output, $question);
         list($module, $modelName) = $this->parseShortcutNotation($modelName);
         // check reserved words
         /*if ($this->getGenerator()->isReservedKeyword($modelName)) {
               $output->writeln(sprintf('<bg=red> "%s" is a reserved word</>.', $modelName));
               continue;
           }*/
         try {
             $m = $mvc->getModule($module);
             // validate model type
             if ('orm' == strtolower($input->getOption('name')) && !file_exists($m->getPath() . '/Entity/' . str_replace('\\', '/', $modelName) . '.php')) {
                 break;
             } else {
                 if (!file_exists($m->getPath() . '/Model/' . str_replace('\\', '/', $modelName) . '.php')) {
                     break;
                 }
             }
             $output->writeln(sprintf('<bg=red>Model/Entity "%s:%s" already exists</>.', $module, $modelName));
         } catch (\Exception $e) {
             $output->writeln(sprintf('<bg=red>Module "%s" does not exist.</>', $module));
         }
     }
     $input->setOption('name', $module . ':' . $modelName);
     if ('orm' == $modelType) {
         // format
         $output->writeln(array('', 'Determine the format to use for the mapping information.', ''));
         $formats = array('yml', 'xml', 'php', 'annotation');
         $question = new Question(sprintf('Configuration format (yml, xml, php, or annotation): <info>[%s]</info>', $input->getOption('format')), $input->getOption('format'));
         $question->setValidator(array('InstallerModule\\Command\\Validators', 'validateFormat'));
         $question->setAutocompleterValues($formats);
         $format = $questionHelper->ask($input, $output, $question);
         $input->setOption('format', $format);
     }
     # fields
     $input->setOption('fields', $this->addFields($input, $output, $questionHelper));
     # repository?
     if ('orm' == $modelType) {
         $output->writeln('');
         $question = new ConfirmationQuestion('Do you want to generate an empty repository class? (yes or no): [yes] ', true);
         $withRepository = $questionHelper->ask($input, $output, $question);
         $input->setOption('with-repository', $withRepository);
     }
     # summary messages
     $sumaryMessages = array('', $this->getHelper('formatter')->formatBlock('Summary before generation', 'bg=blue;fg=white', true), '', sprintf("You are going to generate a \"<info>%s:%s</info>\" %s model/entity", $module, $modelName, strtoupper($modelType)));
     # Format to model type orm
     if ('orm' == $modelType) {
         $sumaryMessages[] = sprintf("using the \"<info>%s</info>\" format.", $format);
     }
     $sumaryMessages[] = '';
     # Summary
     $output->writeln($sumaryMessages);
 }
 protected function executeCommand($command)
 {
     // Cache can not be warmed up as classes can not be redefined during one request
     if (preg_match('/^cache:clear/', $command)) {
         $command .= ' --no-warmup';
     }
     $input = new StringInput($command);
     $input->setInteractive(false);
     $output = new StringOutput();
     $formatter = $output->getFormatter();
     $formatter->setDecorated(true);
     $output->setFormatter(new HtmlOutputFormatterDecorator($formatter));
     # MVC object store
     MVCStore::store('mvc', $this->mvc);
     // Some commands (i.e. doctrine:query:dql) dump things out instead of returning a value
     ob_start();
     $this->application->setAutoExit(false);
     $errorCode = $this->application->run($input, $output);
     // So, if the returned output is empty
     if (!($result = $output->getBuffer())) {
         $result = ob_get_contents();
         // We replace it by the catched output
     }
     ob_end_clean();
     return array('command' => $command, 'output' => $result, 'errorCode' => $errorCode);
 }