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,49 @@
<?php
declare(strict_types=1);
namespace Esun\CustomerMessage\Block\Adminhtml\Message;
use Esun\CustomerMessage\Model\ConversationService;
use Magento\Backend\Block\Template;
use Magento\Sales\Api\OrderRepositoryInterface;
class Index extends Template
{
public function __construct(Template\Context $context, private readonly ConversationService $conversations, private readonly OrderRepositoryInterface $orders, array $data = [])
{
parent::__construct($context, $data);
}
public function getThreads(): array
{
return $this->conversations->getThreadsForAdmin();
}
public function getSelectedThread(): ?array
{
$threadId = (int)$this->getRequest()->getParam('thread_id');
if ($threadId) {
return $this->conversations->getThreadForAdmin($threadId);
}
$orderId = (int)$this->getRequest()->getParam('order_id');
return $orderId ? $this->conversations->getOrderThreadForAdmin($orderId) : null;
}
public function getMessages(?array $thread): array
{
return $thread ? $this->conversations->getMessages((int)$thread['thread_id']) : [];
}
public function getOrder(): ?\Magento\Sales\Api\Data\OrderInterface
{
$orderId = (int)$this->getRequest()->getParam('order_id');
if (!$orderId) {
return null;
}
try {
return $this->orders->get($orderId);
} catch (\Throwable) {
return null;
}
}
}