Browse Source

Intégration app reduction

develop
Fab 3 years ago
parent
commit
659e69a9fb
59 changed files with 1160 additions and 453 deletions
  1. +1
    -1
      Builder/Ticket/TicketBuilder.php
  2. +1
    -1
      Builder/User/UserBuilder.php
  3. +14
    -0
      Component/DateComponent.php
  4. +1
    -1
      Component/FormComponent.php
  5. +39
    -0
      Container/File/FileContainer.php
  6. +39
    -0
      Container/Newsletter/NewsletterContainer.php
  7. +39
    -0
      Container/Reminder/ReminderContainer.php
  8. +48
    -0
      Container/Setting/SiteSettingContainer.php
  9. +39
    -0
      Container/Site/NewsContainer.php
  10. +39
    -0
      Container/Site/PageContainer.php
  11. +39
    -0
      Container/Site/SiteContainer.php
  12. +48
    -0
      Container/Ticket/TicketContainer.php
  13. +39
    -0
      Container/Ticket/TicketMessageContainer.php
  14. +39
    -0
      Container/User/GroupUserContainer.php
  15. +48
    -0
      Container/User/UserContainer.php
  16. +30
    -6
      Controller/AbstractAdminController.php
  17. +2
    -2
      Controller/Newsletter/NewsletterAdminController.php
  18. +7
    -8
      Controller/Reminder/ReminderAdminController.php
  19. +9
    -25
      Controller/Setting/SettingAdminController.php
  20. +2
    -2
      Controller/Site/NewsAdminController.php
  21. +2
    -2
      Controller/Site/PageAdminController.php
  22. +10
    -9
      Controller/Ticket/TicketAdminController.php
  23. +8
    -7
      Controller/User/AccountAdminController.php
  24. +2
    -2
      Controller/User/GroupUserAdminController.php
  25. +3
    -3
      Controller/User/UserAdminController.php
  26. +51
    -0
      Doctrine/Extension/BlameableNullableTrait.php
  27. +1
    -1
      Factory/File/FileFactory.php
  28. +0
    -8
      Factory/File/FileFactoryInterface.php
  29. +1
    -1
      Factory/Newsletter/NewsletterFactory.php
  30. +0
    -8
      Factory/Newsletter/NewsletterFactoryInterface.php
  31. +5
    -2
      Factory/Reminder/ReminderFactory.php
  32. +6
    -4
      Model/Setting/EntitySettingTrait.php
  33. +8
    -0
      Model/Setting/SettingInterface.php
  34. +1
    -12
      Model/Setting/SettingModel.php
  35. +54
    -0
      Model/Site/NewsModel.php
  36. +0
    -17
      Model/Site/PageModel.php
  37. +2
    -14
      Model/Ticket/TicketMessageModel.php
  38. +4
    -83
      Model/Ticket/TicketModel.php
  39. +118
    -26
      Model/User/UserModel.php
  40. +29
    -26
      Repository/AbstractRepository.php
  41. +32
    -4
      Repository/AbstractRepositoryQuery.php
  42. +20
    -0
      Repository/AbstractStore.php
  43. +22
    -85
      Repository/Reminder/ReminderStore.php
  44. +0
    -2
      Repository/Site/NewsRepositoryQuery.php
  45. +4
    -20
      Repository/Site/NewsStore.php
  46. +0
    -6
      Repository/Site/PageRepositoryQuery.php
  47. +0
    -11
      Repository/Site/PageStore.php
  48. +26
    -0
      Repository/StatusRepositoryQueryTrait.php
  49. +2
    -2
      Repository/Ticket/TicketRepositoryQuery.php
  50. +10
    -16
      Repository/Ticket/TicketStore.php
  51. +24
    -0
      Repository/TreeRepositoryQueryTrait.php
  52. +1
    -1
      Repository/User/UserRepository.php
  53. +16
    -8
      Repository/User/UserRepositoryQuery.php
  54. +18
    -20
      Repository/User/UserStore.php
  55. +2
    -2
      Resolver/UrlResolver.php
  56. +21
    -0
      Solver/Setting/SettingSolver.php
  57. +76
    -0
      Solver/Ticket/TicketSolver.php
  58. +53
    -0
      Solver/User/UserSolver.php
  59. +5
    -5
      Translation/TranslatorAdmin.php

+ 1
- 1
Builder/Ticket/TicketBuilder.php View File

} }


// uploadImageTicketMessage // uploadImageTicketMessage
public function uploadImageTicketMessage($formTicket)
public function uploadImageTicketMessage($formTicket): ?string
{ {
return $this->formComponent->uploadFile( return $this->formComponent->uploadFile(
$formTicket, $formTicket,

+ 1
- 1
Builder/User/UserBuilder.php View File

$this->entityManager = $entityManager; $this->entityManager = $entityManager;
} }


public function setNewsletter(UserInterface $user, NewsletterInterface $newsletter, bool $subscribeNewsletter)
public function setNewsletter(UserInterface $user, NewsletterInterface $newsletter, bool $subscribeNewsletter): void
{ {
if ($subscribeNewsletter) { if ($subscribeNewsletter) {
$user->addNewsletter($newsletter); $user->addNewsletter($newsletter);

+ 14
- 0
Component/DateComponent.php View File

return ''; return '';
} }


// getDeliverySlotHour
public function getHour(\DateTime $date)
{
$timestamp = $date->getTimestamp() ;
$hour = $this->date('%kh', $timestamp) ;
$minutes = $this->date('%M', $timestamp) ;

if($minutes != '00') {
$hour .= $minutes ;
}

return $hour ;
}

} }

+ 1
- 1
Component/FormComponent.php View File

} }


// uploadImageTicketMessage // uploadImageTicketMessage
public function uploadFile($form, $child, $directory, $subdirectory)
public function uploadFile($form, $child, $directory, $subdirectory): ?string
{ {
$file = $form->get($child)->getData(); $file = $form->get($child)->getData();



+ 39
- 0
Container/File/FileContainer.php View File

<?php

namespace Lc\SovBundle\Container\File;

use Lc\SovBundle\Factory\File\FileFactory;
use Lc\SovBundle\Repository\File\FileRepositoryQuery;
use Lc\SovBundle\Repository\File\FileStore;

class FileContainer
{
protected FileFactory $factory;
protected FileRepositoryQuery $repositoryQuery;
protected FileStore $store;

public function __construct(
FileFactory $factory,
FileRepositoryQuery $repositoryQuery,
FileStore $store
) {
$this->factory = $factory;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
}

public function getFactory(): FileFactory
{
return $this->factory;
}

public function getRepositoryQuery(): FileRepositoryQuery
{
return $this->repositoryQuery;
}

public function getStore(): FileStore
{
return $this->store;
}
}

+ 39
- 0
Container/Newsletter/NewsletterContainer.php View File

<?php

namespace Lc\SovBundle\Container\Newsletter;

use Lc\SovBundle\Factory\Newsletter\NewsletterFactory;
use Lc\SovBundle\Repository\Newsletter\NewsletterRepositoryQuery;
use Lc\SovBundle\Repository\Newsletter\NewsletterStore;

class NewsletterContainer
{
protected NewsletterFactory $factory;
protected NewsletterRepositoryQuery $repositoryQuery;
protected NewsletterStore $store;

public function __construct(
NewsletterFactory $factory,
NewsletterRepositoryQuery $repositoryQuery,
NewsletterStore $store
) {
$this->factory = $factory;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
}

public function getFactory(): NewsletterFactory
{
return $this->factory;
}

public function getRepositoryQuery(): NewsletterRepositoryQuery
{
return $this->repositoryQuery;
}

public function getStore(): NewsletterStore
{
return $this->store;
}
}

+ 39
- 0
Container/Reminder/ReminderContainer.php View File

<?php

namespace Lc\SovBundle\Container\Reminder;

use Lc\SovBundle\Factory\Reminder\ReminderFactory;
use Lc\SovBundle\Repository\Reminder\ReminderRepositoryQuery;
use Lc\SovBundle\Repository\Reminder\ReminderStore;

class ReminderContainer
{
protected ReminderFactory $factory;
protected ReminderRepositoryQuery $repositoryQuery;
protected ReminderStore $store;

public function __construct(
ReminderFactory $factory,
ReminderRepositoryQuery $repositoryQuery,
ReminderStore $store
) {
$this->factory = $factory;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
}

public function getFactory(): ReminderFactory
{
return $this->factory;
}

public function getRepositoryQuery(): ReminderRepositoryQuery
{
return $this->repositoryQuery;
}

public function getStore(): ReminderStore
{
return $this->store;
}
}

+ 48
- 0
Container/Setting/SiteSettingContainer.php View File

<?php

namespace Lc\SovBundle\Container\Setting;

use Lc\SovBundle\Definition\SiteSettingDefinition;
use Lc\SovBundle\Factory\Setting\SiteSettingFactory;
use Lc\SovBundle\Repository\Setting\SiteSettingRepositoryQuery;
use Lc\SovBundle\Repository\Setting\SiteSettingStore;

class SiteSettingContainer
{
protected SiteSettingFactory $factory;
protected SiteSettingDefinition $definition;
protected SiteSettingRepositoryQuery $repositoryQuery;
protected SiteSettingStore $store;

public function __construct(
SiteSettingFactory $factory,
SiteSettingDefinition $definition,
SiteSettingRepositoryQuery $repositoryQuery,
SiteSettingStore $store
) {
$this->factory = $factory;
$this->definition = $definition;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
}

public function getFactory(): SiteSettingFactory
{
return $this->factory;
}

public function getDefinition(): SiteSettingDefinition
{
return $this->definition;
}

public function getRepositoryQuery(): SiteSettingRepositoryQuery
{
return $this->repositoryQuery;
}

public function getStore(): SiteSettingStore
{
return $this->store;
}
}

+ 39
- 0
Container/Site/NewsContainer.php View File

<?php

namespace Lc\SovBundle\Container\Site;

use Lc\SovBundle\Factory\Site\NewsFactory;
use Lc\SovBundle\Repository\Site\NewsRepositoryQuery;
use Lc\SovBundle\Repository\Site\NewsStore;

class NewsContainer
{
protected NewsFactory $factory;
protected NewsRepositoryQuery $repositoryQuery;
protected NewsStore $store;

public function __construct(
NewsFactory $factory,
NewsRepositoryQuery $repositoryQuery,
NewsStore $store
) {
$this->factory = $factory;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
}

public function getFactory(): NewsFactory
{
return $this->factory;
}

public function getRepositoryQuery(): NewsRepositoryQuery
{
return $this->repositoryQuery;
}

public function getStore(): NewsStore
{
return $this->store;
}
}

+ 39
- 0
Container/Site/PageContainer.php View File

<?php

namespace Lc\SovBundle\Container\Site;

use Lc\SovBundle\Factory\Site\PageFactory;
use Lc\SovBundle\Repository\Site\PageRepositoryQuery;
use Lc\SovBundle\Repository\Site\PageStore;

class PageContainer
{
protected PageFactory $factory;
protected PageRepositoryQuery $repositoryQuery;
protected PageStore $store;

public function __construct(
PageFactory $factory,
PageRepositoryQuery $repositoryQuery,
PageStore $store
) {
$this->factory = $factory;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
}

public function getFactory(): PageFactory
{
return $this->factory;
}

public function getRepositoryQuery(): PageRepositoryQuery
{
return $this->repositoryQuery;
}

public function getStore(): PageStore
{
return $this->store;
}
}

+ 39
- 0
Container/Site/SiteContainer.php View File

<?php

namespace Lc\SovBundle\Container\Site;

use Lc\SovBundle\Factory\Site\SiteFactory;
use Lc\SovBundle\Repository\Site\SiteRepositoryQuery;
use Lc\SovBundle\Repository\Site\SiteStore;

class SiteContainer
{
protected SiteFactory $factory;
protected SiteRepositoryQuery $repositoryQuery;
protected SiteStore $store;

public function __construct(
SiteFactory $factory,
SiteRepositoryQuery $repositoryQuery,
SiteStore $store
) {
$this->factory = $factory;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
}

public function getFactory(): SiteFactory
{
return $this->factory;
}

public function getRepositoryQuery(): SiteRepositoryQuery
{
return $this->repositoryQuery;
}

public function getStore(): SiteStore
{
return $this->store;
}
}

+ 48
- 0
Container/Ticket/TicketContainer.php View File

<?php

namespace Lc\SovBundle\Container\Ticket;

use Lc\SovBundle\Builder\Ticket\TicketBuilder;
use Lc\SovBundle\Factory\Ticket\TicketFactory;
use Lc\SovBundle\Repository\Ticket\TicketRepositoryQuery;
use Lc\SovBundle\Repository\Ticket\TicketStore;

class TicketContainer
{
protected TicketFactory $factory;
protected TicketBuilder $builder;
protected TicketRepositoryQuery $repositoryQuery;
protected TicketStore $store;

public function __construct(
TicketFactory $factory,
TicketBuilder $builder,
TicketRepositoryQuery $repositoryQuery,
TicketStore $store
) {
$this->factory = $factory;
$this->builder = $builder;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
}

public function getFactory(): TicketFactory
{
return $this->factory;
}

public function getBuilder(): TicketBuilder
{
return $this->builder;
}

public function getRepositoryQuery(): TicketRepositoryQuery
{
return $this->repositoryQuery;
}

public function getStore(): TicketStore
{
return $this->store;
}
}

+ 39
- 0
Container/Ticket/TicketMessageContainer.php View File

<?php

namespace Lc\SovBundle\Container\Ticket;

use Lc\SovBundle\Factory\Ticket\TicketMessageFactory;
use Lc\SovBundle\Repository\Ticket\TicketMessageRepositoryQuery;
use Lc\SovBundle\Repository\Ticket\TicketMessageStore;

class TicketMessageContainer
{
protected TicketMessageFactory $factory;
protected TicketMessageRepositoryQuery $repositoryQuery;
protected TicketMessageStore $store;

public function __construct(
TicketMessageFactory $factory,
TicketMessageRepositoryQuery $repositoryQuery,
TicketMessageStore $store
) {
$this->factory = $factory;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
}

public function getFactory(): TicketMessageFactory
{
return $this->factory;
}

public function getRepositoryQuery(): TicketMessageRepositoryQuery
{
return $this->repositoryQuery;
}

public function getStore(): TicketMessageStore
{
return $this->store;
}
}

+ 39
- 0
Container/User/GroupUserContainer.php View File

<?php

namespace Lc\SovBundle\Container\User;

use Lc\SovBundle\Factory\User\GroupUserFactory;
use Lc\SovBundle\Repository\User\GroupUserRepositoryQuery;
use Lc\SovBundle\Repository\User\GroupUserStore;

class GroupUserContainer
{
protected GroupUserFactory $factory;
protected GroupUserRepositoryQuery $repositoryQuery;
protected GroupUserStore $store;

public function __construct(
GroupUserFactory $factory,
GroupUserRepositoryQuery $repositoryQuery,
GroupUserStore $store
) {
$this->factory = $factory;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
}

public function getFactory(): GroupUserFactory
{
return $this->factory;
}

public function getRepositoryQuery(): GroupUserRepositoryQuery
{
return $this->repositoryQuery;
}

public function getStore(): GroupUserStore
{
return $this->store;
}
}

+ 48
- 0
Container/User/UserContainer.php View File

<?php

namespace Lc\SovBundle\Container\User;

use Lc\SovBundle\Builder\User\UserBuilder;
use Lc\SovBundle\Factory\User\UserFactory;
use Lc\SovBundle\Repository\User\UserRepositoryQuery;
use Lc\SovBundle\Repository\User\UserStore;

class UserContainer
{
protected UserFactory $factory;
protected UserBuilder $builder;
protected UserRepositoryQuery $repositoryQuery;
protected UserStore $store;

public function __construct(
UserFactory $factory,
UserBuilder $builder,
UserRepositoryQuery $repositoryQuery,
UserStore $store
) {
$this->factory = $factory;
$this->builder = $builder;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
}

public function getFactory(): UserFactory
{
return $this->factory;
}

public function getBuilder(): UserBuilder
{
return $this->builder;
}

public function getRepositoryQuery(): UserRepositoryQuery
{
return $this->repositoryQuery;
}

public function getStore(): UserStore
{
return $this->store;
}
}

+ 30
- 6
Controller/AbstractAdminController.php View File

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\SovBundle\Component\EntityComponent; use Lc\SovBundle\Component\EntityComponent;
use Lc\SovBundle\Container\File\FileContainer;
use Lc\SovBundle\Container\Newsletter\NewsletterContainer;
use Lc\SovBundle\Container\Reminder\ReminderContainer;
use Lc\SovBundle\Container\Setting\SiteSettingContainer;
use Lc\SovBundle\Container\Site\NewsContainer;
use Lc\SovBundle\Container\Site\PageContainer;
use Lc\SovBundle\Container\Site\SiteContainer;
use Lc\SovBundle\Container\Ticket\TicketContainer;
use Lc\SovBundle\Container\Ticket\TicketMessageContainer;
use Lc\SovBundle\Container\User\GroupUserContainer;
use Lc\SovBundle\Container\User\UserContainer;
use Lc\SovBundle\Doctrine\Extension\DevAliasInterface; use Lc\SovBundle\Doctrine\Extension\DevAliasInterface;
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 Symfony\Component\Form\Extension\Core\Type\DateType; use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType; use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Session\SessionInterface; use Symfony\Component\HttpFoundation\Session\SessionInterface;


abstract class AbstractAdminController extends EaAbstractCrudController abstract class AbstractAdminController extends EaAbstractCrudController
{ {
protected $filtersForm;
protected FormInterface $filtersForm;


public static function getSubscribedServices() public static function getSubscribedServices()
{ {
return array_merge( return array_merge(
parent::getSubscribedServices(), parent::getSubscribedServices(),
[ [
'session' => SessionInterface::class,
'request' => RequestStack::class,
'em' => EntityManagerInterface::class,
'translator_admin' => TranslatorAdmin::class,
TranslatorAdmin::class => TranslatorAdmin::class, TranslatorAdmin::class => TranslatorAdmin::class,
'filter_manager' => FilterManager::class,
SessionInterface::class => SessionInterface::class,
RequestStack::class => RequestStack::class,
EntityManagerInterface::class => EntityManagerInterface::class,
FilterManager::class => FilterManager::class,

FileContainer::class => FileContainer::class,
NewsletterContainer::class => NewsletterContainer::class,
ReminderContainer::class => ReminderContainer::class,
NewsContainer::class => NewsContainer::class,
PageContainer::class => PageContainer::class,
SiteContainer::class => SiteContainer::class,
TicketContainer::class => TicketContainer::class,
TicketMessageContainer::class => TicketMessageContainer::class,
GroupUserContainer::class => GroupUserContainer::class,
UserContainer::class => UserContainer::class,
SiteSettingContainer::class => SiteSettingContainer::class,

] ]
); );
} }

+ 2
- 2
Controller/Newsletter/NewsletterAdminController.php View File



use EasyCorp\Bundle\EasyAdminBundle\Field\FormField; use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\SovBundle\Container\Newsletter\NewsletterContainer;
use Lc\SovBundle\Controller\AbstractAdminController; use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Factory\Newsletter\NewsletterFactory; use Lc\SovBundle\Factory\Newsletter\NewsletterFactory;
use Lc\SovBundle\Field\BooleanField; use Lc\SovBundle\Field\BooleanField;


public function createEntity(string $entityFqcn) public function createEntity(string $entityFqcn)
{ {
$factory = new NewsletterFactory();
return $factory->create();
return $this->get(NewsletterContainer::class)->getFactory()->create();
} }


} }

+ 7
- 8
Controller/Reminder/ReminderAdminController.php View File

use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Lc\CaracoleBundle\Resolver\MerchantResolver; use Lc\CaracoleBundle\Resolver\MerchantResolver;
use Lc\CaracoleBundle\Resolver\SectionResolver; use Lc\CaracoleBundle\Resolver\SectionResolver;
use Lc\SovBundle\Container\Reminder\ReminderContainer;
use Lc\SovBundle\Factory\Reminder\ReminderFactory; use Lc\SovBundle\Factory\Reminder\ReminderFactory;
use Lc\SovBundle\Factory\Reminder\ReminderFactoryInterface;
use Lc\SovBundle\Form\Reminder\ReminderAdminFormType; use Lc\SovBundle\Form\Reminder\ReminderAdminFormType;
use Lc\SovBundle\Repository\Reminder\ReminderRepositoryQueryInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\Form\FormFactoryInterface;
{ {


protected EntityManagerInterface $entityManager; protected EntityManagerInterface $entityManager;
protected ReminderRepositoryQueryInterface $reminderRepositoryQuery;
protected ReminderContainer $reminderContainer;
protected FormFactoryInterface $formFactory; protected FormFactoryInterface $formFactory;
protected UrlGeneratorInterface $urlGenerator; protected UrlGeneratorInterface $urlGenerator;
protected MerchantResolver $merchantResolver; protected MerchantResolver $merchantResolver;


public function __construct( public function __construct(
EntityManagerInterface $entityManager, EntityManagerInterface $entityManager,
ReminderRepositoryQueryInterface $reminderRepositoryQuery,
ReminderContainer $reminderContainer,
FormFactoryInterface $formFactory, FormFactoryInterface $formFactory,
UrlGeneratorInterface $urlGenerator, UrlGeneratorInterface $urlGenerator,
ParameterBagInterface $parameterBag ParameterBagInterface $parameterBag
) { ) {
$this->entityManager = $entityManager; $this->entityManager = $entityManager;
$this->reminderRepositoryQuery = $reminderRepositoryQuery;
$this->reminderContainer = $reminderContainer;
$this->formFactory = $formFactory; $this->formFactory = $formFactory;
$this->urlGenerator = $urlGenerator; $this->urlGenerator = $urlGenerator;
$this->parameterBag = $parameterBag; $this->parameterBag = $parameterBag;
$id = $request->get('id'); $id = $request->get('id');


if($id) { if($id) {
$reminder = $this->reminderRepositoryQuery->getRepository()->find($id);
$reminder = $this->reminderContainer->getRepositoryQuery()->getRepository()->find($id);
$action = $this->urlGenerator->generate( $action = $this->urlGenerator->generate(
$this->parameterBag->get('app.reminder.route_edit'), $this->parameterBag->get('app.reminder.route_edit'),
['id' => $id] ['id' => $id]
public function edit(Request $request) public function edit(Request $request)
{ {
$id = $request->get('id'); $id = $request->get('id');
$reminder = $this->reminderRepositoryQuery->getRepository()->find($id);
$reminder = $this->reminderContainer->getRepositoryQuery()->getRepository()->find($id);


$form = $this->formFactory->create(ReminderAdminFormType::class, $reminder); $form = $this->formFactory->create(ReminderAdminFormType::class, $reminder);
$form->handleRequest($request); $form->handleRequest($request);
public function done(Request $request): JsonResponse public function done(Request $request): JsonResponse
{ {
$id = $request->get('id'); $id = $request->get('id');
$reminder = $this->reminderRepositoryQuery->getRepository()->find($id);
$reminder = $this->reminderContainer->getRepositoryQuery()->getRepository()->find($id);
$done = $request->get('done'); $done = $request->get('done');


if($done == 'true') { if($done == 'true') {

+ 9
- 25
Controller/Setting/SettingAdminController.php View File

namespace Lc\SovBundle\Controller\Setting; namespace Lc\SovBundle\Controller\Setting;


use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Lc\SovBundle\Container\Setting\SiteSettingContainer;
use Lc\SovBundle\Container\Site\SiteContainer;
use Lc\SovBundle\Definition\SiteSettingDefinitionInterface; use Lc\SovBundle\Definition\SiteSettingDefinitionInterface;
use Lc\SovBundle\Form\Setting\SiteSettingsFormType; use Lc\SovBundle\Form\Setting\SiteSettingsFormType;
use Lc\SovBundle\Repository\Setting\SiteSettingRepository; use Lc\SovBundle\Repository\Setting\SiteSettingRepository;


class SettingAdminController extends AbstractController class SettingAdminController extends AbstractController
{ {
protected $em;
protected $translatorAdmin;
protected $siteSettingRepository;
protected $siteSettingDefinition;
protected $siteRepository;

public function __construct(
EntityManagerInterface $em,
TranslatorAdmin $translatorAdmin,
SiteSettingRepository $siteSettingRepository,
SiteSettingDefinitionInterface $siteSettingDefinition,
SiteRepository $siteRepository
) {
$this->em = $em;
$this->translatorAdmin = $translatorAdmin;
$this->siteSettingRepository = $siteSettingRepository;
$this->siteSettingDefinition = $siteSettingDefinition;
$this->siteRepository = $siteRepository;
}


/** /**
* @Route("/admin/setting/site", name="sov_admin_setting_site") * @Route("/admin/setting/site", name="sov_admin_setting_site")
*/ */
public function manageGlobal(Request $request)
public function manageGlobal(Request $request, EntityManagerInterface $entityManager)
{ {
$site = $this->siteRepository->findOneByDevAlias('default') ;

$site = $this->get(SiteContainer::class)->getStore()->getOneByDevAlias('default') ;
$form = $this->createForm(SiteSettingsFormType::class, $site); $form = $this->createForm(SiteSettingsFormType::class, $site);


$form->handleRequest($request); $form->handleRequest($request);


if ($form->isSubmitted() && $form->isValid()) { if ($form->isSubmitted() && $form->isValid()) {


$this->em->update($site);
$this->em->flush();
$entityManager->update($site);
$entityManager->flush();


$this->addFlash('success', $this->translatorAdmin->transFlashMessage('settings_saved'));
$this->addFlash('success', $this->get(TranslatorAdmin::class)->transFlashMessage('settings_saved'));
} }


return $this->render( return $this->render(
'@LcSov/admin/setting/edit_site.html.twig' , '@LcSov/admin/setting/edit_site.html.twig' ,
[ [
'setting_definition' => $this->siteSettingDefinition,
'setting_definition' => $this->get(SiteSettingContainer::class)->getDefinition(),
'form' => $form->createView() 'form' => $form->createView()
] ]
); );

+ 2
- 2
Controller/Site/NewsAdminController.php View File

use EasyCorp\Bundle\EasyAdminBundle\Field\FormField; use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\SovBundle\Container\Site\NewsContainer;
use Lc\SovBundle\Controller\AbstractAdminController; use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Factory\Site\NewsFactory; use Lc\SovBundle\Factory\Site\NewsFactory;
use Lc\SovBundle\Field\CKEditorField; use Lc\SovBundle\Field\CKEditorField;


public function createEntity(string $entityFqcn) public function createEntity(string $entityFqcn)
{ {
$factory = new NewsFactory();
return $factory->create();
return $this->get(NewsContainer::class)->getFactory()->create();
} }
} }

+ 2
- 2
Controller/Site/PageAdminController.php View File

use EasyCorp\Bundle\EasyAdminBundle\Field\FormField; use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\SovBundle\Container\Site\PageContainer;
use Lc\SovBundle\Controller\AbstractAdminController; use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Factory\Site\PageFactory; use Lc\SovBundle\Factory\Site\PageFactory;
use Lc\SovBundle\Field\CKEditorField; use Lc\SovBundle\Field\CKEditorField;


public function createEntity(string $entityFqcn) public function createEntity(string $entityFqcn)
{ {
$factory = new PageFactory();
return $factory->create();
return $this->get(PageContainer::class)->getFactory()->create();
} }


} }

+ 10
- 9
Controller/Ticket/TicketAdminController.php View File



namespace Lc\SovBundle\Controller\Ticket; namespace Lc\SovBundle\Controller\Ticket;


use Doctrine\ORM\EntityManagerInterface;
use EasyCorp\Bundle\EasyAdminBundle\Config\Action; use EasyCorp\Bundle\EasyAdminBundle\Config\Action;
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions; use EasyCorp\Bundle\EasyAdminBundle\Config\Actions;
use EasyCorp\Bundle\EasyAdminBundle\Config\Assets; use EasyCorp\Bundle\EasyAdminBundle\Config\Assets;
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField; use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator;
use Lc\SovBundle\Container\Ticket\TicketContainer;
use Lc\SovBundle\Factory\Ticket\TicketFactory; use Lc\SovBundle\Factory\Ticket\TicketFactory;
use Lc\SovBundle\Factory\Ticket\TicketFactoryInterface; use Lc\SovBundle\Factory\Ticket\TicketFactoryInterface;
use Lc\SovBundle\Factory\Ticket\TicketMessageFactory; use Lc\SovBundle\Factory\Ticket\TicketMessageFactory;
use Lc\SovBundle\Model\Ticket\TicketModel; use Lc\SovBundle\Model\Ticket\TicketModel;
use Lc\SovBundle\Translation\TranslatorAdmin; use Lc\SovBundle\Translation\TranslatorAdmin;
use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\RequestStack;


class TicketAdminController extends AbstractAdminController class TicketAdminController extends AbstractAdminController
{ {


public function createEntity(string $entityFqcn) public function createEntity(string $entityFqcn)
{ {
$factory = new TicketFactory();
return $factory->create();
return $this->get(TicketContainer::class)->getFactory()->create();
} }


public function configureAssets(Assets $assets): Assets public function configureAssets(Assets $assets): Assets
if ($form->isSubmitted() && $form->isValid()) { if ($form->isSubmitted() && $form->isValid()) {
$ticket = $form->getData(); $ticket = $form->getData();


$this->get('em')->persist($ticket);
$this->get('em')->flush();
$this->get(EntityManagerInterface::class)->create($ticket);
$this->get(EntityManagerInterface::class)->flush();


$url = $adminUrlGenerator $url = $adminUrlGenerator
->setAction('index') ->setAction('index')
] ]
); );


$ticketMessageFactory = new TicketMessageFactory();
$ticketMessage = $ticketMessageFactory->create();
$ticketMessage = $this->get(TicketContainer::class)->getFactory()->create();
$formAddTicketMessage = $this->createForm(TicketMessageFormType::class, $ticketMessage); $formAddTicketMessage = $this->createForm(TicketMessageFormType::class, $ticketMessage);
$formAddTicketMessage->handleRequest($this->get('request')->getMasterRequest());
$formAddTicketMessage->handleRequest($this->get(RequestStack::class)->getMainRequest());


if ($formAddTicketMessage->isSubmitted() && $formAddTicketMessage->isValid()) { if ($formAddTicketMessage->isSubmitted() && $formAddTicketMessage->isValid()) {
$ticketMessage = $formAddTicketMessage->getData(); $ticketMessage = $formAddTicketMessage->getData();
$ticketMessage->setTicket($ticket); $ticketMessage->setTicket($ticket);
$ticketMessage->setAnswerByAdmin(true); $ticketMessage->setAnswerByAdmin(true);
$this->get('em')->persist($ticketMessage);
$this->get('em')->flush();
$this->get(EntityManagerInterface::class)->create($ticketMessage);
$this->get(EntityManagerInterface::class)->flush();
} }


return $this->render( return $this->render(

+ 8
- 7
Controller/User/AccountAdminController.php View File



namespace Lc\SovBundle\Controller\User; namespace Lc\SovBundle\Controller\User;


use Doctrine\ORM\EntityManagerInterface;
use Lc\SovBundle\Doctrine\EntityManager; 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;


class AccountAdminController extends AbstractController class AccountAdminController extends AbstractController
{ {
protected $em;
protected EntityManagerInterface $entityManager;


public function __construct(EntityManager $em)
public function __construct(EntityManagerInterface $entityManager)
{ {
$this->em = $em;
$this->entityManager = $entityManager;
} }


/** /**
if ($form->isSubmitted() && $form->isValid()) { if ($form->isSubmitted() && $form->isValid()) {
$user = $form->getData(); $user = $form->getData();


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


$this->addFlash('success', new TranslatableMessage('form.account_profile.message.success', [], 'admin')); $this->addFlash('success', new TranslatableMessage('form.account_profile.message.success', [], 'admin'));
} }


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


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


$this->addFlash('success', new TranslatableMessage('form.account_password.message.success', [], 'admin')); $this->addFlash('success', new TranslatableMessage('form.account_password.message.success', [], 'admin'));
} }

+ 2
- 2
Controller/User/GroupUserAdminController.php View File

namespace Lc\SovBundle\Controller\User; namespace Lc\SovBundle\Controller\User;


use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\SovBundle\Container\User\GroupUserContainer;
use Lc\SovBundle\Controller\AbstractAdminController; use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Factory\User\GroupUserFactory; use Lc\SovBundle\Factory\User\GroupUserFactory;




public function createEntity(string $entityFqcn) public function createEntity(string $entityFqcn)
{ {
$factory = new GroupUserFactory();
return $factory->create();
return $this->get(GroupUserContainer::class)->getFactory()->create();
} }
} }

+ 3
- 3
Controller/User/UserAdminController.php View File

use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField; use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
use EasyCorp\Bundle\EasyAdminBundle\Field\EmailField; use EasyCorp\Bundle\EasyAdminBundle\Field\EmailField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\SovBundle\Container\User\UserContainer;
use Lc\SovBundle\Controller\AbstractAdminController; use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Definition\RolesDefinition; use Lc\SovBundle\Definition\RolesDefinition;
use Lc\SovBundle\Definition\RolesDefinitionInterface; use Lc\SovBundle\Definition\RolesDefinitionInterface;


abstract class UserAdminController extends AbstractAdminController abstract class UserAdminController extends AbstractAdminController
{ {
protected $rolesDefinition;
protected RolesDefinitionInterface $rolesDefinition;


public function __construct( public function __construct(
SessionInterface $session, SessionInterface $session,


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

+ 51
- 0
Doctrine/Extension/BlameableNullableTrait.php View File

<?php

namespace Lc\SovBundle\Doctrine\Extension;

use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Lc\SovBundle\Model\User\UserInterface;

trait BlameableNullableTrait
{

/**
* @Gedmo\Blameable(on="create")
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface")
* @ORM\JoinColumn(nullable=true)
*/
protected $createdBy;

/**
* @Gedmo\Blameable(on="update")
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface")
* @ORM\JoinColumn(nullable=true)
*/
protected $updatedBy;


public function getCreatedBy(): ?UserInterface
{
return $this->createdBy;
}

public function setCreatedBy(?UserInterface $createdBy): self
{
$this->createdBy = $createdBy;

return $this;
}

public function getUpdatedBy(): ?UserInterface
{
return $this->updatedBy;
}

public function setUpdatedBy(?UserInterface $updatedBy): self
{
$this->updatedBy = $updatedBy;

return $this;
}

}

+ 1
- 1
Factory/File/FileFactory.php View File

use Lc\SovBundle\Factory\AbstractFactory; use Lc\SovBundle\Factory\AbstractFactory;
use Lc\SovBundle\Model\File\FileInterface; use Lc\SovBundle\Model\File\FileInterface;


class FileFactory extends AbstractFactory implements FileFactoryInterface
class FileFactory extends AbstractFactory
{ {
public function create(): FileInterface public function create(): FileInterface
{ {

+ 0
- 8
Factory/File/FileFactoryInterface.php View File

<?php

namespace Lc\SovBundle\Factory\File;

interface FileFactoryInterface
{

}

+ 1
- 1
Factory/Newsletter/NewsletterFactory.php View File

use Lc\SovBundle\Factory\AbstractFactory; use Lc\SovBundle\Factory\AbstractFactory;
use Lc\SovBundle\Model\Newsletter\NewsletterInterface; use Lc\SovBundle\Model\Newsletter\NewsletterInterface;


class NewsletterFactory extends AbstractFactory implements NewsletterFactoryInterface
class NewsletterFactory extends AbstractFactory
{ {
public function create(): NewsletterInterface public function create(): NewsletterInterface
{ {

+ 0
- 8
Factory/Newsletter/NewsletterFactoryInterface.php View File

<?php

namespace Lc\SovBundle\Factory\Newsletter;

interface NewsletterFactoryInterface
{

}

+ 5
- 2
Factory/Reminder/ReminderFactory.php View File



class ReminderFactory extends AbstractFactory implements ReminderFactoryInterface class ReminderFactory extends AbstractFactory implements ReminderFactoryInterface
{ {
public function create(string $crudAction = null, string $crudControllerFqcn = null, int $entityId = null): ReminderInterface
{
public function create(
string $crudAction = null,
string $crudControllerFqcn = null,
int $entityId = null
): ReminderInterface {
$reminder = new Reminder(); $reminder = new Reminder();


$reminder->setCrudAction($crudAction); $reminder->setCrudAction($crudAction);

+ 6
- 4
Model/Setting/EntitySettingTrait.php View File



namespace Lc\SovBundle\Model\Setting; namespace Lc\SovBundle\Model\Setting;


//TODO à déplacer dans un solver

trait EntitySettingTrait trait EntitySettingTrait
{ {
public function getSetting($name)
public function getSetting($name): ?SettingModel
{ {
if ($this->getSettings()) { if ($this->getSettings()) {
foreach ($this->getSettings() as $setting) { foreach ($this->getSettings() as $setting) {
} }
} }


return false;
return null;
} }


public function getSettingValue($name)
public function getSettingValue($name): ?string
{ {
if ($this->getSettings()) { if ($this->getSettings()) {
foreach ($this->getSettings() as $setting) { foreach ($this->getSettings() as $setting) {
} }
} }


return false;
return null;
} }


} }

+ 8
- 0
Model/Setting/SettingInterface.php View File

<?php

namespace Lc\SovBundle\Model\Setting;

interface SettingInterface
{

}

+ 1
- 12
Model/Setting/SettingModel.php View File

/** /**
* @ORM\MappedSuperclass() * @ORM\MappedSuperclass()
*/ */
abstract class SettingModel
abstract class SettingModel implements SettingInterface
{ {
/** /**
* @ORM\Column(type="string", length=63) * @ORM\Column(type="string", length=63)
*/ */
protected $file; protected $file;


public function getValue()
{
if ($this->getText()) {
return $this->getText();
} elseif ($this->getDate()) {
return $this->getDate();
} elseif ($this->getFile()) {
return $this->getFile();
}
}

public function getName(): ?string public function getName(): ?string
{ {
return $this->name; return $this->name;

+ 54
- 0
Model/Site/NewsModel.php View File

use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo; use Gedmo\Mapping\Annotation as Gedmo;
use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity; use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity;
use Lc\SovBundle\Model\File\FileInterface;
use Lc\SovBundle\Model\Newsletter\NewsletterInterface;


/** /**
* @ORM\MappedSuperclass() * @ORM\MappedSuperclass()
*/ */
protected $date; protected $date;


/**
* @ORM\Column(type="boolean", nullable=true)
*/
protected $isSent;


/**
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Newsletter\NewsletterInsterface", inversedBy="news")
*/
protected $newsletter;

/**
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\File\FileInsterface", cascade={"persist", "remove"})
*/
protected $image;

public function __toString() public function __toString()
{ {
return $this->getTitle(); return $this->getTitle();


return $this; return $this;
} }

public function getIsSent(): ?bool
{
return $this->isSent;
}

public function setIsSent(?bool $isSent): self
{
$this->isSent = $isSent;

return $this;
}

public function getImage(): ?FileInterface
{
return $this->image;
}

public function setImage(?FileInterface $image): self
{
$this->image = $image;

return $this;
}

public function getNewsletter(): ?NewsletterInterface
{
return $this->newsletter;
}

public function setNewsletter(?NewsletterInterface $newsletter): self
{
$this->newsletter = $newsletter;

return $this;
}
} }

+ 0
- 17
Model/Site/PageModel.php View File

*/ */
abstract class PageModel extends AbstractFullEntity implements PageInterface abstract class PageModel extends AbstractFullEntity implements PageInterface
{ {
/**
* @ORM\Column(type="text", nullable=true)
*/
protected $content;


public function __toString() public function __toString()
{ {
return $this->getTitle(); return $this->getTitle();
} }

public function getContent(): ?string
{
return $this->content;
}

public function setContent(?string $content): self
{
$this->content = $content;

return $this;
}

} }

+ 2
- 14
Model/Ticket/TicketMessageModel.php View File

use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo; use Gedmo\Mapping\Annotation as Gedmo;
use Lc\SovBundle\Doctrine\EntityInterface; use Lc\SovBundle\Doctrine\EntityInterface;
use Lc\SovBundle\Doctrine\Extension\BlameableNullableTrait;
use Lc\SovBundle\Doctrine\Extension\StatusInterface; use Lc\SovBundle\Doctrine\Extension\StatusInterface;
use Lc\SovBundle\Doctrine\Extension\StatusTrait; use Lc\SovBundle\Doctrine\Extension\StatusTrait;
use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity; use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity;
abstract class TicketMessageModel extends AbstractLightEntity implements TicketMessageInterface, EntityInterface, StatusInterface abstract class TicketMessageModel extends AbstractLightEntity implements TicketMessageInterface, EntityInterface, StatusInterface
{ {
use StatusTrait; use StatusTrait;

/**
* @Gedmo\Blameable(on="create")
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface")
* @ORM\JoinColumn(nullable=true)
*/
protected $createdBy;

/**
* @Gedmo\Blameable(on="update")
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface")
* @ORM\JoinColumn(nullable=true)
*/
protected $updatedBy;
use BlameableNullableTrait;


/** /**
* @ORM\Column(type="text") * @ORM\Column(type="text")

+ 4
- 83
Model/Ticket/TicketModel.php View File

use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo; use Gedmo\Mapping\Annotation as Gedmo;
use Lc\SovBundle\Doctrine\EntityInterface; use Lc\SovBundle\Doctrine\EntityInterface;
use Lc\SovBundle\Doctrine\Extension\BlameableNullableTrait;
use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity; use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity;
use Lc\SovBundle\Model\User\UserInterface; use Lc\SovBundle\Model\User\UserInterface;


*/ */
abstract class TicketModel extends AbstractLightEntity implements TicketInterface, EntityInterface abstract class TicketModel extends AbstractLightEntity implements TicketInterface, EntityInterface
{ {
use BlameableNullableTrait;


const TYPE_TECHNICAL_PROBLEM = 'technical-problem'; const TYPE_TECHNICAL_PROBLEM = 'technical-problem';
const TYPE_GENERAL_QUESTION = 'general-question'; const TYPE_GENERAL_QUESTION = 'general-question';


const TICKET_STATUS_BEING_PROCESSED = 'being-processed'; const TICKET_STATUS_BEING_PROCESSED = 'being-processed';
const TICKET_STATUS_CLOSED = 'closed'; const TICKET_STATUS_CLOSED = 'closed';



public function getTypeChoices(): array
{
return [
TicketModel::TYPE_GENERAL_QUESTION,
TicketModel::TYPE_TECHNICAL_PROBLEM,
];
}

public function getStatusChoices(): array
{
return [
TicketModel::TICKET_STATUS_OPEN,
TicketModel::TICKET_STATUS_BEING_PROCESSED,
TicketModel::TICKET_STATUS_CLOSED,
];
}


public function getTypeLabel(): string
{
return 'entity.Ticket.fields.typeChoices.'.$this->getType();
}

public function getStatusLabel(): string
{
return 'entity.Ticket.statuChoices.'.$this->getStatus();
}

/**
* @Gedmo\Blameable(on="create")
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface")
* @ORM\JoinColumn(nullable=true)
*/
protected $createdBy;

/**
* @Gedmo\Blameable(on="update")
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface")
* @ORM\JoinColumn(nullable=true)
*/
protected $updatedBy;

/** /**
* @ORM\Column(type="string", length=32) * @ORM\Column(type="string", length=32)
*/ */
$this->ticketMessages = new ArrayCollection(); $this->ticketMessages = new ArrayCollection();
} }


public function getUsername()
{
if ($this->getUser()) {
return $this->getUser()->getName();
} else {
return strtoupper($this->getVisitorLastname()).' '.$this->getVisitorFirstname();
}
}

public function getUserInfosTicket()
{
$user = $this->getUser();
if ($user) {
return '#'.$user->getId().' '.$user->getName().' '.$user->getEmail();
} else {
return strtoupper($this->getVisitorLastname()).' '.$this->getVisitorFirstname().' '.$this->getVisitorEmail(
);
}
}

public function getEmail()
{
if ($this->getUser()) {
return $this->getUser()->getEmail();
} else {
return $this->getVisitorEmail();
}
}

public function getVisitorInfos()
{
return strtoupper($this->getVisitorLastname()).' '.$this->getVisitorFirstname().' ('.$this->getVisitorEmail(
).')';
}

public function getLastMessage()
{
return $this->getTicketMessages()->last();
}

public function getType(): ?string public function getType(): ?string
{ {
return $this->type; return $this->type;

Model/User/User.php → Model/User/UserModel.php View File



namespace Lc\SovBundle\Model\User; namespace Lc\SovBundle\Model\User;


use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Lc\SovBundle\Doctrine\EntityInterface; use Lc\SovBundle\Doctrine\EntityInterface;
use Lc\SovBundle\Doctrine\Extension\DevAliasInterface;
use Lc\SovBundle\Doctrine\Extension\DevAliasTrait;
use Lc\SovBundle\Model\Newsletter\NewsletterInterface; use Lc\SovBundle\Model\Newsletter\NewsletterInterface;
use Lc\SovBundle\Model\Ticket\TicketInterface;
use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Core\User\UserInterface;


/** /**
* @ORM\MappedSuperclass() * @ORM\MappedSuperclass()
*/ */
abstract class User implements EntityInterface, UserInterface
abstract class UserModel implements EntityInterface, UserInterface, DevAliasInterface
{ {
use DevAliasTrait;
/** /**
* @ORM\Column(type="string", length=180, unique=true) * @ORM\Column(type="string", length=180, unique=true)
*/ */
*/ */
protected $firstname; protected $firstname;


/**
* @ORM\Column(type="string", length=20, nullable=true)
*/
protected $phone;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
protected $gender;

/**
* @ORM\Column(type="date", nullable=true)
*/
protected $birthdate;

/** /**
* @ORM\Column(type="boolean") * @ORM\Column(type="boolean")
*/ */
*/ */
protected $groupUsers; protected $groupUsers;


// isUserInGroupVip
public function isInGroupUserVip()
{
return $this->isInGroupByDevAlias('vip') ;
}
/**
* @ORM\OneToMany(targetEntity="Lc\SovBundle\Model\Ticket\TicketInterface", mappedBy="user")
*/
protected $tickets;


// isUserInGroup
public function isInGroupUser(GroupUserInterface $groupUser)
{
return $this->isInGroupByDevAlias($groupUser->getDevAlias());
}
/**
* @ORM\Column(type="array", nullable=true)
*/
protected $ticketTypesNotification = [];


// isUserInGroupByDevAlias
public function isInGroupByDevAlias(string $groupUserDevAlias)
public function __construct()
{ {
$groupUsers = $this->getGroupUsers();

foreach($groupUsers as $groupUser) {
if($groupUser->getDevAlias() == $groupUserDevAlias) {
return true;
}
}

return false;
$this->tickets = new ArrayCollection();
} }


public function isSubscribedToNewsletter(NewsletterInterface $newsletter)
public function __toString()
{ {
return $this->getNewsletters()->contains($newsletter);
return '#' . $this->getId() . ' ' . strtoupper($this->getLastname()) . ' ' . $this->getFirstname(
) . ' (' . $this->getEmail() . ')';
} }




public function getEmail(): ?string public function getEmail(): ?string
{ {
return $this->email; return $this->email;
return (string)$this->email; return (string)$this->email;
} }




public function getGender(): ?bool
{
return $this->gender;
}

public function setGender(?bool $gender): self
{
$this->gender = $gender;

return $this;
}

public function getBirthdate(): ?\DateTimeInterface
{
return $this->birthdate;
}

public function setBirthdate(\DateTimeInterface $birthdate): self
{
$this->birthdate = $birthdate;

return $this;
}


/** /**
* @see UserInterface * @see UserInterface
*/ */
} }




//TODO vérifier si on peut déplacer da Solver
public function generatePassword($length = 8): string public function generatePassword($length = 8): string
{ {
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
return $this; return $this;
} }


public function getName(): ?string
public function getPhone(): ?string
{
return $this->phone;
}

public function setPhone(?string $phone): self
{ {
return $this->getFirstname().' '.strtoupper($this->getLastname());
$this->phone = $phone;

return $this;
} }


public function isVerified(): bool public function isVerified(): bool
return $this; return $this;
} }




/**
* @return Collection|TicketInterface[]
*/
public function getTickets(): Collection
{
return $this->tickets;
}

public function addTicket(TicketInterface $ticket): self
{
if (!$this->tickets->contains($ticket)) {
$this->tickets[] = $ticket;
$ticket->setUser($this);
}

return $this;
}

public function removeTicket(TicketInterface $ticket): self
{
if ($this->tickets->contains($ticket)) {
$this->tickets->removeElement($ticket);
// set the owning side to null (unless already changed)
if ($ticket->getUser() === $this) {
$ticket->setUser(null);
}
}

return $this;
}

public function getTicketTypesNotification(): ?array
{
return $this->ticketTypesNotification;
}

public function setTicketTypesNotification(?array $ticketTypesNotification): self
{
$this->ticketTypesNotification = $ticketTypesNotification;

return $this;
}


} }

+ 29
- 26
Repository/AbstractRepository.php View File

$this->defaultLocale = $locale; $this->defaultLocale = $locale;
} }


public function findOneByOldUrl($url)
{
$qb = $this->createQueryBuilder('entity')
->where('entity.oldUrls LIKE :oldUrl')
->andWhere('entity.status = 1')
->setParameter(':oldUrl', '%' . $url . '%');

return $qb->getQuery()->getOneOrNullResult();
}

public function getOneOrNullResult(QueryBuilder $qb, $locale = null, $hydrationMode = null) public function getOneOrNullResult(QueryBuilder $qb, $locale = null, $hydrationMode = null)
{ {
return $this->getTranslatedQuery($qb, $locale)->getOneOrNullResult($hydrationMode); return $this->getTranslatedQuery($qb, $locale)->getOneOrNullResult($hydrationMode);
return $query; return $query;
} }


public function findBySimilarSlug($slug)
{
$qb = $this->createQueryBuilder('entity')
->select('COUNT(entity.slug) as totalSimilar')
->andWhere('entity.status>=0')
->andWhere('entity.slug LIKE :slug')
->setParameter('slug', $slug)
->groupBy('entity.slug')
->having('COUNT(entity.slug) >=1');

return $qb->getQuery()->getOneOrNullResult();
}

public function findAll()
// @TODO : à vérifier si on peut les virer
/*public function findAll()
{ {
return $this->findBy(array()); return $this->findBy(array());
} }


protected function setCriteria(array $criteria): array protected function setCriteria(array $criteria): array
{ {
/*$className = $this->getClassMetadata()->getName();
$className = $this->getClassMetadata()->getName();
$entity = new $className; $entity = new $className;


if ($entity instanceof StatusInterface) { if ($entity instanceof StatusInterface) {
if ($criteria['status'] === false) { if ($criteria['status'] === false) {
unset($criteria['status']); unset($criteria['status']);
} }
}*/
}


return $criteria; return $criteria;
}*/

// @TODO : à réécrire dans un Store
/*
public function findBySimilarSlug($slug)
{
$qb = $this->createQueryBuilder('entity')
->select('COUNT(entity.slug) as totalSimilar')
->andWhere('entity.status>=0')
->andWhere('entity.slug LIKE :slug')
->setParameter('slug', $slug)
->groupBy('entity.slug')
->having('COUNT(entity.slug) >=1');

return $qb->getQuery()->getOneOrNullResult();
} }


public function findOneByOldUrl($url)
{
$qb = $this->createQueryBuilder('entity')
->where('entity.oldUrls LIKE :oldUrl')
->andWhere('entity.status = 1')
->setParameter(':oldUrl', '%' . $url . '%');

return $qb->getQuery()->getOneOrNullResult();
}*/

} }

+ 32
- 4
Repository/AbstractRepositoryQuery.php View File

use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Knp\Component\Pager\PaginatorInterface; use Knp\Component\Pager\PaginatorInterface;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\SovBundle\Doctrine\EntityInterface;


abstract class AbstractRepositoryQuery abstract class AbstractRepositoryQuery
{ {
use StatusRepositoryQueryTrait;
use TreeRepositoryQueryTrait;

protected ServiceEntityRepository $repository; protected ServiceEntityRepository $repository;
protected QueryBuilder $query; protected QueryBuilder $query;
protected PaginatorInterface $paginator; protected PaginatorInterface $paginator;
public function count(): string public function count(): string
{ {
return $this->query->getQuery() return $this->query->getQuery()
->getSingleScalarResult();
->getSingleScalarResult();
} }


public function findOne()
public function findOne(): ?EntityInterface
{ {
return $this->query->getQuery() return $this->query->getQuery()
->setMaxResults(1)
->getOneOrNullResult();
->setMaxResults(1)
->getOneOrNullResult();
} }


public function find(): array public function find(): array
return $this->addOrderBy('.' . $field, $sort); return $this->addOrderBy('.' . $field, $sort);
} }
} }

public function filterById(int $id)
{
return $this
->andWhere('.id = :id')
->setParameter('id', $id);
}

public function filterByDevAlias(string $devAlias): self
{
return $this
->andWhere('.devAlias = :devAlias')
->setParameter('devAlias', $devAlias);
}

public function filterBySlug(string $slug)
{
return $this
->andWhere('.slug = :slug')
->setParameter('slug', $slug);
}

} }



+ 20
- 0
Repository/AbstractStore.php View File



namespace Lc\SovBundle\Repository; namespace Lc\SovBundle\Repository;


use Lc\SovBundle\Model\Site\PageInterface;

abstract class AbstractStore abstract class AbstractStore
{ {
public function createQuery($query = null)
{
if (is_null($query)) {
$query = $this->query->create();
}

return $query;
}

public function getRepositoryQuery() public function getRepositoryQuery()
{ {
return $this->query; return $this->query;
} }

public function getOneById(int $id)
{
$query = $this->query->create();

$query->filterById($id);

return $query->findOne();
}
} }

+ 22
- 85
Repository/Reminder/ReminderStore.php View File



public function get($params = [], $query = null) public function get($params = [], $query = null)
{ {
if (is_null($query)) {
$query = $this->query->create();
}
$query = $this->createQuery($query);


$query->filterByDone(); $query->filterByDone();


if (array_key_exists('user', $params)) { if (array_key_exists('user', $params)) {
$query $query
->filterByUser($params['user'])
->groupBy('.id');
->filterByUser($params['user'])
->groupBy('.id');
} }


if (array_key_exists('crudAction', $params)) { if (array_key_exists('crudAction', $params)) {
// findByUser // findByUser
public function getByUser(UserInterface $user, $query = null): array public function getByUser(UserInterface $user, $query = null): array
{ {
if (is_null($query)) {
$query = $this->query->create();
}
$query = $this->createQuery($query);


$query = $this->query->create(); $query = $this->query->create();


$query $query
->filterByUser($user)
->filterIsNotDone()
->orderBy('.dateReminder')
->groupBy('.id');
->filterByUser($user)
->filterIsNotDone()
->orderBy('.dateReminder')
->groupBy('.id');


return $query->find(); return $query->find();
} }


// findByEasyAdminConfigAndUser // findByEasyAdminConfigAndUser
public function getByEasyAdminConfigAndUser( public function getByEasyAdminConfigAndUser(
string $crudAction,
string $crudControllerFqcn,
UserInterface $user,
int $entityId = null,
$query = null
string $crudAction,
string $crudControllerFqcn,
UserInterface $user,
int $entityId = null,
$query = null
): array { ): array {
if (is_null($query)) {
$query = $this->query->create();
}
$query = $this->createQuery($query);


$query $query
->filterByUser($user)
->filterLikeCrudAction($crudAction)
->filterLikeCrudControllerFqcn($crudControllerFqcn)
->filterIsNotDone();
->filterByUser($user)
->filterLikeCrudAction($crudAction)
->filterLikeCrudControllerFqcn($crudControllerFqcn)
->filterIsNotDone();


if ($entityId) { if ($entityId) {
$query $query
->filterLikeEntityId($entityId);
->filterLikeEntityId($entityId);
} }
$query $query
->orderBy('.dateReminder')
->groupBy('.id');
->orderBy('.dateReminder')
->groupBy('.id');


return $query->find(); return $query->find();
} }

// public function findByEasyAdminConfigAndUser($crudAction, $crudControllerFqcn, $user, $entityId = null)
// {
// $qb = $this->createQueryBuilder('e');
// $qb->leftJoin('e.users', 'u');
// $qb->having('COUNT(u.id) = 0');
// $qb->orHaving(':user MEMBER OF e.users');
// $qb->andWhere('e.done = 0');
// $qb->andWhere('e.crudAction LIKE :crudAction');
// $qb->andWhere('e.crudControllerFqcn LIKE :entity');
// $qb->setParameter('crudAction', $crudAction);
// $qb->setParameter('crudControllerFqcn', $crudControllerFqcn);
// $qb->setParameter('user', $user);
// if ($entityId) {
// $qb->andWhere('e.entityId LIKE :id');
// $qb->setParameter('entityId', $entityId);
// }
// $qb->orderBy('e.dateReminder', 'ASC');
// $qb->groupBy('e.id');
//
// return $qb->getQuery()->getResult();
// }
}
/*

public function getRemindersByUser($user)
{
$reminderRepo = $this->em->getRepository(ReminderInterface::class);


$reminders = $reminderRepo->findByUser($user);

$entitiesRepo = array();
$entitiesConfig = array();
if (count($reminders) > 0) {
foreach ($reminders as $reminder) {
if ($reminder->getEntityName()) {
if (!isset($entitiesConfig[$reminder->getEntityName()])) {
$entitiesConfig[$reminder->getEntityName()] = $this->configManager->getEntityConfig($reminder->getEntityName());
}
if ($reminder->getEntityAction() == 'edit' || $reminder->getEntityAction() == 'show') {
if (!isset($entitiesRepo[$reminder->getEntityName()])) {
$entitiesRepo[$reminder->getEntityName()] = $this->em->getRepository($entitiesConfig[$reminder->getEntityName()]['class']);
}

if ($reminder->getEntityId()) {
$reminder->relatedPage = $entitiesRepo[$reminder->getEntityName()]->find($reminder->getEntityId())->__toString();
}
} else {
$reminder->relatedPage = 'Liste de ' . $entitiesConfig[$reminder->getEntityName()]['label'];
}
}
}
}
return $reminders;
}

*/
}

+ 0
- 2
Repository/Site/NewsRepositoryQuery.php View File

namespace Lc\SovBundle\Repository\Site; namespace Lc\SovBundle\Repository\Site;


use Knp\Component\Pager\PaginatorInterface; use Knp\Component\Pager\PaginatorInterface;
use Lc\CaracoleBundle\Repository\StatusRepositoryQueryTrait;
use Lc\SovBundle\Repository\AbstractRepositoryQuery; use Lc\SovBundle\Repository\AbstractRepositoryQuery;


class NewsRepositoryQuery extends AbstractRepositoryQuery implements NewsRepositoryQueryInterface class NewsRepositoryQuery extends AbstractRepositoryQuery implements NewsRepositoryQueryInterface
{ {
use StatusRepositoryQueryTrait;


public function __construct(NewsRepository $repository, PaginatorInterface $paginator) public function __construct(NewsRepository $repository, PaginatorInterface $paginator)
{ {

+ 4
- 20
Repository/Site/NewsStore.php View File

$this->query = $query; $this->query = $query;
} }


//findLatests
// findLatests
public function getLatests(int $maxResults = 0, $query = null): array public function getLatests(int $maxResults = 0, $query = null): array
{ {
if (is_null($query)) {
$query = $this->query->create();
}
$query = $this->createQuery($query);

$query $query
->filterIsOnline() ->filterIsOnline()
->orderBy('.date', 'DESC'); ->orderBy('.date', 'DESC');


if ($maxResults) { if ($maxResults) {
$query
->limit($maxResults);
$query->limit($maxResults);
} }


return $query->find(); return $query->find();
} }

public function findLatests($maxResults = 0)
{
$result = $this->findByMerchantQuery()
->orderBy('e.date', 'DESC');

$result->andWhere('e.status = 1');

if ($maxResults) {
$result->setMaxResults($maxResults);
}

return $result->getQuery()->getResult();
}
} }

+ 0
- 6
Repository/Site/PageRepositoryQuery.php View File

parent::__construct($repository, 'r', $paginator); parent::__construct($repository, 'r', $paginator);
} }


public function filterBySlug(string $slug)
{
return $this
->andWhere('.slug = :slug')
->setParameter('slug', $slug);
}
} }

+ 0
- 11
Repository/Site/PageStore.php View File

{ {
$this->query = $query; $this->query = $query;
} }

//findPageBySlug
public function getBySlug(string $slug): ?PageInterface
{
$query = $this->query->create();

$query
->filterBySlug($slug);

return $query->findOne();
}
} }

+ 26
- 0
Repository/StatusRepositoryQueryTrait.php View File

<?php

namespace Lc\SovBundle\Repository;

trait StatusRepositoryQueryTrait
{
public function filterByStatus(int $status):self
{
return $this->andWhere('.status = :status')->setParameter(':status', $status);
}

public function filterIsOffline():self
{
return $this->andWhere('.status = :status')->setParameter(':status', 0);
}

public function filterIsOnline():self
{
return $this->andWhere('.status = :status')->setParameter(':status', 1);
}

public function filterIsOnlineAndOffline():self
{
return $this->andWhere('.status >= 0');
}
}

+ 2
- 2
Repository/Ticket/TicketRepositoryQuery.php View File

public function filterByStatus($statusArray): self public function filterByStatus($statusArray): self
{ {
return $this return $this
->andWhere('.status IN (:status)')
->setParameter('status', $statusArray);
->andWhere('.status IN (:status)')
->setParameter('status', $statusArray);
} }


public function selectCount(): self public function selectCount(): self

+ 10
- 16
Repository/Ticket/TicketStore.php View File



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


class TicketStore extends AbstractStore implements TicketStoreInterface class TicketStore extends AbstractStore implements TicketStoreInterface
} }


// getTicketsByUser // getTicketsByUser
public function getByUser($user, $query = null): array
public function getByUser(UserInterface $user, $query = null): array
{ {
if (is_null($query)) {
$query = $this->query->create();
}

$query = $this->createQuery($query);
$query->filterByUser($user); $query->filterByUser($user);

return $query->find(); return $query->find();
} }


// findAllOpen
public function getAllOpen(int $limit = 0, $query = null): array
// findAllOpen
public function getOpen(int $limit = 0, $query = null): array
{ {
if (is_null($query)) {
$query = $this->query->create();
}
$query = $this->createQuery($query);


$query $query
->filterByStatus(Ticket::TICKET_STATUS_OPEN) ->filterByStatus(Ticket::TICKET_STATUS_OPEN)
return $query->find(); return $query->find();
} }


//countAllOpen
public function countAllOpen($query = null): string
// countAllOpen
public function countOpen($query = null): string
{ {
if (is_null($query)) {
$query = $this->query->create();
}
$query = $this->createQuery($query);

$query $query
->selectCount() ->selectCount()
->filterByStatus(Ticket::TICKET_STATUS_OPEN); ->filterByStatus(Ticket::TICKET_STATUS_OPEN);

+ 24
- 0
Repository/TreeRepositoryQueryTrait.php View File

<?php

namespace Lc\SovBundle\Repository;

use Lc\SovBundle\Doctrine\EntityInterface;

trait TreeRepositoryQueryTrait
{
public function filterIsParent()
{
return $this->andWhere('.parent is NULL');
}

public function filterIsChildren()
{
return $this->andWhere('.parent is NOT NULL');
}

public function filterByParent(EntityInterface $parent)
{
return $this->andWhere('.parent = :parent')->setParameter('parent', $parent);
}

}

+ 1
- 1
Repository/User/UserRepository.php View File

} }


$user->setPassword($newEncodedPassword); $user->setPassword($newEncodedPassword);
$this->_em->persist($user);
$this->_em->update($user);
$this->_em->flush(); $this->_em->flush();
} }



+ 16
- 8
Repository/User/UserRepositoryQuery.php View File

public function filterByNewsletter(Newsletter $newsletter): self public function filterByNewsletter(Newsletter $newsletter): self
{ {
return $this return $this
->andWhere(':newsletter MEMBER OF .newsletters')
->setParameter('newsletter', $newsletter->getId());
->andWhere(':newsletter MEMBER OF .newsletters')
->setParameter('newsletter', $newsletter->getId());
} }


public function filterLikeRole(string $role): self
public function filterByRole(string $role): self
{ {
return $this return $this
->andWhere('.roles LIKE :roles')
->setParameter('roles', '%"' . $role . '"%');
->andWhere('.roles LIKE :roles')
->setParameter('roles', '%"' . $role . '"%');
} }


public function filterLikeTicketTypeNotification(string $ticketType): self
public function filterByTicketTypeNotification(string $ticketType): self
{ {
return $this return $this
->andWhere('.ticketTypesNotification LIKE :ticketType')
->setParameter('ticketType', '%"' . $ticketType . '"%');
->andWhere('.ticketTypesNotification LIKE :ticketType')
->setParameter('ticketType', '%"' . $ticketType . '"%');
} }

public function filterByEmail(string $email): self
{
return $this
->andWhere('.email LIKE :email')
->setParameter('email', $email);
}

} }

+ 18
- 20
Repository/User/UserStore.php View File

$this->query = $query; $this->query = $query;
} }


//findAllByNewsletter
// findAllByNewsletter
public function getByNewsletter(Newsletter $newsletter, $query = null): array public function getByNewsletter(Newsletter $newsletter, $query = null): array
{ {
if (is_null($query)) {
$query = $this->query->create();
}

$query
->filterByNewsletter($newsletter);

$query = $this->createQuery($query);
$query->filterByNewsletter($newsletter);
return $query->find(); return $query->find();
} }


//findByRole
public function getByRole(string $role): array
// findByRole
public function getByRole(string $role, $query = null): array
{ {
$query = $this->query->create();
$query
->filterLikeRole($role);

$query = $this->createQuery($query);
$query->filterByRole($role);
return $query->find(); return $query->find();
} }


//findByTicketTypesNotification
public function getByTicketTypesNotification(string $ticketType): array
// findByTicketTypesNotification
public function getByTicketTypesNotification(string $ticketType, $query = null): array
{ {
$query = $this->query->create();
$query
->filterLikeTicketTypeNotification($ticketType);

$query = $this->createQuery($query);
$query->filterByTicketTypeNotification($ticketType);
return $query->find(); return $query->find();
} }

public function getOneByEmail(string $email, $query = null)
{
$query = $this->createQuery($query);
$query->filterByEmail($email);
return $query->findOne();
}
} }

+ 2
- 2
Resolver/UrlResolver.php View File

$this->parameterBag = $parameterBag; $this->parameterBag = $parameterBag;
} }


public function isServerLocalhost()
public function isServerLocalhost(): bool
{ {
return in_array($_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1']); return in_array($_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1']);
} }


public function isBot()
public function isBot(): bool
{ {
if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match( if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match(
'/bot|crawl|slurp|spider/i', '/bot|crawl|slurp|spider/i',

+ 21
- 0
Solver/Setting/SettingSolver.php View File

<?php

namespace Lc\SovBundle\Solver\Setting;

use Lc\SovBundle\Model\Setting\SettingInterface;
use Lc\SovBundle\Model\Ticket\TicketInterface;
use Lc\SovBundle\Model\Ticket\TicketModel;

class SettingSolver
{
public function getValue(SettingInterface $setting)
{
if ($this->getText()) {
return $this->getText();
} elseif ($this->getDate()) {
return $this->getDate();
} elseif ($this->getFile()) {
return $this->getFile();
}
}
}

+ 76
- 0
Solver/Ticket/TicketSolver.php View File

<?php

namespace Lc\SovBundle\Solver\Ticket;

use Lc\SovBundle\Model\Ticket\TicketInterface;
use Lc\SovBundle\Model\Ticket\TicketModel;

class TicketSolver
{
public function getTypeChoices(): array
{
return [
TicketModel::TYPE_GENERAL_QUESTION,
TicketModel::TYPE_TECHNICAL_PROBLEM,
];
}

public function getStatusChoices(): array
{
return [
TicketModel::TICKET_STATUS_OPEN,
TicketModel::TICKET_STATUS_BEING_PROCESSED,
TicketModel::TICKET_STATUS_CLOSED,
];
}

public function getTypeLabel(TicketInterface $ticket): string
{
return 'entity.Ticket.fields.typeChoices.'.$ticket->getType();
}

public function getStatusLabel(TicketInterface $ticket): string
{
return 'entity.Ticket.statuChoices.'.$ticket->getStatus();
}

public function getUsername(TicketInterface $ticket)
{
if ($ticket->getUser()) {
return $ticket->getUser()->getName();
} else {
return strtoupper($ticket->getVisitorLastname()).' '.$ticket->getVisitorFirstname();
}
}

public function getUserInfosTicket(TicketInterface $ticket)
{
$user = $ticket->getUser();
if ($user) {
return '#'.$user->getId().' '.$user->getName().' '.$user->getEmail();
} else {
return strtoupper($ticket->getVisitorLastname()).' '.$ticket->getVisitorFirstname().' '.$ticket->getVisitorEmail(
);
}
}

public function getEmail(TicketInterface $ticket)
{
if ($ticket->getUser()) {
return $ticket->getUser()->getEmail();
} else {
return $ticket->getVisitorEmail();
}
}

public function getVisitorInfos(TicketInterface $ticket)
{
return strtoupper($ticket->getVisitorLastname()).' '.$ticket->getVisitorFirstname().' ('.$ticket->getVisitorEmail(
).')';
}

public function getLastMessage(TicketInterface $ticket)
{
return $ticket->getTicketMessages()->last();
}
}

+ 53
- 0
Solver/User/UserSolver.php View File

<?php

namespace Lc\SovBundle\Solver\User;

use Lc\SovBundle\Model\Newsletter\NewsletterInterface;
use Lc\SovBundle\Model\User\GroupUserInterface;
use Lc\SovBundle\Model\User\UserInterface;

class UserSolver
{
// @TODO : à écrire si besoin (voir __toString de UserModel)
public function getSummary(UserInterface $user)
{

}

public function getName(UserInterface $user): ?string
{
return (string) ucfirst(strtolower($user->getFirstname())) . ' ' . strtoupper($user->getLastname());
}


// isUserInGroupVip
public function isInGroupUserVip(UserInterface $user)
{
return $this->isInGroupByDevAlias($user, 'vip') ;
}

// isUserInGroup
public function isInGroupUser(UserInterface $user, GroupUserInterface $groupUser)
{
return $this->isInGroupByDevAlias($user, $groupUser->getDevAlias());
}

// isUserInGroupByDevAlias
public function isInGroupByDevAlias(UserInterface $user, string $groupUserDevAlias)
{
$groupUsers = $user->getGroupUsers();

foreach($groupUsers as $groupUser) {
if($groupUser->getDevAlias() == $groupUserDevAlias) {
return true;
}
}

return false;
}

public function isSubscribedToNewsletter(UserInterface $user, NewsletterInterface $newsletter)
{
return $user->getNewsletters()->contains($newsletter);
}
}

+ 5
- 5
Translation/TranslatorAdmin.php View File



class TranslatorAdmin class TranslatorAdmin
{ {
protected $translator;
protected TranslatorInterface $translator;


const DOMAIN = 'admin'; const DOMAIN = 'admin';


$this->translator = $translator; $this->translator = $translator;
} }


public function transAction($action)
public function transAction($action): string
{ {
return $this->trans('action.' . $action); return $this->trans('action.' . $action);
} }


public function transMenu($menu)
public function transMenu($menu): string
{ {
return $this->trans('menu.' . $menu); return $this->trans('menu.' . $menu);
} }


public function transFlashMessage($name, $params = [])
public function transFlashMessage($name, $params = []): string
{ {
return $this->trans('flash_message.' . $name, $params); return $this->trans('flash_message.' . $name, $params);
} }
); );
} }


public function transTitle($pageName, $entityClass = null, $params = [])
public function transTitle($pageName, $entityClass = null, $params = []): string
{ {
$entityName = $this->getEntityName($entityClass); $entityName = $this->getEntityName($entityClass);



Loading…
Cancel
Save