2017 © Pedro Peláez
 

library doctrine-blender

Package in charge of "blending" doctrine entities (ORM, ODM, etc.)

image

mapado/doctrine-blender

Package in charge of "blending" doctrine entities (ORM, ODM, etc.)

  • Wednesday, August 19, 2015
  • by jdeniau
  • Repository
  • 12 Watchers
  • 5 Stars
  • 4,688 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 5 % Grown

The README.md

Doctrine Blender

Build Status, (*1)

This package makes it really simple to "blend" doctrine entities (ORM, ODM, etc.)., (*2)

It is greatly inspired by the Doctrine MongoDB ODM documentation on the subject., (*3)

Current status

It should work with every doctrine package. It is tested with Doctrine ORM and Doctrine MongoDB., (*4)

It also working with mapado/elastica-query-bundle in the ElasticSearch => Doctrine direction., (*5)

Installation

composer require "mapado/doctrine-blender:0.*"

Usage

Mixing ORM Entity and ODM Document

use Mapado\DoctrineBlender\ObjectBlender;
use Mapado\DoctrineBlender\ExternalAssociation;

$documentManager = ... // get a document manager
$entityManager = ... // get an entity manager

$eventSubscriber = new ObjectBlender;
$eventSubscriber->mapExternalAssociation(
    new ExternalAssociation(
        $entityManager,
        'Acme\Entity\Order',
        'product',
        $documentManager,
        'Acme\Document\Product',
        'getProductId', // optional, auto-generated with the property name
        'setProduct' // optional, auto-generated with the property name
    )
);

Mixing ORM Entities living in different Entity Manager

It is really easy to mix ORM Entities as well:, (*6)

use Mapado\DoctrineBlender\ObjectBlender;
use Mapado\DoctrineBlender\ExternalAssociation;

$entityManager = ... // get an entity manager
$secondEntityManager = ... // get the second manager

$eventSubscriber = new ObjectBlender;
$eventSubscriber->mapExternalAssociation(
    new ExternalAssociation(
        $entityManager,
        'Acme\Entity\Order',
        'product',
        $secondEntityManager,
        'Acme\Document\Product'
    )
);

Configuration

Yaml

doctrine_external_association:
    client_address:         # this key is only for you
        source_object_manager_alias: product_em # an alias you will need to inject later
        classname: 'Entity\Product'
        property_name: 'product'
        reference_object_manager_alias: order_dm # another alia
        reference_class: 'Document\Order'
        reference_getter: 'getProductId'
        reference_setter: 'setProduct'
use Mapado\DoctrineBlender\Configuration\YamlConfiguration;

$ymlConf = new YamlConfiguration('/path/to/external_association.yml');

$entityManager = ... // get an entity manager
$documentManager = ... // get a document manager

$ymlConf->setObjectManagerReference('product_em', $entityManager)
    ->setObjectManagerReference('order_dm', $documentManager)
;

The Versions

19/08 2015

dev-master

9999999-dev

Package in charge of "blending" doctrine entities (ORM, ODM, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

13/10 2014

v0.6.0

0.6.0.0

Package in charge of "blending" doctrine entities (ORM, ODM, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

04/09 2014

v0.5.1

0.5.1.0

Package in charge of "blending" doctrine entities (ORM, ODM, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

02/09 2014

v0.5.0

0.5.0.0

Package in charge of "blending" doctrine entities (ORM, ODM, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

02/09 2014

v0.4.0

0.4.0.0

Package in charge of "blending" doctrine entities (ORM, ODM, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

01/09 2014

v0.3.1

0.3.1.0

Package in charge of "blending" doctrine entities (ORM, ODM, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

01/09 2014

v0.3.0

0.3.0.0

Package in charge of "blending" doctrine entities (ORM, ODM, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

29/08 2014

v0.2.0

0.2.0.0

Package in charge of "blending" doctrine entities (ORM, ODM, etc.)

  Sources   Download

MIT

The Requires

 

The Development Requires

28/08 2014

v0.1.0

0.1.0.0

Package in charge of "blending" doctrine entities (ORM, ODM, etc.)

  Sources   Download

MIT

The Requires