Skip to content

Commit

Permalink
SvgViewInjection
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-42 committed Dec 30, 2020
1 parent 5221aa2 commit 9c3395b
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
4 changes: 3 additions & 1 deletion composer.json
Expand Up @@ -31,10 +31,12 @@
"ext-dom": "*",
"yiisoft/aliases": "^1.1.0",
"yiisoft/composer-config-plugin": "^1.0",
"yiisoft/html": "^3.0"
"yiisoft/html": "^3.0",
"yiisoft/yii-view": "^3.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.0",
"httpsoft/http-message": "^1.0",
"phpmd/phpmd": "@stable",
"phpunit/phpunit": "^9.0",
"squizlabs/php_codesniffer": "^3.5",
Expand Down
8 changes: 4 additions & 4 deletions config/params.php
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

use YiiRocks\SvgInline\SvgInlineInterface;
use YiiRocks\SvgInline\SvgViewInjection;
use Yiisoft\Factory\Definitions\Reference;

return [
Expand All @@ -11,9 +11,9 @@
'fill' => 'currentColor',
],

'yiisoft/view' => [
'defaultParameters' => [
'svg' => Reference::to(SvgInlineInterface::class),
'yiisoft/yii-view' => [
'injections' => [
Reference::to(SvgViewInjection::class),
],
],
];
33 changes: 33 additions & 0 deletions src/SvgViewInjection.php
@@ -0,0 +1,33 @@
<?php

declare(strict_types=1);

namespace YiiRocks\SvgInline;

use Yiisoft\Yii\View\ContentParametersInjectionInterface;
use Yiisoft\Yii\View\LayoutParametersInjectionInterface;

final class SvgViewInjection implements ContentParametersInjectionInterface, LayoutParametersInjectionInterface
{
private SvgInlineInterface $svg;

public function __construct(
SvgInlineInterface $svg
) {
$this->svg = $svg;
}

public function getContentParameters(): array
{
return [
'svg' => $this->svg,
];
}

public function getLayoutParameters(): array
{
return [
'svg' => $this->svg,
];
}
}

0 comments on commit 9c3395b

Please sign in to comment.