8000 [DependencyInjection] Add autowiring capabilities by dunglas · Pull Request #15613 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[DependencyInjection] Add autowiring capabilities #15613

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 19 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Better RunTime exception error.
  • Loading branch information
dunglas committed Oct 1, 2015
commit edce23da281bcf5bc9bcdb6d4ef37e5096eb7f86
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private function completeDefinition($id, Definition $definition)
$value = new Reference($this->types[$typeHint->name]);
} else {
try {
$value = $this->createAutowiredDefinition($typeHint);
$value = $this->createAutowiredDefinition($typeHint, $id);
} catch (RuntimeException $e) {
if (!$parameter->isDefaultValueAvailable()) {
throw $e;
Expand Down Expand Up @@ -197,15 +197,15 @@ private function set($type, $value)
* Registers a definition for the type if possible or throws an exception.
*
* @param \ReflectionClass $typeHint
*
* @param string $id
* @return Reference A reference to the registered definition
*
* @throws RuntimeException
*/
private function createAutowiredDefinition(\ReflectionClass $typeHint)
private function createAutowiredDefinition(\ReflectionClass $typeHint, $id)
{
if (!$typeHint->isInstantiable()) {
throw new RuntimeException(sprintf('Unable to autowire type "%s".', $typeHint->name));
throw new RuntimeException(sprintf('Unable to autowire argument of type "%s" for the service "%s".', $typeHint->name, $id));
}

$argumentId = sprintf('autowired.%s', $typeHint->name);
Expand Down
0