PHP code example of trash-panda / m2-callable-event-listeners

1. Go to this page and download the library: Download trash-panda/m2-callable-event-listeners 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-callable-event-listeners example snippets



use TrashPanda\CallableEventListeners\Model\Manager;
use Magento\Framework\Event\Observer;

class MyCommand
{
    public function ___construct(Manager $manager)
    {
        $manager->listen('some-event', function (Observer $observer) {
            echo "Hey!\n\n";
            var_dump($observer->getData());
        });
    }
}