I have a multilingual website with 2 languages: en (default) and de (german).
I want to fill my categories table with default categories in english, using Doctrine Fixtures like this:
$subcategory1 = new Category();
$subcategory1->setTitle('Comedy');
$subcategory1->setParent($category);
$subcategory2 = new Category();
$subcategory2->setTitle('Action');
$manager->persist($subcategory1);
$manager->persist($subcategory2);
$manager->flush();
I am using Doctrine extension translatable to have the table content also in german. If I have to do it manually I have to do in symfony:
$em = $this->getDoctrine()->getEntityManager();
$category = $em->find('Tracker\MembersBundle\Entity\Category', 51 );
$category->setTitle('Komödie');
$category->setTranslatableLocale('de'); // change locale
$em->persist($category);
$em->flush();
My question is how can I automate this process to make it work while loading fixtures? I have about 30 categories.
Try this method: