本文整理汇总了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());
}