-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #151 from verdigado/fix-calendarize-table-creation
create calendarize fields only if extension is loaded
- Loading branch information
Showing
3 changed files
with
55 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters