Beispiel #1
0
 public function testConstructor()
 {
     $entityData = new EntityData('book', '12345', '<xml>...</xml>');
     $this->assertEquals('book', $entityData->getEntityName());
     $this->assertEquals('12345', $entityData->getEntityId());
     $this->assertEquals('<xml>...</xml>', $entityData->getData());
 }
Beispiel #2
0
 /**
  * Maintain the id mapping (local vs remote id)
  *
  * @param $localEntity
  * @param EntityData $remoteEntityData
  */
 protected function maintainIdMapping($localEntity, EntityData $remoteEntityData)
 {
     $this->gateway->updateIdMapping($remoteEntityData->getEntityName(), $localEntity->getId(), $remoteEntityData->getEntityId());
 }
 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');
     }
 }