本文整理汇总了PHP中Magento\Framework\Message\ManagerInterface::addNotice方法的典型用法代码示例。如果您正苦于以下问题:PHP ManagerInterface::addNotice方法的具体用法?PHP ManagerInterface::addNotice怎么用?PHP ManagerInterface::addNotice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Message\ManagerInterface
的用法示例。
在下文中一共展示了ManagerInterface::addNotice方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeSave
/**
* @return $this
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function beforeSave()
{
if (!empty($this->getValue()) && !$this->_isRegexp($this->getValue())) {
$this->messageManager->addNotice(__('Invalid regular expression: %value', ['value' => $this->getValue()]));
$this->setValue(null);
}
return parent::beforeSave();
}
示例2: execute
/**
* @param Observer $observer
* @return void
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
$dirtyRules = $observer->getData('dirty_rules');
if (!empty($dirtyRules)) {
if ($dirtyRules->getState()) {
$this->messageManager->addNotice($observer->getData('message'));
}
}
}
示例3: execute
/**
* Prevent express checkout
*
* @param \Magento\Framework\Event\Observer $observer
* @return void
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
if (!($this->_persistentSession->isPersistent() && !$this->_customerSession->isLoggedIn())) {
return;
}
/** @var $controllerAction \Magento\Checkout\Controller\Express\RedirectLoginInterface*/
$controllerAction = $observer->getEvent()->getControllerAction();
if (!$controllerAction || !$controllerAction instanceof \Magento\Checkout\Controller\Express\RedirectLoginInterface || $controllerAction->getRedirectActionName() != $controllerAction->getRequest()->getActionName()) {
return;
}
$this->messageManager->addNotice(__('To check out, please sign in using your email address.'));
$customerBeforeAuthUrl = $this->_url->getUrl('persistent/index/expressCheckout');
$this->_expressRedirectHelper->redirectLogin($controllerAction, $customerBeforeAuthUrl);
}
示例4: execute
/**
* @param Observer $observer
* @return void
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
$webhook = $this->storeManager->getStore()->getBaseUrl() . "cpwebhook/";
try {
$client = new Client($this->model->getPublicKey(), $this->model->getPrivateKey(), $this->model->getLiveMode());
Validations::validateGateway($client);
$client->api->createWebhook($webhook);
$response = $client->api->hookRetro($this->model->getConfigData('active') == 1);
if ($response[0]) {
$this->messageManager->addNotice("ComproPago: {$response[1]}");
}
} catch (\Exception $e) {
$this->messageManager->addError("ComproPago: {$e->getMessage()}");
}
}
示例5: updateItems
/**
* Update cart items information
*
* @param array $data
* @return $this
* @throws \Magento\Framework\Exception\LocalizedException
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function updateItems($data)
{
$infoDataObject = new \Magento\Framework\Object($data);
$this->_eventManager->dispatch('checkout_cart_update_items_before', ['cart' => $this, 'info' => $infoDataObject]);
$qtyRecalculatedFlag = false;
foreach ($data as $itemId => $itemInfo) {
$item = $this->getQuote()->getItemById($itemId);
if (!$item) {
continue;
}
if (!empty($itemInfo['remove']) || isset($itemInfo['qty']) && $itemInfo['qty'] == '0') {
$this->removeItem($itemId);
continue;
}
$qty = isset($itemInfo['qty']) ? (double) $itemInfo['qty'] : false;
if ($qty > 0) {
$item->setQty($qty);
$itemInQuote = $this->getQuote()->getItemById($item->getId());
if (!$itemInQuote && $item->getHasError()) {
throw new \Magento\Framework\Exception\LocalizedException(__($item->getMessage()));
}
if (isset($itemInfo['before_suggest_qty']) && $itemInfo['before_suggest_qty'] != $qty) {
$qtyRecalculatedFlag = true;
$this->messageManager->addNotice(__('Quantity was recalculated from %1 to %2', $itemInfo['before_suggest_qty'], $qty), 'quote_item' . $item->getId());
}
}
}
if ($qtyRecalculatedFlag) {
$this->messageManager->addNotice(__('Some products quantities were recalculated because of quantity increment mismatch.'));
}
$this->_eventManager->dispatch('checkout_cart_update_items_after', ['cart' => $this, 'info' => $infoDataObject]);
return $this;
}
示例6: eavAttributeChange
/**
* Update all attribute-dependant index
*
* @param \Magento\Framework\Event\Observer $observer
* @return \Magento\CatalogSearch\Model\Fulltext\Observer
*/
public function eavAttributeChange(\Magento\Framework\Event\Observer $observer)
{
$attribute = $observer->getEvent()->getAttribute();
/* @var $attribute \Magento\Eav\Model\Entity\Attribute */
$entityType = $this->_eavConfig->getEntityType(\Magento\Catalog\Model\Product::ENTITY);
/* @var $entityType \Magento\Eav\Model\Entity\Type */
if ($attribute->getEntityTypeId() != $entityType->getId()) {
return $this;
}
$delete = $observer->getEventName() == 'eav_entity_attribute_delete_after';
if (!$delete && !$attribute->dataHasChangedFor('is_searchable')) {
return $this;
}
$showNotice = false;
if ($delete) {
if ($attribute->getIsSearchable()) {
$showNotice = true;
}
} elseif ($attribute->dataHasChangedFor('is_searchable')) {
$showNotice = true;
}
if ($showNotice) {
$url = $this->_backendUrl->getUrl('adminhtml/system_cache');
$this->messageManager->addNotice(__('Attribute setting change related with Search Index. Please run <a href="%1">Rebuild Search Index</a> process.', $url));
}
return $this;
}
示例7: execute
/**
*
* @param \Magento\Framework\Event\Observer $observer
* @return $this
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
if ($observer->getStore()) {
$scopeId = $observer->getStore();
$scopeType = \Magento\Store\Model\ScopeInterface::SCOPE_STORE;
} elseif ($observer->getWebsite()) {
$scopeId = $observer->getWebsite();
$scopeType = \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE;
} else {
$scopeId = \Magento\Store\Model\Store::DEFAULT_STORE_ID;
$scopeType = \Magento\Store\Model\ScopeInterface::SCOPE_STORE;
}
foreach ($this->getErrors($scopeId, $scopeType) as $error) {
$this->messageManager->addError($error);
}
foreach ($this->getNotices() as $notice) {
$this->messageManager->addNotice($notice);
}
return $this;
}
示例8: beforeSave
/**
* Validate ip addresses before save
*
* @return $this
*/
public function beforeSave()
{
$allowedIpsRaw = $this->getValue();
$noticeMsgArray = [];
$allowedIpsArray = [];
if (empty($allowedIpsRaw)) {
return parent::beforeSave();
}
$dataArray = explode(',', $allowedIpsRaw);
foreach ($dataArray as $data) {
if (filter_var(trim($data), FILTER_VALIDATE_IP)) {
$allowedIpsArray[] = $data;
} else {
$noticeMsgArray[] = $data;
}
}
$noticeMsg = implode(',', $noticeMsgArray);
if (!empty($noticeMsgArray)) {
$this->messageManager->addNotice(__(__('The following invalid values cannot be saved: %values', ['values' => $noticeMsg])));
}
$this->setValue(implode(',', $allowedIpsArray));
return parent::beforeSave();
}
示例9: execute
/**
* {@inheritdoc}
* @param Observer $observer
* @return bool
*/
public function execute(Observer $observer)
{
if ($this->config->isNorouteToSearchEnabled()) {
/** @var \Magento\Framework\App\Request\Http $request */
$request = $observer->getEvent()->getData('request');
/** @var \Magento\Framework\App\Response\Http\Interceptor $response */
$response = $observer->getEvent()->getData('response');
$extension = pathinfo($request->getRequestString(), PATHINFO_EXTENSION);
if ($response->getStatusCode() != 404 || !$request->isGet() || in_array($extension, $this->mediaTypes)) {
return false;
} else {
$searchQuery = $this->getSearchQuery($request);
if (!$searchQuery) {
return false;
}
$message = __('The page you requested was not found, but we have searched for relevant content.');
$this->messageManager->addNotice($message);
$url = $this->urlFactory->create()->addQueryParams(['q' => $searchQuery])->getUrl('catalogsearch/result');
$response->setRedirect($url)->setStatusCode(301)->sendResponse();
}
}
return true;
}
示例10: execute
/**
* @return \Magento\Framework\Controller\Result\Redirect|\Magento\Framework\Controller\ResultInterface
*/
public function execute()
{
$email = $this->getRequest()->getParam('email', false);
$list = $this->getRequest()->getParam('list', false);
$store = $this->getRequest()->getParam('store', false);
if ($email && $list && $store) {
$collection = $this->_objectManager->create('\\Ebizmarts\\Mandrill\\Model\\Unsubscribe')->getCollection();
$collection->addFieldToFilter('main_table.email', array('eq' => $email))->addFieldToFilter('main_table.list', array('eq' => $list))->addFieldToFilter('main_table.store_id', array('eq' => $store))->limit(1);
if ($collection->getSize() == 0) {
$unsubscribe = $this->_objectManager->create('\\Ebizmarts\\Mandrill\\Model\\Unsubscribe');
$unsubscribe->setEmail($email)->setList($list)->setStoreId($store)->setUnsubscribedAt(date('Y-m-d H:i:s'));
$unsubscribe->save();
$this->messageManager->addNotice("You are unsubcribed from {$list}");
} else {
$this->messageManager->addNotice("You are already unsubcribed from {$list}");
}
} else {
$this->messageManager->addNotice("Invalid url format");
}
$resultRedirect = $this->_resultRedirectFactory->create();
$resultRedirect->setPath('/');
return $resultRedirect;
}
示例11: addNotice
public function addNotice($message, $popupText = null, $popupTitle = null)
{
$popupId = $this->addPopup($popupText, $popupTitle);
$this->messageManager->addNotice($this->getMessageText($message, $popupId));
}