/** * @param Request $request * @param Template $template * @param object $controller * @param string $action * * @return array */ private function resolveDefaultParameters(Request $request, Template $template, $controller, $action) { $parameters = array(); $arguments = $template->getVars(); if (0 === count($arguments)) { $r = new \ReflectionObject($controller); $arguments = array(); foreach ($r->getMethod($action)->getParameters() as $param) { $arguments[] = $param->getName(); } } // fetch the arguments of @Template.vars or everything if desired // and assign them to the designated template foreach ($arguments as $argument) { $parameters[$argument] = $request->attributes->get($argument); } return $parameters; }
private function resolveDefaultParameters(Request $request, Template $template, $controller, $action) { $parameters = array(); $arguments = $template->getVars(); if (0 === count($arguments)) { $r = new \ReflectionObject($controller); $arguments = array(); foreach ($r->getMethod($action)->getParameters() as $param) { $arguments[] = $param->getName(); } } foreach ($arguments as $argument) { $parameters[$argument] = $request->attributes->get($argument); } return $parameters; }