What's the right way to instantiate router in config?

Notice: This thread is very old.
JirkaChadima
Member | 5
+
0
-

Hi,

after upgrading to Nette 2.1 I keep getting the following error:

PHP User Deprecated: Passing factories to Nette\DI\Container::addService() is deprecated; pass the object itself.

It's obviously caused by the following part of config.neon:

	services:
		router:
			create: \MyRouter::createRouter

What's the proper way of handling this? Even sandbox uses static factory to create Router. If it's the recommended way, why does it fire the User Deprecated error? It's really confusing.

Tomáš Kolinger
Member | 136
+
0
-

try replace “factory” with “class” or use short-annotation, see https://github.com/…/config.neon#L27

Last edited by Tomáš Kolinger (2015-01-13 09:51)

JirkaChadima
Member | 5
+
0
-

When i use class, services are not instantiated at all. Short version works, but the original error is still there.

JirkaChadima
Member | 5
+
0
-

OK, my bad. It was actually triggered by httRequest substitute used in cli execution which was defined as a Closure.