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 ApiPlatform\Core\Annotation\ApiResource; |
17
|
|
|
use Doctrine\Common\Collections\Collection; |
18
|
|
|
use Doctrine\ORM\Mapping as ORM; |
19
|
|
|
use Silverback\ApiComponentBundle\Annotation as Silverback; |
20
|
|
|
use Silverback\ApiComponentBundle\Model\File\MediaObject; |
21
|
|
|
use Symfony\Component\HttpFoundation\File\File; |
22
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @author Daniel West <[email protected]> |
26
|
|
|
* |
27
|
|
|
* @Silverback\Timestamped |
28
|
|
|
* @ApiResource |
29
|
|
|
* @ORM\Entity |
30
|
|
|
*/ |
31
|
|
|
trait FileTrait |
32
|
|
|
{ |
33
|
|
|
use TimestampedTrait; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @Assert\NotNull(groups={"File:write"}) |
37
|
|
|
*/ |
38
|
|
|
private File $file; |
39
|
|
|
|
40
|
|
|
private string $filePath; |
41
|
|
|
|
42
|
|
|
private bool $temporary = true; |
43
|
|
|
|
44
|
|
|
private object $uploads; |
45
|
|
|
|
46
|
|
|
/** @var Collection|MediaObject[] */ |
47
|
|
|
private Collection $mediaObjects; |
48
|
|
|
|
49
|
|
|
public function getFile(): File |
50
|
|
|
{ |
51
|
|
|
return $this->file; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @return static |
56
|
|
|
*/ |
57
|
|
|
public function setFile(File $file) |
58
|
|
|
{ |
59
|
|
|
$this->file = $file; |
60
|
|
|
|
61
|
|
|
return $this; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function getFilePath(): string |
65
|
|
|
{ |
66
|
|
|
return $this->filePath; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @return static |
71
|
|
|
*/ |
72
|
|
|
public function setFilePath(string $filePath) |
73
|
|
|
{ |
74
|
|
|
$this->filePath = $filePath; |
75
|
|
|
|
76
|
|
|
return $this; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
public function isTemporary(): bool |
80
|
|
|
{ |
81
|
|
|
return $this->temporary; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @return static |
86
|
|
|
*/ |
87
|
|
|
public function setTemporary(bool $temporary) |
88
|
|
|
{ |
89
|
|
|
$this->temporary = $temporary; |
90
|
|
|
|
91
|
|
|
return $this; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
public function getUploads(): object |
95
|
|
|
{ |
96
|
|
|
return $this->uploads; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @return static |
101
|
|
|
*/ |
102
|
|
|
public function setUploads(object $uploads) |
103
|
|
|
{ |
104
|
|
|
$this->uploads = $uploads; |
105
|
|
|
|
106
|
|
|
return $this; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
public function getMediaObjects(): Collection |
110
|
|
|
{ |
111
|
|
|
return $this->mediaObjects; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* @return static |
116
|
|
|
*/ |
117
|
|
|
public function setMediaObjects(Collection $mediaObjects) |
118
|
|
|
{ |
119
|
|
|
$this->mediaObjects = $mediaObjects; |
120
|
|
|
|
121
|
|
|
return $this; |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
|