diff 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
line wrap: on
line diff
--- a/Lib/IMPL/Web/View/TTFactory.pm	Mon Mar 11 01:22:24 2013 +0400
+++ b/Lib/IMPL/Web/View/TTFactory.pm	Tue Mar 19 02:02:37 2013 +0400
@@ -10,8 +10,13 @@
 
 use IMPL::Const qw(:prop);
 use IMPL::declare {
+    require => {
+        Loader => 'IMPL::Code::Loader'
+    },
     base => [
-        'IMPL::Object::Factory' => '@_'
+        'IMPL::Object::Factory' => sub {
+            shift->class || 'IMPL::Web::View::TTControl'
+        }
     ],
     props => [
         template => PROP_RW,
@@ -23,10 +28,13 @@
 };
 
 sub CTOR {
-    my ($this,$factory,$template,$context,$base,$require) = @_;
+    my ($this,$template,$context,$base,$require) = @_;
     
     die IMPL::ArgumentException("A template is required") unless $template;
     
+    Loader->safe->Require($this->factory)
+        if $this->factory and not ref $this->factory;
+    
     $context ||= new Template::Context();
     
     $this->template($template);
@@ -36,12 +44,6 @@
     $this->require($require);
 }
 
-our %CTOR = (
-    'IMPL::Object::Factory' => sub {
-        $_[0]
-    }
-);
-
 sub MergeParameters {
     my ($this,$name,$refProps) = @_;
     
@@ -50,6 +52,8 @@
         $name = (ref $refProps eq 'HASH' and ($refProps->{name} || $refProps->{id})) || '*anonymous*';
     }
     
+    $refProps->{factory} = $this;
+    
     my $base = $this->base;
     
     $this->context->localise();