Browse Source

Structure views / webpack, twig extensions, routes

develop
Guillaume 3 years ago
parent
commit
cbb131922c
64 changed files with 477 additions and 422 deletions
  1. +7
    -0
      Controller/Reminder/ReminderAdminController.php
  2. +8
    -4
      Controller/Security/SecurityAdminController.php
  3. +9
    -7
      Controller/Setting/SettingAdminController.php
  4. +4
    -4
      Controller/Ticket/TicketAdminController.php
  5. +9
    -2
      Controller/User/AccountAdminController.php
  6. +4
    -14
      EventSubscriber/SiteSettingEventSubscriber.php
  7. +8
    -25
      Repository/AbstractRepository.php
  8. +0
    -6
      Repository/AbstractRepositoryInterface.php
  9. +8
    -13
      Repository/File/FileRepository.php
  10. +8
    -0
      Repository/File/FileRepositoryInterface.php
  11. +5
    -10
      Repository/Newsletter/NewsletterRepository.php
  12. +8
    -0
      Repository/Newsletter/NewsletterRepositoryInterface.php
  13. +2
    -3
      Repository/Reminder/ReminderRepository.php
  14. +0
    -56
      Repository/Reminder/ReminderRepositoryBack.php
  15. +8
    -0
      Repository/Reminder/ReminderRepositoryInterface.php
  16. +24
    -1
      Repository/Reminder/ReminderRepositoryQuery.php
  17. +52
    -6
      Repository/Reminder/ReminderStore.php
  18. +5
    -10
      Repository/Setting/SiteSettingRepository.php
  19. +8
    -0
      Repository/Setting/SiteSettingRepositoryInterface.php
  20. +5
    -10
      Repository/Site/NewsRepository.php
  21. +8
    -0
      Repository/Site/NewsRepositoryInterface.php
  22. +5
    -10
      Repository/Site/PageRepository.php
  23. +8
    -0
      Repository/Site/PageRepositoryInterface.php
  24. +6
    -12
      Repository/Site/SiteRepository.php
  25. +8
    -0
      Repository/Site/SiteRepositoryInterface.php
  26. +5
    -12
      Repository/Ticket/TicketMessageRepository.php
  27. +8
    -0
      Repository/Ticket/TicketMessageRepositoryInterface.php
  28. +5
    -12
      Repository/Ticket/TicketRepository.php
  29. +8
    -0
      Repository/Ticket/TicketRepositoryInterface.php
  30. +5
    -12
      Repository/User/GroupUserRepository.php
  31. +8
    -0
      Repository/User/GroupUserRepositoryInterface.php
  32. +22
    -56
      Repository/User/UserRepository.php
  33. +8
    -0
      Repository/User/UserRepositoryInterface.php
  34. +0
    -0
      Resources/assets/app/admin/reminder/app.reminder.js
  35. +0
    -0
      Resources/assets/app/admin/reminder/reminder.js
  36. +0
    -0
      Resources/assets/app/admin/reminder/reminder.scss
  37. +0
    -0
      Resources/assets/app/admin/ticket/app.ticket.js
  38. +0
    -0
      Resources/assets/app/admin/ticket/ticket.js
  39. +3
    -31
      Resources/config/routes.yaml
  40. +0
    -0
      Resources/views/admin/setting/edit_site.html.twig
  41. +3
    -3
      Resources/views/admin/ticket/detail.html.twig
  42. +0
    -0
      Resources/views/admin/ticket/field/email.html.twig
  43. +0
    -0
      Resources/views/admin/ticket/field/lastmessage.html.twig
  44. +0
    -0
      Resources/views/admin/ticket/field/status.html.twig
  45. +0
    -0
      Resources/views/admin/ticket/field/username.html.twig
  46. +1
    -1
      Resources/views/admin/ticket/new.html.twig
  47. +1
    -1
      Resources/views/admin/user/edit_password.html.twig
  48. +1
    -1
      Resources/views/admin/user/edit_profile.html.twig
  49. +0
    -0
      Resources/views/admin/user/request_password.html.twig
  50. +1
    -1
      Resources/views/adminlte/block/menu.html.twig
  51. +0
    -0
      Resources/views/adminlte/block/modal_filemanager.html.twig
  52. +2
    -2
      Resources/views/adminlte/block/navbar_header.html.twig
  53. +2
    -2
      Resources/views/adminlte/crud/edit.html.twig
  54. +3
    -3
      Resources/views/adminlte/crud/field/image.html.twig
  55. +3
    -3
      Resources/views/adminlte/crud/form_theme.html.twig
  56. +2
    -2
      Resources/views/adminlte/crud/index.html.twig
  57. +0
    -0
      Resources/views/adminlte/crud/layout_form.html.twig
  58. +2
    -2
      Resources/views/adminlte/crud/new.html.twig
  59. +1
    -1
      Resources/views/adminlte/crud/sort.html.twig
  60. +1
    -1
      Resources/views/adminlte/dashboard.html.twig
  61. +1
    -1
      Resources/views/adminlte/layout.html.twig
  62. +40
    -0
      Twig/StoreTwigExtension.php
  63. +107
    -0
      Twig/TranslatorTwigExtension.php
  64. +17
    -82
      Twig/TwigExtension.php

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

use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Routing\Annotation\Route;


class ReminderAdminController extends AbstractController class ReminderAdminController extends AbstractController
{ {
$this->parameterBag = $parameterBag; $this->parameterBag = $parameterBag;
} }


/**
* @Route("/admin/reminder/modal", name="sov_admin_reminder_render_modal")
*/
public function renderModal(Request $request): Response public function renderModal(Request $request): Response
{ {
$crudAction = $request->get('crudAction'); $crudAction = $request->get('crudAction');
); );
} }


/**
* @Route("/admin/reminder/new", name="sov_admin_reminder_new")
*/
public function new(Request $request) public function new(Request $request)
{ {
$reminder = $this->createEntity(); $reminder = $this->createEntity();

+ 8
- 4
Controller/Security/SecurityAdminController.php View File



class SecurityAdminController extends AbstractController class SecurityAdminController extends AbstractController
{ {

/**
* @Route("/login", name="sov_login")
*/
public function login(AuthenticationUtils $authenticationUtils): Response public function login(AuthenticationUtils $authenticationUtils): Response
{ {
if ($this->getUser()) { if ($this->getUser()) {
return $this->redirectToRoute('admin_dashboard');
return $this->redirectToRoute('app_admin_dashboard');
} }


// get the login error if there is one // get the login error if there is one
'csrf_token_intention' => 'authenticate', 'csrf_token_intention' => 'authenticate',


// the URL users are redirected to after the login (default: '/admin') // the URL users are redirected to after the login (default: '/admin')
'target_path' => $this->generateUrl('admin_dashboard'),
'target_path' => $this->generateUrl('app_admin_dashboard'),


// the label displayed for the username form field (the |trans filter is applied to it) // the label displayed for the username form field (the |trans filter is applied to it)
'username_label' => 'Your username', 'username_label' => 'Your username',
]); ]);
} }



/**
* @Route("/logout", name="sov_logout")
*/
public function logout() public function logout()
{ {
throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.'); throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');

+ 9
- 7
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\CaracoleBundle\Form\Setting\MerchantSettingsFormType;
use Lc\CaracoleBundle\Form\Setting\SectionSettingsFormType;
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\Site\SiteRepository;
use Lc\SovBundle\Repository\Setting\SiteSettingRepositoryInterface;
use Lc\SovBundle\Repository\Site\SiteRepositoryInterface;
use Lc\SovBundle\Translation\TranslatorAdmin; use Lc\SovBundle\Translation\TranslatorAdmin;
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\Routing\Annotation\Route;


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


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


return $this->render( return $this->render(
'@LcSov/admin/setting/global.html.twig' ,
'@LcSov/admin/setting/edit_site.html.twig' ,
[ [
'setting_definition' => $this->siteSettingDefinition, 'setting_definition' => $this->siteSettingDefinition,
'form' => $form->createView() 'form' => $form->createView()

+ 4
- 4
Controller/Ticket/TicketAdminController.php View File

DateField::new('createdAt')->setFormat('short') DateField::new('createdAt')->setFormat('short')
->hideOnForm(), ->hideOnForm(),
TextField::new('visitorFirstName') TextField::new('visitorFirstName')
->setTemplatePath('@LcSov/admin/ticket/index_username.html.twig')
->setTemplatePath('@LcSov/admin/ticket/field/username.html.twig')
->hideOnForm(), ->hideOnForm(),
TextField::new('visitorEmail') TextField::new('visitorEmail')
->setTemplatePath('@LcSov/admin/ticket/index_email.html.twig')
->setTemplatePath('@LcSov/admin/ticket/field/email.html.twig')
->hideOnForm(), ->hideOnForm(),
AssociationField::new('user') AssociationField::new('user')
->hideOnIndex(), ->hideOnIndex(),
TextField::new('subject'), TextField::new('subject'),
TextField::new('lastMessage') TextField::new('lastMessage')
->setTemplatePath('@LcSov/admin/ticket/index_lastmessage.html.twig')
->setTemplatePath('@LcSov/admin/ticket/field/lastmessage.html.twig')
->hideOnForm(), ->hideOnForm(),
ChoiceField::new('type') ChoiceField::new('type')
->autocomplete() ->autocomplete()
->setChoices( ->setChoices(
TicketModel::getChoicesStatus() TicketModel::getChoicesStatus()
) )
->setTemplatePath('@LcSov/admin/ticket/index_status.html.twig')
->setTemplatePath('@LcSov/admin/ticket/field/status.html.twig')
->hideOnForm(), ->hideOnForm(),
]; ];
} }

+ 9
- 2
Controller/User/AccountAdminController.php View File

use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface; use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use Symfony\Component\Translation\TranslatableMessage; use Symfony\Component\Translation\TranslatableMessage;
use Symfony\Component\Routing\Annotation\Route;


class AccountAdminController extends AbstractController class AccountAdminController extends AbstractController
{ {
$this->em = $em; $this->em = $em;
} }


/**
* @Route("/admin/account/profile", name="sov_admin_account_profile")
*/
public function profile(Request $request): Response public function profile(Request $request): Response
{ {
$user = $this->getUser(); $user = $this->getUser();
} }


return $this->render( return $this->render(
'@LcSov/user/profile.html.twig',
'@LcSov/admin/user/edit_profile.html.twig',
[ [
'form' => $form->createView(), 'form' => $form->createView(),
] ]
); );
} }


/**
* @Route("/admin/account/password", name="sov_admin_account_password")
*/
public function changePassword(Request $request, UserPasswordEncoderInterface $passwordEncoder): Response public function changePassword(Request $request, UserPasswordEncoderInterface $passwordEncoder): Response
{ {
$user = $this->getUser(); $user = $this->getUser();
} }


return $this->render( return $this->render(
'@LcSov/user/change_password.html.twig',
'@LcSov/admin/user/edit_password.html.twig',
[ [
'entity_class' => User::class, 'entity_class' => User::class,
'form' => $form->createView() 'form' => $form->createView()

+ 4
- 14
EventSubscriber/SiteSettingEventSubscriber.php View File

namespace Lc\SovBundle\EventSubscriber; namespace Lc\SovBundle\EventSubscriber;


use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Lc\CaracoleBundle\Definition\MerchantSettingDefinitionInterface;
use Lc\CaracoleBundle\Factory\Setting\MerchantSettingFactory;
use Lc\CaracoleBundle\Factory\Setting\SectionSettingFactory;
use Lc\CaracoleBundle\Factory\User\UserMerchantFactory;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\CaracoleBundle\Repository\Merchant\MerchantRepository;
use Lc\CaracoleBundle\Definition\SectionSettingDefinitionInterface;
use Lc\CaracoleBundle\Repository\Section\SectionRepository;
use Lc\CaracoleBundle\Resolver\MerchantResolver;
use Lc\SovBundle\Definition\SiteSettingDefinitionInterface; use Lc\SovBundle\Definition\SiteSettingDefinitionInterface;
use Lc\SovBundle\Factory\Setting\SiteSettingFactory; use Lc\SovBundle\Factory\Setting\SiteSettingFactory;
use Lc\SovBundle\Factory\Site\SiteFactory; use Lc\SovBundle\Factory\Site\SiteFactory;
use Lc\SovBundle\Repository\Setting\SiteSettingRepository;
use Lc\SovBundle\Repository\Site\SiteRepository;
use Lc\SovBundle\Repository\Setting\SiteSettingRepositoryInterface;
use Lc\SovBundle\Repository\Site\SiteRepositoryInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\Security\Core\Security;


class SiteSettingEventSubscriber implements EventSubscriberInterface class SiteSettingEventSubscriber implements EventSubscriberInterface
{ {


public function __construct( public function __construct(
EntityManagerInterface $em, EntityManagerInterface $em,
SiteSettingRepository $siteSettingRepository,
SiteRepository $siteRepository,
SiteSettingRepositoryInterface $siteSettingRepository,
SiteRepositoryInterface $siteRepository,
SiteSettingDefinitionInterface $siteSettingDefinition, SiteSettingDefinitionInterface $siteSettingDefinition,
SiteSettingFactory $siteSettingFactory, SiteSettingFactory $siteSettingFactory,
SiteFactory $siteFactory SiteFactory $siteFactory

+ 8
- 25
Repository/AbstractRepository.php View File



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


use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepositoryInterface; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepositoryInterface;
use Doctrine\ORM\AbstractQuery; use Doctrine\ORM\AbstractQuery;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query; use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Gedmo\Translatable\TranslatableListener; use Gedmo\Translatable\TranslatableListener;
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface;
use Lc\SovBundle\Doctrine\Extension\StatusInterface;


abstract class AbstractRepository extends EntityRepository implements ServiceEntityRepositoryInterface,
AbstractRepositoryInterface
abstract class AbstractRepository extends ServiceEntityRepository implements ServiceEntityRepositoryInterface,
AbstractRepositoryInterface
{ {

protected $defaultLocale; protected $defaultLocale;


public function setDefaultLocale($locale) public function setDefaultLocale($locale)
$this->defaultLocale = $locale; $this->defaultLocale = $locale;
} }


public function __construct(EntityManagerInterface $entityManager)
{
parent::__construct($entityManager, $entityManager->getClassMetadata($this->getInterfaceClass()));
}

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


return $qb->getQuery()->getOneOrNullResult(); return $qb->getQuery()->getOneOrNullResult();
} }
return $this->getTranslatedQuery($qb, $locale)->getOneOrNullResult($hydrationMode); return $this->getTranslatedQuery($qb, $locale)->getOneOrNullResult($hydrationMode);
} }



public function getResult(QueryBuilder $qb, $locale = null, $hydrationMode = AbstractQuery::HYDRATE_OBJECT) public function getResult(QueryBuilder $qb, $locale = null, $hydrationMode = AbstractQuery::HYDRATE_OBJECT)
{ {
return $this->getTranslatedQuery($qb, $locale)->getResult($hydrationMode); return $this->getTranslatedQuery($qb, $locale)->getResult($hydrationMode);
} }



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



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



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



public function getSingleScalarResult(QueryBuilder $qb, $locale = null) public function getSingleScalarResult(QueryBuilder $qb, $locale = null)
{ {
return $this->getTranslatedQuery($qb, $locale)->getSingleScalarResult(); return $this->getTranslatedQuery($qb, $locale)->getSingleScalarResult();
$qb = $this->createQueryBuilder('entity') $qb = $this->createQueryBuilder('entity')
->select('entity.id, COUNT(entity.slug) as niche') ->select('entity.id, COUNT(entity.slug) as niche')
->andWhere('entity.status>=0') ->andWhere('entity.status>=0')
->andWhere('entity.merchant= :merchant')
->setParameter('merchant', $merchant)
->groupBy('entity.slug') ->groupBy('entity.slug')
->having('COUNT(entity.slug) >1'); ->having('COUNT(entity.slug) >1');


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



public function findAll() public function findAll()
{ {
return $this->findBy(array()); return $this->findBy(array());
return parent::findOneBy($criteria, $orderBy); return parent::findOneBy($criteria, $orderBy);
} }


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;
} }



} }

+ 0
- 6
Repository/AbstractRepositoryInterface.php View File

interface AbstractRepositoryInterface interface AbstractRepositoryInterface
{ {


/**
* Retourne la class ou l'interface correspondant à ce repository
*
* @return string
*/
public function getInterfaceClass();
} }

+ 8
- 13
Repository/File/FileRepository.php View File



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


use Lc\SovBundle\Model\File\FileInterface;
use App\Entity\File\File;
use Doctrine\Persistence\ManagerRegistry;
use Lc\SovBundle\Repository\AbstractRepository; use Lc\SovBundle\Repository\AbstractRepository;
/**
* @method FileInterface|null find($id, $lockMode = null, $lockVersion = null)
* @method FileInterface|null findOneBy(array $criteria, array $orderBy = null)
* @method FileInterface[] findAll()
* @method FileInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class FileRepository extends AbstractRepository
{
public function getInterfaceClass()
{
return FileInterface::class;
}


class FileRepository extends AbstractRepository implements FileRepositoryInterface
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, File::class);
}
} }

+ 8
- 0
Repository/File/FileRepositoryInterface.php View File

<?php

namespace Lc\SovBundle\Repository\File;

interface FileRepositoryInterface
{

}

+ 5
- 10
Repository/Newsletter/NewsletterRepository.php View File



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


use Lc\SovBundle\Model\Newsletter\NewsletterInterface;
use App\Entity\Newsletter\Newsletter;
use Doctrine\Persistence\ManagerRegistry;
use Lc\SovBundle\Repository\AbstractRepository; use Lc\SovBundle\Repository\AbstractRepository;


/**
* @method NewsletterInterface|null find($id, $lockMode = null, $lockVersion = null)
* @method NewsletterInterface|null findOneBy(array $criteria, array $orderBy = null)
* @method NewsletterInterface[] findAll()
* @method NewsletterInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class NewsletterRepository extends AbstractRepository
class NewsletterRepository extends AbstractRepository implements NewsletterRepositoryInterface
{ {
public function getInterfaceClass()
public function __construct(ManagerRegistry $registry)
{ {
return NewsletterInterface::class;
parent::__construct($registry, Newsletter::class);
} }
} }

+ 8
- 0
Repository/Newsletter/NewsletterRepositoryInterface.php View File

<?php

namespace Lc\SovBundle\Repository\Newsletter;

interface NewsletterRepositoryInterface
{

}

+ 2
- 3
Repository/Reminder/ReminderRepository.php View File

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


use App\Entity\Reminder\Reminder; use App\Entity\Reminder\Reminder;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepositoryInterface;
use Doctrine\Persistence\ManagerRegistry; use Doctrine\Persistence\ManagerRegistry;
use Lc\SovBundle\Repository\AbstractRepository;


class ReminderRepository extends ServiceEntityRepository implements ServiceEntityRepositoryInterface
class ReminderRepository extends AbstractRepository implements ReminderRepositoryInterface
{ {
public function __construct(ManagerRegistry $registry) public function __construct(ManagerRegistry $registry)
{ {

+ 0
- 56
Repository/Reminder/ReminderRepositoryBack.php View File

<?php

namespace Lc\SovBundle\Repository\Reminder;

use Lc\SovBundle\Repository\AbstractRepository;
use Lc\SovBundle\Model\Reminder\ReminderInterface;

/**
* @method ReminderInterface|null find($id, $lockMode = null, $lockVersion = null)
* @method ReminderInterface|null findOneBy(array $criteria, array $orderBy = null)
* @method ReminderInterface[] findAll()
* @method ReminderInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class ReminderRepositoryBack extends AbstractRepository
{
public function getInterfaceClass()
{
return ReminderInterface::class;
}

public function findByUser($user)
{
$qb = $this->createQueryBuilder('e')
->leftJoin('e.users', 'u')
->having('COUNT(u.id) = 0')
->orHaving(':user MEMBER OF e.users')
->andWhere('e.done = 0')
->setParameter('user', $user)
->orderBy('e.dateReminder', 'ASC')
->groupBy('e.id');

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

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();
}
}

+ 8
- 0
Repository/Reminder/ReminderRepositoryInterface.php View File

<?php

namespace Lc\SovBundle\Repository\Reminder;

interface ReminderRepositoryInterface
{

}

+ 24
- 1
Repository/Reminder/ReminderRepositoryQuery.php View File



class ReminderRepositoryQuery extends AbstractRepositoryQuery class ReminderRepositoryQuery extends AbstractRepositoryQuery
{ {
public function __construct(ReminderRepository $repository, PaginatorInterface $paginator)
public function __construct(ReminderRepositoryInterface $repository, PaginatorInterface $paginator)
{ {
parent::__construct($repository, 'r', $paginator); parent::__construct($repository, 'r', $paginator);
} }

public function filterDone()
{
return $this
->andWhere('.done = 0');
}

public function filterUser($user)
{
return $this
->leftJoin('.users', 'u')
->having('COUNT(u.id) = 0')
->orHaving(':user MEMBER OF .users')
->setParameter(':user', $user)
->groupBy('.id');
}

public function orderDefault()
{
return $this
->orderBy('.dateReminder', 'ASC');
}

} }

+ 52
- 6
Repository/Reminder/ReminderStore.php View File



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


/**
* class ReminderStore.
*
* @author Simon Vieille <simon@deblan.fr>
*/
class ReminderStore class ReminderStore
{ {
protected ReminderRepositoryQuery $query; protected ReminderRepositoryQuery $query;
$this->query = $query; $this->query = $query;
} }


public function getFoo($query = null)
public function getByUser($user)
{
$query = $this->query->create();

return $query
->filterDone()
->filterUser($user)
->orderDefault()
->find();
}

/*public function getFoo($query = null)
{ {
if (!$query) { if (!$query) {
$query = $this->query->create(); $query = $this->query->create();
->andWhere('.description = :description') ->andWhere('.description = :description')
->setParameter(':description', 'ahah') ->setParameter(':description', 'ahah')
->findOne(); ->findOne();
}*/

/*

public function findByUser($user)
{
$qb = $this->createQueryBuilder('e')
->leftJoin('e.users', 'u')
->having('COUNT(u.id) = 0')
->orHaving(':user MEMBER OF e.users')
->andWhere('e.done = 0')
->setParameter('user', $user)
->orderBy('e.dateReminder', 'ASC')
->groupBy('e.id');

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

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();
}

*/
} }

+ 5
- 10
Repository/Setting/SiteSettingRepository.php View File



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


use App\Entity\Setting\SiteSetting;
use Doctrine\Persistence\ManagerRegistry;
use Lc\SovBundle\Repository\AbstractRepository; use Lc\SovBundle\Repository\AbstractRepository;
use Lc\SovBundle\Model\Setting\SiteSettingInterface;


/**
* @method SiteSettingInterface|null find($id, $lockMode = null, $lockVersion = null)
* @method SiteSettingInterface|null findOneBy(array $criteria, array $orderBy = null)
* @method SiteSettingInterface[] findAll()
* @method SiteSettingInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class SiteSettingRepository extends AbstractRepository
class SiteSettingRepository extends AbstractRepository implements SiteSettingRepositoryInterface
{ {
public function getInterfaceClass()
public function __construct(ManagerRegistry $registry)
{ {
return SiteSettingInterface::class;
parent::__construct($registry, SiteSetting::class);
} }
} }

+ 8
- 0
Repository/Setting/SiteSettingRepositoryInterface.php View File

<?php

namespace Lc\SovBundle\Repository\Setting;

interface SiteSettingRepositoryInterface
{

}

+ 5
- 10
Repository/Site/NewsRepository.php View File



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


use Lc\SovBundle\Model\Site\NewsInterface;
use App\Entity\Site\News;
use Doctrine\Persistence\ManagerRegistry;
use Lc\SovBundle\Repository\AbstractRepository; use Lc\SovBundle\Repository\AbstractRepository;


/**
* @method NewsInterface|null find($id, $lockMode = null, $lockVersion = null)
* @method NewsInterface|null findOneBy(array $criteria, array $orderBy = null)
* @method NewsInterface[] findAll()
* @method NewsInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class NewsRepository extends AbstractRepository
class NewsRepository extends AbstractRepository implements NewsRepositoryInterface
{ {
public function getInterfaceClass()
public function __construct(ManagerRegistry $registry)
{ {
return NewsInterface::class;
parent::__construct($registry, News::class);
} }
} }

+ 8
- 0
Repository/Site/NewsRepositoryInterface.php View File

<?php

namespace Lc\SovBundle\Repository\Site;

interface NewsRepositoryInterface
{

}

+ 5
- 10
Repository/Site/PageRepository.php View File



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


use Lc\SovBundle\Model\Site\PageInterface;
use App\Entity\Site\Page;
use Doctrine\Persistence\ManagerRegistry;
use Lc\SovBundle\Repository\AbstractRepository; use Lc\SovBundle\Repository\AbstractRepository;


/**
* @method PageInterface|null find($id, $lockMode = null, $lockVersion = null)
* @method PageInterface|null findOneBy(array $criteria, array $orderBy = null)
* @method PageInterface[] findAll()
* @method PageInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class PageRepository extends AbstractRepository
class PageRepository extends AbstractRepository implements PageRepositoryInterface
{ {
public function getInterfaceClass()
public function __construct(ManagerRegistry $registry)
{ {
return PageInterface::class;
parent::__construct($registry, Page::class);
} }
} }

+ 8
- 0
Repository/Site/PageRepositoryInterface.php View File

<?php

namespace Lc\SovBundle\Repository\Site;

interface PageRepositoryInterface
{

}

+ 6
- 12
Repository/Site/SiteRepository.php View File



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


use Lc\SovBundle\Model\File\FileInterface;
use Lc\SovBundle\Model\Site\SiteInterface;
use App\Entity\Site\Site;
use Doctrine\Persistence\ManagerRegistry;
use Lc\SovBundle\Repository\AbstractRepository; use Lc\SovBundle\Repository\AbstractRepository;
/**
* @method SiteInterface|null find($id, $lockMode = null, $lockVersion = null)
* @method SiteInterface|null findOneBy(array $criteria, array $orderBy = null)
* @method SiteInterface[] findAll()
* @method SiteInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class SiteRepository extends AbstractRepository

class SiteRepository extends AbstractRepository implements SiteRepositoryInterface
{ {
public function getInterfaceClass()
public function __construct(ManagerRegistry $registry)
{ {
return SiteInterface::class;
parent::__construct($registry, Site::class);
} }

} }

+ 8
- 0
Repository/Site/SiteRepositoryInterface.php View File

<?php

namespace Lc\SovBundle\Repository\Site;

interface SiteRepositoryInterface
{

}

+ 5
- 12
Repository/Ticket/TicketMessageRepository.php View File



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


use Lc\SovBundle\Model\Ticket\TicketMessageInterface;
use App\Entity\Ticket\TicketMessage;
use Doctrine\Persistence\ManagerRegistry;
use Lc\SovBundle\Repository\AbstractRepository; use Lc\SovBundle\Repository\AbstractRepository;


/**
* @method TicketMessageInterface|null find($id, $lockMode = null, $lockVersion = null)
* @method TicketMessageInterface|null findOneBy(array $criteria, array $orderBy = null)
* @method TicketMessageInterface[] findAll()
* @method TicketMessageInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class TicketMessageRepository extends AbstractRepository
class TicketMessageRepository extends AbstractRepository implements TicketMessageRepositoryInterface
{ {
public function getInterfaceClass()
public function __construct(ManagerRegistry $registry)
{ {
return TicketMessageInterface::class;
parent::__construct($registry, TicketMessage::class);
} }


} }

+ 8
- 0
Repository/Ticket/TicketMessageRepositoryInterface.php View File

<?php

namespace Lc\SovBundle\Repository\Ticket;

interface TicketMessageRepositoryInterface
{

}

+ 5
- 12
Repository/Ticket/TicketRepository.php View File



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


use Lc\SovBundle\Model\Ticket\TicketInterface;
use App\Entity\Ticket\Ticket;
use Doctrine\Persistence\ManagerRegistry;
use Lc\SovBundle\Repository\AbstractRepository; use Lc\SovBundle\Repository\AbstractRepository;


/**
* @method TicketInterface|null find($id, $lockMode = null, $lockVersion = null)
* @method TicketInterface|null findOneBy(array $criteria, array $orderBy = null)
* @method TicketInterface[] findAll()
* @method TicketInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class TicketRepository extends AbstractRepository
class TicketRepository extends AbstractRepository implements TicketRepositoryInterface
{ {
public function getInterfaceClass()
public function __construct(ManagerRegistry $registry)
{ {
return TicketInterface::class;
parent::__construct($registry, Ticket::class);
} }


} }

+ 8
- 0
Repository/Ticket/TicketRepositoryInterface.php View File

<?php

namespace Lc\SovBundle\Repository\Ticket;

interface TicketRepositoryInterface
{

}

+ 5
- 12
Repository/User/GroupUserRepository.php View File



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


use App\Entity\User\GroupUser;
use Doctrine\Persistence\ManagerRegistry;
use Lc\SovBundle\Repository\AbstractRepository; use Lc\SovBundle\Repository\AbstractRepository;
use Lc\SovBundle\Model\User\GroupUserInterface;


/**
* @method GroupUserInterface|null find($id, $lockMode = null, $lockVersion = null)
* @method GroupUserInterface|null findOneBy(array $criteria, array $orderBy = null)
* @method GroupUserInterface[] findAll()
* @method GroupUserInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class GroupUserRepository extends AbstractRepository
class GroupUserRepository extends AbstractRepository implements GroupUserRepositoryInterface
{ {
public function getInterfaceClass()
public function __construct(ManagerRegistry $registry)
{ {
return GroupUserInterface::class;
parent::__construct($registry, GroupUser::class);
} }


} }

+ 8
- 0
Repository/User/GroupUserRepositoryInterface.php View File

<?php

namespace Lc\SovBundle\Repository\User;

interface GroupUserRepositoryInterface
{

}

+ 22
- 56
Repository/User/UserRepository.php View File



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


use Lc\SovBundle\Model\User\UserInterface;
use Doctrine\Persistence\ManagerRegistry;
use App\Entity\User\User;
use Lc\SovBundle\Repository\AbstractRepository; use Lc\SovBundle\Repository\AbstractRepository;
use Symfony\Component\Security\Core\Exception\UnsupportedUserException; use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
use Symfony\Component\Security\Core\User\UserInterface as SfUserInterface; use Symfony\Component\Security\Core\User\UserInterface as SfUserInterface;


/**
* @method UserInterface|null find($id, $lockMode = null, $lockVersion = null)
* @method UserInterface|null findOneBy(array $criteria, array $orderBy = null)
* @method UserInterface[] findAll()
* @method UserInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class UserRepository extends AbstractRepository implements PasswordUpgraderInterface
class UserRepository extends AbstractRepository implements UserRepositoryInterface
{ {
public function getInterfaceClass()
{
return UserInterface::class;
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, User::class);
}

/**
* Used to upgrade (rehash) the user's password automatically over time.
*/
public function upgradePassword(SfUserInterface $user, string $newEncodedPassword): void
{
if (!$user instanceof SfUserInterface) {
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user)));
} }


/**
* Used to upgrade (rehash) the user's password automatically over time.
*/
public function upgradePassword(SfUserInterface $user, string $newEncodedPassword): void
{
if (!$user instanceof SfUserInterface) {
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user)));
}
$user->setPassword($newEncodedPassword);
$this->_em->persist($user);
$this->_em->flush();
}


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

public function findByRole($role) {
return $this->createQueryBuilder('u')
public function findByRole($role) {
return $this->createQueryBuilder('u')
->andWhere('u.roles LIKE :role') ->andWhere('u.roles LIKE :role')
->setParameter('role', '%'.$role.'%') ->setParameter('role', '%'.$role.'%')
->getQuery() ->getQuery()
->getResult(); ->getResult();
}

// /**
// * @return User[] Returns an array of User objects
// */
/*
public function findByExampleField($value)
{
return $this->createQueryBuilder('u')
->andWhere('u.exampleField = :val')
->setParameter('val', $value)
->orderBy('u.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/
}


/*
public function findOneBySomeField($value): ?User
{
return $this->createQueryBuilder('u')
->andWhere('u.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/
} }

+ 8
- 0
Repository/User/UserRepositoryInterface.php View File

<?php

namespace Lc\SovBundle\Repository\User;

interface UserRepositoryInterface
{

}

Resources/assets/app/adminlte/reminder/app.reminder.js → Resources/assets/app/admin/reminder/app.reminder.js View File


Resources/assets/app/adminlte/reminder/reminder.js → Resources/assets/app/admin/reminder/reminder.js View File


Resources/assets/app/adminlte/reminder/reminder.scss → Resources/assets/app/admin/reminder/reminder.scss View File


Resources/assets/app/adminlte/ticket/app.ticket.js → Resources/assets/app/admin/ticket/app.ticket.js View File


Resources/assets/app/adminlte/ticket/ticket.js → Resources/assets/app/admin/ticket/ticket.js View File


+ 3
- 31
Resources/config/routes.yaml View File

type: annotation type: annotation
prefix: /manager prefix: /manager


sov_login:
path: /login
controller: Lc\SovBundle\Controller\Security\SecurityAdminController::login

sov_logout:
path: /logout
controller: Lc\SovBundle\Controller\Security\SecurityAdminController::logout

sov_admin_account_profile:
path: /admin/account/profile
controller: Lc\SovBundle\Controller\User\AccountAdminController::profile

sov_admin_account_password:
path: /admin/account/password
controller: Lc\SovBundle\Controller\User\AccountAdminController::changePassword

sov_admin_setting_global:
path: /admin/setting/global
controller: Lc\SovBundle\Controller\Setting\SettingAdminController::manageGlobal

sov_admin_create_ticket:
path: /admin/ticket/create
controller: Lc\SovBundle\Controller\Ticket\TicketAdminController::create

sov_admin_reminder_render_modal:
path: /admin/reminder/modal
controller: Lc\SovBundle\Controller\Reminder\ReminderAdminController::renderModal

sov_admin_reminder_new:
path: /admin/reminder/new
controller: Lc\SovBundle\Controller\Reminder\ReminderAdminController::new
lc_sov_bundle:
resource: "@LcSovBundle/Controller"
type: annotation

Resources/views/admin/setting/global.html.twig → Resources/views/admin/setting/edit_site.html.twig View File


+ 3
- 3
Resources/views/admin/ticket/detail.html.twig View File

{% import '@LcSov/adminlte/macro/infobox.html.twig' as macro %} {% import '@LcSov/adminlte/macro/infobox.html.twig' as macro %}


{% block content_title %} {% block content_title %}
{{ 'detail'|lc_trans_admin_title(ea.getEntity().getFqcn(), {id: ea.getEntity().getInstance().getId()}) }}
{{ 'detail'|sov_trans_admin_title(ea.getEntity().getFqcn(), {id: ea.getEntity().getInstance().getId()}) }}
{% endblock %} {% endblock %}


{% block main %} {% block main %}
<p>{{ message.message|nl2br }}</p> <p>{{ message.message|nl2br }}</p>
{% if message.imageFilename is not null %} {% if message.imageFilename is not null %}
<i>Photo jointe au message : </i> <br/> <i>Photo jointe au message : </i> <br/>
<a href="{{ lc_liip(message.imageFilename, 'big') }}"
<a href="{{ sov_liip(message.imageFilename, 'big') }}"
data-toggle="lightbox"> data-toggle="lightbox">
<img src="{{ lc_liip(message.imageFilename, 'thumb') }}"
<img src="{{ sov_liip(message.imageFilename, 'thumb') }}"
alt="Illustration ticket"/> alt="Illustration ticket"/>
</a> </a>
{% endif %} {% endif %}

Resources/views/admin/ticket/index_email.html.twig → Resources/views/admin/ticket/field/email.html.twig View File


Resources/views/admin/ticket/index_lastmessage.html.twig → Resources/views/admin/ticket/field/lastmessage.html.twig View File


Resources/views/admin/ticket/index_status.html.twig → Resources/views/admin/ticket/field/status.html.twig View File


Resources/views/admin/ticket/index_username.html.twig → Resources/views/admin/ticket/field/username.html.twig View File


+ 1
- 1
Resources/views/admin/ticket/new.html.twig View File

{% extends '@LcSov/adminlte/layout.html.twig' %} {% extends '@LcSov/adminlte/layout.html.twig' %}


{% block content_title %} {% block content_title %}
{# {{ 'ticket.profile'|lc_trans_admin_title }} #}
{# {{ 'ticket.profile'|sov_trans_admin_title }} #}
Créer un ticket Créer un ticket
{% endblock %} {% endblock %}



Resources/views/user/change_password.html.twig → Resources/views/admin/user/edit_password.html.twig View File

{% extends '@LcSov/adminlte/layout.html.twig' %} {% extends '@LcSov/adminlte/layout.html.twig' %}


{% block content_title %} {% block content_title %}
{{ 'account.change_password'|lc_trans_admin_title }}
{{ 'account.change_password'|sov_trans_admin_title }}
{% endblock %} {% endblock %}


{% block main %} {% block main %}

Resources/views/user/profile.html.twig → Resources/views/admin/user/edit_profile.html.twig View File

{% extends '@LcSov/adminlte/layout.html.twig' %} {% extends '@LcSov/adminlte/layout.html.twig' %}


{% block content_title %} {% block content_title %}
{{ 'account.profile'|lc_trans_admin_title }}
{{ 'account.profile'|sov_trans_admin_title }}
{% endblock %} {% endblock %}


{% block main %} {% block main %}

Resources/views/user/request_password.html.twig → Resources/views/admin/user/request_password.html.twig View File


+ 1
- 1
Resources/views/adminlte/block/menu.html.twig View File

{% if item.icon is not empty %} {% if item.icon is not empty %}
<i class="{{ item.icon }} nav-icon"></i> <i class="{{ item.icon }} nav-icon"></i>
{% endif %} {% endif %}
<p>{{ item.label|lc_trans_admin_menu }}</p>
<p>{{ item.label|sov_trans_admin_menu }}</p>
{% if item.hasSubItems %}<i class="right fas fa-angle-left"></i>{% endif %} {% if item.hasSubItems %}<i class="right fas fa-angle-left"></i>{% endif %}
</a> </a>
{% endif %} {% endif %}

Resources/views/adminlte/filemanager/file-manager-modal.html.twig → Resources/views/adminlte/block/modal_filemanager.html.twig View File


+ 2
- 2
Resources/views/adminlte/block/navbar_header.html.twig View File

</li> </li>


<li class="nav-item"> <li class="nav-item">
<a href="{{ path(sov_get_parameter('app.reminder.route_render_modal')) }}" class="btn btn-sm btn-outline-info btn-reminder" data-crud-action="{{ ea.request.query.get('crudAction') }}" data-crud-controller-fqcn="{{ ea.request.query.get('crudControllerFqcn') }}">
<a href="{{ path(sov_parameter('app.reminder.route_render_modal')) }}" class="btn btn-sm btn-outline-info btn-reminder" data-crud-action="{{ ea.request.query.get('crudAction') }}" data-crud-controller-fqcn="{{ ea.request.query.get('crudControllerFqcn') }}">
<i class="action-icon fa fa-plus"></i> <i class="action-icon fa fa-plus"></i>
Pense-bête Pense-bête
</a> </a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a href="{{ path(homepage_route()) }}" class="btn btn-sm btn-block btn-outline-success" target="_blank"
<a href="{{ path(sov_homepage_route()) }}" class="btn btn-sm btn-block btn-outline-success" target="_blank"
rel="noreferrer"> rel="noreferrer">
<i class="action-icon fa fa-eye"></i> <i class="action-icon fa fa-eye"></i>
Afficher le site Afficher le site

+ 2
- 2
Resources/views/adminlte/crud/edit.html.twig View File

{# @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 #}
{% set form = edit_form %} {% set form = edit_form %}
{% extends '@LcSov/adminlte/crud/_form.html.twig' %}
{% extends '@LcSov/adminlte/crud/layout_form.html.twig' %}


{% block body_id 'ea-edit-' ~ entity.name ~ '-' ~ entity.primaryKeyValue %} {% block body_id 'ea-edit-' ~ entity.name ~ '-' ~ entity.primaryKeyValue %}
{% block body_class 'ea-edit ea-edit-' ~ entity.name %} {% block body_class 'ea-edit ea-edit-' ~ entity.name %}


{% block content_title %} {% block content_title %}
{{ 'edit'|lc_trans_admin_title(ea.getEntity().getFqcn(), {id: ea.getEntity().getInstance().getId()}) }}
{{ 'edit'|sov_trans_admin_title(ea.getEntity().getFqcn(), {id: ea.getEntity().getInstance().getId()}) }}
{% endblock %} {% endblock %}


{% block delete_form %} {% block delete_form %}

+ 3
- 3
Resources/views/adminlte/crud/field/image.html.twig View File



{% set id_modal = 'modal-'~field.value.id %} {% set id_modal = 'modal-'~field.value.id %}


<a href="{{ lc_liip(field.value.path, 'big') }}" data-toggle="modal" data-target="#{{ id_modal }}" title="{{ field.value.legend }}">
<img src="{{ lc_liip(field.value.path, 'thumbnail') }}" alt="{{ field.value.legend }}">
<a href="{{ sov_liip(field.value.path, 'big') }}" data-toggle="modal" data-target="#{{ id_modal }}" title="{{ field.value.legend }}">
<img src="{{ sov_liip(field.value.path, 'thumbnail') }}" alt="{{ field.value.legend }}">
</a> </a>


{% embed "@LcSov/adminlte/embed/modal.twig" %} {% embed "@LcSov/adminlte/embed/modal.twig" %}
{% block size %}modal-xl{% endblock %} {% block size %}modal-xl{% endblock %}
{% block title %}{{ field.value.legend ? field.value.legend : 'Image' }}{% endblock %} {% block title %}{{ field.value.legend ? field.value.legend : 'Image' }}{% endblock %}
{% block body %} {% block body %}
<img src="{{ lc_liip(field.value.path, 'big') }}" alt="{{ field.value.legend }}" />
<img src="{{ sov_liip(field.value.path, 'big') }}" alt="{{ field.value.legend }}" />
{% endblock %} {% endblock %}
{% block footer_wrapper %}{% endblock %} {% block footer_wrapper %}{% endblock %}
{% endembed %} {% endembed %}

+ 3
- 3
Resources/views/adminlte/crud/form_theme.html.twig View File

</div> </div>
{% endif %} {% endif %}


{% set help_message = name|lc_trans_admin_help(form.parent.vars.data) %}
{% set help_message = name|sov_trans_admin_help(form.parent.vars.data) %}
{% if help_message != '' %} {% if help_message != '' %}
<small class="form-help">{{ help_message }}</small> <small class="form-help">{{ help_message }}</small>
{% endif %} {% endif %}
{% set entityNameOrObject = form.parent.vars.errors.form.config.dataClass %} {% set entityNameOrObject = form.parent.vars.errors.form.config.dataClass %}
{% endif %} {% endif %}


<{{ element|default('label') }}{% if label_attr %}{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}{% endif %}>{{ (label is not empty and '.' in label) ? label|trans({}, 'admin') : name|lc_trans_admin_field(entityNameOrObject) }}</{{ element|default('label') }}>
<{{ element|default('label') }}{% if label_attr %}{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}{% endif %}>{{ (label is not empty and '.' in label) ? label|trans({}, 'admin') : name|sov_trans_admin_field(entityNameOrObject) }}</{{ element|default('label') }}>


{%- endif -%} {%- endif -%}
{%- endblock form_label %} {%- endblock form_label %}
{% import '@LcSov/adminlte/macro/tabs.html.twig' as mtabs %} {% import '@LcSov/adminlte/macro/tabs.html.twig' as mtabs %}
{% block menu_items %} {% block menu_items %}
{% for panel_name, panel_config in ea_crud_form.form_panels|filter(panel_config => not panel_config.form_tab or panel_config.form_tab == tab_name) %} {% for panel_name, panel_config in ea_crud_form.form_panels|filter(panel_config => not panel_config.form_tab or panel_config.form_tab == tab_name) %}
{{ mtabs.menu_item(panel_name, loop.first, panel_config.label|lc_trans_admin_panel(ea.getEntity().getFqcn())) }}
{{ mtabs.menu_item(panel_name, loop.first, panel_config.label|sov_trans_admin_panel(ea.getEntity().getFqcn())) }}
{% endfor %} {% endfor %}
{% endblock %} {% endblock %}



+ 2
- 2
Resources/views/adminlte/crud/index.html.twig View File

{% block body_class 'index' ~ (entities|length > 0 ? ' index-' ~ entities|first.name : '') %} {% block body_class 'index' ~ (entities|length > 0 ? ' index-' ~ entities|first.name : '') %}


{% block content_title %} {% block content_title %}
{{ 'index'|lc_trans_admin_title(ea.getEntity().getFqcn()) }}
{{ 'index'|sov_trans_admin_title(ea.getEntity().getFqcn()) }}
{% endblock %} {% endblock %}


{% block content_breadcrumb %} {% block content_breadcrumb %}
class="fa fa-fw {{ column_icon }}"></i> class="fa fa-fw {{ column_icon }}"></i>
</a> </a>
{% else %} {% else %}
<span>{{ field.getProperty|lc_trans_admin_field(ea.getEntity().getFqcn()) }}</span>
<span>{{ field.getProperty|sov_trans_admin_field(ea.getEntity().getFqcn()) }}</span>
{% endif %} {% endif %}
</th> </th>
{% endif %} {% endif %}

Resources/views/adminlte/crud/_form.html.twig → Resources/views/adminlte/crud/layout_form.html.twig View File


+ 2
- 2
Resources/views/adminlte/crud/new.html.twig View File

{# @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 #}
{% set form = new_form %} {% set form = new_form %}
{% extends '@LcSov/adminlte/crud/_form.html.twig' %}
{% extends '@LcSov/adminlte/crud/layout_form.html.twig' %}


{% block body_id 'ea-new-' ~ entity.name ~ '-' ~ entity.primaryKeyValue %} {% block body_id 'ea-new-' ~ entity.name ~ '-' ~ entity.primaryKeyValue %}
{% block body_class 'ea-new ea-new-' ~ entity.name %} {% block body_class 'ea-new ea-new-' ~ entity.name %}


{% block content_title %} {% block content_title %}
{{ 'new'|lc_trans_admin_title(ea.getEntity().getFqcn()) }}
{{ 'new'|sov_trans_admin_title(ea.getEntity().getFqcn()) }}
{% endblock %} {% endblock %}


{% block body_javascript %} {% block body_javascript %}

+ 1
- 1
Resources/views/adminlte/crud/sort.html.twig View File

{% block body_class 'index' ~ (entities|length > 0 ? ' index-' ~ entities|first.name : '') %} {% block body_class 'index' ~ (entities|length > 0 ? ' index-' ~ entities|first.name : '') %}


{% block content_title %} {% block content_title %}
{{ 'sort'|lc_trans_admin_title(ea.getEntity().getFqcn()) }}
{{ 'sort'|sov_trans_admin_title(ea.getEntity().getFqcn()) }}
{% endblock %} {% endblock %}


{% block content_breadcrumb %} {% block content_breadcrumb %}

+ 1
- 1
Resources/views/adminlte/dashboard.html.twig View File

{% extends '@LcSov/adminlte/layout.html.twig' %} {% extends '@LcSov/adminlte/layout.html.twig' %}


{% block content_title %} {% block content_title %}
{{ 'dashboard'|lc_trans_admin_title }}
{{ 'dashboard'|sov_trans_admin_title }}
{% endblock %} {% endblock %}


{% block main %} {% block main %}

+ 1
- 1
Resources/views/adminlte/layout.html.twig View File

{% endfor %} {% endfor %}
{% endblock %} {% endblock %}


{% include '@LcSov/adminlte/filemanager/file-manager-modal.html.twig' %}
{% include '@LcSov/adminlte/block/modal_filemanager.html.twig' %}


{% if app.session is not null and app.session.started %} {% if app.session is not null and app.session.started %}
{% set flash_messages = app.session.flashbag.all %} {% set flash_messages = app.session.flashbag.all %}

+ 40
- 0
Twig/StoreTwigExtension.php View File

<?php

namespace Lc\SovBundle\Twig;

use Lc\SovBundle\Repository\Reminder\ReminderStore;
use Symfony\Component\Security\Core\Security;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;

class StoreTwigExtension extends AbstractExtension
{
protected Security $security;
protected ReminderStore $reminderStore;

public function __construct(
Security $security,
ReminderStore $reminderStore
) {
$this->security = $security;
$this->reminderStore = $reminderStore;
}

public function getFunctions()
{
return [
new TwigFunction('sov_get_reminders', [$this, 'getReminders']),
];
}

public function getFilters()
{
return [];
}

public function getReminders()
{
return $this->reminderStore->getByUser($this->security->getUser());
}

}

+ 107
- 0
Twig/TranslatorTwigExtension.php View File

<?php

namespace Lc\SovBundle\Twig;

use App\Repository\ReminderRepository;
use Doctrine\ORM\EntityManagerInterface;
use Lc\SovBundle\Model\Reminder\ReminderInterface;
use Lc\SovBundle\Repository\Reminder\ReminderStore;
use Lc\SovBundle\Translation\TranslatorAdmin;
use Liip\ImagineBundle\Imagine\Cache\CacheManager;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
use Twig\TwigFunction;

class TranslatorTwigExtension extends AbstractExtension
{
protected $parameterBag;
protected $requestStack;
protected $router;
protected $translatorAdmin;

public function __construct(
ParameterBagInterface $parameterBag,
RequestStack $requestStack,
UrlGeneratorInterface $router,
TranslatorAdmin $translatorAdmin
) {
$this->parameterBag = $parameterBag;
$this->requestStack = $requestStack;
$this->router = $router;
$this->translatorAdmin = $translatorAdmin;
}

public function getFunctions()
{
return [
new TwigFunction('sov_translated_urls', [$this, 'getTranslatedUrls']),
];
}


public function getFilters()
{
return [
new TwigFilter('sov_trans_admin_field', [$this, 'transAdminField']),
new TwigFilter('sov_trans_admin_help', [$this, 'transAdminHelp']),
new TwigFilter('sov_trans_admin_panel', [$this, 'transAdminPanel']),
new TwigFilter('sov_trans_admin_menu', [$this, 'transAdminMenu']),
new TwigFilter('sov_trans_admin_title', [$this, 'transAdminTitle']),
new TwigFilter('sov_trans_admin_action', [$this, 'transAdminAction']),
];
}

function getTranslatedUrls()
{
$ret = array();
$langs = $this->parameterBag->get('app.locales');
$currentRoute = $this->requestStack->getCurrentRequest()->get('_route');

$params = array_merge((array)$this->requestStack->getCurrentRequest()->get('_route_params'), $_GET);

if ($currentRoute) {
foreach ($langs as $lg) {
$ret[$lg] = $this->router->generate($currentRoute, array_merge($params, array('_locale' => $lg)));
}
}

return $ret;
}

public function transAdminField($fieldName, $entityClass)
{
return $this->translatorAdmin->transField($fieldName, $entityClass);
}

public function transAdminHelp($fieldName, $entityClass)
{
return $this->translatorAdmin->transHelp($fieldName, $entityClass);
}

public function transAdminPanel($panelName, $entityClass)
{
return $this->translatorAdmin->transPanel($panelName, $entityClass);
}

public function transAdminMenu($menuName)
{
return $this->translatorAdmin->transMenu($menuName);;
}

public function transAdminAction($actionName)
{
return $this->translatorAdmin->transAction($actionName);;
}

public function transAdminTitle($pageName, $entityClass = null, $params = [])
{
return $this->translatorAdmin->transTitle($pageName, $entityClass, $params);
}

}

+ 17
- 82
Twig/TwigExtension.php View File

use App\Repository\ReminderRepository; use App\Repository\ReminderRepository;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Lc\SovBundle\Model\Reminder\ReminderInterface; use Lc\SovBundle\Model\Reminder\ReminderInterface;
use Lc\SovBundle\Repository\Reminder\ReminderStore;
use Lc\SovBundle\Translation\TranslatorAdmin; use Lc\SovBundle\Translation\TranslatorAdmin;
use Liip\ImagineBundle\Imagine\Cache\CacheManager; use Liip\ImagineBundle\Imagine\Cache\CacheManager;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\RequestStack;
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\Contracts\Translation\TranslatorInterface; use Symfony\Contracts\Translation\TranslatorInterface;
use Twig\Extension\AbstractExtension; use Twig\Extension\AbstractExtension;
use Twig\TwigFilter; use Twig\TwigFilter;
protected $router; protected $router;
protected $translator; protected $translator;
protected $translatorAdmin; protected $translatorAdmin;
protected $reminderStore;
protected $security;


public function __construct( public function __construct(
KernelInterface $kernel, KernelInterface $kernel,
RequestStack $requestStack, RequestStack $requestStack,
UrlGeneratorInterface $router, UrlGeneratorInterface $router,
TranslatorInterface $translator, TranslatorInterface $translator,
TranslatorAdmin $translatorAdmin
TranslatorAdmin $translatorAdmin,
ReminderStore $reminderStore,
Security $security
) { ) {
$this->kernel = $kernel; $this->kernel = $kernel;
$this->parameterBag = $parameterBag; $this->parameterBag = $parameterBag;
$this->router = $router; $this->router = $router;
$this->translator = $translator; $this->translator = $translator;
$this->translatorAdmin = $translatorAdmin; $this->translatorAdmin = $translatorAdmin;
$this->reminderStore = $reminderStore;
$this->security = $security;
} }


public function getFunctions() public function getFunctions()
{
return array(
new TwigFunction('lc_liip', [$this, 'lcLiip']),
new TwigFunction('homepage_route', [$this, 'homepageRoute']),
new TwigFunction('page_by_dev_alias', [$this, 'getPageByDevAlias']),
new TwigFunction('translated_urls', [$this, 'getTranslatedUrls']),
new TwigFunction('sov_get_reminders', [$this, 'getReminders']),
new TwigFunction('sov_get_parameter', [$this, 'getParameter']),
);
}


public function getFilters()
{ {
return [ return [
new TwigFilter('lc_cache', [$this, 'lcCache']),
new TwigFilter('lc_trans_admin_field', [$this, 'lcTransAdminField']),
new TwigFilter('lc_trans_admin_help', [$this, 'lcTransAdminHelp']),
new TwigFilter('lc_trans_admin_panel', [$this, 'lcTransAdminPanel']),
new TwigFilter('lc_trans_admin_menu', [$this, 'lcTransAdminMenu']),
new TwigFilter('lc_trans_admin_title', [$this, 'lcTransAdminTitle']),
new TwigFilter('lc_trans_admin_action', [$this, 'lcTransAdminAction']),
new TwigFunction('sov_liip', [$this, 'liip']),
new TwigFunction('sov_get_by_devalias', [$this, 'getByDevAlias']),
new TwigFunction('sov_parameter', [$this, 'getParameter']),
new TwigFunction('sov_homepage_route', [$this, 'getHomepageRoute']),
]; ];
} }


public function lcCache($file)
{
$cacheTime = filemtime($this->kernel->getProjectDir() . '/public' . $file);
if ($cacheTime) {
return $file . '?c=' . $cacheTime;
} else {
return $file . "?c=0";
}
}

public function lcTransAdminField($fieldName, $entityClass)
{
return $this->translatorAdmin->transField($fieldName, $entityClass);
}

public function lcTransAdminHelp($fieldName, $entityClass)
{
return $this->translatorAdmin->transHelp($fieldName, $entityClass);
}


public function lcTransAdminPanel($panelName, $entityClass)
{
return $this->translatorAdmin->transPanel($panelName, $entityClass);
}

public function lcTransAdminMenu($menuName)
{
return $this->translatorAdmin->transMenu($menuName);;
}

public function lcTransAdminAction($actionName)
{
return $this->translatorAdmin->transAction($actionName);;
}

public function lcTransAdminTitle($pageName, $entityClass = null, $params = [])
public function getFilters()
{ {
return $this->translatorAdmin->transTitle($pageName, $entityClass, $params);
return [];
} }


public function lcLiip($path, $thumb = 'tile', $default = 'default.jpg')
public function liip($path, $thumb = 'tile', $default = 'default.jpg')
{ {
if (substr($path, 0, 1) === '/') { if (substr($path, 0, 1) === '/') {
$path = substr($path, 1); $path = substr($path, 1);
return $this->cacheManager->getBrowserPath($this->getFileManagerFolder() . '/' . $default, $thumb); return $this->cacheManager->getBrowserPath($this->getFileManagerFolder() . '/' . $default, $thumb);
} }


function getTranslatedUrls()
{
$ret = array();
$langs = $this->parameterBag->get('app.locales');
$currentRoute = $this->requestStack->getCurrentRequest()->get('_route');

$params = array_merge((array)$this->requestStack->getCurrentRequest()->get('_route_params'), $_GET);

if ($currentRoute) {
foreach ($langs as $lg) {
$ret[$lg] = $this->router->generate($currentRoute, array_merge($params, array('_locale' => $lg)));
}
}

return $ret;
}

public function getFileManagerFolder() public function getFileManagerFolder()
{ {
return $this->parameterBag->get('app.path_uploads'); return $this->parameterBag->get('app.path_uploads');
} }


public function homepageRoute()
public function getHomepageRoute()
{ {
return $this->parameterBag->get('lc_sov.homepage_route'); return $this->parameterBag->get('lc_sov.homepage_route');
} }
return $this->parameterBag->get($name) ; return $this->parameterBag->get($name) ;
} }


public function getReminders()
{
$reminders = $this->em->getRepository(ReminderInterface::class)->findAll() ;
return $reminders;
}

} }

Loading…
Cancel
Save