<?php
use Adtechpotok\Aware\Interfaces\EntityManagerAwareInterface;
use Adtechpotok\Aware\Traits\EntityManagerAwareTrait;
class SomeClass implements EntityManagerAwareInterface
{
use EntityManagerAwareTrait;
public function someMethod()
{
dump($this->em); // $em - дефолтный EntityManager, аналог '@doctrine.orm.default_entity_manager'
}
}services:
some.service:
class: SomeClass
calls:
- {method: setEntityManager, arguments: ['@doctrine.orm.default_entity_manager']}| Aware | Service |
|---|---|
| ConnectionAware | @doctrine.dbal.default_connection |
| CacheAware | @cache.app |
| ContainerAware | @service_container |
| DoctrineAware | @doctrine |
| EntityManagerAware | @doctrine.orm.default_entity_manager |
| EventDispatcherAware | @debug.event_dispatcher |
| FilesystemAware | @filesystem |
| FileLocatorAware | @file_locator |
| FileLinkFormatterAware | @debug.file_link_formatter |
| HttpKernelAware | @http_kernel |
| KernelAware | @kernel |
| LoggerAware | @monolog.logger |
| PropertyAccessorAware | @property_accessor |
| ReaderAware | @annotations.cached_reader |
| RequestStackAware | @request_stack |
| StopwatchAware | @debug.stopwatch |
services:
_defaults:
autowire: true
some.service:
class: SomeClassВажно! При объявлении сервисов, которые требуют использования тэгов - этот способ не подоходит, Symfony игнорирует тэги при autowire.