$this->em->persist($newEntity) ; | $this->em->persist($newEntity) ; | ||||
$this->em->flush() ; | $this->em->flush() ; | ||||
$this->utils->addFlash('warning', "Vous êtes maintenant sur le hub de ".$hub->getTitle()); | |||||
$redirectUrl = $hub->getMerchantConfig('url').substr($this->generateUrl('easyadmin', ['entity' => $easyadmin['entity']['name'], 'action' => 'edit', 'id' =>$newEntity->getId(), 'referer' =>$refererUrl ]),1); | |||||
$redirectUrl = $hub->getMerchantConfig('url').substr($this->generateUrl('easyadmin', ['entity' => $easyadmin['entity']['name'], 'action' => 'edit', 'id' =>$newEntity->getId(), 'referer' =>$refererUrl ]),1).'&hubredirection=true'; | |||||
return $this->redirect($redirectUrl) ; | return $this->redirect($redirectUrl) ; | ||||
} | } |
->find($idMerchant); | ->find($idMerchant); | ||||
if ($merchant) { | if ($merchant) { | ||||
dump($merchant); | |||||
dump('NICHE'); | |||||
$user->setMerchant($merchant); | $user->setMerchant($merchant); | ||||
$em->persist($user); | $em->persist($user); | ||||
$em->flush(); | $em->flush(); | ||||
$this->utils->addFlash('warning', "Vous êtes maintenant sur le hub de ".$idMerchant); | |||||
return $this->redirect($merchant->getMerchantConfig('url').'admin/dashboard') ; | |||||
return $this->redirect($merchant->getMerchantConfig('url').'admin/dashboard?hubredirection=true') ; | |||||
} | } | ||||
} | } | ||||
<?php | |||||
namespace Lc\ShopBundle\EventSubscriber; | |||||
use Lc\ShopBundle\Context\FilterMerchantInterface; | |||||
use Lc\ShopBundle\Context\FilterMultipleMerchantsInterface; | |||||
use Lc\ShopBundle\Context\MerchantUtilsInterface; | |||||
use Lc\ShopBundle\Context\SortableInterface; | |||||
use Lc\ShopBundle\Context\StatusInterface; | |||||
use Lc\ShopBundle\Context\TreeInterface; | |||||
use Lc\ShopBundle\Services\Utils; | |||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | |||||
use Symfony\Component\EventDispatcher\GenericEvent; | |||||
class InitializeEventSubscriber implements EventSubscriberInterface | |||||
{ | |||||
public $merchantUtils; | |||||
public $utils; | |||||
public function __construct(MerchantUtilsInterface $merchantUtils, Utils $utils) | |||||
{ | |||||
$this->merchantUtils = $merchantUtils; | |||||
$this->utils = $utils; | |||||
} | |||||
public static function getSubscribedEvents() | |||||
{ | |||||
return array( | |||||
'easy_admin.post_initialize' => array('initialize'), | |||||
'easy_admin.post_update' => array('updateCommonProperty'), | |||||
); | |||||
} | |||||
public function initialize(GenericEvent $event) | |||||
{ | |||||
$request = $event->getArgument('request'); | |||||
if($request->query->get('hubredirection')){ | |||||
$this->utils->addFlash('alert', "Vous êtes maintenant sur le hub de ".$this->merchantUtils->getMerchantCurrent()->getTitle()); | |||||
} | |||||
} | |||||
} |
$('#lc-flash-messages .notice').each(function (i, notice) { | $('#lc-flash-messages .notice').each(function (i, notice) { | ||||
generateNotice($(notice).find('.type').html(), $(notice).find('.message').html()); | generateNotice($(notice).find('.type').html(), $(notice).find('.message').html()); | ||||
}); | }); | ||||
$('#lc-flash-alert .modal').each(function (i, modal) { | |||||
$(modal).modal('show'); | |||||
}); | |||||
} | } | ||||
function initButtonConfirm() { | function initButtonConfirm() { |
{% if app.session is not null and app.session.started %} | {% if app.session is not null and app.session.started %} | ||||
{% set _flash_messages = app.session.flashbag.all %} | {% set _flash_messages = app.session.flashbag.all %} | ||||
{% if _flash_messages['alert'] is defined and _flash_messages['alert']|length > 0 %} | |||||
<div id="lc-flash-alert"> | |||||
{% for alert in _flash_messages['alert'] %} | |||||
<div class="modal fade"> | |||||
<div class="modal-dialog"> | |||||
<div class="modal-content bg-danger"> | |||||
<div class="modal-header"> | |||||
<h4 class="modal-title">{{ alert|trans|striptags }}</h4> | |||||
</div> | |||||
<div class="modal-footer align-right"> | |||||
<button type="button" data-dismiss="modal" class="btn btn-outline-light">OK</button> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
{% endfor %} | |||||
</div> | |||||
{% endif %} | |||||
{% if _flash_messages|length > 0 %} | {% if _flash_messages|length > 0 %} | ||||
<div id="lc-flash-messages"> | <div id="lc-flash-messages"> | ||||
{% for label, messages in _flash_messages %} | {% for label, messages in _flash_messages %} | ||||
{% for message in messages %} | |||||
<div class="notice"> | |||||
<span class="type">{{ label }}</span> | |||||
<span class="message"> {{ message|trans|striptags }}</span> | |||||
</div> | |||||
{% endfor %} | |||||
{% if label != 'alert' %} | |||||
{% for message in messages %} | |||||
<div class="notice"> | |||||
<span class="type">{{ label }}</span> | |||||
<span class="message"> {{ message|trans|striptags }}</span> | |||||
</div> | |||||
{% endfor %} | |||||
{% endif %} | |||||
{% endfor %} | {% endfor %} | ||||
</div> | </div> | ||||
{% endif %} | {% endif %} |