Thanks to visit codestin.com
Credit goes to github.com

Skip to content

No Entity Manager defined exception #9535

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from

Conversation

armetiz
Copy link
Contributor

@armetiz armetiz commented Nov 19, 2013

This PR is linked to this issue : #9534

@@ -62,8 +63,16 @@ public function validate($entity, Constraint $constraint)

if ($constraint->em) {
$em = $this->registry->getManager($constraint->em);

if(!$em) {
throw new RuntimeException(sprintf("There is not entity manager '%s'", $constraint->em));
Copy link
Member

Choose a reason for hiding this comment

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

I would use a ConstraintDefinitionException here instead, as it is an issue in your constraint mapping

Copy link
Member

Choose a reason for hiding this comment

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

and I would say object manager instead of entity manager, as the constraint is not specific to the ORM but also works for the ODM projects

Use object manager instead of entity manager
@armetiz
Copy link
Contributor Author

armetiz commented Nov 19, 2013

@stof, you right.

Also, the class UniqueEntityValidator take a Symfony\Component\Validator\Constraint on construct. But, two lines later, this class is trying to access to "fields" property which is not defined in the Constraint abstract class but inside the UniqueEntity.. Don't you think that an parameter check can be useful ?

https://github.com/symfony/symfony/blob/master/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php#L47

@stof
Copy link
Member

stof commented Nov 19, 2013

the typehint is required by the interface. You will see the same in all validators

@@ -354,4 +354,56 @@ public function testAssociatedCompositeEntity()
);
$violationsList = $validator->validate($associated);
}

/**
* @group EM
Copy link
Member

Choose a reason for hiding this comment

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

this can be removed on the 2 tests

@armetiz
Copy link
Contributor Author

armetiz commented Nov 19, 2013

@stof thanks for the explanation.

With the latest two commits, this PR seems to be ok to be merged.

} else {
$em = $this->registry->getManagerForClass(get_class($entity));

if (!$em) {
throw new ConstraintDefinitionException(sprintf("There is not object manager associated with this entity '%s'", get_class($entity)));
Copy link
Member

Choose a reason for hiding this comment

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

Unable to find the object manager associated with an entity of class "%s".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fabpot done

fabpot added a commit that referenced this pull request Nov 22, 2013
This PR was submitted for the master branch but it was merged into the 2.2 branch instead (closes #9535).

Discussion
----------

No Entity Manager defined exception

This PR is linked to this issue : #9534

Commits
-------

719ccb7 No Entity Manager defined exception
@fabpot fabpot closed this Nov 22, 2013
@armetiz armetiz deleted the patch-entity-manager branch November 22, 2013 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants