automatic parsing of all presenters based on autoload, looking for inject autowiring services, is it ok?

Notice: This thread is very old.
mcmatak
Member | 490
+
0
-

in my project is lot of parts added by composer, for some reason i need to use more configuration neon files, accurate part of application has its own config where is not defined all services existing in different parts of project,

these parts of project has presenters, it is modules for example adminmodule which is active only for url /admin or cronmodule which is active only for /cron url

but these modules are very different to front module or services module or api module

but these presenters are scanned for @inject annotation and looks for defined services in config, but these concrete config does not need this type of service, and it is not defined

is it understandable?

how i can solve this? define core config with all services?? or in every module define config.services.neon which in all cases will be part of global config.neon?

enumag
Member | 2118
+
0
-

It is most certainly not ok. And I'm afraid that from your description I don't really understand why are you doing it in the first place.

In my opinion each module should have a way to define its services. You can do this using a separate config.neon for each module and just load them all in your bootstrap (or include them in your root config.neon). Alternatively each module can have its own CompilerExtension – that's what I'm using because neon files are too limiting for my use cases.

Is that the answer you are looking for? If not, please elaborate what you're trying to do and why.

mcmatak
Member | 490
+
0
-

no this is not answer, i am doing exactly what you are trying to describe, but it is impossible, bcs if you load only particular config.neon or use own compilerextension (this is what i am doing) so you will not use the services which is not used in this part of module, right?

so for example service like PohodaServices which you use only for pohodamodule, this is module which handle the xml files served to pohoda accounting software, so this service will not be included in frontmodule, right?

but nette search for every presenter based on composer autoload and looking for every type of service which should be injected, and throw exception that this service is not defined?

so even if you are in adminmodule, you load only particular compilerextension or config.neon, so you get exception that pohodamodule/defaultpresenter need some service to be defined …

do you understand?