Skip to content

Private properties of parent classes not injected properly by Container::injectOn()? #257

@holtkamp

Description

@holtkamp

When using Modules in a ZF1 project, it is common to have controllers like this.

class Default_OrderController 
{
    /**
     * @inject
     * @var \Project\Domain\Service\Order
     */
    private $orderDomainService

    public function doSomething()
    {
        $this->orderDomainService->doSomeBusinessStuff();
    }
}

class ModuleX_OrderController extends Default_OrderController
{
    //empty on purpose
}

Using the $this->orderDomainService property works for the default Module, but not for the other Modules. It seems that the current ZF1 integration of the DIC does not inject the values of private properties of parent Controllers / classes. When changing the access level of the property to 'protected', the property does get injected...

Is this intended behaviour of \DI\Container::injectOn() used by the bridge? It would be nice if the class hierarchy upstream is taken into account as well...

PS: offtopic: still looking for a way to get rid of these 'empty' controllers, but seems not possible in ZF1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions