namespace App\EventListener;
use ...
class SearchIndexer
{
private $tokenStorage;
function __construct(TokenStorageInterface $tokenStorage)
{
$this->token_storage = $token_storage;
}
public function preUpdate(LifecycleEventArgs $args)
{
$entity = $args->getObject();
if (!$entity instanceof Product) {
return;
}
if ($this->tokenStorage->getToken()->getUser()->getUsername()){
//any action
}
}
}