예제 #1
0
파일: jApp.php 프로젝트: rodacom/jelix
 public static function declareModulesDir($basePath, $modules = null)
 {
     \Jelix\Core\App::declareModulesDir($basePath, $modules);
 }
예제 #2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $appPath = $input->getArgument('path');
     $appPath = Path::normalizePath($appPath, 0, getcwd());
     $appName = basename($appPath);
     $appPath .= '/';
     if (file_exists($appPath . '/jelix-app.json') || file_exists($appPath . '/project.xml')) {
         throw new \Exception("this application is already created");
     }
     $this->prepareSubCommandApp($appName, $appPath);
     App::setEnv('jelix-scripts');
     \Jelix\DevHelper\JelixScript::checkTempPath();
     if ($p = $input->getOption('wwwpath')) {
         $wwwpath = Path::shortestPath($appPath, $p) . '/';
     } else {
         $wwwpath = App::wwwPath();
     }
     if ($output->isVerbose()) {
         $output->writeln("Create directories and files at {$appPath}");
     }
     $param = $this->_createSkeleton($appPath, $appName, $wwwpath, $input);
     App::declareModulesDir(array($appPath . '/modules/'));
     $installer = new \Jelix\Installer\Installer(new \Jelix\Installer\Reporter\Console($output->isVerbose() ? 'notice' : 'warning'));
     $installer->installApplication();
     $moduleok = true;
     if (!$input->getOption('nodefaultmodule')) {
         try {
             if ($output->isVerbose()) {
                 $output->writeln("Create default module " . $param['modulename']);
             }
             $options = array('module' => $param['modulename'], '--addinstallzone' => true, '--noregistration' => true);
             if ($output->isVerbose()) {
                 $options['-v'] = true;
             }
             $this->executeSubCommand('module:create', $options, $output);
             if ($output->isVerbose()) {
                 $output->writeln("Create main template");
             }
             $this->createFile($appPath . 'modules/' . $param['modulename'] . '/templates/main.tpl', 'module/main.tpl.tpl', $param, "Main template");
         } catch (\Exception $e) {
             $moduleok = false;
             $output->writeln("<error>The module has not been created because of this error: " . $e->getMessage() . "</error>");
             $output->writeln("However the application has been created");
         }
     }
     if ($input->getOption('withcmdline')) {
         if (!$input->getOption('nodefaultmodule') && $moduleok) {
             if ($output->isVerbose()) {
                 $output->writeln("Create a controller in the default module for the cli script");
             }
             $options = array('module' => $param['modulename'], 'controller' => 'default', 'method' => 'index', '--cmdline' => true);
             if ($output->isVerbose()) {
                 $options['-v'] = true;
             }
             $this->executeSubCommand('module:createctrl', $options, $output);
         }
         if ($output->isVerbose()) {
             $output->writeln("Create the cli script");
         }
         $options = array('entrypoint' => $param['modulename'], '--type' => 'cmdline');
         if ($output->isVerbose()) {
             $options['-v'] = true;
         }
         $this->executeSubCommand('app:createentrypoint', $options, $output);
     }
 }