From 9122601322f5eb86c277b921ef9c64d981229b99 Mon Sep 17 00:00:00 2001 From: pamparam83 Date: Tue, 20 Feb 2024 16:34:27 +0300 Subject: [PATCH] Route attribute (#609) * fix-gridview * fix PageToken * fix routeArgument --- blog/README.md | 2 +- blog/config/common/params.php | 2 +- blog/resources/views/user/index.php | 2 -- blog/src/Auth/Controller/AuthController.php | 2 +- blog/src/Blog/Archive/ArchiveController.php | 2 +- blog/src/Blog/BlogController.php | 2 +- blog/src/Blog/CommentController.php | 2 +- blog/src/User/Controller/UserController.php | 6 +++--- blog/src/Widget/OffsetPagination.php | 2 +- blog/tests/Acceptance/LoginAcceptanceCest.php | 2 +- 10 files changed, 11 insertions(+), 13 deletions(-) diff --git a/blog/README.md b/blog/README.md index e126bbf8..3475e92a 100644 --- a/blog/README.md +++ b/blog/README.md @@ -54,7 +54,7 @@ More routes could be added by editing `src/Factory/AppRouterFactory`. The template comes with a ready to use [Codeception](https://codeception.com/) configuration. In order to execute tests run the following command: -``` +```bash composer run serve 127.0.0.1:8080 > ./runtime/yii.log 2>&1 & vendor/bin/codecept run ``` diff --git a/blog/config/common/params.php b/blog/config/common/params.php index f4aec774..ad7e01df 100644 --- a/blog/config/common/params.php +++ b/blog/config/common/params.php @@ -16,7 +16,7 @@ use Yiisoft\Translator\TranslatorInterface; use Yiisoft\Yii\Cycle\Schema\Conveyor\AttributedSchemaConveyor; use Yiisoft\Yii\Cycle\Schema\Provider\FromConveyorSchemaProvider; -use Yiisoft\Yii\Cycle\Schema\Provider\PhpFileSchemaProvider; +use \Cycle\Schema\Provider\PhpFileSchemaProvider; use Yiisoft\Yii\View\CsrfViewInjection; return [ diff --git a/blog/resources/views/user/index.php b/blog/resources/views/user/index.php index 133d1e2f..7720e207 100644 --- a/blog/resources/views/user/index.php +++ b/blog/resources/views/user/index.php @@ -132,9 +132,7 @@ ->dataReader($paginator) ->pagination( OffsetPagination::widget() - ->menuClass('pagination justify-content-center') ->paginator($paginator) - ->urlArguments([]) ->render(), ) ->rowAttributes(['class' => 'align-middle']) diff --git a/blog/src/Auth/Controller/AuthController.php b/blog/src/Auth/Controller/AuthController.php index c50787c6..446f81b5 100644 --- a/blog/src/Auth/Controller/AuthController.php +++ b/blog/src/Auth/Controller/AuthController.php @@ -46,7 +46,7 @@ public function login( ) { $identity = $this->authService->getIdentity(); - if ($identity instanceof CookieLoginIdentityInterface && $loginForm->getAttributeValue('rememberMe')) { + if ($identity instanceof CookieLoginIdentityInterface && $loginForm->getPropertyValue('rememberMe')) { return $cookieLogin->addCookie($identity, $this->redirectToMain()); } diff --git a/blog/src/Blog/Archive/ArchiveController.php b/blog/src/Blog/Archive/ArchiveController.php index 080c9ecb..21cbd468 100644 --- a/blog/src/Blog/Archive/ArchiveController.php +++ b/blog/src/Blog/Archive/ArchiveController.php @@ -7,7 +7,7 @@ use App\Blog\Tag\TagRepository; use Psr\Http\Message\ResponseInterface as Response; use Yiisoft\Data\Paginator\OffsetPaginator; -use Yiisoft\Hydrator\Temp\RouteArgument; +use Yiisoft\Router\HydratorAttribute\RouteArgument; use Yiisoft\Yii\View\ViewRenderer; final class ArchiveController diff --git a/blog/src/Blog/BlogController.php b/blog/src/Blog/BlogController.php index 18552ddb..3030aae8 100644 --- a/blog/src/Blog/BlogController.php +++ b/blog/src/Blog/BlogController.php @@ -9,7 +9,7 @@ use App\Blog\Tag\TagRepository; use Psr\Http\Message\ResponseInterface as Response; use Yiisoft\Data\Paginator\OffsetPaginator; -use Yiisoft\Hydrator\Temp\RouteArgument; +use Yiisoft\Router\HydratorAttribute\RouteArgument; use Yiisoft\User\CurrentUser; use Yiisoft\Yii\View\ViewRenderer; diff --git a/blog/src/Blog/CommentController.php b/blog/src/Blog/CommentController.php index 5b218791..c4de61c7 100644 --- a/blog/src/Blog/CommentController.php +++ b/blog/src/Blog/CommentController.php @@ -7,7 +7,7 @@ use App\Blog\Comment\CommentService; use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ServerRequestInterface as Request; -use Yiisoft\Hydrator\Temp\RouteArgument; +use Yiisoft\Router\HydratorAttribute\RouteArgument; use Yiisoft\Yii\View\ViewRenderer; final class CommentController diff --git a/blog/src/User/Controller/UserController.php b/blog/src/User/Controller/UserController.php index 99ec5edc..60b42244 100644 --- a/blog/src/User/Controller/UserController.php +++ b/blog/src/User/Controller/UserController.php @@ -5,18 +5,18 @@ namespace App\User\Controller; use App\User\UserRepository; +use Yiisoft\Data\Paginator\PageToken; use Psr\Http\Message\ResponseFactoryInterface; use Psr\Http\Message\ResponseInterface as Response; use Yiisoft\Data\Paginator\OffsetPaginator; use Yiisoft\Data\Reader\Sort; use Yiisoft\Input\Http\Attribute\Parameter\Body; use Yiisoft\Input\Http\Attribute\Parameter\Query; -use Yiisoft\Hydrator\Temp\RouteArgument; +use Yiisoft\Router\HydratorAttribute\RouteArgument; use Yiisoft\Yii\View\ViewRenderer; final class UserController { - private const PAGINATION_INDEX = 5; public function __construct(private ViewRenderer $viewRenderer) { @@ -40,7 +40,7 @@ public function index( } $paginator = (new OffsetPaginator($dataReader)); - $paginator = $paginator->withNextPageToken((string) $page)->withPageSize($pageSize); + $paginator = $paginator->withToken(PageToken::next((string) $page))->withPageSize($pageSize); return $this->viewRenderer->render('index', ['paginator' => $paginator]); } diff --git a/blog/src/Widget/OffsetPagination.php b/blog/src/Widget/OffsetPagination.php index c820b6d5..cca65297 100644 --- a/blog/src/Widget/OffsetPagination.php +++ b/blog/src/Widget/OffsetPagination.php @@ -37,7 +37,7 @@ public function urlGenerator(Closure $generator): self public function isRequired(): bool { - return $this->paginator !== null && $this->paginator->isRequired(); + return $this->paginator !== null && $this->paginator->isPaginationRequired(); } /** diff --git a/blog/tests/Acceptance/LoginAcceptanceCest.php b/blog/tests/Acceptance/LoginAcceptanceCest.php index 2d2b6642..25436c6b 100644 --- a/blog/tests/Acceptance/LoginAcceptanceCest.php +++ b/blog/tests/Acceptance/LoginAcceptanceCest.php @@ -66,7 +66,7 @@ public function testLoginSubmitFormWrongDataPassword(AcceptanceTester $I): void } /** - * @depends \App\Tests\Acceptance\SignupAcceptanceCest:testRegisterSuccess + * @depends App\Tests\Acceptance\SignupAcceptanceCest:testRegisterSuccess */ public function testLoginUsernameSubmitFormSuccessData(AcceptanceTester $I): void {