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

Commit beeaf6a

Browse files
committed
Revert "Merge branch 'hotfix/application-should-use-route-middleware-service' into release-3.0.0"
This reverts commit 5f280f2, reversing changes made to bf4a4f8. The reversion is due to the fact that @webimpress has discovered that all supported containers resolve aliases to the target service BEFORE determining if the service has already been created. As such, pulling a service by its alias will retrieve the same instance as pulling it by its canonical name. As such, we can use the canonical name in the `ApplicationFactory` when retrieving the routing middleware for use with the `Application`. Conflicts: CHANGELOG.md
1 parent f1b80f1 commit beeaf6a

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

src/Container/ApplicationFactory.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@
1313
use Zend\Expressive\Application;
1414
use Zend\Expressive\ApplicationPipeline;
1515
use Zend\Expressive\MiddlewareFactory;
16+
use Zend\Expressive\Router\Middleware\PathBasedRoutingMiddleware;
1617
use Zend\HttpHandlerRunner\RequestHandlerRunner;
1718

18-
use const Zend\Expressive\ROUTE_MIDDLEWARE;
19-
2019
/**
2120
* Create an Application instance.
2221
*
@@ -36,7 +35,7 @@ public function __invoke(ContainerInterface $container) : Application
3635
return new Application(
3736
$container->get(MiddlewareFactory::class),
3837
$container->get(ApplicationPipeline::class),
39-
$container->get(ROUTE_MIDDLEWARE),
38+
$container->get(PathBasedRoutingMiddleware::class),
4039
$container->get(RequestHandlerRunner::class)
4140
);
4241
}

src/constants.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
* Should resolve to the Zend\Expressive\Router\Middleware\PathBasedRoutingMiddleware
7171
* service.
7272
*
73+
* @deprecated To remove in version 4.0.0.
7374
* @var string
7475
*/
7576
const ROUTE_MIDDLEWARE = __NAMESPACE__ . '\Middleware\RouteMiddleware';

test/Container/ApplicationFactoryTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
use Zend\HttpHandlerRunner\RequestHandlerRunner;
2020
use Zend\Stratigility\MiddlewarePipeInterface;
2121

22-
use const Zend\Expressive\ROUTE_MIDDLEWARE;
23-
2422
class ApplicationFactoryTest extends TestCase
2523
{
2624
public function testFactoryProducesAnApplication()
@@ -33,7 +31,7 @@ public function testFactoryProducesAnApplication()
3331
$container = $this->prophesize(ContainerInterface::class);
3432
$container->get(MiddlewareFactory::class)->willReturn($middlewareFactory);
3533
$container->get(ApplicationPipeline::class)->willReturn($pipeline);
36-
$container->get(ROUTE_MIDDLEWARE)->willReturn($routeMiddleware);
34+
$container->get(PathBasedRoutingMiddleware::class)->willReturn($routeMiddleware);
3735
$container->get(RequestHandlerRunner::class)->willReturn($runner);
3836

3937
$factory = new ApplicationFactory();

0 commit comments

Comments
 (0)