Message-ID: <754291325.3060.1485851815329.JavaMail.confluence@ip-10-127-227-164> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_3059_311047693.1485851815312" ------=_Part_3059_311047693.1485851815312 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
Version compatibility
This page is compatible with eZ Publish 5.3 / 2014.03
When using the multisite feature, it is sometimes useful to be = able to generate cross-links between the different sites.<= br> This allows to link different resources referenced in a same content re= pository, but configured independently with different tree roots.
{# Linking a location #}=20 <a href=3D"{{ url( 'ez_urlalias', {'locationId': 42, 'siteaccess': 'some= _siteaccess_name'} ) }}">{{ ez_content_name( content ) }}</a> {# Linking a regular route #}=20 <a href=3D"{{ url( "some_route_name", {"siteaccess": "some_siteaccess_na= me"} ) }}">Hello world!</a>=20
namespace Acme\TestBundle\Controller; use eZ\Bundle\EzPublishCoreBundle\Controller as BaseController; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; class MyController extends BaseController { public function fooAction() { // ... $location =3D $this->getRepository()->getLocationService()-&g= t;loadLocation( 123 ); $locationUrl =3D $this->generateUrl( $location, array( 'siteaccess' =3D> 'some_siteaccess_name' ), UrlGeneratorInterface::ABSOLUTE_PATH ); $regularRouteUrl =3D $this->generateUrl( 'some_route_name', array( 'siteaccess' =3D> 'some_siteaccess_name' ), UrlGeneratorInterface::ABSOLUTE_PATH ); // ... } }=20
url()
Twig helper).
URIElement
.InvalidArgumentE=
xception
will be thrown.Ve=
rsatileMatcher
, the link will be generated for the current SiteAcces=
s.Compound\LogicalAnd
, all inner matchers must match. If at least one matcher doesn't implement Versa=
tileMatcher
, it will fail.Compound\LogicalOr
, the first inner matcher suc=
ceeding will win.To implement this feature, a new VersatileMatcher
was added=
to allow SiteAccess matchers to be able to reverse-match.
All=
existing matchers implement this new interface, except the Regexp based ma=
tchers which have been deprecated.
The SiteAccess router has been added a matchByName()
method=
to reflect this addition. Abstract URLGenerator and DefaultRouter have been updated as well.
SiteAccessRouterInterface
.