mirror of
https://github.com/Codappix/search_core.git
synced 2024-11-22 12:16:11 +01:00
Merge pull request #10 from DanielSiepmann/feature/ignore-content-on-non-existing-pages
FEATURE: Respect pages information
This commit is contained in:
commit
30ec03998e
2 changed files with 28 additions and 9 deletions
|
@ -70,6 +70,10 @@ class TcaIndexer implements IndexerInterface
|
|||
$this->logger->info('Start indexing');
|
||||
foreach ($this->getRecordGenerator() as $records) {
|
||||
$this->logger->debug('Index records.', [$records]);
|
||||
if ($records === null) {
|
||||
break;
|
||||
}
|
||||
|
||||
$this->connection->addDocuments($this->tcaTableService->getTableName(), $records);
|
||||
}
|
||||
$this->logger->info('Finish indexing');
|
||||
|
@ -100,13 +104,13 @@ class TcaIndexer implements IndexerInterface
|
|||
/**
|
||||
* @param int $offset
|
||||
* @param int $limit
|
||||
* @return array
|
||||
* @return array|null
|
||||
*/
|
||||
protected function getRecords($offset, $limit)
|
||||
{
|
||||
$records = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
|
||||
$this->tcaTableService->getFields(),
|
||||
$this->tcaTableService->getTableName(),
|
||||
$this->tcaTableService->getTableClause(),
|
||||
$this->tcaTableService->getWhereClause(),
|
||||
'',
|
||||
'',
|
||||
|
@ -117,8 +121,6 @@ class TcaIndexer implements IndexerInterface
|
|||
$this->tcaTableService->prepareRecord($record);
|
||||
}
|
||||
|
||||
// TODO: Ignore records from sys folder?
|
||||
|
||||
return $records;
|
||||
}
|
||||
|
||||
|
@ -130,8 +132,9 @@ class TcaIndexer implements IndexerInterface
|
|||
{
|
||||
$record = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow(
|
||||
$this->tcaTableService->getFields(),
|
||||
$this->tcaTableService->getTableName(),
|
||||
$this->tcaTableService->getWhereClause() . ' AND uid = ' . (int) $identifier
|
||||
$this->tcaTableService->getTableClause(),
|
||||
$this->tcaTableService->getWhereClause()
|
||||
. ' AND ' . $this->tcaTableService->getTableName() . '.uid = ' . (int) $identifier
|
||||
);
|
||||
$this->tcaTableService->prepareRecord($record);
|
||||
|
||||
|
|
|
@ -76,6 +76,14 @@ class TcaTableService
|
|||
return $this->tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTableClause()
|
||||
{
|
||||
return $this->tableName . ' LEFT JOIN pages on ' . $this->tableName . '.pid = pages.uid';
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjust record accordingly to configuration.
|
||||
* @param array &$record
|
||||
|
@ -100,6 +108,10 @@ class TcaTableService
|
|||
$whereClause = '1=1 '
|
||||
. BackendUtility::BEenableFields($this->tableName)
|
||||
. BackendUtility::deleteClause($this->tableName)
|
||||
|
||||
. BackendUtility::BEenableFields('pages')
|
||||
. BackendUtility::deleteClause('pages')
|
||||
. ' AND pages.no_search = 0'
|
||||
;
|
||||
|
||||
$this->logger->debug('Generated where clause.', [$this->tableName, $whereClause]);
|
||||
|
@ -111,8 +123,8 @@ class TcaTableService
|
|||
*/
|
||||
public function getFields()
|
||||
{
|
||||
$fields = 'uid,pid,' . implode(
|
||||
',',
|
||||
$fields = array_merge(
|
||||
['uid','pid'],
|
||||
array_filter(
|
||||
array_keys($this->tca['columns']),
|
||||
function ($columnName) {
|
||||
|
@ -122,8 +134,12 @@ class TcaTableService
|
|||
)
|
||||
);
|
||||
|
||||
foreach ($fields as $key => $field) {
|
||||
$fields[$key] = $this->tableName . '.' . $field;
|
||||
}
|
||||
|
||||
$this->logger->debug('Generated fields.', [$this->tableName, $fields]);
|
||||
return $fields;
|
||||
return implode(',', $fields);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue