本文整理汇总了PHP中Mage_Core_Model_App::isDeveloperMode方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Core_Model_App::isDeveloperMode方法的具体用法?PHP Mage_Core_Model_App::isDeveloperMode怎么用?PHP Mage_Core_Model_App::isDeveloperMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Core_Model_App
的用法示例。
在下文中一共展示了Mage_Core_Model_App::isDeveloperMode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: interpret
/**
* Parse Request body into array of params.
*
* @param string $encodedBody Posted content from request.
* @return array|null Return NULL if content is invalid.
* @throws InvalidArgumentException
* @throws Mage_Webapi_Exception If decoding error was encountered.
*/
public function interpret($encodedBody)
{
if (!is_string($encodedBody)) {
throw new InvalidArgumentException(sprintf('Invalid data type "%s". String is expected.', gettype($encodedBody)));
}
try {
/** @var Mage_Core_Helper_Data $jsonHelper */
$jsonHelper = $this->_helperFactory->get('Mage_Core_Helper_Data');
$decodedBody = $jsonHelper->jsonDecode($encodedBody);
} catch (Zend_Json_Exception $e) {
if (!$this->_app->isDeveloperMode()) {
throw new Mage_Webapi_Exception($this->_helper->__('Decoding error.'), Mage_Webapi_Exception::HTTP_BAD_REQUEST);
} else {
throw new Mage_Webapi_Exception('Decoding error: ' . PHP_EOL . $e->getMessage() . PHP_EOL . $e->getTraceAsString(), Mage_Webapi_Exception::HTTP_BAD_REQUEST);
}
}
return $decodedBody;
}
示例2: apiShutdownFunction
public function apiShutdownFunction()
{
$fatalErrorFlag = E_ERROR | E_USER_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_RECOVERABLE_ERROR;
$error = error_get_last();
if ($error && $error['type'] & $fatalErrorFlag) {
$errorMessage = '';
switch ($error['type']) {
case E_ERROR:
$errorMessage .= "Fatal Error";
break;
case E_PARSE:
$errorMessage .= "Parse Error";
break;
case E_CORE_ERROR:
$errorMessage .= "Core Error";
break;
case E_COMPILE_ERROR:
$errorMessage .= "Compile Error";
break;
case E_USER_ERROR:
$errorMessage .= "User Error";
break;
case E_RECOVERABLE_ERROR:
$errorMessage .= "Recoverable Error";
break;
default:
$errorMessage .= "Unknown error ({$error['type']})";
break;
}
$errorMessage .= ": {$error['message']} in {$error['file']} on line {$error['line']}";
try {
// call registered error dispatcher
trigger_error("'{$errorMessage}'", E_USER_ERROR);
} catch (Exception $e) {
$errorMessage = $e->getMessage();
}
if (!$this->_app->isDeveloperMode()) {
$this->_saveFatalErrorReport($errorMessage);
}
$this->render($errorMessage);
}
}
示例3: checkDeprecationPolicy
/**
* Check if specified method is deprecated or removed.
*
* Throw exception in two cases:<br/>
* - method is removed<br/>
* - method is deprecated and developer mode is enabled
*
* @param string $resourceName
* @param string $method
* @param string $resourceVersion
* @throws Mage_Webapi_Exception
* @throws LogicException
*/
public function checkDeprecationPolicy($resourceName, $method, $resourceVersion)
{
$deprecationPolicy = $this->getDeprecationPolicy($resourceName, $method, $resourceVersion);
if ($deprecationPolicy) {
/** Initialize message with information about what method should be used instead of requested one. */
if (isset($deprecationPolicy['use_resource']) && isset($deprecationPolicy['use_method']) && isset($deprecationPolicy['use_version'])) {
$messageUseMethod = $this->_helper->__('Please use version "%s" of "%s" method in "%s" resource instead.', $deprecationPolicy['use_version'], $deprecationPolicy['use_method'], $deprecationPolicy['use_resource']);
} else {
$messageUseMethod = '';
}
$badRequestCode = Mage_Webapi_Exception::HTTP_BAD_REQUEST;
if (isset($deprecationPolicy['removed'])) {
$removalMessage = $this->_helper->__('Version "%s" of "%s" method in "%s" resource was removed.', $resourceVersion, $method, $resourceName);
throw new Mage_Webapi_Exception($removalMessage . ' ' . $messageUseMethod, $badRequestCode);
} elseif (isset($deprecationPolicy['deprecated']) && $this->_app->isDeveloperMode()) {
$deprecationMessage = $this->_helper->__('Version "%s" of "%s" method in "%s" resource is deprecated.', $resourceVersion, $method, $resourceName);
throw new Mage_Webapi_Exception($deprecationMessage . ' ' . $messageUseMethod, $badRequestCode);
}
}
}
示例4: _renderMessages
/**
* Generate and set HTTP response code, error messages to Response object.
*/
protected function _renderMessages()
{
$formattedMessages = array();
$formattedMessages['messages'] = $this->getMessages();
$responseHttpCode = null;
/** @var Exception $exception */
foreach ($this->getException() as $exception) {
$code = $exception instanceof Mage_Webapi_Exception ? $exception->getCode() : Mage_Webapi_Exception::HTTP_INTERNAL_ERROR;
$messageData = array('code' => $code, 'message' => $exception->getMessage());
if ($this->_app->isDeveloperMode()) {
$messageData['trace'] = $exception->getTraceAsString();
}
$formattedMessages['messages']['error'][] = $messageData;
// keep HTTP code for response
$responseHttpCode = $code;
}
// set HTTP code of the last error, Content-Type, and all rendered error messages to body
$this->setHttpResponseCode($responseHttpCode);
$this->setMimeType($this->_renderer->getMimeType());
$this->setBody($this->_renderer->render($formattedMessages));
return $this;
}