Adding a new Location to a Content item¶
Every published Content item must have at least one Location. One Content item can have more that one Location, which means it is presented in more than one place in the content tree.
Creating a new Location, like creating content, requires using a struct, because a Location value object is read-only.
1 2 3
LocationCreateStruct must receive the parent Location ID.
It sets the
parentLocationId property of the new Location.
You can also provide other properties for the Location, otherwise they will be set to their defaults:
Changing the main Location¶
When a Content item has more that one Location, one Location is always considered the main one.
You can change the main Location using
by updating the
ContentInfo with a
that sets the new main Location:
1 2 3 4
Hiding and revealing Locations¶
See Location visibility for detailed information on the behavior of visible and hidden Locations.
Deleting a Location¶
You can remove a Location either by deleting it, or sending it to Trash.
Deleting makes use of
It permanently deletes the Location, together with its whole subtree.
Content which has only this one Location will be permanently deleted as well. Content which has more Locations will be still available in its other Locations. If you delete the main Location of a Content item that has more Locations, another Location will become the main one.
Moving and copying a subtree¶
You can move a Location with its whole subtree using
1 2 3
LocationService::copySubtree is used in the same way,
but it copies the Location and its subtree instead of moving it.
To copy a subtree you can also make use of the built-in
bin/console ibexa:copy-subtree <sourceLocationId> <targetLocationId>.
Copy subtree limit only applies to operations in the Back Office. It is ignored when copying subtrees using the PHP API.
To empty the Trash (remove all Locations in Trash), use
which takes no arguments.
You can recover an item from Trash using
You must provide the method with the ID of the object in Trash.
Trash Location is identical to the origin Location of the object.
The Content item will be restored under its previous Location. You can also provide a different Location to restore in as a second argument:
You can also search through Trash items and sort the results using several public PHP API search criteria and sort clauses that have been exposed for
For more information, see Searching in trash.
Creating Content Types¶
To operate on Content Types, you need to make use of
Creating a new Content Type, like creating content, must happen with the use of a struct, because a Content Type value object is read-only.
In this case you use
A Content Type must have at least one name, in the main language, and at least one Field definition.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
You can specify more details of the Field definition in the create struct, for example:
1 2 3 4 5 6 7 8 9
Copying Content Types¶
To copy a Content Type, use
The copy will automatically be given an identifier based on the original Content Type identifier
and the copy's ID, for example:
To change the identifier of the copy, use a
1 2 3 4 5
You can handle the calendar using
To get a list of events for a specified time period, use the
You need to provide the method with an EventQuery, which takes a date range and a count as the minimum of parameters:
1 2 3 4 5 6 7 8 9 10 11
You can also get the first and last event in the list by using the
last() methods of an
You can process the events in a collection using the
map(Closure $callback) or
slice(int $offset, ?int $length = null) methods of
EventCollection, for example:
1 2 3 4
Performing calendar actions¶
You can perform a calendar action (e.g. reschedule or unschedule calendar events) using the
You must pass an
EzSystems\EzPlatformCalendar\Calendar\EventAction\EventActionContext instance as argument.
EventActionContext defines events on which the action is performed, as well as action-specific parameters e.g. a new date: