|
@@ 177-187 (lines=11) @@
|
| 174 |
|
* @ParamConverter("estate", class="AppBundle\Entity\Estate", options={"mapping": {"estate": "slug"}}) |
| 175 |
|
* @ParamConverter("user", class="AppBundle\Entity\User", options={"mapping": {"user": "id"}}) |
| 176 |
|
*/ |
| 177 |
|
public function addEstateToFavoritesAction(Estate $estate, User $user, Request $request) |
| 178 |
|
{ |
| 179 |
|
$em = $this->getDoctrine()->getManager(); |
| 180 |
|
if (!$user->hasEstate($estate)) { |
| 181 |
|
$user->addEstate($estate); |
| 182 |
|
$em->persist($user); |
| 183 |
|
$em->flush(); |
| 184 |
|
} |
| 185 |
|
|
| 186 |
|
return $this->redirectToRoute('show_estate', array('slug' => $estate->getSlug())); |
| 187 |
|
} |
| 188 |
|
|
| 189 |
|
/** |
| 190 |
|
* @Route("/delete_favorites/{estate}/{user}", name = "delete_estate_from_favorites") |
|
@@ 194-204 (lines=11) @@
|
| 191 |
|
* @ParamConverter("estate", class="AppBundle\Entity\Estate", options={"mapping": {"estate": "slug"}}) |
| 192 |
|
* @ParamConverter("user", class="AppBundle\Entity\User", options={"mapping": {"user": "id"}}) |
| 193 |
|
*/ |
| 194 |
|
public function deleteEstateFromFavoritesAction(Estate $estate, User $user, Request $request) |
| 195 |
|
{ |
| 196 |
|
$em = $this->getDoctrine()->getManager(); |
| 197 |
|
if ($user->hasEstate($estate)) { |
| 198 |
|
$user->removeEstate($estate); |
| 199 |
|
$em->persist($user); |
| 200 |
|
$em->flush(); |
| 201 |
|
} |
| 202 |
|
|
| 203 |
|
return $this->redirectToRoute('show_estate', array('slug' => $estate->getSlug())); |
| 204 |
|
} |
| 205 |
|
|
| 206 |
|
/** |
| 207 |
|
* @Route("/pdf/{estate}", name = "pdf_estate") |