Gravatar.php

Go to the documentation of this file.
00001 <?php
00002 
00031 class Robo47_Application_Resource_Service_Gravatar
00032 extends Zend_Application_Resource_ResourceAbstract
00033 {
00034 
00038     protected $_service = null;
00039     
00040     public function init()
00041     {
00042         if (!empty($this->_options)) {
00043             $this->_service = $this->_setupService($this->_options);
00044         } else {
00045             $message = 'Empty options in resource ' .
00046                 'Robo47_Application_Resource_Service_Gravatar.';
00047             throw new Robo47_Application_Resource_Exception($message);
00048         }
00049     }
00050 
00057     protected function _setupService($options)
00058     {
00059         $gravatar = new Robo47_Service_Gravatar();
00060 
00061         if (isset($options['rating'])) {
00062             $gravatar->setRating($options['rating']);
00063         }
00064 
00065         if (isset($options['size'])) {
00066             $gravatar->setSize($options['size']);
00067         }
00068 
00069         if (isset($options['default'])) {
00070             $gravatar->setDefault($options['default']);
00071         }
00072 
00073         if (isset($options['cachePrefix'])) {
00074             $gravatar->setCachePrefix($options['cachePrefix']);
00075         }
00076 
00077         if (isset($options['useSSL'])) {
00078             $gravatar->useSSL($options['useSSL']);
00079         }
00080 
00081         if (isset($options['cache'])) {
00082             $gravatar->setCache($options['cache']);
00083         }
00084 
00085         if (isset($options['registryKey'])) {
00086             Zend_Registry::set($options['registryKey'], $gravatar);
00087         }
00088 
00089         return $gravatar;
00090     }
00091 
00097     public function getService()
00098     {
00099         return $this->_service;
00100     }
00101 }