diff options
author | Frédéric Guillot <fred@kanboard.net> | 2014-11-14 22:44:25 -0500 |
---|---|---|
committer | Frédéric Guillot <fred@kanboard.net> | 2014-11-14 22:44:25 -0500 |
commit | b081288188bb1744c9d7bd075aa5936e0ccbb9c4 (patch) | |
tree | 68008e35eb129f74b9b2a49f6f6076ed02b601c6 /app/Core/Registry.php | |
parent | 1487cb27634161ef558c367150213bc7077e4198 (diff) |
Use Pimple instead of Core\Registry and add Monolog for logging
Diffstat (limited to 'app/Core/Registry.php')
-rw-r--r-- | app/Core/Registry.php | 83 |
1 files changed, 0 insertions, 83 deletions
diff --git a/app/Core/Registry.php b/app/Core/Registry.php deleted file mode 100644 index d8b9063e..00000000 --- a/app/Core/Registry.php +++ /dev/null @@ -1,83 +0,0 @@ -<?php - -namespace Core; - -use RuntimeException; - -/** - * The registry class is a dependency injection container - * - * @property mixed db - * @property mixed event - * @package core - * @author Frederic Guillot - */ -class Registry -{ - /** - * Contains all dependencies - * - * @access private - * @var array - */ - private $container = array(); - - /** - * Contains all instances - * - * @access private - * @var array - */ - private $instances = array(); - - /** - * Set a dependency - * - * @access public - * @param string $name Unique identifier for the service/parameter - * @param mixed $value The value of the parameter or a closure to define an object - */ - public function __set($name, $value) - { - $this->container[$name] = $value; - } - - /** - * Get a dependency - * - * @access public - * @param string $name Unique identifier for the service/parameter - * @return mixed The value of the parameter or an object - * @throws RuntimeException If the identifier is not found - */ - public function __get($name) - { - if (isset($this->container[$name])) { - - if (is_callable($this->container[$name])) { - return $this->container[$name](); - } - else { - return $this->container[$name]; - } - } - - throw new \RuntimeException('Identifier not found in the registry: '.$name); - } - - /** - * Return a shared instance of a dependency - * - * @access public - * @param string $name Unique identifier for the service/parameter - * @return mixed Same object instance of the dependency - */ - public function shared($name) - { - if (! isset($this->instances[$name])) { - $this->instances[$name] = $this->$name; - } - - return $this->instances[$name]; - } -} |