Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.x - RouteCollectorProxy #2641

Merged
merged 11 commits into from Apr 21, 2019

Conversation

Projects
None yet
2 participants
@l0gicgate
Copy link
Contributor

commented Apr 21, 2019

This is pull 7 out of 7 to complete the goals set in #2604

App now extends RouteCollectorProxy which provides all of the route mapping functionality.

App::group() Breaking Change
There is a breaking change with App::group(). Now the callable gets a RouteCollectorProxyInterface instance injected which used to be App. All of the original route mapping functionality remains intact.

The new interface implements the following methods:

  • RouteCollectorProxy::getCallableResolver()
  • RouteCollectorProxy::getContainer()
  • RouteCollectorProxy::getRouteCollector()
  • RouteCollectorProxy::get()
  • RouteCollectorProxy::post()
  • RouteCollectorProxy::put()
  • RouteCollectorProxy::patch()
  • RouteCollectorProxy::delete()
  • RouteCollectorProxy::options()
  • RouteCollectorProxy::any()
  • RouteCollectorProxy::getBasePath()
  • RouteCollectorProxy::setBasePath()

The following methods on RouteCollectorInterface are removed:

  • RouteCollectorInterface::pushGroup()
  • RouteCollectorInterface::popGroup()

The following method on RouteCollectorInterface is introduced:

  • RouteCollectorInterface::group() which replaces pushGroup() and popGroup()

Example Usage:

use Slim\App;
use Slim\Http\Factory\DecoratedResponseFactory;
use Slim\Http\ServerRequest;
use Slim\Interfaces\RouteCollectorProxyInterface;
use Slim\Psr7\Factory\ResponseFactory;
use Slim\Psr7\Factory\ServerRequestFactory;
use Slim\Psr7\Factory\StreamFactory;

$responseFactory = new DecoratedResponseFactory(new ResponseFactory(), new StreamFactory());
$app = new App($responseFactory);

/**
 * As mentioned above, the breaking change introduced here is
 * that we don't inject App in the route group callable anymore.
 */
$app->group('/app', function (RouteCollectorProxyInterface $group) {
    $group->get('/hello/{name}', function ($request, $response, $args) {
        return $response;
    });
});

$request = new ServerRequest(ServerRequestFactory::createFromGlobals());
$app->run($request);

@l0gicgate l0gicgate added the Slim 4 label Apr 21, 2019

@l0gicgate l0gicgate added this to the 4.0 milestone Apr 21, 2019

@l0gicgate l0gicgate referenced this pull request Apr 21, 2019

Closed

[DRAFT] 4.x Refactor Routing #2604

7 of 7 tasks complete

l0gicgate added some commits Apr 21, 2019

@l0gicgate l0gicgate merged commit 7377499 into slimphp:4.x Apr 21, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@l0gicgate l0gicgate deleted the l0gicgate:4.x-RouteCollectorProxy branch Apr 21, 2019

@coveralls

This comment has been minimized.

Copy link

commented Apr 21, 2019

Coverage Status

Coverage decreased (-0.5%) to 97.997% when pulling a5f09ac on l0gicgate:4.x-RouteCollectorProxy into e65a4dc on slimphp:4.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.