コード例 #1
0
 public function testAddEntity()
 {
     $fooEntity = $this->createTestEntity(1);
     $barEntity = $this->createTestEntity(2);
     $expectedCount = count($this->entities) + 1;
     $expectedEntities = array_merge($this->entities, array($fooEntity));
     $this->assertEquals($this->entityData, $this->entityData->addEntity($fooEntity));
     $this->assertCount($expectedCount, $this->entityData->getEntities());
     $this->assertEquals($expectedEntities, $this->entityData->getEntities());
     $this->entityData->addEntity($barEntity);
     $expectedCount += 1;
     $expectedEntities = array_merge($expectedEntities, array($barEntity));
     $this->assertCount($expectedCount, $this->entityData->getEntities());
     $this->assertEquals($expectedEntities, $this->entityData->getEntities());
 }
コード例 #2
0
 /**
  * Merge fields
  *
  * @param EntityData $data
  */
 public function run(EntityData $data)
 {
     $masterEntity = $data->getMasterEntity();
     foreach ($data->getEntities() as $entity) {
         if (!$this->doctrineHelper->isEntityEqual($masterEntity, $entity)) {
             $this->entityManager->remove($entity);
         }
     }
 }
コード例 #3
0
 /**
  * Get entities that are not master.
  *
  * @param EntityData $entityData
  * @return array
  */
 protected function getEntitiesToClear(EntityData $entityData)
 {
     $result = array();
     $masterEntity = $entityData->getMasterEntity();
     foreach ($entityData->getEntities() as $entity) {
         if (!$this->doctrineHelper->isEntityEqual($masterEntity, $entity)) {
             $result[] = $entity;
         }
     }
     return $result;
 }