/**
  * Retrieve timeline events.
  *
  * @since 3.1.0
  *
  * @uses wl_core_get_related_entity_ids() to retrieve the entities referenced by the specified post.
  *
  * @param int $post_id The post ID.
  *
  * @return array An array of event posts.
  */
 public function get_events($post_id = null)
 {
     // Get the entity IDs either from the entities related to the specified post or from the last 50 published
     // posts if no post has been specified.
     $ids = is_numeric($post_id) ? wl_core_get_related_entity_ids($post_id) : $this->entity_service->get_all_related_to_last_50_published_posts();
     // Add the post itself if it's an entity.
     if (is_numeric($post_id) && $this->entity_service->is_entity($post_id)) {
         $ids[] = $post_id;
     }
     // If there's no entities, return an empty array right away.
     if (0 === sizeof($ids)) {
         $this->log_service->trace("No events found [ post id :: {$post_id} ]");
         return array();
     }
     $this->log_service->trace("Getting events [ entity ids :: " . join(', ', $ids) . " ]");
     return get_posts(array('post__in' => $ids, 'post_type' => Wordlift_Entity_Service::TYPE_NAME, 'post_status' => 'publish', 'posts_per_page' => -1, 'meta_query' => array('relation' => 'AND', array('key' => Wordlift_Schema_Service::FIELD_DATE_START, 'value' => null, 'compare' => '!='), array('key' => Wordlift_Schema_Service::FIELD_DATE_END, 'value' => null, 'compare' => '!=')), 'tax_query' => array('taxonomy' => Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, 'field' => 'slug', 'terms' => 'event')));
 }