1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Synapse\Cmf\Framework\Media\File\Entity; |
4
|
|
|
|
5
|
|
|
use Majora\Framework\Normalizer\Model\NormalizableTrait; |
6
|
|
|
use Symfony\Component\HttpFoundation\File\File as PhysicalFile; |
7
|
|
|
use Synapse\Cmf\Framework\Media\File\Model\FileInterface; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* File entity class. |
11
|
|
|
*/ |
12
|
|
|
class File implements FileInterface |
13
|
|
|
{ |
14
|
|
|
use NormalizableTrait; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @var int |
18
|
|
|
*/ |
19
|
|
|
protected $id; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @var string |
23
|
|
|
*/ |
24
|
|
|
protected $storePath; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var PhysicalFile |
28
|
|
|
*/ |
29
|
|
|
protected $physicalFile; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var string |
33
|
|
|
*/ |
34
|
|
|
protected $name; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var string |
38
|
|
|
*/ |
39
|
|
|
protected $originalName; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @see NormalizableInterface::getScopes() |
43
|
|
|
*/ |
44
|
6 |
|
public static function getScopes() |
45
|
|
|
{ |
46
|
|
|
return array( |
47
|
6 |
|
'id' => 'id', |
48
|
3 |
|
'default' => array('id', 'name', 'store_path'), |
49
|
3 |
|
); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Returns File id. |
54
|
|
|
* |
55
|
|
|
* @return int |
56
|
|
|
*/ |
57
|
8 |
|
public function getId() |
58
|
|
|
{ |
59
|
8 |
|
return $this->id; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Define File id. |
64
|
|
|
* |
65
|
|
|
* @param int $id |
66
|
|
|
* |
67
|
|
|
* @return self |
68
|
|
|
*/ |
69
|
8 |
|
public function setId($id) |
70
|
|
|
{ |
71
|
8 |
|
$this->id = $id; |
72
|
|
|
|
73
|
8 |
|
return $this; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Returns File name. |
78
|
|
|
* |
79
|
|
|
* @return string |
80
|
|
|
*/ |
81
|
2 |
|
public function getName() |
82
|
|
|
{ |
83
|
2 |
|
return $this->name; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Define File name. |
88
|
|
|
* |
89
|
|
|
* @param string $name |
90
|
|
|
* |
91
|
|
|
* @return self |
92
|
|
|
*/ |
93
|
|
|
public function setName($name) |
94
|
|
|
{ |
95
|
|
|
$this->name = $name; |
96
|
|
|
|
97
|
|
|
return $this; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* Returns File store path. |
102
|
|
|
* |
103
|
|
|
* @return string |
104
|
|
|
*/ |
105
|
2 |
|
public function getStorePath() |
106
|
|
|
{ |
107
|
2 |
|
return $this->storePath; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* Define File store path. |
112
|
|
|
* |
113
|
|
|
* @param string $storePath |
114
|
|
|
* |
115
|
|
|
* @return self |
116
|
|
|
*/ |
117
|
|
|
public function setStorePath($storePath) |
118
|
|
|
{ |
119
|
|
|
$this->storePath = $storePath; |
120
|
|
|
|
121
|
|
|
return $this; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* Returns File physical file. |
126
|
|
|
* |
127
|
|
|
* @return PhysicalFile |
128
|
|
|
*/ |
129
|
|
|
public function getPhysicalFile() |
130
|
|
|
{ |
131
|
|
|
return $this->physicalFile; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* Define File physical file. |
136
|
|
|
* |
137
|
|
|
* @param PhysicalFile $physicalFile |
138
|
|
|
* |
139
|
|
|
* @return self |
140
|
|
|
*/ |
141
|
|
|
public function setPhysicalFile(PhysicalFile $physicalFile) |
142
|
|
|
{ |
143
|
|
|
$this->physicalFile = $physicalFile; |
144
|
|
|
|
145
|
|
|
return $this; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* Returns File original name. |
150
|
|
|
* |
151
|
|
|
* @return string |
152
|
|
|
*/ |
153
|
|
|
public function getOriginalName() |
154
|
|
|
{ |
155
|
|
|
return $this->originalName; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* Define File original name. |
160
|
|
|
* |
161
|
|
|
* @param string $originalName |
162
|
|
|
* |
163
|
|
|
* @return self |
164
|
|
|
*/ |
165
|
|
|
public function setOriginalName($originalName) |
166
|
|
|
{ |
167
|
|
|
$this->originalName = $originalName; |
168
|
|
|
|
169
|
|
|
return $this; |
170
|
|
|
} |
171
|
|
|
} |
172
|
|
|
|