コード例 #1
0
ファイル: EntryPoint.php プロジェクト: rodacom/jelix
 /**
  * @param \Jelix\IniFile\IniModifier    $mainConfig   the mainconfig.ini.php file
  * @param string $configFile the path of the configuration file, relative
  *                           to the var/config directory
  * @param string $file the filename of the entry point
  * @param string $type type of the entry point ('classic', 'cli', 'xmlrpc'....)
  */
 function __construct(\Jelix\IniFile\IniModifier $mainConfig, $configFile, $file, $type)
 {
     $this->type = $type;
     $this->isCliScript = $type == 'cmdline';
     $this->configFile = $configFile;
     $this->scriptName = $this->isCliScript ? $file : '/' . $file;
     $this->file = $file;
     $this->configIni = new \Jelix\IniFile\MultiIniModifier($mainConfig, \Jelix\Core\App::configPath($configFile));
     $compiler = new \Jelix\Core\Config\Compiler($configFile, $this->scriptName, $this->isCliScript);
     $this->config = $compiler->read(true);
     $this->modulesInfos = $compiler->getModulesInfos();
 }
コード例 #2
0
 protected function loadAppConfig()
 {
     if (\Jelix\Core\App::config()) {
         return;
     }
     $ep = $this->getEntryPointInfo($this->entryPointName);
     if ($ep) {
         $configFile = $ep['config'];
     }
     if ($configFile == '') {
         throw new \Exception($this->name . ': Entry point is unknown');
     }
     $compiler = new \Jelix\Core\Config\Compiler($configFile, $this->entryPointName, true);
     \Jelix\Core\App::setConfig($compiler->read(true));
 }
コード例 #3
0
ファイル: EntryPoint.php プロジェクト: jelix/jelix
 /**
  * @param \Jelix\IniFile\MultiIniModifier $mainConfig   the mainconfig.ini.php file combined with defaultconfig.ini.php
  * @param \Jelix\IniFile\MultiIniModifier $localConfig   the localconfig.ini.php file combined with $mainConfig
  * @param string $configFile the path of the configuration file, relative
  *                           to the app/config directory
  * @param string $file the filename of the entry point
  * @param string $type type of the entry point ('classic', 'cli', 'xmlrpc'....)
  */
 function __construct(\Jelix\IniFile\MultiIniModifier $mainConfig, \Jelix\IniFile\MultiIniModifier $localConfig, $configFile, $file, $type)
 {
     $this->type = $type;
     $this->isCliScript = $type == 'cmdline';
     $this->configFile = $configFile;
     $this->scriptName = $this->isCliScript ? $file : '/' . $file;
     $this->file = $file;
     $this->mainConfigIni = $mainConfig;
     $this->localConfigIni = $localConfig;
     $appConfigPath = \Jelix\Core\App::appConfigPath($configFile);
     if (!file_exists($appConfigPath)) {
         \jFile::createDir(dirname($appConfigPath));
         file_put_contents($appConfigPath, ';<' . '?php die(\'\');?' . '>');
     }
     $this->epConfigIni = new \Jelix\IniFile\IniModifier($appConfigPath);
     $varConfigPath = \Jelix\Core\App::configPath($configFile);
     if (!file_exists($varConfigPath)) {
         \jFile::createDir(dirname($varConfigPath));
         file_put_contents($varConfigPath, ';<' . '?php die(\'\');?' . '>');
     }
     $this->localEpConfigIni = new \Jelix\IniFile\IniModifier($varConfigPath);
     $this->fullConfigIni = new \Jelix\IniFile\MultiIniModifier($localConfig, $this->epConfigIni);
     $this->fullConfigIni = new \Jelix\IniFile\MultiIniModifier($this->fullConfigIni, $this->localEpConfigIni);
     $compiler = new \Jelix\Core\Config\Compiler($configFile, $this->scriptName, $this->isCliScript);
     $this->config = $compiler->read(true);
     $this->modulesInfos = $compiler->getModulesInfos();
 }
コード例 #4
0
ファイル: jConfigCompiler.php プロジェクト: mdouchin/jelix
 public static function readAndCache($configFile, $isCli = null, $pseudoScriptName = '')
 {
     $compiler = new \Jelix\Core\Config\Compiler($configFile, $pseudoScriptName, $isCli);
     return $compiler->readAndCache();
 }
コード例 #5
0
ファイル: Installer.php プロジェクト: jelix/jelix
 protected function runPostInstall($installedModules, $ep, $flags)
 {
     $result = true;
     // post install
     foreach ($installedModules as $item) {
         try {
             list($installer, $component, $action) = $item;
             if ($action == Resolver::ACTION_INSTALL) {
                 if ($installer && $flags & self::FLAG_INSTALL_MODULE) {
                     $installer->postInstall();
                     $component->installFinished($ep);
                 }
             } else {
                 if ($action == Resolver::ACTION_UPGRADE) {
                     if ($flags & self::FLAG_UPGRADE_MODULE) {
                         foreach ($installer as $upgrader) {
                             $upgrader->postInstall();
                             $component->upgradeFinished($ep, $upgrader);
                         }
                     }
                 } elseif ($action == Resolver::ACTION_REMOVE) {
                     if ($installer && $flags & self::FLAG_REMOVE_MODULE) {
                         $installer->postUninstall();
                         $component->uninstallFinished($ep);
                     }
                 }
             }
             // we always save the configuration, so it invalidates the cache
             $ep->getConfigIni()->save();
             $this->xmlMapFile->save();
             // we re-load configuration file for each module because
             // previous module installer could have modify it.
             $compiler = new \Jelix\Core\Config\Compiler($ep->getConfigFile(), $ep->scriptName, $ep->isCliScript);
             $ep->setConfigObj($compiler->read(true));
             App::setConfig($ep->getConfigObj());
         } catch (Exception $e) {
             $result = false;
             $this->error($e->getLocaleKey(), $e->getLocaleParameters());
         } catch (\Exception $e) {
             $result = false;
             $this->error('install.module.error', array($component->getName(), $e->getMessage()));
         }
     }
     return $result;
 }
コード例 #6
0
ファイル: Installer.php プロジェクト: mdouchin/jelix
 /**
  * core of the installation
  * @param ModuleInstallLauncher[] $modules
  * @param EntryPoint $ep  the entrypoint
  * @param boolean $installWholeApp true if the installation is done during app installation
  * @param integer $flags to know what to do
  * @return boolean true if the installation is ok
  */
 protected function _installModules(&$modules, EntryPoint $ep, $installWholeApp, $flags = 3)
 {
     $epId = $ep->getEpId();
     $this->notice('install.entrypoint.start', $epId);
     $ep = $this->entryPoints[$epId];
     App::setConfig($ep->getConfigObj());
     if ($ep->getConfigObj()->disableInstallers) {
         $this->notice('install.entrypoint.installers.disabled');
     }
     // first, check dependencies of the component, to have the list of component
     // we should really install.
     $orderedModules = $ep->getOrderedDependencies($modules, $this);
     if ($orderedModules === false) {
         $this->error('install.bad.dependencies');
         $this->ok('install.entrypoint.bad.end', $epId);
         return false;
     }
     $this->ok('install.dependencies.ok');
     // ----------- pre install
     // put also available installers into $componentsToInstall for
     // the next step
     $componentsToInstall = array();
     $result = true;
     foreach ($orderedModules as $item) {
         list($component, $toInstall) = $item;
         try {
             if ($flags == self::FLAG_MIGRATION_11X) {
                 $this->installerIni->setValue($component->getName() . '.installed', 1, $epId);
                 $this->installerIni->setValue($component->getName() . '.version', $component->getSourceVersion(), $epId);
                 if ($ep->getConfigObj()->disableInstallers) {
                     $upgraders = array();
                 } else {
                     $upgraders = $component->getUpgraders($ep);
                     foreach ($upgraders as $upgrader) {
                         $upgrader->preInstall();
                     }
                 }
                 $componentsToInstall[] = array($upgraders, $component, false);
             } else {
                 if ($toInstall) {
                     if ($ep->getConfigObj()->disableInstallers) {
                         $installer = null;
                     } else {
                         $installer = $component->getInstaller($ep, $installWholeApp);
                     }
                     $componentsToInstall[] = array($installer, $component, $toInstall);
                     if ($flags & self::FLAG_INSTALL_MODULE && $installer) {
                         $installer->preInstall();
                     }
                 } else {
                     if ($ep->getConfigObj()->disableInstallers) {
                         $upgraders = array();
                     } else {
                         $upgraders = $component->getUpgraders($ep);
                     }
                     if ($flags & self::FLAG_UPGRADE_MODULE && count($upgraders)) {
                         foreach ($upgraders as $upgrader) {
                             $upgrader->preInstall();
                         }
                     }
                     $componentsToInstall[] = array($upgraders, $component, $toInstall);
                 }
             }
         } catch (Exception $e) {
             $result = false;
             $this->error($e->getLocaleKey(), $e->getLocaleParameters());
         } catch (\Exception $e) {
             $result = false;
             $this->error('install.module.error', array($component->getName(), $e->getMessage()));
         }
     }
     if (!$result) {
         $this->warning('install.entrypoint.bad.end', $epId);
         return false;
     }
     $installedModules = array();
     // -----  installation process
     try {
         foreach ($componentsToInstall as $item) {
             list($installer, $component, $toInstall) = $item;
             if ($toInstall) {
                 if ($installer && $flags & self::FLAG_INSTALL_MODULE) {
                     $installer->install();
                 }
                 $this->installerIni->setValue($component->getName() . '.installed', 1, $epId);
                 $this->installerIni->setValue($component->getName() . '.version', $component->getSourceVersion(), $epId);
                 $this->installerIni->setValue($component->getName() . '.version.date', $component->getSourceDate(), $epId);
                 $this->installerIni->setValue($component->getName() . '.firstversion', $component->getSourceVersion(), $epId);
                 $this->installerIni->setValue($component->getName() . '.firstversion.date', $component->getSourceDate(), $epId);
                 $this->ok('install.module.installed', $component->getName());
                 $installedModules[] = array($installer, $component, true);
             } else {
                 $lastversion = '';
                 foreach ($installer as $upgrader) {
                     if ($flags & self::FLAG_UPGRADE_MODULE) {
                         $upgrader->install();
                     }
                     // we set the version of the upgrade, so if an error occurs in
                     // the next upgrader, we won't have to re-run this current upgrader
                     // during a future update
                     $this->installerIni->setValue($component->getName() . '.version', $upgrader->version, $epId);
                     $this->installerIni->setValue($component->getName() . '.version.date', $upgrader->date, $epId);
                     $this->ok('install.module.upgraded', array($component->getName(), $upgrader->version));
                     $lastversion = $upgrader->version;
                 }
                 // we set the version to the component version, because the version
                 // of the last upgrader could not correspond to the component version.
                 if ($lastversion != $component->getSourceVersion()) {
                     $this->installerIni->setValue($component->getName() . '.version', $component->getSourceVersion(), $epId);
                     $this->installerIni->setValue($component->getName() . '.version.date', $component->getSourceDate(), $epId);
                     $this->ok('install.module.upgraded', array($component->getName(), $component->getSourceVersion()));
                 }
                 $installedModules[] = array($installer, $component, false);
             }
             // we always save the configuration, so it invalidates the cache
             $ep->getConfigIni()->save();
             $this->xmlMapFile->save();
             // we re-load configuration file for each module because
             // previous module installer could have modify it.
             $compiler = new \Jelix\Core\Config\Compiler($ep->getConfigFile(), $ep->scriptName, $ep->isCliScript);
             $ep->setConfigObj($compiler->read(true));
             App::setConfig($ep->getConfigObj());
         }
     } catch (Exception $e) {
         $result = false;
         $this->error($e->getLocaleKey(), $e->getLocaleParameters());
     } catch (\Exception $e) {
         $result = false;
         $this->error('install.module.error', array($component->getName(), $e->getMessage()));
     }
     if (!$result) {
         $this->warning('install.entrypoint.bad.end', $epId);
         return false;
     }
     // post install
     foreach ($installedModules as $item) {
         try {
             list($installer, $component, $toInstall) = $item;
             if ($toInstall) {
                 if ($installer && $flags & self::FLAG_INSTALL_MODULE) {
                     $installer->postInstall();
                     $component->installFinished($ep);
                 }
             } else {
                 if ($flags & self::FLAG_UPGRADE_MODULE) {
                     foreach ($installer as $upgrader) {
                         $upgrader->postInstall();
                         $component->upgradeFinished($ep, $upgrader);
                     }
                 }
             }
             // we always save the configuration, so it invalidates the cache
             $ep->getConfigIni()->save();
             $this->xmlMapFile->save();
             // we re-load configuration file for each module because
             // previous module installer could have modify it.
             $compiler = new \Jelix\Core\Config\Compiler($ep->getConfigFile(), $ep->scriptName, $ep->isCliScript);
             $ep->setConfigObj($compiler->read(true));
             App::setConfig($ep->getConfigObj());
         } catch (Exception $e) {
             $result = false;
             $this->error($e->getLocaleKey(), $e->getLocaleParameters());
         } catch (\Exception $e) {
             $result = false;
             $this->error('install.module.error', array($component->getName(), $e->getMessage()));
         }
     }
     $this->ok('install.entrypoint.end', $epId);
     return $result;
 }