|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
-
- namespace Lc\CaracoleBundle\Controller\Merchant;
-
- use Doctrine\ORM\EntityManagerInterface;
- use Lc\CaracoleBundle\Container\Merchant\MerchantContainer;
- use Lc\CaracoleBundle\Controller\AbstractController;
- use Lc\CaracoleBundle\Definition\MerchantSettingDefinition;
- use Lc\CaracoleBundle\Form\Merchant\SwitchMerchantFormType;
- use Symfony\Component\HttpFoundation\Request;
- use Symfony\Component\Security\Core\Security;
- use Symfony\Component\Routing\Annotation\Route;
-
- class FavoriteMerchantController extends AbstractController
- {
- /**
- * @Route("/merchant/favorite", name="carac_merchant_favorite")
- */
- public function favoriteMerchant(Request $request, Security $security, EntityManagerInterface $entityManager)
- {
- $form = $this->createForm(SwitchMerchantFormType::class);
- $form->handleRequest($request);
-
- if ($form->isSubmitted() && $form->isValid()) {
- $merchant = $form->get('merchant')->getData();
-
- if ($merchant) {
-
- $user = $security->getUser();
- if($user) {
- $user->setFavoriteMerchant($merchant);
- $entityManager->update($user);
- $entityManager->flush();
- }
-
- // @TODO : à fignoler, hein gamin ?
- $url = $this->getSettingSolver()->getSettingValue(
- $merchant,
- MerchantSettingDefinition::SETTING_URL
- ) . 'admin';
-
- if ($url) {
- return $this->redirect($url);
- }
- }
- }
- }
- }
|