|
|
@@ -66,8 +66,6 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
abstract public function getRepositoryQuery(): RepositoryQueryInterface; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function configureResponseParameters(KeyValueStore $responseParameters): KeyValueStore |
|
|
|
{ |
|
|
|
if ($responseParameters->get('global_actions')) { |
|
|
@@ -184,9 +182,15 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
if ($requestListMaxResults) { |
|
|
|
$this->getRequestStack()->getSession()->set($paramSessionListMaxResults, $requestListMaxResults); |
|
|
|
} |
|
|
|
$maxResults = $this->getRequestStack()->getSession()->get($paramSessionListMaxResults) ? $this->get('session')->get( |
|
|
|
|
|
|
|
$maxResults = $this->getRequestStack()->getSession()->get( |
|
|
|
$paramSessionListMaxResults |
|
|
|
) : 30; |
|
|
|
) ? $this->requestStack->getSession()->get($paramSessionListMaxResults) : 30; |
|
|
|
// $maxResults = $this->getRequestStack()->getSession()->get($paramSessionListMaxResults) ? $this->get( |
|
|
|
// 'session' |
|
|
|
// )->get( |
|
|
|
// $paramSessionListMaxResults |
|
|
|
// ) : 30; |
|
|
|
|
|
|
|
$crud->setPaginatorPageSize($maxResults); |
|
|
|
} |
|
|
@@ -247,7 +251,10 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
$queryBuilder = $this->createSortQueryBuilder($context->getSearch(), $context->getEntity(), $fields, $filters); |
|
|
|
$paginator = $this->container->get(PaginatorFactory::class)->create($queryBuilder); |
|
|
|
|
|
|
|
$entities = $this->container->get(EntityFactory::class)->createCollection($context->getEntity(), $paginator->getResults()); |
|
|
|
$entities = $this->container->get(EntityFactory::class)->createCollection( |
|
|
|
$context->getEntity(), |
|
|
|
$paginator->getResults() |
|
|
|
); |
|
|
|
$this->container->get(EntityFactory::class)->processFieldsForAll($entities, $fields); |
|
|
|
|
|
|
|
$sortableForm = $this->createFormBuilder(array('entities', $paginator->getResults())) |
|
|
@@ -320,12 +327,11 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
} |
|
|
|
|
|
|
|
public function duplicate( |
|
|
|
AdminContext $context, |
|
|
|
EntityComponent $entityComponent, |
|
|
|
TranslatorAdmin $translatorAdmin, |
|
|
|
AdminContext $context, |
|
|
|
EntityComponent $entityComponent, |
|
|
|
TranslatorAdmin $translatorAdmin, |
|
|
|
EntityManagerInterface $em |
|
|
|
) |
|
|
|
{ |
|
|
|
) { |
|
|
|
if (!$this->isGranted( |
|
|
|
Permission::EA_EXECUTE_ACTION, |
|
|
|
['action' => ActionDefinition::DUPLICATE, 'entity' => $context->getEntity()] |
|
|
@@ -361,12 +367,11 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
} |
|
|
|
|
|
|
|
public function createIndexRepositoryQuery( |
|
|
|
SearchDto $searchDto, |
|
|
|
EntityDto $entityDto, |
|
|
|
FieldCollection $fields, |
|
|
|
SearchDto $searchDto, |
|
|
|
EntityDto $entityDto, |
|
|
|
FieldCollection $fields, |
|
|
|
FilterCollection $filters |
|
|
|
): RepositoryQueryInterface |
|
|
|
{ |
|
|
|
): RepositoryQueryInterface { |
|
|
|
$repositoryQuery = $this->container->get(EntityRepository::class)->createRepositoryQuery( |
|
|
|
$this->getRepositoryQuery(), |
|
|
|
$searchDto, |
|
|
@@ -401,18 +406,22 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
$filterManager = $this->getFilterManager(); |
|
|
|
|
|
|
|
$this->filtersForm->handleRequest($searchDto->getRequest()); |
|
|
|
$this->isRepositoryQueryFiltered = $filterManager->handleFiltersForm($repositoryQuery, $this->filtersForm, $fields, $entityDto); |
|
|
|
$this->isRepositoryQueryFiltered = $filterManager->handleFiltersForm( |
|
|
|
$repositoryQuery, |
|
|
|
$this->filtersForm, |
|
|
|
$fields, |
|
|
|
$entityDto |
|
|
|
); |
|
|
|
return $repositoryQuery; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function createSortRepositoryQuery( |
|
|
|
SearchDto $searchDto, |
|
|
|
EntityDto $entityDto, |
|
|
|
FieldCollection $fields, |
|
|
|
SearchDto $searchDto, |
|
|
|
EntityDto $entityDto, |
|
|
|
FieldCollection $fields, |
|
|
|
FilterCollection $filters |
|
|
|
): RepositoryQueryInterface |
|
|
|
{ |
|
|
|
): RepositoryQueryInterface { |
|
|
|
$repositoryQuery = $this->createIndexRepositoryQuery($searchDto, $entityDto, $fields, $filters); |
|
|
|
if ($this->isInstanceOf(StatusInterface::class)) { |
|
|
|
$repositoryQuery->filterIsOnline(); |
|
|
@@ -422,34 +431,33 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
} |
|
|
|
|
|
|
|
public function createIndexQueryBuilder( |
|
|
|
SearchDto $searchDto, |
|
|
|
EntityDto $entityDto, |
|
|
|
FieldCollection $fields, |
|
|
|
SearchDto $searchDto, |
|
|
|
EntityDto $entityDto, |
|
|
|
FieldCollection $fields, |
|
|
|
FilterCollection $filters |
|
|
|
): QueryBuilder |
|
|
|
{ |
|
|
|
): QueryBuilder { |
|
|
|
$repositoryQuery = $this->createIndexRepositoryQuery($searchDto, $entityDto, $fields, $filters); |
|
|
|
return $repositoryQuery->getQueryBuilder(); |
|
|
|
} |
|
|
|
|
|
|
|
public function createSortQueryBuilder( |
|
|
|
SearchDto $searchDto, |
|
|
|
EntityDto $entityDto, |
|
|
|
FieldCollection $fields, |
|
|
|
SearchDto $searchDto, |
|
|
|
EntityDto $entityDto, |
|
|
|
FieldCollection $fields, |
|
|
|
FilterCollection $filters |
|
|
|
): QueryBuilder |
|
|
|
{ |
|
|
|
): QueryBuilder { |
|
|
|
$repositoryQuery = $this->createSortRepositoryQuery($searchDto, $entityDto, $fields, $filters); |
|
|
|
return $repositoryQuery->getQueryBuilder(); |
|
|
|
} |
|
|
|
|
|
|
|
public function edit(AdminContext $context) |
|
|
|
{ |
|
|
|
$response = parent::edit($context);; |
|
|
|
$context->getRequest()->setMethod('PATCH'); |
|
|
|
$response = parent::edit($context); |
|
|
|
|
|
|
|
// on vide le flash bag si édition en ajax (notification déjà affichée en Javascript) |
|
|
|
if ($context->getRequest()->isXmlHttpRequest()) { |
|
|
|
$this->get('session')->getFlashBag()->clear(); |
|
|
|
$this->requestStack->getSession()->getFlashBag()->clear(); |
|
|
|
} |
|
|
|
|
|
|
|
return $response; |
|
|
@@ -561,7 +569,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
'label' => false, |
|
|
|
'html_attributes' => array( |
|
|
|
'data-toggle' => 'tooltip', |
|
|
|
'title' =>$this->translatorAdmin->transAction('detail'), |
|
|
|
'title' => $this->translatorAdmin->transAction('detail'), |
|
|
|
), |
|
|
|
] |
|
|
|
); |
|
|
@@ -626,7 +634,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
ActionDefinition::SAVE_AND_CONTINUE, |
|
|
|
[ |
|
|
|
'class' => 'btn btn-info float-right action-save-continue', |
|
|
|
'label' =>$this->translatorAdmin->transAction('save_and_continue'), |
|
|
|
'label' => $this->translatorAdmin->transAction('save_and_continue'), |
|
|
|
] |
|
|
|
); |
|
|
|
|
|
|
@@ -844,7 +852,10 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
return $event->getResponse(); |
|
|
|
} |
|
|
|
|
|
|
|
if (!$this->isGranted(Permission::EA_EXECUTE_ACTION, ['action' => Action::DELETE, 'entity' => $context->getEntity()])) { |
|
|
|
if (!$this->isGranted( |
|
|
|
Permission::EA_EXECUTE_ACTION, |
|
|
|
['action' => Action::DELETE, 'entity' => $context->getEntity()] |
|
|
|
)) { |
|
|
|
throw new ForbiddenActionException($context); |
|
|
|
} |
|
|
|
if (!$context->getEntity()->isAccessible()) { |