Ejemplo n.º 1
0
 /**
  * Sets layout template.
  *
  * @param TemplateView|string $template
  * @return $this
  */
 public function setTemplate($template)
 {
     if (is_string($template)) {
         $template = new TemplateView($template);
     }
     $template->mergeData(['layout' => $this]);
     $this->addChild(new Part($template, 'template'));
     return $this;
 }
Ejemplo n.º 2
0
    <?php 
/** @var TemplateView $component */
use Stringy\StaticStringy;
use ViewComponents\ViewComponents\Component\TemplateView;
foreach ($component->getData() as $key => $value) {
    ?>
        <?php 
    if (is_object($value) && !method_exists($value, '__toString')) {
        continue;
    }
    ?>
        <tr>
            <td><?php 
    echo StaticStringy::humanize($key);
    ?>
</td>
            <td><?php 
    if (is_array($value)) {
        $view = new TemplateView($component->getTemplateName(), $value, $component->getRenderer());
        echo $view->render();
    } else {
        echo $value;
    }
    ?>
</td>
        </tr>
    <?php 
}
?>
</table>
 public function __construct($templateName = 'controls/pagination', $linkTemplateName = 'controls/pagination/link', RendererInterface $renderer = null)
 {
     parent::__construct($templateName, [], $renderer);
     $this->linkTemplateName = $linkTemplateName;
 }