public function __construct($wpdb)
 {
     parent::__construct($wpdb);
     $this->user_dao = Helper_Factory::get_instance()->get_dao('User');
 }
 /**
  * Create DAO object of specified type.
  *
  * @param string $dao
  *
  * @return DAO
  */
 public function create($dao)
 {
     return Helper_Factory::get_instance()->get_dao($dao);
 }
 /**
  * @param Template $template
  */
 public function __construct(Template $template)
 {
     $this->template = $template;
     $this->batch_dao = Helper_Factory::get_instance()->get_dao('Batch');
     $this->post_dao = Helper_Factory::get_instance()->get_dao('Post');
 }
 public function __construct($wpdb)
 {
     parent::__construct($wpdb);
     $this->post_dao = Helper_Factory::get_instance()->get_dao('Post');
     $this->taxonomy_dao = Helper_Factory::get_instance()->get_dao('Taxonomy');
 }
 /**
  * Constructor.
  *
  * @param Batch $batch
  */
 protected function __construct(Batch $batch)
 {
     /**
      * @var Common_API $sme_content_staging_api
      */
     global $sme_content_staging_api;
     $this->batch = $batch;
     $this->api = $sme_content_staging_api;
     $this->batch_dao = Helper_Factory::get_instance()->get_dao('Batch');
     $this->custom_dao = Helper_Factory::get_instance()->get_dao('Custom');
     $this->option_dao = Helper_Factory::get_instance()->get_dao('Option');
     $this->post_dao = Helper_Factory::get_instance()->get_dao('Post');
     $this->post_taxonomy_dao = Helper_Factory::get_instance()->get_dao('Post_Taxonomy');
     $this->postmeta_dao = Helper_Factory::get_instance()->get_dao('Postmeta');
     $this->taxonomy_dao = Helper_Factory::get_instance()->get_dao('Taxonomy');
     $this->term_dao = Helper_Factory::get_instance()->get_dao('Term');
     $this->user_dao = Helper_Factory::get_instance()->get_dao('User');
     // Get diffs from database.
     $this->post_diffs = $this->post_dao->get_post_diffs($batch);
 }
 /**
  * Look for message indicating that a post has been deleted on production
  * and remove these posts from log of deleted posts.
  *
  * @param Message $message
  */
 private function handle_deleted_posts(Message $message)
 {
     $regex = '#<span class="hidden" data-blog-id="(.*?)">(.*?)</span>#';
     preg_match($regex, $message->get_message(), $groups);
     // Make sure groups has been set.
     if (empty($groups[1]) || empty($groups[2])) {
         return;
     }
     $blog_id = intval($groups[1]);
     $post_ids = array_map('intval', explode(',', $groups[2]));
     // Make sure blog ID and post IDs has been set.
     if (!$blog_id || empty($post_ids)) {
         return;
     }
     /**
      * @var Custom_DAO $custom_dao
      */
     $custom_dao = Helper_Factory::get_instance()->get_dao('Custom');
     $current_blog_id = get_current_blog_id();
     // Switch blog if we are not on the correct one.
     if ($current_blog_id !== $blog_id) {
         switch_to_blog($blog_id);
     }
     // Cleanup WP options.
     $custom_dao->remove_from_deleted_posts_log($post_ids);
     // Restore blog if we switched before.
     if ($current_blog_id !== $blog_id) {
         restore_current_blog();
     }
 }