2017 © Pedro Peláez
 

contao-module contao-doctrine-orm

Doctrine ORM for Contao CMS

image

bit3/contao-doctrine-orm

Doctrine ORM for Contao CMS

  • Wednesday, June 10, 2015
  • by tril
  • Repository
  • 0 Watchers
  • 0 Stars
  • 1,386 Installations
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 18 Versions
  • 0 % Grown

The README.md

Doctrine ORM Bridge

This extension provide Doctrine ORM in the Contao Open Source CMS. It provide an entity manager via the service $container['doctrine.orm.entityManager']. To use the Doctrine Connection within the Contao Database Framework, use bit3/contao-doctrine-dbal-driver., (*1)

Entity mapping

To register an entity table, add to your config.php:, (*2)

$GLOBALS['DOCTRINE_ENTITIES'][] = 'orm_my_entity_type';

The table name will be converted to MyEntityType., (*3)

Custom Namespaces can be mapped by a table name prefix to class namespace map:, (*4)

$GLOBALS['DOCTRINE_ENTITY_NAMESPACE_MAP']['orm_my_entity'] = 'My\Entity';

Now the table name will be converted to My\Entity\Type., (*5)

While DOCTRINE_ENTITY_NAMESPACE_MAP is used for table name transformation, the array DOCTRINE_ENTITY_NAMESPACE_ALIAS is used to define doctrine namespace aliases., (*6)

$GLOBALS['DOCTRINE_ENTITY_NAMESPACE_ALIAS']['My'] = 'My\Entity';

Now you can use My:Type instead of My\Entity\Type as entity name., (*7)

Configure entities via DCA

<?php

$GLOBALS['TL_DCA']['...'] = array(
    'entity' => array(
        // (optional) Repository class name
        'repositoryClass' => 'MyEntityRepositoryClassName',

        // (optional) ID generator type
        'idGenerator' => \Doctrine\ORM\Mapping\ClassMetadataInfo::GENERATOR_TYPE_UUID,

        // (optional) Index definition
        'indexes' => array(
            'idx_name' => array('column_one', 'column_two', '...'),
        ),

        // (optional) Unique constraints
        'uniques' => array(
            'unique_name' => array('column_one', 'column_two', '...'),
        ),
    ),
    'fields' => array(
        '...' => array(
            'field' => array(
                'type' => (string),
                // do not set fieldName!
                '
            ),
        ),
    ),
);

Contao hooks

$GLOBALS['TL_HOOKS']['prepareDoctrineEntityManager'] = function(\Doctrine\ORM\Configuration &$config) { ... } Called before the entity manager will be created., (*8)

The Versions