*/ class StatisticsClicksRepository extends Repository { protected function getEntityClassName(): string { return StatisticsClickEntity::class; } public function createOrUpdateClickCount( NewsletterLinkEntity $link, SubscriberEntity $subscriber, NewsletterEntity $newsletter, SendingQueueEntity $queue, ?UserAgentEntity $userAgent ): StatisticsClickEntity { $statistics = $this->findOneBy([ 'link' => $link, 'newsletter' => $newsletter, 'subscriber' => $subscriber, 'queue' => $queue, ]); if (!$statistics instanceof StatisticsClickEntity) { $statistics = new StatisticsClickEntity($newsletter, $queue, $subscriber, $link, 1); if ($userAgent) { $statistics->setUserAgent($userAgent); $statistics->setUserAgentType($userAgent->getUserAgentType()); } $this->persist($statistics); } else { $statistics->setCount($statistics->getCount() + 1); } return $statistics; } }