From 05f76a5826e710929ebc558e846847056222e4fb Mon Sep 17 00:00:00 2001
From: Fabian Becker <fabian.becker@uni-tuebingen.de>
Date: Sun, 29 Sep 2013 17:15:14 +0200
Subject: [PATCH] Add implementation of simple Registry (removing Zend_*
 dependency)

---
 core/Registry.php | 64 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)
 create mode 100644 core/Registry.php

diff --git a/core/Registry.php b/core/Registry.php
new file mode 100644
index 0000000000..e2fa0278cb
--- /dev/null
+++ b/core/Registry.php
@@ -0,0 +1,64 @@
+<?php
+/**
+ * Piwik - Open source web analytics
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ *
+ * @category Piwik
+ * @package Piwik
+ */
+namespace Piwik;
+
+/**
+ * Registry class.
+ *
+ * @package Piwik
+ */
+class Registry
+{
+    private static $instance;
+    private $data;
+
+    private function __construct() {
+        $this->data = array();
+    }
+
+    public static function getInstance() {
+        if(self::$instance == null) {
+            self::$instance = new Registry();
+        }
+        return self::$instance;
+    }
+
+    public static function isRegistered($key) {
+        return self::getInstance()->hasKey($key);
+    }
+
+    public static function get($key) {
+        return self::getInstance()->getKey($key);
+    }
+
+    public static function set($key, $value) {
+        self::getInstance()->setKey($key, $value);
+    }
+
+    public static function unsetInstance() {
+        self::$instance = null;
+    }
+
+    public function setKey($key, $value) {
+        $this->data[$key] = $value;
+    }
+
+    public function getKey($key) {
+        if(!$this->hasKey($key)) {
+            return null;
+        }
+        return $this->data[$key];
+    }
+
+    public function hasKey($key) {
+        return array_key_exists($key, $this->data);
+    }
+}
-- 
GitLab