Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class HomeHandler implements RequestHandlerInterface
- {
- private $template;
- private $dataService;
- public function __construct(
- TemplateTemplateRendererInterface $template = null,
- DataServiceInterface $dataService
- ) {
- $this->template = $template;
- $this->dataService = $dataService;
- }
- public function handle(ServerRequestInterface $request) : ResponseInterface
- {
- $alias = $request->getAttribute('alias', '');
- $item = $this->dataService->getItem($alias);
- if(!isset($item)) {
- // Here you need to throw 404 error
- }
- return new HtmlResponse($this->template->render('app::home-page', $item));
- }
- }
Add Comment
Please, Sign In to add comment