Skip to content
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
31 changes: 23 additions & 8 deletions Classes/Controller/TaskController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use TYPO3\CMS\Backend\Template\ModuleTemplateFactory;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Imaging\IconSize;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Pagination\SimplePagination;
use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity;
Expand Down Expand Up @@ -90,7 +91,7 @@ public function __construct(
PersistenceManagerInterface $persistenceManager,
ModuleTemplateFactory $moduleTemplateFactory,
IconFactory $iconFactory,
private readonly ComponentFactory $componentFactory
private readonly Typo3Version $typo3Version
) {
$this->taskRepository = $taskRepository;
$this->persitenceManager = $persistenceManager;
Expand All @@ -102,10 +103,17 @@ public function initializeAction(): void
{
parent::initializeAction(); // TODO: Change the autogenerated stub
$this->moduleTemplate = $this->moduleTemplateFactory->create($this->request);
$menu = $this->componentFactory->createMenu();
if ($this->typo3Version->getMajorVersion() >= 14) {
$componentFactory = GeneralUtility::makeInstance(ComponentFactory::class);
$menu = $componentFactory->createMenu();
$menuItem = $componentFactory->createMenuItem();
} else {
// @todo Remove this TYPO3 13 fallback (and this version check) once TYPO3 13 support is dropped.
$menu = $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->makeMenu();
$menuItem = $menu->makeMenuItem();
}
$menu->setIdentifier('TaskqueueMenu');
$menuItem = $this->componentFactory
->createMenuItem()
$menuItem = $menuItem
->setHref(
$this->uriBuilder->buildBackendUri()
)
Expand Down Expand Up @@ -366,6 +374,13 @@ protected function buildSimplePagination(SimplePagination $simplePagination, Que
protected function buildButtons()
{
$buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
if ($this->typo3Version->getMajorVersion() >= 14) {
$componentFactory = GeneralUtility::makeInstance(ComponentFactory::class);
$createLinkButton = static fn () => $componentFactory->createLinkButton();
} else {
// @todo Remove this TYPO3 13 fallback (and this version check) once TYPO3 13 support is dropped.
$createLinkButton = static fn () => $buttonBar->makeLinkButton();
}
$buttons = [
[
'table' => 'tx_taskqueue_domain_model_task',
Expand All @@ -382,7 +397,7 @@ protected function buildButtons()
];
foreach ($buttons as $tableConfiguration) {
$title = LocalizationUtility::translate($tableConfiguration['label'], 'taskqueue');
$viewButton = $this->componentFactory->createLinkButton()
$viewButton = $createLinkButton()
->setHref($this->uriBuilder->reset()->setRequest($this->request)->uriFor(
$tableConfiguration['action'],
[],
Expand All @@ -397,7 +412,7 @@ protected function buildButtons()
$buttonBar->addButton($viewButton, ButtonBar::BUTTON_POSITION_LEFT, 2);
}

$deleteFinished = $this->componentFactory->createLinkButton()
$deleteFinished = $createLinkButton()
->setShowLabelText(true)
->setHref($this->uriBuilder->reset()->setRequest($this->request)->uriFor(
'deleteFinished',
Expand All @@ -413,7 +428,7 @@ protected function buildButtons()
->setIcon($this->iconFactory->getIcon('actions-delete', IconSize::SMALL, 'tx-taskqueue-status-finished'));
$buttonBar->addButton($deleteFinished, ButtonBar::BUTTON_POSITION_LEFT, 3);

$deleteFailed = $this->componentFactory->createLinkButton()
$deleteFailed = $createLinkButton()
->setShowLabelText(true)
->setHref($this->uriBuilder->reset()->setRequest($this->request)->uriFor(
'deleteFailed',
Expand All @@ -430,7 +445,7 @@ protected function buildButtons()
$buttonBar->addButton($deleteFailed, ButtonBar::BUTTON_POSITION_LEFT, 3);

// Refresh
$refreshButton = $this->componentFactory->createLinkButton()
$refreshButton = $createLinkButton()
->setHref(GeneralUtility::getIndpEnv('REQUEST_URI'))
->setTitle($this->getLanguageService()->sL('core.core:labels.reload'))
->setIcon($this->iconFactory->getIcon('actions-refresh', IconSize::SMALL));
Expand Down
9 changes: 0 additions & 9 deletions Configuration/Services.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Component\DependencyInjection\Reference;
use TYPO3\CMS\Backend\Template\Components\ComponentFactory;
use TYPO3\CMS\Backend\View\BackendViewFactory;
use TYPO3\CMS\Dashboard\Dashboard;
use Undkonsorten\Taskqueue\Controller\TaskController;
use TYPO3\CMS\Dashboard\Widgets\BarChartWidget;
use Undkonsorten\Taskqueue\Widget\LatestTasksWidget;
use Undkonsorten\Taskqueue\Widget\Provider\FailedTasksProvider;
Expand All @@ -21,13 +19,6 @@
return static function (ContainerConfigurator $configurator, ContainerBuilder $containerBuilder) {
$services = $configurator->services();

if (class_exists(ComponentFactory::class)) {
$services->set(TaskController::class)
->autowire()
->autoconfigure()
->tag('backend.controller');
}

if ($containerBuilder->hasDefinition(Dashboard::class)) {
$services->set('dashboard.widget.taskqueue.latestTasks')
->class(LatestTasksWidget::class)
Expand Down
5 changes: 3 additions & 2 deletions Configuration/Services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ services:

Undkonsorten\Taskqueue\:
resource: '../Classes/*'
exclude:
- '../Classes/Controller/TaskController.php'

Undkonsorten\Taskqueue\Controller\TaskController:
tags: [ 'backend.controller' ]

Undkonsorten\Taskqueue\Command\RunTasksCommand:
tags:
Expand Down
42 changes: 42 additions & 0 deletions Tests/Functional/Controller/TaskControllerContainerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

declare(strict_types=1);

namespace Undkonsorten\Taskqueue\Tests\Functional\Controller;

use PHPUnit\Framework\Attributes\CoversNothing;
use PHPUnit\Framework\Attributes\Test;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
use Undkonsorten\Taskqueue\Controller\TaskController;

/**
* Regression test for the "TaskController service or alias has been removed or inlined when
* the container was compiled" error: `Configuration/Backend/Modules.php` wires the "taskqueue"
* backend module's `controllerActions` directly to `TaskController::class`, so TYPO3's backend
* module dispatcher fetches it straight from the container. When the service definition is
* excluded from registration (as it was before this fix, on TYPO3 13), Symfony's compiler
* strips it entirely as unused - it disappears from both the public and the "private" container
* (`FunctionalTestCase::has()` checks both), which is exactly what `assertTrue` below pins.
*
* Deliberately uses `has()`, not `get()`: fully constructing an ActionController through the
* container outside of an actual HTTP request fails for an unrelated reason (Extbase's
* ConfigurationManager requires a current request, see
* Tests/Functional/Configuration/CliAwareConfigurationManagerNotRequiredTest.php) - `has()`
* checks the DI registration/visibility itself without needing a request context.
*
* A unit test cannot catch this because it never touches the container, and
* Tests/Unit/Controller/TaskControllerTest.php specifically bypasses the constructor.
*/
#[CoversNothing]
final class TaskControllerContainerTest extends FunctionalTestCase
{
protected array $testExtensionsToLoad = [
'undkonsorten/taskqueue',
];

#[Test]
public function taskControllerIsRegisteredInTheContainer(): void
{
self::assertTrue($this->has(TaskController::class));
}
}
2 changes: 1 addition & 1 deletion ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
'author' => 'Eike Starkmann',
'author_email' => 'starkmann@undkonsorten.com',
'state' => 'stable',
'version' => '9.6.1',
'version' => '9.6.2',
'constraints' => [
'depends' => [
'typo3' => '13.4.0-14.3.99',
Expand Down
Loading