本文整理汇总了PHP中Magento\Framework\View\Element\AbstractBlock::addError方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractBlock::addError方法的具体用法?PHP AbstractBlock::addError怎么用?PHP AbstractBlock::addError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\View\Element\AbstractBlock
的用法示例。
在下文中一共展示了AbstractBlock::addError方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addErrorMessages
/**
* @param \Magento\Framework\View\Element\AbstractBlock $resultBlock
* @param ProcessingErrorAggregatorInterface $errorAggregator
* @return $this
*/
protected function addErrorMessages(\Magento\Framework\View\Element\AbstractBlock $resultBlock, ProcessingErrorAggregatorInterface $errorAggregator)
{
if ($errorAggregator->getErrorsCount()) {
$message = '';
$counter = 0;
foreach ($this->getErrorMessages($errorAggregator) as $error) {
$message .= ++$counter . '. ' . $error . '<br>';
if ($counter >= self::LIMIT_ERRORS_MESSAGE) {
break;
}
}
if ($errorAggregator->hasFatalExceptions()) {
foreach ($this->getSystemExceptions($errorAggregator) as $error) {
$message .= $error->getErrorMessage() . ' <a href="#" onclick="$(this).next().show();$(this).hide();return false;">' . __('Show more') . '</a><div style="display:none;">' . __('Additional data') . ': ' . $error->getErrorDescription() . '</div>';
}
}
try {
$resultBlock->addNotice('<strong>' . __('Following Error(s) has been occurred during importing process:') . '</strong><br>' . '<div class="import-error-wrapper">' . __('Only first 100 errors are displayed here. ') . '<a href="' . $this->createDownloadUrlImportHistoryFile($this->createErrorReport($errorAggregator)) . '">' . __('Download full report') . '</a><br>' . '<div class="import-error-list">' . $message . '</div></div>');
} catch (\Exception $e) {
foreach ($this->getErrorMessages($errorAggregator) as $errorMessage) {
$resultBlock->addError($errorMessage);
}
}
}
return $this;
}