diff Lib/IMPL/Web/View/TTFactory.pm @ 300:bf3af33b9003

sync
author cin
date Fri, 22 Mar 2013 01:05:11 +0400
parents 78f767765706
children aeeb57a12046
line wrap: on
line diff
--- a/Lib/IMPL/Web/View/TTFactory.pm	Thu Mar 21 16:00:09 2013 +0400
+++ b/Lib/IMPL/Web/View/TTFactory.pm	Fri Mar 22 01:05:11 2013 +0400
@@ -15,67 +15,56 @@
     },
     base => [
         'IMPL::Object::Factory' => sub {
-            shift->class || 'IMPL::Web::View::TTControl'
+            shift;
         }
     ],
     props => [
         template => PROP_RW,
         context => PROP_RW,
         instances => PROP_RW,
-        base => PROP_RW,
+        baseLocation => PROP_RW,
         require => PROP_RO
     ]
 };
 
 sub CTOR {
-    my ($this,$template,$context,$base,$require) = @_;
+    my ($this,$class,$template,$context,$baseLocation,$require) = @_;
     
     die IMPL::ArgumentException("A template is required") unless $template;
     
-    Loader->safe->Require($this->factory)
-        if $this->factory and not ref $this->factory;
+    Loader->safe->Require($class)
+        if $class and not ref $class;
     
     $context ||= new Template::Context();
     
     $this->template($template);
     $this->context($context);
-    $this->base($base);
+    $this->baseLocation($baseLocation);
     $this->instances(0);
     $this->require($require);
 }
 
 sub MergeParameters {
-    my ($this,$name,$refProps) = @_;
-    
-    if (ref $name) {
-        $refProps = $name;
-        $name = (ref $refProps eq 'HASH' and ($refProps->{name} || $refProps->{id})) || '*anonymous*';
-    }
+    my ($this,$refProps) = @_;
     
     $refProps->{factory} = $this;
     
-    my $base = $this->base;
-    
-    $this->context->localise();
+    my $baseLocation = $this->baseLocation;
     
-    my $ctx = _clone_context($this->context);
+    my $ctx = $this->CloneContext();
     
-    $this->context->delocalise();
-    
-    my $stash = $ctx->stash;
     my $require = $this->require;
     
-    
-    $stash->update({
+    $ctx->stash->update({
         require => sub {
             my ($module) = @_;
             
-            $module =~ s/^\.\//$base\//;
+            $module =~ s/^\.\//$baseLocation\//;
             return $require->($module);
         }        
     });
     
-    return ($name, $this->template, $ctx, $refProps);
+    return ($this->template, $ctx, $refProps);
 }
 
 sub CreateObject {
@@ -102,10 +91,16 @@
     return $instance;
 }
 
-sub _clone_context {
-    my $args = { %{shift || {}} };
+sub CloneContext {
+    my ($this) = @_;
+    
+    $this->context->localise();
+    
+    my $args = { %{$this->context} };
     delete $args->{CONFIG};
     
+    $this->context->delocalise();
+    
     return Template::Context->new($args);
 }