Mercurial > pub > Impl
comparison lib/IMPL/Config/Hierarchy.pm @ 413:af8d359ee4cc ref20150831
working on di container
| author | cin |
|---|---|
| date | Thu, 24 Sep 2015 12:19:30 +0300 |
| parents | 30e8c6a74937 |
| children | ec6f2d389d1e |
comparison
equal
deleted
inserted
replaced
| 412:30e8c6a74937 | 413:af8d359ee4cc |
|---|---|
| 48 return [] unless $role; | 48 return [] unless $role; |
| 49 | 49 |
| 50 my $cache = $this->{$_cache}{$role}; | 50 my $cache = $this->{$_cache}{$role}; |
| 51 | 51 |
| 52 unless ($cache) { | 52 unless ($cache) { |
| 53 $cache = {}; | 53 $cache = { $role, 0 }; |
| 54 | 54 |
| 55 my @roles = ($role); | 55 my @roles = [$role, 0]; |
| 56 | 56 |
| 57 while (my $r = shift @roles ) { | 57 while (my $r = shift @roles ) { |
| 58 next if $cache->{$r}; | 58 my ($name, $level) = @$r; |
| 59 | 59 |
| 60 $cache->{$r} = 1; | 60 $cache->{$name} = $level; |
| 61 if(my $parents = $this->{$roles}{$r}) { | 61 if(my $parents = $this->{$roles}{$name}) { |
| 62 push @roles, @$parents; | 62 foreach my $p (@$parents) { |
| 63 next if $cache{$p}; | |
| 64 push @roles, [$p, $cache{$p} = $level + 1]; | |
| 65 } | |
| 63 } | 66 } |
| 64 } | 67 } |
| 65 $this->{$_cache}{$role} = $cache; | 68 $this->{$_cache}{$role} = $cache; |
| 66 } | 69 } |
| 67 | 70 |
