Boilerplate to use a Directus Instance to Build a Custom Website, Content will be Manage by Directus
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.1 KiB

3 years ago
  1. <?php
  2. namespace App\Controllers;
  3. use App\Controllers\DirectusControllerAbstract;
  4. use App\Repositories\SiteRepository;
  5. use App\Repositories\PostRepository;
  6. /**
  7. * controller for render feed of posts
  8. *
  9. *
  10. * @author Björn Hase, Tentakelfabrik
  11. * @license http://opensource.org/licenses/MIT The MIT License
  12. * @link https://gitea.tentakelfabrik.de/Tentakelfabrik/super-gear-directus
  13. *
  14. */
  15. class FeedController extends DirectusControllerAbstract
  16. {
  17. private $limit = 20;
  18. /**
  19. *
  20. */
  21. protected $page = [
  22. 'data' => [
  23. 'view' => 'rss'
  24. ]
  25. ];
  26. /**
  27. * get single page from slug
  28. *
  29. *
  30. * @param string $slug
  31. */
  32. public function indexAction()
  33. {
  34. $siteRepository = new SiteRepository();
  35. $site = $siteRepository->findOne();
  36. $postRepository = new PostRepository();
  37. $posts = $postRepository->find($this->limit);
  38. // change type
  39. header('Content-Type: text/xml');
  40. $this->render($this->page, [
  41. 'site' => $site,
  42. 'posts' => $posts
  43. ]);
  44. }
  45. }