<?php

namespace Lc\ShopBundle\EventSubscriber;

use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents;
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('postInitialize'),
                );
        }


        public function postInitialize(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());

                }
        }


}