Commit d4232d90 authored by Roman S. Borschel's avatar Roman S. Borschel

[DDC-388] Fixed.

parent 7fefe3f4
...@@ -410,12 +410,7 @@ abstract class AbstractQuery ...@@ -410,12 +410,7 @@ abstract class AbstractQuery
throw new NonUniqueResultException; throw new NonUniqueResultException;
} }
return array_shift($result); return array_shift($result);
}/* else if (is_object($result)) {
if (count($result) > 1) {
throw new NonUniqueResultException;
} }
return $result->first();
}*/
return $result; return $result;
} }
......
<?php <?php
/* /*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
...@@ -152,7 +150,23 @@ abstract class AssociationMapping ...@@ -152,7 +150,23 @@ abstract class AssociationMapping
* *
* @var array * @var array
*/ */
public $joinTable = array(); public $joinTable;
/**
* READ-ONLY: The name of the entity class from which the association was
* inherited in an inheritance hierarchy.
*
* @var string
*/
public $inherited;
/**
* READ-ONLY: The name of the entity or mapped superclass that declares
* the association field in an inheritance hierarchy.
*
* @var string
*/
public $declared;
/** /**
* Initializes a new instance of a class derived from AssociationMapping. * Initializes a new instance of a class derived from AssociationMapping.
...@@ -161,10 +175,8 @@ abstract class AssociationMapping ...@@ -161,10 +175,8 @@ abstract class AssociationMapping
*/ */
public function __construct(array $mapping) public function __construct(array $mapping)
{ {
if ($mapping) {
$this->_validateAndCompleteMapping($mapping); $this->_validateAndCompleteMapping($mapping);
} }
}
/** /**
* Validates & completes the mapping. Mapping defaults are applied here. * Validates & completes the mapping. Mapping defaults are applied here.
...@@ -317,8 +329,9 @@ abstract class AssociationMapping ...@@ -317,8 +329,9 @@ abstract class AssociationMapping
abstract public function load($sourceEntity, $target, $em, array $joinColumnValues = array()); abstract public function load($sourceEntity, $target, $em, array $joinColumnValues = array());
/** /**
* Gets the (possibly quoted) name of the join table.
* *
* @param $platform * @param AbstractPlatform $platform
* @return string * @return string
*/ */
public function getQuotedJoinTableName($platform) public function getQuotedJoinTableName($platform)
......
<?php <?php
/* /*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
...@@ -72,11 +70,10 @@ class ClassMetadata extends ClassMetadataInfo ...@@ -72,11 +70,10 @@ class ClassMetadata extends ClassMetadataInfo
*/ */
public function __construct($entityName) public function __construct($entityName)
{ {
$this->name = $entityName; parent::__construct($entityName);
$this->reflClass = new \ReflectionClass($entityName); $this->reflClass = new ReflectionClass($entityName);
$this->namespace = $this->reflClass->getNamespaceName(); $this->namespace = $this->reflClass->getNamespaceName();
$this->table['name'] = $this->reflClass->getShortName(); $this->table['name'] = $this->reflClass->getShortName();
$this->rootEntityName = $entityName;
} }
/** /**
...@@ -99,18 +96,6 @@ class ClassMetadata extends ClassMetadataInfo ...@@ -99,18 +96,6 @@ class ClassMetadata extends ClassMetadataInfo
return $this->reflFields; return $this->reflFields;
} }
/**
* INTERNAL:
* Adds a reflection property. Usually only used by the ClassMetadataFactory
* while processing inheritance mappings.
*
* @param array $props
*/
public function addReflectionProperty($propName, \ReflectionProperty $property)
{
$this->reflFields[$propName] = $property;
}
/** /**
* Gets a ReflectionProperty for a specific field of the mapped class. * Gets a ReflectionProperty for a specific field of the mapped class.
* *
...@@ -189,7 +174,7 @@ class ClassMetadata extends ClassMetadataInfo ...@@ -189,7 +174,7 @@ class ClassMetadata extends ClassMetadataInfo
public function setIdentifierValues($entity, $id) public function setIdentifierValues($entity, $id)
{ {
if ($this->isIdentifierComposite) { if ($this->isIdentifierComposite) {
foreach ((array)$id as $idField => $idValue) { foreach ($id as $idField => $idValue) {
$this->reflFields[$idField]->setValue($entity, $idValue); $this->reflFields[$idField]->setValue($entity, $idValue);
} }
} else { } else {
...@@ -220,18 +205,6 @@ class ClassMetadata extends ClassMetadataInfo ...@@ -220,18 +205,6 @@ class ClassMetadata extends ClassMetadataInfo
return $this->reflFields[$field]->getValue($entity); return $this->reflFields[$field]->getValue($entity);
} }
/**
* Sets the field mapped to the specified column to the specified value on the given entity.
*
* @param object $entity
* @param string $field
* @param mixed $value
*/
public function setColumnValue($entity, $column, $value)
{
$this->reflFields[$this->fieldNames[$column]]->setValue($entity, $value);
}
/** /**
* Stores the association mapping. * Stores the association mapping.
* *
...@@ -314,7 +287,6 @@ class ClassMetadata extends ClassMetadataInfo ...@@ -314,7 +287,6 @@ class ClassMetadata extends ClassMetadataInfo
'identifier', 'identifier',
'idGenerator', //TODO: Does not really need to be serialized. Could be moved to runtime. 'idGenerator', //TODO: Does not really need to be serialized. Could be moved to runtime.
'inheritanceType', 'inheritanceType',
'inheritedAssociationFields',
'isIdentifierComposite', 'isIdentifierComposite',
'isMappedSuperclass', 'isMappedSuperclass',
'isVersioned', 'isVersioned',
...@@ -339,8 +311,8 @@ class ClassMetadata extends ClassMetadataInfo ...@@ -339,8 +311,8 @@ class ClassMetadata extends ClassMetadataInfo
$this->reflClass = new ReflectionClass($this->name); $this->reflClass = new ReflectionClass($this->name);
foreach ($this->fieldMappings as $field => $mapping) { foreach ($this->fieldMappings as $field => $mapping) {
if (isset($mapping['inherited'])) { if (isset($mapping['declared'])) {
$reflField = new ReflectionProperty($mapping['inherited'], $field); $reflField = new ReflectionProperty($mapping['declared'], $field);
} else { } else {
$reflField = $this->reflClass->getProperty($field); $reflField = $this->reflClass->getProperty($field);
} }
...@@ -349,8 +321,8 @@ class ClassMetadata extends ClassMetadataInfo ...@@ -349,8 +321,8 @@ class ClassMetadata extends ClassMetadataInfo
} }
foreach ($this->associationMappings as $field => $mapping) { foreach ($this->associationMappings as $field => $mapping) {
if (isset($this->inheritedAssociationFields[$field])) { if ($mapping->declared) {
$reflField = new ReflectionProperty($this->inheritedAssociationFields[$field], $field); $reflField = new ReflectionProperty($mapping->declared, $field);
} else { } else {
$reflField = $this->reflClass->getProperty($field); $reflField = $this->reflClass->getProperty($field);
} }
......
...@@ -317,7 +317,10 @@ class ClassMetadataFactory ...@@ -317,7 +317,10 @@ class ClassMetadataFactory
if ( ! isset($mapping['inherited']) && ! $parentClass->isMappedSuperclass) { if ( ! isset($mapping['inherited']) && ! $parentClass->isMappedSuperclass) {
$mapping['inherited'] = $parentClass->name; $mapping['inherited'] = $parentClass->name;
} }
$subClass->addFieldMapping($mapping); if ( ! isset($mapping['declared'])) {
$mapping['declared'] = $parentClass->name;
}
$subClass->addInheritedFieldMapping($mapping);
} }
foreach ($parentClass->reflFields as $name => $field) { foreach ($parentClass->reflFields as $name => $field) {
$subClass->reflFields[$name] = $field; $subClass->reflFields[$name] = $field;
...@@ -325,23 +328,22 @@ class ClassMetadataFactory ...@@ -325,23 +328,22 @@ class ClassMetadataFactory
} }
/** /**
* Adds inherited associations to the subclass mapping. * Adds inherited association mappings to the subclass mapping.
* *
* @param Doctrine\ORM\Mapping\ClassMetadata $subClass * @param Doctrine\ORM\Mapping\ClassMetadata $subClass
* @param Doctrine\ORM\Mapping\ClassMetadata $parentClass * @param Doctrine\ORM\Mapping\ClassMetadata $parentClass
*/ */
private function _addInheritedRelations(ClassMetadata $subClass, ClassMetadata $parentClass) private function _addInheritedRelations(ClassMetadata $subClass, ClassMetadata $parentClass)
{ {
foreach ($parentClass->associationMappings as $mapping) { foreach ($parentClass->associationMappings as $field => $mapping) {
if (isset($parentClass->inheritedAssociationFields[$mapping->sourceFieldName])) { $subclassMapping = clone $mapping;
// parent class also inherited that one if ( ! isset($mapping->inherited) && ! $parentClass->isMappedSuperclass) {
$subClass->addAssociationMapping($mapping, $parentClass->inheritedAssociationFields[$mapping->sourceFieldName]); $subclassMapping->inherited = $parentClass->name;
} else if ( ! $parentClass->isMappedSuperclass) { }
// parent class defined that one if ( ! isset($mapping->declared)) {
$subClass->addAssociationMapping($mapping, $parentClass->name); $subclassMapping->declared = $parentClass->name;
} else {
$subClass->addAssociationMapping($mapping);
} }
$subClass->addInheritedAssociationMapping($subclassMapping);
} }
} }
......
<?php <?php
/* /*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
...@@ -158,7 +156,7 @@ class ClassMetadataInfo ...@@ -158,7 +156,7 @@ class ClassMetadataInfo
public $parentClasses = array(); public $parentClasses = array();
/** /**
* READ-ONLY: The names of all subclasses. * READ-ONLY: The names of all subclasses (descendants).
* *
* @var array * @var array
*/ */
...@@ -195,9 +193,9 @@ class ClassMetadataInfo ...@@ -195,9 +193,9 @@ class ClassMetadataInfo
* - <b>fieldName</b> (string) * - <b>fieldName</b> (string)
* The name of the field in the Entity. * The name of the field in the Entity.
* *
* - <b>type</b> (object Doctrine\DBAL\Types\* or custom type) * - <b>type</b> (string)
* The type of the column. Can be one of Doctrine's portable types * The type name of the mapped field. Can be one of Doctrine's mapping types
* or a custom type. * or a custom mapping type.
* *
* - <b>columnName</b> (string, optional) * - <b>columnName</b> (string, optional)
* The column name. Optional. Defaults to the field name. * The column name. Optional. Defaults to the field name.
...@@ -207,15 +205,9 @@ class ClassMetadataInfo ...@@ -207,15 +205,9 @@ class ClassMetadataInfo
* the type. * the type.
* *
* - <b>id</b> (boolean, optional) * - <b>id</b> (boolean, optional)
* Marks the field as the primary key of the Entity. Multiple fields of an * Marks the field as the primary key of the entity. Multiple fields of an
* entity can have the id attribute, forming a composite key. * entity can have the id attribute, forming a composite key.
* *
* - <b>idGenerator</b> (string, optional)
* Either: idGenerator => 'nameOfGenerator', usually only for TABLE/SEQUENCE generators
* Or: idGenerator => 'identity' or 'auto' or 'table' or 'sequence'
* Note that 'auto', 'table', 'sequence' and 'identity' are reserved names and
* therefore cant be used as a generator name!
*
* - <b>nullable</b> (boolean, optional) * - <b>nullable</b> (boolean, optional)
* Whether the column is nullable. Defaults to FALSE. * Whether the column is nullable. Defaults to FALSE.
* *
...@@ -306,7 +298,7 @@ class ClassMetadataInfo ...@@ -306,7 +298,7 @@ class ClassMetadataInfo
public $lifecycleCallbacks = array(); public $lifecycleCallbacks = array();
/** /**
* READ-ONLY: The association mappings. All mappings, inverse and owning side. * READ-ONLY: The association mappings of this class.
* *
* @var array * @var array
*/ */
...@@ -323,6 +315,7 @@ class ClassMetadataInfo ...@@ -323,6 +315,7 @@ class ClassMetadataInfo
* READ-ONLY: The ID generator used for generating IDs for this class. * READ-ONLY: The ID generator used for generating IDs for this class.
* *
* @var AbstractIdGenerator * @var AbstractIdGenerator
* @todo Remove
*/ */
public $idGenerator; public $idGenerator;
...@@ -358,15 +351,6 @@ class ClassMetadataInfo ...@@ -358,15 +351,6 @@ class ClassMetadataInfo
*/ */
public $changeTrackingPolicy = self::CHANGETRACKING_DEFERRED_IMPLICIT; public $changeTrackingPolicy = self::CHANGETRACKING_DEFERRED_IMPLICIT;
/**
* READ-ONLY: A map of field names to class names, where the field names are association
* fields that have been inherited from another class and values are the names
* of the classes that define the association.
*
* @var array
*/
public $inheritedAssociationFields = array();
/** /**
* READ-ONLY: A flag for whether or not instances of this class are to be versioned * READ-ONLY: A flag for whether or not instances of this class are to be versioned
* with optimistic locking. * with optimistic locking.
...@@ -592,16 +576,6 @@ class ClassMetadataInfo ...@@ -592,16 +576,6 @@ class ClassMetadataInfo
} }
} }
/**
* Maps an embedded value object.
*
* @todo Implementation.
*/
/*public function mapEmbeddedValue()
{
//...
}*/
/** /**
* Gets the identifier (primary key) field names of the class. * Gets the identifier (primary key) field names of the class.
* *
...@@ -716,7 +690,6 @@ class ClassMetadataInfo ...@@ -716,7 +690,6 @@ class ClassMetadataInfo
} }
/** /**
*
* @return boolean * @return boolean
*/ */
public function isInheritanceTypeNone() public function isInheritanceTypeNone()
...@@ -856,16 +829,6 @@ class ClassMetadataInfo ...@@ -856,16 +829,6 @@ class ClassMetadataInfo
} }
} }
/**
* Checks whether the class has any persistent subclasses.
*
* @return boolean TRUE if the class has one or more persistent subclasses, FALSE otherwise.
*/
public function hasSubclasses()
{
return ! $this->subClasses;
}
/** /**
* Sets the parent class names. * Sets the parent class names.
* Assumes that the class names in the passed array are in the order: * Assumes that the class names in the passed array are in the order:
...@@ -879,16 +842,6 @@ class ClassMetadataInfo ...@@ -879,16 +842,6 @@ class ClassMetadataInfo
} }
} }
/**
* Checks whether the class has any persistent parent classes.
*
* @return boolean TRUE if the class has one or more persistent parent classes, FALSE otherwise.
*/
public function hasParentClasses()
{
return ! $this->parentClasses;
}
/** /**
* Sets the inheritance type used by the class and it's subclasses. * Sets the inheritance type used by the class and it's subclasses.
* *
...@@ -903,7 +856,7 @@ class ClassMetadataInfo ...@@ -903,7 +856,7 @@ class ClassMetadataInfo
} }
/** /**
* Checks whether a mapped field is inherited from a superclass. * Checks whether a mapped field is inherited from an entity superclass.
* *
* @return boolean TRUE if the field is inherited, FALSE otherwise. * @return boolean TRUE if the field is inherited, FALSE otherwise.
*/ */
...@@ -920,7 +873,7 @@ class ClassMetadataInfo ...@@ -920,7 +873,7 @@ class ClassMetadataInfo
*/ */
public function isInheritedAssociation($fieldName) public function isInheritedAssociation($fieldName)
{ {
return isset($this->inheritedAssociationFields[$fieldName]); return isset($this->associationMappings[$fieldName]->inherited);
} }
/** /**
...@@ -963,21 +916,6 @@ class ClassMetadataInfo ...@@ -963,21 +916,6 @@ class ClassMetadataInfo
$type == self::INHERITANCE_TYPE_TABLE_PER_CLASS; $type == self::INHERITANCE_TYPE_TABLE_PER_CLASS;
} }
/**
* Checks whether the given type identifies an id generator type.
*
* @param string $type
* @return boolean
*/
private function _isIdGeneratorType($type)
{
return $type == self::GENERATOR_TYPE_AUTO ||
$type == self::GENERATOR_TYPE_IDENTITY ||
$type == self::GENERATOR_TYPE_SEQUENCE ||
$type == self::GENERATOR_TYPE_TABLE ||
$type == self::GENERATOR_TYPE_NONE;
}
/** /**
* Makes some automatic additions to the association mapping to make the life * Makes some automatic additions to the association mapping to make the life
* easier for the user, and store join columns in the metadata. * easier for the user, and store join columns in the metadata.
...@@ -995,7 +933,7 @@ class ClassMetadataInfo ...@@ -995,7 +933,7 @@ class ClassMetadataInfo
} }
/** /**
* Adds a field mapping. * Adds a mapped field to the class.
* *
* @param array $mapping The field mapping. * @param array $mapping The field mapping.
*/ */
...@@ -1015,18 +953,13 @@ class ClassMetadataInfo ...@@ -1015,18 +953,13 @@ class ClassMetadataInfo
* *
* @param AssociationMapping $mapping * @param AssociationMapping $mapping
* @param string $owningClassName The name of the class that defined this mapping. * @param string $owningClassName The name of the class that defined this mapping.
* @todo Rename: addInheritedAssociationMapping
*/ */
public function addAssociationMapping(AssociationMapping $mapping, $owningClassName = null) public function addInheritedAssociationMapping(AssociationMapping $mapping/*, $owningClassName = null*/)
{ {
$sourceFieldName = $mapping->sourceFieldName; if (isset($this->associationMappings[$mapping->sourceFieldName])) {
if (isset($this->associationMappings[$sourceFieldName])) { throw MappingException::duplicateAssociationMapping($this->name, $mapping->sourceFieldName);
throw MappingException::duplicateAssociationMapping($this->name, $sourceFieldName);
}
$this->associationMappings[$sourceFieldName] = $mapping;
if ($owningClassName !== null) {
$this->inheritedAssociationFields[$sourceFieldName] = $owningClassName;
} }
$this->associationMappings[$mapping->sourceFieldName] = $mapping;
} }
/** /**
...@@ -1037,7 +970,7 @@ class ClassMetadataInfo ...@@ -1037,7 +970,7 @@ class ClassMetadataInfo
* @param array $mapping * @param array $mapping
* @todo Rename: addInheritedFieldMapping * @todo Rename: addInheritedFieldMapping
*/ */
public function addFieldMapping(array $fieldMapping) public function addInheritedFieldMapping(array $fieldMapping)
{ {
$this->fieldMappings[$fieldMapping['fieldName']] = $fieldMapping; $this->fieldMappings[$fieldMapping['fieldName']] = $fieldMapping;
$this->columnNames[$fieldMapping['fieldName']] = $fieldMapping['columnName']; $this->columnNames[$fieldMapping['fieldName']] = $fieldMapping['columnName'];
...@@ -1225,17 +1158,6 @@ class ClassMetadataInfo ...@@ -1225,17 +1158,6 @@ class ClassMetadataInfo
} }
} }
/**
* Checks whether the given column name is the discriminator column.
*
* @param string $columnName
* @return boolean
*/
public function isDiscriminatorColumn($columnName)
{
return $columnName === $this->discriminatorColumn['name'];
}
/** /**
* Checks whether the class has a mapped association with the given field name. * Checks whether the class has a mapped association with the given field name.
* *
...@@ -1304,7 +1226,7 @@ class ClassMetadataInfo ...@@ -1304,7 +1226,7 @@ class ClassMetadataInfo
/** /**
* Sets the version field mapping used for versioning. Sets the default * Sets the version field mapping used for versioning. Sets the default
* value to use depending on the column type * value to use depending on the column type.
* *
* @param array $mapping The version field mapping array * @param array $mapping The version field mapping array
*/ */
......
...@@ -78,14 +78,10 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister ...@@ -78,14 +78,10 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
public function getOwningTable($fieldName) public function getOwningTable($fieldName)
{ {
if ( ! isset($this->_owningTableMap[$fieldName])) { if ( ! isset($this->_owningTableMap[$fieldName])) {
if (isset($this->_class->associationMappings[$fieldName])) { if (isset($this->_class->associationMappings[$fieldName]->inherited)) {
if (isset($this->_class->inheritedAssociationFields[$fieldName])) {
$this->_owningTableMap[$fieldName] = $this->_em->getClassMetadata( $this->_owningTableMap[$fieldName] = $this->_em->getClassMetadata(
$this->_class->inheritedAssociationFields[$fieldName] $this->_class->associationMappings[$fieldName]->inherited
)->table['name']; )->table['name'];
} else {
$this->_owningTableMap[$fieldName] = $this->_class->table['name'];
}
} else if (isset($this->_class->fieldMappings[$fieldName]['inherited'])) { } else if (isset($this->_class->fieldMappings[$fieldName]['inherited'])) {
$this->_owningTableMap[$fieldName] = $this->_em->getClassMetadata( $this->_owningTableMap[$fieldName] = $this->_em->getClassMetadata(
$this->_class->fieldMappings[$fieldName]['inherited'] $this->_class->fieldMappings[$fieldName]['inherited']
...@@ -252,8 +248,8 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister ...@@ -252,8 +248,8 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
// Add foreign key columns // Add foreign key columns
foreach ($this->_class->associationMappings as $assoc) { foreach ($this->_class->associationMappings as $assoc) {
if ($assoc->isOwningSide && $assoc->isOneToOne()) { if ($assoc->isOwningSide && $assoc->isOneToOne()) {
$tableAlias = isset($this->_class->inheritedAssociationFields[$assoc->sourceFieldName]) ? $tableAlias = $assoc->inherited ?
$this->_getSQLTableAlias($this->_em->getClassMetadata($this->_class->inheritedAssociationFields[$assoc->sourceFieldName])) $this->_getSQLTableAlias($this->_em->getClassMetadata($assoc->inherited))
: $baseTableAlias; : $baseTableAlias;
foreach ($assoc->targetToSourceKeyColumns as $srcColumn) { foreach ($assoc->targetToSourceKeyColumns as $srcColumn) {
$columnAlias = $srcColumn . $this->_sqlAliasCounter++; $columnAlias = $srcColumn . $this->_sqlAliasCounter++;
...@@ -308,7 +304,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister ...@@ -308,7 +304,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
// Add join columns (foreign keys) // Add join columns (foreign keys)
foreach ($subClass->associationMappings as $assoc2) { foreach ($subClass->associationMappings as $assoc2) {
if ($assoc2->isOwningSide && $assoc2->isOneToOne() && ! isset($subClass->inheritedAssociationFields[$assoc2->sourceFieldName])) { if ($assoc2->isOwningSide && $assoc2->isOneToOne() && ! $assoc2->inherited) {
foreach ($assoc2->targetToSourceKeyColumns as $srcColumn) { foreach ($assoc2->targetToSourceKeyColumns as $srcColumn) {
$columnAlias = $srcColumn . $this->_sqlAliasCounter++; $columnAlias = $srcColumn . $this->_sqlAliasCounter++;
$columnList .= ', ' . $tableAlias . ".$srcColumn AS $columnAlias"; $columnList .= ', ' . $tableAlias . ".$srcColumn AS $columnAlias";
...@@ -377,7 +373,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister ...@@ -377,7 +373,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
foreach ($this->_class->reflFields as $name => $field) { foreach ($this->_class->reflFields as $name => $field) {
if (isset($this->_class->fieldMappings[$name]['inherited']) && ! isset($this->_class->fieldMappings[$name]['id']) if (isset($this->_class->fieldMappings[$name]['inherited']) && ! isset($this->_class->fieldMappings[$name]['id'])
|| isset($this->_class->inheritedAssociationFields[$name]) || isset($this->_class->associationMappings[$name]->inherited)
|| ($this->_class->isVersioned && $this->_class->versionField == $name)) { || ($this->_class->isVersioned && $this->_class->versionField == $name)) {
continue; continue;
} }
......
<?php <?php
/* /*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
...@@ -63,7 +61,7 @@ class SingleTablePersister extends AbstractEntityInheritancePersister ...@@ -63,7 +61,7 @@ class SingleTablePersister extends AbstractEntityInheritancePersister
// Append subclass foreign keys // Append subclass foreign keys
foreach ($subClass->associationMappings as $assoc) { foreach ($subClass->associationMappings as $assoc) {
if ($assoc->isOwningSide && $assoc->isOneToOne() && ! isset($subClass->inheritedAssociationFields[$assoc->sourceFieldName])) { if ($assoc->isOwningSide && $assoc->isOneToOne() && ! $assoc->inherited) {
foreach ($assoc->targetToSourceKeyColumns as $srcColumn) { foreach ($assoc->targetToSourceKeyColumns as $srcColumn) {
$columnAlias = $srcColumn . $this->_sqlAliasCounter++; $columnAlias = $srcColumn . $this->_sqlAliasCounter++;
$columnList .= ', ' . $tableAlias . ".$srcColumn AS $columnAlias"; $columnList .= ', ' . $tableAlias . ".$srcColumn AS $columnAlias";
......
...@@ -695,6 +695,7 @@ class StandardEntityPersister ...@@ -695,6 +695,7 @@ class StandardEntityPersister
$tableAlias = isset($this->_class->fieldMappings[$fieldName]['inherited']) ? $tableAlias = isset($this->_class->fieldMappings[$fieldName]['inherited']) ?
$this->_getSQLTableAlias($this->_em->getClassMetadata($this->_class->fieldMappings[$fieldName]['inherited'])) $this->_getSQLTableAlias($this->_em->getClassMetadata($this->_class->fieldMappings[$fieldName]['inherited']))
: $baseTableAlias; : $baseTableAlias;
$columnName = $this->_class->getQuotedColumnName($fieldName, $this->_platform); $columnName = $this->_class->getQuotedColumnName($fieldName, $this->_platform);
if ($orderBySql != '') { if ($orderBySql != '') {
$orderBySql .= ', '; $orderBySql .= ', ';
......
<?php <?php
/* /*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
...@@ -30,10 +28,7 @@ use Doctrine\DBAL\Connection, ...@@ -30,10 +28,7 @@ use Doctrine\DBAL\Connection,
* Class Table Inheritance (JOINED). * Class Table Inheritance (JOINED).
* *
* @author Roman Borschel <roman@code-factory.org> * @author Roman Borschel <roman@code-factory.org>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.doctrine-project.org
* @since 2.0 * @since 2.0
* @version $Revision$
*/ */
class MultiTableUpdateExecutor extends AbstractSqlExecutor class MultiTableUpdateExecutor extends AbstractSqlExecutor
{ {
......
...@@ -466,8 +466,8 @@ class SqlWalker implements TreeWalker ...@@ -466,8 +466,8 @@ class SqlWalker implements TreeWalker
$dqlAlias = $pathExpr->identificationVariable; $dqlAlias = $pathExpr->identificationVariable;
$class = $this->_queryComponents[$dqlAlias]['metadata']; $class = $this->_queryComponents[$dqlAlias]['metadata'];
if (isset($class->inheritedAssociationFields[$fieldName])) { if (isset($class->associationMappings[$fieldName]->inherited)) {
$class = $this->_em->getClassMetadata($class->inheritedAssociationFields[$fieldName]); $class = $this->_em->getClassMetadata($class->associationMappings[$fieldName]->inherited);
} }
$assoc = $class->associationMappings[$fieldName]; $assoc = $class->associationMappings[$fieldName];
...@@ -538,8 +538,8 @@ class SqlWalker implements TreeWalker ...@@ -538,8 +538,8 @@ class SqlWalker implements TreeWalker
//FIXME: Include foreign key columns of child classes also!!?? //FIXME: Include foreign key columns of child classes also!!??
foreach ($class->associationMappings as $assoc) { foreach ($class->associationMappings as $assoc) {
if ($assoc->isOwningSide && $assoc->isOneToOne()) { if ($assoc->isOwningSide && $assoc->isOneToOne()) {
if (isset($class->inheritedAssociationFields[$assoc->sourceFieldName])) { if ($assoc->inherited) {
$owningClass = $this->_em->getClassMetadata($class->inheritedAssociationFields[$assoc->sourceFieldName]); $owningClass = $this->_em->getClassMetadata($assoc->inherited);
$sqlTableAlias = $this->getSqlTableAlias($owningClass->table['name'], $dqlAlias); $sqlTableAlias = $this->getSqlTableAlias($owningClass->table['name'], $dqlAlias);
} else { } else {
$sqlTableAlias = $this->getSqlTableAlias($class->table['name'], $dqlAlias); $sqlTableAlias = $this->getSqlTableAlias($class->table['name'], $dqlAlias);
...@@ -958,7 +958,7 @@ class SqlWalker implements TreeWalker ...@@ -958,7 +958,7 @@ class SqlWalker implements TreeWalker
// Add join columns (foreign keys) of the subclass // Add join columns (foreign keys) of the subclass
//TODO: Probably better do this in walkSelectClause to honor the INCLUDE_META_COLUMNS hint //TODO: Probably better do this in walkSelectClause to honor the INCLUDE_META_COLUMNS hint
foreach ($subClass->associationMappings as $fieldName => $assoc) { foreach ($subClass->associationMappings as $fieldName => $assoc) {
if ($assoc->isOwningSide && $assoc->isOneToOne() && ! isset($subClass->inheritedAssociationFields[$fieldName])) { if ($assoc->isOwningSide && $assoc->isOneToOne() && ! $assoc->inherited) {
foreach ($assoc->targetToSourceKeyColumns as $srcColumn) { foreach ($assoc->targetToSourceKeyColumns as $srcColumn) {
if ($beginning) $beginning = false; else $sql .= ', '; if ($beginning) $beginning = false; else $sql .= ', ';
$columnAlias = $this->getSqlColumnAlias($srcColumn); $columnAlias = $this->getSqlColumnAlias($srcColumn);
......
...@@ -347,7 +347,7 @@ class SchemaTool ...@@ -347,7 +347,7 @@ class SchemaTool
private function _gatherRelationsSql($class, $table, $schema) private function _gatherRelationsSql($class, $table, $schema)
{ {
foreach ($class->associationMappings as $fieldName => $mapping) { foreach ($class->associationMappings as $fieldName => $mapping) {
if (isset($class->inheritedAssociationFields[$fieldName])) { if ($mapping->inherited) {
continue; continue;
} }
......
; Default configuration file for PHPDoctor
; This config file will cause PHPDoctor to generate API documentation of
; itself.
; PHPDoctor settings
; -----------------------------------------------------------------------------
; Names of files to parse. This can be a single filename, or a comma separated
; list of filenames. Wildcards are allowed.
;files = "*.php"
files = *.php
; Names of files or directories to ignore. This can be a single filename, or a
; comma separated list of filenames. Wildcards are NOT allowed.
ignore = "CVS, .svn, .git, _compiled, vendor"
; The directory to look for files in, if not used the PHPDoctor will look in
; the current directory (the directory it is run from).
source_path = "./lib"
; If you do not want PHPDoctor to look in each sub directory for files
; uncomment this line.
;subdirs = off
; Set how loud PHPDoctor is as it runs. Quiet mode suppresses all output other
; than warnings and errors. Verbose mode outputs additional messages during
; execution.
;quiet = on
;verbose = on
; Select the doclet to use for generating output.
doclet = standard
;doclet = debug
; The directory to find the doclet in. Doclets are expected to be in a
; directory named after themselves at the location given.
;doclet_path = ./doclets
; The directory to find taglets in. Taglets allow you to make PHPDoctor handle
; new tags and to alter the behavour of existing tags and their output.
;taglet_path = ./taglets
; If the code you are parsing does not use package tags or not all elements
; have package tags, use this setting to place unbound elements into a
; particular package.
default_package = "Doctrine"
; Specifies the name of a HTML file containing text for the overview
; documentation to be placed on the overview page. The path is relative to
; "source_path" unless an absolute path is given.
overview = readme.html
; Package comments will be looked for in a file named package.html in the same
; directory as the first source file parsed in that package or in the directory
; given below. If package comments are placed in the directory given below then
; they should be named "<packageName>.html".
package_comment_dir = ./
; Parse out global variables and/or global constants?
;globals = off
;constants = off
; Generate documentation for all class members
;private = on
; Generate documentation for public and protected class members
protected = on
; Generate documentation for only public class members
;public = on
; Use the PEAR compatible handling of the docblock first sentence
;pear_compat = on
; Standard doclet settings
; -----------------------------------------------------------------------------
; The directory to place generated documentation in. If the given path is
; relative to it will be relative to "source_path".
d = "api"
; Specifies the title to be placed in the HTML <title> tag.
windowtitle = "Doctrine"
; Specifies the title to be placed near the top of the overview summary file.
doctitle = "Doctrine: PHP Object-Relational Mapper"
; Specifies the header text to be placed at the top of each output file. The
; header will be placed to the right of the upper navigation bar.
header = "Doctrine"
; Specifies the footer text to be placed at the bottom of each output file. The
; footer will be placed to the right of the lower navigation bar.
footer = "Doctrine"
; Specifies the text to be placed at the bottom of each output file. The text
; will be placed at the bottom of the page, below the lower navigation bar.
;bottom = "This document was generated by <a href="http://phpdoctor.sourceforge.net/">PHPDoctor: The PHP Documentation Creator</a>"
; Create a class tree?
;tree = off
...@@ -48,7 +48,6 @@ class BasicInheritanceMappingTest extends \Doctrine\Tests\OrmTestCase ...@@ -48,7 +48,6 @@ class BasicInheritanceMappingTest extends \Doctrine\Tests\OrmTestCase
$this->assertFalse(isset($class->fieldMappings['mapped2']['inherited'])); $this->assertFalse(isset($class->fieldMappings['mapped2']['inherited']));
$this->assertFalse(isset($class->fieldMappings['transient'])); $this->assertFalse(isset($class->fieldMappings['transient']));
$this->assertTrue(empty($class->inheritedAssociationFields));
$this->assertTrue(isset($class->associationMappings['mappedRelated1'])); $this->assertTrue(isset($class->associationMappings['mappedRelated1']));
} }
...@@ -64,6 +63,7 @@ class BasicInheritanceMappingTest extends \Doctrine\Tests\OrmTestCase ...@@ -64,6 +63,7 @@ class BasicInheritanceMappingTest extends \Doctrine\Tests\OrmTestCase
$this->assertTrue(isset($class2->reflFields['mapped1'])); $this->assertTrue(isset($class2->reflFields['mapped1']));
$this->assertTrue(isset($class2->reflFields['mapped2'])); $this->assertTrue(isset($class2->reflFields['mapped2']));
$this->assertTrue(isset($class2->reflFields['mappedRelated1']));
} }
} }
......
...@@ -162,9 +162,9 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase ...@@ -162,9 +162,9 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
$a1 = new \Doctrine\ORM\Mapping\OneToOneMapping(array('fieldName' => 'foo', 'sourceEntity' => 'stdClass', 'targetEntity' => 'stdClass', 'mappedBy' => 'foo')); $a1 = new \Doctrine\ORM\Mapping\OneToOneMapping(array('fieldName' => 'foo', 'sourceEntity' => 'stdClass', 'targetEntity' => 'stdClass', 'mappedBy' => 'foo'));
$a2 = new \Doctrine\ORM\Mapping\OneToOneMapping(array('fieldName' => 'foo', 'sourceEntity' => 'stdClass', 'targetEntity' => 'stdClass', 'mappedBy' => 'foo')); $a2 = new \Doctrine\ORM\Mapping\OneToOneMapping(array('fieldName' => 'foo', 'sourceEntity' => 'stdClass', 'targetEntity' => 'stdClass', 'mappedBy' => 'foo'));
$cm->addAssociationMapping($a1); $cm->addInheritedAssociationMapping($a1);
$this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); $this->setExpectedException('Doctrine\ORM\Mapping\MappingException');
$cm->addAssociationMapping($a2); $cm->addInheritedAssociationMapping($a2);
} }
public function testDuplicateColumnName_ThrowsMappingException() public function testDuplicateColumnName_ThrowsMappingException()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment