Skip to content

Commit

Permalink
Merge pull request #31 from netlogix/feature/typo3-13-compatibility
Browse files Browse the repository at this point in the history
feat: TYPO3 13.4 compatibility
  • Loading branch information
saschanowak authored Dec 19, 2024
2 parents e8d7eff + 7e9fa5d commit 685e273
Show file tree
Hide file tree
Showing 14 changed files with 135 additions and 400 deletions.
51 changes: 5 additions & 46 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,58 +3,17 @@
# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = 180

# TS/JS-Files
[*.{ts,js}]
indent_size = 2

# JSON-Files
[*.json]
indent_style = tab

# ReST-Files
[*.{rst,rst.txt}]
indent_size = 4
max_line_length = 80

# Markdown-Files
[*.md]
max_line_length = 80

# YAML-Files
[*.{yaml,yml}]
indent_size = 2
[*.php]
max_line_length = 115

# NEON-Files
[*.neon]
[{*.yml,*.yaml}]
indent_size = 2
indent_style = tab

# package.json
[package.json]
indent_size = 2

# TypoScript
[*.{typoscript,tsconfig}]
indent_size = 2

# XLF-Files
[*.xlf]
indent_style = tab

# SQL-Files
[*.sql]
indent_style = tab
indent_size = 2

# .htaccess
[{_.htaccess,.htaccess}]
indent_style = tab
25 changes: 17 additions & 8 deletions .github/workflows/apply-coding-standard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: 'Setup PHP'
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.3'
tools: composer

- name: 'Get Composer Cache Directory'
Expand All @@ -37,23 +37,32 @@ jobs:

- name: 'Rector PHP Code'
shell: bash
run: composer rector-fix
run: composer rector:fix

- name: 'Lint PHP Code'
- name: 'Normalize Composer files'
shell: bash
run: composer lint-fix
run: composer composer:normalize:fix

- name: 'PHP syntax checker'
shell: bash
run: composer php:lint

- name: 'Prettier'
shell: bash
continue-on-error: true
run: ./prettier.sh --write

- name: 'Run PHPUnit unit tests'
shell: bash
run: composer test-unit
run: composer test:unit

- name: 'Run PHPUnit functional tests'
shell: bash
run: composer test-functional
run: composer test:functional

- name: 'Create pull-request'
id: cpr
uses: peter-evans/create-pull-request@v6.0.5
uses: peter-evans/create-pull-request@v7.0.3
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "[automated] Apply Coding Standard"
Expand All @@ -67,4 +76,4 @@ jobs:
if: steps.cpr.outputs.pull-request-operation == 'created'
run: gh pr merge --auto "${{ steps.cpr.outputs.pull-request-number }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ permissions:
jobs:
test:
runs-on: ubuntu-latest
name: TYPO3 v12.4 tests on PHP ${{ matrix.php }}
name: TYPO3 v13.4 tests on PHP ${{ matrix.php }}

strategy:
fail-fast: false
matrix:
php: [ 8.1, 8.2, 8.3 ]
php: [ 8.3, 8.4 ]

steps:
- name: 'Checkout code'
Expand Down Expand Up @@ -61,18 +61,18 @@ jobs:

- name: 'PHPUnit unit tests'
shell: bash
run: composer test-unit
run: composer test:unit

- name: 'PHPUnit functional tests'
shell: bash
run: composer test-functional
run: composer test:functional

- name: 'Merge Coverage Reports'
shell: bash
run: .Build/bin/phpcov merge --html .Build/artifacts/coverage/merged --clover .Build/artifacts/coverage/clover.xml .Build/artifacts/coverage/

- name: 'Generate code coverage summary report'
uses: saschanowak/CloverCodeCoverageSummary@1.0.1
uses: saschanowak/CloverCodeCoverageSummary@1.1.0
with:
filename: .Build/artifacts/coverage/clover.xml

Expand All @@ -83,11 +83,11 @@ jobs:
- name: 'Add title to code coverage summary'
shell: bash
run: sed -i '1 i\## TYPO3 v12.4 tests on PHP ${{ matrix.php }}' code-coverage-summary.md
run: sed -i '1 i\## TYPO3 v13.4 tests on PHP ${{ matrix.php }}' code-coverage-summary.md

- name: 'Add code coverage summary as pr comment'
uses: marocchino/sticky-pull-request-comment@v2
with:
header: coverage-${{ matrix.php }}
recreate: true
path: code-coverage-summary.md
path: code-coverage-summary.md
15 changes: 15 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"arrowParens": "avoid",
"quoteProps": "consistent",
"printWidth": 180,
"singleQuote": true,
"overrides": [
{
"files": ["*.php"],
"options": {
"printWidth": 115,
"plugins": ["@prettier/plugin-php"]
}
}
]
}
32 changes: 14 additions & 18 deletions Classes/EventListener/AddCdnToResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,35 @@

namespace Netlogix\Nxsimplecdn\EventListener;

use Netlogix\Nxsimplecdn\Service\BaseUriService;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use Symfony\Component\DependencyInjection\Attribute\Autowire;
use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Core\Http\ApplicationType;
use TYPO3\CMS\Core\Http\Uri;
use TYPO3\CMS\Core\Resource\Capabilities;
use TYPO3\CMS\Core\Resource\Driver\DriverInterface;
use TYPO3\CMS\Core\Resource\Driver\LocalDriver;
use TYPO3\CMS\Core\Resource\Event\GeneratePublicUrlForResourceEvent;
use TYPO3\CMS\Core\Resource\File;
use TYPO3\CMS\Core\Resource\OnlineMedia\Helpers\OnlineMediaHelperRegistry;
use TYPO3\CMS\Core\Resource\ProcessedFile;
use TYPO3\CMS\Core\Resource\ResourceInterface;
use TYPO3\CMS\Core\Resource\ResourceStorageInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;

class AddCdnToResource
#[AsEventListener]
readonly class AddCdnToResource
{
protected $configuration = [];

public function __construct(ExtensionConfiguration $extensionConfiguration = null)
{
$this->configuration = $extensionConfiguration instanceof ExtensionConfiguration ? $extensionConfiguration->get(
'nxsimplecdn'
) :
GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('nxsimplecdn');
public function __construct(
#[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,
) {
}

public function __invoke(GeneratePublicUrlForResourceEvent $event): void
{
if (!(bool) $this->configuration['enabled']) {
if ($this->enabled === false) {
return;
}

Expand All @@ -54,10 +54,7 @@ public function __invoke(GeneratePublicUrlForResourceEvent $event): void
return;
}

if (
($resource->getStorage()->getCapabilities() & ResourceStorageInterface::CAPABILITY_PUBLIC)
!== ResourceStorageInterface::CAPABILITY_PUBLIC
) {
if ($resource->getStorage()->getCapabilities()->hasCapability(Capabilities::CAPABILITY_PUBLIC) === false) {
return;
}

Expand All @@ -74,12 +71,11 @@ public function __invoke(GeneratePublicUrlForResourceEvent $event): void
private function addCdnPrefixToUrl(ResourceInterface $resourceObject, DriverInterface $driver): string
{
$publicUrl = $driver->getPublicUrl($resourceObject->getIdentifier());
$cdnBaseUrl = GeneralUtility::makeInstance(BaseUriService::class)->getBaseUri();
if (!$resourceObject instanceof ProcessedFile) {
$publicUrl = GeneralUtility::createVersionNumberedFilename($publicUrl);
}

return (string) (new Uri($publicUrl))->withScheme('https')
->withHost($cdnBaseUrl->getHost());
->withHost($this->cdnDomainHost);
}
}
47 changes: 0 additions & 47 deletions Classes/EventListener/AddFileCacheTagForTypolink.php

This file was deleted.

48 changes: 0 additions & 48 deletions Classes/EventListener/FlushCacheTagForFile.php

This file was deleted.

2 changes: 1 addition & 1 deletion Classes/Service/BaseUriService.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use TYPO3\CMS\Core\Http\Uri;
use TYPO3\CMS\Core\Site\Entity\Site;

class BaseUriService
final class BaseUriService
{
public function getBaseUri(): UriInterface
{
Expand Down
Loading

0 comments on commit 685e273

Please sign in to comment.