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