Message-ID: <626356784.3034.1485851709056.JavaMail.confluence@ip-10-127-227-164> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_3033_766031375.1485851709056" ------=_Part_3033_766031375.1485851709056 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
When using the multisite feature, it is sometimes usefu=
l to be able to generate cross-links between the different=
sites.
This allows you to link different resources referenced in the s=
ame content repository, but configured independently with different tree ro=
ots.
{# 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
Important
url()
Twig helper).
URIElement
.InvalidArgumentE=
xception
will be thrown.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.
Note
SiteAccessRouterInterface
.