FormBundle icon indicating copy to clipboard operation
FormBundle copied to clipboard

Fatal error due to deprecation of Symfony\Component\Form\Util\PropertyPath

Open isabellebruchet opened this issue 12 years ago • 5 comments

I have this fatal error after symfony vendor upgrade, trying to use "entity_id" :

FatalErrorException: Error: Class 'Symfony\Component\Form\Util\PropertyPath' not found in vendor/gregwar/form-bundle/Gregwar/FormBundle/DataTransformer/EntityToIdTransformer.php line 85

PropertyPath class is apparently deprecated.

isabellebruchet avatar Oct 07 '13 13:10 isabellebruchet

Just have to replace : $propertyPath = new PropertyPath($this->property); return $propertyPath->getValue($data);

By : $propertyAccessor = new PropertyAccessor(); return $propertyAccessor->getValue($data, $this->property);

And change the use statement : use Symfony\Component\PropertyAccess\PropertyAccessor;

isabellebruchet avatar Oct 07 '13 13:10 isabellebruchet

Is this compatible with older sf versions?

2013/10/7 isabellebruchet [email protected]

Just have to replace : $propertyPath = new PropertyPath($this->property); return $propertyPath->getValue($data);

By : $propertyAccessor = new PropertyAccessor(); return $propertyAccessor->getValue($data, $this->property);

And change the use statement : use Symfony\Component\PropertyAccess\PropertyAccessor;

— Reply to this email directly or view it on GitHubhttps://github.com/Gregwar/FormBundle/issues/16#issuecomment-25808681 .

Grégoire Passault

Gregwar avatar Oct 07 '13 14:10 Gregwar

Apparently these new files exist since version 2.2, however, the code I posted above works, but it is not exactly the right way. PropertyAccessor should not be accessed directly but via PropertyAccess.

isabellebruchet avatar Oct 07 '13 14:10 isabellebruchet

Right way : https://github.com/isabellebruchet/FormBundle/commit/d4ab0260c2e94b9ba2de03dd20f7e6e330b8dc85

isabellebruchet avatar Oct 07 '13 15:10 isabellebruchet

Is this bug still occurs? Imho this issue can be closed.

@isabellebruchet, @Gregwar

Koc avatar Jun 01 '15 18:06 Koc