public function getBody() { $o = $this->entity; // The offering $b = array(); // The session // Offerings that are not valid should not be passed here if ($o->getStatus() == Offering::COURSE_NA) { throw new \Exception("The offering is not available any more"); } $b['id'] = $o->getId(); $b['url'] = $o->getUrl(); $b['displayDate'] = $o->getDisplayDate(); $b['startDate'] = $o->getStartDate()->format('Y-m-d'); $b['startTimeStamp'] = $o->getStartTimestamp(); $b['microdataDate'] = $o->getMicrodataDate(); $b['status'] = $o->getStatus(); $b['courseId'] = $o->getCourse()->getId(); $b['slug'] = $o->getCourse()->getSlug(); // get the state $b['states'] = CourseUtility::getStates($o); $b['state'] = CourseUtility::calculateState($o); // Boost the state depending on the date. This value is used for sorting $b['state'] += CourseUtility::calculateBoost($b['states'], $o->getStartDate()); return $b; }
public static function getStates(Offering $offering) { $state = CourseUtility::calculateState($offering); return self::getStatesFromState($state); }