mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
fix!: add missing methods to RouteCollectionInterface
This commit is contained in:
parent
27f11f59e7
commit
655736d223
@ -22,9 +22,6 @@ use CodeIgniter\HTTP\ResponseInterface;
|
||||
* A Route Collection's sole job is to hold a series of routes. The required
|
||||
* number of methods is kept very small on purpose, but implementors may
|
||||
* add a number of additional methods to customize how the routes are defined.
|
||||
*
|
||||
* The RouteCollection provides the Router with the routes so that it can determine
|
||||
* which controller should be run.
|
||||
*/
|
||||
interface RouteCollectionInterface
|
||||
{
|
||||
@ -62,11 +59,19 @@ interface RouteCollectionInterface
|
||||
*/
|
||||
public function setDefaultNamespace(string $value);
|
||||
|
||||
/**
|
||||
* Returns the default namespace.
|
||||
*/
|
||||
public function getDefaultNamespace(): string;
|
||||
|
||||
/**
|
||||
* Sets the default controller to use when no other controller has been
|
||||
* specified.
|
||||
*
|
||||
* @return RouteCollectionInterface
|
||||
*
|
||||
* @TODO The default controller is only for auto-routing. So this should be
|
||||
* removed in the future.
|
||||
*/
|
||||
public function setDefaultController(string $value);
|
||||
|
||||
@ -86,6 +91,9 @@ interface RouteCollectionInterface
|
||||
* doesn't work well with PHP method names....
|
||||
*
|
||||
* @return RouteCollectionInterface
|
||||
*
|
||||
* @TODO This method is only for auto-routing. So this should be removed in
|
||||
* the future.
|
||||
*/
|
||||
public function setTranslateURIDashes(bool $value);
|
||||
|
||||
@ -96,6 +104,9 @@ interface RouteCollectionInterface
|
||||
* defined routes.
|
||||
*
|
||||
* If FALSE, will stop searching and do NO automatic routing.
|
||||
*
|
||||
* @TODO This method is only for auto-routing. So this should be removed in
|
||||
* the future.
|
||||
*/
|
||||
public function setAutoRoute(bool $value): self;
|
||||
|
||||
@ -107,6 +118,9 @@ interface RouteCollectionInterface
|
||||
* This setting is passed to the Router class and handled there.
|
||||
*
|
||||
* @param callable|null $callable
|
||||
*
|
||||
* @TODO This method is not related to the route collection. So this should
|
||||
* be removed in the future.
|
||||
*/
|
||||
public function set404Override($callable = null): self;
|
||||
|
||||
@ -115,6 +129,9 @@ interface RouteCollectionInterface
|
||||
* or the controller/string.
|
||||
*
|
||||
* @return (Closure(string): (ResponseInterface|string|void))|string|null
|
||||
*
|
||||
* @TODO This method is not related to the route collection. So this should
|
||||
* be removed in the future.
|
||||
*/
|
||||
public function get404Override();
|
||||
|
||||
@ -122,6 +139,9 @@ interface RouteCollectionInterface
|
||||
* Returns the name of the default controller. With Namespace.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @TODO The default controller is only for auto-routing. So this should be
|
||||
* removed in the future.
|
||||
*/
|
||||
public function getDefaultController();
|
||||
|
||||
@ -136,6 +156,9 @@ interface RouteCollectionInterface
|
||||
* Returns the current value of the translateURIDashes setting.
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @TODO This method is only for auto-routing. So this should be removed in
|
||||
* the future.
|
||||
*/
|
||||
public function shouldTranslateURIDashes();
|
||||
|
||||
@ -143,15 +166,38 @@ interface RouteCollectionInterface
|
||||
* Returns the flag that tells whether to autoRoute URI against Controllers.
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @TODO This method is only for auto-routing. So this should be removed in
|
||||
* the future.
|
||||
*/
|
||||
public function shouldAutoRoute();
|
||||
|
||||
/**
|
||||
* Returns the raw array of available routes.
|
||||
*
|
||||
* @return array
|
||||
* @param non-empty-string|null $verb HTTP verb like `GET`,`POST` or `*` or `CLI`.
|
||||
* @param bool $includeWildcard Whether to include '*' routes.
|
||||
*/
|
||||
public function getRoutes();
|
||||
public function getRoutes(?string $verb = null, bool $includeWildcard = true): array;
|
||||
|
||||
/**
|
||||
* Returns one or all routes options
|
||||
*
|
||||
* @param string|null $from The route path (with placeholders or regex)
|
||||
* @param string|null $verb HTTP verb like `GET`,`POST` or `*` or `CLI`.
|
||||
*
|
||||
* @return array<string, int|string> [key => value]
|
||||
*/
|
||||
public function getRoutesOptions(?string $from = null, ?string $verb = null): array;
|
||||
|
||||
/**
|
||||
* Sets the current HTTP verb.
|
||||
*
|
||||
* @param string $verb HTTP verb
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setHTTPVerb(string $verb);
|
||||
|
||||
/**
|
||||
* Returns the current HTTP Verb being used.
|
||||
@ -194,4 +240,28 @@ interface RouteCollectionInterface
|
||||
* Get the flag that limit or not the routes with {locale} placeholder to App::$supportedLocales
|
||||
*/
|
||||
public function shouldUseSupportedLocalesOnly(): bool;
|
||||
|
||||
/**
|
||||
* Checks a route (using the "from") to see if it's filtered or not.
|
||||
*
|
||||
* @param string|null $verb HTTP verb like `GET`,`POST` or `*` or `CLI`.
|
||||
*/
|
||||
public function isFiltered(string $search, ?string $verb = null): bool;
|
||||
|
||||
/**
|
||||
* Returns the filters that should be applied for a single route, along
|
||||
* with any parameters it might have. Parameters are found by splitting
|
||||
* the parameter name on a colon to separate the filter name from the parameter list,
|
||||
* and the splitting the result on commas. So:
|
||||
*
|
||||
* 'role:admin,manager'
|
||||
*
|
||||
* has a filter of "role", with parameters of ['admin', 'manager'].
|
||||
*
|
||||
* @param string $search routeKey
|
||||
* @param string|null $verb HTTP verb like `GET`,`POST` or `*` or `CLI`.
|
||||
*
|
||||
* @return list<string> filter_name or filter_name:arguments like 'role:admin,manager'
|
||||
*/
|
||||
public function getFiltersForRoute(string $search, ?string $verb = null): array;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user