This commit is contained in:
2026-09-15 10:35:56 +08:00
commit 782f8ea7aa
4086 changed files with 631288 additions and 0 deletions
@@ -0,0 +1,20 @@
<?php
declare(strict_types=1);
namespace Esun\PromotionPopup\Model\Config\Source;
use Magento\Framework\Data\OptionSourceInterface;
class Audience implements OptionSourceInterface
{
public const GUEST = 'guest';
public const ALL = 'all';
public function toOptionArray(): array
{
return [
['value' => self::GUEST, 'label' => __('Guests Only')],
['value' => self::ALL, 'label' => __('All Visitors')],
];
}
}
@@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
namespace Esun\PromotionPopup\Model\Config\Source;
use Magento\Cms\Model\ResourceModel\Block\CollectionFactory;
use Magento\Framework\Data\OptionSourceInterface;
class CmsBlock implements OptionSourceInterface
{
public function __construct(private readonly CollectionFactory $collectionFactory)
{
}
public function toOptionArray(): array
{
$collection = $this->collectionFactory->create();
$collection->addFieldToSelect(['title', 'identifier']);
$collection->addFieldToFilter('is_active', 1);
$collection->setOrder('title', 'ASC');
$options = [['value' => '', 'label' => __('-- Please Select --')]];
$identifiers = [];
foreach ($collection as $block) {
$identifier = trim((string)$block->getIdentifier());
if ($identifier === '' || isset($identifiers[$identifier])) {
continue;
}
$identifiers[$identifier] = true;
$options[] = [
'value' => $identifier,
'label' => sprintf('%s [%s]', (string)$block->getTitle(), $identifier),
];
}
return $options;
}
}
@@ -0,0 +1,24 @@
<?php
declare(strict_types=1);
namespace Esun\PromotionPopup\Model\Config\Source;
use Magento\Framework\Data\OptionSourceInterface;
class Frequency implements OptionSourceInterface
{
public const ALWAYS = 'always';
public const SESSION = 'session';
public const DAILY = 'daily';
public const CAMPAIGN = 'campaign';
public function toOptionArray(): array
{
return [
['value' => self::DAILY, 'label' => __('Once per Day')],
['value' => self::SESSION, 'label' => __('Once per Session')],
['value' => self::CAMPAIGN, 'label' => __('Once per Campaign Version')],
['value' => self::ALWAYS, 'label' => __('Every Eligible Page View')],
];
}
}
@@ -0,0 +1,23 @@
<?php
declare(strict_types=1);
namespace Esun\PromotionPopup\Model\Config\Source;
use Magento\Framework\Data\OptionSourceInterface;
class PromotionType implements OptionSourceInterface
{
public const CONTENT_ONLY = 'content_only';
public const REGISTRATION_NEWSLETTER_COUPON = 'registration_newsletter_coupon';
public function toOptionArray(): array
{
return [
[
'value' => self::REGISTRATION_NEWSLETTER_COUPON,
'label' => __('Registration + Newsletter Coupon'),
],
['value' => self::CONTENT_ONLY, 'label' => __('Content Only')],
];
}
}