protected function convertAliasToId(array $configuration, $value)
{
$result = (string) $value;
// First, test if there is an entry in cache for the alias
if ($configuration['useUniqueCache']) {
$cachedId = $this->getFromAliasCacheByAliasValue($configuration, $value, FALSE);
if (MathUtility::canBeInterpretedAsInteger($cachedId)) {
$result = (int) $cachedId;
}
}
if (!is_int($result) && $configuration['table'] !== 'pages') {
// If no cached entry, look it up directly in the table. Note: this will
// most likely fail. When encoding we convert alias field to a nice
// looking URL segment, which usually looks differently from the field.
// But this is the only thing we can do without fetching each record and
// re-encoding the field to find the match.
// Assemble list of fields to look up. This includes localization related fields
$translationEnabled = FALSE;
$fieldList = array();
if ($configuration['languageGetVar'] && $configuration['transOrigPointerField'] && $configuration['languageField']) {
$fieldList[] = 'uid';
if ($configuration['table'] !== 'pages') {
$fieldList[] = $configuration['transOrigPointerField'];
$fieldList[] = $configuration['languageField'];
}
$translationEnabled = TRUE;
}
$fieldList[] = $configuration['id_field'];
$row = $this->databaseConnection->exec_SELECTgetSingleRow(implode(',', $fieldList), $configuration['table'], $configuration['alias_field'] . '=' . $this->databaseConnection->fullQuoteStr($value, $configuration['table']) . ' ' . $configuration['addWhereClause']);
if (is_array($row)) {
$result = (int) $row[$configuration['id_field']];
// If localization is enabled, check if this record is a localized version and if so, find uid of the original version.
if ($translationEnabled && $row[$configuration['languageField']] > 0) {
$result = (int) $row[$configuration['transOrigPointerField']];
}
}
}
return $result;
}