Multiple services of type

Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
Juraj_
Člen | 22
+
0
-

Ahojte,
mam problem s DI. Nechcem aby trieda dedila

\Nette\Application\UI\Presenter

Mam vytvorene 2 kontainery, zalozene na 1 triede, kde len posielam ine argumenty:

some1API:
			class: App\FormsModule\Partners\XXX\some1API
			arguments: ['xxx', 'yyy', '1']
some2API
			class: App\FormsModule\Partners\XXX\some1API
			arguments: ['yyy', 'xxx', '2']

Preto mi hadze chybu:

Service ‚forms.mobileSmallerSender‘: Multiple services of type App\FormsModule\Partners\XXX\some1API found: forms.some1API, forms.some2API

Pouzitie:

class MobilePresenter extends \Nette\Application\UI\Presenter
{
public function startup()
{
	parent::startup();
	$sender1 = $this->context->getService('forms.some1API');
	$this->mobileSmaller = new MobileSmaller($sender1);
}
...
class MobileSmaller
{
private $value1;

	public function __construct(\App\FormsModule\Partners\XXX\some1API $value1 )
	{
		$this->value1= $value1;
	}

Viete mi poradit co stym?
Pouzivam nette 2.0

Editoval Juraj_ (27. 7. 2015 11:29)

F.Vesely
Člen | 369
+
+2
-

Udelej si tovarnicku, ktera bude vytvaret nakonfigurovane instance some1API a tu si pak injectni do presenteru.