-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
tests/test_app/TestApp/View/Widget/TestUsingViewWidget.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org) | ||
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org) | ||
* | ||
* Licensed under The MIT License | ||
* Redistributions of files must retain the above copyright notice. | ||
* | ||
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org) | ||
* @link https://cakephp.org CakePHP(tm) Project | ||
* @since 4.0.0 | ||
* @license https://opensource.org/licenses/mit-license.php MIT License | ||
*/ | ||
namespace TestApp\View\Widget; | ||
|
||
use Cake\View\Form\ContextInterface; | ||
use Cake\View\StringTemplate; | ||
use Cake\View\View; | ||
use Cake\View\Widget\WidgetInterface; | ||
|
||
class TestUsingViewWidget implements WidgetInterface | ||
{ | ||
protected $_templates; | ||
|
||
protected $_view; | ||
|
||
public function __construct(StringTemplate $templates, View $view) | ||
{ | ||
$this->_templates = $templates; | ||
$this->_view = $view; | ||
} | ||
|
||
public function getView(): View | ||
{ | ||
return $this->_view; | ||
} | ||
|
||
public function render(array $data, ContextInterface $context): string | ||
{ | ||
return '<success></success>'; | ||
} | ||
|
||
public function secureFields(array $data): array | ||
{ | ||
if (!isset($data['name']) || $data['name'] === '') { | ||
return []; | ||
} | ||
|
||
return [$data['name']]; | ||
} | ||
} |