本文整理汇总了PHP中Magento\Framework\Message\ManagerInterface::addWarningMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP ManagerInterface::addWarningMessage方法的具体用法?PHP ManagerInterface::addWarningMessage怎么用?PHP ManagerInterface::addWarningMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Message\ManagerInterface
的用法示例。
在下文中一共展示了ManagerInterface::addWarningMessage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Execute method.
*
* @param \Magento\Framework\Event\Observer $observer
*
* @return $this
* @codingStandardsIgnoreStart
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
//@codingStandardsIgnoreEnd
$groups = $this->context->getRequest()->getPost('groups');
if (isset($groups['api']['fields']['username']['inherit']) || isset($groups['api']['fields']['password']['inherit'])) {
return $this;
}
$apiUsername = isset($groups['api']['fields']['username']['value']) ? $groups['api']['fields']['username']['value'] : false;
$apiPassword = isset($groups['api']['fields']['password']['value']) ? $groups['api']['fields']['password']['value'] : false;
//skip if the inherit option is selected
if ($apiUsername && $apiPassword) {
$this->helper->log('----VALIDATING ACCOUNT---');
$isValid = $this->test->validate($apiUsername, $apiPassword);
if ($isValid) {
//save endpoint for account
foreach ($isValid->properties as $property) {
if ($property->name == 'ApiEndpoint' && !empty($property->value)) {
$this->saveApiEndpoint($property->value);
break;
}
}
$this->messageManager->addSuccessMessage(__('API Credentials Valid.'));
} else {
$this->messageManager->addWarningMessage(__('Authorization has been denied for this request.'));
}
}
return $this;
}