Skip to content

Commit

Permalink
Register itself
Browse files Browse the repository at this point in the history
  • Loading branch information
CristianLlanos committed Mar 11, 2021
1 parent 07fd8d7 commit efc0f78
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
use Closure;
use Exception;
use Reliese\Component\Dependency\Container as ContainerComponent;
use Reliese\Component\Dependency\DependencyCaller;
use Reliese\Component\Dependency\DependencyLocator;
use Reliese\Component\Dependency\DependencyRegistrar;
use Reliese\Component\Dependency\Exceptions\UnresolvableDependencyException;
use ReflectionClass;
use ReflectionException;
Expand All @@ -22,6 +25,22 @@ class Container implements ContainerComponent
*/
private $singletons = [];

/**
* Container constructor.
*/
public function __construct()
{
$self = function () {
return $this;
};

$this->singleton(static::class, $self);
$this->singleton(ContainerComponent::class, $self);
$this->singleton(DependencyRegistrar::class, $self);
$this->singleton(DependencyLocator::class, $self);
$this->singleton(DependencyCaller::class, $self);
}

/**
* @param $dependency
* @param Closure $abstraction
Expand Down

0 comments on commit efc0f78

Please sign in to comment.