« blib/lib/Mojolicious/Plugin/Fondation/Perm/Controller/Perm.pm
↑ Summary
lib/Mojolicious/Plugin/Fondation/Perm/Schema/Result/GroupPerm.pm »
| 1 | package Mojolicious::Plugin::Fondation::Perm; | ||||||||||
| 2 | 1 | $Mojolicious::Plugin::Fondation::Perm::VERSION = '0.04'; | |||||||||
| 3 | 1 | ▶ | use Mojo::Base 'Mojolicious::Plugin', -signatures; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use DBIx::Class::Relationship::ManyToMany::Async; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | # ABSTRACT: Permission management plugin for Fondation | ||||||||||
| 7 | |||||||||||
| 8 | 1 | ▶ | sub fondation_meta { | ||||||||
|
Subroutine
fondation_meta: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 9 | return { | ||||||||||
| 10 | 1 | dependencies => [ | |||||||||
| 11 | 'Fondation::Model::DBIx::Async', | ||||||||||
| 12 | 'Fondation::MigrationDBIx', | ||||||||||
| 13 | ], | ||||||||||
| 14 | defaults => { | ||||||||||
| 15 | title => 'Permission Management', | ||||||||||
| 16 | openapi_exclude => ['GroupPerm'], | ||||||||||
| 17 | models => { | ||||||||||
| 18 | perm => { | ||||||||||
| 19 | source => 'Perm', | ||||||||||
| 20 | backend => undef, # must be set in app config | ||||||||||
| 21 | }, | ||||||||||
| 22 | group_perm => { | ||||||||||
| 23 | source => 'GroupPerm', | ||||||||||
| 24 | backend => undef, # must be set in app config | ||||||||||
| 25 | }, | ||||||||||
| 26 | }, | ||||||||||
| 27 | }, | ||||||||||
| 28 | }; | ||||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | 1 | ▶ | sub register ($self, $app, $conf) { | ||||||||
|
Subroutine
register: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 32 | 1 | return $self; | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 1 | ▶ | sub fondation_finalyze ($self, $app, $long_name) { | ||||||||
|
Subroutine
fondation_finalyze: called CC=2 SCAR=9.9
Pod
undocumented
| |||||||||||
| 36 | 1 | my $registry = $app->fondation->registry; | |||||||||
| 37 | |||||||||||
| 38 | # Only establish group↔perm relation if Group plugin is loaded | ||||||||||
| 39 | 1 | ▶ | if ($registry->{'Mojolicious::Plugin::Fondation::Group'}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | # Underlying has_many / belongs_to | ||||||||||
| 41 | 0 | Mojolicious::Plugin::Fondation::Group::Schema::Result::Group->has_many( | |||||||||
| 42 | 'group_perm', | ||||||||||
| 43 | 'Mojolicious::Plugin::Fondation::Perm::Schema::Result::GroupPerm', | ||||||||||
| 44 | 'group_id', | ||||||||||
| 45 | ); | ||||||||||
| 46 | 0 | Mojolicious::Plugin::Fondation::Perm::Schema::Result::GroupPerm->belongs_to( | |||||||||
| 47 | 'group', | ||||||||||
| 48 | 'Mojolicious::Plugin::Fondation::Group::Schema::Result::Group', | ||||||||||
| 49 | { 'foreign.id' => 'self.group_id' }, | ||||||||||
| 50 | ); | ||||||||||
| 51 | |||||||||||
| 52 | 0 | many_to_many_async('Mojolicious::Plugin::Fondation::Perm::Schema::Result::Perm', 'groups', 'group_perm', 'group'); | |||||||||
| 53 | 0 | many_to_many_async('Mojolicious::Plugin::Fondation::Group::Schema::Result::Group', 'perms', 'group_perm', 'perm'); | |||||||||
| 54 | } | ||||||||||
| 55 | |||||||||||
| 56 | 1 | return 1; | |||||||||
| 57 | } | ||||||||||
| 58 | |||||||||||
| 59 | 1 | 1; | |||||||||
| 60 | |||||||||||
| 61 | __END__ | ||||||||||