lib/Rapi/Blog/Template/Dispatcher/NotFound.pm untested

filter: Statementstmt 0.0% 0 / 35 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 59 CC 2 SCAR 10.3
CC
2
Cov
0%
resolved
6.0
rank
2.0
BEGIN
2.0
CRAP 2.8
1 package Rapi::Blog::Template::Dispatcher::NotFound;
2 use strict;
3 use warnings;
4
5 use RapidApp::Util qw(:all);
6 use Rapi::Blog::Util;
7 use List::Util;
8
9 use Moo;
10 extends 'Rapi::Blog::Template::Dispatcher';
11
12 use Types::Standard ':all';
13
14
15 sub rank { 20 }
16
17 has 'exist_in_Provider', is => 'ro', init_arg => undef, lazy => 1, default => sub {
18 my $self = shift;
19 $self->AccessStore->Controller->get_Provider->template_exists_locally($self->path)
20 }, isa => Bool;
21
22
23 sub resolved {
24 my $self = shift;
25 $self->valid_not_found_tpl && ! $self->exist_in_Provider ? $self : $self->_factory_for('Unclaimed')
26 }
27
28
29 has '+maybe_psgi_response', default => sub {
30 my $self = shift;
31
32 # Should be redundant since we already checked this when we claimed the path
33 my $tpl = $self->valid_not_found_tpl or die "unexpected error, we no longer have a valid_not_found_template";
34
35 # Make sure the same Scaffold handles the 404 not found:
36 $self->ctx->stash->{rapi_blog_only_scaffold_uuid} = $self->Scaffold->uuid;
37
38 # Needed to prevent deep recursion when the not found template is private:
39 $self->ctx->stash->{rapi_blog_detach_404_template}++ and return undef;
40
41 $self->ctx->res->status(404);
42 $self->ctx->detach( '/rapidapp/template/view', [$tpl] )
43
44 };
45
46
47
48
49
50
51
52 1;