/** * 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; }
<?php $events_callback = function () { $list = \Crave\Model\ct_event::getMany(array('upcoming' => 1, 'producer__ct_promoter_id' => 7400, 'limit' => 4, 'order_by' => "ct_contract_date.start_date")); $events = array_map(function ($item) { return (object) ['ide' => $item->ide, 'market_name' => $item->ct_contract->market_name, 'start_date' => $item->ct_contract->dates[0]->start_date, 'venue_name' => $item->venue->venu_name, 'media_items' => $item->media_items]; }, $list); return $events; }; $upcoming_events = getFromCache("lindys:homepage:upcoming-events", $events_callback, rand(20, 60)); //dd($events_callback()); dd($upcoming_events);
'crop' => 'center', 'limit' => 1 ); $key = 'cache:newyears.com:event-uri:'.$this->uri; unset ($event); //$event = \mem($key); if(!$event){ // the usage of ide is to prevent the need to handle querystring. $a = unParseEventUrl($p->urlpath.'/'.$p->ide); $eventIds = \Crave\Model\ct_event::getList($a); if(count($eventIds) == 0 ){ // event not found , need to send the user to an error page . echo("<h1>EVENT NOT FOUND</h1>"); die(); } $event = new \Crave\Api\Event($eventIds[0]); $desc_arr = []; $desc = $event->getDescription([ 'website_ide' => $this->website_ide