Download the PHP package adamwojs/ezplatform-location-reference without Composer
On this page you can find all versions of the php package adamwojs/ezplatform-location-reference. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download adamwojs/ezplatform-location-reference
More information about adamwojs/ezplatform-location-reference
Files in adamwojs/ezplatform-location-reference
Package ezplatform-location-reference
Short Description eZ Platform Location Reference
License MIT
Informations about the package ezplatform-location-reference
ezplatform-location-reference
Problem
The common case in the eZ Platform configuration is referencing to some location, usually using Location ID e.g.
- Content root for Site Access (https://doc.ezplatform.com/en/latest/guide/multisite/#location_id)
- Folder used to store Image Assets (https://doc.ezplatform.com/en/latest/api/field_type_reference/#configuration)
There are several issues in this approaches:
- Location IDs differ between environments
- Using Magic numbers is a code smell
This package introduces Domain Specific Language, based on Symfony Expression Language component, allowing to refer locations using meaningful and descriptive expressions.
Usage
Resolve location references
Location reference expressions could be resolved using LocationReferenceResolver
e.g.
Retrieving location reference from SiteAccess aware configuration
Location references could be retrieved from the SiteAccess aware configuration
using LocationConfigResolver
:
Arguments for both getLocation
and getLocationReference
methods are exactly the same as for
\eZ\Publish\Core\MVC\ConfigResolverInterface::getParameter
.
Example:
Available functions
Function | Description | Example |
---|---|---|
root |
Load root location | root() |
parent |
Load parent location | parent(local_id(54)) |
local_id |
Load location by ID | local_id(54) |
remote_id |
Load location by remote ID | remote_id("babe4a915b1dd5d369e79adb9d6c0c6a") |
path |
Load location by path string | path("/1/2/54") |
named |
Load named reference | named("MEDIA") |