/** * Get the object data ready to be sent * @param Db_Object $object * @param integer $id * @param integer $version * @return array */ protected function _loadData(Db_Object $object, $version) { $id = $object->getId(); $vc = Model::factory('Vc'); if (!$version) { $version = $vc->getLastVersion($this->_objectName, $id); } if (!$version) { $data = $object->getData(); $data['id'] = $object->getId(); Response::jsonSuccess($data); } try { $object->loadVersion($version); } catch (Exception $e) { Model::factory($object->getName())->logError('Cannot load version ' . $version . ' for ' . $object->getName() . ':' . $object->getId()); Response::jsonError($this->_lang->get('CANT_LOAD')); } $data = $object->getData(); if (empty($data)) { Response::jsonError($this->_lang->get('CANT_LOAD')); } $data['id'] = $id; $data['version'] = $version; $data['published'] = $object->get('published'); $data['staging_url'] = static::getStagingUrl($object); /* * Prepare multilink properties */ $linkedObjects = $object->getConfig()->getLinks(array('multy')); foreach ($linkedObjects as $linkObject => $fieldCfg) { foreach ($fieldCfg as $field => $linkCfg) { if (empty($data[$field])) { continue; } $data[$field] = array_values($this->_collectLinksData($data[$field], $linkObject)); } } return $data; }