Go to the documentation of this file.00001 <?php
00002
00034 class Robo47_Application_Resource_Autoloader
00035 extends Zend_Application_Resource_ResourceAbstract
00036 {
00037
00041 protected $_autoloader = null;
00042
00043 public function init()
00044 {
00045 if (!empty($this->_options)) {
00046 $this->_autoloader = $this->_setupAutoloader($this->_options);
00047 } else {
00048 $message = 'Empty options in resource ' .
00049 'Robo47_Application_Resource_Autoloader.';
00050 throw new Robo47_Application_Resource_Exception($message);
00051 }
00052 }
00053
00061 public function _setupAutoloader($options)
00062 {
00063 if (!isset($options['classname'])) {
00064 $message = 'Autoloader config doesn\'t contain classname';
00065 throw new Robo47_Application_Resource_Exception($message);
00066 }
00067
00068 if (!isset($options['prefix'])) {
00069 $message = 'Autoloader config doesn\'t contain prefix';
00070 throw new Robo47_Application_Resource_Exception($message);
00071 }
00072
00073 $autoLoader = Zend_Loader_Autoloader::getInstance();
00074 $classname = $options['classname'];
00075 $prefix = $options['prefix'];
00076 $autoLoaderInstance = new $classname();
00077 $autoLoader->pushAutoloader($autoLoaderInstance, $prefix);
00078 return $autoLoaderInstance;
00079 }
00080
00086 public function getAutoloader()
00087 {
00088 return $this->_autoloader;
00089 }
00090 }