|null */ private ?array $order = null; public function __construct( Template\Context $context, private readonly Session $customerSession, private readonly ResourceConnection $resource, private readonly Json $json, array $data = [] ) { parent::__construct($context, $data); } /** @return array */ public function getOrder(): array { if ($this->order !== null) { return $this->order; } $connection = $this->resource->getConnection(); return $this->order = $connection->fetchRow( $connection->select() ->from($this->resource->getTableName('esun_legacy_order')) ->where('legacy_order_id = ?', (int)$this->getRequest()->getParam('id')) ->where('customer_id = ?', (int)$this->customerSession->getCustomerId()) ) ?: []; } /** @return array> */ public function getItems(): array { $order = $this->getOrder(); if (!$order) { return []; } $connection = $this->resource->getConnection(); return $connection->fetchAll( $connection->select() ->from($this->resource->getTableName('esun_legacy_order_item')) ->where('legacy_order_id = ?', (int)$order['legacy_order_id']) ->order('line_number ASC') ); } /** @return array */ public function decodeAddress(?string $value): array { try { return $value ? (array)$this->json->unserialize($value) : []; } catch (\Throwable) { return []; } } }