eZ\Publish\Core\MVC\Symfony\SiteAccess\SiteAccessRouterInterface::matchByName PHP Method

matchByName() public method

Returns corresponding SiteAccess object, according to configuration, with corresponding matcher. If no matcher can be found (e.g. non versatile), matcher property will be "default".
public matchByName ( string $siteAccessName ) : SiteAccess
$siteAccessName string
return eZ\Publish\Core\MVC\Symfony\SiteAccess
    public function matchByName($siteAccessName);

Usage Example

 /**
  * Triggers URL generation for $urlResource and $parameters.
  *
  * @param mixed $urlResource Type can be anything, depending on the context. It's up to the router to pass the appropriate value to the implementor.
  * @param array $parameters Arbitrary hash of parameters to generate a link.
  *                          SiteAccess name can be provided as 'siteaccess' to generate a link to it (cross siteaccess link).
  * @param int $referenceType The type of reference to be generated (one of the constants)
  *
  * @return string
  */
 public function generate($urlResource, array $parameters, $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH)
 {
     $siteAccess = $this->siteAccess;
     $requestContext = $this->requestContext;
     // Retrieving the appropriate SiteAccess to generate the link for.
     if (isset($parameters['siteaccess'])) {
         $siteAccess = $this->siteAccessRouter->matchByName($parameters['siteaccess']);
         if ($siteAccess instanceof SiteAccess && $siteAccess->matcher instanceof SiteAccess\VersatileMatcher) {
             $requestContext = $this->getContextBySimplifiedRequest($siteAccess->matcher->getRequest());
         } else {
             if ($this->logger) {
                 $siteAccess = $this->siteAccess;
                 $this->logger->notice("Could not generate a link using provided 'siteaccess' parameter: {$parameters['siteaccess']}. Generating using current context.");
                 unset($parameters['siteaccess']);
             }
         }
     }
     $url = $this->doGenerate($urlResource, $parameters);
     // Add the SiteAccess URI back if needed.
     if ($siteAccess && $siteAccess->matcher instanceof SiteAccess\URILexer) {
         $url = $siteAccess->matcher->analyseLink($url);
     }
     $url = $requestContext->getBaseUrl() . $url;
     if ($referenceType === UrlGeneratorInterface::ABSOLUTE_URL) {
         $url = $this->generateAbsoluteUrl($url, $requestContext);
     }
     return $url;
 }
All Usage Examples Of eZ\Publish\Core\MVC\Symfony\SiteAccess\SiteAccessRouterInterface::matchByName
SiteAccessRouterInterface