Skip to content

Commit

Permalink
Adapt to router changes (#417)
Browse files Browse the repository at this point in the history
  • Loading branch information
rustamwin committed Dec 24, 2021
1 parent 0dea584 commit b39ed1b
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 23 deletions.
4 changes: 2 additions & 2 deletions config/params.php
Expand Up @@ -11,7 +11,7 @@
use Yiisoft\Cookies\CookieMiddleware;
use Yiisoft\Definitions\Reference;
use Yiisoft\ErrorHandler\Middleware\ErrorCatcher;
use Yiisoft\Router\CurrentRouteInterface;
use Yiisoft\Router\CurrentRoute;
use Yiisoft\Router\Middleware\Router;
use Yiisoft\Router\UrlGeneratorInterface;
use Yiisoft\Session\SessionMiddleware;
Expand Down Expand Up @@ -85,7 +85,7 @@
'parameters' => [
'assetManager' => Reference::to(AssetManager::class),
'urlGenerator' => Reference::to(UrlGeneratorInterface::class),
'currentRoute' => Reference::to(CurrentRouteInterface::class),
'currentRoute' => Reference::to(CurrentRoute::class),
'translator' => Reference::to(TranslatorInterface::class),
],
],
Expand Down
6 changes: 3 additions & 3 deletions src/Blog/Archive/ArchiveController.php
Expand Up @@ -7,7 +7,7 @@
use App\Blog\Tag\TagRepository;
use Psr\Http\Message\ResponseInterface as Response;
use Yiisoft\Data\Paginator\OffsetPaginator;
use Yiisoft\Router\CurrentRouteInterface;
use Yiisoft\Router\CurrentRoute;
use Yiisoft\Yii\View\ViewRenderer;

final class ArchiveController
Expand All @@ -26,7 +26,7 @@ public function index(ArchiveRepository $archiveRepo): Response
return $this->viewRenderer->render('index', ['archive' => $archiveRepo->getFullArchive()]);
}

public function monthlyArchive(CurrentRouteInterface $currentRoute, TagRepository $tagRepository, ArchiveRepository $archiveRepo): Response
public function monthlyArchive(CurrentRoute $currentRoute, TagRepository $tagRepository, ArchiveRepository $archiveRepo): Response
{
$pageNum = (int)$currentRoute->getArgument('page', '1');
$year = (int)$currentRoute->getArgument('year', '0');
Expand All @@ -47,7 +47,7 @@ public function monthlyArchive(CurrentRouteInterface $currentRoute, TagRepositor
return $this->viewRenderer->render('monthly-archive', $data);
}

public function yearlyArchive(CurrentRouteInterface $currentRoute, ArchiveRepository $archiveRepo): Response
public function yearlyArchive(CurrentRoute $currentRoute, ArchiveRepository $archiveRepo): Response
{
$year = (int)$currentRoute->getArgument('year', '0');

Expand Down
4 changes: 2 additions & 2 deletions src/Blog/BlogController.php
Expand Up @@ -9,7 +9,7 @@
use App\Blog\Tag\TagRepository;
use Psr\Http\Message\ResponseInterface as Response;
use Yiisoft\Data\Paginator\OffsetPaginator;
use Yiisoft\Router\CurrentRouteInterface;
use Yiisoft\Router\CurrentRoute;
use Yiisoft\User\CurrentUser;
use Yiisoft\Yii\View\ViewRenderer;

Expand All @@ -31,7 +31,7 @@ public function index(
TagRepository $tagRepository,
ArchiveRepository $archiveRepo,
CurrentUser $currentUser,
CurrentRouteInterface $currentRoute
CurrentRoute $currentRoute
): Response {
$pageNum = (int)$currentRoute->getArgument('page', '1');
$dataReader = $postRepository->findAllPreloaded();
Expand Down
4 changes: 2 additions & 2 deletions src/Blog/CommentController.php
Expand Up @@ -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\Router\CurrentRouteInterface;
use Yiisoft\Router\CurrentRoute;
use Yiisoft\Yii\View\ViewRenderer;

final class CommentController
Expand All @@ -19,7 +19,7 @@ public function __construct(ViewRenderer $viewRenderer)
$this->viewRenderer = $viewRenderer->withControllerName('blog/comments');
}

public function index(Request $request, CommentService $service, CurrentRouteInterface $currentRoute): Response
public function index(Request $request, CommentService $service, CurrentRoute $currentRoute): Response
{
$paginator = $service->getFeedPaginator();
if ($currentRoute->getArgument('next') !== null) {
Expand Down
6 changes: 3 additions & 3 deletions src/Blog/Post/PostController.php
Expand Up @@ -10,7 +10,7 @@
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Yiisoft\Http\Method;
use Yiisoft\Router\CurrentRouteInterface;
use Yiisoft\Router\CurrentRoute;
use Yiisoft\Validator\ValidatorInterface;
use Yiisoft\Yii\View\ViewRenderer;

Expand All @@ -33,7 +33,7 @@ public function __construct(
$this->userService = $userService;
}

public function index(CurrentRouteInterface $currentRoute, PostRepository $postRepository): Response
public function index(CurrentRoute $currentRoute, PostRepository $postRepository): Response
{
$canEdit = $this->userService->hasPermission('editPost');
$slug = $currentRoute->getArgument('slug');
Expand Down Expand Up @@ -71,7 +71,7 @@ public function edit(
Request $request,
PostRepository $postRepository,
ValidatorInterface $validator,
CurrentRouteInterface $currentRoute
CurrentRoute $currentRoute
): Response {
$slug = $currentRoute->getArgument('slug');
$post = $postRepository->fullPostPage($slug);
Expand Down
4 changes: 2 additions & 2 deletions src/Blog/Tag/TagController.php
Expand Up @@ -8,7 +8,7 @@
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface as Response;
use Yiisoft\Data\Paginator\OffsetPaginator;
use Yiisoft\Router\CurrentRouteInterface;
use Yiisoft\Router\CurrentRoute;
use Yiisoft\Yii\View\ViewRenderer;

final class TagController
Expand All @@ -21,7 +21,7 @@ public function __construct(ViewRenderer $viewRenderer)
$this->viewRenderer = $viewRenderer->withControllerName('blog/tag');
}

public function index(CurrentRouteInterface $currentRoute, TagRepository $tagRepository, PostRepository $postRepository, ResponseFactoryInterface $responseFactory): Response
public function index(CurrentRoute $currentRoute, TagRepository $tagRepository, PostRepository $postRepository, ResponseFactoryInterface $responseFactory): Response
{
$label = $currentRoute->getArgument('label');
$pageNum = (int) $currentRoute->getArgument('page', '1');
Expand Down
4 changes: 2 additions & 2 deletions src/User/Controller/ApiUserController.php
Expand Up @@ -9,7 +9,7 @@
use Psr\Http\Message\ResponseInterface;
use Yiisoft\Data\Reader\Sort;
use Yiisoft\DataResponse\DataResponseFactoryInterface;
use Yiisoft\Router\CurrentRouteInterface;
use Yiisoft\Router\CurrentRoute;

final class ApiUserController
{
Expand All @@ -33,7 +33,7 @@ public function index(UserRepository $userRepository): ResponseInterface
return $this->responseFactory->createResponse($items);
}

public function profile(UserRepository $userRepository, CurrentRouteInterface $currentRoute): ResponseInterface
public function profile(UserRepository $userRepository, CurrentRoute $currentRoute): ResponseInterface
{
$login = $currentRoute->getArgument('login');

Expand Down
6 changes: 3 additions & 3 deletions src/User/Controller/UserController.php
Expand Up @@ -9,7 +9,7 @@
use Psr\Http\Message\ResponseInterface as Response;
use Yiisoft\Data\Paginator\OffsetPaginator;
use Yiisoft\Data\Reader\Sort;
use Yiisoft\Router\CurrentRouteInterface;
use Yiisoft\Router\CurrentRoute;
use Yiisoft\Yii\View\ViewRenderer;

final class UserController
Expand All @@ -23,7 +23,7 @@ public function __construct(ViewRenderer $viewRenderer)
$this->viewRenderer = $viewRenderer->withControllerName('user');
}

public function index(UserRepository $userRepository, CurrentRouteInterface $currentRoute): Response
public function index(UserRepository $userRepository, CurrentRoute $currentRoute): Response
{
$pageNum = (int)$currentRoute->getArgument('page', '1');

Expand All @@ -35,7 +35,7 @@ public function index(UserRepository $userRepository, CurrentRouteInterface $cur
return $this->viewRenderer->render('index', ['paginator' => $paginator]);
}

public function profile(CurrentRouteInterface $currentRoute, UserRepository $userRepository, ResponseFactoryInterface $responseFactory): Response
public function profile(CurrentRoute $currentRoute, UserRepository $userRepository, ResponseFactoryInterface $responseFactory): Response
{
$login = $currentRoute->getArgument('login');
$item = $userRepository->findByLogin($login);
Expand Down
5 changes: 2 additions & 3 deletions views/layout/main.php
Expand Up @@ -4,7 +4,6 @@

use App\Asset\AppAsset;
use App\Widget\PerformanceMetrics;
use App\Widget\LanguageSelector;
use Yiisoft\Form\Widget\Field;
use Yiisoft\Form\Widget\Form;
use Yiisoft\Html\Html;
Expand All @@ -14,7 +13,7 @@

/**
* @var \Yiisoft\Router\UrlGeneratorInterface $urlGenerator
* @var \Yiisoft\Router\CurrentRouteInterface $currentRoute
* @var \Yiisoft\Router\CurrentRoute $currentRoute
* @var \Yiisoft\View\WebView $this
* @var \Yiisoft\Assets\AssetManager $assetManager
* @var \Yiisoft\Translator\TranslatorInterface $translator
Expand All @@ -34,7 +33,7 @@
$this->addJsStrings($assetManager->getJsStrings());
$this->addJsVars($assetManager->getJsVars());

$currentRouteName = $currentRoute->getRoute() === null ? '' : $currentRoute->getRoute()->getName();
$currentRouteName = $currentRoute->getName() ?? '';

$this->beginPage();
?>
Expand Down
2 changes: 1 addition & 1 deletion views/site/404.php
Expand Up @@ -7,7 +7,7 @@
/**
* @var \Yiisoft\Translator\TranslatorInterface $translator
* @var \Yiisoft\Router\UrlGeneratorInterface $urlGenerator
* @var \Yiisoft\Router\CurrentRouteInterface $currentRoute
* @var \Yiisoft\Router\CurrentRoute $currentRoute
* @var \Yiisoft\View\WebView $this
*/

Expand Down

0 comments on commit b39ed1b

Please sign in to comment.