/** * Populate this object with data returned from Memcached/Redis/DB * @since Version 3.9.1 * @return void */ private function populate() { $timer = Debug::getTimer(); $row = Utility\LocomotiveUtility::fetchLocomotive($this); if (!is_array($row) || count($row) === 0) { throw new Exception("Data for this locomotive could not be retrieved"); } $lookup = Utility\DataUtility::getLocoColumnMapping(); foreach ($row as $key => $val) { if (isset($lookup[$key])) { $var = $lookup[$key]; $this->{$var} = $val; } } $ints = ["gauge_id", "status_id", "class_id", "owner_id", "operator_id", "photo_id", "manufacturer_id"]; foreach ($ints as $int) { $this->{$int} = filter_var($this->{$int}, FILTER_VALIDATE_INT); } $this->Class = Factory::CreateLocoClass($this->class_id); $this->class =& $this->Class; $this->flickr_tag = trim(str_replace(" ", "", $this->Class->flickr_tag . "-" . $this->number)); $this->gauge_formatted = format_gauge($this->gauge); $this->makeLinks(); Debug::logEvent(__METHOD__, $timer); return $row; }