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

Bastian Waidelich bastian at typo3.org
Mon Feb 20 13:58:02 CET 2012


Kerstin Huppenbauer wrote:

Hi Kerstin,

> 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
>[...]
> try{
> $query->getResult();
> $isDeleteable = TRUE;
> } catch(\Exception $e){
> $isDeleteable = FALSE;
> }
> $conn->rollback();

This seems very hacky to me to be honest ;)
If your domain model is not too complex, why not simply add the 
respective getters to the parent objects, like:

Blog::hasPosts()
Post::hasComments()

and so on..?

Best,
Bastian


More information about the FLOW3-general mailing list