Tiny lints and indentations

This commit is contained in:
Rodrigo de Oliveira 2021-04-17 17:58:52 -03:00
parent 1b096e5103
commit 87912f3153
1 changed files with 29 additions and 40 deletions

View File

@ -6,7 +6,6 @@ use \Tainacan\Entities;
class Old_Tainacan extends Importer{ class Old_Tainacan extends Importer{
protected $steps = [ protected $steps = [
[ [
'name' => 'Create Taxonomies', 'name' => 'Create Taxonomies',
'progress_label' => 'Creating taxonomies', 'progress_label' => 'Creating taxonomies',
@ -33,7 +32,6 @@ class Old_Tainacan extends Importer{
'callback' => 'link_relationships', 'callback' => 'link_relationships',
'total' => 5 'total' => 5
] ]
]; ];
protected $tainacan_api_address, $wordpress_api_address, $actual_collection; protected $tainacan_api_address, $wordpress_api_address, $actual_collection;
@ -64,8 +62,7 @@ class Old_Tainacan extends Importer{
* *
*/ */
public function create_taxonomies() { public function create_taxonomies() {
if (!$this->get_url()) {
if(!$this->get_url()){
$this->add_error_log('Site url not found'); $this->add_error_log('Site url not found');
$this->abort(); $this->abort();
return false; return false;
@ -74,57 +71,49 @@ class Old_Tainacan extends Importer{
$this->add_log('Creating taxonomies'); $this->add_log('Creating taxonomies');
foreach ($this->get_taxonomies() as $taxonomy) { foreach ($this->get_taxonomies() as $taxonomy) {
$tax = new Entities\Taxonomy();
$tax->set_name( $taxonomy->name );
$tax->set_description( $taxonomy->description );
$tax->set_allow_insert('yes');
$tax->set_status('publish');
$tax = new Entities\Taxonomy(); if ($tax->validate()) {
$tax->set_name( $taxonomy->name ); $tax = $this->tax_repo->insert($tax);
$tax->set_description( $taxonomy->description );
$tax->set_allow_insert('yes');
$tax->set_status('publish');
if ($tax->validate()) {
$tax = $this->tax_repo->insert($tax);
$this->add_log('Taxonomy ' . $tax->get_name() . ' created, id from Old'. $taxonomy->term_id ); $this->add_log('Taxonomy ' . $tax->get_name() . ' created, id from Old'. $taxonomy->term_id );
$this->add_transient('tax_' . $taxonomy->term_id . '_id', $tax->get_id());
$this->add_transient('tax_' . $taxonomy->term_id . '_name', $tax->get_name());
$this->add_transient('tax_' . $taxonomy->term_id . '_id', $tax->get_id()); if (isset($taxonomy->children) && $tax) {
$this->add_transient('tax_' . $taxonomy->term_id . '_name', $tax->get_name()); $this->add_all_terms($tax, $taxonomy->children);
}
if (isset($taxonomy->children) && $tax) {
$this->add_all_terms($tax, $taxonomy->children);
}
} else { } else {
$this->add_log('Error creating taxonomy ' . $taxonomy->name ); $this->add_log('Error creating taxonomy ' . $taxonomy->name );
$this->add_log($tax->get_errors()); $this->add_log($tax->get_errors());
}
} }
}
return false; return false;
} }
/** /**
* create the repository metadata which each collection inherits by default * create the repository metadata which each collection inherits by default
* *
*/ */
public function create_repo_metadata(){ public function create_repo_metadata() {
$this->add_log('Creating repository metadata');
$this->add_log('Creating repository metadata');
foreach ($this->get_repo_metadata() as $metadata) { foreach ($this->get_repo_metadata() as $metadata) {
if (isset($metadata->slug) && strpos($metadata->slug, 'socialdb_property_fixed') === false) {
$metadatum_id = $this->create_metadata( $metadata );
} elseif ( strpos($metadata->slug, 'socialdb_property_fixed_tags') !== false ) {
$metadatum_id = $this->create_metadata( $metadata );
}
}
if (isset($metadata->slug) && strpos($metadata->slug, 'socialdb_property_fixed') === false) { $this->add_log('FInished repository metadata');
$metadatum_id = $this->create_metadata( $metadata ); return false;
} elseif ( strpos($metadata->slug, 'socialdb_property_fixed_tags') !== false ){ }
$metadatum_id = $this->create_metadata( $metadata );
}
}
$this->add_log('FInished repository metadata');
return false;
}
/** /**
* create all collections and its metadata * create all collections and its metadata