Skip to content

Commit

Permalink
Adopt to new yiisoft/view and yiisoft/yii-view (#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
vjik committed Sep 18, 2021
1 parent 6c92e04 commit cb52b78
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 15 deletions.
4 changes: 2 additions & 2 deletions composer.json
Expand Up @@ -42,12 +42,12 @@
"yiisoft/log-target-file": "^1.0",
"yiisoft/router": "@dev",
"yiisoft/router-fastroute": "@dev",
"yiisoft/view": "^2.0",
"yiisoft/view": "^3.0",
"yiisoft/yii-bulma": "@dev",
"yiisoft/yii-console": "3.0.x-dev",
"yiisoft/yii-debug": "^3.0@dev",
"yiisoft/yii-event": "^1.0",
"yiisoft/yii-view": "^2.0",
"yiisoft/yii-view": "^3.0",
"yiisoft/yii-web": "^3.0@dev"
},
"require-dev": {
Expand Down
4 changes: 2 additions & 2 deletions config/params.php
Expand Up @@ -3,7 +3,7 @@
declare(strict_types=1);

use App\Command\Hello;
use App\ViewInjection\ContentViewInjection;
use App\ViewInjection\CommonViewInjection;
use App\ViewInjection\LayoutViewInjection;
use Yiisoft\Definitions\Reference;
use Yiisoft\Yii\View\CsrfViewInjection;
Expand Down Expand Up @@ -34,7 +34,7 @@

'yiisoft/yii-view' => [
'injections' => [
Reference::to(ContentViewInjection::class),
Reference::to(CommonViewInjection::class),
Reference::to(CsrfViewInjection::class),
Reference::to(LayoutViewInjection::class),
],
Expand Down
7 changes: 4 additions & 3 deletions resources/views/site/index.php
Expand Up @@ -2,9 +2,10 @@

declare(strict_types=1);

/** @var App\ApplicationParameters $applicationParameters */

$this->params['breadcrumbs'] = '/';
/**
* @var \Yiisoft\View\WebView $this
* @var \App\ApplicationParameters $applicationParameters
*/

$this->setTitle($applicationParameters->getName());
?>
Expand Down
Expand Up @@ -5,9 +5,9 @@
namespace App\ViewInjection;

use App\ApplicationParameters;
use Yiisoft\Yii\View\ContentParametersInjectionInterface;
use Yiisoft\Yii\View\CommonParametersInjectionInterface;

final class ContentViewInjection implements ContentParametersInjectionInterface
final class CommonViewInjection implements CommonParametersInjectionInterface
{
private ApplicationParameters $applicationParameters;

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

public function getContentParameters(): array
public function getCommonParameters(): array
{
return [
'applicationParameters' => $this->applicationParameters,
Expand Down
5 changes: 0 additions & 5 deletions src/ViewInjection/LayoutViewInjection.php
Expand Up @@ -4,7 +4,6 @@

namespace App\ViewInjection;

use App\ApplicationParameters;
use Yiisoft\Assets\AssetManager;
use Yiisoft\I18n\Locale;
use Yiisoft\Router\UrlGeneratorInterface;
Expand All @@ -13,20 +12,17 @@

final class LayoutViewInjection implements LayoutParametersInjectionInterface
{
private ApplicationParameters $applicationParameters;
private AssetManager $assetManager;
private Locale $locale;
private UrlGeneratorInterface $urlGenerator;
private CurrentRoute $currentRoute;

public function __construct(
ApplicationParameters $applicationParameters,
AssetManager $assetManager,
Locale $locale,
UrlGeneratorInterface $urlGenerator,
CurrentRoute $currentRoute
) {
$this->applicationParameters = $applicationParameters;
$this->assetManager = $assetManager;
$this->locale = $locale;
$this->urlGenerator = $urlGenerator;
Expand All @@ -36,7 +32,6 @@ public function __construct(
public function getLayoutParameters(): array
{
return [
'applicationParameters' => $this->applicationParameters,
'assetManager' => $this->assetManager,
'locale' => $this->locale,
'urlGenerator' => $this->urlGenerator,
Expand Down

0 comments on commit cb52b78

Please sign in to comment.