1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file has been created by developers from BitBag. |
5
|
|
|
* Feel free to contact us once you face any issues or want to start |
6
|
|
|
* another great project. |
7
|
|
|
* You can find more information about us on https://bitbag.shop and write us |
8
|
|
|
* an email on [email protected]. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
declare(strict_types=1); |
12
|
|
|
|
13
|
|
|
namespace BitBag\SyliusCmsPlugin\Entity; |
14
|
|
|
|
15
|
|
|
use Sylius\Component\Resource\Model\ToggleableTrait; |
16
|
|
|
use Sylius\Component\Resource\Model\TranslatableTrait; |
17
|
|
|
use Sylius\Component\Resource\Model\TranslationInterface; |
18
|
|
|
use Symfony\Component\HttpFoundation\File\File; |
19
|
|
|
|
20
|
|
|
class Media implements MediaInterface |
21
|
|
|
{ |
22
|
|
|
use ToggleableTrait; |
23
|
|
|
use SectionableTrait; |
24
|
|
|
use ProductsAwareTrait; |
25
|
|
|
use ChannelsAwareTrait; |
26
|
|
|
use TranslatableTrait { |
27
|
|
|
__construct as protected initializeTranslationsCollection; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** @var int */ |
31
|
|
|
protected $id; |
32
|
|
|
|
33
|
|
|
/** @var string */ |
34
|
|
|
protected $type; |
35
|
|
|
|
36
|
|
|
/** @var string */ |
37
|
|
|
protected $code; |
38
|
|
|
|
39
|
|
|
/** @var string */ |
40
|
|
|
protected $path; |
41
|
|
|
|
42
|
|
|
/** @var File */ |
43
|
|
|
protected $file; |
44
|
|
|
|
45
|
|
|
/** @var string */ |
46
|
|
|
protected $mimeType; |
47
|
|
|
|
48
|
|
|
/** @var string */ |
49
|
|
|
protected $originalPath; |
50
|
|
|
|
51
|
|
|
public function __construct() |
52
|
|
|
{ |
53
|
|
|
$this->initializeTranslationsCollection(); |
54
|
|
|
$this->initializeSectionsCollection(); |
55
|
|
|
$this->initializeProductsCollection(); |
56
|
|
|
$this->initializeChannelsCollection(); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function getId(): ?int |
60
|
|
|
{ |
61
|
|
|
return $this->id; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function getType(): ?string |
65
|
|
|
{ |
66
|
|
|
return $this->type; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function setType(?string $type): void |
70
|
|
|
{ |
71
|
|
|
$this->type = $type; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
public function getCode(): ?string |
75
|
|
|
{ |
76
|
|
|
return $this->code; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
public function setCode(?string $code): void |
80
|
|
|
{ |
81
|
|
|
$this->code = $code; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
public function getPath(): ?string |
85
|
|
|
{ |
86
|
|
|
return $this->path; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
public function setPath(?string $path): void |
90
|
|
|
{ |
91
|
|
|
$this->path = $path; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
public function getFile(): ?File |
95
|
|
|
{ |
96
|
|
|
return $this->file; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
public function setFile(?File $file): void |
100
|
|
|
{ |
101
|
|
|
$this->file = $file; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
public function hasFile(): bool |
105
|
|
|
{ |
106
|
|
|
return null !== $this->file; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
public function getMimeType(): ?string |
110
|
|
|
{ |
111
|
|
|
return $this->mimeType; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
public function setMimeType(?string $mimeType): void |
115
|
|
|
{ |
116
|
|
|
$this->mimeType = $mimeType; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
public function getName(): ?string |
120
|
|
|
{ |
121
|
|
|
return $this->getMediaTranslation()->getName(); |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
public function setName(?string $name): void |
125
|
|
|
{ |
126
|
|
|
$this->getMediaTranslation()->setName($name); |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
public function getContent(): ?string |
130
|
|
|
{ |
131
|
|
|
return $this->getMediaTranslation()->getContent(); |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
public function setContent(?string $content): void |
135
|
|
|
{ |
136
|
|
|
$this->getMediaTranslation()->setContent($content); |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
public function getAlt(): ?string |
140
|
|
|
{ |
141
|
|
|
return $this->getMediaTranslation()->getAlt(); |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
public function setAlt(?string $alt): void |
145
|
|
|
{ |
146
|
|
|
$this->getMediaTranslation()->setAlt($alt); |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
public function getLink(): ?string |
150
|
|
|
{ |
151
|
|
|
return $this->getMediaTranslation()->getLink(); |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
public function setLink(?string $link): void |
155
|
|
|
{ |
156
|
|
|
$this->getMediaTranslation()->setLink($link); |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* @return MediaTranslationInterface|TranslationInterface |
161
|
|
|
*/ |
162
|
|
|
protected function getMediaTranslation(): TranslationInterface |
163
|
|
|
{ |
164
|
|
|
return $this->getTranslation(); |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
protected function createTranslation(): MediaTranslationInterface |
168
|
|
|
{ |
169
|
|
|
return new MediaTranslation(); |
170
|
|
|
} |
171
|
|
|
} |
172
|
|
|
|