Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
100.00% |
1 / 1 |
|
100.00% |
7 / 7 |
CRAP | |
100.00% |
11 / 11 |
| MetaBoxTwigView | |
100.00% |
1 / 1 |
|
100.00% |
7 / 7 |
7 | |
100.00% |
11 / 11 |
| render | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
| getTemplate | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
| setTemplate | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
| getContext | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
| setContext | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
| getTwigEnvironment | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
| setTwigEnvironment | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
| <?php | |
| declare(strict_types=1); | |
| namespace Korobochkin\WPKit\MetaBoxes; | |
| use Twig\Environment; | |
| /** | |
| * Class TwigMetaBoxView | |
| */ | |
| class MetaBoxTwigView implements MetaBoxTwigViewInterface | |
| { | |
| /** | |
| * @var string Twig template (path). | |
| */ | |
| protected $template = ''; | |
| /** | |
| * @var string[] Array with variables. | |
| */ | |
| protected $context = array(); | |
| /** | |
| * @var Environment Twig. | |
| */ | |
| protected $twigEnvironment; | |
| /** | |
| * @inheritdoc | |
| */ | |
| public function render(MetaBoxInterface $metaBox) | |
| { | |
| echo $this->getTwigEnvironment()->render($this->getTemplate(), $this->getContext()); | |
| } | |
| /** | |
| * @inheritdoc | |
| */ | |
| public function getTemplate() | |
| { | |
| return $this->template; | |
| } | |
| /** | |
| * @inheritdoc | |
| */ | |
| public function setTemplate($template) | |
| { | |
| $this->template = $template; | |
| return $this; | |
| } | |
| /** | |
| * @inheritdoc | |
| */ | |
| public function getContext() | |
| { | |
| return $this->context; | |
| } | |
| /** | |
| * @inheritdoc | |
| */ | |
| public function setContext(array $context) | |
| { | |
| $this->context = $context; | |
| return $this; | |
| } | |
| /** | |
| * @inheritdoc | |
| */ | |
| public function getTwigEnvironment() | |
| { | |
| return $this->twigEnvironment; | |
| } | |
| /** | |
| * @inheritdoc | |
| */ | |
| public function setTwigEnvironment(Environment $twigEnvironment) | |
| { | |
| $this->twigEnvironment = $twigEnvironment; | |
| return $this; | |
| } | |
| } |