init
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\CustomerCoupon\Model;
|
||||
|
||||
use Magento\Customer\Model\Session;
|
||||
|
||||
class RegistrationCouponGrantContext
|
||||
{
|
||||
private const SESSION_KEY = 'esun_registration_coupon_granted_customer_id';
|
||||
|
||||
public function __construct(private readonly Session $customerSession)
|
||||
{
|
||||
}
|
||||
|
||||
public function markGranted(int $customerId): void
|
||||
{
|
||||
if ($customerId > 0) {
|
||||
$this->customerSession->setData(self::SESSION_KEY, $customerId);
|
||||
}
|
||||
}
|
||||
|
||||
public function consumeGrantedCustomerId(): int
|
||||
{
|
||||
$customerId = (int)$this->customerSession->getData(self::SESSION_KEY);
|
||||
$this->customerSession->unsetData(self::SESSION_KEY);
|
||||
|
||||
return $customerId;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user