1
0
mirror of synced 2025-01-18 22:41:43 +03:00

Incorporate DDC-879 into Cookbook.

This commit is contained in:
Benjamin Eberlei 2010-12-28 00:23:06 +01:00
parent 6bf2f22315
commit ef8689c400
2 changed files with 10 additions and 7 deletions

View File

@ -29,18 +29,25 @@ appropriate autoloaders.
class TablePrefix
{
protected $_prefix = '';
protected $prefix = '';
public function __construct($prefix)
{
$this->_prefix = (string) $prefix;
$this->prefix = (string) $prefix;
}
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
{
$classMetadata = $eventArgs->getClassMetadata();
$classMetadata->setTableName($this->_prefix . $classMetadata->getTableName());
$classMetadata->setTableName($this->prefix . $classMetadata->getTableName());
foreach ($classMetadata->getAssociationMappings() as $fieldName => $mapping) {
if ($mapping['type'] == \Doctrine\ORM\Mapping\ClassMetadataInfo::MANY_TO_MANY) {
$mappedTableName = $classMetadata->associationMappings[$fieldName]['joinTable']['name'];
$classMetadata->associationMappings[$fieldName]['joinTable']['name'] = $this->prefix . $mappedTableName;
}
}
}
}
Telling the EntityManager about our listener

View File

@ -1309,11 +1309,7 @@ Path Expressions
/* "u.Group" */
SingleValuedAssociationPathExpression ::= IdentificationVariable "." SingleValuedAssociationField
<<<<<<< HEAD:manual/en/dql-doctrine-query-language.txt
=======
>>>>>>> ReST:en/reference/dql-doctrine-query-language.rst
/* "u.Group.Permissions" */
CollectionValuedPathExpression ::= IdentificationVariable "." {SingleValuedAssociationField "."}* CollectionValuedAssociationField