From 877c77fbcbb33d85fd52ddad2454ee3ecaf74f16 Mon Sep 17 00:00:00 2001 From: saschanowak <1643495+saschanowak@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:04:48 +0000 Subject: [PATCH] refactor: Apply Coding Standard --- Classes/EventListener/AddCdnToResource.php | 28 ++++++++++++----- Classes/Xclass/PageRenderer.php | 7 ++--- composer.json | 36 +++++++++++----------- 3 files changed, 41 insertions(+), 30 deletions(-) diff --git a/Classes/EventListener/AddCdnToResource.php b/Classes/EventListener/AddCdnToResource.php index bff7568..9d810cc 100644 --- a/Classes/EventListener/AddCdnToResource.php +++ b/Classes/EventListener/AddCdnToResource.php @@ -21,12 +21,19 @@ #[AsEventListener] readonly class AddCdnToResource { - public function __construct( - #[Autowire(expression: 'service("Netlogix\\\Nxsimplecdn\\\Service\\\BaseUriService").getBaseUri().getHost()')] + #[ + Autowire( + expression: 'service("Netlogix\\\Nxsimplecdn\\\Service\\\BaseUriService").getBaseUri().getHost()' + ) + ] protected string $cdnDomainHost, - #[Autowire(expression: 'service("TYPO3\\\CMS\\\Core\\\Configuration\\\ExtensionConfiguration").get("nxsimplecdn", "enabled")')] - protected bool $enabled = false, + #[ + Autowire( + expression: 'service("TYPO3\\\CMS\\\Core\\\Configuration\\\ExtensionConfiguration").get("nxsimplecdn", "enabled")' + ) + ] + protected bool $enabled = false ) { } @@ -54,13 +61,19 @@ public function __invoke(GeneratePublicUrlForResourceEvent $event): void return; } - if ($resource->getStorage()->getCapabilities()->hasCapability(Capabilities::CAPABILITY_PUBLIC) === false) { + if ( + $resource + ->getStorage() + ->getCapabilities() + ->hasCapability(Capabilities::CAPABILITY_PUBLIC) === false + ) { return; } if ( $resource instanceof File && - GeneralUtility::makeInstance(OnlineMediaHelperRegistry::class)->getOnlineMediaHelper($resource) !== false + GeneralUtility::makeInstance(OnlineMediaHelperRegistry::class)->getOnlineMediaHelper($resource) !== + false ) { return; } @@ -75,7 +88,8 @@ private function addCdnPrefixToUrl(ResourceInterface $resourceObject, DriverInte $publicUrl = GeneralUtility::createVersionNumberedFilename($publicUrl); } - return (string) (new Uri($publicUrl))->withScheme('https') + return (string) (new Uri($publicUrl)) + ->withScheme('https') ->withHost($this->cdnDomainHost); } } diff --git a/Classes/Xclass/PageRenderer.php b/Classes/Xclass/PageRenderer.php index 715fb95..a7e1bcb 100644 --- a/Classes/Xclass/PageRenderer.php +++ b/Classes/Xclass/PageRenderer.php @@ -18,11 +18,8 @@ protected function getAbsoluteWebPath(string $file): string return $file; } - $baseUri = GeneralUtility::makeInstance(BaseUriService::class) - ->getBaseUri(); + $baseUri = GeneralUtility::makeInstance(BaseUriService::class)->getBaseUri(); - return (string) (new Uri($file)) - ->withScheme('https') - ->withHost($baseUri->getHost()); + return (string) (new Uri($file))->withScheme('https')->withHost($baseUri->getHost()); } } diff --git a/composer.json b/composer.json index 0cbae79..969c8ed 100644 --- a/composer.json +++ b/composer.json @@ -9,9 +9,9 @@ "require-dev": { "ext-sqlite3": "*", "ergebnis/composer-normalize": "^2.45", + "phpunit/phpcov": "^10.0", "ssch/typo3-rector": "^3.0", - "typo3/testing-framework": "^9.0", - "phpunit/phpcov": "^10.0" + "typo3/testing-framework": "^9.0" }, "autoload": { "psr-4": { @@ -23,35 +23,35 @@ "Netlogix\\Nxsimplecdn\\Tests\\": "Tests/" } }, + "config": { + "allow-plugins": { + "ergebnis/composer-normalize": true, + "typo3/class-alias-loader": true, + "typo3/cms-composer-installers": true + }, + "bin-dir": ".Build/bin", + "vendor-dir": ".Build/vendor" + }, "extra": { "typo3/cms": { "extension-key": "nxsimplecdn", "web-dir": ".Build/public" } }, - "config": { - "vendor-dir": ".Build/vendor", - "bin-dir": ".Build/bin", - "allow-plugins": { - "ergebnis/composer-normalize": true, - "typo3/cms-composer-installers": true, - "typo3/class-alias-loader": true - } - }, "scripts": { + "post-autoload-dump": [ + "@prepare-extension-test-structure" + ], "composer:normalize": "@composer normalize --no-check-lock --dry-run", "composer:normalize:fix": "@composer normalize --no-check-lock", "composer:psr-verify": "@composer dumpautoload --optimize --strict-psr --no-plugins", "php:lint": "find src -name '*.php' -print0 | xargs -r -0 -n 1 -P 4 php -l", + "prepare-extension-test-structure": [ + "Nimut\\TestingFramework\\Composer\\ExtensionTestEnvironment::prepare" + ], "rector": "rector process --dry-run", "rector:fix": "rector process", - "test:unit": "phpunit -c phpunit.xml", "test:functional": "phpunit -c phpunit_functional.xml", - "post-autoload-dump": [ - "@prepare-extension-test-structure" - ], - "prepare-extension-test-structure": [ - "Nimut\\TestingFramework\\Composer\\ExtensionTestEnvironment::prepare" - ] + "test:unit": "phpunit -c phpunit.xml" } }