bit3 / contao-doctrine-orm
Doctrine ORM for Contao CMS
Installs: 1 394
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Type:contao-module
Requires
- php: >=5.3
- beberlei/doctrineextensions: ~1.0
- contao-community-alliance/composer-plugin: ~2.0
- contao-community-alliance/event-dispatcher: ~1
- contao/core: >=2.11.11,<4-dev
- contaoblackforest/contao-doctrine-dbal: ~1.1
- contaoblackforest/contao-logger: ~2.0
- doctrine/migrations: ~1.0
- doctrine/orm: 2.4.*
- jdorn/sql-formatter: ~1.2
- jms/serializer: ~0.15
Requires (Dev)
- phpunit/phpunit: 3.7.*
- squizlabs/php_codesniffer: ~2.3
Conflicts
- contao-community-alliance/dc-general: <2.0.0-beta18
Replaces
- bit3/contao-doctrine-orm: 2.3.2
This package is not auto-updated.
Last update: 2022-02-01 12:25:46 UTC
README
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.
Entity mapping
To register an entity table, add to your config.php:
$GLOBALS['DOCTRINE_ENTITIES'][] = 'orm_my_entity_type';
The table name will be converted to MyEntityType
.
Custom Namespaces can be mapped by a table name prefix to class namespace map:
$GLOBALS['DOCTRINE_ENTITY_NAMESPACE_MAP']['orm_my_entity'] = 'My\Entity';
Now the table name will be converted to My\Entity\Type
.
While DOCTRINE_ENTITY_NAMESPACE_MAP
is used for table name transformation,
the array DOCTRINE_ENTITY_NAMESPACE_ALIAS
is used to define doctrine namespace aliases.
$GLOBALS['DOCTRINE_ENTITY_NAMESPACE_ALIAS']['My'] = 'My\Entity';
Now you can use My:Type
instead of My\Entity\Type
as entity name.
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.