| Handel documentation | Contained in the Handel distribution. |
Handel::Checkout::Plugin - Base module for Handle::Checkout plugins
package MyPackage::FaxOrder;
use Handel::Constants qw(:checkout);
use base 'Handel::Checkout::Plugin';
sub register {
my ($self, $ctx) = @_;
$ctx->add_handler(CHECKOUT_PHASE_DELIVER, \&deliver);
};
sub deliver {
my ($self, $ctx) = @_;
...
return CHECKOUT_HANDLER_OK;
};
Handel::Checkout::Plugin is the base module for all checkout pipeline plugins used in Handel::Checkout.
Returns as new Handle::Checkout::Plugin object. This method is inherited by all subclasses and called when each plugin is loaded into the checkout pipeline. There should be no need to call this method directly.
The following methods are called during various times in the checkout process. Each method receives a reference to its instance as well as reference to the current checkout process:
sub init {
my ($self, $ctx) = @_;
};
This method is called then the plugin is first created and loaded into the checkout pipeline. While a pipeline can be processed more than once, init will only be called the first time the plugin is loaded.
After a plugin is loaded, register is called so the plugin can register
itself with the various phases in the current checkout pipeline process
using add_handler in Handel::Checkout:
sub register {
my ($self, $ctx) = @_;
$ctx->add_handler(CHECKOUT_PHASE_DELIVER, \&deliver);
};
A plugin can register any number of methods with any number of phases.
Each time a checkout pipeline is processed, the setup method is called
on all registered plugins to allow each plugin to perform any
necessary preparation before its registered handler subs are called.
Each time a checkout pipeline is finished being processed, the
teardown method is called on all registered plugins to allow each plugin
to perform any cleanup it may need to do.
Returns the name of the current instance.
Christopher H. Laco
CPAN ID: CLACO
claco@chrislaco.com
http://today.icantfocus.com/blog/
| Handel documentation | Contained in the Handel distribution. |
# $Id$ package Handel::Checkout::Plugin; use strict; use warnings; BEGIN { use Handel::L10N qw/translate/; use Carp qw/cluck/; }; sub new { my ($class, $ctx) = @_; my $self = bless {}, $class; $self->init($ctx); return $self; }; sub init { return; }; sub setup { return; }; sub teardown { return; }; sub register { cluck translate('PLUGIN_HAS_NO_REGISTER'); return; }; sub name { my $self = shift; return ref $self || $self; }; 1; __END__