29 lines
734 B
PHP
29 lines
734 B
PHP
<?php
|
|
|
|
namespace KimaiPlugin\KimaiHeatmapBundle\EventSubscriber;
|
|
|
|
use App\Event\DashboardEvent;
|
|
use App\Widget\WidgetService;
|
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
|
|
|
final class DashboardSubscriber implements EventSubscriberInterface
|
|
{
|
|
public function __construct(private readonly WidgetService $widgetService)
|
|
{
|
|
}
|
|
|
|
public static function getSubscribedEvents(): array
|
|
{
|
|
return [
|
|
DashboardEvent::class => ['onDashboard', 100],
|
|
];
|
|
}
|
|
|
|
public function onDashboard(DashboardEvent $event): void
|
|
{
|
|
$widget = $this->widgetService->getWidget('HeatmapWidget');
|
|
if ($widget !== null) {
|
|
$event->addWidget($widget);
|
|
}
|
|
}
|
|
}
|