src/Kunstmaan/MultiDomainBundle/Router/DomainBasedLocaleRouter.php
public function generate($name, $parameters = array(), $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH)
    {
        if ('_slug' === $name) {
            if ($this->isMultiLanguage() && $this->isMultiDomainHost()) {
                $locale = isset($parameters['_locale']) ? $parameters['_locale'] : $this->getRequestLocale();

                $reverseLocaleMap = $this->getReverseLocaleMap();
                if (isset($reverseLocaleMap[$locale])) {
                    $parameters['_locale'] = $reverseLocaleMap[$locale];
                }
            }
        }

        if (isset($parameters['otherSite'])) {
            $this->otherSite = $this->domainConfiguration->getFullHostById($parameters['otherSite']);
        } else {
            $this->otherSite = null;
        }

        $this->urlGenerator = new UrlGenerator(
            $this->getRouteCollection(),
            $this->getContext()
        );

        if (isset($parameters['otherSite'])) {
            unset($parameters['otherSite']);
        }

        return $this->urlGenerator->generate($name, $parameters, $referenceType);
    }
public function generate($name, $parameters = array(), $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH)
    {
        if ('_slug' === $name) {
            if ($this->isMultiLanguage() && $this->isMultiDomainHost()) {
                $locale = isset($parameters['_locale']) ? $parameters['_locale'] : $this->getRequestLocale();

                $reverseLocaleMap = $this->getReverseLocaleMap();
                if (isset($reverseLocaleMap[$locale])) {
                    $parameters['_locale'] = $reverseLocaleMap[$locale];
                }
            }
        }

        if (isset($parameters['otherSite'])) {
            $this->otherSite = $this->domainConfiguration->getFullHostById($parameters['otherSite']);
        } else {
            $this->otherSite = null;
        }

        $this->urlGenerator = new UrlGenerator(
            $this->getRouteCollection(),
            $this->getContext()
        );

        if (isset($parameters['otherSite'])) {
            unset($parameters['otherSite']);
        }

        return $this->urlGenerator->generate($name, $parameters, $referenceType);
    }
public function generate ( $ name , $ parameters = array ( ) , $ referenceType = UrlGeneratorInterface :: ABSOLUTE_PATH ) { if ( '_slug' === $ name ) { if ( $ this -> isMultiLanguage ( ) && $ this -> isMultiDomainHost ( ) ) { $ locale = isset ( $ parameters [ '_locale' ] ) ? $ parameters [ '_locale' ] : $ this -> getRequestLocale ( ) ; $ reverseLocaleMap = $ this -> getReverseLocaleMap ( ) ; if ( isset ( $ reverseLocaleMap [ $ locale ] ) ) { $ parameters [ '_locale' ] = $ reverseLocaleMap [ $ locale ] ; } } } if ( isset ( $ parameters [ 'otherSite' ] ) ) { $ this -> otherSite = $ this -> domainConfiguration -> getFullHostById ( $ parameters [ 'otherSite' ] ) ; } else { $ this -> otherSite = null ; } $ this -> urlGenerator = new UrlGenerator ( $ this -> getRouteCollection ( ) , $ this -> getContext ( ) ) ; if ( isset ( $ parameters [ 'otherSite' ] ) ) { unset ( $ parameters [ 'otherSite' ] ) ; } return $ this -> urlGenerator -> generate ( $ name , $ parameters , $ referenceType ) ; }
Generate an url for a supplied route

@param string   $name          The path
@param array    $parameters    The route parameters
@param int|bool $referenceType The type of reference to be generated (one of the UrlGeneratorInterface constants)

@return null|string
Generate an url for a supplied route