Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to NOT override Symfony's default router #153

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add option to NOT override Symfony's default router #153

wants to merge 1 commit into from

Conversation

timvermaercke
Copy link

Hi

We're using two bundles (i18nRoutingBundle and one of our own) that will alter the Symfony routing. The problem we had is that our bundle was ignored because the i18n bundle always took the upper hand and our dynamic routing wasn't loaded.

We've found a solution to get them both working but for that we needed to add an option, whether or not the bundle's router replaces the standard Symfony router. If we do this, the JMSi18nBundle plays nicely with other bundles.

@XWB
Copy link
Contributor

XWB commented Dec 4, 2015

You can also extend I18nRouter:

class MyRouter extends I18nRouter
{
}
<service id="my_router" class="MyBundle\Routing\MyRouter" parent="jms_i18n_routing.router" public="false">
</service>

Make sure to load your own bundle behind the I18nRoutingBundle:

public function registerBundles()
{
    $bundles = array(
        new JMS\I18nRoutingBundle\JMSI18nRoutingBundle(),
        new MyBundle\Bundle(),
    );

    return $bundles;
}

Finally use a compiler pass to override the alias:

public function process(ContainerBuilder $container)
{
    $container->setAlias('router', 'my_router');
}

@timvermaercke
Copy link
Author

This was no option for us.
We fixed it by adding a custom CompilerPass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants