|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +/* |
| 6 | + * This file is part of the Doctrine Behavioral Extensions package. |
| 7 | + * (c) Gediminas Morkevicius <gediminas.morkevicius@gmail.com> http://www.gediminasm.org |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +namespace Gedmo\Tests\Sluggable\Fixture\Embeddable; |
| 13 | + |
| 14 | +use Doctrine\DBAL\Types\Types; |
| 15 | +use Doctrine\ORM\Mapping as ORM; |
| 16 | +use Doctrine\ORM\Mapping\Embedded; |
| 17 | +use Gedmo\Mapping\Annotation as Gedmo; |
| 18 | +use Gedmo\Sluggable\Sluggable; |
| 19 | + |
| 20 | +/** |
| 21 | + * @ORM\Entity |
| 22 | + */ |
| 23 | +#[ORM\Entity] |
| 24 | +class User implements Sluggable |
| 25 | +{ |
| 26 | + /** |
| 27 | + * @ORM\Id |
| 28 | + * @ORM\GeneratedValue |
| 29 | + * @ORM\Column(type="integer") |
| 30 | + */ |
| 31 | + #[ORM\Id] |
| 32 | + #[ORM\GeneratedValue] |
| 33 | + #[ORM\Column(type: Types::INTEGER)] |
| 34 | + private ?int $id = null; |
| 35 | + |
| 36 | + /** |
| 37 | + * @ORM\Column(name="username", type="string", length=64) |
| 38 | + */ |
| 39 | + #[ORM\Column(name: 'username', type: Types::STRING, length: 64)] |
| 40 | + private ?string $username = null; |
| 41 | + |
| 42 | + /** |
| 43 | + * @Gedmo\Slug(separator="-", updatable=true, fields={"username", "address.city", "address.country"}) |
| 44 | + * |
| 45 | + * @ORM\Column(name="slug", type="string", length=64, unique=true) |
| 46 | + */ |
| 47 | + #[Gedmo\Slug(separator: '-', updatable: true, fields: ['username', 'address.city', 'address.country'])] |
| 48 | + #[ORM\Column(name: 'slug', type: Types::STRING, length: 64, unique: true)] |
| 49 | + private ?string $slug = null; |
| 50 | + |
| 51 | + /** |
| 52 | + * @ORM\Embeddable(class=Address::class) |
| 53 | + */ |
| 54 | + #[Embedded(class: Address::class)] |
| 55 | + private Address $address; |
| 56 | + |
| 57 | + public function __construct() |
| 58 | + { |
| 59 | + $this->address = new Address(); |
| 60 | + } |
| 61 | + |
| 62 | + public function getId(): ?int |
| 63 | + { |
| 64 | + return $this->id; |
| 65 | + } |
| 66 | + |
| 67 | + public function getUsername(): ?string |
| 68 | + { |
| 69 | + return $this->username; |
| 70 | + } |
| 71 | + |
| 72 | + public function setUsername(?string $username): void |
| 73 | + { |
| 74 | + $this->username = $username; |
| 75 | + } |
| 76 | + |
| 77 | + public function setSlug(?string $slug): void |
| 78 | + { |
| 79 | + $this->slug = $slug; |
| 80 | + } |
| 81 | + |
| 82 | + public function getSlug(): ?string |
| 83 | + { |
| 84 | + return $this->slug; |
| 85 | + } |
| 86 | + |
| 87 | + public function getAddress(): Address |
| 88 | + { |
| 89 | + return $this->address; |
| 90 | + } |
| 91 | + |
| 92 | + public function setAddress(Address $address): void |
| 93 | + { |
| 94 | + $this->address = $address; |
| 95 | + } |
| 96 | +} |
0 commit comments