Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Commit

Permalink
Split router interface into consumer-only and runtime-configurable ve…
Browse files Browse the repository at this point in the history
…rsions
  • Loading branch information
DASPRiD committed Feb 2, 2016
1 parent 3e54dff commit 6b43754
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 22 deletions.
25 changes: 3 additions & 22 deletions src/RouterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,6 @@
*/
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.
*
Expand All @@ -53,7 +33,7 @@ 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.
* URI from it. Additional router-dependent options may be passed.
*
* 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
Expand All @@ -63,8 +43,9 @@ public function match(Request $request);
* @see http://framework.zend.com/manual/current/en/modules/zend.mvc.routing.html
* @param string $name
* @param array $substitutions
* @param array $options
* @return string
* @throws Exception\RuntimeException if unable to generate the given URI.
*/
public function generateUri($name, array $substitutions = []);
public function generateUri($name, array $substitutions = [], array $options = []);
}
38 changes: 38 additions & 0 deletions src/RuntimeConfigurableRouterInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @see https://github.com/zendframework/zend-expressive for the canonical source repository
* @copyright Copyright (c) 2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license https://github.com/zendframework/zend-expressive/blob/master/LICENSE.md New BSD License
*/

namespace Zend\Expressive\Router;

use Zend\Expressive\Router\Exception\RuntimeException;

/**
* Interface defining required router capabilities.
*/
interface RuntimeConfigurableRouterInterface extends 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 RuntimeException when called after match() or
* generateUri() have been called.
*/
public function addRoute(Route $route);
}

0 comments on commit 6b43754

Please sign in to comment.