/**
* @brief Retrieves event data given an event ID or event object.
*
* @see sanitize_event() for optional $filter values. Also, the parameter $event
* must be given as a variable, since it is passed by reference.
*
* @param int|BTB_Event		$event	Event ID or BTB_Event object.
* @param string 			$output Optional, default is Object. Accepts OBJECT, ARRAY_A or ARRAY_N.
* @param string			$filter Optional. Type fo filter to apply. Accepts 'raw', 'edit', 'db', 'display',
*									'attribute' or 'js'. Default 'raw'.
* @return BTB_Event|array|null	Type corresponding to $output on success or null on failure.
*						      	When $output is OBJECT, a `BTB_Event` instance is returned.
*/
function btb_get_event($event, $output = OBJECT, $filter = 'raw')
{
    if ($event instanceof BTB_Event) {
        $_event = $event;
    } elseif (is_object($event)) {
        if (empty($event->filter)) {
            $_event = btb_sanitize_event($event, 'raw');
            $_event = new BTB_Event($_event);
        } elseif ('raw' == $event->filter) {
            $_event = new BTB_Event($event);
        } else {
            $_event = BTB_Event::get_instance($event->ID);
        }
    } else {
        $_event = BTB_Event::get_instance($event);
    }
    if (!$_event) {
        return null;
    }
    $_event = $_event->filter($filter);
    if ($output == ARRAY_A) {
        return $_event->to_array();
    } elseif ($output == ARRAY_N) {
        return array_values($_event->to_array());
    }
    return $_event;
}
 /**
  * Returns a filtered version of this event.
  *
  * @param string $filter The filter context.
  * @return self|array|bool|object|BTB_Event
  */
 public function filter($filter)
 {
     if ($this->filter == $filter) {
         return $this;
     }
     if ($filter == 'raw') {
         return self::get_instance($this->ID);
     }
     return btb_sanitize_event($this, $filter);
 }