Skip to content

Latest commit

 

History

History
73 lines (49 loc) · 2.55 KB

File metadata and controls

73 lines (49 loc) · 2.55 KB

Developers – Events Subscriptions

  1. Installation
  2. Basic configuration
  3. Advanced configuration
  4. Backend interface
  5. Frontend modules
  6. Notifications
  7. Insert tags
  8. Developers

Information for developers

This section is dedicated to the developers only!

Subscription types

By default there are two subscription types available: one for the guests (non-logged-in users) and one for the members (logged-in users). It is easily possible to add a new subscription type or override the existing one. In order to do that simply register your type in the factory:

// config/config.php
\Codefog\EventsSubscriptions\Services::getSubscriptionFactory()->add('my_type', 'MyTypeSubscription');

The class must implement the Codefog\EventsSubscriptions\Subscription\SubscriptionInterface. It can also optionally implement other interfaces such as for the data export or notification sending. For more information and examples please check the existing classes.

After adding the type you may also want to update the DCA and language files:

// dca/tl_calendar_events_subscription.php
$GLOBALS['TL_DCA']['tl_calendar_events_subscription']['palettes']['my_type'] = '{type_legend},type,addedBy;{my_type_legend},my_type_field1';

// languages/en/tl_calendar_events_subscription.php
$GLOBALS['TL_LANG']['tl_calendar_events_subscription']['typeRef']['my_type'] = 'My Type';

Hooks/events

The extension comes with several hooks/events for flexibility.

onExport

The event is triggered when the subscriptions are being exported. The argument passed on is the instance of the Codefog\EventsSubscriptions\Event\ExportEvent object.

$GLOBALS['TL_HOOKS'][\Codefog\EventsSubscriptions\EventDispatcher::EVENT_ON_EXPORT][] = ['MyClass', 'onExport'];

onSubscribe

The event is triggered when the member is subscribed to the event. The argument passed on is the instance of the Codefog\EventsSubscriptions\Event\SubscribeEvent object.

$GLOBALS['TL_HOOKS'][\Codefog\EventsSubscriptions\EventDispatcher::EVENT_ON_SUBSCRIBE][] = ['MyClass', 'onSubscribe'];

onUnsubscribe

The event is triggered when the member is unsubscribed from the event. The argument passed on is the instance of the Codefog\EventsSubscriptions\Event\UnsubscribeEvent object.

$GLOBALS['TL_HOOKS'][\Codefog\EventsSubscriptions\EventDispatcher::EVENT_ON_UNSUBSCRIBE][] = ['MyClass', 'onUnsubscribe'];