Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [Symfony2][Doctrine]Usuwanie translacji gedmo, Gdy usuwamy rekord
marcio
post
Post #1





Grupa: Zarejestrowani
Postów: 2 291
Pomógł: 156
Dołączył: 23.09.2007
Skąd: ITALY-MILAN

Ostrzeżenie: (10%)
X----


Witam mam maly problem potrzebuje usunac wszystkie tlumaczenia z gedmo gdy usuwam jakis rekord.
Problem polega na tym ze nie moge uzywa dotakowych repozytoriow ani encji.
Wiec takie rozwiazanie odpada:
  • https://github.com/l3pp4rd/DoctrineExtensions/blob/master/doc/translatable.md#translation-entity
  • https://github.com/l3pp4rd/DoctrineExtensions/blob/master/doc/translatable.md#personal-translations

Poki co probowalem tak:
  1. /**
  2.   * Cleans texts of of the content with given ID
  3.   *
  4.   * @param integer $contentId ID of the content
  5.   * @return boolean
  6.   */
  7. public function cleanContent($contentId) {
  8. $content = $this->getContentById($contentId);
  9. if ($content !== null) {
  10. $translations = $this->getEntityManager()
  11. ->getRepository('Gedmo\Translatable\Entity\Translation')
  12. ->findBy(array(
  13. 'objectClass' => $this->getEntityClassName(),
  14. 'content' => $content->getContent()
  15. )
  16. );
  17.  
  18. foreach ($translations as $translation) {
  19. $this->getEntityManager()->remove($translation);
  20. }
  21. $content->setContent(null);
  22. $this->getEntityManager()->flush();
  23.  
  24. return true;
  25. }
  26.  
  27. return false;
  28. }

W translations znajduje sie:
Kod
Array ( [0] => Gedmo\Translatable\Entity\Translation Object ( [id:protected] => 1 [locale:protected] => pl_PL [objectClass:protected] => Meritoo\Cmf\PagesContentBundle\Entity\PagesContent [field:protected] => title [foreignKey:protected] => 1 [content:protected] => Strona główna ) [1] => Gedmo\Translatable\Entity\Translation Object ( [id:protected] => 3 [locale:protected] => en_GB [objectClass:protected] => Meritoo\Cmf\PagesContentBundle\Entity\PagesContent [field:protected] => title [foreignKey:protected] => 1 [content:protected] => Strona główna ) [2] => Gedmo\Translatable\Entity\Translation Object ( [id:protected] => 5 [locale:protected] => de_DE [objectClass:protected] => Meritoo\Cmf\PagesContentBundle\Entity\PagesContent [field:protected] => title [foreignKey:protected] => 1 [content:protected] => Strona główna ) [3] => Gedmo\Translatable\Entity\Translation Object ( [id:protected] => 7 [locale:protected] => fr_FR [objectClass:protected] => Meritoo\Cmf\PagesContentBundle\Entity\PagesContent [field:protected] => title [foreignKey:protected] => 1 [content:protected] => Strona główna ) [4] => Gedmo\Translatable\Entity\Translation Object ( [id:protected] => 9 [locale:protected] => en_US [objectClass:protected] => Meritoo\Cmf\PagesContentBundle\Entity\PagesContent [field:protected] => title [foreignKey:protected] => 1 [content:protected] => Strona główna ) )

Czyli mamy encje Translation wiec dlaczego remove nie dziala?
Zero bledow kompletnie nic a w bazie tlumaczenia dalej sa.
Czy ktos wie jak rozwiazac problem?


--------------------
Zainteresowania: XML | PHP | MY(SQL)| C# for .NET | PYTHON
http://code.google.com/p/form-builider/
Moj blog
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 20.08.2025 - 01:05