mapado / doctrine-blender-bundle
Bundle in change of the mapado/doctrine-blender package configuration
Installs: 6 260
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 10
Forks: 0
Open Issues: 1
Requires
- mapado/doctrine-blender: >=0.5.0,<1.0
README
This bundle in charge of the https://github.com/mapado/doctrine-blender integration into a Symfony project.
Installation
composer require "mapado/doctrine-blender-bundle:0.*"
Usage
Entities
Taken from doctrine mongodb documentation
First lets define our Product document:
/** @Document */ class Product { /** @Id */ private $id; /** @String */ private $title; public function getId() { return $this->id; } public function getTitle() { return $this->title; } public function setTitle($title) { $this->title = $title; } }
Next create the Order entity that has a $product and $productId property linking it to the Product that is stored with MongoDB:
namespace Entities; use Documents\Product; /** * @Entity * @Table(name="orders") */ class Order { /** * @Id @Column(type="integer") * @GeneratedValue(strategy="AUTO") */ private $id; /** * @Column(type="string") */ private $productId; /** * @var Documents\Product */ private $product; public function getId() { return $this->id; } public function getProductId() { return $this->productId; } public function setProduct(Product $product) { $this->productId = $product->getId(); $this->product = $product; } public function getProduct() { return $this->product; } }
Configuration
mapado_doctrine_blender: doctrine_external_associations: order: source_object_manager: 'doctrine.orm.order_entity_manager' classname: 'Acme\DemoBundle\Entity\Order' references: product: # this is the name of the property in the source entity reference_id_getter: 'getProductId' # optional, method in the source entity fetching the ref.id reference_setter: 'setProduct' # optional, method in the source entity to set the reference reference_object_manager: 'doctrine_mongodb.odm.product_document_manager' reference_class: 'Acme\DemoBundle\Document\Product' tags: # can also be an array (or an iterator) reference_id_getter: 'getTagIds' # must return an array (or an iterator) of identifiers reference_setter: 'setTags' reference_object_manager: 'doctrine_mongodb.odm.tag_document_manager' reference_class: 'Acme\DemoBundle\Document\Tag' another_reference: # ... another_source: # ...