); | ); | ||||
} | } | ||||
public function createEntity(string $entityFqcn) | |||||
{ | |||||
if(method_exists($this, 'getEntityFactory')) { | |||||
$factoryClass = $this->getEntityFactory(); | |||||
$factory = new $factoryClass; | |||||
return $factory->create(); | |||||
} | |||||
else { | |||||
return parent::createEntity($entityFqcn); | |||||
} | |||||
} | |||||
public function updateEntity(EntityManagerInterface $entityManager, $entityInstance): void | public function updateEntity(EntityManagerInterface $entityManager, $entityInstance): void | ||||
{ | { | ||||
$entityManager->update($entityInstance); | $entityManager->update($entityInstance); |
$assets->addWebpackEncoreEntry('adminlte-sort'); | $assets->addWebpackEncoreEntry('adminlte-sort'); | ||||
$assets->addWebpackEncoreEntry('adminlte-field-collection'); | $assets->addWebpackEncoreEntry('adminlte-field-collection'); | ||||
$assets->addWebpackEncoreEntry('adminlte-field-filemanager'); | $assets->addWebpackEncoreEntry('adminlte-field-filemanager'); | ||||
$assets->addWebpackEncoreEntry('adminlte-reminder'); | |||||
$assets->addWebpackEncoreEntry('sov-reminder'); | |||||
return $assets; | return $assets; | ||||
} | } |
use Lc\CaracoleBundle\Resolver\SectionResolver; | use Lc\CaracoleBundle\Resolver\SectionResolver; | ||||
use Lc\SovBundle\Factory\Reminder\ReminderFactoryInterface; | 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; | ||||
use Symfony\Component\HttpFoundation\JsonResponse; | |||||
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 | ||||
{ | { | ||||
protected EntityManagerInterface $entityManager; | protected EntityManagerInterface $entityManager; | ||||
protected ReminderFactoryInterface $reminderFactory; | protected ReminderFactoryInterface $reminderFactory; | ||||
protected ReminderRepositoryQueryInterface $reminderRepositoryQuery; | |||||
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, | ||||
ReminderFactoryInterface $reminderFactory, | ReminderFactoryInterface $reminderFactory, | ||||
ReminderRepositoryQueryInterface $reminderRepositoryQuery, | |||||
FormFactoryInterface $formFactory, | FormFactoryInterface $formFactory, | ||||
UrlGeneratorInterface $urlGenerator, | UrlGeneratorInterface $urlGenerator, | ||||
MerchantResolver $merchantResolver, | MerchantResolver $merchantResolver, | ||||
) { | ) { | ||||
$this->entityManager = $entityManager; | $this->entityManager = $entityManager; | ||||
$this->reminderFactory = $reminderFactory; | $this->reminderFactory = $reminderFactory; | ||||
$this->reminderRepositoryQuery = $reminderRepositoryQuery; | |||||
$this->formFactory = $formFactory; | $this->formFactory = $formFactory; | ||||
$this->urlGenerator = $urlGenerator; | $this->urlGenerator = $urlGenerator; | ||||
$this->merchantResolver = $merchantResolver; | $this->merchantResolver = $merchantResolver; | ||||
$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'); | |||||
$crudControllerFqcn = $request->get('crudControllerFqcn'); | |||||
$entityId = $request->get('entityId'); | |||||
$reminder = $this->createEntity($crudAction, $crudControllerFqcn, $entityId); | |||||
$id = $request->get('id'); | |||||
if($id) { | |||||
$reminder = $this->reminderRepositoryQuery->getRepository()->find($id); | |||||
$action = $this->urlGenerator->generate( | |||||
$this->parameterBag->get('app.reminder.route_edit'), | |||||
['id' => $id] | |||||
); | |||||
} | |||||
else { | |||||
$crudAction = $request->get('crudAction'); | |||||
$crudControllerFqcn = $request->get('crudControllerFqcn'); | |||||
$entityId = $request->get('entityId') ? $request->get('entityId') : null ; | |||||
$reminder = $this->createEntity($crudAction, $crudControllerFqcn, $entityId); | |||||
$action = $this->urlGenerator->generate( | |||||
$this->parameterBag->get('app.reminder.route_new') | |||||
); | |||||
} | |||||
$form = $this->formFactory->create( | $form = $this->formFactory->create( | ||||
ReminderAdminFormType::class, | ReminderAdminFormType::class, | ||||
$reminder, | $reminder, | ||||
[ | [ | ||||
'action' => $this->urlGenerator->generate( | |||||
$this->parameterBag->get('app.reminder.route_new') | |||||
) | |||||
'action' => $action | |||||
] | ] | ||||
); | ); | ||||
); | ); | ||||
} | } | ||||
/** | |||||
* @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(); | ||||
return $this->redirect($request->headers->get('referer')); | return $this->redirect($request->headers->get('referer')); | ||||
} | } | ||||
public function createEntity(string $crudAction = null, string $crudControllerFqcn = null, int $entityId = null) | |||||
/** | |||||
* @Route("/admin/reminder/edit/{id}", name="sov_admin_reminder_edit") | |||||
*/ | |||||
public function edit(Request $request) | |||||
{ | { | ||||
return $this->reminderFactory->create($crudAction, $crudControllerFqcn, $entityId); | |||||
} | |||||
$id = $request->get('id'); | |||||
$reminder = $this->reminderRepositoryQuery->getRepository()->find($id); | |||||
$form = $this->formFactory->create(ReminderAdminFormType::class, $reminder); | |||||
$form->handleRequest($request); | |||||
/* | |||||
public function renderTemplate($actionName, $templatePath, array $parameters = []) | |||||
{ | |||||
if ($this->request->isXmlHttpRequest() && ($actionName == 'new' || $actionName == 'edit')) { | |||||
$response['flashMessages'] = $this->utils->getFlashMessages(); | |||||
if ($form->isSubmitted() && $form->isValid()) { | |||||
$reminder = $form->getData(); | |||||
$this->entityManager->update($reminder); | |||||
$this->entityManager->flush(); | |||||
$response['data'] = $this->render('@LcShop/backend/default/modal/edit_reminder.twig', $parameters)->getContent(); | |||||
return new Response(json_encode($response)); | |||||
} else { | |||||
return parent::renderTemplate($actionName, $templatePath, $parameters); | |||||
$this->addFlash('success', 'Le pense-bête a bien été mis à jour'); | |||||
} | } | ||||
return $this->redirect($request->headers->get('referer')); | |||||
} | } | ||||
protected function redirectToReferrer() | |||||
/** | |||||
* @Route("/admin/reminder/done", name="sov_admin_reminder_done") | |||||
*/ | |||||
public function done(Request $request): JsonResponse | |||||
{ | { | ||||
$action = $this->request->query->get('action'); | |||||
if ($action == 'new') { | |||||
$this->utils->addFlash('success', 'success.reminder.add'); | |||||
} elseif ($action == 'edit') { | |||||
$this->utils->addFlash('success', 'success.reminder.edit'); | |||||
} elseif ($action == ' setReminderDone') { | |||||
$this->utils->addFlash('success', 'success.reminder.done'); | |||||
} | |||||
$id = $request->get('id'); | |||||
$reminder = $this->reminderRepositoryQuery->getRepository()->find($id); | |||||
$done = $request->get('done'); | |||||
if ($this->request->isXmlHttpRequest()) { | |||||
$response['flashMessages'] = $this->utils->getFlashMessages(); | |||||
return new Response(json_encode($response)); | |||||
} else { | |||||
return parent::redirectToReferrer(); | |||||
if($done == 'true') { | |||||
$reminder->setDone(true); | |||||
} | |||||
else { | |||||
$reminder->setDone(false); | |||||
} | } | ||||
$this->entityManager->update($reminder); | |||||
$this->entityManager->flush(); | |||||
return new JsonResponse(['success' => true]); | |||||
} | } | ||||
public function setReminderDoneAction() | |||||
public function createEntity(string $crudAction = null, string $crudControllerFqcn = null, int $entityId = null) | |||||
{ | { | ||||
$id = $this->request->query->get('id'); | |||||
$done = $this->request->query->get('done'); | |||||
$easyadmin = $this->request->attributes->get('easyadmin'); | |||||
$reminder = $easyadmin['item']; | |||||
$reminder->setDone($done); | |||||
$this->em->persist($reminder); | |||||
$this->em->flush(); | |||||
return $this->redirectToReferrer(); | |||||
}*/ | |||||
return $this->reminderFactory->create($crudAction, $crudControllerFqcn, $entityId); | |||||
} | |||||
} | } |
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.'); |
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\Setting\SiteSettingRepository; | ||||
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 | ||||
{ | { | ||||
$this->siteRepository = $siteRepository; | $this->siteRepository = $siteRepository; | ||||
} | } | ||||
/** | |||||
* @Route("/admin/setting/site", name="sov_admin_setting_site") | |||||
*/ | |||||
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() |
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\Factory\Ticket\TicketFactoryInterface; | use Lc\SovBundle\Factory\Ticket\TicketFactoryInterface; | ||||
use Lc\SovBundle\Factory\Ticket\TicketMessageFactory; | |||||
use Lc\SovBundle\Factory\Ticket\TicketMessageFactoryInterface; | |||||
use Lc\SovBundle\Form\Ticket\TicketFormType; | use Lc\SovBundle\Form\Ticket\TicketFormType; | ||||
use Lc\SovBundle\Form\Ticket\TicketMessageFormType; | use Lc\SovBundle\Form\Ticket\TicketMessageFormType; | ||||
use Lc\SovBundle\Form\Ticket\TicketStatusType; | use Lc\SovBundle\Form\Ticket\TicketStatusType; | ||||
{ | { | ||||
$assets = parent::configureAssets($assets); | $assets = parent::configureAssets($assets); | ||||
$assets->addWebpackEncoreEntry('adminlte-ticket'); | |||||
$assets->addWebpackEncoreEntry('sov-ticket'); | |||||
return $assets; | return $assets; | ||||
} | } | ||||
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() | ||||
$this->translatorAdmin->transChoices(TicketModel::getStatusChoices(), 'Ticket', 'status') | $this->translatorAdmin->transChoices(TicketModel::getStatusChoices(), 'Ticket', 'status') | ||||
) | ) | ||||
->setTemplatePath('@LcSov/admin/ticket/index_status.html.twig') | |||||
->setTemplatePath('@LcSov/admin/ticket/field/status.html.twig') | |||||
->hideOnForm(), | ->hideOnForm(), | ||||
]; | ]; | ||||
} | } | ||||
if ($form->isSubmitted() && $form->isValid()) { | if ($form->isSubmitted() && $form->isValid()) { | ||||
$ticket = $form->getData(); | $ticket = $form->getData(); | ||||
// @TODO : check si ça marche sans | |||||
foreach ($ticket->getTicketMessages() as $ticketMessage) { | |||||
$this->get('em')->persist($ticketMessage); | |||||
} | |||||
$this->get('em')->persist($ticket); | $this->get('em')->persist($ticket); | ||||
$this->get('em')->flush(); | $this->get('em')->flush(); | ||||
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() |
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\Site\SiteRepository; | use Lc\SovBundle\Repository\Site\SiteRepository; | ||||
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 | ||||
{ | { |
<?php | |||||
namespace Lc\SovBundle\Factory\File; | |||||
use App\Entity\File\File; | |||||
use Lc\SovBundle\Factory\AbstractFactory; | |||||
use Lc\SovBundle\Model\File\FileInterface; | |||||
class FileFactory extends AbstractFactory implements FileFactoryInterface | |||||
{ | |||||
public function create(): FileInterface | |||||
{ | |||||
$file = new File(); | |||||
return $file; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Factory\File; | |||||
interface FileFactoryInterface | |||||
{ | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Factory\Newsletter; | |||||
use App\Entity\Newsletter\Newsletter; | |||||
use Lc\SovBundle\Factory\AbstractFactory; | |||||
use Lc\SovBundle\Model\Newsletter\NewsletterInterface; | |||||
class NewsletterFactory extends AbstractFactory implements NewsletterFactoryInterface | |||||
{ | |||||
public function create(): NewsletterInterface | |||||
{ | |||||
$newsletter = new Newsletter(); | |||||
return $newsletter; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Factory\Newsletter; | |||||
interface NewsletterFactoryInterface | |||||
{ | |||||
} |
use App\Entity\Setting\SiteSetting; | use App\Entity\Setting\SiteSetting; | ||||
use Lc\SovBundle\Factory\AbstractFactory; | use Lc\SovBundle\Factory\AbstractFactory; | ||||
use Lc\SovBundle\Model\Setting\SiteSettingInterface; | |||||
class SiteSettingFactory extends AbstractFactory | |||||
class SiteSettingFactory extends AbstractFactory implements SiteSettingFactoryInterface | |||||
{ | { | ||||
public function create() | |||||
public function create(): SiteSettingInterface | |||||
{ | { | ||||
$siteSetting = new SiteSetting(); | $siteSetting = new SiteSetting(); | ||||
<?php | |||||
namespace Lc\SovBundle\Factory\Setting; | |||||
interface SiteSettingFactoryInterface | |||||
{ | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Factory\Site; | |||||
use App\Entity\Site\News; | |||||
use Lc\SovBundle\Factory\AbstractFactory; | |||||
use Lc\SovBundle\Model\Site\NewsInterface; | |||||
class NewsFactory extends AbstractFactory implements NewsFactoryInterface | |||||
{ | |||||
public function create(): NewsInterface | |||||
{ | |||||
$news = new News(); | |||||
return $news; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Factory\Site; | |||||
interface NewsFactoryInterface | |||||
{ | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Factory\Site; | |||||
use App\Entity\Site\Page; | |||||
use Lc\SovBundle\Factory\AbstractFactory; | |||||
use Lc\SovBundle\Model\Site\PageInterface; | |||||
class PageFactory extends AbstractFactory implements PageFactoryInterface | |||||
{ | |||||
public function create(): PageInterface | |||||
{ | |||||
$page = new Page(); | |||||
return $page; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Factory\Site; | |||||
interface PageFactoryInterface | |||||
{ | |||||
} |
use App\Entity\Site\Site; | use App\Entity\Site\Site; | ||||
use Lc\SovBundle\Factory\AbstractFactory; | use Lc\SovBundle\Factory\AbstractFactory; | ||||
use Lc\SovBundle\Model\Site\SiteInterface; | |||||
class SiteFactory extends AbstractFactory | |||||
class SiteFactory extends AbstractFactory implements SiteFactoryInterface | |||||
{ | { | ||||
public function create() | |||||
public function create(): SiteInterface | |||||
{ | { | ||||
$site = new Site(); | $site = new Site(); | ||||
<?php | |||||
namespace Lc\SovBundle\Factory\Site; | |||||
interface SiteFactoryInterface | |||||
{ | |||||
} |
use App\Entity\Ticket\Ticket; | use App\Entity\Ticket\Ticket; | ||||
use Lc\SovBundle\Factory\AbstractFactory; | use Lc\SovBundle\Factory\AbstractFactory; | ||||
use Lc\SovBundle\Model\Ticket\TicketInterface; | |||||
class TicketFactory extends AbstractFactory implements TicketFactoryInterface | class TicketFactory extends AbstractFactory implements TicketFactoryInterface | ||||
{ | { | ||||
protected TicketMessageFactory $ticketMessageFactory; | |||||
protected TicketMessageFactoryInterface $ticketMessageFactory; | |||||
public function __construct(TicketMessageFactory $ticketMessageFactory) | |||||
public function __construct(TicketMessageFactoryInterface $ticketMessageFactory) | |||||
{ | { | ||||
$this->ticketMessageFactory = $ticketMessageFactory; | $this->ticketMessageFactory = $ticketMessageFactory; | ||||
} | } | ||||
public function create() | |||||
public function create(): TicketInterface | |||||
{ | { | ||||
$ticket = new Ticket(); | $ticket = new Ticket(); | ||||
use App\Entity\Ticket\TicketMessage; | use App\Entity\Ticket\TicketMessage; | ||||
use Lc\SovBundle\Factory\AbstractFactory; | use Lc\SovBundle\Factory\AbstractFactory; | ||||
use Lc\SovBundle\Model\Ticket\TicketMessageInterface; | |||||
class TicketMessageFactory extends AbstractFactory | |||||
class TicketMessageFactory extends AbstractFactory implements TicketMessageFactoryInterface | |||||
{ | { | ||||
public function create() | |||||
public function create(): TicketMessageInterface | |||||
{ | { | ||||
$ticketMessage = new TicketMessage(); | $ticketMessage = new TicketMessage(); | ||||
<?php | |||||
namespace Lc\SovBundle\Factory\Ticket; | |||||
interface TicketMessageFactoryInterface | |||||
{ | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Factory\User; | |||||
use App\Entity\User\GroupUser; | |||||
use Lc\SovBundle\Factory\AbstractFactory; | |||||
use Lc\SovBundle\Model\User\GroupUserInterface; | |||||
class GroupUserFactory extends AbstractFactory implements GroupUserFactoryInterface | |||||
{ | |||||
public function create(): GroupUserInterface | |||||
{ | |||||
$groupUser = new GroupUser(); | |||||
return $groupUser; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Factory\User; | |||||
interface GroupUserFactoryInterface | |||||
{ | |||||
} |
use App\Entity\User\User; | use App\Entity\User\User; | ||||
use Lc\SovBundle\Factory\AbstractFactory; | use Lc\SovBundle\Factory\AbstractFactory; | ||||
use Lc\SovBundle\Model\User\UserInterface; | |||||
class UserFactory extends AbstractFactory | class UserFactory extends AbstractFactory | ||||
{ | { | ||||
public function create() | |||||
public function create(): UserInterface | |||||
{ | { | ||||
$user = new User(); | $user = new User(); | ||||
<?php | |||||
namespace Lc\SovBundle\Factory\User; | |||||
interface UserFactoryInterface | |||||
{ | |||||
} |
'invalid_message' => $this->translatorAdmin->trans('form.account_password.message.invalid_passwords'), | 'invalid_message' => $this->translatorAdmin->trans('form.account_password.message.invalid_passwords'), | ||||
] | ] | ||||
); | ); | ||||
$builder->add( | |||||
'submit', | |||||
SubmitType::class, | |||||
array( | |||||
'label' => $this->translatorAdmin->transAction('save') | |||||
) | |||||
); | |||||
} | } | ||||
/** | /** |
TextType::class | TextType::class | ||||
); | ); | ||||
} | } | ||||
$builder->add( | |||||
'submit', | |||||
SubmitType::class, | |||||
[ | |||||
'label' => $this->translatorAdmin->transAction('save') | |||||
] | |||||
); | |||||
} | } | ||||
/** | /** |
<?php | |||||
namespace Lc\SovBundle\Maker; | |||||
use Doctrine\Common\Annotations\Annotation; | |||||
use Symfony\Bundle\MakerBundle\ConsoleStyle; | |||||
use Symfony\Bundle\MakerBundle\DependencyBuilder; | |||||
use Symfony\Bundle\MakerBundle\Generator; | |||||
use Symfony\Bundle\MakerBundle\InputConfiguration; | |||||
use Symfony\Bundle\MakerBundle\Maker\AbstractMaker; | |||||
use Symfony\Component\Console\Command\Command; | |||||
use Symfony\Component\Console\Input\InputArgument; | |||||
use Symfony\Component\Console\Input\InputInterface; | |||||
use function Symfony\Component\String\u; | |||||
class FactoryMaker extends AbstractMaker | |||||
{ | |||||
public static function getCommandName(): string | |||||
{ | |||||
return 'make:factory'; | |||||
} | |||||
public static function getCommandDescription(): string | |||||
{ | |||||
return 'Creates a factory'; | |||||
} | |||||
public function configureCommand(Command $command, InputConfiguration $inputConf) | |||||
{ | |||||
$command | |||||
/*->addArgument( | |||||
'factory-class', | |||||
InputArgument::OPTIONAL, | |||||
'Choose a name for your factory (e.g. <fg=yellow>MyEntityFactory</>)' | |||||
)*/ | |||||
->addArgument( | |||||
'namespace', | |||||
InputArgument::OPTIONAL, | |||||
'Namespace (e.g. <fg=yellow>Lc\SovBundle\Factory</>)' | |||||
) | |||||
->addArgument( | |||||
'domain', | |||||
InputArgument::OPTIONAL, | |||||
'Domain (e.g. <fg=yellow>Order</>)' | |||||
) | |||||
->addArgument( | |||||
'entity-class', | |||||
InputArgument::OPTIONAL, | |||||
'Define the entity (e.g. <fg=yellow>MyEntity</>)' | |||||
) | |||||
->setHelp(''); | |||||
} | |||||
public function generate(InputInterface $input, ConsoleStyle $io, Generator $generator) | |||||
{ | |||||
$entityDetails = $generator->createClassNameDetails( | |||||
$input->getArgument('entity-class'), | |||||
'Entity\\', | |||||
'' | |||||
); | |||||
$factoryClass = $input->getArgument('entity-class') . 'Factory'; | |||||
$factoryDetails = $generator->createClassNameDetails( | |||||
$factoryClass, | |||||
'Factory\\', | |||||
'' | |||||
); | |||||
$options = [ | |||||
'namespace_path' => $input->getArgument('namespace'), | |||||
'domain' => $input->getArgument('domain'), | |||||
'entity_class' => $input->getArgument('entity-class'), | |||||
'entity' => $entityDetails->getFullName(), | |||||
'entity_variable' => '$' . u($input->getArgument('entity-class'))->camel() | |||||
]; | |||||
$generator->generateController( | |||||
$factoryDetails->getFullName(), | |||||
__DIR__ . '/../Resources/maker/factory/factory.tpl.php', | |||||
$options | |||||
); | |||||
$interfaceName = $factoryClass . 'Interface'; | |||||
$generator->generateFile( | |||||
$generator->getRootDirectory() . '/src/Factory/' . $interfaceName . '.php', | |||||
__DIR__ . '/../Resources/maker/factory/factory_interface.tpl.php', | |||||
[ | |||||
'namespace_path' => $input->getArgument('namespace'), | |||||
'domain' => $input->getArgument('domain'), | |||||
'interface_name' => $interfaceName, | |||||
] | |||||
); | |||||
$generator->writeChanges(); | |||||
$this->writeSuccessMessage($io); | |||||
$io->text('Next: Open your new factory class and configure it!'); | |||||
} | |||||
public function configureDependencies(DependencyBuilder $dependencies) | |||||
{ | |||||
$dependencies->addClassDependency( | |||||
Annotation::class, | |||||
'doctrine/annotations' | |||||
); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Maker; | |||||
use Doctrine\Common\Annotations\Annotation; | |||||
use Symfony\Bundle\MakerBundle\ConsoleStyle; | |||||
use Symfony\Bundle\MakerBundle\DependencyBuilder; | |||||
use Symfony\Bundle\MakerBundle\Generator; | |||||
use Symfony\Bundle\MakerBundle\InputConfiguration; | |||||
use Symfony\Bundle\MakerBundle\Maker\AbstractMaker; | |||||
use Symfony\Component\Console\Command\Command; | |||||
use Symfony\Component\Console\Input\InputArgument; | |||||
use Symfony\Component\Console\Input\InputInterface; | |||||
use function Symfony\Component\String\u; | |||||
class RepositoryMaker extends AbstractMaker | |||||
{ | |||||
public static function getCommandName(): string | |||||
{ | |||||
return 'make:repository'; | |||||
} | |||||
public static function getCommandDescription(): string | |||||
{ | |||||
return 'Creates a repository, query and store'; | |||||
} | |||||
public function configureCommand(Command $command, InputConfiguration $inputConf) | |||||
{ | |||||
$command | |||||
->addArgument( | |||||
'namespace', | |||||
InputArgument::OPTIONAL, | |||||
'Namespace (e.g. <fg=yellow>Lc\SovBundle\Repository</>)' | |||||
) | |||||
->addArgument( | |||||
'domain', | |||||
InputArgument::OPTIONAL, | |||||
'Domain (e.g. <fg=yellow>Order</>)' | |||||
) | |||||
->addArgument( | |||||
'entity-class', | |||||
InputArgument::OPTIONAL, | |||||
'Define the entity (e.g. <fg=yellow>MyEntity</>)' | |||||
) | |||||
->setHelp(''); | |||||
} | |||||
public function generate(InputInterface $input, ConsoleStyle $io, Generator $generator) | |||||
{ | |||||
$entityDetails = $generator->createClassNameDetails( | |||||
$input->getArgument('entity-class'), | |||||
'Entity\\', | |||||
'' | |||||
); | |||||
$options = [ | |||||
'namespace_path' => $input->getArgument('namespace'), | |||||
'domain' => $input->getArgument('domain'), | |||||
'entity_class' => $input->getArgument('entity-class'), | |||||
'entity' => $entityDetails->getFullName(), | |||||
]; | |||||
// repository | |||||
$repositoryClass = $input->getArgument('entity-class') . 'Repository'; | |||||
$this->generateClass($generator, $repositoryClass, 'Repository\\', 'repository.tpl.php', $options); | |||||
// repository query | |||||
$repositoryQueryClass = $input->getArgument('entity-class') . 'RepositoryQuery'; | |||||
$options['class_name_repository'] = $repositoryClass; | |||||
$this->generateClass($generator, $repositoryQueryClass, 'Repository\\', 'repository_query.tpl.php', $options); | |||||
// store | |||||
$storeClass = $input->getArgument('entity-class') . 'Store'; | |||||
$options['class_name_repository_query'] = $repositoryQueryClass; | |||||
$this->generateClass($generator, $storeClass, 'Repository\\', 'store.tpl.php', $options); | |||||
// interfaces | |||||
$this->generateInterface($input, $generator, $repositoryQueryClass . 'Interface'); | |||||
$this->generateInterface($input, $generator, $storeClass . 'Interface'); | |||||
// write files | |||||
$generator->writeChanges(); | |||||
$this->writeSuccessMessage($io); | |||||
$io->text('Next: Open your new factory class and configure it!'); | |||||
} | |||||
public function generateClass($generator, $class, $namespacePrefix, $tpl, $options) | |||||
{ | |||||
$repositoryDetails = $generator->createClassNameDetails( | |||||
$class, | |||||
$namespacePrefix, | |||||
'' | |||||
); | |||||
$generator->generateController( | |||||
$repositoryDetails->getFullName(), | |||||
__DIR__ . '/../Resources/maker/repository/'.$tpl, | |||||
$options | |||||
); | |||||
} | |||||
public function generateInterface($input, $generator, $interfaceName) | |||||
{ | |||||
$generator->generateFile( | |||||
$generator->getRootDirectory() . '/src/Repository/' . $interfaceName . '.php', | |||||
__DIR__ . '/../Resources/maker/repository/interface.tpl.php', | |||||
[ | |||||
'namespace_path' => $input->getArgument('namespace'), | |||||
'domain' => $input->getArgument('domain'), | |||||
'interface_name' => $interfaceName, | |||||
] | |||||
); | |||||
} | |||||
public function configureDependencies(DependencyBuilder $dependencies) | |||||
{ | |||||
$dependencies->addClassDependency( | |||||
Annotation::class, | |||||
'doctrine/annotations' | |||||
); | |||||
} | |||||
} |
*/ | */ | ||||
protected $content; | protected $content; | ||||
/** | |||||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface", inversedBy="pages") | |||||
* @ORM\JoinColumn(nullable=false) | |||||
*/ | |||||
protected $merchant; | |||||
/** | |||||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface", inversedBy="pages") | |||||
*/ | |||||
protected $section; | |||||
public function __toString() | public function __toString() | ||||
{ | { | ||||
return $this->getTitle(); | return $this->getTitle(); | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getMerchant(): ?MerchantInterface | |||||
{ | |||||
return $this->merchant; | |||||
} | |||||
public function setMerchant(?MerchantInterface $merchant): self | |||||
{ | |||||
$this->merchant = $merchant; | |||||
return $this; | |||||
} | |||||
public function getSection(): ?SectionInterface | |||||
{ | |||||
return $this->section; | |||||
} | |||||
public function setSection(?SectionInterface $section): self | |||||
{ | |||||
$this->section = $section; | |||||
return $this; | |||||
} | |||||
} | } |
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; | ||||
} | } | ||||
} | } |
interface AbstractRepositoryInterface | interface AbstractRepositoryInterface | ||||
{ | { | ||||
/** | |||||
* Retourne la class ou l'interface correspondant à ce repository | |||||
* | |||||
* @return string | |||||
*/ | |||||
public function getInterfaceClass(); | |||||
} | } |
return $data; | return $data; | ||||
} | } | ||||
} | } | ||||
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 | class FileRepository extends AbstractRepository | ||||
{ | { | ||||
public function getInterfaceClass() | |||||
{ | |||||
return FileInterface::class; | |||||
} | |||||
public function __construct(ManagerRegistry $registry) | |||||
{ | |||||
parent::__construct($registry, File::class); | |||||
} | |||||
} | } |
<?php | |||||
namespace Lc\SovBundle\Repository\File; | |||||
use Knp\Component\Pager\PaginatorInterface; | |||||
use Lc\SovBundle\Repository\AbstractRepositoryQuery; | |||||
class FileRepositoryQuery extends AbstractRepositoryQuery implements FileRepositoryQueryInterface | |||||
{ | |||||
public function __construct(FileRepository $repository, PaginatorInterface $paginator) | |||||
{ | |||||
parent::__construct($repository, 'r', $paginator); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Repository\File; | |||||
interface FileRepositoryQueryInterface | |||||
{ | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Repository\File; | |||||
class FileStore implements FileStoreInterface | |||||
{ | |||||
protected FileRepositoryQueryInterface $query; | |||||
public function __construct(FileRepositoryQueryInterface $query) | |||||
{ | |||||
$this->query = $query; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Repository\File; | |||||
interface FileStoreInterface | |||||
{ | |||||
} |
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 | ||||
{ | { | ||||
public function getInterfaceClass() | |||||
public function __construct(ManagerRegistry $registry) | |||||
{ | { | ||||
return NewsletterInterface::class; | |||||
parent::__construct($registry, Newsletter::class); | |||||
} | } | ||||
} | } |
<?php | |||||
namespace Lc\SovBundle\Repository\Newsletter; | |||||
use Knp\Component\Pager\PaginatorInterface; | |||||
use Lc\SovBundle\Repository\AbstractRepositoryQuery; | |||||
class NewsletterRepositoryQuery extends AbstractRepositoryQuery implements NewsletterRepositoryQueryInterface | |||||
{ | |||||
public function __construct(NewsletterRepository $repository, PaginatorInterface $paginator) | |||||
{ | |||||
parent::__construct($repository, 'r', $paginator); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Repository\Newsletter; | |||||
interface NewsletterRepositoryQueryInterface | |||||
{ | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Repository\Newsletter; | |||||
class NewsletterStore implements NewsletterStoreInterface | |||||
{ | |||||
protected NewsletterRepositoryQueryInterface $query; | |||||
public function __construct(NewsletterRepositoryQueryInterface $query) | |||||
{ | |||||
$this->query = $query; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Repository\Newsletter; | |||||
interface NewsletterStoreInterface | |||||
{ | |||||
} |
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 | |||||
{ | { | ||||
public function __construct(ManagerRegistry $registry) | public function __construct(ManagerRegistry $registry) | ||||
{ | { |
<?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(); | |||||
} | |||||
} |
use Knp\Component\Pager\PaginatorInterface; | use Knp\Component\Pager\PaginatorInterface; | ||||
use Lc\SovBundle\Repository\AbstractRepositoryQuery; | use Lc\SovBundle\Repository\AbstractRepositoryQuery; | ||||
class ReminderRepositoryQuery extends AbstractRepositoryQuery | |||||
class ReminderRepositoryQuery extends AbstractRepositoryQuery implements ReminderRepositoryQueryInterface | |||||
{ | { | ||||
public function __construct(ReminderRepository $repository, PaginatorInterface $paginator) | public function __construct(ReminderRepository $repository, PaginatorInterface $paginator) | ||||
{ | { | ||||
parent::__construct($repository, 'r', $paginator); | parent::__construct($repository, 'r', $paginator); | ||||
} | } | ||||
public function filterDone($done = false) | |||||
{ | |||||
return $this | |||||
->andWhere('.done = :done') | |||||
->setParameter(':done', $done); | |||||
} | |||||
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 filterCrudAction($crudAction) | |||||
{ | |||||
if(is_null($crudAction)) { | |||||
return $this | |||||
->andWhere('.crudControllerFqcn IS NULL'); | |||||
} | |||||
else { | |||||
return $this | |||||
->andWhere('.crudAction = :crudAction') | |||||
->setParameter(':crudAction', $crudAction); | |||||
} | |||||
} | |||||
public function filterCrudControllerFqcn($crudControllerFqcn) | |||||
{ | |||||
if(is_null($crudControllerFqcn)) { | |||||
return $this | |||||
->andWhere('.crudControllerFqcn IS NULL'); | |||||
} | |||||
else { | |||||
return $this | |||||
->andWhere('.crudControllerFqcn = :crudControllerFqcn') | |||||
->setParameter(':crudControllerFqcn', $crudControllerFqcn); | |||||
} | |||||
} | |||||
public function filterEntityId($entityId) | |||||
{ | |||||
if(is_null($entityId)) { | |||||
return $this | |||||
->andWhere('.entityId IS NULL'); | |||||
} | |||||
else { | |||||
return $this | |||||
->andWhere('.entityId = :entityId') | |||||
->setParameter(':entityId', $entityId); | |||||
} | |||||
} | |||||
public function orderDefault() | |||||
{ | |||||
return $this | |||||
->orderBy('.dateReminder', 'ASC'); | |||||
} | |||||
} | } |
<?php | |||||
namespace Lc\SovBundle\Repository\Reminder; | |||||
interface ReminderRepositoryQueryInterface | |||||
{ | |||||
} |
namespace Lc\SovBundle\Repository\Reminder; | namespace Lc\SovBundle\Repository\Reminder; | ||||
/** | |||||
* class ReminderStore. | |||||
* | |||||
* @author Simon Vieille <simon@deblan.fr> | |||||
*/ | |||||
class ReminderStore | |||||
class ReminderStore implements ReminderStoreInterface | |||||
{ | { | ||||
protected ReminderRepositoryQuery $query; | |||||
protected ReminderRepositoryQueryInterface $query; | |||||
public function __construct(ReminderRepositoryQuery $query) | |||||
public function __construct(ReminderRepositoryQueryInterface $query) | |||||
{ | { | ||||
$this->query = $query; | $this->query = $query; | ||||
} | } | ||||
public function getFoo($query = null) | |||||
public function get($params = [], $query = null) | |||||
{ | { | ||||
if (!$query) { | |||||
if(is_null($query)) { | |||||
$query = $this->query->create(); | $query = $this->query->create(); | ||||
} | } | ||||
return $query | |||||
->useCustomFilters() | |||||
->andWhere('.description = :description') | |||||
->setParameter(':description', 'ahah') | |||||
->findOne(); | |||||
$query->filterDone(); | |||||
if(array_key_exists('user', $params)) { | |||||
$query->filterUser($params['user']); | |||||
} | |||||
if(array_key_exists('crudAction', $params)) { | |||||
$query->filterCrudAction($params['crudAction']); | |||||
} | |||||
if(array_key_exists('crudControllerFqcn', $params)) { | |||||
$query->filterCrudControllerFqcn($params['crudControllerFqcn']); | |||||
} | |||||
if(array_key_exists('entityId', $params)) { | |||||
$query->filterEntityId($params['entityId']); | |||||
} | |||||
$query->orderDefault(); | |||||
return $query->find(); | |||||
} | |||||
/* | |||||
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(); | |||||
}*/ | |||||
} | } |
<?php | |||||
namespace Lc\SovBundle\Repository\Reminder; | |||||
interface ReminderStoreInterface | |||||
{ | |||||
} |
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 | ||||
{ | { | ||||
public function getInterfaceClass() | |||||
public function __construct(ManagerRegistry $registry) | |||||
{ | { | ||||
return SiteSettingInterface::class; | |||||
parent::__construct($registry, SiteSetting::class); | |||||
} | } | ||||
} | } |
<?php | |||||
namespace Lc\SovBundle\Repository\Setting; | |||||
use Knp\Component\Pager\PaginatorInterface; | |||||
use Lc\SovBundle\Repository\AbstractRepositoryQuery; | |||||
class SiteSettingRepositoryQuery extends AbstractRepositoryQuery implements SiteSettingRepositoryQueryInterface | |||||
{ | |||||
public function __construct(SiteSettingRepository $repository, PaginatorInterface $paginator) | |||||
{ | |||||
parent::__construct($repository, 'r', $paginator); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Repository\Setting; | |||||
interface SiteSettingRepositoryQueryInterface | |||||
{ | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Repository\Setting; | |||||
class SiteSettingStore implements SiteSettingStoreInterface | |||||
{ | |||||
protected SiteSettingRepositoryQueryInterface $query; | |||||
public function __construct(SiteSettingRepositoryQueryInterface $query) | |||||
{ | |||||
$this->query = $query; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Repository\Setting; | |||||
interface SiteSettingStoreInterface | |||||
{ | |||||
} |
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 | ||||
{ | { | ||||
public function getInterfaceClass() | |||||
public function __construct(ManagerRegistry $registry) | |||||
{ | { | ||||
return NewsInterface::class; | |||||
parent::__construct($registry, News::class); | |||||
} | } | ||||
} | } |
<?php | |||||
namespace Lc\SovBundle\Repository\Site; | |||||
use Knp\Component\Pager\PaginatorInterface; | |||||
use Lc\SovBundle\Repository\AbstractRepositoryQuery; | |||||
class NewsRepositoryQuery extends AbstractRepositoryQuery implements NewsRepositoryQueryInterface | |||||
{ | |||||
public function __construct(NewsRepository $repository, PaginatorInterface $paginator) | |||||
{ | |||||
parent::__construct($repository, 'r', $paginator); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Repository\Site; | |||||
interface NewsRepositoryQueryInterface | |||||
{ | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Repository\Site; | |||||
class NewsStore implements NewsStoreInterface | |||||
{ | |||||
protected NewsRepositoryQueryInterface $query; | |||||
public function __construct(NewsRepositoryQueryInterface $query) | |||||
{ | |||||
$this->query = $query; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Repository\Site; | |||||
interface NewsStoreInterface | |||||
{ | |||||
} |
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 | ||||
{ | { | ||||
public function getInterfaceClass() | |||||
public function __construct(ManagerRegistry $registry) | |||||
{ | { | ||||
return PageInterface::class; | |||||
parent::__construct($registry, Page::class); | |||||
} | } | ||||
} | } |
<?php | |||||
namespace Lc\SovBundle\Repository\Site; | |||||
use Knp\Component\Pager\PaginatorInterface; | |||||
use Lc\SovBundle\Repository\AbstractRepositoryQuery; | |||||
class PageRepositoryQuery extends AbstractRepositoryQuery implements PageRepositoryQueryInterface | |||||
{ | |||||
public function __construct(PageRepository $repository, PaginatorInterface $paginator) | |||||
{ | |||||
parent::__construct($repository, 'r', $paginator); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Repository\Site; | |||||
interface PageRepositoryQueryInterface | |||||
{ | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Repository\Site; | |||||
class PageStore implements PageStoreInterface | |||||
{ | |||||
protected PageRepositoryQueryInterface $query; | |||||
public function __construct(PageRepositoryQueryInterface $query) | |||||
{ | |||||
$this->query = $query; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Repository\Site; | |||||
interface PageStoreInterface | |||||
{ | |||||
} |
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 | ||||
{ | { | ||||
public function getInterfaceClass() | |||||
public function __construct(ManagerRegistry $registry) | |||||
{ | { | ||||
return SiteInterface::class; | |||||
parent::__construct($registry, Site::class); | |||||
} | } | ||||
} | } |
<?php | |||||
namespace Lc\SovBundle\Repository\Site; | |||||
use Knp\Component\Pager\PaginatorInterface; | |||||
use Lc\SovBundle\Repository\AbstractRepositoryQuery; | |||||
class SiteRepositoryQuery extends AbstractRepositoryQuery implements SiteRepositoryQueryInterface | |||||
{ | |||||
public function __construct(SiteRepository $repository, PaginatorInterface $paginator) | |||||
{ | |||||
parent::__construct($repository, 'r', $paginator); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Repository\Site; | |||||
interface SiteRepositoryQueryInterface | |||||
{ | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Repository\Site; | |||||
class SiteStore implements SiteStoreInterface | |||||
{ | |||||
protected SiteRepositoryQueryInterface $query; | |||||
public function __construct(SiteRepositoryQueryInterface $query) | |||||
{ | |||||
$this->query = $query; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Repository\Site; | |||||
interface SiteStoreInterface | |||||
{ | |||||
} |
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 | ||||
{ | { | ||||
public function getInterfaceClass() | |||||
public function __construct(ManagerRegistry $registry) | |||||
{ | { | ||||
return TicketMessageInterface::class; | |||||
parent::__construct($registry, TicketMessage::class); | |||||
} | } | ||||
} | } |
<?php | |||||
namespace Lc\SovBundle\Repository\Ticket; | |||||
use Knp\Component\Pager\PaginatorInterface; | |||||
use Lc\SovBundle\Repository\AbstractRepositoryQuery; | |||||
class TicketMessageRepositoryQuery extends AbstractRepositoryQuery implements TicketMessageRepositoryQueryInterface | |||||
{ | |||||
public function __construct(TicketMessageRepository $repository, PaginatorInterface $paginator) | |||||
{ | |||||
parent::__construct($repository, 'r', $paginator); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Repository\Ticket; | |||||
interface TicketMessageRepositoryQueryInterface | |||||
{ | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Repository\Ticket; | |||||
class TicketMessageStore implements TicketMessageStoreInterface | |||||
{ | |||||
protected TicketMessageRepositoryQueryInterface $query; | |||||
public function __construct(TicketMessageRepositoryQueryInterface $query) | |||||
{ | |||||
$this->query = $query; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Repository\Ticket; | |||||
interface TicketMessageStoreInterface | |||||
{ | |||||
} |
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 | ||||
{ | { | ||||
public function getInterfaceClass() | |||||
public function __construct(ManagerRegistry $registry) | |||||
{ | { | ||||
return TicketInterface::class; | |||||
parent::__construct($registry, Ticket::class); | |||||
} | } | ||||
} | } |
<?php | |||||
namespace Lc\SovBundle\Repository\Ticket; | |||||
use Knp\Component\Pager\PaginatorInterface; | |||||
use Lc\SovBundle\Repository\AbstractRepositoryQuery; | |||||
class TicketRepositoryQuery extends AbstractRepositoryQuery implements TicketRepositoryQueryInterface | |||||
{ | |||||
public function __construct(TicketRepository $repository, PaginatorInterface $paginator) | |||||
{ | |||||
parent::__construct($repository, 'r', $paginator); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Repository\Ticket; | |||||
interface TicketRepositoryQueryInterface | |||||
{ | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Repository\Ticket; | |||||
class TicketStore implements TicketStoreInterface | |||||
{ | |||||
protected TicketRepositoryQueryInterface $query; | |||||
public function __construct(TicketRepositoryQueryInterface $query) | |||||
{ | |||||
$this->query = $query; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Repository\Ticket; | |||||
interface TicketStoreInterface | |||||
{ | |||||
} |
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 | ||||
{ | { | ||||
public function getInterfaceClass() | |||||
public function __construct(ManagerRegistry $registry) | |||||
{ | { | ||||
return GroupUserInterface::class; | |||||
parent::__construct($registry, GroupUser::class); | |||||
} | } | ||||
} | } |
<?php | |||||
namespace Lc\SovBundle\Repository\User; | |||||
use Knp\Component\Pager\PaginatorInterface; | |||||
use Lc\SovBundle\Repository\AbstractRepositoryQuery; | |||||
class GroupUserRepositoryQuery extends AbstractRepositoryQuery implements GroupUserRepositoryQueryInterface | |||||
{ | |||||
public function __construct(GroupUserRepository $repository, PaginatorInterface $paginator) | |||||
{ | |||||
parent::__construct($repository, 'r', $paginator); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Repository\User; | |||||
interface GroupUserRepositoryQueryInterface | |||||
{ | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Repository\User; | |||||
class GroupUserStore implements GroupUserStoreInterface | |||||
{ | |||||
protected GroupUserRepositoryQueryInterface $query; | |||||
public function __construct(GroupUserRepositoryQueryInterface $query) | |||||
{ | |||||
$this->query = $query; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Repository\User; | |||||
interface GroupUserStoreInterface | |||||
{ | |||||
} |
namespace Lc\SovBundle\Repository\User; | namespace Lc\SovBundle\Repository\User; | ||||
use Lc\SovBundle\Model\User\UserInterface; | |||||
use App\Entity\User\User; | |||||
use Doctrine\Persistence\ManagerRegistry; | |||||
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 | |||||
{ | { | ||||
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() | |||||
; | |||||
} | |||||
*/ | |||||
} | |||||
} | } |
<?php | |||||
namespace Lc\SovBundle\Repository\User; | |||||
use Knp\Component\Pager\PaginatorInterface; | |||||
use Lc\SovBundle\Repository\AbstractRepositoryQuery; | |||||
class UserRepositoryQuery extends AbstractRepositoryQuery implements UserRepositoryQueryInterface | |||||
{ | |||||
public function __construct(UserRepository $repository, PaginatorInterface $paginator) | |||||
{ | |||||
parent::__construct($repository, 'r', $paginator); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Repository\User; | |||||
interface UserRepositoryQueryInterface | |||||
{ | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Repository\User; | |||||
class UserStore implements UserStoreInterface | |||||
{ | |||||
protected UserRepositoryQueryInterface $query; | |||||
public function __construct(UserRepositoryQueryInterface $query) | |||||
{ | |||||
$this->query = $query; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Repository\User; | |||||
interface UserStoreInterface | |||||
{ | |||||
} |
crudAction: $(this).data('crud-action'), | crudAction: $(this).data('crud-action'), | ||||
crudControllerFqcn: $(this).data('crud-controller-fqcn'), | crudControllerFqcn: $(this).data('crud-controller-fqcn'), | ||||
entityId: $(this).data('entity-id'), | entityId: $(this).data('entity-id'), | ||||
id: $(this).data('id'), | |||||
}, function(html) { | }, function(html) { | ||||
$(selectorModal).remove() ; | $(selectorModal).remove() ; | ||||
$('body').append(html) ; | $('body').append(html) ; | ||||
}); | }); | ||||
return false ; | return false ; | ||||
}) ; | }) ; | ||||
$('.checkbox-reminder').click(function() { | |||||
$.post($(this).data('url'), { | |||||
id: $(this).data('id'), | |||||
done: $(this).is(':checked') | |||||
}, function(data) { | |||||
Notification.add('success', 'Pense-bête mis à jour'); | |||||
}, 'json'); | |||||
}) ; | |||||
} | } |
li { | li { | ||||
div.text { | div.text { | ||||
padding-left: 30px ; | padding-left: 30px ; | ||||
.badge-date { | |||||
margin-left: 0px; | |||||
margin-right: 6px; | |||||
} | |||||
} | } | ||||
} | } | ||||
} | } |
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 |
arguments: ["@.inner"] | arguments: ["@.inner"] | ||||
# EasyCorp\Bundle\EasyAdminBundle\Form\Type\CrudFormType: | # EasyCorp\Bundle\EasyAdminBundle\Form\Type\CrudFormType: | ||||
# class: Lc\SovBundle\Form\Type\CrudFormType | # class: Lc\SovBundle\Form\Type\CrudFormType | ||||
Lc\SovBundle\Maker\: | |||||
resource: '../../Maker/' | |||||
tags: [ 'maker.command' ] |
<?= "<?php\n" ?> | |||||
namespace <?= $namespace_path; ?>\<?= $domain; ?>; | |||||
use App\Entity\<?= $domain; ?>\<?= $entity_class ?>; | |||||
use Lc\SovBundle\Factory\AbstractFactory; | |||||
class <?= $class_name; ?> extends AbstractFactory implements <?= $class_name; ?>Interface | |||||
{ | |||||
public function create(): <?= $entity_class ?>Interface | |||||
{ | |||||
<?= $entity_variable ?> = new <?= $entity_class ?>(); | |||||
return <?= $entity_variable ?>; | |||||
} | |||||
} |
<?= "<?php\n" ?> | |||||
namespace <?= $namespace_path; ?>\<?= $domain; ?>; | |||||
interface <?= $interface_name; ?> | |||||
{ | |||||
} |