httpContext = $httpContext; $this->json = $json ?: ObjectManager::getInstance()->get( Json::class); parent::__construct($context, $data); } public function getCacheKeyInfo($newval = []) { return array_merge([ 'OLEGNAX_SOCIALICONS_WIDGET', $this->_storeManager->getStore()->getId(), $this->_design->getDesignTheme()->getId(), $this->httpContext->getValue( Context::CONTEXT_GROUP), $this->json->serialize($this->getRequest()->getParams()), $this->json->serialize($this->getData()), ], parent::getCacheKeyInfo(), $newval); } public function getSocialsId() { return 'ox_' . $this->getNameInLayout(); } public function getSocialLinks() { $social = ['facebook', 'facebook_messenger', 'instagram', 'twitter', 'pinterest', 'skype', 'tumblr', 'youtube', 'amazon', 'amazon_pay', 'kickstarter', 'stripe', 'paypal', 'vimeo', 'vk', 'foursquare', 'flickr', 'linkedin', 'whatsapp', 'telegram_plane', 'snapchat', 'reddit', 'discord', 'slack', 'tripadvisor', 'tiktok', 'business']; $socialLink = []; $socialOrder = []; foreach($social as $_social) { $link = $this->getData($_social . '_link'); if($link) { $socialLink[$_social] = $link; $order = $this->getData($_social . '_sort'); if(empty($order)) { $order = 0; } $socialOrder[$_social] = abs((int)$order); } } asort($socialOrder); $result = []; foreach($socialOrder as $_social=>$order) { $result[$_social] = $socialLink[$_social]; } return $result; } public function prepareStyle(array $style, string $separatorValue = ': ', string $separatorAttribute = ';') { $style = array_filter($style); if (empty($style)) { return ''; } foreach ($style as $key => &$value) { $value = $key . $separatorValue . $value; } $style = implode($separatorAttribute, $style); return $style; } public function prepareStyleBlock(array $style) { $result = []; foreach ($style as $selector=> $_style) { $result[$selector] = $this->prepareStyle($_style); } $result = array_filter($result); if (!empty($result)) { foreach ($result as $selector => $_style) { $result[$selector] = $selector .'{' . $_style .'}'; } return ''; } return ''; } }