Skip to content

Conversation

mildabre
Copy link

Use trait Nette\StaticClass in RouterFactory is useless, the function is to prevent creating instance + throw exception when calling non-callable static function. This function is over management, every web developer can use static method on class the correct way without this trait.

Above that the method createRouter() itself MUST NOT be inevitably as static, we can create instance of RouterFactory, register as service @routerFactory and use standard non-static method to create Router:

#	router:
#		create: App\Router\RouterFactory::createRouter()  # static

	routerFactory:
		class: App\Router\RouterFactory

	router:
		create: @routerFactory::create()  #non-static

But feel free to have in the Nette web-project RouterFactory with static method as before, but please remove the unnecessary trait.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants