コード例 #1
0
 /**
  * Test connecting to the AMQP server. Will connect to the AMQP server but will
  * not consume any messages.
  * @param string $hostname
  * @param string $username
  * @param string $password
  * @return array AJAX response body. Should contain a 'message' => string and 'success' => bool
  */
 public function testConnection($hostname, $username, $password)
 {
     try {
         $this->_validateConfiguration($hostname, $username, $password)->_validateConnection($hostname, $username, $password);
     } catch (EbayEnterprise_Amqp_Exception $e) {
         return array('message' => $e->getMessage(), 'success' => false);
     } catch (Exception $e) {
         $logData = ['error_message' => $e->getMessage()];
         $logMessage = 'Failed to connect to AMQP server with message: {error_message}';
         $this->_logger->warning($logMessage, $this->_context->getMetaData(__CLASS__, $logData, $e));
         return array('message' => $this->_helper->__(self::UNABLE_TO_VALIDATE), 'success' => false);
     }
     return array('message' => $this->_helper->__(self::CONNECTION_SUCCESS), 'success' => true);
 }
コード例 #2
0
 /**
  * Set the value of the "config" to the last timestamp captured from an AMQP
  * test message.
  * @return self
  */
 protected function _afterLoad()
 {
     $dateTime = $this->_getLastTimestamp();
     $value = $dateTime ? $dateTime->format(self::TIMESTAMP_FORMAT) : $this->_helper->__(self::NO_TEST_MESSAGE_RECEIVED);
     return $this->setValue($value);
 }
 /**
  * Get the button and scripts contents
  * @param Varien_Data_Form_Element_Abstract $element
  * @return string
  */
 protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 {
     $originalData = $element->getOriginalData();
     $this->addData(array('button_label' => $this->escapeHtml($this->_amqpHelper->__($originalData['button_label'])), 'html_id' => $element->getHtmlId(), 'ajax_url' => $this->getUrl(self::VALIDATION_URL, array('_current' => true))));
     return $this->_toHtml();
 }