diff --git a/lib/Config.php b/lib/Config.php index f53a1d6..95b4115 100644 --- a/lib/Config.php +++ b/lib/Config.php @@ -11,13 +11,14 @@ use OCP\IConfig; class Config { - public function __construct($appName, IConfig $config) { - $this->appName = $appName; - $this->config = $config; + public function __construct( + protected string $appName, + protected IConfig $config, + ) { } public function getTrackingKey(): ?string { - $value = $this->config->getSystemValueString('googleanalytics_tracking_key', ''); + $value = $this->config->getSystemValueString('googleanalytics_tracking_key'); return (empty($value)) ? null : $value; } } diff --git a/lib/Controller/JavaScriptController.php b/lib/Controller/JavaScriptController.php index 9fcade1..c3d181b 100644 --- a/lib/Controller/JavaScriptController.php +++ b/lib/Controller/JavaScriptController.php @@ -9,6 +9,9 @@ use OCA\NCGoogleAnalytics\Config; use OCA\NCGoogleAnalytics\Service\Consent\IConsentService; use OCP\AppFramework\Controller; +use OCP\AppFramework\Http\Attribute\NoAdminRequired; +use OCP\AppFramework\Http\Attribute\NoCSRFRequired; +use OCP\AppFramework\Http\Attribute\PublicPage; use OCP\AppFramework\Http\DataDownloadResponse; use OCP\AppFramework\Http\TextPlainResponse; use OCP\IRequest; @@ -32,12 +35,11 @@ public function __construct( } /** - * @NoAdminRequired - * @NoCSRFRequired - * @PublicPage - * * @return TextPlainResponse|DataDownloadResponse */ + #[NoAdminRequired] + #[NoCSRFRequired] + #[PublicPage] public function tracking(): TextPlainResponse|DataDownloadResponse { $gtmId = $this->config->getTrackingKey();