I just realized that TYPO3 Extbase can (in some situations?) inject dependencies even if you do not pass them to the constructor when you call e.g. $objectManager->get(Foo::class)
? I am confused how and when this works. I could not find the answer myself by reading the source code.
Have a look at \TYPO3\CMS\Extbase\Object\Container\Container::getConstructorArguments()
.
It works as follows:
if
ObjectManager->get()
and$argumentInformation['defaultValue']
is set) and$argumentInformation['dependency']
is set)then this class will be instantiated and supplied as a parameter to the constructor call