本文整理汇总了PHP中Zend_Queue_Adapter_AdapterAbstract::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Queue_Adapter_AdapterAbstract::__construct方法的具体用法?PHP Zend_Queue_Adapter_AdapterAbstract::__construct怎么用?PHP Zend_Queue_Adapter_AdapterAbstract::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Queue_Adapter_AdapterAbstract
的用法示例。
在下文中一共展示了Zend_Queue_Adapter_AdapterAbstract::__construct方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor
*
* @param array|Zend_Config $options
* @param Zend_Queue|null $queue
* @return void
*/
public function __construct($options, Zend_Queue $queue = null)
{
parent::__construct($options, $queue);
if (!extension_loaded("jobqueue_client")) {
require_once PHP_LIBRARY_PATH . 'Zend/Queue/Exception.php';
throw new Zend_Queue_Exception('Platform Job Queue extension does not appear to be loaded');
}
if (!isset($this->_options['daemonOptions'])) {
require_once PHP_LIBRARY_PATH . 'Zend/Queue/Exception.php';
throw new Zend_Queue_Exception('Job Queue host and password should be provided');
}
$options = $this->_options['daemonOptions'];
if (!array_key_exists('host', $options)) {
require_once PHP_LIBRARY_PATH . 'Zend/Queue/Exception.php';
throw new Zend_Queue_Exception('Platform Job Queue host should be provided');
}
if (!array_key_exists('password', $options)) {
require_once PHP_LIBRARY_PATH . 'Zend/Queue/Exception.php';
throw new Zend_Queue_Exception('Platform Job Queue password should be provided');
}
$this->_zendQueue = new ZendApi_Queue($options['host']);
if (!$this->_zendQueue) {
require_once PHP_LIBRARY_PATH . 'Zend/Queue/Exception.php';
throw new Zend_Queue_Exception('Platform Job Queue connection failed');
}
if (!$this->_zendQueue->login($options['password'])) {
require_once PHP_LIBRARY_PATH . 'Zend/Queue/Exception.php';
throw new Zend_Queue_Exception('Job Queue login failed');
}
if ($this->_queue) {
$this->_queue->setMessageClass('Zend_Queue_Message_PlatformJob');
}
}
示例2: __construct
/**
* Constructor
*
* @param array|Zend_Config $options
* @param null|Zend_Queue $queue
* @return void
*/
public function __construct($options, Zend_Queue $queue = null)
{
if (!extension_loaded('mongo')) {
require_once 'Zend/Queue/Exception.php';
throw new Zend_Queue_Exception('Mongo extension does not appear to be loaded');
}
parent::__construct($options, $queue);
$options =& $this->_options['driverOptions'];
if (!array_key_exists('host', $this->_options)) {
$this->_options['host'] = self::DEFAULT_HOST;
}
if (!array_key_exists('port', $this->_options)) {
$this->_options['port'] = self::DEFAULT_PORT;
}
if (!array_key_exists('persistent', $this->_options)) {
$this->_options['persistent'] = self::DEFAULT_PERSISTENT;
}
if (!array_key_exists('dbname', $this->_options)) {
$this->_options['dbname'] = self::DEFAULT_DBNAME;
}
if (!array_key_exists('collection', $this->_options)) {
$this->_options['collection'] = self::DEFAULT_COLLECTION;
}
$options = $this->_options;
$this->_conn = new Mongo($this->_options['host'], $this->_options['port'], $this->_options['persistent']);
$this->_db = $this->_conn->selectDB($this->_options['dbname']);
$result = $this->_collection = $this->_db->selectCollection($this->_options['collection']);
if ($result === false) {
require_once 'Zend/Queue/Exception.php';
throw new Zend_Queue_Exception('Could not connect to Mongo');
}
$this->_host = $options['host'];
$this->_port = (int) $options['port'];
}
示例3: __construct
/**
* Constructor
*
* @param array|Zend_Config $config An array having configuration data
* @param Zend_Queue The Zend_Queue object that created this class
* @return void
*/
public function __construct($options, Zend_Queue $queue = null)
{
parent::__construct($options);
$options =& $this->_options['driverOptions'];
if (!array_key_exists('scheme', $options)) {
$options['scheme'] = self::DEFAULT_SCHEME;
}
if (!array_key_exists('host', $options)) {
$options['host'] = self::DEFAULT_HOST;
}
if (!array_key_exists('port', $options)) {
$options['port'] = self::DEFAULT_PORT;
}
if (array_key_exists('stompClient', $options)) {
$this->_client = $options['stompClient'];
} else {
$this->_client = new Zend_Queue_Stomp_Client($options['scheme'], $options['host'], $options['port']);
}
$connect = $this->_client->createFrame();
// Username and password are optional on some messaging servers
// such as Apache's ActiveMQ
$connect->setCommand('CONNECT');
if (isset($options['username'])) {
$connect->setHeader('login', $options['username']);
$connect->setHeader('passcode', $options['password']);
}
$response = $this->_client->send($connect)->receive();
if (false !== $response && $response->getCommand() != 'CONNECTED') {
//require_once 'Zend/Queue/Exception.php';
throw new Zend_Queue_Exception("Unable to authenticate to '" . $options['scheme'] . '://' . $options['host'] . ':' . $options['port'] . "'");
}
}
示例4: __construct
/**
* Constructor
*
* @param array|Zend_Config $options
* @param null|Zend_Queue $queue
* @return void
*/
public function __construct($options, Zend_Queue $queue = null)
{
if (!extension_loaded('memcache')) {
require_once 'Zend/Queue/Exception.php';
throw new Zend_Queue_Exception('Memcache extension does not appear to be loaded');
}
parent::__construct($options, $queue);
$options = &$this->_options['driverOptions'];
if (!array_key_exists('host', $options)) {
$options['host'] = self::DEFAULT_HOST;
}
if (!array_key_exists('port', $options)) {
$options['port'] = self::DEFAULT_PORT;
}
$this->_cache = new Memcache();
$result = $this->_cache->connect($options['host'], $options['port']);
if ($result === false) {
require_once 'Zend/Queue/Exception.php';
throw new Zend_Queue_Exception('Could not connect to MemcacheQ');
}
$this->_host = $options['host'];
$this->_port = (int)$options['port'];
}
示例5: __construct
/**
* Constructor
*
* @param array|Zend_Config $options
* @param Zend_Queue|null $queue
*
* @return self
*
* @throws Zend_Queue_Exception
*/
public function __construct($options, Zend_Queue $queue = null)
{
Zend_Queue_Adapter_AdapterAbstract::__construct($options, $queue);
if (!isset($this->_options['options'][Zend_Db_Select::FOR_UPDATE])) {
// turn off auto update by default
$this->_options['options'][Zend_Db_Select::FOR_UPDATE] = false;
}
if (!is_bool($this->_options['options'][Zend_Db_Select::FOR_UPDATE])) {
throw new Zend_Queue_Exception('Options array item: Zend_Db_Select::FOR_UPDATE must be boolean');
}
if (!isset($this->_options['dbAdapter']) || !$this->_options['dbAdapter'] instanceof Zend_Db_Adapter_Abstract) {
throw new Zend_Queue_Exception('dbAdapter must be set');
}
if (!isset($this->_options['dbQueueTable']) || empty($this->_options['dbQueueTable'])) {
throw new Zend_Queue_Exception('dbQueueTable must be set');
}
if (!isset($this->_options['dbMessageTable']) || empty($this->_options['dbMessageTable'])) {
throw new Zend_Queue_Exception('dbMessageTable must be set');
}
$db = $this->_options['dbAdapter'];
$queueTable = $this->_options['dbQueueTable'];
$messageTable = $this->_options['dbMessageTable'];
$this->_queueTable = new Zend_Db_Table(array('db' => $db, 'name' => $queueTable, 'primary' => 'queue_id'));
$this->_messageTable = new Zend_Db_Table(array('db' => $db, 'name' => $messageTable, 'primary' => 'message_id'));
}
示例6: __construct
/**
* Constructor
*
* @param array|Zend_Config $options
* @param Zend_Queue|null $queue
* @return void
*/
public function __construct($options, Zend_Queue $queue = null)
{
parent::__construct($options, $queue);
if (!isset($this->_options['options'][Zend_Db_Select::FOR_UPDATE])) {
// turn off auto update by default
$this->_options['options'][Zend_Db_Select::FOR_UPDATE] = false;
}
if (!is_bool($this->_options['options'][Zend_Db_Select::FOR_UPDATE])) {
require_once 'Zend/Queue/Exception.php';
throw new Zend_Queue_Exception('Options array item: Zend_Db_Select::FOR_UPDATE must be boolean');
}
if (isset($this->_options['dbAdapter'])
&& $this->_options['dbAdapter'] instanceof Zend_Db_Adapter_Abstract) {
$db = $this->_options['dbAdapter'];
} else {
$db = $this->_initDbAdapter();
}
$this->_queueTable = new Zend_Queue_Adapter_Db_Queue(array(
'db' => $db,
));
$this->_messageTable = new Zend_Queue_Adapter_Db_Message(array(
'db' => $db,
));
}
示例7: __construct
/**
* Constructor
*
* @param array|Zend_Config $options
* @param null|Zend_Queue $queue
* @return void
*/
public function __construct($options, Zend_Queue $queue = null)
{
parent::__construct($options, $queue);
if (!empty($this->_options['driverOptions'])) {
$this->_rediska = $options['driverOptions'];
}
$this->_rediska = Rediska_Options_RediskaInstance::getRediskaInstance($this->_rediska, 'Zend_Queue_Exception', 'driverOptions');
$this->_queues = new Rediska_Key_Set($this->_getKeyName('queues'), array('rediska' => $this->_rediska));
}
示例8: __construct
/**
* Constructor
*
* @param array|Zend_Config $options
* @param null|Zend_Queue $queue
* @return void
*/
public function __construct($options, Zend_Queue $queue = null)
{
parent::__construct($options, $queue);
$defaultInstance = Rediska::getDefaultInstance();
if (empty($this->_options['driverOptions']) && $defaultInstance) {
$this->_rediska = $defaultInstance;
} else {
$this->_rediska = new Rediska($this->_options['driverOptions']);
}
$this->_queues = new Rediska_Key_Set($this->_getKeyName('queues'));
$this->_queues->setRediska($this->_rediska);
}
示例9: __construct
public function __construct($options, Zend_Queue $queue = null)
{
$this->_queueModel = isset($options['queue_model']) ? $options['queue_model'] : Mage::getModel('enterprise_queue/queue');
unset($options['queue_model']);
$this->_queueTaskModel = isset($options['task_model']) ? $options['task_model'] : Mage::getModel('enterprise_queue/queue_task');
unset($options['task_model']);
$this->_queueCollection = isset($options['queue_collection']) ? $options['queue_collection'] : Mage::getResourceModel('enterprise_queue/queue_collection');
unset($options['queue_collection']);
$this->_queueTaskCollection = isset($options['queue_task_collection']) ? $options['queue_task_collection'] : Mage::getResourceModel('enterprise_queue/queue_task_collection');
unset($options['queue_task_collection']);
$this->_logger = isset($options['logger']) ? $options['logger'] : Mage::getModel('core/logger');
unset($options['logger']);
parent::__construct($options, $queue);
}
示例10: __construct
/**
* Constructor
*
* @param array|Zend_Config $options
* @param Zend_Queue|null $queue
* @return void
*/
public function __construct($options, Zend_Queue $queue = null)
{
parent::__construct($options, $queue);
if (!isset($this->_options['options'][Zend_Db_Select::FOR_UPDATE])) {
// turn off auto update by default
$this->_options['options'][Zend_Db_Select::FOR_UPDATE] = false;
}
if (!is_bool($this->_options['options'][Zend_Db_Select::FOR_UPDATE])) {
require_once 'Zend/Queue/Exception.php';
throw new Zend_Queue_Exception('Options array item: Zend_Db_Select::FOR_UPDATE must be boolean');
}
$options =& $this->_options['driverOptions'];
if (!array_key_exists('type', $options)) {
require_once 'Zend/Queue/Exception.php';
throw new Zend_Queue_Exception("Configuration array must have a key for 'type' for the database type to use");
}
if (!array_key_exists('host', $options)) {
require_once 'Zend/Queue/Exception.php';
throw new Zend_Queue_Exception("Configuration array must have a key for 'host' for the host to use");
}
if (!array_key_exists('username', $options)) {
require_once 'Zend/Queue/Exception.php';
throw new Zend_Queue_Exception("Configuration array must have a key for 'username' for the username to use");
}
if (!array_key_exists('password', $options)) {
require_once 'Zend/Queue/Exception.php';
throw new Zend_Queue_Exception("Configuration array must have a key for 'password' for the password to use");
}
if (!array_key_exists('dbname', $options)) {
require_once 'Zend/Queue/Exception.php';
throw new Zend_Queue_Exception("Configuration array must have a key for 'dbname' for the database to use");
}
try {
$db = Zend_Db::factory($options['type'], $options);
$this->_queueTable = new Zend_Queue_Adapter_Db_Queue(array('db' => $db));
$this->_messageTable = new Zend_Queue_Adapter_Db_Message(array('db' => $db));
} catch (Zend_Db_Exception $e) {
require_once 'Zend/Queue/Exception.php';
throw new Zend_Queue_Exception('Error connecting to database: ' . $e->getMessage(), $e->getCode());
}
}
示例11: __construct
/**
* Constructor
*
* @param array|Zend_Config $options
* @param null|Zend_Queue $queue
* @return void
*/
public function __construct($options, Zend_Queue $queue = null)
{
parent::__construct($options, $queue);
}