<?php

namespace AutoAdmin\Bundle\Core\Doctrine\Traits;

use AutoAdmin\Bundle\Core\Doctrine\ListenerStateManager;
use Symfony\Contracts\Service\Attribute\Required;

trait ListenerStateManagerTrait
{
    protected ListenerStateManager $listenerStateManager;

    #[Required]
    public function injectListenerStateManager(ListenerStateManager $listenerStateManager): void
    {
        $this->listenerStateManager = $listenerStateManager;
    }

    protected function canRun(): bool
    {
        return $this->listenerStateManager->getState() === true;
    }
}
