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);
     }
 }
 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();
 }
 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);
 }
Beispiel #4
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);
     }
 }
 /**
  * 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();
 }
Beispiel #6
0
 /**
  * Utility method to bootstrap Agavi.
  */
 protected function tryBootstrapAgavi()
 {
     if (!self::$agaviBootstrapped) {
         /* Something might f**k 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 f*****g 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;
     }
 }
 /**
  * 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();
 }
Beispiel #8
0
 /**
  * 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);
 }
Beispiel #9
0
 /**
  * Initialize a module and load its autoload, module config etc.
  *
  * @param      string The name of the module to initialize.
  *
  * @author     Felix Gilcher <*****@*****.**>
  * @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;
     }
 }
Beispiel #10
0
// | 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') . ')');
Beispiel #11
0
<?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()
Beispiel #12
0
// |   End:                                                                    |
// +---------------------------------------------------------------------------+
/**
 * Pre-initialization script.
 *
 * @package    agavi
 *
 * @author     Sean Kerr <*****@*****.**>
 * @author     Mike Vincent <*****@*****.**>
 * @author     David Zülke <*****@*****.**>
 * @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';
// 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');
Beispiel #14
0
// +---------------------------------------------------------------------------+
// | 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")                |
Beispiel #15
0
    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)));
    }
Beispiel #16
0
$agaviTestSettings = $GLOBALS['AGAVI_TESTING_ISOLATED_TEST_SETTINGS'];
unset($GLOBALS['AGAVI_TESTING_ISOLATED_TEST_SETTINGS']);
if ($agaviTestSettings['bootstrap'] || $agaviTestSettings['clearCache']) {
    require __DIR__ . '/../../testing.php';
}
if ($agaviTestSettings['bootstrap']) {
    // when agavi is not bootstrapped we don't want / need to load the agavi config
    // values from outside the isolation
    AgaviConfig::fromArray($GLOBALS['AGAVI_TESTING_CONFIG']);
}
unset($GLOBALS['AGAVI_TESTING_CONFIG']);
if ($agaviTestSettings['clearCache']) {
    AgaviToolkit::clearCache();
}
$env = null;
if ($agaviTestSettings['environment']) {
    $env = $agaviTestSettings['environment'];
}
if ($agaviTestSettings['bootstrap']) {
    AgaviTesting::bootstrap($env);
}
if ($agaviTestSettings['defaultContext']) {
    AgaviConfig::set('core.default_context', $agaviTestSettings['defaultContext']);
}
if (!defined('AGAVI_TESTING_BOOTSTRAPPED')) {
    // when PHPUnit runs with preserve global state enabled, AGAVI_TESTING_BOOTSTRAPPED will already be defined
    define('AGAVI_TESTING_BOOTSTRAPPED', true);
}
if (AGAVI_TESTING_ORIGINAL_PHPUNIT_BOOTSTRAP) {
    require_once AGAVI_TESTING_ORIGINAL_PHPUNIT_BOOTSTRAP;
}
 /**
  * Glue our version string together
  *
  * Method is static and public to call from outside
  * if no context is needed (e.g. Phing::Task)
  */
 public static function buildVersionString()
 {
     if (AgaviConfig::get('org.icinga.version.extension', false) == false) {
         $version_format = "%s/v%d.%d.%d";
     } else {
         $version_format = "%s/v%d.%d.%d-%s";
     }
     AgaviConfig::set('org.icinga.version.release', sprintf($version_format, AgaviConfig::get('org.icinga.version.name'), AgaviConfig::get('org.icinga.version.major'), AgaviConfig::get('org.icinga.version.minor'), AgaviConfig::get('org.icinga.version.patch'), AgaviConfig::get('org.icinga.version.extension')), true, true);
 }
Beispiel #18
0
<?php

error_reporting(E_ALL | E_STRICT);
AgaviConfig::set('core.app_dir', dirname(__FILE__));
Beispiel #19
0
 /**
  * @dataProvider literalizeData
  */
 public function testLiteralize($rawValue, $expectedResult, $settings)
 {
     foreach ($settings as $key => $value) {
         AgaviConfig::set($key, $value);
     }
     $literalized = AgaviToolkit::literalize($rawValue);
     $this->assertEquals($expectedResult, $literalized);
 }
Beispiel #20
0
 *
 * @since      0.9.0
 *
 * @version    $Id$
 */
// load the AgaviConfig class
require __DIR__ . '/config/AgaviConfig.class.php';
// check minimum PHP version
AgaviConfig::set('core.minimum_php_version', '5.3.2');
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', $agavi_config_directive_core_agavi_dir = __DIR__, true, true);
// default exception template
AgaviConfig::set('exception.default_template', $agavi_config_directive_core_agavi_dir . '/exception/templates/shiny.php');
// required files
require $agavi_config_directive_core_agavi_dir . '/version.php';
require $agavi_config_directive_core_agavi_dir . '/core/Agavi.class.php';
require $agavi_config_directive_core_agavi_dir . '/util/AgaviAutoloader.class.php';
// required files for classes Agavi and ConfigCache to run
// consider this the bare minimum we need for bootstrapping
require $agavi_config_directive_core_agavi_dir . '/util/AgaviInflector.class.php';
require $agavi_config_directive_core_agavi_dir . '/util/AgaviArrayPathDefinition.class.php';
require $agavi_config_directive_core_agavi_dir . '/util/AgaviVirtualArrayPath.class.php';
require $agavi_config_directive_core_agavi_dir . '/util/AgaviParameterHolder.class.php';
require $agavi_config_directive_core_agavi_dir . '/config/AgaviConfigCache.class.php';
require $agavi_config_directive_core_agavi_dir . '/exception/AgaviException.class.php';
require $agavi_config_directive_core_agavi_dir . '/exception/AgaviAutoloadException.class.php';
require $agavi_config_directive_core_agavi_dir . '/exception/AgaviCacheException.class.php';
require $agavi_config_directive_core_agavi_dir . '/exception/AgaviConfigurationException.class.php';
Beispiel #21
0
 public function testGetSetStringInteger()
 {
     AgaviConfig::set('10', 'ten');
     $this->assertEquals('ten', AgaviConfig::get(10));
     AgaviConfig::set(21, 'twentyone');
     $this->assertEquals('twentyone', AgaviConfig::get('21'));
 }
 /**
  * parses config object
  *
  * should be used to make Form_FormModel object from a config
  * (configuration is inspired by extjs lazy config)
  *
  * @param object $config lazy configuration
  * @param Form_FormModel $form
  * @return Form_FormModel
  */
 public static function fromJson($config, Form_Elements_FieldsetModel $form = null)
 {
     $contextProfile = AgaviConfig::get('core.default_context');
     if (is_null($contextProfile)) {
         $contextProfile = md5(microtime());
         AgaviConfig::set('core.default_context', $contextProfile);
     }
     $context = AgaviContext::getInstance();
     $_form = $context->getModel('Form', 'Form', array($config, $form));
     self::parseChildren($config, $_form);
     return $_form;
 }
<?php

$composer = (require 'vendor/autoload.php');
$composer->addClassMap(['AgaviPhpUnitCli' => 'vendor/honeybee/agavi/src/testing/AgaviPhpUnitCli.class.php']);
putenv('APP_LOCAL_CONFIG_DIR=/tmp');
putenv('APP_DIR=' . realpath(__DIR__ . '/../'));
putenv('APP_ENV=testing');
putenv('APP_CONTEXT=web');
require __DIR__ . '/../app/config.php';
AgaviConfig::set('core.testing_dir', __DIR__);
AgaviPhpUnitCli::dispatch($_SERVER['argv']);
Beispiel #24
0
#!/usr/bin/php
<?php 
error_reporting(E_ALL);
// +---------------------------------------------------------------------------+
// | An absolute filesystem path to the agavi/agavi.php script.                |
// +---------------------------------------------------------------------------+
require dirname(__FILE__) . '/../lib/agavi/src/agavi.php';
// +---------------------------------------------------------------------------+
// | An absolute filesystem path to our app/config.php script.                 |
// +---------------------------------------------------------------------------+
require dirname(__FILE__) . '/../app/config.php';
// +---------------------------------------------------------------------------+
// | Initialize the framework. You may pass an environment name to this method.|
// | By default the 'development' environment sets Agavi into a debug mode.    |
// | In debug mode among other things the cache is cleaned on every request.   |
// +---------------------------------------------------------------------------+
// Setting the running context to web ...
Agavi::bootstrap('development');
AgaviConfig::set('core.default_context', 'console');
AgaviController::initializeModule('AppKit');
AgaviConfig::set('core.context_implementation', 'AppKitAgaviContext');
// +---------------------------------------------------------------------------+
// | Call the controller's dispatch method on the default context              |
// +---------------------------------------------------------------------------+
AgaviContext::getInstance('console')->getController()->dispatch();
 public function testFactoryConfigHandler()
 {
     $FCH = new AgaviFactoryConfigHandler();
     $paramsExpected = array('p1' => 'v1', 'p2' => 'v2');
     AgaviConfig::set('core.use_database', true);
     AgaviConfig::set('core.use_logging', true);
     AgaviConfig::set('core.use_security', true);
     $document = $this->parseConfiguration(AgaviConfig::get('core.config_dir') . '/tests/factories.xml', AgaviConfig::get('core.agavi_dir') . '/config/xsl/factories.xsl');
     $this->includeCode($FCH->execute($document));
     // Execution container
     $this->assertSame(array('class' => 'FCHTestExecutionContainer', 'parameters' => $paramsExpected), $this->factories['execution_container']);
     // Dispatch filter
     $this->assertSame(array('class' => 'FCHTestDispatchFilter', 'parameters' => $paramsExpected), $this->factories['dispatch_filter']);
     // Execution filter
     $this->assertSame(array('class' => 'FCHTestExecutionFilter', 'parameters' => $paramsExpected), $this->factories['execution_filter']);
     // Filter chain
     $this->assertSame(array('class' => 'FCHTestFilterChain', 'parameters' => $paramsExpected), $this->factories['filter_chain']);
     // Security filter
     $this->assertSame(array('class' => 'FCHTestSecurityFilter', 'parameters' => $paramsExpected), $this->factories['security_filter']);
     // Response
     $this->assertSame(array('class' => 'FCHTestResponse', 'parameters' => $paramsExpected), $this->factories['response']);
     // Validation Manager
     $this->assertSame(array('class' => 'FCHTestValidationManager', 'parameters' => $paramsExpected), $this->factories['validation_manager']);
     $this->assertInstanceOf('FCHTestDBManager', $this->databaseManager);
     $this->assertSame($this, $this->databaseManager->context);
     $this->assertSame($paramsExpected, $this->databaseManager->params);
     $this->assertTrue($this->databaseManager->suCalled);
     $this->assertInstanceOf('FCHTestRequest', $this->request);
     $this->assertSame($this, $this->request->context);
     $this->assertSame($paramsExpected, $this->request->params);
     $this->assertTrue($this->request->suCalled);
     $this->assertInstanceOf('FCHTestStorage', $this->storage);
     $this->assertSame($this, $this->storage->context);
     $this->assertSame($paramsExpected, $this->storage->params);
     $this->assertTrue($this->storage->suCalled);
     $this->assertInstanceOf('FCHTestTranslationManager', $this->translationManager);
     $this->assertSame($this, $this->translationManager->context);
     $this->assertSame($paramsExpected, $this->translationManager->params);
     $this->assertTrue($this->translationManager->suCalled);
     $this->assertInstanceOf('FCHTestUser', $this->user);
     $this->assertSame($this, $this->user->context);
     $this->assertSame($paramsExpected, $this->user->params);
     $this->assertTrue($this->user->suCalled);
     $this->assertInstanceOf('FCHTestLoggerManager', $this->loggerManager);
     $this->assertSame($this, $this->loggerManager->context);
     $this->assertSame($paramsExpected, $this->loggerManager->params);
     $this->assertTrue($this->loggerManager->suCalled);
     $this->assertInstanceOf('FCHTestController', $this->controller);
     $this->assertSame($this, $this->controller->context);
     $this->assertSame($paramsExpected, $this->controller->params);
     $this->assertInstanceOf('FCHTestRouting', $this->routing);
     $this->assertSame($this, $this->routing->context);
     $this->assertSame($paramsExpected, $this->routing->params);
     $this->assertTrue($this->routing->suCalled);
 }