Overview

Packages

  • None
  • Service
    • Vimeo

Classes

  • Horde_Service_Vimeo

Exceptions

  • Horde_Service_Vimeo_Exception
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Horde_Serivce_Vimeo:: wrapper around Vimeo's (http://www.vimeo.com)
  4:  * API.
  5:  *
  6:  * Copyright 2008-2012 Horde LLC (http://www.horde.org/)
  7:  *
  8:  * @author Michael J. Rubinsky <mrubinsk@horde.org>
  9:  * @license  http://www.horde.org/licenses/bsd BSD
 10:  * @category Horde
 11:  * @package  Service_Vimeo
 12:  */
 13: class Horde_Service_Vimeo {
 14: 
 15:     /**
 16:      * The format of the data returned from Vimeo.
 17:      * Obviously does not apply to the getEmbedJson() method.
 18:      *
 19:      * php  - serialized php array
 20:      * json - json encoded
 21:      *
 22:      * @var string
 23:      */
 24:     protected $_format = 'php';
 25: 
 26:     /**
 27:      * HTTP client object to use for accessing the Vimeo API.
 28:      * @var Horde_Http_Client
 29:      */
 30:     protected $_http_client;
 31: 
 32:     /**
 33:      * An optional cache object
 34:      *
 35:      * @var Horde_Cache
 36:      */
 37:     protected $_cache;
 38: 
 39:     /**
 40:      * The lifetime of any cached data in seconds.
 41:      *
 42:      * @var int
 43:      */
 44:     protected $_cache_lifetime = 60;
 45: 
 46: 
 47:     /**
 48:      * Setter for changing the format parameter
 49:      *
 50:      * @param string $format  The data format requested.
 51:      */
 52:     public function setFormat($format)
 53:     {
 54:         $this->_format = $format;
 55:     }
 56: 
 57:     /**
 58:      * Facory method. Attempt to return a concrete Horde_Service_Vimeo instance
 59:      * based on the parameters. A 'http_client' parameter is required. An
 60:      * optional 'cache' and 'cache_lifetime' parameters are also taken.
 61:      *
 62:      * @param string $driver  The concrete class to instantiate.
 63:      * @param array $params   An array containing any parameters the class needs.
 64:      *
 65:      * @return Horde_Service_Vimeo object
 66:      */
 67:     public static function factory($driver = 'Simple', $params = null)
 68:     {
 69:         // Check for required dependencies
 70:         if (empty($params['http_client'])) {
 71:             throw new InvalidArgumentException('A http client object is required');
 72:         }
 73: 
 74:         $driver = basename($driver);
 75: 
 76:         $class = 'Horde_Service_Vimeo_' . $driver;
 77:         if (class_exists($class)) {
 78:             return new $class($params['http_client'], $params);
 79:         } else {
 80:             throw new Horde_Service_Vimeo_Exception(sprintf("Unable to load the definition of %s.", $class));
 81:         }
 82:     }
 83: 
 84:     /**
 85:      * Constructor
 86:      *
 87:      * @param Horde_Http_Client $http_client  Http client object.
 88:      * @param array $params                   An array of any other parameters
 89:      *                                        or optional object dependencies.
 90:      *
 91:      * @return Horde_Service_Vimeo object
 92:      */
 93:     protected function __construct($http_client, $params)
 94:     {
 95:         $this->_http_client = $http_client;
 96: 
 97:         if (isset($params['cache'])) {
 98:             $this->_cache = $params['cache'];
 99:             if (isset($params['cache_lifetime'])) {
100:                 $this->_cache_lifetime = $params['cache_lifetime'];
101:             }
102:         }
103:     }
104: 
105: }
API documentation generated by ApiGen