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

feat!: flatten pageType registration configuration structure #27

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions Classes/Registry/PageTypesRegistration.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,32 @@ public function registerPageTypesFromYamlFiles(): void
{
$pageTypes = $this->getAllPageTypeConfigurationFromFiles();

foreach ($pageTypes as $dokType => $pageTypeConfiguration) {
self::registerPageType(
$dokType,
$pageTypeConfiguration['configuration']
);
foreach ($pageTypes as $pageTypeConfiguration) {
self::registerPageType(...$pageTypeConfiguration);
}
}

/**
* Register a single pageType
*
* @param int $dokType The dokType to register the new pageType with
* @param array $configuration The configuration of the pageType
* @param int $dokType
* @param string $label
* @param array $iconSet
* @param bool $isDraggableInNewPageDragArea
* @return void
*/
public static function registerPageType(int $dokType, array $configuration): void
public static function registerPageType(
int $dokType,
string $label,
array $iconSet,
bool $isDraggableInNewPageDragArea = false
): void
{
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][ExtensionConfigurationUtility::EXTKEY]['pageTypes'][$dokType] = $configuration;
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][ExtensionConfigurationUtility::EXTKEY]['pageTypes'][$dokType] = [
'label' => $label,
'iconSet' => $iconSet,
'isDraggableInNewPageDragArea' => $isDraggableInNewPageDragArea
];
}

/**
Expand Down
61 changes: 26 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,61 +106,52 @@ Beside the first two pre-defined directory paths it is also possible to define a
#### 2.1.4 YAML File Example
```
dokType: 87
configuration:
label: 'My Custom pageType'
iconSet:
defaultIcon:
source: 'EXT:your_ext/Resources/Public/Icons/apps-pagetree-mycustompagetype.svg'
hideInMenuIcon:
identifier: 'apps-pagetree-page-frontend-user-hideinmenu'
rootPageIcon:
source: 'EXT:your_ext/Resources/Public/Icons/apps-pagetree-mycustompagetype-root.svg'
isDraggableInNewPageDragArea: true
label: 'My Custom pageType'
iconSet:
defaultIcon:
source: 'EXT:your_ext/Resources/Public/Icons/apps-pagetree-mycustompagetype.svg'
hideInMenuIcon:
identifier: 'apps-pagetree-page-frontend-user-hideinmenu'
rootPageIcon:
source: 'EXT:your_ext/Resources/Public/Icons/apps-pagetree-mycustompagetype-root.svg'
isDraggableInNewPageDragArea: true

```


### 2.2 Using ext_localconf.php
```
```php
\ITplusX\FlexiblePages\Registry\PageTypesRegistration::registerPageType(
87,
[
'label' => 'My Custom pageType',
'iconSet' => [
\ITplusX\FlexiblePages\Configuration\IconSetConfiguration::ICON_TYPE_DEFAULT => [
'source' => 'EXT:your_ext/Resources/Public/Icons/apps-pagetree-mycustompagetype.svg',
],
\ITplusX\FlexiblePages\Configuration\IconSetConfiguration::ICON_TYPE_HIDE_IN_MENU => [
'identifier' => 'apps-pagetree-page-frontend-user-hideinmenu',
]
\ITplusX\FlexiblePages\Configuration\IconSetConfiguration::ICON_TYPE_ROOT_PAGE => [
'source' => 'EXT:your_ext/Resources/Public/Icons/apps-pagetree-mycustompagetype-root.svg',
]
],
'isDraggableInNewPageDragArea' => true
87
'My Custom pageType',
[
\ITplusX\FlexiblePages\Configuration\IconSetConfiguration::ICON_TYPE_DEFAULT => [
'source' => 'EXT:your_ext/Resources/Public/Icons/apps-pagetree-mycustompagetype.svg',
],
\ITplusX\FlexiblePages\Configuration\IconSetConfiguration::ICON_TYPE_HIDE_IN_MENU => [
'identifier' => 'apps-pagetree-page-frontend-user-hideinmenu',
]
\ITplusX\FlexiblePages\Configuration\IconSetConfiguration::ICON_TYPE_ROOT_PAGE => [
'source' => 'EXT:your_ext/Resources/Public/Icons/apps-pagetree-mycustompagetype-root.svg',
]
],
'isDraggableInNewPageDragArea' => true
);
```


### 2.3 Configuration

#### 2.3.1 Registration parameters
| Parameter | Type | Mandatory | Description |
|---------------|-------|-----------|----------------------------------------------------------------------------------------------------|
| dokType | int | ✓ | The dokType to register the new pageType with |
| configuration | array | ✓ | The configuration of the pageType (see: [Configuration parameters](#232-configuration-parameters)) |


#### 2.3.2 Configuration parameters
| Parameter | Type | Mandatory | Description |
|------------------------------|--------|-----------|--------------------------------------------------------------------------------------------------------|
| dokType | int | ✓ | The dokType to register the new pageType with |
| label | string | ✓ | The label of the new pageType |
| iconSet | array | ✓ | The iconSet array of the newPageType. (see: [iconSet configuration parameters](#233-icons-parameters)) |
| iconSet | array | ✓ | The iconSet array of the newPageType. (see: [iconSet configuration parameters](#232-icons-parameters)) |
| isDraggableInNewPageDragArea | bool | | Defines if the new pageType is draggable from above the page tree. (Default: false) |


#### 2.3.3 Icons parameters
#### 2.3.2 Icons parameters
| Parameter | Type | Mandatory | Description | Possible values |
|----------------|-------|-----------|--------------------------------------------------------------|----------------------------------------------------------------------------------------------------------|
| defaultIcon | array | ✓ | The default icon of the page. | - `'source' => '/path/to/file.png'`(EXT: is allowed)<br> - `'identifier' => 'already-registered-identifier'` |
Expand Down