This file is indexed.

/usr/share/perl5/HTML/Mason/Plugin.pm is in libhtml-mason-perl 1:1.52-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
package HTML::Mason::Plugin;
{
  $HTML::Mason::Plugin::VERSION = '1.52';
}

use strict;
use warnings;

sub new {
    my $class = shift;
    bless { @_ }, $class;
}

sub start_request_hook {
    # my ($self, $context) = @_;
    # $context has: request, args
}

sub end_request_hook {
    # my ($self, $context) = @_;
    # $context has: request, args, output, wantarray, result, error
}

sub start_component_hook {
    # my ($self, $context) = @_;
    # $context has: request, comp, args
}

sub end_component_hook {
    # my ($self, $context) = @_;
    # $context has: request, comp, args, wantarray, result, error
}

1;

__END__

=pod

=head1 NAME

HTML::Mason::Plugin - Plugin Base class for Mason

=head1 VERSION

version 1.52

=head1 DESCRIPTION

Use a Mason plugin to have actions occur at the beginning or end of
requests or components. Plugins are activated by passing L<plugins|HTML::Mason::Params/plugins> in
the interpreter or request object. Each plugin in the list can be
specified as a class name (in which case the plugin object is created
once for each request) or as an actual object of the plugin class.

If your plugin can be configured, place the configuration in class
variables - for example,

    $MasonX::Plugin::Timer::Units = 'seconds';

These can be set either from httpd.conf via PerlSetVar
directives, or in perl directly from a handler.pl file.

=head1 SYNOPIS

   package MasonX::Plugin::Timer;
   use base qw(HTML::Mason::Plugin);
   use Time::HiRes;

   sub start_component_hook {
       my ($self, $context) = @_;
       push @{$self->{ timers }}, Time::HiRes::time;
   }

   sub end_component_hook {
       my ($self, $context) = @_;
       my $elapsed = Time::HiRes::time - pop @{$self->{ timers }};
       printf STDERR "Component '%s' took %.1f seconds\n",
           $context->comp->title, $elapsed;
   }

   1;

=head1 PLUGIN HOOKS

A plugin class defines one or more of the following hooks (methods):
I<start_request_hook>, I<end_request_hook>, I<start_component_hook>,
and I<end_component_hook>.

Every hook receives two arguments: the plugin object itself,
and a context object with various methods.

=over

=item start_request_hook

C<start_request_hook> is called before the Mason request begins
execution.  Its context has the following read-only methods:

    request # the current request ($m)
    args    # arguments the request was called with

When called in scalar context, I<args> returns a list reference which
may be modified to change or add to the arguments passed to the first
component. When called in list context, I<args> returns a list (which
may be assigned to a hash).

Note that subrequests (see
L<HTML::Mason::Request|HTML::Mason::Request> will create a new plugin
object and execute this code again; you can skip your code for
subrequests by checking C<is_subrequest> on I<request>. e.g.

   sub start_request_hook {
       my ($self, $context) = @_;
       unless ($context->request->is_subrequest()) {
           # perform hook action
       }
   }

Currently, this hook is called before any information about the
requested component is available, so you cannot call methods like
C<base_comp()> or C<request_args()> on the Request object.

=item end_request_hook

C<end_request_hook> is called before the Mason request
exits. Its context has the following read-only methods:

    request     # the current request ($m)
    args        # arguments the request was called with
    output      # reference to the contents of the output buffer
    wantarray   # value of wantarray the request was called with
    result      # arrayref of value(s) that the request is about to return
    error       # reference to error, if any, that the request is about to throw

When called in scalar context, I<args> returns a list reference; when
called in list context, it returns a list (which may be assigned to a
hash).

I<result> always contains an array ref; if I<wantarray> is 0, the
return value is the the first element of that array. The plugin may
modify I<output> to affect what the request outputs, and 
I<result> and I<error> to affect what the request returns.

=item start_component_hook

C<start_component_hook> is called before a component begins
executing. Its context has the following read-only methods:

    request     # the current request ($m)
    comp        # the component object
    args        # arrayref of arguments the component was called with

The plugin may NOT modify I<args> currently.

=item end_component_hook

C<end_component_hook()> is called after a component has
completed. Its context has the following read-only methods:

    request     # the current request ($m)
    comp        # the component object
    args        # arrayref of arguments the component was called with
    wantarray   # value of wantarray the component was called with
    result      # arrayref of value(s) that the component is about to return
    error       # reference to error, if any, that the component is about to throw

I<result> always contains an array ref; if I<wantarray>
is 0, the return value is the first element of that array.  The plugin
may modify both I<result> and I<error> to affect how the request
returns.

It would be desirable for this hook to have access to the component's
output as well as its return value, but this is currently impossible
because output from multiple components combine into a single buffer.

=back

=head1 WARNINGS

Do not keep an unweakened reference to a request or component object
in your plugin object, or you will create a nasty circular reference.

=head1 SEE ALSO

L<Mason|Mason>

=head1 AUTHORS

=over 4

=item *

Jonathan Swartz <swartz@pobox.com>

=item *

Dave Rolsky <autarch@urth.org>

=item *

Ken Williams <ken@mathforum.org>

=back

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2012 by Jonathan Swartz.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut