config = $config; $this->deploymentVersion = $deploymentVersion; } /** * Append signature to rendered base URL for static view files * * @param \Magento\Framework\Url\ScopeInterface $subject * @param callable $proceed * @param string $type * @param null $secure * @return string * @see \Magento\Framework\Url\ScopeInterface::getBaseUrl() * * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function aroundGetBaseUrl( \Magento\Framework\Url\ScopeInterface $subject, \Closure $proceed, $type = \Magento\Framework\UrlInterface::URL_TYPE_LINK, $secure = null ) { $baseUrl = $proceed($type, $secure); if ($type == \Magento\Framework\UrlInterface::URL_TYPE_STATIC && $this->isUrlSignatureEnabled()) { $baseUrl .= $this->renderUrlSignature() . '/'; } return $baseUrl; } /** * Whether signing of URLs is enabled or not * * @return bool */ protected function isUrlSignatureEnabled() { return (bool)$this->config->getValue(self::XML_PATH_STATIC_FILE_SIGNATURE); } /** * Render URL signature from the template * * @return string */ protected function renderUrlSignature() { return sprintf(self::SIGNATURE_TEMPLATE, $this->deploymentVersion->getValue()); } }