本文整理汇总了PHP中Magento\Framework\Message\ManagerInterface类的典型用法代码示例。如果您正苦于以下问题:PHP ManagerInterface类的具体用法?PHP ManagerInterface怎么用?PHP ManagerInterface使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ManagerInterface类的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());
}
}
}
示例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'));
}
}
示例3: execute
/**
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function execute()
{
$redirectUrl = $this->getUrl('adminhtml/system_config/edit', ['section' => 'connector_developer_settings']);
$result = $this->contactFactory->create()->deleteContactIds();
$this->messageManager->addSuccessMessage('Contact id\'s reseted ' . $result);
$this->_redirect($redirectUrl);
}
示例4: 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;
}
示例5: testTryToSaveInvalidDataShouldFailWithErrors
public function testTryToSaveInvalidDataShouldFailWithErrors()
{
$validatorClass = 'Magento\\MediaStorage\\Model\\File\\Validator\\AvailablePath';
$helperClass = 'Magento\\Sitemap\\Helper\\Data';
$validPaths = [];
$messages = ['message1', 'message2'];
$sessionClass = 'Magento\\Backend\\Model\\Session';
$data = ['sitemap_filename' => 'sitemap_filename', 'sitemap_path' => '/sitemap_path'];
$siteMapId = 1;
$this->requestMock->expects($this->once())->method('getPostValue')->willReturn($data);
$this->requestMock->expects($this->once())->method('getParam')->with('sitemap_id')->willReturn($siteMapId);
$validator = $this->getMock($validatorClass, [], [], '', false);
$validator->expects($this->once())->method('setPaths')->with($validPaths)->willReturnSelf();
$validator->expects($this->once())->method('isValid')->with('/sitemap_path/sitemap_filename')->willReturn(false);
$validator->expects($this->once())->method('getMessages')->willReturn($messages);
$helper = $this->getMock($helperClass, [], [], '', false);
$helper->expects($this->once())->method('getValidPaths')->willReturn($validPaths);
$session = $this->getMock($sessionClass, ['setFormData'], [], '', false);
$session->expects($this->once())->method('setFormData')->with($data)->willReturnSelf();
$this->objectManagerMock->expects($this->once())->method('create')->with($validatorClass)->willReturn($validator);
$this->objectManagerMock->expects($this->any())->method('get')->willReturnMap([[$helperClass, $helper], [$sessionClass, $session]]);
$this->messageManagerMock->expects($this->at(0))->method('addError')->withConsecutive([$messages[0]], [$messages[1]])->willReturnSelf();
$this->resultRedirectMock->expects($this->once())->method('setPath')->with('adminhtml/*/edit', ['sitemap_id' => $siteMapId])->willReturnSelf();
$this->assertSame($this->resultRedirectMock, $this->saveController->execute());
}
示例6: afterLogin
/**
* @param \Magento\Backend\Model\Auth $authModel
* @return void
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function afterLogin(\Magento\Backend\Model\Auth $authModel)
{
$this->sessionsManager->processLogin();
if ($this->sessionsManager->getCurrentSession()->isOtherSessionsTerminated()) {
$this->messageManager->addWarning(__('All other open sessions for this account were terminated.'));
}
}
示例7: execute
/**
* Refresh suppressed contacts.
*/
public function execute()
{
$result = $this->cronFactory->create()->orderSync();
$this->messageManager->addSuccessMessage($result['message']);
$redirectUrl = $this->getUrl('adminhtml/system_config/edit', ['section' => 'connector_developer_settings']);
$this->_redirect($redirectUrl);
}
示例8: 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());
}
示例9: execute
/**
* Refresh suppressed contacts.
*/
public function execute()
{
$result = $this->importerFactory->create()->processQueue();
$this->messageManager->addSuccessMessage($result['message']);
$redirectBack = $this->_redirect->getRefererUrl();
$this->_redirect($redirectBack);
}
示例10: 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;
}
示例11: addSuccessMessage
/**
* Add success message
*
* @return void
*/
private function addSuccessMessage()
{
$params = $this->getParams();
if (isset($params['redirect_parent'])) {
$this->messageManager->addSuccess(__('You created the order.'));
}
}
示例12: execute
/**
* Refresh suppressed contacts.
*/
public function execute()
{
$this->catalogFactory->create()->resetCatalog();
$this->messageManager->addSuccessMessage(__('Done.'));
$redirectUrl = $this->getUrl('adminhtml/system_config/edit', ['section' => 'connector_developer_settings']);
$this->_redirect($redirectUrl);
}
示例13: execute
/**
* Refresh suppressed contacts.
*/
public function execute()
{
$result = $this->cronFactory->create()->contactSync();
$this->messageManager->addSuccessMessage($result['message']);
$redirectBack = $this->_redirect->getRefererUrl();
$this->_redirect($redirectBack);
}
示例14: 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();
}
示例15: testBeforeSaveFail
public function testBeforeSaveFail()
{
$wrongValue = '/^mozillai';
$this->regexp->setValue($wrongValue);
$this->messageManager->expects($this->once())->method('addNotice')->with(__('Invalid regular expression: %value', ['value' => $wrongValue]));
$this->regexp->beforeSave();
$this->assertNull($this->regexp->getValue());
}