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.

36 lines
805 B

3 years ago
  1. <?php
  2. namespace App\Controllers;
  3. use App\Controllers\DirectusControllerAbstract;
  4. use App\Repositories\PostRepository;
  5. /**
  6. * controller for page items from directus
  7. *
  8. *
  9. * @author Björn Hase, Tentakelfabrik
  10. * @license http://opensource.org/licenses/MIT The MIT License
  11. * @link https://gitea.tentakelfabrik.de/Tentakelfabrik/super-gear-directus
  12. *
  13. */
  14. class PostController extends DirectusControllerAbstract
  15. {
  16. /**
  17. * get single page from slug
  18. *
  19. *
  20. * @param string $slug
  21. */
  22. public function getAction($slug)
  23. {
  24. $repository = new PostRepository();
  25. $post = $repository->findOneBySlug($slug);
  26. if (count($post['data']) === 0) {
  27. $this->app->redirect('/404');
  28. } else {
  29. $this->render($post);
  30. }
  31. }
  32. }