public function ChunkedXMLFIReader::init in Feed Import 8
Here you'll init your reader.
Overrides FeedImportReader::init
File
- feed_import_base/
src/ ChunkedXMLFIReader.php, line 33
Class
- ChunkedXMLFIReader
- CunkedXML Reader class, used for huge XML files.
Namespace
Drupal\feed_import_baseCode
public function init() {
// Check for resource location and parent xpath.
if (empty($this->options['url']) || empty($this->options['parent'])) {
return FALSE;
}
$this->options += array(
'stream' => NULL,
);
// Check for stream options.
if ($ctx = $this
->getStreamContext($this->options['stream'])) {
// Open the file using stream options.
$this->fh = fopen($this->options['url'], 'rb', FALSE, $ctx);
}
else {
// Open the file.
$this->fh = fopen($this->options['url'], 'rb');
}
if (!$this->fh) {
return FALSE;
}
// Get tag info.
$this->root = $this->options['parent'];
$tag = explode('/', $this->options['parent']);
unset($this->options['parent']);
list($tag) = explode('[', trim(end($tag)));
if (!$tag || $tag == '*' || $tag[0] == '@') {
return FALSE;
}
$this->tagOpen = "<{$tag}";
$this->tagClose = "</{$tag}>";
$this->tagLen = strlen($tag);
$this->tagCloseLen = strlen($this->tagClose);
// Create an empty array of read items.
$this->items = array();
return TRUE;
}