Code snippets for symfony 1.x

Navigation

Refine Tags

Snippets tagged "action handleerror"

forward wrapper that accepts a routing label

Here is a forward method wrapper that accepts a routing label. Since forward does not do parameters neither does this. Though it would be nice.

public static function fooForward(&$sfa, $route)
  {
    $url = sfContext::getInstance()->getController()->genUrl($route);
    $routing = explode("/", $url, 3);
    switch (count($routing))
    {
      case (3):
        $sfa->forward($routing[1],$routing[2]);
        break;
      case (2):
        $sfa->forward($routing[1], 'index');
        break;
      default:
        error_log(sprintf("Error in fooForward for routing label %s", $route));
        break;
    }
  }

Call it in an action:

  public function handleError()
  {
    fooTools::fooForward($this, '@someLabel');
  }

If there where parameters in the label the $url would have them. Though they can not be used in this case.

by roland cruse on 2006-09-27, tagged action  forward  handleerror  routing 
(3 comments)