本文整理汇总了PHP中Magento\Framework\Logger::logException方法的典型用法代码示例。如果您正苦于以下问题:PHP Logger::logException方法的具体用法?PHP Logger::logException怎么用?PHP Logger::logException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Logger
的用法示例。
在下文中一共展示了Logger::logException方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Get associated grouped products grid popup
*
* @return void
*/
public function execute()
{
$productId = (int) $this->getRequest()->getParam('id');
/** @var $product \Magento\Catalog\Model\Product */
$product = $this->factory->create();
$product->setStoreId($this->getRequest()->getParam('store', 0));
$typeId = $this->getRequest()->getParam('type');
if (!$productId && $typeId) {
$product->setTypeId($typeId);
}
$product->setData('_edit_mode', true);
if ($productId) {
try {
$product->load($productId);
} catch (\Exception $e) {
$product->setTypeId(\Magento\Catalog\Model\Product\Type::DEFAULT_TYPE);
$this->logger->logException($e);
}
}
$setId = (int) $this->getRequest()->getParam('set');
if ($setId) {
$product->setAttributeSetId($setId);
}
$this->registry->register('current_product', $product);
$this->_view->loadLayout(false);
$this->_view->renderLayout();
}
示例2: build
/**
* Build product based on user request
*
* @param RequestInterface $request
* @return \Magento\Catalog\Model\Product
*/
public function build(RequestInterface $request)
{
$productId = (int) $request->getParam('id');
/** @var $product \Magento\Catalog\Model\Product */
$product = $this->productFactory->create();
$product->setStoreId($request->getParam('store', 0));
$typeId = $request->getParam('type');
if (!$productId && $typeId) {
$product->setTypeId($typeId);
}
$product->setData('_edit_mode', true);
if ($productId) {
try {
$product->load($productId);
} catch (\Exception $e) {
$product->setTypeId(\Magento\Catalog\Model\Product\Type::DEFAULT_TYPE);
$this->logger->logException($e);
}
}
$setId = (int) $request->getParam('set');
if ($setId) {
$product->setAttributeSetId($setId);
}
$this->registry->register('product', $product);
$this->registry->register('current_product', $product);
$this->wysiwygConfig->setStoreId($request->getParam('store'));
return $product;
}
示例3: invoke
/**
* Create order
*
* @param \Magento\Sales\Service\V1\Data\Order $orderDataObject
* @return bool
* @throws \Exception
*/
public function invoke(\Magento\Sales\Service\V1\Data\Order $orderDataObject)
{
try {
$order = $this->orderConverter->getModel($orderDataObject);
return (bool) $order->save();
} catch (\Exception $e) {
$this->logger->logException($e);
throw new \Exception(__('An error has occurred during order creation'));
}
}
示例4: send
/**
* Send email about new order.
* Process mail exception
*
* @param Order $order
* @return bool
*/
public function send(Order $order)
{
try {
$this->orderSender->send($order);
} catch (\Magento\Framework\Mail\Exception $exception) {
$this->logger->logException($exception);
$this->messageManager->addWarning(__('You did not email your customer. Please check your email settings.'));
return false;
}
return true;
}
示例5: execute
/**
* Instantiate IPN model and pass IPN request to it
*
* @return void
*/
public function execute()
{
if (!$this->getRequest()->isPost()) {
return;
}
try {
$data = $this->getRequest()->getPost();
$this->_ipnFactory->create(array('data' => $data))->processIpnRequest();
} catch (\Exception $e) {
$this->_logger->logException($e);
}
}
示例6: invoke
/**
* @param \Magento\Sales\Service\V1\Data\Invoice $invoiceDataObject
* @return bool
* @throws \Exception
*/
public function invoke(\Magento\Sales\Service\V1\Data\Invoice $invoiceDataObject)
{
try {
/** @var \Magento\Sales\Model\Order\Invoice $invoice */
$invoice = $this->invoiceConverter->getModel($invoiceDataObject);
if (!$invoice) {
return false;
}
$invoice->register();
$invoice->save();
return true;
} catch (\Exception $e) {
$this->logger->logException($e);
throw new \Exception(__('An error has occurred during creating Invoice'));
}
}
示例7: setAddress
/**
* {@inheritdoc}
*/
public function setAddress($cartId, $addressData)
{
/** @var \Magento\Sales\Model\Quote $quote */
$quote = $this->quoteLoader->load($cartId, $this->storeManager->getStore()->getId());
if ($quote->isVirtual()) {
throw new NoSuchEntityException('Cart contains virtual product(s) only. Shipping address is not applicable');
}
/** @var \Magento\Sales\Model\Quote\Address $address */
$address = $this->quoteAddressFactory->create();
$this->addressValidator->validate($addressData);
if ($addressData->getId()) {
$address->load($addressData->getId());
}
$address = $this->addressConverter->convertDataObjectToModel($addressData, $address);
$address->setSameAsBilling(0);
$quote->setShippingAddress($address);
$quote->setDataChanges(true);
try {
$quote->save();
} catch (\Exception $e) {
$this->logger->logException($e);
throw new InputException('Unable to save address. Please, check input data.');
}
return $quote->getShippingAddress()->getId();
}
示例8: scheduledBackup
/**
* Create Backup
*
* @return $this
*/
public function scheduledBackup()
{
if (!$this->_scopeConfig->isSetFlag(self::XML_PATH_BACKUP_ENABLED, ScopeInterface::SCOPE_STORE)) {
return $this;
}
if ($this->_scopeConfig->isSetFlag(self::XML_PATH_BACKUP_MAINTENANCE_MODE, ScopeInterface::SCOPE_STORE)) {
$this->maintenanceMode->set(true);
}
$type = $this->_scopeConfig->getValue(self::XML_PATH_BACKUP_TYPE, ScopeInterface::SCOPE_STORE);
$this->_errors = array();
try {
$backupManager = $this->_backupFactory->create($type)->setBackupExtension($this->_backupData->getExtensionByType($type))->setTime(time())->setBackupsDir($this->_backupData->getBackupsDir());
$this->_coreRegistry->register('backup_manager', $backupManager);
if ($type != \Magento\Framework\Backup\Factory::TYPE_DB) {
$backupManager->setRootDir($this->_filesystem->getPath(\Magento\Framework\App\Filesystem::ROOT_DIR))->addIgnorePaths($this->_backupData->getBackupIgnorePaths());
}
$backupManager->create();
$message = $this->_backupData->getCreateSuccessMessageByType($type);
$this->_logger->log($message);
} catch (\Exception $e) {
$this->_errors[] = $e->getMessage();
$this->_errors[] = $e->getTrace();
$this->_logger->log($e->getMessage(), \Zend_Log::ERR);
$this->_logger->logException($e);
}
if ($this->_scopeConfig->isSetFlag(self::XML_PATH_BACKUP_MAINTENANCE_MODE, ScopeInterface::SCOPE_STORE)) {
$this->maintenanceMode->set(false);
}
return $this;
}
示例9: _getTZOffsetTransitions
/**
* Retrieve transitions for offsets of given timezone
*
* @param string $timezone
* @param mixed $from
* @param mixed $to
* @return array
*/
protected function _getTZOffsetTransitions($timezone, $from = null, $to = null)
{
$tzTransitions = array();
try {
if (!empty($from)) {
$from = new \Magento\Framework\Stdlib\DateTime\Date($from, \Magento\Framework\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT);
$from = $from->getTimestamp();
}
$to = new \Magento\Framework\Stdlib\DateTime\Date($to, \Magento\Framework\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT);
$nextPeriod = $this->_getWriteAdapter()->formatDate($to->toString(\Magento\Framework\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT));
$to = $to->getTimestamp();
$dtz = new \DateTimeZone($timezone);
$transitions = $dtz->getTransitions();
$dateTimeObject = new \Magento\Framework\Stdlib\DateTime\Date('c');
for ($i = count($transitions) - 1; $i >= 0; $i--) {
$tr = $transitions[$i];
try {
$this->timezoneValidator->validate($tr['ts'], $to);
} catch (\Magento\Framework\Stdlib\DateTime\Timezone\ValidationException $e) {
continue;
}
$dateTimeObject->set($tr['time']);
$tr['time'] = $this->_getWriteAdapter()->formatDate($dateTimeObject->toString(\Magento\Framework\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT));
$tzTransitions[$tr['offset']][] = array('from' => $tr['time'], 'to' => $nextPeriod);
if (!empty($from) && $tr['ts'] < $from) {
break;
}
$nextPeriod = $tr['time'];
}
} catch (\Exception $e) {
$this->_logger->logException($e);
}
return $tzTransitions;
}
示例10: postToConsumer
/**
* {@inheritdoc}
*/
public function postToConsumer($consumerId, $endpointUrl)
{
try {
$consumer = $this->_consumerFactory->create()->load($consumerId);
if (!$consumer->getId()) {
throw new \Magento\Framework\Oauth\Exception(__('A consumer with ID %1 does not exist', $consumerId), OauthInterface::ERR_PARAMETER_REJECTED);
}
$consumerData = $consumer->getData();
$verifier = $this->_tokenFactory->create()->createVerifierToken($consumerId);
$storeBaseUrl = $this->_storeManager->getStore()->getBaseUrl();
$this->_httpClient->setUri($endpointUrl);
$this->_httpClient->setParameterPost(array('oauth_consumer_key' => $consumerData['key'], 'oauth_consumer_secret' => $consumerData['secret'], 'store_base_url' => $storeBaseUrl, 'oauth_verifier' => $verifier->getVerifier()));
$maxredirects = $this->_dataHelper->getConsumerPostMaxRedirects();
$timeout = $this->_dataHelper->getConsumerPostTimeout();
$this->_httpClient->setConfig(array('maxredirects' => $maxredirects, 'timeout' => $timeout));
$this->_httpClient->request(\Magento\Framework\HTTP\ZendClient::POST);
return $verifier->getVerifier();
} catch (\Magento\Framework\Model\Exception $exception) {
throw $exception;
} catch (\Magento\Framework\Oauth\Exception $exception) {
throw $exception;
} catch (\Exception $exception) {
$this->_logger->logException($exception);
throw new \Magento\Framework\Oauth\Exception('Unable to post data to consumer due to an unexpected error');
}
}
示例11: _logException
/**
* Log information about exception to exception log.
*
* @param \Exception $exception
* @return string $reportId
*/
protected function _logException(\Exception $exception)
{
$exceptionClass = get_class($exception);
$reportId = uniqid("webapi-");
$exceptionForLog = new $exceptionClass("Report ID: {$reportId}; Message: {$exception->getMessage()}", $exception->getCode());
$this->_logger->logException($exceptionForLog);
return $reportId;
}
示例12: invoke
/**
* Invoke CreateShipment service
*
* @param \Magento\Sales\Service\V1\Data\Shipment $shipmentDataObject
* @return bool
* @throws \Exception
*/
public function invoke(\Magento\Sales\Service\V1\Data\Shipment $shipmentDataObject)
{
try {
/** @var \Magento\Sales\Model\Order\Shipment $shipment */
$shipment = $this->shipmentConverter->getModel($shipmentDataObject);
if (!$shipment) {
return false;
}
$shipment->getOrder()->setIsInProcess(true);
$shipment->register();
$shipment->save();
return true;
} catch (\Exception $e) {
$this->logger->logException($e);
throw new \Exception(__('An error has occurred during creating Shipment'));
}
}
示例13: notify
/**
* Notify user
*
* @param AbstractModel $model
* @return bool
* @throws \Magento\Framework\Mail\Exception
*/
public function notify(\Magento\Sales\Model\AbstractModel $model)
{
try {
$this->sender->send($model);
if (!$model->getEmailSent()) {
return false;
}
$historyItem = $this->historyCollectionFactory->create()->getUnnotifiedForInstance($model);
if ($historyItem) {
$historyItem->setIsCustomerNotified(1);
$historyItem->save();
}
} catch (Exception $e) {
$this->logger->logException($e);
return false;
}
return true;
}
示例14: removePermissions
/**
* {@inheritdoc}
*/
public function removePermissions($integrationId)
{
try {
$this->_deleteRole($integrationId);
} catch (\Exception $e) {
$this->_logger->logException($e);
throw new LocalizedException('Error happened while deleting role and permissions. Check exception log for details.');
}
}
示例15: execute
/**
* Instantiate IPN model and pass IPN request to it
*
* @return void
*/
public function execute()
{
if (!$this->getRequest()->isPost()) {
return;
}
try {
$data = $this->getRequest()->getPost();
$this->_ipnFactory->create(array('data' => $data))->processIpnRequest();
} catch (UnavailableException $e) {
$this->_logger->logException($e);
$this->getResponse()->setHeader('HTTP/1.1', '503 Service Unavailable')->sendResponse();
/** @todo eliminate usage of exit statement */
exit;
} catch (\Exception $e) {
$this->_logger->logException($e);
$this->getResponse()->setHttpResponseCode(500);
}
}