class SettingAdminController extends AbstractController | class SettingAdminController extends AbstractController | ||||
{ | { | ||||
protected EntityManagerInterface $entityManager; | |||||
protected TranslatorAdmin $translatorAdmin; | |||||
protected SiteSettingContainer $siteSettingContainer; | |||||
protected SiteContainer $siteContainer; | |||||
public function __construct( | |||||
EntityManagerInterface $entityManager, | |||||
TranslatorAdmin $translatorAdmin, | |||||
SiteSettingContainer $siteSettingContainer, | |||||
SiteContainer $siteContainer | |||||
) { | |||||
$this->entityManager = $entityManager; | |||||
$this->translatorAdmin = $translatorAdmin; | |||||
$this->siteSettingContainer = $siteSettingContainer; | |||||
$this->siteContainer = $siteContainer; | |||||
} | |||||
/** | /** | ||||
* @Route("/admin/setting/site", name="sov_admin_setting_site") | * @Route("/admin/setting/site", name="sov_admin_setting_site") | ||||
*/ | */ | ||||
public function manageGlobal(Request $request) | |||||
public function manageGlobal(Request $request, EntityManagerInterface $entityManager) | |||||
{ | { | ||||
$site = $this->siteContainer->getRepositoryQuery()->getRepository()->findOneByDevAlias('default') ; | |||||
$site = $this->get(SiteContainer::class)->getStore()->getOneByDevAlias('default') ; | |||||
$form = $this->createForm(SiteSettingsFormType::class, $site); | $form = $this->createForm(SiteSettingsFormType::class, $site); | ||||
$form->handleRequest($request); | $form->handleRequest($request); | ||||
if ($form->isSubmitted() && $form->isValid()) { | if ($form->isSubmitted() && $form->isValid()) { | ||||
$this->entityManager->update($site); | |||||
$this->entityManager->flush(); | |||||
$entityManager->update($site); | |||||
$entityManager->flush(); | |||||
$this->addFlash('success', $this->translatorAdmin->transFlashMessage('settings_saved')); | |||||
$this->addFlash('success', $this->get(TranslatorAdmin::class)->transFlashMessage('settings_saved')); | |||||
} | } | ||||
return $this->render( | return $this->render( | ||||
'@LcSov/admin/setting/edit_site.html.twig' , | '@LcSov/admin/setting/edit_site.html.twig' , | ||||
[ | [ | ||||
'setting_definition' => $this->siteSettingContainer->getDefinition(), | |||||
'setting_definition' => $this->get(SiteSettingContainer::class)->getDefinition(), | |||||
'form' => $form->createView() | 'form' => $form->createView() | ||||
] | ] | ||||
); | ); |
<?php | |||||
namespace Lc\SovBundle\Doctrine\Extension; | |||||
use Doctrine\ORM\Mapping as ORM; | |||||
use Gedmo\Mapping\Annotation as Gedmo; | |||||
use Lc\SovBundle\Model\User\UserInterface; | |||||
trait BlameableNullableTrait | |||||
{ | |||||
/** | |||||
* @Gedmo\Blameable(on="create") | |||||
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface") | |||||
* @ORM\JoinColumn(nullable=true) | |||||
*/ | |||||
protected $createdBy; | |||||
/** | |||||
* @Gedmo\Blameable(on="update") | |||||
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface") | |||||
* @ORM\JoinColumn(nullable=true) | |||||
*/ | |||||
protected $updatedBy; | |||||
public function getCreatedBy(): ?UserInterface | |||||
{ | |||||
return $this->createdBy; | |||||
} | |||||
public function setCreatedBy(?UserInterface $createdBy): self | |||||
{ | |||||
$this->createdBy = $createdBy; | |||||
return $this; | |||||
} | |||||
public function getUpdatedBy(): ?UserInterface | |||||
{ | |||||
return $this->updatedBy; | |||||
} | |||||
public function setUpdatedBy(?UserInterface $updatedBy): self | |||||
{ | |||||
$this->updatedBy = $updatedBy; | |||||
return $this; | |||||
} | |||||
} |
namespace Lc\SovBundle\Model\Setting; | namespace Lc\SovBundle\Model\Setting; | ||||
//TODO à déplacer dans un solver | |||||
trait EntitySettingTrait | trait EntitySettingTrait | ||||
{ | { | ||||
public function getSetting($name) | |||||
public function getSetting($name): ?SettingModel | |||||
{ | { | ||||
if ($this->getSettings()) { | if ($this->getSettings()) { | ||||
foreach ($this->getSettings() as $setting) { | foreach ($this->getSettings() as $setting) { | ||||
} | } | ||||
} | } | ||||
return false; | |||||
return null; | |||||
} | } | ||||
public function getSettingValue($name) | |||||
public function getSettingValue($name): ?string | |||||
{ | { | ||||
if ($this->getSettings()) { | if ($this->getSettings()) { | ||||
foreach ($this->getSettings() as $setting) { | foreach ($this->getSettings() as $setting) { | ||||
} | } | ||||
} | } | ||||
return false; | |||||
return null; | |||||
} | } | ||||
} | } |
<?php | |||||
namespace Lc\SovBundle\Model\Setting; | |||||
interface SettingInterface | |||||
{ | |||||
} |
/** | /** | ||||
* @ORM\MappedSuperclass() | * @ORM\MappedSuperclass() | ||||
*/ | */ | ||||
abstract class SettingModel | |||||
abstract class SettingModel implements SettingInterface | |||||
{ | { | ||||
/** | /** | ||||
* @ORM\Column(type="string", length=63) | * @ORM\Column(type="string", length=63) | ||||
*/ | */ | ||||
protected $file; | protected $file; | ||||
public function getValue() | |||||
{ | |||||
if ($this->getText()) { | |||||
return $this->getText(); | |||||
} elseif ($this->getDate()) { | |||||
return $this->getDate(); | |||||
} elseif ($this->getFile()) { | |||||
return $this->getFile(); | |||||
} | |||||
} | |||||
public function getName(): ?string | public function getName(): ?string | ||||
{ | { | ||||
return $this->name; | return $this->name; |
*/ | */ | ||||
abstract class PageModel extends AbstractFullEntity implements PageInterface | abstract class PageModel extends AbstractFullEntity implements PageInterface | ||||
{ | { | ||||
/** | |||||
* @ORM\Column(type="text", nullable=true) | |||||
*/ | |||||
protected $content; | |||||
public function __toString() | public function __toString() | ||||
{ | { | ||||
return $this->getTitle(); | return $this->getTitle(); | ||||
} | } | ||||
public function getContent(): ?string | |||||
{ | |||||
return $this->content; | |||||
} | |||||
public function setContent(?string $content): self | |||||
{ | |||||
$this->content = $content; | |||||
return $this; | |||||
} | |||||
} | } |
use Doctrine\ORM\Mapping as ORM; | use Doctrine\ORM\Mapping as ORM; | ||||
use Gedmo\Mapping\Annotation as Gedmo; | use Gedmo\Mapping\Annotation as Gedmo; | ||||
use Lc\SovBundle\Doctrine\EntityInterface; | use Lc\SovBundle\Doctrine\EntityInterface; | ||||
use Lc\SovBundle\Doctrine\Extension\BlameableNullableTrait; | |||||
use Lc\SovBundle\Doctrine\Extension\StatusInterface; | use Lc\SovBundle\Doctrine\Extension\StatusInterface; | ||||
use Lc\SovBundle\Doctrine\Extension\StatusTrait; | use Lc\SovBundle\Doctrine\Extension\StatusTrait; | ||||
use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity; | use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity; | ||||
abstract class TicketMessageModel extends AbstractLightEntity implements TicketMessageInterface, EntityInterface, StatusInterface | abstract class TicketMessageModel extends AbstractLightEntity implements TicketMessageInterface, EntityInterface, StatusInterface | ||||
{ | { | ||||
use StatusTrait; | use StatusTrait; | ||||
/** | |||||
* @Gedmo\Blameable(on="create") | |||||
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface") | |||||
* @ORM\JoinColumn(nullable=true) | |||||
*/ | |||||
protected $createdBy; | |||||
/** | |||||
* @Gedmo\Blameable(on="update") | |||||
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface") | |||||
* @ORM\JoinColumn(nullable=true) | |||||
*/ | |||||
protected $updatedBy; | |||||
use BlameableNullableTrait; | |||||
/** | /** | ||||
* @ORM\Column(type="text") | * @ORM\Column(type="text") |
use Doctrine\ORM\Mapping as ORM; | use Doctrine\ORM\Mapping as ORM; | ||||
use Gedmo\Mapping\Annotation as Gedmo; | use Gedmo\Mapping\Annotation as Gedmo; | ||||
use Lc\SovBundle\Doctrine\EntityInterface; | use Lc\SovBundle\Doctrine\EntityInterface; | ||||
use Lc\SovBundle\Doctrine\Extension\BlameableNullableTrait; | |||||
use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity; | use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity; | ||||
use Lc\SovBundle\Model\User\UserInterface; | use Lc\SovBundle\Model\User\UserInterface; | ||||
*/ | */ | ||||
abstract class TicketModel extends AbstractLightEntity implements TicketInterface, EntityInterface | abstract class TicketModel extends AbstractLightEntity implements TicketInterface, EntityInterface | ||||
{ | { | ||||
use BlameableNullableTrait; | |||||
const TYPE_TECHNICAL_PROBLEM = 'technical-problem'; | const TYPE_TECHNICAL_PROBLEM = 'technical-problem'; | ||||
const TYPE_GENERAL_QUESTION = 'general-question'; | const TYPE_GENERAL_QUESTION = 'general-question'; | ||||
const TICKET_STATUS_BEING_PROCESSED = 'being-processed'; | const TICKET_STATUS_BEING_PROCESSED = 'being-processed'; | ||||
const TICKET_STATUS_CLOSED = 'closed'; | const TICKET_STATUS_CLOSED = 'closed'; | ||||
public function getTypeChoices(): array | |||||
{ | |||||
return [ | |||||
TicketModel::TYPE_GENERAL_QUESTION, | |||||
TicketModel::TYPE_TECHNICAL_PROBLEM, | |||||
]; | |||||
} | |||||
public function getStatusChoices(): array | |||||
{ | |||||
return [ | |||||
TicketModel::TICKET_STATUS_OPEN, | |||||
TicketModel::TICKET_STATUS_BEING_PROCESSED, | |||||
TicketModel::TICKET_STATUS_CLOSED, | |||||
]; | |||||
} | |||||
public function getTypeLabel(): string | |||||
{ | |||||
return 'entity.Ticket.fields.typeChoices.'.$this->getType(); | |||||
} | |||||
public function getStatusLabel(): string | |||||
{ | |||||
return 'entity.Ticket.statuChoices.'.$this->getStatus(); | |||||
} | |||||
/** | |||||
* @Gedmo\Blameable(on="create") | |||||
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface") | |||||
* @ORM\JoinColumn(nullable=true) | |||||
*/ | |||||
protected $createdBy; | |||||
/** | |||||
* @Gedmo\Blameable(on="update") | |||||
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface") | |||||
* @ORM\JoinColumn(nullable=true) | |||||
*/ | |||||
protected $updatedBy; | |||||
/** | /** | ||||
* @ORM\Column(type="string", length=32) | * @ORM\Column(type="string", length=32) | ||||
*/ | */ | ||||
$this->ticketMessages = new ArrayCollection(); | $this->ticketMessages = new ArrayCollection(); | ||||
} | } | ||||
public function getUsername() | |||||
{ | |||||
if ($this->getUser()) { | |||||
return $this->getUser()->getName(); | |||||
} else { | |||||
return strtoupper($this->getVisitorLastname()).' '.$this->getVisitorFirstname(); | |||||
} | |||||
} | |||||
public function getUserInfosTicket() | |||||
{ | |||||
$user = $this->getUser(); | |||||
if ($user) { | |||||
return '#'.$user->getId().' '.$user->getName().' '.$user->getEmail(); | |||||
} else { | |||||
return strtoupper($this->getVisitorLastname()).' '.$this->getVisitorFirstname().' '.$this->getVisitorEmail( | |||||
); | |||||
} | |||||
} | |||||
public function getEmail() | |||||
{ | |||||
if ($this->getUser()) { | |||||
return $this->getUser()->getEmail(); | |||||
} else { | |||||
return $this->getVisitorEmail(); | |||||
} | |||||
} | |||||
public function getVisitorInfos() | |||||
{ | |||||
return strtoupper($this->getVisitorLastname()).' '.$this->getVisitorFirstname().' ('.$this->getVisitorEmail( | |||||
).')'; | |||||
} | |||||
public function getLastMessage() | |||||
{ | |||||
return $this->getTicketMessages()->last(); | |||||
} | |||||
public function getType(): ?string | public function getType(): ?string | ||||
{ | { | ||||
return $this->type; | return $this->type; |
namespace Lc\SovBundle\Model\User; | namespace Lc\SovBundle\Model\User; | ||||
use Doctrine\Common\Collections\ArrayCollection; | |||||
use Doctrine\Common\Collections\Collection; | use Doctrine\Common\Collections\Collection; | ||||
use Doctrine\ORM\Mapping as ORM; | use Doctrine\ORM\Mapping as ORM; | ||||
use Lc\SovBundle\Doctrine\EntityInterface; | use Lc\SovBundle\Doctrine\EntityInterface; | ||||
use Lc\SovBundle\Model\Newsletter\NewsletterInterface; | use Lc\SovBundle\Model\Newsletter\NewsletterInterface; | ||||
use Lc\SovBundle\Model\Ticket\TicketInterface; | |||||
use Symfony\Component\Security\Core\User\UserInterface; | use Symfony\Component\Security\Core\User\UserInterface; | ||||
/** | /** | ||||
* @ORM\MappedSuperclass() | * @ORM\MappedSuperclass() | ||||
*/ | */ | ||||
abstract class User implements EntityInterface, UserInterface | |||||
abstract class UserModel implements EntityInterface, UserInterface | |||||
{ | { | ||||
/** | /** | ||||
* @ORM\Column(type="string", length=180, unique=true) | * @ORM\Column(type="string", length=180, unique=true) | ||||
*/ | */ | ||||
protected $firstname; | protected $firstname; | ||||
/** | |||||
* @ORM\Column(type="string", length=20, nullable=true) | |||||
*/ | |||||
protected $phone; | |||||
/** | |||||
* @ORM\Column(type="boolean", nullable=true) | |||||
*/ | |||||
protected $gender; | |||||
/** | /** | ||||
* @ORM\Column(type="boolean") | * @ORM\Column(type="boolean") | ||||
*/ | */ | ||||
*/ | */ | ||||
protected $groupUsers; | protected $groupUsers; | ||||
// isUserInGroupVip | |||||
public function isInGroupUserVip() | |||||
{ | |||||
return $this->isInGroupByDevAlias('vip') ; | |||||
} | |||||
/** | |||||
* @ORM\OneToMany(targetEntity="Lc\SovBundle\Model\Ticket\TicketInterface", mappedBy="user") | |||||
*/ | |||||
protected $tickets; | |||||
// isUserInGroup | |||||
public function isInGroupUser(GroupUserInterface $groupUser) | |||||
{ | |||||
return $this->isInGroupByDevAlias($groupUser->getDevAlias()); | |||||
} | |||||
/** | |||||
* @ORM\Column(type="array", nullable=true) | |||||
*/ | |||||
protected $ticketTypesNotification = []; | |||||
// isUserInGroupByDevAlias | |||||
public function isInGroupByDevAlias(string $groupUserDevAlias) | |||||
public function __construct() | |||||
{ | { | ||||
$groupUsers = $this->getGroupUsers(); | |||||
foreach($groupUsers as $groupUser) { | |||||
if($groupUser->getDevAlias() == $groupUserDevAlias) { | |||||
return true; | |||||
} | |||||
} | |||||
return false; | |||||
$this->tickets = new ArrayCollection(); | |||||
} | } | ||||
public function isSubscribedToNewsletter(NewsletterInterface $newsletter) | |||||
public function __toString() | |||||
{ | { | ||||
return $this->getNewsletters()->contains($newsletter); | |||||
return '#' . $this->getId() . ' ' . strtoupper($this->getLastname()) . ' ' . $this->getFirstname( | |||||
) . ' (' . $this->getEmail() . ')'; | |||||
} | } | ||||
public function getEmail(): ?string | public function getEmail(): ?string | ||||
{ | { | ||||
return $this->email; | return $this->email; | ||||
return (string)$this->email; | return (string)$this->email; | ||||
} | } | ||||
public function getGender(): ?bool | |||||
{ | |||||
return $this->gender; | |||||
} | |||||
public function setGender(?bool $gender): self | |||||
{ | |||||
$this->gender = $gender; | |||||
return $this; | |||||
} | |||||
/** | /** | ||||
* @see UserInterface | * @see UserInterface | ||||
*/ | */ | ||||
return $this; | return $this; | ||||
} | } | ||||
/** | |||||
* @return Collection|TicketInterface[] | |||||
*/ | |||||
public function getTickets(): Collection | |||||
{ | |||||
return $this->tickets; | |||||
} | |||||
public function addTicket(TicketInterface $ticket): self | |||||
{ | |||||
if (!$this->tickets->contains($ticket)) { | |||||
$this->tickets[] = $ticket; | |||||
$ticket->setUser($this); | |||||
} | |||||
return $this; | |||||
} | |||||
public function removeTicket(TicketInterface $ticket): self | |||||
{ | |||||
if ($this->tickets->contains($ticket)) { | |||||
$this->tickets->removeElement($ticket); | |||||
// set the owning side to null (unless already changed) | |||||
if ($ticket->getUser() === $this) { | |||||
$ticket->setUser(null); | |||||
} | |||||
} | |||||
return $this; | |||||
} | |||||
public function getTicketTypesNotification(): ?array | |||||
{ | |||||
return $this->ticketTypesNotification; | |||||
} | |||||
public function setTicketTypesNotification(?array $ticketTypesNotification): self | |||||
{ | |||||
$this->ticketTypesNotification = $ticketTypesNotification; | |||||
return $this; | |||||
} | |||||
} | } |
return $this->addOrderBy('.' . $field, $sort); | return $this->addOrderBy('.' . $field, $sort); | ||||
} | } | ||||
} | } | ||||
public function filterById(int $id) | |||||
{ | |||||
return $this | |||||
->andWhere('.id = :id') | |||||
->setParameter('id', $id); | |||||
} | |||||
public function filterByDevAlias(string $devAlias): self | |||||
{ | |||||
return $this | |||||
->andWhere('.devAlias = :devAlias') | |||||
->setParameter('devAlias', $devAlias); | |||||
} | |||||
} | } | ||||
{ | { | ||||
return $this->query; | return $this->query; | ||||
} | } | ||||
public function getOneById(int $id) | |||||
{ | |||||
$query = $this->query->create(); | |||||
$query->filterById($id); | |||||
return $query->findOne(); | |||||
} | |||||
public function getOneByDevAlias(string $devAlias) | |||||
{ | |||||
$query = $this->query->create(); | |||||
$query->filterByDevAlias($devAlias); | |||||
return $query->findOne(); | |||||
} | |||||
} | } |
->andWhere('.ticketTypesNotification LIKE :ticketType') | ->andWhere('.ticketTypesNotification LIKE :ticketType') | ||||
->setParameter('ticketType', '%"' . $ticketType . '"%'); | ->setParameter('ticketType', '%"' . $ticketType . '"%'); | ||||
} | } | ||||
} | |||||
public function filterByEmail(string $email): self | |||||
{ | |||||
return $this | |||||
->andWhere('.email LIKE :email') | |||||
->setParameter('email', $email); | |||||
} | |||||
} |
} | } | ||||
$query | $query | ||||
->filterByNewsletter($newsletter); | |||||
->filterByNewsletter($newsletter); | |||||
return $query->find(); | return $query->find(); | ||||
} | } | ||||
{ | { | ||||
$query = $this->query->create(); | $query = $this->query->create(); | ||||
$query | $query | ||||
->filterByRole($role); | |||||
->filterByRole($role); | |||||
return $query->find(); | return $query->find(); | ||||
} | } | ||||
{ | { | ||||
$query = $this->query->create(); | $query = $this->query->create(); | ||||
$query | $query | ||||
->filterByTicketTypeNotification($ticketType); | |||||
->filterByTicketTypeNotification($ticketType); | |||||
return $query->find(); | return $query->find(); | ||||
} | } | ||||
public function getOneByEmail(string $email) | |||||
{ | |||||
$query = $this->query->create(); | |||||
$query | |||||
->filterByEmail($email); | |||||
return $query->findOne(); | |||||
} | |||||
} | } |
<?php | |||||
namespace Lc\SovBundle\Solver\Setting; | |||||
use Lc\SovBundle\Model\Setting\SettingInterface; | |||||
use Lc\SovBundle\Model\Ticket\TicketInterface; | |||||
use Lc\SovBundle\Model\Ticket\TicketModel; | |||||
class SettingSolver | |||||
{ | |||||
public function getValue(SettingInterface $setting) | |||||
{ | |||||
if ($this->getText()) { | |||||
return $this->getText(); | |||||
} elseif ($this->getDate()) { | |||||
return $this->getDate(); | |||||
} elseif ($this->getFile()) { | |||||
return $this->getFile(); | |||||
} | |||||
} | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Solver\Ticket; | |||||
use Lc\SovBundle\Model\Ticket\TicketInterface; | |||||
use Lc\SovBundle\Model\Ticket\TicketModel; | |||||
class TicketSolver | |||||
{ | |||||
public function getTypeChoices(): array | |||||
{ | |||||
return [ | |||||
TicketModel::TYPE_GENERAL_QUESTION, | |||||
TicketModel::TYPE_TECHNICAL_PROBLEM, | |||||
]; | |||||
} | |||||
public function getStatusChoices(): array | |||||
{ | |||||
return [ | |||||
TicketModel::TICKET_STATUS_OPEN, | |||||
TicketModel::TICKET_STATUS_BEING_PROCESSED, | |||||
TicketModel::TICKET_STATUS_CLOSED, | |||||
]; | |||||
} | |||||
public function getTypeLabel(TicketInterface $ticket): string | |||||
{ | |||||
return 'entity.Ticket.fields.typeChoices.'.$ticket->getType(); | |||||
} | |||||
public function getStatusLabel(TicketInterface $ticket): string | |||||
{ | |||||
return 'entity.Ticket.statuChoices.'.$ticket->getStatus(); | |||||
} | |||||
public function getUsername(TicketInterface $ticket) | |||||
{ | |||||
if ($ticket->getUser()) { | |||||
return $ticket->getUser()->getName(); | |||||
} else { | |||||
return strtoupper($ticket->getVisitorLastname()).' '.$ticket->getVisitorFirstname(); | |||||
} | |||||
} | |||||
public function getUserInfosTicket(TicketInterface $ticket) | |||||
{ | |||||
$user = $ticket->getUser(); | |||||
if ($user) { | |||||
return '#'.$user->getId().' '.$user->getName().' '.$user->getEmail(); | |||||
} else { | |||||
return strtoupper($ticket->getVisitorLastname()).' '.$ticket->getVisitorFirstname().' '.$ticket->getVisitorEmail( | |||||
); | |||||
} | |||||
} | |||||
public function getEmail(TicketInterface $ticket) | |||||
{ | |||||
if ($ticket->getUser()) { | |||||
return $ticket->getUser()->getEmail(); | |||||
} else { | |||||
return $ticket->getVisitorEmail(); | |||||
} | |||||
} | |||||
public function getVisitorInfos(TicketInterface $ticket) | |||||
{ | |||||
return strtoupper($ticket->getVisitorLastname()).' '.$ticket->getVisitorFirstname().' ('.$ticket->getVisitorEmail( | |||||
).')'; | |||||
} | |||||
public function getLastMessage(TicketInterface $ticket) | |||||
{ | |||||
return $ticket->getTicketMessages()->last(); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Solver\User; | |||||
use Lc\SovBundle\Model\Newsletter\NewsletterInterface; | |||||
use Lc\SovBundle\Model\User\GroupUserInterface; | |||||
use Lc\SovBundle\Model\User\UserInterface; | |||||
class UserSolver | |||||
{ | |||||
// @TODO : à écrire si besoin (voir __toString de UserModel) | |||||
public function getSummary(UserInterface $user) | |||||
{ | |||||
} | |||||
public function getName(UserInterface $user): ?string | |||||
{ | |||||
return (string) ucfirst(strtolower($user->getFirstname())) . ' ' . strtoupper($user->getLastname()); | |||||
} | |||||
// isUserInGroupVip | |||||
public function isInGroupUserVip(UserInterface $user) | |||||
{ | |||||
return $this->isInGroupByDevAlias($user, 'vip') ; | |||||
} | |||||
// isUserInGroup | |||||
public function isInGroupUser(UserInterface $user, GroupUserInterface $groupUser) | |||||
{ | |||||
return $this->isInGroupByDevAlias($user, $groupUser->getDevAlias()); | |||||
} | |||||
// isUserInGroupByDevAlias | |||||
public function isInGroupByDevAlias(UserInterface $user, string $groupUserDevAlias) | |||||
{ | |||||
$groupUsers = $user->getGroupUsers(); | |||||
foreach($groupUsers as $groupUser) { | |||||
if($groupUser->getDevAlias() == $groupUserDevAlias) { | |||||
return true; | |||||
} | |||||
} | |||||
return false; | |||||
} | |||||
public function isSubscribedToNewsletter(UserInterface $user, NewsletterInterface $newsletter) | |||||
{ | |||||
return $user->getNewsletters()->contains($newsletter); | |||||
} | |||||
} |