Skip to content

Commit

Permalink
Additional review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
lonnieezell committed Jan 14, 2022
1 parent 2657ce8 commit dc36185
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 16 deletions.
4 changes: 2 additions & 2 deletions app/Config/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ class View extends BaseView
* have a chance to alter the generated output just prior to caching
* the results.
*
* All classes must implement CodeIgniter\View\ViewDecorator
* All classes must implement CodeIgniter\View\ViewDecoratorInterface
*
* @var array
* @var class-string<\CodeIgniter\View\ViewDecoratorInterface>[]
*/
public $decorators = [];
}
4 changes: 2 additions & 2 deletions system/Config/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ class View extends BaseConfig
* have a chance to alter the generated output just prior to caching
* the results.
*
* All classes must implement CodeIgniter\View\ViewDecorator
* All classes must implement CodeIgniter\View\ViewDecoratorInterface
*
* @var array
* @var class-string<\CodeIgniter\View\ViewDecoratorInterface>[]
*/
public $decorators = [];

Expand Down
2 changes: 1 addition & 1 deletion system/Language/en/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
'noCellClass' => 'No view cell class provided.',
'invalidCellClass' => 'Unable to locate view cell class: {0}.',
'tagSyntaxError' => 'You have a syntax error in your Parser tags: {0}',
'invalidDecoratorClass' => '{0} is not a valid ViewDecorator.',
'invalidDecoratorClass' => '{0} is not a valid View Decorator.',
];
11 changes: 10 additions & 1 deletion system/View/ViewDecoratorTrait.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/**
* This file is part of CodeIgniter 4 framework.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/

namespace CodeIgniter\View;

use CodeIgniter\View\Exceptions\ViewException;
Expand All @@ -12,7 +21,7 @@ trait ViewDecoratorTrait
* Runs the generated output through and declared
* view decorators.
*/
private function decorateOutput(string $html): string
protected function decorateOutput(string $html): string
{
$decorators = config('View')->decorators;

Expand Down
4 changes: 1 addition & 3 deletions tests/_support/View/WorldDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ class WorldDecorator implements ViewDecoratorInterface
{
public static function decorate(string $html): string
{
$html = str_ireplace('World', 'Galaxy', $html);

return $html;
return str_ireplace('World', 'Galaxy', $html);
}
}
10 changes: 5 additions & 5 deletions tests/system/View/DecoratorsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function setUp(): void

public function testNoDecoratorsDoesntAlter()
{
$config = $this->config;
$config = $this->config;
$config->decorators = [];
Factories::injectMock('config', 'View', $config);

Expand All @@ -55,7 +55,7 @@ public function testThrowsOnInvalidClass()
$this->expectException(ViewException::class);
$this->expectExceptionMessage(lang('View.invalidDecoratorClass', ['Tests\Support\View\BadDecorator']));

$config = $this->config;
$config = $this->config;
$config->decorators = [BadDecorator::class];
Factories::injectMock('config', 'View', $config);

Expand All @@ -69,7 +69,7 @@ public function testThrowsOnInvalidClass()

public function testDecoratorAltersOutput()
{
$config = $this->config;
$config = $this->config;
$config->decorators = [WorldDecorator::class];
Factories::injectMock('config', 'View', $config);

Expand All @@ -83,7 +83,7 @@ public function testDecoratorAltersOutput()

public function testParserNoDecoratorsDoesntAlter()
{
$config = $this->config;
$config = $this->config;
$config->decorators = [];
Factories::injectMock('config', 'View', $config);

Expand All @@ -95,7 +95,7 @@ public function testParserNoDecoratorsDoesntAlter()

public function testParserDecoratorAltersOutput()
{
$config = $this->config;
$config = $this->config;
$config->decorators = [WorldDecorator::class];
Factories::injectMock('config', 'View', $config);

Expand Down
4 changes: 2 additions & 2 deletions user_guide_src/source/outgoing/view_decorators.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ the resulting HTML.

namespace App\Views\Decorators;

use CodeIgniter\Views\Interfaces\ViewDecorator;
use CodeIgniter\Views\ViewDecoratorInterface;

class MyDecorator implements ViewDecorator
class MyDecorator implements ViewDecoratorInterface
{
public static function decorate(string $html): string
{
Expand Down

0 comments on commit dc36185

Please sign in to comment.