ErrorHandler.php

Go to the documentation of this file.
00001 <?php
00002 
00033 class Robo47_Application_Resource_ErrorHandler
00034 extends Zend_Application_Resource_ResourceAbstract
00035 {
00036 
00041     protected $_errorHandler = null;
00042     
00043     public function init()
00044     {
00045         if (!empty($this->_options)) {
00046             $this->_errorHandler = $this->_setupErrorHandler($this->_options);
00047         } else {
00048             $message = 'Empty options in resource ' .
00049                 'Robo47_Application_Resource_ErrorHandler.';
00050             throw new Robo47_Application_Resource_Exception($message);
00051         }
00052     }
00053 
00059     protected function _setupErrorHandler($options)
00060     {
00061         $errorHandler = new Robo47_ErrorHandler();
00062 
00063         if (isset($options['registryKey'])) {
00064             Zend_Registry::set($options['registryKey'], $errorHandler);
00065         }
00066         if (isset($options['setLogFromRegistryKey'])) {
00067             $log = Zend_Registry::get($options['setLogFromRegistryKey']);
00068             $errorHandler->setLog($log);
00069         }
00070         if (isset($options['logCategory'])) {
00071             $errorHandler->setLogCategory($options['logCategory']);
00072         }
00073         if (isset($options['errorPriorityMapping'])) {
00074             $errorPriorityMapping = $options['errorPriorityMapping'];
00075             $errorHandler->setErrorPriorityMapping($errorPriorityMapping);
00076         }
00077         if (isset($options['registerAsErrorHandler'])) {
00078             $errorHandler->registerAsErrorHandler();
00079         }
00080         return $errorHandler;
00081     }
00082 
00088     public function getErrorHandler()
00089     {
00090         return $this->_errorHandler;
00091     }
00092 }