当前位置: 首页>>代码示例>>PHP>>正文


PHP ManagerInterface::addError方法代码示例

本文整理汇总了PHP中Magento\Framework\Message\ManagerInterface::addError方法的典型用法代码示例。如果您正苦于以下问题:PHP ManagerInterface::addError方法的具体用法?PHP ManagerInterface::addError怎么用?PHP ManagerInterface::addError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Framework\Message\ManagerInterface的用法示例。


在下文中一共展示了ManagerInterface::addError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 /**
  * Update items stock status and low stock date.
  *
  * @param Observer $observer
  * @return void
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function execute(Observer $observer)
 {
     if ($this->config->isNewRelicEnabled()) {
         if (!$this->newRelicWrapper->isExtensionInstalled()) {
             $this->config->disableModule();
             $this->messageManager->addError(__('The New Relic integration requires the newrelic-php5 agent, which is not installed. More 
                     information on installing the agent is available <a target="_blank" href="%1">here</a>.', 'https://docs.newrelic.com/docs/agents/php-agent/installation/php-agent-installation-overview'), $this->messageManager->getDefaultGroup());
         }
     }
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:17,代码来源:CheckConfig.php

示例2: execute

 /**
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     try {
         $this->checkoutSession->loadCustomerQuote();
     } catch (\Magento\Framework\Exception\LocalizedException $e) {
         $this->messageManager->addError($e->getMessage());
     } catch (\Exception $e) {
         $this->messageManager->addException($e, __('Load customer quote error'));
     }
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:15,代码来源:LoadCustomerQuoteObserver.php

示例3: handleException

 /**
  * Handle exception
  *
  * @param \Exception $e
  * @return void
  */
 protected function handleException($e)
 {
     $needToMaskDisplayMessage = !$e instanceof \Magento\Framework\Exception\LocalizedException && $this->appState->getMode() != State::MODE_DEVELOPER;
     $displayMessage = $needToMaskDisplayMessage ? (string) new \Magento\Framework\Phrase('An error occurred while processing your request') : $e->getMessage();
     $this->messageManager->addError($displayMessage);
     $this->logger->critical($e->getMessage());
 }
开发者ID:opexsw,项目名称:magento2,代码行数:13,代码来源:FrontController.php

示例4: getWishlist

 /**
  * {@inheritdoc}
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function getWishlist($wishlistId = null)
 {
     if ($this->wishlist) {
         return $this->wishlist;
     }
     try {
         if (!$wishlistId) {
             $wishlistId = $this->request->getParam('wishlist_id');
         }
         $customerId = $this->customerSession->getCustomerId();
         $wishlist = $this->wishlistFactory->create();
         if (!$wishlistId && !$customerId) {
             return $wishlist;
         }
         if ($wishlistId) {
             $wishlist->load($wishlistId);
         } elseif ($customerId) {
             $wishlist->loadByCustomerId($customerId, true);
         }
         if (!$wishlist->getId() || $wishlist->getCustomerId() != $customerId) {
             throw new \Magento\Framework\Exception\NoSuchEntityException(__('The requested Wish List doesn\'t exist.'));
         }
     } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
         $this->messageManager->addError($e->getMessage());
         return false;
     } catch (\Exception $e) {
         $this->messageManager->addException($e, __('We can\'t create the Wish List right now.'));
         return false;
     }
     $this->wishlist = $wishlist;
     return $wishlist;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:36,代码来源:WishlistProvider.php

示例5: beforeExecute

 /**
  * Before execute login
  *
  * @param Login $login
  * @return void
  */
 public function beforeExecute(Login $login)
 {
     $logoutReasonCode = $this->securityCookieHelper->getLogoutReasonCookie();
     if ($this->isLoginForm($login) && $logoutReasonCode >= 0) {
         $this->messageManager->addError($this->sessionsManager->getLogoutReasonMessageByStatus($logoutReasonCode));
         $this->securityCookieHelper->deleteLogoutReasonCookie();
     }
 }
开发者ID:dragonsword007008,项目名称:magento2,代码行数:14,代码来源:LoginController.php

示例6: addUserLogoutNotification

 /**
  * Add user logout notification
  *
  * @return $this
  */
 protected function addUserLogoutNotification()
 {
     if ($this->isAjaxRequest()) {
         $this->securityCookieHelper->setLogoutReasonCookie($this->sessionsManager->getCurrentSession()->getStatus());
     } else {
         $this->messageManager->addError($this->sessionsManager->getLogoutReasonMessage());
     }
     return $this;
 }
开发者ID:dragonsword007008,项目名称:magento2,代码行数:14,代码来源:AuthSession.php

示例7: loadCustomerQuote

 /**
  * @return void
  */
 public function loadCustomerQuote()
 {
     try {
         $this->_checkoutSession->loadCustomerQuote();
     } catch (\Magento\Framework\Model\Exception $e) {
         $this->messageManager->addError($e->getMessage());
     } catch (\Exception $e) {
         $this->messageManager->addException($e, __('Load customer quote error'));
     }
 }
开发者ID:aiesh,项目名称:magento2,代码行数:13,代码来源:Observer.php

示例8: validateRequireEntry

 /**
  * Check if required fields is not empty
  *
  * @param array $data
  * @return bool
  */
 public function validateRequireEntry(array $data)
 {
     $requiredFields = ['title' => __('Page Title'), 'stores' => __('Store View'), 'is_active' => __('Status')];
     $errorNo = true;
     foreach ($data as $field => $value) {
         if (in_array($field, array_keys($requiredFields)) && $value == '') {
             $errorNo = false;
             $this->messageManager->addError(__('To apply changes you should fill in hidden required "%1" field', $requiredFields[$field]));
         }
     }
     return $errorNo;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:18,代码来源:PostDataProcessor.php

示例9: execute

 /**
  * Update saved shipping methods available for ShipperHQ
  *
  * @param EventObserver $observer
  * @return void
  */
 public function execute(EventObserver $observer)
 {
     if ($this->shipperDataHelper->getConfigValue('carriers/shipper/active')) {
         $refreshResult = $this->shipperCarrier->refreshCarriers();
         if (array_key_exists('error', $refreshResult)) {
             $message = __($refreshResult['error']);
             $this->messageManager->addError($message);
         } else {
             $message = __('%1 carriers have been updated from ShipperHQ', count($refreshResult));
             $this->messageManager->addSuccess($message);
         }
     }
 }
开发者ID:shipperhq,项目名称:module-shipper,代码行数:19,代码来源:RefreshCarriers.php

示例10: execute

 /**
  * Check CAPTCHA on Contact Us page
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     $formId = 'contact_us';
     $captcha = $this->_helper->getCaptcha($formId);
     if ($captcha->isRequired()) {
         /** @var \Magento\Framework\App\Action\Action $controller */
         $controller = $observer->getControllerAction();
         if (!$captcha->isCorrect($this->captchaStringResolver->resolve($controller->getRequest(), $formId))) {
             $this->messageManager->addError(__('Incorrect CAPTCHA.'));
             $this->_actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
             $this->redirect->redirect($controller->getResponse(), 'contact/index/index');
         }
     }
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:20,代码来源:CheckContactUsFormObserver.php

示例11: 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()}");
     }
 }
开发者ID:compropago,项目名称:plugin-magento-2,代码行数:19,代码来源:WebhookRegister.php

示例12: _checkFullPath

 /**
  * Check file system full path
  *
  * @param  string $fullPath
  * @param  bool $recursive
  * @param  bool $existence
  * @return bool
  */
 protected function _checkFullPath($fullPath, $recursive, $existence)
 {
     $result = true;
     $directory = $this->_filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::ROOT_DIR);
     $path = $directory->getRelativePath($fullPath);
     if ($recursive && $directory->isDirectory($path)) {
         $pathsToCheck = $directory->read($path);
         array_unshift($pathsToCheck, $path);
     } else {
         $pathsToCheck = array($path);
     }
     $skipFileNames = array('.svn', '.htaccess');
     foreach ($pathsToCheck as $pathToCheck) {
         if (in_array(basename($pathToCheck), $skipFileNames)) {
             continue;
         }
         if ($existence) {
             $setError = !$directory->isWritable($path);
         } else {
             $setError = $directory->isExist($path) && !$directory->isWritable($path);
         }
         if ($setError) {
             $this->messageManager->addError(__('Path "%1" must be writable.', $pathToCheck));
             $result = false;
         }
     }
     return $result;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:36,代码来源:Filesystem.php

示例13: execute

 /**
  * Check captcha on user login page
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @throws NoSuchEntityException
  * @return $this
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     $formId = 'user_login';
     $captchaModel = $this->_helper->getCaptcha($formId);
     $controller = $observer->getControllerAction();
     $loginParams = $controller->getRequest()->getPost('login');
     $login = is_array($loginParams) && array_key_exists('username', $loginParams) ? $loginParams['username'] : null;
     if ($captchaModel->isRequired($login)) {
         $word = $this->captchaStringResolver->resolve($controller->getRequest(), $formId);
         if (!$captchaModel->isCorrect($word)) {
             try {
                 $customer = $this->getCustomerRepository()->get($login);
                 $this->getAuthentication()->processAuthenticationFailure($customer->getId());
             } catch (NoSuchEntityException $e) {
                 //do nothing as customer existance is validated later in authenticate method
             }
             $this->messageManager->addError(__('Incorrect CAPTCHA'));
             $this->_actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
             $this->_session->setUsername($login);
             $beforeUrl = $this->_session->getBeforeAuthUrl();
             $url = $beforeUrl ? $beforeUrl : $this->_customerUrl->getLoginUrl();
             $controller->getResponse()->setRedirect($url);
         }
     }
     $captchaModel->logAttempt($login);
     return $this;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:34,代码来源:CheckUserLoginObserver.php

示例14: checkCronStatus

 /**
  * Method allows to display message about not working cron job in admin panel.
  * Need call at start of adminhtml controller action.
  *
  * @param string $jobCode Cron job code (from crontab.xml).
  * @param bool   $output  By default - return cron error as adminhtml error message, otherwise - as string.
  * @param string $prefix  Additional text to cron job error message.
  * @return array [$status, $message]
  */
 public function checkCronStatus($jobCode, $output = true, $prefix = '')
 {
     if (!$this->isCronRunning($jobCode)) {
         $message = '';
         if ($prefix) {
             $message .= $prefix . ' ';
         }
         $message .= __('Cron for magento is not running.' . ' To setup a cron job follow the <a target="_blank" href="%1">link</a>', 'http://devdocs.magento.com/guides/v2.0/config-guide/cli/config-cli-subcommands-cron.html');
         if ($output) {
             $this->messageManager->addError($message);
         } else {
             return [false, $message];
         }
     }
     return [true, ''];
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:25,代码来源:Cron.php

示例15: load

 /**
  * Load invoice
  * @deprecated
  * @param int $orderId
  * @param null|int $invoiceId
  * @param array $invoiceItems
  * @return \Magento\Sales\Model\Order\Invoice | bool
  * @throws \Exception
  */
 public function load($orderId, $invoiceId = null, array $invoiceItems = [])
 {
     $invoice = false;
     if ($invoiceId) {
         $invoice = $this->_objectManager->create('Magento\\Sales\\Model\\Order\\Invoice')->load($invoiceId);
         if (!$invoice->getId()) {
             $this->messageManager->addError(__('The invoice no longer exists.'));
             return false;
         }
     } elseif ($orderId) {
         $order = $this->_objectManager->create('Magento\\Sales\\Model\\Order')->load($orderId);
         /**
          * Check order existing
          */
         if (!$order->getId()) {
             $this->messageManager->addError(__('The order no longer exists.'));
             return false;
         }
         /**
          * Check invoice create availability
          */
         if (!$order->canInvoice()) {
             $this->messageManager->addError(__('The order does not allow an invoice to be created.'));
             return false;
         }
         $invoice = $this->_objectManager->create('Magento\\Sales\\Model\\Service\\Order', array('order' => $order))->prepareInvoice($invoiceItems);
         if (!$invoice->getTotalQty()) {
             throw new \Exception(__('Cannot create an invoice without products.'));
         }
     }
     $this->registry->register('current_invoice', $invoice);
     return $invoice;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:42,代码来源:InvoiceLoader.php


注:本文中的Magento\Framework\Message\ManagerInterface::addError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。