|
|
@@ -36,7 +36,6 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; |
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; |
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; |
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Security\Permission; |
|
|
|
use Lc\CaracoleBundle\Controller\Order\OrderShopAdminController; |
|
|
|
use Lc\SovBundle\Component\EntityComponent; |
|
|
|
use Lc\SovBundle\Container\ComponentContainer; |
|
|
|
use Lc\SovBundle\Container\File\FileContainer; |
|
|
@@ -50,6 +49,7 @@ use Lc\SovBundle\Container\Ticket\TicketContainer; |
|
|
|
use Lc\SovBundle\Container\Ticket\TicketMessageContainer; |
|
|
|
use Lc\SovBundle\Container\User\GroupUserContainer; |
|
|
|
use Lc\SovBundle\Container\User\UserContainer; |
|
|
|
use Lc\SovBundle\Definition\ActionDefinition; |
|
|
|
use Lc\SovBundle\Doctrine\Extension\DevAliasInterface; |
|
|
|
use Lc\SovBundle\Doctrine\Extension\SeoInterface; |
|
|
|
use Lc\SovBundle\Doctrine\Extension\SortableInterface; |
|
|
@@ -60,18 +60,14 @@ use Lc\SovBundle\Field\Filter\FilterManager; |
|
|
|
use Lc\SovBundle\Form\Common\FiltersFormType; |
|
|
|
use Lc\SovBundle\Form\Common\PositionType; |
|
|
|
use Lc\SovBundle\Notification\MailMailjetNotification; |
|
|
|
use Lc\SovBundle\Solver\Setting\SettingSolver; |
|
|
|
use Lc\SovBundle\Translation\FlashBagTranslator; |
|
|
|
use Lc\SovBundle\Translation\TranslatorAdmin; |
|
|
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; |
|
|
|
use Symfony\Component\Form\Extension\Core\Type\CollectionType; |
|
|
|
use Symfony\Component\Form\Extension\Core\Type\DateTimeType; |
|
|
|
use Symfony\Component\Form\Extension\Core\Type\DateType; |
|
|
|
use Symfony\Component\Form\Extension\Core\Type\IntegerType; |
|
|
|
use Symfony\Component\Form\Extension\Core\Type\TextType; |
|
|
|
use Symfony\Component\Form\FormInterface; |
|
|
|
use Symfony\Component\HttpFoundation\JsonResponse; |
|
|
|
use Symfony\Component\HttpFoundation\RequestStack; |
|
|
|
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface; |
|
|
|
use Symfony\Component\HttpFoundation\Session\SessionInterface; |
|
|
|
|
|
|
|
|
|
|
@@ -103,6 +99,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
UserContainer::class => UserContainer::class, |
|
|
|
SiteSettingContainer::class => SiteSettingContainer::class, |
|
|
|
MailMailjetNotification::class => MailMailjetNotification::class, |
|
|
|
SettingSolver::class => SettingSolver::class |
|
|
|
] |
|
|
|
); |
|
|
|
} |
|
|
@@ -119,14 +116,15 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
if (Crud::PAGE_INDEX === $responseParameters->get('pageName')) { |
|
|
|
$responseParameters->set('fields', $this->configureFields('index')); |
|
|
|
|
|
|
|
if ($this->filtersForm === null) { |
|
|
|
//TODO supprimer ce code rapport au filtre dans les index |
|
|
|
/*if ($this->filtersForm === null) { |
|
|
|
die('nncncd'); |
|
|
|
//TODO delete under code |
|
|
|
|
|
|
|
$options['fields'] = $responseParameters->get('fields'); |
|
|
|
$options['entity_class'] = $this->getEntityFqcn(); |
|
|
|
$options['entity_name'] = $responseParameters->get('entity')->getName(); |
|
|
|
$this->filtersForm = $this->createForm(FiltersFormType::class, null, $options); |
|
|
|
} |
|
|
|
}*/ |
|
|
|
$responseParameters->set('filters_form', $this->filtersForm); |
|
|
|
} |
|
|
|
|
|
|
@@ -317,7 +315,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
} |
|
|
|
|
|
|
|
$url = $this->get(AdminUrlGenerator::class) |
|
|
|
->setAction(Action::INDEX) |
|
|
|
->setAction(ActionDefinition::INDEX) |
|
|
|
->generateUrl(); |
|
|
|
$this->addFlashTranslator('success', 'sorted'); |
|
|
|
|
|
|
@@ -370,7 +368,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
$em->flush(); |
|
|
|
|
|
|
|
$url = $this->get(AdminUrlGenerator::class) |
|
|
|
->setAction(Action::EDIT) |
|
|
|
->setAction(ActionDefinition::EDIT) |
|
|
|
->setEntityId($newEntity->getId()) |
|
|
|
->generateUrl(); |
|
|
|
|
|
|
@@ -497,8 +495,8 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
$this->handleSortableEntityActions($actions); |
|
|
|
$this->handleTreeEntityActions($actions); |
|
|
|
|
|
|
|
/*$actions->reorder(Crud::PAGE_EDIT, [Action::INDEX, Action::SAVE_AND_RETURN, Action::SAVE_AND_CONTINUE, Action::DELETE]); |
|
|
|
$actions->reorder(Crud::PAGE_NEW, [Action::INDEX, Action::SAVE_AND_RETURN, Action::SAVE_AND_ADD_ANOTHER]);*/ |
|
|
|
/*$actions->reorder(Crud::PAGE_EDIT, [ActionDefinition::INDEX, ActionDefinition::SAVE_AND_RETURN, ActionDefinition::SAVE_AND_CONTINUE, ActionDefinition::DELETE]); |
|
|
|
$actions->reorder(Crud::PAGE_NEW, [ActionDefinition::INDEX, ActionDefinition::SAVE_AND_RETURN, ActionDefinition::SAVE_AND_ADD_ANOTHER]);*/ |
|
|
|
|
|
|
|
return $actions; |
|
|
|
} |
|
|
@@ -506,12 +504,12 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
public function getDuplicateAction(): Action |
|
|
|
{ |
|
|
|
$duplicateAction = Action::new( |
|
|
|
'duplicate', |
|
|
|
$this->get(TranslatorAdmin::class)->transAction('duplicate'), |
|
|
|
ActionDefinition::DUPLICATE, |
|
|
|
$this->get(TranslatorAdmin::class)->transAction(ActionDefinition::DUPLICATE), |
|
|
|
'fa fa-fw fa-copy' |
|
|
|
) |
|
|
|
->linkToCrudAction('duplicate') |
|
|
|
->setLabel($this->get(TranslatorAdmin::class)->transAction('duplicate')) |
|
|
|
->linkToCrudAction(ActionDefinition::DUPLICATE) |
|
|
|
->setLabel($this->get(TranslatorAdmin::class)->transAction(ActionDefinition::DUPLICATE)) |
|
|
|
->setCssClass('in-dropdown text-info action-confirm'); |
|
|
|
|
|
|
|
return $duplicateAction; |
|
|
@@ -524,7 +522,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
$this->actionUpdate( |
|
|
|
$actions, |
|
|
|
Crud::PAGE_INDEX, |
|
|
|
Action::NEW, |
|
|
|
ActionDefinition::NEW, |
|
|
|
[ |
|
|
|
'icon' => 'plus', |
|
|
|
'label' => $this->get(TranslatorAdmin::class)->transAction('create'), |
|
|
@@ -535,7 +533,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
$this->actionUpdate( |
|
|
|
$actions, |
|
|
|
Crud::PAGE_INDEX, |
|
|
|
Action::EDIT, |
|
|
|
ActionDefinition::EDIT, |
|
|
|
[ |
|
|
|
'class' => 'btn btn-sm btn-primary', |
|
|
|
'icon' => 'edit', |
|
|
@@ -550,7 +548,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
$this->actionUpdate( |
|
|
|
$actions, |
|
|
|
Crud::PAGE_INDEX, |
|
|
|
Action::DETAIL, |
|
|
|
ActionDefinition::DETAIL, |
|
|
|
[ |
|
|
|
'icon' => 'eye', |
|
|
|
'add_class' => 'btn btn-sm btn-success', |
|
|
@@ -565,7 +563,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
$this->actionUpdate( |
|
|
|
$actions, |
|
|
|
Crud::PAGE_INDEX, |
|
|
|
Action::DELETE, |
|
|
|
ActionDefinition::DELETE, |
|
|
|
[ |
|
|
|
'icon' => 'trash', |
|
|
|
'dropdown' => true, |
|
|
@@ -576,7 +574,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
$this->actionUpdate( |
|
|
|
$actions, |
|
|
|
Crud::PAGE_INDEX, |
|
|
|
Action::BATCH_DELETE, |
|
|
|
ActionDefinition::BATCH_DELETE, |
|
|
|
[ |
|
|
|
'class' => 'btn btn-sm btn-danger', |
|
|
|
'icon' => 'trash', |
|
|
@@ -588,14 +586,14 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
|
|
|
|
public function buildEditActions(Actions $actions): void |
|
|
|
{ |
|
|
|
$actions->add(Crud::PAGE_EDIT, Action::INDEX); |
|
|
|
$actions->add(Crud::PAGE_EDIT, Action::DELETE); |
|
|
|
$actions->add(Crud::PAGE_EDIT, ActionDefinition::INDEX); |
|
|
|
$actions->add(Crud::PAGE_EDIT, ActionDefinition::DELETE); |
|
|
|
|
|
|
|
|
|
|
|
$this->actionUpdate( |
|
|
|
$actions, |
|
|
|
Crud::PAGE_EDIT, |
|
|
|
Action::SAVE_AND_RETURN, |
|
|
|
ActionDefinition::SAVE_AND_RETURN, |
|
|
|
[ |
|
|
|
'add_class' => 'float-right ', |
|
|
|
'icon' => 'check', |
|
|
@@ -606,7 +604,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
$this->actionUpdate( |
|
|
|
$actions, |
|
|
|
Crud::PAGE_EDIT, |
|
|
|
Action::INDEX, |
|
|
|
ActionDefinition::INDEX, |
|
|
|
[ |
|
|
|
'icon' => 'chevron-left', |
|
|
|
'class' => 'btn btn-link', |
|
|
@@ -618,7 +616,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
$this->actionUpdate( |
|
|
|
$actions, |
|
|
|
Crud::PAGE_EDIT, |
|
|
|
Action::SAVE_AND_CONTINUE, |
|
|
|
ActionDefinition::SAVE_AND_CONTINUE, |
|
|
|
[ |
|
|
|
'class' => 'btn btn-info float-right action-save-continue', |
|
|
|
'label' => $this->get(TranslatorAdmin::class)->transAction('save_and_continue'), |
|
|
@@ -628,7 +626,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
$this->actionUpdate( |
|
|
|
$actions, |
|
|
|
Crud::PAGE_EDIT, |
|
|
|
Action::DELETE, |
|
|
|
ActionDefinition::DELETE, |
|
|
|
[ |
|
|
|
'icon' => 'trash', |
|
|
|
'class' => 'btn btn-outline-danger action-delete', |
|
|
@@ -643,12 +641,12 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
|
|
|
|
public function buildNewActions(Actions $actions): void |
|
|
|
{ |
|
|
|
$actions->add(Crud::PAGE_NEW, Action::INDEX); |
|
|
|
$actions->add(Crud::PAGE_NEW, ActionDefinition::INDEX); |
|
|
|
|
|
|
|
$this->actionUpdate( |
|
|
|
$actions, |
|
|
|
Crud::PAGE_EDIT, |
|
|
|
Action::SAVE_AND_RETURN, |
|
|
|
ActionDefinition::SAVE_AND_RETURN, |
|
|
|
[ |
|
|
|
'add_class' => 'float-right', |
|
|
|
'icon' => 'check', |
|
|
@@ -659,7 +657,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
$this->actionUpdate( |
|
|
|
$actions, |
|
|
|
Crud::PAGE_EDIT, |
|
|
|
Action::INDEX, |
|
|
|
ActionDefinition::INDEX, |
|
|
|
[ |
|
|
|
'icon' => 'chevron-left', |
|
|
|
'class' => 'btn btn-link', |
|
|
@@ -670,7 +668,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
$this->actionUpdate( |
|
|
|
$actions, |
|
|
|
Crud::PAGE_EDIT, |
|
|
|
Action::SAVE_AND_ADD_ANOTHER, |
|
|
|
ActionDefinition::SAVE_AND_ADD_ANOTHER, |
|
|
|
[ |
|
|
|
'class' => 'btn btn-info float-right', |
|
|
|
'label' => $this->get(TranslatorAdmin::class)->transAction('save_and_add_another'), |
|
|
@@ -683,7 +681,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
if ($this->isInstanceOf(TranslatableInterface::class)) { |
|
|
|
$actions->update( |
|
|
|
Crud::PAGE_INDEX, |
|
|
|
Action::EDIT, |
|
|
|
ActionDefinition::EDIT, |
|
|
|
function (Action $action) { |
|
|
|
$action->setTemplatePath('@LcSov/adminlte/crud/action/translatable.html.twig'); |
|
|
|
|
|
|
@@ -696,8 +694,8 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
public function handleSortableEntityActions(Actions $actions): void |
|
|
|
{ |
|
|
|
if ($this->isInstanceOf(SortableInterface::class)) { |
|
|
|
$sortAction = Action::new('sort', $this->get(TranslatorAdmin::class)->transAction('sort'), 'fa fa-sort') |
|
|
|
->linkToCrudAction('sort') |
|
|
|
$sortAction = Action::new(ActionDefinition::SORT, $this->get(TranslatorAdmin::class)->transAction(ActionDefinition::SORT), 'fa fa-sort') |
|
|
|
->linkToCrudAction(ActionDefinition::SORT) |
|
|
|
->setCssClass('btn btn-sm btn-success') |
|
|
|
->createAsGlobalAction(); |
|
|
|
|
|
|
@@ -710,22 +708,22 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
{ |
|
|
|
if ($this->isInstanceOf(TreeInterface::class)) { |
|
|
|
$indexChildAction = Action::new( |
|
|
|
'index_children', |
|
|
|
$this->get(TranslatorAdmin::class)->transAction('index_children'), |
|
|
|
ActionDefinition::INDEX_CHILDREN, |
|
|
|
$this->get(TranslatorAdmin::class)->transAction(ActionDefinition::INDEX_CHILDREN), |
|
|
|
'fa fa-list' |
|
|
|
) |
|
|
|
->linkToCrudAction(Action::INDEX) |
|
|
|
->linkToCrudAction(ActionDefinition::INDEX) |
|
|
|
->setLabel('') |
|
|
|
->setHtmlAttributes(array('data-toggle' => 'tooltip', 'title' => 'Afficher les enfants')) |
|
|
|
->setTemplatePath('@LcSov/adminlte/crud/action/index_children.html.twig') |
|
|
|
->setCssClass('btn btn-sm btn-success'); |
|
|
|
|
|
|
|
$backParentAction = Action::new( |
|
|
|
'index_parent', |
|
|
|
$this->get(TranslatorAdmin::class)->transAction('index_parent'), |
|
|
|
ActionDefinition::INDEX_PARENT, |
|
|
|
$this->get(TranslatorAdmin::class)->transAction(ActionDefinition::INDEX_PARENT), |
|
|
|
'fa fa-chevron-left' |
|
|
|
) |
|
|
|
->linkToCrudAction(Action::INDEX) |
|
|
|
->linkToCrudAction(ActionDefinition::INDEX) |
|
|
|
->setCssClass('btn btn-sm btn-info') |
|
|
|
->createAsGlobalAction(); |
|
|
|
|
|
|
@@ -784,7 +782,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
/** @var CrudControllerInterface $controller */ |
|
|
|
$controller = $this->get(ControllerFactory::class)->getCrudControllerInstance( |
|
|
|
$autocompleteContext[EA::CRUD_CONTROLLER_FQCN], |
|
|
|
Action::INDEX, |
|
|
|
ActionDefinition::INDEX, |
|
|
|
$context->getRequest() |
|
|
|
); |
|
|
|
/** @var FieldDto $field */ |
|
|
@@ -813,7 +811,9 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
public function createCustomForm($class, $action, $controller, $entity, $dataInOption = true, $options = array()) |
|
|
|
{ |
|
|
|
if ($dataInOption) { |
|
|
|
$options['data'] = $entity; |
|
|
|
$data = $entity; |
|
|
|
}else{ |
|
|
|
$data = null; |
|
|
|
} |
|
|
|
|
|
|
|
$options['action'] = $this->get(AdminUrlGenerator::class) |
|
|
@@ -822,7 +822,27 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
->setEntityId($entity->getId()) |
|
|
|
->generateUrl(); |
|
|
|
|
|
|
|
return $this->createForm($class, null, $options); |
|
|
|
return $this->createForm($class, $data, $options); |
|
|
|
} |
|
|
|
|
|
|
|
public function generateEaUrl(string $controller =null, string $action=null, int $entityId=null, array $extraParam = array()): string |
|
|
|
{ |
|
|
|
$adminUrlGenerator = $this->get(AdminUrlGenerator::class); |
|
|
|
if ($controller) { |
|
|
|
$adminUrlGenerator->setController($controller); |
|
|
|
} |
|
|
|
if ($action) { |
|
|
|
$adminUrlGenerator->setAction($action); |
|
|
|
} |
|
|
|
if ($entityId) { |
|
|
|
$adminUrlGenerator->setEntityId($entityId); |
|
|
|
} |
|
|
|
if($extraParam){ |
|
|
|
foreach ($extraParam as $key=>$value) { |
|
|
|
$adminUrlGenerator->set($key, $value); |
|
|
|
} |
|
|
|
} |
|
|
|
return $adminUrlGenerator->generateUrl(); |
|
|
|
} |
|
|
|
|
|
|
|
} |