-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question about Injection via symfony instead of Pooler #100
Comments
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. 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. |
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 ?
The text was updated successfully, but these errors were encountered: