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.
 
 

75 lines
1.4 KiB

<?php
namespace App\Controllers;
use SuperGear\Directus\Controllers\ControllerAbstract;
use SuperGear\Repositories\Manager;
/**
* controller for page items from directus
*
*
*
* @author Björn Hase
* @license http://opensource.org/licenses/MIT The MIT License
* @link https://gitlab.tentakelfabrik.de/super-gear/directus GitHub Repository
*
*/
class PageController extends ControllerAbstract
{
/** slug for home */
const HOME_SLUG = 'home';
/** default view */
protected $defaultView = 'page/default';
/**
* get home page from slug
*
*
*/
public function indexAction()
{
$repository = Manager::get('Page');
$page = $repository->findOneBySlug(self::HOME_SLUG);
if ($this->notFound($page)) {
$this->app->redirect('404');
}
$this->render($page);
}
/**
* get single page from slug
*
*
* @param string $slug
*/
public function getAction($slug)
{
$repository = Manager::get('Page');
$page = $repository->findOneBySlug($slug);
if ($this->notFound($page)) {
$this->app->redirect('404');
}
$this->render($page);
}
/**
* if page not found
*
*/
public function notFoundAction()
{
$page = [
'data' => [
'view' => 'page/404'
]
];
$this->render($page);
}
}