Skip to content

Commit

Permalink
refactor: do not use and deprecate setDefaultController() method
Browse files Browse the repository at this point in the history
The constructor of the Router class already defines the default controller.
  • Loading branch information
kenjis committed Feb 12, 2022
1 parent 61b9a23 commit 2822a18
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
13 changes: 5 additions & 8 deletions system/Router/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -459,15 +459,12 @@ public function autoRoute(string $uri)
{
$segments = explode('/', $uri);

// WARNING: Directories get shifted out of the segments array.
$segments = $this->scanControllers($segments);

// If we don't have any segments left - try the default controller;
// WARNING: Directories get shifted out of the segments array.
if (empty($segments)) {
$this->setDefaultController();
}
// If we don't have any segments left - use the default controller;
// If not empty, then the first segment should be the controller
else {
if (! empty($segments)) {
$this->controller = ucfirst(array_shift($segments));
}

Expand Down Expand Up @@ -643,8 +640,6 @@ protected function setRequest(array $segments = [])
{
// If we don't have any segments - try the default controller;
if (empty($segments)) {
$this->setDefaultController();

return;
}

Expand All @@ -665,6 +660,8 @@ protected function setRequest(array $segments = [])

/**
* Sets the default controller based on the info set in the RouteCollection.
*
* @deprecated This was an unnecessary method, so it is no longer used.
*/
protected function setDefaultController()
{
Expand Down
1 change: 1 addition & 0 deletions user_guide_src/source/changelogs/v4.2.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Deprecations
- ``CodeIgniter\Database\SQLSRV\Connection::getError()`` is deprecated. Use ``CodeIgniter\Database\SQLSRV\Connection::error()`` instead.
- ``CodeIgniter\Debug\Exceptions::cleanPath()`` and ``CodeIgniter\Debug\Toolbar\Collectors\BaseCollector::cleanPath()`` are deprecated. Use the ``clean_path()`` function instead.
- ``CodeIgniter\Log\Logger::cleanFilenames()`` and ``CodeIgniter\Test\TestLogger::cleanup()`` are both deprecated. Use the ``clean_path()`` function instead.
- ``CodeIgniter\Router\setDefaultController()`` is deprecated.

Bugs Fixed
**********
Expand Down

0 comments on commit 2822a18

Please sign in to comment.