Exemplo n.º 1
0
 /**
  * Initialize key parameters of a RemoteQuery based adpater
  * 
  * This will attempt to set host, user, and authentication information, as
  * well as port and protocol. User and authentication information may 
  * retrieved from the environment context if that feature is enabled.
  * 
  * @param Cpanel_Query_Http_Abstract $adapter Adapter to initialize
  * 
  * @return Cpanel_Query_Http_Abstract Initialized adapter
  */
 protected function initAdapter(Cpanel_Query_Http_Abstract $adapter)
 {
     $vars['host'] = $this->getOption('host');
     $vars['user'] = $this->getOption('user');
     if (!($vars['hash'] = $this->getOption('hash'))) {
         $vars['password'] = $this->getOption('password');
     } else {
         $vars['password'] = null;
     }
     $vars['port'] = $this->getOption('port');
     $vars['protocol'] = $this->getOption('protocol');
     if (!$this->disableEnvironmentContext) {
         $vars = $this->_getEnvironmentContext($vars);
     }
     $adapter->init($vars['host'], $vars['user'], $vars['password']);
     if (!empty($vars['hash'])) {
         $adapter->setHash($vars['hash']);
     }
     if ($vars['port']) {
         $adapter->setPort($vars['port']);
     } elseif ($vars['protocol']) {
         $adapter->setProtocol($vars['protocol']);
     }
     return $adapter;
 }
Exemplo n.º 2
0
 /**
  * Constructor
  * 
  * Prepare the adapter for use by Service.
  * 
  * If $RFT is not passed the const Cpanel_Service_Adapter_Cpanelapi::DRFT will be
  * used when invoking {@link setAdapterResponseFormatType()} at 
  * instantiation
  * 
  * HTTP port is set to '2083' by default.  {@link setPort()}
  * 
  * NOTE: this constructor as support for the legacy PHP XML-API client class
  * 
  * @param string $host     Host address for query call
  * @param string $user     User to authenticate query call
  * @param string $password Password to authenticate query call
  * @param string $RFT      Response format type
  * 
  * @return Cpanel_Service_Adapter_Cpanelapi
  */
 public function __construct($host = null, $user = null, $password = null, $RFT = null)
 {
     parent::__construct();
     if ($host) {
         $this->host = $host;
     }
     if ($user) {
         $this->user = $user;
     }
     if ($password) {
         $this->setPassword($password);
     }
     $this->setPort('2083');
     $RFT = $RFT ? $RFT : self::DRFT;
     $this->setAdapterResponseFormatType($RFT);
     return $this;
 }