return $request->isMethod('POST') && $this->getLoginUrl($request) === $request->getPathInfo(); | 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')); | $email = trim($request->request->get('email')); |
namespace Lc\SovBundle\Builder\User; | namespace Lc\SovBundle\Builder\User; | ||||
use Doctrine\ORM\EntityManagerInterface; | use Doctrine\ORM\EntityManagerInterface; | ||||
use Lc\CaracoleBundle\Model\Address\AddressInterface; | |||||
use Lc\SovBundle\Doctrine\EntityInterface; | use Lc\SovBundle\Doctrine\EntityInterface; | ||||
use Lc\SovBundle\Doctrine\Extension\BlameableInterface; | use Lc\SovBundle\Doctrine\Extension\BlameableInterface; | ||||
use Lc\SovBundle\Factory\User\UserFactory; | use Lc\SovBundle\Factory\User\UserFactory; | ||||
use Lc\SovBundle\Model\Newsletter\NewsletterInterface; | use Lc\SovBundle\Model\Newsletter\NewsletterInterface; | ||||
use Lc\SovBundle\Model\Ticket\TicketInterface; | |||||
use Lc\SovBundle\Model\User\UserInterface; | use Lc\SovBundle\Model\User\UserInterface; | ||||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||||
use Lc\SovBundle\Repository\User\UserStore; | use Lc\SovBundle\Repository\User\UserStore; | ||||
use Lc\SovBundle\Solver\User\UserSolver; | use Lc\SovBundle\Solver\User\UserSolver; | ||||
use Symfony\Component\Console\Input\InputInterface; | use Symfony\Component\Console\Input\InputInterface; | ||||
use Symfony\Component\Console\Output\OutputInterface; | use Symfony\Component\Console\Output\OutputInterface; | ||||
use Symfony\Component\Console\Question\Question; | use Symfony\Component\Console\Question\Question; | ||||
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface; | |||||
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface; | |||||
class CreateUserCommand extends Command | class CreateUserCommand extends Command | ||||
{ | { | ||||
private $passwordEncoder; | private $passwordEncoder; | ||||
private $em; | private $em; | ||||
public function __construct(UserPasswordEncoderInterface $passwordEncoder, EntityManager $entityManager) | |||||
public function __construct(UserPasswordHasherInterface $passwordEncoder, EntityManager $entityManager) | |||||
{ | { | ||||
parent::__construct(); | parent::__construct(); | ||||
$user->setEmail($email); | $user->setEmail($email); | ||||
$user->setRoles(array($role)); | $user->setRoles(array($role)); | ||||
$password = $this->passwordEncoder->encodePassword($user, $password); | |||||
$password = $this->passwordEncoder->hashPassword($user, $password); | |||||
$user->setPassword($password); | $user->setPassword($password); | ||||
protected SettingBuilder $settingBuilder; | protected SettingBuilder $settingBuilder; | ||||
public function __construct(string $name = null, SettingBuilder $settingBuilder) | |||||
public function __construct(string $name = null, SettingBuilder $settingBuilder=null) | |||||
{ | { | ||||
parent::__construct($name); | parent::__construct($name); | ||||
$this->settingBuilder = $settingBuilder; | $this->settingBuilder = $settingBuilder; |
use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; | use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Dto\SearchDto; | 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\BeforeCrudActionEvent; | use EasyCorp\Bundle\EasyAdminBundle\Event\BeforeCrudActionEvent; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Event\BeforeEntityDeletedEvent; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Event\BeforeEntityUpdatedEvent; | use EasyCorp\Bundle\EasyAdminBundle\Event\BeforeEntityUpdatedEvent; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Exception\ForbiddenActionException; | use EasyCorp\Bundle\EasyAdminBundle\Exception\ForbiddenActionException; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Exception\InsufficientEntityPermissionException; | use EasyCorp\Bundle\EasyAdminBundle\Exception\InsufficientEntityPermissionException; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; | use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; | use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Security\Permission; | use EasyCorp\Bundle\EasyAdminBundle\Security\Permission; | ||||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||||
use Lc\SovBundle\Component\EntityComponent; | use Lc\SovBundle\Component\EntityComponent; | ||||
use Lc\SovBundle\Definition\ActionDefinition; | use Lc\SovBundle\Definition\ActionDefinition; | ||||
use Lc\SovBundle\Doctrine\Extension\DevAliasInterface; | use Lc\SovBundle\Doctrine\Extension\DevAliasInterface; | ||||
use Lc\SovBundle\Doctrine\Extension\OpenGraphInterface; | |||||
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\StatusInterface; | use Lc\SovBundle\Doctrine\Extension\StatusInterface; | ||||
use Lc\SovBundle\Doctrine\Extension\TranslatableInterface; | use Lc\SovBundle\Doctrine\Extension\TranslatableInterface; | ||||
use Lc\SovBundle\Doctrine\Extension\TreeInterface; | use Lc\SovBundle\Doctrine\Extension\TreeInterface; | ||||
use Lc\SovBundle\Field\CollectionField; | 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\FiltersFormType; | ||||
use Lc\SovBundle\Form\Common\PositionType; | use Lc\SovBundle\Form\Common\PositionType; | ||||
use Lc\SovBundle\Model\User\UserInterface; | |||||
use Lc\SovBundle\Repository\EntityRepository; | use Lc\SovBundle\Repository\EntityRepository; | ||||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | use Lc\SovBundle\Repository\RepositoryQueryInterface; | ||||
use Lc\SovBundle\Translation\FlashBagTranslator; | |||||
use Lc\SovBundle\Translation\TranslatorAdmin; | use Lc\SovBundle\Translation\TranslatorAdmin; | ||||
use Symfony\Component\Form\Extension\Core\Type\CollectionType; | use Symfony\Component\Form\Extension\Core\Type\CollectionType; | ||||
use Symfony\Component\Form\Extension\Core\Type\TextType; | use Symfony\Component\Form\Extension\Core\Type\TextType; | ||||
use Symfony\Component\Form\FormInterface; | use Symfony\Component\Form\FormInterface; | ||||
use Symfony\Component\HttpFoundation\JsonResponse; | use Symfony\Component\HttpFoundation\JsonResponse; | ||||
use Symfony\Component\HttpFoundation\RequestStack; | |||||
use Symfony\Component\HttpFoundation\Response; | use Symfony\Component\HttpFoundation\Response; | ||||
abstract class AbstractAdminController extends EaAbstractCrudController | abstract class AbstractAdminController extends EaAbstractCrudController | ||||
use ControllerTrait; | use ControllerTrait; | ||||
protected FormInterface $filtersForm; | protected FormInterface $filtersForm; | ||||
protected TranslatorAdmin $translatorAdmin; | |||||
protected bool $isRepositoryQueryFiltered = false; | protected bool $isRepositoryQueryFiltered = false; | ||||
abstract public function getRepositoryQuery(): RepositoryQueryInterface; | abstract public function getRepositoryQuery(): RepositoryQueryInterface; | ||||
public function configureResponseParameters(KeyValueStore $responseParameters): KeyValueStore | public function configureResponseParameters(KeyValueStore $responseParameters): KeyValueStore | ||||
{ | { | ||||
if ($responseParameters->get('global_actions')) { | if ($responseParameters->get('global_actions')) { | ||||
public function overrideGlobalActions(?ActionCollection $actions): void | public function overrideGlobalActions(?ActionCollection $actions): void | ||||
{ | { | ||||
if ($actions) { | 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) { | foreach ($actions as $i => $action) { | ||||
//récriture du bouton 'retour au parent' | //récriture du bouton 'retour au parent' | ||||
$entityClass = $this->getEntityFqcn(); | $entityClass = $this->getEntityFqcn(); | ||||
$paramListMaxResults = 'listMaxResults'; | $paramListMaxResults = 'listMaxResults'; | ||||
$paramSessionListMaxResults = $entityClass . '-' . $paramListMaxResults; | $paramSessionListMaxResults = $entityClass . '-' . $paramListMaxResults; | ||||
$requestListMaxResults = $this->get(RequestStack::class)->getCurrentRequest()->get($paramListMaxResults); | |||||
$requestListMaxResults = $this->getRequestStack()->getCurrentRequest()->get($paramListMaxResults); | |||||
if ($requestListMaxResults) { | 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 | $paramSessionListMaxResults | ||||
) : 30; | ) : 30; | ||||
public function sort(AdminContext $context) | public function sort(AdminContext $context) | ||||
{ | { | ||||
$event = new BeforeCrudActionEvent($context); | $event = new BeforeCrudActionEvent($context); | ||||
$this->get('event_dispatcher')->dispatch($event); | |||||
$this->container->get('event_dispatcher')->dispatch($event); | |||||
if ($event->isPropagationStopped()) { | if ($event->isPropagationStopped()) { | ||||
return $event->getResponse(); | return $event->getResponse(); | ||||
} | } | ||||
} | } | ||||
$fields = FieldCollection::new($this->configureFields(Crud::PAGE_INDEX)); | $fields = FieldCollection::new($this->configureFields(Crud::PAGE_INDEX)); | ||||
$filters = $this->get(FilterFactory::class)->create( | |||||
$filters = $this->container->get(FilterFactory::class)->create( | |||||
$context->getCrud()->getFiltersConfig(), | $context->getCrud()->getFiltersConfig(), | ||||
$fields, | $fields, | ||||
$context->getEntity() | $context->getEntity() | ||||
); | ); | ||||
$queryBuilder = $this->createSortQueryBuilder($context->getSearch(), $context->getEntity(), $fields, $filters); | $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())) | $sortableForm = $this->createFormBuilder(array('entities', $paginator->getResults())) | ||||
->add( | ->add( | ||||
) | ) | ||||
->getForm(); | ->getForm(); | ||||
$entityManager = $this->getDoctrine()->getManagerForClass($this->getEntityFqcn()); | |||||
$entityManager = $this->container->get('doctrine')->getManagerForClass($this->getEntityFqcn()); | |||||
$repository = $entityManager->getRepository($this->getEntityFqcn()); | $repository = $entityManager->getRepository($this->getEntityFqcn()); | ||||
$sortableForm->handleRequest($context->getRequest()); | $sortableForm->handleRequest($context->getRequest()); | ||||
} | } | ||||
$event = new BeforeEntityUpdatedEvent($entityInstance); | $event = new BeforeEntityUpdatedEvent($entityInstance); | ||||
$this->get('event_dispatcher')->dispatch($event); | |||||
$this->container->get('event_dispatcher')->dispatch($event); | |||||
$entityInstance = $event->getEntityInstance(); | $entityInstance = $event->getEntityInstance(); | ||||
$entityInstance->setPosition($elm['position']); | $entityInstance->setPosition($elm['position']); | ||||
//$this->get('event_dispatcher')->dispatch(new AfterEntityUpdatedEvent($entityInstance)); | //$this->get('event_dispatcher')->dispatch(new AfterEntityUpdatedEvent($entityInstance)); | ||||
} | } | ||||
$url = $this->get(AdminUrlGenerator::class) | |||||
$url = $this->container->get(AdminUrlGenerator::class) | |||||
->setAction(ActionDefinition::INDEX) | ->setAction(ActionDefinition::INDEX) | ||||
->generateUrl(); | ->generateUrl(); | ||||
$this->addFlashTranslator('success', 'sorted'); | $this->addFlashTranslator('success', 'sorted'); | ||||
); | ); | ||||
$responseParameters->set('fields', $this->configureFields('index')); | $responseParameters->set('fields', $this->configureFields('index')); | ||||
$event = new AfterCrudActionEvent($context, $responseParameters); | $event = new AfterCrudActionEvent($context, $responseParameters); | ||||
$this->get('event_dispatcher')->dispatch($event); | |||||
$this->container->get('event_dispatcher')->dispatch($event); | |||||
if ($event->isPropagationStopped()) { | if ($event->isPropagationStopped()) { | ||||
return $event->getResponse(); | return $event->getResponse(); | ||||
} | } | ||||
FilterCollection $filters | FilterCollection $filters | ||||
): RepositoryQueryInterface | ): RepositoryQueryInterface | ||||
{ | { | ||||
$repositoryQuery = $this->get(EntityRepository::class)->createRepositoryQuery( | |||||
$repositoryQuery = $this->container->get(EntityRepository::class)->createRepositoryQuery( | |||||
$this->getRepositoryQuery(), | $this->getRepositoryQuery(), | ||||
$searchDto, | $searchDto, | ||||
$entityDto, | $entityDto, | ||||
) | ) | ||||
); | ); | ||||
$filterManager = $this->get(FilterManager::class); | |||||
$filterManager = $this->getFilterManager(); | |||||
$this->filtersForm->handleRequest($searchDto->getRequest()); | $this->filtersForm->handleRequest($searchDto->getRequest()); | ||||
$this->isRepositoryQueryFiltered = $filterManager->handleFiltersForm($repositoryQuery, $this->filtersForm, $fields, $entityDto); | $this->isRepositoryQueryFiltered = $filterManager->handleFiltersForm($repositoryQuery, $this->filtersForm, $fields, $entityDto); | ||||
{ | { | ||||
$entityManager->update($entityInstance); | $entityManager->update($entityInstance); | ||||
$entityManager->flush(); | $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 | public function persistEntity(EntityManagerInterface $entityManager, $entityInstance): void | ||||
{ | { | ||||
$entityManager->create($entityInstance); | $entityManager->create($entityInstance); | ||||
$entityManager->flush(); | $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 | public function deleteEntity(EntityManagerInterface $entityManager, $entityInstance): void | ||||
$entityManager->delete($entityInstance); | $entityManager->delete($entityInstance); | ||||
} | } | ||||
$entityManager->flush(); | $entityManager->flush(); | ||||
$this->get(FlashBagTranslator::class)->add('success', 'deleted', $this->getTranslationEntityName()); | |||||
$this->getFlashBagTranslator()->add('success', 'deleted', $this->getTranslationEntityName()); | |||||
} | } | ||||
public function configureActions(Actions $actions): Actions | public function configureActions(Actions $actions): Actions | ||||
{ | { | ||||
$duplicateAction = Action::new( | $duplicateAction = Action::new( | ||||
ActionDefinition::DUPLICATE, | ActionDefinition::DUPLICATE, | ||||
$this->get(TranslatorAdmin::class)->transAction(ActionDefinition::DUPLICATE), | |||||
$this->translatorAdmin->transAction(ActionDefinition::DUPLICATE), | |||||
'fa fa-fw fa-copy' | 'fa fa-fw fa-copy' | ||||
) | ) | ||||
->linkToCrudAction(ActionDefinition::DUPLICATE) | ->linkToCrudAction(ActionDefinition::DUPLICATE) | ||||
->setLabel($this->get(TranslatorAdmin::class)->transAction(ActionDefinition::DUPLICATE)) | |||||
->setLabel($this->translatorAdmin->transAction(ActionDefinition::DUPLICATE)) | |||||
->setCssClass('in-dropdown text-info action-confirm'); | ->setCssClass('in-dropdown text-info action-confirm'); | ||||
return $duplicateAction; | return $duplicateAction; | ||||
ActionDefinition::NEW, | ActionDefinition::NEW, | ||||
[ | [ | ||||
'icon' => 'plus', | 'icon' => 'plus', | ||||
'label' => $this->get(TranslatorAdmin::class)->transAction('create'), | |||||
'label' => $this->translatorAdmin->transAction('create'), | |||||
'add_class' => 'btn-sm', | 'add_class' => 'btn-sm', | ||||
] | ] | ||||
); | ); | ||||
'label' => false, | 'label' => false, | ||||
'html_attributes' => array( | 'html_attributes' => array( | ||||
'data-toggle' => 'tooltip', | 'data-toggle' => 'tooltip', | ||||
'title' => $this->get(TranslatorAdmin::class)->transAction('edit'), | |||||
'title' => $this->translatorAdmin->transAction('edit'), | |||||
), | ), | ||||
] | ] | ||||
); | ); | ||||
'label' => false, | 'label' => false, | ||||
'html_attributes' => array( | 'html_attributes' => array( | ||||
'data-toggle' => 'tooltip', | 'data-toggle' => 'tooltip', | ||||
'title' => $this->get(TranslatorAdmin::class)->transAction('detail'), | |||||
'title' =>$this->translatorAdmin->transAction('detail'), | |||||
), | ), | ||||
] | ] | ||||
); | ); | ||||
[ | [ | ||||
'icon' => 'trash', | 'icon' => 'trash', | ||||
'dropdown' => true, | 'dropdown' => true, | ||||
'label' => $this->get(TranslatorAdmin::class)->transAction('delete'), | |||||
'label' => $this->translatorAdmin->transAction('delete'), | |||||
'class' => 'dropdown-item text-danger in-dropdown action-delete', | 'class' => 'dropdown-item text-danger in-dropdown action-delete', | ||||
] | ] | ||||
); | ); | ||||
[ | [ | ||||
'class' => 'btn btn-sm btn-danger', | 'class' => 'btn btn-sm btn-danger', | ||||
'icon' => 'trash', | 'icon' => 'trash', | ||||
'label' => $this->get(TranslatorAdmin::class)->transAction('delete'), | |||||
'label' => $this->translatorAdmin->transAction('delete'), | |||||
] | ] | ||||
); | ); | ||||
} | } | ||||
[ | [ | ||||
'add_class' => 'float-right ', | 'add_class' => 'float-right ', | ||||
'icon' => 'check', | 'icon' => 'check', | ||||
'label' => $this->get(TranslatorAdmin::class)->transAction('save_and_return'), | |||||
'label' => $this->translatorAdmin->transAction('save_and_return'), | |||||
] | ] | ||||
); | ); | ||||
[ | [ | ||||
'icon' => 'chevron-left', | 'icon' => 'chevron-left', | ||||
'class' => 'btn btn-link', | 'class' => 'btn btn-link', | ||||
'label' => $this->get(TranslatorAdmin::class)->transAction('back_index'), | |||||
'label' => $this->translatorAdmin->transAction('back_index'), | |||||
] | ] | ||||
); | ); | ||||
ActionDefinition::SAVE_AND_CONTINUE, | ActionDefinition::SAVE_AND_CONTINUE, | ||||
[ | [ | ||||
'class' => 'btn btn-info float-right action-save-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'), | |||||
] | ] | ||||
); | ); | ||||
[ | [ | ||||
'icon' => 'trash', | 'icon' => 'trash', | ||||
'class' => 'btn btn-outline-danger action-delete', | 'class' => 'btn btn-outline-danger action-delete', | ||||
'label' => $this->get(TranslatorAdmin::class)->transAction('delete'), | |||||
'label' => $this->translatorAdmin->transAction('delete'), | |||||
] | ] | ||||
); | ); | ||||
} | } | ||||
[ | [ | ||||
'add_class' => 'float-right', | 'add_class' => 'float-right', | ||||
'icon' => 'check', | 'icon' => 'check', | ||||
'label' => $this->get(TranslatorAdmin::class)->transAction('save_and_return'), | |||||
'label' => $this->translatorAdmin->transAction('save_and_return'), | |||||
] | ] | ||||
); | ); | ||||
[ | [ | ||||
'icon' => 'chevron-left', | 'icon' => 'chevron-left', | ||||
'class' => 'btn btn-link', | 'class' => 'btn btn-link', | ||||
'label' => $this->get(TranslatorAdmin::class)->transAction('back_index'), | |||||
'label' => $this->translatorAdmin->transAction('back_index'), | |||||
] | ] | ||||
); | ); | ||||
ActionDefinition::SAVE_AND_ADD_ANOTHER, | ActionDefinition::SAVE_AND_ADD_ANOTHER, | ||||
[ | [ | ||||
'class' => 'btn btn-info float-right', | 'class' => 'btn btn-info float-right', | ||||
'label' => $this->get(TranslatorAdmin::class)->transAction('save_and_add_another'), | |||||
'label' => $this->translatorAdmin->transAction('save_and_add_another'), | |||||
] | ] | ||||
); | ); | ||||
} | } | ||||
if ($this->isInstanceOf(SortableInterface::class)) { | if ($this->isInstanceOf(SortableInterface::class)) { | ||||
$sortAction = Action::new( | $sortAction = Action::new( | ||||
ActionDefinition::SORT, | ActionDefinition::SORT, | ||||
$this->get(TranslatorAdmin::class)->transAction(ActionDefinition::SORT), | |||||
$this->translatorAdmin->transAction(ActionDefinition::SORT), | |||||
'fa fa-sort' | 'fa fa-sort' | ||||
) | ) | ||||
->linkToCrudAction(ActionDefinition::SORT) | ->linkToCrudAction(ActionDefinition::SORT) | ||||
if ($this->isInstanceOf(TreeInterface::class)) { | if ($this->isInstanceOf(TreeInterface::class)) { | ||||
$indexChildAction = Action::new( | $indexChildAction = Action::new( | ||||
ActionDefinition::INDEX_CHILDREN, | ActionDefinition::INDEX_CHILDREN, | ||||
$this->get(TranslatorAdmin::class)->transAction(ActionDefinition::INDEX_CHILDREN), | |||||
$this->translatorAdmin->transAction(ActionDefinition::INDEX_CHILDREN), | |||||
'fa fa-list' | 'fa fa-list' | ||||
) | ) | ||||
->linkToCrudAction(ActionDefinition::INDEX) | ->linkToCrudAction(ActionDefinition::INDEX) | ||||
$backParentAction = Action::new( | $backParentAction = Action::new( | ||||
ActionDefinition::INDEX_PARENT, | ActionDefinition::INDEX_PARENT, | ||||
$this->get(TranslatorAdmin::class)->transAction(ActionDefinition::INDEX_PARENT), | |||||
$this->getTranslatorAdmin()->transAction(ActionDefinition::INDEX_PARENT), | |||||
'fa fa-chevron-left' | 'fa fa-chevron-left' | ||||
) | ) | ||||
->linkToCrudAction(ActionDefinition::INDEX) | ->linkToCrudAction(ActionDefinition::INDEX) | ||||
$controller->configureFields($autocompleteContext['originatingPage']) | $controller->configureFields($autocompleteContext['originatingPage']) | ||||
)->getByProperty($autocompleteContext['propertyName']); | )->getByProperty($autocompleteContext['propertyName']); | ||||
$filterManager = $this->get(FilterManager::class); | |||||
$filterManager = $this->getFilterManager(); | |||||
$filteredValue = ['value' => $context->getRequest()->query->get('q')]; | $filteredValue = ['value' => $context->getRequest()->query->get('q')]; | ||||
$filterManager->applyFilter($repositoryQuery, $field, $filteredValue); | $filterManager->applyFilter($repositoryQuery, $field, $filteredValue); | ||||
$repositoryQuery->select('.' . $autocompleteContext['propertyName']); | $repositoryQuery->select('.' . $autocompleteContext['propertyName']); |
namespace Lc\SovBundle\Controller; | namespace Lc\SovBundle\Controller; | ||||
use Doctrine\ORM\EntityManagerInterface; | use Doctrine\ORM\EntityManagerInterface; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; | use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; | ||||
use Knp\Component\Pager\PaginatorInterface; | use Knp\Component\Pager\PaginatorInterface; | ||||
use Lc\SovBundle\Component\FileComponent; | use Lc\SovBundle\Component\FileComponent; | ||||
use Lc\SovBundle\Solver\Setting\SettingSolver; | use Lc\SovBundle\Solver\Setting\SettingSolver; | ||||
use Lc\SovBundle\Translation\FlashBagTranslator; | use Lc\SovBundle\Translation\FlashBagTranslator; | ||||
use Lc\SovBundle\Translation\TranslatorAdmin; | use Lc\SovBundle\Translation\TranslatorAdmin; | ||||
use Mailjet\MailjetSwiftMailer\SwiftMailer\MailjetTransport; | |||||
//use Mailjet\MailjetSwiftMailer\SwiftMailer\MailjetTransport; | |||||
use Psr\Log\LoggerInterface; | use Psr\Log\LoggerInterface; | ||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | ||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface; | use Symfony\Component\EventDispatcher\EventDispatcherInterface; | ||||
use Symfony\Component\HttpFoundation\Request; | use Symfony\Component\HttpFoundation\Request; | ||||
use Symfony\Component\HttpFoundation\RequestStack; | use Symfony\Component\HttpFoundation\RequestStack; | ||||
use Symfony\Component\HttpFoundation\Session\SessionInterface; | |||||
use Symfony\Component\HttpKernel\KernelInterface; | use Symfony\Component\HttpKernel\KernelInterface; | ||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; | use Symfony\Component\Routing\Generator\UrlGeneratorInterface; | ||||
use Symfony\Component\Security\Core\Security; | use Symfony\Component\Security\Core\Security; | ||||
trait ControllerTrait | trait ControllerTrait | ||||
{ | { | ||||
protected TranslatorAdmin $translatorAdmin; | |||||
protected RequestStack $requestStack; | |||||
public function __construct( | |||||
TranslatorAdmin $translatorAdmin, | |||||
RequestStack $requestStack | |||||
){ | |||||
$this->translatorAdmin = $translatorAdmin; | |||||
$this->requestStack = $requestStack; | |||||
} | |||||
/* | /* | ||||
* Fonctions privées | * Fonctions privées | ||||
*/ | */ | ||||
set_time_limit(0); | 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 | //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 | //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 | public static function getSubscribedServices(): array | ||||
Security::class => Security::class, | Security::class => Security::class, | ||||
EntityManagerInterface::class => EntityManagerInterface::class, | EntityManagerInterface::class => EntityManagerInterface::class, | ||||
UrlGeneratorInterface::class => UrlGeneratorInterface::class, | UrlGeneratorInterface::class => UrlGeneratorInterface::class, | ||||
SessionInterface::class => SessionInterface::class, | |||||
// SessionInterface::class => SessionInterface::class, | |||||
PaginatorInterface::class => PaginatorInterface::class, | PaginatorInterface::class => PaginatorInterface::class, | ||||
RequestStack::class => RequestStack::class, | RequestStack::class => RequestStack::class, | ||||
EventDispatcherInterface::class => EventDispatcherInterface::class, | EventDispatcherInterface::class => EventDispatcherInterface::class, | ||||
TranslatorAdmin::class => TranslatorAdmin::class, | TranslatorAdmin::class => TranslatorAdmin::class, | ||||
FilterManager::class => FilterManager::class, | FilterManager::class => FilterManager::class, | ||||
FlashBagTranslator::class => FlashBagTranslator::class, | FlashBagTranslator::class => FlashBagTranslator::class, | ||||
MailjetTransport::class => MailjetTransport::class, | |||||
// MailjetTransport::class => MailjetTransport::class, | |||||
AdminUrlGenerator::class => AdminUrlGenerator::class, | AdminUrlGenerator::class => AdminUrlGenerator::class, | ||||
SettingSolver::class => SettingSolver::class, | SettingSolver::class => SettingSolver::class, | ||||
ComponentContainer::class => ComponentContainer::class, | ComponentContainer::class => ComponentContainer::class, | ||||
} | } | ||||
$this->get(FlashBagTranslator::class)->add( | |||||
$this->container->get(FlashBagTranslator::class)->add( | |||||
$type, | $type, | ||||
$translationKeyName, | $translationKeyName, | ||||
$translationEntityName, | $translationEntityName, | ||||
int $entityId = null, | int $entityId = null, | ||||
array $extraParam = array() | array $extraParam = array() | ||||
): string { | ): string { | ||||
$adminUrlGenerator = $this->get(AdminUrlGenerator::class); | |||||
$adminUrlGenerator = $this->container->get(AdminUrlGenerator::class); | |||||
if ($controller) { | if ($controller) { | ||||
$adminUrlGenerator->setController($controller); | $adminUrlGenerator->setController($controller); | ||||
} | } | ||||
public function getTemplating(): Environment | public function getTemplating(): Environment | ||||
{ | { | ||||
return $this->get(Environment::class); | |||||
return $this->container->get(Environment::class); | |||||
} | } | ||||
public function getApplicationDefinition(): ApplicationDefinition | public function getApplicationDefinition(): ApplicationDefinition | ||||
{ | { | ||||
return $this->get(ApplicationDefinition::class); | |||||
return $this->container->get(ApplicationDefinition::class); | |||||
} | } | ||||
public function getEntityManager(): EntityManagerInterface | public function getEntityManager(): EntityManagerInterface | ||||
{ | { | ||||
return $this->get(EntityManagerInterface::class); | |||||
return $this->container->get(EntityManagerInterface::class); | |||||
} | } | ||||
public function getRouter(): UrlGeneratorInterface | 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 | public function getSecurity(): Security | ||||
{ | { | ||||
return $this->get(Security::class); | |||||
return $this->container->get(Security::class); | |||||
} | } | ||||
public function getPaginator(): PaginatorInterface | public function getPaginator(): PaginatorInterface | ||||
{ | { | ||||
return $this->get(PaginatorInterface::class); | |||||
return $this->container->get(PaginatorInterface::class); | |||||
} | } | ||||
public function getRequestStack(): RequestStack | public function getRequestStack(): RequestStack | ||||
{ | { | ||||
return $this->get(RequestStack::class); | |||||
return $this->container->get(RequestStack::class); | |||||
} | } | ||||
public function getEventDispatcher(): EventDispatcherInterface | public function getEventDispatcher(): EventDispatcherInterface | ||||
{ | { | ||||
return $this->get(EventDispatcherInterface::class); | |||||
return $this->container->get(EventDispatcherInterface::class); | |||||
} | } | ||||
public function getParameterBag(): ParameterBagInterface | public function getParameterBag(): ParameterBagInterface | ||||
{ | { | ||||
return $this->get(ParameterBagInterface::class); | |||||
return $this->container->get(ParameterBagInterface::class); | |||||
} | } | ||||
public function getTranslator(): TranslatorInterface | public function getTranslator(): TranslatorInterface | ||||
{ | { | ||||
return $this->get(TranslatorInterface::class); | |||||
return $this->container->get(TranslatorInterface::class); | |||||
} | } | ||||
public function getPdfGenerator(): PdfGenerator | public function getPdfGenerator(): PdfGenerator | ||||
{ | { | ||||
return $this->get(PdfGenerator::class); | |||||
return $this->container->get(PdfGenerator::class); | |||||
} | } | ||||
public function getTranslatorAdmin(): TranslatorAdmin | public function getTranslatorAdmin(): TranslatorAdmin | ||||
{ | { | ||||
return $this->get(TranslatorAdmin::class); | |||||
return $this->container->get(TranslatorAdmin::class); | |||||
} | } | ||||
public function getLogger(): LoggerInterface | 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 | public function getAdminUrlGenerator(): AdminUrlGenerator | ||||
{ | { | ||||
return $this->get(AdminUrlGenerator::class); | |||||
return $this->container->get(AdminUrlGenerator::class); | |||||
} | } | ||||
public function getKernel(): KernelInterface | public function getKernel(): KernelInterface | ||||
{ | { | ||||
return $this->get(KernelInterface::class); | |||||
return $this->container->get(KernelInterface::class); | |||||
} | } | ||||
public function getSettingSolver(): SettingSolver | public function getSettingSolver(): SettingSolver | ||||
{ | { | ||||
return $this->get(SettingSolver::class); | |||||
return $this->container->get(SettingSolver::class); | |||||
} | } | ||||
public function getSettingValue($entity, $settingName) | public function getSettingValue($entity, $settingName) | ||||
{ | { | ||||
return $this->getSettingSolver()->getSettingValue($entity, $settingName); | |||||
return $this->container->getSettingSolver()->getSettingValue($entity, $settingName); | |||||
} | } | ||||
public function getComponentContainer(): ComponentContainer | public function getComponentContainer(): ComponentContainer | ||||
{ | { | ||||
return $this->get(ComponentContainer::class); | |||||
return $this->container->get(ComponentContainer::class); | |||||
} | } | ||||
public function getFileContainer(): FileContainer | public function getFileContainer(): FileContainer | ||||
{ | { | ||||
return $this->get(FileContainer::class); | |||||
return $this->container->get(FileContainer::class); | |||||
} | } | ||||
public function getNewsletterContainer(): NewsletterContainer | public function getNewsletterContainer(): NewsletterContainer | ||||
{ | { | ||||
return $this->get(NewsletterContainer::class); | |||||
return $this->container->get(NewsletterContainer::class); | |||||
} | } | ||||
public function getReminderContainer(): ReminderContainer | public function getReminderContainer(): ReminderContainer | ||||
{ | { | ||||
return $this->get(ReminderContainer::class); | |||||
return $this->container->get(ReminderContainer::class); | |||||
} | } | ||||
public function getNewsContainer(): NewsContainer | public function getNewsContainer(): NewsContainer | ||||
{ | { | ||||
return $this->get(NewsContainer::class); | |||||
return $this->container->get(NewsContainer::class); | |||||
} | } | ||||
public function getPageContainer(): PageContainer | public function getPageContainer(): PageContainer | ||||
{ | { | ||||
return $this->get(PageContainer::class); | |||||
return $this->container->get(PageContainer::class); | |||||
} | } | ||||
public function getSiteContainer(): SiteContainer | public function getSiteContainer(): SiteContainer | ||||
{ | { | ||||
return $this->get(SiteContainer::class); | |||||
return $this->container->get(SiteContainer::class); | |||||
} | } | ||||
public function getTicketContainer(): TicketContainer | public function getTicketContainer(): TicketContainer | ||||
{ | { | ||||
return $this->get(TicketContainer::class); | |||||
return $this->container->get(TicketContainer::class); | |||||
} | } | ||||
public function getTicketMessageContainer(): TicketMessageContainer | public function getTicketMessageContainer(): TicketMessageContainer | ||||
{ | { | ||||
return $this->get(TicketMessageContainer::class); | |||||
return $this->container->get(TicketMessageContainer::class); | |||||
} | } | ||||
public function getGroupUserContainer(): GroupUserContainer | public function getGroupUserContainer(): GroupUserContainer | ||||
{ | { | ||||
return $this->get(GroupUserContainer::class); | |||||
return $this->container->get(GroupUserContainer::class); | |||||
} | } | ||||
public function getUserContainer(): UserContainer | public function getUserContainer(): UserContainer | ||||
{ | { | ||||
return $this->get(UserContainer::class); | |||||
return $this->container->get(UserContainer::class); | |||||
} | } | ||||
public function getSiteSettingContainer(): SiteSettingContainer | public function getSiteSettingContainer(): SiteSettingContainer | ||||
{ | { | ||||
return $this->get(SiteSettingContainer::class); | |||||
return $this->container->get(SiteSettingContainer::class); | |||||
} | } | ||||
public function setNoMemoryAndTimeLimit(): void | public function setNoMemoryAndTimeLimit(): void | ||||
set_time_limit(0); | 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); | |||||
} | |||||
} | } |
// the name visible to end users | // the name visible to end users | ||||
->setTitle('LA CLIC !') | ->setTitle('LA CLIC !') | ||||
// the path defined in this method is passed to the Twig asset() function | // 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' | // the domain used by default is 'messages' | ||||
->setTranslationDomain('admin'); | ->setTranslationDomain('admin'); | ||||
} | } |
namespace Lc\SovBundle\Controller\Reminder; | namespace Lc\SovBundle\Controller\Reminder; | ||||
use Doctrine\ORM\EntityManagerInterface; | use Doctrine\ORM\EntityManagerInterface; | ||||
use Lc\CaracoleBundle\Resolver\MerchantResolver; | |||||
use Lc\CaracoleBundle\Resolver\SectionResolver; | |||||
use Lc\SovBundle\Container\Reminder\ReminderContainer; | use Lc\SovBundle\Container\Reminder\ReminderContainer; | ||||
use Lc\SovBundle\Controller\ControllerTrait; | use Lc\SovBundle\Controller\ControllerTrait; | ||||
use Lc\SovBundle\Factory\Reminder\ReminderFactory; | use Lc\SovBundle\Factory\Reminder\ReminderFactory; | ||||
protected ReminderContainer $reminderContainer; | protected ReminderContainer $reminderContainer; | ||||
protected FormFactoryInterface $formFactory; | protected FormFactoryInterface $formFactory; | ||||
protected UrlGeneratorInterface $urlGenerator; | protected UrlGeneratorInterface $urlGenerator; | ||||
protected MerchantResolver $merchantResolver; | |||||
protected SectionResolver $sectionResolver; | |||||
protected ParameterBagInterface $parameterBag; | protected ParameterBagInterface $parameterBag; | ||||
public function __construct( | public function __construct( | ||||
$this->entityManager->persist($reminder); | $this->entityManager->persist($reminder); | ||||
$this->entityManager->flush(); | $this->entityManager->flush(); | ||||
$this->addFlashTranslator('success', 'added'); | |||||
$this->addFlashTranslator('success', 'added', 'Reminder'); | |||||
} | } | ||||
return $this->redirect($request->headers->get('referer')); | return $this->redirect($request->headers->get('referer')); |
public function configureCrud(Crud $crud): Crud | 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->setDefaultSort(array('updatedAt' => 'DESC')); | ||||
$crud->overrideTemplate('crud/detail', '@LcSov/admin/ticket/detail.html.twig'); | $crud->overrideTemplate('crud/detail', '@LcSov/admin/ticket/detail.html.twig'); | ||||
return $crud; | return $crud; |
use Doctrine\ORM\EntityManagerInterface; | use Doctrine\ORM\EntityManagerInterface; | ||||
use Lc\SovBundle\Controller\ControllerTrait; | use Lc\SovBundle\Controller\ControllerTrait; | ||||
use Lc\SovBundle\Doctrine\EntityManager; | |||||
use Lc\SovBundle\Form\User\ChangePasswordFormType; | use Lc\SovBundle\Form\User\ChangePasswordFormType; | ||||
use Lc\SovBundle\Form\User\ProfileFormType; | use Lc\SovBundle\Form\User\ProfileFormType; | ||||
use Lc\SovBundle\Model\User\UserModel; | use Lc\SovBundle\Model\User\UserModel; | ||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||||
use Symfony\Component\HttpFoundation\Request; | use Symfony\Component\HttpFoundation\Request; | ||||
use Symfony\Component\HttpFoundation\Response; | 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; | use Symfony\Component\Routing\Annotation\Route; | ||||
class AccountAdminController extends AbstractController | class AccountAdminController extends AbstractController | ||||
/** | /** | ||||
* @Route("/admin/account/password", name="sov_admin_account_password") | * @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(); | $user = $this->getUser(); | ||||
$form = $this->createForm(ChangePasswordFormType::class, $user); | $form = $this->createForm(ChangePasswordFormType::class, $user); | ||||
$plainPassword = $form->get('plain_password')->getData(); | $plainPassword = $form->get('plain_password')->getData(); | ||||
$user->setPassword($passwordEncoder->encodePassword($user, $plainPassword)); | |||||
$user->setPassword($passwordEncoder->hashPassword($user, $plainPassword)); | |||||
$this->entityManager->update($user); | $this->entityManager->update($user); | ||||
$this->entityManager->flush(); | $this->entityManager->flush(); |
use Lc\SovBundle\Translation\FlashBagTranslator; | use Lc\SovBundle\Translation\FlashBagTranslator; | ||||
use Lc\SovBundle\Translation\TranslatorAdmin; | use Lc\SovBundle\Translation\TranslatorAdmin; | ||||
use Symfony\Component\HttpFoundation\RequestStack; | use Symfony\Component\HttpFoundation\RequestStack; | ||||
use Symfony\Component\HttpFoundation\Session\SessionInterface; | |||||
abstract class UserAdminController extends AbstractAdminController | abstract class UserAdminController extends AbstractAdminController | ||||
{ | { | ||||
public function buildIndexActions(Actions $actions): void | public function buildIndexActions(Actions $actions): void | ||||
{ | { | ||||
parent::buildIndexActions($actions); // TODO: Change the autogenerated stub | |||||
parent::buildIndexActions($actions); | |||||
$actions->add(Crud::PAGE_INDEX, $this->getSwitchUserAction()); | $actions->add(Crud::PAGE_INDEX, $this->getSwitchUserAction()); | ||||
} | } | ||||
{ | { | ||||
$switchAction = Action::new( | $switchAction = Action::new( | ||||
ActionDefinition::SWITCH_USER, | ActionDefinition::SWITCH_USER, | ||||
$this->get(TranslatorAdmin::class)->transAction(ActionDefinition::SWITCH_USER), | |||||
$this->getTranslatorAdmin()->transAction(ActionDefinition::SWITCH_USER), | |||||
'fa fa-fw fa-user-secret' | 'fa fa-fw fa-user-secret' | ||||
) | ) | ||||
->linkToCrudAction(ActionDefinition::SWITCH_USER) | ->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'); | ->setCssClass('in-dropdown text-info action-confirm action_switch'); | ||||
return $switchAction; | return $switchAction; | ||||
public function overrideEntitiesActions(?EntityCollection $entities, string $pageName): void | 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 ($entities as $entity) { | ||||
foreach ($entity->getActions() as $action) { | foreach ($entity->getActions() as $action) { | ||||
if ($action->getName() == ActionDefinition::SWITCH_USER) { | if ($action->getName() == ActionDefinition::SWITCH_USER) { | ||||
public function createEntity(string $entityFqcn) | public function createEntity(string $entityFqcn) | ||||
{ | { | ||||
return $this->get(UserContainer::class)->getFactory()->create(); | |||||
return $this->getUserContainer()->getFactory()->create(); | |||||
} | } | ||||
public function delete(AdminContext $context) | public function delete(AdminContext $context) |
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField; | use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField; | use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | 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\CKEditorField; | ||||
use Lc\SovBundle\Field\CollectionField; | use Lc\SovBundle\Field\CollectionField; | ||||
use Lc\SovBundle\Field\ImageManagerField; | use Lc\SovBundle\Field\ImageManagerField; | ||||
'status' => StatusField::new('status')->setSortable(true), | 'status' => StatusField::new('status')->setSortable(true), | ||||
'createdAt' => DateTimeField::new('createdAt')->setSortable(true), | 'createdAt' => DateTimeField::new('createdAt')->setSortable(true), | ||||
'updatedAt' => DateTimeField::new('updatedAt')->setSortable(true), | 'updatedAt' => DateTimeField::new('updatedAt')->setSortable(true), | ||||
'createdBy' => AssociationField::new('createdBy'), | |||||
'createdBy' => \EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField::new('createdBy'), | |||||
'updatedBy' => AssociationField::new('updatedBy') | 'updatedBy' => AssociationField::new('updatedBy') | ||||
]; | ]; | ||||
} | } |
use EasyCorp\Bundle\EasyAdminBundle\Field\DateField; | use EasyCorp\Bundle\EasyAdminBundle\Field\DateField; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField; | use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | 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\Field\AbstractFieldDefinition; | ||||
use Lc\SovBundle\Definition\RolesDefinition; | use Lc\SovBundle\Definition\RolesDefinition; | ||||
use Lc\SovBundle\Solver\Ticket\TicketSolver; | use Lc\SovBundle\Solver\Ticket\TicketSolver; |
return $this; | return $this; | ||||
} | } | ||||
public function clear($objectName = null): self | |||||
public function clear($objectName = null): void | |||||
{ | { | ||||
$this->wrapped->clear($objectName); | $this->wrapped->clear($objectName); | ||||
return $this; | |||||
} | } | ||||
public function refresh($object): self | public function refresh($object): self | ||||
return $this; | return $this; | ||||
} | } | ||||
public function persist($entity) | |||||
public function persist($entity):void | |||||
{ | { | ||||
$this->wrapped->persist($entity); | $this->wrapped->persist($entity); | ||||
} | } |
namespace Lc\SovBundle\EventListener; | 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\Event\ExceptionEvent; | ||||
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; | use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; | ||||
{ | { | ||||
public function __construct( | public function __construct( | ||||
SessionInterface $session | |||||
RequestStack $requestStack | |||||
) { | ) { | ||||
$this->session = $session; | |||||
$this->requestStack = $requestStack; | |||||
} | } | ||||
public function onKernelException(ExceptionEvent $event) | public function onKernelException(ExceptionEvent $event) | ||||
// On détecte une erreur interne (500), on remove les sessions qui servent de filtre dans l'admin | // On détecte une erreur interne (500), on remove les sessions qui servent de filtre dans l'admin | ||||
if ($exception instanceof HttpExceptionInterface != true) { | if ($exception instanceof HttpExceptionInterface != true) { | ||||
if (!headers_sent()) { | if (!headers_sent()) { | ||||
foreach ($this->session->all() as $key => $s) { | |||||
foreach ($this->requestStack->getSession()->all() as $key => $s) { | |||||
if (str_contains($key, "_filter")) { | if (str_contains($key, "_filter")) { | ||||
$this->session->remove($key); | |||||
$this->requestStack->getSession()->remove($key); | |||||
} | } | ||||
} | } | ||||
} | } |
use Lc\SovBundle\Model\User\UserInterface; | use Lc\SovBundle\Model\User\UserInterface; | ||||
use Lc\SovBundle\Repository\AbstractRepositoryInterface; | use Lc\SovBundle\Repository\AbstractRepositoryInterface; | ||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | 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 | class UserPasswordEventSubscriber implements EventSubscriberInterface | ||||
{ | { | ||||
protected $passwordEncoder; | protected $passwordEncoder; | ||||
public function __construct(UserPasswordEncoderInterface $passwordEncoder) | |||||
public function __construct(UserPasswordHasherInterface $passwordEncoder) | |||||
{ | { | ||||
$this->passwordEncoder = $passwordEncoder; | $this->passwordEncoder = $passwordEncoder; | ||||
} | } | ||||
if ($entity instanceof UserInterface) { | if ($entity instanceof UserInterface) { | ||||
if ($entity->getPassword() == null) { | if ($entity->getPassword() == null) { | ||||
$password = $this->passwordEncoder->encodePassword($entity, $entity->generatePassword()); | |||||
$password = $this->passwordEncoder->hashPassword($entity, $entity->generatePassword()); | |||||
$entity->setPassword($password); | $entity->setPassword($password); | ||||
} | } | ||||
} | } |
<?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; | |||||
} | |||||
} |
use Symfony\Component\Form\Extension\Core\Type\TextType; | use Symfony\Component\Form\Extension\Core\Type\TextType; | ||||
use Symfony\Component\Form\Form; | use Symfony\Component\Form\Form; | ||||
use Symfony\Component\HttpFoundation\RequestStack; | use Symfony\Component\HttpFoundation\RequestStack; | ||||
use Symfony\Component\HttpFoundation\Session\SessionInterface; | |||||
/** | /** | ||||
* @author La clic ! <contact@laclic.fr> | * @author La clic ! <contact@laclic.fr> | ||||
*/ | */ | ||||
class FilterManager | class FilterManager | ||||
{ | { | ||||
protected $em; | |||||
protected EntityManagerInterface $em; | |||||
protected RequestStack $requestStack; | |||||
protected bool $isFiltered = false; | protected bool $isFiltered = false; | ||||
protected $translatorAdmin; | protected $translatorAdmin; | ||||
use FilterTrait; | use FilterTrait; | ||||
public function __construct( | public function __construct( | ||||
SessionInterface $session, | |||||
RequestStack $requestStack, | |||||
EntityManagerInterface $entityManager, | EntityManagerInterface $entityManager, | ||||
TranslatorAdmin $translatorAdmin | TranslatorAdmin $translatorAdmin | ||||
) { | ) { | ||||
$this->session = $session; | |||||
$this->requestStack = $requestStack; | |||||
$this->em = $entityManager; | $this->em = $entityManager; | ||||
$this->translatorAdmin = $translatorAdmin; | $this->translatorAdmin = $translatorAdmin; | ||||
} | } | ||||
//Il existe une valeur posté dans le formulaire | //Il existe une valeur posté dans le formulaire | ||||
if ($value !== null) { | if ($value !== null) { | ||||
$this->session->set($sessionParam, $value); | |||||
$this->requestStack->getSession()->set($sessionParam, $value); | |||||
return $value; | return $value; | ||||
} | } | ||||
// pas de valeur et le form est envoyé, on supprimer le filtre correspondant | // pas de valeur et le form est envoyé, on supprimer le filtre correspondant | ||||
elseif($formField->isSubmitted()) { | elseif($formField->isSubmitted()) { | ||||
$this->session->remove($sessionParam); | |||||
$this->requestStack->getSession()->remove($sessionParam); | |||||
} | } | ||||
//action reset | //action reset | ||||
if ($filtersForm->get('reset')->getData() == 'clearAll') { | if ($filtersForm->get('reset')->getData() == 'clearAll') { | ||||
$this->session->remove($sessionParam); | |||||
$this->requestStack->getSession()->remove($sessionParam); | |||||
return null; | return null; | ||||
} | } | ||||
//Récupération des valeurs stocké en sessions si le forrmFilters n'a pas été posté | //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 | //Champ date | ||||
if ($formField->getConfig()->getOption('input') == 'datetime') { | if ($formField->getConfig()->getOption('input') == 'datetime') { |
namespace Lc\SovBundle; | namespace Lc\SovBundle; | ||||
use Lc\SovBundle\DependencyInjection\LcSovExtension; | use Lc\SovBundle\DependencyInjection\LcSovExtension; | ||||
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; | |||||
use Symfony\Component\HttpKernel\Bundle\Bundle; | use Symfony\Component\HttpKernel\Bundle\Bundle; | ||||
class LcSovBundle extends Bundle | class LcSovBundle extends Bundle | ||||
{ | { | ||||
public function getContainerExtension() | |||||
public function getContainerExtension(): ?ExtensionInterface | |||||
{ | { | ||||
return new LcSovExtension(); | return new LcSovExtension(); | ||||
} | } |
use Lc\SovBundle\Doctrine\Extension\DevAliasTrait; | use Lc\SovBundle\Doctrine\Extension\DevAliasTrait; | ||||
use Lc\SovBundle\Doctrine\Extension\TimestampableTrait; | use Lc\SovBundle\Doctrine\Extension\TimestampableTrait; | ||||
use Lc\SovBundle\Model\Ticket\TicketInterface; | use Lc\SovBundle\Model\Ticket\TicketInterface; | ||||
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface; | |||||
use Symfony\Component\Security\Core\User\UserInterface; | use Symfony\Component\Security\Core\User\UserInterface; | ||||
use Lc\SovBundle\Model\User\UserInterface as SovUserInterface; | use Lc\SovBundle\Model\User\UserInterface as SovUserInterface; | ||||
/** | /** | ||||
* @ORM\MappedSuperclass() | * @ORM\MappedSuperclass() | ||||
*/ | */ | ||||
abstract class UserModel implements EntityInterface, UserInterface, SovUserInterface, DevAliasInterface | |||||
abstract class UserModel implements EntityInterface, UserInterface, SovUserInterface, DevAliasInterface, PasswordAuthenticatedUserInterface | |||||
{ | { | ||||
use DevAliasTrait; | use DevAliasTrait; | ||||
use TimestampableTrait; | use TimestampableTrait; | ||||
{ | { | ||||
$this->tickets = new ArrayCollection(); | $this->tickets = new ArrayCollection(); | ||||
} | } | ||||
public function getUserIdentifier(): string | |||||
{ | |||||
return (string) $this->email; | |||||
} | |||||
public function __toString() | public function __toString() | ||||
{ | { |
class MailMailjetNotification | 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); | |||||
// } | |||||
} | } |
namespace Lc\SovBundle\Repository\Site; | namespace Lc\SovBundle\Repository\Site; | ||||
use Lc\CaracoleBundle\Repository\SectionStoreTrait; | |||||
use Lc\SovBundle\Repository\AbstractStore; | use Lc\SovBundle\Repository\AbstractStore; | ||||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | use Lc\SovBundle\Repository\RepositoryQueryInterface; | ||||
namespace Lc\SovBundle\Repository\Ticket; | namespace Lc\SovBundle\Repository\Ticket; | ||||
use App\Entity\Ticket\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\Model\User\UserInterface; | ||||
use Lc\SovBundle\Repository\AbstractStore; | use Lc\SovBundle\Repository\AbstractStore; | ||||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | use Lc\SovBundle\Repository\RepositoryQueryInterface; |
margin-right: 6px; | margin-right: 6px; | ||||
} | } | ||||
} | } | ||||
.form-check-label{ | |||||
height: 24px; | |||||
vertical-align: bottom; | |||||
} | |||||
} | } | ||||
} | } | ||||
} | } |
.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; | |||||
} | |||||
} | |||||
} |
legend { | legend { | ||||
font-weight: bold; | 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 { | .label-ticket { | ||||
display: none; | display: none; | ||||
} | } |
border-radius: 50%; | border-radius: 50%; | ||||
background: white; | background: white; | ||||
} | } | ||||
} | } | ||||
.form-check-label :hover input ~ .checkmark { | .form-check-label :hover input ~ .checkmark { |
import {SovTools} from "./tools"; | |||||
export class SovWidgetCollection { | export class SovWidgetCollection { | ||||
static setCollectionWidgetAdd($collectionWidget) { | static setCollectionWidgetAdd($collectionWidget) { | ||||
if ($collectionWidget.data('allow-add')) { | if ($collectionWidget.data('allow-add')) { | ||||
$collectionWidget.find('.field-collection-add').on('click', function (e) { | $collectionWidget.find('.field-collection-add').on('click', function (e) { | ||||
// grab the prototype template | // grab the prototype template |
app.admin.logo_sidebar: 'laclic.png' | app.admin.logo_sidebar: 'laclic.png' | ||||
app.site_name: 'laclic-sov' | app.site_name: 'laclic-sov' | ||||
app.mail_debug: '' | 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: | services: | ||||
_defaults: | _defaults: |
fields: | fields: | ||||
users: Utilisateurs | users: Utilisateurs | ||||
dateReminder: Date limite | dateReminder: Date limite | ||||
flashes: | |||||
success: | |||||
added: Le pense bête a bien été ajouté | |||||
Ticket: | Ticket: | ||||
label: Ticket | label: Ticket | ||||
label_plurial: Tickets | label_plurial: Tickets | ||||
confirmDelete: Confirmer la suppression | confirmDelete: Confirmer la suppression | ||||
createdAt: Créé le | createdAt: Créé le | ||||
user: Utilisateur | user: Utilisateur | ||||
createdBy: Créé par | |||||
updatedBy: Mis à jour par | |||||
firstname: Prénom | firstname: Prénom | ||||
lastname: Nom | lastname: Nom | ||||
page: Page | page: Page | ||||
updated: L'élément a bien été mis à jour | updated: L'élément a bien été mis à jour | ||||
deleted: L'élément a bien été supprimé | deleted: L'élément a bien été supprimé | ||||
duplicate: L'élément a bien été dupliqué | duplicate: L'élément a bien été dupliqué | ||||
sorted: La position des éléments a bien été modifié | |||||
error: | error: | ||||
validation: Une erreur est survenue à l'envoi du formulaire. Réessayer et si le problème persiste, contactez les développeurs. | 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 | created: Une erreur est survenue à la création de l'élément |
{% if 'toMany' == field.customOptions.get('associationType') %} | {% if 'toMany' == field.customOptions.get('associationType') %} | ||||
<span class="badge badge-secondary">{{ field.formattedValue }}</span> | <span class="badge badge-secondary">{{ field.formattedValue }}</span> | ||||
{% else %} | {% 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 %} | {% else %} | ||||
{{ field.formattedValue }} | {{ field.formattedValue }} | ||||
{% endif %} | {% endif %} |
{# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #} | {# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #} | ||||
{# @var entity \EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto #} | {# @var entity \EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto #} | ||||
{% extends ea.templatePath('layout') %} | {% extends ea.templatePath('layout') %} | ||||
{% trans_default_domain ea.i18n.translationDomain %} | |||||
{% if ea.crud.currentAction == 'new' %} | {% if ea.crud.currentAction == 'new' %} | ||||
{% set form = new_form %} | {% 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_id = 'ea-new-' ~translation_entity_name ~ '-' ~ entity.primaryKeyValue %} | ||||
{% set body_class = 'ea-new ea-new-' ~ translation_entity_name %} | {% set body_class = 'ea-new ea-new-' ~ translation_entity_name %} | ||||
{% set content_title = 'new'|sov_trans_admin_title(translation_entity_name) %} | {% set content_title = 'new'|sov_trans_admin_title(translation_entity_name) %} | ||||
{% elseif ea.crud.currentAction == 'edit' %} | {% elseif ea.crud.currentAction == 'edit' %} | ||||
{% set form = edit_form %} | {% 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_id = 'ea-edit-' ~ translation_entity_name ~ '-' ~ entity.primaryKeyValue %} | ||||
{% set body_class = 'ea-edit ea-edit-' ~ translation_entity_name %} | {% set body_class = 'ea-edit ea-edit-' ~ translation_entity_name %} | ||||
{% if attribute(ea.getEntity().getInstance(), 'getTitle') is defined %} | {% if attribute(ea.getEntity().getInstance(), 'getTitle') is defined %} | ||||
{% endif %} | {% endif %} | ||||
{% endif %} | {% endif %} | ||||
{% form_theme form with ea.crud.formThemes only %} | {% form_theme form with ea.crud.formThemes only %} | ||||
{% trans_default_domain ea.i18n.translationDomain %} | |||||
{% block body_id body_id %} | {% block body_id body_id %} | ||||
{% block body_class body_class %} | {% block body_class body_class %} | ||||
{{ content_title }} | {{ content_title }} | ||||
{% endblock %} | {% endblock %} | ||||
{% block head_javascript %} | |||||
{{ parent() }} | |||||
<script src="{{ asset('form.js', ea.assets.defaultAssetPackageName) }}"></script> | |||||
{% endblock head_javascript %} | |||||
{% block configured_head_contents %} | {% block configured_head_contents %} | ||||
{{ parent() }} | {{ parent() }} | ||||
{% for htmlContent in form.vars.ea_crud_form.assets.headContents %} | |||||
{% for htmlContent in ea_field_assets.headContents %} | |||||
{{ htmlContent|raw }} | {{ htmlContent|raw }} | ||||
{% endfor %} | {% endfor %} | ||||
{% endblock %} | {% endblock %} | ||||
{% block configured_stylesheets %} | |||||
{% block configured_body_contents %} | |||||
{{ parent() }} | {{ 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 %} | {% endfor %} | ||||
{% endblock %} | {% endblock %} | ||||
{% block configured_javascripts %} | |||||
{% block configured_stylesheets %} | |||||
{{ parent() }} | {{ 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 %} | {% endblock %} | ||||
{% block page_actions_wrapper %} | {% block page_actions_wrapper %} | ||||
{% endblock page_actions_wrapper %} | {% endblock page_actions_wrapper %} | ||||
{% block main %} | {% block main %} | ||||
<div class="row"> | <div class="row"> | ||||
<div class="col-8"> | <div class="col-8"> |
{# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #} | {# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #} | ||||
{% use '@EasyAdmin/crud/form_theme.html.twig' %} | |||||
{% extends '@EasyAdmin/crud/form_theme.html.twig' %} | |||||
{% block form_start %} | {% block form_start %} | ||||
{% if form.vars.errors|length > 0 and 'ea_crud' in form.vars.block_prefixes|default([]) %} | {% if form.vars.errors|length > 0 and 'ea_crud' in form.vars.block_prefixes|default([]) %} | ||||
'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-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-add': allow_add ? 'true' : 'false', | ||||
'data-allow-delete': allow_delete ? '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 : '', | 'data-form-type-name-placeholder': prototype is defined ? prototype.vars.name : '', | ||||
}) %} | }) %} | ||||
</div> | </div> | ||||
{% endblock collection_entry_widget %} | {% 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 %} | {% block file_manager_image_row %} | ||||
{{ form_widget(form) }} | {{ form_widget(form) }} | ||||
{% endblock file_manager_image_row %} | {% endblock file_manager_image_row %} |
namespace Lc\SovBundle\Translation; | namespace Lc\SovBundle\Translation; | ||||
use Symfony\Component\HttpFoundation\Session\SessionInterface; | |||||
use Symfony\Component\HttpFoundation\RequestStack; | |||||
/** | /** | ||||
* class FlashBag. | * class FlashBag. | ||||
class FlashBagTranslator | class FlashBagTranslator | ||||
{ | { | ||||
protected SessionInterface $session; | |||||
protected RequestStack $requestStack; | |||||
protected TranslatorAdmin $translatorAdmin; | 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; | $this->translatorAdmin = $translatorAdmin; | ||||
} | } | ||||
$translationEntityName = null, | $translationEntityName = null, | ||||
$translationParam = array() | $translationParam = array() | ||||
): void { | ): void { | ||||
$this->session->getFlashBag()->add( | |||||
$this->requestStack->getSession()->getFlashBag()->add( | |||||
$type, | $type, | ||||
$this->translatorAdmin->transFlashMessage( | $this->translatorAdmin->transFlashMessage( | ||||
$type, | $type, |
namespace Lc\SovBundle\Twig; | 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\Model\Site\SiteInterface; | ||||
use Lc\SovBundle\Repository\Reminder\ReminderStoreInterface; | use Lc\SovBundle\Repository\Reminder\ReminderStoreInterface; | ||||
use Lc\SovBundle\Solver\Setting\SettingSolver; | use Lc\SovBundle\Solver\Setting\SettingSolver; | ||||
public function getReminders($params) | public function getReminders($params) | ||||
{ | { | ||||
// @TODO : à faire | |||||
return array(); | |||||
return $this->reminderStore->get($params); | |||||
} | } | ||||
} | } |