diff --git a/Classes/EventListener/AddCdnToResource.php b/Classes/EventListener/AddCdnToResource.php index ccc2496..3968b1b 100644 --- a/Classes/EventListener/AddCdnToResource.php +++ b/Classes/EventListener/AddCdnToResource.php @@ -5,6 +5,7 @@ namespace Netlogix\Nxsimplecdn\EventListener; use Netlogix\Nxsimplecdn\Service\BaseUriService; +use TYPO3\CMS\Core\Configuration\ExtensionConfiguration; use TYPO3\CMS\Core\Http\ApplicationType; use TYPO3\CMS\Core\Http\Uri; use TYPO3\CMS\Core\Resource\Driver\DriverInterface; @@ -18,8 +19,25 @@ class AddCdnToResource { + protected $configuration = []; + + public function __construct( + ExtensionConfiguration $extensionConfiguration = null + ) { + $this->configuration = $extensionConfiguration ? $extensionConfiguration->get('nxsimplecdn') : + GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('nxsimplecdn'); + } + public function __invoke(GeneratePublicUrlForResourceEvent $event): void { + if ((bool)$this->configuration['enabled'] === false) { + return; + } + + if ($event->getPublicUrl() !== null) { + return; + } + $driver = $event->getDriver(); $resource = $event->getResource(); if ( diff --git a/ext_conf_template.txt b/ext_conf_template.txt new file mode 100644 index 0000000..0514d85 --- /dev/null +++ b/ext_conf_template.txt @@ -0,0 +1,2 @@ +# cat=nxsimplecdn/; type=boolean; label=active CDN for locala files +enabled=1