Catalyst-Plugin-ForwardChained

 view release on metacpan or  search on metacpan

lib/Catalyst/Plugin/ForwardChained.pm  view on Meta::CPAN

This is a hackaround, not a clean solution.

Experimental.

=head1 SYNOPSIS

    # In your application class 
    use Catalyst qw/ ForwardChained /;
    
    # ... somwhere else:
    $c->forward_to_chained( [ qw/ chained endpoint /, [ qw/ args / ] );
    $c->forward_to_chained( 'chained/endpoint', [ qw/ args / ] );


=head2 Example 1

Having some controller:

    package MyApp::Controller::Test;
    
    # ..
    # to be clear :

lib/Catalyst/Plugin/ForwardChained.pm  view on Meta::CPAN

use warnings;

use vars qw/ $VERSION /;
use Catalyst::Exception;

$VERSION = '0.03';


=head2 forward_to_chained

forwards to a certain chained action endpoint ..

    $c->forward_to_chained( "some/path", [ qw/ arg1 arg2 arg3 / ] );
    $c->forward_to_chained( [qw/ some path /], [ qw/ arg1 arg2 arg3 / ] );

=cut

sub forward_to_chained {
    my ( $c, $chained_ref, $args_ref ) = @_;
    
    

lib/Catalyst/Plugin/ForwardChained.pm  view on Meta::CPAN

    #$c->dispatcher->dispatch( $c );
    
    # .. and set orig captures back
    $c->req->captures( $captures_ref );
    
    return ;
}



=head2 get_chained_action_endpoints

returns array or arrayref of endpoints.. to help you find the one you need

    my @endpoints = $c->get_chained_action_endpoints;
    my $endpoints_ref = $c->get_chained_action_endpoints;

=cut

sub get_chained_action_endpoints {
    my ( $c ) = @_;
    
    my $actions_ref = $c->dispatcher->action_hash;
    my @endpoints   = 
        sort
        grep { 
            defined $actions_ref->{ $_ }->{ attributes } && 
            ref $actions_ref->{ $_ }->{ attributes }->{ Chained } 
        } 
        grep { ! /(?:^|\/)_[A-Z]+$/ } keys %{ $actions_ref }
    ;
    
    return wantarray ? @endpoints : \@endpoints;
}







=head1 AUTHOR



( run in 0.248 second using v1.01-cache-2.11-cpan-27979f6cc8f )