w moich usług konstruktoraJak dać pojemnik jako argument do usług
public function __construct(
EntityManager $entityManager,
SecurityContextInterface $securityContext)
{
$this->securityContext = $securityContext;
$this->entityManager = $entityManager;
mijam EntityManager i securityContext jako argument. także mój services.xml jest tutaj
<service id="acme.memberbundle.calendar_listener" class="Acme\MemberBundle\EventListener\CalendarEventListener">
<argument type="service" id="doctrine.orm.entity_manager" />
<argument type="service" id="security.context" />
ale teraz chcę użyć kontenera w usługach takich jak
$this->container->get('router')->generate('fos_user_profile_edit')
jak mogę przejść pojemnik do usług?
Dlaczego nie można dodać 'fos_user_profile_edit' jako argument? jeśli nie jest to wymagane, możesz użyć zastrzyku ustawiającego. Myślę, że powinieneś mieć bardzo dobry powód do wstrzyknięcia pojemnika na usługi. Sprawię, że twój kod nie będzie przenośny – Rocco