Skip to content
Snippets Groups Projects
Commit 4ef7bbf8 authored by Moreau Elise's avatar Moreau Elise
Browse files

add controller to see group's messages

parent 6b70eebf
No related branches found
No related tags found
No related merge requests found
<?php
declare(strict_types=1);
namespace App\Application\Actions\Message;
use App\Domain\Group\Group ;
use Psr\Http\Message\ResponseInterface as Response;
class GroupMessagesListAction extends MessageAction
{
/**
* {@inheritdoc}
*/
protected function action(): Response
{
$groupId = (int) $this->resolveArg('id');
$group = $this->groupRepository->find($groupId);
if (!isset($_SESSION['userId']) || !$group->hasUser($_SESSION['userId'])){
return $this->response
->withHeader('Location', '/groups/')
->withStatus(302);
}
$transmitter_id = $_SESSION['userId'];
$messages = $this->messageRepository->findBy(array('receiver' => $groupId), array('date' => 'ASC'));
$this->logger->info("Messages list was viewed.");
return $this->twig->render($this->response, "/message/messenger.twig", ["messages" => $messages, "group" => $group, 'session' => $_SESSION]);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment