示例#1
0
 /**
  * @param  ChildCategory $category The ChildCategory object to remove.
  * @return $this|ChildFile The current object (for fluent API support)
  */
 public function removeCategory(ChildCategory $category)
 {
     if ($this->getCategories()->contains($category)) {
         $pos = $this->collCategories->search($category);
         $this->collCategories->remove($pos);
         if (null === $this->categoriesScheduledForDeletion) {
             $this->categoriesScheduledForDeletion = clone $this->collCategories;
             $this->categoriesScheduledForDeletion->clear();
         }
         $this->categoriesScheduledForDeletion[] = $category;
         $category->setFile(null);
     }
     return $this;
 }
示例#2
0
 /**
  * Remove category of this object
  * through the object_category cross reference table.
  *
  * @param ChildCategory $category
  * @return ChildObject The current object (for fluent API support)
  */
 public function removeCategory(ChildCategory $category)
 {
     if ($this->getCategories()->contains($category)) {
         $objectCategory = new ChildObjectCategory();
         $objectCategory->setCategory($category);
         if ($category->isObjectsLoaded()) {
             //remove the back reference if available
             $category->getObjects()->removeObject($this);
         }
         $objectCategory->setObject($this);
         $this->removeObjectCategory(clone $objectCategory);
         $objectCategory->clear();
         $this->collCategories->remove($this->collCategories->search($category));
         if (null === $this->categoriesScheduledForDeletion) {
             $this->categoriesScheduledForDeletion = clone $this->collCategories;
             $this->categoriesScheduledForDeletion->clear();
         }
         $this->categoriesScheduledForDeletion->push($category);
     }
     return $this;
 }