本文整理汇总了PHP中WebserviceRequest::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP WebserviceRequest::getInstance方法的具体用法?PHP WebserviceRequest::getInstance怎么用?PHP WebserviceRequest::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebserviceRequest
的用法示例。
在下文中一共展示了WebserviceRequest::getInstance方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateWs
/**
* For a given {id_product, id_product_attribute and id_shop}, gets the stock available id associated
*
* @param int $id_product
* @param int $id_product_attribute Optional
* @param int $id_shop Optional
* @return int
*/
public function updateWs()
{
if ($this->depends_on_stock) {
return WebserviceRequest::getInstance()->setError(500, Tools::displayError('You can\'t update stock available when it\'s depend on stock'));
}
return $this->update();
}
示例2: updateWs
/**
* For a given {id_product, id_product_attribute and id_shop}, gets the stock available id associated
*
* @param int $id_product
* @param int $id_product_attribute Optional
* @param int $id_shop Optional
* @return int
*/
public function updateWs()
{
if ($this->depends_on_stock) {
return WebserviceRequest::getInstance()->setError(500, Tools::displayError('You cannot update the available stock when it depends on stock.'), 133);
}
return $this->update();
}
示例3: displayError
/**
* Display last SQL error
*
* @param bool $sql
*/
public function displayError($sql = false)
{
global $webservice_call;
$errno = $this->getNumberError();
if ($webservice_call && $errno) {
WebserviceRequest::getInstance()->setError(500, '[SQL Error] ' . $this->getMsgError() . '. Query was : ' . $sql, 97);
} else {
if (_PS_DEBUG_SQL_ && $errno && !defined('PS_INSTALLATION_IN_PROGRESS')) {
if ($sql) {
throw new PrestaShopDatabaseException($this->getMsgError() . '<br /><br /><pre>' . $sql . '</pre>');
}
throw new PrestaShopDatabaseException($this->getMsgError());
}
}
}
示例4: displayMySQLError
public function displayMySQLError($query = false)
{
global $webservice_call;
if ($webservice_call && mysql_errno($this->_link)) {
WebserviceRequest::getInstance()->setError(500, '[SQL Error] ' . mysql_error($this->_link) . '. Query was : ' . $query, 97);
} elseif (_PS_DEBUG_SQL_ and mysql_errno($this->_link) and !defined('PS_INSTALLATION_IN_PROGRESS')) {
if ($query) {
die(Tools::displayError(mysql_error($this->_link) . '<br /><br /><pre>' . $query . '</pre>'));
}
die(Tools::displayError(mysql_error($this->_link)));
}
}
示例5: displayError
/**
* Display last SQL error
*
* @param bool $sql
*/
public function displayError($sql = false)
{
global $webservice_call;
$errno = $this->getNumberError();
if ($webservice_call && $errno) {
$dbg = debug_backtrace();
WebserviceRequest::getInstance()->setError(500, '[SQL Error] ' . $this->getMsgError() . '. From ' . (isset($dbg[3]['class']) ? $dbg[3]['class'] : '') . '->' . $dbg[3]['function'] . '() Query was : ' . $sql, 97);
} else {
if (_PS_DEBUG_SQL_ && $errno && !defined('PS_INSTALLATION_IN_PROGRESS')) {
if ($sql) {
throw new PrestaShopDatabaseException($this->getMsgError() . '<br /><br /><pre>' . $sql . '</pre>');
}
throw new PrestaShopDatabaseException($this->getMsgError());
}
}
}
示例6: webserviceErrorHandler
/**
* Used to replace the default PHP error handler, in order to display PHP errors in a XML format
*
* @param string $errno contains the level of the error raised, as an integer
* @param array $errstr contains the error message, as a string
* @param array $errfile errfile, which contains the filename that the error was raised in, as a string
* @param array $errline errline, which contains the line number the error was raised at, as an integer
* @return boolean Always return true to avoid the default PHP error handler
*/
public function webserviceErrorHandler($errno, $errstr, $errfile, $errline)
{
$display_errors = strtolower(ini_get('display_errors')) != 'off';
if (!(error_reporting() & $errno) || $display_errors) {
return;
}
$errortype = array(E_ERROR => 'Error', E_WARNING => 'Warning', E_PARSE => 'Parse', E_NOTICE => 'Notice', E_CORE_ERROR => 'Core Error', E_CORE_WARNING => 'Core Warning', E_COMPILE_ERROR => 'Compile Error', E_COMPILE_WARNING => 'Compile Warning', E_USER_ERROR => 'Error', E_USER_WARNING => 'User warning', E_USER_NOTICE => 'User notice', E_STRICT => 'Runtime Notice', E_RECOVERABLE_ERROR => 'Recoverable error');
$type = isset($errortype[$errno]) ? $errortype[$errno] : 'Unknown error';
error_log('[PHP ' . $type . ' #' . $errno . '] ' . $errstr . ' (' . $errfile . ', line ' . $errline . ')');
switch ($errno) {
case E_ERROR:
WebserviceRequest::getInstance()->setError(500, '[PHP Error #' . $errno . '] ' . $errstr . ' (' . $errfile . ', line ' . $errline . ')', 2);
break;
case E_WARNING:
WebserviceRequest::getInstance()->setError(500, '[PHP Warning #' . $errno . '] ' . $errstr . ' (' . $errfile . ', line ' . $errline . ')', 3);
break;
case E_PARSE:
WebserviceRequest::getInstance()->setError(500, '[PHP Parse #' . $errno . '] ' . $errstr . ' (' . $errfile . ', line ' . $errline . ')', 4);
break;
case E_NOTICE:
WebserviceRequest::getInstance()->setError(500, '[PHP Notice #' . $errno . '] ' . $errstr . ' (' . $errfile . ', line ' . $errline . ')', 5);
break;
case E_CORE_ERROR:
WebserviceRequest::getInstance()->setError(500, '[PHP Core #' . $errno . '] ' . $errstr . ' (' . $errfile . ', line ' . $errline . ')', 6);
break;
case E_CORE_WARNING:
WebserviceRequest::getInstance()->setError(500, '[PHP Core warning #' . $errno . '] ' . $errstr . ' (' . $errfile . ', line ' . $errline . ')', 7);
break;
case E_COMPILE_ERROR:
WebserviceRequest::getInstance()->setError(500, '[PHP Compile #' . $errno . '] ' . $errstr . ' (' . $errfile . ', line ' . $errline . ')', 8);
break;
case E_COMPILE_WARNING:
WebserviceRequest::getInstance()->setError(500, '[PHP Compile warning #' . $errno . '] ' . $errstr . ' (' . $errfile . ', line ' . $errline . ')', 9);
break;
case E_USER_ERROR:
WebserviceRequest::getInstance()->setError(500, '[PHP Error #' . $errno . '] ' . $errstr . ' (' . $errfile . ', line ' . $errline . ')', 10);
break;
case E_USER_WARNING:
WebserviceRequest::getInstance()->setError(500, '[PHP User warning #' . $errno . '] ' . $errstr . ' (' . $errfile . ', line ' . $errline . ')', 11);
break;
case E_USER_NOTICE:
WebserviceRequest::getInstance()->setError(500, '[PHP User notice #' . $errno . '] ' . $errstr . ' (' . $errfile . ', line ' . $errline . ')', 12);
break;
case E_STRICT:
WebserviceRequest::getInstance()->setError(500, '[PHP Strict #' . $errno . '] ' . $errstr . ' (' . $errfile . ', line ' . $errline . ')', 13);
break;
case E_RECOVERABLE_ERROR:
WebserviceRequest::getInstance()->setError(500, '[PHP Recoverable error #' . $errno . '] ' . $errstr . ' (' . $errfile . ', line ' . $errline . ')', 14);
break;
default:
WebserviceRequest::getInstance()->setError(500, '[PHP Unknown error #' . $errno . '] ' . $errstr . ' (' . $errfile . ', line ' . $errline . ')', 15);
}
return true;
}
示例7: setWsPositionInCategory
/**
* Webservice setter : set virtual field position in category
*
* @return bool
*/
public function setWsPositionInCategory($position)
{
if ($position < 0) {
WebserviceRequest::getInstance()->setError(500, Tools::displayError('You cannot set a negative position, the minimum for a position is 0.'), 134);
}
$result = Db::getInstance()->executeS('
SELECT `id_product`
FROM `' . _DB_PREFIX_ . 'category_product`
WHERE `id_category` = ' . (int) $this->id_category_default . '
ORDER BY `position`
');
if ($position > 0 && $position + 1 > count($result)) {
WebserviceRequest::getInstance()->setError(500, Tools::displayError('You cannot set a position greater than the total number of products in the category, minus 1 (position numbering starts at 0).'), 135);
}
foreach ($result as &$value) {
$value = $value['id_product'];
}
$current_position = $this->getWsPositionInCategory();
if ($current_position && isset($result[$current_position])) {
$save = $result[$current_position];
unset($result[$current_position]);
array_splice($result, (int) $position, 0, $save);
}
foreach ($result as $position => $id_product) {
Db::getInstance()->update('category_product', array('position' => $position), '`id_category` = ' . (int) $this->id_category_default . ' AND `id_product` = ' . (int) $id_product);
}
return true;
}
示例8: webserviceErrorHandler
/**
* Used to replace the default PHP error handler, in order to display PHP errors in a XML format
*
* @param string $errno contains the level of the error raised, as an integer
* @param array $errstr contains the error message, as a string
* @param array $errfile errfile, which contains the filename that the error was raised in, as a string
* @param array $errline errline, which contains the line number the error was raised at, as an integer
* @return boolean Always return true to avoid the default PHP error handler
*/
public function webserviceErrorHandler($errno, $errstr, $errfile, $errline)
{
if (!(error_reporting() & $errno)) {
return;
}
switch ($errno) {
case E_ERROR:
WebserviceRequest::getInstance()->setError(500, '[PHP Error #' . $errno . '] ' . $errstr . ' (' . $errfile . ', line ' . $errline . ')');
break;
case E_WARNING:
WebserviceRequest::getInstance()->setError(500, '[PHP Warning #' . $errno . '] ' . $errstr . ' (' . $errfile . ', line ' . $errline . ')');
break;
case E_PARSE:
WebserviceRequest::getInstance()->setError(500, '[PHP Parse #' . $errno . '] ' . $errstr . ' (' . $errfile . ', line ' . $errline . ')');
break;
case E_NOTICE:
WebserviceRequest::getInstance()->setError(500, '[PHP Notice #' . $errno . '] ' . $errstr . ' (' . $errfile . ', line ' . $errline . ')');
break;
case E_CORE_ERROR:
WebserviceRequest::getInstance()->setError(500, '[PHP Core #' . $errno . '] ' . $errstr . ' (' . $errfile . ', line ' . $errline . ')');
break;
case E_CORE_WARNING:
WebserviceRequest::getInstance()->setError(500, '[PHP Core warning #' . $errno . '] ' . $errstr . ' (' . $errfile . ', line ' . $errline . ')');
break;
case E_COMPILE_ERROR:
WebserviceRequest::getInstance()->setError(500, '[PHP Compile #' . $errno . '] ' . $errstr . ' (' . $errfile . ', line ' . $errline . ')');
break;
case E_COMPILE_WARNING:
WebserviceRequest::getInstance()->setError(500, '[PHP Compile warning #' . $errno . '] ' . $errstr . ' (' . $errfile . ', line ' . $errline . ')');
break;
case E_USER_ERROR:
WebserviceRequest::getInstance()->setError(500, '[PHP Error #' . $errno . '] ' . $errstr . ' (' . $errfile . ', line ' . $errline . ')');
break;
case E_USER_WARNING:
WebserviceRequest::getInstance()->setError(500, '[PHP User warning #' . $errno . '] ' . $errstr . ' (' . $errfile . ', line ' . $errline . ')');
break;
case E_USER_NOTICE:
WebserviceRequest::getInstance()->setError(500, '[PHP User notice #' . $errno . '] ' . $errstr . ' (' . $errfile . ', line ' . $errline . ')');
break;
case E_STRICT:
WebserviceRequest::getInstance()->setError(500, '[PHP Strict #' . $errno . '] ' . $errstr . ' (' . $errfile . ', line ' . $errline . ')');
break;
case E_RECOVERABLE_ERROR:
WebserviceRequest::getInstance()->setError(500, '[PHP Recoverable error #' . $errno . '] ' . $errstr . ' (' . $errfile . ', line ' . $errline . ')');
break;
default:
WebserviceRequest::getInstance()->setError(500, '[PHP Unknown error #' . $errno . '] ' . $errstr . ' (' . $errfile . ', line ' . $errline . ')');
}
return true;
}
示例9: setWsCustomizedDataTextFields
/**
* Set customized text fields
* (for webservice)
*
* @param array $values
*
* @return bool
*/
public function setWsCustomizedDataTextFields($values)
{
$cart = new Cart($this->id_cart);
if (!Validate::isLoadedObject($cart)) {
WebserviceRequest::getInstance()->setError(500, Tools::displayError('Could not load cart id=' . $this->id_cart), 137);
return false;
}
Db::getInstance()->execute('
DELETE FROM `' . _DB_PREFIX_ . 'customized_data`
WHERE id_customization = ' . (int) $this->id . '
AND type = 1');
foreach ($values as $value) {
$query = 'INSERT INTO `' . _DB_PREFIX_ . 'customized_data` (`id_customization`, `type`, `index`, `value`)
VALUES (' . (int) $this->id . ', 1, ' . (int) $value['id_customization_field'] . ', \'' . pSQL($value['value']) . '\')';
if (!Db::getInstance()->execute($query)) {
return false;
}
}
return true;
}
示例10: call_user_func
$class_name = 'WebserviceRequest';
$bad_class_name = true;
}
// fetch the request
$request = call_user_func(array($class_name, 'getInstance'));
$result = $request->fetch($key, $method, $_GET['url'], $params, $bad_class_name, $input_xml);
// display result
if (ob_get_length() == 0) {
header($result['content_type']);
} else {
header('Content-Type: application/javascript');
}
// Useful for debug...
header($result['status']);
header($result['x_powered_by']);
header($result['execution_time']);
if (isset($result['ps_ws_version'])) {
header($result['ps_ws_version']);
}
if ($result['type'] == 'xml') {
header($result['content_sha1']);
echo $result['content'];
} elseif ($result['type'] == 'image') {
if ($result['content_type'] == 'Content-Type: image/jpeg') {
imagejpeg(WebserviceRequest::getInstance()->_imageResource);
} elseif ($result['content_type'] == 'Content-Type: image/gif') {
imagegif(WebserviceRequest::getInstance()->_imageResource);
}
imagedestroy(WebserviceRequest::getInstance()->_imageResource);
}
ob_end_flush();