2 declare(strict_types = 1);
19 use Doctrine\DBAL\Connection;
112 throw new \InvalidArgumentException(
113 'tableName must be string',
118 throw new \InvalidArgumentException(
119 'routeFieldName name must be string',
124 throw new \InvalidArgumentException(
125 '$routeValuePrefix must be string with one character',
137 $this->slugUniqueInSite = $this->isSlugUniqueInSite($this->tableName, $this->routeFieldName);
143 public function generate(
string $value): ?string
147 if (!isset($result[$this->routeFieldName])) {
151 (
string)$result[$this->routeFieldName]
158 public function resolve(
string $value): ?string
162 if ($result[$this->languageParentFieldName] ??
null > 0) {
165 if (isset($result[
'uid'])) {
166 return (
string)$result[
'uid'];
176 return array_filter([
179 $this->routeFieldName,
180 $this->languageFieldName,
181 $this->languageParentFieldName,
191 if (empty($this->routeValuePrefix) || $value ===
null) {
194 return ltrim($value, $this->routeValuePrefix);
200 $result = $queryBuilder
201 ->select(...$this->persistenceFieldNames)
202 ->where($queryBuilder->expr()->eq(
204 $queryBuilder->createNamedParameter($value, \PDO::PARAM_INT)
208 return $result !==
false ? $result :
null;
213 $languageAware = $this->languageFieldName !==
null && $this->languageParentFieldName !==
null;
217 $queryBuilder->expr()->eq(
218 $this->routeFieldName,
219 $queryBuilder->createNamedParameter($value, \PDO::PARAM_STR)
224 if ($languageAware) {
225 $languageIds = $this->resolveAllRelevantLanguageIds();
226 $constraints[] = $queryBuilder->expr()->in(
227 $this->languageFieldName,
228 $queryBuilder->createNamedParameter($languageIds, Connection::PARAM_INT_ARRAY)
232 $results = $queryBuilder
233 ->select(...$this->persistenceFieldNames)
234 ->where(...$constraints)
239 if ($this->slugUniqueInSite) {
240 $results = array_values($this->filterContainedInSite($results));
243 if (!$languageAware) {
244 return $results[0] ??
null;
247 return $this->resolveLanguageFallback($results, $this->languageFieldName, $languageIds);
252 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
253 ->getQueryBuilderForTable($this->tableName)
254 ->from($this->tableName);
255 $queryBuilder->setRestrictions(
256 GeneralUtility::makeInstance(FrontendRestrictionContainer::class, $this->context)
260 $queryBuilder->getRestrictions()->removeByType(FrontendGroupRestriction::class);
261 return $queryBuilder;
270 $languageId = $this->siteLanguage->getLanguageId();
271 if ($record ===
null || $languageId === 0) {
276 if ($this->tableName ===
'pages') {
277 return $pageRepository->getPageOverlay($record, $languageId);
279 return $pageRepository
280 ->getRecordOverlay($this->tableName, $record, $languageId) ?:
null;
288 $context = clone GeneralUtility::makeInstance(Context::class);
293 return GeneralUtility::makeInstance(
294 PageRepository::class,