supports() public method

Returns true if this class is able to render the given template.
public supports ( mixed $name ) : boolean
$name mixed A template name or a TemplateReferenceInterface instance
return boolean true if this class supports the given template, false otherwise
 /**
  * @inheritdoc
  */
 public function setTemplateName($templateName)
 {
     if (null === $this->templatingEngine) {
         throw new TemplatingException('Set template engine first');
     }
     if (!$this->templatingEngine->supports($templateName)) {
         throw new TemplateNotSupportedException(sprintf('Template %s is not supported by templating engine', $templateName));
     }
     $this->templateName = $templateName;
 }
 /**
  * Gets the RequireJS src
  *
  * @return string Returns a string that represents the RequireJS src
  */
 public function src()
 {
     if ($this->engine->exists($this->requireJsSrc) && $this->engine->supports($this->requireJsSrc)) {
         return $this->engine->render($this->requireJsSrc);
     }
     return $this->requireJsSrc;
 }
 /**
  * Gets the RequireJS src
  *
  * @return string Returns a string that represents the RequireJS src
  */
 public function src()
 {
     try {
         if ($this->engine->exists($this->requireJsSrc) && $this->engine->supports($this->requireJsSrc)) {
             return $this->engine->render($this->requireJsSrc);
         }
     } catch (\InvalidArgumentException $err) {
     }
     return $this->requireJsSrc;
 }
Example #4
0
 /**
  * {@inheritdoc}
  */
 public function render($name, array $parameters = [])
 {
     $event = new ViewEvent('render', $name);
     $event->setParameters(array_replace($this->globals, end($this->parameters) ?: [], $parameters));
     $this->events->trigger($event, [$this]);
     if (!$event->isPropagationStopped()) {
         $name = preg_replace('/\\.php$/i', '', $name);
         $this->events->trigger($event->setName($name), [$this]);
     }
     $result = $event->getResult();
     $params = $this->parameters[] = $event->getParameters();
     if ($result === null && $this->engine->supports($event->getTemplate())) {
         $result = $this->engine->render($event->getTemplate(), array_replace(['params' => new ArrObject($params)], $params));
     }
     array_pop($this->parameters);
     return $result;
 }
Example #5
0
 public function supports($name)
 {
     return $this->engine->supports($name);
 }