Skip to content

Commit

Permalink
[TASK] Apply code style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
christianbltr committed Oct 4, 2024
1 parent ba099e9 commit ed08f9e
Show file tree
Hide file tree
Showing 19 changed files with 43 additions and 54 deletions.
3 changes: 1 addition & 2 deletions Classes/Backend/Filterlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ public function getListOfAvailableFilteroptionsForFlexforms(&$config)
}

if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyFilteroptionsForFlexforms'] ?? null)) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyFilteroptionsForFlexforms'] as
$_classRef) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyFilteroptionsForFlexforms'] as $_classRef) {
$_procObj = GeneralUtility::makeInstance($_classRef);
$_procObj->modifyFilteroptionsForFlexforms($config, $rowFilter, $this);
}
Expand Down
3 changes: 1 addition & 2 deletions Classes/Controller/BackendModuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -639,8 +639,7 @@ public function getStatisticTableData(
string $pageColumn,
int $pageUid,
string $tableCol
): array
{
): array {
$queryBuilder = Db::getQueryBuilder($table);
$queryBuilder->getRestrictions()->removeAll();
if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() < 13) {
Expand Down
6 changes: 3 additions & 3 deletions Classes/Indexer/IndexerBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
use Tpwd\KeSearch\Lib\SearchHelper;
use Tpwd\KeSearch\Service\IndexerStatusService;
use Tpwd\KeSearch\Utility\FileUtility;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
use TYPO3\CMS\Core\Database\Query\QueryHelper;
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
Expand Down Expand Up @@ -312,9 +312,9 @@ public function addTagsToRecords($uids, $pageWhere = '')
->fetchAllAssociative();

if (!empty($pageWhere)) {
$where = $pageWhere . ' AND ';
$where = $pageWhere . ' AND ';
} else {
$where = '';
$where = '';
}
$where .= 'no_search <> 1 ';

Expand Down
29 changes: 13 additions & 16 deletions Classes/Indexer/IndexerRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

use Exception;
use PDO;
use Psr\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Tpwd\KeSearch\Domain\Repository\IndexRepository;
Expand Down Expand Up @@ -449,7 +447,7 @@ public function prepareStatements()
AND language = ?
LIMIT 1
"');
} catch (Exception $e) {
} catch (\Exception $e) {
$errorMessage = 'Error while preparing searchStmt: ' . $e->getMessage();
$this->logger->error($errorMessage);
$this->indexingErrors[] = $errorMessage;
Expand All @@ -475,7 +473,7 @@ public function prepareStatements()
tstamp=?' . $addUpdateQuery . '
WHERE uid=?
"');
} catch (Exception $e) {
} catch (\Exception $e) {
$errorMessage = 'Error while preparing updateStmt: ' . $e->getMessage();
$this->logger->error($errorMessage);
$this->indexingErrors[] = $errorMessage;
Expand All @@ -490,7 +488,7 @@ public function prepareStatements()
. ' starttime, endtime, fe_group, tstamp, crdate' . $addInsertQueryFields . ')
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?' . $addInsertQueryValues . ', ?)
"');
} catch (Exception $e) {
} catch (\Exception $e) {
$errorMessage = 'Error while preparing insertStmt: ' . $e->getMessage();
$this->logger->error($errorMessage);
$this->indexingErrors[] = $errorMessage;
Expand All @@ -503,7 +501,7 @@ public function prepareStatements()
if ($this->indexRepository->getTotalNumberOfRecords() == 0) {
try {
Db::getDatabaseConnection('tx_kesearch_index')->executeStatement('ALTER TABLE tx_kesearch_index DISABLE KEYS');
} catch (Exception $e) {
} catch (\Exception $e) {
$errorMessage = 'Error while disabling keys: ' . $e->getMessage();
$this->logger->error($errorMessage);
$this->indexingErrors[] = $errorMessage;
Expand All @@ -520,7 +518,7 @@ public function cleanUpProcessAfterIndexing()
try {
Db::getDatabaseConnection('tx_kesearch_index')
->executeStatement('ALTER TABLE tx_kesearch_index ENABLE KEYS');
} catch (Exception $e) {
} catch (\Exception $e) {
$errorMessage = 'Error while enabling keys: ' . $e->getMessage();
$this->logger->error($errorMessage);
$this->indexingErrors[] = $errorMessage;
Expand All @@ -529,7 +527,7 @@ public function cleanUpProcessAfterIndexing()
try {
Db::getDatabaseConnection('tx_kesearch_index')
->executeStatement('DEALLOCATE PREPARE searchStmt');
} catch (Exception $e) {
} catch (\Exception $e) {
$errorMessage = 'Error while deallocating searchStmt: ' . $e->getMessage();
$this->logger->error($errorMessage);
$this->indexingErrors[] = $errorMessage;
Expand All @@ -538,7 +536,7 @@ public function cleanUpProcessAfterIndexing()
try {
Db::getDatabaseConnection('tx_kesearch_index')
->executeStatement('DEALLOCATE PREPARE updateStmt');
} catch (Exception $e) {
} catch (\Exception $e) {
$errorMessage = 'Error while deallocating updateStmt: ' . $e->getMessage();
$this->logger->error($errorMessage);
$this->indexingErrors[] = $errorMessage;
Expand All @@ -547,7 +545,7 @@ public function cleanUpProcessAfterIndexing()
try {
Db::getDatabaseConnection('tx_kesearch_index')
->executeStatement('DEALLOCATE PREPARE insertStmt');
} catch (Exception $e) {
} catch (\Exception $e) {
$errorMessage = 'Error while deallocating insertStmt: ' . $e->getMessage();
$this->logger->error($errorMessage);
$this->indexingErrors[] = $errorMessage;
Expand Down Expand Up @@ -644,7 +642,7 @@ public function rotateSphinxIndex()
$content .= '<b>Checking status of Sphinx daemon:</b> ';
$sphinxFailedToConnect = false;
foreach ($retArr as $retRow) {
if (strpos($retRow, 'WARNING') !== false) {
if (str_contains($retRow, 'WARNING')) {
$this->logger->warning('Sphinx: ' . $retRow);
$content .= '<div class="error">SPHINX ' . $retRow . '</div>' . "\n";
$sphinxFailedToConnect = true;
Expand Down Expand Up @@ -680,7 +678,7 @@ public function rotateSphinxIndex()
. '</p>'
. "\n\n";
foreach ($retArr as $retRow) {
if (strpos($retRow, 'WARNING') !== false) {
if (str_contains($retRow, 'WARNING')) {
$this->logger->error('Sphinx: ' . $retRow);
$content .= '<div class="error">SPHINX ' . $retRow . '</div>' . "\n";
}
Expand Down Expand Up @@ -734,8 +732,7 @@ public function storeInIndex(
$fe_group = '',
$debugOnly = false,
$additionalFields = []
): bool
{
): bool {
// if there are errors found in current record return false and break processing
if (!$this->checkIfRecordHasErrorsBeforeIndexing($storagePid, $title, $type, $targetPid)) {
return false;
Expand Down Expand Up @@ -892,7 +889,7 @@ public function insertRecordIntoIndex($fieldValues, bool $debugOnly = false)
Db::getDatabaseConnection('tx_kesearch_index')->executeStatement($queryArray['set']);
Db::getDatabaseConnection('tx_kesearch_index')->executeStatement($queryArray['execute']);
Db::getDatabaseConnection('tx_kesearch_index')->executeStatement('COMMIT;');
} catch (Exception $e) {
} catch (\Exception $e) {
$this->logger->error($e->getMessage());
$this->indexingErrors[] = $e->getMessage();
}
Expand Down Expand Up @@ -953,7 +950,7 @@ public function updateRecordInIndex($fieldValues, bool $debugOnly = false)
Db::getDatabaseConnection('tx_kesearch_index')->executeStatement($queryArray['set']);
Db::getDatabaseConnection('tx_kesearch_index')->executeStatement($queryArray['execute']);
Db::getDatabaseConnection('tx_kesearch_index')->executeStatement('COMMIT;');
} catch (Exception $e) {
} catch (\Exception $e) {
// @extensionScannerIgnoreLine
$this->logger->error($e->getMessage());
$this->indexingErrors[] = $e->getMessage();
Expand Down
5 changes: 2 additions & 3 deletions Classes/Indexer/Types/News.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,7 @@ public function startIndexing()

// hook for custom modifications of the indexed data, e.g. the tags
if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyExtNewsIndexEntry'] ?? null)) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyExtNewsIndexEntry'] as
$_classRef) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyExtNewsIndexEntry'] as $_classRef) {
$_procObj = GeneralUtility::makeInstance($_classRef);
$_procObj->modifyExtNewsIndexEntry(
$title,
Expand Down Expand Up @@ -416,7 +415,7 @@ private function getCategoryData($newsRecord)
$categoryData['single_pid'] = 0;

if ($categoryData['uid_list']) {
foreach ($categoryData['uid_list']as $categoryUid) {
foreach ($categoryData['uid_list'] as $categoryUid) {
$newsCat = $categoryRepository->findByUid($categoryUid);
// check if this category has a single_pid and if this page really is reachable (not deleted, hidden or time restricted)
if ($newsCat['single_pid'] && !$categoryData['single_pid'] && $pageRepository->findByUid($newsCat['single_pid'])) {
Expand Down
6 changes: 2 additions & 4 deletions Classes/Indexer/Types/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -1198,8 +1198,7 @@ public function storeFileContentToIndex($fileObject, $content, $fileIndexerObjec

//hook for custom modifications of the indexed data, e. g. the tags
if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyFileIndexEntryFromContentIndexer'] ?? null)) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyFileIndexEntryFromContentIndexer'] as
$_classRef) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyFileIndexEntryFromContentIndexer'] as $_classRef) {
$_procObj = GeneralUtility::makeInstance($_classRef);
$_procObj->modifyFileIndexEntryFromContentIndexer(
$fileObject,
Expand Down Expand Up @@ -1258,8 +1257,7 @@ public function getContentFromContentElement(array $ttContentRow, string $field

// hook for modifiying a content elements content
if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyContentFromContentElement'] ?? null)) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyContentFromContentElement'] as
$_classRef) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyContentFromContentElement'] as $_classRef) {
$_procObj = GeneralUtility::makeInstance($_classRef);
$_procObj->modifyContentFromContentElement(
$content,
Expand Down
3 changes: 1 addition & 2 deletions Classes/Indexer/Types/TtContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,7 @@ public function getPageContent($uid)

// hook for custom modifications of the indexed data, e. g. the tags
if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyContentIndexEntry'] ?? null)) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyContentIndexEntry'] as
$_classRef) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyContentIndexEntry'] as $_classRef) {
$_procObj = GeneralUtility::makeInstance($_classRef);
$_procObj->modifyContentIndexEntry(
$row['header'],
Expand Down
3 changes: 1 addition & 2 deletions Classes/Indexer/Types/TtNews.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,7 @@ public function startIndexing()

// hook for custom modifications of the indexed data, e.g. the tags
if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyExtTtNewsIndexEntry'] ?? null)) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyExtTtNewsIndexEntry'] as
$_classRef) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyExtTtNewsIndexEntry'] as $_classRef) {
$_procObj = GeneralUtility::makeInstance($_classRef);
$_procObj->modifyExtNewsIndexEntry(
$title,
Expand Down
3 changes: 1 addition & 2 deletions Classes/Lib/Items.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ public function fillIndexerConfig(&$params, $pObj)
$indexerRunner = GeneralUtility::makeInstance(IndexerRunner::class);
// hook for custom registration of further indexerConfigurations
if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['registerIndexerConfiguration'] ?? null)) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['registerIndexerConfiguration'] as
$_classRef) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['registerIndexerConfiguration'] as $_classRef) {
$_procObj = GeneralUtility::makeInstance($_classRef, $indexerRunner);
$_procObj->registerIndexerConfiguration($params, $pObj);
}
Expand Down
2 changes: 1 addition & 1 deletion Classes/Lib/SearchHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ public static function getResultLinkConfiguration(array $resultRow, $targetDefau
{
$linkConf = [];

list($type) = explode(':', $resultRow['type']);
[$type] = explode(':', $resultRow['type']);

switch ($type) {
case 'file':
Expand Down
2 changes: 1 addition & 1 deletion Classes/Lib/Searchphrase.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function checkAgainstDefaultValue($searchString)
public function explodeSearchPhrase(string $searchString, bool $replaceAdditionalWordCharacters = false)
{
preg_match_all('/([+\-~<>])?\".*?"|[^ ]+/', $searchString, $matches);
list($searchParts) = $matches;
[$searchParts] = $matches;
if (is_array($searchParts) && count($searchParts)) {
foreach ($searchParts as $key => $word) {
// check for boolean seperator
Expand Down
2 changes: 1 addition & 1 deletion Classes/Lib/Searchresult.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function getTitle(): string
// configure the link
$linkconf = $this->getResultLinkConfiguration();

list($type) = explode(':', $this->row['type']);
[$type] = explode(':', $this->row['type']);
switch ($type) {
case 'file':
// if we use FAL, see if we have a title in the metadata
Expand Down
17 changes: 7 additions & 10 deletions Classes/Plugins/PluginBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

use Exception;
use Psr\Http\Message\ServerRequestInterface;
use Tpwd\KeSearch\Domain\Repository\FileMetaDataRepository;
use Tpwd\KeSearch\Domain\Repository\FileReferenceRepository;
Expand Down Expand Up @@ -174,7 +173,7 @@ public function init(ServerRequestInterface $request)
$currentFlexFormConfiguration = $flexFormConfiguration;
$contentElement = $this->pi_getRecord('tt_content', (int)($loadFlexformsFromOtherCE));
if (is_int($contentElement) && $contentElement == 0) {
throw new Exception('Content element with search configuration is not set or not accessible. Maybe hidden or deleted?');
throw new \Exception('Content element with search configuration is not set or not accessible. Maybe hidden or deleted?');
}
$this->cObj->data['pi_flexform'] = $contentElement['pi_flexform'];
$flexFormConfiguration = array_merge($currentFlexFormConfiguration, $this->getFlexFormConfiguration());
Expand Down Expand Up @@ -449,8 +448,7 @@ public function renderFilters()

// hook for modifying filter options
if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyFilterOptionsArray'] ?? null)) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyFilterOptionsArray'] as
$_classRef) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyFilterOptionsArray'] as $_classRef) {
$_procObj = GeneralUtility::makeInstance($_classRef);
$options = $_procObj->modifyFilterOptionsArray($filter['uid'], $options, $this);
}
Expand All @@ -477,8 +475,7 @@ public function renderFilters()
// and $filterData['rawHtmlContent'] to your pre-rendered filter code
// hook for custom filter renderer
if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['customFilterRenderer'] ?? null)) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['customFilterRenderer'] as
$_classRef) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['customFilterRenderer'] as $_classRef) {
$_procObj = GeneralUtility::makeInstance($_classRef);
$_procObj->customFilterRenderer($filter['uid'], $options, $this, $filterData);
}
Expand Down Expand Up @@ -758,7 +755,7 @@ public function getSearchResults()

// add type marker
// for file results just use the "file" type, not the file extension (eg. "file:pdf")
list($type) = explode(':', $row['type']);
[$type] = explode(':', $row['type']);
$tempMarkerArray['type'] = str_replace(' ', '_', $type);

// use the markers array as a base for the fluid template values
Expand Down Expand Up @@ -848,7 +845,7 @@ public function getSearchResults()
*/
public function getFileReference($row): int
{
list($type) = explode(':', $row['type']);
[$type] = explode(':', $row['type']);
switch ($type) {
case 'page':
if ($this->conf['showPageImages'] ?? false) {
Expand Down Expand Up @@ -914,7 +911,7 @@ public function getFileReference($row): int
*/
public function getTypeIconPath(string $typeComplete): string
{
list($type) = explode(':', $typeComplete);
[$type] = explode(':', $typeComplete);
$name = str_replace(':', '_', $typeComplete);

if ($this->conf['resultListTypeIcon'][$name] ?? false) {
Expand Down Expand Up @@ -1300,7 +1297,7 @@ public function setRequest(ServerRequestInterface $request)
public function translate(string $key, string $alternativeLabel = ''): string
{
if (!str_starts_with($key, 'LLL:')) {
$key = 'LLL:'. $this->languageFile . ':' . $key;
$key = 'LLL:' . $this->languageFile . ':' . $key;
}
$label = LocalizationUtility::translate($key, 'KeSearch');
if (empty($label)) {
Expand Down
4 changes: 2 additions & 2 deletions Classes/Service/AdditionalContentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,14 @@ public function findLinkedFiles(array $contentRow, string $field = 'bodytext'):
// Find files linked in RTE
$blockSplit = $this->rteHtmlParser->splitIntoBlock('A', (string)$contentRow[$field], true);
foreach ($blockSplit as $k => $v) {
list($attributes) = $this->rteHtmlParser->get_tag_attributes($this->rteHtmlParser->getFirstTag($v), true);
[$attributes] = $this->rteHtmlParser->get_tag_attributes($this->rteHtmlParser->getFirstTag($v), true);
if (!empty($attributes['href'])) {
try {
$hrefInformation = $this->linkService->resolve($attributes['href']);
if ($hrefInformation['type'] === LinkService::TYPE_FILE) {
$fileObjects[] = $hrefInformation['file'];
}
} catch (Exception $exception) {
} catch (\Exception $exception) {
$this->logger->error($exception->getMessage());
}
}
Expand Down
Loading

0 comments on commit ed08f9e

Please sign in to comment.