chamilo /
chamilo-lms
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | /* For licensing terms, see /license.txt */ |
||
| 6 | |||
| 7 | namespace Chamilo\CourseBundle\Entity; |
||
| 8 | |||
| 9 | use Chamilo\CoreBundle\Entity\AbstractResource; |
||
| 10 | use Chamilo\CoreBundle\Entity\ResourceInterface; |
||
| 11 | use Chamilo\CoreBundle\Entity\User; |
||
| 12 | use Chamilo\CourseBundle\Repository\CNotebookRepository; |
||
| 13 | use DateTime; |
||
| 14 | use Doctrine\ORM\Mapping as ORM; |
||
| 15 | use Gedmo\Mapping\Annotation as Gedmo; |
||
| 16 | use Stringable; |
||
| 17 | use Symfony\Component\Uid\Uuid; |
||
| 18 | use Symfony\Component\Validator\Constraints as Assert; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * CNotebook. |
||
| 22 | */ |
||
| 23 | #[ORM\Table(name: 'c_notebook')] |
||
| 24 | #[ORM\Entity(repositoryClass: CNotebookRepository::class)] |
||
| 25 | class CNotebook extends AbstractResource implements ResourceInterface, Stringable |
||
| 26 | { |
||
| 27 | #[ORM\Column(name: 'iid', type: 'integer')] |
||
| 28 | #[ORM\Id] |
||
| 29 | #[ORM\GeneratedValue] |
||
| 30 | protected ?int $iid = null; |
||
| 31 | |||
| 32 | #[ORM\ManyToOne(targetEntity: User::class)] |
||
| 33 | #[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id', onDelete: 'CASCADE')] |
||
| 34 | protected User $user; |
||
| 35 | |||
| 36 | #[Assert\NotBlank] |
||
| 37 | #[ORM\Column(name: 'title', type: 'string', length: 255, nullable: false)] |
||
| 38 | protected string $title; |
||
| 39 | |||
| 40 | #[Assert\NotBlank] |
||
| 41 | #[ORM\Column(name: 'description', type: 'text', nullable: false)] |
||
| 42 | protected string $description; |
||
| 43 | |||
| 44 | #[Gedmo\Timestampable(on: 'create')] |
||
| 45 | #[ORM\Column(name: 'creation_date', type: 'datetime', nullable: false)] |
||
| 46 | protected DateTime $creationDate; |
||
| 47 | |||
| 48 | #[Gedmo\Timestampable(on: 'update')] |
||
| 49 | #[ORM\Column(name: 'update_date', type: 'datetime', nullable: false)] |
||
| 50 | protected DateTime $updateDate; |
||
| 51 | |||
| 52 | #[ORM\Column(name: 'status', type: 'integer', nullable: true)] |
||
| 53 | protected ?int $status; |
||
| 54 | |||
| 55 | public function __construct() |
||
| 56 | { |
||
| 57 | $this->status = 0; |
||
| 58 | } |
||
| 59 | |||
| 60 | public function __toString(): string |
||
| 61 | { |
||
| 62 | return $this->getTitle(); |
||
| 63 | } |
||
| 64 | |||
| 65 | public function getUser(): User |
||
| 66 | { |
||
| 67 | return $this->user; |
||
| 68 | } |
||
| 69 | |||
| 70 | public function setUser(User $user): self |
||
| 71 | { |
||
| 72 | $this->user = $user; |
||
| 73 | |||
| 74 | return $this; |
||
| 75 | } |
||
| 76 | |||
| 77 | public function setTitle(string $title): self |
||
| 78 | { |
||
| 79 | $this->title = $title; |
||
| 80 | |||
| 81 | return $this; |
||
| 82 | } |
||
| 83 | |||
| 84 | public function getTitle(): string |
||
| 85 | { |
||
| 86 | return $this->title; |
||
| 87 | } |
||
| 88 | |||
| 89 | public function setDescription(string $description): self |
||
| 90 | { |
||
| 91 | $this->description = $description; |
||
| 92 | |||
| 93 | return $this; |
||
| 94 | } |
||
| 95 | |||
| 96 | /** |
||
| 97 | * Get description. |
||
| 98 | * |
||
| 99 | * @return string |
||
| 100 | */ |
||
| 101 | public function getDescription() |
||
| 102 | { |
||
| 103 | return $this->description; |
||
| 104 | } |
||
| 105 | |||
| 106 | public function setCreationDate(DateTime $creationDate): self |
||
| 107 | { |
||
| 108 | $this->creationDate = $creationDate; |
||
| 109 | |||
| 110 | return $this; |
||
| 111 | } |
||
| 112 | |||
| 113 | /** |
||
| 114 | * Get creationDate. |
||
| 115 | * |
||
| 116 | * @return DateTime |
||
| 117 | */ |
||
| 118 | public function getCreationDate() |
||
| 119 | { |
||
| 120 | return $this->creationDate; |
||
| 121 | } |
||
| 122 | |||
| 123 | public function setUpdateDate(DateTime $updateDate): self |
||
| 124 | { |
||
| 125 | $this->updateDate = $updateDate; |
||
| 126 | |||
| 127 | return $this; |
||
| 128 | } |
||
| 129 | |||
| 130 | /** |
||
| 131 | * Get updateDate. |
||
| 132 | * |
||
| 133 | * @return DateTime |
||
| 134 | */ |
||
| 135 | public function getUpdateDate() |
||
| 136 | { |
||
| 137 | return $this->updateDate; |
||
| 138 | } |
||
| 139 | |||
| 140 | public function setStatus(int $status): self |
||
| 141 | { |
||
| 142 | $this->status = $status; |
||
| 143 | |||
| 144 | return $this; |
||
| 145 | } |
||
| 146 | |||
| 147 | /** |
||
| 148 | * Get status. |
||
| 149 | * |
||
| 150 | * @return int |
||
| 151 | */ |
||
| 152 | public function getStatus() |
||
| 153 | { |
||
| 154 | return $this->status; |
||
| 155 | } |
||
| 156 | |||
| 157 | /** |
||
| 158 | * Get iid. |
||
| 159 | */ |
||
| 160 | public function getIid(): ?int |
||
| 161 | { |
||
| 162 | return $this->iid; |
||
| 163 | } |
||
| 164 | |||
| 165 | public function getResourceIdentifier(): int|Uuid |
||
| 166 | { |
||
| 167 | return $this->getIid(); |
||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 168 | } |
||
| 169 | |||
| 170 | public function getResourceName(): string |
||
| 171 | { |
||
| 172 | return $this->getTitle(); |
||
| 173 | } |
||
| 174 | |||
| 175 | public function setResourceName(string $name): self |
||
| 176 | { |
||
| 177 | return $this->setTitle($name); |
||
| 178 | } |
||
| 179 | } |
||
| 180 |