Project

General

Profile

Actions

Bug #77828

closed

Inversion of Control is not working in controller action arguments

Added by Dennis Römmich over 7 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2016-09-03
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
7
PHP Version:
5.6
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

If you register an Implementation like extbase does in typo3/sysext/extbase/ext_localconf.php:9 it won't be considered if the given interface ist passed as an action controller argument.

Example:
1. Register an implementation in your ext_localconf.php

/** @var $extbaseObjectContainer \TYPO3\CMS\Extbase\Object\Container\Container */
$extbaseObjectContainer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\Container\Container::class);
$extbaseObjectContainer->registerImplementation(\MyVendor\MyExtension\MyInterface::class, \MyVendor\MyExtension\Domain\Model\MyClass::class);

2. Create a simple Action in your ActionController with passig MyInterface as TypeHint:

    /**
     * showAction
     *
     * @param \MyVendor\MyExtension\MyInterface $myClass
     * @return void
     */
    public function showAction(\MyVendor\MyExtension\MyInterface $myClass)
    {
        //do some stuff
    }

It will lead to an Exception:

#1297759968: Exception while property mapping at property path "": No converter found which can be used to convert from "string" to "\MyVendor\MyExtension\MyInterface".

Actions

Also available in: Atom PDF