110
|
1 package IMPL::Web::QueryHandler::UrlController;
|
97
|
2 use strict;
|
|
3 use base qw(IMPL::Web::QueryHandler);
|
|
4
|
|
5 use IMPL::Class::Property;
|
|
6 use IMPL::Exception;
|
139
|
7 use Carp qw(croak);
|
97
|
8
|
|
9 BEGIN {
|
|
10 public property namespace => prop_all;
|
|
11 }
|
|
12
|
|
13 __PACKAGE__->PassThroughArgs;
|
|
14
|
|
15 sub Process {
|
|
16 my ($this,$action,$nextHandler) = @_;
|
|
17
|
|
18 my $namespace = $this->namespace || $action->application->type;
|
|
19
|
|
20 my @target = grep $_, split /\//, ($ENV{PATH_INFO} || '') or die new IMPL::Exception("No target specified");
|
|
21
|
|
22 my $method = pop @target;
|
|
23 $method =~ s/\.\w+$//;
|
|
24
|
|
25 my $module = join '::',$namespace,@target;
|
|
26
|
139
|
27 eval "require $module; 1;" unless eval{ $module->can('InvokeAction'); };
|
|
28 if (my $err = $@ ) {
|
|
29 die new IMPL::Exception("Failed to load module",$module,$err);
|
|
30 }
|
97
|
31
|
|
32 if(UNIVERSAL::can($module,'InvokeAction')) {
|
|
33 $module->InvokeAction($method,$action);
|
|
34 } else {
|
|
35 die new IMPL::InvalidOperationException("Failed to invoke action",$ENV{PATH_INFO},$module,$method);
|
|
36 }
|
|
37 }
|
|
38
|
110
|
39 1;
|
|
40
|
|
41 __END__
|
|
42
|
|
43 =pod
|
|
44
|
|
45 =head1 NAME
|
|
46
|
|
47 C<IMPL::Web::QueryHandler::UrlController> - вызов метода на основе <url> запроса.
|
|
48
|
|
49 =head1 DESCRIPTION
|
|
50
|
|
51 Использует переменную C<$ENV{PATH_INFO}> для получения имени и метода модуля.
|
|
52
|
|
53 =cut |