- Member | 464
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
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.
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)
- Generous Backer | 575
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)
- Nette Blogger | 1019
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)
- Member | 464
Yeah, that's probably the problem, there is
scanDirs: false in
the project. When I register the presenter into services, it starts
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.. 🤷♂️