diff --git a/administrator/components/com_banners/Controller/Banner.php b/administrator/components/com_banners/Controller/BannerController.php similarity index 98% rename from administrator/components/com_banners/Controller/Banner.php rename to administrator/components/com_banners/Controller/BannerController.php index 08dd5d1284359..2b95f803d3088 100644 --- a/administrator/components/com_banners/Controller/Banner.php +++ b/administrator/components/com_banners/Controller/BannerController.php @@ -18,7 +18,7 @@ * * @since 1.6 */ -class Banner extends Form +class BannerController extends Form { /** * The prefix to use with controller messages. diff --git a/administrator/components/com_banners/Controller/Banners.php b/administrator/components/com_banners/Controller/BannersController.php similarity index 98% rename from administrator/components/com_banners/Controller/Banners.php rename to administrator/components/com_banners/Controller/BannersController.php index ab000e4d0aa93..3bb199aadac87 100644 --- a/administrator/components/com_banners/Controller/Banners.php +++ b/administrator/components/com_banners/Controller/BannersController.php @@ -20,7 +20,7 @@ * * @since 1.6 */ -class Banners extends Admin +class BannersController extends Admin { /** * The prefix to use with controller messages. diff --git a/administrator/components/com_banners/Controller/Client.php b/administrator/components/com_banners/Controller/ClientController.php similarity index 94% rename from administrator/components/com_banners/Controller/Client.php rename to administrator/components/com_banners/Controller/ClientController.php index 2820a4fc21432..2552d7a6021f3 100644 --- a/administrator/components/com_banners/Controller/Client.php +++ b/administrator/components/com_banners/Controller/ClientController.php @@ -17,7 +17,7 @@ * * @since 1.6 */ -class Client extends Form +class ClientController extends Form { /** * The prefix to use with controller messages. diff --git a/administrator/components/com_banners/Controller/Clients.php b/administrator/components/com_banners/Controller/ClientsController.php similarity index 96% rename from administrator/components/com_banners/Controller/Clients.php rename to administrator/components/com_banners/Controller/ClientsController.php index 6225cddd94217..1a220537a2320 100644 --- a/administrator/components/com_banners/Controller/Clients.php +++ b/administrator/components/com_banners/Controller/ClientsController.php @@ -17,7 +17,7 @@ * * @since 1.6 */ -class Clients extends Admin +class ClientsController extends Admin { /** * The prefix to use with controller messages. diff --git a/administrator/components/com_banners/Controller/Controller.php b/administrator/components/com_banners/Controller/DisplayController.php similarity index 97% rename from administrator/components/com_banners/Controller/Controller.php rename to administrator/components/com_banners/Controller/DisplayController.php index 1ff2d503630d7..ba45e3a68813a 100644 --- a/administrator/components/com_banners/Controller/Controller.php +++ b/administrator/components/com_banners/Controller/DisplayController.php @@ -18,7 +18,7 @@ * * @since 1.6 */ -class Controller extends BaseController +class DisplayController extends BaseController { /** * The default view. diff --git a/administrator/components/com_banners/Controller/Tracks.php b/administrator/components/com_banners/Controller/TracksController.php similarity index 98% rename from administrator/components/com_banners/Controller/Tracks.php rename to administrator/components/com_banners/Controller/TracksController.php index 6a5a416a63043..ecbc6f24fa9ec 100644 --- a/administrator/components/com_banners/Controller/Tracks.php +++ b/administrator/components/com_banners/Controller/TracksController.php @@ -11,14 +11,14 @@ defined('_JEXEC') or die; use Joomla\CMS\Application\ApplicationHelper; -use Joomla\CMS\Controller\Controller as BaseController; +use Joomla\CMS\Controller\Controller; /** * Tracks list controller class. * * @since 1.6 */ -class Tracks extends BaseController +class TracksController extends Controller { /** * The prefix to use with controller messages. diff --git a/libraries/src/Controller/Form.php b/libraries/src/Controller/Form.php index 33e0a27d9aa36..d383594824e75 100644 --- a/libraries/src/Controller/Form.php +++ b/libraries/src/Controller/Form.php @@ -93,12 +93,21 @@ public function __construct($config = array(), MvcFactoryInterface $factory = nu { $r = null; - if (!preg_match('/(.*)Controller(.*)/i', get_class($this), $r)) + $match = 'Controller'; + + // If there is a namespace append a backslash + if (strpos(get_class($this), '\\')) + { + $match .= '\\\\'; + } + + if (!preg_match('/(.*)' . $match . '(.*)/i', get_class($this), $r)) { throw new \Exception(\JText::_('JLIB_APPLICATION_ERROR_CONTROLLER_GET_NAME'), 500); } - $this->context = str_replace('\\', '', strtolower($r[2])); + // Remove the backslashes and the suffix controller + $this->context = str_replace(array('\\', 'controller'), '', strtolower($r[2])); } // Guess the item view as the context. diff --git a/libraries/src/Dispatcher/Dispatcher.php b/libraries/src/Dispatcher/Dispatcher.php index 6c799e6a990a6..9b609237b8df8 100644 --- a/libraries/src/Dispatcher/Dispatcher.php +++ b/libraries/src/Dispatcher/Dispatcher.php @@ -149,7 +149,7 @@ public function dispatch() else { // Do we have a controller? - $controller = $this->input->get('controller', 'controller'); + $controller = $this->input->get('controller', 'display'); $task = $command; } @@ -199,7 +199,19 @@ public function getController($name, $client = null, $config = array()) // Set up the client $client = $client ? $client : ucfirst($this->app->getName()); - $controllerClass = $namespace . $client . '\\Controller\\' . ucfirst($name); + $controllerClass = $namespace . $client . '\\Controller\\' . ucfirst($name) . 'Controller'; + + // @todo Remove me when core extensions are converted + if (!class_exists($controllerClass)) + { + $controllerClass = $namespace . $client . '\\Controller\\' . ucfirst($name); + } + + // @todo Remove me when core extensions are converted + if (!class_exists($controllerClass) && $name == 'display') + { + $controllerClass = $namespace . $client . '\\Controller\\Controller'; + } if (!class_exists($controllerClass)) {