本文整理汇总了PHP中Symfony\Component\HttpKernel\Controller\ControllerResolver::doGetArguments方法的典型用法代码示例。如果您正苦于以下问题:PHP ControllerResolver::doGetArguments方法的具体用法?PHP ControllerResolver::doGetArguments怎么用?PHP ControllerResolver::doGetArguments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\HttpKernel\Controller\ControllerResolver
的用法示例。
在下文中一共展示了ControllerResolver::doGetArguments方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doGetArguments
protected function doGetArguments(Request $request, $controller, array $parameters)
{
foreach ($parameters as $param) {
if ($param->getClass() && $param->getClass()->isInstance($this->app)) {
$request->attributes->set($param->getName(), $this->app);
break;
}
}
return parent::doGetArguments($request, $controller, $parameters);
}
开发者ID:nagi88,项目名称:controller-resolver-inject-constructor,代码行数:10,代码来源:DecoratorControllerResolverSymfony.php
示例2: doGetArguments
protected function doGetArguments(Request $request, $controller, array $parameters)
{
/** @var \ReflectionParameter $param */
foreach ($parameters as $param) {
/** @var \Symfony\Component\Routing\Route $route */
$route = $this->app['routes']->get($request->attributes->get('_route'));
$bundle = $this->app->getSubBundle($route->getOption('bundle_name'));
if ($bundle && $param->getClass() && $param->getClass()->isInstance($bundle)) {
$request->attributes->set($param->getName(), $bundle);
continue;
}
if ($param->getClass() && $param->getClass()->isInstance($this->app)) {
$request->attributes->set($param->getName(), $this->app);
continue;
}
}
return parent::doGetArguments($request, $controller, $parameters);
}
示例3: doGetArguments
/**
* {@inheritdoc}
*/
protected function doGetArguments(Request $request, $controller, array $parameters)
{
$arguments = parent::doGetArguments($request, $controller, $parameters);
// The parameter converter overrides the raw request attributes with the
// upcasted objects. However, it keeps a backup copy of the original, raw
// values in a special request attribute ('_raw_variables'). If a controller
// argument has a type hint, we pass it the upcasted object, otherwise we
// pass it the original, raw value.
if ($request->attributes->has('_raw_variables') && ($raw = $request->attributes->get('_raw_variables')->all())) {
foreach ($parameters as $parameter) {
// Use the raw value if a parameter has no typehint.
if (!$parameter->getClass() && isset($raw[$parameter->name])) {
$position = $parameter->getPosition();
$arguments[$position] = $raw[$parameter->name];
}
}
}
return $arguments;
}
示例4: doGetArguments
protected function doGetArguments(Request $request, $controller, array $parameters)
{
$args = $this->injectArguments($parameters, $request);
foreach ($args as $key => $value) {
$request->attributes->set($key, $value);
}
return parent::doGetArguments($request, $controller, $parameters);
}