[Catalyst] Helper classes shared across multiple controllers
- any recommendations?
Jonathan Rockway
jon at jrock.us
Wed Oct 10 07:07:14 GMT 2007
Stefan K=FChn wrote:
> I would like to provide functionality to multiple controllers. =
Base classes. Common code goes in a base class:
package YourApp::BaseController::Foo;
use base 'Catalyst::Controller';
sub some_method {}
sub some_action :Attributes Are OK {}
1;
Then:
package YourApp::Controller::Bar;
use base 'YourApp::BaseController::Foo';
# now you have some_method and some_action
Finally, use __PACKAGE__->config to your advantage. =
I have a good example of controller subclassing here:
=
http://search.cpan.org/src/JROCKWAY/Catalyst-Model-Adaptor-0.01/t/lib/TestA=
pp/BaseController/Adaptor.pm
That base class is used in a few places:
=
http://search.cpan.org/src/JROCKWAY/Catalyst-Model-Adaptor-0.01/t/lib/TestA=
pp/Controller/Adaptor.pm
=
http://search.cpan.org/src/JROCKWAY/Catalyst-Model-Adaptor-0.01/t/lib/TestA=
pp/Controller/Factory.pm
=
http://search.cpan.org/src/JROCKWAY/Catalyst-Model-Adaptor-0.01/t/lib/TestA=
pp/Controller/PerRequest.pm
Pretty nice, eh?
Regards,
Jonathan Rockway
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 370 bytes
Desc: OpenPGP digital signature
Url : http://lists.scsys.co.uk/pipermail/catalyst/attachments/20071010/4599=
113b/signature.pgp
More information about the Catalyst
mailing list