From 3c58a86d9349f773e950ae04aae0aba0c87e1699 Mon Sep 17 00:00:00 2001 From: Alexander Kellner Date: Thu, 1 Feb 2024 12:28:20 +0100 Subject: [PATCH] [TASK] Use setter for domain property in some objects in a classic way This helps if new objects should be created via extbase property mapper (e.g. via API) where a domain is given --- Classes/Domain/Model/Download.php | 8 +++++++- Classes/Domain/Model/Newsvisit.php | 8 +++++++- Classes/Domain/Model/Pagevisit.php | 8 +++++++- Classes/Domain/Tracker/DownloadTracker.php | 3 ++- Classes/Domain/Tracker/NewsTracker.php | 2 +- Classes/Domain/Tracker/PageTracker.php | 2 +- 6 files changed, 25 insertions(+), 6 deletions(-) diff --git a/Classes/Domain/Model/Download.php b/Classes/Domain/Model/Download.php index 57a21d0c..56b1f95b 100644 --- a/Classes/Domain/Model/Download.php +++ b/Classes/Domain/Model/Download.php @@ -78,7 +78,13 @@ public function getDomain(): string return $this->domain; } - public function setDomain(): self + public function setDomain(string $domain): self + { + $this->domain = $domain; + return $this; + } + + public function setDomainAutomatically(): self { $this->domain = FrontendUtility::getCurrentDomain(); return $this; diff --git a/Classes/Domain/Model/Newsvisit.php b/Classes/Domain/Model/Newsvisit.php index d5bb71ee..730d1d96 100644 --- a/Classes/Domain/Model/Newsvisit.php +++ b/Classes/Domain/Model/Newsvisit.php @@ -97,7 +97,13 @@ public function getDomain(): string return $this->domain; } - public function setDomain(): self + public function setDomain(string $domain): self + { + $this->domain = $domain; + return $this; + } + + public function setDomainAutomatically(): self { $this->domain = FrontendUtility::getCurrentDomain(); return $this; diff --git a/Classes/Domain/Model/Pagevisit.php b/Classes/Domain/Model/Pagevisit.php index e45857db..8fd66b0d 100644 --- a/Classes/Domain/Model/Pagevisit.php +++ b/Classes/Domain/Model/Pagevisit.php @@ -126,7 +126,13 @@ public function getDomain(): string return $this->domain; } - public function setDomain(): self + public function setDomain(string $domain): self + { + $this->domain = $domain; + return $this; + } + + public function setDomainAutomatically(): self { $this->domain = FrontendUtility::getCurrentDomain(); return $this; diff --git a/Classes/Domain/Tracker/DownloadTracker.php b/Classes/Domain/Tracker/DownloadTracker.php index a5a45199..26fcc06e 100644 --- a/Classes/Domain/Tracker/DownloadTracker.php +++ b/Classes/Domain/Tracker/DownloadTracker.php @@ -66,7 +66,8 @@ protected function getAndPersistNewDownload(string $href, int $pageIdentifier): $downloadRepository = GeneralUtility::makeInstance(DownloadRepository::class); $pageRepository = GeneralUtility::makeInstance(PageRepository::class); $page = $pageRepository->findByIdentifier($pageIdentifier); - $download = GeneralUtility::makeInstance(Download::class)->setHref($href)->setPage($page)->setDomain(); + $download = GeneralUtility::makeInstance(Download::class) + ->setHref($href)->setPage($page)->setDomainAutomatically(); if ($file !== null) { $download->setFile($file); } diff --git a/Classes/Domain/Tracker/NewsTracker.php b/Classes/Domain/Tracker/NewsTracker.php index 5537be77..4957f4c8 100644 --- a/Classes/Domain/Tracker/NewsTracker.php +++ b/Classes/Domain/Tracker/NewsTracker.php @@ -75,7 +75,7 @@ protected function getNewsvisit( $newsvisit ->setNews($news) ->setLanguage($languageUid) - ->setDomain() + ->setDomainAutomatically() ->setVisitor($visitor) ->setPagevisit($pagevisit); return $newsvisit; diff --git a/Classes/Domain/Tracker/PageTracker.php b/Classes/Domain/Tracker/PageTracker.php index 7acb990f..5b6f7610 100644 --- a/Classes/Domain/Tracker/PageTracker.php +++ b/Classes/Domain/Tracker/PageTracker.php @@ -72,7 +72,7 @@ protected function getPageVisit(int $pageUid, int $languageUid, string $referrer ->setPage($page) ->setLanguage($languageUid) ->setReferrer($referrer) - ->setDomain() + ->setDomainAutomatically() ->setVisitor($visitor); return $pageVisit; }