[TYPO3-mvc] remove object from object storage
Marc Bastian Heinrichs
typo3 at mbh-web.de
Thu Aug 1 09:57:24 CEST 2013
Hey,
Am 31.07.2013 17:50, schrieb Federico Bernardin:
> This is my situation:
>
> Entity A with property (m:n) favorites of type objectStorage<B>. B is another
> entity.
>
> My Controller fetches object A from repository and fetches from url an entity
> of type B (called $myFavoriteToRemove). Then I use this
$myFavoriteToRemove to
> remove the correct object from A->favorites. But the favorite isn't
> removed. So I debug in deep the code and I found that
> spl_object_hash($myFavoriteToRemove) hash isn't the same as the
> object in A->favorites with the same uid, so the detach function of
> objectstorage doesn't work (it doesn't find any object in storage
> array).
It's a php and a processing thing of the current implementation. The
spl_object_hash is only the same for the same instance of a object. But
you will get two different instances of objects with the same data -
one by argument mapping and one by fetching the related objects. In
this case it's because of the order of the fetching from the
persistence. If fetching the relations would be done before mapping the
argument, I guess the instances will be the same.
ATM I have no other solution than yours.
Best
Marc Bastian
More information about the TYPO3-project-typo3v4mvc
mailing list