Skip to content

Commit

Permalink
Testing & refactoring in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
rotimi committed Nov 15, 2023
1 parent 4463fcf commit 8199b4b
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions src/controllers/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ public function __construct(
/** @psalm-suppress MixedAssignment */
$this->view_renderer = $this->getContainerItem('new_view_renderer');


$uri_path = ($req->getUri() instanceof \Psr\Http\Message\UriInterface)
? $req->getUri()->getPath() : '';

Expand Down Expand Up @@ -238,30 +237,28 @@ public function __construct(
$this->current_uri_computed = sMVC_UriToString($recomputed_uri);
}

if( ($this->controller_name_from_uri === '') || ($this->action_name_from_uri === '') ) {

if(
(($this->controller_name_from_uri === '') || ($this->action_name_from_uri === ''))
&& ( ($uri_path !== '') && ($uri_path !== '/') && (strpos($uri_path, '/') !== false) )
) {
// calculate $this->controller_name_from_uri and / or
// $this->action_name_from_uri if necessary
if( $uri_path[0] === '/' ) {

if( ($uri_path !== '') && $uri_path !== '/' && strpos($uri_path, '/') !== false ) {

if( $uri_path[0] === '/' ) {

// remove leading slash /
$uri_path = substr($uri_path, 1);
}
// remove leading slash /
$uri_path = substr($uri_path, 1);
}

$uri_path_parts = explode('/', $uri_path);
$uri_path_parts = explode('/', $uri_path);

if( count($uri_path_parts) >= 1 && ($this->controller_name_from_uri === '') ) {
if( count($uri_path_parts) >= 1 && ($this->controller_name_from_uri === '') ) {

$this->controller_name_from_uri = $uri_path_parts[0];
}
$this->controller_name_from_uri = $uri_path_parts[0];
}

if( count($uri_path_parts) >= 2 && ($this->action_name_from_uri === '') ) {
if( count($uri_path_parts) >= 2 && ($this->action_name_from_uri === '') ) {

$this->action_name_from_uri = $uri_path_parts[1];
}
$this->action_name_from_uri = $uri_path_parts[1];
}
}

Expand Down

0 comments on commit 8199b4b

Please sign in to comment.