From 42b360f479ce7f5635aed2edfe9a1be84d258d26 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 4 Apr 2019 07:29:26 -0400 Subject: [PATCH] Implement feedback changes to App\Router - Add class PhpDoc - Switch Router->routeCollector scope to protected - Added getter for Router->routeCollector - Added EOF new line - Removed unused use statement - Improved App->collectRoutes PhpDoc --- src/App.php | 5 +++-- src/App/Router.php | 20 +++++++++++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/App.php b/src/App.php index d5698bdb76..da9239c685 100644 --- a/src/App.php +++ b/src/App.php @@ -1249,7 +1249,7 @@ class App } $router = new App\Router(); - $this->collectRoutes($router->routeCollector); + $this->collectRoutes($router->getRouteCollector()); $this->module_class = $router->getModuleClass($this->cmd); @@ -1507,7 +1507,7 @@ class App } /** - * @brief Static declaration of Friendica routes. + * Static declaration of Friendica routes. * * Supports: * - Route groups @@ -1518,6 +1518,7 @@ class App * * Handler must be the name of a class extending Friendica\BaseModule. * + * @brief Static declaration of Friendica routes. * @param RouteCollector $routeCollector * @throws InternalServerErrorException */ diff --git a/src/App/Router.php b/src/App/Router.php index 1281001a3b..7753b6bbb9 100644 --- a/src/App/Router.php +++ b/src/App/Router.php @@ -7,12 +7,21 @@ use FastRoute\DataGenerator\GroupCountBased; use FastRoute\Dispatcher; use FastRoute\RouteCollector; use FastRoute\RouteParser\Std; -use Friendica\Module\Itemsource; +/** + * Wrapper for FastRoute\Router + * + * This wrapper only makes use of a subset of the router features, mainly parses a route rule to return the relevant + * module class. + * + * Actual routes are defined in App->collectRoutes. + * + * @package Friendica\App + */ class Router { /** @var RouteCollector */ - public $routeCollector; + protected $routeCollector; public function __construct(RouteCollector $routeCollector = null) { @@ -23,6 +32,11 @@ class Router $this->routeCollector = $routeCollector; } + public function getRouteCollector() + { + return $this->routeCollector; + } + public function getModuleClass($cmd) { $cmd = '/' . ltrim($cmd, '/'); @@ -40,4 +54,4 @@ class Router return $moduleClass; } -} \ No newline at end of file +}