Search code examples
semanticssubroutinecatalyst

What does 'for' in `uri_for` mean?


In Catalyst, I don't understand what does the for means in the $c->URI_for(); subroutine.

Is it an abbrev for for + something (could be forward), an acronym or something ?


Solution

  • It means the URI for whatever that particular $c is.

    $c->uri_for( $path, @args?, \%query_values? )

    Merges path with $c->request->base for absolute URIs and with $c->namespace for relative URIs, then returns a normalized URI object. If any args are passed, they are added at the end of the path. If the last argument to uri_for is a hash reference, it is assumed to contain GET parameter key/value pairs, which will be appended to the URI in standard fashion.

    Instead of $path, you can also optionally pass a $action object which will be resolved to a path using $c->dispatcher->uri_for_action; if the first element of @args is an arrayref it is treated as a list of captures to be passed to uri_for_action.

    In terms of French, think of it in terms of pour, as in Nom pour le livre (name for the book) although, given it's been some twenty years since I last actually spoke French, I may have inadverdently insulted your heritage :-)