cross link application with symfony - part 2

A few week ago, I have posted an article about Cross Link Application with symfony. The implementation was not totally fine, as collection route was not handled and the configuration parts was not so logical. I spent some time to improve it. The solution is still bundled with the swToolboxPlugin (v1.2.6).

Configuration

  • edit your app.yml file to include the following configuration

    ---
    all:
      swToolbox:
        cross_link_application:
          frontend:
            enabled: on                     # enable the feature 
            load:
              backend:
                dev: rabaix.net/backend.php   # define the full path for the dev environnement
                prod: rabaix.net/backend      # define the full path for the prod environnement 
          backend:
            enabled: on                     # enable the feature for the 
            load:
              frontend:
                dev: rabaix.net/frontend_dev.php
                prod: rabaix.net
    
  • edit your factories.yml

    ---
    all:
      routing:
        class: swPatternRouting
    

Check your log

In your log, you should see new routes prefixed with 'swEncapsulateRoute' and the name of the route. In the following backend log (tail -f log/backend_dev.log). 2 routes from the frontend are loaded

{swPatternRouting} Connect sfRoute "default_index" (/:module)
{swPatternRouting} Connect sfRoute "default" (/:module/:action/*)
[...]
{swPatternRouting} Connect swEncapsulateRoute "frontend.homepage" (/)
{swPatternRouting} Connect swEncapsulateRoute "frontend.sw_blog_view_post" (/blog/:year/:month/:day/:slug)
[...]
 

If you havn't these lines, then something is wrong with the configuration.

No more hack !

When I first introduce this feature, I have added some php code that you can add if you don't want to include the application name (frontend.sw_blog_view_post => sw_blog_view_post). Now this code is included into the swPatternRouting, so from the backend you can do :

// symfony 1.2 syntax with a sfDoctrineRoute with the application name
echo link_to('View post', 'frontend.sw_blog_view_post', $blog) 
 
// symfony 1.2 syntax with a sfDoctrineRoute without the application name
echo link_to('View post', 'sw_blog_view_post', $blog) 
 
// old symfony 1.2 syntax with the application name
echo link_to('View post', '@frontend.sw_blog_view_post?year='.$blog->getYear().'&month='.$blog->getMonth().'&day='.$blog->getDay().'&slug='.$blog->getSlug()) 
 
// old symfony 1.2 syntax without the application name
echo link_to('View post', '@sw_blog_view_post?year='.$blog->getYear().'&month='.$blog->getMonth().'&day='.$blog->getDay().'&slug='.$blog->getSlug()) 
 

Add comment











A la recherche de projets symfony ?

Tags

Last posts