From ffd9cfc6c8212f236821cbde86573ff8558dd87b Mon Sep 17 00:00:00 2001 From: Pepijn Over Date: Fri, 27 Feb 2015 17:11:37 +0100 Subject: [PATCH] [refactoring] renaming initialize() and initializeAction() methods to run() to correspond with router naming --- src/psm/Module/AbstractController.php | 10 +++++----- .../Module/Config/Controller/ConfigController.php | 2 +- src/psm/Module/ControllerInterface.php | 4 ++-- .../Module/Server/Controller/ServerController.php | 12 ++++++------ src/psm/Module/User/Controller/UserController.php | 4 ++-- src/psm/Router.php | 4 ++-- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/psm/Module/AbstractController.php b/src/psm/Module/AbstractController.php index d9b37676..0c3e8566 100644 --- a/src/psm/Module/AbstractController.php +++ b/src/psm/Module/AbstractController.php @@ -143,19 +143,19 @@ abstract class AbstractController extends ContainerAware implements ControllerIn } /** - * Initialize the controller. + * Run the controller. * * @param string $action if NULL, the action will be retrieved from user input (GET/POST) * @return \Symfony\Component\HttpFoundation\Response */ - public function initialize($action = null) { + public function run($action = null) { if($action === null) { $action = psm_GET('action', psm_POST('action', $this->action_default)); } $this->xhr = (bool) psm_GET('xhr', psm_POST('xhr', false)); - if(!in_array($action, $this->actions) || !($result = $this->initializeAction($action))) { - $result = $this->initializeAction($this->action_default); + if(!in_array($action, $this->actions) || !($result = $this->runAction($action))) { + $result = $this->runAction($this->action_default); } if($result instanceof Response) { @@ -173,7 +173,7 @@ abstract class AbstractController extends ContainerAware implements ControllerIn * @param string $action * @return mixed FALSE when action couldnt be initialized, response otherwise */ - protected function initializeAction($action) { + protected function runAction($action) { if(isset($this->user_level_required_actions[$action])) { if($this->getUser()->getUserLevel() > $this->user_level_required_actions[$action]) { // user is not allowed to access this action.. diff --git a/src/psm/Module/Config/Controller/ConfigController.php b/src/psm/Module/Config/Controller/ConfigController.php index 045215d7..c51e6e72 100644 --- a/src/psm/Module/Config/Controller/ConfigController.php +++ b/src/psm/Module/Config/Controller/ConfigController.php @@ -196,7 +196,7 @@ class ConfigController extends AbstractController { $this->default_tab = 'pushover'; } } - return $this->initializeAction('index'); + return $this->runAction('index'); } /** diff --git a/src/psm/Module/ControllerInterface.php b/src/psm/Module/ControllerInterface.php index 834300af..25843a1d 100644 --- a/src/psm/Module/ControllerInterface.php +++ b/src/psm/Module/ControllerInterface.php @@ -35,9 +35,9 @@ interface ControllerInterface extends ContainerAwareInterface { public function __construct(Database $db, \Twig_Environment $twig); /** - * Initialize the module + * Run the controller */ - public function initialize(); + public function run(); /** * Get the minimum required user level for this controller diff --git a/src/psm/Module/Server/Controller/ServerController.php b/src/psm/Module/Server/Controller/ServerController.php index 1b3ec39e..a7f59d8f 100644 --- a/src/psm/Module/Server/Controller/ServerController.php +++ b/src/psm/Module/Server/Controller/ServerController.php @@ -170,7 +170,7 @@ class ServerController extends AbstractServerController { $edit_server = $this->getServers($this->server_id); if(empty($edit_server)) { $this->addMessage(psm_get_lang('servers', 'error_server_no_match'), 'error'); - return $this->initializeAction('index'); + return $this->runAction('index'); } $tpl_data['titlemode'] = psm_get_lang('system', 'edit') . ' ' . $edit_server['label']; @@ -298,9 +298,9 @@ class ServerController extends AbstractServerController { $back_to = isset($_GET['back_to']) ? $_GET['back_to'] : 'index'; if($back_to == 'view') { - return $this->initializeAction('view'); + return $this->runAction('view'); } else { - return $this->initializeAction('index'); + return $this->runAction('index'); } } @@ -321,7 +321,7 @@ class ServerController extends AbstractServerController { } $this->addMessage(psm_get_lang('servers', 'deleted'), 'success'); } - return $this->initializeAction('index'); + return $this->runAction('index'); } /** @@ -329,12 +329,12 @@ class ServerController extends AbstractServerController { */ protected function executeView() { if($this->server_id == 0) { - return $this->initializeAction('index'); + return $this->runAction('index'); } $server = $this->getServers($this->server_id); if(empty($server)) { - return $this->initializeAction('index'); + return $this->runAction('index'); } $tpl_data = $this->getLabels(); diff --git a/src/psm/Module/User/Controller/UserController.php b/src/psm/Module/User/Controller/UserController.php index 174b3a20..e4b3a4b2 100644 --- a/src/psm/Module/User/Controller/UserController.php +++ b/src/psm/Module/User/Controller/UserController.php @@ -47,14 +47,14 @@ class UserController extends AbstractController { $this->twig->addGlobal('subtitle', psm_get_lang('menu', 'user')); } - public function initialize() { + public function run() { $servers = $this->db->select(PSM_DB_PREFIX.'servers', null, array('server_id', 'label'), '', "ORDER BY `active` ASC, `status` DESC, `label` ASC"); // change the indexes to reflect their server ids foreach($servers as $server) { $this->servers[$server['server_id']] = $server; } - return parent::initialize(); + return parent::run(); } /** diff --git a/src/psm/Router.php b/src/psm/Router.php index 2682bf41..8e2226be 100644 --- a/src/psm/Router.php +++ b/src/psm/Router.php @@ -33,7 +33,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; /** - * The router class opens the controller and initializes the module. + * The router class opens the controller and runs the module. * * It uses a so-called $mod param to determine which controller to load. * The $mod of run() has 2 components, separated by an underscore. The first part determines @@ -96,7 +96,7 @@ class Router { } } - $response = $controller->initialize($action); + $response = $controller->run($action); if(!($response instanceof Response)) { throw new \LogicException('Controller did not return a Response object.');