Artifact 81a5706a2a15ed05fc121d0409fb9658c83b845e:
- File
library/ATWF/Application/Resources/Resourcebase.tcl
— part of check-in
[912787020c]
at
2010-11-29 19:48:59
on branch trunk
—
-- Des for renaming und die folgenden Zeilen werden ignoriert --
M Application/Bootstraps/Bootstrapper.tcl M Application/Bootstraps/BootstrapBase.tcl M Application/Bootstraps/ResourceBootstrapper.tcl M Application/Bootstraps/Bootstrap.tcl M Application/Modules/Autoloader.tcl M Application/Modules/Bootstrap.tcl M Application/Resources/Locale.tcl M Application/Resources/Navigation.tcl M Application/Resources/Router.tcl M Application/Resources/Resourcebase.tcl M Application/Resources/Session.tcl M Application/Resources/Db.tcl M Application/Resources/Resource.tcl M Application/Resources/Modules.tcl M Application/Resources/View.tcl M Application/Resources/Frontcontroller.tcl M Application/Resources/Layout.tcl M Application/Resources/Translate.tcl
git-svn-id: https://atwf.svn.sourceforge.net/svnroot/atwf@451 3ddb7fe1-eb8e-4980-8f37-d9e37380b5db (user: arnulf@wiedemann-pri.de size: 4489)
- File
library/ATWF/Applications/Resources/Resourcebase.tcl
— part of check-in
[5cea8e4c27]
at
2010-11-29 19:50:35
on branch trunk
— renaming
git-svn-id: https://atwf.svn.sourceforge.net/svnroot/atwf@452 3ddb7fe1-eb8e-4980-8f37-d9e37380b5db (user: arnulf@wiedemann-pri.de size: 4489)
#************************************************************************* #* #* $Author$ #* $URL$ #* #* This module has been implemented in Tcl by using mostly the corresponding module #* Application/Resource/ResourceAbstract.php from the Zend framework see: http://framework.zend.com #* So the ideas are also copyrighted by Zend Technologies USA Inc. (http://www.zend.com) #* The implementation in Tcl uses ditcs and lists instead of php arrays. #* #* The Contents of this file are made available subject to the terms of #* the following license see @license below #* #* Copyright 2010 Arnulf Wiedemann #* #* Author: Arnulf Wiedemann #* #* Contributor(s): #* # @category ATWF # @package library # @subpackage Applications::Resources::Resourcebase # @license BSD License (see file license.terms in the source top drectory) # @version $Id$ #************************************************************************/ namespace eval ::ATWF { ::itcl::extendedclass Applications::Resources::Resourcebase { inherit ::ATWF::Base # Parent bootstrap # # @variable Application_Bootstrap_Bootstrapper protected variable _bootstrap [list] # Options for the resource # # @variable array protected variable _options [list] # Option keys to skip when calling setOptions() # # @variable list protected variable _skipOptions [list options config] constructor {{options {}}} {} public method setOptions {options} public method getOptions {} public method mergeOptions {dict1 {dict2 {}}} public method setBootstrap {bootstrap} public method getBootstrap {} } #============================ constructor ==================================== # Create a instance with options # # @param mixed $options ::itcl::body Applications::Resources::Resourcebase::constructor {{options {}}} { if {[llength $options] >= 2} { setOptions $options } else { if {[::itcl::is object -class ::ATWF::Config $options]} { setOptions [$options toList] } } } #============================ setOptions ===================================== # Set options from array # # @param array $options Configuration for resource # @return Applications::Resources::Resourcebase ::itcl::body Applications::Resources::Resourcebase::setOptions {options} { foreach {key value} $options { if {[lsearch $_skipOptions [string tolower $key]] >= 0} { continue } set method "set[string tolower $key]" if {[methodExists $this $method real_method]} { $real_method $value } if {$key eq "bootstrap"} { set options [dict remove $options $key] } } set _options [mergeOptions $_options $options] return $this } #============================ getOptions ===================================== # Retrieve resource options # # @return array ::itcl::body Applications::Resources::Resourcebase::getOptions {} { return $_options } #============================ mergeOptions =================================== # Merge options recursively # # @param dict dict1 # @param mixed dict2 # @return array ::itcl::body Applications::Resources::Resourcebase::mergeOptions {dict1 {dict2 {}}} { if {$dict2 ne ""} { foreach {key val} $dict2 { if {[llength [dict get $dict2 $key]] >= 2} { if {[dict exists $dict1 $key] && ([llength [dict get $dict1 $key]] >= 2)} { dict set dict1 $key [merge_options [dict get $dict1 $key] [dict get $dict2 $key]] } else { dict set dict1 $key [dict get $dict2 $key] } } else { dict set dict1 $key $val } } } return $dict1 } #============================ setBootstrap =================================== # Set the bootstrap to which the resource is attached # # @param Application_Bootstrap_Bootstrapper bootstrap # @return Applications::Resources::ResourcebaseResource ::itcl::body Applications::Resources::Resourcebase::setBootstrap {bootstrap} { set _bootstrap $bootstrap return $this } #============================ getBootstrap =================================== # Retrieve the bootstrap to which the resource is attached # # @return list|Application_Bootstrap_Bootstrapper ::itcl::body Applications::Resources::Resourcebase::getBootstrap {} { return $_bootstrap } } ; # END ::ATWF