Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[DDC-193] Fixed.
  • Loading branch information
romanb committed Apr 9, 2010
1 parent 5381e3d commit 7cc56c4
Show file tree
Hide file tree
Showing 59 changed files with 159 additions and 211 deletions.
2 changes: 1 addition & 1 deletion UPGRADE_TO_2_0
Expand Up @@ -46,7 +46,7 @@ Prefer PHP default values, if possible.

## Partial Objects

xxx
[TBD: New syntax, results, etc.]

## XML Mapping Driver

Expand Down
9 changes: 6 additions & 3 deletions doctrine-mapping.xsd
Expand Up @@ -217,7 +217,7 @@
</xs:complexType>

<xs:complexType name="order-by-field">
<xs:attribute name="field" type="XS:NMTOKEN" use="required" />
<xs:attribute name="name" type="xs:NMTOKEN" use="required" />
<xs:attribute name="direction" type="orm:order-by-direction" default="ASC" />
</xs:complexType>

Expand All @@ -237,6 +237,7 @@
<xs:attribute name="target-entity" type="xs:NMTOKEN" use="required" />
<xs:attribute name="field" type="xs:NMTOKEN" use="required" />
<xs:attribute name="mapped-by" type="xs:NMTOKEN" />
<xs:attribute name="inversed-by" type="xs:NMTOKEN" />
<xs:attribute name="fetch" type="orm:fetch-type" default="LAZY" />
</xs:complexType>

Expand All @@ -246,7 +247,7 @@
<xs:element name="order-by" type="orm:order-by" minOccurs="0" />
</xs:sequence>
<xs:attribute name="target-entity" type="xs:NMTOKEN" use="required" />
<xs:attribute name="mapped-by" type="xs:NMTOKEN" />
<xs:attribute name="mapped-by" type="xs:NMTOKEN" use="required" />
<xs:attribute name="field" type="xs:NMTOKEN" use="required" />
<xs:attribute name="orphan-removal" type="xs:boolean" default="false" />
<xs:attribute name="fetch" type="orm:fetch-type" default="LAZY" />
Expand All @@ -264,6 +265,7 @@
<xs:attribute name="field" type="xs:NMTOKEN" use="required" />
<xs:attribute name="orphan-removal" type="xs:boolean" default="false" />
<xs:attribute name="fetch" type="orm:fetch-type" default="LAZY" />
<xs:attribute name="inversed-by" type="xs:NMTOKEN" />
</xs:complexType>

<xs:complexType name="one-to-one">
Expand All @@ -274,9 +276,10 @@
<xs:element name="join-columns" type="orm:join-columns"/>
</xs:choice>
</xs:sequence>
<xs:attribute name="field" type="xs:NMTOKEN" use="required" />
<xs:attribute name="target-entity" type="xs:NMTOKEN" use="required" />
<xs:attribute name="mapped-by" type="xs:NMTOKEN" />
<xs:attribute name="field" type="xs:NMTOKEN" use="required" />
<xs:attribute name="inversed-by" type="xs:NMTOKEN" />
<xs:attribute name="orphan-removal" type="xs:boolean" default="false" />
<xs:attribute name="fetch" type="orm:fetch-type" default="LAZY" />
</xs:complexType>
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/Common/EventArgs.php
Expand Up @@ -26,7 +26,7 @@
*
* This class contains no event data. It is used by events that do not pass state
* information to an event handler when an event is raised. The single empty EventArgs
* instance can be obtained through {@link getEmptyInstance()}.
* instance can be obtained through {@link getEmptyInstance}.
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
Expand Down
7 changes: 3 additions & 4 deletions lib/Doctrine/Common/EventSubscriber.php
Expand Up @@ -16,29 +16,28 @@
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
* <http://www.doctrine-project.org>.
*/

namespace Doctrine\Common;

/**
* An EventSubscriber knows himself what events he is interested in.
* If an EventSubscriber is added to an EventManager, the manager invokes
* getSubscribedEvents() and registers the subscriber as a listener for all
* {@link getSubscribedEvents} and registers the subscriber as a listener for all
* returned events.
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
interface EventSubscriber
{
/**
* Returns an array of events that this subscriber listens
* Returns an array of events this subscriber wants to listen to.
*
* @return array
*/
Expand Down
9 changes: 5 additions & 4 deletions lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php
Expand Up @@ -87,8 +87,8 @@ protected function _prepare()
if ($assoc->mappedBy) {
$this->_hints['fetched'][$className][$assoc->mappedBy] = true;
} else {
if (isset($class->inverseMappings[$sourceClassName][$assoc->sourceFieldName])) {
$inverseAssoc = $class->inverseMappings[$sourceClassName][$assoc->sourceFieldName];
if ($assoc->inversedBy) {
$inverseAssoc = $class->associationMappings[$assoc->inversedBy];
if ($inverseAssoc->isOneToOne()) {
$this->_hints['fetched'][$className][$inverseAssoc->sourceFieldName] = true;
if ($class->subClasses) {
Expand Down Expand Up @@ -346,9 +346,10 @@ protected function _hydrateRow(array $data, array &$cache, array &$result)
$this->_uow->setOriginalEntityProperty($oid, $relationField, $element);
$targetClass = $this->_ce[$relation->targetEntityName];
if ($relation->isOwningSide) {
//TODO: Just check hints['fetched'] here?
// If there is an inverse mapping on the target class its bidirectional
if (isset($targetClass->inverseMappings[$relation->sourceEntityName][$relationField])) {
$inverseAssoc = $targetClass->inverseMappings[$relation->sourceEntityName][$relationField];
if ($relation->inversedBy) {
$inverseAssoc = $targetClass->associationMappings[$relation->inversedBy];
if ($inverseAssoc->isOneToOne()) {
$targetClass->reflFields[$inverseAssoc->sourceFieldName]->setValue($element, $parentObject);
$this->_uow->setOriginalEntityProperty(spl_object_hash($element), $inverseAssoc->sourceFieldName, $parentObject);
Expand Down
1 change: 0 additions & 1 deletion lib/Doctrine/ORM/Mapping/ClassMetadata.php
Expand Up @@ -315,7 +315,6 @@ public function __sleep()
'idGenerator', //TODO: Does not really need to be serialized. Could be moved to runtime.
'inheritanceType',
'inheritedAssociationFields',
'inverseMappings', //TODO: Remove! DDC-193
'isIdentifierComposite',
'isMappedSuperclass',
'isVersioned',
Expand Down
58 changes: 3 additions & 55 deletions lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
Expand Up @@ -127,9 +127,9 @@ class ClassMetadataInfo
public $namespace;

/**
* READ-ONLY: The name of the entity class that is at the root of the entity inheritance
* hierarchy. If the entity is not part of an inheritance hierarchy this is the same
* as $_entityName.
* READ-ONLY: The name of the entity class that is at the root of the mapped entity inheritance
* hierarchy. If the entity is not part of a mapped inheritance hierarchy this is the same
* as {@link $entityName}.
*
* @var string
*/
Expand Down Expand Up @@ -312,14 +312,6 @@ class ClassMetadataInfo
*/
public $associationMappings = array();

/**
* READ-ONLY: List of inverse association mappings, indexed by mappedBy field name.
*
* @var array
* @todo Remove! See http://www.doctrine-project.org/jira/browse/DDC-193
*/
public $inverseMappings = array();

/**
* READ-ONLY: Flag indicating whether the identifier/primary key of the class is composite.
*
Expand Down Expand Up @@ -531,34 +523,6 @@ public function getAssociationMapping($fieldName)
return $this->associationMappings[$fieldName];
}

/**
* Gets the inverse association mapping for the given target class name and
* owning fieldname.
*
* @param string $mappedByFieldName The field on the
* @return Doctrine\ORM\Mapping\AssociationMapping The mapping or NULL if there is no such
* inverse association mapping.
*/
public function getInverseAssociationMapping($targetClassName, $mappedByFieldName)
{
return isset($this->inverseMappings[$targetClassName][$mappedByFieldName]) ?
$this->inverseMappings[$targetClassName][$mappedByFieldName] : null;
}

/**
* Checks whether the class has an inverse association mapping that points to the
* specified class and ha the specified mappedBy field.
*
* @param string $targetClassName The name of the target class.
* @param string $mappedByFieldName The name of the mappedBy field that points to the field on
* the target class that owns the association.
* @return boolean
*/
public function hasInverseAssociationMapping($targetClassName, $mappedByFieldName)
{
return isset($this->inverseMappings[$targetClassName][$mappedByFieldName]);
}

/**
* Gets all association mappings of the class.
*
Expand Down Expand Up @@ -1063,7 +1027,6 @@ public function addAssociationMapping(AssociationMapping $mapping, $owningClassN
if ($owningClassName !== null) {
$this->inheritedAssociationFields[$sourceFieldName] = $owningClassName;
}
$this->_registerMappingIfInverse($mapping);
}

/**
Expand Down Expand Up @@ -1093,20 +1056,6 @@ public function mapOneToOne(array $mapping)
$this->_storeAssociationMapping($oneToOneMapping);
}

/**
* Registers the mapping as an inverse mapping, if it is a mapping on the
* inverse side of an association mapping.
*
* @param AssociationMapping The mapping to register as inverse if it is a mapping
* for the inverse side of an association.
*/
private function _registerMappingIfInverse(AssociationMapping $assoc)
{
if ( ! $assoc->isOwningSide) {
$this->inverseMappings[$assoc->targetEntityName][$assoc->mappedBy] = $assoc;
}
}

/**
* Adds a one-to-many mapping.
*
Expand Down Expand Up @@ -1154,7 +1103,6 @@ protected function _storeAssociationMapping(AssociationMapping $assocMapping)
throw MappingException::duplicateFieldMapping($this->name, $sourceFieldName);
}
$this->associationMappings[$sourceFieldName] = $assocMapping;
$this->_registerMappingIfInverse($assocMapping);
}

/**
Expand Down
12 changes: 6 additions & 6 deletions lib/Doctrine/ORM/Mapping/Driver/AbstractFileDriver.php
Expand Up @@ -55,7 +55,7 @@ abstract class AbstractFileDriver implements Driver
* @var string
*/
protected $_fileExtension;

/**
* Initializes a new FileDriver that looks in the given path(s) for mapping
* documents and operates in the specified operating mode.
Expand All @@ -76,7 +76,7 @@ public function addPaths(array $paths)
{
$this->_paths = array_unique(array_merge($this->_paths, $paths));
}

/**
* Retrieve the defined metadata lookup paths.
*
Expand Down Expand Up @@ -107,7 +107,7 @@ public function setFileExtension($fileExtension)
{
$this->_fileExtension = $fileExtension;
}

/**
* Get the element of schema meta data for the class from the mapping file.
* This will lazily load the mapping file if it is not loaded yet
Expand All @@ -132,7 +132,7 @@ public function getElement($className)
public function isTransient($className)
{
$fileName = str_replace('\\', '.', $className) . $this->_fileExtension;

// Check whether file exists
foreach ((array) $this->_paths as $path) {
if (file_exists($path . DIRECTORY_SEPARATOR . $fileName)) {
Expand All @@ -142,7 +142,7 @@ public function isTransient($className)

return true;
}

/**
* Gets the names of all mapped classes known to this driver.
*
Expand All @@ -151,7 +151,7 @@ public function isTransient($className)
public function getAllClassNames()
{
$classes = array();

if ($this->_paths) {
foreach ((array) $this->_paths as $path) {
if ( ! is_dir($path)) {
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php
Expand Up @@ -173,7 +173,7 @@ public function loadMetadataForClass($className, ClassMetadataInfo $metadata)
// Evaluate InheritanceType annotation
if (isset($classAnnotations['Doctrine\ORM\Mapping\InheritanceType'])) {
$inheritanceTypeAnnot = $classAnnotations['Doctrine\ORM\Mapping\InheritanceType'];
$metadata->setInheritanceType(constant('\Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_' . $inheritanceTypeAnnot->value));
$metadata->setInheritanceType(constant('Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_' . $inheritanceTypeAnnot->value));
}

// Evaluate DiscriminatorColumn annotation
Expand All @@ -195,7 +195,7 @@ public function loadMetadataForClass($className, ClassMetadataInfo $metadata)
// Evaluate DoctrineChangeTrackingPolicy annotation
if (isset($classAnnotations['Doctrine\ORM\Mapping\ChangeTrackingPolicy'])) {
$changeTrackingAnnot = $classAnnotations['Doctrine\ORM\Mapping\ChangeTrackingPolicy'];
$metadata->setChangeTrackingPolicy(constant('\Doctrine\ORM\Mapping\ClassMetadata::CHANGETRACKING_' . $changeTrackingAnnot->value));
$metadata->setChangeTrackingPolicy(constant('Doctrine\ORM\Mapping\ClassMetadata::CHANGETRACKING_' . $changeTrackingAnnot->value));
}

// Evaluate annotations on properties/fields
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php
Expand Up @@ -29,7 +29,7 @@
Doctrine\Common\Util\Inflector;

/**
* The DatabaseDriver reverse engineers the mapping metadata from a database
* The DatabaseDriver reverse engineers the mapping metadata from a database.
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
Expand Down Expand Up @@ -67,7 +67,7 @@ public function loadMetadataForClass($className, ClassMetadataInfo $metadata)

$columns = $this->_sm->listTableColumns($tableName);

if($this->_sm->getDatabasePlatform()->supportsForeignKeyConstraints()) {
if ($this->_sm->getDatabasePlatform()->supportsForeignKeyConstraints()) {
$foreignKeys = $this->_sm->listTableForeignKeys($tableName);
} else {
$foreignKeys = array();
Expand Down
2 changes: 0 additions & 2 deletions lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php
Expand Up @@ -37,7 +37,6 @@ final class DiscriminatorColumn extends Annotation {
public $length;
}
final class DiscriminatorMap extends Annotation {}
/*final class SubClasses extends Annotation {}*/
final class Id extends Annotation {}
final class GeneratedValue extends Annotation {
public $strategy = 'AUTO';
Expand Down Expand Up @@ -124,7 +123,6 @@ final class SequenceGenerator extends Annotation {
public $initialValue = 1;
}
final class ChangeTrackingPolicy extends Annotation {}

final class OrderBy extends Annotation {}

/* Annotations for lifecycle callbacks */
Expand Down
6 changes: 3 additions & 3 deletions lib/Doctrine/ORM/Mapping/Driver/DriverChain.php
Expand Up @@ -46,7 +46,7 @@ class DriverChain implements Driver
private $_drivers = array();

/**
* Add a nested driver
* Add a nested driver.
*
* @param Driver $nestedDriver
* @param string $namespace
Expand All @@ -57,7 +57,7 @@ public function addDriver(Driver $nestedDriver, $namespace)
}

/**
* Get the array of nested drivers
* Get the array of nested drivers.
*
* @return array $drivers
*/
Expand All @@ -74,7 +74,7 @@ public function getDrivers()
*/
public function loadMetadataForClass($className, ClassMetadataInfo $metadata)
{
foreach ($this->_drivers AS $namespace => $driver) {
foreach ($this->_drivers as $namespace => $driver) {
if (strpos($className, $namespace) === 0) {
$driver->loadMetadataForClass($className, $metadata);
return;
Expand Down
1 change: 0 additions & 1 deletion lib/Doctrine/ORM/Mapping/Driver/PhpDriver.php
Expand Up @@ -49,7 +49,6 @@ class PhpDriver extends AbstractFileDriver
* {@inheritdoc}
*/
protected $_fileExtension = '.php';

protected $_metadata;

/**
Expand Down

0 comments on commit 7cc56c4

Please sign in to comment.