mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-17 08:47:52 +00:00
Development
- Fixed BootManager not loading. - Optimised for-loops.
This commit is contained in:
@@ -107,10 +107,10 @@ abstract class LoadableRoute extends Route implements ILoadableRoute
|
|||||||
|
|
||||||
/* Let's parse the values of any {} parameter in the url */
|
/* Let's parse the values of any {} parameter in the url */
|
||||||
|
|
||||||
$max = count($params);
|
$max = count($params) - 1;
|
||||||
$keys = array_keys($params);
|
$keys = array_keys($params);
|
||||||
|
|
||||||
for ($i = 0; $i < $max; $i++) {
|
for ($i = $max; $i >= 0; $i--) {
|
||||||
$param = $keys[$i];
|
$param = $keys[$i];
|
||||||
$value = $params[$param];
|
$value = $params[$param];
|
||||||
|
|
||||||
|
|||||||
@@ -77,10 +77,11 @@ abstract class Route implements IRoute
|
|||||||
$lastCharacter = '';
|
$lastCharacter = '';
|
||||||
$isParameter = false;
|
$isParameter = false;
|
||||||
$parameter = '';
|
$parameter = '';
|
||||||
|
$routeLength = strlen($route) - 1;
|
||||||
|
|
||||||
for ($i = 0; $i < strlen($route); $i++) {
|
for ($i = $routeLength; $i >= 0; $i--) {
|
||||||
|
|
||||||
$character = $route[$i];
|
$character = strrev($route)[$i];
|
||||||
|
|
||||||
if ($character === '{') {
|
if ($character === '{') {
|
||||||
/* Remove "/" and "\" from regex */
|
/* Remove "/" and "\" from regex */
|
||||||
@@ -129,9 +130,9 @@ abstract class Route implements IRoute
|
|||||||
|
|
||||||
$parameters = [];
|
$parameters = [];
|
||||||
|
|
||||||
$max = count($parameterNames);
|
$max = count($parameterNames) - 1;
|
||||||
|
|
||||||
for ($i = 0; $i < $max; $i++) {
|
for ($i = $max; $i >= 0; $i--) {
|
||||||
|
|
||||||
$name = $parameterNames[$i];
|
$name = $parameterNames[$i];
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ class RouteController extends LoadableRoute implements IControllerRoute
|
|||||||
|
|
||||||
/* Remove requestType from method-name, if it exists */
|
/* Remove requestType from method-name, if it exists */
|
||||||
if ($method !== null) {
|
if ($method !== null) {
|
||||||
|
|
||||||
$max = count(static::$requestTypes);
|
$max = count(static::$requestTypes);
|
||||||
|
|
||||||
for ($i = 0; $i < $max; $i++) {
|
for ($i = 0; $i < $max; $i++) {
|
||||||
@@ -70,6 +71,7 @@ class RouteController extends LoadableRoute implements IControllerRoute
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$method .= '/';
|
$method .= '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,9 +20,9 @@ class RouteGroup extends Route implements IGroupRoute
|
|||||||
{
|
{
|
||||||
if (count($this->domains) > 0) {
|
if (count($this->domains) > 0) {
|
||||||
|
|
||||||
$max = count($this->domains);
|
$max = count($this->domains) - 1;
|
||||||
|
|
||||||
for ($i = 0; $i < $max; $i++) {
|
for ($i = $max; $i >= 0; $i--) {
|
||||||
|
|
||||||
$domain = $this->domains[$i];
|
$domain = $this->domains[$i];
|
||||||
$parameters = $this->parseParameters($domain, $request->getHost(), '.*');
|
$parameters = $this->parseParameters($domain, $request->getHost(), '.*');
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ class Router
|
|||||||
$max = count($this->bootManagers) - 1;
|
$max = count($this->bootManagers) - 1;
|
||||||
|
|
||||||
/* @var $manager IRouterBootManager */
|
/* @var $manager IRouterBootManager */
|
||||||
for ($i = 0; $i < $max; $i++) {
|
for ($i = $max; $i >= 0; $i--) {
|
||||||
|
|
||||||
$manager = $this->bootManagers[$i];
|
$manager = $this->bootManagers[$i];
|
||||||
|
|
||||||
@@ -345,10 +345,10 @@ class Router
|
|||||||
*/
|
*/
|
||||||
public function findRoute($name)
|
public function findRoute($name)
|
||||||
{
|
{
|
||||||
$max = count($this->processedRoutes);
|
$max = count($this->processedRoutes) - 1;
|
||||||
|
|
||||||
/* @var $route ILoadableRoute */
|
/* @var $route ILoadableRoute */
|
||||||
for ($i = 0; $i < $max; $i++) {
|
for ($i = $max; $i >= 0; $i--) {
|
||||||
|
|
||||||
$route = $this->processedRoutes[$i];
|
$route = $this->processedRoutes[$i];
|
||||||
|
|
||||||
@@ -443,10 +443,10 @@ class Router
|
|||||||
|
|
||||||
/* Loop through all the routes to see if we can find a match */
|
/* Loop through all the routes to see if we can find a match */
|
||||||
|
|
||||||
$max = count($this->processedRoutes);
|
$max = count($this->processedRoutes) - 1;
|
||||||
|
|
||||||
/* @var $route ILoadableRoute */
|
/* @var $route ILoadableRoute */
|
||||||
for ($i = 0; $i < $max; $i++) {
|
for ($i = $max; $i >= 0; $i--) {
|
||||||
|
|
||||||
$route = $this->processedRoutes[$i];
|
$route = $this->processedRoutes[$i];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user