Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision b8388d68

Von Moritz Bunkus vor etwa 9 Jahren hinzugefügt

  • ID b8388d6875acac67b5a7d2fb0a8203d6426fea1e
  • Vorgänger 1132e5ed
  • Nachfolger 66fab876

Dispatcher: aktuellen Controller, Action, Routing-Typ in Request-Objekt speichern

Unterschiede anzeigen:

SL/Dispatcher.pm
use Encode;
use English qw(-no_match_vars);
use File::Basename;
use List::MoreUtils qw(all);
use List::MoreUtils qw(apply all);
use List::Util qw(first);
use SL::ArchiveZipFixes;
use SL::Auth;
......
$::lxdebug->log_request($routing_type, $script_name, $action);
$::request->type(lc($routing{request_type} || 'html'));
$::request->routing_type($routing{type});
$::request->controller(apply { s{.*/|\.pl$}{}g } $routing{controller});
if ($routing_type eq 'old') {
$::form->{action} = lc $::form->{action};
......
$::form->{script} = $script . $suffix;
my $actual_action = $::locale->findsub($routing{action});
$actual_action = apply { s{^action_}{} } first { m{^action_} && $::form->{$_} } keys %{ $::form } if $actual_action eq 'dispatcher';
$::request->action($actual_action);
} else {
_require_controller($script_name);
$::form->{script} = "controller.pl";
$::request->action($routing{action});
}
eval {
......
$self->{request}->Finish;
}
$::lxdebug->end_request(routing_type => $routing_type, script_name => $script_name, action => $action);
$::lxdebug->end_request;
# cleanup
$::auth->save_session;
SL/LXDebug.pm
}
sub end_request {
my ($self, %params) = @_;
my ($self) = @_;
return 1 unless want_request_timer();
$self->_write("time", sprintf('%f (%s/%s)', $self->get_request_time, $params{script_name}, $params{action}));
$self->_write("time", $::request ? sprintf('%f (%s/%s)', $self->get_request_time, $::request->controller, $::request->action) : sprintf('%f', $self->get_request_time));
$self->{calldepth} = 0;
}
SL/Request.pm
use Rose::Object::MakeMethods::Generic
(
scalar => [ qw(applying_database_upgrades) ],
scalar => [ qw(applying_database_upgrades routing_type controller action) ],
'scalar --get_set_init' => [ qw(cgi layout presenter is_ajax type) ],
);
......
Returns the requested content type (either C<html>, C<js> or C<json>).
=item C<controller>
Returns the name of the current controller. This is either the base
name of a script in C<bin/mozilla> (e.g. C<oe>; for the old routing
type) or the base name of one of the packages in C<SL/Controller>
(e.g. C<BackgroundJob>; for the new controller routing type).
=item C<action>
Returns the name of the current action.
=item C<routing_type>
Returns the routing type. This depends on the requested controller. It
can be either C<old> for one of the scripts in C<bin/mozilla> or
C<controller> for one of the new controllers in C<SL/Controller>.
=item C<layout>
Set and retrieve the layout object for the current request. Must be an instance

Auch abrufbar als: Unified diff