/** * Adds the provided blob to the tree. * * @param WordPress_GitHub_Sync_Blob $blob Blob to add to tree. * * @return $this */ public function add_blob(WordPress_GitHub_Sync_Blob $blob) { $this->paths[$blob->path()] = $this->shas[$blob->sha()] = $blob; return $this; }
/** * Imports a single blob content into matching post. * * @param WordPress_GitHub_Sync_Blob $blob Blob to transform into a Post. * * @return WordPress_GitHub_Sync_Post */ protected function blob_to_post(WordPress_GitHub_Sync_Blob $blob) { $args = array('post_content' => $blob->content_import()); $meta = $blob->meta(); if ($meta) { if (array_key_exists('layout', $meta)) { $args['post_type'] = $meta['layout']; unset($meta['layout']); } if (array_key_exists('published', $meta)) { $args['post_status'] = true === $meta['published'] ? 'publish' : 'draft'; unset($meta['published']); } if (array_key_exists('post_title', $meta)) { $args['post_title'] = $meta['post_title']; unset($meta['post_title']); } if (array_key_exists('ID', $meta)) { $args['ID'] = $meta['ID']; unset($meta['ID']); } } $meta['_sha'] = $blob->sha(); $post = new WordPress_GitHub_Sync_Post($args, $this->app->api()); $post->set_meta($meta); return $post; }