/** * Get status records, parse new records * and remove processed xml files * * @throws \Exception */ public function collection() { $finder = new Finder(); $finder->files()->in($this->source); if ($finder->files()->count()) { $parser = new Parser($finder, function ($file) use($filesystem) { if (!\phpQuery::newDocumentFileXML($file)) { throw new \Exception('Can not create php query object'); } return (new Record())->setName(pq('task')->text())->setDate(pq('date')->text())->setDescription("<p>Status: " . pq('status')->text() . "</p>" . "<p>Command: " . pq('command')->text() . "</p>" . "<p>Error: " . pq('error')->text() . "</p>"); }); $this->cache->refresh($parser->collection()); } return $this->cache->load(); }
/** * Get status records, parse new records * and remove processed xml files * * @throws \Exception */ public function collection(\Closure $on_remove_record = null) { $finder = new Finder(); $finder->files()->in($this->source); if ($finder->files()->count()) { $parser = new Parser($finder, function ($file) { assert(\phpQuery::newDocumentFileXML($file), 'Can not create php query object'); $record = new Record(); $record->setName(pq('task')->text()); $record->setDate(pq('date')->text()); $record->setStatus(pq('status')->text()); $record->setNotice(pq('notice')->text()); $record->setError(pq('error')->text()); $record->setFatal(pq('fatal')->text()); $record->setLog(pq('log')->text()); return $record; }); $this->cache->refresh($parser->collection(), $on_remove_record); } return $this->cache->load(); }