Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

Fix Doctrine ODM Support #489

Merged
merged 2 commits into from
May 2, 2016
Merged

Fix Doctrine ODM Support #489

merged 2 commits into from
May 2, 2016

Conversation

cbourgois
Copy link
Contributor

Changes Faker\ORM\Doctrine\EntityPopulator to manage Doctrine ODM Documents.

Using the Class Doctrine\Common\Persistence\Mapping\ClassMetadata instead of Doctrine\ORM\Mapping\ClassMetadata

Managing ODM ReferenceOne as ORM One-To-One relations
(\Doctrine\ODM\MongoDB\Mapping\ClassMetadata does not have the getAssociationMappings function, I retrieve associationMappings using the exposed public var)

Changes generateId's signature to avoid using Doctrine\ORM\EntityManagerInterface; uses Doctrine\Common\Persistence\ObjectManager instead.

$unique = true;
$optional = isset($mapping['joinColumns'][0]['nullable']) ? $mapping['joinColumns'][0]['nullable'] : false;
break;
if ($this->class instanceof \Doctrine\ORM\Mapping\ClassMetadata) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be imported shouldn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As described here : http://php.net/manual/en/language.operators.type.php (part.7) , no it shouldn't.

If I do something like this:

<?php
$faker = \Faker\Factory::create();
$isFooBar = $faker instanceof \Foo\Bar;

$isFooBarvalue is false.

The test can be rewritten like this if we want

 if ($this->class instanceof '\Doctrine\ORM\Mapping\ClassMetadata') {

If we want, for more clarity, we can split class to Faker\ORM\Doctrine\EntityPopulator and Faker\ORM\Doctrine\DocumentPopulator, and add an addDocument in Faker\ORM\Doctrine\Populator, for using Entity for ORM use and Document for ODM use.

@fzaninotto
Copy link
Owner

@beberlei Could you validate this PR for me please? I have no idea if it may break things or not...

@fzaninotto
Copy link
Owner

@lexicalbits any feedback on this one?

@lexicalbits
Copy link
Contributor

@fzaninotto I don't think it bears on the issue I raised in #475, so no comments from me.

@fzaninotto
Copy link
Owner

Could you rebase on master?

cbourgois added 2 commits May 2, 2016 10:29
Changes Faker\ORM\Doctrine\EntityPopulator to manage Doctrine ODM Documents.

Using the Class Doctrine\Common\Persistence\Mapping\ClassMetadata instead of Doctrine\ORM\Mapping\ClassMetadata

Managing ODM ReferenceOne as ORM One-To-One relations
(\Doctrine\ODM\MongoDB\Mapping\ClassMetadata does not have the getAssociationMappings function, I retrieve associationMappings using the exposed public var)

Changes generateId's signature to avoid using Doctrine\ORM\EntityManagerInterface; uses Doctrine\Common\Persistence\ObjectManager instead.
Changes Faker\ORM\Doctrine\EntityPopulator to manage Doctrine ODM Documents.

Using the Class Doctrine\Common\Persistence\Mapping\ClassMetadata instead of Doctrine\ORM\Mapping\ClassMetadata

Managing ODM ReferenceOne as ORM One-To-One relations
(\Doctrine\ODM\MongoDB\Mapping\ClassMetadata does not have the getAssociationMappings function, I retrieve associationMappings using the exposed public var)

Changes generateId's signature to avoid using Doctrine\ORM\EntityManagerInterface; uses Doctrine\Common\Persistence\ObjectManager instead.
@cbourgois
Copy link
Contributor Author

It's done

@fzaninotto fzaninotto merged commit 120198f into fzaninotto:master May 2, 2016
@fzaninotto
Copy link
Owner

Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants