[TYPO3-mvc] remove object from object storage

Federico Bernardin typo3list at bernardin.it
Thu Aug 1 10:16:32 CEST 2013


Thanks Marc, 
but it's very strange, what I did it's a standard process, in my case it's a removing from user's favorite of an entity and this entity is passed from url.
This process doesn't work, it's worrying unless I'm wrong.

Cheers
Federico

Il giorno 01/ago/2013, alle ore 09:57, Marc Bastian Heinrichs <typo3 at mbh-web.de> ha scritto:

> 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
> 
> 
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc



More information about the TYPO3-project-typo3v4mvc mailing list