<?php
namespace App\Auction\Controller;
use App\Network\Service\NetworkProfileService;
use App\Profile\Model\Profile;
use App\Profile\Service\ProfileService;
use Pimcore\Controller\FrontendController;
use Pimcore\Model\DataObject\Auction;
use Pimcore\Model\DataObject\Auctionlot;
use Pimcore\Model\DataObject\News;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
#[Route([
'name' => 'auction_tab_navigation_',
'localizedPaths' => [
'en' => '/{_locale}/auction/tabnav',
'de' => '/{_locale}/auction/tabnav',
'fr' => '/{_locale}/auction/tabnav',
],
])]
class AuctionTabNavigationController extends FrontendController
{
#[Route('/{id}/timeline', name: 'timeline')]
public function timeline(Request $request, $id, NetworkProfileService $networkProfileService, ProfileService $profileService): Response
{
// {% include 'network/auction/sections/auction_section_timeline.html.twig' with {
// user: user,
// auction: auction,
// hideCard: true
// } only %}
$request->setRequestFormat('text/html');
return $this->renderForm('network/auction/sections/auction_section_timeline.html.twig', [
'user' => $this->getUser(),
'auction' => Auction::getById($id),
'hideCard' => true,
// 'horseEvents' => ['auctions' => $horseAuctions, 'racedays' => $horseRacedays],
]);
}
#[Route('/{id}/horses', name: 'horses')]
public function horses(Request $request, $id): Response
{
$request->setRequestFormat('text/html');
return $this->renderForm('network/auction/sections/auction_section_horses.html.twig', [
'auction' => Auction::getById($id),
]);
}
#[Route('/{id}/attendees', name: 'attendees')]
public function attendees(Request $request, $id): Response
{
$auction = Auction::getById($id);
$attendees = $auction->getAttendees();
$attendeeProfiles = [];
foreach ($attendees as $attendee) {
$attendeeProfiles[] = Profile::getById($attendee->getObjectId());
}
$sortedAttendeeProfile = [];
foreach ($attendeeProfiles as $profile) {
$key = explode('\\', $profile->getPrimaryProfile());
$key = end($key);
$key = str_replace('Profile', '', $key);
$key = mb_strtolower($key);
$sortedAttendeeProfile[$key][] = $profile;
usort($sortedAttendeeProfile[$key], fn ($a, $b) => strcmp($a->getName(), $b->getName()));
}
$request->setRequestFormat('text/html');
return $this->renderForm('network/auction/sections/auction_section_attendees.html.twig', [
'auction' => Auction::getById($id),
'attendees' => $sortedAttendeeProfile,
]);
}
#[Route('/{id}/auctionlots', name: 'auctionlots')]
public function auctionlots(Request $request, $id): Response
{
$auction = Auction::getById($id);
$totalAuctionlots = Auctionlot::getList()
->filterByAuction($auction)
->getTotalCount();
$request->setRequestFormat('text/html');
$auction = Auction::getById($id);
$topAuctionlots = Auctionlot::getByAuction($auction);
$topAuctionlots->setCondition('price__value IS NOT NULL and status != "auction.status.not-sold" and status != "auction.status.withdrawn" and status != "auction.status.repurchased"');
$topAuctionlots->setOrderKey('price__value');
$topAuctionlots->setOrder('desc');
$topAuctionlots->setLimit(5);
return $this->renderForm('network/auction/sections/auction_section_auctionlots.html.twig', [
'auction' => $auction,
'totalAuctionlots' => $totalAuctionlots,
'auctionlots' => $topAuctionlots,
]);
}
#[Route('/{id}/news', name: 'news')]
public function news(Request $request, $id): Response
{
$request->setRequestFormat('text/html');
$news = News::getList();
$news->addConditionParam('auctions LIKE :id', ['id' => '%'.$id.'%']);
return $this->renderForm('network/auction/sections/auction_section_news.html.twig', [
'auction' => Auction::getById($id),
'news' => $news,
// 'horseEvents' => ['auctions' => $horseAuctions, 'racedays' => $horseRacedays],
]);
}
#[Route('/{id}/top-auctionlots', name: 'top_auctionlots')]
public function topAuctionlots(Request $request, $id): Response
{
$auction = Auction::getById($id);
$auctionlots = Auctionlot::getByAuction($auction);
$auctionlots->setCondition('price__value IS NOT NULL and status != "auction.status.not-sold" and status != "auction.status.withdrawn" and status != "auction.status.repurchased"');
$auctionlots->setOrderKey('price__value');
$auctionlots->setOrder('desc');
$auctionlots->setLimit(5);
return $this->renderForm('network/auction/sections/auction_section_top_auctionlots.html.twig', [
'auction' => Auction::getById($id),
'auctionlots' => $auctionlots,
// 'horseEvents' => ['auctions' => $horseAuctions, 'racedays' => $horseRacedays],
]);
}
// {% do tab_navigation_add({ name: 'network', action: 'network' }) %}
// {% do tab_navigation_add({ name: 'references', action: 'references_list' }) %}
// {% do tab_navigation_add({ name: 'team', action: 'team' }) %}
}