Example #1
0
 /**
  * @param  ChildGallery $gallery The ChildGallery object to remove.
  * @return $this|ChildUser The current object (for fluent API support)
  */
 public function removeGallery(ChildGallery $gallery)
 {
     if ($this->getGalleries()->contains($gallery)) {
         $pos = $this->collGalleries->search($gallery);
         $this->collGalleries->remove($pos);
         if (null === $this->galleriesScheduledForDeletion) {
             $this->galleriesScheduledForDeletion = clone $this->collGalleries;
             $this->galleriesScheduledForDeletion->clear();
         }
         $this->galleriesScheduledForDeletion[] = $gallery;
         $gallery->setUser(null);
     }
     return $this;
 }
Example #2
0
 /**
  * Remove gallery of this object
  * through the images_galleries_map cross reference table.
  *
  * @param ChildGallery $gallery
  * @return ChildImage The current object (for fluent API support)
  */
 public function removeGallery(ChildGallery $gallery)
 {
     if ($this->getGalleries()->contains($gallery)) {
         $imageGalleryMap = new ChildImageGalleryMap();
         $imageGalleryMap->setGallery($gallery);
         if ($gallery->isImagesLoaded()) {
             //remove the back reference if available
             $gallery->getImages()->removeObject($this);
         }
         $imageGalleryMap->setImage($this);
         $this->removeImageGalleryMap(clone $imageGalleryMap);
         $imageGalleryMap->clear();
         $this->collGalleries->remove($this->collGalleries->search($gallery));
         if (null === $this->galleriesScheduledForDeletion) {
             $this->galleriesScheduledForDeletion = clone $this->collGalleries;
             $this->galleriesScheduledForDeletion->clear();
         }
         $this->galleriesScheduledForDeletion->push($gallery);
     }
     return $this;
 }