« lib/Mojolicious/Plugin/Fondation/Workflow/Action/Workflow.pm
↑ Summary
blib/lib/Mojolicious/Plugin/Fondation/Workflow/Schema/Result/Workflow.pm »
| 1 | package Mojolicious::Plugin::Fondation::Workflow::Proxy; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 2 | $Mojolicious::Plugin::Fondation::Workflow::Proxy::VERSION = '0.02'; | |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use Mojo::Base -base, -signatures; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | has [qw(wf factory c type)]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # ── State accessors ────────────────────────────────────────────────── | ||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 3 | ▶ | sub state ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
state: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 3 | return $self->wf->state; | |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 0 | ▶ | sub state_label ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
state_label: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 0 | my $state_name = $self->state; | |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | my $meta = $self->_state_meta($state_name); | |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | ▶ | return $self->c->l($meta->{label} // $state_name); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$meta->{"label"} // $state_name
MC/DC0%0/2
$meta->{"label"} // $state_name
$meta->{"label"}
$state_name
Truth table0%0/3
A // B
A= $meta->{"label"}B= $state_name
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | ▶ | sub state_color ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
state_color: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | my $state_name = $self->state; | |||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | my $meta = $self->_state_meta($state_name); | |||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | return $meta->{color} // 'secondary'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$meta->{"color"} // "secondary"
MC/DC0%0/1
$meta->{"color"} // "secondary"
$meta->{"color"}
Truth table0%0/2
A
A= $meta->{"color"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | sub state_icon ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
state_icon: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | my $state_name = $self->state; | |||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | my $meta = $self->_state_meta($state_name); | |||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | return $meta->{icon}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | # Return the full fondation metadata of the current state | ||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | # (label, color, icon, parameters, plugin, description, ...) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | sub state_fondation ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
state_fondation: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | return $self->_state_meta($self->state); | |||||||||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | # ── Actions ────────────────────────────────────────────────────────── | ||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 1 | ▶ | sub actions ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
actions: called CC=11 SCAR=27.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 1 | my @action_names = $self->wf->get_current_actions; | |||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 1 | my @result; | |||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | # Stable sort: back first, then next, then everything else | ||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 1 | my %order = (back => 0, next => 1); | |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | @action_names = sort { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 1 | ▶ | ($order{$a} // 2) <=> ($order{$b} // 2) || $a cmp $b | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition42%3/7
($order{$a} // 2) <=> ($order{$b} // 2) || $a cmp $b
$order{$a} // 2
$order{$b} // 2
MC/DC0%0/2
($order{$a} // 2) <=> ($order{$b} // 2) || $a cmp $b
$order{$a}
$a cmp $b
MC/DC0%0/1
$order{$b} // 2
$order{$b}
Truth table33%1/3
A || B
A= $order{$a}B= $a cmp $b
Truth table50%1/2
A
A= $order{$b}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | } @action_names; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 1 | foreach my $name (@action_names) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 2 | ▶ | next unless $self->_action_authorized($name); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 2 | ▶ | my $meta = $self->_action_meta($name) // {}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->_action_meta($name) // {}
MC/DC0%0/1
$self->_action_meta($name) // {}
$self->_action_meta($name)
Truth table50%1/2
A
A= $self->_action_meta($name)
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | push @result, { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | label => $self->c->l($meta->{label} // $name), | ||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | color => $meta->{color} // 'primary', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | icon => $meta->{icon}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | confirm => $meta->{confirm} ? $self->c->l($meta->{confirm}) : undef, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | group => $meta->{group} // 'main', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | permission => $meta->{permission}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 2 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition42%3/7
$meta->{"label"} // $name
$meta->{"color"} // "primary"
$meta->{"group"} // "main"
MC/DC0%0/2
$meta->{"label"} // $name
$meta->{"label"}
$name
MC/DC0%0/1
$meta->{"color"} // "primary"
$meta->{"color"}
MC/DC0%0/1
$meta->{"group"} // "main"
$meta->{"group"}
Truth table33%1/3
A // B
A= $meta->{"label"}B= $name
Truth table50%1/2
A
A= $meta->{"color"}
Truth table50%1/2
A
A= $meta->{"group"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 1 | return \@result; | |||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 1 | ▶ | sub can ($self, $action_name) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
can: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 1 | my @available = $self->wf->get_current_actions; | |||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 1 | ▶ | return 0 unless grep { $_ eq $action_name } @available; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 1 | return $self->_action_authorized($action_name); | |||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | # ── Execute ────────────────────────────────────────────────────────── | ||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 2 | ▶ | sub execute ($self, $action_name, $params = {}) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
execute: called CC=6 SCAR=19.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 2 | my $c = $self->c; | |||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 2 | my $type = $self->type; | |||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 2 | my $context = $self->wf->context->param; | |||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | # Hook: before_execute | ||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 2 | $c->app->plugins->emit_hook(workflow_before_execute => $c, $type, $action_name, $context); | |||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 2 | my $old_state = $self->wf->state; | |||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 2 | my $new_state; | |||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 2 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 2 | $new_state = $self->wf->execute_action($action_name, $params); | |||||||||||||||||||||||||||||||||||||||||||||||
| 87 | # Workflow.pm 2.09 does not auto-add history during execute_action; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | # save_workflow already runs internally, but there's nothing to save | ||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | # unless we explicitly add_history first. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | $self->wf->add_history({ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | action => $action_name, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 2 | ▶ | description => $params->{comment} // '', | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition40%2/5
$params->{"comment"} // ""
$c->can("current_user") and $c->current_user
MC/DC0%0/1
$params->{"comment"} // ""
$params->{"comment"}
MC/DC0%0/2
$c->can("current_user") and $c->current_user
$c->can("current_user")
$c->current_user
Truth table50%1/2
A
A= $params->{"comment"}
Truth table33%1/3
A and B
A= $c->can("current_user")B= $c->current_user
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | state => $new_state, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | user => ($c->can('current_user') && $c->current_user) ? $c->current_user->id : 'n/a', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | workflow_id => $self->wf->id, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 2 | $self->factory->save_workflow($self->wf); | |||||||||||||||||||||||||||||||||||||||||||||||
| 98 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 2 | ▶ | if (my $err = $@) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | $c->app->plugins->emit_hook(workflow_on_error => $c, $type, $action_name, $context, $err); | |||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | die $err; | |||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | # Hook: after_execute | ||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 2 | $c->app->plugins->emit_hook(workflow_after_execute => $c, $type, $action_name, $context, $new_state); | |||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 2 | return $new_state; | |||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | # ── History ────────────────────────────────────────────────────────── | ||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 1 | ▶ | sub history ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
history: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 1 | my @records = $self->wf->get_history; | |||||||||||||||||||||||||||||||||||||||||||||||
| 114 | return [ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 1 | map { { | |||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 2 | action => $_->action, | |||||||||||||||||||||||||||||||||||||||||||||||
| 117 | description => $_->description, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | state => $_->state, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | user => $_->user, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | date => $_->date, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } } @records | ||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | # ── Workflow ID ───────────────────────────────────────────────────── | ||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 3 | ▶ | sub id ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
id: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 3 | return $self->wf->id; | |||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | # ── Internal: metadata extraction ──────────────────────────────────── | ||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 5 | ▶ | sub _workflow_config ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_workflow_config: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 5 | my $type = $self->type; | |||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 5 | ▶ | return $self->factory->{_workflow_config}{$type} // {}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->factory->{"_workflow_config"}{$type} // {}
MC/DC0%0/1
$self->factory->{"_workflow_config"}{$type} // {}
$self->factory->{"_workflow_config"}{$type}
Truth table50%1/2
A
A= $self->factory->{"_workflow_config"}{$type}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | sub _state_meta ($self, $state_name) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_state_meta: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | my $config = $self->_workflow_config; | |||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | my $states = $config->{state} // []; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$config->{"state"} // []
MC/DC0%0/1
$config->{"state"} // []
$config->{"state"}
Truth table0%0/2
A
A= $config->{"state"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | foreach my $s (@$states) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | return $s->{fondation} if $s->{name} eq $state_name; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | return {}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 5 | ▶ | sub _action_meta ($self, $action_name) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_action_meta: called CC=11 SCAR=38.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | # Look in global action config first | ||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 5 | my $config = $self->_workflow_config; | |||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 5 | ▶ | my $actions = $config->{action} // []; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$config->{"action"} // []
MC/DC0%0/1
$config->{"action"} // []
$config->{"action"}
Truth table50%1/2
A
A= $config->{"action"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 5 | foreach my $a (@$actions) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 7 | ▶ | return $a->{fondation} if $a->{name} eq $action_name && $a->{fondation}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$a->{"name"} eq $action_name and $a->{"fondation"}
MC/DC50%1/2
$a->{"name"} eq $action_name and $a->{"fondation"}
$a->{"name"} eq $action_name
$a->{"fondation"}
Truth table66%2/3
A and B
A= $a->{"name"} eq $action_nameB= $a->{"fondation"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | # Also check inline action definitions in states | ||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | my $states = $config->{state} // []; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$config->{"state"} // []
MC/DC0%0/1
$config->{"state"} // []
$config->{"state"}
Truth table0%0/2
A
A= $config->{"state"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | foreach my $s (@$states) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | my $s_actions = $s->{action} // []; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$s->{"action"} // []
MC/DC0%0/1
$s->{"action"} // []
$s->{"action"}
Truth table0%0/2
A
A= $s->{"action"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | foreach my $a (@$s_actions) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | return $a->{fondation} if $a->{name} eq $action_name && $a->{fondation}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$a->{"name"} eq $action_name and $a->{"fondation"}
MC/DC0%0/2
$a->{"name"} eq $action_name and $a->{"fondation"}
$a->{"name"} eq $action_name
$a->{"fondation"}
Truth table0%0/3
A and B
A= $a->{"name"} eq $action_nameB= $a->{"fondation"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | return {}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 3 | ▶ | sub _action_authorized ($self, $action_name) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_action_authorized: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 3 | my $meta = $self->_action_meta($action_name); | |||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 3 | my $permission = $meta->{permission}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 3 | ▶ | return 1 unless defined $permission; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 3 | my $c = $self->c; | |||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 3 | ▶ | return 1 unless $c->has_helper('check_perm'); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 3 | return $c->check_perm($permission); | |||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||