public function testGetRenderAs() { $render = 'myrender'; $this->tpl->renderAs($render); $this->assertEquals($render, $this->tpl->getRenderAs()); }
/** * Shortcut for rendering a template * @deprecated 7.0.0 return a template response instead * @param string $templateName the name of the template * @param array $params the template parameters in key => value structure * @param string $renderAs user renders a full page, blank only your template * admin an entry in the admin settings * @param string[] $headers set additional headers in name/value pairs * @return \OCP\AppFramework\Http\TemplateResponse containing the page * @since 6.0.0 */ public function render($templateName, array $params = array(), $renderAs = 'user', array $headers = array()) { $response = new TemplateResponse($this->appName, $templateName); $response->setParams($params); $response->renderAs($renderAs); foreach ($headers as $name => $value) { $response->addHeader($name, $value); } return $response; }
/** * If an AmpacheException is being caught, the appropiate ampache * exception response is rendered * @param Controller $controller the controller that is being called * @param string $methodName the name of the method that will be called on * the controller * @param \Exception $exception the thrown exception * @throws \Exception the passed in exception if it cant handle it * @return Response a Response object or null in case that the exception could not be handled */ public function afterException($controller, $methodName, \Exception $exception) { if ($exception instanceof AmpacheException && $this->isAmpacheCall) { $response = new TemplateResponse($this->appname, 'ampache/error'); $response->renderAs('blank'); $response->addHeader('Content-Type', 'text/xml; charset=UTF-8'); $response->setParams(array('code' => $exception->getCode(), 'message' => $exception->getMessage())); return $response; } throw $exception; }