[Catalyst-dev] RFC: action_uri

Matt S Trout dbix-class at trout.me.uk
Mon Oct 2 15:21:34 CEST 2006


A. Pagaltzis wrote:
> * Bogdan Lucaciu <bogdan at wiz.ro> [2006-10-02 13:35]:
>> Would this alternative syntax be acceptable:
>> $c->action_uri('Foo::Bar->baz', bla); ?
> 
> Hiding special syntax inside a string is a bad idea. Just pass
> two parameters.
> 
>     $c->action_uri_for( 'Foo::Bar' => baz => bla );

Or use the action private path -

$c->action_uri('/foo/bar/baz', $blah);

with

$c->action_uri([ 'Foo::Bar' => 'baz' ], $blah);

as a synonym.

> It is also conceivable to shift the problem around:
> 
>     $c->controller('Foo::Bar')->action_for('baz')->uri_for($c, bla);
> 
> As long as the original, but a bit more convenient, and might be
> useful in its own right in some contexts.
> 
> But I don’t like any of these options. They mix too many
> different responsibilities. Hmm… I think a method on `$c` much
> like `controller` would be the cleanest approach:
> 
>     $c->uri_for($c->action_for('Foo::Bar', 'baz'), bla);
> 
> Hmm, come to think of it, both `action_uri_for` and `action_for`
> should probably be added.

Not sure I agree if you're going to do it like that - it hard-codes the 
concept of actions only existing under controllers, which while "usual" 
practice isn't required to be the case.

-- 
      Matt S Trout       Offering custom development, consultancy and support
   Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +



More information about the Catalyst-dev mailing list