mirror of
https://github.com/flarum/framework.git
synced 2025-01-19 18:12:59 +08:00
Add another abstract action base class for dealing with returned views
This commit is contained in:
parent
cff0e96eaa
commit
95677e05e3
24
src/Support/HtmlAction.php
Normal file
24
src/Support/HtmlAction.php
Normal 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 = []);
|
||||
}
|
Loading…
Reference in New Issue
Block a user