1 | <?php |
||
19 | class Downloader implements DownloaderInterface |
||
20 | { |
||
21 | /** @var EventDispatcherInterface */ |
||
22 | private $dispatcher; |
||
23 | |||
24 | /** @var PersistenceHandlerInterface */ |
||
25 | private $persistenceHandler; |
||
26 | |||
27 | /** @var RequestHandlerInterface */ |
||
28 | private $requestHandler; |
||
29 | |||
30 | /** @var int the maximum number of downloaded resources. 0 means no limit */ |
||
31 | private $downloadLimit = 0; |
||
32 | |||
33 | /** @var PostFetchFilterInterface[] */ |
||
34 | private $postFetchFilters = array(); |
||
35 | |||
36 | /** |
||
37 | * @param int Maximum number of resources to download |
||
38 | * @return $this |
||
39 | */ |
||
40 | public function setDownloadLimit($downloadLimit) |
||
45 | |||
46 | /** |
||
47 | * @return int Maximum number of resources to download |
||
48 | */ |
||
49 | public function getdownloadLimit() |
||
53 | |||
54 | /** |
||
55 | * @param PostFetchFilterInterface $filter |
||
56 | */ |
||
57 | public function addPostFetchFilter(PostFetchFilterInterface $filter) |
||
61 | |||
62 | /** |
||
63 | * @param DiscoveredUri $uri |
||
64 | * @return false|Resource |
||
65 | */ |
||
66 | public function download(DiscoveredUri $uri) |
||
77 | |||
78 | public function isDownLoadLimitExceeded() |
||
82 | |||
83 | /** |
||
84 | * A shortcut for EventDispatcher::dispatch() |
||
85 | * |
||
86 | * @param string $eventName |
||
87 | * @param null|Event $event |
||
88 | */ |
||
89 | private function dispatch($eventName, Event $event = null) |
||
93 | |||
94 | /** |
||
95 | * @param EventDispatcherInterface $eventDispatcher |
||
96 | * @return $this |
||
97 | */ |
||
98 | public function setDispatcher(EventDispatcherInterface $eventDispatcher) |
||
104 | |||
105 | /** |
||
106 | * @return EventDispatcherInterface |
||
107 | */ |
||
108 | public function getDispatcher() |
||
115 | |||
116 | |||
117 | /** |
||
118 | * @param DiscoveredUri $uri |
||
119 | * @return Resource|false |
||
120 | */ |
||
121 | protected function fetchResource(DiscoveredUri $uri) |
||
146 | |||
147 | /** |
||
148 | * @param Resource $resource |
||
149 | * @return bool |
||
150 | */ |
||
151 | private function matchesPostfetchFilter(Resource $resource) |
||
164 | |||
165 | /** |
||
166 | * @param PersistenceHandlerInterface $persistenceHandler |
||
167 | */ |
||
168 | public function setPersistenceHandler(PersistenceHandlerInterface $persistenceHandler) |
||
172 | |||
173 | /** |
||
174 | * @return PersistenceHandlerInterface |
||
175 | */ |
||
176 | public function getPersistenceHandler() |
||
184 | |||
185 | /** |
||
186 | * @param RequestHandlerInterface $requestHandler |
||
187 | */ |
||
188 | public function setRequestHandler(RequestHandlerInterface $requestHandler) |
||
192 | |||
193 | /** |
||
194 | * @return RequestHandlerInterface |
||
195 | */ |
||
196 | public function getRequestHandler() |
||
204 | |||
205 | } |
||
206 |