本文整理匯總了PHP中Magento\Framework\Message\Manager::hasMessages方法的典型用法代碼示例。如果您正苦於以下問題:PHP Manager::hasMessages方法的具體用法?PHP Manager::hasMessages怎麽用?PHP Manager::hasMessages使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Framework\Message\Manager
的用法示例。
在下文中一共展示了Manager::hasMessages方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: afterDispatch
/**
* Set Cookie for msg box when it displays first
*
* @param \Magento\Framework\App\FrontController $subject
* @param \Magento\Framework\App\ResponseInterface $response
*
* @return \Magento\Framework\App\ResponseInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function afterDispatch(\Magento\Framework\App\FrontController $subject, \Magento\Framework\App\ResponseInterface $response)
{
if ($this->request->isPost() && $this->messageManager->hasMessages()) {
$this->cookie->set(self::COOKIE_NAME, 1, self::COOKIE_PERIOD, '/');
}
return $response;
}
示例2: afterDispatch
/**
* Set Cookie for msg box when it displays first
*
* @param FrontController $subject
* @param \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface $result
*
* @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function afterDispatch(FrontController $subject, $result)
{
if ($this->request->isPost() && $this->messageManager->hasMessages()) {
$publicCookieMetadata = $this->cookieMetadataFactory->createPublicCookieMetadata()->setDuration(self::COOKIE_PERIOD)->setPath('/')->setHttpOnly(false);
$this->cookieManager->setPublicCookie(self::COOKIE_NAME, 1, $publicCookieMetadata);
}
return $result;
}
示例3: testAddMessage
/**
* @param string $type
* @param string $methodName
* @dataProvider addMessageDataProvider
*/
public function testAddMessage($type, $methodName)
{
$this->assertFalse($this->model->hasMessages());
$message = 'Message';
$messageCollection = $this->getMock('Magento\\Framework\\Message\\Collection', ['addMessage'], [], '', false);
$this->session->expects($this->any())->method('getData')->will($this->returnValue($messageCollection));
$this->eventManager->expects($this->once())->method('dispatch')->with('session_abstract_add_message');
$this->messageFactory->expects($this->once())->method('create')->with($type, $message)->will($this->returnValue($this->messageMock));
$this->model->{$methodName}($message, 'group');
$this->assertTrue($this->model->hasMessages());
}