Skip to content

Commit fbd2de5

Browse files
authored
[BUGFIX] Make backend module work again (#168)
1 parent d014d0b commit fbd2de5

File tree

7 files changed

+14
-22
lines changed

7 files changed

+14
-22
lines changed

Build/rector/rector.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
use Rector\Config\RectorConfig;
1919
use Rector\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector;
20-
use Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector;
2120
use Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector;
2221
use Ssch\TYPO3Rector\CodeQuality\General\ExtEmConfRector;
2322
use Ssch\TYPO3Rector\Configuration\Typo3Option;

Classes/Controller/BackendController.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
use T3docs\BlogExample\Domain\Repository\PostRepository;
2727
use T3docs\BlogExample\Service\BlogFactory;
2828
use TYPO3\CMS\Backend\Template\Components\ButtonBar;
29+
use TYPO3\CMS\Backend\Template\Components\ComponentFactory;
2930
use TYPO3\CMS\Backend\Template\Components\Menu\Menu;
3031
use TYPO3\CMS\Backend\Template\ModuleTemplate;
3132
use TYPO3\CMS\Backend\Template\ModuleTemplateFactory;
@@ -58,6 +59,7 @@ public function __construct(
5859
protected readonly ModuleTemplateFactory $moduleTemplateFactory,
5960
private readonly IconFactory $iconFactory,
6061
private readonly LanguageServiceFactory $languageServiceFactory,
62+
protected readonly ComponentFactory $componentFactory,
6163
) {}
6264

6365
public function addPopulateButton(ButtonBar $buttonBar): void
@@ -265,17 +267,21 @@ private function buildMenu(ModuleTemplate $view, string &$context): Menu
265267
'index' => [
266268
'controller' => 'Backend',
267269
'action' => 'index',
268-
'label' => $this->getLanguageService()->sL('blog_example.messages:administration.menu.index'),
270+
'label' => $this->getLanguageService()->translate('administration.menu.index', 'blog_example.messages') ?? 'abc',
269271
],
270272
'showAllComents' => [
271273
'controller' => 'Backend',
272274
'action' => 'showAllComments',
273-
'label' => $this->getLanguageService()->sL('blog_example.messages:administration.menu.comments'),
275+
'label' => $this->getLanguageService()->translate('administration.menu.comments', 'blog_example.messages') ?? 'abc',
274276
],
275277
];
276278

279+
$menuRegistry = $view->getDocHeaderComponent()->getMenuRegistry();
280+
//$menu = $this->componentFactory->createMenu();
281+
//$menu->setIdentifier('viewSelector')->setLabel('View');
282+
277283
$menu = $view->getDocHeaderComponent()->getMenuRegistry()->makeMenu();
278-
$menu->setIdentifier('BlogExampleModuleMenu');
284+
$menu->setIdentifier('BlogExampleModuleMenu')->setLabel('View');
279285

280286
foreach ($menuItems as $menuItemConfig) {
281287
$isActive = $this->request->getControllerActionName() === $menuItemConfig['action'];

Classes/Domain/Model/Post.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class Post extends AbstractEntity implements \Stringable
5151
/**
5252
* @var ?ObjectStorage<Tag>
5353
*/
54+
#[Cascade(['value' => 'remove'])]
5455
public ?ObjectStorage $tags = null;
5556

5657
/**

Classes/Domain/Model/Tag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
* The TYPO3 project - inspiring people to share!
1818
*/
1919

20-
use TYPO3\CMS\Extbase\DomainObject\AbstractValueObject;
2120
use Symfony\Component\Validator\Constraints as Assert;
21+
use TYPO3\CMS\Extbase\DomainObject\AbstractValueObject;
2222

2323
/**
2424
* A blog post tag

Classes/Service/BlogFactory.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use T3docs\BlogExample\Domain\Model\Comment;
1010
use T3docs\BlogExample\Domain\Model\Person;
1111
use T3docs\BlogExample\Domain\Model\Post;
12-
use T3docs\BlogExample\Domain\Model\Tag;
1312
use TYPO3\CMS\Core\SingletonInterface;
1413

1514
/*
@@ -76,19 +75,6 @@ public function createBlog(int $blogNumber = 1): Blog
7675
$comment->setContent('Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.');
7776
$post->addComment($comment);
7877

79-
// create some random tags
80-
if (random_int(0, 1) > 0) {
81-
$tag = new Tag('MVC');
82-
$post->addTag($tag);
83-
}
84-
if (random_int(0, 1) > 0) {
85-
$tag = new Tag('Domain Driven Design');
86-
$post->addTag($tag);
87-
}
88-
if (random_int(0, 1) > 0) {
89-
$tag = new Tag('TYPO3');
90-
$post->addTag($tag);
91-
}
9278
// add the post to the current blog
9379
$blog->addPost($post);
9480
$post->setBlog($blog);

Configuration/TCA/Overrides/tt_content.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?php
22

33
declare(strict_types=1);
4-
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
54
use TYPO3\CMS\Extbase\Utility\ExtensionUtility;
65

76
defined('TYPO3') or die();
@@ -19,7 +18,7 @@
1918
'blog_example_icon',
2019
'blog_example',
2120
'LLL:blog_example.plugin:blog_list.description',
22-
'FILE:EXT:blog_example/Configuration/FlexForms/PluginSettings.xml'
21+
'FILE:EXT:blog_example/Configuration/FlexForms/PluginSettings.xml',
2322
);
2423
ExtensionUtility::registerPlugin(
2524
'blog_example',
@@ -28,5 +27,5 @@
2827
'blog_example_icon',
2928
'blog_example',
3029
'LLL:blog_example.plugin:blog_admin.description',
31-
'FILE:EXT:blog_example/Configuration/FlexForms/PluginSettings.xml'
30+
'FILE:EXT:blog_example/Configuration/FlexForms/PluginSettings.xml',
3231
);

Resources/Private/Backend/Templates/Index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<tr>
1616
<th class="nowrap align-top">Blog</th>
1717
<th class="align-top">Description</th>
18+
<th class="align-top">Description</th>
1819
<th class="align-top">&nbsp;</th>
1920
</tr>
2021
</thead>

0 commit comments

Comments
 (0)