Usage
This page describes how the ContentSync plugin works and how to use it.
Naviga Web provides a cloud hosted service called "Content Sync". The service will keep track of events from one specific Open Content and POST specified events to a configured list of sites.
The plugin exposes the endpoint where these events can be posted. The events will then be validated and dispatched through PSR-14 standards to any listeners that might be interested.
We will refer to contenttype
in this documentation. This is a property that every object has in Open Content, and it describes the type of content, i.e. Article
, Concept
and List
.
Registering a Listener
You register your listener to \Everyware\Plugin\ContentSync\ContentEvents::listen()
.
Description
Parameters
$contentType (string) - Specifies which contenttype
you are interested in.
$listener (ContentEventListener) - The listener that will handle the "Event" needs to implement the \Everyware\Plugin\ContentSync\Contracts\ContentEventListener
interface.
$priority (int) - The order in which the listeners are triggered. Lower numbers correspond with earlier trigger, and listeners with the same priority are triggered in the order in which they were added. Default value: 10
Prioritize your actions
While registering your listener you have the option to add a priority for when your listener should be triggered. By default, the listeners are triggered in the order they were added with a start priority of 10
.
Sometimes you'll want to make sure that your listener is triggered at the very beginning. You can then give your listener a priority of 1-9
. Then your listener will be triggered before all other events with a lower priority.
There is no certain way to make sure that your listener is triggered last but the rule of thumb is: the higher the priority, the more likely it is that it is to be triggered last.
The order in which the listener is added does still apply if multiple listeners are added with the same priority.
Events
There are three types off supported Events: ADD
, DELETE
and UPDATE
. Every event relates to one object from Open Content with a specific contenttype
.
Events will be dispatched as \Everyware\Plugin\ContentSync\Event
objects that implement the \Everyware\Plugin\ContentSync\Contracts\ContentEvent
interface.
The Everyware\Plugin\ContentSync\Contracts\ContentEvent
interface provides methods for extracting useful data from the event.
Examples
Let's say you wanted to listen for Article
events.
Your class might look like this:
Then you'd register it like this:
Let's say that you'd like to separate how you handle the different types of events.
Well you could do something like this:
Last updated
Was this helpful?