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 = null; |
39
|
|
|
|
40
|
|
|
private string $filePath; |
41
|
|
|
|
42
|
|
|
private ?object $uploadsResource = null; |
43
|
|
|
|
44
|
|
|
/** @var Collection|MediaObject[] */ |
45
|
|
|
private Collection $mediaObjects; |
46
|
|
|
|
47
|
|
|
public function getFile(): ?File |
48
|
|
|
{ |
49
|
|
|
return $this->file; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @return static |
54
|
|
|
*/ |
55
|
|
|
public function setFile(?File $file) |
56
|
|
|
{ |
57
|
|
|
$this->file = $file; |
58
|
|
|
|
59
|
|
|
return $this; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function getFilePath(): string |
63
|
|
|
{ |
64
|
|
|
return $this->filePath; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @return static |
69
|
|
|
*/ |
70
|
|
|
public function setFilePath(string $filePath) |
71
|
|
|
{ |
72
|
|
|
$this->filePath = $filePath; |
73
|
|
|
|
74
|
|
|
return $this; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function getUploadsResource(): ?object |
78
|
|
|
{ |
79
|
|
|
return $this->uploadsResource; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @return static |
84
|
|
|
*/ |
85
|
|
|
public function setUploadsResource(?object $uploadsResource) |
86
|
|
|
{ |
87
|
|
|
$this->uploadsResource = $uploadsResource; |
88
|
|
|
|
89
|
|
|
return $this; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
public function getMediaObjects(): Collection |
93
|
|
|
{ |
94
|
|
|
return $this->mediaObjects; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @return static |
99
|
|
|
*/ |
100
|
|
|
public function setMediaObjects(Collection $mediaObjects) |
101
|
|
|
{ |
102
|
|
|
$this->mediaObjects = $mediaObjects; |
103
|
|
|
|
104
|
|
|
return $this; |
105
|
|
|
} |
106
|
|
|
} |
107
|
|
|
|