Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
53 lines (41 sloc) 1.38 KB
<?php
namespace App\Kernel;
use DIMicroKernel\Kernel;
/**
* @author Michael Mayer <michael@liquidbytes.net>
* @license MIT
*/
class WebApp extends Kernel
{
protected $urlPrefix = '';
public function __construct($appPath, $debug = false)
{
parent::__construct('web', $appPath, $debug);
}
public function init()
{
if ($this->debug) {
ini_set('display_errors', 1);
}
}
public function getUrlPrefix($urlPrefixPostfix = ''): string
{
return $this->urlPrefix . $urlPrefixPostfix;
}
public function setUrlPrefix(string $urlPrefix)
{
$this->urlPrefix = $urlPrefix;
}
protected function setUp()
{
$container = $this->getContainer();
// The error router catches errors and displays them as error pages
$container->get('router.error')->route();
// Routing for REST API calls
$container->get('router.rest')->route($this->getUrlPrefix('/api/v1'), 'controller.rest.v1.');
// All other requests are routed to a default controller action (client-side routing e.g. with Vue.js)
$container->get('router.twig_default')->route($this->getUrlPrefix(), 'controller.web.index', 'index');
// Uncomment the following line to enable server-side routing
// $container->get('router.twig')->route($this->getUrlPrefix(), 'controller.web.');
}
}
You can’t perform that action at this time.