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
PHP 8+: Support for attributes #2235
Comments
I'd love to see this. I currently can't migrate to |
@makraz You might want to edit your title to "PHP 8+: Support for attributes" since I initially thought you were missing some special attribute when in fact you wish for attributes to be supported at all. Good initiative! |
Thanks @fridde for the feedback |
/**
* @Gedmo\Timestampable(on="create")
*/
#[ORM\Column(type: Types::DATETIMETZ_IMMUTABLE)]
public \DateTimeImmutable $createdAt; Not elegant, but works on my side. |
@bpolaszek Woah, for some reason I didn't realize that we could mix annotations and attributes. I thought that Gedmo would use the system I declared in Thanks for pointing out this workaround. This will be useful during the transition. |
That's a good workaround @bpolaszek. Unfortunately it doesn't work for blameable because the BlameableListener uses doctrine annotations to determine if the property is an association.
|
Why shouldn't this work? The BlameableListener works on the ClassMetadata provided by doctrine so it should not matter how you mapped your fields. Anyway I would definitely favor having attributes, I try to prevent mixing annotations and attributes. |
Hi @bpolaszek, mappings:
App:
type: attribute
dir: '%kernel.project_dir%/src/Entity/'
prefix: 'App\Entity\' Edit: gedmo.listener.timestampable:
class: Gedmo\Timestampable\TimestampableListener
tags:
- { name: doctrine.event_subscriber, connection: default }
calls:
- [ setAnnotationReader, [ "@annotation_reader" ] ] |
Workaround for TimestampableEntity and BlameableEntity can be removed after doctrine-extensions/DoctrineExtensions#2235 and related PRs are solved
Support for ORM attribute mapping was added in |
What are your plans for PHP 8+?
Is there any WIP about mapping attributes so we could use #[ORM\Column] instead of /** @var ORM\Column */?
If not, I'll like to work on this.
The text was updated successfully, but these errors were encountered: