Skip to content
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

FOSUserBundle incompatibility, Properties XXXX does not exist #180

Open
IvanCou opened this issue Nov 23, 2016 · 1 comment
Open

FOSUserBundle incompatibility, Properties XXXX does not exist #180

IvanCou opened this issue Nov 23, 2016 · 1 comment

Comments

@IvanCou
Copy link

IvanCou commented Nov 23, 2016

After 3 days working arround this problem there is some informations that could be useful for people in the same configuration.

I had the error "Properties XXXX does not exist" when I try to display datatable for some entities only.

In fact the problem occur only if there is a relation between the entity you want to display and a FosUser entity, even if you don't display any field of the user entity.

And the problem occur Only if the connected user is related with one of entities.
If your connected user is not related to company entity (for exemple) all is working perfect, as soon as you add the connected user to one company, you ar not able to display datatable and you get the message "Properties XXXX does not exist" .

it's look like there is a incompatibility with the proxy.objects used by FOSUserBundle et AliDatatble in DoctrineBuilder.php

there is my actual composer version, I have already try with the latest ones with the same results
"friendsofsymfony/user-bundle": "v2.0.0-alpha3",
"ali/datatable": "2.1.0",

@IvanCou
Copy link
Author

IvanCou commented Nov 30, 2016

There is the solution if it can help 👍

in fact the Doctrine builder don't manage correctly the proxy Objects and the reflectionClass.
If you try to use ReflexionClass on a proxy object you are not able to get proporties of the main object.
so there is a way to make it works by retreiving the real class of a proxyobject before get his properies

if (isset($object)){
$ref_class = new \ReflectionClass($object);
if (property_exists($ref_class, $prop) or property_exists($object,$prop) ){
$property = $ref_class->getProperty($prop);
$property->setAccessible(true);
return $property->getValue($object);
}
else {
$realClass = \Doctrine\Common\Util\ClassUtils::getRealClass(get_class($object));
$property = (new \ReflectionClass($realClass))->getProperty($prop);
$property->setAccessible(true);
return $property->getValue($object);
}
}

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

No branches or pull requests

1 participant