summaryrefslogtreecommitdiff
path: root/src/Container
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2017-09-19 14:50:20 +0200
committerIgor Scheller <igor.scheller@igorshp.de>2017-09-19 14:50:46 +0200
commit0ac981876432ff8f7f76ffee8c5102b633d760d4 (patch)
tree2d1bbfe85a74260ac937edd3da744ed84004256d /src/Container
parent8c81adc8e83969e90b4c54daf4a396b1094134ff (diff)
Added Application
Diffstat (limited to 'src/Container')
-rw-r--r--src/Container/Container.php35
1 files changed, 23 insertions, 12 deletions
diff --git a/src/Container/Container.php b/src/Container/Container.php
index df2f92fe..9af5c1e6 100644
--- a/src/Container/Container.php
+++ b/src/Container/Container.php
@@ -49,6 +49,17 @@ class Container implements ContainerInterface
*/
public function instance($abstract, $instance)
{
+ $this->singleton($abstract, $instance);
+ }
+
+ /**
+ * Register a shared entry as singleton in the container
+ *
+ * @param string $abstract
+ * @param mixed $instance
+ */
+ public function singleton($abstract, $instance)
+ {
$this->instances[$abstract] = $instance;
}
@@ -69,9 +80,20 @@ class Container implements ContainerInterface
}
/**
+ * Resolve the requested object
+ *
+ * @param string $abstract
+ * @return mixed
+ */
+ protected function resolve($abstract)
+ {
+ return $this->instances[$abstract];
+ }
+
+ /**
* Get the globally available instance of the container
*
- * @return Container
+ * @return self
*/
public static function getInstance()
{
@@ -91,15 +113,4 @@ class Container implements ContainerInterface
{
static::$instance = $container;
}
-
- /**
- * Resolve the requested object
- *
- * @param string $abstract
- * @return mixed
- */
- protected function resolve($abstract)
- {
- return $this->instances[$abstract];
- }
}