#108557Streamline Page Types
Description
There are several old gimmicks that were made for Page Types, which can now be streamlined so that Content Blocks has an easier time adding new types.
1. PageDoktypeRegistry
This is the registry for the former global $PAGE_TYPES. The name is misleading, as the real registration of Page Types is made through TCA.
The registry is more or less a restriction container which is used when adding new Records to Pages.
1.1 When the new TCA option “security.ignorePageTypeRestriction” was added for TCA tables, the class received lots of “initializeTca” calls, because it now extends the registry. This was mainly made to maintain the API.
The main interest in this class is the method “isRecordTypeAllowedForDoktype”. This logic should be introduced in a new service called “RecordOnPageRestriction” or something similar. This service reverses the current approach: First load TCA allowed records and then enrich them with the state of PageDoktypeRegistry.
1.2 As more and more moves towards TCA, it is a low hanging fruit to introduce a new TCA option “allowedTables” for Page Types:
TCA.pages.types.123.allowedTables = ‘aTable’
This way, both “allowedTables” and “ignorePageTypeRestriction” are defined in TCA and can be consolidated by only using TcaSchema.
1.3 Only thing left is the peculiar option “onlyAllowedTables”. This option has no own usage in Core Page Types. However, if set for custom Page Types, this will enforce that allowed Tables are considered when switching Page Types (doktypes).
There are some options we can go:
1. As there is no usage in Core and it is seldom used, we could drop this option altogether. Corresponding Code in DataHandler could be removed.
2. As this option enforces database integrity, it is a good thing and could be enabled by default and make it not configurable anymore.
3. Leave the logic as is, but introduce a new option in TCA instead. Give it a better name to distinguish from allowedTables along the way.
1.4 When there is almost nothing left in PageDoktypeRegistry, remove it with a breaking change while introducing new, more specific APIs to replace leftover functionality.
2.0 User TsConfig options.pageTree.doktypesToShowInNewPageDragArea
It is tedious to always add the new Page Type to the Drag/Drop area via User TsConfig. It would be far better to handle it like the current way in NewContentElementWizard: Load all available Page Types from TcaSchema and remove unwanted Page Types individually.
3.0 After all this cleanup the Content Blocks code can be simplified.
3.1 Remove call to PageDoktypeRegistry and introduce new options “allowedTables” and maybe “enforceAllowedTablesWhenSwitchingTypes”.
3.2 Remove added user tsconfig