Skip to content

Commit

Permalink
Fix #708 - Fix custom TimeTable registration for TYPO3 v12
Browse files Browse the repository at this point in the history
  • Loading branch information
lochmueller committed Mar 11, 2024
1 parent e1cca0b commit 7af2244
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function getIdentifier(): string

public function getLabel(): string
{
return 'Manipulation';
return 'LLL:EXT:calendarize/Resources/Private/Language/locallang.xlf:configuration.type.calendarize_manipulation';
}

public function getTcaServiceTypeFields(): string
Expand Down
7 changes: 2 additions & 5 deletions Classes/Service/TimeTableService.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
*/
class TimeTableService extends AbstractService
{
public function __construct(protected ConfigurationRepository $configurationRepository)
{
}

/**
* Build the timetable for the given configuration matrix (sorted).
*/
Expand All @@ -44,7 +40,8 @@ public function getTimeTablesByConfigurationIds(array $ids, int $workspace): arr

// Disable Workspace for selection to get also offline versions of configuration
$GLOBALS['TCA']['tx_calendarize_domain_model_configuration']['ctrl']['versioningWS'] = false;
$configuration = $this->configurationRepository->findByUid($configurationUid);
// Do not use DI for repo to avoid problem in ext_localconf.php loading context
$configuration = GeneralUtility::makeInstance(ConfigurationRepository::class)->findByUid($configurationUid);
$GLOBALS['TCA']['tx_calendarize_domain_model_configuration']['ctrl']['versioningWS'] = true;
if (!($configuration instanceof Configuration)) {
continue;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

use HDNET\Calendarize\Domain\Model\Configuration;
use HDNET\Calendarize\Service\SecondaryTimeTableService;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;

$flexForms = [];

/** @var SecondaryTimeTableService $secondaryTimeTableService */
$secondaryTimeTableService = GeneralUtility::makeInstance(SecondaryTimeTableService::class);
$services = $secondaryTimeTableService->getSecondaryTimeTables();

if (!empty($services)) {
ExtensionManagementUtility::addTcaSelectItemGroup(
'tx_calendarize_domain_model_configuration',
'type',
'secondary',
'Secondary'
);
foreach ($services as $service) {
$timeTable = [
'label' => $service->getLabel(),
'value' => $service->getIdentifier(),
'group' => 'secondary',
];
$flexForms[$service->getIdentifier()] = $service->getFlexForm();
ExtensionManagementUtility::addTcaSelectItem(
'tx_calendarize_domain_model_configuration',
'type',
$timeTable
);
$GLOBALS['TCA']['tx_calendarize_domain_model_configuration']['ctrl']['typeicon_classes'][$service->getIdentifier()] = 'apps-calendarize-type-' . Configuration::TYPE_TIME;
$GLOBALS['TCA']['tx_calendarize_domain_model_configuration']['types'][$service->getIdentifier()]['showitem'] = $service->getTcaServiceTypeFields();
}
}
ExtensionManagementUtility::addTCAcolumns(
'tx_calendarize_domain_model_configuration',
[
'flex_form' => [
'label' => 'LLL:EXT:calendarize/Resources/Private/Language/locallang.xlf:tx_calendarize_domain_model_configuration.flex_form',
'config' => [
'type' => 'flex',
'ds_pointerField' => 'type',
'ds' => $flexForms,
],
],
]
);
6 changes: 6 additions & 0 deletions Resources/Private/Language/locallang.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
<trans-unit id="tx_calendarize_domain_model_configuration.end_date_dynamic">
<source>End date (dynamic)</source>
</trans-unit>
<trans-unit id="tx_calendarize_domain_model_configuration.flex_form">
<source>Configuration</source>
</trans-unit>
<trans-unit id="configuration.end_date_dynamic.1day">
<source>1 day</source>
</trans-unit>
Expand Down Expand Up @@ -362,6 +365,9 @@
<trans-unit id="configuration.type.timeExclude">
<source>Time (exclude)</source>
</trans-unit>
<trans-unit id="configuration.type.calendarize_manipulation">
<source>Time Manipulation</source>
</trans-unit>
<trans-unit id="configuration.state.canceled">
<source>Canceled</source>
</trans-unit>
Expand Down

0 comments on commit 7af2244

Please sign in to comment.