Exemplo n.º 1
0
 /**
  * Startup the Agavi core
  *
  * @param      string environment the environment to use for this session.
  *
  * @author     David Zülke <*****@*****.**>
  * @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);
     }
 }
 /**
  * Startup the Agavi core
  *
  * @param      string environment the environment to use for this session.
  *
  * @author     Felix Gilcher <*****@*****.**>
  * @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();
 }
Exemplo n.º 3
0
 public function main()
 {
     $agaviPath = realpath(getcwd() . '/src/agavi.php');
     if (!$agaviPath && !file_exists($agaviPath)) {
         throw new BuildException('Agavi not found.');
     }
     require_once $agaviPath;
     $this->project->setUserProperty('agavi.version', AgaviConfig::get('agavi.version'));
     $this->project->setUserProperty('agavi.pear.version', sprintf("%d.%d.%d%s", AgaviConfig::get('agavi.major_version'), AgaviConfig::get('agavi.minor_version'), AgaviConfig::get('agavi.micro_version'), AgaviConfig::has('agavi.status') ? AgaviConfig::get('agavi.status') : ''));
     $status = AgaviConfig::get('agavi.status');
     if ($status == 'dev') {
         $status = 'devel';
     } elseif (strpos($status, 'alpha') !== false) {
         $status = 'alpha';
     } elseif (strpos($status, 'beta') !== false) {
         $status = 'beta';
     } elseif (strpos($status, 'RC') !== false) {
         $status = 'beta';
     } else {
         $status = 'stable';
     }
     $this->project->setUserProperty('agavi.status', $status);
 }
 /**
  * Maps module config to our private class vars
  * @throws AppKitModelException
  * @return boolean
  * @author mhein
  */
 private function mapConfig()
 {
     foreach (self::$configMap as $setting => $varname) {
         if (AgaviConfig::has($setting)) {
             $this->{$varname} = AgaviConfig::get($setting, null);
         } else {
             throw new AppKitModelException('IcingaApi setting \'%s\' not configured', $setting);
         }
     }
     return true;
 }
Exemplo n.º 5
0
// | For the full copyright and license information, please view the LICENSE   |
// | 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 <*****@*****.**>
 * @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') . ')');
Exemplo n.º 6
0
 public function testReadonlySurvivesRemove()
 {
     AgaviConfig::set('bla', 'goo', true, true);
     $this->assertFalse(AgaviConfig::remove('bla'));
     $this->assertTrue(AgaviConfig::has('bla'));
 }
 /**
  *
  * Replace custom strings with agavi configuration items
  * @param string $text
  * @todo Move into better class space
  * @deprecated Please implement bether construct (Maybe Agavi itself can?)
  * @return string
  */
 public static function replaceConfigVars($text)
 {
     $m = array();
     if (preg_match_all('/%([^%]+)%/', $text, $m, PREG_SET_ORDER)) {
         foreach ($m as $match) {
             if (AgaviConfig::has($match[1])) {
                 $text = preg_replace('/' . preg_quote($match[0]) . '/', AgaviConfig::get($match[1]), $text);
             }
         }
     }
     return $text;
 }