Name
Catalyst::Plugin::ConfigComponents - Creates components from config entries
Version
0.6.$Revision: 128 $
Synopsis
# In your Catalyst application
package YourApp;
use Catalyst qw(ConfigComponents);
__PACKAGE__->setup;
# In your applications config file
<component name="Model::YourModel">
<parent_classes>YourExternal::ModelE<lt>/parent_classes>
<parent_classes>Catalyst::ModelE<lt>/parent_classes>
</component>
# Do not create YourApp::Model::YourModel this module will do it for you
# In a controller this will call your_method in
# the class YourExternal::Model
$result = $c->model( q(YourModel) )->your_method( ... );
Description
When the application starts this module creates Catalyst component class definitions using config information. The defined class inherits from the list of parent classes referenced in the config file
Configuration and Environment
Specify a Plugin::ConfigComponents config option. Attributes are
- component_active
-
If the component_active config attribute exists and is false the component will not be loaded
- parent_classes
-
List of classes for the derived component to inherit from
- search_extra
-
To add additional search paths, specify a key named search_extra as an array reference. Items in the array beginning with :: will have the application class name prepended to them
- setup_method
-
Defaults to
_setup_config_components
, the method to call after the call to Catalyst::setup_components
You may want to add the line:
Class::C3::initialize();
to your Catalyst application after the __PACKAGE__->setup
call if the base class creates any "diamond" patterns in the inheritance tree
Subroutines/Methods
setup_components
Calls the setup method (which defaults to "setup_config_components") after the parent method
_setup_config_components
For each config key matching \A Model|View|Controller ::
it checks if the corresponding component already exists, and if it doesn't this method creates it at run-time
The parent class is set to MyApp->config->{ $component }->{parent_classes}
if it exists, Catalyst::$component
otherwise. The parent_classes can be an array ref in which case the defined class will inherit from all classes in the list (multiple inheritance)
Diagnostics
None
Dependencies
Incompatibilities
There are no known incompatibilities in this module
Bugs and Limitations
There are no known bugs in this module. Please report problems to the address below. Patches are welcome
Author
Peter Flanigan, <Support at RoxSoft.co.uk>
Acknowledgements
Larry Wall - For the Perl programming language
This code was originally posted to the Catalyst mailing list by Dagfinn Ilmari Mannsåker as a patch in response to an idea by Castaway. I thought it would be better as a plugin and have extended it to handle MI
License and Copyright
Copyright (c) 2008-2012 Peter Flanigan. All rights reserved
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic
This program is distributed in the hope that it will be useful, but WITHOUT WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 219:
Non-ASCII character seen before =encoding in 'Mannsåker'. Assuming CP1252