Skip to content

Commit

Permalink
[!!!][TASK] Added TYPO3 1.5 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
derhansen committed Sep 22, 2023
1 parent a14acb3 commit fa43062
Show file tree
Hide file tree
Showing 49 changed files with 423 additions and 1,216 deletions.
37 changes: 7 additions & 30 deletions Classes/Analyzers/AbstractAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
namespace UniWue\UwA11yCheck\Analyzers;

use GuzzleHttp\Client;
use GuzzleHttp\Exception\ClientException;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Database\QueryGenerator;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use UniWue\UwA11yCheck\Check\Preset;
use UniWue\UwA11yCheck\Check\ResultSet;
use UniWue\UwA11yCheck\Tests\TestInterface;
use UniWue\UwA11yCheck\Utility\QueryGenerator;

/**
* Class AbstractAnalyzer
Expand All @@ -17,29 +18,15 @@ abstract class AbstractAnalyzer implements AnalyzerInterface
{
public const TYPE_INTERNAL = 'internal';

/**
* @var string
*/
protected $type = '';
protected string $type = '';
protected array $pageUids = [];

/**
* @var array
*/
protected $pageUids = [];

/**
* @return string
*/
public function getType()
public function getType(): string
{
return $this->type;
}
/**
* Runs all tests for the given preset and recordUid
*
* @param Preset $preset
* @param int $recordUid
* @return ResultSet
*/
public function runTests(Preset $preset, int $recordUid): ResultSet
{
Expand All @@ -58,7 +45,7 @@ public function runTests(Preset $preset, int $recordUid): ResultSet
$result = $test->run($html, $recordUid);
$results[] = $result;
}
} catch (\GuzzleHttp\Exception\ClientException $e) {
} catch (ClientException $e) {
$resultSet->setFailed(true);
$resultSet->setFailedMessage($e->getMessage());
}
Expand All @@ -75,16 +62,13 @@ public function runTests(Preset $preset, int $recordUid): ResultSet

/**
* Initializes the pageUids to check
*
* @param int $pageUid
* @param int $levels
*/
public function initializePageUids(int $pageUid, int $levels = 0): void
{
$pageUids = [$pageUid];
if ($levels > 0) {
$queryGenerator = GeneralUtility::makeInstance(QueryGenerator::class);
$pidList = $queryGenerator->getTreeList($pageUid, $levels, 0, 1);
$pidList = $queryGenerator->getTreeList($pageUid, $levels, 0);
$pageUids = GeneralUtility::intExplode(',', $pidList, true);
}

Expand All @@ -93,10 +77,6 @@ public function initializePageUids(int $pageUid, int $levels = 0): void

/**
* Returns the PID of the record
*
* @param string $table
* @param int $recordUid
* @return int
*/
protected function getPidByRecordUid(string $table, int $recordUid): int
{
Expand All @@ -110,9 +90,6 @@ protected function getPidByRecordUid(string $table, int $recordUid): int

/**
* Fetches the resulting HTML from the given URL
*
* @param string $url
* @return string
*/
protected function fetchHtml(string $url): string
{
Expand Down
12 changes: 3 additions & 9 deletions Classes/Analyzers/NewsAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@ class NewsAnalyzer extends AbstractAnalyzer
/**
* @var string
*/
protected $type = AbstractAnalyzer::TYPE_INTERNAL;
protected string $type = AbstractAnalyzer::TYPE_INTERNAL;

/**
* Return an aray of news record Uids to check
*
* @param Preset $preset
* @return array
*/
public function getCheckRecordUids(Preset $preset): array
{
Expand All @@ -43,11 +40,8 @@ public function getCheckRecordUids(Preset $preset): array

/**
* Returns all news UIDs matching the given demand
*
* @param SingleTableDemand $demand
* @return array
*/
protected function getNewsRecordUids(SingleTableDemand $demand)
protected function getNewsRecordUids(SingleTableDemand $demand): array
{
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable($demand->getTableName());
Expand Down Expand Up @@ -84,7 +78,7 @@ protected function getNewsRecordUids(SingleTableDemand $demand)
$query->setMaxResults($demand->getMaxResults());
}

$queryResult = $query->execute()->fetchAll();
$queryResult = $query->execute()->fetchAllAssociative();

$uidList = [];
foreach ($queryResult as $record) {
Expand Down
8 changes: 1 addition & 7 deletions Classes/Analyzers/PageContentAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,10 @@
*/
class PageContentAnalyzer extends AbstractAnalyzer
{
/**
* @var string
*/
protected $type = AbstractAnalyzer::TYPE_INTERNAL;
protected string $type = AbstractAnalyzer::TYPE_INTERNAL;

/**
* Return an aray of page record Uids to check
*
* @param Preset $preset
* @return array
*/
public function getCheckRecordUids(Preset $preset): array
{
Expand Down
11 changes: 1 addition & 10 deletions Classes/Check/A11yCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,10 @@
*/
class A11yCheck
{
/**
* @var Preset
*/
protected $preset;
protected Preset $preset;

/**
* A11yCheck constructor.
*
* @param Preset $preset
*/
public function __construct(Preset $preset)
{
Expand All @@ -24,10 +19,6 @@ public function __construct(Preset $preset)

/**
* Executes the check and returns the result as objectStorage
*
* @param int $id
* @param int $levels
* @return array
*/
public function executeCheck(int $id, int $levels = 0): array
{
Expand Down
69 changes: 9 additions & 60 deletions Classes/Check/Preset.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,12 @@
*/
class Preset
{
/**
* @var string
*/
protected $id = '';

/**
* @var string
*/
protected $name = '';

/**
* @var string
*/
protected $description = '';

/**
* @var AbstractAnalyzer
*/
protected $analyzer;

/**
* @var AbstractCheckUrlGenerator
*/
protected $checkUrlGenerator;

/**
* @var TestSuite
*/
protected $testSuite;
protected string $id = '';
protected string $name = '';
protected string $description = '';
protected AbstractAnalyzer $analyzer;
protected AbstractCheckUrlGenerator $checkUrlGenerator;
protected TestSuite $testSuite;

/**
* Preset constructor.
Expand All @@ -65,73 +42,48 @@ public function __construct(
$this->testSuite = $testSuite;
}

/**
* @return string
*/
public function getId()
public function getId(): string
{
return $this->id;
}

/**
* @return string
*/
public function getName()
public function getName(): string
{
return $this->name;
}

/**
* @return string
*/
public function getDescription(): string
{
return $this->description;
}

/**
* @return string
*/
public function getCheckTableName(): string
{
return $this->checkUrlGenerator->getTableName();
}

/**
* @return string
*/
public function getEditRecordTableName(): string
{
return $this->checkUrlGenerator->getEditRecordTable();
}

/**
* Returns the check URL
*
* @param int $id
* @return string
*/
public function getCheckUrl(int $id): string
{
return $this->checkUrlGenerator->getCheckUrl($id);
}

/**
* @return TestSuite
*/
public function getTestSuite(): TestSuite
{
return $this->testSuite;
}

/**
* Executes the testSuite configured in the preset by the given page UID and recursive levels
*
* @param int $pageUid
* @param int $levels
* @return array
*/
public function executeTestSuiteByPageUid(int $pageUid, int $levels)
public function executeTestSuiteByPageUid(int $pageUid, int $levels): array
{
$result = [];
$this->analyzer->initializePageUids($pageUid, $levels);
Expand All @@ -145,9 +97,6 @@ public function executeTestSuiteByPageUid(int $pageUid, int $levels)

/**
* Executes the testSuite configured in the preset by the given array of record UIDs
*
* @param array $recordUids
* @return array
*/
public function executeTestSuiteByRecordUids(array $recordUids): array
{
Expand Down
Loading

0 comments on commit fa43062

Please sign in to comment.