Skip to content

Commit

Permalink
Merge pull request #23 from rengaw83/feature/compatibility-php8
Browse files Browse the repository at this point in the history
[TASK] Make compatible to PHP 8 and TYPO3 11
  • Loading branch information
georgringer authored Feb 7, 2023
2 parents dadd89a + 61e28c7 commit 2504833
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 27 deletions.
12 changes: 6 additions & 6 deletions Classes/Domain/Model/Dto/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ public function __construct(string $tableName)
$this->title = $tcaCtrl['title'];
$this->titleField = $tcaCtrl['label'];
$this->deletedField = isset($tcaCtrl['delete']) ? $tcaCtrl['delete'] : '';
$this->titleLabel = $GLOBALS['TCA'][$tableName]['columns'][$this->titleField]['label'];
$this->gdprRestrictionField = $tcaCtrl['gdpr']['restriction_field'] ?: '';
$this->gdprRandomizedField = $tcaCtrl['gdpr']['randomized_field'] ?: '';
$this->gdprRandomizeMapping = $tcaCtrl['gdpr']['randomize_mapping'] ?: [];
$this->gdprRandomizedDateField = $tcaCtrl['gdpr']['randomize_datefield'] ?: '';
$this->gdprExpirePeriod = $tcaCtrl['gdpr']['randomize_expirePeriod'] ?: 365;
$this->titleLabel = $GLOBALS['TCA'][$tableName]['columns'][$this->titleField]['label'] ?? '';
$this->gdprRestrictionField = $tcaCtrl['gdpr']['restriction_field'] ?? '';
$this->gdprRandomizedField = $tcaCtrl['gdpr']['randomized_field'] ?? '';
$this->gdprRandomizeMapping = $tcaCtrl['gdpr']['randomize_mapping'] ?? [];
$this->gdprRandomizedDateField = $tcaCtrl['gdpr']['randomize_datefield'] ?? '';
$this->gdprExpirePeriod = $tcaCtrl['gdpr']['randomize_expirePeriod'] ?? 365;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions Classes/Domain/Repository/RecordRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ public function getStatisticOfTable(string $table): array
->fetchAll();

return [
'restricted' => (int)$rows[1]['count'],
'public' => (int)$rows[0]['count']
'restricted' => (int) ($rows[1]['count'] ?? 0),
'public' => (int) ($rows[0]['count'] ?? 0)
];
}

Expand Down
2 changes: 1 addition & 1 deletion Classes/Hooks/IconFactoryHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function postOverlayPriorityLookup($table, array $row, array $status, $ic
{
if (TableInformation::isTableEnabled($table)) {
$table = Table::getInstance($table);
if ($table->randomizationEnabled() && $row[$table->getGdprRandomizedField()]) {
if ($table->randomizationEnabled() && ($row[$table->getGdprRandomizedField()] ?? false)) {
$iconName = 'overlay-locked';
}
}
Expand Down
1 change: 1 addition & 0 deletions Classes/Service/TableInformation.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class TableInformation
public static function isTableEnabled(string $table): bool
{
if (isset($GLOBALS['TCA'][$table])
&& !empty($GLOBALS['TCA'][$table]['ctrl']['gdpr'])
&& is_array($GLOBALS['TCA'][$table]['ctrl']['gdpr'])
&& $GLOBALS['TCA'][$table]['ctrl']['gdpr']['enabled']) {
return true;
Expand Down
17 changes: 0 additions & 17 deletions Configuration/Commands.php

This file was deleted.

31 changes: 31 additions & 0 deletions Configuration/Services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
services:
_defaults:
autowire: true
autoconfigure: true
public: false

GeorgRinger\Gdpr\:
resource: '../Classes/*'
exclude: '../Classes/Domain/Model/*'

#
# Commands to be executed by typo3, where the key of the array
# is the name of the command (to be called as the first argument after typo3).
# Required parameter is the "class" of the command which needs to be a subclass
# of Symfony/Console/Command.
#
# example: bin/typo3 gdpr:randomize

GeorgRinger\Gdpr\Command\RandomizeCommand:
tags:
-
name: 'console.command'
command: 'gdpr:randomize'
description: 'Randomize data'

GeorgRinger\Gdpr\Command\AnonymizeIpCommand:
tags:
-
name: 'console.command'
command: 'gdpr:anonymizeIp'
description: 'Anonymize IP address of given rows'
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
],
"require": {
"typo3/cms-core": "^10 || ^11",
"fzaninotto/faker": "^1.7"
"fakerphp/faker": "^1.10"
},
"autoload": {
"psr-4": {
Expand Down

0 comments on commit 2504833

Please sign in to comment.