annotate Lib/IMPL/Web/View/TTRegistry.pm @ 304:2ff513227cb4

*TTView: refactoring. Added control registry for the document.
author cin
date Mon, 15 Apr 2013 07:44:50 +0400
parents
children b5d5793f348e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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;
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
3
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
4 use IMPL::Const qw(:prop);
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
5 use IMPL::declare {
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
6 require => {
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
7 TTFactory => 'IMPL::Web::View::TTFactory'
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
8 },
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
9 base => [
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
10 'IMPL::Object' => undef
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
11 ],
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
12 props => [
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
13 loader => PROP_RW,
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
14 context => PROP_RW,
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
15 _cache => PROP_RW,
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
16 ]
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
17 };
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
18
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
19 sub Require {
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
20 my ($this,$name) = @_;
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
21
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
22 if(my $factory = $this->_cache->{$name}) {
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
23 return $factory;
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
24 } else {
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
25 my $template = $this->loader->template($name)
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
26 or die AppException->new("Failed to load a template $name");
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
27
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
28 $factory = TTFactory->new(
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
29 $template,
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
30 $this->context,
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
31 $name,
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
32 $this
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
33 );
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
34
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
35 $this->_cache->{$name} = $factory;
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
36 return $factory;
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
37 }
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
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
40 1;
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
41
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
42 __END__