Skip to content

Commit 84a3e06

Browse files
author
Marc André Audet
committed
Added the parsing of a callable in $method_path for Routes
1 parent 9c053c0 commit 84a3e06

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

library/Cervo/Cervo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Cervo
3737
/**
3838
* The current version of Cervo.
3939
*/
40-
const VERSION = '2.5.2';
40+
const VERSION = '2.5.3';
4141

4242
/**
4343
* All the libraries instances that have been initialized through getLibrary().

library/Cervo/Libraries/RouterPath/Route.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,21 @@ class Route extends \Cervo\Libraries\RouterPath
7272
* Set the path, the module, the controller and the method.
7373
* Sanitize the path and compute the regex.
7474
*
75-
* @param string $path
76-
* @param string $controller
77-
* @param int $http_method
78-
* @param array $params
75+
* @param string $path
76+
* @param string|callable $method_path
77+
* @param int $http_method
78+
* @param array $params
7979
*
8080
* @throws InvalidControllerException
8181
*/
82-
public function __construct($path, $controller, $http_method = self::M_ALL, $params = [])
82+
public function __construct($path, $method_path, $http_method = self::M_ALL, $params = [])
8383
{
84-
$controller_e = explode('/', $controller);
84+
if (is_callable($method_path))
85+
{
86+
$method_path = $method_path();
87+
}
88+
89+
$controller_e = explode('/', $method_path);
8590
$c_controller_e = count($controller_e);
8691

8792
if ($c_controller_e < 3)

0 commit comments

Comments
 (0)