Skip to content

Commit 1b8c8af

Browse files
authored
Adapt to yiisoft/middleware-dispatcher changes (#172)
1 parent 19146c8 commit 1b8c8af

File tree

8 files changed

+19
-11
lines changed

8 files changed

+19
-11
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Yii Router Change Log
22

3-
## 1.1.1 under development
3+
## 1.2.0 under development
44

5-
- no changes in this release.
5+
- Chg #172: Upgrade the `yiisoft/middleware-dispatcher` dependency to version `3.0` (@rustamwin)
66

77
## 1.1.0 June 27, 2022
88

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"psr/http-server-handler": "^1.0",
2626
"psr/http-server-middleware": "^1.0",
2727
"yiisoft/http": "^1.2",
28-
"yiisoft/middleware-dispatcher": "^2.0",
28+
"yiisoft/middleware-dispatcher": "^3.0",
2929
"yiisoft/router-implementation": "1.0.0"
3030
},
3131
"require-dev": {

src/Middleware/Router.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use Yiisoft\Http\Method;
1414
use Yiisoft\Http\Status;
1515
use Yiisoft\Middleware\Dispatcher\MiddlewareDispatcher;
16-
use Yiisoft\Middleware\Dispatcher\MiddlewareFactoryInterface;
16+
use Yiisoft\Middleware\Dispatcher\MiddlewareFactory;
1717
use Yiisoft\Router\CurrentRoute;
1818
use Yiisoft\Router\UrlMatcherInterface;
1919

@@ -27,7 +27,7 @@ final class Router implements MiddlewareInterface
2727
public function __construct(
2828
UrlMatcherInterface $matcher,
2929
ResponseFactoryInterface $responseFactory,
30-
MiddlewareFactoryInterface $middlewareFactory,
30+
MiddlewareFactory $middlewareFactory,
3131
CurrentRoute $currentRoute,
3232
?EventDispatcherInterface $eventDispatcher = null
3333
) {

tests/GroupTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use stdClass;
1717
use Yiisoft\Middleware\Dispatcher\MiddlewareDispatcher;
1818
use Yiisoft\Middleware\Dispatcher\MiddlewareFactory;
19+
use Yiisoft\Middleware\Dispatcher\WrapperFactory;
1920
use Yiisoft\Router\Group;
2021
use Yiisoft\Router\Route;
2122
use Yiisoft\Router\RouteCollection;
@@ -444,8 +445,10 @@ public function handle(ServerRequestInterface $request): ResponseInterface
444445

445446
private function getDispatcher(): MiddlewareDispatcher
446447
{
448+
$container = new Container([]);
449+
$wrapperFactory = new WrapperFactory($container);
447450
return new MiddlewareDispatcher(
448-
new MiddlewareFactory(new Container([])),
451+
new MiddlewareFactory($container, $wrapperFactory),
449452
$this->createMock(EventDispatcherInterface::class)
450453
);
451454
}

tests/MatchingResultTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Yiisoft\Http\Method;
1717
use Yiisoft\Middleware\Dispatcher\MiddlewareDispatcher;
1818
use Yiisoft\Middleware\Dispatcher\MiddlewareFactory;
19+
use Yiisoft\Middleware\Dispatcher\WrapperFactory;
1920
use Yiisoft\Router\MatchingResult;
2021
use Yiisoft\Router\Route;
2122

@@ -51,7 +52,7 @@ public function testProcessSuccess(): void
5152
{
5253
$container = $this->createMock(ContainerInterface::class);
5354
$dispatcher = new MiddlewareDispatcher(
54-
new MiddlewareFactory($container),
55+
new MiddlewareFactory($container, new WrapperFactory($container)),
5556
$this->createMock(EventDispatcherInterface::class)
5657
);
5758
$route = Route::post('/', $dispatcher)->middleware($this->getMiddleware());

tests/Middleware/RouterTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Psr\Http\Server\RequestHandlerInterface;
1515
use Yiisoft\Http\Method;
1616
use Yiisoft\Middleware\Dispatcher\MiddlewareFactory;
17+
use Yiisoft\Middleware\Dispatcher\WrapperFactory;
1718
use Yiisoft\Router\CurrentRoute;
1819
use Yiisoft\Router\Group;
1920
use Yiisoft\Router\MatchingResult;
@@ -207,7 +208,7 @@ private function createRouterMiddleware(
207208
return new Router(
208209
$this->getMatcher($routeCollection),
209210
new Psr17Factory(),
210-
new MiddlewareFactory($container),
211+
new MiddlewareFactory($container, new WrapperFactory($container)),
211212
$currentRoute ?? new CurrentRoute()
212213
);
213214
}

tests/RouteCollectionTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use RuntimeException;
1616
use Yiisoft\Middleware\Dispatcher\MiddlewareDispatcher;
1717
use Yiisoft\Middleware\Dispatcher\MiddlewareFactory;
18+
use Yiisoft\Middleware\Dispatcher\WrapperFactory;
1819
use Yiisoft\Router\Group;
1920
use Yiisoft\Router\Route;
2021
use Yiisoft\Router\RouteCollection;
@@ -382,8 +383,9 @@ public function handle(ServerRequestInterface $request): Response
382383

383384
private function getDispatcher(ContainerInterface $container = null): MiddlewareDispatcher
384385
{
386+
$container ??= $this->createMock(ContainerInterface::class);
385387
return new MiddlewareDispatcher(
386-
new MiddlewareFactory($container ?? $this->createMock(ContainerInterface::class)),
388+
new MiddlewareFactory($container, new WrapperFactory($container)),
387389
$this->createMock(EventDispatcherInterface::class)
388390
);
389391
}

tests/RouteTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Yiisoft\Http\Method;
1717
use Yiisoft\Middleware\Dispatcher\MiddlewareDispatcher;
1818
use Yiisoft\Middleware\Dispatcher\MiddlewareFactory;
19+
use Yiisoft\Middleware\Dispatcher\WrapperFactory;
1920
use Yiisoft\Router\Route;
2021
use Yiisoft\Router\Tests\Support\AssertTrait;
2122
use Yiisoft\Router\Tests\Support\Container;
@@ -381,13 +382,13 @@ private function getDispatcher(ContainerInterface $container = null): Middleware
381382
{
382383
if ($container === null) {
383384
return new MiddlewareDispatcher(
384-
new MiddlewareFactory($this->getContainer()),
385+
new MiddlewareFactory($this->getContainer(), new WrapperFactory($this->getContainer())),
385386
$this->createMock(EventDispatcherInterface::class)
386387
);
387388
}
388389

389390
return new MiddlewareDispatcher(
390-
new MiddlewareFactory($container),
391+
new MiddlewareFactory($container, new WrapperFactory($container)),
391392
$this->createMock(EventDispatcherInterface::class)
392393
);
393394
}

0 commit comments

Comments
 (0)