Overview
I have a multi-site setup consisting of three individual sites. Each of these sites has its own configuration file that includes a 'feeds'
option. This option specifies the feeds where events can be fetched by my event plugin.
The 'feeds'
option looks like this in the config.php
:
config.php
'feeds' => [
'https://feed-eins.test',
'https://feed-zwei.test'
],
Objective
Currently, my event plugin exports all events that have the âexportâ flag set to true, regardless of the feed they belong to. Now, I want to customize this behavior. I want to filter events based on the feed URLs (âfeed-einsâ and âfeed-zweiâ) stored in the $receivingsites
field of each event.
The $receivingsites
field contains a comma-separated string of feed URLs, like so: 'https://feed-eins.test, https://feed-zwei.test'
.
Current Implementation
In the current state of my event pluginâs index.php
, I have a route defined for â/export/eventsâ. This route fetches and exports all events that have their âexportâ flag set to true. It does not yet differentiate between the two feeds.
'routes' => [
[
'pattern' => '/export/events',
'method' => 'GET',
'action' => function(){
$events = site()->index()->filterBy('intendedTemplate', 'event')->filterBy('export', 'true');
$data = [];
foreach($events as $event) {
$data[] = [
'slug' => (string)$event->slug(),
'receivingsites' => (string)$event->receivingsites(),
];
}
return Kirby\Http\Response::json($data, 200, true);
}
],