From e09d673cc2fe77f45c47507bc6f988ab21458cb7 Mon Sep 17 00:00:00 2001 From: diosmosis <benakamoorthi@fastmail.fm> Date: Fri, 21 Mar 2014 10:10:30 +0000 Subject: [PATCH] Allow controller action to be different from API action in Controller::renderReport. --- core/Plugin/Controller.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/core/Plugin/Controller.php b/core/Plugin/Controller.php index a49013a8de..ff750decc8 100644 --- a/core/Plugin/Controller.php +++ b/core/Plugin/Controller.php @@ -203,15 +203,16 @@ abstract class Controller /** * Convenience method that creates and renders a ViewDataTable for a API method. * - * @param string $pluginName The name of the plugin (eg, `'UserSettings'`). * @param string $apiAction The name of the API action (eg, `'getResolution'`). + * @param bool $controllerAction The name of the Controller action name that is rendering the report. Defaults + * to the `$apiAction`. * @param bool $fetch If `true`, the rendered string is returned, if `false` it is `echo`'d. * @throws \Exception if `$pluginName` is not an existing plugin or if `$apiAction` is not an * existing method of the plugin's API. * @return string|void See `$fetch`. * @api */ - protected function renderReport($apiAction) + protected function renderReport($apiAction, $controllerAction = false) { $pluginName = $this->pluginName; @@ -224,7 +225,11 @@ abstract class Controller $apiAction = $apiProxy->buildApiActionName($pluginName, $apiAction); - $view = ViewDataTableFactory::build(null, $apiAction); + if ($controllerAction !== false) { + $controllerAction = $pluginName . '.' . $controllerAction; + } + + $view = ViewDataTableFactory::build(null, $apiAction, $controllerAction); $rendered = $view->render(); return $rendered; -- GitLab