/** * Hydrate a SpiderRecord from an OrientRecord * * @param $orientRecord * @return Response */ protected function mapOrientRecordToCollection(OrientRecord $orientRecord) { // Or we map a single record to a Spider Record $collection = new Collection($orientRecord->getOData()); $collection->add(['id' => $orientRecord->getRid()->jsonSerialize(), 'label' => $orientRecord->getOClass(), 'meta.rid' => $orientRecord->getRid(), 'meta.version' => $orientRecord->getVersion(), 'meta.oClass' => $orientRecord->getOClass()]); $collection->protect('id'); $collection->protect('label'); $collection->protect('meta'); return $collection; }
/** * @param $record * @return \stdClass * @throws \Exception */ protected function populateRecord(Record $record) { $classMap = $this->em->classMap; $key = $record->getOClass(); if (array_key_exists($key, $classMap)) { $entity = new $classMap[$key](); /* @var EntityInterface $entity */ $entity->setRid($record->getRid()); $oData = $record->getOData(); if (!empty($oData) && is_array($oData)) { foreach ($oData as $key => $value) { $entity->{$key} = $value; } } return $entity; } throw new Exception('Key not found'); }
protected static function isEdge(Record &$record) { $data = $record->getOData(); if (isset($data['in']) && isset($data['out'])) { return true; } return false; }