kernel
This commit is contained in:
parent
6d38f62e8d
commit
91dc9194e0
@ -2,4 +2,7 @@ DB_HOST=localhost
|
||||
DB_USER=root
|
||||
DB_DRIVER=mysql
|
||||
DB_PASSWORD=123edsaqw
|
||||
DB_NAME=mfw
|
||||
DB_NAME=mfw
|
||||
|
||||
VIEWS_PATH=/views
|
||||
VIEWS_CACHE_PATH=/views_cache
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,4 +1,4 @@
|
||||
.idea
|
||||
vendor
|
||||
.env
|
||||
cache
|
||||
views_cache
|
@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\controllers;
|
||||
|
||||
class Controller
|
||||
{
|
||||
protected \Twig\Loader\FilesystemLoader $loader;
|
||||
protected \Twig\Environment $twig;
|
||||
public function __construct()
|
||||
{
|
||||
$this->loader = new \Twig\Loader\FilesystemLoader(__DIR__.'/../views');
|
||||
$this->twig = new \Twig\Environment($this->loader, ['cache' => 'app/views/cache']);
|
||||
}
|
||||
}
|
@ -2,12 +2,13 @@
|
||||
namespace app\controllers;
|
||||
|
||||
use app\models\Question;
|
||||
use kernel\Controller;
|
||||
|
||||
|
||||
class QuestionController extends Controller{
|
||||
public function actionCreate()
|
||||
{
|
||||
echo $this->twig->render('questionCreate.html');
|
||||
echo $this->twig->render('question_create.html.twig');
|
||||
}
|
||||
|
||||
public function actionGetQuestionsWithAnswers(): array
|
||||
|
@ -2,9 +2,9 @@
|
||||
namespace app\controllers;
|
||||
|
||||
|
||||
use app\helpers\Debug;
|
||||
use app\models\Question;
|
||||
use app\models\User;
|
||||
use kernel\Controller;
|
||||
|
||||
class UserController extends Controller{
|
||||
public function actionCreate(): void
|
||||
|
@ -11,7 +11,8 @@
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"app\\": "app/",
|
||||
"migrations\\": "migrations/"
|
||||
"migrations\\": "migrations/",
|
||||
"kernel\\": "kernel/"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
24
index.php
24
index.php
@ -27,18 +27,18 @@ $router->group(["prefix" => "admin"], function (RouteCollector $router){
|
||||
$router->post("/", [\app\controllers\UserController::class, 'actionAdd']);
|
||||
$router->post("/edit", [\app\controllers\UserController::class, 'actionEdit']);
|
||||
});
|
||||
// $router->group(["prefix" => "question"], function (RouteCollector $router){
|
||||
// $router->get('/create', [QuestionController::class, 'actionCreate']);
|
||||
// $router->get('/update', [QuestionController::class, 'actionUpdate']);
|
||||
// $router->get('/delete/{id}', [QuestionController::class, 'actionDelete']);
|
||||
// $router->get('/', [QuestionController::class, 'actionIndex']);
|
||||
// $router->get('/{id}', [QuestionController::class, 'actionView']);
|
||||
// $router->post("/", [QuestionController::class, 'actionAdd']);
|
||||
// $router->post("/edit", [QuestionController::class, 'actionEdit']);
|
||||
// });
|
||||
// $router->group(["prefix" => "post"], function (RouteCollector $router){
|
||||
// $router->get('/', [\app\controllers\PostController::class, 'actionIndex']);
|
||||
// });
|
||||
$router->group(["prefix" => "question"], function (RouteCollector $router){
|
||||
$router->get('/create', [QuestionController::class, 'actionCreate']);
|
||||
$router->get('/update', [QuestionController::class, 'actionUpdate']);
|
||||
$router->get('/delete/{id}', [QuestionController::class, 'actionDelete']);
|
||||
$router->get('/', [QuestionController::class, 'actionIndex']);
|
||||
$router->get('/{id}', [QuestionController::class, 'actionView']);
|
||||
$router->post("/", [QuestionController::class, 'actionAdd']);
|
||||
$router->post("/edit", [QuestionController::class, 'actionEdit']);
|
||||
});
|
||||
$router->group(["prefix" => "post"], function (RouteCollector $router){
|
||||
$router->get('/', [\app\controllers\PostController::class, 'actionIndex']);
|
||||
});
|
||||
});
|
||||
|
||||
$router->get('/allQuestions', [QuestionController::class, 'actionViewAllQuestions']);
|
||||
|
15
kernel/Controller.php
Normal file
15
kernel/Controller.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace kernel;
|
||||
|
||||
class Controller
|
||||
{
|
||||
protected \Twig\Loader\FilesystemLoader $loader;
|
||||
protected \Twig\Environment $twig;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->loader = new \Twig\Loader\FilesystemLoader(ROOT_DIR . $_ENV['VIEWS_PATH']);
|
||||
$this->twig = new \Twig\Environment($this->loader, ['cache' => ROOT_DIR . $_ENV['VIEWS_CACHE_PATH']]);
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
{% extends "mainLayout.html" %}
|
||||
{% extends "main_layout.html.twig" %}
|
||||
|
||||
{% block content %}
|
||||
<form action="/admin/question" method="post">
|
Loading…
Reference in New Issue
Block a user