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