2

I was using JMSI8nRoutingBundle in my (Sylius) project, everything was going well.

I've just switch to CMFRouting for some of my routes (mainly products), but these routes don't work properly when I have JMS i8n routing enabled, here is the error I get when using {{ path(product) }} :

Catchable fatal error: Object of class MyApp\Model\MyProduct could not
be converted to string in C:\wamp\www\caissin\vendor\jms\i18n-routing-
bundle\JMS\I18nRoutingBundle\Router\I18nRouter.php on line 133

If I disable JMS i8n routing, everything is going well with the CMF routes & the classic ones.

So my question is: is there something specific to do to make JMS i8n routing & CMF routing work together? It seems that JMS is taking over CMF, instead of doing a chain together.

Weirdly I haven't found anything on google regarding this topic.

Thanks in advance.

abacco
  • 303
  • 2
  • 9
  • The CMF RoutingBundle is not tested with JMSI18nRouting because it can separate the route (url) from the content, offering an alternative to JMSI18nRouting. you would simply supply one route per language, all pointing to the same content. But with the Sylius routing i don't know exactly. If you don't get a reply here, try opening an issue on sylius to get support. – dbu Jun 11 '14 at 11:31

2 Answers2

2

the issue is caused how JMSi18nBundle overrides the default router: https://github.com/schmittjoh/JMSI18nRoutingBundle/issues/73

1

The following branch helped me, to get JMSI18nRoutingBundle working together with Sylius:

https://github.com/ekyna/JMSI18nRoutingBundle/tree/symfony-cmf

Register the custom repository in your composer.json:

"repositories": [
{
  "type": "vcs",
  "url": "https://github.com/ekyna/JMSI18nRoutingBundle.git"
}
]

and reference to the "symfony-cmf" branch in the "require" block

"jms/i18n-routing-bundle": "dev-symfony-cmf"

This should do the trick.

Dont forget to register the bundle in your AppKernel.php:

new \JMS\I18nRoutingBundle\JMSI18nRoutingBundle(),

and setup routing config in your config.yml:

jms_i18n_routing:
    default_locale: "de"
    locales: [en, de]
    strategy: prefix

Finally run "composer update" on your terminal.

Update:

To get login/logout working correctly, you may want to use Sylius routes in the firewall definition.

i updated the "main" firewall with this "form_login" parameters:

form_login:
    provider: sylius_user_provider
    login_path: sylius_user_security_login
    check_path: sylius_user_security_check
    failure_path: sylius_user_security_login
    default_target_path: sylius_homepage
    use_forward:  false
    use_referer: true

and these "logout" settings:

logout:
    path: sylius_user_security_logout
    target: sylius_homepage
Headd2k
  • 11
  • 2