Skip to content

Commit

Permalink
Merge pull request #32 from netlogix/automated-apply-coding-standards
Browse files Browse the repository at this point in the history
[automated] Apply Coding Standard
  • Loading branch information
saschanowak authored Dec 19, 2024
2 parents f2209e1 + 877c77f commit 885d26a
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 30 deletions.
28 changes: 21 additions & 7 deletions Classes/EventListener/AddCdnToResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
}

Expand Down Expand Up @@ -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;
}
Expand All @@ -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);
}
}
7 changes: 2 additions & 5 deletions Classes/Xclass/PageRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
36 changes: 18 additions & 18 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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"
}
}

0 comments on commit 885d26a

Please sign in to comment.