Example #1
0
 /**
  * @param null $path
  * @param null $default
  *
  * @return array|mixed
  */
 static final function config($path = NULL, $default = NULL)
 {
     if (!static::$_config) {
         static::$_config = Kohana::$config->load('restfulapi')->as_array();
     }
     return NULL !== $path ? Kohana_Arr::path(static::$_config, $path, $default) : static::$_config;
 }
Example #2
0
 /**
  * Loads config data and reCaptcha library.
  *
  * @return  void
  */
 protected static function _init()
 {
     if (empty(static::$_config)) {
         static::$_config = Kohana::$config->load('recaptcha');
     }
     require_once Kohana::find_file('vendor', 'recaptcha/recaptchalib');
 }
Example #3
0
 public static function config(array $config = [])
 {
     if (!$config) {
         return static::$_config;
     }
     static::$_config = $config;
 }
Example #4
0
 public static function loadConfigFile($_file_path)
 {
     if (file_exists($_file_path)) {
         $_file_contents = file_get_contents($_file_path);
         $_config_data = json_decode($_file_contents, true);
         static::$_config = array_merge(static::$_config, $_config_data);
     }
 }
 public static function config()
 {
     if (empty(static::$_config)) {
         $adminBean = BeanFactory::getBean("Administration");
         static::$_config = $adminBean->getConfigForModule('dm_Recycler', 'base');
     }
     return static::$_config;
 }
 public static function initialize()
 {
     // resolve details from host name
     // get site ID
     /*
     		if(empty(static::$ID))
     		{
     			if(!empty($_SERVER['SITE_ID']))
     				static::$ID = $_SERVER['SITE_ID'];
     			else
     				throw new Exception('No Site ID detected');
     		}
     */
     // get site root
     if (empty(static::$rootPath)) {
         if (!empty($_SERVER['SITE_ROOT'])) {
             static::$rootPath = $_SERVER['SITE_ROOT'];
         } else {
             throw new Exception('No Site root detected');
         }
     }
     // retrieve static configuration
     if (!(static::$_config = apc_fetch($_SERVER['HTTP_HOST'])) || $_GET['_recache'] == static::$controlKey) {
         static::$_config = static::_compileConfiguration();
         apc_store($_SERVER['HTTP_HOST'], static::$_config);
     }
     // get host-specific config
     if (!(static::$_hostConfig = static::$_config['hosts'][$_SERVER['HTTP_HOST']])) {
         throw new Exception('Current host is unknown');
     }
     if (static::$_hostConfig['ParentHostname']) {
         if (!(static::$_parentHostConfig = static::$_config['hosts'][static::$_hostConfig['ParentHostname']])) {
             throw new Exception('Parent host is unknown');
         }
     }
     // get request URI
     if (empty(static::$requestURI)) {
         static::$requestURI = parse_url($_SERVER['REQUEST_URI']);
     }
     // get path stack
     static::$pathStack = static::$requestPath = static::splitPath(static::$requestURI['path']);
     // register class loader
     spl_autoload_register('Site::loadClass');
     // set error handle
     set_error_handler('Site::handleError');
     // register exception handler
     set_exception_handler('Site::handleException');
     // check virtual system for site config
     static::loadConfig(__CLASS__);
     if (is_callable(static::$onInitialized)) {
         call_user_func(static::$onInitialized);
     }
 }
Example #7
0
 public static function load($configFile)
 {
     if (!file_exists($configFile) || !is_readable($configFile)) {
         return;
     }
     $config = file_get_contents($configFile);
     try {
         static::$_config = json_decode($config, true);
     } catch (Exception $e) {
     }
     return static::$_config;
 }
Example #8
0
 public static function load()
 {
     $lang = static::getLaguage();
     $filename = get_template_directory() . '/lang/' . $lang . '.json';
     if (!file_exists($filename) || !is_readable($filename)) {
         return;
     }
     $config = file_get_contents($filename);
     try {
         static::$_config = json_decode($config, true);
     } catch (Exception $e) {
     }
     return static::$_config;
 }
Example #9
0
	/**
	 * Used to set configuration options.
	 *
	 * Sending the config options through the static reference initalizes the
	 * instance. If you need to send a driver config through the static reference,
	 * make sure its the first one sent! If errors arise, create a new instance using
	 * factory().
	 *
	 * @param  array   $config   An array of configuration settings.
	 * @return Image_Driver
	 */
	public static function config($index = array(), $value = null)
	{
		if (static::$_instance === null)
		{
			if ($value !== null)
				$index = array($index => $value);
			if (is_array($index))
				static::$_config = array_merge(static::$_config, $index);
			static::instance();
			return static::instance();
		} else {
			return static::instance()->config($index, $value);
		}
	}
 /**
  * @param $config array
  */
 public static function run($config)
 {
     static::$_config = $config;
     // initialize error handling
     register_shutdown_function(array('App', 'onFatalError'));
     set_exception_handler(array('App', 'onException'));
     set_error_handler(array('App', 'onError'));
     $response = App::response();
     // init response
     $response->enableBuffering();
     // start output buffering
     // initialize class Autoloader
     $autoloader = static::autoloader();
     // initialize Router
     $router = static::router();
     $parsedUrl = $router->parseRequestUrl(App::request()->getUrl());
     $controllerClassName = $parsedUrl['controller'];
     $actionMethodName = $parsedUrl['action'];
     $parameters = $parsedUrl['parameters'];
     if (!$autoloader->classDefined($controllerClassName)) {
         trigger_error('Controller "' . $controllerClassName . '" not found');
         App::response()->sendNotFoundAndExit();
     }
     /** @var $controller AppController */
     $controller = new $controllerClassName();
     $controller->setAction($actionMethodName);
     $controller->setParameters($parameters);
     // get response from action
     $actionContent = $controller->run();
     // get layout from controller
     $layout = $controller->getLayout();
     if ($layout) {
         // if layout not disabled ( @see AppController::disableLayout() )
         $layoutView = new AppView('layouts/' . $layout);
         $layoutView->title = static::$_config['applicationName'];
         $layoutView->content = $actionContent;
         // insert action response into page layout
         // render page
         echo $layoutView->render();
     }
     // send response to client
     App::response()->sendContent();
 }
Example #11
0
File: Config.php Project: p-m-d/naf
 public static function config($key = null, $value = null)
 {
     if (is_null($key) && is_null($value)) {
         return static::$_config;
     }
     $path = explode('.', $key);
     if (!is_null($value)) {
         if (is_null($key)) {
             static::$_config = (array) $value;
         } else {
             $config =& static::$_config;
             foreach ($path as $i => $k) {
                 if (is_numeric($k) && intval($k) > 0 || $k === '0') {
                     $k = intval($k);
                 }
                 if ($i === count($path) - 1) {
                     $config[$k] = $value;
                 } else {
                     if (!isset($config[$k])) {
                         $config[$k] = [];
                     }
                     $config =& $config[$k];
                 }
             }
         }
         return static::config($key);
     } else {
         $value = null;
         $config = static::$_config;
         while ($index = array_shift($path)) {
             if (isset($config[$index])) {
                 $config = $config[$index];
                 if (empty($path)) {
                     $value = $config;
                 }
             } else {
                 break;
             }
         }
         return $value;
     }
 }
Example #12
0
 /**
  * Setup basic error handling checks/types, as well as register the error and exception
  * handlers and wipes out all configuration and resets the error handler to its initial state
  * when loaded. Mainly used for testing.
  */
 public static function reset()
 {
     static::$_config = array();
     static::$_checks = array();
     static::$_exceptionHandler = null;
     static::$_checks = array('type' => function ($config, $info) {
         return (bool) array_filter((array) $config['type'], function ($type) use($info) {
             return $type === $info['type'] || is_subclass_of($info['type'], $type);
         });
     }, 'code' => function ($config, $info) {
         return $config['code'] & $info['code'];
     }, 'stack' => function ($config, $info) {
         return (bool) array_intersect((array) $config['stack'], $info['stack']);
     }, 'message' => function ($config, $info) {
         return preg_match($config['message'], $info['message']);
     });
     $self = get_called_class();
     static::$_exceptionHandler = function ($exception, $return = false) use($self) {
         if (ob_get_length()) {
             ob_end_clean();
         }
         $info = compact('exception') + array('type' => get_class($exception), 'stack' => $self::trace($exception->getTrace()));
         foreach (array('message', 'file', 'line', 'trace') as $key) {
             $method = 'get' . ucfirst($key);
             $info[$key] = $exception->{$method}();
         }
         return $return ? $info : $self::handle($info);
     };
 }
Example #13
0
    public static function loadConfig() {
      $ini = parse_ini_file(static::BASE_DIRECTORY . 'Config/settings.ini', true);

      if ( file_exists(static::BASE_DIRECTORY . 'Config/local_settings.ini') ) {
        $local = parse_ini_file(static::BASE_DIRECTORY . 'Config/local_settings.ini', true);

        $ini = array_merge($ini, $local);
      }

      static::$_config = $ini;
    }
Example #14
0
 /**
  * 
  * DBConnector::resetAllStaticPropertiesExceptDefaultConfig() resets all properties
  * DBConnector::resetAllStaticPropertiesExceptDefaultConfig('_db') will reset only DBConnector::$_db
  * 
  * @param string $prop_name name of the property (eg. 'db' or '_db') whose value is to be reset. 
  * 
  */
 public static function resetAllStaticPropertiesExceptDefaultConfig($prop_name = '')
 {
     switch ($prop_name) {
         case '_config':
         case 'config':
             // Map of configuration settings
             static::$_config = array();
             break;
         case '_db':
         case 'db':
             // Map of database connections, instances of the PDO class
             static::$_db = array();
             break;
         case '_last_query':
         case 'last_query':
             // Last query run, only populated if logging is enabled
             static::$_last_query = '';
             break;
         case '_query_log':
         case 'query_log':
             // Log of all queries run, mapped by connection key, only populated if logging is enabled
             static::$_query_log = array();
             break;
         default:
             //////////////////////////
             // Reset all properties //
             //////////////////////////
             // Map of configuration settings
             static::$_config = array();
             // Map of database connections, instances of the PDO class
             static::$_db = array();
             // Last query run, only populated if logging is enabled
             static::$_last_query = '';
             // Log of all queries run, mapped by connection key, only populated if logging is enabled
             static::$_query_log = array();
             break;
     }
 }
Example #15
0
 /**
  * Wipes out all configuration and resets the error handler to its initial state when loaded.
  * Mainly used for testing.
  *
  * @return void
  */
 public static function reset()
 {
     static::$_config = array();
     static::$_checks = array();
     static::$_handlers = array();
     static::$_exceptionHandler = null;
     static::__init();
 }
Example #16
0
File: ORM.php Project: voku/idiorm
 /**
  * Delete all configs in _config array.
  */
 public static function reset_config()
 {
     static::$_config = array();
 }
Example #17
0
 /**
  * 获取配置文件
  */
 public function getConfig()
 {
     return static::$_config = $this->getConfiguration()->getConfigLoad();
 }
Example #18
0
 /**
  * Clears the registry of configuration and instances.
  *
  * @return void
  */
 public static function clear()
 {
     static::$_instances = [];
     static::$_config = [];
     static::$_fallbacked = [];
 }
Example #19
0
 /**
  * Load the configuration array
  *
  * @return void
  */
 protected static function _load()
 {
     if (!empty(static::$_config)) {
         return;
     }
     static::$_config = Configure::read('Queues') ?: [];
 }
Example #20
0
 /**
  * Reset all the connected loggers.  This is useful to do when changing the logging
  * configuration or during testing when you want to reset the internal state of the
  * Log class.
  *
  * Resets the configured logging adapters, as well as any custom logging levels.
  * This will also clear the configuration data.
  *
  * @return void
  */
 public static function reset()
 {
     static::$_registry = null;
     static::$_config = [];
     static::$_dirtyConfig = true;
 }
Example #21
0
 public static function initialize($rootPath, $hostname = null)
 {
     static::$initializeTime = microtime(true);
     // get site root
     if ($rootPath) {
         static::$rootPath = $rootPath;
     } elseif (!static::$rootPath) {
         throw new Exception('No site root detected');
     }
     // load config
     if (!(static::$_config = apc_fetch(static::$rootPath))) {
         if (is_readable(static::$rootPath . '/site.json')) {
             static::$_config = json_decode(file_get_contents(static::$rootPath . '/site.json'), true);
             apc_store(static::$rootPath, static::$_config);
         } elseif (is_readable(static::$rootPath . '/Site.config.php')) {
             include static::$rootPath . '/Site.config.php';
             apc_store(static::$rootPath, static::$_config);
         }
     }
     static::$config = static::$_config;
     // TODO: deprecate
     // get hostname
     if ($hostname) {
         static::$hostname = $hostname;
     } elseif (!static::$hostname) {
         if (!empty(static::$config['primary_hostname'])) {
             static::$hostname = static::$config['primary_hostname'];
         } else {
             throw new Exception('No hostname detected');
         }
     }
     // get path stack
     if (!empty($_SERVER['REQUEST_URI'])) {
         $path = $_SERVER['REQUEST_URI'];
         if (false !== ($qPos = strpos($path, '?'))) {
             $path = substr($path, 0, $qPos);
         }
         static::$pathStack = static::$requestPath = static::splitPath($path);
     }
     // set useful transaction name for newrelic
     if (extension_loaded('newrelic')) {
         newrelic_name_transaction(static::getConfig('handle') . '/' . implode('/', site::$requestPath));
     }
     // register class loader
     spl_autoload_register('Site::loadClass');
     // set error handle
     set_error_handler('Site::handleError');
     // register exception handler
     set_exception_handler('Site::handleException');
     // check virtual system for site config
     static::loadConfig(__CLASS__);
     // get site title
     if (!static::$title) {
         static::$title = static::getConfig('label');
     }
     // configure error display
     ini_set('display_errors', static::$debug);
     // check virtual system for proxy config
     if (class_exists('HttpProxy')) {
         static::loadConfig('HttpProxy');
     }
     if (is_callable(static::$onInitialized)) {
         call_user_func(static::$onInitialized);
     }
 }
Example #22
0
 private static function load()
 {
     static::$_config = (include APPPATH . 'config.php');
 }
Example #23
0
 /**
  * Get application configuration from config file
  *
  * Loads and caches the config file. By default, the config file is expected
  * at config/braintacle.ini, but a different file name and path can be set
  * via the BRAINTACLE_CONFIG environment variable.
  *
  * @throws \RuntimeException if file cannot be parsed
  * @codeCoverageIgnore
  */
 public static function getConfig()
 {
     if (!static::$_config) {
         $filename = getenv('BRAINTACLE_CONFIG') ?: static::getPath('config/braintacle.ini');
         static::$_config = parse_ini_file($filename, true);
         if (!static::$_config) {
             throw new \RuntimeException('Could not read config file ' . $filename);
         }
     }
     return static::$_config;
 }
Example #24
0
 /**
  * reset
  *
  * Reset the static state
  *
  * @return void
  */
 public static function reset()
 {
     static::$_config = static::$_defaultConfig;
     static::$_model = null;
     static::$_translations = null;
 }
Example #25
0
 static function init()
 {
     static::$_config = (include_once __DIR__ . "/../config.php");
     static::$_db = getDb(static::$_config);
 }
Example #26
0
 /**
  * Configures the redis backend for use as well as some application specific things.
  *
  * This method is called by `Redis::__init()`.
  *
  * @param array $options Possible options are:
  *     - `expiry`: allows setting a default expiration
  *     - `namespace`: makes overwriting or re-configuring the namespace easy
  *     - `connection`: defines, what connection to use, defaults to li3_redis
  *     - `separator`: in case you prefer a different separator, defaults to `:`
  *     - `format`: allows setting a prefix for keys, e.g. Environment
  * @return array
  */
 public static function config(array $options = array())
 {
     $config = Libraries::get('li3_redis');
     $defaults = array('expiry' => false, 'namespace' => '', 'connection' => 'li3_redis', 'separator' => ':', 'format' => '{:environment}:');
     if (!empty($config['format'])) {
         $defaults['format'] = $config['format'];
     }
     if (!empty($config['connection'])) {
         $defaults['connection'] = $config['connection'];
     }
     $options += $defaults;
     static::connection(Connections::get($options['connection']));
     return static::$_config = $options;
 }
	public static function config(array $config) {
		static::$_config = $config + static::$_config;
	}
Example #28
0
 static function setConfig($config)
 {
     static::$_config = $config;
 }
Example #29
0
 public static function init()
 {
     static::$_loader = (require TESTS_PATH . '/../vendor/autoload.php');
     static::$_config = (require TESTS_PATH . '/config.php');
     static::$_adapter = new Adapter(array('driver' => 'Mysqli', 'host' => static::$_config['db']['host'], 'database' => static::$_config['db']['dbname'], 'username' => static::$_config['db']['username'], 'password' => static::$_config['db']['password'], 'driver_options' => array(\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES UTF8'), 'options' => array('buffer_results' => true)));
 }
Example #30
0
 /**
  * Add values to the current loaded configuration.
  *
  * @uses Titon\Utility\Hash
  *
  * @param string $key
  * @param mixed $value
  */
 public static function set($key, $value)
 {
     static::$_config = Hash::set(static::$_config, $key, $value);
 }