Skip to content

Commit

Permalink
Merge pull request #44 from chrismichaels84/patch-di
Browse files Browse the repository at this point in the history
PATCH: Makes IoC trait chainable
  • Loading branch information
Michael Wilson committed Mar 23, 2016
2 parents c735762 + f017eee commit 255478a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Contracts/IocManagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function initDi(array $components = []);
*
* @param string $alias
* @param callable|string|object $factory
* @return object
* @return $this
*/
public function di($alias, $factory);

Expand Down
11 changes: 9 additions & 2 deletions src/Traits/ManagesIocTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ trait ManagesIocTrait
/**
* Initializes IoC Container
* @param array $components
* @return void
* @return $this
*/
public function initDi(array $components = [])
{
$this->initManager();
$this->add($this->nameOfIocManifest, $components);

return $this;
}

/**
Expand Down Expand Up @@ -84,7 +86,7 @@ public function fetch($alias, $fallback = '_michaels_no_fallback')
* @param string $alias
* @param callable|string|object $factory
* @param array $declared
* @return void
* @return $this
*/
public function di($alias, $factory, array $declared = null)
{
Expand All @@ -94,6 +96,8 @@ public function di($alias, $factory, array $declared = null)
if ($declared) {
$this->set($this->nameOfIocManifest . "._declarations.$alias", $declared);
}

return $this;
}

/**
Expand All @@ -104,16 +108,19 @@ public function di($alias, $factory, array $declared = null)
public function share($alias)
{
$this->add($this->nameOfIocManifest . "._singletons.$alias", true);
return $this;
}

/**
* Add a pipeline to to the que
* @param $alias
* @param $pipeline
* @return $this
*/
public function setup($alias, $pipeline)
{
$this->add($this->nameOfIocManifest . "._pipelines.$alias", $pipeline);
return $this;
}

/**
Expand Down

0 comments on commit 255478a

Please sign in to comment.