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,78 @@
<?php
declare(strict_types=1);
namespace Esun\Catalog\Block\Adminhtml\Faq;
use Esun\Catalog\Model\Faq;
use Esun\Catalog\Model\FaqFactory;
use Magento\Backend\Block\Template;
use Magento\Backend\Block\Template\Context;
use Magento\Cms\Model\Wysiwyg\Config as WysiwygConfig;
use Magento\Framework\Data\FormFactory;
use Magento\Store\Model\System\Store;
class EditBlock extends Template
{
private ?Faq $faq = null;
public function __construct(
Context $context,
private readonly FaqFactory $faqFactory,
private readonly Store $storeSystem,
private readonly FormFactory $formFactory,
private readonly WysiwygConfig $wysiwygConfig,
array $data = []
) {
parent::__construct($context, $data);
}
public function getFaqModel(): Faq
{
if ($this->faq === null) {
$this->faq = $this->faqFactory->create();
$id = (int)$this->getRequest()->getParam('id');
if ($id) {
$this->faq->load($id);
}
}
return $this->faq;
}
public function getStoreOptions(): array
{
return $this->storeSystem->getStoreValuesForForm(false, true);
}
public function getSaveUrl(): string
{
return $this->getUrl('esun_catalog/faq/save');
}
public function getBackUrl(): string
{
return $this->getUrl('esun_catalog/faq/index');
}
public function getContentEditorHtml(): string
{
$form = $this->formFactory->create();
$editor = $form->addField('content', 'editor', [
'name' => 'content',
'label' => __('Content'),
'title' => __('Content'),
'style' => 'height:28em',
'required' => false,
'value' => (string)$this->getFaqModel()->getData('content'),
'config' => $this->wysiwygConfig->getConfig([
'add_variables' => false,
'add_widgets' => true,
'add_images' => true,
'is_pagebuilder_enabled' => true,
'pagebuilder_button' => true,
]),
]);
return $editor->getElementHtml();
}
}
@@ -0,0 +1,48 @@
<?php
declare(strict_types=1);
namespace Esun\Catalog\Block\Adminhtml\Faq;
use Esun\Catalog\Model\ResourceModel\Faq\Collection;
use Esun\Catalog\Model\ResourceModel\Faq\CollectionFactory;
use Magento\Backend\Block\Template;
use Magento\Backend\Block\Template\Context;
class ListBlock extends Template
{
private ?Collection $faqs = null;
public function __construct(
Context $context,
private readonly CollectionFactory $collectionFactory,
array $data = []
) {
parent::__construct($context, $data);
}
public function getFaqs(): Collection
{
if ($this->faqs === null) {
$this->faqs = $this->collectionFactory->create()
->setOrder('sort_order', 'ASC')
->setOrder('faq_id', 'DESC');
}
return $this->faqs;
}
public function getNewUrl(): string
{
return $this->getUrl('esun_catalog/faq/new');
}
public function getEditUrl(int $id): string
{
return $this->getUrl('esun_catalog/faq/edit', ['id' => $id]);
}
public function getDeleteUrl(int $id): string
{
return $this->getUrl('esun_catalog/faq/delete', ['id' => $id]);
}
}