DoctrineEncryptBundle icon indicating copy to clipboard operation
DoctrineEncryptBundle copied to clipboard

ORM\Embedded attribute not working (formerly: attributes instead of annotations)

Open jerome2710 opened this issue 1 year ago • 1 comments

Annotations are being removed in favor of PHP 8 attributes.

Could we get an #[Encrypted] attribute, just like the current @Encrypted annotation?

This will likely result in the need of adjusting the subscriber as well, as it currently uses the Doctrine\Common\Annotations\Reader.

It is currently possible combine Doctrine attributes and the Encrypted annotation. However, when using the #[ORM\Embeddable] attribute, the subscriber does not decrypt embeddables as it only scans for annotations: https://github.com/absolute-quantum/DoctrineEncryptBundle/blob/master/src/Subscribers/DoctrineEncryptSubscriber.php#L246.

jerome2710 avatar Dec 29 '23 14:12 jerome2710

I have been debugging this to create a merge request. The Reader-class called at https://github.com/absolute-quantum/DoctrineEncryptBundle/blob/master/src/Subscribers/DoctrineEncryptSubscriber.php#L246 is actually autowired to a custom Reader: https://github.com/absolute-quantum/DoctrineEncryptBundle/blob/master/src/Mapping/AttributeAnnotationReader.php. This reader checks both annotations as attributes.

But unfortunately, for some reason only Gedmo annotations are allowed: https://github.com/absolute-quantum/DoctrineEncryptBundle/blob/master/src/Mapping/AttributeReader.php#L70. The #[ORM\Embedded(...)] is not a Gedmo annotation and therefore it is not working. Commenting out L70 & L75 makes it work for me.

jerome2710 avatar Jan 03 '24 10:01 jerome2710