Задать вопрос
@antonowano
Профессиональный самоучка

Сервисы инициализируются в момент вызова сервиса или в момент запроса к сайту?

В какой момент происходит их инициализация?
Не повлияет ли на скорость работы сайта большое кол-во сервисов?
И возможно ли сократить список используя регулярные выражения (типа AppBundle\Model\*Model)
services:
    #Models
    app.model.companies:
        class: AppBundle\Model\CompaniesModel
        arguments:
            em: "@doctrine.orm.entity_manager"
            requestStack: "@request_stack"
    app.model.complex:
        class: AppBundle\Model\ComplexModel
        arguments:
            em: "@doctrine.orm.entity_manager"
            requestStack: "@request_stack"
    app.model.offers:
        class: AppBundle\Model\OffersModel
        arguments:
            em: "@doctrine.orm.entity_manager"
            requestStack: "@request_stack"
    app.model.posts:
        class: AppBundle\Model\PostsModel
        arguments:
            em: "@doctrine.orm.entity_manager"
            requestStack: "@request_stack"
  • Вопрос задан
  • 165 просмотров
Подписаться 1 Оценить Комментировать
Решение пользователя bears К ответам на вопрос (3)
@bears
symfony.com/doc/current/book/service_container.htm...

~~~
When you ask for the app.mailer service from the container, the container constructs the object and returns it. This is another major advantage of using the service container. Namely, a service is never constructed until it's needed. If you define a service and never use it on a request, the service is never created. This saves memory and increases the speed of your application. This also means that there's very little or no performance hit for defining lots of services. Services that are never used are never constructed.
~~~

p.s. Просто интересно, почему используете энтити менеджер в сущности?
Ответ написан