/**
  * @param CanonicalUrlEvent $event
  */
 public function generateUrlCanonical(CanonicalUrlEvent $event)
 {
     $preUrl = null;
     $url = null;
     $uri = $this->request->getUri();
     $parseUrlByCurrentLocale = $this->getParseUrlByCurrentLocale();
     if (!empty($uri) && false !== ($parse = parse_url($uri))) {
         // test if current domain equal lang domain
         if ($parse['host'] !== $parseUrlByCurrentLocale['host']) {
             $preUrl = $parseUrlByCurrentLocale['scheme'] . '://' . $parseUrlByCurrentLocale['host'];
         }
         if (strpos($parse['path'], '/index.php') > -1) {
             $path = explode('/index.php', $parse['path']);
             $url = $path[1];
         } elseif (strpos($parse['path'], '/index_dev.php') > -1) {
             $path = explode('/index_dev.php', $parse['path']);
             $url = $path[1];
         } elseif ($parse['path'] !== '/') {
             $url = $parse['path'];
         }
     }
     if (empty($url)) {
         $url = '/?' . $this->request->getQueryString();
     }
     $event->setUrl($preUrl . $url);
 }