Просмотр исходного кода

Adapatation à symfony6 et easyadmin4

feature/symfony6.1
Fabien Normand 1 год назад
Родитель
Сommit
f2c9e1fdcd
36 измененных файлов: 354 добавлений и 469 удалений
  1. +1
    -1
      Authenticator/LoginFormAuthenticator.php
  2. +0
    -3
      Builder/User/UserBuilder.php
  3. +3
    -3
      Command/CreateUserCommand.php
  4. +1
    -1
      Command/SiteSettingInitCommand.php
  5. +40
    -46
      Controller/AbstractAdminController.php
  6. +64
    -45
      Controller/ControllerTrait.php
  7. +1
    -1
      Controller/Dashboard/DashboardAdminController.php
  8. +1
    -5
      Controller/Reminder/ReminderAdminController.php
  9. +1
    -1
      Controller/Ticket/TicketAdminController.php
  10. +3
    -5
      Controller/User/AccountAdminController.php
  11. +5
    -6
      Controller/User/UserAdminController.php
  12. +2
    -2
      Definition/Field/AbstractFieldDefinition.php
  13. +1
    -1
      Definition/Field/User/UserFieldDefinition.php
  14. +2
    -4
      Doctrine/EntityManager.php
  15. +5
    -5
      EventListener/ExceptionListener.php
  16. +3
    -4
      EventSubscriber/User/UserPasswordEventSubscriber.php
  17. +0
    -149
      Field/AssociationField.php
  18. +9
    -10
      Field/Filter/FilterManager.php
  19. +2
    -1
      LcSovBundle.php
  20. +6
    -1
      Model/User/UserModel.php
  21. +111
    -110
      Notification/MailMailjetNotification.php
  22. +0
    -1
      Repository/Site/NewsStore.php
  23. +0
    -2
      Repository/Ticket/TicketStore.php
  24. +4
    -0
      Resources/assets/app/admin/reminder/reminder.scss
  25. +22
    -0
      Resources/assets/app/adminlte/field/collection/form.scss
  26. +0
    -22
      Resources/assets/app/adminlte/form/form.scss
  27. +0
    -1
      Resources/assets/app/adminlte/main/scss/form/_checkboxradio.scss
  28. +2
    -1
      Resources/assets/functions/widget-collection.js
  29. +3
    -0
      Resources/config/services.yaml
  30. Двоичные данные
      Resources/public/img/favicon.png
  31. +6
    -0
      Resources/translations/admin.fr.yaml
  32. +2
    -2
      Resources/views/adminlte/crud/field/association.html.twig
  33. +22
    -25
      Resources/views/adminlte/crud/form.html.twig
  34. +26
    -2
      Resources/views/adminlte/crud/form_theme.html.twig
  35. +5
    -5
      Translation/FlashBagTranslator.php
  36. +1
    -4
      Twig/StoreTwigExtension.php

+ 1
- 1
Authenticator/LoginFormAuthenticator.php Просмотреть файл

@@ -53,7 +53,7 @@ class LoginFormAuthenticator extends AbstractLoginFormAuthenticator
return $request->isMethod('POST') && $this->getLoginUrl($request) === $request->getPathInfo();
}

public function authenticate(Request $request): PassportInterface
public function authenticate(Request $request):Passport
{

$email = trim($request->request->get('email'));

+ 0
- 3
Builder/User/UserBuilder.php Просмотреть файл

@@ -3,14 +3,11 @@
namespace Lc\SovBundle\Builder\User;

use Doctrine\ORM\EntityManagerInterface;
use Lc\CaracoleBundle\Model\Address\AddressInterface;
use Lc\SovBundle\Doctrine\EntityInterface;
use Lc\SovBundle\Doctrine\Extension\BlameableInterface;
use Lc\SovBundle\Factory\User\UserFactory;
use Lc\SovBundle\Model\Newsletter\NewsletterInterface;
use Lc\SovBundle\Model\Ticket\TicketInterface;
use Lc\SovBundle\Model\User\UserInterface;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Lc\SovBundle\Repository\User\UserStore;
use Lc\SovBundle\Solver\User\UserSolver;


+ 3
- 3
Command/CreateUserCommand.php Просмотреть файл

@@ -10,14 +10,14 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\Question;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;

class CreateUserCommand extends Command
{
private $passwordEncoder;
private $em;

public function __construct(UserPasswordEncoderInterface $passwordEncoder, EntityManager $entityManager)
public function __construct(UserPasswordHasherInterface $passwordEncoder, EntityManager $entityManager)
{
parent::__construct();

@@ -55,7 +55,7 @@ class CreateUserCommand extends Command
$user->setEmail($email);
$user->setRoles(array($role));

$password = $this->passwordEncoder->encodePassword($user, $password);
$password = $this->passwordEncoder->hashPassword($user, $password);

$user->setPassword($password);


+ 1
- 1
Command/SiteSettingInitCommand.php Просмотреть файл

@@ -15,7 +15,7 @@ class SiteSettingInitCommand extends Command

protected SettingBuilder $settingBuilder;

public function __construct(string $name = null, SettingBuilder $settingBuilder)
public function __construct(string $name = null, SettingBuilder $settingBuilder=null)
{
parent::__construct($name);
$this->settingBuilder = $settingBuilder;

+ 40
- 46
Controller/AbstractAdminController.php Просмотреть файл

@@ -20,9 +20,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto;
use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto;
use EasyCorp\Bundle\EasyAdminBundle\Dto\SearchDto;
use EasyCorp\Bundle\EasyAdminBundle\Event\AfterCrudActionEvent;
use EasyCorp\Bundle\EasyAdminBundle\Event\AfterEntityUpdatedEvent;
use EasyCorp\Bundle\EasyAdminBundle\Event\BeforeCrudActionEvent;
use EasyCorp\Bundle\EasyAdminBundle\Event\BeforeEntityDeletedEvent;
use EasyCorp\Bundle\EasyAdminBundle\Event\BeforeEntityUpdatedEvent;
use EasyCorp\Bundle\EasyAdminBundle\Exception\ForbiddenActionException;
use EasyCorp\Bundle\EasyAdminBundle\Exception\InsufficientEntityPermissionException;
@@ -37,31 +35,24 @@ 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\Model\Section\SectionInterface;
use Lc\SovBundle\Component\EntityComponent;
use Lc\SovBundle\Definition\ActionDefinition;
use Lc\SovBundle\Doctrine\Extension\DevAliasInterface;
use Lc\SovBundle\Doctrine\Extension\OpenGraphInterface;
use Lc\SovBundle\Doctrine\Extension\SeoInterface;
use Lc\SovBundle\Doctrine\Extension\SortableInterface;
use Lc\SovBundle\Doctrine\Extension\StatusInterface;
use Lc\SovBundle\Doctrine\Extension\TranslatableInterface;
use Lc\SovBundle\Doctrine\Extension\TreeInterface;
use Lc\SovBundle\Field\CollectionField;
use Lc\SovBundle\Field\Filter\FilterManager;
use Lc\SovBundle\Field\ImageManagerField;
use Lc\SovBundle\Form\Common\FiltersFormType;
use Lc\SovBundle\Form\Common\PositionType;
use Lc\SovBundle\Model\User\UserInterface;
use Lc\SovBundle\Repository\EntityRepository;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Lc\SovBundle\Translation\FlashBagTranslator;
use Lc\SovBundle\Translation\TranslatorAdmin;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
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\Response;

abstract class AbstractAdminController extends EaAbstractCrudController
@@ -69,11 +60,14 @@ abstract class AbstractAdminController extends EaAbstractCrudController
use ControllerTrait;

protected FormInterface $filtersForm;
protected TranslatorAdmin $translatorAdmin;
protected bool $isRepositoryQueryFiltered = false;

abstract public function getRepositoryQuery(): RepositoryQueryInterface;




public function configureResponseParameters(KeyValueStore $responseParameters): KeyValueStore
{
if ($responseParameters->get('global_actions')) {
@@ -107,8 +101,8 @@ abstract class AbstractAdminController extends EaAbstractCrudController
public function overrideGlobalActions(?ActionCollection $actions): void
{
if ($actions) {
$context = $this->get(AdminContextProvider::class)->getContext();
$adminUrlGenerator = $this->get(AdminUrlGenerator::class);
$context = $this->getAdminContextProvider()->getContext();
$adminUrlGenerator = $this->getAdminUrlGenerator();

foreach ($actions as $i => $action) {
//récriture du bouton 'retour au parent'
@@ -185,12 +179,12 @@ abstract class AbstractAdminController extends EaAbstractCrudController
$entityClass = $this->getEntityFqcn();
$paramListMaxResults = 'listMaxResults';
$paramSessionListMaxResults = $entityClass . '-' . $paramListMaxResults;
$requestListMaxResults = $this->get(RequestStack::class)->getCurrentRequest()->get($paramListMaxResults);
$requestListMaxResults = $this->getRequestStack()->getCurrentRequest()->get($paramListMaxResults);

if ($requestListMaxResults) {
$this->get('session')->set($paramSessionListMaxResults, $requestListMaxResults);
$this->getRequestStack()->getSession()->set($paramSessionListMaxResults, $requestListMaxResults);
}
$maxResults = $this->get('session')->get($paramSessionListMaxResults) ? $this->get('session')->get(
$maxResults = $this->getRequestStack()->getSession()->get($paramSessionListMaxResults) ? $this->get('session')->get(
$paramSessionListMaxResults
) : 30;

@@ -233,7 +227,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController
public function sort(AdminContext $context)
{
$event = new BeforeCrudActionEvent($context);
$this->get('event_dispatcher')->dispatch($event);
$this->container->get('event_dispatcher')->dispatch($event);
if ($event->isPropagationStopped()) {
return $event->getResponse();
}
@@ -244,17 +238,17 @@ abstract class AbstractAdminController extends EaAbstractCrudController
}

$fields = FieldCollection::new($this->configureFields(Crud::PAGE_INDEX));
$filters = $this->get(FilterFactory::class)->create(
$filters = $this->container->get(FilterFactory::class)->create(
$context->getCrud()->getFiltersConfig(),
$fields,
$context->getEntity()
);

$queryBuilder = $this->createSortQueryBuilder($context->getSearch(), $context->getEntity(), $fields, $filters);
$paginator = $this->get(PaginatorFactory::class)->create($queryBuilder);
$paginator = $this->container->get(PaginatorFactory::class)->create($queryBuilder);

$entities = $this->get(EntityFactory::class)->createCollection($context->getEntity(), $paginator->getResults());
$this->get(EntityFactory::class)->processFieldsForAll($entities, $fields);
$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()))
->add(
@@ -268,7 +262,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController
)
->getForm();

$entityManager = $this->getDoctrine()->getManagerForClass($this->getEntityFqcn());
$entityManager = $this->container->get('doctrine')->getManagerForClass($this->getEntityFqcn());
$repository = $entityManager->getRepository($this->getEntityFqcn());

$sortableForm->handleRequest($context->getRequest());
@@ -283,7 +277,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController
}

$event = new BeforeEntityUpdatedEvent($entityInstance);
$this->get('event_dispatcher')->dispatch($event);
$this->container->get('event_dispatcher')->dispatch($event);
$entityInstance = $event->getEntityInstance();

$entityInstance->setPosition($elm['position']);
@@ -293,7 +287,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController
//$this->get('event_dispatcher')->dispatch(new AfterEntityUpdatedEvent($entityInstance));
}

$url = $this->get(AdminUrlGenerator::class)
$url = $this->container->get(AdminUrlGenerator::class)
->setAction(ActionDefinition::INDEX)
->generateUrl();
$this->addFlashTranslator('success', 'sorted');
@@ -317,7 +311,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController
);
$responseParameters->set('fields', $this->configureFields('index'));
$event = new AfterCrudActionEvent($context, $responseParameters);
$this->get('event_dispatcher')->dispatch($event);
$this->container->get('event_dispatcher')->dispatch($event);
if ($event->isPropagationStopped()) {
return $event->getResponse();
}
@@ -373,7 +367,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController
FilterCollection $filters
): RepositoryQueryInterface
{
$repositoryQuery = $this->get(EntityRepository::class)->createRepositoryQuery(
$repositoryQuery = $this->container->get(EntityRepository::class)->createRepositoryQuery(
$this->getRepositoryQuery(),
$searchDto,
$entityDto,
@@ -404,7 +398,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController
)
);

$filterManager = $this->get(FilterManager::class);
$filterManager = $this->getFilterManager();

$this->filtersForm->handleRequest($searchDto->getRequest());
$this->isRepositoryQueryFiltered = $filterManager->handleFiltersForm($repositoryQuery, $this->filtersForm, $fields, $entityDto);
@@ -474,14 +468,14 @@ abstract class AbstractAdminController extends EaAbstractCrudController
{
$entityManager->update($entityInstance);
$entityManager->flush();
$this->get(FlashBagTranslator::class)->add('success', 'updated', $this->getTranslationEntityName());
$this->getFlashBagTranslator()->add('success', 'updated', $this->getTranslationEntityName());
}

public function persistEntity(EntityManagerInterface $entityManager, $entityInstance): void
{
$entityManager->create($entityInstance);
$entityManager->flush();
$this->get(FlashBagTranslator::class)->add('success', 'created', $this->getTranslationEntityName());
$this->getFlashBagTranslator()->add('success', 'created', $this->getTranslationEntityName());
}

public function deleteEntity(EntityManagerInterface $entityManager, $entityInstance): void
@@ -493,7 +487,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController
$entityManager->delete($entityInstance);
}
$entityManager->flush();
$this->get(FlashBagTranslator::class)->add('success', 'deleted', $this->getTranslationEntityName());
$this->getFlashBagTranslator()->add('success', 'deleted', $this->getTranslationEntityName());
}

public function configureActions(Actions $actions): Actions
@@ -517,11 +511,11 @@ abstract class AbstractAdminController extends EaAbstractCrudController
{
$duplicateAction = Action::new(
ActionDefinition::DUPLICATE,
$this->get(TranslatorAdmin::class)->transAction(ActionDefinition::DUPLICATE),
$this->translatorAdmin->transAction(ActionDefinition::DUPLICATE),
'fa fa-fw fa-copy'
)
->linkToCrudAction(ActionDefinition::DUPLICATE)
->setLabel($this->get(TranslatorAdmin::class)->transAction(ActionDefinition::DUPLICATE))
->setLabel($this->translatorAdmin->transAction(ActionDefinition::DUPLICATE))
->setCssClass('in-dropdown text-info action-confirm');

return $duplicateAction;
@@ -537,7 +531,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController
ActionDefinition::NEW,
[
'icon' => 'plus',
'label' => $this->get(TranslatorAdmin::class)->transAction('create'),
'label' => $this->translatorAdmin->transAction('create'),
'add_class' => 'btn-sm',
]
);
@@ -552,7 +546,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController
'label' => false,
'html_attributes' => array(
'data-toggle' => 'tooltip',
'title' => $this->get(TranslatorAdmin::class)->transAction('edit'),
'title' => $this->translatorAdmin->transAction('edit'),
),
]
);
@@ -567,7 +561,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController
'label' => false,
'html_attributes' => array(
'data-toggle' => 'tooltip',
'title' => $this->get(TranslatorAdmin::class)->transAction('detail'),
'title' =>$this->translatorAdmin->transAction('detail'),
),
]
);
@@ -579,7 +573,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController
[
'icon' => 'trash',
'dropdown' => true,
'label' => $this->get(TranslatorAdmin::class)->transAction('delete'),
'label' => $this->translatorAdmin->transAction('delete'),
'class' => 'dropdown-item text-danger in-dropdown action-delete',
]
);
@@ -591,7 +585,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController
[
'class' => 'btn btn-sm btn-danger',
'icon' => 'trash',
'label' => $this->get(TranslatorAdmin::class)->transAction('delete'),
'label' => $this->translatorAdmin->transAction('delete'),
]
);
}
@@ -610,7 +604,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController
[
'add_class' => 'float-right ',
'icon' => 'check',
'label' => $this->get(TranslatorAdmin::class)->transAction('save_and_return'),
'label' => $this->translatorAdmin->transAction('save_and_return'),
]
);

@@ -621,7 +615,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController
[
'icon' => 'chevron-left',
'class' => 'btn btn-link',
'label' => $this->get(TranslatorAdmin::class)->transAction('back_index'),
'label' => $this->translatorAdmin->transAction('back_index'),
]
);

@@ -632,7 +626,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController
ActionDefinition::SAVE_AND_CONTINUE,
[
'class' => 'btn btn-info float-right action-save-continue',
'label' => $this->get(TranslatorAdmin::class)->transAction('save_and_continue'),
'label' =>$this->translatorAdmin->transAction('save_and_continue'),
]
);

@@ -643,7 +637,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController
[
'icon' => 'trash',
'class' => 'btn btn-outline-danger action-delete',
'label' => $this->get(TranslatorAdmin::class)->transAction('delete'),
'label' => $this->translatorAdmin->transAction('delete'),
]
);
}
@@ -663,7 +657,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController
[
'add_class' => 'float-right',
'icon' => 'check',
'label' => $this->get(TranslatorAdmin::class)->transAction('save_and_return'),
'label' => $this->translatorAdmin->transAction('save_and_return'),
]
);

@@ -674,7 +668,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController
[
'icon' => 'chevron-left',
'class' => 'btn btn-link',
'label' => $this->get(TranslatorAdmin::class)->transAction('back_index'),
'label' => $this->translatorAdmin->transAction('back_index'),
]
);

@@ -684,7 +678,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController
ActionDefinition::SAVE_AND_ADD_ANOTHER,
[
'class' => 'btn btn-info float-right',
'label' => $this->get(TranslatorAdmin::class)->transAction('save_and_add_another'),
'label' => $this->translatorAdmin->transAction('save_and_add_another'),
]
);
}
@@ -709,7 +703,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController
if ($this->isInstanceOf(SortableInterface::class)) {
$sortAction = Action::new(
ActionDefinition::SORT,
$this->get(TranslatorAdmin::class)->transAction(ActionDefinition::SORT),
$this->translatorAdmin->transAction(ActionDefinition::SORT),
'fa fa-sort'
)
->linkToCrudAction(ActionDefinition::SORT)
@@ -725,7 +719,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController
if ($this->isInstanceOf(TreeInterface::class)) {
$indexChildAction = Action::new(
ActionDefinition::INDEX_CHILDREN,
$this->get(TranslatorAdmin::class)->transAction(ActionDefinition::INDEX_CHILDREN),
$this->translatorAdmin->transAction(ActionDefinition::INDEX_CHILDREN),
'fa fa-list'
)
->linkToCrudAction(ActionDefinition::INDEX)
@@ -736,7 +730,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController

$backParentAction = Action::new(
ActionDefinition::INDEX_PARENT,
$this->get(TranslatorAdmin::class)->transAction(ActionDefinition::INDEX_PARENT),
$this->getTranslatorAdmin()->transAction(ActionDefinition::INDEX_PARENT),
'fa fa-chevron-left'
)
->linkToCrudAction(ActionDefinition::INDEX)
@@ -812,7 +806,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController
$controller->configureFields($autocompleteContext['originatingPage'])
)->getByProperty($autocompleteContext['propertyName']);

$filterManager = $this->get(FilterManager::class);
$filterManager = $this->getFilterManager();
$filteredValue = ['value' => $context->getRequest()->query->get('q')];
$filterManager->applyFilter($repositoryQuery, $field, $filteredValue);
$repositoryQuery->select('.' . $autocompleteContext['propertyName']);

+ 64
- 45
Controller/ControllerTrait.php Просмотреть файл

@@ -3,6 +3,7 @@
namespace Lc\SovBundle\Controller;

use Doctrine\ORM\EntityManagerInterface;
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider;
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator;
use Knp\Component\Pager\PaginatorInterface;
use Lc\SovBundle\Component\FileComponent;
@@ -25,13 +26,12 @@ use Lc\SovBundle\Repository\EntityRepository;
use Lc\SovBundle\Solver\Setting\SettingSolver;
use Lc\SovBundle\Translation\FlashBagTranslator;
use Lc\SovBundle\Translation\TranslatorAdmin;
use Mailjet\MailjetSwiftMailer\SwiftMailer\MailjetTransport;
//use Mailjet\MailjetSwiftMailer\SwiftMailer\MailjetTransport;
use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Core\Security;
@@ -41,6 +41,15 @@ use Twig\Environment;

trait ControllerTrait
{
protected TranslatorAdmin $translatorAdmin;
protected RequestStack $requestStack;
public function __construct(
TranslatorAdmin $translatorAdmin,
RequestStack $requestStack
){
$this->translatorAdmin = $translatorAdmin;
$this->requestStack = $requestStack;
}
/*
* Fonctions privées
*/
@@ -50,7 +59,7 @@ trait ControllerTrait
set_time_limit(0);
}

//TODO si vous avez une erreur avec le :array c'est qu'il faut passer à symfony 5.4.
//Si vous avez une erreur avec le :array c'est qu'il faut passer à symfony 5.4.
//Suivez la procédure suivante : https://symfony.com/doc/current/setup/unstable_versions.html#upgrading-your-project-to-an-unstable-symfony-version
//En gros il faut changer tout les dépendances symfony/ qui sont en 5.3 par 5.4 dans composer.json
public static function getSubscribedServices(): array
@@ -64,7 +73,7 @@ trait ControllerTrait
Security::class => Security::class,
EntityManagerInterface::class => EntityManagerInterface::class,
UrlGeneratorInterface::class => UrlGeneratorInterface::class,
SessionInterface::class => SessionInterface::class,
// SessionInterface::class => SessionInterface::class,
PaginatorInterface::class => PaginatorInterface::class,
RequestStack::class => RequestStack::class,
EventDispatcherInterface::class => EventDispatcherInterface::class,
@@ -75,7 +84,7 @@ trait ControllerTrait
TranslatorAdmin::class => TranslatorAdmin::class,
FilterManager::class => FilterManager::class,
FlashBagTranslator::class => FlashBagTranslator::class,
MailjetTransport::class => MailjetTransport::class,
// MailjetTransport::class => MailjetTransport::class,
AdminUrlGenerator::class => AdminUrlGenerator::class,
SettingSolver::class => SettingSolver::class,
ComponentContainer::class => ComponentContainer::class,
@@ -97,7 +106,7 @@ trait ControllerTrait
}


$this->get(FlashBagTranslator::class)->add(
$this->container->get(FlashBagTranslator::class)->add(
$type,
$translationKeyName,
$translationEntityName,
@@ -116,7 +125,7 @@ trait ControllerTrait
int $entityId = null,
array $extraParam = array()
): string {
$adminUrlGenerator = $this->get(AdminUrlGenerator::class);
$adminUrlGenerator = $this->container->get(AdminUrlGenerator::class);
if ($controller) {
$adminUrlGenerator->setController($controller);
}
@@ -141,157 +150,152 @@ trait ControllerTrait

public function getTemplating(): Environment
{
return $this->get(Environment::class);
return $this->container->get(Environment::class);
}

public function getApplicationDefinition(): ApplicationDefinition
{
return $this->get(ApplicationDefinition::class);
return $this->container->get(ApplicationDefinition::class);
}

public function getEntityManager(): EntityManagerInterface
{
return $this->get(EntityManagerInterface::class);
return $this->container->get(EntityManagerInterface::class);
}

public function getRouter(): UrlGeneratorInterface
{
return $this->get(UrlGeneratorInterface::class);
}

public function getSession(): SessionInterface
{
return $this->get(SessionInterface::class);
return $this->container->get(UrlGeneratorInterface::class);
}

public function getSecurity(): Security
{
return $this->get(Security::class);
return $this->container->get(Security::class);
}

public function getPaginator(): PaginatorInterface
{
return $this->get(PaginatorInterface::class);
return $this->container->get(PaginatorInterface::class);
}

public function getRequestStack(): RequestStack
{
return $this->get(RequestStack::class);
return $this->container->get(RequestStack::class);
}

public function getEventDispatcher(): EventDispatcherInterface
{
return $this->get(EventDispatcherInterface::class);
return $this->container->get(EventDispatcherInterface::class);
}

public function getParameterBag(): ParameterBagInterface
{
return $this->get(ParameterBagInterface::class);
return $this->container->get(ParameterBagInterface::class);
}

public function getTranslator(): TranslatorInterface
{
return $this->get(TranslatorInterface::class);
return $this->container->get(TranslatorInterface::class);
}

public function getPdfGenerator(): PdfGenerator
{
return $this->get(PdfGenerator::class);
return $this->container->get(PdfGenerator::class);
}

public function getTranslatorAdmin(): TranslatorAdmin
{
return $this->get(TranslatorAdmin::class);
return $this->container->get(TranslatorAdmin::class);
}

public function getLogger(): LoggerInterface
{
return $this->get(LoggerInterface::class);
return $this->container->get(LoggerInterface::class);
}

public function getMailjetTransport(): MailjetTransport
{
return $this->get(MailjetTransport::class);
}
// public function getMailjetTransport(): MailjetTransport
// {
// return $this->container->get(MailjetTransport::class);
// }

public function getAdminUrlGenerator(): AdminUrlGenerator
{
return $this->get(AdminUrlGenerator::class);
return $this->container->get(AdminUrlGenerator::class);
}

public function getKernel(): KernelInterface
{
return $this->get(KernelInterface::class);
return $this->container->get(KernelInterface::class);
}

public function getSettingSolver(): SettingSolver
{
return $this->get(SettingSolver::class);
return $this->container->get(SettingSolver::class);
}

public function getSettingValue($entity, $settingName)
{
return $this->getSettingSolver()->getSettingValue($entity, $settingName);
return $this->container->getSettingSolver()->getSettingValue($entity, $settingName);
}

public function getComponentContainer(): ComponentContainer
{
return $this->get(ComponentContainer::class);
return $this->container->get(ComponentContainer::class);
}

public function getFileContainer(): FileContainer
{
return $this->get(FileContainer::class);
return $this->container->get(FileContainer::class);
}

public function getNewsletterContainer(): NewsletterContainer
{
return $this->get(NewsletterContainer::class);
return $this->container->get(NewsletterContainer::class);
}

public function getReminderContainer(): ReminderContainer
{
return $this->get(ReminderContainer::class);
return $this->container->get(ReminderContainer::class);
}

public function getNewsContainer(): NewsContainer
{
return $this->get(NewsContainer::class);
return $this->container->get(NewsContainer::class);
}

public function getPageContainer(): PageContainer
{
return $this->get(PageContainer::class);
return $this->container->get(PageContainer::class);
}

public function getSiteContainer(): SiteContainer
{
return $this->get(SiteContainer::class);
return $this->container->get(SiteContainer::class);
}

public function getTicketContainer(): TicketContainer
{
return $this->get(TicketContainer::class);
return $this->container->get(TicketContainer::class);
}

public function getTicketMessageContainer(): TicketMessageContainer
{
return $this->get(TicketMessageContainer::class);
return $this->container->get(TicketMessageContainer::class);
}

public function getGroupUserContainer(): GroupUserContainer
{
return $this->get(GroupUserContainer::class);
return $this->container->get(GroupUserContainer::class);
}

public function getUserContainer(): UserContainer
{
return $this->get(UserContainer::class);
return $this->container->get(UserContainer::class);
}

public function getSiteSettingContainer(): SiteSettingContainer
{
return $this->get(SiteSettingContainer::class);
return $this->container->get(SiteSettingContainer::class);
}

public function setNoMemoryAndTimeLimit(): void
@@ -300,4 +304,19 @@ trait ControllerTrait
set_time_limit(0);
}

public function getFilterManager():FilterManager
{
return $this->container->get(FilterManager::class);
}

public function getAdminContextProvider(): AdminContextProvider
{
return $this->container->get(AdminContextProvider::class);
}

public function getFlashBagTranslator(): FlashBagTranslator
{
return $this->container->get(FlashBagTranslator::class);
}

}

+ 1
- 1
Controller/Dashboard/DashboardAdminController.php Просмотреть файл

@@ -33,7 +33,7 @@ class DashboardAdminController extends AbstractDashboardController
// the name visible to end users
->setTitle('LA CLIC !')
// the path defined in this method is passed to the Twig asset() function
->setFaviconPath('assets/img/frontend/favicon-pdl.png')
->setFaviconPath('bundles/lcsov/img/favicon.png')
// the domain used by default is 'messages'
->setTranslationDomain('admin');
}

+ 1
- 5
Controller/Reminder/ReminderAdminController.php Просмотреть файл

@@ -3,8 +3,6 @@
namespace Lc\SovBundle\Controller\Reminder;

use Doctrine\ORM\EntityManagerInterface;
use Lc\CaracoleBundle\Resolver\MerchantResolver;
use Lc\CaracoleBundle\Resolver\SectionResolver;
use Lc\SovBundle\Container\Reminder\ReminderContainer;
use Lc\SovBundle\Controller\ControllerTrait;
use Lc\SovBundle\Factory\Reminder\ReminderFactory;
@@ -26,8 +24,6 @@ class ReminderAdminController extends AbstractController
protected ReminderContainer $reminderContainer;
protected FormFactoryInterface $formFactory;
protected UrlGeneratorInterface $urlGenerator;
protected MerchantResolver $merchantResolver;
protected SectionResolver $sectionResolver;
protected ParameterBagInterface $parameterBag;

public function __construct(
@@ -99,7 +95,7 @@ class ReminderAdminController extends AbstractController
$this->entityManager->persist($reminder);
$this->entityManager->flush();

$this->addFlashTranslator('success', 'added');
$this->addFlashTranslator('success', 'added', 'Reminder');
}

return $this->redirect($request->headers->get('referer'));

+ 1
- 1
Controller/Ticket/TicketAdminController.php Просмотреть файл

@@ -46,7 +46,7 @@ abstract class TicketAdminController extends AbstractAdminController

public function configureCrud(Crud $crud): Crud
{
$crud = parent::configureCrud($crud); // TODO: Change the autogenerated stub
$crud = parent::configureCrud($crud);
$crud->setDefaultSort(array('updatedAt' => 'DESC'));
$crud->overrideTemplate('crud/detail', '@LcSov/admin/ticket/detail.html.twig');
return $crud;

+ 3
- 5
Controller/User/AccountAdminController.php Просмотреть файл

@@ -4,15 +4,13 @@ namespace Lc\SovBundle\Controller\User;

use Doctrine\ORM\EntityManagerInterface;
use Lc\SovBundle\Controller\ControllerTrait;
use Lc\SovBundle\Doctrine\EntityManager;
use Lc\SovBundle\Form\User\ChangePasswordFormType;
use Lc\SovBundle\Form\User\ProfileFormType;
use Lc\SovBundle\Model\User\UserModel;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use Symfony\Component\Translation\TranslatableMessage;
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
use Symfony\Component\Routing\Annotation\Route;

class AccountAdminController extends AbstractController
@@ -57,7 +55,7 @@ class AccountAdminController extends AbstractController
/**
* @Route("/admin/account/password", name="sov_admin_account_password")
*/
public function changePassword(Request $request, UserPasswordEncoderInterface $passwordEncoder): Response
public function changePassword(Request $request, UserPasswordHasherInterface $passwordEncoder): Response
{
$user = $this->getUser();
$form = $this->createForm(ChangePasswordFormType::class, $user);
@@ -69,7 +67,7 @@ class AccountAdminController extends AbstractController

$plainPassword = $form->get('plain_password')->getData();

$user->setPassword($passwordEncoder->encodePassword($user, $plainPassword));
$user->setPassword($passwordEncoder->hashPassword($user, $plainPassword));

$this->entityManager->update($user);
$this->entityManager->flush();

+ 5
- 6
Controller/User/UserAdminController.php Просмотреть файл

@@ -34,13 +34,12 @@ use Lc\SovBundle\Model\User\UserInterface;
use Lc\SovBundle\Translation\FlashBagTranslator;
use Lc\SovBundle\Translation\TranslatorAdmin;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Session\SessionInterface;

abstract class UserAdminController extends AbstractAdminController
{
public function buildIndexActions(Actions $actions): void
{
parent::buildIndexActions($actions); // TODO: Change the autogenerated stub
parent::buildIndexActions($actions);

$actions->add(Crud::PAGE_INDEX, $this->getSwitchUserAction());
}
@@ -49,11 +48,11 @@ abstract class UserAdminController extends AbstractAdminController
{
$switchAction = Action::new(
ActionDefinition::SWITCH_USER,
$this->get(TranslatorAdmin::class)->transAction(ActionDefinition::SWITCH_USER),
$this->getTranslatorAdmin()->transAction(ActionDefinition::SWITCH_USER),
'fa fa-fw fa-user-secret'
)
->linkToCrudAction(ActionDefinition::SWITCH_USER)
->setLabel($this->get(TranslatorAdmin::class)->transAction(ActionDefinition::SWITCH_USER))
->setLabel($this->getTranslatorAdmin()->transAction(ActionDefinition::SWITCH_USER))
->setCssClass('in-dropdown text-info action-confirm action_switch');

return $switchAction;
@@ -61,7 +60,7 @@ abstract class UserAdminController extends AbstractAdminController

public function overrideEntitiesActions(?EntityCollection $entities, string $pageName): void
{
parent::overrideEntitiesActions($entities, $pageName); // TODO: Change the autogenerated stub
parent::overrideEntitiesActions($entities, $pageName);
foreach ($entities as $entity) {
foreach ($entity->getActions() as $action) {
if ($action->getName() == ActionDefinition::SWITCH_USER) {
@@ -90,7 +89,7 @@ abstract class UserAdminController extends AbstractAdminController

public function createEntity(string $entityFqcn)
{
return $this->get(UserContainer::class)->getFactory()->create();
return $this->getUserContainer()->getFactory()->create();
}

public function delete(AdminContext $context)

+ 2
- 2
Definition/Field/AbstractFieldDefinition.php Просмотреть файл

@@ -8,7 +8,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\SovBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use Lc\SovBundle\Field\CKEditorField;
use Lc\SovBundle\Field\CollectionField;
use Lc\SovBundle\Field\ImageManagerField;
@@ -56,7 +56,7 @@ abstract class AbstractFieldDefinition
'status' => StatusField::new('status')->setSortable(true),
'createdAt' => DateTimeField::new('createdAt')->setSortable(true),
'updatedAt' => DateTimeField::new('updatedAt')->setSortable(true),
'createdBy' => AssociationField::new('createdBy'),
'createdBy' => \EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField::new('createdBy'),
'updatedBy' => AssociationField::new('updatedBy')
];
}

+ 1
- 1
Definition/Field/User/UserFieldDefinition.php Просмотреть файл

@@ -8,7 +8,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
use EasyCorp\Bundle\EasyAdminBundle\Field\DateField;
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use Lc\SovBundle\Definition\Field\AbstractFieldDefinition;
use Lc\SovBundle\Definition\RolesDefinition;
use Lc\SovBundle\Solver\Ticket\TicketSolver;

+ 2
- 4
Doctrine/EntityManager.php Просмотреть файл

@@ -88,11 +88,9 @@ class EntityManager extends EntityManagerDecorator
return $this;
}

public function clear($objectName = null): self
public function clear($objectName = null): void
{
$this->wrapped->clear($objectName);

return $this;
}

public function refresh($object): self
@@ -102,7 +100,7 @@ class EntityManager extends EntityManagerDecorator
return $this;
}

public function persist($entity)
public function persist($entity):void
{
$this->wrapped->persist($entity);
}

+ 5
- 5
EventListener/ExceptionListener.php Просмотреть файл

@@ -2,7 +2,7 @@

namespace Lc\SovBundle\EventListener;

use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;

@@ -10,9 +10,9 @@ class ExceptionListener
{

public function __construct(
SessionInterface $session
RequestStack $requestStack
) {
$this->session = $session;
$this->requestStack = $requestStack;
}

public function onKernelException(ExceptionEvent $event)
@@ -23,9 +23,9 @@ class ExceptionListener
// On détecte une erreur interne (500), on remove les sessions qui servent de filtre dans l'admin
if ($exception instanceof HttpExceptionInterface != true) {
if (!headers_sent()) {
foreach ($this->session->all() as $key => $s) {
foreach ($this->requestStack->getSession()->all() as $key => $s) {
if (str_contains($key, "_filter")) {
$this->session->remove($key);
$this->requestStack->getSession()->remove($key);
}
}
}

+ 3
- 4
EventSubscriber/User/UserPasswordEventSubscriber.php Просмотреть файл

@@ -12,14 +12,13 @@ use Lc\SovBundle\Event\EntityManager\EntityManagerEvent;
use Lc\SovBundle\Model\User\UserInterface;
use Lc\SovBundle\Repository\AbstractRepositoryInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;

class UserPasswordEventSubscriber implements EventSubscriberInterface
{
protected $passwordEncoder;

public function __construct(UserPasswordEncoderInterface $passwordEncoder)
public function __construct(UserPasswordHasherInterface $passwordEncoder)
{
$this->passwordEncoder = $passwordEncoder;
}
@@ -37,7 +36,7 @@ class UserPasswordEventSubscriber implements EventSubscriberInterface

if ($entity instanceof UserInterface) {
if ($entity->getPassword() == null) {
$password = $this->passwordEncoder->encodePassword($entity, $entity->generatePassword());
$password = $this->passwordEncoder->hashPassword($entity, $entity->generatePassword());
$entity->setPassword($password);
}
}

+ 0
- 149
Field/AssociationField.php Просмотреть файл

@@ -1,149 +0,0 @@
<?php

namespace Lc\SovBundle\Field;

use Doctrine\ORM\EntityRepository;
use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldInterface;
use EasyCorp\Bundle\EasyAdminBundle\Field\FieldTrait;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;

final class AssociationField implements FieldInterface
{
use FieldTrait;

public const OPTION_AUTOCOMPLETE = 'autocomplete';
public const OPTION_CRUD_CONTROLLER = 'crudControllerFqcn';
public const OPTION_WIDGET = 'widget';
public const OPTION_QUERY_BUILDER_CALLABLE = 'queryBuilderCallable';
/** @internal this option is intended for internal use only */
public const OPTION_RELATED_URL = 'relatedUrl';
/** @internal this option is intended for internal use only */
public const OPTION_DOCTRINE_ASSOCIATION_TYPE = 'associationType';

public const WIDGET_AUTOCOMPLETE = 'autocomplete';
public const WIDGET_NATIVE = 'native';

/** @internal this option is intended for internal use only */
public const PARAM_AUTOCOMPLETE_CONTEXT = 'autocompleteContext';

protected $queryBuilderParameters = array();

/**
* @param string|false|null $label
*/
public static function new(string $propertyName, $label = null): self
{
return (new self())
->setProperty($propertyName)
->setLabel($label)
->setTemplatePath('@LcSov/adminlte/crud/field/association.html.twig')
->setFormType(EntityType::class)
->addCssClass('field-association')
->setCustomOption(self::OPTION_AUTOCOMPLETE, false)
->setCustomOption(self::OPTION_CRUD_CONTROLLER, null)
->setCustomOption(self::OPTION_WIDGET, self::WIDGET_AUTOCOMPLETE)
->setCustomOption(self::OPTION_QUERY_BUILDER_CALLABLE, null)
->setCustomOption(self::OPTION_RELATED_URL, '')
->setCustomOption(self::OPTION_DOCTRINE_ASSOCIATION_TYPE, null);
}

public function setFilterOnDevAlias(string $devAlias): self
{
$this->queryBuilderParameters['devAlias'] = $devAlias;

return $this;
}

public function setFilterIsOnline(): self
{
$this->queryBuilderParameters['status'] = 1;

return $this;
}

public function setLeftJoin($entityName): self
{
$this->queryBuilderParameters['leftJoin'][] = $entityName;

return $this;
}

public function addAndWhere($whereClause, $key, $value): self
{
$this->queryBuilderParameters['andWhere'][] = [
'whereClause' => $whereClause,
'key' => $key,
'value' => $value
];

return $this;
}

public function addOrderBy($field, $direction = 'ASC'): self
{
$this->queryBuilderParameters['orderBy'][] = $field;
$this->queryBuilderParameters['orderByDirection'][] = $direction;

return $this;
}

/**
* @deprecated Utiliser setFormTypeOption('choices', $choices) avec $choices issu d'un Store.
*/
public function initQueryBuilder(): self
{
$param = $this->queryBuilderParameters;
$this->setFormTypeOption(
'query_builder',
function (EntityRepository $er) use ($param) {
$qb = $er->createQueryBuilder('e');

if (isset($param['status'])) {
$qb->andWhere('e.status = :status')->setParameter('status', $param['status']);
}

if (isset($param['orderBy'])) {
foreach ($param['orderBy'] as $i => $field) {
$qb->addOrderBy('e.' . $param['orderBy'][$i], $param['orderByDirection'][$i]);
}
}

if (isset($param['leftJoin'])) {
foreach ($param['leftJoin'] as $i => $entityName) {
$qb->leftJoin('e.' . $entityName, $entityName)->addSelect($entityName);
}
}

if (isset($param['andWhere'])) {
foreach ($param['andWhere'] as $i => $whereClause) {
$qb->andWhere($whereClause['whereClause'])->setParameter($whereClause['key'], $whereClause['value']);
}
}

return $qb;
}
);
return $this;
}

public function autocomplete(): self
{
$this->setCustomOption(self::OPTION_AUTOCOMPLETE, true);

return $this;
}

public function renderAsNativeWidget(bool $asNative = true): self
{
$this->setCustomOption(self::OPTION_WIDGET, $asNative ? self::WIDGET_NATIVE : self::WIDGET_AUTOCOMPLETE);

return $this;
}

public function setCrudController(string $crudControllerFqcn): self
{
$this->setCustomOption(self::OPTION_CRUD_CONTROLLER, $crudControllerFqcn);

return $this;
}
}

+ 9
- 10
Field/Filter/FilterManager.php Просмотреть файл

@@ -22,26 +22,25 @@ use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Form;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Session\SessionInterface;


/**
* @author La clic ! <contact@laclic.fr>
*/
class FilterManager
{
protected $em;
protected EntityManagerInterface $em;
protected RequestStack $requestStack;
protected bool $isFiltered = false;
protected $translatorAdmin;

use FilterTrait;

public function __construct(
SessionInterface $session,
RequestStack $requestStack,
EntityManagerInterface $entityManager,
TranslatorAdmin $translatorAdmin
) {
$this->session = $session;
$this->requestStack = $requestStack;
$this->em = $entityManager;
$this->translatorAdmin = $translatorAdmin;
}
@@ -157,23 +156,23 @@ class FilterManager

//Il existe une valeur posté dans le formulaire
if ($value !== null) {
$this->session->set($sessionParam, $value);
$this->requestStack->getSession()->set($sessionParam, $value);
return $value;
}
// pas de valeur et le form est envoyé, on supprimer le filtre correspondant
elseif($formField->isSubmitted()) {
$this->session->remove($sessionParam);
$this->requestStack->getSession()->remove($sessionParam);
}

//action reset
if ($filtersForm->get('reset')->getData() == 'clearAll') {
$this->session->remove($sessionParam);
$this->requestStack->getSession()->remove($sessionParam);
return null;
}

//Récupération des valeurs stocké en sessions si le forrmFilters n'a pas été posté
if ($this->session->get($sessionParam) && !$filtersForm->isSubmitted() && $formField) {
$value = $this->session->get($sessionParam);
if ($this->requestStack->getSession()->get($sessionParam) && !$filtersForm->isSubmitted() && $formField) {
$value = $this->requestStack->getSession()->get($sessionParam);

//Champ date
if ($formField->getConfig()->getOption('input') == 'datetime') {

+ 2
- 1
LcSovBundle.php Просмотреть файл

@@ -3,12 +3,13 @@
namespace Lc\SovBundle;

use Lc\SovBundle\DependencyInjection\LcSovExtension;
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
use Symfony\Component\HttpKernel\Bundle\Bundle;


class LcSovBundle extends Bundle
{
public function getContainerExtension()
public function getContainerExtension(): ?ExtensionInterface
{
return new LcSovExtension();
}

+ 6
- 1
Model/User/UserModel.php Просмотреть файл

@@ -10,13 +10,14 @@ use Lc\SovBundle\Doctrine\Extension\DevAliasInterface;
use Lc\SovBundle\Doctrine\Extension\DevAliasTrait;
use Lc\SovBundle\Doctrine\Extension\TimestampableTrait;
use Lc\SovBundle\Model\Ticket\TicketInterface;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Lc\SovBundle\Model\User\UserInterface as SovUserInterface;

/**
* @ORM\MappedSuperclass()
*/
abstract class UserModel implements EntityInterface, UserInterface, SovUserInterface, DevAliasInterface
abstract class UserModel implements EntityInterface, UserInterface, SovUserInterface, DevAliasInterface, PasswordAuthenticatedUserInterface
{
use DevAliasTrait;
use TimestampableTrait;
@@ -91,6 +92,10 @@ abstract class UserModel implements EntityInterface, UserInterface, SovUserInter
{
$this->tickets = new ArrayCollection();
}
public function getUserIdentifier(): string
{
return (string) $this->email;
}

public function __toString()
{

+ 111
- 110
Notification/MailMailjetNotification.php Просмотреть файл

@@ -11,114 +11,115 @@ use Twig\Environment;

class MailMailjetNotification
{
const SUBJECT = 'subject';
const SUBJECT_PREFIX = 'subject-prefix';
const TO_EMAIL = 'to-email';
const COPY_TO = 'copy-to';
const COPY_HIDDEN_TO = 'copy-hidden-to';
const TO_NAME = 'to-name';
const FROM_EMAIL = 'from-email';
const FROM_NAME = 'from-name';
const REPLY_TO = 'reply-to';
const CONTENT_TEMPLATE = 'content-template';
const CONTENT_DATA = 'content-data';
const ATTACHMENT_DATA = 'attachment-data';
const ATTACHMENT_FILENAME = 'attachment-filename';
const ATTACHMENT_CONTENT_TYPE = 'attachment-content-type';

protected MailjetTransport $transport;
protected Environment $templating;
protected ParameterBagInterface $parameterBag;
protected SettingSolver $settingSolver;
protected SiteStore $siteStore;

public function __construct(
MailjetTransport $mailjetTransport,
Environment $templating,
ParameterBagInterface $parameterBag,
SettingSolver $settingSolver,
SiteStore $siteStore
) {
$this->transport = $mailjetTransport;
$this->templating = $templating;
$this->parameterBag = $parameterBag;
$this->settingSolver = $settingSolver;
$this->siteStore = $siteStore;
}

public function send($params = [])
{
$siteDefault = $this->siteStore->getOneDefault();

$emailSubjectPrefix = (isset($params[self::SUBJECT_PREFIX]) && $params[self::SUBJECT_PREFIX] && strlen($params[self::SUBJECT_PREFIX]) > 0)
? $params[self::SUBJECT_PREFIX]
: $this->settingSolver->getSettingValue(
$siteDefault,
SiteSettingDefinition::SETTING_EMAIL_SUBJECT_PREFIX
);

$emailFrom = (isset($params[self::FROM_EMAIL]) && $params[self::FROM_EMAIL] && strlen($params[self::FROM_EMAIL]) > 0)
? $params[self::FROM_EMAIL]
: $this->settingSolver->getSettingValue(
$siteDefault,
SiteSettingDefinition::SETTING_EMAIL_FROM
);

$emailFromName = (isset($params[self::FROM_NAME]) && $params[self::FROM_NAME] && strlen($params[self::FROM_NAME]) > 0)
? $params[self::FROM_NAME]
: $this->settingSolver->getSettingValue(
$siteDefault,
SiteSettingDefinition::SETTING_EMAIL_FROM_NAME
);

$message = new \Swift_Message($emailSubjectPrefix . $params[self::SUBJECT]);

if ($this->parameterBag->get('mailjet.dev.redirect.active') == 1) {
$message->addTo(
$this->parameterBag->get('mailjet.dev.redirect.email'),
isset($params[self::TO_NAME]) ?? null
);
} else {
$message->addTo(
$params[self::TO_EMAIL],
isset($params[self::TO_NAME]) ?? null
);
}

$contentData = [];
if (isset($params[self::CONTENT_DATA])) {
$contentData = $params[self::CONTENT_DATA];
}

$message->addFrom($emailFrom, $emailFromName)
->setBody(
$this->templating->render($params[self::CONTENT_TEMPLATE] . '-html.html.twig', $contentData),
'text/html'
)
->addPart($this->templating->render($params[self::CONTENT_TEMPLATE] . '-text.html.twig', $contentData));

if (isset($params[self::COPY_TO]) && strlen($params[self::COPY_TO])) {
$message->addCc($params[self::COPY_TO]);
}

if (isset($params[self::COPY_HIDDEN_TO]) && strlen($params[self::COPY_HIDDEN_TO])) {
$message->addBcc($params[self::COPY_HIDDEN_TO]);
}

if (isset($params[self::REPLY_TO]) && strlen($params[self::REPLY_TO])) {
$message->addReplyTo($params[self::REPLY_TO]);
}

if (isset($params[self::ATTACHMENT_DATA]) && isset($params[self::ATTACHMENT_FILENAME]) && isset($params[self::ATTACHMENT_CONTENT_TYPE])) {
$message->attach(
\Swift_Attachment::newInstance(
$params[self::ATTACHMENT_DATA],
$params[self::ATTACHMENT_FILENAME],
$params[self::ATTACHMENT_CONTENT_TYPE]
)
);
}

return $this->transport->send($message);
}
//TODO symfony6
// const SUBJECT = 'subject';
// const SUBJECT_PREFIX = 'subject-prefix';
// const TO_EMAIL = 'to-email';
// const COPY_TO = 'copy-to';
// const COPY_HIDDEN_TO = 'copy-hidden-to';
// const TO_NAME = 'to-name';
// const FROM_EMAIL = 'from-email';
// const FROM_NAME = 'from-name';
// const REPLY_TO = 'reply-to';
// const CONTENT_TEMPLATE = 'content-template';
// const CONTENT_DATA = 'content-data';
// const ATTACHMENT_DATA = 'attachment-data';
// const ATTACHMENT_FILENAME = 'attachment-filename';
// const ATTACHMENT_CONTENT_TYPE = 'attachment-content-type';
//
// protected MailjetTransport $transport;
// protected Environment $templating;
// protected ParameterBagInterface $parameterBag;
// protected SettingSolver $settingSolver;
// protected SiteStore $siteStore;
//
// public function __construct(
// MailjetTransport $mailjetTransport,
// Environment $templating,
// ParameterBagInterface $parameterBag,
// SettingSolver $settingSolver,
// SiteStore $siteStore
// ) {
// $this->transport = $mailjetTransport;
// $this->templating = $templating;
// $this->parameterBag = $parameterBag;
// $this->settingSolver = $settingSolver;
// $this->siteStore = $siteStore;
// }
//
// public function send($params = [])
// {
// $siteDefault = $this->siteStore->getOneDefault();
//
// $emailSubjectPrefix = (isset($params[self::SUBJECT_PREFIX]) && $params[self::SUBJECT_PREFIX] && strlen($params[self::SUBJECT_PREFIX]) > 0)
// ? $params[self::SUBJECT_PREFIX]
// : $this->settingSolver->getSettingValue(
// $siteDefault,
// SiteSettingDefinition::SETTING_EMAIL_SUBJECT_PREFIX
// );
//
// $emailFrom = (isset($params[self::FROM_EMAIL]) && $params[self::FROM_EMAIL] && strlen($params[self::FROM_EMAIL]) > 0)
// ? $params[self::FROM_EMAIL]
// : $this->settingSolver->getSettingValue(
// $siteDefault,
// SiteSettingDefinition::SETTING_EMAIL_FROM
// );
//
// $emailFromName = (isset($params[self::FROM_NAME]) && $params[self::FROM_NAME] && strlen($params[self::FROM_NAME]) > 0)
// ? $params[self::FROM_NAME]
// : $this->settingSolver->getSettingValue(
// $siteDefault,
// SiteSettingDefinition::SETTING_EMAIL_FROM_NAME
// );
//
// $message = new \Swift_Message($emailSubjectPrefix . $params[self::SUBJECT]);
//
// if ($this->parameterBag->get('mailjet.dev.redirect.active') == 1) {
// $message->addTo(
// $this->parameterBag->get('mailjet.dev.redirect.email'),
// isset($params[self::TO_NAME]) ?? null
// );
// } else {
// $message->addTo(
// $params[self::TO_EMAIL],
// isset($params[self::TO_NAME]) ?? null
// );
// }
//
// $contentData = [];
// if (isset($params[self::CONTENT_DATA])) {
// $contentData = $params[self::CONTENT_DATA];
// }
//
// $message->addFrom($emailFrom, $emailFromName)
// ->setBody(
// $this->templating->render($params[self::CONTENT_TEMPLATE] . '-html.html.twig', $contentData),
// 'text/html'
// )
// ->addPart($this->templating->render($params[self::CONTENT_TEMPLATE] . '-text.html.twig', $contentData));
//
// if (isset($params[self::COPY_TO]) && strlen($params[self::COPY_TO])) {
// $message->addCc($params[self::COPY_TO]);
// }
//
// if (isset($params[self::COPY_HIDDEN_TO]) && strlen($params[self::COPY_HIDDEN_TO])) {
// $message->addBcc($params[self::COPY_HIDDEN_TO]);
// }
//
// if (isset($params[self::REPLY_TO]) && strlen($params[self::REPLY_TO])) {
// $message->addReplyTo($params[self::REPLY_TO]);
// }
//
// if (isset($params[self::ATTACHMENT_DATA]) && isset($params[self::ATTACHMENT_FILENAME]) && isset($params[self::ATTACHMENT_CONTENT_TYPE])) {
// $message->attach(
// \Swift_Attachment::newInstance(
// $params[self::ATTACHMENT_DATA],
// $params[self::ATTACHMENT_FILENAME],
// $params[self::ATTACHMENT_CONTENT_TYPE]
// )
// );
// }
//
// return $this->transport->send($message);
// }
}

+ 0
- 1
Repository/Site/NewsStore.php Просмотреть файл

@@ -2,7 +2,6 @@

namespace Lc\SovBundle\Repository\Site;

use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;


+ 0
- 2
Repository/Ticket/TicketStore.php Просмотреть файл

@@ -3,8 +3,6 @@
namespace Lc\SovBundle\Repository\Ticket;

use App\Entity\Ticket\Ticket;
use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\SovBundle\Model\Ticket\TicketInterface;
use Lc\SovBundle\Model\User\UserInterface;
use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

+ 4
- 0
Resources/assets/app/admin/reminder/reminder.scss Просмотреть файл

@@ -10,6 +10,10 @@ div#reminders {
margin-right: 6px;
}
}
.form-check-label{
height: 24px;
vertical-align: bottom;
}
}
}
}

+ 22
- 0
Resources/assets/app/adminlte/field/collection/form.scss Просмотреть файл

@@ -0,0 +1,22 @@

.field-collection {
padding-top: 15px;

legend {
font-weight: bold;
font-size: 18px;
}

.field-collection-item {
background-color: gainsboro;
padding: 10px;
position: relative;
border-radius: 5px;

.field-collection-delete {
position: absolute;
right: 7px;
top: 11px;
}
}
}

+ 0
- 22
Resources/assets/app/adminlte/form/form.scss Просмотреть файл

@@ -44,28 +44,6 @@
legend {
font-weight: bold;
}
.field-collection {
padding-top: 15px;

legend {
font-weight: bold;
font-size: 18px;
}

.field-collection-item {
background-color: gainsboro;
padding: 10px;
position: relative;
border-radius: 5px;

.field-collection-delete {
position: absolute;
right: 0px;
top: 0px;
}
}
}

.label-ticket {
display: none;
}

+ 0
- 1
Resources/assets/app/adminlte/main/scss/form/_checkboxradio.scss Просмотреть файл

@@ -102,7 +102,6 @@
border-radius: 50%;
background: white;
}

}

.form-check-label :hover input ~ .checkmark {

+ 2
- 1
Resources/assets/functions/widget-collection.js Просмотреть файл

@@ -1,6 +1,7 @@
import {SovTools} from "./tools";

export class SovWidgetCollection {
static setCollectionWidgetAdd($collectionWidget) {

if ($collectionWidget.data('allow-add')) {
$collectionWidget.find('.field-collection-add').on('click', function (e) {
// grab the prototype template

+ 3
- 0
Resources/config/services.yaml Просмотреть файл

@@ -3,6 +3,9 @@ parameters:
app.admin.logo_sidebar: 'laclic.png'
app.site_name: 'laclic-sov'
app.mail_debug: ''
app.reminder.route_render_modal: 'sov_admin_reminder_render_modal'
app.reminder.route_new: 'sov_admin_reminder_new'
app.reminder.route_edit: 'sov_admin_reminder_edit'

services:
_defaults:

Двоичные данные
Resources/public/img/favicon.png Просмотреть файл

Before After
Width: 64  |  Height: 64  |  Size: 5.4KB

+ 6
- 0
Resources/translations/admin.fr.yaml Просмотреть файл

@@ -81,6 +81,9 @@ entity:
fields:
users: Utilisateurs
dateReminder: Date limite
flashes:
success:
added: Le pense bête a bien été ajouté
Ticket:
label: Ticket
label_plurial: Tickets
@@ -124,6 +127,8 @@ entity:
confirmDelete: Confirmer la suppression
createdAt: Créé le
user: Utilisateur
createdBy: Créé par
updatedBy: Mis à jour par
firstname: Prénom
lastname: Nom
page: Page
@@ -174,6 +179,7 @@ entity:
updated: L'élément a bien été mis à jour
deleted: L'élément a bien été supprimé
duplicate: L'élément a bien été dupliqué
sorted: La position des éléments a bien été modifié
error:
validation: Une erreur est survenue à l'envoi du formulaire. Réessayer et si le problème persiste, contactez les développeurs.
created: Une erreur est survenue à la création de l'élément

+ 2
- 2
Resources/views/adminlte/crud/field/association.html.twig Просмотреть файл

@@ -4,8 +4,8 @@
{% if 'toMany' == field.customOptions.get('associationType') %}
<span class="badge badge-secondary">{{ field.formattedValue }}</span>
{% else %}
{% if field.customOption('crudControllerFqcn') is not null and field.value is not null%}
<a href="{{ ea_url_short(field.customOption('crudControllerFqcn'), 'edit', field.value.id) }}">{{ field.formattedValue }}</a>
{% if field.customOptions.get('relatedUrl') is not null %}
<a href="{{ field.customOptions.get('relatedUrl') }}">{{ field.formattedValue }}</a>
{% else %}
{{ field.formattedValue }}
{% endif %}

+ 22
- 25
Resources/views/adminlte/crud/form.html.twig Просмотреть файл

@@ -1,12 +1,14 @@
{# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #}
{# @var entity \EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto #}

{% extends ea.templatePath('layout') %}

{% trans_default_domain ea.i18n.translationDomain %}

{% if ea.crud.currentAction == 'new' %}

{% set form = new_form %}

{% set ea_field_assets = ea.crud.fieldAssets(constant('EasyCorp\\Bundle\\EasyAdminBundle\\Config\\Crud::PAGE_NEW')) %}
{% set body_id = 'ea-new-' ~translation_entity_name ~ '-' ~ entity.primaryKeyValue %}
{% set body_class = 'ea-new ea-new-' ~ translation_entity_name %}
{% set content_title = 'new'|sov_trans_admin_title(translation_entity_name) %}
@@ -14,6 +16,7 @@
{% elseif ea.crud.currentAction == 'edit' %}
{% set form = edit_form %}

{% set ea_field_assets = ea.crud.fieldAssets(constant('EasyCorp\\Bundle\\EasyAdminBundle\\Config\\Crud::PAGE_EDIT')) %}
{% set body_id = 'ea-edit-' ~ translation_entity_name ~ '-' ~ entity.primaryKeyValue %}
{% set body_class = 'ea-edit ea-edit-' ~ translation_entity_name %}
{% if attribute(ea.getEntity().getInstance(), 'getTitle') is defined %}
@@ -24,12 +27,8 @@
{% endif %}
{% endif %}



{% form_theme form with ea.crud.formThemes only %}

{% trans_default_domain ea.i18n.translationDomain %}


{% block body_id body_id %}
{% block body_class body_class %}
@@ -38,44 +37,42 @@
{{ content_title }}
{% endblock %}


{% block head_javascript %}
{{ parent() }}
<script src="{{ asset('form.js', ea.assets.defaultAssetPackageName) }}"></script>
{% endblock head_javascript %}

{% block configured_head_contents %}
{{ parent() }}
{% for htmlContent in form.vars.ea_crud_form.assets.headContents %}
{% for htmlContent in ea_field_assets.headContents %}
{{ htmlContent|raw }}
{% endfor %}
{% endblock %}

{% block configured_stylesheets %}
{% block configured_body_contents %}
{{ parent() }}

{% for css_asset in form.vars.ea_crud_form.assets.cssAssets %}
<link rel="stylesheet" href="{{ asset(css_asset) }}">
{% endfor %}

{% for webpack_encore_entry in form.vars.ea_crud_form.assets.webpackEncoreAssets %}
{{ ea_call_function_if_exists('encore_entry_link_tags', webpack_encore_entry) }}
{% for htmlContent in ea_field_assets.bodyContents %}
{{ htmlContent|raw }}
{% endfor %}
{% endblock %}


{% block configured_javascripts %}
{% block configured_stylesheets %}
{{ parent() }}
{{ include('@EasyAdmin/includes/_css_assets.html.twig', { assets: ea_field_assets.cssAssets }, with_context = false) }}
{{ include('@EasyAdmin/includes/_encore_link_tags.html.twig', { assets: ea_field_assets.webpackEncoreAssets }, with_context = false) }}
{% endblock %}

{% for js_asset in form.vars.ea_crud_form.assets.jsAssets %}
<script src="{{ asset(js_asset) }}"></script>
{% endfor %}

{% for webpack_encore_entry in form.vars.ea_crud_form.assets.webpackEncoreAssets %}
{{ ea_call_function_if_exists('encore_entry_script_tags', webpack_encore_entry) }}
{% endfor %}
{% block configured_javascripts %}
{{ parent() }}
{{ include('@EasyAdmin/includes/_js_assets.html.twig', { assets: ea_field_assets.jsAssets }, with_context = false) }}
{{ include('@EasyAdmin/includes/_encore_script_tags.html.twig', { assets: ea_field_assets.webpackEncoreAssets }, with_context = false) }}
{% endblock %}

{% block page_actions_wrapper %}
{% endblock page_actions_wrapper %}




{% block main %}
<div class="row">
<div class="col-8">

+ 26
- 2
Resources/views/adminlte/crud/form_theme.html.twig Просмотреть файл

@@ -1,5 +1,5 @@
{# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #}
{% use '@EasyAdmin/crud/form_theme.html.twig' %}
{% extends '@EasyAdmin/crud/form_theme.html.twig' %}

{% block form_start %}
{% if form.vars.errors|length > 0 and 'ea_crud' in form.vars.block_prefixes|default([]) %}
@@ -159,7 +159,7 @@
'data-entry-is-complex': form.vars.ea_crud_form.ea_field and form.vars.ea_crud_form.ea_field.customOptions.get('entryIsComplex') ? 'true' : 'false',
'data-allow-add': allow_add ? 'true' : 'false',
'data-allow-delete': allow_delete ? 'true' : 'false',
'data-num-items': form.children|length,
'data-num-items': form.children is empty ? 0 : max(form.children|keys),
'data-form-type-name-placeholder': prototype is defined ? prototype.vars.name : '',
}) %}

@@ -190,6 +190,30 @@
</div>
{% endblock collection_entry_widget %}

{% block collection_entry_row %}
{% set is_array_field = 'EasyCorp\\Bundle\\EasyAdminBundle\\Field\\ArrayField' == form_parent(form).vars.ea_crud_form.ea_field.fieldFqcn ?? false %}
{% set is_complex = form_parent(form).vars.ea_crud_form.ea_field.customOptions.get('entryIsComplex') ?? false %}
{% set allows_deleting_items = form_parent(form).vars.allow_delete|default(false) %}
{% set render_expanded = form_parent(form).vars.ea_crud_form.ea_field.customOptions.get('renderExpanded') ?? false %}
{% set delete_item_button %}
<button type="button" class="btn btn-link btn-link-danger field-collection-delete-button"
title="{{ 'action.remove_item'|trans({}, 'EasyAdminBundle') }}">
<i class="far fa-trash-alt"></i>
</button>
{% endset %}

<div class="form-group">
{% if is_array_field|default(false) %}
{{ form_widget(form) }}
{% if allows_deleting_items %}
{{ delete_item_button }}
{% endif %}
{% else %}
{{ form_widget(form) }}
{% endif %}
</div>
{% endblock collection_entry_row %}

{% block file_manager_image_row %}
{{ form_widget(form) }}
{% endblock file_manager_image_row %}

+ 5
- 5
Translation/FlashBagTranslator.php Просмотреть файл

@@ -3,7 +3,7 @@
namespace Lc\SovBundle\Translation;


use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\HttpFoundation\RequestStack;

/**
* class FlashBag.
@@ -13,12 +13,12 @@ use Symfony\Component\HttpFoundation\Session\SessionInterface;
class FlashBagTranslator
{

protected SessionInterface $session;
protected RequestStack $requestStack;
protected TranslatorAdmin $translatorAdmin;

public function __construct(SessionInterface $session, TranslatorAdmin $translatorAdmin)
public function __construct(RequestStack $requestStack, TranslatorAdmin $translatorAdmin)
{
$this->session = $session;
$this->requestStack = $requestStack;
$this->translatorAdmin = $translatorAdmin;
}

@@ -31,7 +31,7 @@ class FlashBagTranslator
$translationEntityName = null,
$translationParam = array()
): void {
$this->session->getFlashBag()->add(
$this->requestStack->getSession()->getFlashBag()->add(
$type,
$this->translatorAdmin->transFlashMessage(
$type,

+ 1
- 4
Twig/StoreTwigExtension.php Просмотреть файл

@@ -2,8 +2,6 @@

namespace Lc\SovBundle\Twig;

use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\SovBundle\Model\Site\SiteInterface;
use Lc\SovBundle\Repository\Reminder\ReminderStoreInterface;
use Lc\SovBundle\Solver\Setting\SettingSolver;
@@ -48,8 +46,7 @@ class StoreTwigExtension extends AbstractExtension

public function getReminders($params)
{
// @TODO : à faire
return array();
return $this->reminderStore->get($params);
}

}

Загрузка…
Отмена
Сохранить