Load Doctrine mappings dynamically for your entities by configuration
Proxy Driver for Doctrine which allows you to add custom relations dynamically by configuration.
This is useful if you use foreign entities, which you can't change, but you like to add own relations between them and your entities.
- Setting all possible relations to entities:
- Setting repository class
New to Composer? Read the introduction. Run the following Composer command:
$ composer require fabiang/doctrine-dynamic
<?php use Fabiang\DoctrineDynamic\ConfigurationFactory; use Fabiang\DoctrineDynamic\ProxyDriverFactory; use Doctrine\ORM\EntityManager; $configurationFactory = new ConfigurationFactory(); $configuration = $configurationFactory->factory([ \Mymodule\Entity\Customer::class => [ 'options' => [ 'repository' => \Mymodule\Repository\CustomerRepository::class, ], 'fields' => [ 'fieldname' => [ 'products' => [ 'oneToMany' => [ [ 'targetEntity' => \Mymodule\Entity\Customer::class, 'mappedBy' => 'customer', ], ] ], ] ] ], \Mymodule\Entity\Products::class => [ 'fields' => [ 'customer' => [ 'manyToOne' => [ [ 'targetEntity' => \Mymodule\Entity\Products::class, 'inversedBy' => 'products', 'joinColumns' => [ 'name' => 'customer_id', 'referencedColumnName' => 'id' ] ], ] ], ] ], ]); /** @var $entityManager EntityManager */ // get it from a container for example $entityManager = $container->get(EntityManager::class); $proxyDriverFactory = new ProxyDriverFactory(); $proxyDriverFactory->factory($entityManager, $configuration);
Fork the project on Github and send an pull request with your changes. Make sure you didn't break anything with running the following commands:
composer install ./vendor/bin/phpunit ./vendor/bin/behat
BSD-2-Clause. See the LICENSE.md.