Kaynağa Gözat

Correctif switch merchant

packProduct
Fabien Normand 3 yıl önce
ebeveyn
işleme
1468096b5e
2 değiştirilmiş dosya ile 49 ekleme ve 1 silme
  1. +48
    -0
      Controller/Merchant/FavoriteMerchantAdminController.php
  2. +1
    -1
      Resources/views/admin/merchant/modal/switch_merchant.html.twig

+ 48
- 0
Controller/Merchant/FavoriteMerchantAdminController.php Dosyayı Görüntüle

@@ -0,0 +1,48 @@
<?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 FavoriteMerchantAdminController extends AbstractController
{
/**
* @Route("/admin/merchant/favorite", name="carac_merchant_favorite_admin")
*/
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);
}
}
}
}
}

+ 1
- 1
Resources/views/admin/merchant/modal/switch_merchant.html.twig Dosyayı Görüntüle

@@ -15,7 +15,7 @@
comme marchand favoris ou simplement indiquer que vous visitez ce marchand pour aujourd'hui.</p>
{% endblock %}
{% block footer %}
{% set form_switch_merchant = carac_form_switch_merchant('admin', 'carac_merchant_favorite') %}
{% set form_switch_merchant = carac_form_switch_merchant('admin', 'carac_merchant_favorite_admin') %}
{% form_theme form_switch_merchant '@LcSov/adminlte/crud/form_theme.html.twig' %}
{{ form_start(form_switch_merchant) }}
<div class="hidden">

Yükleniyor…
İptal
Kaydet