Skip to content

Commit

Permalink
Added checking for the url parts.
Browse files Browse the repository at this point in the history
  • Loading branch information
devcorrelator committed May 4, 2018
1 parent b400a44 commit 9fb4d6e
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/Routing/RouteBuilder.php
Expand Up @@ -747,28 +747,27 @@ protected static function parseDefaults($defaults)
if (preg_match($regex, $defaults, $matches)) {
unset($matches[0]);
$matches = array_filter($matches, function ($value) {
return $value !== '' && $value !== '::';
return $value !== '::';
});

// Intentionally incomplete switch
switch (count($matches)) {
case 2:
return [
'controller' => $matches[3],
'action' => $matches[4]
'controller' => (isset($matches[3] ? $matches[3] : null),
'action' => (isset($matches[4] ? $matches[4] : null)
];
case 3:
return [
'prefix' => (isset($matches[2]) ? strtolower($matches[2]) : false),
'controller' => $matches[3],
'action' => $matches[4]
'prefix' => (isset($matches[2]) ? strtolower($matches[2]) : null),
'controller' => (isset($matches[3] ? $matches[3] : null),
'action' => (isset($matches[4] ? $matches[4] : null)
];
case 4:
return [
'plugin' => $matches[1],
'prefix' => (isset($matches[2]) ? strtolower($matches[2]) : false),
'controller' => $matches[3],
'action' => $matches[4]
'plugin' => (isset($matches[1] ? $matches[1] : null),
'prefix' => (isset($matches[2]) ? strtolower($matches[2]) : null),
'controller' => (isset($matches[3] ? $matches[3] : null),
'action' => (isset($matches[4] ? $matches[4] : null)
];
}
}
Expand Down

0 comments on commit 9fb4d6e

Please sign in to comment.