You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.1 KiB
PHP
59 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers;
|
|
|
|
use App\Services\View;
|
|
|
|
/**
|
|
* BaseController
|
|
*/
|
|
class BaseController
|
|
{
|
|
/**
|
|
* @var \Smarty
|
|
*/
|
|
protected $view;
|
|
|
|
/**
|
|
* @var \Slim\Views\PhpRenderer
|
|
*/
|
|
protected $renderer;
|
|
|
|
/**
|
|
* @var \App\Models\User
|
|
*/
|
|
protected $user;
|
|
|
|
/**
|
|
* Construct page renderer
|
|
*/
|
|
public function __construct(\Slim\Container $container)
|
|
{
|
|
$this->view = View::getSmarty();
|
|
$this->user = Auth::getUser();
|
|
|
|
// TODO
|
|
$this->renderer = $container->get('renderer');
|
|
|
|
if ($this->user->isLogin) {
|
|
define('TEMPLATE_PATH', BASE_PATH . '/templates/views/' . $this->user->theme . '/');
|
|
} else {
|
|
define('TEMPLATE_PATH', BASE_PATH . '/templates/views/' . $_ENV['theme'] . '/');
|
|
}
|
|
|
|
$this->renderer->setTemplatePath(TEMPLATE_PATH);
|
|
$this->renderer->addAttribute('user', $this->user);
|
|
}
|
|
|
|
|
|
/**
|
|
* @param $response
|
|
* @param $res
|
|
* @return mixed
|
|
*/
|
|
public function echoJson($response, $res)
|
|
{
|
|
return $response->getBody()->write(json_encode($res));
|
|
}
|
|
}
|