public function testGetKey() { $entityData = new EntityData('book', '12345', '<xml>...</xml>'); $this->assertEquals('book.12345', $entityData->getKey()); }
public function updateEntityData(EntityData $entityData) { $this->entityData[$entityData->getKey()] = $entityData; }
/** * Transform the entity data into a local entity * * Optionally provide the service adapter to do the job * * @param EntityData $entityData * @param ServiceAdapterInterface $serviceAdapter * @return mixed */ protected function transformEntityData(EntityData $entityData, ServiceAdapterInterface $serviceAdapter = null) { if (null == $serviceAdapter) { $serviceAdapter = $this->getServiceAdapter($entityData->getEntityName()); } // Use the service adapter to transform the entity data $localEntity = $serviceAdapter->transformEntityData($entityData); // If the manager is responsible for tracking references between local and remote entity ids // then maintain the id mapping relationship if ($this->config['use_id_mapping']) { $this->maintainIdMapping($localEntity, $entityData); } return $localEntity; }
public function transformEntityData(EntityData $entityData) { switch ($entityData->getEntityName()) { case 'product': $product = new LocalProduct(); // In reality the local persistence gateway would generate the local id $product->id = 'local' . $entityData->getEntityId(); $product->category = $entityData->getDependencyReference('category'); return $product; case 'category': $cat = new LocalProductCategory(); // In reality the local persistence gateway would generate the local id $cat->name = $entityData->getEntityId(); return $cat; default: throw new \Exception('this should never be reached'); } }