2017 © Pedro Peláez
 

library doctrine-dynamic

Load Doctrine mappings dynamically for your entities by configuration

image

fabiang/doctrine-dynamic

Load Doctrine mappings dynamically for your entities by configuration

  • Wednesday, December 7, 2016
  • by fabiang
  • Repository
  • 3 Watchers
  • 3 Stars
  • 254 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

fabiang/doctrine-dynamic

Proxy Driver for Doctrine which allows you to add custom relations dynamically by configuration., (*1)

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., (*2)

Latest Stable Version License
CI Scrutinizer Code Quality Code Coverage, (*3)

Features

  • Setting all possible relations to entities:
    • OneToOne
    • ManyToOne
    • OneToMany
    • ManyToMany
  • Setting repository class

Installation

New to Composer? Read the introduction. Run the following Composer command:, (*4)

$ composer require fabiang/doctrine-dynamic

Framework integration

Usage

<?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);

Development

This library is tested with PHPUnit and Behat., (*5)

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:, (*6)

composer install
./vendor/bin/phpunit
./vendor/bin/behat

Licence

BSD-2-Clause. See the LICENSE.md., (*7)

The Versions

07/12 2016

dev-master

9999999-dev

Load Doctrine mappings dynamically for your entities by configuration

  Sources   Download

BSD-2-Clause

The Requires

 

The Development Requires

05/10 2016

0.1.2

0.1.2.0

Load Doctrine mappings dynamically for your entities by configuration

  Sources   Download

BSD-2-Clause

The Requires

 

The Development Requires

05/10 2016

0.1.1

0.1.1.0

Load Doctrine mappings dynamically for your entities by configuration

  Sources   Download

BSD-2-Clause

The Requires

 

The Development Requires

04/10 2016

0.1.0

0.1.0.0

Load Doctrine mappings dynamically for your entities by configuration

  Sources   Download

BSD-2-Clause

The Requires

 

The Development Requires