/**
  * Import taxonomy.
  *
  * @param Taxonomy $taxonomy
  */
 public function import_taxonomy(Taxonomy $taxonomy)
 {
     // Get the term.
     $term = $taxonomy->get_term();
     // Import term.
     if ($term !== null) {
         $this->import_term($taxonomy->get_term());
     }
     // If a parent taxonomy exists, import it.
     if ($taxonomy->get_parent() !== null) {
         $this->import_taxonomy($taxonomy->get_parent());
     }
     // Taxonomy ID on production environment.
     try {
         $this->taxonomy_dao->get_taxonomy_id_by_taxonomy($taxonomy);
     } catch (Exception $e) {
         $this->api->add_deploy_message($this->batch->get_id(), $e->getMessage(), 'warning');
     }
     if (!$taxonomy->get_id()) {
         // This taxonomy does not exist on production, create it.
         $this->taxonomy_dao->insert($taxonomy);
     } else {
         // This taxonomy exists on production, update it.
         $this->taxonomy_dao->update_taxonomy($taxonomy);
     }
 }
 /**
  * @param Taxonomy $taxonomy
  */
 public function set_taxonomy(Taxonomy $taxonomy)
 {
     $this->set_id($this->post->get_id() . '-' . $taxonomy->get_id());
     $this->taxonomy = $taxonomy;
 }
 /**
  * @param Taxonomy $taxonomy
  * @return array
  */
 private function get_term_hierarchy(Taxonomy $taxonomy)
 {
     $query = $this->wpdb->prepare('SELECT option_value FROM ' . $this->wpdb->options . ' WHERE option_name = %s', $taxonomy->get_taxonomy() . '_children');
     $result = $this->wpdb->get_row($query, ARRAY_A);
     if (isset($result['option_value'])) {
         if ($array = unserialize($result['option_value'])) {
             return $array;
         } else {
             return array();
         }
     }
     return null;
 }