Skip to content

Commit

Permalink
Add support for Elements::EVENT_REGISTER_ELEMENT_TYPES (#328)
Browse files Browse the repository at this point in the history
Allows the Event element to be registered properly with Craft.
  • Loading branch information
engram-design authored Oct 9, 2024
1 parent 5934503 commit 04eb905
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/plugin/src/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ public function init(): void
$this->initTemplateVariables();
$this->initWidgets();
$this->initFieldTypes();
$this->initElementTypes();
$this->initEventListeners();
$this->initPermissions();
$this->initBundles();
Expand Down Expand Up @@ -363,6 +364,17 @@ function (RegisterComponentTypesEvent $event) {
);
}

private function initElementTypes(): void
{
Event::on(
Elements::class,
Elements::EVENT_REGISTER_ELEMENT_TYPES,
function (RegisterComponentTypesEvent $event) {
$event->types[] = \Solspace\Calendar\Elements\Event::class;
}
);
}

private function initEventListeners(): void
{
Event::on(Sites::class, Sites::EVENT_AFTER_SAVE_SITE, [$this->events, 'addSiteHandler']);
Expand Down

0 comments on commit 04eb905

Please sign in to comment.