src/Network/Controller/NetworkTabNavigationController.php line 55

Open in your IDE?
  1. <?php
  2. namespace App\Network\Controller;
  3. use App\Network\Service\NetworkProfileService;
  4. use App\Profile\Model\Profile;
  5. use App\Profile\Service\ProfileService;
  6. use Carbon\Carbon;
  7. use Doctrine\DBAL\Query\QueryBuilder;
  8. use Pimcore\Controller\FrontendController;
  9. use Pimcore\Model\DataObject\Auction;
  10. use Pimcore\Model\DataObject\Raceday;
  11. use Symfony\Component\HttpFoundation\Request;
  12. use Symfony\Component\HttpFoundation\Response;
  13. use Symfony\Component\Routing\Annotation\Route;
  14. #[Route([
  15.   'name' => 'profile_tab_navigation_',
  16.   'localizedPaths' => [
  17.     'en' => '/{_locale}/tabnav',
  18.     'de' => '/{_locale}/tabnav',
  19.     'fr' => '/{_locale}/tabnav',
  20.   ],
  21. ])]
  22. class NetworkTabNavigationController extends FrontendController
  23. {
  24.   #[Route('/{id}/timeline'name'timeline')]
  25.   public function timeline(Request $request$idNetworkProfileService $networkProfileServiceProfileService $profileService): Response
  26.   {
  27.     $profile Profile::getById($id);
  28.     $subprofileKeys $profileService->getActiveSubProfileIdentifiers($profile);
  29.     $horses $networkProfileService->getAssociatedHorsesByProfile($subprofileKeys$profile);
  30.     $auctionEvents $networkProfileService->getFutureAuctionsByProfile($profile);
  31.     $raceEvents $networkProfileService->getFutureRacedaysByProfile($profile);
  32.     $marketplacePosts $networkProfileService->getLatestMarketplacePostsByProfile($profile);
  33.     // dd();
  34.     $request->setRequestFormat('text/html');
  35.     return $this->renderForm('network/profile/sections/profile_section_timeline.html.twig', [
  36.       'user' => $this->getUser(),
  37.       'profile' => Profile::getById($id),
  38.       'highlightedPost' => $request->get('highlightedPost'),
  39.       'horses' => $horses,
  40.       'raceEvents' => $raceEvents,
  41.       'auctionEvents' => $auctionEvents,
  42.       'marketplacePosts' => $marketplacePosts,
  43.       // 'horseEvents' => ['auctions' => $horseAuctions, 'racedays' => $horseRacedays],
  44.     ]);
  45.   }
  46.   #[Route('/{id}/achievements'name'achievements')]
  47.   public function achievements(Request $request$idNetworkProfileService $networkProfileServiceProfileService $profileService): Response
  48.   {
  49.     $profile Profile::getById($id);
  50.     $achievementCategories $networkProfileService->getAchievementCategoriesByProfile($profile);
  51.     // dd();
  52.     $request->setRequestFormat('text/html');
  53.     return $this->renderForm('network/profile/sections/profile_section_achievements.html.twig', [
  54.       'user' => $this->getUser(),
  55.       'profile' => $profile,
  56.       'categories' => $achievementCategories,
  57.       // 'horseEvents' => ['auctions' => $horseAuctions, 'racedays' => $horseRacedays],
  58.     ]);
  59.   }
  60.   #[Route('/{id}/news'name'news')]
  61.   public function news(Request $request$id): Response
  62.   {
  63.     $request->setRequestFormat('text/html');
  64.     return $this->renderForm('network/profile/sections/profile_section_news.html.twig', [
  65.       'user' => $this->getUser(),
  66.       'profile' => Profile::getById($id),
  67.       // 'horseEvents' => ['auctions' => $horseAuctions, 'racedays' => $horseRacedays],
  68.     ]);
  69.   }
  70.   #[Route('/{id}/network'name'network')]
  71.   public function network(Request $request$id): Response
  72.   {
  73.     return $this->renderForm('network/profile/sections/profile_section_network.html.twig', [
  74.       'user' => $this->getUser(),
  75.       'profile' => Profile::getById($id),
  76.     ]);
  77.   }
  78.   #[Route('/{id}/references'name'references')]
  79.   public function references(Request $request$id): Response
  80.   {
  81.     return $this->renderForm('network/profile/sections/profile_section_references.html.twig', [
  82.       'user' => $this->getUser(),
  83.       'profile' => Profile::getById($id),
  84.     ]);
  85.   }
  86.   #[Route('/{id}/team'name'team')]
  87.   public function team(Request $request$id): Response
  88.   {
  89.     return $this->renderForm('network/profile/sections/profile_section_team.html.twig', [
  90.       'user' => $this->getUser(),
  91.       'profile' => Profile::getById($id),
  92.     ]);
  93.   }
  94.   #[Route('/{id}/horse-lists'name'horse_lists')]
  95.   public function horses(Request $request$idNetworkProfileService $networkProfileServiceProfileService $profileService): Response
  96.   {
  97.     $profile Profile::getById($id);
  98.     $subprofileKeys $profileService->getActiveSubProfileIdentifiers($profile);
  99.     $horses $networkProfileService->getAssociatedHorsesByProfile($subprofileKeys$profile);
  100.     $profile Profile::getById($id);
  101.     $horseRacedays Raceday::getList();
  102.     $horseRacedays->onCreateQueryBuilder(function (QueryBuilder $queryBuilder) use ($profile) {
  103.       $queryBuilder->join('object_raceday''object_horse''horse''horses LIKE CONCAT("%", `horse`.`oo_id` , "%")');
  104.       $queryBuilder->where('object_raceday.date >= "'.Carbon::now()->format('Y-m-d').'" AND object_raceday.horses IS NOT NULL AND (horse.racingmanager__id ='.$profile->getId().' OR horse.jockey__id ='.$profile->getId().' OR horse.owner__id ='.$profile->getId().' OR horse.breeder__id ='.$profile->getId().' OR horse.trainer__id ='.$profile->getId().')');
  105.       $queryBuilder->orderBy('object_raceday.date''ASC');
  106.       $queryBuilder->distinct();
  107.       $queryBuilder->setMaxResults(3);
  108.     });
  109.     $horseAuctions Auction::getList();
  110.     $horseAuctions->onCreateQueryBuilder(function (QueryBuilder $queryBuilder) use ($profile) {
  111.       $queryBuilder->innerJoin('object_auction''object_horse''horse''horses LIKE CONCAT("%", `horse`.`oo_id` , "%")');
  112.       $queryBuilder->where('end >="'.Carbon::now()->format('Y-m-d').'" AND horses IS NOT NULL AND (horse.racingmanager__id ='.$profile->getId().' OR horse.jockey__id ='.$profile->getId().' OR horse.owner__id ='.$profile->getId().' OR horse.breeder__id ='.$profile->getId().' OR horse.trainer__id ='.$profile->getId().')');
  113.       $queryBuilder->distinct();
  114.       $queryBuilder->setMaxResults(3);
  115.     });
  116.     return $this->renderForm('network/profile/sections/profile_section_horses.html.twig', [
  117.       'user' => $this->getUser(),
  118.       'profile' => $profile,
  119.       'managedHorses' => $horses['managedHorses'],
  120.       'trainedHorses' => $horses['trainedHorses'],
  121.       'ownedHorses' => $horses['ownedHorses'],
  122.       'bredHorses' => $horses['bredHorses'],
  123.       'auctionEvents' => $horseAuctions,
  124.       'racedayEvents' => $horseRacedays,
  125.     ]);
  126.   }
  127.   // #[Route('/{id}/horse-events', name: 'horse_events')]
  128.   // public function horseEvents(Request $request, $id, NetworkProfileService $networkProfileService, ProfileService $profileService): Response
  129.   // {
  130.   //   $profile = Profile::getById($id);
  131.   //   $horseRacedays = Raceday::getList();
  132.   //   $horseRacedays->onCreateQueryBuilder(function (QueryBuilder $queryBuilder) use ($profile) {
  133.   //     $queryBuilder->join('object_raceday', 'object_horse', 'horse', 'horses LIKE CONCAT("%", `horse`.`oo_id` , "%")');
  134.   //     $queryBuilder->where('object_raceday.date >= "'.Carbon::now()->format('Y-m-d').'" AND object_raceday.horses IS NOT NULL AND (horse.racingmanager__id ='.$profile->getId().' OR horse.jockey__id ='.$profile->getId().' OR horse.owner__id ='.$profile->getId().' OR horse.breeder__id ='.$profile->getId().' OR horse.trainer__id ='.$profile->getId().')');
  135.   //     $queryBuilder->orderBy('object_raceday.date', 'ASC');
  136.   //     $queryBuilder->distinct();
  137.   //     $queryBuilder->setMaxResults(3);
  138.   //   });
  139.   //   $horseAuctions = Auction::getList();
  140.   //   $horseAuctions->onCreateQueryBuilder(function (QueryBuilder $queryBuilder) use ($profile) {
  141.   //     $queryBuilder->innerJoin('object_auction', 'object_horse', 'horse', 'horses LIKE CONCAT("%", `horse`.`oo_id` , "%")');
  142.   //     $queryBuilder->where('end >="'.Carbon::now()->format('Y-m-d').'" AND horses IS NOT NULL AND (horse.racingmanager__id ='.$profile->getId().' OR horse.jockey__id ='.$profile->getId().' OR horse.owner__id ='.$profile->getId().' OR horse.breeder__id ='.$profile->getId().' OR horse.trainer__id ='.$profile->getId().')');
  143.   //     $queryBuilder->distinct();
  144.   //     $queryBuilder->setMaxResults(3);
  145.   //   });
  146.   //   return $this->renderForm('network/profile/sections/profile_section_horse_events.html.twig', [
  147.   //     'user' => $this->getUser(),
  148.   //     'profile' => $profile,
  149.   //     'auctionEvents' => $horseAuctions,
  150.   //     'racedayEvents' => $horseRacedays,
  151.   //   ]);
  152.   // }
  153.   #[Route('/{id}/auctions'name'auctions')]
  154.   public function auctions(Request $request$id): Response
  155.   {
  156.     $profile Profile::getById($id);
  157.     return $this->renderForm('network/profile/sections/profile_section_auctions.html.twig', [
  158.       'user' => $this->getUser(),
  159.       'profile' => $profile,
  160.     ]);
  161.   }
  162.   #[Route('/{id}/racedays'name'raceday_list')]
  163.   public function racedays(Request $request$id): Response
  164.   {
  165.     $profile Profile::getById($id);
  166.     return $this->renderForm('network/profile/sections/profile_section_racedays.html.twig', [
  167.       'user' => $this->getUser(),
  168.       'profile' => $profile,
  169.     ]);
  170.   }
  171. // {% do tab_navigation_add({ name: 'network', action: 'network' }) %}
  172. // {% do tab_navigation_add({ name: 'references', action: 'references_list' }) %}
  173. // {% do tab_navigation_add({ name: 'team', action: 'team' }) %}
  174. }