Startseiten-Prototyp unter Dev-Link

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Kevin Adametz 2026-05-28 08:21:40 +00:00
parent 086ba968f7
commit 754aa699a1
4 changed files with 390 additions and 0 deletions

View file

@ -84,6 +84,127 @@ class PageRepository extends NestedTreeRepository
return $ret;
}
/**
* Curated offer selection for the start page test version.
*
* The existing findOffers() intentionally shuffles results. For the crisis
* communication start page we need a stable order with currently sellable
* destinations first.
*
* @param int $limit
* @return Page[]
*/
public function findHomepageOffers($limit = 12)
{
$pages = $this->createQueryBuilder('node')
->distinct()
->innerJoin('node.travelProgram', 'tp')
->addSelect('tp')
->innerJoin('tp.countries', 'c')
->addSelect('c')
->where('node.status = 1')
->andWhere('tp.status = 1')
->orderBy('node.order')
->addOrderBy('tp.position')
->addOrderBy('node.title')
->getQuery()
->execute();
$pages = array_values(array_filter($pages, function (Page $page) {
return $this->getHomepagePriority($page) <= 4;
}));
usort($pages, function (Page $a, Page $b) {
$priorityA = $this->getHomepagePriority($a);
$priorityB = $this->getHomepagePriority($b);
if ($priorityA !== $priorityB) {
return $priorityA - $priorityB;
}
$orderA = $a->getOrder() ?: 9999;
$orderB = $b->getOrder() ?: 9999;
if ($orderA !== $orderB) {
return $orderA - $orderB;
}
return strcasecmp($a->getTitle(), $b->getTitle());
});
return array_slice($pages, 0, $limit);
}
/**
* @return Page[]
*/
public function findHomepageCountryPages()
{
$pages = $this->findCountryPages();
usort($pages, function (Page $a, Page $b) {
$priorityA = $this->getHomepagePriority($a);
$priorityB = $this->getHomepagePriority($b);
if ($priorityA !== $priorityB) {
return $priorityA - $priorityB;
}
return strcasecmp($a->getTitle(), $b->getTitle());
});
return $pages;
}
private function getHomepagePriority(Page $page)
{
$haystack = $this->buildHomepageSortHaystack($page);
$priorities = [
0 => ['aegypt', 'agypt', 'egypt'],
1 => ['marokko'],
2 => ['usbek', 'uzbek'],
3 => ['oman'],
4 => ['jordan'],
6 => ['israel'],
7 => ['tuerkei', 'turkei'],
8 => ['iran'],
];
foreach ($priorities as $priority => $needles) {
foreach ($needles as $needle) {
if (strpos($haystack, $needle) !== false) {
return $priority;
}
}
}
return 99;
}
private function buildHomepageSortHaystack(Page $page)
{
$parts = [
$page->getSlug(),
$page->getTitle(),
$page->getTitleShort(),
$page->getRealUrlPath(),
];
if ($page->getCountry()) {
$parts[] = $page->getCountry()->getName();
$parts[] = $page->getCountry()->getSlug();
}
if ($page->getTravelProgram()) {
foreach ($page->getTravelProgram()->getCountries() as $country) {
$parts[] = $country->getName();
$parts[] = $country->getSlug();
}
}
return strtolower(implode(' ', array_filter($parts)));
}
public function findCountryPages()
{
return $this->createQueryBuilder('node')