<?php
declare(strict_types=1);
namespace App\Entity\User;
use App\Entity\Customer\Customer;
use App\Trait\Archivable;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Scheb\TwoFactorBundle\Model\Google\TwoFactorInterface;
use Sylius\Component\Core\Model\ShopUser as BaseShopUser;
use TheCodingMachine\DoubleAuthenticationPlugin\Model\TcmDoubleAuthenticationPluginTrait;
/** @method Customer|null getCustomer() */
#[ORM\Table(name: 'sylius_shop_user')]
#[ORM\Entity]
class ShopUser extends BaseShopUser implements TwoFactorInterface
{
use TcmDoubleAuthenticationPluginTrait;
use Archivable;
#[ORM\Column(name: 'enabled_at', type: 'datetime', nullable: true)]
private DateTime|null $enabledAt = null;
#[ORM\Column(name: 'disabled_at', type: 'datetime', nullable: true)]
private DateTime|null $disabledAt = null;
#[ORM\Column(name: 'must_change_password', type: 'boolean', options: ['default' => true])]
private bool $mustChangePassword = true;
#[ORM\Column(name: 'password_changed_at', type: 'datetime', nullable: true)]
private DateTime|null $passwordChangedAt = null;
#[ORM\OneToMany(mappedBy: 'shopUser', targetEntity: VerificationToken::class, cascade: ['all'], orphanRemoval: true)]
private Collection $verificationTokens;
#[ORM\Column(name: 'account_status', type: 'string', length: 50, options: ['default' => 'pending'])]
private string $accountStatus = 'pending';
#[ORM\Column(name: 'first_login_at', type: 'datetime', nullable: true)]
private DateTime|null $firstLoginAt = null;
public function __construct()
{
parent::__construct();
$this->verificationTokens = new ArrayCollection();
}
public function getGoogleAuthenticatorUsername(): string
{
return $this->getEmail() ?: '';
}
public function getEnabledAt(): DateTime|null
{
return $this->enabledAt;
}
public function setEnabledAt(DateTime|null $enabledAt): void
{
$this->enabledAt = $enabledAt;
}
public function getDisabledAt(): DateTime|null
{
return $this->disabledAt;
}
public function setDisabledAt(DateTime|null $disabledAt): void
{
$this->disabledAt = $disabledAt;
}
public function isLocked(): bool
{
return $this->locked;
}
public function isMustChangePassword(): bool
{
return $this->mustChangePassword;
}
public function setMustChangePassword(bool $mustChangePassword): void
{
$this->mustChangePassword = $mustChangePassword;
}
public function getPasswordChangedAt(): DateTime|null
{
return $this->passwordChangedAt;
}
public function setPasswordChangedAt(DateTime|null $passwordChangedAt): void
{
$this->passwordChangedAt = $passwordChangedAt;
}
/** @return Collection<array-key, VerificationToken> */
public function getVerificationTokens(): Collection
{
return $this->verificationTokens;
}
/** @param Collection<array-key, VerificationToken> $verificationTokens */
public function setVerificationToken(Collection $verificationTokens): void
{
$this->verificationTokens = $verificationTokens;
}
public function addVerificationToken(VerificationToken $verificationToken): self
{
if (! $this->verificationTokens->contains($verificationToken)) {
$this->verificationTokens[] = $verificationToken;
}
return $this;
}
public function removeVerificationToken(VerificationToken $verificationToken): void
{
$this->verificationTokens->removeElement($verificationToken);
}
public function getAccountStatus(): string
{
return $this->accountStatus;
}
public function setAccountStatus(string $accountStatus): void
{
$this->accountStatus = $accountStatus;
}
public function getFirstLoginAt(): DateTime|null
{
return $this->firstLoginAt;
}
public function setFirstLoginAt(DateTime|null $firstLoginAt): void
{
$this->firstLoginAt = $firstLoginAt;
}
}