OXID eShop CE  4.8.12
 All Classes Files Functions Variables Pages
oxefidownloader.php
Go to the documentation of this file.
1 <?php
2 
3 
4 DEFINE('EFIRE_WSDL_URL', 'https://soap.oxid-efire.com/');
5 //DEFINE('EFIRE_WSDL_URL', 'http://efire-linux:12156/');
6 
12 {
18  protected $_oSoapClient = null;
19 
20  protected $_sVersion = null;
21 
32  public function downloadConnector($sUsername, $sPassword, $sShopVersion, $blSaveCredentials)
33  {
34 
35  if ($blSaveCredentials) {
36  $this->getConfig()->saveShopConfVar('str', 'sEfiUsername', $sUsername);
37  $this->getConfig()->saveShopConfVar('str', 'sEfiPassword', $sPassword);
38  } else {
39  $this->getConfig()->saveShopConfVar('str', 'sEfiUsername', null);
40  $this->getConfig()->saveShopConfVar('str', 'sEfiPassword', null);
41  }
42 
43  $this->_init($sUsername, $sPassword);
44 
45  $sFileName = getShopBasePath() . "core/". strtolower(basename($this->_getConnectorClassName($sShopVersion))) . ".php";
46  $sFileContents = $this->_getConnectorContents($sShopVersion);
47 
48  //writing to file
49  $fOut = fopen($sFileName, "w");
50  if (!fputs($fOut, $sFileContents)) {
51  throw new oxException('EXCEPTION_COULDNOTWRITETOFILE');
52  }
53  fclose($fOut);
54 
55  //remove possible old connector from the main shop dir
56  if (file_exists(getShopBasePath() . "oxefi.php")) {
57  unlink(getShopBasePath() . "oxefi.php");
58  }
59 
60  return $sFileName;
61  }
62 
71  protected function _init($sUsername, $sPassword)
72  {
73  $this->_oClient = new SoapClient( EFIRE_WSDL_URL . 'eshopconnector/?wsdl',
74  array(
75  'trace' => 1,
76  'style' => SOAP_DOCUMENT,
77  'login' => $sUsername,
78  'password' => $sPassword,
79  'cache_wsdl' => WSDL_CACHE_NONE
80  )
81  );
82 
83  }
84 
92  protected function _getConnectorClassName($sShopVersion)
93  {
94  $oResponse = $this->_oClient->getConnectorClassName($sShopVersion);
95 
96  if (!$oResponse->blResult) {
97  throw new Exception($oResponse->sMessage);
98  }
99 
100  return $oResponse->sMessage;
101  }
102 
111  protected function _getConnectorContents($sShopVersion)
112  {
113  $oResponse = $this->_oClient->getConnectorFileContents($sShopVersion);
114 
115  if (!$oResponse->blResult) {
116  throw new Exception($oResponse->sMessage);
117  }
118 
119  return $oResponse->sMessage;
120  }
121 
122 }