Skip to content

Commit

Permalink
Merge branch '4.x-RefactorRouteGroup' into 4.x
Browse files Browse the repository at this point in the history
Closes #2612
  • Loading branch information
akrabat committed Apr 2, 2019
2 parents a36fc2f + 5a1d90f commit 821d563
Show file tree
Hide file tree
Showing 9 changed files with 151 additions and 243 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

### Removed

- [#2612](https://github.com/slimphp/Slim/pull/2612) Remove Routable, refactored RouteGroup and Route interface
- [#2589](https://github.com/slimphp/Slim/pull/2589) Remove App::$settings altogether
- [#2587](https://github.com/slimphp/Slim/pull/2587) Remove Pimple as a dev-dependency
- [#2398](https://github.com/slimphp/Slim/pull/2398) Slim no longer has error handling built into App. Add ErrorMiddleware() as the outermost middleware.
Expand Down
27 changes: 14 additions & 13 deletions Slim/Interfaces/RouteGroupInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,10 @@

use Psr\Http\Server\MiddlewareInterface;
use Slim\App;
use Slim\MiddlewareDispatcher;

/**
* RouteGroup Interface
*
* @package Slim
* @since 3.0.0
*/
interface RouteGroupInterface
{
/**
* Get route pattern
*
* @return string
*/
public function getPattern(): string;

/**
* @param MiddlewareInterface|string|callable $middleware
* @return RouteGroupInterface
Expand All @@ -39,6 +27,19 @@ public function add($middleware): RouteGroupInterface;
*/
public function addMiddleware(MiddlewareInterface $middleware): RouteGroupInterface;

/**
* @param MiddlewareDispatcher $dispatcher
* @return RouteGroupInterface
*/
public function appendMiddlewareToDispatcher(MiddlewareDispatcher $dispatcher): RouteGroupInterface;

/**
* Get route pattern
*
* @return string
*/
public function getPattern(): string;

/**
* Execute route group callable in the context of the Slim App
*
Expand Down
24 changes: 16 additions & 8 deletions Slim/Interfaces/RouteInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;

/**
* Route Interface
*
* @package Slim
* @since 3.0.0
*/
interface RouteInterface
{
/**
Expand All @@ -38,6 +32,21 @@ public function getArgument(string $name, $default = null);
*/
public function getArguments(): array;

/**
* Get route callable
*
* @return callable|string
*/
public function getCallable();

/**
* Set route callable
*
* @param callable|string $callable
* @return RouteInterface
*/
public function setCallable($callable): RouteInterface;

/**
* Get route name
*
Expand Down Expand Up @@ -95,11 +104,10 @@ public function addMiddleware(MiddlewareInterface $middleware): RouteInterface;
/**
* Prepare the route for use
*
* @param ServerRequestInterface $request
* @param array $arguments
* @return RouteInterface
*/
public function prepare(ServerRequestInterface $request, array $arguments): RouteInterface;
public function prepare(array $arguments): RouteInterface;

/**
* Run route
Expand Down
2 changes: 1 addition & 1 deletion Slim/Middleware/RoutingMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function performRouting(ServerRequestInterface $request): ServerRequestIn
$routeArguments = $routingResults->getRouteArguments();
$routeIdentifier = $routingResults->getRouteIdentifier() ?? '';
$route = $this->router->lookupRoute($routeIdentifier);
$route->prepare($request, $routeArguments);
$route->prepare($routeArguments);
return $request
->withAttribute('route', $route)
->withAttribute('routingResults', $routingResults);
Expand Down
76 changes: 0 additions & 76 deletions Slim/Routable.php

This file was deleted.

Loading

0 comments on commit 821d563

Please sign in to comment.