-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Adding support to bind scalar values to controller arguments #26658
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,14 +136,17 @@ public function process(ContainerBuilder $container) | |
$binding = $bindings[$bindingName]; | ||
|
||
list($bindingValue, $bindingId) = $binding->getValues(); | ||
$binding->setValues(array($bindingValue, $bindingId, true)); | ||
|
||
if (!$bindingValue instanceof Reference) { | ||
continue; | ||
$args[$p->name] = new Reference('value.'.$container->hash($bindingValue)); | ||
$container->register((string) $args[$p->name], 'mixed') | ||
->setFactory('current') | ||
->addArgument(array($bindingValue)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As this service is here to build a scalar, I should we should mark it as non-shared, to avoiding registering the scalar in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why? what's the issue with sharing a scalar (or array btw?) |
||
} else { | ||
$args[$p->name] = $bindingValue; | ||
} | ||
|
||
$binding->setValues(array($bindingValue, $bindingId, true)); | ||
$args[$p->name] = $bindingValue; | ||
|
||
continue; | ||
} elseif (!$type || !$autowire) { | ||
continue; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use
_value
as prefix, to reduce the likeliness of conflicts with an actual service, as the YAML format forbids using the underscore prefix in service ids since 4.0.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in ba05588