Mercurial > pub > Impl
annotate Lib/IMPL/Web/View/TTRegistry.pm @ 319:d485467eca92
small fixes
author | cin |
---|---|
date | Wed, 15 May 2013 02:00:42 +0400 |
parents | 5e4e7c8fbca1 |
children | 72799d1211c5 |
rev | line source |
---|---|
304
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
1 package IMPL::Web::View::TTRegistry; |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
2 use strict; |
305 | 3 use mro; |
304
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
4 |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
5 use IMPL::Const qw(:prop); |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
6 use IMPL::declare { |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
7 require => { |
309 | 8 TTFactory => 'IMPL::Web::View::TTFactory', |
9 TTControl => '-IMPL::Web::View::TTControl' | |
304
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
10 }, |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
11 base => [ |
305 | 12 'IMPL::Object' => undef, |
13 'IMPL::Object::Disposable' => undef | |
304
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
14 ], |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
15 props => [ |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
16 loader => PROP_RW, |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
17 context => PROP_RW, |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
18 _cache => PROP_RW, |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
19 ] |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
20 }; |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
21 |
305 | 22 sub CTOR { |
23 my ($this,$loader,$context) = @_; | |
24 | |
25 $this->loader($loader); | |
26 $this->context($context); | |
27 $this->_cache({}); | |
28 } | |
29 | |
304
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
30 sub Require { |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
31 my ($this,$name) = @_; |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
32 |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
33 if(my $factory = $this->_cache->{$name}) { |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
34 return $factory; |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
35 } else { |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
36 my $template = $this->loader->template($name) |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
37 or die AppException->new("Failed to load a template $name"); |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
38 |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
39 $factory = TTFactory->new( |
309 | 40 $template->class || TTControl, |
304
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
41 $template, |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
42 $this->context, |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
43 $name, |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
44 $this |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
45 ); |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
46 |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
47 $this->_cache->{$name} = $factory; |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
48 return $factory; |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
49 } |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
50 } |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
51 |
305 | 52 sub Dispose { |
53 my ($this) = @_; | |
54 | |
55 $this->_cache(undef); | |
56 $this->context(undef); | |
57 $this->loader(undef); | |
58 | |
59 $this->next::method(); | |
60 } | |
61 | |
304
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
62 1; |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
63 |
2ff513227cb4
*TTView: refactoring. Added control registry for the document.
cin
parents:
diff
changeset
|
64 __END__ |
305 | 65 |
66 =pod | |
67 | |
68 =head1 NAME | |
69 | |
70 C<IMPL::Web::View::Registry> - реестр шаблонов документа. | |
71 | |
72 =head1 DESCRIPTION | |
73 | |
74 Используется для реализации функции C<require> внутри шаблонов. | |
75 | |
76 | |
77 | |
78 =cut |