Skip to content

Commit

Permalink
[TASK] Improve compatibility to container 3.0.1
Browse files Browse the repository at this point in the history
As an event was enhanced, two classes in this extension are not needed anymore.
  • Loading branch information
garbast committed Nov 8, 2024
1 parent fec3860 commit 5164e08
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 168 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@

namespace Evoweb\EwCollapsibleContainer\EventListener;

use B13\Container\Backend\Grid\ContainerGridColumn;
use Evoweb\EwCollapsibleContainer\Xclass\BeforeContainerPreviewIsRenderedEvent;
use Evoweb\EwCollapsibleContainer\Xclass\ContainerGridColumn as BaseContainerGridColumn;
use B13\Container\Events\BeforeContainerPreviewIsRenderedEvent;
use B13\Container\Backend\Grid\ContainerGridColumn as BaseContainerGridColumn;
use Evoweb\EwCollapsibleContainer\Xclass\ContainerGridColumn;
use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;

Expand All @@ -35,16 +35,16 @@ public function __invoke(BeforeContainerPreviewIsRenderedEvent $event): void
}
}

protected function setColumnCollapsedState(int $recordUid, BaseContainerGridColumn $columnObject): void
protected function setColumnCollapsedState(int $recordUid, ContainerGridColumn $column): void
{
$backendUser = $this->getBackendUser();
$collapseId = $recordUid . ContainerGridColumn::CONTAINER_COL_POS_DELIMITER . $columnObject->getColumnNumber();
$collapseId = $recordUid . BaseContainerGridColumn::CONTAINER_COL_POS_DELIMITER . $column->getColumnNumber();
if (isset($backendUser->uc['moduleData']['list']['containerExpanded'][$collapseId])) {
$collapsed = $backendUser->uc['moduleData']['list']['containerExpanded'][$collapseId] > 0;
} else {
$collapsed = (bool)($columnObject->getDefinition()['collapsed'] ?? false);
$collapsed = (bool)($column->getDefinition()['collapsed'] ?? false);
}
$columnObject->setCollapsed($collapsed);
$column->setCollapsed($collapsed);
}

protected function getBackendUser(): BackendUserAuthentication
Expand Down
52 changes: 0 additions & 52 deletions Classes/Xclass/BeforeContainerPreviewIsRenderedEvent.php

This file was deleted.

87 changes: 0 additions & 87 deletions Classes/Xclass/ContainerPreviewRenderer.php

This file was deleted.

34 changes: 34 additions & 0 deletions Documentation/Example/Index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
.. include:: /Includes.rst.txt
.. index:: Example
.. _example:

=======
Example
=======

.. code-block:: php
:caption: Configuration/TCA/Overrides/tt_content.php
$configuration = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
\B13\Container\Tca\ContainerConfiguration::class,
'demo_container',
$languageFile . 'CType.I.demo_container',
$languageFile . 'CType.I.demo_container-plus_wiz_description',
[
[
[
'name' => 'Elements',
'colPos' => 200,
'allowed' => ['CType' => 'kwicks_element'],
'collapsed' => true,
'minitems' => 1,
'maxitems' => 5,
]
]
]
);
$configuration->setGroup('ew_fischer');
$configuration->setIcon('content-card-group');
GeneralUtility::makeInstance(Registry::class)->configureContainer($configuration);
1 change: 1 addition & 0 deletions Documentation/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ a GNU/GPL CMS/Framework available from http://typo3.org
:titlesonly:

Installation/Index
Example/Index

.. Meta Menu
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,17 @@ $configuration = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
'colPos' => 200,
'allowed' => ['CType' => 'kwicks_element'],
'collapsed' => true,
'minitems' => 1,
'maxitems' => 5,
]
]
]
);

$configuration->setGroup('ew_fischer');
$configuration->setIcon('content-card-group');

GeneralUtility::makeInstance(Registry::class)->configureContainer($configuration);
```

Add setTemplate to disable ability to collapse for defined container elements.
Expand Down
10 changes: 2 additions & 8 deletions Resources/Public/Css/container.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
display: inline-block;
}

[data-collapse-state="collapsed"] {
display: none;
}

[data-collapse-state="collapsed"],
.container-collapsed-column-marker {
display: none;
}
Expand All @@ -23,10 +20,7 @@
display: block;
}

.t3-page-ce {
display: none;
}

.t3-page-ce,
.t3-page-ce-wrapper {
display: none;
}
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
],
"require": {
"typo3/cms-backend": "^13.0 || 13.0.x-dev || dev-main",
"typo3/cms-core": "^13.0 || 13.0.x-dev || dev-main"
"typo3/cms-core": "^13.0 || 13.0.x-dev || dev-main",
"b13/container": "^3.0.1 || dev-master"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.62.0"
Expand Down
18 changes: 5 additions & 13 deletions ext_localconf.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
<?php

declare(strict_types=1);

defined('TYPO3') or die();

use B13\Container\Backend\Grid\ContainerGridColumn as BaseContainerGridColumn;
use B13\Container\Backend\Preview\ContainerPreviewRenderer as BaseContainerPreviewRenderer;
use Evoweb\EwCollapsibleContainer\Xclass\ContainerGridColumn;
use Evoweb\EwCollapsibleContainer\Xclass\ContainerPreviewRenderer;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;

call_user_func(function () {
if (ExtensionManagementUtility::isLoaded('container')) {
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][BaseContainerGridColumn::class] = [
'className' => ContainerGridColumn::class,
];
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][BaseContainerPreviewRenderer::class] = [
'className' => ContainerPreviewRenderer::class,
];
}
});
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][BaseContainerGridColumn::class] = [
'className' => ContainerGridColumn::class,
];

0 comments on commit 5164e08

Please sign in to comment.