tourze/user-event-bundle

用户交互事件

Installs: 26

Dependents: 2

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:symfony-bundle

0.0.4 2025-04-19 13:12 UTC

This package is auto-updated.

Last update: 2025-04-19 13:14:05 UTC


README

Latest Version License

A Symfony bundle for managing user interaction events with flexible and extensible features.

English | 中文

Features

  • Automatic collection and management of user interaction events
  • Extendable event base class
  • Context information support
  • Easy integration with existing Symfony applications

Installation

composer require tourze/user-event-bundle

Quick Start

Add the bundle to your config/bundles.php:

<?php

return [
    // ...
    Tourze\UserEventBundle\UserEventBundle::class => ['all' => true],
];

Configure the bundle in config/packages/tourze_user_event.yaml:

tourze_user_event:
    use_lookup: true  # Optional, defaults to true

Usage

Creating Custom Events

<?php

namespace App\Event;

use Tourze\UserEventBundle\Event\UserInteractionEvent;

class UserMessageEvent extends UserInteractionEvent
{
    public static function getTitle(): string
    {
        return 'User Message Event';
    }
}

Using the Event Finder

<?php

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Tourze\UserEventBundle\Service\EventFinder;

class EventController extends AbstractController
{
    #[Route('/events', name: 'app_events')]
    public function index(EventFinder $eventFinder): Response
    {
        $events = $eventFinder->genSelectData();
        
        return $this->render('event/index.html.twig', [
            'events' => $events,
        ]);
    }
}

Testing

./vendor/bin/phpunit packages/user-event-bundle/tests

License

The MIT License (MIT). Please see License File for more information.