Factory method for chainability
public static create ( Twig_Template $template = null, array $context = [], array $globals = [], integer $status = 200, array $headers = [] ) : |
||
$template | Twig_Template | An object that is able to render a template with context |
$context | array | An array of context variables |
$globals | array | An array of global context variables |
$status | integer | The response status code |
$headers | array | An array of response headers |
return |
/** * Render a template, possibly store it in cache. Or, if applicable, return the cached result. * * @param string $template the template name * @param array $vars array of context variables * @param array $globals array of global variables * * @return mixed */ public function render($template, $vars = array(), $globals = array()) { // Start the 'stopwatch' for the profiler. $this->app['stopwatch']->start('bolt.render', 'template'); $response = BoltResponse::create($this->app[$this->twigKey]->loadTemplate($template), $vars, $globals); // Stop the 'stopwatch' for the profiler. $this->app['stopwatch']->stop('bolt.render'); return $response; }
/** * Render a template, possibly store it in cache. Or, if applicable, return the cached result. * * @param string $template the template name * @param array $vars array of context variables * @param array $globals array of global variables * * @return \Bolt\Response\BoltResponse */ public function render($template, $vars = [], $globals = []) { $response = BoltResponse::create($this->app[$this->twigKey]->loadTemplate($template), $vars, $globals); $response->setStopwatch($this->app['stopwatch']); return $response; }
public function testGetTemplateName() { $app = $this->getApp(); $response = BoltResponse::create($app['twig']->loadTemplate('error.twig'), []); $this->assertEquals('error.twig', $response->getTemplateName()); }