Source of file ViewableDataProcessor.php
Size: 1,086 Bytes - Last Modified: 2021-12-24T06:50:57+00:00
/var/www/docs.ssmods.com/process/src/src/Processors/ViewableDataProcessor.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 | <?php namespace Heyday\CacheInclude\Processors; use InvalidArgumentException; use SilverStripe\View\ViewableData; class ViewableDataProcessor implements ProcessorInterface { /** * @var ViewableData */ protected $context; /** * @param ViewableData $context * @return $this */ public function setContext(ViewableData $context) { $this->context = $context; return $this; } /** * @param $name * @return string * @throws \InvalidArgumentException */ public function __invoke($name) { if (!$this->context instanceof ViewableData) { throw new InvalidArgumentException('Context must be instance of ViewableData'); } if ($this->context->hasMethod($name)) { $result = $this->context->$name(); if ($result instanceof ViewableData && method_exists($result, 'forTemplate')) { return $result->forTemplate(); } return $result; } return $this->context->renderWith($name); } } |