本文整理汇总了PHP中jApp::setConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP jApp::setConfig方法的具体用法?PHP jApp::setConfig怎么用?PHP jApp::setConfig使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jApp
的用法示例。
在下文中一共展示了jApp::setConfig方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadAppConfig
function loadAppConfig()
{
if (jApp::config()) {
return;
}
$xml = simplexml_load_file(jApp::appPath('project.xml'));
$configFile = '';
foreach ($xml->entrypoints->entry as $entrypoint) {
$file = (string) $entrypoint['file'];
if ($file == $this->entryPointName) {
$configFile = (string) $entrypoint['config'];
break;
}
}
if ($configFile == '') {
throw new Exception("Entry point is unknown");
}
require_once JELIX_LIB_PATH . "core/jConfigCompiler.class.php";
jApp::setConfig(jConfigCompiler::read($configFile, true, true, $this->entryPointName));
}
示例2: initJelixConfig
/**
* init jelix configuration.
*
* If you need to setup a full jelix environment with a coordinator,
* prefer to call initClassicRequest
* @param string $config the configuration file to use, as if you were inside an entry point
* @param string $entryPoint the entrypoint name as indicated into project.xml
*/
protected static function initJelixConfig($config = 'index/config.ini.php', $entryPoint = 'index.php')
{
$config = jConfigCompiler::read($config, true, true, $entryPoint);
jApp::setConfig($config);
jApp::setCoord(null);
}
示例3: run
public function run()
{
$this->loadAppConfig();
$module = $this->getParam('module');
$initialVersion = $this->getOption('-ver');
if ($initialVersion === false) {
$initialVersion = '0.1pre';
}
// note: since module name are used for name of generated name,
// only this characters are allowed
if ($module == null || preg_match('/([^a-zA-Z_0-9])/', $module)) {
throw new Exception("'" . $module . "' is not a valid name for a module");
}
// check if the module already exist or not
$path = '';
try {
$path = $this->getModulePath($module);
} catch (Exception $e) {
}
if ($path != '') {
throw new Exception("module '" . $module . "' already exists");
}
// verify the given repository
$repository = $this->getParam('repository', 'app:modules/');
if (substr($repository, -1) != '/') {
$repository .= '/';
}
$repositoryPath = jFile::parseJelixPath($repository);
$iniDefault = new jIniFileModifier(jApp::mainConfigFile());
$this->updateModulePath($iniDefault, $iniDefault->getValue('modulesPath'), $repository, $repositoryPath);
if ($this->verbose()) {
echo "modulePath updated in the main configuration\n";
}
if (!$this->allEntryPoint) {
$list = $this->getEntryPointsList();
foreach ($list as $k => $entryPoint) {
if ($entryPoint['file'] == $this->entryPointName) {
$ini = new jIniFileModifier(jApp::configPath($entryPoint['config']));
break;
}
}
if (!$ini) {
throw new Exception("entry point is unknown");
}
$this->updateModulePath($ini, jApp::config()->modulesPath, $repository, $repositoryPath);
if ($this->verbose()) {
echo "modulePath updated in the configuration " . $entryPoint['config'] . "\n";
}
}
$path = $repositoryPath . $module . '/';
$this->createDir($path);
jApp::setConfig(null);
if ($this->getOption('-admin')) {
$this->removeOption('-nosubdir');
$this->removeOption('-addinstallzone');
}
$param = array();
$param['module'] = $module;
$param['default_id'] = $module . $this->config->infoIDSuffix;
$param['version'] = $initialVersion;
$this->createFile($path . 'module.xml', 'module/module.xml.tpl', $param);
// create all sub directories of a module
if (!$this->getOption('-nosubdir')) {
$this->createDir($path . 'classes/');
$this->createDir($path . 'zones/');
$this->createDir($path . 'controllers/');
$this->createDir($path . 'templates/');
$this->createDir($path . 'classes/');
$this->createDir($path . 'daos/');
$this->createDir($path . 'forms/');
$this->createDir($path . 'locales/');
$this->createDir($path . 'locales/en_US/');
$this->createDir($path . 'locales/fr_FR/');
$this->createDir($path . 'install/');
if ($this->verbose()) {
echo "Sub directories have been created in the new module {$module}.\n";
}
$this->createFile($path . 'install/install.php', 'module/install.tpl', $param);
$this->createFile($path . 'urls.xml', 'module/urls.xml.tpl', array());
}
$isdefault = $this->getOption('-defaultmodule');
// activate the module in the application
if ($isdefault) {
$iniDefault->setValue('startModule', $module);
$iniDefault->setValue('startAction', 'default:index');
if ($this->verbose()) {
echo "The new module {$module} becomes the default module\n";
}
}
$iniDefault->setValue($module . '.access', $this->allEntryPoint ? 2 : 1, 'modules');
$iniDefault->save();
$list = $this->getEntryPointsList();
$install = new jIniFileModifier(jApp::configPath('installer.ini.php'));
// install the module for all needed entry points
foreach ($list as $k => $entryPoint) {
$configFile = jApp::configPath($entryPoint['config']);
$epconfig = new jIniFileModifier($configFile);
if ($this->allEntryPoint) {
$access = 2;
} else {
//.........这里部分代码省略.........
示例4: handleCustomTestSuite
protected function handleCustomTestSuite()
{
$modulesTests = -1;
/*
$this->options[0] is an array of all options '--xxx'.
each values is an array(0=>'optionname', 1=>'value if given')
$this->options[1] is a list of parameters given after options
it can be array(0=>'test name', 1=>'filename')
*/
foreach ($this->options[0] as $option) {
switch ($option[0]) {
case '--entrypoint':
$this->entryPoint = $option[1];
break;
case '--all-modules':
$modulesTests = 0;
break;
case '--module':
$modulesTests = 1;
// test is the module name
// testFile is the test file inside the module
break;
case '--testtype':
$this->testType = $option[1];
break;
}
}
if (isset($this->options[1][1]) && $modulesTests != 0) {
// a specifique test file
$this->arguments['testFile'] = $this->options[1][1];
} else {
$this->arguments['testFile'] = '';
}
$appInstaller = new jInstallerApplication();
$this->epInfo = $appInstaller->getEntryPointInfo($this->entryPoint);
// let's load configuration now, and coordinator. it could be needed by tests
// (during load of their php files or during execution)
jApp::setConfig(jConfigCompiler::readAndCache($this->epInfo->configFile, null, $this->entryPoint));
jApp::setCoord(new jCoordinator('', false));
if ($modulesTests == 0) {
// we add all modules in the test list
$suite = $this->getAllModulesTestSuites();
if (count($suite)) {
$this->arguments['test'] = $suite;
unset($this->arguments['testFile']);
} else {
$this->showMessage("Error: no tests in modules\n");
exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT);
}
} else {
if ($modulesTests == 1 && !$this->version36) {
$suite = $this->getModuleTestSuite($this->options[1][0]);
if (count($suite)) {
$this->arguments['test'] = $suite;
if (isset($this->options[1][1])) {
// a specifique test file
$this->arguments['testFile'] = $this->options[1][1];
} else {
$this->arguments['testFile'] = '';
}
} else {
$this->showMessage("Error: no tests in the module\n");
exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT);
}
} else {
if ($modulesTests == 1) {
if (isset($this->options[1][1])) {
// a specifique test file
$suite = $this->getModuleTestSuite($this->options[1][0], $this->options[1][1]);
} else {
$suite = $this->getModuleTestSuite($this->options[1][0]);
}
if (count($suite)) {
$this->arguments['test'] = $suite;
} else {
$this->showMessage("Error: no tests in the module\n");
exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT);
}
}
}
}
}
示例5: _installModules
protected function _installModules(&$modules, $epId, $installWholeApp, $flags = 3)
{
$this->notice('install.entrypoint.start', $epId);
$ep = $this->entryPoints[$epId];
jApp::setConfig($ep->config);
if ($ep->config->disableInstallers) {
$this->notice('install.entrypoint.installers.disabled');
}
$result = $this->checkDependencies($modules, $epId);
if (!$result) {
$this->error('install.bad.dependencies');
$this->ok('install.entrypoint.bad.end', $epId);
return false;
}
$this->ok('install.dependencies.ok');
$componentsToInstall = array();
foreach ($this->_componentsToInstall 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->config->disableInstallers) {
$upgraders = array();
} else {
$upgraders = $component->getUpgraders($ep);
foreach ($upgraders as $upgrader) {
$upgrader->preInstall();
}
}
$componentsToInstall[] = array($upgraders, $component, false);
} else {
if ($toInstall) {
if ($ep->config->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->config->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 (jInstallerException $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();
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();
}
$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;
}
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);
//.........这里部分代码省略.........
示例6: _installModules
/**
* core of the installation
* @param array $modules list of jInstallerComponentModule
* @param string $epId the entrypoint id
* @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, $epId, $installWholeApp, $flags = 3)
{
$this->notice('install.entrypoint.start', $epId);
$ep = $this->entryPoints[$epId];
jApp::setConfig($ep->config);
if ($ep->config->disableInstallers) {
$this->notice('install.entrypoint.installers.disabled');
}
// first, check dependencies of the component, to have the list of component
// we should really install. It fills $this->_componentsToInstall, in the right
// order
$result = $this->checkDependencies($modules, $epId);
if (!$result) {
$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();
foreach ($this->_componentsToInstall 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->config->disableInstallers) {
$upgraders = array();
} else {
$upgraders = $component->getUpgraders($ep);
foreach ($upgraders as $upgrader) {
$upgrader->preInstall();
}
}
$componentsToInstall[] = array($upgraders, $component, false);
} else {
if ($toInstall) {
if ($ep->config->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->config->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 (jInstallerException $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 = '';
//.........这里部分代码省略.........
示例7: loadAppConfig
function loadAppConfig()
{
if (jApp::config()) {
return;
}
$xml = simplexml_load_file(jApp::appPath('project.xml'));
$configFile = '';
foreach ($xml->entrypoints->entry as $entrypoint) {
$file = (string) $entrypoint['file'];
if ($file == $this->entryPointName) {
$configFile = (string) $entrypoint['config'];
break;
}
}
if ($configFile == '') {
throw new Exception($this->name . ": Entry point is unknown");
}
jApp::setConfig(jConfigCompiler::read($configFile, true, true, $this->entryPointName));
}