for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace League\Plates\HydrateTemplate;
use League\Plates;
/** takes an array of hydrate templates and chains them together */
class ChainHydrateTemplate implements Plates\HydrateTemplate
{
private $hydrate_templates;
public function __construct(array $hydrate_templates) {
$this->hydrate_templates = $hydrate_templates;
}
public function hydrateTemplate(Plates\Template $template) {
foreach ($this->hydrate_templates as $ht) {
$ht->hydrateTemplate($template);
/** This constructor will map any callables into CallableHydrateTemplate */
public static function create(array $hydrate_templates) {
return new self(array_map(function($ht) {
if ($ht instanceof Plates\HydrateTemplate) {
return $ht;
if (is_callable($ht)) {
return new CallableHydrateTemplate($ht);
throw new Plates\Exception\HydrateTemplateException('Expected instance of HydrateTemplate, got ' . Plates\Util\debugType($ht));
}, $hydrate_templates));