1 | <?php |
||
12 | class FileSerializedResourcePersistenceHandler implements PersistenceHandler |
||
13 | { |
||
14 | /** |
||
15 | * @var string the path where all spider results should be persisted. |
||
16 | * The results will be grouped in a directory by spider ID. |
||
17 | */ |
||
18 | private $path = ''; |
||
19 | |||
20 | private $spiderId = ''; |
||
21 | |||
22 | private $totalSizePersisted = 0; |
||
23 | |||
24 | /** @var \Iterator */ |
||
25 | private $iterator; |
||
26 | |||
27 | /** @var Finder */ |
||
28 | private $finder; |
||
29 | |||
30 | /** |
||
31 | * @param string $path the path where all spider results should be persisted. |
||
32 | * The results will be grouped in a directory by spider ID. |
||
33 | */ |
||
34 | public function __construct($path) |
||
38 | |||
39 | public function setSpiderId($spiderId) |
||
48 | |||
49 | public function count() |
||
53 | |||
54 | private function getResultPath() |
||
58 | |||
59 | public function persist(Resource $resource) |
||
65 | |||
66 | private function getFinder() |
||
73 | |||
74 | private function getIterator() |
||
81 | |||
82 | /** |
||
83 | * @return Resource |
||
84 | */ |
||
85 | public function current() |
||
89 | |||
90 | /** |
||
91 | * @return void |
||
92 | */ |
||
93 | public function next() |
||
97 | |||
98 | /** |
||
99 | * @return int |
||
100 | */ |
||
101 | public function key() |
||
105 | |||
106 | /** |
||
107 | * @return boolean |
||
108 | */ |
||
109 | public function valid() |
||
113 | |||
114 | /** |
||
115 | * @return void |
||
116 | */ |
||
117 | public function rewind() |
||
121 | } |
||
122 |