/**
  * Process add/remove files.
  *
  * @param object $collection The collection to be altered.
  * @param array $files The files to be added or removed.
  *
  * @return void.
  */
 protected function _addRemoveFilesFromCollection($collection, $files)
 {
     foreach ($files as $id => $value) {
         if ($value == 'add' && !$collection->checkForFileMembership($id)) {
             $assoc = new BagitFileCollectionAssociation();
             $assoc->collection_id = $collection->id;
             $assoc->file_id = $id;
             $assoc->save();
         } else {
             if ($value == 'remove') {
                 $assoc = $this->_helper->db->getTable('BagitFileCollectionAssociation')->getAssociationByIds($id, $collection->id);
                 $assoc->delete();
             }
         }
     }
 }
 /**
  * Adds all files to the collection.
  *
  * @return array $files The files.
  */
 public function addAllFiles()
 {
     $fileTable = $this->getTable('File');
     $files = $fileTable->fetchObjects($fileTable->getSelect());
     foreach ($files as $file) {
         $test_for_assoc = $this->getTable('BagitFileCollectionAssociation')->getAssociationByIds($file->id, $this->id);
         if (count($test_for_assoc) == 0) {
             $assoc = new BagitFileCollectionAssociation();
             $assoc->file_id = $file->id;
             $assoc->collection_id = $this->id;
             $assoc->save();
         }
     }
 }