diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Lib/IMPL/Web/View/TTRegistry.pm	Mon Apr 15 07:44:50 2013 +0400
@@ -0,0 +1,42 @@
+package IMPL::Web::View::TTRegistry;
+use strict;
+
+use IMPL::Const qw(:prop);
+use IMPL::declare {
+    require => {
+        TTFactory => 'IMPL::Web::View::TTFactory'        
+    },
+    base => [
+        'IMPL::Object' => undef
+    ],
+    props => [
+        loader => PROP_RW,
+        context => PROP_RW,
+        _cache => PROP_RW,
+    ]
+};
+
+sub Require {
+    my ($this,$name) = @_;
+    
+    if(my $factory = $this->_cache->{$name}) {
+        return $factory;
+    } else {
+        my $template = $this->loader->template($name)
+            or die AppException->new("Failed to load a template $name");
+         
+        $factory = TTFactory->new(
+            $template,
+            $this->context,
+            $name,
+            $this
+        );
+        
+        $this->_cache->{$name} = $factory;
+        return $factory;
+    }
+}
+
+1;
+
+__END__