Browse Source

Correctif backoffice

master
Fab 4 years ago
parent
commit
62f1c70256
5 changed files with 80 additions and 16 deletions
  1. +1
    -2
      ShopBundle/Controller/Backend/AdminController.php
  2. +1
    -8
      ShopBundle/Controller/Backend/MerchantController.php
  3. +47
    -0
      ShopBundle/EventSubscriber/InitializeEventSubscriber.php
  4. +4
    -0
      ShopBundle/Resources/public/js/backend/script/default/init-common.js
  5. +27
    -6
      ShopBundle/Resources/views/backend/default/block/flash_messages.html.twig

+ 1
- 2
ShopBundle/Controller/Backend/AdminController.php View File

$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) ;
} }

+ 1
- 8
ShopBundle/Controller/Backend/MerchantController.php View File

->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') ;
} }
} }



+ 47
- 0
ShopBundle/EventSubscriber/InitializeEventSubscriber.php View File

<?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());

}
}


}

+ 4
- 0
ShopBundle/Resources/public/js/backend/script/default/init-common.js View File

$('#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() {

+ 27
- 6
ShopBundle/Resources/views/backend/default/block/flash_messages.html.twig View File

{% 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 %}

Loading…
Cancel
Save