From 8c512b0d2d73a0930a420030dd6fecb8cb2d506f Mon Sep 17 00:00:00 2001 From: David King Date: Fri, 18 Jan 2013 14:00:40 -0500 Subject: [ticket/11334] Properly generate controller URL until paths issue gets fixed PHPBB3-11334 --- phpBB/includes/controller/helper.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'phpBB/includes/controller') diff --git a/phpBB/includes/controller/helper.php b/phpBB/includes/controller/helper.php index 6cacc8fefa..2098f51edf 100644 --- a/phpBB/includes/controller/helper.php +++ b/phpBB/includes/controller/helper.php @@ -85,17 +85,14 @@ class phpbb_controller_helper } /** - * Easily generate a URL + * Generate a URL * - * @param array $url_parts Each array element is a 'folder' - * i.e. array('my', 'ext') maps to ./app.php/my/ext - * @param mixed $query The Query string, passed directly into the second - * argument of append_sid() - * @return string A URL that has already been run through append_sid() + * @param string $route The route to travel + * @return string The URL already passed through append_sid() */ - public function url(array $url_parts, $query = '') + protected function url($route) { - return append_sid($this->phpbb_root_path . implode('/', $url_parts), $query); + return append_sid($this->phpbb_root_path . 'app.' . $this->php_ext, array('controller' => $route)); } /** -- cgit v1.2.1 From d3e2fae66d74f79ef7dcfe2e24f47efaa5c106e2 Mon Sep 17 00:00:00 2001 From: David King Date: Fri, 15 Feb 2013 16:48:43 -0500 Subject: [ticket/11334] Add a test for the controller helper URL method PHPBB3-11334 --- phpBB/includes/controller/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/controller') diff --git a/phpBB/includes/controller/helper.php b/phpBB/includes/controller/helper.php index 2098f51edf..0e64829874 100644 --- a/phpBB/includes/controller/helper.php +++ b/phpBB/includes/controller/helper.php @@ -55,7 +55,7 @@ class phpbb_controller_helper * @param string $phpbb_root_path phpBB root path * @param string $php_ext PHP extension */ - public function __construct(phpbb_template $template, phpbb_user $user, $phpbb_root_path, $php_ext) + public function __construct(phpbb_template $template = null, phpbb_user $user = null, $phpbb_root_path = './', $php_ext = '.php') { $this->template = $template; $this->user = $user; -- cgit v1.2.1 From 5e89ce1898857f29e5345adf31d62bbed1fb985b Mon Sep 17 00:00:00 2001 From: David King Date: Fri, 15 Feb 2013 16:52:54 -0500 Subject: [ticket/11334] Make url helper method public PHPBB3-11334 --- phpBB/includes/controller/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/controller') diff --git a/phpBB/includes/controller/helper.php b/phpBB/includes/controller/helper.php index 0e64829874..f2beca2056 100644 --- a/phpBB/includes/controller/helper.php +++ b/phpBB/includes/controller/helper.php @@ -90,7 +90,7 @@ class phpbb_controller_helper * @param string $route The route to travel * @return string The URL already passed through append_sid() */ - protected function url($route) + public function url($route) { return append_sid($this->phpbb_root_path . 'app.' . $this->php_ext, array('controller' => $route)); } -- cgit v1.2.1 From 5850a2cbf6e8313feeb55154e1083d73b45f4dc3 Mon Sep 17 00:00:00 2001 From: David King Date: Sat, 16 Feb 2013 19:21:34 -0500 Subject: [ticket/11334] Remove extraneous period PHPBB3-11334 --- phpBB/includes/controller/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/controller') diff --git a/phpBB/includes/controller/helper.php b/phpBB/includes/controller/helper.php index f2beca2056..451c448a18 100644 --- a/phpBB/includes/controller/helper.php +++ b/phpBB/includes/controller/helper.php @@ -92,7 +92,7 @@ class phpbb_controller_helper */ public function url($route) { - return append_sid($this->phpbb_root_path . 'app.' . $this->php_ext, array('controller' => $route)); + return append_sid($this->phpbb_root_path . 'app' . $this->php_ext, array('controller' => $route)); } /** -- cgit v1.2.1 From ff9a0e4ef4756c5a9cce3f023b07d9f9a0e5653a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 15 Mar 2013 13:35:43 +0100 Subject: [ticket/11334] Expand functionality of helper->url() Expanded the functionality of helper->url() to support all parameters of append_sid() itself. PHPBB3-11334 --- phpBB/includes/controller/helper.php | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'phpBB/includes/controller') diff --git a/phpBB/includes/controller/helper.php b/phpBB/includes/controller/helper.php index 451c448a18..4c021849f4 100644 --- a/phpBB/includes/controller/helper.php +++ b/phpBB/includes/controller/helper.php @@ -87,12 +87,30 @@ class phpbb_controller_helper /** * Generate a URL * - * @param string $route The route to travel + * @param string $route The route to travel + * @param mixed $params String or array of additional url parameters + * @param bool $is_amp Is url using & (true) or & (false) + * @param string $session_id Possibility to use a custom session id instead of the global one * @return string The URL already passed through append_sid() */ - public function url($route) + public function url($route, $params = false, $is_amp = true, $session_id = false) { - return append_sid($this->phpbb_root_path . 'app' . $this->php_ext, array('controller' => $route)); + if (is_array($params) && !empty($params)) + { + $params = array_merge(array( + 'controller' => $route, + ), $params); + } + else if (is_string($params) && $params) + { + $params = 'controller=' . $route . (($is_amp) ? '&' : '&') . $params; + } + else + { + $params = array('controller' => $route); + } + + return append_sid($this->phpbb_root_path . 'app' . $this->php_ext, $params, $is_amp, $session_id); } /** -- cgit v1.2.1 From 076711d9a95e05083143b7ac4a589914a2e2b2ad Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 15 Mar 2013 14:02:46 +0100 Subject: [ticket/11334] Use mocks instead of making parameters optional PHPBB3-11334 --- phpBB/includes/controller/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/controller') diff --git a/phpBB/includes/controller/helper.php b/phpBB/includes/controller/helper.php index 4c021849f4..1464267711 100644 --- a/phpBB/includes/controller/helper.php +++ b/phpBB/includes/controller/helper.php @@ -55,7 +55,7 @@ class phpbb_controller_helper * @param string $phpbb_root_path phpBB root path * @param string $php_ext PHP extension */ - public function __construct(phpbb_template $template = null, phpbb_user $user = null, $phpbb_root_path = './', $php_ext = '.php') + public function __construct(phpbb_template $template, phpbb_user $user, $phpbb_root_path, $php_ext) { $this->template = $template; $this->user = $user; -- cgit v1.2.1 From 3b0cdc53629c3a852762ae9b96b809cf4b1af2c4 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 15 Mar 2013 15:21:15 +0100 Subject: [ticket/11334] Allow parameters to be specified in the route PHPBB3-11334 --- phpBB/includes/controller/helper.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/controller') diff --git a/phpBB/includes/controller/helper.php b/phpBB/includes/controller/helper.php index 1464267711..46c6307cb4 100644 --- a/phpBB/includes/controller/helper.php +++ b/phpBB/includes/controller/helper.php @@ -95,6 +95,13 @@ class phpbb_controller_helper */ public function url($route, $params = false, $is_amp = true, $session_id = false) { + $route_params = ''; + if (($route_delim = strpos($route, '?')) !== false) + { + $route_params = substr($route, $route_delim); + $route = substr($route, 0, $route_delim); + } + if (is_array($params) && !empty($params)) { $params = array_merge(array( @@ -110,7 +117,7 @@ class phpbb_controller_helper $params = array('controller' => $route); } - return append_sid($this->phpbb_root_path . 'app' . $this->php_ext, $params, $is_amp, $session_id); + return append_sid($this->phpbb_root_path . 'app' . $this->php_ext . $route_params, $params, $is_amp, $session_id); } /** -- cgit v1.2.1 From 6ef363547abf98445d20db61ffa5bac66b260603 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Wed, 24 Apr 2013 17:10:17 -0500 Subject: [ticket/11335] (controller/helper.php) Make php_ext 'php' not '.php' PHPBB3-11335 --- phpBB/includes/controller/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/controller') diff --git a/phpBB/includes/controller/helper.php b/phpBB/includes/controller/helper.php index 46c6307cb4..74410ddfd1 100644 --- a/phpBB/includes/controller/helper.php +++ b/phpBB/includes/controller/helper.php @@ -117,7 +117,7 @@ class phpbb_controller_helper $params = array('controller' => $route); } - return append_sid($this->phpbb_root_path . 'app' . $this->php_ext . $route_params, $params, $is_amp, $session_id); + return append_sid($this->phpbb_root_path . 'app.' . $this->php_ext . $route_params, $params, $is_amp, $session_id); } /** -- cgit v1.2.1 From 884a5b06fa2e300285a67885d0652d201c7a330a Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Thu, 4 Jul 2013 10:13:05 -0500 Subject: [feature/twig] Add set_style function to controller helper PHPBB3-11598 --- phpBB/includes/controller/helper.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/controller') diff --git a/phpBB/includes/controller/helper.php b/phpBB/includes/controller/helper.php index 74410ddfd1..ec09757a5d 100644 --- a/phpBB/includes/controller/helper.php +++ b/phpBB/includes/controller/helper.php @@ -23,6 +23,12 @@ use Symfony\Component\HttpFoundation\Response; */ class phpbb_controller_helper { + /** + * Style object + * @var phpbb_style + */ + protected $style; + /** * Template object * @var phpbb_template @@ -50,19 +56,36 @@ class phpbb_controller_helper /** * Constructor * + * @param phpbb_style $style Style object * @param phpbb_template $template Template object * @param phpbb_user $user User object * @param string $phpbb_root_path phpBB root path * @param string $php_ext PHP extension */ - public function __construct(phpbb_template $template, phpbb_user $user, $phpbb_root_path, $php_ext) + public function __construct(phpbb_style $style, phpbb_template $template, phpbb_user $user, $phpbb_root_path, $php_ext) { + $this->style = $style; $this->template = $template; $this->user = $user; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; } + /** + * Set style location based on (current) user's chosen style. + * + * @param array $style_directories The directories to add style paths for + * E.g. array('ext/foo/bar/styles', 'styles') + * Default: array('styles') (phpBB's style directory) + * @return phpbb_controller_helper $this + */ + public function set_style($style_base_directory = array('styles')) + { + $this->style->set_style($style_base_directory); + + return $this; + } + /** * Automate setting up the page and creating the response object. * -- cgit v1.2.1 From 2fb48d60f1b8ea111c766d6d9e7a3dde2b8a4e74 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Thu, 4 Jul 2013 11:08:36 -0500 Subject: [feature/twig] Attempt to automatically set style dir for ext controllers Extension authors can change it themselves if necessary PHPBB3-11598 --- phpBB/includes/controller/resolver.php | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/controller') diff --git a/phpBB/includes/controller/resolver.php b/phpBB/includes/controller/resolver.php index ee469aa9c8..2c7d112748 100644 --- a/phpBB/includes/controller/resolver.php +++ b/phpBB/includes/controller/resolver.php @@ -37,16 +37,24 @@ class phpbb_controller_resolver implements ControllerResolverInterface */ protected $container; + /** + * phpbb_style object + * @var phpbb_style + */ + protected $style; + /** * Construct method * * @param phpbb_user $user User Object * @param ContainerInterface $container ContainerInterface object + * @param phpbb_style $style */ - public function __construct(phpbb_user $user, ContainerInterface $container) + public function __construct(phpbb_user $user, ContainerInterface $container, phpbb_style $style) { $this->user = $user; $this->container = $container; + $this->style = $style; } /** @@ -80,6 +88,24 @@ class phpbb_controller_resolver implements ControllerResolverInterface $controller_object = $this->container->get($service); + /* + * If this is an extension controller, we'll try to automatically set + * the style paths for the extension (the ext author can change them + * if necessary). + */ + $controller_dir = explode('_', get_class($controller_object)); + + // 0 phpbb, 1 ext, 2 vendor, 3 extension name, ... + if ($controller_dir[1] === 'ext') + { + $controller_style_dir = 'ext/' . $controller_dir[2] . '/' . $controller_dir[3] . '/styles'; + + if (is_dir($controller_style_dir)) + { + $this->style->set_style(array($controller_style_dir, 'styles')); + } + } + return array($controller_object, $method); } -- cgit v1.2.1 From 1ce33c1ff62426d030731cca100c4119bcd5265d Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Thu, 4 Jul 2013 11:12:26 -0500 Subject: [feature/twig] Safety check for 2fb48d6 PHPBB3-11598 --- phpBB/includes/controller/resolver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/controller') diff --git a/phpBB/includes/controller/resolver.php b/phpBB/includes/controller/resolver.php index 2c7d112748..e44aa14b55 100644 --- a/phpBB/includes/controller/resolver.php +++ b/phpBB/includes/controller/resolver.php @@ -96,7 +96,7 @@ class phpbb_controller_resolver implements ControllerResolverInterface $controller_dir = explode('_', get_class($controller_object)); // 0 phpbb, 1 ext, 2 vendor, 3 extension name, ... - if ($controller_dir[1] === 'ext') + if (isset($controller_dir[3]) && $controller_dir[1] === 'ext') { $controller_style_dir = 'ext/' . $controller_dir[2] . '/' . $controller_dir[3] . '/styles'; -- cgit v1.2.1 From b7ede06835ba784b81365946f057adf75ae7592b Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Thu, 4 Jul 2013 11:16:44 -0500 Subject: [feature/twig] Make style dependency optional for resolver PHPBB3-11598 --- phpBB/includes/controller/resolver.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/controller') diff --git a/phpBB/includes/controller/resolver.php b/phpBB/includes/controller/resolver.php index e44aa14b55..95dfc8da8e 100644 --- a/phpBB/includes/controller/resolver.php +++ b/phpBB/includes/controller/resolver.php @@ -50,7 +50,7 @@ class phpbb_controller_resolver implements ControllerResolverInterface * @param ContainerInterface $container ContainerInterface object * @param phpbb_style $style */ - public function __construct(phpbb_user $user, ContainerInterface $container, phpbb_style $style) + public function __construct(phpbb_user $user, ContainerInterface $container, phpbb_style $style = null) { $this->user = $user; $this->container = $container; @@ -96,7 +96,7 @@ class phpbb_controller_resolver implements ControllerResolverInterface $controller_dir = explode('_', get_class($controller_object)); // 0 phpbb, 1 ext, 2 vendor, 3 extension name, ... - if (isset($controller_dir[3]) && $controller_dir[1] === 'ext') + if (!is_null($this->style) && isset($controller_dir[3]) && $controller_dir[1] === 'ext') { $controller_style_dir = 'ext/' . $controller_dir[2] . '/' . $controller_dir[3] . '/styles'; -- cgit v1.2.1 From 13c356545465a457b8c55dd9638f89165bab6271 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 5 Jul 2013 12:11:59 -0500 Subject: [feature/twig] Remove style dependency for controller helper If a controller wants to use set_style, it can just use phpbb_style PHPBB3-11598 --- phpBB/includes/controller/helper.php | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) (limited to 'phpBB/includes/controller') diff --git a/phpBB/includes/controller/helper.php b/phpBB/includes/controller/helper.php index ec09757a5d..74410ddfd1 100644 --- a/phpBB/includes/controller/helper.php +++ b/phpBB/includes/controller/helper.php @@ -23,12 +23,6 @@ use Symfony\Component\HttpFoundation\Response; */ class phpbb_controller_helper { - /** - * Style object - * @var phpbb_style - */ - protected $style; - /** * Template object * @var phpbb_template @@ -56,36 +50,19 @@ class phpbb_controller_helper /** * Constructor * - * @param phpbb_style $style Style object * @param phpbb_template $template Template object * @param phpbb_user $user User object * @param string $phpbb_root_path phpBB root path * @param string $php_ext PHP extension */ - public function __construct(phpbb_style $style, phpbb_template $template, phpbb_user $user, $phpbb_root_path, $php_ext) + public function __construct(phpbb_template $template, phpbb_user $user, $phpbb_root_path, $php_ext) { - $this->style = $style; $this->template = $template; $this->user = $user; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; } - /** - * Set style location based on (current) user's chosen style. - * - * @param array $style_directories The directories to add style paths for - * E.g. array('ext/foo/bar/styles', 'styles') - * Default: array('styles') (phpBB's style directory) - * @return phpbb_controller_helper $this - */ - public function set_style($style_base_directory = array('styles')) - { - $this->style->set_style($style_base_directory); - - return $this; - } - /** * Automate setting up the page and creating the response object. * -- cgit v1.2.1 From 7030578bbe9e11c18b5becaf8b06e670e3c2e3cd Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 14 Jul 2013 01:32:34 -0400 Subject: [ticket/11698] Moving all autoloadable files to phpbb/ PHPBB3-11698 --- phpBB/includes/controller/exception.php | 24 ----- phpBB/includes/controller/helper.php | 139 ---------------------------- phpBB/includes/controller/provider.php | 82 ----------------- phpBB/includes/controller/resolver.php | 154 -------------------------------- 4 files changed, 399 deletions(-) delete mode 100644 phpBB/includes/controller/exception.php delete mode 100644 phpBB/includes/controller/helper.php delete mode 100644 phpBB/includes/controller/provider.php delete mode 100644 phpBB/includes/controller/resolver.php (limited to 'phpBB/includes/controller') diff --git a/phpBB/includes/controller/exception.php b/phpBB/includes/controller/exception.php deleted file mode 100644 index faa8b6b584..0000000000 --- a/phpBB/includes/controller/exception.php +++ /dev/null @@ -1,24 +0,0 @@ -template = $template; - $this->user = $user; - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - } - - /** - * Automate setting up the page and creating the response object. - * - * @param string $handle The template handle to render - * @param string $page_title The title of the page to output - * @param int $status_code The status code to be sent to the page header - * @return Response object containing rendered page - */ - public function render($template_file, $page_title = '', $status_code = 200) - { - page_header($page_title); - - $this->template->set_filenames(array( - 'body' => $template_file, - )); - - page_footer(true, false, false); - - return new Response($this->template->assign_display('body'), $status_code); - } - - /** - * Generate a URL - * - * @param string $route The route to travel - * @param mixed $params String or array of additional url parameters - * @param bool $is_amp Is url using & (true) or & (false) - * @param string $session_id Possibility to use a custom session id instead of the global one - * @return string The URL already passed through append_sid() - */ - public function url($route, $params = false, $is_amp = true, $session_id = false) - { - $route_params = ''; - if (($route_delim = strpos($route, '?')) !== false) - { - $route_params = substr($route, $route_delim); - $route = substr($route, 0, $route_delim); - } - - if (is_array($params) && !empty($params)) - { - $params = array_merge(array( - 'controller' => $route, - ), $params); - } - else if (is_string($params) && $params) - { - $params = 'controller=' . $route . (($is_amp) ? '&' : '&') . $params; - } - else - { - $params = array('controller' => $route); - } - - return append_sid($this->phpbb_root_path . 'app.' . $this->php_ext . $route_params, $params, $is_amp, $session_id); - } - - /** - * Output an error, effectively the same thing as trigger_error - * - * @param string $message The error message - * @param string $code The error code (e.g. 404, 500, 503, etc.) - * @return Response A Reponse instance - */ - public function error($message, $code = 500) - { - $this->template->assign_vars(array( - 'MESSAGE_TEXT' => $message, - 'MESSAGE_TITLE' => $this->user->lang('INFORMATION'), - )); - - return $this->render('message_body.html', $this->user->lang('INFORMATION'), $code); - } -} diff --git a/phpBB/includes/controller/provider.php b/phpBB/includes/controller/provider.php deleted file mode 100644 index b2a5b9f6b2..0000000000 --- a/phpBB/includes/controller/provider.php +++ /dev/null @@ -1,82 +0,0 @@ -routing_paths = $routing_paths; - } - - /** - * Locate paths containing routing files - * This sets an internal property but does not return the paths. - * - * @return The current instance of this object for method chaining - */ - public function import_paths_from_finder(phpbb_extension_finder $finder) - { - // We hardcode the path to the core config directory - // because the finder cannot find it - $this->routing_paths = array_merge(array('config'), array_map('dirname', array_keys($finder - ->directory('config') - ->prefix('routing') - ->suffix('yml') - ->find() - ))); - - return $this; - } - - /** - * Get a list of controllers and return it - * - * @param string $base_path Base path to prepend to file paths - * @return array Array of controllers and their route information - */ - public function find($base_path = '') - { - $routes = new RouteCollection; - foreach ($this->routing_paths as $path) - { - $loader = new YamlFileLoader(new FileLocator($base_path . $path)); - $routes->addCollection($loader->load('routing.yml')); - } - - return $routes; - } -} diff --git a/phpBB/includes/controller/resolver.php b/phpBB/includes/controller/resolver.php deleted file mode 100644 index 95dfc8da8e..0000000000 --- a/phpBB/includes/controller/resolver.php +++ /dev/null @@ -1,154 +0,0 @@ -user = $user; - $this->container = $container; - $this->style = $style; - } - - /** - * Load a controller callable - * - * @param Symfony\Component\HttpFoundation\Request $request Symfony Request object - * @return bool|Callable Callable or false - * @throws phpbb_controller_exception - */ - public function getController(Request $request) - { - $controller = $request->attributes->get('_controller'); - - if (!$controller) - { - throw new phpbb_controller_exception($this->user->lang['CONTROLLER_NOT_SPECIFIED']); - } - - // Require a method name along with the service name - if (stripos($controller, ':') === false) - { - throw new phpbb_controller_exception($this->user->lang['CONTROLLER_METHOD_NOT_SPECIFIED']); - } - - list($service, $method) = explode(':', $controller); - - if (!$this->container->has($service)) - { - throw new phpbb_controller_exception($this->user->lang('CONTROLLER_SERVICE_UNDEFINED', $service)); - } - - $controller_object = $this->container->get($service); - - /* - * If this is an extension controller, we'll try to automatically set - * the style paths for the extension (the ext author can change them - * if necessary). - */ - $controller_dir = explode('_', get_class($controller_object)); - - // 0 phpbb, 1 ext, 2 vendor, 3 extension name, ... - if (!is_null($this->style) && isset($controller_dir[3]) && $controller_dir[1] === 'ext') - { - $controller_style_dir = 'ext/' . $controller_dir[2] . '/' . $controller_dir[3] . '/styles'; - - if (is_dir($controller_style_dir)) - { - $this->style->set_style(array($controller_style_dir, 'styles')); - } - } - - return array($controller_object, $method); - } - - /** - * Dependencies should be specified in the service definition and can be - * then accessed in __construct(). Arguments are sent through the URL path - * and should match the parameters of the method you are using as your - * controller. - * - * @param Symfony\Component\HttpFoundation\Request $request Symfony Request object - * @param mixed $controller A callable (controller class, method) - * @return bool False - * @throws phpbb_controller_exception - */ - public function getArguments(Request $request, $controller) - { - // At this point, $controller contains the object and method name - list($object, $method) = $controller; - $mirror = new ReflectionMethod($object, $method); - - $arguments = array(); - $parameters = $mirror->getParameters(); - $attributes = $request->attributes->all(); - foreach ($parameters as $param) - { - if (array_key_exists($param->name, $attributes)) - { - $arguments[] = $attributes[$param->name]; - } - else if ($param->getClass() && $param->getClass()->isInstance($request)) - { - $arguments[] = $request; - } - else if ($param->isDefaultValueAvailable()) - { - $arguments[] = $param->getDefaultValue(); - } - else - { - throw new phpbb_controller_exception($this->user->lang('CONTROLLER_ARGUMENT_VALUE_MISSING', $param->getPosition() + 1, get_class($object) . ':' . $method, $param->name)); - } - } - - return $arguments; - } -} -- cgit v1.2.1