Issue Bug Closed

#90480resolveControllerAliasFromControllerClassName returns wrong alias

Daniel Gohlke 02/21/20, 23:22 updated 02/27/20, 12:44

Description

The new method to resolve an alias from the given controller class name in ExtensionUtility::configurePlugin does not respect any subdirectories in the controller directory.

As a result, the corresponding template of the controller is not found, because the wrong directory is searched.

An example how it works in TYPO3 v8 and v9:

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
    'Extcode.cart',
    'MiniCart',
    [
        'Cart\CartPreview' => 'show',
        'Cart\Currency' => 'update',
    ],
    // non-cacheable actions
    [
        'Cart\CartPreview' => 'show',
        'Cart\Currency' => 'update',
    ]
);

There is a controller \Extcode\Cart\Controller\Cart\CartPreviewController according to the plugin registration above. For the actions of the controller the templates are located in Resources/Private/Templates/Cart/CartPreview.

The new plugin registration looks like this.

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
    'Cart',
    'MiniCart',
    [
        \Extcode\Cart\Controller\Cart\CartPreviewController::class => 'show',
        \Extcode\Cart\Controller\Cart\CurrencyController::class => 'update',
    ],
    // non-cacheable actions
    [
        \Extcode\Cart\Controller\Cart\CartPreviewController::class => 'show',
        \Extcode\Cart\Controller\Cart\CurrencyController::class => 'update',
    ]
);

The new method generates an alias from the given class name. To generate this alias, only the last part of the class name is used, not the entire namespace.

The method should return Cart\CartPreview instead of Cart\CartPreview.

Reviews 1