deblan.io-murph/src/Controller/Blog/CommentAdminController.php

109 lines
3.5 KiB
PHP

<?php
namespace App\Controller\Blog;
use App\Core\Controller\Admin\AdminController;
use App\Core\Manager\EntityManager;
use App\Entity\Blog\Comment as Entity;
use App\Form\Blog\CommentType as EntityType;
use App\Form\Blog\Filter\CommentFilterType;
use App\Repository\Blog\CommentRepositoryQuery as RepositoryQuery;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\Routing\Annotation\Route;
use App\Core\Controller\Admin\Crud\CrudController;
use App\Core\Crud\CrudConfiguration;
use App\Core\Crud\Field\DatetimeField;
use App\Core\Crud\Field\TextField;
use App\Form\Blog\CommentType;
/**
* @Route("/admin/blog/comment")
*/
class CommentAdminController extends CrudController
{
public function getConfiguration(): CrudConfiguration
{
return CrudConfiguration::create()
->setPageTitle('index', 'Commentaire')
->setPageTitle('edit', 'Par {author}')
->setPageTitle('show', 'Par {author}')
->setPageRoute('index', 'admin_blog_comment_index')
->setPageRoute('edit', 'admin_blog_comment_edit')
->setPageRoute('show', 'admin_blog_comment_show')
->setPageRoute('delete', 'admin_blog_comment_delete')
->setPageRoute('filter', 'admin_blog_comment_filter')
->setForm('edit', CommentType::class, [])
->setForm('filter', CommentFilterType::class, [])
->setAction('index', 'new', false)
->setView('show_entity', 'blog/comment_admin/_show.html.twig')
->setView('form', 'blog/comment_admin/_form.html.twig')
->setField('index', 'Auteur', TextField::class, [
'view' => 'blog/comment_admin/field/author.html.twig',
'attr' => ['class' => 'miw-300'],
])
->setField('index', 'Date', DatetimeField::class, [
'property' => 'createdAt',
'attr' => ['class' => 'miw-200'],
])
->setField('index', 'Status', TextField::class, [
'view' => 'blog/comment_admin/field/status.html.twig',
'attr' => ['class' => 'miw-100'],
])
;
}
/**
* @Route("/{page}", name="admin_blog_comment_index", requirements={"page": "\d+"})
*/
public function index(int $page = 1, RepositoryQuery $query, Request $request, Session $session): Response
{
$query->orderBy('.id', 'DESC');
return $this->doIndex($page, $query, $request, $session);
}
/**
* @Route("/edit/{entity}", name="admin_blog_comment_edit")
*/
public function edit(Entity $entity, EntityManager $entityManager, Request $request): Response
{
return $this->doEdit($entity, $entityManager, $request);
}
/**
* @Route("/show/{entity}", name="admin_blog_comment_show")
*/
public function show(Entity $entity): Response
{
return $this->doShow($entity);
}
/**
* @Route("/filters", name="admin_blog_comment_filter")
*/
public function filter(Session $session): Response
{
return $this->doFilter($session);
}
/**
* @Route("/delete/{entity}", name="admin_blog_comment_delete", methods={"DELETE"})
*/
public function delete(Entity $entity, EntityManager $entityManager, Request $request): Response
{
return $this->doDelete($entity, $entityManager, $request);
}
public function getSection(): string
{
return 'blog_comment';
}
}