symfony-cmf / cmf-sandbox

Base project for trying CMF components integration
http://cmf.symfony.com
Other
367 stars 140 forks source link

use Alice to load fixtures #194

Open lsmith77 opened 11 years ago

lsmith77 commented 11 years ago

https://github.com/nelmio/alice

related to https://github.com/symfony-cmf/SimpleCmsBundle/pull/55

uwej711 commented 11 years ago

How would you handle multi lang content, I guess we need some extension to call bindTranslation?

lsmith77 commented 11 years ago

i havent looked at the details yet but yeah i guess we might need something along those lines

/cc @Seldaek

dbu commented 11 years ago

one language would be handled by setting the locale field. but after that indeed we would need "something" that knows what is going on. @Seldaek phpcr-odm translated fields can be updated on the same document and with another call to bindTranslation stored in that language.

uwej711 commented 11 years ago

Currently I use something like this in our manual fixtures:

contact:
    class: Website\ContentBundle\Document\Page
    locales:
        en:
            metaTitle: "Contact - Test"
            metaDescription: "Contact - Test"
        de:
            metaTitle: "Kontakt - Test"
            metaDescription: "Kontakt Beschreibung - Test"

which with Alice could be something like this

Website\ContentBundle\Document\Page:
    contact:
        locale:
            en:
                metaTitle: "Contact - Test"
                metaDescription: "Contact - Test"
            de:
                metaTitle: "Kontakt - Test"
                metaDescription: "Kontakt Beschreibung - Test"
Seldaek commented 11 years ago

Alice doens't support localization of an entire item at the moment. It can create two documents in two languages though and then you bind them as the two translations.. I don't know exactly how things work in the CMF nowadays but if you can articulate a bit more maybe we find a good solution. Otherwise the latest alice release has processors which allow you to modify the objects on the way to the doctrine object manager, that might also help.

uwej711 commented 11 years ago

I did a quick research and unfortunately the different Doctrine behaviours (ORM) feature different APIs and differ again from PHPCR-ODM. I will look into the processors stuff, maybe that can help.

uwej711 commented 11 years ago

Unfortunately the processors have no knowledge of the original fixture data, so this doesn't seem to help. Maybe we can introduce an other syntax like

metaTitle:de: Titel

or

metaTitle: 
     locale: de
     value: Title
Seldaek commented 11 years ago

Can you show me in php code how it looks to populate one of those objects with multiple langs?

uwej711 commented 11 years ago

What we need for phpcr odm in the end is something like this:

foreach ($locales as $locale => $value) {
    $page->setMetaTitle($value);
    $page->set ...   // another translated field
    $manager->bindTranslation($page, $locale);
}

It would be good to set all the fields and call bindTranslation only once per field, although it should work to repeat it for each field.

dbu commented 11 years ago

bindTranslation only once per document and locale - might be we would even get not nullable validation complaints otherwise.

uwej711 commented 11 years ago

For doing this we still have the translations issue and maybe image loading although I'm not sure we have images in the fixtures ...

lsmith77 commented 11 years ago

we do not have images in the fixtures yet .. but we might want to in the future.

dbu commented 11 years ago

i remove the 1.0 milestone from this task. its not critical.