|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Silverback API Component Bundle Project |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Daniel West <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
declare(strict_types=1); |
|
13
|
|
|
|
|
14
|
|
|
namespace Silverback\ApiComponentBundle\Entity\Utility; |
|
15
|
|
|
|
|
16
|
|
|
use Doctrine\Common\Collections\Collection; |
|
17
|
|
|
use Silverback\ApiComponentBundle\Model\File\MediaObject; |
|
18
|
|
|
use Symfony\Component\HttpFoundation\File\File; |
|
19
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @author Daniel West <[email protected]> |
|
23
|
|
|
* @author Vincent Chalamon <[email protected]> |
|
24
|
|
|
*/ |
|
25
|
|
|
trait FileTrait |
|
26
|
|
|
{ |
|
27
|
|
|
/** |
|
28
|
|
|
* @Assert\NotNull(groups={"File:write"}) |
|
29
|
|
|
*/ |
|
30
|
|
|
private ?File $file = null; |
|
31
|
|
|
|
|
32
|
|
|
private string $filePath; |
|
33
|
|
|
|
|
34
|
|
|
private ?\DateTimeInterface $uploadedAt; |
|
35
|
|
|
|
|
36
|
|
|
private ?object $uploadsResource = null; |
|
37
|
|
|
|
|
38
|
|
|
/** @var Collection|MediaObject[] */ |
|
39
|
|
|
private Collection $mediaObjects; |
|
40
|
|
|
|
|
41
|
|
|
public function getFile(): ?File |
|
42
|
|
|
{ |
|
43
|
|
|
return $this->file; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @return static |
|
48
|
|
|
*/ |
|
49
|
|
|
public function setFile(?File $file) |
|
50
|
|
|
{ |
|
51
|
|
|
$this->file = $file; |
|
52
|
|
|
|
|
53
|
|
|
return $this; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function getFilePath(): string |
|
57
|
|
|
{ |
|
58
|
|
|
return $this->filePath; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
public function getUploadedAt(): ?\DateTimeInterface |
|
62
|
|
|
{ |
|
63
|
|
|
return $this->uploadedAt; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
public function setUploadedAt(?\DateTimeInterface $uploadedAt): void |
|
67
|
|
|
{ |
|
68
|
|
|
$this->uploadedAt = $uploadedAt; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* @return static |
|
73
|
|
|
*/ |
|
74
|
|
|
public function setFilePath(string $filePath) |
|
75
|
|
|
{ |
|
76
|
|
|
$this->filePath = $filePath; |
|
77
|
|
|
|
|
78
|
|
|
return $this; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
public function getUploadsResource(): ?object |
|
82
|
|
|
{ |
|
83
|
|
|
return $this->uploadsResource; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* @return static |
|
88
|
|
|
*/ |
|
89
|
|
|
public function setUploadsResource(?object $uploadsResource) |
|
90
|
|
|
{ |
|
91
|
|
|
$this->uploadsResource = $uploadsResource; |
|
92
|
|
|
|
|
93
|
|
|
return $this; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
public function getMediaObjects(): Collection |
|
97
|
|
|
{ |
|
98
|
|
|
return $this->mediaObjects; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* @return static |
|
103
|
|
|
*/ |
|
104
|
|
|
public function setMediaObjects(Collection $mediaObjects) |
|
105
|
|
|
{ |
|
106
|
|
|
$this->mediaObjects = $mediaObjects; |
|
107
|
|
|
|
|
108
|
|
|
return $this; |
|
109
|
|
|
} |
|
110
|
|
|
} |
|
111
|
|
|
|