Search code examples
phproutessymfony1

Symfony 1.0 - Extend sfRouting


Anyone know if the following 'class' entry in routing.yml is possible in SF1.0? I tried to add it and override some methods like getInstance() and getCurrentRouteName(), but they never get called upon, even though I am making calls to them manually.

checkout_landing:
  class: CustomRoute # Can I do this in SF1.0?
  url: /checkout/landing/:k/*
  param: { module: sharedCheckout, action: landing }

We have implemented this 'per-route' custom class configuration in SF1.2, but it doesn't seem to be working for SF1.0. I suspect for SF1.0 I will have to add a custom class entry to the factories.yml file which will affect all routes.

Bonus question: Anyone able to emulate the 'extra_parameters_as_query_string' in SF1.0? Right now, with the above url entry, and GET params are converted to pseduo sub-dirs, for example a querystring like:

$params = array('foo' => 'bar', 'pet' => 'dog');

$url = sprintf('@checkout_landing?%s', http_build_query($params));

// Looks like:

http://example.com/checkout/landing/foo/bar/cat/dog

// I need it to look like

http://example.com/checkout/landing?foo=bar&pet=dog

Solution

  • I browsed the compiled cached code for routes, and sure enough in SF1.0 there are no custom object references based on 'Class' entries in the yaml file. However when I view compiled cache code for routes generated in SF1.4, the custom objects are available.

    As upgrading is not an option, I opted to generate the urls the old fashioned way, manually.