contaoblackforest/contao-doctrine-orm 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

contaoblackforest/contao-doctrine-orm

最新稳定版本:2.4.0

Composer 安装命令:

composer require contaoblackforest/contao-doctrine-orm

包简介

Doctrine ORM for Contao CMS

README 文档

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.

统计信息

  • 总下载量: 2.31k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 4
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: LGPL-3.0-or-later
  • 更新时间: 2015-05-28