PHP code example of trash-panda / m2-message-manager-remover

1. Go to this page and download the library: Download trash-panda/m2-message-manager-remover library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

trash-panda / m2-message-manager-remover example snippets


$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$messageManager = $om->create(\Magento\Framework\Message\ManagerInterface::class);

$messageManager->addNotice('First message');
$messageManager->addNotice('Second message');

$remover = new Remover($messageManager);
$remover->removeLastAddedMessage(); //only remove "Second Message"
$remover->removeByRegex('/message/'); //remove all message matching regex '/message/'
$remover->removeAll(); //remove all messages