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

redirection when groupname is already used

parent 799e6ba0
No related branches found
No related tags found
No related merge requests found
...@@ -15,6 +15,7 @@ use Doctrine\Common\Cache\FilesystemCache; ...@@ -15,6 +15,7 @@ use Doctrine\Common\Cache\FilesystemCache;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Mapping\Driver\AnnotationDriver; use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
use Doctrine\ORM\Tools\Setup; use Doctrine\ORM\Tools\Setup;
use Slim\Views\Twig; use Slim\Views\Twig;
use Slim\Flash\Messages; use Slim\Flash\Messages;
......
...@@ -20,9 +20,17 @@ class CreateGroupAction extends GroupAction ...@@ -20,9 +20,17 @@ class CreateGroupAction extends GroupAction
$groupname = $parsedRequestBody['name']; $groupname = $parsedRequestBody['name'];
$description = $parsedRequestBody['description']; $description = $parsedRequestBody['description'];
$group = new Group(null, $groupname, $description); if ($this->groupRepository->findOneBy(array('name' => $groupname))){
$userRepository->find($_SESSION['userId'])->addGroup($group); return $this->twig->render(
$userRepository->find($_SESSION['userId'])->addGroupAdmin($group); $this->response, "/group/create_group.twig",
array(
"name" => $groupname,
"description" => $description,
"message" => "Groupname already exist",
"formstatus" => "error"
)
);
}
$this->em->persist($group); $this->em->persist($group);
$this->em->flush(); $this->em->flush();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment