FEATURE: Respect pages information

* If content is on a deleted or inactive page, ignore it.
* Also respect disable search setting of page.
This commit is contained in:
Daniel Siepmann 2016-12-13 10:38:49 +01:00
parent e30463ddc7
commit fef760ee0d
2 changed files with 28 additions and 9 deletions

View file

@ -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);

View file

@ -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);
}
/**