Example #1
0
 /**
  * Override for getAll to include the winner character object
  */
 public static function getAll($force = false)
 {
     $cacheKey = 'Api:Bracket:getAll_' . BRACKET_SOURCE;
     $retVal = Lib\Cache::Get($cacheKey);
     if (false === $retVal || $force) {
         $brackets = parent::queryReturnAll(['source' => BRACKET_SOURCE, 'state' => ['ne' => BS_HIDDEN]], ['score' => 'desc', 'state' => 'desc', 'start' => 'desc']);
         $retVal = [];
         foreach ($brackets as $bracket) {
             if ($bracket->winnerCharacterId) {
                 $bracket->winner = Character::getById($bracket->winnerCharacterId);
             }
             if ($bracket->start <= time() || $force) {
                 $retVal[] = $bracket;
             }
         }
         Lib\Cache::Set($cacheKey, $retVal, 3600);
     }
     return $retVal;
 }