More complex setup of service

Notice: This thread is very old.
mkoubik
Member | 728
+
0
-

How do I call chain of methods in service's setup? I use it for doctrine's connection.
This:

services:
	doctrine.conenction:
		create: ...
		setup:
			- getDatabasePlatform()->registerDoctrinetypeMapping(enum, string)

doesn't work.

And this:

services:
	doctrine.connection:
		create: ...
		setup:
			- @doctrine.platform::registerDoctrinetypeMapping(enum, string)

	doctrine.platform:
		create: @doctrine.connection::getDatabasePlatform()

(obviously) complains about circular reference.

Majkl578
Moderator | 1364
+
0
-

One option might be:

setup:
    - "?->getDatabasePlatform()->registerDoctrinetypeMapping(?, ?)"(@self, "enum", "string")
Filip Procházka
Moderator | 4668
+
0
-

Or you could just use kdyby/doctrine ;)

doctrine:
	types:
		myType: My\Cool\Type

Theese complicated setups are better done in compiler extensions.

Last edited by Filip Procházka (2013-09-17 00:42)

Honza Marek
Member | 1664
+
0
-

You should implement factory in PHP instead of programming in neon.

mkoubik
Member | 728
+
0
-

I know, but the goal of this is simplicity:

  • require doctrine/orm
  • include one neon config (seems more clear to me than extension)
  • done
enumag
Member | 2118
+
0
-

@mkoubik: Well with Kdyby/Doctrine it's even more simple:

  • require kdyby/doctrine
  • register extension + add database username, pass, … (about 5 lines total in config.neon)
  • done ;-)
mkoubik
Member | 728
+
0
-

Yeah, but kdyby/doctrine is full of stuff i don't need.

Also I don't like using extensions for things that don't need to be integrated to nette (I use kdyby/console though). All I need is to get the entity manager to DI container, everything else is job for my domain/persistence logic.

Last edited by mkoubik (2013-09-17 22:23)

Filip Procházka
Moderator | 4668
+
0
-

mkoubik wrote:

include one neon config (seems more clear to me than extension)

Well, it's not :) And you're spending preciouse hours on something that has been already done and it's much better already, because shitload of people is using it and reporting stuff.

Yeah, but kdyby/doctrine is full of stuff i don't need.

<OT>You may think that, but you're wrong :) I'm gonna interrogate you at some posobota :P</OT>

Last edited by Filip Procházka (2013-09-18 13:43)

mkoubik
Member | 728
+
0
-

It's because doctrine is full of stuff I don't need (but also full of stuf that I desperately need and that are not included in no existing php orm). Kdyby/Doctrine is great for builduing anemic CRUD model, but full of antipatterns from DDD's point of view. Looking forward to discussing it.