Closed lossendae closed 6 years ago
You do know that you can register the models as services right? (Read the last chapter of README.md)
I didn't know.
Seems a little daunting to tag each and every models and declare them as services. I will look in the symfony doc if it's possible to automatically tag all models and model layers.
Thanks for the pointer.
You can tag them automatically. But I'm not using autowiring so you'll have to look at the docs on how to do that.
I did find something akin to autotagging in the doc : https://symfony.com/blog/new-in-symfony-3-3-service-autoconfiguration
This may answer all my questions. I will test that and report it here. Should i close the issue ?
IMHO yes.
As feedback, it indeed works fine with autotagging feature.
Additionally, i had to override the default session builder in yaml config to use mine:
pomm.model_manager.session_builder:
class: 'App\Model\Name\SessionBuilder'
Shouldn't it be precised in the documentation as well ?
Hello,
I've been using Pomm for a while, and there is only one thing that really itch me: the need to load models by using the Session.
In services you have to inject a session, most often the default one
@pomm.default_session
and then:You can work without it, or some IDE provides external plugins that deal with similar cases (to setup for every project you're using pomm with).
I've played a little with Symfony Flex autowiring and have been able to inject Model classes with the default session directly in services requiring them by declaring the following rule in my
services.yaml
:and modifying the
initialize
method a little to prevent an error :It works, with this i can directly autowire my models via constructor. Less code, i have my type hinting.
But, but i'm curious. What do i lose by not using the session to load my model ?