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
|
public function standardPageAction(Organizations $organization, $id)
{
$arraypicture = array();
$firstPicture = $this->getDoctrine()->getRepository('AppBundle:Organizations')->getFirstPicture($id);
if (null !== $firstPicture->getFirstPicture()) {
array_push($arraypicture, 'uploads/first_image/'.$firstPicture->getFirstPicture());
} elseif (null !== $organization->getOrgaStructure()) {
if (null !== $organization->getOrgaStructure()->getType()) {
if (null !== $organization->getOrgaStructure()->getType()->getPicture()) {
array_push($arraypicture, 'uploads/etablissement/'.$organization->getOrgaStructure()->getType()->getPicture());
} else {
array_push($arraypicture, 'images/Etablissement.jpeg');
}
} else {
array_push($arraypicture, 'images/Etablissement.jpeg');
}
} else {
array_push($arraypicture, 'images/Etablissement.jpeg');
}
$picture = $this->getDoctrine()->getRepository('AppBundle:Media')->getImageByOrganizations($id);
foreach ($picture as $pictures) {
array_push($arraypicture, 'uploads/image/'.$pictures->getFileName());
}
$user = $this->getUser();
$emuser = $this->getDoctrine()->getRepository('ApplicationSonataUserBundle:User');
$usero = $emuser->getOrganizationsByUser($id);
$comment = new Comment();
$comment->setOrganizationsComment($organization);
$form = $this->createForm('AppBundle\Form\Type\CommentType', $comment);
$formHandler = new Handler\CommentHandler($form, $this->get('request'), $this->get('doctrine.orm.default_entity_manager'));
if ($formHandler->process()) {
return $this->redirectToRoute('structure_page', array('id' => $organization->getId(), 'name' => $organization->getName()));
}
$alertContent = new AlertContent();
$alertForm = $this->createForm('AppBundle\Form\Type\AlertContentType', $alertContent);
$comments = $organization->getComments();
$this->addFlash(
'_target_path',
$this->generateUrl('structure_page', array('id' => $organization->getId(), 'name' => $organization->getName()))
);
return $this->render(':front:organizationPage.html.twig', array(
'form' => $form->createView(),
'pictures' => $arraypicture,
'user' => $user,
'usero' => $usero,
'alertForm' => $alertForm->createView(),
'organization' => $organization,
'comments' => $comments,
));
} |
Partager