Example #1
0
 /**
  * @param \Enlight_Event_EventArgs $args
  */
 public function onAfterRegisterShop(\Enlight_Event_EventArgs $args)
 {
     /** @var $container Container */
     $container = $args->getSubject();
     /** @var $router \Shopware\Components\Routing\RouterInterface  */
     $router = $container->get('router');
     /** @var $shop \Shopware\Models\Shop\Shop */
     $shop = $container->get('shop');
     /** @var $config \Shopware_Components_Config */
     $config = $container->get('config');
     // Register the shop (we're to soon)
     $config->setShop($shop);
     $context = $router->getContext();
     $newContext = Context::createFromShop($shop, $config);
     // Reuse the host
     if ($newContext->getHost() === null) {
         $newContext->setHost($context->getHost());
         $newContext->setBaseUrl($context->getBaseUrl());
         // Reuse https
         if (!$newContext->isSecure()) {
             $newContext->setSecure($context->isSecure());
             $newContext->setSecureBaseUrl($context->getSecureBaseUrl());
         }
     }
     // Reuse the global params like controller and action
     $globalParams = $context->getGlobalParams();
     $newContext->setGlobalParams($globalParams);
     $router->setContext($newContext);
 }