Skip to content

[DependencyInjection] Parent service not instantiated in child with XML config #4098

Closed
tombevers opened this Issue Apr 24, 2012 · 0 comments

1 participant

@tombevers

When using parent services by configuring them via XML they are not instantiated in the child services that use them. When using yaml this is working fine.

XML Config:

...
<service id="pc.service" class="Service" abstract="true">
    <call method="setEntityManager">
        <argument type="service" id="doctrine.entitymanager" />
    </call>
</service>
...
<service id="service.stats" class="Stats" parent="pc.service" />
...
class Service
{
    protected $_em;

    public function setEntityManager($entityManager)
    {
        $this->_em = $entityManager;
    }
}

class Stats extends PC_Service
{
    $this->_em should be set here but isn't
}
@tombevers tombevers closed this May 29, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.