本文整理汇总了PHP中Magento\Framework\Message\ManagerInterface类的典型用法代码示例。如果您正苦于以下问题:PHP ManagerInterface类的具体用法?PHP ManagerInterface怎么用?PHP ManagerInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ManagerInterface类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: 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);
}
开发者ID:dotmailer,项目名称:dotmailer-magento2-extension,代码行数:10,代码来源:Deletecontactids.php
示例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;
}
开发者ID:dotmailer,项目名称:dotmailer-magento2-extension,代码行数:36,代码来源:ApiValidate.php
示例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());
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:25,代码来源:SaveTest.php
示例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.'));
}
}
开发者ID:Doability,项目名称:magento2dev,代码行数:12,代码来源:Auth.php
示例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);
}
开发者ID:dotmailer,项目名称:dotmailer-magento2-extension,代码行数:10,代码来源:Ordersync.php
示例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());
}
开发者ID:opexsw,项目名称:magento2,代码行数:13,代码来源:FrontController.php
示例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);
}
开发者ID:dotmailer,项目名称:dotmailer-magento2-extension,代码行数:10,代码来源:Importersync.php
示例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;
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:36,代码来源:WishlistProvider.php
示例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.'));
}
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:12,代码来源:Iframe.php
示例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);
}
开发者ID:dotmailer,项目名称:dotmailer-magento2-extension,代码行数:10,代码来源:Catalogreset.php
示例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);
}
开发者ID:dotmailer,项目名称:dotmailer-magento2-extension,代码行数:10,代码来源:Contactsync.php
示例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();
}
开发者ID:ytorbyk,项目名称:magento2-geo-store-switcher,代码行数:12,代码来源:Regexp.php
示例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());
}
开发者ID:ytorbyk,项目名称:magento2-geo-store-switcher,代码行数:8,代码来源:RegexpTest.php
示例16: getSectionData
/**
* {@inheritdoc}
*/
public function getSectionData()
{
$messages = $this->messageManager->getMessages(true);
return ['messages' => array_reduce($messages->getItems(), function (array $result, MessageInterface $message) {
$result[] = ['type' => $message->getType(), 'text' => $message->getText()];
return $result;
}, [])];
}
开发者ID:nja78,项目名称:magento2,代码行数:11,代码来源:Messages.php
示例17: testLoadCustomerQuoteThrowingException
public function testLoadCustomerQuoteThrowingException()
{
$exception = new \Exception('Message');
$this->checkoutSession->expects($this->once())->method('loadCustomerQuote')->will($this->throwException($exception));
$this->messageManager->expects($this->once())->method('addException')->with($exception, 'Load customer quote error');
$observerMock = $this->getMockBuilder('Magento\\Framework\\Event\\Observer')->disableOriginalConstructor()->getMock();
$this->object->execute($observerMock);
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:8,代码来源:LoadCustomerQuoteObserverTest.php
示例18: testDeleteActionNoId
public function testDeleteActionNoId()
{
$this->requestMock->expects($this->once())->method('getParam')->willReturn(null);
$this->messageManagerMock->expects($this->once())->method('addError')->with(__('We can\'t find a synonym group to delete.'));
$this->messageManagerMock->expects($this->never())->method('addSuccess');
$this->resultRedirectMock->expects($this->once())->method('setPath')->with('*/*/')->willReturnSelf();
$this->assertSame($this->resultRedirectMock, $this->deleteController->execute());
}
开发者ID:Doability,项目名称:magento2dev,代码行数:8,代码来源:DeleteTest.php
示例19: checkSearchEngineSupport
/**
* Checks if 'synonyms' feature is supported by configured search engine. If not supported displays a notice
*
* @return void
*/
protected function checkSearchEngineSupport()
{
// Display a notice if search engine configuration does not support synonyms
$searchEngine = $this->engineResolver->getCurrentSearchEngine();
if (!$this->searchFeatureConfig->isFeatureSupported(\Magento\Framework\Search\SearchEngine\ConfigInterface::SEARCH_ENGINE_FEATURE_SYNONYMS, $searchEngine)) {
$this->messageManager->addNoticeMessage(__('Search synonyms are not supported by the %1 search engine. ' . 'Any synonyms you enter won\'t be used.', $searchEngine));
}
}
开发者ID:Doability,项目名称:magento2dev,代码行数:13,代码来源:ResultPageBuilder.php
示例20: 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
注:本文中的Magento\Framework\Message\ManagerInterface类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论