Skip to content

Commit

Permalink
Update event registration (Register.php)
Browse files Browse the repository at this point in the history
  • Loading branch information
okmiim committed Nov 19, 2023
1 parent 02ac119 commit 4ce823e
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 162 deletions.
21 changes: 2 additions & 19 deletions Classes/Register.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class Register
* Register in the extTables.
*
* @param array $configuration
*
* @deprecated use Register::extLocalconf in your ext_localconf and Register::createTcaConfiguration in your TCA override configuration
*/
public static function extTables(array $configuration): void
{
Expand All @@ -36,25 +38,6 @@ public static function extLocalconf(array $configuration): void
self::registerItem($configuration);
}

/**
* Get the EXT:autoloader default configuration.
*
* @return array
*/
public static function getDefaultAutoloader(): array
{
return [
// 'SmartObjects', replaced with tca and sql
// 'Hooks', see ext_localconf.php
// 'Slots', @todo replace with event listener
// 'FlexForms', see Overrides/tt_content.php
// 'Icon', see Icons.php
// 'CommandController', see services.yaml
// 'StaticTyposcript', see Overrides/sys_template.php
// 'TypeConverter', see services.yaml
];
}

/**
* Get the register.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

use HDNET\Calendarize\Register;

defined('TYPO3') or exit();

Register::createTcaConfiguration(Register::getGroupCalendarizeConfiguration());
28 changes: 4 additions & 24 deletions Configuration/TCA/Overrides/tx_calendarize_domain_model_event.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,12 @@

declare(strict_types=1);

use HDNET\Calendarize\Register;

defined('TYPO3') or exit();

Register::createTcaConfiguration(Register::getDefaultCalendarizeConfiguration());

if (!\HDNET\Calendarize\Utility\ConfigurationUtility::get('disableDefaultEvent')) {
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToInsertRecords('tx_calendarize_domain_model_event');

$GLOBALS['TCA']['tx_calendarize_domain_model_event']['columns']['calendarize'] = [
'label' => 'Calendarize',
'l10n_mode' => 'exclude',
'config' => [
'type' => 'inline',
'foreign_table' => 'tx_calendarize_domain_model_configuration',
'minitems' => 1,
'maxitems' => 99,
'behaviour' => [
'enableCascadingDelete' => true,
],
],
];
$GLOBALS['TCA']['tx_calendarize_domain_model_event']['columns']['calendarize_info'] = [
'label' => 'LLL:EXT:calendarize/Resources/Private/Language/locallang.xlf:tca.information',
'config' => [
'type' => 'none',
'renderType' => 'calendarizeInfoElement',
'parameters' => [
'items' => 10,
],
],
];
}
9 changes: 9 additions & 0 deletions Configuration/TCA/Overrides/tx_kesearch_indexerconfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

defined('TYPO3') or exit();

if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('ke_search')) {
$GLOBALS['TCA']['tx_kesearch_indexerconfig']['columns']['sysfolder']['displayCond'] .= ',calendarize';
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,29 +74,6 @@
'required' => true,
],
],
'configurations' => [
'label' => 'Calendarize',
'l10n_mode' => 'exclude',
'config' => [
'type' => 'inline',
'foreign_table' => 'tx_calendarize_domain_model_configuration',
'minitems' => 1,
'maxitems' => 99,
'behaviour' => [
'enableCascadingDelete' => true,
],
],
],
'calendarize_info' => [
'label' => $ll . 'tca.information',
'config' => [
'type' => 'none',
'renderType' => 'calendarizeInfoElement',
'parameters' => [
'items' => 10,
],
],
],
'import_id' => [
'label' => $ll . 'tx_calendarize_domain_model_configurationgroup.import_id',
'exclude' => true,
Expand All @@ -105,6 +82,7 @@
'readOnly' => true,
],
],
// The columns 'configurations' and 'calendarize_info' are added in overrides
],
'palettes' => [
'access' => [
Expand Down
24 changes: 1 addition & 23 deletions Configuration/TCA/tx_calendarize_domain_model_event.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,35 +228,13 @@
],
'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:sys_category.categories',
],
'calendarize' => [
'label' => 'Calendarize',
'l10n_mode' => 'exclude',
'config' => [
'type' => 'inline',
'foreign_table' => 'tx_calendarize_domain_model_configuration',
'minitems' => 1,
'maxitems' => 99,
'behaviour' => [
'enableCascadingDelete' => true,
],
],
],
'calendarize_info' => [
'label' => $ll . 'tca.information',
'config' => [
'type' => 'none',
'renderType' => 'calendarizeInfoElement',
'parameters' => [
'items' => 10,
],
],
],
't3_origuid' => [
'config' => [
'type' => 'passthrough',
'default' => 0,
],
],
// The columns 'calendarize' and 'calendarize_info' are added in overrides
],
'palettes' => [
'language' => [
Expand Down
67 changes: 40 additions & 27 deletions Documentation/DeveloperManual/OwnEvents/Index.rst
Original file line number Diff line number Diff line change
@@ -1,52 +1,65 @@
.. include:: /Includes.txt

Own events
----------

.. _ownevents:

Own events
==========

The concept of the calendarize extension is the creation of own models and tables that should be part of the calendar output.

Configuration
-------------

Calendarize needs a configuration to handle your own model.
A common practice is to store this in a static function (e.g. :php:`Classes/Register.php`).

.. code-block:: php
:caption: EXT:some_extension/Classes/Register.php
// in ext_tables.php
$configuration = [...];
\HDNET\Calendarize\Register::extTables($configuration);
$configuration = [
// Unique Key for the register (e.g. you Extension Key + "Event")
'uniqueRegisterKey' => 'MyEvent',
// Title for your events (this is shown in the FlexForm configuration of the Plugins)
'title' => 'My Event',
// Name of your model
'modelName' => \HDNET\MyExtension\Domain\Model\MyEvent::class,
// Partials identifier (HTML) for your event (in most cases unique)
'partialIdentifier' => 'MyEvent',
// Table name of your event table
'tableName' => 'tx_myextension_domain_model_myevent',
// If true, your event requires at least one event configuration
'required' => true,
// [OPTIONAL] All classNames used for the extended models
'subClasses' => array of classnames,
// [OPTIONAL] Field name of the configurations, default is 'calendarize' (recommended)
'fieldName' => 'calendarize'
];
This configuration is then registered to calendarize by adding it to your :php:`ext_localconf.php`:

.. code-block:: php
:caption: EXT:some_extension/ext_localconf.php
// in ext_localconf.php
$configuration = [...];
\HDNET\Calendarize\Register::extLocalconf($configuration);
The following code show the configuration that should be the same in ext_tables and ext_localconf:
Additionally, you need to add the TCA configuration for the event configuration and information field:

.. code-block:: php
:caption: EXT:some_extension/Configuration/TCA/Overrides/<tx_extension_domain_model_event>.php
$configuration = [
'uniqueRegisterKey' => 'MyEvent', // A unique Key for the register (e.g. you Extension Key + "Event")
'title' => 'My Event', // The title for your events (this is shown in the FlexForm configuration of the Plugins)
'modelName' => \HDNET\MyExtension\Domain\Model\MyEvent::class, // the name of your model
'partialIdentifier' => 'MyEvent', // the identifier of the partials for your event. In most cases this is also unique
'tableName' => 'tx_myextension_domain_model_myevent', // the table name of your event table
'required' => true, // set to true, than your event need a least one event configuration
'subClasses' => array of classnames, // insert here all classNames, which are used for the extended models
];
Beginning with Typo3 version 8.5 frontend requests no longer load ext_tables.php in requests.
The only exception is if a backend user is logged in to the backend at the same time to initialize the admin panel or frontend editing.
In order to load the needed column mapping for your Model, you have to override the tca configuration for the corresponding table:
\HDNET\Calendarize\Register::createTcaConfiguration($configuration);
.. code-block:: php
// in Configuration/TCA/Overrides/<tx_extension_domain_model_event>.php
\HDNET\Calendarize\Register::createTcaConfiguration($configuration);
Change preview count
~~~~~~~~~~~~~~~~~~~~

To modify the amount of items shown in the preview you can change the amount in the ext_tables.php after calling the Register::extTables method.
The default value is 10 items.
To modify the amount of items shown in the preview you can change the amount in the TCA override.
10 items are displayed by default.

.. code-block:: php
:caption: EXT:some_extension/Configuration/TCA/Overrides/<tx_extension_domain_model_event>.php
// in ext_tables.php
$GLOBALS['TCA']['tx_myextension_domain_model_myevent']['columns']['calendarize_info']['config']['items'] = 25;
24 changes: 3 additions & 21 deletions ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@
/**
* General ext_localconf file.
*/

defined('TYPO3') or exit();

use HDNET\Calendarize\Controller\BookingController;
use HDNET\Calendarize\Controller\CalendarController;
use HDNET\Calendarize\Domain\Model\ConfigurationGroup;
use HDNET\Calendarize\Domain\Model\Event;
use HDNET\Calendarize\Form\Element\CalendarizeInfoElement;
use HDNET\Calendarize\Hooks\KeSearchIndexer;
use HDNET\Calendarize\Hooks\ProcessCmdmapClass;
use HDNET\Calendarize\Hooks\ProcessDatamapClass;
use HDNET\Calendarize\Register;
use HDNET\Calendarize\Typolink\DatabaseRecordLinkBuilder;
use HDNET\Calendarize\Utility\ConfigurationUtility;
use HDNET\Calendarize\Xclass\WorkspaceRemoteServer;
Expand All @@ -22,25 +20,9 @@
use TYPO3\CMS\Workspaces\Controller\Remote\RemoteServer;

(function () {
$GLOBALS['TYPO3_CONF_VARS']['EXT']['Calendarize']['ConfigurationGroup'] = [
'uniqueRegisterKey' => 'ConfigurationGroup',
'title' => 'Calendarize Configuration Group',
'modelName' => ConfigurationGroup::class,
'partialIdentifier' => 'ConfigurationGroup',
'tableName' => 'tx_calendarize_domain_model_configurationgroup',
'required' => true,
'fieldName' => 'configurations',
];

Register::extLocalconf(Register::getGroupCalendarizeConfiguration());
if (!(bool)ConfigurationUtility::get('disableDefaultEvent')) {
$GLOBALS['TYPO3_CONF_VARS']['EXT']['Calendarize']['Event'] = [
'uniqueRegisterKey' => 'Event',
'title' => 'Calendarize Event',
'modelName' => Event::class,
'partialIdentifier' => 'Event',
'tableName' => 'tx_calendarize_domain_model_event',
'required' => true,
];
Register::extLocalconf(Register::getDefaultCalendarizeConfiguration());
}

$calendar = CalendarController::class;
Expand Down
25 changes: 0 additions & 25 deletions ext_tables.php

This file was deleted.

0 comments on commit 4ce823e

Please sign in to comment.