本文整理汇总了PHP中AgaviConfig::set方法的典型用法代码示例。如果您正苦于以下问题:PHP AgaviConfig::set方法的具体用法?PHP AgaviConfig::set怎么用?PHP AgaviConfig::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AgaviConfig
的用法示例。
在下文中一共展示了AgaviConfig::set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
if (file_exists($this->icingaWebDir . '/app/config.php')) {
require $this->icingaWebDir . '/lib/agavi/src/agavi.php';
require $this->icingaWebDir . '/app/config.php';
require_once $this->icingaWebDir . '/lib/doctrine/lib/Doctrine/Exception.php';
require_once $this->icingaWebDir . '/lib/doctrine/lib/Doctrine/Locator/Injectable.php';
require_once $this->icingaWebDir . '/lib/doctrine/lib/Doctrine/Access.php';
require_once $this->icingaWebDir . '/lib/doctrine/lib/Doctrine/Record/Abstract.php';
require_once $this->icingaWebDir . '/lib/doctrine/lib/Doctrine/Record.php';
require_once $this->icingaWebDir . '/lib/doctrine/lib/Doctrine/Record/Iterator.php';
require_once $this->icingaWebDir . '/lib/doctrine/lib/Doctrine/Null.php';
require_once $this->icingaWebDir . '/lib/doctrine/lib/Doctrine/Core.php';
require_once $this->icingaWebDir . '/lib/doctrine/lib/Doctrine/Configurable.php';
require_once $this->icingaWebDir . '/lib/doctrine/lib/Doctrine/Manager/Exception.php';
require_once $this->icingaWebDir . '/lib/doctrine/lib/Doctrine/Manager.php';
require_once $this->icingaWebDir . '/app/modules/AppKit/lib/database/models/generated/BaseNsmUser.php';
require_once $this->icingaWebDir . '/app/modules/AppKit/lib/database/models/NsmUser.php';
Agavi::bootstrap('production');
AgaviConfig::set('core.default_context', 'web');
AgaviConfig::set('core.context_implementation', 'AppKitAgaviContext');
AgaviContext::getInstance('web')->getController()->dispatch();
$icingWebUser = new NsmUser('nsm_user');
// $icingWebUser->
$icingWebUser->updatePassword($newPassword);
}
}
示例2: main
public function main()
{
require_once dirname(__FILE__) . '/../../app/config.php';
Agavi::bootstrap('development');
AgaviController::initializeModule('AppKit');
AgaviConfig::set('core.default_context', 'console');
AgaviConfig::set('core.context_implementation', 'AppKitAgaviContext');
AgaviContext::getInstance('console')->getController()->dispatch();
}
示例3: tearDown
public function tearDown()
{
$_SERVER = $this->_SERVER;
$_ENV = $this->_ENV;
$_GET = $this->_GET;
$ctx = AgaviContext::getInstance('routing-server-cases');
$ctx->getRequest()->initialize($ctx);
AgaviConfig::set('core.use_routing', false);
}
示例4: bootstrap
/**
* Startup the Agavi core
*
* @param string environment the environment to use for this session.
*
* @author David Zülke <dz@bitxtender.com>
* @since 0.11.0
*/
public static function bootstrap($environment = null)
{
// set up our __autoload
spl_autoload_register(array('AgaviAutoloader', 'loadClass'));
try {
if ($environment === null) {
// no env given? let's read one from core.environment
$environment = AgaviConfig::get('core.environment');
} elseif (AgaviConfig::has('core.environment') && AgaviConfig::isReadonly('core.environment')) {
// env given, but core.environment is read-only? then we must use that instead and ignore the given setting
$environment = AgaviConfig::get('core.environment');
}
if ($environment === null) {
// still no env? oh man...
throw new AgaviException('You must supply an environment name to Agavi::bootstrap() or set the name of the default environment to be used in the configuration directive "core.environment".');
}
// finally set the env to what we're really using now.
AgaviConfig::set('core.environment', $environment, true, true);
AgaviConfig::set('core.debug', false, false);
if (!AgaviConfig::has('core.app_dir')) {
throw new AgaviException('Configuration directive "core.app_dir" not defined, terminating...');
}
// define a few filesystem paths
AgaviConfig::set('core.cache_dir', AgaviConfig::get('core.app_dir') . '/cache', false, true);
AgaviConfig::set('core.config_dir', AgaviConfig::get('core.app_dir') . '/config', false, true);
AgaviConfig::set('core.system_config_dir', AgaviConfig::get('core.agavi_dir') . '/config/defaults', false, true);
AgaviConfig::set('core.lib_dir', AgaviConfig::get('core.app_dir') . '/lib', false, true);
AgaviConfig::set('core.model_dir', AgaviConfig::get('core.app_dir') . '/models', false, true);
AgaviConfig::set('core.module_dir', AgaviConfig::get('core.app_dir') . '/modules', false, true);
AgaviConfig::set('core.template_dir', AgaviConfig::get('core.app_dir') . '/templates', false, true);
AgaviConfig::set('core.cldr_dir', AgaviConfig::get('core.agavi_dir') . '/translation/data', false, true);
// autoloads first (will trigger the compilation of config_handlers.xml)
$autoload = AgaviConfig::get('core.config_dir') . '/autoload.xml';
if (!is_readable($autoload)) {
$autoload = AgaviConfig::get('core.system_config_dir') . '/autoload.xml';
}
AgaviConfigCache::load($autoload);
// load base settings
AgaviConfigCache::load(AgaviConfig::get('core.config_dir') . '/settings.xml');
// clear our cache if the conditions are right
if (AgaviConfig::get('core.debug')) {
AgaviToolkit::clearCache();
// load base settings
AgaviConfigCache::load(AgaviConfig::get('core.config_dir') . '/settings.xml');
}
$compile = AgaviConfig::get('core.config_dir') . '/compile.xml';
if (!is_readable($compile)) {
$compile = AgaviConfig::get('core.system_config_dir') . '/compile.xml';
}
// required classes for the framework
AgaviConfigCache::load($compile);
} catch (Exception $e) {
AgaviException::render($e);
}
}
示例5: bootstrap
/**
* Loads the agavi and appkit bootstrap
* TODO: the appkit bootstrap is not really needed, the console context
* uses it's factories. Perhaps a "cron" context can be created to minimize
* memory usage and optimize performance
*
*/
private function bootstrap()
{
require_once $this->agaviPath;
require_once $this->configPath;
// +---------------------------------------------------------------------------+
// Setting the running context to web ...
Agavi::bootstrap('development');
AgaviConfig::set('core.default_context', 'console');
AgaviController::initializeModule('AppKit');
AgaviConfig::set('core.context_implementation', 'AppKitAgaviContext');
AppKitAgaviContext::getInstance();
}
示例6: tryBootstrapAgavi
/**
* Utility method to bootstrap Agavi.
*/
protected function tryBootstrapAgavi()
{
if (!self::$agaviBootstrapped) {
/* Something might fuck up. We always use the template that you can
* actually read. */
AgaviConfig::set('exception.default_template', sprintf('%s/templates/plaintext.php', (string) $this->project->getProperty('agavi.directory.src.exception')), $overwrite = true, $readonly = true);
/* To further prevent fucking up, we force it into debug mode. */
AgaviConfig::set('core.debug', true, $overwrite = true, $readonly = true);
require_once sprintf('%s/%s/config.php', (string) $this->project->getProperty('project.directory'), (string) $this->project->getProperty('project.directory.app'));
Agavi::bootstrap($this->project->getProperty('project.build.environment'));
self::$agaviBootstrapped = true;
}
}
示例7: bootstrap
/**
* Startup the Agavi core
*
* @param string environment the environment to use for this session.
*
* @author Felix Gilcher <felix.gilcher@exozet.com>
* @since 1.0.0
*/
public static function bootstrap($environment = null)
{
if ($environment === null) {
// no env given? let's read one from testing.environment
$environment = AgaviConfig::get('testing.environment');
} elseif (AgaviConfig::has('testing.environment') && AgaviConfig::isReadonly('testing.environment')) {
// env given, but testing.environment is read-only? then we must use that instead and ignore the given setting
$environment = AgaviConfig::get('testing.environment');
}
if ($environment === null) {
// still no env? oh man...
throw new Exception('You must supply an environment name to AgaviTesting::bootstrap() or set the name of the default environment to be used for testing in the configuration directive "testing.environment".');
}
// finally set the env to what we're really using now.
AgaviConfig::set('testing.environment', $environment, true, true);
// bootstrap the framework for autoload, config handlers etc.
Agavi::bootstrap($environment);
ini_set('include_path', get_include_path() . PATH_SEPARATOR . dirname(dirname(__FILE__)));
$GLOBALS['AGAVI_CONFIG'] = AgaviConfig::toArray();
}
示例8: bootstrapAgavi
/**
* Starts an agavi context for testing purposes. This was bundled into the
* test bootstrap method to call this only once
* @param string $env Name of the context
* @return AgaviContext The created context
*/
public function bootstrapAgavi($env = 'testing', array $modules = array())
{
require IcingaWebTestTool::getRootPath() . '/lib/agavi/src/agavi.php';
AgaviConfig::set('core.testing_dir', IcingaWebTestTool::getTestPath());
AgaviConfig::set('core.app_dir', IcingaWebTestTool::getRootPath() . DIRECTORY_SEPARATOR . 'app');
AgaviConfig::set('core.root_dir', IcingaWebTestTool::getRootPath());
Agavi::bootstrap($env);
AgaviConfig::set('core.default_context', $env);
AppKitAgaviUtil::initializeModule('AppKit');
AppKitAgaviUtil::initializeModule('Api');
foreach ($modules as $module) {
AppKitAgaviUtil::initializeModule($module);
}
AgaviConfig::set('core.context_implementation', 'AppKitAgaviContext');
return AgaviContext::getInstance($env);
}
示例9: initializeModule
/**
* Initialize a module and load its autoload, module config etc.
*
* @param string The name of the module to initialize.
*
* @author Felix Gilcher <felix.gilcher@bitextender.com>
* @since 1.0.0
*/
public function initializeModule($moduleName)
{
$lowerModuleName = strtolower($moduleName);
if (null === AgaviConfig::get('modules.' . $lowerModuleName . '.enabled')) {
// set some defaults first
AgaviConfig::fromArray(array('modules.' . $lowerModuleName . '.agavi.action.path' => '%core.module_dir%/${moduleName}/actions/${actionName}Action.class.php', 'modules.' . $lowerModuleName . '.agavi.cache.path' => '%core.module_dir%/${moduleName}/cache/${actionName}.xml', 'modules.' . $lowerModuleName . '.agavi.template.directory' => '%core.module_dir%/${module}/templates', 'modules.' . $lowerModuleName . '.agavi.validate.path' => '%core.module_dir%/${moduleName}/validate/${actionName}.xml', 'modules.' . $lowerModuleName . '.agavi.view.path' => '%core.module_dir%/${moduleName}/views/${viewName}View.class.php', 'modules.' . $lowerModuleName . '.agavi.view.name' => '${actionName}${viewName}'));
// include the module configuration
// loaded only once due to the way load() (former import()) works
if (is_readable(AgaviConfig::get('core.module_dir') . '/' . $moduleName . '/config/module.xml')) {
include_once AgaviConfigCache::checkConfig(AgaviConfig::get('core.module_dir') . '/' . $moduleName . '/config/module.xml');
} else {
AgaviConfig::set('modules.' . $lowerModuleName . '.enabled', true);
}
$moduleAutoload = AgaviConfig::get('core.module_dir') . '/' . $moduleName . '/config/autoload.xml';
if (is_readable($moduleAutoload)) {
AgaviConfigCache::load($moduleAutoload);
}
if (AgaviConfig::get('modules.' . $lowerModuleName . '.enabled')) {
$moduleConfigHandlers = AgaviConfig::get('core.module_dir') . '/' . $moduleName . '/config/config_handlers.xml';
if (is_readable($moduleConfigHandlers)) {
AgaviConfigCache::addConfigHandlersFile($moduleConfigHandlers);
}
}
}
if (!AgaviConfig::get('modules.' . $lowerModuleName . '.enabled')) {
throw new AgaviDisabledModuleException(sprintf('The module "%1$s" is disabled.', $moduleName));
}
// check for a module config.php
$moduleConfig = AgaviConfig::get('core.module_dir') . '/' . $moduleName . '/config.php';
if (is_readable($moduleConfig)) {
require_once $moduleConfig;
}
}
示例10:
// | file that was distributed with this source code. You can also view the |
// | LICENSE file online at http://www.agavi.org/LICENSE.txt |
// | vi: set noexpandtab: |
// | Local Variables: |
// | indent-tabs-mode: t |
// | End: |
// +---------------------------------------------------------------------------+
/**
* Version initialization script.
*
* @package agavi
*
* @author David Zülke <dz@bitxtender.com>
* @copyright Authors
* @copyright The Agavi Project
*
* @since 0.9.0
*
* @version $Id$
*/
AgaviConfig::set('agavi.name', 'Agavi');
AgaviConfig::set('agavi.major_version', '1');
AgaviConfig::set('agavi.minor_version', '1');
AgaviConfig::set('agavi.micro_version', '0');
AgaviConfig::set('agavi.status', 'dev');
AgaviConfig::set('agavi.branch', 'trunk');
AgaviConfig::set('agavi.version', AgaviConfig::get('agavi.major_version') . '.' . AgaviConfig::get('agavi.minor_version') . '.' . AgaviConfig::get('agavi.micro_version') . (AgaviConfig::has('agavi.status') ? '-' . AgaviConfig::get('agavi.status') : ''));
AgaviConfig::set('agavi.release', AgaviConfig::get('agavi.name') . '/' . AgaviConfig::get('agavi.version'));
AgaviConfig::set('agavi.url', 'http://www.agavi.org');
AgaviConfig::set('agavi_info', AgaviConfig::get('agavi.release') . ' (' . AgaviConfig::get('agavi.url') . ')');
示例11: realpath
<?php
AgaviConfig::set('core.testing_dir', realpath(__DIR__));
AgaviConfig::set('core.app_dir', realpath(__DIR__ . '/sandbox/app/'));
AgaviConfig::set('core.cache_dir', AgaviConfig::get('core.app_dir') . '/cache');
// for the clearCache() before bootstrap()
示例12: dirname
// | End: |
// +---------------------------------------------------------------------------+
/**
* Pre-initialization script.
*
* @package agavi
*
* @author Sean Kerr <skerr@mojavi.org>
* @author Mike Vincent <mike@agavi.org>
* @author David Zülke <dz@bitxtender.com>
* @copyright Authors
* @copyright The Agavi Project
*
* @since 0.9.0
*
* @version $Id: agavi.php 4718 2011-06-16 18:55:28Z david $
*/
// load the AgaviConfig class
require dirname(__FILE__) . '/config/AgaviConfig.class.php';
// check minimum PHP version
AgaviConfig::set('core.minimum_php_version', '5.2.0');
if (version_compare(PHP_VERSION, AgaviConfig::get('core.minimum_php_version'), '<')) {
trigger_error('Agavi requires PHP version ' . AgaviConfig::get('core.minimum_php_version') . ' or greater', E_USER_ERROR);
}
// define a few filesystem paths
AgaviConfig::set('core.agavi_dir', dirname(__FILE__), true, true);
// default exception template
AgaviConfig::set('exception.default_template', AgaviConfig::get('core.agavi_dir') . '/exception/templates/shiny.php');
// required files
require AgaviConfig::get('core.agavi_dir') . '/version.php';
require AgaviConfig::get('core.agavi_dir') . '/core/Agavi.class.php';
示例13: getenv
// AgaviConfig::set('project.templates_dir', AgaviConfig::get('project.dir') . '/app/templates'); // see twigrenderer
// always points to the honeybee skeleton templates lookup dir (whether honeybee runs standalone or as vendor lib)
AgaviConfig::set('core.honeybee_skeleton_dir', AgaviConfig::get('core.honeybee_dir') . '/dev/skeletons');
// project's skeleton lookup dir
AgaviConfig::set('core.skeleton_dir', AgaviConfig::get('core.cms_dir') . '/dev/skeletons');
// all skeleton lookup locations
AgaviConfig::set('core.skeleton_dirs', [AgaviConfig::get('core.skeleton_dir'), AgaviConfig::get('core.honeybee_skeleton_dir')]);
// allow a custom cache directory location
$cache_dir = getenv('APP_CACHE_DIR');
//$cache_dir = '/dev/shm/cache';
if ($cache_dir === false) {
// default cache directory takes environment into account to mitigate cases
// where the environment on a server is switched and the cache isn't cleared
AgaviConfig::set('core.cache_dir', AgaviConfig::get('core.app_dir') . '/cache', true, true);
AgaviConfig::set('core.cache_dir_without_env', AgaviConfig::get('core.app_dir') . '/cache', true, true);
} else {
// use cache directory given by environment variable
$cache_dir = realpath($cache_dir);
AgaviConfig::set('core.cache_dir', $cache_dir, true, true);
// overwrite, readonly
AgaviConfig::set('core.cache_dir_without_env', $cache_dir, true, true);
}
// contexts are e.g. 'web', 'console', 'soap' or 'xmlrpc'
$default_context = @$default_context ?: getenv('APP_CONTEXT');
if (!$default_context) {
throw new RuntimeException('Missing default context setting or APP_CONTEXT environment variable.');
}
// this is one of the most important settings for agavi
AgaviConfig::set('core.default_context', $default_context);
// some default timezone should always be set
date_default_timezone_set('Europe/Berlin');
示例14:
// +---------------------------------------------------------------------------+
// | An absolute filesystem path to the agavi package. This directory |
// | contains all the Agavi packages. |
// | |
// | This constant will be auto-set by Agavi if you do not supply it. |
// | The default value is the name of the directory "agavi.php" resides in. |
// +---------------------------------------------------------------------------+
// AgaviConfig::set('core.agavi_dir', '%%PATH_TO_AGAVI%%');
// +---------------------------------------------------------------------------+
// | An absolute filesystem path to your web application directory. This |
// | directory is the root of your web application, which includes the core |
// | configuration files and related web application data. |
// | You shouldn't have to change this usually since it's auto-determined. |
// | Agavi can't determine this automatically, so you always have to supply it.|
// +---------------------------------------------------------------------------+
AgaviConfig::set('core.app_dir', __DIR__);
// +---------------------------------------------------------------------------+
// | An absolute filesystem path to the directory where cache files will be |
// | stored. |
// | |
// | NOTE: If you're going to use a public temp directory, make sure this is a |
// | sub-directory of the temp directory. The cache system will attempt |
// | to clean up *ALL* data in this directory. |
// | |
// | This constant will be auto-set by Agavi if you do not supply it. |
// | The default value is: "<core.app_dir>/cache" |
// +---------------------------------------------------------------------------+
// AgaviConfig::set('core.cache_dir', AgaviConfig::get('core.app_dir') . '/cache');
// +---------------------------------------------------------------------------+
// | You may also modify the following other directives in this file: |
// | - core.config_dir (defaults to "<core.app_dir>/config") |
示例15: main
public function main()
{
set_time_limit(0);
require_once 'src/agavi.php';
$this->olsonDir = realpath($this->olsonDir);
$this->outputDir = realpath($this->outputDir);
AgaviConfig::set('olson.dir', $this->olsonDir);
AgaviConfig::set('core.app_dir', getcwd() . '/etc/olson/agavi/app');
Agavi::bootstrap('');
$context = AgaviContext::getInstance('');
if (!$this->olsonDir || !file_exists($this->olsonDir)) {
throw new BuildException('Olson data directory is not defined or does not exist.');
}
if (!$this->outputDir || !file_exists($this->outputDir)) {
throw new BuildException('Timezone data output directory is not defined or does not exist.');
}
$this->log("Building compiling olson files in {$this->olsonDir} to {$this->outputDir}", PROJECT_MSG_INFO);
$links = array();
$zones = array();
$di = new DirectoryIterator($this->olsonDir);
foreach ($di as $file) {
if ($file->isFile()) {
// the file doesn't contain an extension so we parse it
// and we don't want the factory time zone
if (strpos($file->getFilename(), '.') === false && $file->getFilename() != 'factory') {
$this->log(sprintf('compiling %s', $file->getPathname()), PROJECT_MSG_INFO);
$parser = new AgaviTimeZoneDataParser();
$parser->initialize(AgaviContext::getInstance($context));
$rules = $parser->parse($file->getPathname());
$zones = $rules['zones'] + $zones;
$links = $rules['links'] + $links;
}
}
}
$baseCode = '<?php
/**
* %s
* %s
*
* @package agavi
* @subpackage translation
*
* @copyright Authors
* @copyright The Agavi Project
*
* @since 0.11.0
*
* @version $Id' . '$
*/
return %s;
?>';
$zoneList = array();
foreach ($zones as $name => $zone) {
$fname = preg_replace('#([^a-z0-9_])#ie', "'_'.ord('\\1').'_'", $name) . '.php';
$pathname = $this->outputDir . '/' . $fname;
$zone['name'] = $name;
$zoneList[$name] = array('type' => 'zone', 'filename' => $fname);
$this->log('Writing zone ' . $name . ' to: ' . $pathname);
file_put_contents($pathname, sprintf($baseCode, sprintf('Data file for timezone "%s".', $name), sprintf('Compiled from olson file "%s", version %s.', $zone['source'], $zone['version']), var_export($zone, true)));
}
foreach ($links as $from => $to) {
$zoneList[$from] = array('type' => 'link', 'to' => $to);
}
$this->log('Writing zone listing to: ' . $this->outputDir . '/zonelist.php');
file_put_contents($this->outputDir . '/zonelist.php', sprintf($baseCode, 'Zone list file.', sprintf('Generated on %s.', gmdate('c')), var_export($zoneList, true)));
}