Tutorial Extension  1.0.0
SellerDeck Extensions - Tutorial Extension
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
CAbstractHandshaking Class Reference

Inherited by CHandshaking.

Public Member Functions

 __construct ($aInitMessage)
 
 GetResponse ()
 
 SetHeader ($sHeader="Content-Type: application/xml; charset=utf-8")
 

Protected Member Functions

 VersionInformation ()
 
 SDDConfiguration ()
 
 ExtensionConfiguration ()
 
 AppInit ()
 

Protected Attributes

 $m_aInitMessage = []
 

Detailed Description

Definition at line 11 of file CAbstractHandshaking.php.

Constructor & Destructor Documentation

__construct (   $aInitMessage)

__construct - Object constructor

public

Parameters
array$aInitMessageInit Message
Returns
void

Definition at line 26 of file CAbstractHandshaking.php.

27  {
28  if (empty($aInitMessage) || false === $aInitMessage)
29  {
30  define('HANDSHAKING', true);
31  require_once(FRAMEWORK_ROOT . 'bootstrap.php');
32  \SDExtension\Helper\CLogger::get('unknown', CACHE_ROOT)->addError(EXCEPTION_MSG_NO_DATA);
33  throw new \SDExtension\SDException\SDException(EXCEPTION_MSG_NO_DATA, EXCEPTION_CODE_NO_DATA);
34  }
35  $this->m_aInitMessage = $aInitMessage;
36  return $this;
37  }
static get($sChannel="default", $sLogRoot="")
Definition: CLogger.php:90

Member Function Documentation

AppInit ( )
abstractprotected

AppInit - Init Application

protected

Returns
void
ExtensionConfiguration ( )
protected

ExtensionConfiguration - Extension Configuration

Handshaking round #3

protected

Returns
string Response XML

Definition at line 174 of file CAbstractHandshaking.php.

175  {
176  //
177  // Init Settings
178  //
179  $this->AppInit();
180  $sConfigFile = CONFIG_APP_ROOT . "handshake_response3.php";
181  $aResponse = load_config($sConfigFile, function() use ($sConfigFile)
182  {
183  \SDExtension\Helper\CLogger::get(LOG_CHANNEL_NAME)->addError(EXCEPTION_MSG_CANT_LOAD_CONFIG_FILE . ": $sConfigFile.");
184  throw new \SDExtension\SDException\SDException(EXCEPTION_MSG_CANT_LOAD_CONFIG_FILE . ": $sConfigFile.", EXCEPTION_CODE_CANT_LOAD_CONFIG_FILE);
185  });
186  $sResponseXML = SDExtension\Helper\Array2XML::createXML('response', $aResponse)->saveXML();
187  SDExtension\Helper\CLogger::get()->addInfo("Handshaking done!");
188  //
189  // Unlocking
190  //
191  @RemoveLock();
192  return $sResponseXML;
193  }
static get($sChannel="default", $sLogRoot="")
Definition: CLogger.php:90
static & createXML($node_name, $arr=array(), $namespace=null)
Definition: Array2XML.php:62
GetResponse ( )

GetResponse - Getting Response

public

Parameters
array$aInitMessageInit Message
Returns
string Response XML

Definition at line 46 of file CAbstractHandshaking.php.

47  {
48  $this->SetHeader();
49  switch ($this->GetFunction())
50  {
51  case HANDSHAKE_VERSION_INFORMATION:
52  define('HANDSHAKING', true);
53  require_once(FRAMEWORK_ROOT . 'bootstrap.php');
54  return $this->VersionInformation();
55  break;
56  case HANDSHAKE_SDD_CONFIGURATION:
57  define('HANDSHAKING', true);
58  require_once(FRAMEWORK_ROOT . 'bootstrap.php');
59  return $this->SDDConfiguration();
60  break;
61  case HANDSHAKE_EXTENSION_CONFIGURATION:
62  require_once(FRAMEWORK_ROOT . 'bootstrap.php');
63  return $this->ExtensionConfiguration();
64  break;
65  default:
66  }
67  }
SetHeader($sHeader="Content-Type: application/xml; charset=utf-8")
SDDConfiguration ( )
protected

SDDConfiguration - SellerDeck Desktop Configuration

Handshaking round #2

protected

Returns
string Response XML

Definition at line 134 of file CAbstractHandshaking.php.

135  {
136  $sSiteName = arr_get($this->m_aInitMessage, 'site.sitename.sitename', DEFAULT_SITE_NAME);
137  $sSdeLogs = arr_get($this->m_aInitMessage, 'paths.logs.site', DEFAULT_LOG_ROOT);
138  $sSiteSdeDataFolder = arr_get($this->m_aInitMessage, 'paths.files.temporary', DEFAULT_CONFIG_ROOT) . DS;
139  if (!file_exists($sSdeLogs))
140  {
141  @mkdir($sSdeLogs, 0777, true);
142  }
143  if (!file_exists($sSiteSdeDataFolder))
144  {
145  @mkdir($sSiteSdeDataFolder, 0777, true);
146  }
147  @rename(CACHE_ROOT . "version.php", $sSiteSdeDataFolder . "version.php");
148  @save_config($this->m_aInitMessage, false, $sSiteSdeDataFolder . "details.php");
149  @save_config([
150  'sSiteName' => $sSiteName,
151  'sSdeLogs' => $sSdeLogs,
152  'sSiteSdeDataFolder' => $sSiteSdeDataFolder,
153  ], false, CACHE_ROOT . "details_temp.php");
154  $sConfigFile = CONFIG_APP_ROOT . "handshake_response2.php";
155  $aResponse = load_config($sConfigFile, function() use ($sConfigFile)
156  {
157  \SDExtension\Helper\CLogger::get(LOG_CHANNEL_NAME)->addError(EXCEPTION_MSG_CANT_LOAD_CONFIG_FILE . ": $sConfigFile.");
158  throw new \SDExtension\SDException\SDException(EXCEPTION_MSG_CANT_LOAD_CONFIG_FILE . ": $sConfigFile.", EXCEPTION_CODE_CANT_LOAD_CONFIG_FILE);
159  });
160  $sResponseXML = SDExtension\Helper\Array2XML::createXML('response', $aResponse)->saveXML();
161  @SDExtension\Helper\CLogger::init($sSiteName, $sSdeLogs . DS);
162  @SDExtension\Helper\CLogger::get()->addInfo("Handshaking #2");
163  return $sResponseXML;
164  }
static get($sChannel="default", $sLogRoot="")
Definition: CLogger.php:90
static init($sChannel="default", $sLogRoot="")
Definition: CLogger.php:43
static & createXML($node_name, $arr=array(), $namespace=null)
Definition: Array2XML.php:62
SetHeader (   $sHeader = "Content-Type: application/xml; charset=utf-8")

SetHeader - Setting Response XML header

public

Parameters
string$sHeaderResponse XML header
Returns
CAbstractHandshaking This object

Definition at line 76 of file CAbstractHandshaking.php.

76  : application/xml; charset=utf-8")
77  {
78 //
79 // Response XML header
80 //
81  header($sHeader);
82  return $this;
83  }
VersionInformation ( )
protected

VersionInformation - Version Information

Handshaking round #1

protected

Returns
string Response XML

Definition at line 104 of file CAbstractHandshaking.php.

105  {
106  $sConfigFileVersion = CACHE_ROOT . "version.php";
107  @save_config($this->m_aInitMessage, true, $sConfigFileVersion);
108  $nActualVersionNumber = @arr_get($this->m_aInitMessage, 'versionid.major', 1) * 10000 + @arr_get($this->m_aInitMessage, 'versionid.minor', 0) * 100 + @arr_get($this->m_aInitMessage, 'versionid.maintenance', 0);
109  $sActualVersion = @arr_get($this->m_aInitMessage, 'versionid.major', 1) . "." . @arr_get($this->m_aInitMessage, 'versionid.minor', 0) . "." . @arr_get($this->m_aInitMessage, 'versionid.maintenance', 0);
110  $nRequiredVersionNumber = REQUIRED_SDD_VERSION_MAJOR * 10000 + REQUIRED_SDD_VERSION_MINOR * 100 + REQUIRED_SDD_VERSION_MAINTENANCE;
111  if ($nActualVersionNumber < $nRequiredVersionNumber)
112  {
113  $nRequiredVersion = REQUIRED_SDD_VERSION_MAJOR . "." . REQUIRED_SDD_VERSION_MINOR . "." . REQUIRED_SDD_VERSION_MAINTENANCE;
114  \SDExtension\Helper\CLogger::get('unknown', CACHE_ROOT)->addError(sprintf(EXCEPTION_MSG_SDD_INCOMPATIBLE, $nRequiredVersion));
115  }
116  $sConfigFile = CONFIG_APP_ROOT . "handshake_response1.php";
117  $aResponse = load_config($sConfigFile, function() use ($sConfigFile)
118  {
119  \SDExtension\Helper\CLogger::get('unknown', CACHE_ROOT)->addError(EXCEPTION_MSG_CANT_LOAD_CONFIG_FILE . ": $sConfigFile.");
120  throw new \SDExtension\SDException\SDException(EXCEPTION_MSG_CANT_LOAD_CONFIG_FILE . ": $sConfigFile.", EXCEPTION_CODE_CANT_LOAD_CONFIG_FILE);
121  });
122  $sResponseXML = SDExtension\Helper\Array2XML::createXML('response', $aResponse)->saveXML();
123  return $sResponseXML;
124  }
static get($sChannel="default", $sLogRoot="")
Definition: CLogger.php:90
static & createXML($node_name, $arr=array(), $namespace=null)
Definition: Array2XML.php:62

The documentation for this class was generated from the following file: