Skip to content

Commit

Permalink
Merge pull request #152 from verdigado/fix-calendarize-table-creation…
Browse files Browse the repository at this point in the history
…_v10

create calendarize fields only if extension is loaded - 4.1.x
  • Loading branch information
albig committed Dec 6, 2023
2 parents 65fc0a9 + b78d34c commit 3025cf8
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 8 deletions.
39 changes: 39 additions & 0 deletions Classes/EventListener/CalendarizeOdsOsmSqlListener.php
@@ -0,0 +1,39 @@
<?php

declare(strict_types=1);

namespace Bobosch\OdsOsm\EventListener;

use HDNET\Calendarize\Register;
use TYPO3\CMS\Core\Database\Event\AlterTableDefinitionStatementsEvent;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;

class CalendarizeOdsOsmSqlListener
{
public function __invoke(AlterTableDefinitionStatementsEvent $event): void
{
if (ExtensionManagementUtility::isLoaded('calendarize')) {
$event->addSqlData($this->getCalendarizeDatabaseString());
}
}

/**
* Get the calendarize string for the registered tables.
*
* @return string
*/
protected function getCalendarizeDatabaseString()
{
$sql = [];
foreach (Register::getRegister() as $configuration) {
if ($configuration['tableName'] == 'tx_calendarize_domain_model_event') {
$sql[] = "CREATE TABLE " . $configuration['tableName'] . " (
tx_odsosm_lon decimal(9,6) NOT NULL DEFAULT '0.000000',
tx_odsosm_lat decimal(8,6) NOT NULL DEFAULT '0.000000',
);";
}
}

return implode(LF, $sql);
}
}
16 changes: 16 additions & 0 deletions Configuration/Services.yaml
@@ -0,0 +1,16 @@
# PSR-14 EventListener for eventExtendedMultiple() in CalendarController
services:
_defaults:
autowire: true
autoconfigure: true
public: false

Bobosch\OdsOsm\:
resource: '../Classes/*'

Bobosch\OdsOsm\EventListener\CalendarizeOdsOsmSqlListener:
tags:
- name: event.listener
identifier: 'calendarizeOdsOsmSql'
event: TYPO3\CMS\Core\Database\Event\AlterTableDefinitionStatementsEvent
after: 'calendarizeField'
8 changes: 0 additions & 8 deletions ext_tables.sql
Expand Up @@ -20,14 +20,6 @@ CREATE TABLE sys_category (
tx_odsosm_marker int(10) unsigned NOT NULL DEFAULT '0'
);

--
-- Table structure for table 'tx_calendarize_domain_model_event'
--
CREATE TABLE tx_calendarize_domain_model_event (
tx_odsosm_lon decimal(9,6) NOT NULL DEFAULT '0.000000',
tx_odsosm_lat decimal(8,6) NOT NULL DEFAULT '0.000000'
);

--
-- Table structure for table 'tx_odsosm_geocache'
--
Expand Down

0 comments on commit 3025cf8

Please sign in to comment.