mirror of
https://github.com/DanielSiepmann/tracking.git
synced 2024-12-10 03:36:08 +01:00
TYPO3 13 (#117)
* Update everything for TYPO3 v12 + v13 --------- Co-authored-by: Daniel Siepmann <daniel.siepmann@codappix.com>
This commit is contained in:
parent
5aa08b5e6c
commit
b83093e023
63 changed files with 1413 additions and 1565 deletions
58
.github/workflows/ci.yaml
vendored
58
.github/workflows/ci.yaml
vendored
|
@ -10,12 +10,12 @@ jobs:
|
|||
check-composer:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: 7.4
|
||||
php-version: 8.3
|
||||
coverage: none
|
||||
tools: composer:v2
|
||||
env:
|
||||
|
@ -29,13 +29,12 @@ jobs:
|
|||
strategy:
|
||||
matrix:
|
||||
php-version:
|
||||
- 7.4
|
||||
- 8.0
|
||||
- 8.1
|
||||
- 8.2
|
||||
- 8.3
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
|
@ -51,12 +50,12 @@ jobs:
|
|||
needs:
|
||||
- check-composer
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: "7.4"
|
||||
php-version: "8.3"
|
||||
coverage: none
|
||||
tools: composer:v2
|
||||
env:
|
||||
|
@ -80,7 +79,7 @@ jobs:
|
|||
coding-guideline:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
|
@ -104,26 +103,23 @@ jobs:
|
|||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- db-version: '8'
|
||||
php-version: '7.4'
|
||||
typo3-version: '^11.5'
|
||||
- db-version: '8'
|
||||
php-version: '8.0'
|
||||
typo3-version: '^11.5'
|
||||
- db-version: '8'
|
||||
php-version: '8.1'
|
||||
typo3-version: '^11.5'
|
||||
- db-version: '8'
|
||||
php-version: '8.2'
|
||||
typo3-version: '^11.5'
|
||||
- db-version: '8'
|
||||
php-version: '8.1'
|
||||
typo3-version: '^12.4'
|
||||
- db-version: '8'
|
||||
php-version: '8.2'
|
||||
typo3-version: '^12.4'
|
||||
- db-version: '8'
|
||||
php-version: '8.3'
|
||||
typo3-version: '^12.4'
|
||||
- db-version: '8'
|
||||
php-version: '8.2'
|
||||
typo3-version: '^13.3'
|
||||
- db-version: '8'
|
||||
php-version: '8.3'
|
||||
typo3-version: '^13.3'
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
|
@ -148,7 +144,7 @@ jobs:
|
|||
done
|
||||
|
||||
- name: Install dependencies with expected TYPO3 version
|
||||
run: composer require --prefer-dist --no-progress "typo3/cms-backend:${{ matrix.typo3-version }}" "typo3/cms-core:${{ matrix.typo3-version }}" "typo3/cms-dashboard:${{ matrix.typo3-version }}"
|
||||
run: composer require --prefer-dist --no-progress "typo3/cms-core:${{ matrix.typo3-version }}"
|
||||
|
||||
- name: PHPUnit Tests
|
||||
run: |-
|
||||
|
@ -164,20 +160,18 @@ jobs:
|
|||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- php-version: '7.4'
|
||||
typo3-version: '^11.5'
|
||||
- php-version: '8.0'
|
||||
typo3-version: '^11.5'
|
||||
- php-version: '8.1'
|
||||
typo3-version: '^11.5'
|
||||
- php-version: '8.2'
|
||||
typo3-version: '^11.5'
|
||||
- php-version: '8.1'
|
||||
typo3-version: '^12.4'
|
||||
- php-version: '8.2'
|
||||
typo3-version: '^12.4'
|
||||
- php-version: '8.3'
|
||||
typo3-version: '^12.4'
|
||||
- php-version: '8.2'
|
||||
typo3-version: '^13.3'
|
||||
- php-version: '8.3'
|
||||
typo3-version: '^13.3'
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
|
@ -189,7 +183,7 @@ jobs:
|
|||
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Install dependencies with expected TYPO3 version
|
||||
run: composer require --prefer-dist --no-progress "typo3/cms-backend:${{ matrix.typo3-version }}" "typo3/cms-core:${{ matrix.typo3-version }}" "typo3/cms-dashboard:${{ matrix.typo3-version }}"
|
||||
run: composer require --prefer-dist --no-progress "typo3/cms-core:${{ matrix.typo3-version }}"
|
||||
|
||||
- name: Code Quality (by PHPStan)
|
||||
run: ./vendor/bin/phpstan analyse
|
||||
|
|
|
@ -1,63 +1,365 @@
|
|||
<?php
|
||||
$finder = (new PhpCsFixer\Finder())
|
||||
->ignoreVCSIgnored(true)
|
||||
->in(realpath(__DIR__))
|
||||
;
|
||||
|
||||
return (new \PhpCsFixer\Config())
|
||||
declare(strict_types=1);
|
||||
|
||||
use PhpCsFixer\Config;
|
||||
use PhpCsFixer\Finder;
|
||||
use PhpCsFixer\Fixer\Alias\MbStrFunctionsFixer;
|
||||
use PhpCsFixer\Fixer\Alias\NoAliasFunctionsFixer;
|
||||
use PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer;
|
||||
use PhpCsFixer\Fixer\ArrayNotation\NoMultilineWhitespaceAroundDoubleArrowFixer;
|
||||
use PhpCsFixer\Fixer\ArrayNotation\NoWhitespaceBeforeCommaInArrayFixer;
|
||||
use PhpCsFixer\Fixer\ArrayNotation\NormalizeIndexBraceFixer;
|
||||
use PhpCsFixer\Fixer\ArrayNotation\ReturnToYieldFromFixer;
|
||||
use PhpCsFixer\Fixer\ArrayNotation\TrimArraySpacesFixer;
|
||||
use PhpCsFixer\Fixer\ArrayNotation\WhitespaceAfterCommaInArrayFixer;
|
||||
use PhpCsFixer\Fixer\ArrayNotation\YieldFromArrayToYieldsFixer;
|
||||
use PhpCsFixer\Fixer\AttributeNotation\AttributeEmptyParenthesesFixer;
|
||||
use PhpCsFixer\Fixer\Basic\NoMultipleStatementsPerLineFixer;
|
||||
use PhpCsFixer\Fixer\Basic\NoTrailingCommaInSinglelineFixer;
|
||||
use PhpCsFixer\Fixer\Basic\NonPrintableCharacterFixer;
|
||||
use PhpCsFixer\Fixer\Basic\NumericLiteralSeparatorFixer;
|
||||
use PhpCsFixer\Fixer\Casing\ClassReferenceNameCasingFixer;
|
||||
use PhpCsFixer\Fixer\Casing\NativeFunctionCasingFixer;
|
||||
use PhpCsFixer\Fixer\Casing\NativeTypeDeclarationCasingFixer;
|
||||
use PhpCsFixer\Fixer\CastNotation\CastSpacesFixer;
|
||||
use PhpCsFixer\Fixer\CastNotation\ModernizeTypesCastingFixer;
|
||||
use PhpCsFixer\Fixer\CastNotation\NoUnsetCastFixer;
|
||||
use PhpCsFixer\Fixer\ClassNotation\ClassAttributesSeparationFixer;
|
||||
use PhpCsFixer\Fixer\ClassNotation\NoNullPropertyInitializationFixer;
|
||||
use PhpCsFixer\Fixer\ClassNotation\OrderedClassElementsFixer;
|
||||
use PhpCsFixer\Fixer\ClassNotation\OrderedInterfacesFixer;
|
||||
use PhpCsFixer\Fixer\ClassNotation\OrderedTraitsFixer;
|
||||
use PhpCsFixer\Fixer\ClassNotation\OrderedTypesFixer;
|
||||
use PhpCsFixer\Fixer\ClassNotation\SelfAccessorFixer;
|
||||
use PhpCsFixer\Fixer\Comment\MultilineCommentOpeningClosingFixer;
|
||||
use PhpCsFixer\Fixer\Comment\NoEmptyCommentFixer;
|
||||
use PhpCsFixer\Fixer\Comment\SingleLineCommentStyleFixer;
|
||||
use PhpCsFixer\Fixer\ControlStructure\NoSuperfluousElseifFixer;
|
||||
use PhpCsFixer\Fixer\ControlStructure\NoUnneededBracesFixer;
|
||||
use PhpCsFixer\Fixer\ControlStructure\NoUnneededControlParenthesesFixer;
|
||||
use PhpCsFixer\Fixer\ControlStructure\NoUselessElseFixer;
|
||||
use PhpCsFixer\Fixer\ControlStructure\SimplifiedIfReturnFixer;
|
||||
use PhpCsFixer\Fixer\ControlStructure\TrailingCommaInMultilineFixer;
|
||||
use PhpCsFixer\Fixer\FunctionNotation\DateTimeCreateFromFormatCallFixer;
|
||||
use PhpCsFixer\Fixer\FunctionNotation\MethodArgumentSpaceFixer;
|
||||
use PhpCsFixer\Fixer\FunctionNotation\NoUnreachableDefaultArgumentValueFixer;
|
||||
use PhpCsFixer\Fixer\FunctionNotation\NoUselessSprintfFixer;
|
||||
use PhpCsFixer\Fixer\FunctionNotation\NullableTypeDeclarationForDefaultNullValueFixer;
|
||||
use PhpCsFixer\Fixer\FunctionNotation\PhpdocToParamTypeFixer;
|
||||
use PhpCsFixer\Fixer\FunctionNotation\PhpdocToPropertyTypeFixer;
|
||||
use PhpCsFixer\Fixer\FunctionNotation\PhpdocToReturnTypeFixer;
|
||||
use PhpCsFixer\Fixer\FunctionNotation\RegularCallableCallFixer;
|
||||
use PhpCsFixer\Fixer\FunctionNotation\StaticLambdaFixer;
|
||||
use PhpCsFixer\Fixer\Import\FullyQualifiedStrictTypesFixer;
|
||||
use PhpCsFixer\Fixer\Import\GlobalNamespaceImportFixer;
|
||||
use PhpCsFixer\Fixer\Import\NoUnneededImportAliasFixer;
|
||||
use PhpCsFixer\Fixer\Import\NoUnusedImportsFixer;
|
||||
use PhpCsFixer\Fixer\Import\OrderedImportsFixer;
|
||||
use PhpCsFixer\Fixer\LanguageConstruct\ClassKeywordFixer;
|
||||
use PhpCsFixer\Fixer\LanguageConstruct\CombineConsecutiveIssetsFixer;
|
||||
use PhpCsFixer\Fixer\LanguageConstruct\CombineConsecutiveUnsetsFixer;
|
||||
use PhpCsFixer\Fixer\LanguageConstruct\NullableTypeDeclarationFixer;
|
||||
use PhpCsFixer\Fixer\LanguageConstruct\SingleSpaceAroundConstructFixer;
|
||||
use PhpCsFixer\Fixer\ListNotation\ListSyntaxFixer;
|
||||
use PhpCsFixer\Fixer\NamespaceNotation\BlankLinesBeforeNamespaceFixer;
|
||||
use PhpCsFixer\Fixer\Naming\NoHomoglyphNamesFixer;
|
||||
use PhpCsFixer\Fixer\Operator\ConcatSpaceFixer;
|
||||
use PhpCsFixer\Fixer\Operator\IncrementStyleFixer;
|
||||
use PhpCsFixer\Fixer\Operator\LongToShorthandOperatorFixer;
|
||||
use PhpCsFixer\Fixer\Operator\NewWithParenthesesFixer;
|
||||
use PhpCsFixer\Fixer\Operator\NoUselessConcatOperatorFixer;
|
||||
use PhpCsFixer\Fixer\Operator\ObjectOperatorWithoutWhitespaceFixer;
|
||||
use PhpCsFixer\Fixer\Operator\OperatorLinebreakFixer;
|
||||
use PhpCsFixer\Fixer\Operator\StandardizeIncrementFixer;
|
||||
use PhpCsFixer\Fixer\Operator\TernaryOperatorSpacesFixer;
|
||||
use PhpCsFixer\Fixer\Operator\TernaryToElvisOperatorFixer;
|
||||
use PhpCsFixer\Fixer\Operator\TernaryToNullCoalescingFixer;
|
||||
use PhpCsFixer\Fixer\PhpUnit\PhpUnitConstructFixer;
|
||||
use PhpCsFixer\Fixer\PhpUnit\PhpUnitDataProviderReturnTypeFixer;
|
||||
use PhpCsFixer\Fixer\PhpUnit\PhpUnitDataProviderStaticFixer;
|
||||
use PhpCsFixer\Fixer\PhpUnit\PhpUnitDedicateAssertFixer;
|
||||
use PhpCsFixer\Fixer\PhpUnit\PhpUnitDedicateAssertInternalTypeFixer;
|
||||
use PhpCsFixer\Fixer\PhpUnit\PhpUnitFqcnAnnotationFixer;
|
||||
use PhpCsFixer\Fixer\PhpUnit\PhpUnitMethodCasingFixer;
|
||||
use PhpCsFixer\Fixer\PhpUnit\PhpUnitMockFixer;
|
||||
use PhpCsFixer\Fixer\PhpUnit\PhpUnitMockShortWillReturnFixer;
|
||||
use PhpCsFixer\Fixer\PhpUnit\PhpUnitNamespacedFixer;
|
||||
use PhpCsFixer\Fixer\PhpUnit\PhpUnitNoExpectationAnnotationFixer;
|
||||
use PhpCsFixer\Fixer\PhpUnit\PhpUnitSetUpTearDownVisibilityFixer;
|
||||
use PhpCsFixer\Fixer\PhpUnit\PhpUnitStrictFixer;
|
||||
use PhpCsFixer\Fixer\PhpUnit\PhpUnitTestAnnotationFixer;
|
||||
use PhpCsFixer\Fixer\PhpUnit\PhpUnitTestCaseStaticMethodCallsFixer;
|
||||
use PhpCsFixer\Fixer\Phpdoc\NoBlankLinesAfterPhpdocFixer;
|
||||
use PhpCsFixer\Fixer\Phpdoc\NoEmptyPhpdocFixer;
|
||||
use PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer;
|
||||
use PhpCsFixer\Fixer\Phpdoc\PhpdocAlignFixer;
|
||||
use PhpCsFixer\Fixer\Phpdoc\PhpdocIndentFixer;
|
||||
use PhpCsFixer\Fixer\Phpdoc\PhpdocLineSpanFixer;
|
||||
use PhpCsFixer\Fixer\Phpdoc\PhpdocNoAccessFixer;
|
||||
use PhpCsFixer\Fixer\Phpdoc\PhpdocOrderByValueFixer;
|
||||
use PhpCsFixer\Fixer\Phpdoc\PhpdocOrderFixer;
|
||||
use PhpCsFixer\Fixer\Phpdoc\PhpdocParamOrderFixer;
|
||||
use PhpCsFixer\Fixer\Phpdoc\PhpdocScalarFixer;
|
||||
use PhpCsFixer\Fixer\Phpdoc\PhpdocSeparationFixer;
|
||||
use PhpCsFixer\Fixer\Phpdoc\PhpdocToCommentFixer;
|
||||
use PhpCsFixer\Fixer\Phpdoc\PhpdocTrimConsecutiveBlankLineSeparationFixer;
|
||||
use PhpCsFixer\Fixer\Phpdoc\PhpdocTrimFixer;
|
||||
use PhpCsFixer\Fixer\Phpdoc\PhpdocTypesFixer;
|
||||
use PhpCsFixer\Fixer\Phpdoc\PhpdocTypesOrderFixer;
|
||||
use PhpCsFixer\Fixer\Phpdoc\PhpdocVarAnnotationCorrectOrderFixer;
|
||||
use PhpCsFixer\Fixer\Phpdoc\PhpdocVarWithoutNameFixer;
|
||||
use PhpCsFixer\Fixer\ReturnNotation\NoUselessReturnFixer;
|
||||
use PhpCsFixer\Fixer\Semicolon\MultilineWhitespaceBeforeSemicolonsFixer;
|
||||
use PhpCsFixer\Fixer\Semicolon\NoEmptyStatementFixer;
|
||||
use PhpCsFixer\Fixer\Semicolon\NoSinglelineWhitespaceBeforeSemicolonsFixer;
|
||||
use PhpCsFixer\Fixer\Semicolon\SemicolonAfterInstructionFixer;
|
||||
use PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer;
|
||||
use PhpCsFixer\Fixer\StringNotation\NoTrailingWhitespaceInStringFixer;
|
||||
use PhpCsFixer\Fixer\StringNotation\SingleQuoteFixer;
|
||||
use PhpCsFixer\Fixer\StringNotation\StringImplicitBackslashesFixer;
|
||||
use PhpCsFixer\Fixer\StringNotation\StringLengthToEmptyFixer;
|
||||
use PhpCsFixer\Fixer\Whitespace\ArrayIndentationFixer;
|
||||
use PhpCsFixer\Fixer\Whitespace\CompactNullableTypeDeclarationFixer;
|
||||
use PhpCsFixer\Fixer\Whitespace\MethodChainingIndentationFixer;
|
||||
use PhpCsFixer\Fixer\Whitespace\NoExtraBlankLinesFixer;
|
||||
use PhpCsFixer\Fixer\Whitespace\NoSpacesAroundOffsetFixer;
|
||||
use PhpCsFixer\Fixer\Whitespace\StatementIndentationFixer;
|
||||
use PhpCsFixer\Fixer\Whitespace\TypeDeclarationSpacesFixer;
|
||||
use PhpCsFixer\Fixer\Whitespace\TypesSpacesFixer;
|
||||
use PhpCsFixer\Preg;
|
||||
|
||||
/**
|
||||
* Transforms a given class to php-cs-fixer rule name.
|
||||
* That way we can use auto completion, phpstan, etc.
|
||||
*
|
||||
* @param class-string $className
|
||||
*/
|
||||
function transform(string $className): string
|
||||
{
|
||||
$nameParts = explode('\\', $className);
|
||||
$name = mb_substr(end($nameParts), 0, -mb_strlen('Fixer'));
|
||||
|
||||
return mb_strtolower(Preg::replace(
|
||||
'/(?<!^)((?=[\p{Lu}][^\p{Lu}])|(?<![\p{Lu}])(?=[\p{Lu}]))/',
|
||||
'_',
|
||||
$name
|
||||
));
|
||||
}
|
||||
|
||||
return (new Config())
|
||||
->setRiskyAllowed(true)
|
||||
->setFinder(
|
||||
(new Finder())
|
||||
->ignoreVCSIgnored(true)
|
||||
->in(realpath(__DIR__))
|
||||
)
|
||||
->setRules([
|
||||
'@DoctrineAnnotation' => true,
|
||||
'@PSR2' => true,
|
||||
'array_syntax' => ['syntax' => 'short'],
|
||||
'blank_line_after_opening_tag' => true,
|
||||
'braces' => ['allow_single_line_closure' => true],
|
||||
'cast_spaces' => ['space' => 'none'],
|
||||
'compact_nullable_typehint' => true,
|
||||
'concat_space' => ['spacing' => 'one'],
|
||||
'declare_equal_normalize' => ['space' => 'none'],
|
||||
'dir_constant' => true,
|
||||
'function_to_constant' => ['functions' => ['get_called_class', 'get_class', 'get_class_this', 'php_sapi_name', 'phpversion', 'pi']],
|
||||
'function_typehint_space' => true,
|
||||
'lowercase_cast' => true,
|
||||
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
|
||||
'modernize_strpos' => true,
|
||||
'modernize_types_casting' => true,
|
||||
'native_function_casing' => true,
|
||||
'new_with_braces' => true,
|
||||
'no_alias_functions' => true,
|
||||
'no_blank_lines_after_phpdoc' => true,
|
||||
'no_empty_phpdoc' => true,
|
||||
'no_empty_statement' => true,
|
||||
'no_extra_blank_lines' => true,
|
||||
'no_leading_import_slash' => true,
|
||||
'no_leading_namespace_whitespace' => true,
|
||||
'no_null_property_initialization' => true,
|
||||
'no_short_bool_cast' => true,
|
||||
'no_singleline_whitespace_before_semicolons' => true,
|
||||
'no_superfluous_elseif' => true,
|
||||
'no_trailing_comma_in_singleline_array' => true,
|
||||
'no_unneeded_control_parentheses' => true,
|
||||
'no_unused_imports' => true,
|
||||
'no_useless_else' => true,
|
||||
'no_whitespace_in_blank_line' => true,
|
||||
'ordered_imports' => true,
|
||||
'php_unit_construct' => ['assertions' => ['assertEquals', 'assertSame', 'assertNotEquals', 'assertNotSame']],
|
||||
'php_unit_mock_short_will_return' => true,
|
||||
'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
|
||||
'phpdoc_no_access' => true,
|
||||
'phpdoc_no_empty_return' => true,
|
||||
'phpdoc_no_package' => true,
|
||||
'phpdoc_scalar' => true,
|
||||
'phpdoc_trim' => true,
|
||||
'phpdoc_types' => true,
|
||||
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
|
||||
'return_type_declaration' => ['space_before' => 'none'],
|
||||
'single_quote' => true,
|
||||
'single_line_comment_style' => ['comment_types' => ['hash']],
|
||||
'single_trait_insert_per_statement' => true,
|
||||
'trailing_comma_in_multiline' => ['elements' => ['arrays']],
|
||||
'whitespace_after_comma_in_array' => true,
|
||||
'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false],
|
||||
'@PSR12' => true,
|
||||
transform(ArrayIndentationFixer::class) => true,
|
||||
transform(ArraySyntaxFixer::class) => [
|
||||
'syntax' => 'short',
|
||||
],
|
||||
transform(AttributeEmptyParenthesesFixer::class) => true,
|
||||
transform(BlankLinesBeforeNamespaceFixer::class) => true,
|
||||
transform(CastSpacesFixer::class) => true,
|
||||
transform(ClassAttributesSeparationFixer::class) => [
|
||||
'elements' => [
|
||||
'const' => 'one',
|
||||
'method' => 'one',
|
||||
'property' => 'one',
|
||||
'trait_import' => 'one',
|
||||
],
|
||||
],
|
||||
transform(ClassKeywordFixer::class) => true,
|
||||
transform(ClassReferenceNameCasingFixer::class) => true,
|
||||
transform(CombineConsecutiveIssetsFixer::class) => true,
|
||||
transform(CombineConsecutiveUnsetsFixer::class) => true,
|
||||
transform(CompactNullableTypeDeclarationFixer::class) => true,
|
||||
transform(ConcatSpaceFixer::class) => [
|
||||
'spacing' => 'one',
|
||||
],
|
||||
transform(DateTimeCreateFromFormatCallFixer::class) => true,
|
||||
transform(DeclareStrictTypesFixer::class) => true,
|
||||
transform(FullyQualifiedStrictTypesFixer::class) => [
|
||||
'import_symbols' => true,
|
||||
'leading_backslash_in_global_namespace' => true,
|
||||
],
|
||||
transform(GlobalNamespaceImportFixer::class) => true,
|
||||
transform(IncrementStyleFixer::class) => [
|
||||
'style' => 'post',
|
||||
],
|
||||
transform(ListSyntaxFixer::class) => true,
|
||||
transform(LongToShorthandOperatorFixer::class) => true,
|
||||
transform(MbStrFunctionsFixer::class) => true,
|
||||
transform(MethodArgumentSpaceFixer::class) => [
|
||||
'on_multiline' => 'ensure_fully_multiline',
|
||||
'attribute_placement' => 'standalone',
|
||||
],
|
||||
transform(MethodChainingIndentationFixer::class) => true,
|
||||
transform(ModernizeTypesCastingFixer::class) => true,
|
||||
transform(MultilineCommentOpeningClosingFixer::class) => true,
|
||||
transform(MultilineWhitespaceBeforeSemicolonsFixer::class) => [
|
||||
'strategy' => 'new_line_for_chained_calls',
|
||||
],
|
||||
transform(NativeFunctionCasingFixer::class) => true,
|
||||
transform(NativeTypeDeclarationCasingFixer::class) => true,
|
||||
transform(NewWithParenthesesFixer::class) => [
|
||||
'anonymous_class' => false,
|
||||
'named_class' => true,
|
||||
],
|
||||
transform(NoAliasFunctionsFixer::class) => true,
|
||||
transform(NoBlankLinesAfterPhpdocFixer::class) => true,
|
||||
transform(NoEmptyCommentFixer::class) => true,
|
||||
transform(NoEmptyPhpdocFixer::class) => true,
|
||||
transform(NoEmptyStatementFixer::class) => true,
|
||||
transform(NoExtraBlankLinesFixer::class) => true,
|
||||
transform(NoHomoglyphNamesFixer::class) => true,
|
||||
transform(NoMultilineWhitespaceAroundDoubleArrowFixer::class) => true,
|
||||
transform(NoMultipleStatementsPerLineFixer::class) => true,
|
||||
transform(NoNullPropertyInitializationFixer::class) => true,
|
||||
transform(NoSinglelineWhitespaceBeforeSemicolonsFixer::class) => true,
|
||||
transform(NoSpacesAroundOffsetFixer::class) => true,
|
||||
transform(NoSuperfluousElseifFixer::class) => true,
|
||||
transform(NoSuperfluousPhpdocTagsFixer::class) => [
|
||||
'allow_mixed' => true,
|
||||
],
|
||||
transform(NoTrailingCommaInSinglelineFixer::class) => true,
|
||||
transform(NoTrailingWhitespaceInStringFixer::class) => true,
|
||||
transform(NoUnneededBracesFixer::class) => true,
|
||||
transform(NoUnneededControlParenthesesFixer::class) => true,
|
||||
transform(NoUnneededImportAliasFixer::class) => true,
|
||||
transform(NoUnreachableDefaultArgumentValueFixer::class) => true,
|
||||
transform(NoUnsetCastFixer::class) => true,
|
||||
transform(NoUnusedImportsFixer::class) => true,
|
||||
transform(NoUselessConcatOperatorFixer::class) => true,
|
||||
transform(NoUselessElseFixer::class) => true,
|
||||
transform(NoUselessReturnFixer::class) => true,
|
||||
transform(NoUselessSprintfFixer::class) => true,
|
||||
transform(NoWhitespaceBeforeCommaInArrayFixer::class) => true,
|
||||
transform(NonPrintableCharacterFixer::class) => true,
|
||||
transform(NormalizeIndexBraceFixer::class) => true,
|
||||
transform(NullableTypeDeclarationFixer::class) => true,
|
||||
transform(NullableTypeDeclarationForDefaultNullValueFixer::class) => true,
|
||||
transform(NumericLiteralSeparatorFixer::class) => [
|
||||
'strategy' => NumericLiteralSeparatorFixer::STRATEGY_NO_SEPARATOR,
|
||||
],
|
||||
transform(ObjectOperatorWithoutWhitespaceFixer::class) => true,
|
||||
transform(OperatorLinebreakFixer::class) => [
|
||||
'position' => 'beginning', ],
|
||||
transform(OrderedClassElementsFixer::class) => [
|
||||
'order' => [
|
||||
'use_trait',
|
||||
'case',
|
||||
'constant_public',
|
||||
'constant_protected',
|
||||
'constant_private',
|
||||
'property_public',
|
||||
'property_protected',
|
||||
'property_private',
|
||||
'construct',
|
||||
'destruct',
|
||||
'phpunit',
|
||||
'method_public',
|
||||
'method_protected',
|
||||
'method_private',
|
||||
'magic',
|
||||
],
|
||||
'case_sensitive' => true,
|
||||
],
|
||||
transform(OrderedImportsFixer::class) => [
|
||||
'sort_algorithm' => 'alpha',
|
||||
'case_sensitive' => true,
|
||||
],
|
||||
transform(OrderedInterfacesFixer::class) => [
|
||||
'case_sensitive' => true,
|
||||
],
|
||||
transform(OrderedTraitsFixer::class) => [
|
||||
'case_sensitive' => true,
|
||||
],
|
||||
transform(OrderedTypesFixer::class) => [
|
||||
'case_sensitive' => true,
|
||||
],
|
||||
transform(PhpUnitConstructFixer::class) => true,
|
||||
transform(PhpUnitDataProviderReturnTypeFixer::class) => true,
|
||||
transform(PhpUnitDataProviderStaticFixer::class) => [
|
||||
'force' => true,
|
||||
],
|
||||
transform(PhpUnitDedicateAssertFixer::class) => true,
|
||||
transform(PhpUnitDedicateAssertInternalTypeFixer::class) => true,
|
||||
transform(PhpUnitFqcnAnnotationFixer::class) => true,
|
||||
transform(PhpUnitMethodCasingFixer::class) => true,
|
||||
transform(PhpUnitMockFixer::class) => true,
|
||||
transform(PhpUnitMockShortWillReturnFixer::class) => true,
|
||||
transform(PhpUnitNamespacedFixer::class) => true,
|
||||
transform(PhpUnitNoExpectationAnnotationFixer::class) => true,
|
||||
transform(PhpUnitSetUpTearDownVisibilityFixer::class) => true,
|
||||
transform(PhpUnitStrictFixer::class) => true,
|
||||
transform(PhpUnitTestAnnotationFixer::class) => [
|
||||
'style' => 'annotation',
|
||||
],
|
||||
transform(PhpUnitTestCaseStaticMethodCallsFixer::class) => [
|
||||
'call_type' => 'self',
|
||||
],
|
||||
transform(PhpdocAlignFixer::class) => [
|
||||
'align' => 'left',
|
||||
],
|
||||
transform(PhpdocIndentFixer::class) => true,
|
||||
transform(PhpdocLineSpanFixer::class) => true,
|
||||
transform(PhpdocNoAccessFixer::class) => true,
|
||||
transform(PhpdocOrderByValueFixer::class) => [
|
||||
'annotations' => [
|
||||
'covers', 'throws',
|
||||
],
|
||||
],
|
||||
transform(PhpdocOrderFixer::class) => true,
|
||||
transform(PhpdocParamOrderFixer::class) => true,
|
||||
transform(PhpdocScalarFixer::class) => true,
|
||||
transform(PhpdocSeparationFixer::class) => [
|
||||
'groups' => [
|
||||
['see'],
|
||||
['throw'],
|
||||
['param'],
|
||||
['return'],
|
||||
],
|
||||
],
|
||||
transform(PhpdocToCommentFixer::class) => true,
|
||||
transform(PhpdocToParamTypeFixer::class) => true,
|
||||
transform(PhpdocToPropertyTypeFixer::class) => true,
|
||||
transform(PhpdocToReturnTypeFixer::class) => true,
|
||||
transform(PhpdocTrimConsecutiveBlankLineSeparationFixer::class) => true,
|
||||
transform(PhpdocTrimFixer::class) => true,
|
||||
transform(PhpdocTypesFixer::class) => true,
|
||||
transform(PhpdocTypesOrderFixer::class) => [
|
||||
'case_sensitive' => true,
|
||||
],
|
||||
transform(PhpdocVarAnnotationCorrectOrderFixer::class) => true,
|
||||
transform(PhpdocVarWithoutNameFixer::class) => true,
|
||||
transform(RegularCallableCallFixer::class) => true,
|
||||
transform(ReturnToYieldFromFixer::class) => true,
|
||||
transform(SelfAccessorFixer::class) => true,
|
||||
transform(SemicolonAfterInstructionFixer::class) => true,
|
||||
transform(SimplifiedIfReturnFixer::class) => true,
|
||||
transform(SingleLineCommentStyleFixer::class) => true,
|
||||
transform(SingleQuoteFixer::class) => true,
|
||||
transform(SingleSpaceAroundConstructFixer::class) => true,
|
||||
transform(StandardizeIncrementFixer::class) => true,
|
||||
transform(StatementIndentationFixer::class) => true,
|
||||
transform(StaticLambdaFixer::class) => true,
|
||||
transform(StringImplicitBackslashesFixer::class) => [
|
||||
'single_quoted' => 'ignore',
|
||||
],
|
||||
transform(StringLengthToEmptyFixer::class) => true,
|
||||
transform(TernaryOperatorSpacesFixer::class) => true,
|
||||
transform(TernaryToElvisOperatorFixer::class) => true,
|
||||
transform(TernaryToNullCoalescingFixer::class) => true,
|
||||
transform(TrailingCommaInMultilineFixer::class) => true,
|
||||
transform(TrimArraySpacesFixer::class) => true,
|
||||
transform(TypeDeclarationSpacesFixer::class) => true,
|
||||
transform(TypesSpacesFixer::class) => true,
|
||||
transform(WhitespaceAfterCommaInArrayFixer::class) => [
|
||||
'ensure_single_space' => true,
|
||||
],
|
||||
transform(YieldFromArrayToYieldsFixer::class) => true,
|
||||
])
|
||||
->setFinder($finder);
|
||||
;
|
||||
|
|
|
@ -31,15 +31,9 @@ use Symfony\Component\Console\Style\SymfonyStyle;
|
|||
|
||||
class UpdateDataCommand extends Command
|
||||
{
|
||||
/**
|
||||
* @var Pageview
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
public function __construct(Pageview $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
|
||||
public function __construct(
|
||||
private readonly Pageview $repository
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace DanielSiepmann\Tracking\Dashboard\Provider;
|
||||
|
||||
use Exception;
|
||||
use TYPO3\CMS\Core\Database\Connection;
|
||||
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
|
||||
use TYPO3\CMS\Dashboard\Widgets\ListDataProviderInterface;
|
||||
|
@ -30,35 +31,14 @@ use TYPO3\CMS\Dashboard\Widgets\ListDataProviderInterface;
|
|||
class NewestPageviews implements ListDataProviderInterface
|
||||
{
|
||||
/**
|
||||
* @var QueryBuilder
|
||||
* @param int[] $languageLimitation
|
||||
*/
|
||||
private $queryBuilder;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $maxResults;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $pagesToExclude;
|
||||
|
||||
/**
|
||||
* @var array<int>
|
||||
*/
|
||||
private $languageLimitation;
|
||||
|
||||
public function __construct(
|
||||
QueryBuilder $queryBuilder,
|
||||
int $maxResults = 6,
|
||||
array $pagesToExclude = [],
|
||||
array $languageLimitation = []
|
||||
private readonly QueryBuilder $queryBuilder,
|
||||
private readonly int $maxResults = 6,
|
||||
private readonly array $pagesToExclude = [],
|
||||
private readonly array $languageLimitation = []
|
||||
) {
|
||||
$this->queryBuilder = $queryBuilder;
|
||||
$this->maxResults = $maxResults;
|
||||
$this->pagesToExclude = $pagesToExclude;
|
||||
$this->languageLimitation = $languageLimitation;
|
||||
}
|
||||
|
||||
public function getItems(): array
|
||||
|
@ -98,10 +78,13 @@ class NewestPageviews implements ListDataProviderInterface
|
|||
$this->queryBuilder->where(...$constraints);
|
||||
}
|
||||
|
||||
$items = $this->queryBuilder->execute()->fetchAll();
|
||||
$items = $this->queryBuilder->executeQuery()->fetchAllAssociative();
|
||||
foreach ($items as $item) {
|
||||
if (is_array($item) === false) {
|
||||
continue;
|
||||
if (is_string($item['url']) === false) {
|
||||
throw new Exception('url of item was not string: ' . var_export($item['url'], true), 1707327319);
|
||||
}
|
||||
if (is_string($item['user_agent']) === false) {
|
||||
throw new Exception('user_agent of item was not string: ' . var_export($item['user_agent'], true), 1707327344);
|
||||
}
|
||||
|
||||
$preparedItems[] = sprintf(
|
||||
|
|
|
@ -24,6 +24,7 @@ declare(strict_types=1);
|
|||
namespace DanielSiepmann\Tracking\Dashboard\Provider;
|
||||
|
||||
use DanielSiepmann\Tracking\Extension;
|
||||
use Doctrine\DBAL\Platforms\SqlitePlatform;
|
||||
use TYPO3\CMS\Core\Database\Connection;
|
||||
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
|
||||
use TYPO3\CMS\Core\Localization\LanguageService;
|
||||
|
@ -32,49 +33,20 @@ use TYPO3\CMS\Dashboard\Widgets\ChartDataProviderInterface;
|
|||
|
||||
class PageviewsPerDay implements ChartDataProviderInterface
|
||||
{
|
||||
/**
|
||||
* @var LanguageService
|
||||
*/
|
||||
private $languageService;
|
||||
private LanguageService $languageService;
|
||||
|
||||
/**
|
||||
* @var QueryBuilder
|
||||
* @param int[] $pagesToExclude
|
||||
* @param int[] $languageLimitation
|
||||
*/
|
||||
private $queryBuilder;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $days;
|
||||
|
||||
/**
|
||||
* @var array<int>
|
||||
*/
|
||||
private $pagesToExclude;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $dateFormat;
|
||||
|
||||
/**
|
||||
* @var array<int>
|
||||
*/
|
||||
private $languageLimitation;
|
||||
|
||||
public function __construct(
|
||||
QueryBuilder $queryBuilder,
|
||||
int $days = 31,
|
||||
array $pagesToExclude = [],
|
||||
array $languageLimitation = [],
|
||||
string $dateFormat = 'Y-m-d'
|
||||
private readonly QueryBuilder $queryBuilder,
|
||||
private readonly int $days = 31,
|
||||
private readonly array $pagesToExclude = [],
|
||||
private readonly array $languageLimitation = [],
|
||||
private readonly string $dateFormat = 'Y-m-d'
|
||||
) {
|
||||
$this->languageService = $GLOBALS['LANG'];
|
||||
$this->queryBuilder = $queryBuilder;
|
||||
$this->days = $days;
|
||||
$this->pagesToExclude = $pagesToExclude;
|
||||
$this->languageLimitation = $languageLimitation;
|
||||
$this->dateFormat = $dateFormat;
|
||||
}
|
||||
|
||||
public function getChartData(): array
|
||||
|
@ -102,16 +74,16 @@ class PageviewsPerDay implements ChartDataProviderInterface
|
|||
$data = [];
|
||||
|
||||
for ($daysBefore = $this->days; $daysBefore >= 0; $daysBefore--) {
|
||||
$label = date($this->dateFormat, (int)strtotime('-' . $daysBefore . ' day'));
|
||||
$label = date($this->dateFormat, (int) strtotime('-' . $daysBefore . ' day'));
|
||||
$labels[$label] = $label;
|
||||
$data[$label] = 0;
|
||||
}
|
||||
|
||||
$start = (int)strtotime('-' . $this->days . ' day 0:00:00');
|
||||
$end = (int)strtotime('tomorrow midnight');
|
||||
$start = (int) strtotime('-' . $this->days . ' day 0:00:00');
|
||||
$end = (int) strtotime('tomorrow midnight');
|
||||
|
||||
foreach ($this->getPageviewsInPeriod($start, $end) as $day) {
|
||||
$data[$day['label']] = (int)$day['count'];
|
||||
$data[$day['label']] = (int) $day['count'];
|
||||
}
|
||||
|
||||
return [
|
||||
|
@ -154,13 +126,15 @@ class PageviewsPerDay implements ChartDataProviderInterface
|
|||
->groupBy('label')
|
||||
->orderBy('label', 'ASC')
|
||||
;
|
||||
|
||||
if ($this->queryBuilder->getConnection()->getDatabasePlatform()->getName() === 'sqlite') {
|
||||
if (
|
||||
(class_exists(SqlitePlatform::class) && $this->queryBuilder->getConnection()->getDatabasePlatform() instanceof SqlitePlatform)
|
||||
|| (method_exists($this->queryBuilder->getConnection()->getDatabasePlatform(), 'getName') && $this->queryBuilder->getConnection()->getDatabasePlatform()->getName() === 'sqlite')
|
||||
) {
|
||||
$this->queryBuilder->addSelectLiteral('date(crdate, "unixepoch") as "label"');
|
||||
} else {
|
||||
$this->queryBuilder->addSelectLiteral('FROM_UNIXTIME(crdate, "%Y-%m-%d") as "label"');
|
||||
}
|
||||
|
||||
return $this->queryBuilder->execute()->fetchAll();
|
||||
return $this->queryBuilder->executeQuery()->fetchAllAssociative();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace DanielSiepmann\Tracking\Dashboard\Provider;
|
||||
|
||||
use Exception;
|
||||
use TYPO3\CMS\Core\Database\Connection;
|
||||
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
|
||||
use TYPO3\CMS\Dashboard\WidgetApi;
|
||||
|
@ -31,35 +32,14 @@ use TYPO3\CMS\Dashboard\Widgets\ChartDataProviderInterface;
|
|||
class PageviewsPerOperatingSystem implements ChartDataProviderInterface
|
||||
{
|
||||
/**
|
||||
* @var QueryBuilder
|
||||
* @param int[] $languageLimitation
|
||||
*/
|
||||
private $queryBuilder;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $days;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $maxResults;
|
||||
|
||||
/**
|
||||
* @var array<int>
|
||||
*/
|
||||
private $languageLimitation;
|
||||
|
||||
public function __construct(
|
||||
QueryBuilder $queryBuilder,
|
||||
int $days = 31,
|
||||
int $maxResults = 6,
|
||||
array $languageLimitation = []
|
||||
private readonly QueryBuilder $queryBuilder,
|
||||
private readonly int $days = 31,
|
||||
private readonly int $maxResults = 6,
|
||||
private readonly array $languageLimitation = []
|
||||
) {
|
||||
$this->queryBuilder = $queryBuilder;
|
||||
$this->days = $days;
|
||||
$this->maxResults = $maxResults;
|
||||
$this->languageLimitation = $languageLimitation;
|
||||
}
|
||||
|
||||
public function getChartData(): array
|
||||
|
@ -112,13 +92,13 @@ class PageviewsPerOperatingSystem implements ChartDataProviderInterface
|
|||
->orderBy('total', 'desc')
|
||||
->addOrderBy('operating_system', 'asc')
|
||||
->setMaxResults($this->maxResults)
|
||||
->execute()
|
||||
->fetchAll()
|
||||
->executeQuery()
|
||||
->fetchAllAssociative()
|
||||
;
|
||||
|
||||
foreach ($result as $row) {
|
||||
if (is_array($row) === false) {
|
||||
continue;
|
||||
if (is_string($row['operating_system']) === false) {
|
||||
throw new Exception('operating_system of row was not string: ' . var_export($row['operating_system'], true), 1707326866);
|
||||
}
|
||||
|
||||
$labels[] = mb_strimwidth($row['operating_system'], 0, 50, '…');
|
||||
|
|
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace DanielSiepmann\Tracking\Dashboard\Provider;
|
||||
|
||||
use Exception;
|
||||
use TYPO3\CMS\Backend\Utility\BackendUtility;
|
||||
use TYPO3\CMS\Core\Database\Connection;
|
||||
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
|
||||
|
@ -33,49 +34,17 @@ use TYPO3\CMS\Dashboard\Widgets\ChartDataProviderInterface;
|
|||
class PageviewsPerPage implements ChartDataProviderInterface
|
||||
{
|
||||
/**
|
||||
* @var QueryBuilder
|
||||
* @param int[] $pagesToExclude
|
||||
* @param int[] $languageLimitation
|
||||
*/
|
||||
private $queryBuilder;
|
||||
|
||||
/**
|
||||
* @var PageRepository
|
||||
*/
|
||||
private $pageRepository;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $days;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $maxResults;
|
||||
|
||||
/**
|
||||
* @var array<int>
|
||||
*/
|
||||
private $pagesToExclude;
|
||||
|
||||
/**
|
||||
* @var array<int>
|
||||
*/
|
||||
private $languageLimitation;
|
||||
|
||||
public function __construct(
|
||||
QueryBuilder $queryBuilder,
|
||||
PageRepository $pageRepository,
|
||||
int $days = 31,
|
||||
int $maxResults = 6,
|
||||
array $pagesToExclude = [],
|
||||
array $languageLimitation = []
|
||||
private readonly QueryBuilder $queryBuilder,
|
||||
private readonly PageRepository $pageRepository,
|
||||
private readonly int $days = 31,
|
||||
private readonly int $maxResults = 6,
|
||||
private readonly array $pagesToExclude = [],
|
||||
private readonly array $languageLimitation = []
|
||||
) {
|
||||
$this->queryBuilder = $queryBuilder;
|
||||
$this->pageRepository = $pageRepository;
|
||||
$this->days = $days;
|
||||
$this->maxResults = $maxResults;
|
||||
$this->pagesToExclude = $pagesToExclude;
|
||||
$this->languageLimitation = $languageLimitation;
|
||||
}
|
||||
|
||||
public function getChartData(): array
|
||||
|
@ -136,16 +105,16 @@ class PageviewsPerPage implements ChartDataProviderInterface
|
|||
->orderBy('total', 'desc')
|
||||
->addOrderBy('latest', 'desc')
|
||||
->setMaxResults($this->maxResults)
|
||||
->execute()
|
||||
->fetchAll()
|
||||
->executeQuery()
|
||||
->fetchAllAssociative()
|
||||
;
|
||||
|
||||
foreach ($result as $row) {
|
||||
if (is_array($row) === false) {
|
||||
continue;
|
||||
if (is_numeric($row['pid']) === false) {
|
||||
throw new Exception('PID of row was not numeric: ' . var_export($row['pid'], true), 1707326783);
|
||||
}
|
||||
|
||||
$labels[] = $this->getRecordTitle((int)$row['pid']);
|
||||
$labels[] = $this->getRecordTitle((int) $row['pid']);
|
||||
$data[] = $row['total'];
|
||||
}
|
||||
|
||||
|
@ -159,13 +128,16 @@ class PageviewsPerPage implements ChartDataProviderInterface
|
|||
{
|
||||
$record = BackendUtility::getRecord('pages', $uid);
|
||||
if (count($this->languageLimitation) === 1 && $record !== null) {
|
||||
$record = $this->pageRepository->getRecordOverlay('pages', $record, $this->languageLimitation[0]);
|
||||
$record = $this->pageRepository->getPageOverlay(
|
||||
$record,
|
||||
$this->languageLimitation[0]
|
||||
);
|
||||
}
|
||||
|
||||
if (is_array($record) === false) {
|
||||
return 'Unkown';
|
||||
}
|
||||
|
||||
return strip_tags(BackendUtility::getRecordTitle('pages', $record, true));
|
||||
return strip_tags((string) BackendUtility::getRecordTitle('pages', $record, true));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,9 +23,10 @@ declare(strict_types=1);
|
|||
|
||||
namespace DanielSiepmann\Tracking\Dashboard\Provider;
|
||||
|
||||
use DanielSiepmann\Tracking\LanguageAspectFactory;
|
||||
use Exception;
|
||||
use Generator;
|
||||
use TYPO3\CMS\Backend\Utility\BackendUtility;
|
||||
use TYPO3\CMS\Core\Context\LanguageAspect;
|
||||
use TYPO3\CMS\Core\Database\Connection;
|
||||
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
|
||||
use TYPO3\CMS\Core\Domain\Repository\PageRepository;
|
||||
|
@ -35,63 +36,20 @@ use TYPO3\CMS\Dashboard\Widgets\ChartDataProviderInterface;
|
|||
class Recordviews implements ChartDataProviderInterface
|
||||
{
|
||||
/**
|
||||
* @var PageRepository
|
||||
* @param int[] $pagesToExclude
|
||||
* @param int[] $languageLimitation
|
||||
*/
|
||||
private $pageRepository;
|
||||
|
||||
/**
|
||||
* @var QueryBuilder
|
||||
*/
|
||||
private $queryBuilder;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $days;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $maxResults;
|
||||
|
||||
/**
|
||||
* @var array<int>
|
||||
*/
|
||||
private $pagesToExclude;
|
||||
|
||||
/**
|
||||
* @var array<int>
|
||||
*/
|
||||
private $languageLimitation;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $recordTableLimitation;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $recordTypeLimitation;
|
||||
|
||||
public function __construct(
|
||||
PageRepository $pageRepository,
|
||||
QueryBuilder $queryBuilder,
|
||||
int $days = 31,
|
||||
int $maxResults = 6,
|
||||
array $pagesToExclude = [],
|
||||
array $languageLimitation = [],
|
||||
array $recordTableLimitation = [],
|
||||
array $recordTypeLimitation = []
|
||||
private readonly PageRepository $pageRepository,
|
||||
private readonly QueryBuilder $queryBuilder,
|
||||
private readonly LanguageAspectFactory $languageAspectFactory,
|
||||
private readonly int $days = 31,
|
||||
private readonly int $maxResults = 6,
|
||||
private readonly array $pagesToExclude = [],
|
||||
private readonly array $languageLimitation = [],
|
||||
private readonly array $recordTableLimitation = [],
|
||||
private readonly array $recordTypeLimitation = []
|
||||
) {
|
||||
$this->pageRepository = $pageRepository;
|
||||
$this->queryBuilder = $queryBuilder;
|
||||
$this->days = $days;
|
||||
$this->pagesToExclude = $pagesToExclude;
|
||||
$this->languageLimitation = $languageLimitation;
|
||||
$this->maxResults = $maxResults;
|
||||
$this->recordTableLimitation = $recordTableLimitation;
|
||||
$this->recordTypeLimitation = $recordTypeLimitation;
|
||||
}
|
||||
|
||||
public function getChartData(): array
|
||||
|
@ -118,8 +76,13 @@ class Recordviews implements ChartDataProviderInterface
|
|||
if (is_numeric($recordview['record_uid']) === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_string($recordview['record_table_name']) === false) {
|
||||
throw new Exception('record_table_name of recordview was not string: ' . var_export($recordview['record_table_name'], true), 1707327404);
|
||||
}
|
||||
|
||||
$record = $this->getRecord(
|
||||
(int)$recordview['record_uid'],
|
||||
(int) $recordview['record_uid'],
|
||||
$recordview['record_table_name']
|
||||
);
|
||||
|
||||
|
@ -133,7 +96,7 @@ class Recordviews implements ChartDataProviderInterface
|
|||
continue;
|
||||
}
|
||||
|
||||
$labels[] = mb_strimwidth($record['title'], 0, 25, '…');
|
||||
$labels[] = mb_strimwidth((string) $record['title'], 0, 25, '…');
|
||||
$data[] = $recordview['total'];
|
||||
}
|
||||
|
||||
|
@ -143,6 +106,9 @@ class Recordviews implements ChartDataProviderInterface
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Generator<array>
|
||||
*/
|
||||
private function getRecordviewsRecords(): Generator
|
||||
{
|
||||
$constraints = [
|
||||
|
@ -194,10 +160,10 @@ class Recordviews implements ChartDataProviderInterface
|
|||
->orderBy('total', 'desc')
|
||||
->addOrderBy('latest', 'desc')
|
||||
->setMaxResults($this->maxResults)
|
||||
->execute()
|
||||
->executeQuery()
|
||||
;
|
||||
|
||||
while ($row = $result->fetch()) {
|
||||
while ($row = $result->fetchAssociative()) {
|
||||
yield $row;
|
||||
}
|
||||
}
|
||||
|
@ -210,10 +176,10 @@ class Recordviews implements ChartDataProviderInterface
|
|||
|
||||
$record = BackendUtility::getRecord($table, $uid);
|
||||
if (count($this->languageLimitation) === 1 && $record !== null) {
|
||||
$record = $this->pageRepository->getRecordOverlay(
|
||||
$record = $this->pageRepository->getLanguageOverlay(
|
||||
$table,
|
||||
$record,
|
||||
$this->createLanguageAspect($this->languageLimitation[0])
|
||||
$this->languageAspectFactory->createFromLanguageUid($this->languageLimitation[0])
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -222,17 +188,8 @@ class Recordviews implements ChartDataProviderInterface
|
|||
}
|
||||
|
||||
return [
|
||||
'title' => strip_tags(BackendUtility::getRecordTitle($table, $record, true)),
|
||||
'title' => strip_tags((string) BackendUtility::getRecordTitle($table, $record, true)),
|
||||
'type' => $record[$recordTypeField] ?? '',
|
||||
];
|
||||
}
|
||||
|
||||
private function createLanguageAspect(int $languageUid): LanguageAspect
|
||||
{
|
||||
return new LanguageAspect(
|
||||
$languageUid,
|
||||
null,
|
||||
LanguageAspect::OVERLAYS_MIXED
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ class SymfonyExpressionLanguage implements Factory
|
|||
}
|
||||
try {
|
||||
return ArrayUtility::getValueByPath($array, $path);
|
||||
} catch (MissingArrayPathException $e) {
|
||||
} catch (MissingArrayPathException) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,8 +25,5 @@ namespace DanielSiepmann\Tracking\Domain\Model;
|
|||
|
||||
interface Expression
|
||||
{
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function evaluate();
|
||||
public function evaluate(): mixed;
|
||||
}
|
||||
|
|
|
@ -28,57 +28,15 @@ use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
|
|||
|
||||
class Pageview implements HasUserAgent
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $uid = 0;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $pageUid;
|
||||
|
||||
/**
|
||||
* @var SiteLanguage
|
||||
*/
|
||||
private $language;
|
||||
|
||||
/**
|
||||
* @var DateTimeImmutable
|
||||
*/
|
||||
private $crdate;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $pageType;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $url;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $userAgent;
|
||||
|
||||
public function __construct(
|
||||
int $pageUid,
|
||||
SiteLanguage $language,
|
||||
DateTimeImmutable $crdate,
|
||||
int $pageType,
|
||||
string $url,
|
||||
string $userAgent,
|
||||
int $uid = 0
|
||||
private readonly int $pageUid,
|
||||
private readonly SiteLanguage $language,
|
||||
private readonly DateTimeImmutable $crdate,
|
||||
private readonly int $pageType,
|
||||
private readonly string $url,
|
||||
private readonly string $userAgent,
|
||||
private readonly int $uid = 0
|
||||
) {
|
||||
$this->uid = $uid;
|
||||
$this->pageUid = $pageUid;
|
||||
$this->language = $language;
|
||||
$this->crdate = $crdate;
|
||||
$this->pageType = $pageType;
|
||||
$this->url = $url;
|
||||
$this->userAgent = $userAgent;
|
||||
}
|
||||
|
||||
public function getUid(): int
|
||||
|
|
|
@ -25,29 +25,11 @@ namespace DanielSiepmann\Tracking\Domain\Model;
|
|||
|
||||
class RecordRule
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $matches;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $recordUid;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $tableName;
|
||||
|
||||
public function __construct(
|
||||
string $matches,
|
||||
string $recordUid,
|
||||
string $tableName
|
||||
private readonly string $matches,
|
||||
private readonly string $recordUid,
|
||||
private readonly string $tableName
|
||||
) {
|
||||
$this->matches = $matches;
|
||||
$this->recordUid = $recordUid;
|
||||
$this->tableName = $tableName;
|
||||
}
|
||||
|
||||
public static function fromArray(array $config): self
|
||||
|
|
|
@ -28,57 +28,15 @@ use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
|
|||
|
||||
class Recordview implements HasUserAgent
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $pageUid;
|
||||
|
||||
/**
|
||||
* @var SiteLanguage
|
||||
*/
|
||||
private $language;
|
||||
|
||||
/**
|
||||
* @var DateTimeImmutable
|
||||
*/
|
||||
private $crdate;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $url;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $userAgent;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $recordUid;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $tableName;
|
||||
|
||||
public function __construct(
|
||||
int $pageUid,
|
||||
SiteLanguage $language,
|
||||
DateTimeImmutable $crdate,
|
||||
string $url,
|
||||
string $userAgent,
|
||||
int $recordUid,
|
||||
string $tableName
|
||||
private readonly int $pageUid,
|
||||
private readonly SiteLanguage $language,
|
||||
private readonly DateTimeImmutable $crdate,
|
||||
private readonly string $url,
|
||||
private readonly string $userAgent,
|
||||
private readonly int $recordUid,
|
||||
private readonly string $tableName
|
||||
) {
|
||||
$this->pageUid = $pageUid;
|
||||
$this->language = $language;
|
||||
$this->crdate = $crdate;
|
||||
$this->url = $url;
|
||||
$this->userAgent = $userAgent;
|
||||
$this->recordUid = $recordUid;
|
||||
$this->tableName = $tableName;
|
||||
}
|
||||
|
||||
public function getPageUid(): int
|
||||
|
|
|
@ -27,32 +27,14 @@ use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
|
|||
|
||||
class SymfonyExpression implements Expression
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $expression;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $values;
|
||||
|
||||
/**
|
||||
* @var ExpressionLanguage
|
||||
*/
|
||||
private $symfonyExpression;
|
||||
|
||||
public function __construct(
|
||||
string $expression,
|
||||
array $values,
|
||||
ExpressionLanguage $symfonyExpression
|
||||
private readonly string $expression,
|
||||
private readonly array $values,
|
||||
private readonly ExpressionLanguage $symfonyExpression
|
||||
) {
|
||||
$this->expression = $expression;
|
||||
$this->values = $values;
|
||||
$this->symfonyExpression = $symfonyExpression;
|
||||
}
|
||||
|
||||
public function evaluate()
|
||||
public function evaluate(): mixed
|
||||
{
|
||||
return $this->symfonyExpression->evaluate(
|
||||
$this->expression,
|
||||
|
|
|
@ -24,23 +24,18 @@ declare(strict_types=1);
|
|||
namespace DanielSiepmann\Tracking\Domain\Pageview;
|
||||
|
||||
use DanielSiepmann\Tracking\Domain\Model\Pageview;
|
||||
use DanielSiepmann\Tracking\Domain\Repository\Site;
|
||||
use DateTimeImmutable;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use TYPO3\CMS\Core\Routing\PageArguments;
|
||||
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
|
||||
use TYPO3\CMS\Core\Site\SiteFinder;
|
||||
use UnexpectedValueException;
|
||||
|
||||
class Factory
|
||||
{
|
||||
/**
|
||||
* @var SiteFinder
|
||||
*/
|
||||
private $siteFinder;
|
||||
|
||||
public function __construct(SiteFinder $siteFinder)
|
||||
{
|
||||
$this->siteFinder = $siteFinder;
|
||||
public function __construct(
|
||||
private readonly Site $siteRepository
|
||||
) {
|
||||
}
|
||||
|
||||
public function fromRequest(ServerRequestInterface $request): Pageview
|
||||
|
@ -49,8 +44,8 @@ class Factory
|
|||
$this->getRouting($request)->getPageId(),
|
||||
$this->getLanguage($request),
|
||||
new DateTimeImmutable(),
|
||||
(int)$this->getRouting($request)->getPageType(),
|
||||
(string)$request->getUri(),
|
||||
(int) $this->getRouting($request)->getPageType(),
|
||||
(string) $request->getUri(),
|
||||
$request->getHeader('User-Agent')[0] ?? ''
|
||||
);
|
||||
}
|
||||
|
@ -58,13 +53,13 @@ class Factory
|
|||
public function fromDbRow(array $dbRow): Pageview
|
||||
{
|
||||
return new Pageview(
|
||||
(int)$dbRow['pid'],
|
||||
$this->siteFinder->getSiteByPageId((int)$dbRow['pid'])->getLanguageById((int)$dbRow['sys_language_uid']),
|
||||
(int) $dbRow['pid'],
|
||||
$this->siteRepository->findByPageUid((int) $dbRow['pid'])->getLanguageById((int) $dbRow['sys_language_uid']),
|
||||
new DateTimeImmutable('@' . $dbRow['crdate']),
|
||||
(int)$dbRow['type'],
|
||||
(int) $dbRow['type'],
|
||||
$dbRow['url'],
|
||||
$dbRow['user_agent'],
|
||||
(int)$dbRow['uid']
|
||||
(int) $dbRow['uid']
|
||||
);
|
||||
}
|
||||
|
||||
|
|