Airship\Engine\Lens::display PHP Method

display() public method

Render a template and print out its contents.
public display ( string $base, array $params = [], string $mime = 'text/html;charset=UTF-8' ) : boolean
$base string Template to render (e.g. 'index' or 'dir/index')
$params array Parameters to pass towards the array
$mime string MIME type header to transmit
return boolean
    public function display(string $base, array $params = [], string $mime = 'text/html;charset=UTF-8') : bool
    {
        if (!\headers_sent()) {
            \ob_start();
            // We need to render this to make sure our CSP headers send!
            echo $this->twigEnv->render($base . '.twig', \array_merge($this->stored, $params));
            $this->sendStandardHeaders($mime);
            \ob_end_flush();
            return true;
        }
        echo $this->twigEnv->render($base . '.twig', \array_merge($this->stored, $params));
        return true;
    }

Usage Example

Example #1
0
 /**
  * Render a template and terminate execution. Do not cache.
  *
  * @param string $name
  * @param mixed[] ...$cArgs Constructor arguments
  * @return void
  * @exit
  */
 protected function lens(string $name, ...$cArgs)
 {
     if (isset($this->airship_lens_override[$name])) {
         $name = $this->airship_lens_override[$name];
     }
     $this->airship_lens_object->display($name, ...$cArgs);
     exit;
 }