Init Gitea

This commit is contained in:
dqj
2025-10-06 21:45:33 +09:00
commit c8607205a2
33 changed files with 4268 additions and 0 deletions

51
Entity/BaseInfoTrait.php Normal file
View File

@@ -0,0 +1,51 @@
<?php
/*
* This file is part of EC-CUBE
*
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
*
* http://www.ec-cube.co.jp/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Plugin\Passkeys\Entity;
use Doctrine\ORM\Mapping as ORM;
use Eccube\Annotation\EntityExtension;
/**
* @EntityExtension("Eccube\Entity\BaseInfo")
*/
trait BaseInfoTrait
{
/**
* Use passkeys
*
* @var bool
*
* @ORM\Column(name="passkeys_use", type="boolean", nullable=false, options={"default":false})
*/
private bool $passkeys_use;
/**
* @return bool
*/
public function isPasskeysUse(): bool
{
log_info('isPasskeysUse:'.$this->passkeys_use);
return $this->passkeys_use;
}
/**
* @param bool $passkeys_use
*/
public function setPasskeysUse(bool $passkeys_use): void
{
$this->passkeys_use = $passkeys_use;
log_info('setPasskeysUse:'.$this->passkeys_use);
}
}

71
Entity/CustomerTrait.php Normal file
View File

@@ -0,0 +1,71 @@
<?php
/*
* This file is part of EC-CUBE
*
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
*
* http://www.ec-cube.co.jp/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Plugin\Passkeys\Entity;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Eccube\Annotation\EntityExtension;
/**
* @EntityExtension("Eccube\Entity\Customer")
*/
trait CustomerTrait
{
/**
* @var boolean
*
* @ORM\Column(name="enable_passkeys", type="boolean", nullable=false, options={"default":true})
*/
private bool $enable_passkeys = true;
/**
* @var Collection
*
* @ORM\OneToMany(targetEntity="\Plugin\Passkeys\Entity\PasskeysCustomerCookie", mappedBy="Customer")
*/
private $PasskeysCustomerCookies;
/**
* @return bool
*/
public function isEnablePasskeys(): bool
{
return $this->enable_passkeys;
}
/**
* @param bool $enable_passkeys
*/
public function setEnablePasskeys(bool $enable_passkeys): void
{
$this->enable_passkeys = $enable_passkeys;
}
/**
* @return Collection
*/
public function getPasskeysCustomerCookies(): Collection
{
return $this->PasskeysCustomerCookies;
}
/**
* @param Collection $PasskeysCustomerCookies
*/
public function setPasskeysCustomerCookies(Collection $PasskeysCustomerCookies): void
{
$this->PasskeysCustomerCookies = $PasskeysCustomerCookies;
}
}

View File

@@ -0,0 +1,241 @@
<?php
/*
* This file is part of EC-CUBE
*
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
*
* http://www.ec-cube.co.jp/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Plugin\Passkeys\Entity;
use Doctrine\ORM\Mapping as ORM;
use Eccube\Entity\AbstractEntity;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Validator\Constraints as Assert;
/**
* PasskeysConfig
*
* @ORM\Table(name="plg_passkeys_config")
* @ORM\InheritanceType("SINGLE_TABLE")
* @ORM\DiscriminatorColumn(name="discriminator_type", type="string", length=255)
* @ORM\HasLifecycleCallbacks()
* @ORM\Entity(repositoryClass="Plugin\Passkeys\Repository\PasskeysAuthConfigRepository")
* @UniqueEntity("id")
*/
class PasskeysAuthConfig extends AbstractEntity
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer", options={"unsigned":true})
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="api_key", type="string", nullable=true, length=200)
*/
private $api_key = null;
/**
* @var string
*
* @ORM\Column(name="api_secret", type="string", nullable=true, length=200)
*/
private $api_secret = null;
private $plain_api_secret;
/**
* @var string
*
* @ORM\Column(name="from_phone_number", type="string", nullable=true, length=200)
*/
private $from_phone_number = null;
/**
* @var string
*
* @ORM\Column(name="include_routes", type="text", nullable=true)
*/
private $include_routes = null;
/**
* Constructor.
*/
public function __construct()
{
}
/**
* Get id.
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Get api_key.
*
* @return string
*/
public function getApiKey()
{
return $this->api_key;
}
/**
* Set api_key.
*
* @param string $apiKey
*
* @return PasskeysAuthConfig
*/
public function setApiKey($apiKey)
{
$this->api_key = $apiKey;
return $this;
}
/**
* Get api_secret.
*
* @return string
*/
public function getApiSecret()
{
return $this->api_secret;
}
/**
* Set api_secret.
*
* @param string $apiSecret
*
* @return PasskeysAuthConfig
*/
public function setApiSecret($apiSecret)
{
$this->api_secret = $apiSecret;
return $this;
}
/**
* Get from phone number.
*
* @return string
*/
public function getFromPhoneNumber()
{
return $this->from_phone_number;
}
/**
* Set from phone number.
*
* @param string $fromPhoneNumber
*
* @return PasskeysAuthConfig
*/
public function setFromPhoneNumber(string $fromPhoneNumber)
{
$this->from_phone_number = $fromPhoneNumber;
return $this;
}
public function addIncludeRoute(string $route)
{
$routes = $this->getRoutes($this->getIncludeRoutes());
if (!in_array($route, $routes)) {
$this->setIncludeRoutes($this->include_routes.PHP_EOL.$route);
}
return $this;
}
private function getRoutes(?string $routes): array
{
if (!$routes) {
return [];
}
return explode(PHP_EOL, $routes);
}
/**
* Get include_routes.
*
* @return string|null
*/
public function getIncludeRoutes()
{
return $this->include_routes;
}
/**
* Set include_routes.
*
* @param string|null $include_routes
*
* @return PasskeysAuthConfig
*/
public function setIncludeRoutes($include_routes = null)
{
$this->include_routes = $include_routes;
return $this;
}
public function removeIncludeRoute(string $route)
{
$routes = $this->getRoutes($this->getIncludeRoutes());
if (in_array($route, $routes)) {
$routes = array_diff($routes, [$route]);
$this->setIncludeRoutes($this->getRoutesAsString($routes));
}
return $this;
}
private function getRoutesAsString(array $routes): string
{
return implode(PHP_EOL, $routes);
}
/**
* @param string|null $plain_api_secret
*
* @return PasskeysAuthConfig
*/
public function setPlainApiSecret(?string $plain_api_secret): PasskeysAuthConfig
{
$this->plain_api_secret = $plain_api_secret;
return $this;
}
/**
* @return mixed
*/
public function getPlainApiSecret(): ?string
{
return $this->plain_api_secret;
}
}

142
Entity/PasskeysAuthType.php Normal file
View File

@@ -0,0 +1,142 @@
<?php
/*
* This file is part of EC-CUBE
*
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
*
* http://www.ec-cube.co.jp/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Plugin\Passkeys\Entity;
use Doctrine\ORM\Mapping as ORM;
use Eccube\Entity\AbstractEntity;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* PasskeysConfig
*
* @ORM\Table(name="plg_passkeys_type")
* @ORM\InheritanceType("SINGLE_TABLE")
* @ORM\DiscriminatorColumn(name="discriminator_type", type="string", length=255)
* @ORM\HasLifecycleCallbacks()
* @ORM\Entity(repositoryClass="Plugin\Passkeys\Repository\PasskeysAuthTypeRepository")
* @UniqueEntity("id")
*/
class PasskeysAuthType extends AbstractEntity
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer", options={"unsigned":true})
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", nullable=false, length=200, unique=true)
*/
private $name;
/**
* @var string
*
* @ORM\Column(name="route", type="string", nullable=false, length=200, unique=true)
*/
private $route = null;
/**
* @var boolean
*
* @ORM\Column(name="is_disabled", type="boolean", nullable=false)
*/
private $isDisabled = false;
/**
* Constructor.
*/
public function __construct()
{
}
/**
* Get id.
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Get name.
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set name.
*
* @param string $name
*
* @return PasskeysAuthType
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get route.
*
* @return string
*/
public function getRoute()
{
return $this->route;
}
/**
* Set route.
*
* @param string $route
*
* @return PasskeysAuthType
*/
public function setRoute($route)
{
$this->route = $route;
return $this;
}
/**
* @return bool
*/
public function isDisabled(): bool
{
return $this->isDisabled;
}
/**
* @param bool $isDisabled
*/
public function setIsDisabled(bool $isDisabled): void
{
$this->isDisabled = $isDisabled;
}
}

View File

@@ -0,0 +1,197 @@
<?php
/*
* This file is part of EC-CUBE
*
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
*
* http://www.ec-cube.co.jp/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Plugin\Passkeys\Entity;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
use Eccube\Entity\AbstractEntity;
use Eccube\Entity\Customer;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* PasskeysCustomerCookie
*
* @ORM\Table(name="plg_passkeys_customer_cookie")
* @ORM\InheritanceType("SINGLE_TABLE")
* @ORM\DiscriminatorColumn(name="discriminator_type", type="string", length=255)
* @ORM\HasLifecycleCallbacks()
* @ORM\Entity(repositoryClass="Plugin\Passkeys\Repository\PasskeysAuthConfigRepository")
* @UniqueEntity("id")
*/
class PasskeysCustomerCookie extends AbstractEntity
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer", options={"unsigned":true})
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private int $id;
/**
* @var Customer
*
* @ORM\ManyToOne(targetEntity="Eccube\Entity\Customer", inversedBy="PasskeysCustomerCookie")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="customer_id", referencedColumnName="id")
* })
*/
private Customer $Customer;
/**
* @var string
*
* @ORM\Column(name="cookie_name", type="string", nullable=false, length=512)
*/
private string $cookie_name;
/**
* @var string
*
* @ORM\Column(name="cookie_value", type="string", nullable=false, length=512, unique=true)
*/
private string $cookie_value;
/**
* @var \DateTime
*
* @ORM\Column(name="cookie_expire_date", type="datetime", nullable=true)
*/
private ?\DateTime $cookie_expire_date;
/**
* @var \DateTime
*
* @ORM\Column(name="created_at", type="datetime", nullable=false)
*/
private \DateTime $createdAt;
/**
* @var \DateTime
*
* @ORM\Column(name="updated_at", type="datetime", nullable=false)
*/
private \DateTime $updatedAt;
/**
* @ORM\PrePersist
* @ORM\PreUpdate
*/
public function updatedTimestamps(): void
{
$this->setUpdatedAt(new \DateTime('now'));
if (!isset($this->createdAt) || $this->getCreatedAt() === null) {
$this->setCreatedAt(new \DateTime('now'));
}
}
/**
* @return \DateTime
*/
public function getCreatedAt(): \DateTime
{
return $this->createdAt;
}
/**
* @param \DateTime $createdAt
*/
public function setCreatedAt(\DateTime $createdAt): void
{
$this->createdAt = $createdAt;
}
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @return Customer
*/
public function getCustomer(): Customer
{
return $this->Customer;
}
/**
* @param Customer $Customer
*/
public function setCustomer(Customer $Customer): void
{
$this->Customer = $Customer;
}
/**
* @return string
*/
public function getCookieName(): string
{
return $this->cookie_name;
}
/**
* @param string $cookie_name
*/
public function setCookieName(string $cookie_name): void
{
$this->cookie_name = $cookie_name;
}
/**
* @return string
*/
public function getCookieValue(): string
{
return $this->cookie_value;
}
/**
* @param string $cookie_value
*/
public function setCookieValue(string $cookie_value): void
{
$this->cookie_value = $cookie_value;
}
/**
* @return \DateTime
*/
public function getCookieExpireDate(): \DateTime
{
return $this->cookie_expire_date;
}
/**
* @param \DateTime $cookie_expire_date
*/
public function setCookieExpireDate(\DateTime $cookie_expire_date): void
{
$this->cookie_expire_date = $cookie_expire_date;
}
/**
* @return \DateTime
*/
public function getUpdatedAt(): \DateTime
{
return $this->updatedAt;
}
/**
* @param \DateTime $updatedAt
*/
public function setUpdatedAt(\DateTime $updatedAt): void
{
$this->updatedAt = $updatedAt;
}
}