Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit63094c4

Browse files
committed
adjust location of controller autowire check
1 parentf359ada commit63094c4

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

‎src/Symfony/Component/HttpKernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -121,21 +121,6 @@ public function process(ContainerBuilder $container)
121121
$args = [];
122122
foreach ($parametersas$p) {
123123
/** @var \ReflectionParameter $p */
124-
if (class_exists(Autowire::class) &&$attr =$p->getAttributes(Autowire::class)[0] ??null) {
125-
$value =$attr->newInstance()->value;
126-
127-
if ($valueinstanceof Reference) {
128-
$args[$p->name] =newReference($value,$p->allowsNull() ? ContainerInterface::NULL_ON_INVALID_REFERENCE : ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE);
129-
}else {
130-
$args[$p->name] =newReference('.value.'.$container->hash($value));
131-
$container->register((string)$args[$p->name],'mixed')
132-
->setFactory('current')
133-
->addArgument([$value]);
134-
}
135-
136-
continue;
137-
}
138-
139124
$type =ltrim($target = (string) ProxyHelper::getTypeHint($r,$p),'\\');
140125
$invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE;
141126

@@ -164,7 +149,7 @@ public function process(ContainerBuilder $container)
164149
}
165150

166151
continue;
167-
}elseif (!$type ||!$autowire||'\\' !==$target[0]) {
152+
}elseif (!$autowire ||(!$p->getAttributes(Autowire::class) && (!$type||'\\' !==$target[0]))) {
168153
continue;
169154
}elseif (is_subclass_of($type, \UnitEnum::class)) {
170155
// do not attempt to register enum typed arguments if not already present in bindings
@@ -177,6 +162,21 @@ public function process(ContainerBuilder $container)
177162
continue;
178163
}
179164

165+
if (class_exists(Autowire::class) &&$attr =$p->getAttributes(Autowire::class)[0] ??null) {
166+
$value =$attr->newInstance()->value;
167+
168+
if ($valueinstanceof Reference) {
169+
$args[$p->name] =$type ?newTypedReference($value,$type,$invalidBehavior,$p->name) :newReference($value,$invalidBehavior);
170+
}else {
171+
$args[$p->name] =newReference('.value.'.$container->hash($value));
172+
$container->register((string)$args[$p->name],'mixed')
173+
->setFactory('current')
174+
->addArgument([$value]);
175+
}
176+
177+
continue;
178+
}
179+
180180
if ($type && !$p->isOptional() && !$p->allowsNull() && !class_exists($type) && !interface_exists($type,false)) {
181181
$message =sprintf('Cannot determine controller argument for "%s::%s()": the $%s argument is type-hinted with the non-existent class or interface: "%s".',$class,$r->name,$p->name,$type);
182182

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp