1
0
Fork 0

Base of admin panel

This commit is contained in:
Ethanell 2021-01-16 16:04:30 +01:00
parent bdaa255e98
commit 1a03203d01
12 changed files with 41 additions and 84 deletions

View file

@ -17,28 +17,4 @@ class AdminController extends AbstractController
'controller_name' => 'AdminController',
]);
}
/**
* @Route("/admin/posts", name="posts")
*/
public function posts(): Response
{
}
/**
* @Route("/admin/categories", name="categories")
*/
public function categories(): Response
{
}
/**
* @Route("/admin/comments", name="comments")
*/
public function comments(): Response
{
}
}

View file

@ -10,18 +10,19 @@ use Symfony\Component\Routing\Annotation\Route;
class CategoryController extends AbstractController
{
/**
* @Route("/category", name="category")
* @Route("/admin/categories", name="categories")
*/
public function index(): Response
{
return $this->render('category/index.html.twig', [
return $this->render('category/categories.html.twig', [
'controller_name' => 'CategoryController',
'categories' => $this->getDoctrine()->getRepository(Category::class)->findAll()
]);
}
public function categorySummary(): Response
{
return $this->render('category_summary.html.twig', [
return $this->render('category/category_summary.html.twig', [
'controller_name' => 'CategoryController',
'Categories' => array_filter($this->getDoctrine()->getRepository(Category::class)->findAll(), static function ($c) {return count($c->getPosts())>=1;})
]);

View file

@ -10,18 +10,19 @@ use Symfony\Component\Routing\Annotation\Route;
class CommentController extends AbstractController
{
/**
* @Route("/comment", name="comment")
* @Route("/admin/comments", name="comments")
*/
public function index(): Response
{
return $this->render('comment/index.html.twig', [
return $this->render('comment/comments.html.twig', [
'controller_name' => 'CommentController',
'comments' => $this->getDoctrine()->getRepository(Comment::class)->findAll()
]);
}
public function recentComment(): Response
{
return $this->render('recent_comment.html.twig', [
return $this->render('comment/recent_comment.html.twig', [
'controller_name' => 'CommentController',
'comments' => $this->getDoctrine()->getRepository(Comment::class)->findBy(array('valid' => true), array('createdAt' => 'DESC'), 5, 0)
]);

View file

@ -40,6 +40,17 @@ class PostController extends AbstractController
]);
}
/**
* @Route("/admin/posts", name="posts")
*/
public function posts(): Response
{
return $this->render('post/posts.html.twig', [
'controller_name' => 'PostController',
'posts' => $this->getDoctrine()->getRepository(Post::class)->findAll()
]);
}
private function formGenerator(Post $post) : FormInterface
{
$comment = new Comment();

View file

@ -3,18 +3,5 @@
{% block title %}Hello AdminController!{% endblock %}
{% block body %}
<style>
.example-wrapper { margin: 1em auto; max-width: 800px; width: 95%; font: 18px/1.5 sans-serif; }
.example-wrapper code { background: #F5F5F5; padding: 2px 6px; }
</style>
<div class="example-wrapper">
<h1>Hello {{ controller_name }}! ✅</h1>
This friendly message is coming from:
<ul>
<li>Your controller at <code><a href="{{ '/home/flifloo/Nextcloud/IUT/PHP Avancée/blog/src/Controller/AdminController.php'|file_link(0) }}">src/Controller/AdminController.php</a></code></li>
<li>Your template at <code><a href="{{ '/home/flifloo/Nextcloud/IUT/PHP Avancée/blog/templates/admin/index.html.twig'|file_link(0) }}">templates/admin/index.html.twig</a></code></li>
</ul>
</div>
<h1 class="text-center">Admin panel</h1>
{% endblock %}

View file

@ -0,0 +1,7 @@
{% extends 'admin/base-admin.html.twig' %}
{% block title %}Hello AdminController!{% endblock %}
{% block body %}
{% endblock %}

View file

@ -0,0 +1,7 @@
{% extends 'admin/base-admin.html.twig' %}
{% block title %}Hello AdminController!{% endblock %}
{% block body %}
{% endblock %}

View file

@ -1,20 +0,0 @@
{% extends 'base.html.twig' %}
{% block title %}Hello CategoryController!{% endblock %}
{% block body %}
<style>
.example-wrapper { margin: 1em auto; max-width: 800px; width: 95%; font: 18px/1.5 sans-serif; }
.example-wrapper code { background: #F5F5F5; padding: 2px 6px; }
</style>
<div class="example-wrapper">
<h1>Hello {{ controller_name }}! ✅</h1>
This friendly message is coming from:
<ul>
<li>Your controller at <code><a href="{{ '/home/flifloo/Nextcloud/IUT/PHP Avancée/blog/src/Controller/CategoryController.php'|file_link(0) }}">src/Controller/CategoryController.php</a></code></li>
<li>Your template at <code><a href="{{ '/home/flifloo/Nextcloud/IUT/PHP Avancée/blog/templates/category/index.html.twig'|file_link(0) }}">templates/category/index.html.twig</a></code></li>
</ul>
</div>
{% endblock %}

View file

@ -0,0 +1,7 @@
{% extends 'admin/base-admin.html.twig' %}
{% block title %}Hello AdminController!{% endblock %}
{% block body %}
{% endblock %}

View file

@ -1,20 +0,0 @@
{% extends 'base.html.twig' %}
{% block title %}Hello CommentController!{% endblock %}
{% block body %}
<style>
.example-wrapper { margin: 1em auto; max-width: 800px; width: 95%; font: 18px/1.5 sans-serif; }
.example-wrapper code { background: #F5F5F5; padding: 2px 6px; }
</style>
<div class="example-wrapper">
<h1>Hello {{ controller_name }}! ✅</h1>
This friendly message is coming from:
<ul>
<li>Your controller at <code><a href="{{ '/home/flifloo/Nextcloud/IUT/PHP Avancée/blog/src/Controller/CommentController.php'|file_link(0) }}">src/Controller/CommentController.php</a></code></li>
<li>Your template at <code><a href="{{ '/home/flifloo/Nextcloud/IUT/PHP Avancée/blog/templates/comment/index.html.twig'|file_link(0) }}">templates/comment/index.html.twig</a></code></li>
</ul>
</div>
{% endblock %}