You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
842 B
32 lines
842 B
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Silex\Controller;
|
|
|
|
use Silex\DI\DI;
|
|
use Silex\Http\HttpResponse;
|
|
|
|
class UserController
|
|
{
|
|
public function index(DI $di): HttpResponse
|
|
{
|
|
$news = $di->getNewsGateway()->getPaginatedRecentNews();
|
|
return new HttpResponse(200, 'home', ['news' => $news]);
|
|
}
|
|
|
|
public function viewPost(DI $di, array $params): HttpResponse
|
|
{
|
|
$newsId = intval($params['id']);
|
|
$news = $di->getNewsGateway()->getById($newsId);
|
|
return new HttpResponse(200, 'newsView', ['news' => $news]);
|
|
}
|
|
|
|
public function viewPostComments(DI $di, array $params): HttpResponse
|
|
{
|
|
$newsId = intval($params['id']);
|
|
$comments = $di->getCommentGateway()->getByNewsId($newsId);
|
|
return new HttpResponse(200, 'comment', ['comments' => $comments]);
|
|
}
|
|
}
|