Ejemplo n.º 1
0
 protected function _execute(InputInterface $input, OutputInterface $output)
 {
     \Jelix\Core\AppManager::close();
     if ($this->verbose()) {
         $reporter = new \Jelix\Installer\Reporter\Console('notice', 'Low-level migration');
     } else {
         $reporter = new \Jelix\Installer\Reporter\Console('error', 'Low-level migration');
     }
     // launch the low-level migration
     $migrator = new \Jelix\Installer\Migration($reporter);
     $migrator->migrate();
     // we can now launch the installer/updater
     if ($this->verbose()) {
         $reporter = new \Jelix\Installer\Reporter\Console();
     } else {
         $reporter = new \Jelix\Installer\Reporter\Console('error');
     }
     $installer = new \Jelix\Installer\Installer($reporter);
     if ($input->getOption('entry-point')) {
         $installer->installEntryPoint($this->entryPointId);
     } else {
         $installer->installApplication();
     }
     try {
         \Jelix\Core\AppManager::clearTemp(\Jelix\Core\App::tempBasePath());
     } catch (\Exception $e) {
         if ($e->getCode() == 2) {
             $output->writeln("<error>Error: bad path in jApp::tempBasePath(), it is equals to '" . jApp::tempBasePath() . "' !!</error>");
             $output->writeln("       Jelix cannot clear the content of the temp directory.");
             $output->writeln("       you must clear it your self.");
             $output->writeln("       Correct the path in the application.init.php or create the directory");
         } else {
             $output->writeln("<error>Error: " . $e->getMessage() . "</error>");
         }
     }
     \Jelix\Core\AppManager::open();
 }
Ejemplo n.º 2
0
 public function run()
 {
     // retrieve the type of entry point we want to create
     $type = $this->getOption('-type');
     if (!$type) {
         $type = 'classic';
     } else {
         if (!in_array($type, array('classic', 'jsonrpc', 'xmlrpc', 'soap', 'cmdline'))) {
             throw new Exception("invalid type");
         }
     }
     // retrieve the name of the entry point
     $name = $this->getParam('name');
     if (preg_match('/(.*)\\.php$/', $name, $m)) {
         $name = $m[1];
     }
     // the full path of the entry point
     if ($type == 'cmdline') {
         $entryPointFullPath = App::scriptsPath($name . '.php');
         $entryPointTemplate = 'scripts/cmdline.php.tpl';
     } else {
         $entryPointFullPath = App::wwwPath($name . '.php');
         $entryPointTemplate = 'www/' . ($type == 'classic' ? 'index' : $type) . '.php.tpl';
     }
     if (file_exists($entryPointFullPath)) {
         throw new Exception("the entry point already exists");
     }
     $entryPointDir = dirname($entryPointFullPath) . '/';
     $this->loadAppInfos();
     // retrieve the config file name
     $configFile = $this->getParam('config');
     if ($configFile == null) {
         if ($type == 'cmdline') {
             $configFile = 'cmdline/' . $name . '.ini.php';
         } else {
             $configFile = $name . '/config.ini.php';
         }
     }
     // let's create the config file if needed
     $configFilePath = App::configPath($configFile);
     if (!file_exists($configFilePath)) {
         $this->createDir(dirname($configFilePath));
         // the file doesn't exists
         // if there is a -copy-config parameter, we copy this file
         $originalConfig = $this->getOption('-copy-config');
         if ($originalConfig) {
             if (!file_exists(App::configPath($originalConfig))) {
                 throw new Exception("unknown original configuration file");
             }
             file_put_contents($configFilePath, file_get_contents(App::configPath($originalConfig)));
             if ($this->verbose()) {
                 echo "Configuration file {$configFile} has been created from the config file {$originalConfig}.\n";
             }
         } else {
             // else we create a new config file, with the startmodule of the default
             // config as a module name.
             $mainConfig = parse_ini_file(App::mainConfigFile(), true);
             $param = array();
             if (isset($mainConfig['startModule'])) {
                 $param['modulename'] = $mainConfig['startModule'];
             } else {
                 $param['modulename'] = 'jelix';
             }
             $this->createFile($configFilePath, 'var/config/index/config.ini.php.tpl', $param, "Configuration file");
         }
     }
     $inifile = new \Jelix\IniFile\MultiIniModifier(App::mainConfigFile(), $configFilePath);
     $param = array();
     $param['modulename'] = $inifile->getValue('startModule');
     // creation of the entry point
     $this->createDir($entryPointDir);
     $param['rp_app'] = $this->getRelativePath($entryPointDir, App::appPath());
     $param['config_file'] = $configFile;
     $this->createFile($entryPointFullPath, $entryPointTemplate, $param, "Entry point");
     if ($type != 'cmdline') {
         if (null === $inifile->getValue($name, 'simple_urlengine_entrypoints', null, true)) {
             $inifile->setValue($name, '', 'simple_urlengine_entrypoints', null, true);
         }
         if (null === $inifile->getValue($name, 'basic_significant_urlengine_entrypoints', null, true)) {
             $inifile->setValue($name, '1', 'basic_significant_urlengine_entrypoints', null, true);
         }
         $inifile->save();
     }
     $this->appInfos->addEntryPointInfo($name . ".php", $configFile, $type);
     if ($this->verbose()) {
         echo $this->appInfos->getFile() . " has been updated.\n";
     }
     $installer = new \Jelix\Installer\Installer(new \Jelix\Installer\Reporter\Console('warning'));
     $installer->installEntryPoint($name . ".php");
     if ($this->verbose()) {
         echo "All modules have been initialized for the new entry point.\n";
     }
 }
Ejemplo n.º 3
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // retrieve the type of entry point we want to create
     $type = $input->getOption('type');
     if (!in_array($type, array('classic', 'jsonrpc', 'xmlrpc', 'soap', 'cmdline'))) {
         throw new \Exception("invalid type");
     }
     // retrieve the name of the entry point
     $name = $input->getArgument('entrypoint');
     if (preg_match('/(.*)\\.php$/', $name, $m)) {
         $name = $m[1];
     }
     // the full path of the entry point
     if ($type == 'cmdline') {
         $entryPointFullPath = App::scriptsPath($name . '.php');
         $entryPointTemplate = 'scripts/cmdline.php.tpl';
     } else {
         $entryPointFullPath = App::wwwPath($name . '.php');
         $entryPointTemplate = 'www/' . ($type == 'classic' ? 'index' : $type) . '.php.tpl';
     }
     if (file_exists($entryPointFullPath)) {
         throw new \Exception("the entry point already exists");
     }
     $entryPointDir = dirname($entryPointFullPath) . '/';
     $this->loadAppInfos();
     // retrieve the config file name
     $configFile = $input->getArgument('config');
     if ($configFile == null) {
         if ($type == 'cmdline') {
             $configFile = 'cmdline/' . $name . '.ini.php';
         } else {
             $configFile = $name . '/config.ini.php';
         }
     }
     // let's create the config file if needed
     $configFilePath = App::appConfigPath($configFile);
     if (!file_exists($configFilePath)) {
         $this->createDir(dirname($configFilePath));
         // the file doesn't exists
         // if there is a -copy-config parameter, we copy this file
         $originalConfig = $input->getOption('copy-config');
         if ($originalConfig) {
             if (!file_exists(App::appConfigPath($originalConfig))) {
                 throw new \Exception("unknown original configuration file");
             }
             file_put_contents($configFilePath, file_get_contents(App::appConfigPath($originalConfig)));
             if ($this->verbose()) {
                 $output->writeln("Configuration file {$configFile} has been created from the config file {$originalConfig}.");
             }
         } else {
             // else we create a new config file
             $param = array();
             $this->createFile($configFilePath, 'app/config/index/config.ini.php.tpl', $param, "Configuration file");
         }
     }
     $inifile = new \Jelix\IniFile\MultiIniModifier(App::mainConfigFile(), $configFilePath);
     $urlsFile = App::appConfigPath($inifile->getValue('significantFile', 'urlengine'));
     $xmlMap = new \Jelix\Routing\UrlMapping\XmlMapModifier($urlsFile, true);
     $param = array();
     // creation of the entry point
     $this->createDir($entryPointDir);
     $param['rp_app'] = Path::shortestPath($entryPointDir, App::appPath());
     $param['config_file'] = $configFile;
     $this->createFile($entryPointFullPath, $entryPointTemplate, $param, "Entry point");
     if ($type != 'cmdline') {
         $xmlEp = $xmlMap->addEntryPoint($name, $type);
         /*if ($type == 'classic') {
               $xmlEp->addUrlAction('/', $module, $action);
           }*/
         $xmlMap->save();
     }
     $this->appInfos->addEntryPointInfo($name . ".php", $configFile, $type);
     if ($this->verbose()) {
         $output->writeln($this->appInfos->getFile() . " has been updated.");
     }
     $installer = new \Jelix\Installer\Installer(new \Jelix\Installer\Reporter\Console('warning'));
     $installer->installEntryPoint($name . ".php");
     if ($this->verbose()) {
         $output->writeln("All modules have been initialized for the new entry point.");
     }
 }