As we dropped Joomla 4 support in our extensions, it is time now to get rid of old legacy code and prepare for the future. Therefor we shipped a new major version for DPCalendar as we had to break some minor stuff for calendar plugins.
Following our established release strategy, we are excited to announce a new major version of DPCalendar and new feature versions of DPMedia, DPCases and DPAttachments. This time one week earlier than normal as here in Switzerland is summer season is approaching soon. Today, we are releasing the following updates:
- DPCalendar 11.0.0 [Download]
- DPMedia 1.22.0 [Download]
- DPAttachments 5.9.0 [Download]
- DPCases 3.9.0 [Download]
DPCalendar 11
The new major version of DPCalendar comes only with one new feature. Bookings can now be created through the API as well. Like that it is possible to trigger the booking process through an external app, which will be handy when AI agents control your Joomla based site through one of the MCP plugins.
Backwards compatibility breaks
With this major release, DPCalendar moves all its plugins to the event subscriber architecture of Joomla (SubscriberInterface) and dispatches every event as a typed event object. The old "one argument per parameter" style of plugins is deprecated since Joomla 5.4 and will be removed in Joomla 7, so we made the switch now. For most sites the update runs without any action. But if you have written your own plugin for DPCalendar, or your site uses template overrides of DPCalendar views, read this section before you update.
Minimum requirements
- Joomla 5.4.0 or newer is required. Joomla 4 is no longer supported, sites on Joomla 4.4 should stay on DPCalendar 10.
- PHP 8.1 is still the minimum PHP version.
For plugin developers
New event classes
All DPCalendar events now have their own event class in the namespace DigitalPeak\Component\DPCalendar\Administrator\Event. Instead of individual arguments, a listener gets one event object with getters for the data. Results are no longer returned, they are added to the event with $event->addResult().
| Event name | Event class | Getters | Result |
|---|---|---|---|
onCalendarsFetch |
CalendarsFetchEvent |
getCalendarIds(), getType() |
array |
onEventsFetch |
EventsFetchEvent |
getCalendarId(), getStartDate(), getEndDate(), getOptions() |
array |
onEventFetch |
EventFetchEvent |
getEventId() |
object or null |
onEventSave |
EventSaveEvent |
getData() |
string |
onEventDelete |
EventDeleteEvent |
getEventId() |
bool |
onEventsSync |
EventsSyncEvent |
getPlugin(), getCalendarIds() |
– |
onCalendarAfterDelete |
CalendarAfterDeleteEvent |
getCalendar() |
– |
onDPCalendarDoAction |
DoActionEvent |
getAction(), getPlugin(), getData() |
mixed |
onDPCalendarGetIcal |
GetIcalEvent |
getCalendarId() |
string |
onDPCalendarEventAfterSave |
EventAfterSaveEvent |
getEvent(), getIsNew() |
– |
onContentDisplayEventList |
DisplayEventListEvent |
getContext(), getCalendarIds(), getEvents() |
– |
onDPCalendarAfterButtons |
AfterButtonsEvent |
getViewName(), getItems() |
string |
onDPCalendarAfterToolbar |
AfterToolbarEvent |
getViewName(), getToolbar() |
– |
onDPCalendarAfterPaymentForm |
AfterPaymentFormEvent |
getContext(), getItem(), getParams(), getPage() |
string |
onDPCalendarAfterBookingFinished |
AfterBookingFinishedEvent |
getBooking(), getTickets() |
– |
onDPCalendarBeforeSendMail / onDPCalendarAfterSendMail |
BeforeSendMailEvent / AfterSendMailEvent |
getContext(), getMailer(), getData() |
– |
onDPCalendarBeforeCreatePDF / onDPCalendarAfterCreatePDF |
BeforeCreatePDFEvent / AfterCreatePDFEvent |
getPdf(), getItem() |
– |
onDPCalendarAfterCreatePDFFile |
AfterCreatePDFFileEvent |
getPdf(), getFileName(), getItem() |
– |
onDPCalendarBeforeExecute |
BeforeExecuteEvent |
getInput() |
– |
onDPPaymentProviders |
PaymentProvidersEvent |
– | array |
onDPPaymentNew |
PaymentNewEvent |
getBooking() |
string |
onDPPaymentCallBack |
PaymentCallBackEvent |
getBooking(), getData() |
bool |
onDPCalendarLoadInvoice |
LoadInvoiceEvent |
getBooking() |
array or null |
The results are type checked by Joomla. If your listener has nothing to contribute, simply return without adding a result instead of adding null, false or an empty string.
Plugins extending DPCalendarPlugin, SyncPlugin or PaymentPlugin
The base classes DPCalendarPlugin, SyncPlugin and PaymentPlugin implement SubscriberInterface now. This has a couple of consequences for plugins which extend them:
- The constructor has no dispatcher argument anymore. Remove the dispatcher from the
newcall in yourservices/provider.phpfile and set it with$plugin->setDispatcher()where needed. - Only subscribed events are called. Joomla doesn't call every public
on*method anymore. When your plugin listens to additional events, for exampleonContentAfterDisplay, you have to add them ingetSubscribedEvents()and merge them with the events of the parent class. Otherwise your listener is silently ignored. - Overridden listeners must use the new signature. If you override
onEventsFetch,onContentPrepareFormor one of the other listeners of the base class, the method must accept the event object and callparent::onEventsFetch($event). Otherwise PHP throws an incompatible signature error. - Helper methods got their own names. The logic behind the listeners moved to protected methods, which you can call or override instead:
DPCalendarPlugin:fetchEventsFromCache(),saveExternalEvent(),deleteExternalEvent()PaymentPlugin:onDPPaymentProviders()is nowgetPaymentProviders(),onDPPaymentNew()is nowstartPayment(),onDPPaymentCallBack()is nowprocessCallBack()andonDPCalendarLoadInvoice()is nowloadInvoice()
A plugin which needs an additional event looks then like this:
use DigitalPeak\Component\DPCalendar\Administrator\Plugin\SyncPlugin;
use Joomla\CMS\Event\Content\AfterDisplayEvent;
class MyCalendar extends SyncPlugin
{
protected string $identifier = 'my';
public static function getSubscribedEvents(): array
{
return array_merge(parent::getSubscribedEvents(), [
'onContentAfterDisplay' => 'onContentAfterDisplay',
]);
}
public function onContentAfterDisplay(AfterDisplayEvent $event): void
{
if ($event->getContext() !== 'com_dpcalendar.event') {
return;
}
$event->addResult('<div>My output</div>');
}
}
Plugins with the old listener style
Plugins which do not extend one of the DPCalendar base classes and still use the old method signatures, like onCalendarsFetch($calendarIds, $type), keep working. The DPCalendar events pass the arguments in the same order as before. But this compatibility layer is deprecated in Joomla and will be gone with Joomla 7, so we recommend to migrate your plugin to the subscriber interface now.
Triggering DPCalendar events
If your extension triggers DPCalendar events itself, for example to fetch the events of a calendar, you have to dispatch the new event class. Triggering them with $app->triggerEvent() and an array of arguments results in a fatal error, because the DPCalendar plugins expect the typed event object.
// Before
$results = $app->triggerEvent('onEventsFetch', [$calendarId, $start, $end, $options]);
// Now
use DigitalPeak\Component\DPCalendar\Administrator\Event\EventsFetchEvent;
$results = $app->getDispatcher()->dispatch(
'onEventsFetch',
new EventsFetchEvent('onEventsFetch', [
'calendarId' => $calendarId,
'startDate' => $start,
'endDate' => $end,
'options' => $options,
])
)->getArgument('result', []);
For sites with template overrides
Some view templates trigger events directly. If you have an override of one of the following files in your template, compare it with the new version of DPCalendar and update it:
booking/pay.php(must be updated) – The override triggers theonDPPaymentNewevent. The old call$this->app->triggerEvent('onDPPaymentNew', [$this->booking])breaks the payment page with a fatal error, as the payment plugins expect aPaymentNewEventnow. Replace it with:use DigitalPeak\Component\DPCalendar\Administrator\Event\PaymentNewEvent; $button = $this->getDispatcher()->dispatch( 'onDPPaymentNew', new PaymentNewEvent('onDPPaymentNew', ['booking' => $this->booking]) )->getArgument('result', []);event/default_locations.php,location/default_details.php,locations/default_details_full.phpand the layoutevent/tooltip.php(recommended) – These files trigger the Joomla content eventsonContentBeforeDisplayandonContentPrepare. Old overrides still work, but they use the deprecatedtriggerEvent()function. Update them to dispatch the Joomla event classesBeforeDisplayEventandContentPrepareEvent, as the original files do now.
The easiest way to check your overrides is the template manager of Joomla. After the update it lists the overrides of changed files under System → Template: Updated Overrides, where you can compare them with the new core files.
New feature versions
In the other extensions we made some small changes to improve compatibility, these changes didn't require a new major version so we ship them as new feature ones..
A full changelog is added in the respective download release description on our download site.
Kind regards
Allon Moritz aka laoneo
Founder of Digital Peak
