简体   繁体   中英

How to convert symfony gedmo annotation to PHP 8 Attributes

I'm working on Symfony 6 PHP 8 project and i'm using gedmo doctrine extension.

I can't find a full documentation about converting gedmo annotation to PHP 8 Attributes.

I'm tring to convert like this:

/**
 * @ORM\Column(type="string", length=255)
 * @Gedmo\Slug(fields={"title"})
 */
private $slug;

#[Gedmo\Slug(fields: title)]

but it doesn't work !

How can i use gedmo with PHP 8 Attributes?

you'll have to do the whole class property with attributes. the fields property at slug needs to be an array.

#[\Gedmo\Mapping\Annotation\Slug(fields: ['name'])]
#[\Doctrine\ORM\Mapping\Column(
    type: 'string',
    length: 255,     
)]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM