Bitly.php

Go to the documentation of this file.
00001 <?php
00002 
00031 class Robo47_Application_Resource_Service_Bitly
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_Bitly.';
00047             throw new Robo47_Application_Resource_Exception($message);
00048         }
00049     }
00050 
00055     protected function _setupService($options)
00056     {
00057         if (!isset($options['login'])) {
00058             $message = 'No login provided';
00059             throw new Robo47_Application_Resource_Exception($message);
00060         }
00061 
00062         if (!isset($options['apiKey'])) {
00063             $message = 'No apiKey provided';
00064             throw new Robo47_Application_Resource_Exception($message);
00065         }
00066 
00067         $bitly = new Robo47_Service_Bitly(
00068             $options['login'],
00069             $options['apiKey']
00070         );
00071 
00072         if (isset($options['format'])) {
00073             $bitly->setFormat($options['format']);
00074         }
00075 
00076         if (isset($options['resultFormat'])) {
00077             $bitly->setResultFormat($options['resultFormat']);
00078         }
00079 
00080         if (isset($options['callback'])) {
00081             $bitly->setCallback($options['callback']);
00082         }
00083 
00084         if (isset($options['version'])) {
00085             $bitly->setVersion($options['version']);
00086         }
00087 
00088         if (isset($options['registryKey'])) {
00089             Zend_Registry::set($options['registryKey'], $bitly);
00090         }
00091 
00092         return $bitly;
00093     }
00094 
00099     public function getService()
00100     {
00101         return $this->_service;
00102     }
00103 }