namespace Lc\SovBundle\Controller\Admin; | namespace Lc\SovBundle\Controller\Admin; | ||||
use Doctrine\ORM\EntityManagerInterface; | |||||
use Doctrine\ORM\QueryBuilder; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection; | use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Collection\FilterCollection; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Config\Action; | use EasyCorp\Bundle\EasyAdminBundle\Config\Action; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions; | use EasyCorp\Bundle\EasyAdminBundle\Config\Actions; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Config\Assets; | use EasyCorp\Bundle\EasyAdminBundle\Config\Assets; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Config\Option\EA; | use EasyCorp\Bundle\EasyAdminBundle\Config\Option\EA; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; | use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController as EaAbstractCrudController; | use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController as EaAbstractCrudController; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Dto\SearchDto; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Event\AfterCrudActionEvent; | use EasyCorp\Bundle\EasyAdminBundle\Event\AfterCrudActionEvent; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Event\AfterEntityUpdatedEvent; | use EasyCorp\Bundle\EasyAdminBundle\Event\AfterEntityUpdatedEvent; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Event\BeforeCrudActionEvent; | use EasyCorp\Bundle\EasyAdminBundle\Event\BeforeCrudActionEvent; | ||||
use Lc\SovBundle\Doctrine\Extension\SeoInterface; | use Lc\SovBundle\Doctrine\Extension\SeoInterface; | ||||
use Lc\SovBundle\Doctrine\Extension\SortableInterface; | use Lc\SovBundle\Doctrine\Extension\SortableInterface; | ||||
use Lc\SovBundle\Doctrine\Extension\TranslatableInterface; | use Lc\SovBundle\Doctrine\Extension\TranslatableInterface; | ||||
use Lc\SovBundle\Doctrine\Extension\TreeInterface; | |||||
use Lc\SovBundle\Field\CollectionField; | use Lc\SovBundle\Field\CollectionField; | ||||
use Lc\SovBundle\Field\GalleryManagerField; | use Lc\SovBundle\Field\GalleryManagerField; | ||||
use Lc\SovBundle\Form\Type\Crud\PositionType; | use Lc\SovBundle\Form\Type\Crud\PositionType; | ||||
public function configureActions(Actions $actions): Actions | public function configureActions(Actions $actions): Actions | ||||
{ | { | ||||
/* Translatable */ | /* Translatable */ | ||||
if (in_array(TranslatableInterface::class, class_implements($this->getEntityFqcn()))) { | |||||
if ($this->isInstanceOf(TranslatableInterface::class)) { | |||||
$actions->update( | $actions->update( | ||||
Crud::PAGE_INDEX, | Crud::PAGE_INDEX, | ||||
Action::EDIT, | Action::EDIT, | ||||
$actions->add(Crud::PAGE_EDIT, Action::DELETE); | $actions->add(Crud::PAGE_EDIT, Action::DELETE); | ||||
$actions->add(Crud::PAGE_NEW, Action::INDEX); | $actions->add(Crud::PAGE_NEW, Action::INDEX); | ||||
if (in_array(SortableInterface::class, class_implements($this->getEntityFqcn()))) { | |||||
if ($this->isInstanceOf(SortableInterface::class)) { | |||||
$sortAction = Action::new('sort', 'Ordonner', 'fa fa-sort') | $sortAction = Action::new('sort', 'Ordonner', 'fa fa-sort') | ||||
->linkToCrudAction('sort') | ->linkToCrudAction('sort') | ||||
->setCssClass('btn btn-info') | ->setCssClass('btn btn-info') | ||||
->setHtmlAttributes(array('entityId' => 'ncihe')) | |||||
->createAsGlobalAction(); | ->createAsGlobalAction(); | ||||
$actions->add(Crud::PAGE_INDEX, $sortAction); | $actions->add(Crud::PAGE_INDEX, $sortAction); | ||||
} | } | ||||
if ($this->isInstanceOf(TreeInterface::class)) { | |||||
$indexChildAction = Action::new('index_children', 'Afficher les enfants', 'fa fa-sort') | |||||
->linkToCrudAction(Action::INDEX) | |||||
->setTemplatePath('@LcSov/adminlte/crud/action/index_children.html.twig') | |||||
->setCssClass('btn btn-info'); | |||||
$actions->add(Crud::PAGE_INDEX, $indexChildAction); | |||||
} | |||||
$actions->reorder(Crud::PAGE_EDIT, [Action::INDEX, Action::SAVE_AND_RETURN, Action::SAVE_AND_CONTINUE]); | $actions->reorder(Crud::PAGE_EDIT, [Action::INDEX, Action::SAVE_AND_RETURN, Action::SAVE_AND_CONTINUE]); | ||||
$actions->reorder(Crud::PAGE_NEW, [Action::INDEX, Action::SAVE_AND_RETURN, Action::SAVE_AND_ADD_ANOTHER]); | $actions->reorder(Crud::PAGE_NEW, [Action::INDEX, Action::SAVE_AND_RETURN, Action::SAVE_AND_ADD_ANOTHER]); | ||||
} | } | ||||
if (isset($button['icon'])) { | if (isset($button['icon'])) { | ||||
$action->setIcon('fa fa-' . $button['icon']); | |||||
$action->setIcon('fa fa-'.$button['icon']); | |||||
} | } | ||||
if (isset($button['label'])) { | if (isset($button['label'])) { | ||||
{ | { | ||||
$entityClass = $this->getEntityFqcn(); | $entityClass = $this->getEntityFqcn(); | ||||
$paramListMaxResults = 'listMaxResults'; | $paramListMaxResults = 'listMaxResults'; | ||||
$paramSessionListMaxResults = $entityClass . '-' . $paramListMaxResults; | |||||
$paramSessionListMaxResults = $entityClass.'-'.$paramListMaxResults; | |||||
$requestListMaxResults = $this->request->getCurrentRequest()->get($paramListMaxResults); | $requestListMaxResults = $this->request->getCurrentRequest()->get($paramListMaxResults); | ||||
if ($requestListMaxResults) { | if ($requestListMaxResults) { | ||||
public function configureFields(string $pageName): iterable | public function configureFields(string $pageName): iterable | ||||
{ | { | ||||
if (in_array(SeoInterface::class, class_implements($this->getEntityFqcn()))) { | |||||
if ($this->isInstanceOf(SortableInterface::class)) { | |||||
$seoPanel = [ | $seoPanel = [ | ||||
FormField::addPanel('Seo'), | FormField::addPanel('Seo'), | ||||
TextField::new('metaTitle')->setLabel('Meta Title')->setHelp( | TextField::new('metaTitle')->setLabel('Meta Title')->setHelp( | ||||
]; | ]; | ||||
} | } | ||||
if (in_array(DevAliasInterface::class, class_implements($this->getEntityFqcn()))) { | |||||
if ($this->isInstanceOf(DevAliasInterface::class)) { | |||||
$confPanel = [ | $confPanel = [ | ||||
FormField::addPanel('Conf'), | FormField::addPanel('Conf'), | ||||
TextField::new('devAlias')->hideOnIndex(), | TextField::new('devAlias')->hideOnIndex(), | ||||
} | } | ||||
public function sort(AdminContext $context) | public function sort(AdminContext $context) | ||||
{ | { | ||||
$event = new BeforeCrudActionEvent($context); | $event = new BeforeCrudActionEvent($context); | ||||
return $event->getResponse(); | return $event->getResponse(); | ||||
} | } | ||||
if (!$this->isGranted(Permission::EA_EXECUTE_ACTION) || !in_array( | |||||
SortableInterface::class, | |||||
class_implements($this->getEntityFqcn()) | |||||
)) { | |||||
if (!$this->isGranted(Permission::EA_EXECUTE_ACTION) || !$this->isInstanceOf(SortableInterface::class)) { | |||||
throw new ForbiddenActionException($context); | throw new ForbiddenActionException($context); | ||||
} | } | ||||
->getForm(); | ->getForm(); | ||||
$entityManager = $this->getDoctrine()->getManagerForClass($this->getEntityFqcn()); | $entityManager = $this->getDoctrine()->getManagerForClass($this->getEntityFqcn()); | ||||
dump($entityManager); | |||||
$repository = $entityManager->getRepository($this->getEntityFqcn()); | $repository = $entityManager->getRepository($this->getEntityFqcn()); | ||||
$sortableForm->handleRequest($context->getRequest()); | $sortableForm->handleRequest($context->getRequest()); | ||||
if ($sortableForm->isSubmitted() && $sortableForm->isValid()) { | if ($sortableForm->isSubmitted() && $sortableForm->isValid()) { | ||||
// $entityInstance = $event->getEntityInstance(); | |||||
foreach ($sortableForm->get('entities')->getData() as $elm) { | foreach ($sortableForm->get('entities')->getData() as $elm) { | ||||
$entityInstance = $repository->find($elm['id']); | $entityInstance = $repository->find($elm['id']); | ||||
$entityDto = $context->getEntity()->newWithInstance($entityInstance); | $entityDto = $context->getEntity()->newWithInstance($entityInstance); | ||||
$url = $this->get(AdminUrlGenerator::class) | $url = $this->get(AdminUrlGenerator::class) | ||||
->setAction(Action::INDEX) | ->setAction(Action::INDEX) | ||||
->generateUrl(); | ->generateUrl(); | ||||
$this->addFlash('success', 'Position modifié', array(), 'mweb'); | |||||
$this->addFlash('success', 'Position modifié', array()); | |||||
return $this->redirect($url); | return $this->redirect($url); | ||||
} | } | ||||
return $responseParameters; | return $responseParameters; | ||||
} | } | ||||
public function createIndexQueryBuilder( | |||||
SearchDto $searchDto, | |||||
EntityDto $entityDto, | |||||
FieldCollection $fields, | |||||
FilterCollection $filters | |||||
): QueryBuilder { | |||||
$queryBuilder = parent::createIndexQueryBuilder( | |||||
$searchDto, | |||||
$entityDto, | |||||
$fields, | |||||
$filters | |||||
); | |||||
dump(get_defined_vars()); | |||||
if ($this->isInstanceOf(TreeInterface::class)) { | |||||
$entityId = $searchDto->getRequest()->get('entityId'); | |||||
if ($entityId !== null) { | |||||
$queryBuilder->andWhere('entity.parent = :entityId'); | |||||
$queryBuilder->setParameter('entityId', $searchDto->getRequest()->get('entityId')); | |||||
} else { | |||||
$queryBuilder->andWhere('entity.parent IS NULL'); | |||||
} | |||||
} | |||||
return $queryBuilder; | |||||
} | |||||
public function createSortQueryBuilder( | |||||
SearchDto $searchDto, | |||||
EntityDto $entityDto, | |||||
FieldCollection $fields, | |||||
FilterCollection $filters | |||||
): QueryBuilder { | |||||
$queryBuilder = parent::createIndexQueryBuilder( | |||||
$searchDto, | |||||
$entityDto, | |||||
$fields, | |||||
$filters | |||||
); | |||||
if ($this->isInstanceOf(TreeInterface::class)) { | |||||
$entityId = $searchDto->getRequest()->get('entityId'); | |||||
if ($entityId !== null) { | |||||
$queryBuilder->andWhere('entity.parent = :entityId'); | |||||
$queryBuilder->setParameter('entityId', $searchDto->getRequest()->get('entityId')); | |||||
} else { | |||||
$queryBuilder->andWhere('entity.parent IS NULL'); | |||||
} | |||||
} | |||||
return $queryBuilder; | |||||
} | |||||
public function isInstanceOf(string $interfaceName): bool | |||||
{ | |||||
return in_array($interfaceName, class_implements($this->getEntityFqcn())); | |||||
} | |||||
public function updateEntity(EntityManagerInterface $entityManager, $entityInstance): void | |||||
{ | |||||
$entityManager->update($entityInstance); | |||||
$entityManager->flush(); | |||||
} | |||||
public function persistEntity(EntityManagerInterface $entityManager, $entityInstance): void | |||||
{ | |||||
$entityManager->create($entityInstance); | |||||
$entityManager->flush(); | |||||
} | |||||
} | } | ||||
'crud/paginator' => '@LcSov/adminlte/crud/paginator.html.twig', | 'crud/paginator' => '@LcSov/adminlte/crud/paginator.html.twig', | ||||
'crud/edit' => '@LcSov/adminlte/crud/edit.html.twig', | 'crud/edit' => '@LcSov/adminlte/crud/edit.html.twig', | ||||
'crud/new' => '@LcSov/adminlte/crud/new.html.twig', | 'crud/new' => '@LcSov/adminlte/crud/new.html.twig', | ||||
//'crud/action' => '@LcSov/adminlte/crud/action/action.html.twig', | |||||
] | ] | ||||
) | ) | ||||
->setFormThemes( | ->setFormThemes( |
namespace Lc\SovBundle\Doctrine; | namespace Lc\SovBundle\Doctrine; | ||||
use Doctrine\ORM\Decorator\EntityManagerDecorator; | |||||
use Doctrine\ORM\EntityManager as DoctrineEntityManager; | use Doctrine\ORM\EntityManager as DoctrineEntityManager; | ||||
use Doctrine\ORM\EntityManagerInterface; | use Doctrine\ORM\EntityManagerInterface; | ||||
use Lc\SovBundle\Event\EntityManager\EntityManagerEvent; | use Lc\SovBundle\Event\EntityManager\EntityManagerEvent; | ||||
/** | /** | ||||
* class EntityManager. | * class EntityManager. | ||||
* | * | ||||
* @author Simon Vieille <simon@deblan.fr> | |||||
* @author La clic !!!! | |||||
*/ | */ | ||||
class EntityManager | |||||
class EntityManager extends EntityManagerDecorator | |||||
{ | { | ||||
protected EventDispatcherInterface $eventDispatcher; | |||||
protected EventDispatcherInterface $eventDispatcher; | |||||
protected DoctrineEntityManager $entityManager; | |||||
protected DoctrineEntityManager $entityManager; | |||||
public function __construct(EventDispatcherInterface $eventDispatcher, EntityManagerInterface $entityManager) | |||||
{ | |||||
$this->eventDispatcher = $eventDispatcher; | |||||
$this->entityManager = $entityManager; | |||||
} | |||||
public function getRepository($className) | |||||
{ | |||||
return $this->entityManager->getRepository($this->getEntityName($className)); | |||||
} | |||||
public function __construct(EntityManagerInterface $wrapped, EventDispatcherInterface $eventDispatcher) | |||||
{ | |||||
$this->eventDispatcher = $eventDispatcher; | |||||
parent::__construct($wrapped); | |||||
} | |||||
public function new($className) | |||||
{ | |||||
$entityName = $this->getEntityName($className); | |||||
return new $entityName; | |||||
} | |||||
public function getRepository($className) | |||||
{ | |||||
return $this->wrapped->getRepository($this->getEntityName($className)); | |||||
} | |||||
public function create(EntityInterface $entity): self | |||||
{ | |||||
$this->persist($entity); | |||||
$this->eventDispatcher->dispatch(new EntityManagerEvent($entity), EntityManagerEvent::CREATE_EVENT); | |||||
public function new($className) | |||||
{ | |||||
$entityName = $this->getEntityName($className); | |||||
return $this; | |||||
} | |||||
return new $entityName; | |||||
} | |||||
public function update(EntityInterface $entity): self | |||||
{ | |||||
$this->persist($entity); | |||||
$this->eventDispatcher->dispatch(new EntityManagerEvent($entity), EntityManagerEvent::UPDATE_EVENT); | |||||
public function create(EntityInterface $entity): self | |||||
{ | |||||
$this->persist($entity); | |||||
$this->eventDispatcher->dispatch(new EntityManagerEvent($entity), EntityManagerEvent::CREATE_EVENT); | |||||
return $this; | |||||
} | |||||
return $this; | |||||
} | |||||
public function delete(EntityInterface $entity): self | |||||
{ | |||||
$this->remove($entity); | |||||
$this->eventDispatcher->dispatch(new EntityManagerEvent($entity), EntityManagerEvent::DELETE_EVENT); | |||||
public function update(EntityInterface $entity): self | |||||
{ | |||||
$this->persist($entity); | |||||
$this->eventDispatcher->dispatch(new EntityManagerEvent($entity), EntityManagerEvent::UPDATE_EVENT); | |||||
return $this; | |||||
} | |||||
return $this; | |||||
} | |||||
public function flush(): self | |||||
{ | |||||
$this->entityManager->flush(); | |||||
public function delete(EntityInterface $entity): self | |||||
{ | |||||
$this->remove($entity); | |||||
$this->eventDispatcher->dispatch(new EntityManagerEvent($entity), EntityManagerEvent::DELETE_EVENT); | |||||
return $this; | |||||
} | |||||
return $this; | |||||
} | |||||
public function clear(): self | |||||
{ | |||||
$this->entityManager->clear(); | |||||
public function flush($entity=null): self | |||||
{ | |||||
$this->wrapped->flush($entity); | |||||
return $this; | |||||
} | |||||
return $this; | |||||
} | |||||
public function refresh(EntityInterface $entity): self | |||||
{ | |||||
$this->entityManager->refresh($entity); | |||||
public function clear($objectName = null): self | |||||
{ | |||||
$this->wrapped->clear($objectName); | |||||
return $this; | |||||
} | |||||
return $this; | |||||
} | |||||
protected function persist(EntityInterface $entity) | |||||
{ | |||||
$this->entityManager->persist($entity); | |||||
} | |||||
public function refresh($object): self | |||||
{ | |||||
$this->wrapped->refresh($object); | |||||
public function getClassMetadata($className){ | |||||
return $this->entityManager->getClassMetadata($className); | |||||
} | |||||
return $this; | |||||
} | |||||
public function persist($entity) | |||||
{ | |||||
$this->wrapped->persist($entity); | |||||
} | |||||
public function getEntityName($className) | |||||
{ | |||||
if (substr($className, -9) === 'Interface') { | |||||
return $this->entityManager->getClassMetadata($className)->getName(); | |||||
}else{ | |||||
return $className; | |||||
} | |||||
public function getClassMetadata($className) | |||||
{ | |||||
return $this->wrapped->getClassMetadata($className); | |||||
} | |||||
public function getEntityName($className) | |||||
{ | |||||
if (substr($className, -9) === 'Interface') { | |||||
return $this->wrapped->getClassMetadata($className)->getName(); | |||||
} else { | |||||
return $className; | |||||
} | } | ||||
} | |||||
} | } |
<?php | |||||
namespace Lc\SovBundle\EventSubscriber\Action; | |||||
use Doctrine\ORM\PersistentCollection; | |||||
use Doctrine\ORM\Query; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Event\AfterCrudActionEvent; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Event\BeforeCrudActionEvent; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Event\BeforeEntityPersistedEvent; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; | |||||
use Gedmo\Translatable\TranslatableListener; | |||||
use Lc\SovBundle\Doctrine\Extension\TranslatableInterface; | |||||
use Lc\SovBundle\Doctrine\EntityManager; | |||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | |||||
use function Symfony\Component\Translation\t; | |||||
class ActionEasyAdminSubscriber implements EventSubscriberInterface | |||||
{ | |||||
protected $em; | |||||
protected $adminUrlGenerator; | |||||
public function __construct(EntityManager $entityManager, AdminUrlGenerator $adminUrlGenerator) | |||||
{ | |||||
$this->em = $entityManager; | |||||
$this->adminUrlGenerator = $adminUrlGenerator; | |||||
} | |||||
public static function getSubscribedEvents() | |||||
{ | |||||
return [ | |||||
AfterCrudActionEvent::class => ['overrideSortAction'], | |||||
]; | |||||
} | |||||
public function overrideSortAction(AfterCrudActionEvent $event) | |||||
{ | |||||
$actions = $event->getResponseParameters()->get('global_actions'); | |||||
if ($actions) { | |||||
foreach ($actions as $action) { | |||||
if ($action->getName() == 'sort') { | |||||
$entityId = $event->getAdminContext()->getRequest()->get('entityId'); | |||||
if ($entityId != null) { | |||||
$url = $this->adminUrlGenerator | |||||
->setController($event->getAdminContext()->getCrud()->getControllerFqcn()) | |||||
->setAction($action->getName()) | |||||
->set('entityId', $entityId) | |||||
->generateUrl(); | |||||
$action->setLinkUrl($url); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} |
<?php | |||||
namespace Lc\SovBundle\EventSubscriber; | |||||
use Doctrine\ORM\EntityManagerInterface; | |||||
use Lc\SovBundle\Doctrine\EntityInterface; | |||||
use Lc\SovBundle\Doctrine\Extension\SortableInterface; | |||||
use Lc\SovBundle\Doctrine\Extension\StatusInterface; | |||||
use Lc\SovBundle\Doctrine\Extension\TreeInterface; | |||||
use Lc\SovBundle\Event\EntityManager\EntityManagerEvent; | |||||
use Lc\SovBundle\Repository\AbstractRepositoryInterface; | |||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | |||||
class CreateEntityEventSubscriber implements EventSubscriberInterface | |||||
{ | |||||
protected $em; | |||||
protected $adminUrlGenerator; | |||||
public function __construct(EntityManagerInterface $entityManager) | |||||
{ | |||||
$this->em = $entityManager; | |||||
} | |||||
public static function getSubscribedEvents() | |||||
{ | |||||
return [ | |||||
EntityManagerEvent::CREATE_EVENT => ['createEntity'], | |||||
]; | |||||
} | |||||
public function createEntity(EntityManagerEvent $event) | |||||
{ | |||||
$entity = $event->getEntity(); | |||||
$entityRepository = $this->em->getRepository(get_class($entity)); | |||||
if ($entity instanceof SortableInterface) { | |||||
$this->setSortableProperty($entity, $entityRepository); | |||||
} | |||||
} | |||||
private function setSortableProperty(EntityInterface $entity, AbstractRepositoryInterface $entityRepository) | |||||
{ | |||||
if ($entity instanceof StatusInterface) { | |||||
$countParam['status'] = 1; | |||||
} | |||||
if ($entity instanceof TreeInterface) { | |||||
if($entity->getParent()){ | |||||
$countParam['parent'] = $entity->getParent()->getId(); | |||||
}else{ | |||||
$countParam['parent'] = null; | |||||
} | |||||
} | |||||
$total = $entityRepository->count($countParam); | |||||
$entity->setPosition($total); | |||||
} | |||||
} |
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||||
use function Symfony\Component\Translation\t; | use function Symfony\Component\Translation\t; | ||||
class TranslationEasyAdminSubscriber implements EventSubscriberInterface | |||||
class TranslationEasyAdminSubscriber implements EventSubscriberInterface | |||||
{ | { | ||||
protected $em; | protected $em; | ||||
return (new self()) | return (new self()) | ||||
->setProperty($propertyName) | ->setProperty($propertyName) | ||||
->setLabel($label) | ->setLabel($label) | ||||
->setTemplatePath('@LcSov/tabler/crud/field/collection.html.twig') | |||||
->setTemplatePath('@LcSov/adminlte/crud/field/collection.html.twig') | |||||
->setFormType(CollectionType::class) | ->setFormType(CollectionType::class) | ||||
->addWebpackEncoreEntries('adminlte-field-collection') | ->addWebpackEncoreEntries('adminlte-field-collection') | ||||
->setFormTypeOption('allow_add', true) | ->setFormTypeOption('allow_add', true) |
decorates: EasyCorp\Bundle\EasyAdminBundle\Form\Type\CrudFormType | decorates: EasyCorp\Bundle\EasyAdminBundle\Form\Type\CrudFormType | ||||
arguments: ['@form.type_guesser.doctrine', '@.inner'] | arguments: ['@form.type_guesser.doctrine', '@.inner'] | ||||
Lc\SovBundle\Doctrine\EntityManager: | |||||
public: false | |||||
decorates: doctrine.orm.default_entity_manager | |||||
arguments: ["@.inner"] | |||||
# EasyCorp\Bundle\EasyAdminBundle\Form\Type\CrudFormType: | # EasyCorp\Bundle\EasyAdminBundle\Form\Type\CrudFormType: | ||||
# class: Lc\SovBundle\Form\Type\CrudFormType | |||||
# class: Lc\SovBundle\Form\Type\CrudFormType |
{# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #} | |||||
{# @var action \EasyCorp\Bundle\EasyAdminBundle\Dto\ActionDto #} | |||||
{# @var entity \EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto #} | |||||
{% if entity.instance.childrens|length > 0%} | |||||
{{ include('@EasyAdmin/crud/action.html.twig') }} | |||||
{% endif %} |
<tr> | <tr> | ||||
{% if has_batch_actions %} | {% if has_batch_actions %} | ||||
<th class=""> | <th class=""> | ||||
<input type="hidden" id="batch_form_entityIds" value="" /> | |||||
<input type="hidden" id="batch_form_entityIds" value=""/> | |||||
<span><input type="checkbox" | <span><input type="checkbox" | ||||
class="form-check-input m-0 align-middle form-batch-checkbox-all"></span> | class="form-check-input m-0 align-middle form-batch-checkbox-all"></span> | ||||
</th> | </th> | ||||
{% for field in fields ?? [] %} | {% for field in fields ?? [] %} | ||||
{% set field = field.getAsDto() %} | {% set field = field.getAsDto() %} | ||||
{% set is_sorting_field = ea.search.isSortingField(field.property) %} | |||||
{% set next_sort_direction = is_sorting_field ? (ea.search.sortDirection(field.property) == ea_sort_desc ? ea_sort_asc : ea_sort_desc) : ea_sort_desc %} | |||||
{% set column_icon = is_sorting_field ? (next_sort_direction == ea_sort_desc ? 'fa-arrow-up' : 'fa-arrow-down') : 'fa-sort' %} | |||||
<th class="{{ is_sorting_field ? 'sorted' }} {{ field.isVirtual ? 'field-virtual' }} {% if field.textAlign %}text-{{ field.textAlign }}{% endif %}" | |||||
dir="{{ ea.i18n.textDirection }}"> | |||||
{% if field.isSortable %} | |||||
<a href="{{ ea_url({ page: 1, sort: { (field.property): next_sort_direction } }).includeReferrer() }}"> | |||||
{{ field.label|raw }} <i class="fa fa-fw {{ column_icon }}"></i> | |||||
</a> | |||||
{% else %} | |||||
<span>{{ field.label|raw }}</span> | |||||
{% endif %} | |||||
</th> | |||||
{% if field.isDisplayedOn('index') %} | |||||
{% set is_sorting_field = ea.search.isSortingField(field.property) %} | |||||
{% set next_sort_direction = is_sorting_field ? (ea.search.sortDirection(field.property) == ea_sort_desc ? ea_sort_asc : ea_sort_desc) : ea_sort_desc %} | |||||
{% set column_icon = is_sorting_field ? (next_sort_direction == ea_sort_desc ? 'fa-arrow-up' : 'fa-arrow-down') : 'fa-sort' %} | |||||
<th class="{{ is_sorting_field ? 'sorted' }} {{ field.isVirtual ? 'field-virtual' }} {% if field.textAlign %}text-{{ field.textAlign }}{% endif %}" | |||||
dir="{{ ea.i18n.textDirection }}"> | |||||
{% if field.isSortable %} | |||||
<a href="{{ ea_url({ page: 1, sort: { (field.property): next_sort_direction } }).includeReferrer() }}"> | |||||
{{ field.label ? field.label|raw : field.getProperty|raw }} <i class="fa fa-fw {{ column_icon }}"></i> | |||||
</a> | |||||
{% else %} | |||||
<span>{{ field.label ? field.label|raw : field.getProperty|raw }}</span> | |||||
{% endif %} | |||||
</th> | |||||
{% endif %} | |||||
{% endfor %} | {% endfor %} | ||||
<th class="w-1" {% if ea.crud.showEntityActionsAsDropdown %}width="10px"{% endif %} | <th class="w-1" {% if ea.crud.showEntityActionsAsDropdown %}width="10px"{% endif %} |