|
| 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 <[email protected]> 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\SoftDeleteable\Fixture\Entity; |
| 13 | + |
| 14 | +use Doctrine\Common\Collections\ArrayCollection; |
| 15 | +use Doctrine\Common\Collections\Collection; |
| 16 | +use Doctrine\DBAL\Types\Types; |
| 17 | +use Doctrine\ORM\Mapping as ORM; |
| 18 | +use Gedmo\Mapping\Annotation as Gedmo; |
| 19 | +use Gedmo\SoftDeleteable\Traits\SoftDeleteableEntity; |
| 20 | + |
| 21 | +/** |
| 22 | + * @ORM\Entity |
| 23 | + * |
| 24 | + * @Gedmo\SoftDeleteable(fieldName="deletedAt") |
| 25 | + */ |
| 26 | +#[ORM\Entity] |
| 27 | +#[Gedmo\SoftDeleteable(fieldName: 'deletedAt')] |
| 28 | +class Author |
| 29 | +{ |
| 30 | + use SoftDeleteableEntity; |
| 31 | + |
| 32 | + /** |
| 33 | + * @var int|null |
| 34 | + * |
| 35 | + * @ORM\Id |
| 36 | + * @ORM\GeneratedValue(strategy="IDENTITY") |
| 37 | + * @ORM\Column(type="integer") |
| 38 | + */ |
| 39 | + #[ORM\Id] |
| 40 | + #[ORM\GeneratedValue(strategy: 'IDENTITY')] |
| 41 | + #[ORM\Column(type: Types::INTEGER)] |
| 42 | + private $id; |
| 43 | + |
| 44 | + /** |
| 45 | + * @ORM\Column(type="string") |
| 46 | + */ |
| 47 | + #[ORM\Column(type: Types::STRING)] |
| 48 | + private ?string $firstname = null; |
| 49 | + |
| 50 | + /** |
| 51 | + * @ORM\Column(type="string") |
| 52 | + */ |
| 53 | + #[ORM\Column(type: Types::STRING)] |
| 54 | + private ?string $lastname = null; |
| 55 | + |
| 56 | + /** |
| 57 | + * @var Collection<int, Article> |
| 58 | + * |
| 59 | + * @ORM\OneToMany(targetEntity="Article", mappedBy="author", cascade={"persist"}) |
| 60 | + */ |
| 61 | + #[ORM\OneToMany(targetEntity: Article::class, mappedBy: 'author', cascade: ['persist'])] |
| 62 | + private Collection $articles; |
| 63 | + |
| 64 | + public function __construct() |
| 65 | + { |
| 66 | + $this->articles = new ArrayCollection(); |
| 67 | + } |
| 68 | + |
| 69 | + public function getId(): ?int |
| 70 | + { |
| 71 | + return $this->id; |
| 72 | + } |
| 73 | + |
| 74 | + public function setFirstname(?string $firstname): void |
| 75 | + { |
| 76 | + $this->firstname = $firstname; |
| 77 | + } |
| 78 | + |
| 79 | + public function getFirstname(): ?string |
| 80 | + { |
| 81 | + return $this->firstname; |
| 82 | + } |
| 83 | + |
| 84 | + public function setLastname(?string $lastname): void |
| 85 | + { |
| 86 | + $this->lastname = $lastname; |
| 87 | + } |
| 88 | + |
| 89 | + public function getLastname(): ?string |
| 90 | + { |
| 91 | + return $this->lastname; |
| 92 | + } |
| 93 | + |
| 94 | + public function addArticle(Article $article): void |
| 95 | + { |
| 96 | + $this->articles[] = $article; |
| 97 | + } |
| 98 | + |
| 99 | + /** |
| 100 | + * @return Collection<int, Article> |
| 101 | + */ |
| 102 | + public function getArticles(): Collection |
| 103 | + { |
| 104 | + return $this->articles; |
| 105 | + } |
| 106 | +} |
0 commit comments