Task #87550

Use controller classes when registering plugins/modules

Added by Alexander Schnitzler 10 months ago. Updated 4 months ago.

Status:
Closed
Priority:
Should have
Category:
Extbase
Start date:
2019-01-25
Due date:
% Done:

100%

TYPO3 Version:
10
PHP Version:
7.2
Tags:
Complexity:
Sprint Focus:

Related issues

Related to TYPO3 Core - Bug #88513: Non-FQCN controllers should still be usable in Extbase Closed 2019-06-06

Associated revisions

Revision e67b6cf1 (diff)
Added by Alexander Schnitzler 9 months ago

[TASK] Use FQCN's when registering plugins/modules

The following methods used controller aliases:

- \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin
- \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule

This means, that while configuring plugins or modules, a list
of controllers (and their actions) had to be provided, so they
could be registered as available controllers for said plugin
or module.

The controller name used for the registration, was kind of an
alias for that controller. It was the class name without the
namespace and without the "Controller" suffix. By a certain
convention a proper class name could be derived from that
alias. All this was necessary back then when TYPO3 didn't have
a proper autoloader and when the class location was derived
from the class name. These circumstances do not exist any more
and since it's only important that a controller class exists,
the registration of plugins must now use the fully qualified
controller class name as array key.

The former syntax

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'TYPO3.CMS.IndexedSearch',
'Pi2',
['Search' => 'form,search,noTypoScript'],
['Search' => 'form,search']
);

has to be converted to

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'IndexedSearch',
'Pi2',
[
\TYPO3\CMS\IndexedSearch\Controller\SearchController::class
=> 'form,search,noTypoScript'
],
[
\TYPO3\CMS\IndexedSearch\Controller\SearchController::class
=> 'form,search'
]
);

Please note, that not only the controller configuration changed.
The vendor `TYPO3.CMS` in `TYPO3.CMS.IndexedSearch`, must no longer
be set. Instead, the vendor will be evaluated by looking at the
controller namespace.

Releases: master
Resolves: #87550
Change-Id: If47d087836c4345a8180dae3d4e4b8cd384e684c
Reviewed-on: https://review.typo3.org/59566
Tested-by: TYPO3com <>
Reviewed-by: Jörg Bösche <>
Reviewed-by: Mona Muzaffar <>
Tested-by: Mona Muzaffar <>
Reviewed-by: Anja Leichsenring <>
Tested-by: Anja Leichsenring <>

History

#1 Updated by Gerrit Code Review 10 months ago

  • Status changed from New to Under Review

Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/59566

#2 Updated by Gerrit Code Review 10 months ago

Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/59566

#3 Updated by Gerrit Code Review 10 months ago

Patch set 7 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/59566

#4 Updated by Gerrit Code Review 10 months ago

Patch set 8 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/59566

#5 Updated by Gerrit Code Review 10 months ago

Patch set 9 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/59566

#6 Updated by Gerrit Code Review 10 months ago

Patch set 10 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/59566

#7 Updated by Anonymous 9 months ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

#8 Updated by Benni Mack 6 months ago

  • Status changed from Resolved to Closed

#9 Updated by Oliver Hader 5 months ago

  • Related to Bug #88513: Non-FQCN controllers should still be usable in Extbase added

#10 Updated by Robert Vock 4 months ago

Just a small note:
If the configurePlugin call still uses the old controller name without the fully qualified class name and a class with that name exist, the automatic fallback does not work:
ExtensionUtility.php#L76

I don't think there are many instances were this is a problem, but I had a SmartyController and the class Smarty exists, so this code did not work in TYPO3 v10:

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
    'VierwdSmarty',
    'smarty_render',
    ['Smarty' => 'render',],
    []
);

I got this exception:

#1476109646 TYPO3\CMS\Extbase\Mvc\Exception\InvalidControllerException
Invalid controller "Smarty". The controller must implement the TYPO3\CMS\Extbase\Mvc\Controller\ControllerInterface.

As I said: I do not think there are many (or even any ;-)) extensions, were this is a problem. I just wanted to leave this note, if someone else has this problem.

Also available in: Atom PDF