Skip to content
Snippets Groups Projects
Select Git revision
  • cf961f344e929ff56d8f98154b6de2601355bf16
  • main default protected
  • studip-rector
  • ci-opt
  • course-members-export-as-word
  • data-vue-app
  • pipeline-improvements
  • webpack-optimizations
  • rector
  • icon-renewal
  • http-client-and-factories
  • jsonapi-atomic-operations
  • vueify-messages
  • tic-2341
  • 135-translatable-study-areas
  • extensible-sorm-action-parameters
  • sorm-configuration-trait
  • jsonapi-mvv-routes
  • docblocks-for-magic-methods
19 results

BlockFeedback.php

Blame
  • 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)