weew/container-doctrine-integration

Make doctrine repositories injectable in the weew/container.

v1.0.1 2016-07-21 11:17 UTC

This package is not auto-updated.

Last update: 2024-11-19 22:36:29 UTC


README

Build Status Code Quality Test Coverage Version Licence

Table of contents

Installation

composer require weew/container-doctrine-integration

Introduction

Doctrine repositories are not injectable on their own since they are not easily instantiable. To make it work you'll have to work with factories do some argument parsing and so on. This is exactly what this package does, it makes doctrine repositories injectable trough the weew/container container.

Conventions

There are certain conventions that you must follow to be able to inject doctrine repositories. Repositories loader does this kind of repository name to entity name conversion: Vendor\Package\Repositories\FooRepository should map to this entity Vendor\Package\Entities\Foo.

If this name matching strategy is not sufficient for you, you may provide your own implementation of the IRepositoryNameParser interface.

Usage

To make repositories injectable simply create a new instance of IDoctrineRepositoriesLoader, pass in an instance of IContainer and an instance ObjectManager and enable it.

$loader = new DoctrineRepositoriesLoader($container, $om);
$loader->enable();