Skip to content

Commit

Permalink
[TASK] minimize registry parameter by reordering #5
Browse files Browse the repository at this point in the history
Relates to: #5
  • Loading branch information
Achim Fritz committed Jul 11, 2020
1 parent 722140c commit cc679f7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 5 deletions.
41 changes: 38 additions & 3 deletions Classes/Tca/Registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ class Registry implements SingletonInterface
* @param string $cType
* @param string $label
* @param string $description
* @param string $icon
* @param array $grid
* @param string $icon
* @param string $backendTemplate
* @param string $gridTemplate
* @param bool $registerInNewContentElementWizard
*/
public function registerContainer(
public function addContainer(
string $cType,
string $label,
string $description,
array $grid,
string $icon = 'EXT:container/Resources/Public/Icons/Extension.svg',
array $grid = [],
string $backendTemplate = 'EXT:container/Resources/Private/Templates/Container.html',
string $gridTemplate = 'EXT:container/Resources/Private/Templates/Grid.html',
bool $registerInNewContentElementWizard = true
Expand Down Expand Up @@ -71,6 +71,41 @@ public function registerContainer(
];
}


/**
* @param string $cType
* @param string $label
* @param string $description
* @param string $icon
* @param array $grid
* @param string $backendTemplate
* @param string $gridTemplate
* @param bool $registerInNewContentElementWizard
*/
public function registerContainer(
string $cType,
string $label,
string $description,
string $icon = 'EXT:container/Resources/Public/Icons/Extension.svg',
array $grid = [],
string $backendTemplate = 'EXT:container/Resources/Private/Templates/Container.html',
string $gridTemplate = 'EXT:container/Resources/Private/Templates/Grid.html',
bool $registerInNewContentElementWizard = true
): void
{
trigger_error('use "addContainer" instead of "registerContainer", parameter order changed!', E_USER_DEPRECATED);
$this->addContainer(
$cType,
$label,
$description,
$grid,
$icon,
$backendTemplate,
$gridTemplate,
$registerInNewContentElementWizard
);
}

/**
* @param string $cType
* @param int $colPos
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ see `EXT:container_example` for a simple usage of a custom container.

This is an example for create a 2 column container

\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\B13\Container\Tca\Registry::class)->registerContainer(
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\B13\Container\Tca\Registry::class)->addContainer(
'b13-2cols-with-header-container', // CType
'2 Column Container With Header', // label
'Some Description of the Container', // description
'EXT:container/Resources/Public/Icons/Extension.svg', // icon file, or existing icon identifier
[
[
['name' => 'header', 'colPos' => 200, 'colspan' => 2, 'allowed' => ['CType' => 'header, textmedia']] // rowspan also supported
Expand All @@ -55,6 +54,7 @@ This is an example for create a 2 column container
['name' => 'right side', 'colPos' => 202]
]
], // grid configuration
'EXT:container/Resources/Public/Icons/Extension.svg', // icon file, or existing icon identifier
'EXT:container/Resources/Private/Templates/Container.html', // Template for Backend View
'EXT:container/Resources/Private/Templates/Grid.html', // Template for Grid
true // register in new content element wizard
Expand Down

0 comments on commit cc679f7

Please sign in to comment.