PHP Class Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Datei anzeigen Open project: nexcess/magento-turpentine Class Usage Examples

Protected Properties

Property Type Description
$_options array options array
$_socket Nexcessnet_Turpentine_Model_Varnish_Admin_Socket The socket this configurator is based on

Public Methods

Method Description
__construct ( $options = [] )
generate ( $doClean = true )
getAllowedHostsRegex ( ) : string Get hosts as regex
getBaseUrlPathRegex ( ) : string Get the base url path regex
getFromSocket ( Nexcessnet_Turpentine_Model_Varnish_Admin_Socket $socket ) : Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract Get the correct version of a configurator from a socket
save ( string $generatedConfig ) : null Save the generated config to the file specified in Magento config

Protected Methods

Method Description
_cleanVcl ( string $dirtyVcl ) : string Remove empty and commented out lines from the generated VCL
_cleanVclHelper ( string $line ) : boolean Helper to filter out blank/commented lines for VCL cleaning
_formatTemplate ( string $template, array $vars ) : string Format a template string, replacing {{keys}} with the appropriate values and remove unspecified keys
_getAdminBackend ( ) : string Get the admin backend configuration string
_getAdminFrontname ( ) : string Get the Magento admin frontname
_getAdvancedSessionValidationTargets ( ) : string Get the advanced session validation restrictions
_getBaseUrlPaths ( ) : array Get the path part of each store's base URL and static file URLs
_getCrawlerIps ( ) : array Get the list of crawler IPs
_getCrawlerUserAgents ( ) : string Get the regex formatted list of crawler user agents
_getCustomIncludeFilename ( $position = '' ) : string Get the name of the custom include VCL file
_getCustomTemplateFilename ( ) : string Get the custom VCL template, if it exists Returns 'null' if the file doesn't exist
_getDebugIps ( ) : array Get the list of allowed debug IPs
_getDefaultBackend ( ) : string Get the default backend configuration string
_getDefaultTtl ( ) : string Get the default cache TTL from Magento config
_getEnableCaching ( ) : string Get the Enable Caching value
_getEnableDebugHeaders ( ) : string Get whether debug headers should be enabled or not
_getForceCacheStatic ( ) : string Get the Force Static Caching option
_getGenerateSession ( ) : string Get the Generate Session
_getGenerateSessionEnd ( ) : string Get the Generate Session
_getGenerateSessionExpires ( ) : string Get the Generate Session Expires
_getGenerateSessionStart ( ) : string Get the Generate Session
_getGetParamExcludes ( ) : string Format the GET variable excludes for insertion in a regex
_getGracePeriod ( ) : string Get the grace period for vcl_fetch
_getIgnoreGetParameters ( )
_getLruFactor ( ) : string Get the time to increase a cached objects TTL on cache hit (in seconds).
_getNormalizeCookieRegex ( ) : string Get the regex for cookie normalization
_getNormalizeCookieTarget ( ) : string Get the hostname for cookie normalization
_getNormalizeHostTarget ( ) : string Get the hostname for host normalization from Magento's base URL
_getSimpleHashStatic ( ) : string Get the Force Static Caching option
_getStaticExtensions ( ) : string Format the list of static cache extensions
_getStaticTtl ( ) : string Get the static caching TTL
_getTemplateVars ( ) : array Build the list of template variables to apply to the VCL template
_getUrlExcludes ( ) : string Format the URL exclusions for insertion in a regex. Admin frontname and API are automatically added.
_getUrlTtls ( ) : string Format the by-url TTL value list
_getVclFilename ( ) : string Get the name of the file to save the VCL to
_getVclTemplateFilename ( string $baseFilename ) : string Get the full path for a given template filename
_sendUnModifiedUrlToBackend ( ) : boolean
_vcl_acl ( string $name, array $hosts ) : string Format a VCL ACL declaration
_vcl_backend ( string $name, string $host, string $port, array $options = [] ) : string Format a VCL backend declaration
_vcl_call ( string $subroutine ) : string Format a VCL subroutine call
_vcl_director ( string $name, array $backendOptions ) : string Format a VCL director declaration, for load balancing
_vcl_director_backend ( string $host, string $port, string $probeUrl = '', array $options = [] ) : string Format a VCL backend declaration to put inside director
_vcl_get_probe ( string $probeUrl ) : string Format a VCL probe declaration to put in backend which is in director
_vcl_sub_allowed_hosts_regex ( ) : string Get the Host normalization sub routine
_vcl_sub_https_redirect_fix ( ) : string When using Varnish as front door listen on port 80 and Nginx/Apache listen on port 443 for HTTPS, the fix will keep the url parameters when redirect from HTTP to HTTPS.
_vcl_sub_maintenance_allowed_ips ( ) : string Get the allowed IPs when in maintenance mode
_vcl_sub_normalize_encoding ( ) : string Get the Accept-Encoding normalization sub routine
_vcl_sub_normalize_host ( ) : string Get the Host normalization sub routine
_vcl_sub_normalize_user_agent ( ) : string Get the User-Agent normalization sub routine
_vcl_sub_synth ( ) : string Get the allowed IPs when in maintenance mode
_vcl_sub_synth_https_fix ( ) : string vcl_synth for fixing https

Method Details

__construct() public method

public __construct ( $options = [] )

_cleanVcl() protected method

Remove empty and commented out lines from the generated VCL
protected _cleanVcl ( string $dirtyVcl ) : string
$dirtyVcl string generated vcl
return string

_cleanVclHelper() protected method

Helper to filter out blank/commented lines for VCL cleaning
protected _cleanVclHelper ( string $line ) : boolean
$line string
return boolean

_formatTemplate() protected method

Format a template string, replacing {{keys}} with the appropriate values and remove unspecified keys
protected _formatTemplate ( string $template, array $vars ) : string
$template string template string to operate on
$vars array array of key => value replacements
return string

_getAdminBackend() protected method

Get the admin backend configuration string
protected _getAdminBackend ( ) : string
return string

_getAdminFrontname() protected method

This is just the plain string, not in URL format. ex: http://example.com/magento/admin -> admin
protected _getAdminFrontname ( ) : string
return string

_getAdvancedSessionValidationTargets() protected method

Note that if User-Agent Normalization is on then the normalized user-agent is used for user-agent validation instead of the full user-agent

_getBaseUrlPaths() protected method

Get the path part of each store's base URL and static file URLs
protected _getBaseUrlPaths ( ) : array
return array

_getCrawlerIps() protected method

Get the list of crawler IPs
protected _getCrawlerIps ( ) : array
return array

_getCrawlerUserAgents() protected method

Get the regex formatted list of crawler user agents
protected _getCrawlerUserAgents ( ) : string
return string

_getCustomIncludeFilename() protected method

Get the name of the custom include VCL file
protected _getCustomIncludeFilename ( $position = '' ) : string
return string

_getCustomTemplateFilename() protected method

Get the custom VCL template, if it exists Returns 'null' if the file doesn't exist
protected _getCustomTemplateFilename ( ) : string
return string

_getDebugIps() protected method

Get the list of allowed debug IPs
protected _getDebugIps ( ) : array
return array

_getDefaultBackend() protected method

Get the default backend configuration string
protected _getDefaultBackend ( ) : string
return string

_getDefaultTtl() protected method

Get the default cache TTL from Magento config
protected _getDefaultTtl ( ) : string
return string

_getEnableCaching() protected method

Get the Enable Caching value
protected _getEnableCaching ( ) : string
return string

_getEnableDebugHeaders() protected method

Get whether debug headers should be enabled or not
protected _getEnableDebugHeaders ( ) : string
return string

_getForceCacheStatic() protected method

Get the Force Static Caching option
protected _getForceCacheStatic ( ) : string
return string

_getGenerateSession() protected method

Get the Generate Session
protected _getGenerateSession ( ) : string
return string

_getGenerateSessionEnd() protected method

Get the Generate Session
protected _getGenerateSessionEnd ( ) : string
return string

_getGenerateSessionExpires() protected method

Get the Generate Session Expires
protected _getGenerateSessionExpires ( ) : string
return string

_getGenerateSessionStart() protected method

Get the Generate Session
protected _getGenerateSessionStart ( ) : string
return string

_getGetParamExcludes() protected method

Format the GET variable excludes for insertion in a regex
protected _getGetParamExcludes ( ) : string
return string

_getGracePeriod() protected method

This is curently hardcoded to 15 seconds, will be configurable at some point
protected _getGracePeriod ( ) : string
return string

_getIgnoreGetParameters() protected method

protected _getIgnoreGetParameters ( )

_getLruFactor() protected method

This should be set very low since it gets added to every hit.
protected _getLruFactor ( ) : string
return string

_getNormalizeCookieRegex() protected method

Get the regex for cookie normalization
protected _getNormalizeCookieRegex ( ) : string
return string

_getNormalizeCookieTarget() protected method

Get the hostname for cookie normalization
protected _getNormalizeCookieTarget ( ) : string
return string

_getNormalizeHostTarget() protected method

Get the hostname for host normalization from Magento's base URL
protected _getNormalizeHostTarget ( ) : string
return string

_getSimpleHashStatic() protected method

Get the Force Static Caching option
protected _getSimpleHashStatic ( ) : string
return string

_getStaticExtensions() protected method

Format the list of static cache extensions
protected _getStaticExtensions ( ) : string
return string

_getStaticTtl() protected method

Get the static caching TTL
protected _getStaticTtl ( ) : string
return string

_getTemplateVars() protected method

Build the list of template variables to apply to the VCL template
protected _getTemplateVars ( ) : array
return array

_getUrlExcludes() protected method

Format the URL exclusions for insertion in a regex. Admin frontname and API are automatically added.
protected _getUrlExcludes ( ) : string
return string

_getUrlTtls() protected method

Format the by-url TTL value list
protected _getUrlTtls ( ) : string
return string

_getVclFilename() protected method

Get the name of the file to save the VCL to
protected _getVclFilename ( ) : string
return string

_getVclTemplateFilename() protected method

Get the full path for a given template filename
protected _getVclTemplateFilename ( string $baseFilename ) : string
$baseFilename string
return string

_sendUnModifiedUrlToBackend() protected method

_vcl_acl() protected method

Format a VCL ACL declaration
protected _vcl_acl ( string $name, array $hosts ) : string
$name string ACL name
$hosts array list of hosts to add to the ACL
return string

_vcl_backend() protected method

Format a VCL backend declaration
protected _vcl_backend ( string $name, string $host, string $port, array $options = [] ) : string
$name string name of the backend
$host string backend host
$port string backend port
$options array options
return string

_vcl_call() protected method

Format a VCL subroutine call
protected _vcl_call ( string $subroutine ) : string
$subroutine string subroutine name
return string

_vcl_director() protected method

Format a VCL director declaration, for load balancing
protected _vcl_director ( string $name, array $backendOptions ) : string
$name string name of the director, also used to select config settings
$backendOptions array options for each backend
return string

_vcl_director_backend() protected method

Format a VCL backend declaration to put inside director
protected _vcl_director_backend ( string $host, string $port, string $probeUrl = '', array $options = [] ) : string
$host string backend host
$port string backend port
$probeUrl string URL to check if backend is up
$options array extra options for backend
return string

_vcl_get_probe() protected method

Format a VCL probe declaration to put in backend which is in director
protected _vcl_get_probe ( string $probeUrl ) : string
$probeUrl string URL to check if backend is up
return string

_vcl_sub_allowed_hosts_regex() protected method

Get the Host normalization sub routine
protected _vcl_sub_allowed_hosts_regex ( ) : string
return string

_vcl_sub_https_redirect_fix() protected method

When using Varnish as front door listen on port 80 and Nginx/Apache listen on port 443 for HTTPS, the fix will keep the url parameters when redirect from HTTP to HTTPS.
protected _vcl_sub_https_redirect_fix ( ) : string
return string

_vcl_sub_maintenance_allowed_ips() protected method

Get the allowed IPs when in maintenance mode

_vcl_sub_normalize_encoding() protected method

Get the Accept-Encoding normalization sub routine
protected _vcl_sub_normalize_encoding ( ) : string
return string

_vcl_sub_normalize_host() protected method

Get the Host normalization sub routine
protected _vcl_sub_normalize_host ( ) : string
return string

_vcl_sub_normalize_user_agent() protected method

Get the User-Agent normalization sub routine

_vcl_sub_synth() protected method

Get the allowed IPs when in maintenance mode
protected _vcl_sub_synth ( ) : string
return string

_vcl_sub_synth_https_fix() protected method

vcl_synth for fixing https
protected _vcl_sub_synth_https_fix ( ) : string
return string

generate() abstract public method

abstract public generate ( $doClean = true )

getAllowedHostsRegex() public method

ex: base_url: example.com path_regex: (example.com|example.net)
public getAllowedHostsRegex ( ) : string
return string

getBaseUrlPathRegex() public method

ex: base_url: http://example.com/magento/ path_regex: /magento/(?:(?:index|litespeed)\.php/)?
public getBaseUrlPathRegex ( ) : string
return string

getFromSocket() public static method

Get the correct version of a configurator from a socket
public static getFromSocket ( Nexcessnet_Turpentine_Model_Varnish_Admin_Socket $socket ) : Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract
$socket Nexcessnet_Turpentine_Model_Varnish_Admin_Socket
return Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract

save() public method

Save the generated config to the file specified in Magento config
public save ( string $generatedConfig ) : null
$generatedConfig string config generated by @generate
return null

Property Details

$_options protected_oe property

options array
protected array $_options
return array

$_socket protected_oe property

The socket this configurator is based on
protected Nexcessnet_Turpentine_Model_Varnish_Admin_Socket $_socket
return Nexcessnet_Turpentine_Model_Varnish_Admin_Socket