Alter importer class name and start parser method

This commit is contained in:
Eduardo Humberto 2019-02-15 21:39:33 -02:00
parent ef30e48d39
commit 5ca7e732e4
2 changed files with 32 additions and 2 deletions

View File

@ -52,6 +52,15 @@ class Importer_Handler {
'manual_mapping' => false,
]);
// $this->register_importer([
// 'name' => 'OAI PMH',
// 'description' => __('Import structure from a OAI PMH repository', 'tainacan'),
// 'slug' => 'oaipmh_importer',
// 'class_name' => '\Tainacan\Importer\Oaipmh_Importer',
// 'manual_collection' => false,
// 'manual_mapping' => false,
// ]);
do_action('tainacan_register_importers');
add_action( 'tainacan-enqueue-admin-scripts', array($this, 'enqueue_scripts') );

View File

@ -3,7 +3,7 @@ namespace Tainacan\Importer;
use Tainacan;
use Tainacan\Entities;
class Oaipmh extends Importer {
class Oaipmh_Importer extends Importer {
protected $steps = [
[
@ -15,7 +15,7 @@ class Oaipmh extends Importer {
'name' => 'Import Items',
'progress_label' => 'Import Items',
'callback' => 'process_collections'
],
]
];
@ -49,6 +49,27 @@ class Oaipmh extends Importer {
//private functions
/**
* decode request from wp_remote
* @return array/bool
*/
protected function decode_request($result, $url){
if (is_wp_error($result)) {
$this->add_error_log($result->get_error_message());
$this->add_error_log('Error in fetch remote' . $url);
$this->abort();
return false;
} else if (isset($result['body'])){
// TODO: parse body
}
$this->add_error_log('Error in fetch remote');
$this->abort();
return false;
}
/**
* executes the request
*/