<?php
namespace App\Entity;
use App\Config\RightConfig;
use App\Repository\UserRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use JsonSerializable;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* @ORM\Entity(repositoryClass=UserRepository::class)
* @ORM\Table(name="`users`")
* @UniqueEntity(fields={"username"}, message="There is already an account with this username")
* @UniqueEntity(fields={"messengerCode"}, message="This Messenger code is already used")
* @method string getUserIdentifier()
*/
class User implements UserInterface, JsonSerializable
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=180)
*/
private $username;
/**
* @ORM\Column(type="json")
*/
private $roles = [];
/**
* @var string The hashed password
* @ORM\Column(type="string", nullable=true)
*/
private $password;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $civility;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $firstName;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $email;
/**
* @ORM\Column(type="date", nullable=true)
*/
private ?\DateTimeInterface $birthDate = null;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $description;
/**
* @ORM\Column(type="text", nullable=true)
*/
private ?string $clientSearchNote = null;
/**
* @ORM\Column(type="string", length=20, nullable=true)
*/
private $phone;
/**
* @ORM\Column(type="string", length=30, nullable=true)
*/
private $second_phone;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $adress;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
private $country;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
private $region;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $city;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $zip;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $type;
/**
* @ORM\Column(type="boolean")
*/
private $isVerified = false;
/**
* @ORM\OneToMany(targetEntity=Link::class, mappedBy="user", cascade={"persist", "remove"}, orphanRemoval=true)
*/
private $links;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @ORM\Column(type="boolean", options={"default": false})
*/
private $isBlocked = false;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $blockedAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $unblockedAt;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $blockReason;
/**
* @ORM\Column(type="json", nullable=true)
*
* Exemple de structure :
* {
* "monday": [{"start": "09:00", "end": "12:00"}, {"start": "14:00", "end": "16:00"}],
* "tuesday": [],
* "wednesday": [{"start": "10:00", "end": "15:00"}],
* ...
* }
*/
private $blockedHours = [];
/**
* @ORM\OneToMany(targetEntity=Document::class, mappedBy="client")
*/
private $documents;
/**
* @ORM\OneToMany(targetEntity=Document::class, mappedBy="user")
*/
private $userDocuments;
/**
* @ORM\OneToMany(targetEntity=Address::class, mappedBy="user")
*/
private $multiAddress;
/**
* @ORM\OneToMany(targetEntity=Comment::class, mappedBy="user")
*/
private $comments;
/**
* @ORM\OneToMany(targetEntity=Comment::class, mappedBy="client")
*/
private $notes;
/**
* @ORM\ManyToOne(targetEntity=Supplier::class, inversedBy="contacts")
*/
private $supplier;
/**
* @ORM\OneToMany(targetEntity=Contact::class, mappedBy="linkedClient")
*/
private $contacts;
/**
* @ORM\ManyToOne(targetEntity=Promotion::class, inversedBy="clients")
*/
private $promotion;
/**
* @ORM\OneToMany(targetEntity=Activity::class, mappedBy="currentUser")
* @ORM\OrderBy({"createdAt" = "DESC"})
*/
private $activities;
/**
* @ORM\ManyToMany(targetEntity=Produit::class, mappedBy="users")
*/
private $produits;
/**
* @ORM\ManyToOne(targetEntity=GroupUser::class, inversedBy="users")
* @ORM\JoinColumn(nullable=true)
*/
private $groupUser;
/**
* @ORM\ManyToMany(targetEntity=GroupUser::class, inversedBy="usersMultiGroups")
* @ORM\JoinTable(name="user_user_group",
* joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="CASCADE")},
* inverseJoinColumns={@ORM\JoinColumn(name="group_user_id", referencedColumnName="id", onDelete="CASCADE")}
* )
*/
private $groupUsers;
/**
* @ORM\ManyToOne(targetEntity=UserPost::class)
* @ORM\JoinColumn(name="user_post_id", referencedColumnName="id", nullable=true, onDelete="SET NULL")
*/
private $userPost;
/**
* @ORM\ManyToOne(targetEntity=ClientType::class)
* @ORM\JoinColumn(name="client_type_id", referencedColumnName="id", nullable=true, onDelete="SET NULL")
*/
private $clientType;
/**
* @ORM\Column(type="boolean")
*/
private $clientTypeLocked = false;
/**
* @ORM\Column(type="boolean", options={"default": true})
*/
private $internalMessengerSoundEnabled = true;
/**
* @ORM\Column(type="boolean", options={"default": false})
*/
private $internalMessengerBrowserNotificationsEnabled = false;
/**
* @ORM\Column(type="string", length=10, nullable=true, unique=true)
*/
private ?string $messengerCode = null;
/**
* @ORM\ManyToMany(targetEntity=Warehouse::class, inversedBy="users")
* @ORM\JoinTable(name="user_warehouse")
*/
private Collection $warehouses;
public function __construct()
{
$this->links = new ArrayCollection();
$this->documents = new ArrayCollection();
$this->userDocuments = new ArrayCollection();
$this->contacts = new ArrayCollection();
$this->multiAddress = new ArrayCollection();
$this->comments = new ArrayCollection();
$this->notes = new ArrayCollection();
$this->activities = new ArrayCollection();
$this->produits = new ArrayCollection();
$this->groupUsers = new ArrayCollection();
$this->warehouses = new ArrayCollection();
$this->zip="";
}
public function getId(): ?int
{
return $this->id;
}
public function getUsername(): ?string
{
return $this->username;
}
public function setUsername(string $username): self
{
$this->username = $username;
return $this;
}
/**
* @see UserInterface
*/
public function getRoles(): array
{
$roles = $this->roles;
// guarantee every user at least has ROLE_USER
$roles[] = 'ROLE_USER';
return array_unique($roles);
}
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
/**
* @see UserInterface
*/
public function getPassword(): string
{
return (string) $this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
/**
* Returning a salt is only needed, if you are not using a modern
* hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
*
* @see UserInterface
*/
public function getSalt(): ?string
{
return null;
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
public function getCivility(): ?string
{
return $this->civility;
}
public function setCivility(string $civility): self
{
$this->civility = $civility;
return $this;
}
public function getFirstName(): ?string
{
return $this->firstName;
}
public function setFirstName(?string $firstName): self
{
$this->firstName = $firstName;
return $this;
}
public function getFullName(): ?string
{
return $this->firstName;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): self
{
$this->email = $email;
return $this;
}
public function getBirthDate(): ?\DateTimeInterface
{
return $this->birthDate;
}
public function setBirthDate(?\DateTimeInterface $birthDate): self
{
$this->birthDate = $birthDate;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(string $description): self
{
$this->description = $description;
return $this;
}
public function getClientSearchNote(): ?string
{
return $this->clientSearchNote;
}
public function setClientSearchNote(?string $clientSearchNote): self
{
$clientSearchNote = trim((string) $clientSearchNote);
$this->clientSearchNote = $clientSearchNote !== '' ? $clientSearchNote : null;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(string $phone): self
{
$this->phone = $phone;
return $this;
}
public function getSecondPhone(): ?string
{
return $this->second_phone;
}
public function setSecondPhone(?string $second_phone): self
{
$this->second_phone = $second_phone;
return $this;
}
public function getAdress(): ?string
{
return $this->adress;
}
public function setAdress(?string $adress): self
{
$this->adress = $adress ?? '';
return $this;
}
public function getCountry(): ?string
{
return $this->country;
}
public function setCountry(string $country): self
{
$this->country = $country;
return $this;
}
public function getRegion(): ?string
{
return $this->region;
}
public function setRegion(?string $region): self
{
$this->region = $region ?? '';
return $this;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(?string $city): self
{
$this->city = $city ?? '';
return $this;
}
public function getZip(): ?string
{
return $this->zip;
}
public function setZip(?string $zip): self
{
$this->zip = $zip ?? '';
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(string $type): self
{
$this->type = $type;
return $this;
}
public function isVerified(): bool
{
return $this->isVerified;
}
public function setIsVerified(bool $isVerified): self
{
$this->isVerified = $isVerified;
return $this;
}
/**
* @return Collection|Link[]
*/
public function getLinks(): Collection
{
return $this->links;
}
public function addLink(Link $link): self
{
if( !$this->links->contains($link)) {
$this->links[] = $link;
$link->setUser($this);
}
return $this;
}
public function removeLink(Link $link): self
{
if( $this->links->removeElement($link)) {
// set the owning side to null (unless already changed)
if( $link->getUser() === $this) {
$link->setUser(null);
}
}
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getBlockedHours(): ?array
{
return $this->blockedHours;
}
public function setBlockedHours(?array $blockedHours): self
{
$this->blockedHours = $blockedHours;
return $this;
}
public function isBlocked(): bool
{
return (bool) $this->isBlocked || $this->isBlockedAt();
}
public function isAutoBlocked(): bool
{
return $this->isBlacklisted === true;
}
public function isManuallyBlocked(): bool
{
return $this->isBlocked === true;
}
public function canCreateCommande(): bool
{
return !$this->isManuallyBlocked();
}
// Nouvelle méthode avec tes paramètres (nom différent)
public function isBlockedAt( ?\DateTimeInterface $now = null,?\DateTimeZone $tz = null): bool {
$tz = $tz ?: new \DateTimeZone('Africa/Tunis');
$now = $now ? (new \DateTimeImmutable($now->format('c')))->setTimezone($tz)
: new \DateTimeImmutable('now', $tz);
// 1) Blocage permanent
if (!empty($this->isBlocked)) {
return true;
}
// 2) Blocage entre deux dates
$ba = $this->blockedAt instanceof \DateTimeInterface ? (new \DateTimeImmutable($this->blockedAt->format('c')))->setTimezone($tz) : null;
$ua = $this->unblockedAt instanceof \DateTimeInterface ? (new \DateTimeImmutable($this->unblockedAt->format('c')))->setTimezone($tz) : null;
if ($ba) {
if ($ua) {
if ($now >= $ba && $now < $ua) return true;
} else {
if ($now >= $ba) return true;
}
}
// 3) Plages horaires quotidiennes
if (empty($this->blockedHours) || !is_array($this->blockedHours)) {
return false;
}
$map = [
'monday'=>'mon','mon'=>'mon',
'tuesday'=>'tue','tue'=>'tue',
'wednesday'=>'wed','wed'=>'wed',
'thursday'=>'thu','thu'=>'thu',
'friday'=>'fri','fri'=>'fri',
'saturday'=>'sat','sat'=>'sat',
'sunday'=>'sun','sun'=>'sun',
'1'=>'mon','2'=>'tue','3'=>'wed','4'=>'thu','5'=>'fri','6'=>'sat','7'=>'sun','0'=>'sun',
];
$key = strtolower($now->format('D')); // mon..sun
$key = $map[$key] ?? $key;
$ranges = $this->blockedHours[$key] ?? [];
if (empty($ranges) || !is_array($ranges)) return false;
$toMin = static function (?string $hm): ?int {
if (!$hm || !preg_match('/^(\d{1,2}):(\d{2})$/', $hm, $m)) return null;
return ((int)$m[1]) * 60 + (int)$m[2];
};
$nowMin = (int)$now->format('H') * 60 + (int)$now->format('i');
foreach ($ranges as $r) {
$start = $toMin($r['start'] ?? null);
$end = $toMin($r['end'] ?? null);
if ($start === null && $end === null) continue;
if ($start !== null && $end !== null) {
if ($start < $end) {
if ($nowMin >= $start && $nowMin < $end) return true;
} elseif ($start > $end) {
if ($nowMin >= $start || $nowMin < $end) return true;
} else {
continue;
}
}
}
return false;
}
public function getIsBlocked(): bool
{
return $this->isBlocked;
}
public function setIsBlocked(bool $blocked): self
{
$this->isBlocked = $blocked;
return $this;
}
public function getBlockedAt(): ?\DateTimeInterface
{
return $this->blockedAt;
}
public function setBlockedAt(?\DateTimeInterface $date): self
{
$this->blockedAt = $date;
return $this;
}
public function getUnblockedAt(): ?\DateTimeInterface
{
return $this->unblockedAt;
}
public function setUnblockedAt(?\DateTimeInterface $date): self
{
$this->unblockedAt = $date;
return $this;
}
public function getBlockReason(): ?string
{
return $this->blockReason;
}
public function setBlockReason(?string $reason): self
{
$this->blockReason = $reason;
return $this;
}
/**
* @return Collection|Document[]
*/
public function getDocuments(): Collection
{
return $this->documents;
}
public function addDocument(Document $document): self
{
if( !$this->documents->contains($document)) {
$this->documents[] = $document;
$document->setClient($this);
}
return $this;
}
public function removeDocument(Document $document): self
{
if( $this->documents->removeElement($document)) {
// set the owning side to null (unless already changed)
if( $document->getClient() === $this) {
$document->setClient(null);
}
}
return $this;
}
/**
* @return Collection|Document[]
*/
public function getUserDocuments(): Collection
{
return $this->userDocuments;
}
public function addUserDocument(Document $userDocument): self
{
if( !$this->userDocuments->contains($userDocument)) {
$this->userDocuments[] = $userDocument;
$userDocument->setUser($this);
}
return $this;
}
public function removeUserDocument(Document $userDocument): self
{
if( $this->userDocuments->removeElement($userDocument)) {
// set the owning side to null (unless already changed)
if( $userDocument->getUser() === $this) {
$userDocument->setUser(null);
}
}
return $this;
}
/**
* @return Collection|Address[]
*/
public function getMultiAddress(): Collection
{
return $this->multiAddress;
}
public function addMultiAddress(Address $multiAddress): self
{
if( !$this->multiAddress->contains($multiAddress)) {
$this->multiAddress[] = $multiAddress;
$multiAddress->setUser($this);
}
return $this;
}
public function removeMultiAddress(Address $multiAddress): self
{
if( $this->multiAddress->removeElement($multiAddress)) {
// set the owning side to null (unless already changed)
if( $multiAddress->getUser() === $this) {
$multiAddress->setUser(null);
}
}
return $this;
}
/**
* @return Collection|Comment[]
*/
public function getComments(): Collection
{
return $this->comments;
}
public function addComment(Comment $comment): self
{
if( !$this->comments->contains($comment)) {
$this->comments[] = $comment;
$comment->setUser($this);
}
return $this;
}
public function removeComment(Comment $comment): self
{
if( $this->comments->removeElement($comment)) {
// set the owning side to null (unless already changed)
if( $comment->getUser() === $this) {
$comment->setUser(null);
}
}
return $this;
}
/**
* @return Collection|Comment[]
*/
public function getNotes(): Collection
{
return $this->notes;
}
public function addNote(Comment $note): self
{
if( !$this->notes->contains($note)) {
$this->notes[] = $note;
$note->setClient($this);
}
return $this;
}
public function removeNote(Comment $note): self
{
if( $this->notes->removeElement($note)) {
// set the owning side to null (unless already changed)
if( $note->getUser() === $this) {
$note->setUser(null);
}
}
return $this;
}
public function getSupplier(): ?Supplier
{
return $this->supplier;
}
public function setSupplier(?Supplier $supplier): self
{
$this->supplier = $supplier;
return $this;
}
/**
* @return Collection<int, Contact>
*/
public function getContacts(): Collection
{
return $this->contacts;
}
public function addContact(Contact $contact): self
{
if (!$this->contacts->contains($contact)) {
$this->contacts[] = $contact;
$contact->setLinkedClient($this);
}
return $this;
}
public function removeContact(Contact $contact): self
{
if ($this->contacts->removeElement($contact)) {
if ($contact->getLinkedClient() === $this) {
$contact->setLinkedClient(null);
}
}
return $this;
}
public function getPromotion(): ?Promotion
{
return $this->promotion;
}
public function setPromotion(?Promotion $promotion): self
{
$this->promotion = $promotion;
return $this;
}
/**
* @return Collection|Activity[]
*/
public function getActivities(): Collection
{
return $this->activities;
}
public function addActivity(Activity $activity): self
{
if( !$this->activities->contains($activity)) {
$this->activities[] = $activity;
$activity->setCurrentUser($this);
}
return $this;
}
public function removeActivity(Activity $activity): self
{
if( $this->activities->removeElement($activity)) {
// set the owning side to null (unless already changed)
if( $activity->getCurrentUser() === $this) {
$activity->setCurrentUser(null);
}
}
return $this;
}
public function getGroupUser(): ?GroupUser
{
return $this->groupUser;
}
/**
* @return Collection|GroupUser[]
*/
public function getGroupUsers(): Collection
{
return $this->groupUsers;
}
public function addGroupUser(GroupUser $groupUser): self
{
if (!$this->groupUsers->contains($groupUser)) {
$this->groupUsers[] = $groupUser;
$groupUser->addUsersMultiGroup($this);
}
return $this;
}
public function removeGroupUser(GroupUser $groupUser): self
{
if ($this->groupUsers->removeElement($groupUser)) {
$groupUser->removeUsersMultiGroup($this);
if ($this->groupUser && $this->isSameGroupUser($this->groupUser, $groupUser)) {
$this->groupUser = $this->getFirstAssignedGroupUser();
}
}
return $this;
}
public function setGroupUsers(iterable $groupUsers): self
{
foreach ($this->groupUsers->toArray() as $existingGroupUser) {
$this->removeGroupUser($existingGroupUser);
}
foreach ($groupUsers as $groupUser) {
if ($groupUser instanceof GroupUser) {
$this->addGroupUser($groupUser);
}
}
return $this;
}
/**
* @return GroupUser[]
*/
public function getEffectiveGroupUsers(): array
{
$groups = [];
$seen = [];
$append = static function (?GroupUser $groupUser) use (&$groups, &$seen): void {
if (!$groupUser) {
return;
}
$key = $groupUser->getId() !== null
? 'id:' . $groupUser->getId()
: 'obj:' . spl_object_hash($groupUser);
if (isset($seen[$key])) {
return;
}
$seen[$key] = true;
$groups[] = $groupUser;
};
$append($this->groupUser);
foreach ($this->groupUsers as $groupUser) {
$append($groupUser);
}
return $groups;
}
/**
* @return string[]
*/
public function getEffectiveGroupUserNames(): array
{
$names = [];
foreach ($this->getEffectiveGroupUsers() as $groupUser) {
$name = trim((string) $groupUser->getName());
if ($name !== '') {
$names[] = $name;
}
}
return array_values(array_unique($names));
}
public function getEffectiveGroupUserLabel(): string
{
$names = $this->getEffectiveGroupUserNames();
return $names !== [] ? implode(', ', $names) : 'Sans groupe';
}
public function syncLegacyGroupUserIntoGroupUsers(): self
{
if ($this->groupUser instanceof GroupUser) {
$this->addGroupUser($this->groupUser);
}
return $this;
}
public function syncPrimaryGroupUserFromGroupUsers(): self
{
if ($this->groupUser instanceof GroupUser && !$this->hasAssignedGroupUser($this->groupUser)) {
$this->groupUser = null;
}
if ($this->groupUser === null) {
$this->groupUser = $this->getFirstAssignedGroupUser();
}
return $this;
}
public function getArrayRight(): array
{
if (in_array('ROLE_SUPER_ADMIN', (array) $this->getRoles(), true)) {
return RightConfig::allCodes();
}
$rights = [];
foreach ($this->getEffectiveGroupUsers() as $groupUser) {
foreach ($groupUser->getRights() as $right) {
if ($right && method_exists($right, 'getCode')) {
$rights[] = (string) $right->getCode();
}
}
}
return array_values(array_unique(array_filter($rights)));
}
public function setGroupUser(?GroupUser $groupUser): self
{
$this->groupUser = $groupUser;
if ($groupUser instanceof GroupUser) {
$this->addGroupUser($groupUser);
}
return $this;
}
public function getUserPost(): ?UserPost
{
return $this->userPost;
}
public function setUserPost(?UserPost $post): self
{
$this->userPost = $post;
return $this;
}
public function __call($name, $arguments)
{
// TODO: Implement @method string getUserIdentifier()
}
private function hasAssignedGroupUser(GroupUser $groupUser): bool
{
foreach ($this->groupUsers as $assignedGroupUser) {
if ($this->isSameGroupUser($assignedGroupUser, $groupUser)) {
return true;
}
}
return false;
}
private function getFirstAssignedGroupUser(): ?GroupUser
{
foreach ($this->groupUsers as $groupUser) {
if ($groupUser instanceof GroupUser) {
return $groupUser;
}
}
return null;
}
private function isSameGroupUser(?GroupUser $left, ?GroupUser $right): bool
{
if (!$left || !$right) {
return false;
}
if ($left->getId() !== null && $right->getId() !== null) {
return $left->getId() === $right->getId();
}
return $left === $right;
}
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return array(
'adress' => $this->getAdress(),
'firstName' => $this->getFirstName(),
'username' => $this->getUsername(),
'email' => $this->getEmail(),
'birthDate' => $this->getBirthDate() ? $this->getBirthDate()->format('Y-m-d') : null,
'password' => '',
'newPassword' => '',
'confirmPassword' => ''
);
}
/**
* @return Collection|Produit[]
*/
public function getProduits(): Collection
{
return $this->produits;
}
public function addProduit(Produit $produit): self
{
if( !$this->produits->contains($produit)) {
$this->produits[] = $produit;
$produit->addUser($this);
}
return $this;
}
public function removeProduit(Produit $produit): self
{
if( $this->produits->contains($produit)) {
$this->produits->removeElement($produit);
$produit->removeUser($this);
}
return $this;
}
public function getClientType(): ?ClientType
{
return $this->clientType;
}
public function setClientType(?ClientType $clientType): self
{
$this->clientType = $clientType;
return $this;
}
public function isClientTypeLocked(): bool
{
return (bool) $this->clientTypeLocked;
}
public function setClientTypeLocked(bool $locked): self
{
$this->clientTypeLocked = $locked;
return $this;
}
public function getClientTypeCode(): ?string
{
return $this->clientType ? $this->clientType->getCode() : null;
}
public function isBlacklisted(): bool
{
return $this->getClientTypeCode() === 'BLACKLIST';
}
public function getInternalMessengerSoundEnabled(): bool
{
return (bool) $this->internalMessengerSoundEnabled;
}
public function setInternalMessengerSoundEnabled(bool $internalMessengerSoundEnabled): self
{
$this->internalMessengerSoundEnabled = $internalMessengerSoundEnabled;
return $this;
}
public function getInternalMessengerBrowserNotificationsEnabled(): bool
{
return (bool) $this->internalMessengerBrowserNotificationsEnabled;
}
public function setInternalMessengerBrowserNotificationsEnabled(bool $internalMessengerBrowserNotificationsEnabled): self
{
$this->internalMessengerBrowserNotificationsEnabled = $internalMessengerBrowserNotificationsEnabled;
return $this;
}
public function getMessengerCode(): ?string
{
return $this->messengerCode;
}
public function setMessengerCode(?string $messengerCode): self
{
$messengerCode = trim((string) $messengerCode);
$this->messengerCode = $messengerCode !== '' ? $messengerCode : null;
return $this;
}
/**
* @return Collection|Warehouse[]
*/
public function getWarehouses(): Collection
{
return $this->warehouses;
}
public function addWarehouse(Warehouse $warehouse): self
{
if (!$this->warehouses->contains($warehouse)) {
$this->warehouses->add($warehouse);
}
return $this;
}
public function removeWarehouse(Warehouse $warehouse): self
{
$this->warehouses->removeElement($warehouse);
return $this;
}
}