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\CourseBundle\Repository\CAnnouncementAttachmentRepository; |
12
|
|
|
use Doctrine\ORM\Mapping as ORM; |
13
|
|
|
use Stringable; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* CAnnouncementAttachment. |
17
|
|
|
*/ |
18
|
|
|
#[ORM\Table(name: 'c_announcement_attachment')] |
19
|
|
|
#[ORM\Entity(repositoryClass: CAnnouncementAttachmentRepository::class)] |
20
|
|
|
class CAnnouncementAttachment extends AbstractResource implements ResourceInterface, Stringable |
21
|
|
|
{ |
22
|
|
|
#[ORM\Column(name: 'iid', type: 'integer')] |
23
|
|
|
#[ORM\Id] |
24
|
|
|
#[ORM\GeneratedValue] |
25
|
|
|
protected ?int $iid = null; |
26
|
|
|
|
27
|
|
|
#[ORM\Column(name: 'path', type: 'string', length: 255, nullable: false)] |
28
|
|
|
protected string $path; |
29
|
|
|
|
30
|
|
|
#[ORM\Column(name: 'comment', type: 'text', nullable: true)] |
31
|
|
|
protected ?string $comment = null; |
32
|
|
|
|
33
|
|
|
#[ORM\Column(name: 'size', type: 'integer', nullable: false)] |
34
|
|
|
protected int $size; |
35
|
|
|
|
36
|
|
|
#[ORM\ManyToOne(targetEntity: CAnnouncement::class, inversedBy: 'attachments')] |
37
|
|
|
#[ORM\JoinColumn(name: 'announcement_id', referencedColumnName: 'iid', onDelete: 'CASCADE')] |
38
|
|
|
private ?CAnnouncement $announcement = null; |
39
|
|
|
|
40
|
|
|
#[ORM\Column(name: 'filename', type: 'string', length: 255, nullable: false)] |
41
|
|
|
protected string $filename; |
42
|
|
|
|
43
|
|
|
public function __construct() |
44
|
|
|
{ |
45
|
|
|
$this->comment = ''; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function __toString(): string |
49
|
|
|
{ |
50
|
|
|
return $this->getFilename(); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function setPath(string $path): self |
54
|
|
|
{ |
55
|
|
|
$this->path = $path; |
56
|
|
|
|
57
|
|
|
return $this; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Get path. |
62
|
|
|
* |
63
|
|
|
* @return string |
64
|
|
|
*/ |
65
|
|
|
public function getPath() |
66
|
|
|
{ |
67
|
|
|
return $this->path; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function setComment(string $comment): self |
71
|
|
|
{ |
72
|
|
|
$this->comment = $comment; |
73
|
|
|
|
74
|
|
|
return $this; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Get comment. |
79
|
|
|
* |
80
|
|
|
* @return string |
81
|
|
|
*/ |
82
|
|
|
public function getComment() |
83
|
|
|
{ |
84
|
|
|
return $this->comment; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
public function setSize(int $size): self |
88
|
|
|
{ |
89
|
|
|
$this->size = $size; |
90
|
|
|
|
91
|
|
|
return $this; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Get size. |
96
|
|
|
* |
97
|
|
|
* @return int |
98
|
|
|
*/ |
99
|
|
|
public function getSize() |
100
|
|
|
{ |
101
|
|
|
return $this->size; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
public function getIid(): ?int |
105
|
|
|
{ |
106
|
|
|
return $this->iid; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
public function setFilename(string $filename): self |
110
|
|
|
{ |
111
|
|
|
$this->filename = $filename; |
112
|
|
|
|
113
|
|
|
return $this; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* Get filename. |
118
|
|
|
* |
119
|
|
|
* @return string |
120
|
|
|
*/ |
121
|
|
|
public function getFilename() |
122
|
|
|
{ |
123
|
|
|
return $this->filename; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
public function getAnnouncement(): ?CAnnouncement |
127
|
|
|
{ |
128
|
|
|
return $this->announcement; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
public function setAnnouncement(?CAnnouncement $announcement): static |
132
|
|
|
{ |
133
|
|
|
$this->announcement = $announcement; |
134
|
|
|
|
135
|
|
|
return $this; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
public function getResourceIdentifier(): int |
139
|
|
|
{ |
140
|
|
|
return $this->getIid(); |
|
|
|
|
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
public function getResourceName(): string |
144
|
|
|
{ |
145
|
|
|
return $this->getFilename(); |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
public function setResourceName(string $name): self |
149
|
|
|
{ |
150
|
|
|
return $this->setFilename($name); |
151
|
|
|
} |
152
|
|
|
} |
153
|
|
|
|