Skip to content

Commit

Permalink
WIP|Fix PHPStan and PHPUnit findings
Browse files Browse the repository at this point in the history
WIP:
    * Ensure language handling works (no more sys_language table?!)
  • Loading branch information
DanielSiepmann committed Dec 4, 2023
1 parent 1aa393a commit cc2ee35
Show file tree
Hide file tree
Showing 107 changed files with 3,042 additions and 1,892 deletions.
9 changes: 3 additions & 6 deletions Classes/Domain/Import/EntityMapper/EntityRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@

namespace WerkraumMedia\ThueCat\Domain\Import\EntityMapper;

use TYPO3\CMS\Core\Utility\ArrayUtility;

/**
* Registry with supported entities and their types.
*/
Expand Down Expand Up @@ -69,10 +67,9 @@ public function getEntityByTypes(array $types): string
return '';
}

$matches = ArrayUtility::sortArraysByKey(
$matches,
'priority'
);
usort($matches, static function (array $configA, array $configB): int {
return $configA['priority'] <=> $configB['priority'];
});

return end($matches)['entityClassName'];
}
Expand Down
4 changes: 2 additions & 2 deletions Classes/Domain/Import/Importer/SaveData.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ private function getExistingUid(Entity $entity): int
));
}

$result = $queryBuilder->execute()->fetchColumn();
$result = $queryBuilder->executeQuery()->fetchOne();
if (is_numeric($result)) {
return (int)$result;
}
Expand All @@ -217,7 +217,7 @@ private function getDefaultLanguageIdentifier(Entity $entity): int
$queryBuilder->createNamedParameter(0)
));

$result = $queryBuilder->execute()->fetchColumn();
$result = $queryBuilder->executeQuery()->fetchOne();
if (is_numeric($result)) {
return (int)$result;
}
Expand Down
4 changes: 2 additions & 2 deletions Classes/Domain/Import/Typo3Converter/LanguageHandling.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ public function getAvailable(ImportConfiguration $configuration): array
throw new InvalidArgumentException('Unsupported configuration, need to retrieve storage pid.', 1629710300);
}
return array_map(function (SiteLanguage $language) {
return $language->getTwoLetterIsoCode();
return $language->getLocale()->getLanguageCode();
}, $this->getLanguages($configuration->getStoragePid()));
}

public function getLanguageUidForString(int $pageUid, string $isoCode): int
{
foreach ($this->getLanguages($pageUid) as $language) {
if ($language->getTwoLetterIsoCode() === $isoCode) {
if ($language->getLocale()->getLanguageCode() === $isoCode) {
return $language->getLanguageId();
}
}
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Model/Backend/ImportConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function getLastChanged(): ?DateTimeImmutable
public function getLastImported(): ?DateTimeImmutable
{
$lastImport = null;
$positionOfLastLog = (string)(count($this->logs) - 1);
$positionOfLastLog = (count($this->logs) - 1);
if ($this->logs->offsetExists($positionOfLastLog)) {
$lastImport = $this->logs->offsetGet($positionOfLastLog);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,16 @@

namespace WerkraumMedia\ThueCat\Domain\Repository\Backend;

use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
use TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings;
use TYPO3\CMS\Extbase\Persistence\Repository;
use WerkraumMedia\ThueCat\Domain\Import\ImportConfiguration;

class ImportConfigurationRepository extends Repository
{
public function __construct(
ObjectManagerInterface $objectManager,
Typo3QuerySettings $querySettings
) {
parent::__construct($objectManager);
parent::__construct();

$querySettings->setRespectStoragePage(false);

Expand Down
4 changes: 1 addition & 3 deletions Classes/Domain/Repository/Backend/ImportLogRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
namespace WerkraumMedia\ThueCat\Domain\Repository\Backend;

use TYPO3\CMS\Core\DataHandling\DataHandler;
use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
use TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings;
use TYPO3\CMS\Extbase\Persistence\QueryInterface;
use TYPO3\CMS\Extbase\Persistence\Repository;
Expand All @@ -38,11 +37,10 @@ class ImportLogRepository extends Repository
private $dataHandler;

public function __construct(
ObjectManagerInterface $objectManager,
DataHandler $dataHandler,
Typo3QuerySettings $querySettings
) {
parent::__construct($objectManager);
parent::__construct();

$this->dataHandler = $dataHandler;

Expand Down
4 changes: 1 addition & 3 deletions Classes/Domain/Repository/Backend/OrganisationRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

namespace WerkraumMedia\ThueCat\Domain\Repository\Backend;

use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
use TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings;
use TYPO3\CMS\Extbase\Persistence\Repository;
use WerkraumMedia\ThueCat\Domain\Model\Backend\Organisation;
Expand All @@ -34,10 +33,9 @@
class OrganisationRepository extends Repository
{
public function __construct(
ObjectManagerInterface $objectManager,
Typo3QuerySettings $querySettings
) {
parent::__construct($objectManager);
parent::__construct();

$querySettings->setRespectStoragePage(false);
$this->setDefaultQuerySettings($querySettings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

namespace WerkraumMedia\ThueCat\Domain\Repository\Backend;

use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
use TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings;
use TYPO3\CMS\Extbase\Persistence\QueryResultInterface;
use TYPO3\CMS\Extbase\Persistence\Repository;
Expand All @@ -32,10 +31,9 @@
class ParkingFacilityRepository extends Repository
{
public function __construct(
ObjectManagerInterface $objectManager,
Typo3QuerySettings $querySettings
) {
parent::__construct($objectManager);
parent::__construct();

$querySettings->setRespectStoragePage(false);

Expand Down
4 changes: 1 addition & 3 deletions Classes/Domain/Repository/Backend/TownRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

namespace WerkraumMedia\ThueCat\Domain\Repository\Backend;

use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
use TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings;
use TYPO3\CMS\Extbase\Persistence\Repository;
use WerkraumMedia\ThueCat\Domain\Import\ResolveForeignReference;
Expand All @@ -32,10 +31,9 @@
class TownRepository extends Repository
{
public function __construct(
ObjectManagerInterface $objectManager,
Typo3QuerySettings $querySettings
) {
parent::__construct($objectManager);
parent::__construct();

$querySettings->setRespectStoragePage(false);

Expand Down
2 changes: 1 addition & 1 deletion Classes/Frontend/DataProcessing/ResolveEntities.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private function resolveEntities(string $tableName, array $uids): array
));

$rows = [];
foreach ($queryBuilder->execute() as $row) {
foreach ($queryBuilder->executeQuery()->iterateAssociative() as $row) {
$row = $this->tsfe->sys_page->getLanguageOverlay($tableName, $row);
if (is_array($row)) {
$rows[] = $row;
Expand Down
6 changes: 3 additions & 3 deletions Classes/Updates/BackendModuleUserPermission.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function updateNecessary(): bool
$qb->from('be_users');
$qb->where($qb->expr()->like('userMods', $qb->createNamedParameter('%site_ThuecatThuecat%')));

return $qb->execute()->fetchOne() > 0;
return $qb->executeQuery()->fetchOne() > 0;
}

public function executeUpdate(): bool
Expand All @@ -73,14 +73,14 @@ public function executeUpdate(): bool
$qb->select('uid', 'userMods');
$qb->from('be_users');
$qb->where($qb->expr()->like('userMods', $qb->createNamedParameter('%site_ThuecatThuecat%')));
$result = $qb->execute();
$result = $qb->executeQuery()->iterateAssociative();

foreach ($result as $backendUser) {
$qb = $this->connectionPool->getQueryBuilderForTable('be_users');
$qb->update('be_users');
$qb->set('userMods', $this->updateMods($backendUser['userMods']));
$qb->where($qb->expr()->eq('uid', $qb->createNamedParameter($backendUser['uid'])));
$qb->execute();
$qb->executeStatement();
}

return true;
Expand Down
6 changes: 3 additions & 3 deletions Configuration/TCA/Overrides/pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
$tableName,
'module',
[
0 => $languagePath . '.module.thuecat',
1 => 'thuecat',
2 => 'pages_module_thuecat',
'label' => $languagePath . '.module.thuecat',
'value' => 'thuecat',
'icon' => 'pages_module_thuecat',
]
);
})(
Expand Down
8 changes: 4 additions & 4 deletions Configuration/TCA/Overrides/pages_tourist_attraction.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@
$tableName,
'doktype',
[
$languagePath,
$doktype,
Extension::getIconPath() . $tableName . '_' . $pageIdentifier . '.svg',
Extension::TCA_SELECT_GROUP_IDENTIFIER,
'label' => $languagePath,
'value' => $doktype,
'icon' => Extension::getIconPath() . $tableName . '_' . $pageIdentifier . '.svg',
'group' => Extension::TCA_SELECT_GROUP_IDENTIFIER,
]
);
})(
Expand Down
8 changes: 4 additions & 4 deletions Configuration/TCA/Overrides/tt_content_tourist_attraction.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@
$tableName,
'CType',
[
$languagePath,
$cType,
Extension::getIconPath() . 'tt_content_' . $cType . '.svg',
Extension::TCA_SELECT_GROUP_IDENTIFIER,
'label' => $languagePath,
'value' => $cType,
'icon' => Extension::getIconPath() . 'tt_content_' . $cType . '.svg',
'group' => Extension::TCA_SELECT_GROUP_IDENTIFIER,
]
);
})(
Expand Down
5 changes: 2 additions & 3 deletions Configuration/TCA/tx_thuecat_import_configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,8 @@
],
'tstamp' => [
'config' => [
'type' => 'input',
'renderType' => 'inputDateTime',
'eval' => 'datetime',
'type' => 'datetime',
'format' => 'datetime',
'readOnly' => true,
],
],
Expand Down
5 changes: 2 additions & 3 deletions Configuration/TCA/tx_thuecat_import_log.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@
'crdate' => [
'label' => $languagePath . '.crdate',
'config' => [
'type' => 'input',
'renderType' => 'inputDateTime',
'eval' => 'datetime',
'type' => 'datetime',
'format' => 'datetime',
'readOnly' => true,
],
],
Expand Down
5 changes: 2 additions & 3 deletions Configuration/TCA/tx_thuecat_import_log_entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,8 @@
'crdate' => [
'label' => $languagePath . '.crdate',
'config' => [
'type' => 'input',
'renderType' => 'inputDateTime',
'eval' => 'datetime',
'type' => 'datetime',
'format' => 'datetime',
'readOnly' => true,
],
],
Expand Down
5 changes: 2 additions & 3 deletions Configuration/TCA/tx_thuecat_organisation.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,8 @@
'tstamp' => [
'label' => $languagePath . '.tstamp',
'config' => [
'type' => 'input',
'renderType' => 'inputDateTime',
'eval' => 'datetime',
'type' => 'datetime',
'format' => 'datetime',
'readOnly' => true,
],
],
Expand Down
10 changes: 4 additions & 6 deletions Configuration/TCA/tx_thuecat_tourist_attraction.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

declare(strict_types=1);

use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use WerkraumMedia\ThueCat\Extension;

defined('TYPO3') or die();
Expand Down Expand Up @@ -304,11 +303,10 @@
'editorial_images' => [
'label' => $languagePath . '.editorial_images',
'l10n_mode' => 'exclude',
'config' => ExtensionManagementUtility::getFileFieldTCAConfig(
'editorial_images',
[],
$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
),
'config' => [
'type' => 'file',
'allowed' => 'common-image-types',
],
],
],
'palettes' => [
Expand Down
45 changes: 0 additions & 45 deletions Tests/Acceptance/Data/BasicDatabase.csv

This file was deleted.

Loading

0 comments on commit cc2ee35

Please sign in to comment.