gmarche/vendor/zendframework/zend-expressive-router/src/RouterInterface.php

69 lines
2.6 KiB
PHP

<?php
/**
* @see https://github.com/zendframework/zend-expressive-router for the canonical source repository
* @copyright Copyright (c) 2015-2016 Zend Technologies USA Inc. (http://www.zend.com)
* @license https://github.com/zendframework/zend-expressive-router/blob/master/LICENSE.md New BSD License
*/
namespace Zend\Expressive\Router;
use Psr\Http\Message\ServerRequestInterface as Request;
/**
* Interface defining required router capabilities.
*/
interface RouterInterface
{
/**
* Add a route.
*
* This method adds a route against which the underlying implementation may
* match. Implementations MUST aggregate route instances, but MUST NOT use
* the details to inject the underlying router until `match()` and/or
* `generateUri()` is called. This is required to allow consumers to
* modify route instances before matching (e.g., to provide route options,
* inject a name, etc.).
*
* The method MUST raise Exception\RuntimeException if called after either `match()`
* or `generateUri()` have already been called, to ensure integrity of the
* router between invocations of either of those methods.
*
* @param Route $route
* @throws Exception\RuntimeException when called after match() or
* generateUri() have been called.
*/
public function addRoute(Route $route);
/**
* Match a request against the known routes.
*
* Implementations will aggregate required information from the provided
* request instance, and pass them to the underlying router implementation;
* when done, they will then marshal a `RouteResult` instance indicating
* the results of the matching operation and return it to the caller.
*
* @param Request $request
* @return RouteResult
*/
public function match(Request $request);
/**
* Generate a URI from the named route.
*
* Takes the named route and any substitutions, and attempts to generate a
* URI from it.
*
* The URI generated MUST NOT be escaped. If you wish to escape any part of
* the URI, this should be performed afterwards; consider passing the URI
* to league/uri to encode it.
*
* @see https://github.com/auraphp/Aura.Router#generating-a-route-path
* @see http://framework.zend.com/manual/current/en/modules/zend.mvc.routing.html
* @param string $name
* @param array $substitutions
* @return string
* @throws Exception\RuntimeException if unable to generate the given URI.
*/
public function generateUri($name, array $substitutions = []);
}