Bläddra i källkod

Merge

develop
Fab 3 år sedan
förälder
incheckning
af8b945a8e
18 ändrade filer med 472 tillägg och 17 borttagningar
  1. +123
    -2
      Builder/Ticket/TicketBuilder.php
  2. +75
    -0
      Builder/Ticket/TicketMessageBuilder.php
  3. +40
    -3
      Builder/User/UserBuilder.php
  4. +2
    -0
      Component/FormComponent.php
  5. +102
    -0
      Container/ComponentContainer.php
  6. +10
    -1
      Container/Ticket/TicketMessageContainer.php
  7. +2
    -1
      Controller/AbstractAdminController.php
  8. +3
    -4
      Doctrine/Extension/BlameableTrait.php
  9. +4
    -3
      EventSubscriber/SortablePropertyEventSubscriber.php
  10. +48
    -0
      Form/Newsletter/NewsletterType.php
  11. +1
    -0
      Model/Site/NewsModel.php
  12. +3
    -0
      Model/User/UserModel.php
  13. +6
    -0
      Repository/Ticket/TicketMessageRepositoryQuery.php
  14. +9
    -1
      Repository/Ticket/TicketMessageStore.php
  15. +1
    -1
      Repository/Ticket/TicketStore.php
  16. +1
    -0
      Repository/User/UserStore.php
  17. +29
    -0
      Twig/SettingTwigExtension.php
  18. +13
    -1
      Twig/TwigExtension.php

+ 123
- 2
Builder/Ticket/TicketBuilder.php Visa fil

@@ -2,18 +2,139 @@

namespace Lc\SovBundle\Builder\Ticket;

use Doctrine\ORM\EntityManagerInterface;
use Lc\CaracoleBundle\Notification\MailMailjetNotification;
use Lc\SovBundle\Component\FormComponent;
use Lc\SovBundle\Factory\Ticket\TicketFactory;
use Lc\SovBundle\Model\Ticket\TicketInterface;
use Lc\SovBundle\Model\Ticket\TicketMessageInterface;
use Lc\SovBundle\Model\Ticket\TicketModel;
use Lc\SovBundle\Repository\User\UserStore;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;

class TicketBuilder
{
protected EntityManagerInterface $entityManager;
protected MailMailjetNotification $mailMailjetNotification;
protected FormComponent $formComponent;
protected ParameterBagInterface $parameterBag;
protected TicketFactory $ticketFactory;
protected AuthorizationCheckerInterface $authorizationChecker;
protected UserStore $userStore;

public function __construct(FormComponent $formComponent, ParameterBagInterface $parameterBag)
{
public function __construct(
EntityManagerInterface $entityManager,
MailMailjetNotification $mailMailjetNotification,
FormComponent $formComponent,
ParameterBagInterface $parameterBag,
AuthorizationCheckerInterface $authorizationChecker,
TicketFactory $ticketFactory,
UserStore $userStore
) {
$this->entityManager = $entityManager;
$this->mailMailjetNotification = $mailMailjetNotification;
$this->formComponent = $formComponent;
$this->parameterBag = $parameterBag;
$this->ticketFactory = $ticketFactory;
$this->userStore = $userStore;
}

public function create(array $params = []): TicketInterface
{
$ticket = $this->ticketFactory->create();

$this->init($ticket, $params);

$user = $ticket->getUser();
if ($ticket->getUser()) {
$email = $user->getEmail();
$firstname = $user->getFirstname();
} else {
$email = $params['visitorEmail'];
$firstname = $params['visitorFirstname'];
}

if (isset($params['createByAdmin']) && $params['createByAdmin']) {
// envoi email au client
$this->mailMailjetNotification->send(
[
MailMailjetNotification::SUBJECT => 'Vous avez reçu un nouveau message',
MailMailjetNotification::TO_EMAIL => $email,
MailMailjetNotification::CONTENT_TEMPLATE => 'mail/ticket-new-by-admin',
MailMailjetNotification::CONTENT_DATA => [
'firstname' => $firstname,
'ticket' => $ticket,
],
]
);
} else {
$this->mailMailjetNotification->send(
[
MailMailjetNotification::SUBJECT => 'Nouvelle demande',
MailMailjetNotification::TO_EMAIL => $email,
MailMailjetNotification::CONTENT_TEMPLATE => 'mail/ticket-new',
MailMailjetNotification::CONTENT_DATA => [
'firstname' => $firstname,
'ticket' => $ticket,
],
]
);
}

$this->entityManager->persist($ticket);
$this->entityManager->flush();

// notifyAdmin
$usersToNotify = $this->userStore->getByTicketTypesNotification($ticket->getType());

foreach ($usersToNotify as $userToNotify) {
if ($this->authorizationChecker->isGranted('ROLE_ADMIN', $userToNotify)) {
$this->mailMailjetNotification->send(
[
MailMailjetNotification::SUBJECT => 'Nouveau ticket sur Place du Local',
MailMailjetNotification::TO_EMAIL => $userToNotify->getEmail(),
MailMailjetNotification::CONTENT_TEMPLATE => 'mail/ticket-notification',
MailMailjetNotification::CONTENT_DATA => [
'firstname' => $userToNotify->getFirstname(),
'ticket' => $ticket,
'ticketMessage' => $ticket->getTicketMessage(),
],
]
);
}
}

return $ticket;
}

public function init(TicketInterface $ticket, array $params = []): void
{
if (isset($params['user'])) {
$ticket->setUser($params['user']);
} else {
$ticket->setVisitorFirstname($params['visitorFirstname']);
$ticket->setVisitorLastname($params['visitorLastname']);
$ticket->setVisitorEmail($params['visitorEmail']);
$ticket->setVisitorToken(uniqid());
}

$ticket
->setStatus(TicketModel::TICKET_STATUS_OPEN)
->setType($params['type'])
->setSubject($params['subject']);

$ticketMessage = $ticket->getTicketMessage();
$ticketMessage->setStatus(1);
$ticketMessage->setMessage($params['message']);

if (isset($params['imageFilename']) && $params['imageFilename']) {
$ticketMessage->setImageFilename($params['imageFilename']);
}

if (isset($params['createByAdmin']) && $params['createByAdmin']) {
$ticketMessage->setAnswerByAdmin(true);
}
}

// uploadImageTicketMessage

+ 75
- 0
Builder/Ticket/TicketMessageBuilder.php Visa fil

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

namespace Lc\SovBundle\Builder\Ticket;

use Doctrine\ORM\EntityManagerInterface;
use Lc\CaracoleBundle\Notification\MailMailjetNotification;
use Lc\SovBundle\Component\FormComponent;
use Lc\SovBundle\Factory\Ticket\TicketFactory;
use Lc\SovBundle\Factory\Ticket\TicketMessageFactory;
use Lc\SovBundle\Model\Ticket\TicketInterface;
use Lc\SovBundle\Model\Ticket\TicketMessageInterface;
use Lc\SovBundle\Model\Ticket\TicketModel;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;

class TicketMessageBuilder
{
protected EntityManagerInterface $entityManager;
protected MailMailjetNotification $mailMailjetNotification;
protected TicketMessageFactory $ticketMessageFactory;

public function __construct(
EntityManagerInterface $entityManager,
MailMailjetNotification $mailMailjetNotification,
TicketMessageFactory $ticketMessageFactory
) {
$this->entityManager = $entityManager;
$this->mailMailjetNotification = $mailMailjetNotification;
$this->ticketMessageFactory = $ticketMessageFactory;
}

public function create(array $params = []): TicketMessageInterface
{
$ticket = $params['ticket'];
$ticketMessage = $this->ticketMessageFactory->create($ticket);

$ticketMessage->setStatus(1);
$ticketMessage->setTicket($ticket);
$ticketMessage->setMessage($params['message']);

if (isset($params['answerByAdmin']) && $params['answerByAdmin']) {
$ticketMessage->setAnswerByAdmin($params['answerByAdmin']);

// envoi email au client
$this->mailMailjetNotification->send(
[
MailMailjetNotification::SUBJECT => 'Réponse à votre demande',
MailMailjetNotification::TO_EMAIL => $ticket->getUser() ? $ticket->getUser()->getEmail(
) : $ticket->getVisitorEmail(),
MailMailjetNotification::CONTENT_TEMPLATE => 'mail/ticket-response',
MailMailjetNotification::CONTENT_DATA => [
'firstname' => $ticket->getUser() ? $ticket->getUser()->getFirstname(
) : $ticket->getVisitorFirstname(),
'ticket' => $ticket,
],
]
);
}
$this->entityManager->persist($ticketMessage);

if (isset($params['imageFilename']) && $params['imageFilename']) {
$ticketMessage->setImageFilename($params['imageFilename']);
}
if (isset($params['closeTicket']) && $params['closeTicket']) {
$ticket->setStatus(TicketModel::TICKET_STATUS_CLOSED);
}

$ticket->setUpdatedAt(new \DateTime());

$this->entityManager->persist($ticket);
$this->entityManager->flush();

return $ticketMessage;
}

}

+ 40
- 3
Builder/User/UserBuilder.php Visa fil

@@ -3,16 +3,23 @@
namespace Lc\SovBundle\Builder\User;

use Doctrine\ORM\EntityManagerInterface;
use Lc\SovBundle\Doctrine\EntityInterface;
use Lc\SovBundle\Doctrine\Extension\BlameableInterface;
use Lc\SovBundle\Model\Newsletter\NewsletterInterface;
use Lc\SovBundle\Model\User\UserInterface;
use Lc\SovBundle\Repository\User\UserStore;
use Lc\SovBundle\Solver\User\UserSolver;

class UserBuilder
{
protected EntityManagerInterface $entityManager;

public function __construct(EntityManagerInterface $entityManager)
protected UserStore $userStore;
protected UserSolver $userSolver;
public function __construct(EntityManagerInterface $entityManager, UserStore $userStore, UserSolver $userSolver)
{
$this->entityManager = $entityManager;
$this->userStore = $userStore;
$this->userSolver = $userSolver;
}

public function setNewsletter(UserInterface $user, NewsletterInterface $newsletter, bool $subscribeNewsletter): void
@@ -22,8 +29,38 @@ class UserBuilder
} else {
$user->removeNewsletter($newsletter);
}
$this->entityManager->persist($user);
$this->entityManager->flush();
}

public function initBlameableSystem(EntityInterface $entity)
{
$userSystem = $this->userStore->getOneByDevAlias('system');
$this->initBlameable($entity, $userSystem);

return $entity;
}
public function initBlameableUpdatedSystem(EntityInterface $entity)
{
$userSystem = $this->userStore->getOneByDevAlias('system');
$this->initBlameableUpdated($entity, $userSystem);

return $entity;
}

public function initBlameable(EntityInterface $entity, UserInterface $user)
{
if ($entity instanceof BlameableInterface) {
$entity->setCreatedBy($user);
}
$this->initBlameableUpdated($entity, $user);
}

public function initBlameableUpdated(EntityInterface $entity, UserInterface $user)
{
if ($entity instanceof BlameableInterface) {
$entity->setUpdatedBy($user);
}
}
}

+ 2
- 0
Component/FormComponent.php Visa fil

@@ -6,6 +6,8 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\HttpFoundation\File\Exception\FileException;
use Symfony\Component\Validator\Constraints\EqualTo;
use Symfony\Component\Validator\Constraints\NotNull;

class FormComponent
{

+ 102
- 0
Container/ComponentContainer.php Visa fil

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

namespace Lc\SovBundle\Container;

use Lc\SovBundle\Component\CitiesComponent;
use Lc\SovBundle\Component\CookieComponent;
use Lc\SovBundle\Component\DateComponent;
use Lc\SovBundle\Component\EntityComponent;
use Lc\SovBundle\Component\FileComponent;
use Lc\SovBundle\Component\FormComponent;
use Lc\SovBundle\Component\MetaComponent;
use Lc\SovBundle\Component\NumberComponent;
use Lc\SovBundle\Component\PointLocationComponent;
use Lc\SovBundle\Component\StringComponent;

class ComponentContainer
{
protected CitiesComponent $citiesComponent;
protected CookieComponent $cookieComponent;
protected DateComponent $dateComponent;
protected EntityComponent $entityComponent;
protected FileComponent $fileComponent;
protected FormComponent $formComponent;
protected MetaComponent $metaComponent;
protected NumberComponent $numberComponent;
protected PointLocationComponent $pointLocationComponent;
protected StringComponent $stringComponent;

public function __construct(
CitiesComponent $citiesComponent,
CookieComponent $cookieComponent,
DateComponent $dateComponent,
EntityComponent $entityComponent,
FileComponent $fileComponent,
FormComponent $formComponent,
MetaComponent $metaComponent,
NumberComponent $numberComponent,
PointLocationComponent $pointLocationComponent,
StringComponent $stringComponent
) {
$this->citiesComponent = $citiesComponent;
$this->cookieComponent = $cookieComponent;
$this->dateComponent = $dateComponent;
$this->entityComponent = $entityComponent;
$this->fileComponent = $fileComponent;
$this->formComponent = $formComponent;
$this->metaComponent = $metaComponent;
$this->numberComponent = $numberComponent;
$this->pointLocationComponent = $pointLocationComponent;
$this->stringComponent = $stringComponent;
}

public function getCitiesComponent(): CitiesComponent
{
return $this->citiesComponent;
}

public function getCookieComponent(): CookieComponent
{
return $this->cookieComponent;
}

public function getDateComponent(): DateComponent
{
return $this->dateComponent;
}

public function getEntityComponent(): EntityComponent
{
return $this->entityComponent;
}

public function getFileComponent(): FileComponent
{
return $this->fileComponent;
}

public function getFormComponent(): FormComponent
{
return $this->formComponent;
}

public function getMetaComponent(): MetaComponent
{
return $this->metaComponent;
}

public function getNumberComponent(): NumberComponent
{
return $this->numberComponent;
}

public function getPointLocationComponent(): PointLocationComponent
{
return $this->pointLocationComponent;
}

public function getStringComponent(): StringComponent
{
return $this->stringComponent;
}
}

+ 10
- 1
Container/Ticket/TicketMessageContainer.php Visa fil

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

namespace Lc\SovBundle\Container\Ticket;

use Lc\SovBundle\Builder\Ticket\TicketMessageBuilder;
use Lc\SovBundle\Factory\Ticket\TicketMessageFactory;
use Lc\SovBundle\Repository\Ticket\TicketMessageRepositoryQuery;
use Lc\SovBundle\Repository\Ticket\TicketMessageStore;
@@ -11,15 +12,18 @@ class TicketMessageContainer
protected TicketMessageFactory $factory;
protected TicketMessageRepositoryQuery $repositoryQuery;
protected TicketMessageStore $store;
protected TicketMessageBuilder $builder;

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

public function getFactory(): TicketMessageFactory
@@ -36,4 +40,9 @@ class TicketMessageContainer
{
return $this->store;
}

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

+ 2
- 1
Controller/AbstractAdminController.php Visa fil

@@ -37,6 +37,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider;
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator;
use EasyCorp\Bundle\EasyAdminBundle\Security\Permission;
use Lc\SovBundle\Component\EntityComponent;
use Lc\SovBundle\Container\ComponentContainer;
use Lc\SovBundle\Container\File\FileContainer;
use Lc\SovBundle\Container\Newsletter\NewsletterContainer;
use Lc\SovBundle\Container\Reminder\ReminderContainer;
@@ -84,6 +85,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController
RequestStack::class => RequestStack::class,
EntityManagerInterface::class => EntityManagerInterface::class,
FilterManager::class => FilterManager::class,
ComponentContainer::class => ComponentContainer::class,
FileContainer::class => FileContainer::class,
NewsletterContainer::class => NewsletterContainer::class,
ReminderContainer::class => ReminderContainer::class,
@@ -95,7 +97,6 @@ abstract class AbstractAdminController extends EaAbstractCrudController
GroupUserContainer::class => GroupUserContainer::class,
UserContainer::class => UserContainer::class,
SiteSettingContainer::class => SiteSettingContainer::class,

]
);
}

+ 3
- 4
Doctrine/Extension/BlameableTrait.php Visa fil

@@ -12,14 +12,14 @@ trait BlameableTrait
/**
* @Gedmo\Blameable(on="create")
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface")
* @ORM\JoinColumn(nullable=false)
* @ORM\JoinColumn(nullable=true)
*/
protected $createdBy;

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

@@ -47,5 +47,4 @@ trait BlameableTrait

return $this;
}

}
}

+ 4
- 3
EventSubscriber/SortablePropertyEventSubscriber.php Visa fil

@@ -41,14 +41,15 @@ class SortablePropertyEventSubscriber implements EventSubscriberInterface

private function setSortableProperty(EntityInterface $entity, AbstractRepositoryInterface $entityRepository)
{
$countParam = array();
if ($entity instanceof StatusInterface) {
$countParam['status'] = 1;
}

if ($entity instanceof TreeInterface) {
if($entity->getParent()){
if ($entity->getParent()) {
$countParam['parent'] = $entity->getParent()->getId();
}else{
} else {
$countParam['parent'] = null;
}
}
@@ -59,4 +60,4 @@ class SortablePropertyEventSubscriber implements EventSubscriberInterface
}


}
}

+ 48
- 0
Form/Newsletter/NewsletterType.php Visa fil

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

namespace Lc\SovBundle\Form\Newsletter;

use Lc\SovBundle\Component\FormComponent;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\Email;
use Symfony\Component\Validator\Constraints\NotNull;

class NewsletterType extends AbstractType
{
protected FormComponent $formComponent;

public function __construct(FormComponent $formComponent)
{
$this->formComponent = $formComponent;
}

public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add(
'email',
EmailType::class,
[
'label' => 'Renseignez votre adresse email :',
'constraints' => [
new Email(),
new NotNull()
]
]
);

// captcha
$this->formComponent->addCaptchaType($builder);
}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(
[

]
);
}
}

+ 1
- 0
Model/Site/NewsModel.php Visa fil

@@ -18,6 +18,7 @@ abstract class NewsModel extends AbstractFullEntity implements NewsInterface, Op

use OpenGraphTrait;


/**
* @ORM\Column(type="datetime")
* @Gedmo\Timestampable(on="create")

+ 3
- 0
Model/User/UserModel.php Visa fil

@@ -8,6 +8,7 @@ use Doctrine\ORM\Mapping as ORM;
use Lc\SovBundle\Doctrine\EntityInterface;
use Lc\SovBundle\Doctrine\Extension\DevAliasInterface;
use Lc\SovBundle\Doctrine\Extension\DevAliasTrait;
use Lc\SovBundle\Doctrine\Extension\TimestampableTrait;
use Lc\SovBundle\Model\Newsletter\NewsletterInterface;
use Lc\SovBundle\Model\Ticket\TicketInterface;
use Symfony\Component\Security\Core\User\UserInterface;
@@ -18,6 +19,8 @@ use Symfony\Component\Security\Core\User\UserInterface;
abstract class UserModel implements EntityInterface, UserInterface, DevAliasInterface
{
use DevAliasTrait;
use TimestampableTrait;

/**
* @ORM\Column(type="string", length=180, unique=true)
*/

+ 6
- 0
Repository/Ticket/TicketMessageRepositoryQuery.php Visa fil

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

use Knp\Component\Pager\PaginatorInterface;
use Lc\SovBundle\Model\Ticket\TicketInterface;
use Lc\SovBundle\Repository\AbstractRepositoryQuery;

class TicketMessageRepositoryQuery extends AbstractRepositoryQuery implements TicketMessageRepositoryQueryInterface
@@ -11,4 +12,9 @@ class TicketMessageRepositoryQuery extends AbstractRepositoryQuery implements Ti
{
parent::__construct($repository, 'r', $paginator);
}

public function filterByTicket(TicketInterface $ticket)
{
return $this->andWhereEqual('ticket', $ticket);
}
}

+ 9
- 1
Repository/Ticket/TicketMessageStore.php Visa fil

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

namespace Lc\SovBundle\Repository\Ticket;

use Lc\SovBundle\Model\Ticket\TicketInterface;
use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

@@ -15,7 +16,7 @@ class TicketMessageStore extends AbstractStore implements TicketMessageStoreInte
}
public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->orderBy('createdAt', 'ASC');
return $query;
}

@@ -29,4 +30,11 @@ class TicketMessageStore extends AbstractStore implements TicketMessageStoreInte
{
return $query;
}

public function getByTicket(TicketInterface $ticket, $query = null)
{
$query = $this->createDefaultQuery($query);
$query->filterByTicket($ticket);
return $query->find();
}
}

+ 1
- 1
Repository/Ticket/TicketStore.php Visa fil

@@ -20,7 +20,7 @@ class TicketStore extends AbstractStore implements TicketStoreInterface

public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->orderBy('id');
$query->orderBy('updatedAt', 'DESC');
return $query;
}


+ 1
- 0
Repository/User/UserStore.php Visa fil

@@ -61,4 +61,5 @@ class UserStore extends AbstractStore implements UserStoreInterface
$query->filterByEmail($email);
return $query->findOne();
}

}

+ 29
- 0
Twig/SettingTwigExtension.php Visa fil

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

namespace Lc\SovBundle\Twig;

use Lc\SovBundle\Solver\Setting\SettingSolver;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;

class SettingTwigExtension extends AbstractExtension
{
protected SettingSolver $settingSolver;

public function __construct(SettingSolver $settingSolver)
{
$this->settingSolver = $settingSolver;
}

public function getFunctions()
{
return array(
new TwigFunction('sov_setting', [$this, 'getSettingValue']),
);
}

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

+ 13
- 1
Twig/TwigExtension.php Visa fil

@@ -4,10 +4,12 @@ namespace Lc\SovBundle\Twig;

use App\Repository\ReminderRepository;
use Doctrine\ORM\EntityManagerInterface;
use Lc\SovBundle\Form\Newsletter\NewsletterType;
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\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
@@ -29,6 +31,7 @@ class TwigExtension extends AbstractExtension
protected $translatorAdmin;
protected $reminderStore;
protected $security;
protected FormFactoryInterface $formFactory;

public function __construct(
KernelInterface $kernel,
@@ -40,7 +43,8 @@ class TwigExtension extends AbstractExtension
TranslatorInterface $translator,
TranslatorAdmin $translatorAdmin,
ReminderStore $reminderStore,
Security $security
Security $security,
FormFactoryInterface $formFactory
) {
$this->kernel = $kernel;
$this->parameterBag = $parameterBag;
@@ -52,6 +56,7 @@ class TwigExtension extends AbstractExtension
$this->translatorAdmin = $translatorAdmin;
$this->reminderStore = $reminderStore;
$this->security = $security;
$this->formFactory = $formFactory;
}

public function getFunctions()
@@ -63,6 +68,7 @@ class TwigExtension extends AbstractExtension
new TwigFunction('sov_homepage_route', [$this, 'getHomepageRoute']),
new TwigFunction('lc_format_price', [$this, 'formatPrice']),
new TwigFunction('die', [$this, 'die']),
new TwigFunction('get_form_newsletter', [$this, 'getFormNewsletter']),
];
}

@@ -140,4 +146,10 @@ class TwigExtension extends AbstractExtension
return $this->parameterBag->get($name);
}

public function getFormNewsletter()
{
$form = $this->formFactory->create(NewsletterType::class);
return $form->createView();
}

}

Laddar…
Avbryt
Spara