Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create API to add custom Index/TimeTable Types #708

Closed
lochmueller opened this issue Oct 24, 2022 · 3 comments
Closed

Create API to add custom Index/TimeTable Types #708

lochmueller opened this issue Oct 24, 2022 · 3 comments

Comments

@lochmueller
Copy link
Owner

tbd.

@lochmueller
Copy link
Owner Author

Hey @okmiim
I added a Interface for custom time table generators incl. the addaptions in the right services:
2ab9d0d

It allows extension developers to register custom time table generators.
Bildschirmfoto 2023-01-17 um 22 59 28

All "custom generators" are disabled by default and could be enabled in the extension manager configuration of EXT.calendarize. So it is possible to ship a few generators, but also external generators are also possible.

Do you like this idea/API? I would add a few more generators/ideas shortly.

Regards,
Tim

@okmiim okmiim changed the title Create API to add custom Index Types Create API to add custom Index/TimeTable Types Oct 28, 2023
@okmiim
Copy link
Collaborator

okmiim commented Oct 28, 2023

Hi @lochmueller,

your implementation is not compatible with TYPO3v12 anymore.
When you try to instantiate the SecondaryTimeTableService in TCA, you get following error:
#1638976434 LogicException
TYPO3\CMS\Core\Cache\CacheManager can not be injected/instantiated during ext_localconf.php or TCA loading. Use lazy loading instead.

Alternative idea:
a) "Manually" create TCA configuration and add the items to flexform, type and types. The service is then (mostly) obsolete.


What I tried to implement: (Configuration/TCA/Overrides/tx_calendarize_domain_model_configuration.php)

$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' => [
            'config' => [
                'type' => 'flex',
                'ds_pointerField' => 'type',
                'ds' => $flexForms,
            ],
        ],
    ]
 );

@lochmueller
Copy link
Owner Author

Hey @okmiim ,
thanks for the preperation. I fixed the ext_localconf.php be remove one DI trigger in one of the service objects. I added your logic and tests the custom "Time Manipulation" example in v12.
Regards,
Tim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants