//$events = \Crave\Api\Event::getFeaturedFeed($a); $events = \Crave\Api\Event::getFeaturedEvents($filters); array_walk($events, function (&$event) use($default_market, $media_config_small) { $ct_event = new \Crave\Model\ct_event(); $event->ct_contract = new stdClass(); $event->ct_contract->market_slug = $default_market['slug']; $event->venue = new stdClass(); $event->venue->name = $event->venue_name; $event->venue->slug = $event->venue_slug; $event->venue->address = $event->address; $event->venue->address1 = $event->address1; $event->venue->address2 = $event->address2; $event->venue->city = $event->city; $event->venue->zip = $event->zip; $event->venue->state = $event->state; $event->url = parseEventUrl($event); $ct_event->ct_event_id = $event->ct_event_id; /** * Fetch media for the event . */ $mediaIds = $ct_event->getMediaIDs(1); $index = count($mediaIds) > 1 ? 1 : 0; //$mediaIds[$index] $event->img_small = \vf::getItem($ct_event->getFlyer(), $media_config_small); if (!$event->img_small && count($mediaIds)) { $event->img_small = \vf::getItem($mediaIds[0], $media_config_small); } }); \mem($cache_name, $events, $event_cache_duration); } $default_markets[$i]['events'] = $events;
/** * Returns a list of events to be used in left / right rails of different pages. * * @param int $market_id * @param bool $refreshed - prevents infinite loop if the function had to be called again . * @return Array - list of object with url, and title * * @todo : add a check that it's not a barcrawl */ function getLeftRailEvents($query, $refresh = false) { global $cache_refresh; $cache_key = 'cache::leftrail:market'; foreach ($query as $key => $value) { $cache_key .= '::' . $key . ':' . $value; } $cache_name = $cache_key; if (!$cache_refresh && !$refresh) { $left_events = \mem($cache_name); } if (!$left_events) { $left_events = []; $left_eventIds = \Crave\Model\ct_event::getList($query); foreach ($left_eventIds as $id) { $obj = new stdClass(); $e = new \Crave\Api\Event(['id' => $id, 'no_tickets' => true]); $obj->url = parseEventUrl($e); $obj->title = $e->is->bc ? $e->event_name : $e->where->name; $left_events[] = $obj; } \mem($cache_name, $left_events, $event_cache_duration); } else { if (!$refresh && !is_array($left_events)) { // there has been a problem with the cached data . // calling the function again while refreshing the cache return getLeftRailEvents($query, true); } } return $left_events; }