8000 feature #19011 [HttpKernel] Add convenient method ArgumentResolver:: … · symfony/symfony@7ed1e97 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7ed1e97

Browse files
committed
feature #19011 [HttpKernel] Add convenient method ArgumentResolver:: getDefaultArgumentValueResolvers (romainneutron)
This PR was merged into the 3.2-dev branch. Discussion ---------- [HttpKernel] Add convenient method ArgumentResolver:: getDefaultArgumentValueResolvers | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | N/A | License | MIT | Doc PR | N/A I realized while implementing my own `ArgumentValueResolver` that registering a new one is not easy, you have to give the whole list of resolver instead of pushing your one in the stack. Commits ------- 6fdfc92 [HttpKernel] Add convenient method ArgumentResolver::addArgumentValueResolver
2 parents 86eb7a3 + 6fdfc92 commit 7ed1e97

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/Symfony/Component/HttpKernel/Controller/ArgumentResolver.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,7 @@ final class ArgumentResolver implements ArgumentResolverInterface
3636
public function __construct(ArgumentMetadataFactoryInterface $argumentMetadataFactory = null, array $argumentValueResolvers = array())
3737
{
3838
$this->argumentMetadataFactory = $argumentMetadataFactory ?: new ArgumentMetadataFactory();
39-
$this->argumentValueResolvers = $argumentValueResolvers ?: array(
40-
new RequestAttributeValueResolver(),
41-
new RequestValueResolver(),
42-
new DefaultValueResolver(),
43-
new VariadicValueResolver(),
44-
);
39+
$this->argumentValueResolvers = $argumentValueResolvers ?: self::getDefaultArgumentValueResolvers();
4540
}
4641

4742
/**
@@ -84,4 +79,14 @@ public function getArguments(Request $request, $controller)
8479

8580
return $arguments;
8681
}
82+
83+
public static function getDefaultArgumentValueResolvers()
84+
{
85+
return array(
86+
new RequestAttributeValueResolver(),
87+
new RequestValueResolver(),
88+
new DefaultValueResolver(),
89+
new VariadicValueResolver(),
90+
);
91+
}
8792
}

0 commit comments

Comments
 (0)
0