<?php

abstract class Atmail_Config_Abstract
{
	private static $_config = false;

	protected static function getSection($section)
	{		
		if (self::$_config === false) 
		{
			self::$_config = Zend_Registry::get("config");
		}
		
		if (!empty($section) && isset(self::$_config->$section))
		{
			return self::$_config->$section;
		}
		
		throw new Exception("Invalid config section requested: $section");
	}
	

	public static function get($section, $keyName="")
	{
		$section = self::getSection($section);
		
		if (empty($keyName))
		{
			return $section;
		}
		
		if (isset($section[$keyName]))
		{
			return $section[$keyName];
		}
		
		throw new Exception("Invalid Config keyName requested: $keyName");
	}

}
