urlInterface = $urlInterface; $this->helper = $helper; } /** * Prepare url using passed id path and return it * * @return string|false if path was not found in url rewrites. * @SuppressWarnings(PHPMD.NPathComplexity) * @throws RuntimeException */ public function getHref() { if ($this->_href === null) { if (!$this->getData('id_path')) { return false; } $rewriteData = $this->parseIdPath($this->getData('id_path')); $href = $this->urlInterface->getUrl('ox_quickview/catalog_product/view', ['id' => $rewriteData[1]]); $this->_href = $href; } return $this->_href; } /** * Parse id_path * * @param string $idPath * @return array * @throws RuntimeException */ protected function parseIdPath($idPath) { $rewriteData = explode('/', $idPath); if (!isset($rewriteData[0]) || !isset($rewriteData[1])) { throw new RuntimeException('Wrong id_path structure.'); } return $rewriteData; } /** * @return bool */ public function isEnabled() { return $this->helper->isEnabled(); } /** * @return string */ public function getWidgetId() { return 'ox_hotspotquickview_' . substr(md5(microtime()), -5); } /** * */ protected function _construct() { $this->setData('position_left', abs((float)$this->getData('position_left'))); $this->setData('position_top', abs((float)$this->getData('position_top'))); $this->setData('border-radius', abs((int)$this->getData('border-radius'))); $this->setData('border', abs((int)$this->getData('border'))); $this->setData('rel_nofollow', (bool)$this->getData('rel_nofollow')); parent::_construct(); } }