NAME

OpenInteract2::Setup::ReadActionTable - Reads actions from all packages and stores them in context

SYNOPSIS

my $setup = OpenInteract2::Setup->new( 'read action table' );
$setup->run();

my $action_table = CTX->action_table;
while ( my ( $name, $action_info ) = each ${ $action_table } ) {
    print "Action $name has data:\n", Dumper( $action_info ), "\n";
}

DESCRIPTION

This setup action creates the action table. The action table holds all configuration data for all actions and once it's created is stored in the context. The action table is a hash with action names as keys and their configuration data as a hashref of values.

To do this, first we:

  • Asks each package for its action file(s)

  • Reads in all actions from each file given.

    If we find an action name collision the last one read in wins, but we log an 'error' message stating which one was overwritten and which won.

For each action read in we do the following:

  • Store the action name in the property 'name'

  • Add to the action the package name ('package_name') and version ('package_version') it came from

  • Add to the action the path to the configuration file sourcing it ('package_config_file').

Once we read in all actions we:

  • Apply any global override rules.

  • Notify any configuration observers (see OpenInteract2::Config::Initializer) with an observation of type 'action' and the action configuration hashref as arguments.

  • Assign the full set of action data to the context (using action_table()).

Example, given a single action file with two actions:

action.ini
----------------------------------------
[user]
class        = OpenInteract2::Handler::User
security     = no
default_task = search_form

[newuser]
class        = OpenInteract2::Handler::NewUser
error        = OpenInteract2::Error::User
security     = no
default_task = show
----------------------------------------

This would result in an action table:

user => {
   class                => 'OpenInteract2::Handler::User',
   security             => 'no',
   default_task         => 'search_form',
   name                 => 'user',
   package_name         => 'base_user',
   package_version      => 1.45,
   package_config_file  => '/home/httpd/mysite/pkg/base_user-1.45/conf/action.ini',
},
newuser => {
   class                => 'OpenInteract2::Handler::NewUser',
   error                => 'OpenInteract2::Error::User',
   security             => 'no',
   default_task         => 'show'
   name                 => 'newuser',
   package_name         => 'base_user',
   package_version      => 1.45,
   package_config_file  => '/home/httpd/mysite/pkg/base_user-1.45/conf/action.ini',
   author               => 'Chris Winters E<lt>chris@cwinters.comE<gt>',
},

Setup Metadata

name - 'read action table'

dependencies - 'read packages'

SEE ALSO

OpenInteract2::Setup

OpenInteract2::Action

COPYRIGHT

Copyright (c) 2005 Chris Winters. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHORS

Chris Winters <chris@cwinters.com>