PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / trunk
Matomo Analytics – Powerful, Privacy-First Insights for WordPress vtrunk
5.11.1 5.11.0 5.10.2 5.10.1 trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.3.2 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.2 4.1.3 4.10.0 4.11.0 4.12.0 4.13.0 4.13.2 4.13.3 4.13.4 4.13.5 4.14.0 4.14.1 4.14.2 4.15.0 4.15.1 4.15.2 4.15.3 4.2.0 4.3.0 4.3.1 4.4.1 4.4.2 4.5.0 4.6.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.10.0 5.2.0 5.2.1 5.2.2 5.3.0 5.3.1 5.3.2 5.3.3 5.6.0 5.6.1 5.7.0 5.7.1 5.8.0 5.8.1 5.8.2
matomo / app / libs / Zend / Registry.php
matomo / app / libs / Zend Last commit date
Db 1 month ago Session 1 year ago Config.php 1 month ago Db.php 2 years ago Exception.php 1 year ago LICENSE.txt 6 years ago Registry.php 2 years ago Session.php 1 month ago Version.php 1 month ago
Registry.php
194 lines
1 <?php
2
3 namespace {
4 /**
5 * Zend Framework
6 *
7 * LICENSE
8 *
9 * This source file is subject to the new BSD license that is bundled
10 * with this package in the file LICENSE.txt.
11 * It is also available through the world-wide-web at this URL:
12 * http://framework.zend.com/license/new-bsd
13 * If you did not receive a copy of the license and are unable to
14 * obtain it through the world-wide-web, please send an email
15 * to license@zend.com so we can send you a copy immediately.
16 *
17 * @category Zend
18 * @package Zend_Registry
19 * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
20 * @license http://framework.zend.com/license/new-bsd New BSD License
21 * @version $Id: Registry.php 23775 2011-03-01 17:25:24Z ralph $
22 */
23 /**
24 * Generic storage class helps to manage global data.
25 *
26 * @category Zend
27 * @package Zend_Registry
28 * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
29 * @license http://framework.zend.com/license/new-bsd New BSD License
30 */
31 class Zend_Registry extends \ArrayObject
32 {
33 /**
34 * Class name of the singleton registry object.
35 * @var string
36 */
37 private static $_registryClassName = 'Zend_Registry';
38 /**
39 * Registry object provides storage for shared objects.
40 * @var Zend_Registry
41 */
42 private static $_registry = null;
43 /**
44 * Retrieves the default registry instance.
45 *
46 * @return Zend_Registry
47 */
48 public static function getInstance()
49 {
50 if (self::$_registry === null) {
51 self::init();
52 }
53 return self::$_registry;
54 }
55 /**
56 * Set the default registry instance to a specified instance.
57 *
58 * @param Zend_Registry $registry An object instance of type Zend_Registry,
59 * or a subclass.
60 * @return void
61 * @throws Zend_Exception if registry is already initialized.
62 */
63 public static function setInstance(\Zend_Registry $registry)
64 {
65 if (self::$_registry !== null) {
66 // require_once 'Zend/Exception.php';
67 throw new \Zend_Exception('Registry is already initialized');
68 }
69 self::setClassName(\get_class($registry));
70 self::$_registry = $registry;
71 }
72 /**
73 * Initialize the default registry instance.
74 *
75 * @return void
76 */
77 protected static function init()
78 {
79 self::setInstance(new self::$_registryClassName());
80 }
81 /**
82 * Set the class name to use for the default registry instance.
83 * Does not affect the currently initialized instance, it only applies
84 * for the next time you instantiate.
85 *
86 * @param string $registryClassName
87 * @return void
88 * @throws Zend_Exception if the registry is initialized or if the
89 * class name is not valid.
90 */
91 public static function setClassName($registryClassName = 'Zend_Registry')
92 {
93 if (self::$_registry !== null) {
94 // require_once 'Zend/Exception.php';
95 throw new \Zend_Exception('Registry is already initialized');
96 }
97 if (!\is_string($registryClassName)) {
98 // require_once 'Zend/Exception.php';
99 throw new \Zend_Exception("Argument is not a class name");
100 }
101 /**
102 * @see Zend_Loader
103 */
104 if (!\class_exists($registryClassName)) {
105 // require_once 'Zend/Loader.php';
106 \Zend_Loader::loadClass($registryClassName);
107 }
108 self::$_registryClassName = $registryClassName;
109 }
110 /**
111 * Unset the default registry instance.
112 * Primarily used in tearDown() in unit tests.
113 * @returns void
114 */
115 public static function _unsetInstance()
116 {
117 self::$_registry = null;
118 }
119 /**
120 * getter method, basically same as offsetGet().
121 *
122 * This method can be called from an object of type Zend_Registry, or it
123 * can be called statically. In the latter case, it uses the default
124 * static instance stored in the class.
125 *
126 * @param string $index - get the value associated with $index
127 * @return mixed
128 * @throws Zend_Exception if no entry is registerd for $index.
129 */
130 public static function get($index)
131 {
132 $instance = self::getInstance();
133 if (!$instance->offsetExists($index)) {
134 // require_once 'Zend/Exception.php';
135 // debug_print_backtrace();
136 throw new \Zend_Exception("No entry is registered for key '{$index}'");
137 }
138 return $instance->offsetGet($index);
139 }
140 /**
141 * setter method, basically same as offsetSet().
142 *
143 * This method can be called from an object of type Zend_Registry, or it
144 * can be called statically. In the latter case, it uses the default
145 * static instance stored in the class.
146 *
147 * @param string $index The location in the ArrayObject in which to store
148 * the value.
149 * @param mixed $value The object to store in the ArrayObject.
150 * @return void
151 */
152 public static function set($index, $value)
153 {
154 $instance = self::getInstance();
155 $instance->offsetSet($index, $value);
156 }
157 /**
158 * Returns TRUE if the $index is a named value in the registry,
159 * or FALSE if $index was not found in the registry.
160 *
161 * @param string $index
162 * @return boolean
163 */
164 public static function isRegistered($index)
165 {
166 if (self::$_registry === null) {
167 return \false;
168 }
169 return self::$_registry->offsetExists($index);
170 }
171 /**
172 * Constructs a parent ArrayObject with default
173 * ARRAY_AS_PROPS to allow acces as an object
174 *
175 * @param array $array data array
176 * @param integer $flags ArrayObject flags
177 */
178 public function __construct($array = array(), $flags = parent::ARRAY_AS_PROPS)
179 {
180 parent::__construct($array, $flags);
181 }
182 /**
183 * @param string $index
184 * @returns mixed
185 *
186 * Workaround for http://bugs.php.net/bug.php?id=40442 (ZF-960).
187 */
188 public function offsetExists($index)
189 {
190 return \array_key_exists($index, $this);
191 }
192 }
193 }
194