2021-03-30 19:35:49 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Controller\Blog;
|
|
|
|
|
2021-06-03 14:04:39 +02:00
|
|
|
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\Core\Entity\EntityInterface;
|
2021-03-30 19:35:49 +02:00
|
|
|
use App\Core\Manager\EntityManager;
|
|
|
|
use App\Entity\Blog\Comment as Entity;
|
2021-06-03 14:04:39 +02:00
|
|
|
use App\Form\Blog\CommentType;
|
2021-03-30 20:40:36 +02:00
|
|
|
use App\Form\Blog\Filter\CommentFilterType;
|
2021-03-30 19:35:49 +02:00
|
|
|
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;
|
|
|
|
|
2022-11-19 20:42:30 +01:00
|
|
|
#[Route(path: '/admin/blog/comment')]
|
2021-05-12 15:24:43 +02:00
|
|
|
class CommentAdminController extends CrudController
|
2021-03-30 19:35:49 +02:00
|
|
|
{
|
2021-05-12 15:24:43 +02:00
|
|
|
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')
|
2021-06-03 13:57:57 +02:00
|
|
|
->setPageRoute('batch', 'admin_blog_comment_batch')
|
2021-05-12 15:24:43 +02:00
|
|
|
|
|
|
|
->setForm('edit', CommentType::class, [])
|
|
|
|
->setForm('filter', CommentFilterType::class, [])
|
|
|
|
|
|
|
|
->setAction('index', 'new', false)
|
|
|
|
|
2021-05-13 17:33:09 +02:00
|
|
|
->setView('show_entity', 'blog/comment_admin/_show.html.twig')
|
|
|
|
->setView('form', 'blog/comment_admin/_form.html.twig')
|
2021-05-12 15:24:43 +02:00
|
|
|
|
2021-05-15 18:30:31 +02:00
|
|
|
->setDefaultSort('index', 'createdAt', 'desc')
|
|
|
|
|
2021-05-12 15:24:43 +02:00
|
|
|
->setField('index', 'Auteur', TextField::class, [
|
|
|
|
'view' => 'blog/comment_admin/field/author.html.twig',
|
2021-05-15 18:30:31 +02:00
|
|
|
'sort' => ['author', '.author'],
|
2021-05-12 15:24:43 +02:00
|
|
|
'attr' => ['class' => 'miw-300'],
|
|
|
|
])
|
|
|
|
->setField('index', 'Date', DatetimeField::class, [
|
|
|
|
'property' => 'createdAt',
|
2021-05-15 18:30:31 +02:00
|
|
|
'sort' => ['createdAt', '.createdAt'],
|
2021-05-12 15:24:43 +02:00
|
|
|
'attr' => ['class' => 'miw-200'],
|
|
|
|
])
|
|
|
|
->setField('index', 'Status', TextField::class, [
|
|
|
|
'view' => 'blog/comment_admin/field/status.html.twig',
|
|
|
|
'attr' => ['class' => 'miw-100'],
|
|
|
|
])
|
2021-06-03 13:57:57 +02:00
|
|
|
|
2021-06-03 14:04:39 +02:00
|
|
|
->setBatchAction('index', 'delete', 'Delete', function (EntityInterface $entity, EntityManager $manager) {
|
2021-06-03 13:57:57 +02:00
|
|
|
$manager->delete($entity);
|
|
|
|
})
|
2021-05-12 15:24:43 +02:00
|
|
|
;
|
|
|
|
}
|
2021-03-30 19:35:49 +02:00
|
|
|
|
2022-11-19 20:42:30 +01:00
|
|
|
#[Route(path: '/{page}', name: 'admin_blog_comment_index', requirements: ['page' => '\d+'])]
|
2022-01-23 17:22:59 +01:00
|
|
|
public function index(RepositoryQuery $query, Request $request, Session $session, int $page = 1): Response
|
2021-03-30 19:35:49 +02:00
|
|
|
{
|
2021-05-12 15:24:43 +02:00
|
|
|
return $this->doIndex($page, $query, $request, $session);
|
2021-03-30 19:35:49 +02:00
|
|
|
}
|
|
|
|
|
2022-11-19 20:42:30 +01:00
|
|
|
#[Route(path: '/edit/{entity}', name: 'admin_blog_comment_edit')]
|
2021-03-30 19:35:49 +02:00
|
|
|
public function edit(Entity $entity, EntityManager $entityManager, Request $request): Response
|
|
|
|
{
|
2021-05-12 15:24:43 +02:00
|
|
|
return $this->doEdit($entity, $entityManager, $request);
|
2021-03-30 19:35:49 +02:00
|
|
|
}
|
|
|
|
|
2022-11-19 20:42:30 +01:00
|
|
|
#[Route(path: '/show/{entity}', name: 'admin_blog_comment_show')]
|
2021-03-30 19:35:49 +02:00
|
|
|
public function show(Entity $entity): Response
|
|
|
|
{
|
2021-05-12 15:24:43 +02:00
|
|
|
return $this->doShow($entity);
|
2021-03-30 19:35:49 +02:00
|
|
|
}
|
|
|
|
|
2022-11-19 20:42:30 +01:00
|
|
|
#[Route(path: '/filters', name: 'admin_blog_comment_filter')]
|
2021-05-12 15:24:43 +02:00
|
|
|
public function filter(Session $session): Response
|
2021-03-30 19:35:49 +02:00
|
|
|
{
|
2021-05-12 15:24:43 +02:00
|
|
|
return $this->doFilter($session);
|
2021-03-30 19:35:49 +02:00
|
|
|
}
|
|
|
|
|
2022-11-19 20:42:30 +01:00
|
|
|
#[Route(path: '/delete/{entity}', name: 'admin_blog_comment_delete', methods: ['DELETE'])]
|
2021-03-30 19:35:49 +02:00
|
|
|
public function delete(Entity $entity, EntityManager $entityManager, Request $request): Response
|
|
|
|
{
|
2021-05-12 15:24:43 +02:00
|
|
|
return $this->doDelete($entity, $entityManager, $request);
|
2021-03-30 19:35:49 +02:00
|
|
|
}
|
|
|
|
|
2022-11-19 20:42:30 +01:00
|
|
|
#[Route(path: '/admin/blog_comment/batch/{page}', name: 'admin_blog_comment_batch', methods: ['POST'], requirements: ['page' => '\d+'])]
|
2022-01-23 17:22:59 +01:00
|
|
|
public function batch(RepositoryQuery $query, EntityManager $entityManager, Request $request, Session $session, int $page = 1): Response
|
2021-06-03 13:57:57 +02:00
|
|
|
{
|
|
|
|
return $this->doBatch($page, $query, $entityManager, $request, $session);
|
|
|
|
}
|
|
|
|
|
2021-03-30 19:35:49 +02:00
|
|
|
public function getSection(): string
|
|
|
|
{
|
|
|
|
return 'blog_comment';
|
|
|
|
}
|
|
|
|
}
|