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.

25 lines
625 B

<?php
declare(strict_types=1);
namespace Silex\Controller;
use DateTime;
use Silex\DI\DI;
use Silex\Http\HttpResponse;
use Silex\Model\Comment;
use Silex\Util\Pagination;
class UserController
{
private const PER_PAGE = 12;
public function comment(DI $di, array $params): void
{
$newsId = intval($params['id']);
$news = $di->getNewsGateway()->getById($newsId);
$di->getCommentGateway()->insert(new Comment(-1, $newsId, new DateTime(), $_POST['content'], $di->getSecurity()->getCurrentUserId()));
HttpResponse::redirect($di->getRouter()->url($news->getSlugRedirect()));
}
}