|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Doctrs\SonataImportBundle\Entity; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
|
|
|
|
|
6
|
|
|
use Symfony\Component\HttpFoundation\File\File; |
|
7
|
|
|
use Symfony\Component\HttpFoundation\File\UploadedFile; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* UploadFile |
|
11
|
|
|
* |
|
12
|
|
|
* @ORM\Table("ext_sonata_import_file") |
|
13
|
|
|
* @ORM\Entity(repositoryClass="Doctrs\SonataImportBundle\Repository\DefaultRepository") |
|
14
|
|
|
* @ORM\HasLifecycleCallbacks() |
|
15
|
|
|
*/ |
|
16
|
|
|
class UploadFile |
|
17
|
|
|
{ |
|
18
|
|
|
|
|
19
|
|
|
const STATUS_LOAD = 1; |
|
20
|
|
|
const STATUS_SUCCESS = 2; |
|
21
|
|
|
const STATUS_ERROR = 3; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @var integer |
|
25
|
|
|
* |
|
26
|
|
|
* @ORM\Column(name="id", type="integer") |
|
27
|
|
|
* @ORM\Id |
|
28
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
|
29
|
|
|
*/ |
|
30
|
|
|
private $id; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @var \DateTime |
|
34
|
|
|
* |
|
35
|
|
|
* @ORM\Column(name="ts", type="datetime") |
|
36
|
|
|
*/ |
|
37
|
|
|
private $ts; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @var string |
|
41
|
|
|
* |
|
42
|
|
|
* @ORM\Column(name="file", type="string") |
|
43
|
|
|
* @var UploadedFile |
|
44
|
|
|
*/ |
|
45
|
|
|
private $file; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @var string |
|
49
|
|
|
* |
|
50
|
|
|
* @ORM\Column(name="encode", type="string") |
|
51
|
|
|
*/ |
|
52
|
|
|
private $encode; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @var string |
|
56
|
|
|
* |
|
57
|
|
|
* @ORM\Column(name="loader_class", type="string") |
|
58
|
|
|
*/ |
|
59
|
|
|
private $loaderClass; |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @var string |
|
63
|
|
|
* |
|
64
|
|
|
* @ORM\Column(name="status", type="integer") |
|
65
|
|
|
*/ |
|
66
|
|
|
private $status; |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @var string |
|
70
|
|
|
* |
|
71
|
|
|
* @ORM\Column(name="message", type="text", nullable=true) |
|
72
|
|
|
*/ |
|
73
|
|
|
private $message; |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @ORM\OneToMany(targetEntity="Doctrs\SonataImportBundle\Entity\ImportLog", mappedBy="uploadFile") |
|
77
|
|
|
*/ |
|
78
|
|
|
private $importLog; |
|
79
|
|
|
|
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* Get id |
|
83
|
|
|
* |
|
84
|
|
|
* @return integer |
|
85
|
|
|
*/ |
|
86
|
|
|
public function getId() |
|
87
|
|
|
{ |
|
88
|
|
|
return $this->id; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* Get ts |
|
93
|
|
|
* |
|
94
|
|
|
* @return \DateTime |
|
95
|
|
|
*/ |
|
96
|
|
|
public function getTs() |
|
97
|
|
|
{ |
|
98
|
|
|
return $this->ts; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* Set file |
|
103
|
|
|
* |
|
104
|
|
|
* @param string $file |
|
105
|
|
|
* @return UploadFile |
|
106
|
|
|
*/ |
|
107
|
|
|
public function setFile($file) |
|
108
|
|
|
{ |
|
109
|
|
|
$this->file = $file; |
|
110
|
|
|
|
|
111
|
|
|
return $this; |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* Get file |
|
116
|
|
|
* |
|
117
|
|
|
* @return UploadedFile|null |
|
118
|
|
|
*/ |
|
119
|
|
|
public function getFile() |
|
120
|
|
|
{ |
|
121
|
|
|
return $this->file; |
|
|
|
|
|
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* @ORM\PrePersist() |
|
126
|
|
|
* @ORM\PreUpdate() |
|
127
|
|
|
*/ |
|
128
|
|
|
public function prePersistUpdate() { |
|
129
|
|
|
if (!$this->status) { |
|
130
|
|
|
$this->status = self::STATUS_LOAD; |
|
131
|
|
|
} |
|
132
|
|
|
$this->ts = new \DateTime(); |
|
133
|
|
|
} |
|
134
|
|
|
|
|
135
|
|
|
/** |
|
136
|
|
|
* @param $encode |
|
137
|
|
|
* @return UploadFile |
|
138
|
|
|
*/ |
|
139
|
|
|
public function setEncode($encode) { |
|
140
|
|
|
$this->encode = $encode; |
|
141
|
|
|
|
|
142
|
|
|
return $this; |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
/** |
|
146
|
|
|
* @return string |
|
147
|
|
|
*/ |
|
148
|
|
|
public function getEncode() { |
|
149
|
|
|
return $this->encode; |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
/** |
|
153
|
|
|
* @param $message |
|
154
|
|
|
* @return UploadFile |
|
155
|
|
|
*/ |
|
156
|
|
|
public function setMessage($message) { |
|
157
|
|
|
$this->message = $message; |
|
158
|
|
|
|
|
159
|
|
|
return $this; |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
/** |
|
163
|
|
|
* @return string |
|
164
|
|
|
*/ |
|
165
|
|
|
public function getMessage() { |
|
166
|
|
|
return $this->message; |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
|
|
/** |
|
170
|
|
|
* @param $status |
|
171
|
|
|
* @return UploadFile |
|
172
|
|
|
*/ |
|
173
|
|
|
public function setStatus($status) { |
|
174
|
|
|
$this->status = $status; |
|
175
|
|
|
|
|
176
|
|
|
return $this; |
|
177
|
|
|
} |
|
178
|
|
|
|
|
179
|
|
|
/** |
|
180
|
|
|
* @return string |
|
181
|
|
|
*/ |
|
182
|
|
|
public function getStatus() { |
|
183
|
|
|
return $this->status; |
|
184
|
|
|
} |
|
185
|
|
|
|
|
186
|
|
|
/** |
|
187
|
|
|
* @param $loaderClass |
|
188
|
|
|
* @return $this |
|
189
|
|
|
*/ |
|
190
|
|
|
public function setLoaderClass($loaderClass) { |
|
191
|
|
|
$this->loaderClass = $loaderClass; |
|
192
|
|
|
|
|
193
|
|
|
return $this; |
|
194
|
|
|
} |
|
195
|
|
|
|
|
196
|
|
|
/** |
|
197
|
|
|
* @return string |
|
198
|
|
|
*/ |
|
199
|
|
|
public function getLoaderClass() { |
|
200
|
|
|
return $this->loaderClass; |
|
201
|
|
|
} |
|
202
|
|
|
|
|
203
|
|
|
public function move($uploadDir) { |
|
204
|
|
|
$file = $this->getFile(); |
|
205
|
|
|
$fileName = md5(uniqid() . time()) . '.' . $file->guessExtension(); |
|
206
|
|
|
$file->move($uploadDir, $fileName); |
|
207
|
|
|
$this->setFile($uploadDir . '/' . $fileName); |
|
208
|
|
|
} |
|
209
|
|
|
|
|
210
|
|
|
/** |
|
211
|
|
|
* @param $message |
|
212
|
|
|
* @return $this |
|
213
|
|
|
*/ |
|
214
|
|
|
public function setStatusError($message) { |
|
215
|
|
|
$this->setStatus(self::STATUS_ERROR); |
|
216
|
|
|
$this->setMessage($message); |
|
217
|
|
|
return $this; |
|
218
|
|
|
} |
|
219
|
|
|
|
|
220
|
|
|
/** |
|
221
|
|
|
* @return string |
|
222
|
|
|
*/ |
|
223
|
|
|
public function __toString() { |
|
224
|
|
|
return (string)$this->message; |
|
225
|
|
|
} |
|
226
|
|
|
|
|
227
|
|
|
/** |
|
228
|
|
|
* @return mixed |
|
229
|
|
|
*/ |
|
230
|
|
|
public function getImportLog() |
|
231
|
|
|
{ |
|
232
|
|
|
return $this->importLog; |
|
233
|
|
|
} |
|
234
|
|
|
} |
|
235
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths