From b6e12bedc51b56cf0f1a5930e69a4c377cd3dfe5 Mon Sep 17 00:00:00 2001 From: jrags <> Date: Thu, 21 Sep 2006 00:57:53 +0000 Subject: Added providers demo, sqlmembershipprovider sqlroleprovider both load via modules now, but are not totaly functional yet. TLogin* controls created but not functional yet. --- .../Configuration/TProtectedConfiguration.php | 84 ++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 framework/Configuration/TProtectedConfiguration.php (limited to 'framework/Configuration/TProtectedConfiguration.php') diff --git a/framework/Configuration/TProtectedConfiguration.php b/framework/Configuration/TProtectedConfiguration.php new file mode 100644 index 00000000..da643014 --- /dev/null +++ b/framework/Configuration/TProtectedConfiguration.php @@ -0,0 +1,84 @@ + + * @version $Id: TProtectedConfiguration.php 1398 2006-09-08 19:31:03Z xue $ + * @package System.Configuration + * @since 3.1 + */ +final class TProtectedConfiguration extends TModule +{ + private $_defaultProvider; + /** + * @var array list of providers available + */ + private $_providers=array(); + /** + * @var string external configuration file + */ + private $_configFile=null; + + public function getDefaultProvider() + { + return $this->_defaultProvider; + } + public function setDefaultProvider($value) + { + $this->_defaultProvider = TPropertyValue::ensureString($value); + } + public function getProvider($value=null) + { + if ($value) + $index = $value; + else + $index = $this->_defaultProvider; + + $provider = $this->_providers[$index]; + + if (!$provider instanceof TProviderBase) + throw new TConfigurationException('protectedconfiguration_not_a_provider',$index); + + return $provider; + } + + public function init($config) + { + if($this->_configFile!==null) + { + if(is_file($this->_configFile)) + { + $dom=new TXmlDocument; + $dom->loadFromFile($this->_configFile); + $this->loadConfig($dom); + } + else + throw new TConfigurationException('protectedconfiguration_configfile_invalid',$this->_configFile); + } + $this->loadConfig($config); +// $this->getApplication()->attachEventHandler('OnEndRequest',array($this,'collectLogs')); + } + /** + * Loads configuration from an XML element + * @param TXmlElement configuration node + * @throws TConfigurationException if log route class or type is not specified + */ + private function loadConfig($xml) + { + foreach($xml->getElementsByTagName('provider') as $providerConfig) + { + $properties=$providerConfig->getAttributes(); + if(($class=$properties->remove('class'))===null) + throw new TConfigurationException('protectedconfiguration_providerclass_required'); + $provider=Prado::createComponent($class); + if(!($provider instanceof TProviderBase)) + throw new TConfigurationException('protectedconfiguration_providertype_invalid'); + foreach($properties as $name=>$value) + $provider->setSubproperty($name,$value); + $this->_providers[$provider->getId()]=$provider; + $provider->init($providerConfig); + } + } +} +?> \ No newline at end of file -- cgit v1.2.3