예제 #1
0
 protected function updateCollection()
 {
     foreach ($this->forAdd as $newEntity) {
         $this->wrappedEntity->addToCollection($this->component->name, $newEntity);
         $this->wrappedEntity->getEntityManager()->persist($newEntity);
     }
     foreach ($this->forRemoval as $entityForRemove) {
         $this->wrappedEntity->removeFromCollection($this->component->name, $entityForRemove);
         if ($this->type == ClassMetadata::ONE_TO_MANY && $this->wrappedEntity->getEntityManager()->contains($entityForRemove)) {
             $this->wrappedEntity->getEntityManager()->remove($entityForRemove);
         }
     }
 }