src/Auction/Controller/AuctionTabNavigationController.php line 46

Open in your IDE?
  1. <?php
  2. namespace App\Auction\Controller;
  3. use App\Network\Service\NetworkProfileService;
  4. use App\Profile\Model\Profile;
  5. use App\Profile\Service\ProfileService;
  6. use Pimcore\Controller\FrontendController;
  7. use Pimcore\Model\DataObject\Auction;
  8. use Pimcore\Model\DataObject\Auctionlot;
  9. use Pimcore\Model\DataObject\News;
  10. use Symfony\Component\HttpFoundation\Request;
  11. use Symfony\Component\HttpFoundation\Response;
  12. use Symfony\Component\Routing\Annotation\Route;
  13. #[Route([
  14.   'name' => 'auction_tab_navigation_',
  15.   'localizedPaths' => [
  16.     'en' => '/{_locale}/auction/tabnav',
  17.     'de' => '/{_locale}/auction/tabnav',
  18.     'fr' => '/{_locale}/auction/tabnav',
  19.   ],
  20. ])]
  21. class AuctionTabNavigationController extends FrontendController
  22. {
  23.   #[Route('/{id}/timeline'name'timeline')]
  24.   public function timeline(Request $request$idNetworkProfileService $networkProfileServiceProfileService $profileService): Response
  25.   {
  26.     // {% include 'network/auction/sections/auction_section_timeline.html.twig' with {
  27.     //   user: user,
  28.     //   auction: auction,
  29.     //   hideCard: true
  30.     // } only %}
  31.     $request->setRequestFormat('text/html');
  32.     return $this->renderForm('network/auction/sections/auction_section_timeline.html.twig', [
  33.       'user' => $this->getUser(),
  34.       'auction' => Auction::getById($id),
  35.       'hideCard' => true,
  36.       // 'horseEvents' => ['auctions' => $horseAuctions, 'racedays' => $horseRacedays],
  37.     ]);
  38.   }
  39.   #[Route('/{id}/horses'name'horses')]
  40.   public function horses(Request $request$id): Response
  41.   {
  42.     $request->setRequestFormat('text/html');
  43.     return $this->renderForm('network/auction/sections/auction_section_horses.html.twig', [
  44.       'auction' => Auction::getById($id),
  45.     ]);
  46.   }
  47.   #[Route('/{id}/attendees'name'attendees')]
  48.   public function attendees(Request $request$id): Response
  49.   {
  50.     $auction Auction::getById($id);
  51.     $attendees $auction->getAttendees();
  52.     $attendeeProfiles = [];
  53.     foreach ($attendees as $attendee) {
  54.       $attendeeProfiles[] = Profile::getById($attendee->getObjectId());
  55.     }
  56.     $sortedAttendeeProfile = [];
  57.     foreach ($attendeeProfiles as $profile) {
  58.       $key explode('\\'$profile->getPrimaryProfile());
  59.       $key end($key);
  60.       $key str_replace('Profile'''$key);
  61.       $key mb_strtolower($key);
  62.       $sortedAttendeeProfile[$key][] = $profile;
  63.       usort($sortedAttendeeProfile[$key], fn ($a$b) => strcmp($a->getName(), $b->getName()));
  64.     }
  65.     $request->setRequestFormat('text/html');
  66.     return $this->renderForm('network/auction/sections/auction_section_attendees.html.twig', [
  67.       'auction' => Auction::getById($id),
  68.       'attendees' => $sortedAttendeeProfile,
  69.     ]);
  70.   }
  71.   #[Route('/{id}/auctionlots'name'auctionlots')]
  72.   public function auctionlots(Request $request$id): Response
  73.   {
  74.     $auction Auction::getById($id);
  75.     $totalAuctionlots Auctionlot::getList()
  76.     ->filterByAuction($auction)
  77.     ->getTotalCount();
  78.     $request->setRequestFormat('text/html');
  79.     $auction Auction::getById($id);
  80.     $topAuctionlots Auctionlot::getByAuction($auction);
  81.     $topAuctionlots->setCondition('price__value IS NOT NULL and status != "auction.status.not-sold" and status != "auction.status.withdrawn" and status != "auction.status.repurchased"');
  82.     $topAuctionlots->setOrderKey('price__value');
  83.     $topAuctionlots->setOrder('desc');
  84.     $topAuctionlots->setLimit(5);
  85.     return $this->renderForm('network/auction/sections/auction_section_auctionlots.html.twig', [
  86.       'auction' => $auction,
  87.       'totalAuctionlots' => $totalAuctionlots,
  88.       'auctionlots' => $topAuctionlots,
  89.     ]);
  90.   }
  91.   #[Route('/{id}/news'name'news')]
  92.   public function news(Request $request$id): Response
  93.   {
  94.     $request->setRequestFormat('text/html');
  95.     $news News::getList();
  96.     $news->addConditionParam('auctions LIKE :id', ['id' => '%'.$id.'%']);
  97.     return $this->renderForm('network/auction/sections/auction_section_news.html.twig', [
  98.       'auction' => Auction::getById($id),
  99.       'news' => $news,
  100.       // 'horseEvents' => ['auctions' => $horseAuctions, 'racedays' => $horseRacedays],
  101.     ]);
  102.   }
  103.   #[Route('/{id}/top-auctionlots'name'top_auctionlots')]
  104.   public function topAuctionlots(Request $request$id): Response
  105.   {
  106.     $auction Auction::getById($id);
  107.     $auctionlots Auctionlot::getByAuction($auction);
  108.     $auctionlots->setCondition('price__value IS NOT NULL and status != "auction.status.not-sold" and status != "auction.status.withdrawn" and status != "auction.status.repurchased"');
  109.     $auctionlots->setOrderKey('price__value');
  110.     $auctionlots->setOrder('desc');
  111.     $auctionlots->setLimit(5);
  112.     return $this->renderForm('network/auction/sections/auction_section_top_auctionlots.html.twig', [
  113.        'auction' => Auction::getById($id),
  114.        'auctionlots' => $auctionlots,
  115.        // 'horseEvents' => ['auctions' => $horseAuctions, 'racedays' => $horseRacedays],
  116.      ]);
  117.   }
  118. // {% do tab_navigation_add({ name: 'network', action: 'network' }) %}
  119. // {% do tab_navigation_add({ name: 'references', action: 'references_list' }) %}
  120. // {% do tab_navigation_add({ name: 'team', action: 'team' }) %}
  121. }