|  | @@ -18,16 +18,24 @@ class TripalTermController extends EntityAPIController {
 | 
	
		
			
				|  |  |    /**
 | 
	
		
			
				|  |  |     * Delete a single entity.
 | 
	
		
			
				|  |  |     */
 | 
	
		
			
				|  |  | -  public function delete($entity) {
 | 
	
		
			
				|  |  | -    $transaction = db_transaction();
 | 
	
		
			
				|  |  | +  public function delete($ids, DatabaseTransaction $transaction = NULL) {
 | 
	
		
			
				|  |  | +    $entities = $ids ? $this->load($ids) : FALSE;
 | 
	
		
			
				|  |  | +    if (!$entities) {
 | 
	
		
			
				|  |  | +      // Do nothing, in case invalid or no ids have been passed.
 | 
	
		
			
				|  |  | +      return;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    $transaction = isset($transaction) ? $transaction : db_transaction();
 | 
	
		
			
				|  |  |      try {
 | 
	
		
			
				|  |  |        // Invoke hook_entity_delete().
 | 
	
		
			
				|  |  | -      module_invoke_all('entity_delete', $entity, 'TripalTerm');
 | 
	
		
			
				|  |  | -      field_attach_delete('TripalTerm', $entity);
 | 
	
		
			
				|  |  | +      $ids = array_keys($entities);
 | 
	
		
			
				|  |  | +      foreach ($entities as $id => $entity) {
 | 
	
		
			
				|  |  | +        module_invoke_all('entity_delete', $entity, 'TripalTerm');
 | 
	
		
			
				|  |  | +        field_attach_delete('TripalTerm', $entity);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -      db_delete('tripal_term')
 | 
	
		
			
				|  |  | -        ->condition('accession', $entity->accession)
 | 
	
		
			
				|  |  | -        ->execute();
 | 
	
		
			
				|  |  | +        db_delete('tripal_term')
 | 
	
		
			
				|  |  | +          ->condition('accession', $entity->accession)
 | 
	
		
			
				|  |  | +          ->execute();
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      catch (Exception $e) {
 | 
	
		
			
				|  |  |        $transaction->rollback();
 | 
	
	
		
			
				|  | @@ -41,11 +49,11 @@ class TripalTermController extends EntityAPIController {
 | 
	
		
			
				|  |  |    /**
 | 
	
		
			
				|  |  |     * Saves the custom fields using drupal_write_record().
 | 
	
		
			
				|  |  |     */
 | 
	
		
			
				|  |  | -  public function save($entity) {
 | 
	
		
			
				|  |  | +  public function save($entity, DatabaseTransaction $transaction = NULL) {
 | 
	
		
			
				|  |  |      global $user;
 | 
	
		
			
				|  |  |      $pkeys = array();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    $transaction  = db_transaction();
 | 
	
		
			
				|  |  | +    $transaction = isset($transaction) ? $transaction : db_transaction();
 | 
	
		
			
				|  |  |      try {
 | 
	
		
			
				|  |  |        // If our entity has no id, then we need to give it a
 | 
	
		
			
				|  |  |        // time of creation.
 |