Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Member Functions
Signature Class Reference

Public Member Functions

 __construct (\Magento\Framework\View\Url\ConfigInterface $config, \Magento\Framework\App\View\Deployment\Version $deploymentVersion)
 
 afterGetBaseUrl (\Magento\Framework\Url\ScopeInterface $subject, $baseUrl, $type=\Magento\Framework\UrlInterface::URL_TYPE_LINK, $secure=null)
 

Data Fields

const XML_PATH_STATIC_FILE_SIGNATURE = 'dev/static/sign'
 
const SIGNATURE_TEMPLATE = 'version%s'
 

Protected Member Functions

 isUrlSignatureEnabled ()
 
 renderUrlSignature ()
 

Detailed Description

Plugin that activates signing of static file URLs with corresponding deployment version

Definition at line 12 of file Signature.php.

Constructor & Destructor Documentation

◆ __construct()

Parameters
\Magento\Framework\View\Url\ConfigInterface$config
\Magento\Framework\App\View\Deployment\Version$deploymentVersion

Definition at line 38 of file Signature.php.

41  {
42  $this->config = $config;
43  $this->deploymentVersion = $deploymentVersion;
44  }
$config
Definition: fraud_order.php:17

Member Function Documentation

◆ afterGetBaseUrl()

afterGetBaseUrl ( \Magento\Framework\Url\ScopeInterface  $subject,
  $baseUrl,
  $type = \Magento\Framework\UrlInterface::URL_TYPE_LINK,
  $secure = null 
)

Append signature to rendered base URL for static view files

Parameters
\Magento\Framework\Url\ScopeInterface$subject
string$baseUrl
string$type
null$secure
Returns
string
See also
\Magento\Framework\Url\ScopeInterface::getBaseUrl()

@SuppressWarnings(PHPMD.UnusedFormalParameter)

Definition at line 58 of file Signature.php.

63  {
64  if ($type == \Magento\Framework\UrlInterface::URL_TYPE_STATIC && $this->isUrlSignatureEnabled()) {
65  $baseUrl .= $this->renderUrlSignature() . '/';
66  }
67  return $baseUrl;
68  }
$type
Definition: item.phtml:13

◆ isUrlSignatureEnabled()

isUrlSignatureEnabled ( )
protected

Whether signing of URLs is enabled or not

Returns
bool

Definition at line 75 of file Signature.php.

76  {
77  return (bool)$this->config->getValue(self::XML_PATH_STATIC_FILE_SIGNATURE);
78  }

◆ renderUrlSignature()

renderUrlSignature ( )
protected

Render URL signature from the template

Returns
string

Definition at line 85 of file Signature.php.

86  {
87  return sprintf(self::SIGNATURE_TEMPLATE, $this->deploymentVersion->getValue());
88  }

Field Documentation

◆ SIGNATURE_TEMPLATE

const SIGNATURE_TEMPLATE = 'version%s'

Template of signature component of URL, parametrized with the deployment version of static files

Definition at line 22 of file Signature.php.

◆ XML_PATH_STATIC_FILE_SIGNATURE

const XML_PATH_STATIC_FILE_SIGNATURE = 'dev/static/sign'

XPath for configuration setting of signing static files

Definition at line 17 of file Signature.php.


The documentation for this class was generated from the following file: