contaoblackforest / contao-doctrine-orm
Doctrine ORM for Contao CMS
Installs: 2 313
Dependents: 4
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 1
Open Issues: 2
Type:contao-module
Requires
- php: ^5.6 || ^7.0
- beberlei/doctrineextensions: ~1.0.0
- contao-community-alliance/composer-plugin: ^2.0
- contao-community-alliance/event-dispatcher: ^1.3
- contao/core: ^3.5.5
- contaoblackforest/contao-doctrine-dbal: ^1.2
- contaoblackforest/contao-logger: ^2.0
- doctrine/migrations: ~1.0.0
- doctrine/orm: ~2.4.1
- 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-beta22
Replaces
- bit3/contao-doctrine-orm: 2.4.0
This package is auto-updated.
Last update: 2024-10-29 04:41:55 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.