Skip to content

Commit

Permalink
Add missing tests for the resolving callbacks on the container
Browse files Browse the repository at this point in the history
+ bug fix related to multiple calls to "resolving" and "afterResolving" callbacks
  • Loading branch information
imanghafoori1 committed Jan 6, 2019
1 parent d329797 commit d0a7adb
Show file tree
Hide file tree
Showing 2 changed files with 383 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Illuminate/Container/Container.php
Expand Up @@ -261,7 +261,8 @@ protected function getClosure($abstract, $concrete)
return $container->build($concrete);
}

return $container->make($concrete, $parameters);
// To prevent extra call to resolving callbacks, we make the object silently.
return $container->resolve($concrete, $parameters, true);
};
}

Expand Down Expand Up @@ -630,9 +631,10 @@ public function get($id)
*
* @param string $abstract
* @param array $parameters
* @param bool $silent
* @return mixed
*/
protected function resolve($abstract, $parameters = [])
protected function resolve($abstract, $parameters = [], $silent = false)
{
$abstract = $this->getAlias($abstract);

Expand Down Expand Up @@ -674,8 +676,9 @@ protected function resolve($abstract, $parameters = [])
$this->instances[$abstract] = $object;
}

$this->fireResolvingCallbacks($abstract, $object);

if (! $silent) {
$this->fireResolvingCallbacks($abstract, $object);
}
// Before returning, we will also set the resolved flag to "true" and pop off
// the parameter overrides for this build. After those two things are done
// we will be ready to return back the fully constructed class instance.
Expand Down

0 comments on commit d0a7adb

Please sign in to comment.