本文整理汇总了PHP中OCP\AppFramework\Http\TemplateResponse::renderAs方法的典型用法代码示例。如果您正苦于以下问题:PHP TemplateResponse::renderAs方法的具体用法?PHP TemplateResponse::renderAs怎么用?PHP TemplateResponse::renderAs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCP\AppFramework\Http\TemplateResponse
的用法示例。
在下文中一共展示了TemplateResponse::renderAs方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetRenderAs
public function testGetRenderAs()
{
$render = 'myrender';
$this->tpl->renderAs($render);
$this->assertEquals($render, $this->tpl->getRenderAs());
}
示例2: render
/**
* 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;
}
示例3: afterException
/**
* 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;
}