csv importer - move intelligence to create metadata in the Importer Class (ref. #138)
This commit is contained in:
parent
6c9e00b882
commit
f9b214e3f9
|
@ -201,22 +201,6 @@ class REST_Importers_Controller extends REST_Controller {
|
|||
|
||||
if ($att == 'collection') {
|
||||
if (is_array($value) && isset($value['id'])) {
|
||||
|
||||
if(isset($value['mapping']) && is_array($value['mapping'])){
|
||||
foreach( $value['mapping'] as $metadatum_id => $header ){
|
||||
|
||||
if( !is_numeric($metadatum_id) ) {
|
||||
$metadatum = $importer->create_new_metadata( $header, $value['id']);
|
||||
|
||||
if( is_object($metadatum) ){
|
||||
unset($value['mapping'][$metadatum_id]);
|
||||
$value['mapping'][$metadatum->get_id()] = $header;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$importer->add_collection($value);
|
||||
continue;
|
||||
} else {
|
||||
|
|
|
@ -715,6 +715,20 @@ class CSV extends Importer {
|
|||
if (isset($collection['id'])) {
|
||||
|
||||
if( isset($collection['mapping']) && is_array($collection['mapping']) ){
|
||||
|
||||
foreach( $collection['mapping'] as $metadatum_id => $header ){
|
||||
|
||||
if( !is_numeric($metadatum_id) ) {
|
||||
$metadatum = $this->create_new_metadata( $header, $collection['id']);
|
||||
|
||||
if( is_object($metadatum) ){
|
||||
unset($collection['mapping'][$metadatum_id]);
|
||||
$collection['mapping'][$metadatum->get_id()] = $header;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$this->save_mapping( $collection['id'], $collection['mapping'] );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue