1 | <?php |
||
20 | class Downloader |
||
21 | { |
||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | const FAVICON_MIME = 'image/x-icon'; |
||
26 | |||
27 | /** |
||
28 | * @var Filesystem |
||
29 | */ |
||
30 | protected $fs; |
||
31 | |||
32 | /** |
||
33 | * @var Client |
||
34 | */ |
||
35 | protected $client; |
||
36 | |||
37 | /** |
||
38 | * @var ValidatorInterface |
||
39 | */ |
||
40 | protected $validator; |
||
41 | |||
42 | /** |
||
43 | * @var string |
||
44 | */ |
||
45 | protected $root = ''; |
||
46 | |||
47 | /** |
||
48 | * @var string |
||
49 | */ |
||
50 | protected $favicon_root = ''; |
||
51 | |||
52 | /** |
||
53 | * @var string |
||
54 | */ |
||
55 | protected $favicon_proxy = ''; |
||
56 | |||
57 | /** |
||
58 | * @param Filesystem $fs |
||
59 | * @param Client $client |
||
60 | * @param ValidatorInterface $validator |
||
61 | * @param string $root |
||
62 | * @param string $favicon_root |
||
63 | * @param string $favicon_proxy |
||
64 | */ |
||
65 | 33 | public function __construct( |
|
66 | Filesystem $fs, |
||
67 | Client $client, |
||
68 | ValidatorInterface $validator, |
||
69 | $root, |
||
70 | $favicon_root, |
||
71 | $favicon_proxy |
||
72 | ) { |
||
73 | 33 | $this->fs = $fs; |
|
74 | 33 | $this->client = $client; |
|
75 | 33 | $this->validator = $validator; |
|
76 | 33 | $this->root = $root; |
|
77 | 33 | $this->favicon_root = $favicon_root; |
|
78 | 33 | $this->favicon_proxy = $favicon_proxy; |
|
79 | 33 | } |
|
80 | |||
81 | /** |
||
82 | * @return string |
||
83 | */ |
||
84 | 1 | public function getRoot() |
|
88 | |||
89 | /** |
||
90 | * @param string $url |
||
91 | * @param string $target |
||
92 | * @param bool $override |
||
93 | * |
||
94 | * @return bool |
||
95 | */ |
||
96 | 21 | public function download($url, $target, $override = false) |
|
110 | |||
111 | /** |
||
112 | * @param string $url |
||
113 | * @param string $target |
||
114 | * @param bool $override |
||
115 | * |
||
116 | * @return bool |
||
117 | */ |
||
118 | 16 | public function image($url, $target, $override = false) |
|
133 | |||
134 | /** |
||
135 | * @param string $url |
||
136 | * |
||
137 | * @return bool |
||
138 | */ |
||
139 | 3 | public function isExists($url) |
|
150 | |||
151 | /** |
||
152 | * @param string $host |
||
153 | * @param bool $override |
||
154 | * |
||
155 | * @return string|false |
||
156 | */ |
||
157 | 3 | public function favicon($host, $override = false) |
|
167 | |||
168 | /** |
||
169 | * @param string $url |
||
170 | * @param EntityInterface $entity |
||
171 | * @param bool $override |
||
172 | * |
||
173 | * @return bool |
||
174 | */ |
||
175 | 5 | public function entity($url, EntityInterface $entity, $override = false) |
|
189 | |||
190 | /** |
||
191 | * @param Image $entity |
||
192 | * @param string $url |
||
193 | * @param bool $override |
||
194 | */ |
||
195 | 14 | public function imageField(Image $entity, $url = '', $override = false) |
|
240 | |||
241 | /** |
||
242 | * @param Image $entity |
||
243 | * @param bool $override |
||
244 | * |
||
245 | * @return string |
||
246 | */ |
||
247 | 12 | protected function getTargetDirForImageField(Image $entity, $override = false) |
|
257 | |||
258 | /** |
||
259 | * @param string $filename |
||
260 | * |
||
261 | * @return string |
||
262 | */ |
||
263 | 3 | public function getUniqueFilename($filename) |
|
274 | } |
||
275 |