コード例 #1
0
ファイル: EntityDataTest.php プロジェクト: vespolina/syncer
 public function testGetKey()
 {
     $entityData = new EntityData('book', '12345', '<xml>...</xml>');
     $this->assertEquals('book.12345', $entityData->getKey());
 }
コード例 #2
0
 public function updateEntityData(EntityData $entityData)
 {
     $this->entityData[$entityData->getKey()] = $entityData;
 }
コード例 #3
0
ファイル: SyncManager.php プロジェクト: vespolina/syncer
 /**
  * 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;
 }
コード例 #4
0
 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');
     }
 }