2012-06-20 11 views

cevap

8

:CaptureArgs(N) maçlar azından N args sola orada eğer. Terminal olmayan Zincirleme işleyicileri için kullanılır. sol tam olarak N args varsa

:Args(N) sadece eşleşir. Örneğin

,

sub catalog : Chained : CaptureArgs(1) { 
    my ($self, $c, $arg) = @_; 
    ... 
} 

sub item : Chained('catalog') : Args(2) { 
    my ($self, $c, $arg1, $arg2) = @_; 
    ... 
} 

stoktaki

/catalog/*/item/*/* 
+0

, teşekkürler. – friedo

5

CaptureArgs Catalyst Zincirli yöntemlerde kullanılır.

Args zincirli yöntemin sonuna işaret eder. ex

:

sub base_method : Chained('/') :PathPart("account") :CaptureArgs(0) 
{ 

} 
sub after_base : Chained('base_method') :PathPart("org") :CaptureArgs(2) 
{ 

} 
sub base_end : Chained('after_base') :PathPart("edit") :Args(1) 
{ 

} 

zincirleme yöntemlerle Üstü /account/org/*/*/edit/* maç.

Burada, zincirin son yöntemizincirinin sonu işaretidir. Args zincirinin sonuna işaretlemek için kullanılır. Bu, zincirin hala devam ettiği anlamına gelen CaptureArgs kullanılır.

Args

da yönteme argüman belirlenmesi için katalizörün diğer yöntemler kullanılır. cpan Catalyst::DispatchType::Chained den Ayrıca

: güzel o kadar temizler

The endpoint of the chain specifies how many arguments it 
gets through the Args attribute. :Args(0) would be none at all, 
:Args without an integer would be unlimited. The path parts that 
aren't endpoints are using CaptureArgs to specify how many parameters 
they expect to receive. 
İlgili konular