[TYPO3-mvc] remove object from object storage

Federico Bernardin typo3list at bernardin.it
Thu Aug 1 09:25:09 CEST 2013


Hi Gianluca,
$myFavoriteToRemove is fetched by Extbase because I passed the object via url. Yes it is load with lazy, but the remove process is managed completely by extbase (with object storage).

The problem is that two objects should be the same but they aren't. I don't know why, but fetching object from repository or fetching (the same object) from object storage doesn't give the same result.

cheers
Federico

Il giorno 01/ago/2013, alle ore 09:05, Gianluca Strafella <gianluca.strafella at webformat.com> ha scritto:

> Hi Federico,
> as it is fetched from storage the object $myFavoriteToRemove?
> Have you already checked if $myFavoriteToRemove is an instance of "B" entity ? If  "favorites " property is fetched with lazy loading, could be need load the real instance on it.
> 
> Regards,
> Gianluca
> 
> Il 31/07/2013 17:50, Federico Bernardin ha scritto:
>> Hi guys,
>> I've a strange behavior with remove an object from object Storage.
>> 
>> 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).
>> 
>> My code is:
>> A->removeFavorite($myFavoriteToRemove);
>> But it doesn't work, the problem is that described above.
>> 
>> So my solution is:
>> foreach (A->getFavorites() as $favorite) {
>> 					if ($favorite->getUid() == $myFavoriteToRemove->getUid()) {
>> 						A->removeFavorite($favorite);
>> 					}
>> 				}
>> 
>> And this works fine, but is it the real best solution?
>> 
>> thanks
>> Federico
>> 
> 
> -- 
> Gianluca Strafella
> 
> Software Developer
> gianluca.strafella at webformat.com
> Tel.   +39-0427-926.389
> 
> WEBFORMAT srl – www.webformat.com
> Via S. Francesco d'Assisi, 6 – 20122 MILANO
> Corte Europa, 12 - 33097 SPILIMBERGO (PN)
> 
> _______________________________________________
> 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