PHP code example of xervice / event

1. Go to this page and download the library: Download xervice/event 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/ */

    

xervice / event example snippets





namespace App\Event;


use Xervice\Event\EventDependencyProvider as XerviceEventDependencyProvider;
use XerviceTest\Event\Listener\TestListener;

class EventDependencyProvider extends XerviceEventDependencyProvider
{
    protected function getListener(): array
    {
        return [
            'test' => [
                TestListener::class //implemente EventListenerInterface
            ]
        ];
    }

}

    /**
     * @return \Xervice\Event\Business\Provider\EventProviderInterface
     */
    public function createEventProvider(): EventProviderInterface
    {
        return new DefaultEventProvider(
            $this->createListenerProvider()
        );
    }

    $newEventContent = new OwnDataProvider(); // DataProviderInterface
    $newEventContent->setData('MyTest');

    $event = new EventDataProvider();
    $event
        ->setName('MY_EVENT_NAME')
        ->setMessage($newEvent);

    $eventFacade->fireEvent($event);