Skip to content

Commit

Permalink
Bugfix: Allow for arbitrary values to be stored (Resolves #24)
Browse files Browse the repository at this point in the history
  • Loading branch information
philipobenito committed Feb 21, 2015
1 parent c1994f4 commit 6cbb3d8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

All Notable changes to `League\Container` will be documented in this file

## 1.3.1 - 2015-02-21

### Fixed
- Fixed bug where arbitrary values were attempted to be resolved as classes.

## 1.3.0 - 2015-02-09

### Added
Expand Down
17 changes: 11 additions & 6 deletions src/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function add($alias, $concrete = null, $singleton = false)

// if the concrete is an already instantiated object, we just store it
// as a singleton
if (is_object($concrete) && ! $concrete instanceof \Closure) {
if ((is_object($concrete) && ! $concrete instanceof \Closure)) {
$this->singletons[$alias] = $concrete;
return null;
}
Expand All @@ -81,12 +81,17 @@ public function add($alias, $concrete = null, $singleton = false)
$factory = $this->getDefinitionFactory();
$definition = $factory($alias, $concrete, $this);

$this->items[$alias] = [
'definition' => $definition,
'singleton' => (boolean) $singleton
];
if ($definition instanceof DefinitionInterface) {
$this->items[$alias] = [
'definition' => $definition,
'singleton' => (boolean) $singleton
];

return $definition;
return $definition;
}

// dealing with an arbitrary value so just store as singleton
$this->singletons[$alias] = $concrete;
}

/**
Expand Down

0 comments on commit 6cbb3d8

Please sign in to comment.