Select Git revision
BlockFeedback.php
Forked from
Stud.IP / Stud.IP
Source project has a limited visibility.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
Config.class.php 12.84 KiB
<?php
/**
* Config.class.php
* provides access to global configuration
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* @author André Noack <noack@data-quest.de>
* @copyright 2010 Stud.IP Core-Group
* @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
* @category Stud.IP
*/
class Config implements ArrayAccess, Countable, IteratorAggregate
{
private static $instance = null;
/**
* contains all config entries as field => value pairs
* @var array
*/
protected $data = [];
/**
* contains additional metadata for config fields
* @var array
*/
protected $metadata = [];
/**
* returns singleton instance
* @return Config
*/
public static function get()
{
if (self::$instance === null) {
$config = new Config();
self::$instance = $config;
}
return self::$instance;
}
/**
* alias of Config::get() for compatibility
* @return Config
*/
public static function getInstance()
{
return self::get();
}
/**
* use to set singleton instance for testing
* or to unset by passing null
* @param Config $my_instance
*/
public static function set()
{
$my_instance = func_get_arg(0);
self::$instance = $my_instance;
}
/**
* pass array of config entries in field => value pairs
* to circumvent fetching from database
* @param array $data
*/
public function __construct($data = null)