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/PageController.php

58 lines
1.2 KiB

<?php
namespace App\Controllers;
use App\Controllers\DirectusControllerAbstract;
3 years ago
use App\Repositories\PageRepository;
/**
* 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 PageController extends DirectusControllerAbstract
{
/** default view */
protected $defaultView = 'page/default';
/** 404 */
protected $page404 = [
'data' => [
'title' => '404',
3 years ago
'slug' => '404',
'view' => 'page/404'
]
];
/**
* get single page from slug
*
*
* @param string $slug
*/
public function getAction($slug = NULL)
{
3 years ago
$pageRepository = new PageRepository();
$page = $pageRepository->findOneBySlug($slug);
3 years ago
if (count($page['data']) === 0) {
3 years ago
$this->app->redirect('/404');
} else {
$this->render($page);
}
}
/**
* if page not found
*
*/
public function notFoundAction()
{
$this->render($this->page404);
}
}