Skip to content

Commit

Permalink
[BUGFIX] Wrong Parameter Type in customIndexer for ke_search
Browse files Browse the repository at this point in the history
Resolves: #110
  • Loading branch information
tritumdg committed Jul 8, 2022
1 parent 886c950 commit a203f13
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 46 deletions.
3 changes: 2 additions & 1 deletion .gitlab-ci.yml
Expand Up @@ -6,7 +6,7 @@ cache:

variables:
COMPOSER_CACHE_DIR: ".composer"
TYPO3_PATH_WEB: "$CI_PROJECT_DIR/.build/Web"
TYPO3_PATH_WEB: "$CI_PROJECT_DIR/.build/public"
MYSQL_DATABASE: "typo3"
MYSQL_ROOT_PASSWORD: "joh316"
typo3DatabaseName: "typo3"
Expand Down Expand Up @@ -86,6 +86,7 @@ phpstan:analyse:
before_script:
- composer config platform.php 7.4
- composer install --no-progress --no-ansi --no-interaction
- composer req tpwd/ke_search "^4.4"
script:
- .build/bin/phpstan analyse -c Build/phpstan.neon

Expand Down
52 changes: 8 additions & 44 deletions Classes/Hooks/KeSearchIndexer.php
Expand Up @@ -9,6 +9,7 @@
* LICENSE file that was distributed with this source code.
*/

use Tpwd\KeSearch\Indexer\IndexerRunner;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\QueryGenerator;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
Expand All @@ -22,7 +23,7 @@ class KeSearchIndexer
* @param array $params
* @param $pObj
*/
public function registerIndexerConfiguration(&$params, $pObj)
public function registerIndexerConfiguration(array &$params, $pObj): void
{
$newArray = [
'Cart Product Indexer',
Expand All @@ -32,14 +33,7 @@ public function registerIndexerConfiguration(&$params, $pObj)
$params['items'][] = $newArray;
}

/**
* custom indexer for ke_search
*
* @param array $indexerConfig
* @param array $indexerObject
* @return string Output.
*/
public function customIndexer(&$indexerConfig, &$indexerObject)
public function customIndexer(array &$indexerConfig, IndexerRunner &$indexerObject): string
{
if ($indexerConfig['type'] === 'cartproductindexer') {
return $this->cartProductIndexer($indexerConfig, $indexerObject);
Expand All @@ -48,15 +42,7 @@ public function customIndexer(&$indexerConfig, &$indexerObject)
return '';
}

/**
* cart indexer for ke_search
*
* @param array $indexerConfig
* @param array $indexerObject
*
* @return string
*/
public function cartProductIndexer(&$indexerConfig, &$indexerObject)
public function cartProductIndexer(array &$indexerConfig, IndexerRunner &$indexerObject): string
{
$productIndexerName = 'Product Indexer "' . $indexerConfig['title'] . '"';

Expand Down Expand Up @@ -117,14 +103,7 @@ public function cartProductIndexer(&$indexerConfig, &$indexerObject)
return '<p><b>' . $productIndexerName . '</b><br/><strong>' . $productIndexerMessage . '</strong></p>';
}

/**
* Returns all Storage Pids for indexing
*
* @param $config
*
* @return string
*/
protected function getPidList($config)
protected function getPidList(array $config): string
{
$recursivePids = $this->extendPidListByChildren($config['startingpoints_recursive'], 99);
if ($config['sysfolder']) {
Expand All @@ -134,15 +113,7 @@ protected function getPidList($config)
}
}

/**
* Find all ids from given ids and level
*
* @param string $pidList
* @param int $recursive
*
* @return string
*/
protected function extendPidListByChildren($pidList = '', $recursive = 0)
protected function extendPidListByChildren(string $pidList = '', int $recursive = 0): string
{
$recursive = (int)$recursive;

Expand All @@ -166,12 +137,8 @@ protected function extendPidListByChildren($pidList = '', $recursive = 0)

/**
* Returns all products for a given PidList
*
* @param string $indexPids
*
* @return array
*/
protected function getProductsToIndex($indexPids)
protected function getProductsToIndex(string $indexPids): array
{
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_cartproducts_domain_model_product_product');
Expand All @@ -188,10 +155,7 @@ protected function getProductsToIndex($indexPids)
return $products;
}

/**
*
*/
protected function getTargetPidFormCategory($categoryUid)
protected function getTargetPidFormCategory($categoryUid): ?int
{
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('sys_category');
Expand Down
2 changes: 1 addition & 1 deletion ext_emconf.php
Expand Up @@ -5,7 +5,7 @@
'description' => 'Shopping Cart(s) for TYPO3 - Products',
'category' => 'plugin',
'shy' => false,
'version' => '4.0.5',
'version' => '4.0.6',
'dependencies' => '',
'conflicts' => '',
'priority' => '',
Expand Down

0 comments on commit a203f13

Please sign in to comment.