[TYPO3-mvc] How should/can I pass parameters to an object's constructor using dependency injection?
Simon Tuck
stu at rtpartner.ch
Thu Nov 18 15:42:58 CET 2010
Hi,
I'm looking at the changes in the latest version of extbase (1.3) and I
was wondering how I would/could pass parameters to an object's
constructor using the DI container.
So, in the following example taken from the current changelog
(extbase/ChangeLog.txt):
class Tx_Foo_Controller_MyController
{
protected $loggingService;
/**
* @param Tx_Foo_Service_LoggingService $loggingService
*/
public function injectLoggingService(Tx_Foo_Service_LoggingService
$loggingService)
{
$this->loggingService = $loggingService;
}
}
How can I pass parameters to the constructor of the logging service
singleton?:
class Tx_Foo_Service_LoggingService implements t3lib_Singleton
{
/**
*
* @param string $foo
* @return void
*/
public function __construct($foo)
{
$this->setFoo($foo);
}
}
Thanks!
Simon
More information about the TYPO3-project-typo3v4mvc
mailing list