Database connection class hard-wired in Nette Extension

Notice: This thread is very old.
Kacer_Bob
Member | 7
+
0
-

Hi,
is there any reason why class ‘Nette\Database\Connection’ is hard-wired into NetteExtension?
I'd like to use my own descendant of that class, but I'm not able to change used class in config.neon.
I expected that if I use following definition I'll get object of specified class:

<?php
nette:
	database:
		default:
			class: \MyDatabase\Class
?>
HosipLan
Moderator | 4668
+
0
-

No, you won't. You'd have to change class of the service. That part you're trying si parameters for extensions.

services:
	nette.database.default:
		class: MyDatabase\MyClass

But after this, makes no sense for you to let Nette configure NDB, because you'd have to pass the parameters “by hand”. So just create new configured service, and don't configure the section in nette:.

services:
	connection:
		class: MyDatabase\MyClass("host=localhost;...", ...)