mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-10-03 20:09:42 +00:00
Fix visibility of EntityManager parameter in child classes
This commit is contained in:
@@ -12,8 +12,10 @@ declare(strict_types=1);
|
||||
namespace Chill\PersonBundle\CRUD\Controller;
|
||||
|
||||
use Chill\MainBundle\CRUD\Controller\CRUDController;
|
||||
use Chill\MainBundle\CRUD\Controller\string;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
@@ -23,9 +25,9 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
*/
|
||||
class EntityPersonCRUDController extends CRUDController
|
||||
{
|
||||
public function __construct(protected readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) {}
|
||||
public function __construct(protected ManagerRegistry $managerRegistry) {}
|
||||
|
||||
protected function generateTemplateParameter(string $action, mixed $entity, Request $request, array $defaultTemplateParameters = [])
|
||||
protected function generateTemplateParameter(string $action, mixed $entity, Request $request, array $defaultTemplateParameters = []): array
|
||||
{
|
||||
$templateParameters = parent::generateTemplateParameter($action, $entity, $request, $defaultTemplateParameters);
|
||||
|
||||
@@ -36,20 +38,15 @@ class EntityPersonCRUDController extends CRUDController
|
||||
|
||||
/**
|
||||
* Override the base method to add a filtering step to a person.
|
||||
*
|
||||
* @return QueryBuilder
|
||||
*/
|
||||
protected function buildQueryEntities(string $action, Request $request): \Doctrine\ORM\QueryBuilder
|
||||
protected function buildQueryEntities(string $action, Request $request): QueryBuilder
|
||||
{
|
||||
$qb = parent::buildQueryEntities($action, $request);
|
||||
|
||||
return $this->filterQueryEntitiesByPerson($action, $qb, $request);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Chill\MainBundle\CRUD\Controller\string|string $action
|
||||
*/
|
||||
protected function createEntity($action, Request $request): object
|
||||
protected function createEntity(string $action, Request $request): object
|
||||
{
|
||||
$entity = parent::createEntity($action, $request);
|
||||
|
||||
@@ -63,9 +60,10 @@ class EntityPersonCRUDController extends CRUDController
|
||||
/**
|
||||
* Add a where clause to the buildQuery.
|
||||
*
|
||||
* @param \Chill\PersonBundle\CRUD\Controller\QueryBuilder $qb
|
||||
*
|
||||
* @return \Chill\PersonBundle\CRUD\Controller\QueryBuilder
|
||||
* @param string $action
|
||||
* @param QueryBuilder $qb
|
||||
* @param Request $request
|
||||
* @return QueryBuilder
|
||||
*/
|
||||
protected function filterQueryEntitiesByPerson(string $action, QueryBuilder $qb, Request $request): QueryBuilder
|
||||
{
|
||||
@@ -137,10 +135,6 @@ class EntityPersonCRUDController extends CRUDController
|
||||
'save-and-new' => $this->redirectToRoute('chill_crud_'.$this->getCrudName().'_new', [
|
||||
'person_id' => $this->getPerson($request)->getId(),
|
||||
]),
|
||||
'new' => $this->redirectToRoute('chill_crud_'.$this->getCrudName().'_view', [
|
||||
'id' => $entity->getId(),
|
||||
'person_id' => $this->getPerson($request)->getId(),
|
||||
]),
|
||||
default => $this->redirectToRoute('chill_crud_'.$this->getCrudName().'_view', [
|
||||
'id' => $entity->getId(),
|
||||
'person_id' => $this->getPerson($request)->getId(),
|
||||
|
@@ -13,6 +13,7 @@ namespace Chill\PersonBundle\CRUD\Controller;
|
||||
|
||||
use Chill\MainBundle\CRUD\Controller\CRUDController;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@@ -20,7 +21,7 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class OneToOneEntityPersonCRUDController extends CRUDController
|
||||
{
|
||||
public function __construct(private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) {}
|
||||
public function __construct(protected ManagerRegistry $managerRegistry) {}
|
||||
|
||||
protected function generateRedirectOnCreateRoute($action, Request $request, $entity): string
|
||||
{
|
||||
@@ -67,7 +68,7 @@ class OneToOneEntityPersonCRUDController extends CRUDController
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function onPreFlush(string $action, $entity, FormInterface $form, Request $request)
|
||||
protected function onPreFlush(string $action, $entity, FormInterface $form, Request $request): void
|
||||
{
|
||||
$this->managerRegistry->getManager()->persist($entity);
|
||||
}
|
||||
|
Reference in New Issue
Block a user