winzana/functional-event

Implement Symfony event with Annotation

v0.1.2 2019-06-27 11:37 UTC

This package is auto-updated.

Last update: 2024-04-27 22:40:05 UTC


README

Symfony functional Event Bundle

Install

Create a config file config/packages/winzana_model_event.yaml.

event:
    mapping:
        paths: ['%kernel.project_dir%/src/CommandHandler']

Add bundle into config\bundles.php.

<?php

return [   
    Winzana\Core\Event\EventBundle::class => ['all' => true],
];

Example

In your CommandHandler directory.

<?php
namespace App\CommandHandler;

use Winzana\Core\Event\Annotation\Event;
use Winzana\Core\Event\Interfaces\EventInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;

/**
 * Class CreateUserCommandHandler
 * @Event()
 */
final class CreateUserCommandHandler implements EventInterface
{
    public function __invoke(GetResponseEvent $event)
    {
        // TODO: Implement __invoke() method.
    }

    public function getEventName(): string
    {
        return 'kernel.request';
    }

    public function getPriority(): int
    {
        return 10;
    }

}