!!!|Own module group (#106)

Add own module group and migrate old menu to different modules.
This should improve user experience as most users are used to modules
and are not aware of the dropdown menu.

Rename Overview controller to Configuration controller
As it handled configurations.
This streamlines with labels and identifiers.
This commit is contained in:
Daniel Siepmann 2023-01-30 15:51:17 +01:00 committed by GitHub
parent 45eda76e98
commit 6f98b353fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 200 additions and 128 deletions

View file

@ -25,8 +25,6 @@ namespace WerkraumMedia\ThueCat\Controller\Backend;
use TYPO3\CMS\Backend\View\BackendTemplateView;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Extbase\Mvc\View\ViewInterface;
use WerkraumMedia\ThueCat\View\Backend\Menu;
abstract class AbstractController extends ActionController
{
@ -43,17 +41,4 @@ abstract class AbstractController extends ActionController
* @var string
*/
protected $defaultViewObjectName = BackendTemplateView::class;
protected function initializeView(ViewInterface $view): void
{
if ($view instanceof BackendTemplateView) {
$this->getMenu()->addMenu(
$view->getModuleTemplate()->getDocHeaderComponent()->getMenuRegistry(),
$this->uriBuilder,
get_class($this)
);
}
}
abstract protected function getMenu(): Menu;
}

View file

@ -25,9 +25,8 @@ namespace WerkraumMedia\ThueCat\Controller\Backend;
use WerkraumMedia\ThueCat\Domain\Repository\Backend\ImportConfigurationRepository;
use WerkraumMedia\ThueCat\Domain\Repository\Backend\OrganisationRepository;
use WerkraumMedia\ThueCat\View\Backend\Menu;
class OverviewController extends AbstractController
class ConfigurationController extends AbstractController
{
/**
* @var OrganisationRepository
@ -39,19 +38,12 @@ class OverviewController extends AbstractController
*/
private $importConfigurationRepository;
/**
* @var Menu
*/
private $menu;
public function __construct(
OrganisationRepository $organisationRepository,
ImportConfigurationRepository $importConfigurationRepository,
Menu $menu
ImportConfigurationRepository $importConfigurationRepository
) {
$this->organisationRepository = $organisationRepository;
$this->importConfigurationRepository = $importConfigurationRepository;
$this->menu = $menu;
}
public function indexAction(): void
@ -61,9 +53,4 @@ class OverviewController extends AbstractController
'organisations' => $this->organisationRepository->findAll(),
]);
}
protected function getMenu(): Menu
{
return $this->menu;
}
}

View file

@ -30,7 +30,6 @@ use WerkraumMedia\ThueCat\Domain\Model\Backend\ImportConfiguration;
use WerkraumMedia\ThueCat\Domain\Repository\Backend\ImportLogRepository;
use WerkraumMedia\ThueCat\Extension;
use WerkraumMedia\ThueCat\Typo3Wrapper\TranslationService;
use WerkraumMedia\ThueCat\View\Backend\Menu;
class ImportController extends AbstractController
{
@ -49,21 +48,14 @@ class ImportController extends AbstractController
*/
private $translation;
/**
* @var Menu
*/
private $menu;
public function __construct(
Importer $importer,
ImportLogRepository $repository,
TranslationService $translation,
Menu $menu
TranslationService $translation
) {
$this->importer = $importer;
$this->repository = $repository;
$this->translation = $translation;
$this->menu = $menu;
}
public function indexAction(): void
@ -86,12 +78,7 @@ class ImportController extends AbstractController
$this->createImportDoneFlashMessage($importConfiguration);
}
$this->redirect('index', 'Backend\Overview');
}
protected function getMenu(): Menu
{
return $this->menu;
$this->redirect('index', 'Backend\Configuration');
}
private function createImportErrorFlashMessage(ImportConfiguration $importConfiguration): void

View file

@ -29,8 +29,8 @@ use TYPO3\CMS\Core\Imaging\IconRegistry;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Utility\ExtensionUtility;
use WerkraumMedia\ThueCat\Controller\Backend\ConfigurationController;
use WerkraumMedia\ThueCat\Controller\Backend\ImportController;
use WerkraumMedia\ThueCat\Controller\Backend\OverviewController;
class Extension
{
@ -51,17 +51,43 @@ class Extension
{
ExtensionUtility::registerModule(
self::EXTENSION_NAME,
'site',
'thuecat',
'',
'',
[],
[
OverviewController::class => 'index',
ImportController::class => 'import, index',
'access' => 'user,group',
'icon' => self::getIconPath() . 'ModuleGroup.svg',
'labels' => self::getLanguagePath() . 'locallang_mod.xlf',
]
);
ExtensionUtility::registerModule(
self::EXTENSION_NAME,
'thuecat',
'configurations',
'',
[
ConfigurationController::class => 'index',
ImportController::class => 'import',
],
[
'access' => 'user,group',
'icon' => self::getIconPath() . 'Extension.svg',
'labels' => self::getLanguagePath() . 'locallang_mod.xlf',
'icon' => self::getIconPath() . 'ModuleConfigurations.svg',
'labels' => self::getLanguagePath() . 'locallang_mod_configurations.xlf',
]
);
ExtensionUtility::registerModule(
self::EXTENSION_NAME,
'thuecat',
'imports',
'',
[
ImportController::class => 'index,import',
],
[
'access' => 'user,group',
'icon' => self::getIconPath() . 'ModuleImports.svg',
'labels' => self::getLanguagePath() . 'locallang_mod_imports.xlf',
]
);
}

View file

@ -0,0 +1,114 @@
<?php
declare(strict_types=1);
/*
* Copyright (C) 2023 Daniel Siepmann <coding@daniel-siepmann.de>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
namespace WerkraumMedia\ThueCat\Updates;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Install\Updates\DatabaseUpdatedPrerequisite;
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;
class BackendModuleUserPermission implements UpgradeWizardInterface
{
/**
* @var ConnectionPool
*/
private $connectionPool;
public function __construct(
ConnectionPool $connectionPool
) {
$this->connectionPool = $connectionPool;
}
public function getIdentifier(): string
{
return self::class;
}
public function getTitle(): string
{
return 'Update user permissions for ThüCAT modules.';
}
public function getDescription(): string
{
return 'The module was migrated to an own group which changes the permission identifiers.';
}
public function updateNecessary(): bool
{
$qb = $this->connectionPool->getQueryBuilderForTable('be_users');
$qb->getRestrictions()->removeAll();
$qb->count('*');
$qb->from('be_users');
$qb->where($qb->expr()->like('userMods', $qb->createNamedParameter('%site_ThuecatThuecat%')));
return $qb->execute()->fetchOne() > 0;
}
public function executeUpdate(): bool
{
$qb = $this->connectionPool->getQueryBuilderForTable('be_users');
$qb->getRestrictions()->removeAll();
$qb->select('uid', 'userMods');
$qb->from('be_users');
$qb->where($qb->expr()->like('userMods', $qb->createNamedParameter('%site_ThuecatThuecat%')));
$result = $qb->execute();
foreach ($result as $backendUser) {
$qb = $this->connectionPool->getQueryBuilderForTable('be_users');
$qb->update('be_users');
$qb->set('userMods', $this->updateMods($backendUser['userMods']));
$qb->where($qb->expr()->eq('uid', $qb->createNamedParameter($backendUser['uid'])));
$qb->execute();
}
return true;
}
private function updateMods(string $mods): string
{
$mods = GeneralUtility::trimExplode(',', $mods, true);
unset($mods[array_search('site_ThuecatThuecat', $mods)]);
$mods[] = 'ThuecatThuecat';
$mods[] = 'ThuecatThuecat_ThuecatConfigurations';
$mods[] = 'ThuecatThuecat_ThuecatImports';
return implode(',', $mods);
}
public function getPrerequisites(): array
{
return [
DatabaseUpdatedPrerequisite::class,
];
}
public static function register(): void
{
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'][self::class] = self::class;
}
}

View file

@ -1,68 +0,0 @@
<?php
declare(strict_types=1);
/*
* Copyright (C) 2021 Daniel Siepmann <coding@daniel-siepmann.de>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
namespace WerkraumMedia\ThueCat\View\Backend;
use TYPO3\CMS\Backend\Template\Components\MenuRegistry;
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
use WerkraumMedia\ThueCat\Controller\Backend\ImportController;
use WerkraumMedia\ThueCat\Controller\Backend\OverviewController;
use WerkraumMedia\ThueCat\Extension;
use WerkraumMedia\ThueCat\Typo3Wrapper\TranslationService;
class Menu
{
/**
* @var TranslationService
*/
private $translation;
public function __construct(
TranslationService $translation
) {
$this->translation = $translation;
}
public function addMenu(
MenuRegistry $registry,
UriBuilder $uriBuilder,
string $controllerClassName
): void {
$menu = $registry->makeMenu();
$menu->setIdentifier('action');
$menuItem = $menu->makeMenuItem();
$menuItem->setTitle($this->translation->translate('module.overview.headline', Extension::EXTENSION_NAME));
$menuItem->setHref($uriBuilder->reset()->uriFor('index', [], 'Backend\Overview'));
$menuItem->setActive($controllerClassName === OverviewController::class);
$menu->addMenuItem($menuItem);
$menuItem = $menu->makeMenuItem();
$menuItem->setTitle($this->translation->translate('module.imports.headline', Extension::EXTENSION_NAME));
$menuItem->setHref($uriBuilder->reset()->uriFor('index', [], 'Backend\Import'));
$menuItem->setActive($controllerClassName === ImportController::class);
$menu->addMenuItem($menuItem);
$registry->addMenu($menu);
}
}

View file

@ -4,7 +4,9 @@
Breaking
--------
Nothing
* Permissions of backend modules.
The modules got new identifiers. User permissions need to be adjusted.
An update wizard is provided that will migrate the permissions.
Features
--------

View file

@ -31,7 +31,7 @@
<source>Actions</source>
</trans-unit>
<trans-unit id="module.overview.headline" xml:space="preserve">
<source>ThüCAT - Overview</source>
<source>ThüCAT - Configurations</source>
</trans-unit>
<trans-unit id="module.importConfigurations.headline" xml:space="preserve">

View file

@ -4,13 +4,10 @@
<header/>
<body>
<trans-unit id="mlang_labels_tablabel" resname="mlang_labels_tablabel">
<source>ThüCat</source>
</trans-unit>
<trans-unit id="mlang_labels_tabdescr" resname="mlang_labels_tabdescr">
<source>Provides access to current connection, imported data and configuration.</source>
<source>ThüCAT</source>
</trans-unit>
<trans-unit id="mlang_tabs_tab" resname="mlang_tabs_tab">
<source>ThüCat</source>
<source>ThüCAT</source>
</trans-unit>
</body>
</file>

View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" datatype="plaintext" original="messages" date="2021-02-01T09:56:02Z" product-name="ThueCat Backend Module Labels (Title, Description, …)">
<header/>
<body>
<trans-unit id="mlang_tabs_tab" resname="mlang_tabs_tab">
<source>Configurations</source>
</trans-unit>
<trans-unit id="mlang_labels_tablabel" resname="mlang_labels_tablabel">
<source>Provides an short overview</source>
</trans-unit>
<trans-unit id="mlang_labels_tabdescr" resname="mlang_labels_tabdescr">
<source>Shows all existing import configurations and allows to edit, import and create new configurations.</source>
</trans-unit>
</body>
</file>
</xliff>

View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" datatype="plaintext" original="messages" date="2021-02-01T09:56:02Z" product-name="ThueCat Backend Module Labels (Title, Description, …)">
<header/>
<body>
<trans-unit id="mlang_tabs_tab" resname="mlang_tabs_tab">
<source>Imports</source>
</trans-unit>
<trans-unit id="mlang_labels_tablabel" resname="mlang_labels_tablabel">
<source>Shows executed imports and their results</source>
</trans-unit>
<trans-unit id="mlang_labels_tabdescr" resname="mlang_labels_tabdescr">
<source>Provides detailed overview of errors during imports, as well as how many records of each type were imported.</source>
</trans-unit>
</body>
</file>
</xliff>

View file

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><svg id="b" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><g id="c"><path d="m64,64H0V0h64v64Z" style="fill:#ffd400;"/><path d="m19,21c.55,0,1-.45,1-1s-.45-1-1-1-1,.45-1,1,.45,1,1,1Zm3-1c0-.55.45-1,1-1h22c.55,0,1,.45,1,1s-.45,1-1,1h-22c-.55,0-1-.44-1-1Zm-6-3h32v6H16v-6Zm3,12c.55,0,1-.45,1-1s-.45-1-1-1-1,.45-1,1,.45,1,1,1Zm3-1c0-.55.45-1,1-1h22c.55,0,1,.45,1,1s-.45,1-1,1h-22c-.55,0-1-.44-1-1Zm-6-3h32v6H16v-6Zm3,12c.55,0,1-.45,1-1s-.45-1-1-1-1,.45-1,1,.45,1,1,1Zm3-1c0-.55.45-1,1-1h22c.55,0,1,.45,1,1s-.45,1-1,1h-22c-.55,0-1-.44-1-1Zm-6-3h32v6H16v-6Zm6,11c0-.55.45-1,1-1h22c.55,0,1,.45,1,1s-.45,1-1,1h-22c-.55,0-1-.44-1-1Zm-3,1c.55,0,1-.45,1-1s-.45-1-1-1-1,.45-1,1,.45,1,1,1Zm-3-4h32v6H16v-6Z" style="fill:#fff; fill-rule:evenodd;"/><path d="m50.92,39.01c0,5.8-4.7,10.5-10.5,10.5s-10.5-4.7-10.5-10.5,4.7-10.5,10.5-10.5,10.5,4.7,10.5,10.5Z" style="fill:#ffd400;"/><path d="m48.21,37.81l-2.43-.69c-.07-.19-.14-.38-.23-.56l1.22-2.2c.06-.11.04-.25-.05-.34l-1.31-1.31c-.09-.09-.23-.11-.34-.05l-2.2,1.22c-.18-.09-.37-.16-.56-.23l-.69-2.43c-.04-.12-.15-.21-.28-.21h-1.85c-.13,0-.24.08-.27.21l-.69,2.43c-.19.07-.38.14-.56.23l-2.2-1.22c-.11-.06-.25-.04-.34.05l-1.31,1.31c-.09.09-.11.23-.05.34l1.22,2.2c-.09.18-.16.37-.23.56l-2.43.69c-.12.04-.21.15-.21.28v1.85c0,.13.08.24.21.27l2.43.69c.07.19.14.38.23.56l-1.22,2.2c-.06.11-.04.25.05.34l1.31,1.31c.09.09.23.11.34.05l2.2-1.22c.18.09.37.16.56.23l.69,2.43c.04.12.15.21.28.21h1.85c.13,0,.24-.08.27-.21l.69-2.43c.19-.07.38-.14.56-.23l2.2,1.22c.11.06.25.04.34-.05l1.31-1.31c.09-.09.11-.23.05-.34l-1.22-2.2c.09-.18.16-.37.23-.56l2.43-.69c.12-.04.21-.15.21-.28v-1.85c0-.13-.08-.24-.21-.28Zm-7.79,4.63c-1.89,0-3.43-1.53-3.43-3.43s1.53-3.43,3.43-3.43,3.43,1.53,3.43,3.43-1.53,3.43-3.43,3.43Zm1.44-3.43c0,.79-.64,1.44-1.44,1.44s-1.44-.64-1.44-1.44.64-1.44,1.44-1.44,1.44.64,1.44,1.44Z" style="fill:#fff;"/><path d="m48.92,47.58h-8v-8h8v8Z" style="fill:#fff; stroke:#ffd400; stroke-miterlimit:10;"/><polygon points="47.35 43.65 45.42 43.65 45.42 41.08 44.42 41.08 44.42 43.65 42.49 43.65 44.92 46.08 47.35 43.65" style="fill:#ffd400;"/></g></svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

View file

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><svg id="b" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><g id="c"><path d="m64,64H0V0h64v64Z" style="fill:#ffd400;"/><path d="m42.05,47.31h-23.57c-.59,0-1.07-.48-1.07-1.07V15.32c0-.59.48-1.07,1.07-1.07h23.57c.59,0,1.07.48,1.07,1.07v30.92c0,.59-.48,1.07-1.07,1.07Z" style="fill:#fff;"/><path d="m19.24,16.09h1.85s.07.03.07.07v29.25s-.03.07-.07.07h-1.85s-.07-.03-.07-.07v-29.25s.03-.07.07-.07Z" style="fill:#ffd400;"/><rect x="24.75" y="19.66" width="14.69" height="13.78" style="fill:#ffe780;"/><path d="m26.64,29.19h10.92s.05.03.05.07v1.85s-.02.07-.05.07h-10.92s-.05-.03-.05-.07v-1.85s.02-.07.05-.07Z" style="fill:#fff;"/><path d="m48.63,39.2v9.52c0,.59-.48,1.07-1.07,1.07h-21.73c-.59,0-1.07-.48-1.07-1.07v-9.52c0-.59.48-1.07,1.07-1.07h21.73c.59,0,1.07.48,1.07,1.07Z" style="fill:#fff;"/><path d="m47.65,50.25h-21.91c-.8,0-1.44-.65-1.44-1.44v-9.69c0-.8.65-1.44,1.44-1.44h21.91c.8,0,1.44.65,1.44,1.44v9.69c0,.8-.65,1.44-1.44,1.44Zm-21.91-11.66c-.29,0-.53.24-.53.53v9.69c0,.29.24.53.53.53h21.91c.29,0,.53-.24.53-.53v-9.69c0-.29-.24-.53-.53-.53h-21.91Z" style="fill:#ffd400;"/><path d="m32.22,46.83h-4.31v-5.97h1.54v4.81h2.77v1.15Z" style="fill:#ffd400;"/><path d="m38.95,43.85c0,.95-.27,1.71-.82,2.27s-1.3.84-2.26.84-1.71-.28-2.26-.84-.82-1.31-.82-2.27.27-1.72.82-2.27,1.3-.84,2.26-.84,1.71.28,2.26.84c.55.56.82,1.31.82,2.27Zm-2.04,1.51c.15-.18.26-.4.33-.64.07-.25.11-.54.11-.87,0-.36-.04-.66-.12-.91-.08-.25-.19-.45-.32-.61-.14-.16-.29-.28-.47-.35-.18-.07-.36-.11-.56-.11s-.38.03-.55.1c-.17.07-.33.18-.47.34-.13.15-.24.36-.33.62-.08.26-.13.57-.13.92s.04.66.12.91c.08.25.19.45.32.61s.29.27.47.35c.18.07.37.11.57.11s.39-.04.57-.11.34-.19.47-.35Z" style="fill:#ffd400;"/><path d="m45.41,46.49c-.27.1-.62.21-1.06.31-.44.1-.88.16-1.32.16-1.02,0-1.81-.28-2.38-.83-.57-.55-.86-1.31-.86-2.29s.29-1.67.87-2.24c.58-.57,1.39-.85,2.43-.85.39,0,.77.03,1.12.11s.75.21,1.19.42v1.4h-.17c-.08-.06-.18-.14-.33-.24-.14-.1-.28-.19-.42-.26-.15-.09-.34-.16-.54-.22-.21-.06-.43-.09-.66-.09-.27,0-.52.04-.74.12-.22.08-.42.2-.6.37-.17.16-.3.36-.4.61-.1.25-.15.53-.15.86,0,.66.17,1.17.53,1.52s.87.52,1.55.52c.06,0,.12,0,.19,0s.14,0,.19-.01v-1.17h-1.19v-1.13h2.75v2.95Z" style="fill:#ffd400;"/><polygon points="35.45 25 28.75 25 32.1 28.35 35.45 25" style="fill:#fff;"/><line x1="32.1" y1="21.92" x2="32.1" y2="25.45" style="fill:none; stroke:#fff; stroke-miterlimit:10; stroke-width:2px;"/></g></svg>

After

Width:  |  Height:  |  Size: 2.4 KiB

View file

@ -11,7 +11,7 @@ $EM_CONF[$_EXTKEY] = [
'author' => 'Daniel Siepmann',
'author_email' => 'coding@daniel-siepmann.de',
'author_company' => '',
'version' => '1.3.0',
'version' => '2.0.0',
'constraints' => [
'depends' => [
'core' => '',

View file

@ -4,6 +4,8 @@ defined('TYPO3') or die();
\WerkraumMedia\ThueCat\Extension::registerConfig();
\WerkraumMedia\ThueCat\Updates\BackendModuleUserPermission::register();
(static function (string $extensionKey) {
TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScriptSetup(
'@import "EXT:' . $extensionKey . '/Configuration/TypoScript/Default/Setup.typoscript"'

View file

@ -11,5 +11,9 @@ parameters:
checkGenericClassInNonGenericObjectType: false
ignoreErrors:
# Depending on TYPO3 version
- "#^Cannot call method fetchColumn\\(\\) on Doctrine\\\\DBAL\\\\Result\\|int\\.$#"
- "#^Argument of an invalid type Doctrine\\\\DBAL\\\\Driver\\\\ResultStatement\\|int supplied for foreach, only iterables are supported\\.$#"
- "#^Argument of an invalid type Doctrine\\\\DBAL\\\\Result\\|int supplied for foreach, only iterables are supported\\.$#"
- "#^Cannot call method fetchColumn\\(\\) on Doctrine\\\\DBAL\\\\Driver\\\\ResultStatement\\|int\\.$#"
- "#^Cannot call method fetchColumn\\(\\) on Doctrine\\\\DBAL\\\\Result\\|int\\.$#"
- "#^Cannot call method fetchOne\\(\\) on Doctrine\\\\DBAL\\\\Driver\\\\ResultStatement\\|int\\.$#"
- "#^Cannot call method fetchOne\\(\\) on Doctrine\\\\DBAL\\\\Result\\|int\\.$#"