Presenter decorator not called

dakur
Member | 493
+
0
-

Hi, does anyone any idea, why these decorators are not called?

decorator:
	App\FrontModule\Presenters\BasePresenter:
		setup:
			- setSomething() # there is var_dump() inside the method
			- nonExistent()
			- $a = true # private property – no error

Note that it doesn't matter if the method exists, it neither fails nor outputs anything. When I try to modify decorator or setup keyword to something non-sense, it fails, as well as it fails for non existent decorated class. It just doesn't call the decorators.

I have nette/di installed v3.1.2. Also there is contributte/di v0.5.5, but it's from other packages, I don't use it on my own.

Last edited by dakur (2023-04-20 11:14)

m.brecher
Generous Backer | 872
+
0
-

@dakur

Hi,

I have tested in my BasePresenter and I thing in my project everything works as expected:

decorator:
	App\Presenters\BasePresenter:
		setup:
			- setSomething() # exists => is called
			- nonExistent()  # not exists => Nette\MemberAccessException
			- $private = true # private property => Nette\MemberAccessException

existing public method is called
non existing method throws exception
private property throws exception

I have installed nette/di v3.1.2

May be the root of problem is in contributte/di v0.5.5 ??

Last edited by m.brecher (2023-04-20 18:48)

jiri.pudil
Nette Blogger | 1032
+
0
-

Just to rule this one out: what does your config/container look like? Decorators only decorate registered services; if you disable all means of automatic registration of presenters (https://doc.nette.org/…onfiguration#…) then presenters are not registered as services and therefore not decorated

Last edited by jiri.pudil (2023-04-21 09:24)

dakur
Member | 493
+
0
-

Yeah, that's probably the problem, there is scanDirs: false in the project. When I register the presenter into services, it starts working.

The way to go is probably to make some configuration object instead, register it to DI and then inject into BasePresenter, however it's strange that it worked with decorator before the upgrade.. 🤷‍♂️

Thanks!