Skip to content

Commit

Permalink
Deprecate and alias ClassMetadataInfo (doctrine#1733)
Browse files Browse the repository at this point in the history
  • Loading branch information
alcaeus committed Jan 10, 2019
1 parent b3ccd29 commit b796f50
Show file tree
Hide file tree
Showing 39 changed files with 3,043 additions and 3,028 deletions.
7 changes: 7 additions & 0 deletions UPGRADE-1.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,10 @@ class User
private $groups;
}
```

### `ClassMetadataInfo` class deprecated

The `Doctrine\ODM\MongoDB\Mapping\ClassMetadataInfo` class has been deprecated
in favor of `Doctrine\ODM\MongoDB\Mapping\ClassMetadata` and will be dropped in
2.0.

7 changes: 3 additions & 4 deletions lib/Doctrine/ODM/MongoDB/Aggregation/Stage/GraphLookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
use Doctrine\ODM\MongoDB\Aggregation\Builder;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ODM\MongoDB\Mapping\ClassMetadata;
use Doctrine\ODM\MongoDB\Mapping\ClassMetadataInfo;
use Doctrine\ODM\MongoDB\Mapping\MappingException;
use Doctrine\ODM\MongoDB\Types\Type;

Expand Down Expand Up @@ -198,9 +197,9 @@ private function getReferencedFieldName($fieldName, array $mapping)
}

switch ($mapping['storeAs']) {
case ClassMetadataInfo::REFERENCE_STORE_AS_ID:
case ClassMetadataInfo::REFERENCE_STORE_AS_REF:
return ClassMetadataInfo::getReferenceFieldName($mapping['storeAs'], $mapping['name']);
case ClassMetadata::REFERENCE_STORE_AS_ID:
case ClassMetadata::REFERENCE_STORE_AS_REF:
return ClassMetadata::getReferenceFieldName($mapping['storeAs'], $mapping['name']);
break;

default:
Expand Down
13 changes: 6 additions & 7 deletions lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Lookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
use Doctrine\ODM\MongoDB\Aggregation\Builder;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ODM\MongoDB\Mapping\ClassMetadata;
use Doctrine\ODM\MongoDB\Mapping\ClassMetadataInfo;
use Doctrine\ODM\MongoDB\Mapping\MappingException;

/**
Expand Down Expand Up @@ -111,9 +110,9 @@ private function fromReference($fieldName)

if ($referenceMapping['isOwningSide']) {
switch ($referenceMapping['storeAs']) {
case ClassMetadataInfo::REFERENCE_STORE_AS_ID:
case ClassMetadataInfo::REFERENCE_STORE_AS_REF:
$referencedFieldName = ClassMetadataInfo::getReferenceFieldName($referenceMapping['storeAs'], $referenceMapping['name']);
case ClassMetadata::REFERENCE_STORE_AS_ID:
case ClassMetadata::REFERENCE_STORE_AS_REF:
$referencedFieldName = ClassMetadata::getReferenceFieldName($referenceMapping['storeAs'], $referenceMapping['name']);
break;

default:
Expand All @@ -130,9 +129,9 @@ private function fromReference($fieldName)

$mappedByMapping = $this->targetClass->getFieldMapping($referenceMapping['mappedBy']);
switch ($mappedByMapping['storeAs']) {
case ClassMetadataInfo::REFERENCE_STORE_AS_ID:
case ClassMetadataInfo::REFERENCE_STORE_AS_REF:
$referencedFieldName = ClassMetadataInfo::getReferenceFieldName($mappedByMapping['storeAs'], $mappedByMapping['name']);
case ClassMetadata::REFERENCE_STORE_AS_ID:
case ClassMetadata::REFERENCE_STORE_AS_REF:
$referencedFieldName = ClassMetadata::getReferenceFieldName($mappedByMapping['storeAs'], $mappedByMapping['name']);
break;

default:
Expand Down
16 changes: 8 additions & 8 deletions lib/Doctrine/ODM/MongoDB/DocumentManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Common\Persistence\ObjectRepository;
use Doctrine\MongoDB\Connection;
use Doctrine\ODM\MongoDB\Mapping\ClassMetadataInfo;
use Doctrine\ODM\MongoDB\Mapping\ClassMetadata;
use Doctrine\ODM\MongoDB\Mapping\MappingException;
use Doctrine\ODM\MongoDB\Hydrator\HydratorFactory;
use Doctrine\ODM\MongoDB\Proxy\ProxyFactory;
Expand Down Expand Up @@ -556,7 +556,7 @@ public function flush($document = null, array $options = array())
*/
public function getReference($documentName, $identifier)
{
/* @var $class \Doctrine\ODM\MongoDB\Mapping\ClassMetadataInfo */
/* @var $class \Doctrine\ODM\MongoDB\Mapping\ClassMetadata */
$class = $this->metadataFactory->getMetadataFor(ltrim($documentName, '\\'));

// Check identity map first, if its already in there just return it.
Expand Down Expand Up @@ -697,27 +697,27 @@ public function createReference($document, array $referenceMapping)

$storeAs = isset($referenceMapping['storeAs']) ? $referenceMapping['storeAs'] : null;
switch ($storeAs) {
case ClassMetadataInfo::REFERENCE_STORE_AS_ID:
if ($class->inheritanceType === ClassMetadataInfo::INHERITANCE_TYPE_SINGLE_COLLECTION) {
case ClassMetadata::REFERENCE_STORE_AS_ID:
if ($class->inheritanceType === ClassMetadata::INHERITANCE_TYPE_SINGLE_COLLECTION) {
throw MappingException::simpleReferenceMustNotTargetDiscriminatedDocument($referenceMapping['targetDocument']);
}

return $class->getDatabaseIdentifierValue($id);
break;


case ClassMetadataInfo::REFERENCE_STORE_AS_REF:
case ClassMetadata::REFERENCE_STORE_AS_REF:
$reference = ['id' => $class->getDatabaseIdentifierValue($id)];
break;

case ClassMetadataInfo::REFERENCE_STORE_AS_DB_REF:
case ClassMetadata::REFERENCE_STORE_AS_DB_REF:
$reference = [
'$ref' => $class->getCollection(),
'$id' => $class->getDatabaseIdentifierValue($id),
];
break;

case ClassMetadataInfo::REFERENCE_STORE_AS_DB_REF_WITH_DB:
case ClassMetadata::REFERENCE_STORE_AS_DB_REF_WITH_DB:
$reference = [
'$ref' => $class->getCollection(),
'$id' => $class->getDatabaseIdentifierValue($id),
Expand Down Expand Up @@ -779,7 +779,7 @@ public function createDBRef($document, array $referenceMapping = null)
@trigger_error('The ' . __METHOD__ . ' method has been deprecated and will be removed in ODM 2.0. Use createReference() instead.', E_USER_DEPRECATED);

if (!isset($referenceMapping['storeAs'])) {
$referenceMapping['storeAs'] = ClassMetadataInfo::REFERENCE_STORE_AS_DB_REF;
$referenceMapping['storeAs'] = ClassMetadata::REFERENCE_STORE_AS_DB_REF;
}

return $this->createReference($document, $referenceMapping);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

namespace Doctrine\ODM\MongoDB\Mapping\Annotations;

use Doctrine\ODM\MongoDB\Mapping\ClassMetadataInfo;
use Doctrine\ODM\MongoDB\Mapping\ClassMetadata;
use Doctrine\ODM\MongoDB\Utility\CollectionHelper;

/**
Expand All @@ -32,7 +32,7 @@ final class ReferenceMany extends AbstractField
public $type = 'many';
public $reference = true;
public $simple = false; // @deprecated
public $storeAs = ClassMetadataInfo::REFERENCE_STORE_AS_DB_REF_WITH_DB;
public $storeAs = ClassMetadata::REFERENCE_STORE_AS_DB_REF_WITH_DB;
public $targetDocument;
public $discriminatorField;
public $discriminatorMap;
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ODM/MongoDB/Mapping/Annotations/ReferenceOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

namespace Doctrine\ODM\MongoDB\Mapping\Annotations;

use Doctrine\ODM\MongoDB\Mapping\ClassMetadataInfo;
use Doctrine\ODM\MongoDB\Mapping\ClassMetadata;

/**
* Specifies a one-to-one relationship to a different document
Expand All @@ -31,7 +31,7 @@ final class ReferenceOne extends AbstractField
public $type = 'one';
public $reference = true;
public $simple = false; // @deprecated
public $storeAs = ClassMetadataInfo::REFERENCE_STORE_AS_DB_REF_WITH_DB;
public $storeAs = ClassMetadata::REFERENCE_STORE_AS_DB_REF_WITH_DB;
public $targetDocument;
public $discriminatorField;
public $discriminatorMap;
Expand Down
Loading

0 comments on commit b796f50

Please sign in to comment.