159 lines
5.9 KiB
PHP
159 lines
5.9 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace App\Controller;
|
||
|
|
||
|
use App\Core\Controller\Admin\Crud\CrudController;
|
||
|
use App\Core\Crud\CrudConfiguration;
|
||
|
use App\Core\Crud\Field;
|
||
|
use App\Core\Entity\EntityInterface;
|
||
|
use App\Core\Manager\EntityManager;
|
||
|
use App\Entity\TeamContact as Entity;
|
||
|
use App\Factory\TeamContactFactory as Factory;
|
||
|
use App\Form\TeamContactType as Type;
|
||
|
use App\Repository\TeamContactRepositoryQuery as RepositoryQuery;
|
||
|
use Symfony\Component\HttpFoundation\Request;
|
||
|
use Symfony\Component\HttpFoundation\Response;
|
||
|
use Symfony\Component\HttpFoundation\Session\Session;
|
||
|
use Symfony\Component\Routing\Annotation\Route;
|
||
|
|
||
|
class TeamContactAdminController extends CrudController
|
||
|
{
|
||
|
/**
|
||
|
* @Route("/admin/team_contact/{page}", name="admin_team_contact_index", methods={"GET"}, requirements={"page":"\d+"})
|
||
|
*/
|
||
|
public function index(RepositoryQuery $query, Request $request, Session $session, int $page = 1): Response
|
||
|
{
|
||
|
return $this->doIndex($page, $query, $request, $session);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @Route("/admin/team_contact/new", name="admin_team_contact_new", methods={"GET", "POST"})
|
||
|
*/
|
||
|
public function new(Factory $factory, EntityManager $entityManager, Request $request): Response
|
||
|
{
|
||
|
return $this->doNew($factory->create(), $entityManager, $request);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @Route("/admin/team_contact/show/{entity}", name="admin_team_contact_show", methods={"GET"})
|
||
|
*/
|
||
|
public function show(Entity $entity): Response
|
||
|
{
|
||
|
return $this->doShow($entity);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @Route("/admin/team_contact/filter", name="admin_team_contact_filter", methods={"GET"})
|
||
|
*/
|
||
|
public function filter(Session $session): Response
|
||
|
{
|
||
|
return $this->doFilter($session);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @Route("/admin/team_contact/edit/{entity}", name="admin_team_contact_edit", methods={"GET", "POST"})
|
||
|
*/
|
||
|
public function edit(Entity $entity, EntityManager $entityManager, Request $request): Response
|
||
|
{
|
||
|
return $this->doEdit($entity, $entityManager, $request);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @Route("/admin/team_contact/sort/{page}", name="admin_team_contact_sort", methods={"POST"}, requirements={"page":"\d+"})
|
||
|
*/
|
||
|
public function sort(RepositoryQuery $query, EntityManager $entityManager, Request $request, Session $session, int $page = 1): Response
|
||
|
{
|
||
|
return $this->doSort($page, $query, $entityManager, $request, $session);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @Route("/admin/team_contact/batch/{page}", name="admin_team_contact_batch", methods={"POST"}, requirements={"page":"\d+"})
|
||
|
*/
|
||
|
public function batch(RepositoryQuery $query, EntityManager $entityManager, Request $request, Session $session, int $page = 1): Response
|
||
|
{
|
||
|
return $this->doBatch($page, $query, $entityManager, $request, $session);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @Route("/admin/team_contact/delete/{entity}", name="admin_team_contact_delete", methods={"DELETE"})
|
||
|
*/
|
||
|
public function delete(Entity $entity, EntityManager $entityManager, Request $request): Response
|
||
|
{
|
||
|
return $this->doDelete($entity, $entityManager, $request);
|
||
|
}
|
||
|
|
||
|
protected function getConfiguration(): CrudConfiguration
|
||
|
{
|
||
|
return CrudConfiguration::create()
|
||
|
->setPageTitle('index', 'Contacts')
|
||
|
->setPageTitle('edit', '{name}')
|
||
|
->setPageTitle('new', 'Nouveau contact')
|
||
|
->setPageTitle('show', '{name}')
|
||
|
|
||
|
->setPageRoute('index', 'admin_team_contact_index')
|
||
|
->setPageRoute('new', 'admin_team_contact_new')
|
||
|
->setPageRoute('edit', 'admin_team_contact_edit')
|
||
|
->setPageRoute('show', 'admin_team_contact_show')
|
||
|
->setPageRoute('sort', 'admin_team_contact_sort')
|
||
|
->setPageRoute('batch', 'admin_team_contact_batch')
|
||
|
->setPageRoute('delete', 'admin_team_contact_delete')
|
||
|
->setPageRoute('filter', 'admin_team_contact_filter')
|
||
|
|
||
|
->setForm('edit', Type::class, [])
|
||
|
->setForm('new', Type::class)
|
||
|
// ->setForm('filter', Type::class)
|
||
|
|
||
|
// ->setMaxPerPage('index', 20)
|
||
|
|
||
|
// ->setIsSortableCollection('index', false)
|
||
|
// ->setSortableCollectionProperty('sortOrder')
|
||
|
|
||
|
->setView('form', 'admin/team_contact/_form.html.twig')
|
||
|
|
||
|
// ->setAction('index', 'new', true)
|
||
|
->setAction('index', 'show', false)
|
||
|
// ->setAction('index', 'edit', true)
|
||
|
// ->setAction('index', 'delete', true)
|
||
|
|
||
|
// ->setAction('edit', 'back', true)
|
||
|
->setAction('edit', 'show', false)
|
||
|
// ->setAction('edit', 'delete', true)
|
||
|
|
||
|
// ->setAction('show', 'back', true)
|
||
|
// ->setAction('show', 'edit', true)
|
||
|
|
||
|
->setField('index', 'Nom', Field\TextField::class, [
|
||
|
'property' => 'name',
|
||
|
'attr' => ['class' => 'col-md-4'],
|
||
|
])
|
||
|
->setField('index', 'Téléphones', Field\TextField::class, [
|
||
|
'property_builder' => function(EntityInterface $entity) {
|
||
|
return implode("<br>", array_map(fn($e) => $e['value'], $entity->getPhones()));
|
||
|
},
|
||
|
'raw' => true,
|
||
|
'attr' => ['class' => 'col-md-4'],
|
||
|
])
|
||
|
->setField('index', 'Emails', Field\TextField::class, [
|
||
|
'property_builder' => function(EntityInterface $entity) {
|
||
|
return implode("<br>", array_map(fn($e) => $e['value'], $entity->getEmails()));
|
||
|
},
|
||
|
'raw' => true,
|
||
|
'attr' => ['class' => 'col-md-4'],
|
||
|
])
|
||
|
|
||
|
// ->setField('index', 'Foo', Field\TextField::class, [
|
||
|
// 'property' => 'foo',
|
||
|
// ])
|
||
|
|
||
|
// ->setBatchAction('index', 'delete', 'Delete', function(EntityInterface $entity, EntityManager $manager) {
|
||
|
// $manager->delete($entity);
|
||
|
// })
|
||
|
;
|
||
|
}
|
||
|
|
||
|
protected function getSection(): string
|
||
|
{
|
||
|
return 'team_contact';
|
||
|
}
|
||
|
}
|