diff -r bd595ad770fc -r 1c2f13fd785c web/enmi/Zend/Queue/Adapter/AdapterAbstract.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/enmi/Zend/Queue/Adapter/AdapterAbstract.php Thu Jan 20 19:30:54 2011 +0100 @@ -0,0 +1,191 @@ + (string) Amazon AWS Access Key + * secret_key => (string) Amazon AWS Secret Key + * dbname => (string) The name of the database to user + * username => (string) Connect to the database as this username. + * password => (string) Password associated with the username. + * host => (string) What host to connect to, defaults to localhost + * port => (string) The port of the database + * + * @param array|Zend_Config $config An array having configuration data + * @param Zend_Queue The Zend_Queue object that created this class + * @return void + * @throws Zend_Queue_Exception + */ + public function __construct($options, Zend_Queue $queue = null) + { + if ($options instanceof Zend_Config) { + $options = $options->toArray(); + } + + /* + * Verify that adapter parameters are in an array. + */ + if (!is_array($options)) { + require_once 'Zend/Queue/Exception.php'; + throw new Zend_Queue_Exception('Adapter options must be an array or Zend_Config object'); + } + + // set the queue + if ($queue !== null) { + $this->setQueue($queue); + } + + $adapterOptions = array(); + $driverOptions = array(); + + // Normalize the options and merge with the defaults + if (array_key_exists('options', $options)) { + if (!is_array($options['options'])) { + require_once 'Zend/Queue/Exception.php'; + throw new Zend_Queue_Exception("Configuration array 'options' must be an array"); + } + + // Can't use array_merge() because keys might be integers + foreach ($options['options'] as $key => $value) { + $adapterOptions[$key] = $value; + } + } + if (array_key_exists('driverOptions', $options)) { + // can't use array_merge() because keys might be integers + foreach ((array)$options['driverOptions'] as $key => $value) { + $driverOptions[$key] = $value; + } + } + $this->_options = array_merge($this->_options, $options); + $this->_options['options'] = $adapterOptions; + $this->_options['driverOptions'] = $driverOptions; + } + + /******************************************************************** + * Queue management functions + *********************************************************************/ + /** + * get the Zend_Queue class that is attached to this object + * + * @return Zend_Queue|null + */ + public function getQueue() + { + return $this->_queue; + } + + /** + * set the Zend_Queue class for this object + * + * @param Zend_Queue $queue + * @return Zend_Queue_Adapter_AdapterInterface + */ + public function setQueue(Zend_Queue $queue) + { + $this->_queue = $queue; + return $this; + } + + /** + * Returns the configuration options in this adapter. + * + * @return array + */ + public function getOptions() + { + return $this->_options; + } + + /** + * Indicates if a function is supported or not. + * + * @param string $name + * @return boolean + */ + public function isSupported($name) + { + $list = $this->getCapabilities(); + + return (isset($list[$name]) && $list[$name]); + } +}