[FLOW3-general] Best Practice to check for references before removing objects

Kerstin Huppenbauer kerstin.huppenbauer at die-digiparden.de
Mon Feb 20 12:35:55 CET 2012


Hi,

maybe it's not the best solution, but this is how it works for me:
(if someone else needs this too)
I added this to my abstractRepository

/**
  * checks wheter an object is deleteable or not
  *
  * @param object $object
  * @return boolean
  */
public function checkDeleteable($object) {
	$conn = $this->entityManager->getConnection();	
	$conn->beginTransaction();
	$query = $this->entityManager->createQuery('DELETE FROM 
'.$this->entityClassName.' o WHERE o = :object');
	$query->setParameter('object', $object);		
	try{
		$query->getResult();
		$isDeleteable = TRUE;			
	} catch(\Exception $e){			
		$isDeleteable = FALSE;
	}
	$conn->rollback();
	return $isDeleteable;	
}

any suggestions welcome :-)

Cheers
Kerstin



> Hi,
>
> i would like to render a delete-link only, if the object has no references.
> What is the best practice to do this?
> Try to remove the object and rollback the transaction?
>
> How can this be done in FLOW3?
>
>
> Cheers
> Kerstin



More information about the FLOW3-general mailing list