X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst.pm;h=6aa73577c3a15eaa58aa9c20e4864a24f1a646b7;hb=4e68badce837f4ebc4567faeaa707bbae88c5ffd;hp=47b4e30cf03e6b4db8e04f7585210f963c226001;hpb=aa7e913e96898ca59fbf3170d4b9fe1de444e3e5;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 47b4e30..6aa7357 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -807,12 +807,34 @@ Returns or takes a hashref containing the application's configuration. __PACKAGE__->config( { db => 'dsn:SQLite:foo.db' } ); You can also use a C, C or C config file -like myapp.yml in your applications home directory. See +like myapp.conf in your applications home directory. See L. - --- - db: dsn:SQLite:foo.db +=head3 Cascading configuration. +The config method is present on all Catalyst components, and configuration +will be merged when an application is started. Configuration loaded with +L takes precedence over other configuration, +followed by configuration in your top level C class. These two +configurations are merged, and then configuration data whos hash key matches a +component name is merged with configuration for that component. + +The configuration for a component is then passed to the C method when a +component is constructed. + +For example: + + MyApp->config({ 'Model::Foo' => { bar => 'baz', overrides => 'me' } }); + MyApp::Model::Foo->config({ quux => 'frob', 'overrides => 'this' }); + +will mean that C receives the following data when +constructed: + + MyApp::Model::Foo->new({ + bar => 'baz', + quux => 'frob', + overrides => 'me', + }); =cut @@ -903,9 +925,9 @@ loads and instantiates the given class. MyApp->plugin( 'prototype', 'HTML::Prototype' ); $c->prototype->define_javascript_functions; - + B This method of adding plugins is deprecated. The ability -to add plugins like this B in a Catalyst 5.9. +to add plugins like this B in a Catalyst 5.81. Please do not use this functionality in new code. =cut @@ -913,9 +935,9 @@ Please do not use this functionality in new code. sub plugin { my ( $class, $name, $plugin, @args ) = @_; - # See block comment in t/unit_core_plugin.t - $class->log->warn(qq/Adding plugin using the ->plugin method is deprecated, and will be removed in Catalyst 5.9/); - + # See block comment in t/unit_core_plugin.t + $class->log->warn(qq/Adding plugin using the ->plugin method is deprecated, and will be removed in Catalyst 5.81/); + $class->_register_plugin( $plugin, 1 ); eval { $plugin->import }; @@ -1087,7 +1109,7 @@ EOF =head2 $app->setup_finalize A hook to attach modifiers to. -Using C< after setup => sub{}; > doesn't work, because of quirky things done for plugin setup. +Using C<< after setup => sub{}; >> doesn't work, because of quirky things done for plugin setup. Also better than C< setup_finished(); >, as that is a getter method. sub setup_finalize { @@ -1202,6 +1224,38 @@ sub uri_for { $res; } +=head2 $c->uri_for_action( $path, \@captures?, @args?, \%query_values? ) + +=head2 $c->uri_for_action( $action, \@captures?, @args?, \%query_values? ) + +=over + +=item $path + +A private path to the Catalyst action you want to create a URI for. + +This is a shortcut for calling C<< $c->dispatcher->get_action_by_path($path) +>> and passing the resulting C<$action> and the remaining arguments to C<< +$c->uri_for >>. + +You can also pass in a Catalyst::Action object, in which case it is passed to +C<< $c->uri_for >>. + +=back + +=cut + +sub uri_for_action { + my ( $c, $path, @args ) = @_; + my $action = blessed($path) + ? $path + : $c->dispatcher->get_action_by_path($path); + unless (defined $action) { + croak "Can't find action for path '$path'"; + } + return $c->uri_for( $action, @args ); +} + =head2 $c->welcome_message Returns the Catalyst welcome HTML page.