>|null */ private ?array $items = null; public function __construct( Context $context, private readonly ImageProvider $imageProvider, array $data = [] ) { parent::__construct($context, $data); } public function getSubtitle(): string { return trim((string) $this->getConfig('subtitle')); } public function getExploreAllUrl(): string { return trim((string) $this->getConfig('explore_all_url')); } /** * @return array> */ public function getItems(): array { if ($this->items === null) { $this->items = $this->imageProvider->getImagesByCategoryId($this->getCategoryId()); } return $this->items; } public function getCacheKeyInfo(): array { return [ 'ESUN_HOMEPAGE_APPLICATION', (int) $this->_storeManager->getStore()->getId(), $this->getCategoryId(), sha1($this->getSubtitle()), sha1($this->getExploreAllUrl()), ]; } public function getIdentities(): array { $identities = []; $categoryId = $this->getCategoryId(); if ($categoryId > 0) { $identities[] = Category::CACHE_TAG . '_' . $categoryId; } foreach ($this->getItems() as $item) { $identities[] = Image::CACHE_TAG . '_' . (int) $item['id']; } return array_values(array_unique($identities)); } private function getCategoryId(): int { return (int) $this->getConfig('category_id'); } private function getConfig(string $field): mixed { return $this->_scopeConfig->getValue( self::XML_PATH . $field, ScopeInterface::SCOPE_STORE ); } }