Add another abstract action base class for dealing with returned views

This commit is contained in:
Franz Liedke 2015-05-27 03:01:09 +02:00
parent cff0e96eaa
commit 95677e05e3

View File

@ -0,0 +1,24 @@
<?php namespace Flarum\Support;
use Illuminate\Contracts\Bus\Dispatcher;
use Psr\Http\Message\ServerRequestInterface as Request;
use Zend\Diactoros\Response;
abstract class HtmlAction extends Action
{
public function handle(Request $request, $routeParams = [])
{
$view = $this->render($request, $routeParams);
$response = new Response();
$response->getBody()->write($view->render());
return $response;
}
/**
* @param Request $request
* @param array $routeParams
* @return \Illuminate\Contracts\View\View
*/
abstract protected function render(Request $request, $routeParams = []);
}