Re à tous,
J'ai changer ma facon de pensé :
J'ai fait en sorte qu'un event soit relié a 2 switchBoard. J'ai donc changé mes relation.
Dans mon controller j'ai donc fait ça :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| public function contactBetweenUsersAction($userToExchange)
{
if(!$this->get('security.context')->isGranted('ROLE_USER'))
{
return $this->render('monSiteUserBundle:NotRegister:notRegister.html.twig');
}
else
{
$userManager = $this->get('fos_user.user_manager');
$userCurrent = $this->container->get('security.context')->getToken()->getUser();
$user = $userManager->findUserBy(array('username' => $userCurrent->getUsername()));
$monboard = null;
if($user->getmonBoard() != null)
{
$monboard = $user->getmonBoard();
}
else
{
$monboard = new \monSite\monBoardBundle\Entity\monBoard();
$user->setmonBoard($monboard);
}
$monevent = $this->initmonEvent($monboard);
$monboard->setLastEvent($monevent);
$form = $this->createForm(new \monSite\monBoardBundle\Form\Type\monBoardType(),
$monboard);
$monBoardToExchange = null;
if($userToExchange->getmonBoard() != null)
{
$monBoardToExchange = $userToExchange->getmonBoard();
}
else
{
$monBoardToExchange = new \monSite\monBoardBundle\Entity\monBoard();
$userToExchange->setmonBoard($monBoardToExchange);
}
$userToExchange->setmonBoard($monBoardToExchange);
$monBoardToExchange->addmonEvent($monevent);
$userManager->updateUser($userToExchange);
$userManager->updateUser($user);
$formHandler = new \monSite\monBoardBundle\Form\Handler\monBoardHandler($form,
$this->get('request'),
$userManager,
$user
);
if($formHandler->process())
{
return $this->redirect($this->generateUrl('mon_Site_user_monboard'));
}
return $this->render('monSiteUserBundle:monBoard:contactBetweenUsers.html.twig',
array('form' => $form->createView()));
}
}
private function initmonEvent(\monSite\monBoardBundle\Entity\monBoard $monBoard)
{
$monevent = new \monSite\monBoardBundle\Entity\monEvent();
$status = $this->getDoctrine()->getRepository('monSitemonBoardBundle:monStatus')->findAllStatus();;
$monevent->setStatus($status[0]);
$monevent->setmonBoard($monBoard);
return $monevent;
} |
Dans ma vue :
{% render 'monSiteUserBundle:monBoard:contactBetweenUsers' with { 'userToExchange' : user } %}
et j'ai l'erreur suivante :
Controller "monSite\UserBundle\Controller\monBoardController::contactBetweenUsersAction()" requires that you provide a value for the "$userToExchange" argument (because there is no default value or because there is a non optional argument after this one)
voilà voilà...
Ca me déprime...
Partager