change AssetHelpers to have short IDs instead of class names

This will make better code reuse: The Asset Manager will instead
call the AssetHelper with the id of "cut" or "copy" to get the
correct operation.
This commit is contained in:
Doug Bell 2011-02-25 15:44:06 -06:00
parent f249070c50
commit b9e879b7aa
22 changed files with 156 additions and 115 deletions

View file

@ -83,14 +83,20 @@ sub handler {
if ( $session->form->get("op") eq "assetHelper" ) {
# Load and run the requested asset helper www_ method
my $class = $session->form->get('className');
WebGUI::Pluggable::load( $class );
my $method = $session->form->get('method') || "view";
my $assetId = $session->form->get('assetId');
my $asset = WebGUI::Asset->newById( $session, $assetId );
if ( $class->can( "www_" . $method ) ) {
return $class->can( "www_" . $method )->( $class, $asset );
my $helperId = $session->form->get('helperId');
my $class = $asset->getHelpers->{ $helperId }->{ className };
WebGUI::Pluggable::load( $class );
my $helper = $class->new( id => $helperId, session => $session );
my $method = $session->form->get('method') || "view";
if ( $helper->can( "www_" . $method ) ) {
return $helper->can( "www_" . $method )->( $helper, $asset );
}
else {
$session->log->error( sprintf 'Invalid asset helper "%s" calling method "%s"', $helperId, $method );
}
}