comparison Lib/IMPL/Web/View/TTFactory.pm @ 298:78f767765706

TT view refactoring
author cin
date Tue, 19 Mar 2013 02:02:37 +0400
parents 86ff93b34f2a
children bf3af33b9003
comparison
equal deleted inserted replaced
297:52aae1b85084 298:78f767765706
8 use Scalar::Util qw(weaken); 8 use Scalar::Util qw(weaken);
9 9
10 10
11 use IMPL::Const qw(:prop); 11 use IMPL::Const qw(:prop);
12 use IMPL::declare { 12 use IMPL::declare {
13 require => {
14 Loader => 'IMPL::Code::Loader'
15 },
13 base => [ 16 base => [
14 'IMPL::Object::Factory' => '@_' 17 'IMPL::Object::Factory' => sub {
18 shift->class || 'IMPL::Web::View::TTControl'
19 }
15 ], 20 ],
16 props => [ 21 props => [
17 template => PROP_RW, 22 template => PROP_RW,
18 context => PROP_RW, 23 context => PROP_RW,
19 instances => PROP_RW, 24 instances => PROP_RW,
21 require => PROP_RO 26 require => PROP_RO
22 ] 27 ]
23 }; 28 };
24 29
25 sub CTOR { 30 sub CTOR {
26 my ($this,$factory,$template,$context,$base,$require) = @_; 31 my ($this,$template,$context,$base,$require) = @_;
27 32
28 die IMPL::ArgumentException("A template is required") unless $template; 33 die IMPL::ArgumentException("A template is required") unless $template;
34
35 Loader->safe->Require($this->factory)
36 if $this->factory and not ref $this->factory;
29 37
30 $context ||= new Template::Context(); 38 $context ||= new Template::Context();
31 39
32 $this->template($template); 40 $this->template($template);
33 $this->context($context); 41 $this->context($context);
34 $this->base($base); 42 $this->base($base);
35 $this->instances(0); 43 $this->instances(0);
36 $this->require($require); 44 $this->require($require);
37 } 45 }
38 46
39 our %CTOR = (
40 'IMPL::Object::Factory' => sub {
41 $_[0]
42 }
43 );
44
45 sub MergeParameters { 47 sub MergeParameters {
46 my ($this,$name,$refProps) = @_; 48 my ($this,$name,$refProps) = @_;
47 49
48 if (ref $name) { 50 if (ref $name) {
49 $refProps = $name; 51 $refProps = $name;
50 $name = (ref $refProps eq 'HASH' and ($refProps->{name} || $refProps->{id})) || '*anonymous*'; 52 $name = (ref $refProps eq 'HASH' and ($refProps->{name} || $refProps->{id})) || '*anonymous*';
51 } 53 }
54
55 $refProps->{factory} = $this;
52 56
53 my $base = $this->base; 57 my $base = $this->base;
54 58
55 $this->context->localise(); 59 $this->context->localise();
56 60