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.
super-gear-directus/app/Controllers/PostController.php

37 lines
805 B

3 years ago
<?php
namespace App\Controllers;
use App\Controllers\DirectusControllerAbstract;
use App\Repositories\PostRepository;
/**
* controller for page items from directus
*
*
* @author Björn Hase, Tentakelfabrik
* @license http://opensource.org/licenses/MIT The MIT License
* @link https://gitea.tentakelfabrik.de/Tentakelfabrik/super-gear-directus
*
*/
class PostController extends DirectusControllerAbstract
{
/**
* get single page from slug
*
*
* @param string $slug
*/
public function getAction($slug)
{
$repository = new PostRepository();
$post = $repository->findOneBySlug($slug);
if (count($post['data']) === 0) {
$this->app->redirect('/404');
} else {
$this->render($post);
}
}
}