Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\CommonModule\Components;
- use Nette,
- App;
- /**
- * @author Martin Konečný
- */
- class AjaxTemplate extends BaseControl
- {
- /** @var string */
- private $templateName;
- /** @var array */
- private $templateParams;
- /**
- * @param string
- * @param array
- */
- public function __construct($templateName, $templateParams = array())
- {
- parent::__construct();
- $this->templateName = $templateName;
- $this->templateParams = (array) $templateParams;
- }
- /**
- * @param string
- * @param array
- */
- public static function create($templateName, $templateParams = array())
- {
- $self = new self($templateName, $templateParams);
- return $self->getHtml();
- }
- /**
- * @return string
- */
- public function getHtml()
- {
- $this->template->setParameters($this->templateParams);
- $this->template->setFile(__DIR__ . "/templates/{$this->templateName}.latte");
- $result = (string) $this->template;
- return $result;
- }
- /**
- * @param string
- * @param callable
- */
- public function addFilter($name, $callable)
- {
- $this->template->addFilter($name, $callable);
- }
- /**
- * @return string
- */
- public function __toString()
- {
- return $this->getHtml();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement