src/Document/Controller/DocumentController.php line 33

Open in your IDE?
  1. <?php
  2. namespace App\Document\Controller;
  3. use App\Auction\Form\Type\AuctionDetailFilterType;
  4. use App\Auction\Manager\AuctionManager;
  5. use App\EventMap\EventMap;
  6. use App\Race\Form\Type\RaceDetailFilterType;
  7. use App\Race\Manager\RaceManager;
  8. use App\Race\Model\Raceday;
  9. use App\Service\photoNewsService;
  10. use Carbon\Carbon;
  11. use Doctrine\DBAL\Query\QueryBuilder;
  12. use Knp\Component\Pager\PaginatorInterface;
  13. use Pimcore\Controller\FrontendController;
  14. use Pimcore\Model\DataObject;
  15. use Pimcore\Model\DataObject\Auction;
  16. use Pimcore\Model\DataObject\Auctionhouse;
  17. use Pimcore\Model\DataObject\Jockey;
  18. use Pimcore\Model\DataObject\News;
  19. use Pimcore\Model\DataObject\Owner;
  20. use Pimcore\Model\DataObject\Photographer;
  21. use Pimcore\Model\DataObject\Race;
  22. use Pimcore\Model\DataObject\Racingtrack;
  23. use Pimcore\Model\DataObject\Studfarm;
  24. use Pimcore\Model\DataObject\Trainer;
  25. use Symfony\Component\HttpFoundation\Request;
  26. use Symfony\Component\Notifier\NotifierInterface;
  27. use Symfony\Component\Routing\Annotation\Route;
  28. class DocumentController extends FrontendController
  29. {
  30.   public function document(NotifierInterface $notifier)
  31.   {
  32.     $class get_class($this->document);
  33.     $templates = [
  34.           'Pimcore\Model\Document\Page' => 'document/index.html.twig',
  35.           'Pimcore\Model\Document\Hardlink\Wrapper\Page' => 'document/index.html.twig',
  36.           'Pimcore\Model\Document\Snippet' => 'layout/snippet/snippet.html.twig',
  37.           'Pimcore\Model\Document\Email' => 'layout/email/email.html.twig',
  38.           'Pimcore\Model\Document\Newsletter' => 'layout/newsletter/newsletter.html.twig',
  39.         ];
  40.     return $this->renderTemplate($templates[$class]);
  41.   }
  42.   /**
  43.    * impressum.
  44.    */
  45.   public function impressumAction(Request $request)
  46.   {
  47.     return $this->renderTemplate('document/impressum.html.twig');
  48.   }
  49.   /**
  50.    * This is quick and dirty, please remove as soon as the auction house profiles are implemented
  51.    * TODO: Remove after profile auction house has been implemented.
  52.    */
  53.   public function auctionHouseAction(Request $requestRaceManager $raceManagerEventMap $eventMapAuctionManager $auctionManagerPaginatorInterface $paginator)
  54.   {
  55.     $auctionHouse $this->document->getProperty('auctionhouse');
  56.     if (!$auctionHouse) {
  57.       $auctionHouse Auctionhouse::getById(24);
  58.     }
  59.     // dd($this->document->getEditable('team')->getElements()[0]->getEditable('name'));
  60.     // foreach ($this->document->getEditable('team')->getIterator() as $team) {
  61.     //   dd($team);
  62.     //   // code...
  63.     // }
  64.     // news holen
  65.     $total 0;
  66.     $auctionsHouseNews = [];
  67.     if ($auctionHouse->getNews()) {
  68.       $newsfolder $auctionHouse->getNews()->getPath().$auctionHouse->getNews()->getKey();
  69.       $auctionsHouseNews News::getList()
  70.           ->setCondition('o_path LIKE :folder', ['folder' => $newsfolder.'%']);
  71.       $total $auctionsHouseNews->getTotalCount();
  72.       $auctionsHouseNews $auctionsHouseNews->setOrderKey(['date'])->setOrder(['desc'])->setLimit(5)->load();
  73.     }
  74.     $now Carbon::now();
  75.     $filter $this->createForm(AuctionDetailFilterType::class, [
  76.       'period' => $request->get('period''future'),
  77.     ], ['method' => 'get']);
  78.     $filter->handleRequest($request);
  79.     $auctions Auction::getList();
  80.     $auctions->setCondition('auctionhouse__id = :auctionHouse and end >= :end', ['auctionHouse' => $auctionHouse->getId(), 'end' => Carbon::now()->format('Y-m-d')]);
  81.     // $auctions->setCondition('end >= :end', ['end' => Carbon::now()->format('Y-m-d')]);
  82.     $auctions->setOrderKey('end');
  83.     $auctions->setOrder('asc');
  84.     if ($filter->isSubmitted() && $filter->isValid()) {
  85.       $data = (object) $filter->getData();
  86.       // if($auctionHouse->getId()){
  87.       $auctions->setCondition('auctionhouse__id = :auctionHouse', ['auctionHouse' => $auctionHouse->getId()]);
  88.       $auctions->setOrderKey('end');
  89.       $data->period == 'past' $auctions->addConditionParam('end < :end', ['end' => Carbon::now()->format('Y-m-d')])->setOrder('desc') : null;
  90.       $data->period == 'future' $auctions->addConditionParam('end >= :end', ['end' => Carbon::now()->format('Y-m-d')])->setOrder('asc') : null;
  91.     }
  92.     $page $request->get('page'1);
  93.     $paginaton $paginator->paginate($auctions$page5);
  94.     $countdowns = [];
  95.     foreach ($auctions as $auction) {
  96.       if ($auction->getStart() && $auction->getStart() > $now) {
  97.         $countdowns[$auction->getId()] = $auction->getStart()->diffAsCarbonInterval($now);
  98.       } else {
  99.         if ($auction->getEnd()) {
  100.           $countdowns[$auction->getId()] = $auction->getEnd()->diffAsCarbonInterval($now);
  101.         }
  102.       }
  103.     }
  104.     // MARKER
  105.     $races $auctionHouse->getRaces();
  106.     $marker = [
  107.       ...$eventMap->generateMarker($races),
  108.       ...$eventMap->generateMarker($auctions->load()),
  109.     ];
  110.     return $this->renderTemplate('document/profiles/auction_house.html.twig', [
  111.       'auctionhouse' => $auctionHouse,
  112.         'profile' => $auctionHouse,
  113.         'auctions' => $auctions,
  114.         'pagination' => $paginaton,
  115.         'now' => $now,
  116.         'countdowns' => $countdowns,
  117.         'auctionsHouseNews' => $auctionsHouseNews,
  118.         'marker' => $marker,
  119.         'offset' => $request->request->get('offset'0) + 5,
  120.         'total' => $total,
  121.         'filter' => $filter->createView(),
  122.         '',
  123.     ]);
  124.   }
  125.   /**
  126.    * This is quick and dirty, please remove as soon as the photographer profiles are implemented
  127.    * TODO: Remove after profile photographer has been implemented.
  128.    */
  129.   public function photographerAction(Request $request)
  130.   {
  131.     $photographer $this->document->getProperty('photographer');
  132.     if (!$photographer) {
  133.       throw $this->createNotFoundException('No Photographer found for document');
  134.     }
  135.     // crawls https://www.galoppfoto.de/de/events and returns generated news
  136.     // $photoNewsService = new photoNewsService();
  137.     // $photoNewsService -> getPhotoNews();
  138.     $news $photographer->getNews();
  139.     return $this->renderTemplate('document/profiles/photographer.html.twig', [
  140.           'photographer' => $photographer,
  141.           'profile' => $photographer,
  142.           'news' => $news,
  143.         ]);
  144.   }
  145.   /**
  146.    * This is quick and dirty, please remove as soon as the owner profiles are implemented
  147.    * TODO: Remove after profile owner has been implemented.
  148.    */
  149.   public function ownerAction(Request $requestRaceManager $raceManager)
  150.   {
  151.     $owner $this->document->getProperty('owner');
  152.     if (!$owner) {
  153.       throw $this->createNotFoundException('No Owner found for document');
  154.     }
  155.     $horses $owner->getHorses();
  156.     $auctions = [];
  157.     foreach ($horses as $horse) {
  158.       $folder $horse->getParent();
  159.       $auction Auction::getByHorseFolder($folder1);
  160.       if (!$auction) {
  161.         continue;
  162.       }
  163.       $auctions[$auction->getId()]['auction'] = $auction;
  164.       $auctions[$auction->getId()]['horses'][] = $horse;
  165.     }
  166.     // Horselist
  167.     $horselist = [];
  168.     foreach ($horses as $horse) {
  169.       if ($horse->getTrainer()) {
  170.         $horselist[$horse->getTrainer()->getId()][] = [
  171.               'trainer' => $horse->getTrainer(),
  172.               'horse' => $horse,
  173.             ];
  174.       }
  175.     }
  176.     $newsOffset $request->request->get('offset'0) + 5;
  177.     return $this->renderTemplate('document/profiles/owner.html.twig', [
  178.           'owner' => $owner,
  179.           'profile' => $owner,
  180.           'auctions' => $auctions,
  181.           // "racedays" => $racedays,
  182.           'horselist' => $horselist,
  183.           'now' => new Carbon(),
  184.           'offset' => $newsOffset,
  185.           'total' => count($owner->getNews()),
  186.           'ownerNews' => array_slice($owner->getNews(), 0$newsOffset),
  187.         ]);
  188.   }
  189.   /**
  190.    * List Of PhotoNews.
  191.    *
  192.    * @Route("/photoNews/{profilType}/{profilId}", name="photo_news")
  193.    */
  194.   public function photoNews(Request $request$profilId)
  195.   {
  196.     $photographer Photographer::getById($profilId);
  197.     $limit = (int) $request->get('limit'5);
  198.     $total 0;
  199.     $newsList $photographer->getNews();
  200.     // echo '<pre>', var_dump($news), '</pre>';
  201.     // $news->addConditionParam('date >= :now', ['now' => Carbon::now()->format('Y-m-d')]);
  202.     // $news->onCreateQueryBuilder(
  203.     //   function (QueryBuilder $queryBuilder) {
  204.     //     $queryBuilder->groupBy(['DATE(date)']);
  205.     //   }
  206.     // );
  207.     // $news->setLimit($limit);
  208.     // $total = $news->getTotalCount();
  209.     // $news = $news->load();
  210.     $total count($newsList);
  211.     $trimmedNewsList = [];
  212.     for ($i 0$i $limit && $i count($newsList); ++$i) {
  213.       array_push($trimmedNewsList$newsList[$i]);
  214.     }
  215.     // echo '<pre>', var_dump($trimmedNewsList), '</pre>';
  216.     return $this->renderTemplate('news/photoNews.html.twig', [
  217.       'profilType' => 'Photographer',
  218.       'profilId' => $profilId,
  219.       'news' => $trimmedNewsList,
  220.       'limit' => $limit,
  221.       'total' => $total,
  222.     ]);
  223.   }
  224.   /**
  225.    * List Of Racedays.
  226.    *
  227.    * @Route("/racedays/{profilType}/{profilId}", name="race_days")
  228.    */
  229.   public function racedays(Request $request$profilType$profilIdRaceManager $raceManager)
  230.   {
  231.     $profil = [];
  232.     if ('Owner' === $profilType) {
  233.       $profil Owner::getById($profilId);
  234.     } elseif ('Trainer' === $profilType) {
  235.       $profil Trainer::getById($profilId);
  236.     } elseif ('Jockey' === $profilType) {
  237.       $profil Jockey::getById($profilId);
  238.     } elseif ('Auctionhouse' === $profilType) {
  239.       $profil Auctionhouse::getById($profilId);
  240.     } elseif ('Studfarm' === $profilType) {
  241.       $profil Studfarm::getById($profilId);
  242.     }
  243.     $limit = (int) $request->get('limit'5);
  244.     $total 0;
  245.     if (!$profil) {
  246.       throw $this->createNotFoundException('No Profil found for document');
  247.     }
  248.     $racedays = [];
  249.     $racesRelationData $profil->retrieveRelationData(['fieldname' => 'races''ownertype' => 'object']);
  250.     $raceIds array_map(function ($relation) {
  251.       return $relation['dest_id'];
  252.     }, $racesRelationData);
  253.     $days Race::getList();
  254.     $days->addConditionParam('oo_id in (:races)', ['races' => $raceIds]);
  255.     $days->addConditionParam('start >= :now', ['now' => Carbon::now()->format('Y-m-d')]);
  256.     $days->onCreateQueryBuilder(
  257.       function (QueryBuilder $queryBuilder) {
  258.         $queryBuilder->groupBy(['DATE(start)''racingtrack__id']);
  259.       }
  260.     );
  261.     $days->setLimit($limit);
  262.     $total $days->getTotalCount();
  263.     $days $days->load();
  264.     foreach ($days as $day) {
  265.       $races $raceManager->getRacesByDayAndRacingtrack($day->getStart(), $day->getRacingtrack());
  266.       $races->addConditionParam('oo_id in (:races)', ['races' => $raceIds]);
  267.       $races->addConditionParam('start >= :now', ['now' => Carbon::now()->format('Y-m-d')]);
  268.       $racedays[] = [
  269.           'day' => $day,
  270.           'races' => $races->load(),
  271.         ];
  272.     }
  273.     $response $this->renderTemplate('racingtrack/race_days.html.twig', [
  274.         'racedays' => $racedays,
  275.         'profilType' => $profilType,
  276.         'profilId' => $profilId,
  277.         'limit' => $limit,
  278.         'total' => $total,
  279.       ]);
  280.     return $response;
  281.   }
  282.   /**
  283.    * This is quick and dirty, please remove as soon as the owner profiles are implemented
  284.    * TODO: Remove after profile owner has been implemented.
  285.    */
  286.   public function studfarmAction(Request $requestRaceManager $raceManager)
  287.   {
  288.     $studfarm $this->document->getProperty('studfarm');
  289.     if (!$studfarm) {
  290.       throw $this->createNotFoundException('No Studfarm found for document');
  291.     }
  292.     $horses $studfarm->getHorses();
  293.     $auctions = [];
  294.     foreach ($horses as $horse) {
  295.       $folder $horse->getParent();
  296.       $auction Auction::getByHorseFolder($folder1);
  297.       if (!$auction) {
  298.         continue;
  299.       }
  300.       $auctions[$auction->getId()]['auction'] = $auction;
  301.       $auctions[$auction->getId()]['horses'][] = $horse;
  302.     }
  303.     $newsOffset $request->request->get('offset'0) + 5;
  304.     return $this->renderTemplate('document/profiles/studfarm.html.twig', [
  305.         'studfarm' => $studfarm,
  306.         'profile' => $studfarm,
  307.         // "racedays" => $racedays,
  308.         'auctions' => $auctions,
  309.         'now' => new Carbon(),
  310.         'offset' => $newsOffset,
  311.         'total' => count($studfarm->getNews()),
  312.         'studfarmNews' => array_slice($studfarm->getNews(), 0$newsOffset),
  313.       ]);
  314.   }
  315.   /**
  316.    * This is quick and dirty, please remove as soon as the owner profiles are implemented
  317.    * TODO: Remove after profile owner has been implemented.
  318.    */
  319.   public function associationAction(Request $requestRaceManager $raceManagerEventMap $eventMapPaginatorInterface $paginator)
  320.   {
  321.     $association $this->document->getProperty('association');
  322.     if (!$association) {
  323.       throw $this->createNotFoundException('No Association found for document');
  324.     }
  325.     $period $request->get('period''future');
  326.     $page $request->get('page'1);
  327.     $filter $this->createForm(RaceDetailFilterType::class, [
  328.       'period' => $period,
  329.     ], ['method' => 'get']);
  330.     $filter->handleRequest($request);
  331.     $racedays = [];
  332.     $allRaces = [];
  333.     if ($association->getRaces()) {
  334.       $folder $association->getRaces()->getFullPath();
  335.       $racedays = new \App\Raceday\Model\Listing();
  336.       $racedays->setCondition('object_race.o_path LIKE :folder', ['folder' => $folder.'%']);
  337.       $racedays->addConditionParam('start >= :now', ['now' => Carbon::now()->format('Y-m-d')]);
  338.       if ($filter->isSubmitted() && $filter->isValid()) {
  339.         $data = (object) $filter->getData();
  340.         if ($data->period) {
  341.           $racedays = new \App\Raceday\Model\Listing();
  342.           $racedays->setCondition('object_race.o_path LIKE :folder', ['folder' => $folder.'%']);
  343.           $racedays->addConditionParam('object_race.start '.($data->period == 'future' '>=' '<').' :now', ['now' => Carbon::now()->format('Y-m-d')]);
  344.           // $racedays->addConditionParam('date ')
  345.           $racedays->setOrderKey('object_race.start'false);
  346.           $racedays->setOrder($data->period == 'future' 'asc' 'desc');
  347.         }
  348.       }
  349.     }
  350.     $pagination $paginator->paginate(
  351.       $racedays,
  352.       $page,
  353.       5
  354.     );
  355.     $newsOffset $request->request->get('offset'0) + 5;
  356.     // MARKER
  357.     $marker = [];
  358.     $marker $eventMap->generateMarker($allRaces);
  359.     return $this->renderTemplate('document/profiles/association.html.twig', [
  360.         'association' => $association,
  361.         'profile' => $association,
  362.         'racedays' => $racedays,
  363.         'now' => new Carbon(),
  364.         'marker' => $marker,
  365.         'offset' => $newsOffset,
  366.         'total' => count($association->getNews()),
  367.         'associationNews' => array_slice($association->getNews(), 0$newsOffset),
  368.         'filter' => $filter->createView(),
  369.         'pagination' => $pagination,
  370.       ]);
  371.   }
  372.   /**
  373.    * This is quick and dirty, please remove as soon as the trainer profiles are implemented
  374.    * TODO: Remove after profile trainer has been implemented.
  375.    */
  376.   public function trainerAction(Request $requestRaceManager $raceManager)
  377.   {
  378.     /**
  379.      * @var Trainer
  380.      */
  381.     $trainer $this->document->getProperty('trainer');
  382.     if (!$trainer) {
  383.       throw $this->createNotFoundException('No Trainer found for document');
  384.     }
  385.     $horses $trainer->getHorses();
  386.     $auctions = [];
  387.     foreach ($horses as $horse) {
  388.       $folder $horse->getParent();
  389.       $auction Auction::getByHorseFolder($folder1);
  390.       if (!$auction) {
  391.         continue;
  392.       }
  393.       $auctions[$auction->getId()]['auction'] = $auction;
  394.       $auctions[$auction->getId()]['horses'][] = $horse;
  395.     }
  396.     // Horselist
  397.     $horselist = [];
  398.     foreach ($horses as $horse) {
  399.       if ($horse->getOwner()) {
  400.         $horselist[$horse->getOwner()->getId()][] = [
  401.             'owner' => $horse->getOwner(),
  402.             'horse' => $horse,
  403.           ];
  404.       }
  405.     }
  406.     $newsOffset $request->request->get('offset'0) + 5;
  407.     return $this->renderTemplate('document/profiles/trainer.html.twig', [
  408.         'trainer' => $trainer,
  409.         'profile' => $trainer,
  410.         // "racedays" => $racedays,
  411.         'auctions' => $auctions,
  412.         'horselist' => $horselist,
  413.         'now' => new Carbon(),
  414.         'offset' => $newsOffset,
  415.         'total' => count($trainer->getNews()),
  416.         'trainerNews' => array_slice($trainer->getNews(), 0$newsOffset),
  417.       ]);
  418.   }
  419.   /**
  420.    * This is quick and dirty, please remove as soon as the jockey profiles are implemented
  421.    * TODO: Remove after profile jockey has been implemented.
  422.    */
  423.   public function jockeyAction(Request $requestRaceManager $raceManager)
  424.   {
  425.     /**
  426.      * @var Jockey
  427.      */
  428.     $jockey $this->document->getProperty('jockey');
  429.     if (!$jockey) {
  430.       throw $this->createNotFoundException('No Jockey found for document');
  431.     }
  432.     $horses $jockey->getHorses();
  433.     $auctions = [];
  434.     foreach ($horses as $horse) {
  435.       $folder $horse->getParent();
  436.       $auction Auction::getByHorseFolder($folder1);
  437.       if (!$auction) {
  438.         continue;
  439.       }
  440.       $auctions[$auction->getId()]['auction'] = $auction;
  441.       $auctions[$auction->getId()]['horses'][] = $horse;
  442.     }
  443.     $newsOffset $request->request->get('offset'0) + 5;
  444.     return $this->renderTemplate('document/profiles/jockey.html.twig', [
  445.         'jockey' => $jockey,
  446.         // "racedays" => $racedays,
  447.         'auctions' => $auctions,
  448.         'now' => new Carbon(),
  449.         'offset' => $newsOffset,
  450.         'total' => count($jockey->getNews()),
  451.         'jockeyNews' => array_slice($jockey->getNews(), 0$newsOffset),
  452.       ]);
  453.   }
  454.   /**
  455.    * This is quick and dirty, please remove as soon as the racetrack profiles are implemented
  456.    * TODO: Remove after profile racetrack has been implemented.
  457.    */
  458.   public function racetrackAction(Request $requestRaceManager $raceManagerPaginatorInterface $paginator)
  459.   {
  460.     /**
  461.      * @var Racingtrack
  462.      */
  463.     $racetrack $this->document->getProperty('racetrack');
  464.     if (!$racetrack) {
  465.       throw $this->createNotFoundException('No Race-Track found for document');
  466.     }
  467.     // racetrack filter
  468.     $period $request->get('period''future');
  469.     $page $request->get('page'1);
  470.     $filter $this->createForm(RaceDetailFilterType::class, [
  471.       'period' => $period,
  472.     ], ['method' => 'get']);
  473.     $filter->handleRequest($request);
  474.     // $racedays = Raceday::getList()->setCondition('racingtrack__id LIKE :racetrack', [ 'racetrack' => $racetrack->getId()]);
  475.     //  $racedays->setOrderKey('object_race.start', false);
  476.     $racedays = new \App\Raceday\Model\Listing();
  477.     $sql $racedays->setCondition('object_race.racingtrack__id = :racetrack and object_race.start >= :now', ['racetrack' => $racetrack->getId(),  'now' => Carbon::now()->format('Y-m-d')]);
  478.     // dd([$sql, $racetrack->getId()]);
  479.     $racedays->setOrderKey('object_race.start'false);
  480.     if ($filter->isSubmitted() && $filter->isValid()) {
  481.       $data = (object) $filter->getData();
  482.       if ($data->period) {
  483.         // $racedays = new \App\Raceday\Model\Listing();
  484.         $racedays->setCondition('object_race.racingtrack__id = :racetrack and object_race.start '.($data->period == 'future' '>=' '<').' :now', ['racetrack' => $racetrack->getId(), 'now' => Carbon::now()->format('Y-m-d')]);
  485.         // $racedays->addConditionParam('date ')
  486.         $racedays->setOrderKey('object_race.start'false);
  487.         $data->period == 'past' $racedays->setOrder('desc') : null;
  488.         $data->period == 'future' $racedays->setOrder('asc') : null;
  489.       }
  490.     }
  491.     $pagination $paginator->paginate(
  492.       $racedays,
  493.       $page,
  494.       5
  495.     );
  496.     // news holen
  497.     $racetrackNews = [];
  498.     if ($racetrack->getNews()) {
  499.       $racetrackfolder $racetrack->getNews()->getPath().$racetrack->getNews()->getKey();
  500.       $racetrackNews News::getList()
  501.         ->setCondition('o_path LIKE :folder or subaffiliation LIKE :racetrack or affiliation__id LIKE :racetrackId', ['folder' => $racetrackfolder.'%''racetrack' => '%,object|'.$racetrack->getId().',%''racetrackId' => $racetrack->getId()]);
  502.       $total $racetrackNews->getTotalCount();
  503.       $racetrackNews $racetrackNews->setOrderKey(['date'])
  504.         ->setOrder(['desc'])
  505.         ->setLimit(5)
  506.         ->load();
  507.       return $this->renderTemplate('document/profiles/racetrack.html.twig', [
  508.           'racetrack' => $racetrack,
  509.           'racetrackNews' => $racetrackNews,
  510.           'racedays' => $racedays,
  511.           'now' => new Carbon(),
  512.           'offset' => $request->request->get('offset'0) + 5,
  513.           'total' => $total,
  514.           'pagination' => $pagination,
  515.           'filter' => $filter->createView(),
  516.         ]);
  517.     } else {
  518.       return $this->renderTemplate('document/profiles/racetrack.html.twig', [
  519.         'racetrack' => $racetrack,
  520.         'racetrackNews' => $racetrackNews,
  521.         'racedays' => $racedays,
  522.         'now' => new Carbon(),
  523.         // 'offset' => $request->request->get('offset', 0)+5,
  524.         'pagination' => $pagination,
  525.         'filter' => $filter->createView(),
  526.       ]);
  527.     }
  528.   }
  529.   /**
  530.    * @Route("/profile/{profileId}/stream/news/", name="profile_stream_news")
  531.    */
  532.   public function profileStreamNews(Request $request$profileId)
  533.   {
  534.     $profile DataObject::getById($profileId);
  535.     $increaseOffsetBy 5;
  536.     if (gettype($profile->getNews()) == 'object') {
  537.       $profilePath $profile->getNews()->getFullPath();
  538.       $news News::getList()
  539.       ->setCondition('o_path LIKE :folder', ['folder' => $profilePath.'%']);
  540.       $total $news->getTotalCount();
  541.       $offset = (int) $request->get('offset'$increaseOffsetBy);
  542.       $totalReached = ($total $offset $increaseOffsetBy);
  543.       $news $news->setOrderKey(['date'])
  544.         ->setOrder(['desc'])
  545.         ->setOffset($offset)
  546.         ->setLimit(5)
  547.         ->load();
  548.     } else {
  549.       $total count($profile->getNews());
  550.       $offset = (int) $request->get('offset'$increaseOffsetBy);
  551.       $totalReached = ($total $offset $increaseOffsetBy);
  552.       $news array_slice($profile->getNews(), $offset$increaseOffsetBy);
  553.     }
  554.     return $this->renderForm('document/profiles/news_list_stream.html.twig', [
  555.         'profile' => $profile,
  556.         'news' => $news,
  557.         'offset' => $offset $increaseOffsetBy,
  558.         'total' => $total,
  559.         'totalReached' => $totalReached,
  560.     ]);
  561.   }
  562. }