repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Model/Dummy/Request.php
Nexcessnet_Turpentine_Model_Dummy_Request.setQuery
public function setQuery($spec, $value = null) { if ((null === $value) && ! is_array($spec)) { #require_once 'Zend/Controller/Exception.php'; throw new Zend_Controller_Exception('Invalid value passed to setQuery(); must be either array of values or key/value pair'); } if ((null === $value) && is_array($spec)) { foreach ($spec as $key => $value) { $this->setQuery($key, $value); } return $this; } $this->GET[(string) $spec] = $value; return $this; }
php
public function setQuery($spec, $value = null) { if ((null === $value) && ! is_array($spec)) { #require_once 'Zend/Controller/Exception.php'; throw new Zend_Controller_Exception('Invalid value passed to setQuery(); must be either array of values or key/value pair'); } if ((null === $value) && is_array($spec)) { foreach ($spec as $key => $value) { $this->setQuery($key, $value); } return $this; } $this->GET[(string) $spec] = $value; return $this; }
[ "public", "function", "setQuery", "(", "$", "spec", ",", "$", "value", "=", "null", ")", "{", "if", "(", "(", "null", "===", "$", "value", ")", "&&", "!", "is_array", "(", "$", "spec", ")", ")", "{", "#require_once 'Zend/Controller/Exception.php';", "thr...
Set GET values @param string|array $spec @param null|mixed $value @return Zend_Controller_Request_Http
[ "Set", "GET", "values" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Dummy/Request.php#L120-L133
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Model/Dummy/Request.php
Nexcessnet_Turpentine_Model_Dummy_Request.setRequestUri
public function setRequestUri($requestUri = null) { if ($requestUri === null) { if (isset($this->SERVER['HTTP_X_REWRITE_URL'])) { // check this first so IIS will catch $requestUri = $this->SERVER['HTTP_X_REWRITE_URL']; } elseif ( // IIS7 with URL Rewrite: make sure we get the unencoded url (double slash problem) isset($this->SERVER['IIS_WasUrlRewritten']) && $this->SERVER['IIS_WasUrlRewritten'] == '1' && isset($this->SERVER['UNENCODED_URL']) && $this->SERVER['UNENCODED_URL'] != '' ) { $requestUri = $this->SERVER['UNENCODED_URL']; } elseif (isset($this->SERVER['REQUEST_URI'])) { $requestUri = $this->SERVER['REQUEST_URI']; // Http proxy reqs setup request uri with scheme and host [and port] + the url path, only use url path $schemeAndHttpHost = $this->getScheme().'://'.$this->getHttpHost(); if (strpos($requestUri, $schemeAndHttpHost) === 0) { $requestUri = substr($requestUri, strlen($schemeAndHttpHost)); } } elseif (isset($this->SERVER['ORIG_PATH_INFO'])) { // IIS 5.0, PHP as CGI $requestUri = $this->SERVER['ORIG_PATH_INFO']; if ( ! empty($this->SERVER['QUERY_STRING'])) { $requestUri .= '?'.$this->SERVER['QUERY_STRING']; } } else { return $this; } } elseif ( ! is_string($requestUri)) { return $this; } else { // Set GET items, if available if (false !== ($pos = strpos($requestUri, '?'))) { // Get key => value pairs and set $_GET $query = substr($requestUri, $pos + 1); parse_str($query, $vars); $this->setQuery($vars); } } $this->_requestUri = $requestUri; return $this; }
php
public function setRequestUri($requestUri = null) { if ($requestUri === null) { if (isset($this->SERVER['HTTP_X_REWRITE_URL'])) { // check this first so IIS will catch $requestUri = $this->SERVER['HTTP_X_REWRITE_URL']; } elseif ( // IIS7 with URL Rewrite: make sure we get the unencoded url (double slash problem) isset($this->SERVER['IIS_WasUrlRewritten']) && $this->SERVER['IIS_WasUrlRewritten'] == '1' && isset($this->SERVER['UNENCODED_URL']) && $this->SERVER['UNENCODED_URL'] != '' ) { $requestUri = $this->SERVER['UNENCODED_URL']; } elseif (isset($this->SERVER['REQUEST_URI'])) { $requestUri = $this->SERVER['REQUEST_URI']; // Http proxy reqs setup request uri with scheme and host [and port] + the url path, only use url path $schemeAndHttpHost = $this->getScheme().'://'.$this->getHttpHost(); if (strpos($requestUri, $schemeAndHttpHost) === 0) { $requestUri = substr($requestUri, strlen($schemeAndHttpHost)); } } elseif (isset($this->SERVER['ORIG_PATH_INFO'])) { // IIS 5.0, PHP as CGI $requestUri = $this->SERVER['ORIG_PATH_INFO']; if ( ! empty($this->SERVER['QUERY_STRING'])) { $requestUri .= '?'.$this->SERVER['QUERY_STRING']; } } else { return $this; } } elseif ( ! is_string($requestUri)) { return $this; } else { // Set GET items, if available if (false !== ($pos = strpos($requestUri, '?'))) { // Get key => value pairs and set $_GET $query = substr($requestUri, $pos + 1); parse_str($query, $vars); $this->setQuery($vars); } } $this->_requestUri = $requestUri; return $this; }
[ "public", "function", "setRequestUri", "(", "$", "requestUri", "=", "null", ")", "{", "if", "(", "$", "requestUri", "===", "null", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "SERVER", "[", "'HTTP_X_REWRITE_URL'", "]", ")", ")", "{", "// chec...
Set the REQUEST_URI on which the instance operates If no request URI is passed, uses the value in $_SERVER['REQUEST_URI'], $_SERVER['HTTP_X_REWRITE_URL'], or $_SERVER['ORIG_PATH_INFO'] + $_SERVER['QUERY_STRING']. @param string $requestUri @return Zend_Controller_Request_Http
[ "Set", "the", "REQUEST_URI", "on", "which", "the", "instance", "operates" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Dummy/Request.php#L252-L293
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Model/Dummy/Request.php
Nexcessnet_Turpentine_Model_Dummy_Request.setBasePath
public function setBasePath($basePath = null) { if ($basePath === null) { $filename = (isset($this->SERVER['SCRIPT_FILENAME'])) ? basename($this->SERVER['SCRIPT_FILENAME']) : ''; $baseUrl = $this->getBaseUrl(); if (empty($baseUrl)) { $this->_basePath = ''; return $this; } if (basename($baseUrl) === $filename) { $basePath = dirname($baseUrl); } else { $basePath = $baseUrl; } } if (substr(PHP_OS, 0, 3) === 'WIN') { $basePath = str_replace('\\', '/', $basePath); } $this->_basePath = rtrim($basePath, '/'); return $this; }
php
public function setBasePath($basePath = null) { if ($basePath === null) { $filename = (isset($this->SERVER['SCRIPT_FILENAME'])) ? basename($this->SERVER['SCRIPT_FILENAME']) : ''; $baseUrl = $this->getBaseUrl(); if (empty($baseUrl)) { $this->_basePath = ''; return $this; } if (basename($baseUrl) === $filename) { $basePath = dirname($baseUrl); } else { $basePath = $baseUrl; } } if (substr(PHP_OS, 0, 3) === 'WIN') { $basePath = str_replace('\\', '/', $basePath); } $this->_basePath = rtrim($basePath, '/'); return $this; }
[ "public", "function", "setBasePath", "(", "$", "basePath", "=", "null", ")", "{", "if", "(", "$", "basePath", "===", "null", ")", "{", "$", "filename", "=", "(", "isset", "(", "$", "this", "->", "SERVER", "[", "'SCRIPT_FILENAME'", "]", ")", ")", "?",...
Set the base path for the URL @param string|null $basePath @return Zend_Controller_Request_Http
[ "Set", "the", "base", "path", "for", "the", "URL" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Dummy/Request.php#L393-L418
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Model/Dummy/Request.php
Nexcessnet_Turpentine_Model_Dummy_Request.getParams
public function getParams() { $return = $this->_params; $paramSources = $this->getParamSources(); if (in_array('_GET', $paramSources) && isset($this->GET) && is_array($this->GET) ) { $return += $this->GET; } if (in_array('_POST', $paramSources) && isset($this->POST) && is_array($this->POST) ) { $return += $this->POST; } return $return; }
php
public function getParams() { $return = $this->_params; $paramSources = $this->getParamSources(); if (in_array('_GET', $paramSources) && isset($this->GET) && is_array($this->GET) ) { $return += $this->GET; } if (in_array('_POST', $paramSources) && isset($this->POST) && is_array($this->POST) ) { $return += $this->POST; } return $return; }
[ "public", "function", "getParams", "(", ")", "{", "$", "return", "=", "$", "this", "->", "_params", ";", "$", "paramSources", "=", "$", "this", "->", "getParamSources", "(", ")", ";", "if", "(", "in_array", "(", "'_GET'", ",", "$", "paramSources", ")",...
Retrieve an array of parameters Retrieves a merged array of parameters, with precedence of userland params (see {@link setParam()}), $_GET, $_POST (i.e., values in the userland params will take precedence over all others). @return array
[ "Retrieve", "an", "array", "of", "parameters" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Dummy/Request.php#L457-L473
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Model/Dummy/Request.php
Nexcessnet_Turpentine_Model_Dummy_Request._initFakeSuperGlobals
protected function _initFakeSuperGlobals() { $this->GET = array(); $this->POST = $_POST; $this->SERVER = $_SERVER; $this->ENV = $_ENV; }
php
protected function _initFakeSuperGlobals() { $this->GET = array(); $this->POST = $_POST; $this->SERVER = $_SERVER; $this->ENV = $_ENV; }
[ "protected", "function", "_initFakeSuperGlobals", "(", ")", "{", "$", "this", "->", "GET", "=", "array", "(", ")", ";", "$", "this", "->", "POST", "=", "$", "_POST", ";", "$", "this", "->", "SERVER", "=", "$", "_SERVER", ";", "$", "this", "->", "EN...
Init the fake superglobal vars @return null
[ "Init", "the", "fake", "superglobal", "vars" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Dummy/Request.php#L514-L519
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Model/Dummy/Request.php
Nexcessnet_Turpentine_Model_Dummy_Request._fixupFakeSuperGlobals
protected function _fixupFakeSuperGlobals($uri) { $uri = str_replace('|', urlencode('|'), $uri); $parsedUrl = parse_url($uri); if (isset($parsedUrl['path'])) { $this->SERVER['REQUEST_URI'] = $parsedUrl['path']; } if (isset($parsedUrl['query']) && $parsedUrl['query']) { $this->SERVER['QUERY_STRING'] = $parsedUrl['query']; $this->SERVER['REQUEST_URI'] .= '?'.$this->SERVER['QUERY_STRING']; } else { $this->SERVER['QUERY_STRING'] = null; } parse_str($this->SERVER['QUERY_STRING'], $this->GET); if (isset($this->SERVER['SCRIPT_URI'])) { $start = strpos($this->SERVER['SCRIPT_URI'], '/', 9); $sub = substr($this->SERVER['SCRIPT_URI'], $start); $this->SERVER['SCRIPT_URI'] = substr( $this->SERVER['SCRIPT_URI'], 0, $start ). @str_replace( $this->SERVER['SCRIPT_URL'], $parsedUrl['path'], $sub, $c = 1 ); } if (isset($this->SERVER['SCRIPT_URL'])) { $this->SERVER['SCRIPT_URL'] = $parsedUrl['path']; } }
php
protected function _fixupFakeSuperGlobals($uri) { $uri = str_replace('|', urlencode('|'), $uri); $parsedUrl = parse_url($uri); if (isset($parsedUrl['path'])) { $this->SERVER['REQUEST_URI'] = $parsedUrl['path']; } if (isset($parsedUrl['query']) && $parsedUrl['query']) { $this->SERVER['QUERY_STRING'] = $parsedUrl['query']; $this->SERVER['REQUEST_URI'] .= '?'.$this->SERVER['QUERY_STRING']; } else { $this->SERVER['QUERY_STRING'] = null; } parse_str($this->SERVER['QUERY_STRING'], $this->GET); if (isset($this->SERVER['SCRIPT_URI'])) { $start = strpos($this->SERVER['SCRIPT_URI'], '/', 9); $sub = substr($this->SERVER['SCRIPT_URI'], $start); $this->SERVER['SCRIPT_URI'] = substr( $this->SERVER['SCRIPT_URI'], 0, $start ). @str_replace( $this->SERVER['SCRIPT_URL'], $parsedUrl['path'], $sub, $c = 1 ); } if (isset($this->SERVER['SCRIPT_URL'])) { $this->SERVER['SCRIPT_URL'] = $parsedUrl['path']; } }
[ "protected", "function", "_fixupFakeSuperGlobals", "(", "$", "uri", ")", "{", "$", "uri", "=", "str_replace", "(", "'|'", ",", "urlencode", "(", "'|'", ")", ",", "$", "uri", ")", ";", "$", "parsedUrl", "=", "parse_url", "(", "$", "uri", ")", ";", "if...
Fix up the fake superglobal vars @param string $uri @return null
[ "Fix", "up", "the", "fake", "superglobal", "vars" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Dummy/Request.php#L527-L553
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/controllers/Adminhtml/CacheController.php
Nexcessnet_Turpentine_Adminhtml_CacheController.massEnableAction
public function massEnableAction() { $types = $this->getRequest()->getParam('types'); $allTypes = Mage::app()->useCache(); $updatedTypes = 0; foreach ($types as $code) { if (empty($allTypes[$code])) { $allTypes[$code] = 1; $updatedTypes++; } } if ($updatedTypes > 0) { // disable FPC when Varnish cache is enabled: if ($allTypes['turpentine_pages'] == 1 || $allTypes['turpentine_esi_blocks'] == 1) { $allTypes['full_page'] = 0; Mage::getSingleton('core/session')->addSuccess(Mage::helper('adminhtml')->__("Full page cache has been disabled since Varnish cache is enabled.")); } else if ($allTypes['full_page'] == 1) { Mage::getSingleton('core/session')->addSuccess(Mage::helper('adminhtml')->__("Turpentine cache has been disabled since Full Page cache is enabled.")); } // disable FPC when Varnish cache is enabled. Mage::app()->saveUseCache($allTypes); $this->_getSession()->addSuccess(Mage::helper('adminhtml')->__("%s cache type(s) enabled.", $updatedTypes)); } $this->_redirect('*/*'); }
php
public function massEnableAction() { $types = $this->getRequest()->getParam('types'); $allTypes = Mage::app()->useCache(); $updatedTypes = 0; foreach ($types as $code) { if (empty($allTypes[$code])) { $allTypes[$code] = 1; $updatedTypes++; } } if ($updatedTypes > 0) { // disable FPC when Varnish cache is enabled: if ($allTypes['turpentine_pages'] == 1 || $allTypes['turpentine_esi_blocks'] == 1) { $allTypes['full_page'] = 0; Mage::getSingleton('core/session')->addSuccess(Mage::helper('adminhtml')->__("Full page cache has been disabled since Varnish cache is enabled.")); } else if ($allTypes['full_page'] == 1) { Mage::getSingleton('core/session')->addSuccess(Mage::helper('adminhtml')->__("Turpentine cache has been disabled since Full Page cache is enabled.")); } // disable FPC when Varnish cache is enabled. Mage::app()->saveUseCache($allTypes); $this->_getSession()->addSuccess(Mage::helper('adminhtml')->__("%s cache type(s) enabled.", $updatedTypes)); } $this->_redirect('*/*'); }
[ "public", "function", "massEnableAction", "(", ")", "{", "$", "types", "=", "$", "this", "->", "getRequest", "(", ")", "->", "getParam", "(", "'types'", ")", ";", "$", "allTypes", "=", "Mage", "::", "app", "(", ")", "->", "useCache", "(", ")", ";", ...
Mass action for cache enabeling
[ "Mass", "action", "for", "cache", "enabeling" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/controllers/Adminhtml/CacheController.php#L15-L41
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/controllers/Varnish/ManagementController.php
Nexcessnet_Turpentine_Varnish_ManagementController.flushAllAction
public function flushAllAction() { Mage::dispatchEvent('turpentine_varnish_flush_all'); $result = Mage::getModel('turpentine/varnish_admin')->flushAll(); foreach ($result as $name => $value) { if ($value === true) { $this->_getSession() ->addSuccess(Mage::helper('turpentine/data') ->__('Flushed Varnish cache for: ').$name); } else { $this->_getSession() ->addError(Mage::helper('turpentine/data') ->__('Error flushing Varnish cache on: ').$name); } } $this->_redirect('*/cache'); }
php
public function flushAllAction() { Mage::dispatchEvent('turpentine_varnish_flush_all'); $result = Mage::getModel('turpentine/varnish_admin')->flushAll(); foreach ($result as $name => $value) { if ($value === true) { $this->_getSession() ->addSuccess(Mage::helper('turpentine/data') ->__('Flushed Varnish cache for: ').$name); } else { $this->_getSession() ->addError(Mage::helper('turpentine/data') ->__('Error flushing Varnish cache on: ').$name); } } $this->_redirect('*/cache'); }
[ "public", "function", "flushAllAction", "(", ")", "{", "Mage", "::", "dispatchEvent", "(", "'turpentine_varnish_flush_all'", ")", ";", "$", "result", "=", "Mage", "::", "getModel", "(", "'turpentine/varnish_admin'", ")", "->", "flushAll", "(", ")", ";", "foreach...
Full flush action, flushes all Magento URLs in Varnish cache @return null
[ "Full", "flush", "action", "flushes", "all", "Magento", "URLs", "in", "Varnish", "cache" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/controllers/Varnish/ManagementController.php#L46-L61
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/controllers/Varnish/ManagementController.php
Nexcessnet_Turpentine_Varnish_ManagementController.flushPartialAction
public function flushPartialAction() { $postData = $this->getRequest()->getPost(); if ( ! isset($postData['pattern'])) { $this->_getSession()->addError($this->__('Missing URL post data')); } else { $pattern = $postData['pattern']; Mage::dispatchEvent('turpentine_varnish_flush_partial', array('pattern' => $pattern)); $result = Mage::getModel('turpentine/varnish_admin') ->flushUrl($pattern); foreach ($result as $name => $value) { if ($value === true) { $this->_getSession() ->addSuccess(Mage::helper('turpentine/data') ->__('Flushed matching URLs for: ').$name); } else { $this->_getSession() ->addError(Mage::helper('turpentine/data') ->__('Error flushing matching URLs on: ').$name); } } } $this->_redirect('*/cache'); }
php
public function flushPartialAction() { $postData = $this->getRequest()->getPost(); if ( ! isset($postData['pattern'])) { $this->_getSession()->addError($this->__('Missing URL post data')); } else { $pattern = $postData['pattern']; Mage::dispatchEvent('turpentine_varnish_flush_partial', array('pattern' => $pattern)); $result = Mage::getModel('turpentine/varnish_admin') ->flushUrl($pattern); foreach ($result as $name => $value) { if ($value === true) { $this->_getSession() ->addSuccess(Mage::helper('turpentine/data') ->__('Flushed matching URLs for: ').$name); } else { $this->_getSession() ->addError(Mage::helper('turpentine/data') ->__('Error flushing matching URLs on: ').$name); } } } $this->_redirect('*/cache'); }
[ "public", "function", "flushPartialAction", "(", ")", "{", "$", "postData", "=", "$", "this", "->", "getRequest", "(", ")", "->", "getPost", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "postData", "[", "'pattern'", "]", ")", ")", "{", "$", "t...
Partial flush action, flushes Magento URLs matching "pattern" in POST data @return null
[ "Partial", "flush", "action", "flushes", "Magento", "URLs", "matching", "pattern", "in", "POST", "data" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/controllers/Varnish/ManagementController.php#L69-L92
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/controllers/Varnish/ManagementController.php
Nexcessnet_Turpentine_Varnish_ManagementController.applyConfigAction
public function applyConfigAction() { Mage::dispatchEvent('turpentine_varnish_apply_config'); $helper = Mage::helper('turpentine'); $result = Mage::getModel('turpentine/varnish_admin')->applyConfig($helper ->shouldStripVclWhitespace('apply') ); foreach ($result as $name => $value) { if ($value === true) { $this->_getSession() ->addSuccess($helper ->__('VCL successfully applied to '.$name)); } else { $this->_getSession() ->addError($helper ->__(sprintf('Failed to apply the VCL to %s: %s', $name, $value))); } } $this->_redirect('*/cache'); }
php
public function applyConfigAction() { Mage::dispatchEvent('turpentine_varnish_apply_config'); $helper = Mage::helper('turpentine'); $result = Mage::getModel('turpentine/varnish_admin')->applyConfig($helper ->shouldStripVclWhitespace('apply') ); foreach ($result as $name => $value) { if ($value === true) { $this->_getSession() ->addSuccess($helper ->__('VCL successfully applied to '.$name)); } else { $this->_getSession() ->addError($helper ->__(sprintf('Failed to apply the VCL to %s: %s', $name, $value))); } } $this->_redirect('*/cache'); }
[ "public", "function", "applyConfigAction", "(", ")", "{", "Mage", "::", "dispatchEvent", "(", "'turpentine_varnish_apply_config'", ")", ";", "$", "helper", "=", "Mage", "::", "helper", "(", "'turpentine'", ")", ";", "$", "result", "=", "Mage", "::", "getModel"...
Load the current VCL in varnish and activate it @return null
[ "Load", "the", "current", "VCL", "in", "varnish", "and", "activate", "it" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/controllers/Varnish/ManagementController.php#L129-L148
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/controllers/Varnish/ManagementController.php
Nexcessnet_Turpentine_Varnish_ManagementController.saveConfigAction
public function saveConfigAction() { $cfgr = Mage::getModel('turpentine/varnish_admin')->getConfigurator(); if (is_null($cfgr)) { $this->_getSession()->addError( $this->__('Failed to load configurator') ); } else { Mage::dispatchEvent('turpentine_varnish_save_config', array('cfgr' => $cfgr)); $result = $cfgr->save($cfgr->generate( Mage::helper('turpentine')->shouldStripVclWhitespace('save') )); if ($result[0]) { $this->_getSession() ->addSuccess(Mage::helper('turpentine') ->__('The VCL file has been saved.')); } else { $this->_getSession() ->addError(Mage::helper('turpentine') ->__('Failed to save the VCL file: '.$result[1]['message'])); } } $this->_redirect('*/cache'); }
php
public function saveConfigAction() { $cfgr = Mage::getModel('turpentine/varnish_admin')->getConfigurator(); if (is_null($cfgr)) { $this->_getSession()->addError( $this->__('Failed to load configurator') ); } else { Mage::dispatchEvent('turpentine_varnish_save_config', array('cfgr' => $cfgr)); $result = $cfgr->save($cfgr->generate( Mage::helper('turpentine')->shouldStripVclWhitespace('save') )); if ($result[0]) { $this->_getSession() ->addSuccess(Mage::helper('turpentine') ->__('The VCL file has been saved.')); } else { $this->_getSession() ->addError(Mage::helper('turpentine') ->__('Failed to save the VCL file: '.$result[1]['message'])); } } $this->_redirect('*/cache'); }
[ "public", "function", "saveConfigAction", "(", ")", "{", "$", "cfgr", "=", "Mage", "::", "getModel", "(", "'turpentine/varnish_admin'", ")", "->", "getConfigurator", "(", ")", ";", "if", "(", "is_null", "(", "$", "cfgr", ")", ")", "{", "$", "this", "->",...
Save the config to the configured file action @return null
[ "Save", "the", "config", "to", "the", "configured", "file", "action" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/controllers/Varnish/ManagementController.php#L155-L176
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/controllers/Varnish/ManagementController.php
Nexcessnet_Turpentine_Varnish_ManagementController.getConfigAction
public function getConfigAction() { $cfgr = Mage::getModel('turpentine/varnish_admin') ->getConfigurator(); if (is_null($cfgr)) { $this->_getSession()->addError($this->__('Failed to load configurator')); $this->_redirect('*/cache'); } else { $vcl = $cfgr->generate( Mage::helper('turpentine')->shouldStripVclWhitespace('download') ); $this->getResponse() ->setHttpResponseCode(200) ->setHeader('Content-Type', 'text/plain', true) ->setHeader('Content-Length', strlen($vcl)) ->setHeader('Content-Disposition', 'attachment; filename=default.vcl') ->setBody($vcl); return $this; } }
php
public function getConfigAction() { $cfgr = Mage::getModel('turpentine/varnish_admin') ->getConfigurator(); if (is_null($cfgr)) { $this->_getSession()->addError($this->__('Failed to load configurator')); $this->_redirect('*/cache'); } else { $vcl = $cfgr->generate( Mage::helper('turpentine')->shouldStripVclWhitespace('download') ); $this->getResponse() ->setHttpResponseCode(200) ->setHeader('Content-Type', 'text/plain', true) ->setHeader('Content-Length', strlen($vcl)) ->setHeader('Content-Disposition', 'attachment; filename=default.vcl') ->setBody($vcl); return $this; } }
[ "public", "function", "getConfigAction", "(", ")", "{", "$", "cfgr", "=", "Mage", "::", "getModel", "(", "'turpentine/varnish_admin'", ")", "->", "getConfigurator", "(", ")", ";", "if", "(", "is_null", "(", "$", "cfgr", ")", ")", "{", "$", "this", "->", ...
Present the generated config for download @return $this
[ "Present", "the", "generated", "config", "for", "download" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/controllers/Varnish/ManagementController.php#L183-L201
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/controllers/Varnish/ManagementController.php
Nexcessnet_Turpentine_Varnish_ManagementController.switchNavigationAction
public function switchNavigationAction() { $type = $this->getRequest()->get('type'); if (is_null($type)) { $this->_redirect('noRoute'); return; } $cookieName = Mage::helper('turpentine')->getBypassCookieName(); $cookieModel = Mage::getModel('core/cookie'); $adminSession = Mage::getSingleton('adminhtml/session'); switch ($type) { case 'default': $cookieModel->set( $cookieName, Mage::helper('turpentine/varnish')->getSecretHandshake(), null, // period null, // path null, // domain false, // secure true ); // httponly $adminSession->addSuccess(Mage::helper('turpentine/data') ->__('The Varnish bypass cookie has been successfully added.')); break; case 'varnish': $cookieModel->delete($cookieName); $adminSession->addSuccess(Mage::helper('turpentine/data') ->__('The Varnish bypass cookie has been successfully removed.')); break; default: $adminSession->addError(Mage::helper('turpentine/data') ->__('The given navigation type is not supported!')); break; } $this->_redirectReferer(); }
php
public function switchNavigationAction() { $type = $this->getRequest()->get('type'); if (is_null($type)) { $this->_redirect('noRoute'); return; } $cookieName = Mage::helper('turpentine')->getBypassCookieName(); $cookieModel = Mage::getModel('core/cookie'); $adminSession = Mage::getSingleton('adminhtml/session'); switch ($type) { case 'default': $cookieModel->set( $cookieName, Mage::helper('turpentine/varnish')->getSecretHandshake(), null, // period null, // path null, // domain false, // secure true ); // httponly $adminSession->addSuccess(Mage::helper('turpentine/data') ->__('The Varnish bypass cookie has been successfully added.')); break; case 'varnish': $cookieModel->delete($cookieName); $adminSession->addSuccess(Mage::helper('turpentine/data') ->__('The Varnish bypass cookie has been successfully removed.')); break; default: $adminSession->addError(Mage::helper('turpentine/data') ->__('The given navigation type is not supported!')); break; } $this->_redirectReferer(); }
[ "public", "function", "switchNavigationAction", "(", ")", "{", "$", "type", "=", "$", "this", "->", "getRequest", "(", ")", "->", "get", "(", "'type'", ")", ";", "if", "(", "is_null", "(", "$", "type", ")", ")", "{", "$", "this", "->", "_redirect", ...
Activate or deactivate the Varnish bypass @return void
[ "Activate", "or", "deactivate", "the", "Varnish", "bypass" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/controllers/Varnish/ManagementController.php#L208-L246
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Block/Adminhtml/Cache/Grid.php
Nexcessnet_Turpentine_Block_Adminhtml_Cache_Grid._prepareCollection
protected function _prepareCollection() { parent::_prepareCollection(); $collection = $this->getCollection(); $turpentineEnabled = false; $fullPageEnabled = false; foreach ($collection as $key=>$item) { if ($item->getStatus() == 1 && ($item->getId() == 'turpentine_pages' || $item->getId() == 'turpentine_esi_blocks')) { $turpentineEnabled = true; } if ($item->getStatus() == 1 && $item->getId() == 'full_page') { $fullPageEnabled = true; } } if ($turpentineEnabled && !$fullPageEnabled) { $collection->removeItemByKey('full_page'); } if ($fullPageEnabled && !$turpentineEnabled) { $collection->removeItemByKey('turpentine_pages'); $collection->removeItemByKey('turpentine_esi_blocks'); } $this->setCollection($collection); return $this; }
php
protected function _prepareCollection() { parent::_prepareCollection(); $collection = $this->getCollection(); $turpentineEnabled = false; $fullPageEnabled = false; foreach ($collection as $key=>$item) { if ($item->getStatus() == 1 && ($item->getId() == 'turpentine_pages' || $item->getId() == 'turpentine_esi_blocks')) { $turpentineEnabled = true; } if ($item->getStatus() == 1 && $item->getId() == 'full_page') { $fullPageEnabled = true; } } if ($turpentineEnabled && !$fullPageEnabled) { $collection->removeItemByKey('full_page'); } if ($fullPageEnabled && !$turpentineEnabled) { $collection->removeItemByKey('turpentine_pages'); $collection->removeItemByKey('turpentine_esi_blocks'); } $this->setCollection($collection); return $this; }
[ "protected", "function", "_prepareCollection", "(", ")", "{", "parent", "::", "_prepareCollection", "(", ")", ";", "$", "collection", "=", "$", "this", "->", "getCollection", "(", ")", ";", "$", "turpentineEnabled", "=", "false", ";", "$", "fullPageEnabled", ...
Prepare grid collection
[ "Prepare", "grid", "collection" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Block/Adminhtml/Cache/Grid.php#L14-L37
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Model/Core/Session.php
Nexcessnet_Turpentine_Model_Core_Session.getFormKey
public function getFormKey() { if (Mage::registry('replace_form_key') && ! Mage::app()->getRequest()->getParam('form_key', false)) { // flag request for ESI processing Mage::register('turpentine_esi_flag', true, true); return '{{form_key_esi_placeholder}}'; } else { return parent::getFormKey(); } }
php
public function getFormKey() { if (Mage::registry('replace_form_key') && ! Mage::app()->getRequest()->getParam('form_key', false)) { // flag request for ESI processing Mage::register('turpentine_esi_flag', true, true); return '{{form_key_esi_placeholder}}'; } else { return parent::getFormKey(); } }
[ "public", "function", "getFormKey", "(", ")", "{", "if", "(", "Mage", "::", "registry", "(", "'replace_form_key'", ")", "&&", "!", "Mage", "::", "app", "(", ")", "->", "getRequest", "(", ")", "->", "getParam", "(", "'form_key'", ",", "false", ")", ")",...
Retrieve Session Form Key @return string A 16 bit unique key for forms
[ "Retrieve", "Session", "Form", "Key" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Core/Session.php#L34-L44
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Helper/Ban.php
Nexcessnet_Turpentine_Helper_Ban.getParentProducts
public function getParentProducts($childProduct) { $parentProducts = array(); foreach (array('configurable', 'grouped') as $pType) { foreach (Mage::getModel('catalog/product_type_'.$pType) ->getParentIdsByChild($childProduct->getId()) as $parentId) { $parentProducts[] = Mage::getModel('catalog/product') ->load($parentId); } } return $parentProducts; }
php
public function getParentProducts($childProduct) { $parentProducts = array(); foreach (array('configurable', 'grouped') as $pType) { foreach (Mage::getModel('catalog/product_type_'.$pType) ->getParentIdsByChild($childProduct->getId()) as $parentId) { $parentProducts[] = Mage::getModel('catalog/product') ->load($parentId); } } return $parentProducts; }
[ "public", "function", "getParentProducts", "(", "$", "childProduct", ")", "{", "$", "parentProducts", "=", "array", "(", ")", ";", "foreach", "(", "array", "(", "'configurable'", ",", "'grouped'", ")", "as", "$", "pType", ")", "{", "foreach", "(", "Mage", ...
Get parent products of a configurable or group product @param Mage_Catalog_Model_Product $childProduct @return array
[ "Get", "parent", "products", "of", "a", "configurable", "or", "group", "product" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Helper/Ban.php#L53-L63
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Helper/Debug.php
Nexcessnet_Turpentine_Helper_Debug.logInfo
public function logInfo($message) { if (func_num_args() > 1) { $message = $this->_prepareLogMessage(func_get_args()); } return $this->_log(Zend_Log::INFO, $message); }
php
public function logInfo($message) { if (func_num_args() > 1) { $message = $this->_prepareLogMessage(func_get_args()); } return $this->_log(Zend_Log::INFO, $message); }
[ "public", "function", "logInfo", "(", "$", "message", ")", "{", "if", "(", "func_num_args", "(", ")", ">", "1", ")", "{", "$", "message", "=", "$", "this", "->", "_prepareLogMessage", "(", "func_get_args", "(", ")", ")", ";", "}", "return", "$", "thi...
Logs info. @param $message @return string
[ "Logs", "info", "." ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Helper/Debug.php#L74-L81
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Helper/Debug.php
Nexcessnet_Turpentine_Helper_Debug.logDebug
public function logDebug($message) { if ( ! Mage::helper('turpentine/varnish')->getVarnishDebugEnabled()) { return; } if (func_num_args() > 1) { $message = $this->_prepareLogMessage(func_get_args()); } return $this->_log(Zend_Log::DEBUG, $message); }
php
public function logDebug($message) { if ( ! Mage::helper('turpentine/varnish')->getVarnishDebugEnabled()) { return; } if (func_num_args() > 1) { $message = $this->_prepareLogMessage(func_get_args()); } return $this->_log(Zend_Log::DEBUG, $message); }
[ "public", "function", "logDebug", "(", "$", "message", ")", "{", "if", "(", "!", "Mage", "::", "helper", "(", "'turpentine/varnish'", ")", "->", "getVarnishDebugEnabled", "(", ")", ")", "{", "return", ";", "}", "if", "(", "func_num_args", "(", ")", ">", ...
Logs debug. @param $message @return string
[ "Logs", "debug", "." ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Helper/Debug.php#L89-L100
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Helper/Debug.php
Nexcessnet_Turpentine_Helper_Debug._prepareLogMessage
protected function _prepareLogMessage(array $args) { $pattern = $args[0]; $substitutes = array_slice($args, 1); if ( ! $this->_validatePattern($pattern, $substitutes)) { return $pattern; } return vsprintf($pattern, $substitutes); }
php
protected function _prepareLogMessage(array $args) { $pattern = $args[0]; $substitutes = array_slice($args, 1); if ( ! $this->_validatePattern($pattern, $substitutes)) { return $pattern; } return vsprintf($pattern, $substitutes); }
[ "protected", "function", "_prepareLogMessage", "(", "array", "$", "args", ")", "{", "$", "pattern", "=", "$", "args", "[", "0", "]", ";", "$", "substitutes", "=", "array_slice", "(", "$", "args", ",", "1", ")", ";", "if", "(", "!", "$", "this", "->...
Prepares advanced log message. @param array $args @return string
[ "Prepares", "advanced", "log", "message", "." ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Helper/Debug.php#L108-L118
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Helper/Debug.php
Nexcessnet_Turpentine_Helper_Debug.logBackTrace
public function logBackTrace($backTrace = null) { if (is_null($backTrace)) { $backTrace = debug_backtrace(); array_shift($backTrace); } $btuuid = Mage::helper('turpentine/data')->generateUuid(); $this->log('TRACEBACK: START ** %s **', $btuuid); $this->log('TRACEBACK: URL: %s', $_SERVER['REQUEST_URI']); for ($i = 0; $i < count($backTrace); $i++) { $line = $backTrace[$i]; $this->log('TRACEBACK: #%02d: %s:%d', $i, $line['file'], $line['line']); $this->log('TRACEBACK: ==> %s%s%s(%s)', (is_object(@$line['object']) ? get_class($line['object']) : @$line['class']), @$line['type'], $line['function'], $this->_backtrace_formatArgs($line['args'])); } $this->log('TRACEBACK: END ** %s **', $btuuid); }
php
public function logBackTrace($backTrace = null) { if (is_null($backTrace)) { $backTrace = debug_backtrace(); array_shift($backTrace); } $btuuid = Mage::helper('turpentine/data')->generateUuid(); $this->log('TRACEBACK: START ** %s **', $btuuid); $this->log('TRACEBACK: URL: %s', $_SERVER['REQUEST_URI']); for ($i = 0; $i < count($backTrace); $i++) { $line = $backTrace[$i]; $this->log('TRACEBACK: #%02d: %s:%d', $i, $line['file'], $line['line']); $this->log('TRACEBACK: ==> %s%s%s(%s)', (is_object(@$line['object']) ? get_class($line['object']) : @$line['class']), @$line['type'], $line['function'], $this->_backtrace_formatArgs($line['args'])); } $this->log('TRACEBACK: END ** %s **', $btuuid); }
[ "public", "function", "logBackTrace", "(", "$", "backTrace", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "backTrace", ")", ")", "{", "$", "backTrace", "=", "debug_backtrace", "(", ")", ";", "array_shift", "(", "$", "backTrace", ")", ";", "}"...
Log a backtrace, can pass a already generated backtrace to use @param array $backTrace @return null
[ "Log", "a", "backtrace", "can", "pass", "a", "already", "generated", "backtrace", "to", "use" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Helper/Debug.php#L167-L187
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Helper/Debug.php
Nexcessnet_Turpentine_Helper_Debug.logValue
public function logValue($value, $name = null) { if (is_null($name)) { $name = 'VALUE'; } $this->log('%s => %s', $name, $this->_backtrace_formatArgsHelper($value)); }
php
public function logValue($value, $name = null) { if (is_null($name)) { $name = 'VALUE'; } $this->log('%s => %s', $name, $this->_backtrace_formatArgsHelper($value)); }
[ "public", "function", "logValue", "(", "$", "value", ",", "$", "name", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "name", ")", ")", "{", "$", "name", "=", "'VALUE'", ";", "}", "$", "this", "->", "log", "(", "'%s => %s'", ",", "$", "...
Like var_dump to the log @param mixed $value @return null
[ "Like", "var_dump", "to", "the", "log" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Helper/Debug.php#L195-L201
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Helper/Debug.php
Nexcessnet_Turpentine_Helper_Debug._log
protected function _log($level, $message) { $message = 'TURPENTINE: '.$message; Mage::log($message, $level, $this->_getLogFileName()); return $message; }
php
protected function _log($level, $message) { $message = 'TURPENTINE: '.$message; Mage::log($message, $level, $this->_getLogFileName()); return $message; }
[ "protected", "function", "_log", "(", "$", "level", ",", "$", "message", ")", "{", "$", "message", "=", "'TURPENTINE: '", ".", "$", "message", ";", "Mage", "::", "log", "(", "$", "message", ",", "$", "level", ",", "$", "this", "->", "_getLogFileName", ...
Log a message through Magento's logging facility @param int $level @param string $message @return string
[ "Log", "a", "message", "through", "Magento", "s", "logging", "facility" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Helper/Debug.php#L210-L214
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Helper/Debug.php
Nexcessnet_Turpentine_Helper_Debug._backtrace_formatArgsHelper
protected function _backtrace_formatArgsHelper($arg) { $value = $arg; if (is_object($arg)) { $value = sprintf('OBJECT(%s)', get_class($arg)); } elseif (is_resource($arg)) { $value = 'RESOURCE'; } elseif (is_array($arg)) { $value = 'ARRAY[%s](%s)'; $c = array(); foreach ($arg as $k => $v) { $c[] = sprintf('%s => %s', $k, $this->_backtrace_formatArgsHelper($v)); } $value = sprintf($value, count($arg), implode(', ', $c)); } elseif (is_string($arg)) { $value = sprintf('\'%s\'', $arg); } elseif (is_bool($arg)) { $value = $arg ? 'TRUE' : 'FALSE'; } elseif (is_null($arg)) { $value = 'NULL'; } return $value; }
php
protected function _backtrace_formatArgsHelper($arg) { $value = $arg; if (is_object($arg)) { $value = sprintf('OBJECT(%s)', get_class($arg)); } elseif (is_resource($arg)) { $value = 'RESOURCE'; } elseif (is_array($arg)) { $value = 'ARRAY[%s](%s)'; $c = array(); foreach ($arg as $k => $v) { $c[] = sprintf('%s => %s', $k, $this->_backtrace_formatArgsHelper($v)); } $value = sprintf($value, count($arg), implode(', ', $c)); } elseif (is_string($arg)) { $value = sprintf('\'%s\'', $arg); } elseif (is_bool($arg)) { $value = $arg ? 'TRUE' : 'FALSE'; } elseif (is_null($arg)) { $value = 'NULL'; } return $value; }
[ "protected", "function", "_backtrace_formatArgsHelper", "(", "$", "arg", ")", "{", "$", "value", "=", "$", "arg", ";", "if", "(", "is_object", "(", "$", "arg", ")", ")", "{", "$", "value", "=", "sprintf", "(", "'OBJECT(%s)'", ",", "get_class", "(", "$"...
Format a value for inclusion in the backtrace @param mixed $arg @return null
[ "Format", "a", "value", "for", "inclusion", "in", "the", "backtrace" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Helper/Debug.php#L266-L288
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Helper/Cron.php
Nexcessnet_Turpentine_Helper_Cron.addUrlsToCrawlerQueue
public function addUrlsToCrawlerQueue(array $urls) { // TODO: remove this debug message if ($this->getCrawlerDebugEnabled()) { foreach ($urls as $url) { Mage::helper('turpentine/debug')->log( 'Adding URL to queue: %s', $url ); } } $oldQueue = $this->_readUrlQueue(); $newQueue = array_unique(array_merge($oldQueue, $urls)); $this->_writeUrlQueue($newQueue); $diff = count($newQueue) - count($oldQueue); return $diff; }
php
public function addUrlsToCrawlerQueue(array $urls) { // TODO: remove this debug message if ($this->getCrawlerDebugEnabled()) { foreach ($urls as $url) { Mage::helper('turpentine/debug')->log( 'Adding URL to queue: %s', $url ); } } $oldQueue = $this->_readUrlQueue(); $newQueue = array_unique(array_merge($oldQueue, $urls)); $this->_writeUrlQueue($newQueue); $diff = count($newQueue) - count($oldQueue); return $diff; }
[ "public", "function", "addUrlsToCrawlerQueue", "(", "array", "$", "urls", ")", "{", "// TODO: remove this debug message", "if", "(", "$", "this", "->", "getCrawlerDebugEnabled", "(", ")", ")", "{", "foreach", "(", "$", "urls", "as", "$", "url", ")", "{", "Ma...
Add a list of URLs to the queue, returns how many unique URLs were actually added to the queue @param array $urls @return int
[ "Add", "a", "list", "of", "URLs", "to", "the", "queue", "returns", "how", "many", "unique", "URLs", "were", "actually", "added", "to", "the", "queue" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Helper/Cron.php#L75-L88
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Helper/Cron.php
Nexcessnet_Turpentine_Helper_Cron.getNextUrl
public function getNextUrl() { $urls = $this->_readUrlQueue(); $nextUrl = array_shift($urls); $this->_writeUrlQueue($urls); return $nextUrl; }
php
public function getNextUrl() { $urls = $this->_readUrlQueue(); $nextUrl = array_shift($urls); $this->_writeUrlQueue($urls); return $nextUrl; }
[ "public", "function", "getNextUrl", "(", ")", "{", "$", "urls", "=", "$", "this", "->", "_readUrlQueue", "(", ")", ";", "$", "nextUrl", "=", "array_shift", "(", "$", "urls", ")", ";", "$", "this", "->", "_writeUrlQueue", "(", "$", "urls", ")", ";", ...
Pop a URL to crawl off the queue, or null if no URLs left @return string|null
[ "Pop", "a", "URL", "to", "crawl", "off", "the", "queue", "or", "null", "if", "no", "URLs", "left" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Helper/Cron.php#L95-L100
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Helper/Cron.php
Nexcessnet_Turpentine_Helper_Cron.getCrawlerClient
public function getCrawlerClient() { if (is_null($this->_crawlerClient)) { $this->_crawlerClient = new Varien_Http_Client(null, array( 'useragent' => sprintf( 'Nexcessnet_Turpentine/%s Magento/%s Varien_Http_Client', Mage::helper('turpentine/data')->getVersion(), Mage::getVersion() ), 'keepalive' => true, )); $this->_crawlerClient->setCookie('frontend', 'crawler-session'); } return $this->_crawlerClient; }
php
public function getCrawlerClient() { if (is_null($this->_crawlerClient)) { $this->_crawlerClient = new Varien_Http_Client(null, array( 'useragent' => sprintf( 'Nexcessnet_Turpentine/%s Magento/%s Varien_Http_Client', Mage::helper('turpentine/data')->getVersion(), Mage::getVersion() ), 'keepalive' => true, )); $this->_crawlerClient->setCookie('frontend', 'crawler-session'); } return $this->_crawlerClient; }
[ "public", "function", "getCrawlerClient", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "_crawlerClient", ")", ")", "{", "$", "this", "->", "_crawlerClient", "=", "new", "Varien_Http_Client", "(", "null", ",", "array", "(", "'useragent'", "=...
Get the crawler http client @return Varien_Http_Client
[ "Get", "the", "crawler", "http", "client" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Helper/Cron.php#L116-L128
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Helper/Cron.php
Nexcessnet_Turpentine_Helper_Cron.getAllUrls
public function getAllUrls() { $urls = array(); $origStore = Mage::app()->getStore(); $visibility = array( Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH, Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG, ); foreach (Mage::app()->getStores() as $storeId => $store) { Mage::app()->setCurrentStore($store); $baseUrl = $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK); $urls[] = $baseUrl; foreach (Mage::getModel('catalog/category') ->getCollection($storeId) ->addIsActiveFilter() as $cat) { $urls[] = $cat->getUrl(); foreach ($cat->getProductCollection($storeId) ->addUrlRewrite($cat->getId()) ->addAttributeToFilter('visibility', $visibility) as $prod) { $urls[] = $prod->getProductUrl(); } } $sitemap = (Mage::getConfig()->getNode('modules/MageWorx_XSitemap') !== FALSE) ? 'mageworx_xsitemap/cms_page' : 'sitemap/cms_page'; foreach (Mage::getResourceModel($sitemap) ->getCollection($storeId) as $item) { $urls[] = $baseUrl.$item->getUrl(); } } Mage::app()->setCurrentStore($origStore); return array_unique($urls); }
php
public function getAllUrls() { $urls = array(); $origStore = Mage::app()->getStore(); $visibility = array( Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH, Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG, ); foreach (Mage::app()->getStores() as $storeId => $store) { Mage::app()->setCurrentStore($store); $baseUrl = $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK); $urls[] = $baseUrl; foreach (Mage::getModel('catalog/category') ->getCollection($storeId) ->addIsActiveFilter() as $cat) { $urls[] = $cat->getUrl(); foreach ($cat->getProductCollection($storeId) ->addUrlRewrite($cat->getId()) ->addAttributeToFilter('visibility', $visibility) as $prod) { $urls[] = $prod->getProductUrl(); } } $sitemap = (Mage::getConfig()->getNode('modules/MageWorx_XSitemap') !== FALSE) ? 'mageworx_xsitemap/cms_page' : 'sitemap/cms_page'; foreach (Mage::getResourceModel($sitemap) ->getCollection($storeId) as $item) { $urls[] = $baseUrl.$item->getUrl(); } } Mage::app()->setCurrentStore($origStore); return array_unique($urls); }
[ "public", "function", "getAllUrls", "(", ")", "{", "$", "urls", "=", "array", "(", ")", ";", "$", "origStore", "=", "Mage", "::", "app", "(", ")", "->", "getStore", "(", ")", ";", "$", "visibility", "=", "array", "(", "Mage_Catalog_Model_Product_Visibili...
Get the list of all URLs @return array
[ "Get", "the", "list", "of", "all", "URLs" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Helper/Cron.php#L171-L203
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Helper/Cron.php
Nexcessnet_Turpentine_Helper_Cron.addProductToCrawlerQueue
public function addProductToCrawlerQueue($product) { $productUrls = array(); $origStore = Mage::app()->getStore(); foreach (Mage::app()->getStores() as $storeId => $store) { Mage::app()->setCurrentStore($store); $baseUrl = $store->getBaseUrl( Mage_Core_Model_Store::URL_TYPE_LINK ); $productUrls[] = $product->getProductUrl(); foreach ($product->getCategoryIds() as $catId) { $cat = Mage::getModel('catalog/category')->load($catId); $productUrls[] = rtrim($baseUrl, '/').'/'. ltrim($product->getUrlModel() ->getUrlPath($product, $cat), '/'); } } Mage::app()->setCurrentStore($origStore); return $this->addUrlsToCrawlerQueue($productUrls); }
php
public function addProductToCrawlerQueue($product) { $productUrls = array(); $origStore = Mage::app()->getStore(); foreach (Mage::app()->getStores() as $storeId => $store) { Mage::app()->setCurrentStore($store); $baseUrl = $store->getBaseUrl( Mage_Core_Model_Store::URL_TYPE_LINK ); $productUrls[] = $product->getProductUrl(); foreach ($product->getCategoryIds() as $catId) { $cat = Mage::getModel('catalog/category')->load($catId); $productUrls[] = rtrim($baseUrl, '/').'/'. ltrim($product->getUrlModel() ->getUrlPath($product, $cat), '/'); } } Mage::app()->setCurrentStore($origStore); return $this->addUrlsToCrawlerQueue($productUrls); }
[ "public", "function", "addProductToCrawlerQueue", "(", "$", "product", ")", "{", "$", "productUrls", "=", "array", "(", ")", ";", "$", "origStore", "=", "Mage", "::", "app", "(", ")", "->", "getStore", "(", ")", ";", "foreach", "(", "Mage", "::", "app"...
Add URLs to the queue by product model @param Mage_Catalog_Model_Product $product @return int
[ "Add", "URLs", "to", "the", "queue", "by", "product", "model" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Helper/Cron.php#L211-L228
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Helper/Cron.php
Nexcessnet_Turpentine_Helper_Cron.addCategoryToCrawlerQueue
public function addCategoryToCrawlerQueue($category) { $catUrls = array(); $origStore = Mage::app()->getStore(); foreach (Mage::app()->getStores() as $storeId => $store) { Mage::app()->setCurrentStore($store); $catUrls[] = $category->getUrl(); } Mage::app()->setCurrentStore($origStore); return $this->addUrlsToCrawlerQueue($catUrls); }
php
public function addCategoryToCrawlerQueue($category) { $catUrls = array(); $origStore = Mage::app()->getStore(); foreach (Mage::app()->getStores() as $storeId => $store) { Mage::app()->setCurrentStore($store); $catUrls[] = $category->getUrl(); } Mage::app()->setCurrentStore($origStore); return $this->addUrlsToCrawlerQueue($catUrls); }
[ "public", "function", "addCategoryToCrawlerQueue", "(", "$", "category", ")", "{", "$", "catUrls", "=", "array", "(", ")", ";", "$", "origStore", "=", "Mage", "::", "app", "(", ")", "->", "getStore", "(", ")", ";", "foreach", "(", "Mage", "::", "app", ...
Add URLs to the queue by category model @param Mage_Catalog_Model_Category $category @return int
[ "Add", "URLs", "to", "the", "queue", "by", "category", "model" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Helper/Cron.php#L236-L245
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Helper/Cron.php
Nexcessnet_Turpentine_Helper_Cron.addCmsPageToCrawlerQueue
public function addCmsPageToCrawlerQueue($cmsPageId) { $page = Mage::getModel('cms/page')->load($cmsPageId); $pageUrls = array(); $origStore = Mage::app()->getStore(); foreach (Mage::app()->getStores() as $storeId => $store) { Mage::app()->setCurrentStore($store); $page->setStoreId($storeId); $pageUrls[] = Mage::getUrl(null, array('_direct' => $page->getIdentifier())); } Mage::app()->setCurrentStore($origStore); return $this->addUrlsToCrawlerQueue($pageUrls); }
php
public function addCmsPageToCrawlerQueue($cmsPageId) { $page = Mage::getModel('cms/page')->load($cmsPageId); $pageUrls = array(); $origStore = Mage::app()->getStore(); foreach (Mage::app()->getStores() as $storeId => $store) { Mage::app()->setCurrentStore($store); $page->setStoreId($storeId); $pageUrls[] = Mage::getUrl(null, array('_direct' => $page->getIdentifier())); } Mage::app()->setCurrentStore($origStore); return $this->addUrlsToCrawlerQueue($pageUrls); }
[ "public", "function", "addCmsPageToCrawlerQueue", "(", "$", "cmsPageId", ")", "{", "$", "page", "=", "Mage", "::", "getModel", "(", "'cms/page'", ")", "->", "load", "(", "$", "cmsPageId", ")", ";", "$", "pageUrls", "=", "array", "(", ")", ";", "$", "or...
Add URLs to queue by CMS page ID @param int $cmsPageId @return int
[ "Add", "URLs", "to", "queue", "by", "CMS", "page", "ID" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Helper/Cron.php#L253-L265
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Helper/Cron.php
Nexcessnet_Turpentine_Helper_Cron._readUrlQueue
protected function _readUrlQueue() { $readQueue = @unserialize( Mage::app()->loadCache(self::CRAWLER_URLS_CACHE_ID) ); if ( ! is_array($readQueue)) { // This is the first time the queue has been read since the last // cache flush (or the queue is corrupt) // Returning an empty array here would be the proper behavior, // but causes the queue to not be saved on the full cache flush event return $this->getAllUrls(); } else { return $readQueue; } }
php
protected function _readUrlQueue() { $readQueue = @unserialize( Mage::app()->loadCache(self::CRAWLER_URLS_CACHE_ID) ); if ( ! is_array($readQueue)) { // This is the first time the queue has been read since the last // cache flush (or the queue is corrupt) // Returning an empty array here would be the proper behavior, // but causes the queue to not be saved on the full cache flush event return $this->getAllUrls(); } else { return $readQueue; } }
[ "protected", "function", "_readUrlQueue", "(", ")", "{", "$", "readQueue", "=", "@", "unserialize", "(", "Mage", "::", "app", "(", ")", "->", "loadCache", "(", "self", "::", "CRAWLER_URLS_CACHE_ID", ")", ")", ";", "if", "(", "!", "is_array", "(", "$", ...
Get the crawler URL queue from the cache @return array
[ "Get", "the", "crawler", "URL", "queue", "from", "the", "cache" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Helper/Cron.php#L272-L284
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Helper/Esi.php
Nexcessnet_Turpentine_Helper_Esi.getDummyRequest
public function getDummyRequest($url = null) { if ($url === null) { $url = $this->getDummyUrl(); } $request = Mage::getModel('turpentine/dummy_request', $url); $request->fakeRouterDispatch(); return $request; }
php
public function getDummyRequest($url = null) { if ($url === null) { $url = $this->getDummyUrl(); } $request = Mage::getModel('turpentine/dummy_request', $url); $request->fakeRouterDispatch(); return $request; }
[ "public", "function", "getDummyRequest", "(", "$", "url", "=", "null", ")", "{", "if", "(", "$", "url", "===", "null", ")", "{", "$", "url", "=", "$", "this", "->", "getDummyUrl", "(", ")", ";", "}", "$", "request", "=", "Mage", "::", "getModel", ...
Get mock request Used to pretend that the request was for the base URL instead of turpentine/esi/getBlock while rendering ESI blocks. Not perfect, but may be good enough @return Mage_Core_Controller_Request_Http
[ "Get", "mock", "request" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Helper/Esi.php#L179-L186
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Helper/Esi.php
Nexcessnet_Turpentine_Helper_Esi.getCacheClearEvents
public function getCacheClearEvents() { Varien_Profiler::start('turpentine::helper::esi::getCacheClearEvents'); $cacheKey = $this->getCacheClearEventsCacheKey(); $events = @unserialize(Mage::app()->loadCache($cacheKey)); if (is_null($events) || $events === false) { $events = $this->_loadEsiCacheClearEvents(); Mage::app()->saveCache(serialize($events), $cacheKey, array('LAYOUT_GENERAL_CACHE_TAG')); } Varien_Profiler::stop('turpentine::helper::esi::getCacheClearEvents'); return array_merge($this->getDefaultCacheClearEvents(), $events); }
php
public function getCacheClearEvents() { Varien_Profiler::start('turpentine::helper::esi::getCacheClearEvents'); $cacheKey = $this->getCacheClearEventsCacheKey(); $events = @unserialize(Mage::app()->loadCache($cacheKey)); if (is_null($events) || $events === false) { $events = $this->_loadEsiCacheClearEvents(); Mage::app()->saveCache(serialize($events), $cacheKey, array('LAYOUT_GENERAL_CACHE_TAG')); } Varien_Profiler::stop('turpentine::helper::esi::getCacheClearEvents'); return array_merge($this->getDefaultCacheClearEvents(), $events); }
[ "public", "function", "getCacheClearEvents", "(", ")", "{", "Varien_Profiler", "::", "start", "(", "'turpentine::helper::esi::getCacheClearEvents'", ")", ";", "$", "cacheKey", "=", "$", "this", "->", "getCacheClearEventsCacheKey", "(", ")", ";", "$", "events", "=", ...
Get the list of events that should cause the ESI cache to be cleared @return string[]
[ "Get", "the", "list", "of", "events", "that", "should", "cause", "the", "ESI", "cache", "to", "be", "cleared" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Helper/Esi.php#L215-L226
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Helper/Esi.php
Nexcessnet_Turpentine_Helper_Esi.getCorsOrigin
public function getCorsOrigin($url = null) { if (is_null($url)) { $baseUrl = Mage::getBaseUrl(); } else { $baseUrl = $url; } $path = parse_url($baseUrl, PHP_URL_PATH); $domain = parse_url($baseUrl, PHP_URL_HOST); // there has to be a better way to just strip the path off return substr($baseUrl, 0, strpos($baseUrl, $path, strpos($baseUrl, $domain))); }
php
public function getCorsOrigin($url = null) { if (is_null($url)) { $baseUrl = Mage::getBaseUrl(); } else { $baseUrl = $url; } $path = parse_url($baseUrl, PHP_URL_PATH); $domain = parse_url($baseUrl, PHP_URL_HOST); // there has to be a better way to just strip the path off return substr($baseUrl, 0, strpos($baseUrl, $path, strpos($baseUrl, $domain))); }
[ "public", "function", "getCorsOrigin", "(", "$", "url", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "url", ")", ")", "{", "$", "baseUrl", "=", "Mage", "::", "getBaseUrl", "(", ")", ";", "}", "else", "{", "$", "baseUrl", "=", "$", "url"...
Get the CORS origin field from the unsecure base URL If this isn't added to AJAX responses they won't load properly @return string
[ "Get", "the", "CORS", "origin", "field", "from", "the", "unsecure", "base", "URL" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Helper/Esi.php#L248-L260
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Helper/Esi.php
Nexcessnet_Turpentine_Helper_Esi.getLayoutXml
public function getLayoutXml() { Varien_Profiler::start('turpentine::helper::esi::getLayoutXml'); if (is_null($this->_layoutXml)) { if ($useCache = Mage::app()->useCache('layout')) { $cacheKey = $this->getFileLayoutUpdatesXmlCacheKey(); $this->_layoutXml = simplexml_load_string( Mage::app()->loadCache($cacheKey) ); } // this check is redundant if the layout cache is disabled if ( ! $this->_layoutXml) { $this->_layoutXml = $this->_loadLayoutXml(); if ($useCache) { Mage::app()->saveCache($this->_layoutXml->asXML(), $cacheKey, array('LAYOUT_GENERAL_CACHE_TAG')); } } } Varien_Profiler::stop('turpentine::helper::esi::getLayoutXml'); return $this->_layoutXml; }
php
public function getLayoutXml() { Varien_Profiler::start('turpentine::helper::esi::getLayoutXml'); if (is_null($this->_layoutXml)) { if ($useCache = Mage::app()->useCache('layout')) { $cacheKey = $this->getFileLayoutUpdatesXmlCacheKey(); $this->_layoutXml = simplexml_load_string( Mage::app()->loadCache($cacheKey) ); } // this check is redundant if the layout cache is disabled if ( ! $this->_layoutXml) { $this->_layoutXml = $this->_loadLayoutXml(); if ($useCache) { Mage::app()->saveCache($this->_layoutXml->asXML(), $cacheKey, array('LAYOUT_GENERAL_CACHE_TAG')); } } } Varien_Profiler::stop('turpentine::helper::esi::getLayoutXml'); return $this->_layoutXml; }
[ "public", "function", "getLayoutXml", "(", ")", "{", "Varien_Profiler", "::", "start", "(", "'turpentine::helper::esi::getLayoutXml'", ")", ";", "if", "(", "is_null", "(", "$", "this", "->", "_layoutXml", ")", ")", "{", "if", "(", "$", "useCache", "=", "Mage...
Get the layout's XML structure This is cached because it's expensive to load for each ESI'd block @return Mage_Core_Model_Layout_Element|SimpleXMLElement
[ "Get", "the", "layout", "s", "XML", "structure" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Helper/Esi.php#L269-L288
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Helper/Esi.php
Nexcessnet_Turpentine_Helper_Esi.getCacheClearEventsCacheKey
public function getCacheClearEventsCacheKey() { $design = Mage::getDesign(); return Mage::helper('turpentine/data') ->getCacheKeyHash(array( 'FILE_LAYOUT_ESI_CACHE_EVENTS', $design->getArea(), $design->getPackageName(), $design->getTheme('layout'), Mage::app()->getStore()->getId(), )); }
php
public function getCacheClearEventsCacheKey() { $design = Mage::getDesign(); return Mage::helper('turpentine/data') ->getCacheKeyHash(array( 'FILE_LAYOUT_ESI_CACHE_EVENTS', $design->getArea(), $design->getPackageName(), $design->getTheme('layout'), Mage::app()->getStore()->getId(), )); }
[ "public", "function", "getCacheClearEventsCacheKey", "(", ")", "{", "$", "design", "=", "Mage", "::", "getDesign", "(", ")", ";", "return", "Mage", "::", "helper", "(", "'turpentine/data'", ")", "->", "getCacheKeyHash", "(", "array", "(", "'FILE_LAYOUT_ESI_CACHE...
Get the cache key for the cache clear events @return string
[ "Get", "the", "cache", "key", "for", "the", "cache", "clear", "events" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Helper/Esi.php#L295-L305
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Helper/Esi.php
Nexcessnet_Turpentine_Helper_Esi.getFormKeyEsiUrl
public function getFormKeyEsiUrl() { $urlOptions = array( $this->getEsiTtlParam() => $this->getDefaultEsiTtl(), $this->getEsiMethodParam() => 'esi', $this->getEsiScopeParam() => 'global', $this->getEsiCacheTypeParam() => 'private', ); $esiUrl = Mage::getUrl('turpentine/esi/getFormKey', $urlOptions); // setting [web/unsecure/base_url] can be https://... but ESI can never be HTTPS $esiUrl = preg_replace('|^https://|i', 'http://', $esiUrl); return $esiUrl; }
php
public function getFormKeyEsiUrl() { $urlOptions = array( $this->getEsiTtlParam() => $this->getDefaultEsiTtl(), $this->getEsiMethodParam() => 'esi', $this->getEsiScopeParam() => 'global', $this->getEsiCacheTypeParam() => 'private', ); $esiUrl = Mage::getUrl('turpentine/esi/getFormKey', $urlOptions); // setting [web/unsecure/base_url] can be https://... but ESI can never be HTTPS $esiUrl = preg_replace('|^https://|i', 'http://', $esiUrl); return $esiUrl; }
[ "public", "function", "getFormKeyEsiUrl", "(", ")", "{", "$", "urlOptions", "=", "array", "(", "$", "this", "->", "getEsiTtlParam", "(", ")", "=>", "$", "this", "->", "getDefaultEsiTtl", "(", ")", ",", "$", "this", "->", "getEsiMethodParam", "(", ")", "=...
Get URL for grabbing form key via ESI @return string
[ "Get", "URL", "for", "grabbing", "form", "key", "via", "ESI" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Helper/Esi.php#L356-L367
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Helper/Esi.php
Nexcessnet_Turpentine_Helper_Esi.getEsiLayoutBlockNode
public function getEsiLayoutBlockNode($layout, $blockName) { // first try very specific by checking for action setEsiOptions inside block $blockNodes = $layout->getNode()->xpath( sprintf('//block[@name=\'%s\'][action[@method=\'setEsiOptions\']]', $blockName) ); $blockNode = end($blockNodes); // fallback: only match name if ( ! ($blockNode instanceof Mage_Core_Model_Layout_Element)) { $blockNodes = $layout->getNode()->xpath( sprintf('//block[@name=\'%s\']', $blockName) ); $blockNode = end($blockNodes); } return $blockNode; }
php
public function getEsiLayoutBlockNode($layout, $blockName) { // first try very specific by checking for action setEsiOptions inside block $blockNodes = $layout->getNode()->xpath( sprintf('//block[@name=\'%s\'][action[@method=\'setEsiOptions\']]', $blockName) ); $blockNode = end($blockNodes); // fallback: only match name if ( ! ($blockNode instanceof Mage_Core_Model_Layout_Element)) { $blockNodes = $layout->getNode()->xpath( sprintf('//block[@name=\'%s\']', $blockName) ); $blockNode = end($blockNodes); } return $blockNode; }
[ "public", "function", "getEsiLayoutBlockNode", "(", "$", "layout", ",", "$", "blockName", ")", "{", "// first try very specific by checking for action setEsiOptions inside block", "$", "blockNodes", "=", "$", "layout", "->", "getNode", "(", ")", "->", "xpath", "(", "s...
Grab a block node by name from the layout XML. Multiple blocks with the same name may exist in the layout, because some themes use 'unsetChild' to remove a block and create it with the same name somewhere else. For example Ultimo does this. @param Mage_Core_Model_Layout $layout @param string $blockName value of name= attribute in layout XML @return Mage_Core_Model_Layout_Element
[ "Grab", "a", "block", "node", "by", "name", "from", "the", "layout", "XML", "." ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Helper/Esi.php#L380-L395
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Helper/Esi.php
Nexcessnet_Turpentine_Helper_Esi._loadEsiCacheClearEvents
protected function _loadEsiCacheClearEvents() { Varien_Profiler::start('turpentine::helper::esi::_loadEsiCacheClearEvents'); $layoutXml = $this->getLayoutXml(); $events = $layoutXml->xpath( '//action[@method=\'setEsiOptions\']/params/flush_events/*' ); if ($events) { $events = array_unique(array_map( create_function('$e', 'return (string)$e->getName();'), $events )); } else { $events = array(); } Varien_Profiler::stop('turpentine::helper::esi::_loadEsiCacheClearEvents'); return $events; }
php
protected function _loadEsiCacheClearEvents() { Varien_Profiler::start('turpentine::helper::esi::_loadEsiCacheClearEvents'); $layoutXml = $this->getLayoutXml(); $events = $layoutXml->xpath( '//action[@method=\'setEsiOptions\']/params/flush_events/*' ); if ($events) { $events = array_unique(array_map( create_function('$e', 'return (string)$e->getName();'), $events )); } else { $events = array(); } Varien_Profiler::stop('turpentine::helper::esi::_loadEsiCacheClearEvents'); return $events; }
[ "protected", "function", "_loadEsiCacheClearEvents", "(", ")", "{", "Varien_Profiler", "::", "start", "(", "'turpentine::helper::esi::_loadEsiCacheClearEvents'", ")", ";", "$", "layoutXml", "=", "$", "this", "->", "getLayoutXml", "(", ")", ";", "$", "events", "=", ...
Load the ESI cache clear events from the layout @return array
[ "Load", "the", "ESI", "cache", "clear", "events", "from", "the", "layout" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Helper/Esi.php#L402-L417
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Helper/Esi.php
Nexcessnet_Turpentine_Helper_Esi._loadLayoutXml
protected function _loadLayoutXml() { Varien_Profiler::start('turpentine::helper::esi::_loadLayoutXml'); $design = Mage::getDesign(); $layoutXml = Mage::getSingleton('core/layout') ->getUpdate() ->getFileLayoutUpdatesXml( $design->getArea(), $design->getPackageName(), $design->getTheme('layout'), Mage::app()->getStore()->getId() ); Varien_Profiler::stop('turpentine::helper::esi::_loadLayoutXml'); return $layoutXml; }
php
protected function _loadLayoutXml() { Varien_Profiler::start('turpentine::helper::esi::_loadLayoutXml'); $design = Mage::getDesign(); $layoutXml = Mage::getSingleton('core/layout') ->getUpdate() ->getFileLayoutUpdatesXml( $design->getArea(), $design->getPackageName(), $design->getTheme('layout'), Mage::app()->getStore()->getId() ); Varien_Profiler::stop('turpentine::helper::esi::_loadLayoutXml'); return $layoutXml; }
[ "protected", "function", "_loadLayoutXml", "(", ")", "{", "Varien_Profiler", "::", "start", "(", "'turpentine::helper::esi::_loadLayoutXml'", ")", ";", "$", "design", "=", "Mage", "::", "getDesign", "(", ")", ";", "$", "layoutXml", "=", "Mage", "::", "getSinglet...
Load the layout's XML structure, bypassing any caching @return Mage_Core_Model_Layout_Element
[ "Load", "the", "layout", "s", "XML", "structure", "bypassing", "any", "caching" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Helper/Esi.php#L424-L436
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Model/Session.php
Nexcessnet_Turpentine_Model_Session.saveMessages
public function saveMessages($blockName, $messages) { $allMessages = $this->getMessages(); $allMessages[$blockName] = array_merge( $this->loadMessages($blockName), $messages ); $this->setMessages($allMessages); }
php
public function saveMessages($blockName, $messages) { $allMessages = $this->getMessages(); $allMessages[$blockName] = array_merge( $this->loadMessages($blockName), $messages ); $this->setMessages($allMessages); }
[ "public", "function", "saveMessages", "(", "$", "blockName", ",", "$", "messages", ")", "{", "$", "allMessages", "=", "$", "this", "->", "getMessages", "(", ")", ";", "$", "allMessages", "[", "$", "blockName", "]", "=", "array_merge", "(", "$", "this", ...
Save the messages for a given block to the session @param string $blockName @param array $messages @return null
[ "Save", "the", "messages", "for", "a", "given", "block", "to", "the", "session" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Session.php#L40-L45
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Model/Session.php
Nexcessnet_Turpentine_Model_Session.loadMessages
public function loadMessages($blockName) { $messages = $this->getMessages(); if (is_array(@$messages[$blockName])) { return $messages[$blockName]; } else { return array(); } }
php
public function loadMessages($blockName) { $messages = $this->getMessages(); if (is_array(@$messages[$blockName])) { return $messages[$blockName]; } else { return array(); } }
[ "public", "function", "loadMessages", "(", "$", "blockName", ")", "{", "$", "messages", "=", "$", "this", "->", "getMessages", "(", ")", ";", "if", "(", "is_array", "(", "@", "$", "messages", "[", "$", "blockName", "]", ")", ")", "{", "return", "$", ...
Retrieve the messages for a given messages block @param string $blockName @return array
[ "Retrieve", "the", "messages", "for", "a", "given", "messages", "block" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Session.php#L53-L60
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Model/Session.php
Nexcessnet_Turpentine_Model_Session.clearMessages
public function clearMessages($blockName) { $messages = $this->getMessages(); unset($messages[$blockName]); $this->setMessages($messages); }
php
public function clearMessages($blockName) { $messages = $this->getMessages(); unset($messages[$blockName]); $this->setMessages($messages); }
[ "public", "function", "clearMessages", "(", "$", "blockName", ")", "{", "$", "messages", "=", "$", "this", "->", "getMessages", "(", ")", ";", "unset", "(", "$", "messages", "[", "$", "blockName", "]", ")", ";", "$", "this", "->", "setMessages", "(", ...
Clear the messages stored for a block @param string $blockName @return null
[ "Clear", "the", "messages", "stored", "for", "a", "block" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Session.php#L68-L72
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Model/Session.php
Nexcessnet_Turpentine_Model_Session.getMessages
public function getMessages($clear = false) { $messages = $this->getData('messages'); if ( ! is_array($messages)) { $messages = array(); } return $messages; }
php
public function getMessages($clear = false) { $messages = $this->getData('messages'); if ( ! is_array($messages)) { $messages = array(); } return $messages; }
[ "public", "function", "getMessages", "(", "$", "clear", "=", "false", ")", "{", "$", "messages", "=", "$", "this", "->", "getData", "(", "'messages'", ")", ";", "if", "(", "!", "is_array", "(", "$", "messages", ")", ")", "{", "$", "messages", "=", ...
Retrieve the stored messages @return array
[ "Retrieve", "the", "stored", "messages" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Session.php#L79-L85
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Model/Observer/Varnish.php
Nexcessnet_Turpentine_Model_Observer_Varnish.fixCmRedisSessionLocks
public function fixCmRedisSessionLocks($eventObject) { if (Mage::helper('core')->isModuleEnabled('Cm_RedisSession')) { if ( ! empty($_COOKIE['frontend']) && 'crawler-session' == $_COOKIE['frontend'] && ! defined('CM_REDISSESSION_LOCKING_ENABLED')) { define('CM_REDISSESSION_LOCKING_ENABLED', false); } } }
php
public function fixCmRedisSessionLocks($eventObject) { if (Mage::helper('core')->isModuleEnabled('Cm_RedisSession')) { if ( ! empty($_COOKIE['frontend']) && 'crawler-session' == $_COOKIE['frontend'] && ! defined('CM_REDISSESSION_LOCKING_ENABLED')) { define('CM_REDISSESSION_LOCKING_ENABLED', false); } } }
[ "public", "function", "fixCmRedisSessionLocks", "(", "$", "eventObject", ")", "{", "if", "(", "Mage", "::", "helper", "(", "'core'", ")", "->", "isModuleEnabled", "(", "'Cm_RedisSession'", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "_COOKIE", "[", ...
Turpentine sets the fake cookie 'frontend=crawler-session' when a crawler is detected. This causes lock problems with Cm_RedisSession, because all crawler hits are requesting the same session lock. Cm_RedisSession provides the define CM_REDISSESSION_LOCKING_ENABLED to overrule if locking should be enabled. @param $eventObject @return null
[ "Turpentine", "sets", "the", "fake", "cookie", "frontend", "=", "crawler", "-", "session", "when", "a", "crawler", "is", "detected", ".", "This", "causes", "lock", "problems", "with", "Cm_RedisSession", "because", "all", "crawler", "hits", "are", "requesting", ...
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Observer/Varnish.php#L66-L73
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Model/Observer/Varnish.php
Nexcessnet_Turpentine_Model_Observer_Varnish.adminSystemConfigChangedSection
public function adminSystemConfigChangedSection($eventObject) { if (Mage::helper('turpentine/varnish')->getVarnishEnabled() && Mage::helper('turpentine/data')->getAutoApplyOnSave()) { $result = Mage::getModel('turpentine/varnish_admin')->applyConfig(); $session = Mage::getSingleton('core/session'); $helper = Mage::helper('turpentine'); foreach ($result as $name => $value) { if ($value === true) { $session->addSuccess($helper ->__('VCL successfully applied to: '.$name)); } else { $session->addError($helper ->__(sprintf('Failed to apply the VCL to %s: %s', $name, $value))); } } $cfgr = Mage::getModel('turpentine/varnish_admin')->getConfigurator(); if (is_null($cfgr)) { $session->addError($helper ->__('Failed to load configurator')); } else { $result = $cfgr->save($cfgr->generate($helper->shouldStripVclWhitespace('save'))); if ($result[0]) { $session->addSuccess($helper ->__('The VCL file has been saved.')); } else { $session->addError($helper ->__('Failed to save the VCL file: '.$result[1]['message'])); } } } }
php
public function adminSystemConfigChangedSection($eventObject) { if (Mage::helper('turpentine/varnish')->getVarnishEnabled() && Mage::helper('turpentine/data')->getAutoApplyOnSave()) { $result = Mage::getModel('turpentine/varnish_admin')->applyConfig(); $session = Mage::getSingleton('core/session'); $helper = Mage::helper('turpentine'); foreach ($result as $name => $value) { if ($value === true) { $session->addSuccess($helper ->__('VCL successfully applied to: '.$name)); } else { $session->addError($helper ->__(sprintf('Failed to apply the VCL to %s: %s', $name, $value))); } } $cfgr = Mage::getModel('turpentine/varnish_admin')->getConfigurator(); if (is_null($cfgr)) { $session->addError($helper ->__('Failed to load configurator')); } else { $result = $cfgr->save($cfgr->generate($helper->shouldStripVclWhitespace('save'))); if ($result[0]) { $session->addSuccess($helper ->__('The VCL file has been saved.')); } else { $session->addError($helper ->__('Failed to save the VCL file: '.$result[1]['message'])); } } } }
[ "public", "function", "adminSystemConfigChangedSection", "(", "$", "eventObject", ")", "{", "if", "(", "Mage", "::", "helper", "(", "'turpentine/varnish'", ")", "->", "getVarnishEnabled", "(", ")", "&&", "Mage", "::", "helper", "(", "'turpentine/data'", ")", "->...
Re-apply and save Varnish configuration on config change @param mixed $eventObject @return null
[ "Re", "-", "apply", "and", "save", "Varnish", "configuration", "on", "config", "change" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Observer/Varnish.php#L81-L112
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Model/Observer/Ban.php
Nexcessnet_Turpentine_Model_Observer_Ban.banClientEsiCache
public function banClientEsiCache($eventObject) { $eventName = $eventObject->getEvent()->getName(); if (Mage::helper('turpentine/esi')->getEsiEnabled() && ! in_array($eventName, $this->_esiClearFlag)) { $sessionId = Mage::app()->getRequest()->getCookie('frontend'); if ($sessionId) { $result = $this->_getVarnishAdmin()->flushExpression( 'obj.http.X-Varnish-Session', '==', $sessionId, '&&', 'obj.http.X-Turpentine-Flush-Events', '~', $eventName ); Mage::dispatchEvent('turpentine_ban_client_esi_cache', $result); if ($this->_checkResult($result)) { Mage::helper('turpentine/debug') ->logDebug('Cleared ESI cache for client (%s) on event: %s', $sessionId, $eventName); } else { Mage::helper('turpentine/debug') ->logWarn( 'Failed to clear Varnish ESI cache for client: %s', $sessionId ); } } $this->_esiClearFlag[] = $eventName; } }
php
public function banClientEsiCache($eventObject) { $eventName = $eventObject->getEvent()->getName(); if (Mage::helper('turpentine/esi')->getEsiEnabled() && ! in_array($eventName, $this->_esiClearFlag)) { $sessionId = Mage::app()->getRequest()->getCookie('frontend'); if ($sessionId) { $result = $this->_getVarnishAdmin()->flushExpression( 'obj.http.X-Varnish-Session', '==', $sessionId, '&&', 'obj.http.X-Turpentine-Flush-Events', '~', $eventName ); Mage::dispatchEvent('turpentine_ban_client_esi_cache', $result); if ($this->_checkResult($result)) { Mage::helper('turpentine/debug') ->logDebug('Cleared ESI cache for client (%s) on event: %s', $sessionId, $eventName); } else { Mage::helper('turpentine/debug') ->logWarn( 'Failed to clear Varnish ESI cache for client: %s', $sessionId ); } } $this->_esiClearFlag[] = $eventName; } }
[ "public", "function", "banClientEsiCache", "(", "$", "eventObject", ")", "{", "$", "eventName", "=", "$", "eventObject", "->", "getEvent", "(", ")", "->", "getName", "(", ")", ";", "if", "(", "Mage", "::", "helper", "(", "'turpentine/esi'", ")", "->", "g...
Clear the ESI block cache for a specific client Events: the events are applied dynamically according to what events are set for the various blocks' esi policies @param Varien_Object $eventObject @return null
[ "Clear", "the", "ESI", "block", "cache", "for", "a", "specific", "client" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Observer/Ban.php#L49-L73
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Model/Observer/Ban.php
Nexcessnet_Turpentine_Model_Observer_Ban.banProductPageCache
public function banProductPageCache($eventObject) { if (Mage::helper('turpentine/varnish')->getVarnishEnabled()) { $banHelper = Mage::helper('turpentine/ban'); $product = $eventObject->getProduct(); $urlPattern = $banHelper->getProductBanRegex($product); $result = $this->_getVarnishAdmin()->flushUrl($urlPattern); Mage::dispatchEvent('turpentine_ban_product_cache', $result); $cronHelper = Mage::helper('turpentine/cron'); if ($this->_checkResult($result) && $cronHelper->getCrawlerEnabled()) { $cronHelper->addProductToCrawlerQueue($product); foreach ($banHelper->getParentProducts($product) as $parentProduct) { $cronHelper->addProductToCrawlerQueue($parentProduct); } } } }
php
public function banProductPageCache($eventObject) { if (Mage::helper('turpentine/varnish')->getVarnishEnabled()) { $banHelper = Mage::helper('turpentine/ban'); $product = $eventObject->getProduct(); $urlPattern = $banHelper->getProductBanRegex($product); $result = $this->_getVarnishAdmin()->flushUrl($urlPattern); Mage::dispatchEvent('turpentine_ban_product_cache', $result); $cronHelper = Mage::helper('turpentine/cron'); if ($this->_checkResult($result) && $cronHelper->getCrawlerEnabled()) { $cronHelper->addProductToCrawlerQueue($product); foreach ($banHelper->getParentProducts($product) as $parentProduct) { $cronHelper->addProductToCrawlerQueue($parentProduct); } } } }
[ "public", "function", "banProductPageCache", "(", "$", "eventObject", ")", "{", "if", "(", "Mage", "::", "helper", "(", "'turpentine/varnish'", ")", "->", "getVarnishEnabled", "(", ")", ")", "{", "$", "banHelper", "=", "Mage", "::", "helper", "(", "'turpenti...
Ban a specific product page from the cache Events: catalog_product_save_commit_after @param Varien_Object $eventObject @return null
[ "Ban", "a", "specific", "product", "page", "from", "the", "cache" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Observer/Ban.php#L84-L101
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Model/Observer/Ban.php
Nexcessnet_Turpentine_Model_Observer_Ban.banProductPageCacheCheckStock
public function banProductPageCacheCheckStock($eventObject) { if (Mage::helper('turpentine/varnish')->getVarnishEnabled()) { $item = $eventObject->getItem(); if ($item->getStockStatusChangedAutomatically() || ($item->getOriginalInventoryQty() <= 0 && $item->getQty() > 0 && $item->getQtyCorrection() > 0)) { $banHelper = Mage::helper('turpentine/ban'); $cronHelper = Mage::helper('turpentine/cron'); $product = Mage::getModel('catalog/product') ->load($item->getProductId()); $urlPattern = $banHelper->getProductBanRegex($product); $result = $this->_getVarnishAdmin()->flushUrl($urlPattern); Mage::dispatchEvent('turpentine_ban_product_cache_check_stock', $result); if ($this->_checkResult($result) && $cronHelper->getCrawlerEnabled()) { $cronHelper->addProductToCrawlerQueue($product); foreach ($banHelper->getParentProducts($product) as $parentProduct) { $cronHelper->addProductToCrawlerQueue($parentProduct); } } } } }
php
public function banProductPageCacheCheckStock($eventObject) { if (Mage::helper('turpentine/varnish')->getVarnishEnabled()) { $item = $eventObject->getItem(); if ($item->getStockStatusChangedAutomatically() || ($item->getOriginalInventoryQty() <= 0 && $item->getQty() > 0 && $item->getQtyCorrection() > 0)) { $banHelper = Mage::helper('turpentine/ban'); $cronHelper = Mage::helper('turpentine/cron'); $product = Mage::getModel('catalog/product') ->load($item->getProductId()); $urlPattern = $banHelper->getProductBanRegex($product); $result = $this->_getVarnishAdmin()->flushUrl($urlPattern); Mage::dispatchEvent('turpentine_ban_product_cache_check_stock', $result); if ($this->_checkResult($result) && $cronHelper->getCrawlerEnabled()) { $cronHelper->addProductToCrawlerQueue($product); foreach ($banHelper->getParentProducts($product) as $parentProduct) { $cronHelper->addProductToCrawlerQueue($parentProduct); } } } } }
[ "public", "function", "banProductPageCacheCheckStock", "(", "$", "eventObject", ")", "{", "if", "(", "Mage", "::", "helper", "(", "'turpentine/varnish'", ")", "->", "getVarnishEnabled", "(", ")", ")", "{", "$", "item", "=", "$", "eventObject", "->", "getItem",...
Ban a product page from the cache if it's stock status changed Events: cataloginventory_stock_item_save_after @param Varien_Object $eventObject @return null
[ "Ban", "a", "product", "page", "from", "the", "cache", "if", "it", "s", "stock", "status", "changed" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Observer/Ban.php#L112-L137
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Model/Observer/Ban.php
Nexcessnet_Turpentine_Model_Observer_Ban.banCategoryCache
public function banCategoryCache($eventObject) { if (Mage::helper('turpentine/varnish')->getVarnishEnabled()) { $category = $eventObject->getCategory(); $result = $this->_getVarnishAdmin()->flushUrl($category->getUrlKey()); Mage::dispatchEvent('turpentine_ban_category_cache', $result); $cronHelper = Mage::helper('turpentine/cron'); if ($this->_checkResult($result) && $cronHelper->getCrawlerEnabled()) { $cronHelper->addCategoryToCrawlerQueue($category); } } }
php
public function banCategoryCache($eventObject) { if (Mage::helper('turpentine/varnish')->getVarnishEnabled()) { $category = $eventObject->getCategory(); $result = $this->_getVarnishAdmin()->flushUrl($category->getUrlKey()); Mage::dispatchEvent('turpentine_ban_category_cache', $result); $cronHelper = Mage::helper('turpentine/cron'); if ($this->_checkResult($result) && $cronHelper->getCrawlerEnabled()) { $cronHelper->addCategoryToCrawlerQueue($category); } } }
[ "public", "function", "banCategoryCache", "(", "$", "eventObject", ")", "{", "if", "(", "Mage", "::", "helper", "(", "'turpentine/varnish'", ")", "->", "getVarnishEnabled", "(", ")", ")", "{", "$", "category", "=", "$", "eventObject", "->", "getCategory", "(...
Ban a category page, and any subpages on save Events: catalog_category_save_commit_after @param Varien_Object $eventObject @return null
[ "Ban", "a", "category", "page", "and", "any", "subpages", "on", "save" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Observer/Ban.php#L148-L159
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Model/Observer/Ban.php
Nexcessnet_Turpentine_Model_Observer_Ban.banCmsPageCache
public function banCmsPageCache($eventObject) { if (Mage::helper('turpentine/varnish')->getVarnishEnabled()) { $pageId = $eventObject->getDataObject()->getIdentifier(); $result = $this->_getVarnishAdmin()->flushUrl($pageId.'(?:\.html?)?\/?$'); Mage::dispatchEvent('turpentine_ban_cms_page_cache', $result); $cronHelper = Mage::helper('turpentine/cron'); if ($this->_checkResult($result) && $cronHelper->getCrawlerEnabled()) { $cronHelper->addCmsPageToCrawlerQueue($pageId); } } }
php
public function banCmsPageCache($eventObject) { if (Mage::helper('turpentine/varnish')->getVarnishEnabled()) { $pageId = $eventObject->getDataObject()->getIdentifier(); $result = $this->_getVarnishAdmin()->flushUrl($pageId.'(?:\.html?)?\/?$'); Mage::dispatchEvent('turpentine_ban_cms_page_cache', $result); $cronHelper = Mage::helper('turpentine/cron'); if ($this->_checkResult($result) && $cronHelper->getCrawlerEnabled()) { $cronHelper->addCmsPageToCrawlerQueue($pageId); } } }
[ "public", "function", "banCmsPageCache", "(", "$", "eventObject", ")", "{", "if", "(", "Mage", "::", "helper", "(", "'turpentine/varnish'", ")", "->", "getVarnishEnabled", "(", ")", ")", "{", "$", "pageId", "=", "$", "eventObject", "->", "getDataObject", "("...
Ban a specific CMS page from cache after edit Events: cms_page_save_commit_after @param Varien_Object $eventObject @return null
[ "Ban", "a", "specific", "CMS", "page", "from", "cache", "after", "edit" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Observer/Ban.php#L207-L218
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Model/Observer/Ban.php
Nexcessnet_Turpentine_Model_Observer_Ban.banAllCache
public function banAllCache($eventObject) { if (Mage::helper('turpentine/varnish')->getVarnishEnabled()) { $result = $this->_getVarnishAdmin()->flushAll(); Mage::dispatchEvent('turpentine_ban_all_cache', $result); $this->_checkResult($result); } }
php
public function banAllCache($eventObject) { if (Mage::helper('turpentine/varnish')->getVarnishEnabled()) { $result = $this->_getVarnishAdmin()->flushAll(); Mage::dispatchEvent('turpentine_ban_all_cache', $result); $this->_checkResult($result); } }
[ "public", "function", "banAllCache", "(", "$", "eventObject", ")", "{", "if", "(", "Mage", "::", "helper", "(", "'turpentine/varnish'", ")", "->", "getVarnishEnabled", "(", ")", ")", "{", "$", "result", "=", "$", "this", "->", "_getVarnishAdmin", "(", ")",...
Do a full cache flush, corresponds to "Flush Magento Cache" and "Flush Cache Storage" buttons in admin > cache management Events: adminhtml_cache_flush_system adminhtml_cache_flush_all @param Varien_Object $eventObject @return null
[ "Do", "a", "full", "cache", "flush", "corresponds", "to", "Flush", "Magento", "Cache", "and", "Flush", "Cache", "Storage", "buttons", "in", "admin", ">", "cache", "management" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Observer/Ban.php#L259-L265
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Model/Observer/Ban.php
Nexcessnet_Turpentine_Model_Observer_Ban.banCacheType
public function banCacheType($eventObject) { switch ($eventObject->getType()) { //note this is the name of the container xml tag in config.xml, // **NOT** the cache tag name case Mage::helper('turpentine/esi')->getMageCacheName(): if (Mage::helper('turpentine/esi')->getEsiEnabled()) { $result = $this->_getVarnishAdmin()->flushUrl( '/turpentine/esi/getBlock/' ); Mage::dispatchEvent('turpentine_ban_esi_cache', $result); $this->_checkResult($result); } break; case Mage::helper('turpentine/varnish')->getMageCacheName(): $this->banAllCache($eventObject); break; } }
php
public function banCacheType($eventObject) { switch ($eventObject->getType()) { //note this is the name of the container xml tag in config.xml, // **NOT** the cache tag name case Mage::helper('turpentine/esi')->getMageCacheName(): if (Mage::helper('turpentine/esi')->getEsiEnabled()) { $result = $this->_getVarnishAdmin()->flushUrl( '/turpentine/esi/getBlock/' ); Mage::dispatchEvent('turpentine_ban_esi_cache', $result); $this->_checkResult($result); } break; case Mage::helper('turpentine/varnish')->getMageCacheName(): $this->banAllCache($eventObject); break; } }
[ "public", "function", "banCacheType", "(", "$", "eventObject", ")", "{", "switch", "(", "$", "eventObject", "->", "getType", "(", ")", ")", "{", "//note this is the name of the container xml tag in config.xml,", "// **NOT** the cache tag name", "case", "Mage", "::", "he...
Do a flush on the ESI blocks Events: adminhtml_cache_refresh_type @param Varien_Object $eventObject @return null
[ "Do", "a", "flush", "on", "the", "ESI", "blocks" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Observer/Ban.php#L276-L292
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Model/Observer/Ban.php
Nexcessnet_Turpentine_Model_Observer_Ban.banProductReview
public function banProductReview($eventObject) { if (Mage::helper('turpentine/varnish')->getVarnishEnabled()) { $patterns = array(); /* @var $review \Mage_Review_Model_Review*/ $review = $eventObject->getObject(); /* @var $productCollection \Mage_Review_Model_Resource_Review_Product_Collection*/ $productCollection = $review->getProductCollection(); $products = $productCollection->addEntityFilter((int) $review->getEntityPkValue())->getItems(); $productIds = array_unique(array_map( create_function('$p', 'return $p->getEntityId();'), $products )); $patterns[] = sprintf('/review/product/list/id/(?:%s)/category/', implode('|', array_unique($productIds))); $patterns[] = sprintf('/review/product/view/id/%d/', $review->getEntityId()); $productPatterns = array(); foreach ($products as $p) { $urlKey = $p->getUrlModel()->formatUrlKey($p->getName()); if ($urlKey) { $productPatterns[] = $urlKey; } } if ( ! empty($productPatterns)) { $productPatterns = array_unique($productPatterns); $patterns[] = sprintf('(?:%s)', implode('|', $productPatterns)); } $urlPattern = implode('|', $patterns); $result = $this->_getVarnishAdmin()->flushUrl($urlPattern); return $this->_checkResult($result); } }
php
public function banProductReview($eventObject) { if (Mage::helper('turpentine/varnish')->getVarnishEnabled()) { $patterns = array(); /* @var $review \Mage_Review_Model_Review*/ $review = $eventObject->getObject(); /* @var $productCollection \Mage_Review_Model_Resource_Review_Product_Collection*/ $productCollection = $review->getProductCollection(); $products = $productCollection->addEntityFilter((int) $review->getEntityPkValue())->getItems(); $productIds = array_unique(array_map( create_function('$p', 'return $p->getEntityId();'), $products )); $patterns[] = sprintf('/review/product/list/id/(?:%s)/category/', implode('|', array_unique($productIds))); $patterns[] = sprintf('/review/product/view/id/%d/', $review->getEntityId()); $productPatterns = array(); foreach ($products as $p) { $urlKey = $p->getUrlModel()->formatUrlKey($p->getName()); if ($urlKey) { $productPatterns[] = $urlKey; } } if ( ! empty($productPatterns)) { $productPatterns = array_unique($productPatterns); $patterns[] = sprintf('(?:%s)', implode('|', $productPatterns)); } $urlPattern = implode('|', $patterns); $result = $this->_getVarnishAdmin()->flushUrl($urlPattern); return $this->_checkResult($result); } }
[ "public", "function", "banProductReview", "(", "$", "eventObject", ")", "{", "if", "(", "Mage", "::", "helper", "(", "'turpentine/varnish'", ")", "->", "getVarnishEnabled", "(", ")", ")", "{", "$", "patterns", "=", "array", "(", ")", ";", "/* @var $review \\...
Ban a product's reviews page @param Varien_Object $eventObject @return bool
[ "Ban", "a", "product", "s", "reviews", "page" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Observer/Ban.php#L300-L334
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Model/Observer/Ban.php
Nexcessnet_Turpentine_Model_Observer_Ban._checkResult
protected function _checkResult($result) { $rvalue = true; foreach ($result as $socketName => $value) { if ($value !== true) { Mage::helper('turpentine/debug')->logWarn( 'Error in Varnish action result for server [%s]: %s', $socketName, $value ); $rvalue = false; } } return $rvalue; }
php
protected function _checkResult($result) { $rvalue = true; foreach ($result as $socketName => $value) { if ($value !== true) { Mage::helper('turpentine/debug')->logWarn( 'Error in Varnish action result for server [%s]: %s', $socketName, $value ); $rvalue = false; } } return $rvalue; }
[ "protected", "function", "_checkResult", "(", "$", "result", ")", "{", "$", "rvalue", "=", "true", ";", "foreach", "(", "$", "result", "as", "$", "socketName", "=>", "$", "value", ")", "{", "if", "(", "$", "value", "!==", "true", ")", "{", "Mage", ...
Check a result from varnish admin action, log if result has errors @param array $result stored as $socketName => $result @return bool
[ "Check", "a", "result", "from", "varnish", "admin", "action", "log", "if", "result", "has", "errors" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Observer/Ban.php#L342-L353
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Model/Observer/Ban.php
Nexcessnet_Turpentine_Model_Observer_Ban._getVarnishAdmin
protected function _getVarnishAdmin() { if (is_null($this->_varnishAdmin)) { $this->_varnishAdmin = Mage::getModel('turpentine/varnish_admin'); } return $this->_varnishAdmin; }
php
protected function _getVarnishAdmin() { if (is_null($this->_varnishAdmin)) { $this->_varnishAdmin = Mage::getModel('turpentine/varnish_admin'); } return $this->_varnishAdmin; }
[ "protected", "function", "_getVarnishAdmin", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "_varnishAdmin", ")", ")", "{", "$", "this", "->", "_varnishAdmin", "=", "Mage", "::", "getModel", "(", "'turpentine/varnish_admin'", ")", ";", "}", "...
Get the varnish admin socket @return Nexcessnet_Turpentine_Model_Varnish_Admin
[ "Get", "the", "varnish", "admin", "socket" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Observer/Ban.php#L360-L365
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Model/Observer/Cron.php
Nexcessnet_Turpentine_Model_Observer_Cron.queueAllUrls
public function queueAllUrls($eventObject) { $helper = Mage::helper('turpentine/cron'); if ($helper->getCrawlerEnabled()) { $helper->addUrlsToCrawlerQueue($helper->getAllUrls()); } }
php
public function queueAllUrls($eventObject) { $helper = Mage::helper('turpentine/cron'); if ($helper->getCrawlerEnabled()) { $helper->addUrlsToCrawlerQueue($helper->getAllUrls()); } }
[ "public", "function", "queueAllUrls", "(", "$", "eventObject", ")", "{", "$", "helper", "=", "Mage", "::", "helper", "(", "'turpentine/cron'", ")", ";", "if", "(", "$", "helper", "->", "getCrawlerEnabled", "(", ")", ")", "{", "$", "helper", "->", "addUrl...
Queue all URLs @param Varien_Object $eventObject @return null
[ "Queue", "all", "URLs" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Observer/Cron.php#L85-L90
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Model/Observer/Cron.php
Nexcessnet_Turpentine_Model_Observer_Cron._crawlUrl
protected function _crawlUrl($url) { $client = Mage::helper('turpentine/cron')->getCrawlerClient(); $client->setUri($url); Mage::helper('turpentine/debug')->logDebug('Crawling URL: %s', $url); try { $response = $client->request(); } catch (Exception $e) { Mage::helper('turpentine/debug')->logWarn( 'Error crawling URL (%s): %s', $url, $e->getMessage() ); return false; } return $response->isSuccessful(); }
php
protected function _crawlUrl($url) { $client = Mage::helper('turpentine/cron')->getCrawlerClient(); $client->setUri($url); Mage::helper('turpentine/debug')->logDebug('Crawling URL: %s', $url); try { $response = $client->request(); } catch (Exception $e) { Mage::helper('turpentine/debug')->logWarn( 'Error crawling URL (%s): %s', $url, $e->getMessage() ); return false; } return $response->isSuccessful(); }
[ "protected", "function", "_crawlUrl", "(", "$", "url", ")", "{", "$", "client", "=", "Mage", "::", "helper", "(", "'turpentine/cron'", ")", "->", "getCrawlerClient", "(", ")", ";", "$", "client", "->", "setUri", "(", "$", "url", ")", ";", "Mage", "::",...
Request a single URL, returns whether the request was successful or not @param string $url @return bool
[ "Request", "a", "single", "URL", "returns", "whether", "the", "request", "was", "successful", "or", "not" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Observer/Cron.php#L98-L111
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/controllers/EsiController.php
Nexcessnet_Turpentine_EsiController.getFormKeyAction
public function getFormKeyAction() { $resp = $this->getResponse(); $resp->setBody( Mage::getSingleton('core/session')->real_getFormKey() ); $resp->setHeader('X-Turpentine-Cache', '1'); $resp->setHeader('X-Turpentine-Flush-Events', implode(',', Mage::helper('turpentine/esi') ->getDefaultCacheClearEvents())); $resp->setHeader('X-Turpentine-Block', 'form_key'); Mage::register('turpentine_nocache_flag', false, true); Mage::helper('turpentine/debug')->logDebug('Generated form_key: %s', $resp->getBody()); }
php
public function getFormKeyAction() { $resp = $this->getResponse(); $resp->setBody( Mage::getSingleton('core/session')->real_getFormKey() ); $resp->setHeader('X-Turpentine-Cache', '1'); $resp->setHeader('X-Turpentine-Flush-Events', implode(',', Mage::helper('turpentine/esi') ->getDefaultCacheClearEvents())); $resp->setHeader('X-Turpentine-Block', 'form_key'); Mage::register('turpentine_nocache_flag', false, true); Mage::helper('turpentine/debug')->logDebug('Generated form_key: %s', $resp->getBody()); }
[ "public", "function", "getFormKeyAction", "(", ")", "{", "$", "resp", "=", "$", "this", "->", "getResponse", "(", ")", ";", "$", "resp", "->", "setBody", "(", "Mage", "::", "getSingleton", "(", "'core/session'", ")", "->", "real_getFormKey", "(", ")", ")...
Spit out the form key for this session @return null
[ "Spit", "out", "the", "form", "key", "for", "this", "session" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/controllers/EsiController.php#L38-L51
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/controllers/EsiController.php
Nexcessnet_Turpentine_EsiController.postDispatch
public function postDispatch() { $flag = $this->getFlag('', self::FLAG_NO_START_SESSION); $this->setFlag('', self::FLAG_NO_START_SESSION, true); parent::postDispatch(); $this->setFlag('', self::FLAG_NO_START_SESSION, $flag); }
php
public function postDispatch() { $flag = $this->getFlag('', self::FLAG_NO_START_SESSION); $this->setFlag('', self::FLAG_NO_START_SESSION, true); parent::postDispatch(); $this->setFlag('', self::FLAG_NO_START_SESSION, $flag); }
[ "public", "function", "postDispatch", "(", ")", "{", "$", "flag", "=", "$", "this", "->", "getFlag", "(", "''", ",", "self", "::", "FLAG_NO_START_SESSION", ")", ";", "$", "this", "->", "setFlag", "(", "''", ",", "self", "::", "FLAG_NO_START_SESSION", ","...
Need to disable this flag to prevent setting the last URL but we don't want to completely break sessions. see Mage_Core_Controller_Front_Action::postDispatch @return null
[ "Need", "to", "disable", "this", "flag", "to", "prevent", "setting", "the", "last", "URL", "but", "we", "don", "t", "want", "to", "completely", "break", "sessions", "." ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/controllers/EsiController.php#L154-L159
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin/Socket.php
Nexcessnet_Turpentine_Model_Varnish_Admin_Socket.setTimeout
public function setTimeout($timeout) { $this->_timeout = (int) $timeout; if ( ! is_null($this->_varnishConn)) { stream_set_timeout($this->_varnishConn, $this->_timeout); } return $this; }
php
public function setTimeout($timeout) { $this->_timeout = (int) $timeout; if ( ! is_null($this->_varnishConn)) { stream_set_timeout($this->_varnishConn, $this->_timeout); } return $this; }
[ "public", "function", "setTimeout", "(", "$", "timeout", ")", "{", "$", "this", "->", "_timeout", "=", "(", "int", ")", "$", "timeout", ";", "if", "(", "!", "is_null", "(", "$", "this", "->", "_varnishConn", ")", ")", "{", "stream_set_timeout", "(", ...
Set the timeout to connect to the varnish instance @param int $timeout
[ "Set", "the", "timeout", "to", "connect", "to", "the", "varnish", "instance" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin/Socket.php#L230-L236
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin/Socket.php
Nexcessnet_Turpentine_Model_Varnish_Admin_Socket.setVersion
public function setVersion($version) { if (in_array($version, self::$_VERSIONS)) { $this->_version = $version; } else { Mage::throwException('Unsupported Varnish version: '.$version); } }
php
public function setVersion($version) { if (in_array($version, self::$_VERSIONS)) { $this->_version = $version; } else { Mage::throwException('Unsupported Varnish version: '.$version); } }
[ "public", "function", "setVersion", "(", "$", "version", ")", "{", "if", "(", "in_array", "(", "$", "version", ",", "self", "::", "$", "_VERSIONS", ")", ")", "{", "$", "this", "->", "_version", "=", "$", "version", ";", "}", "else", "{", "Mage", ":...
Explicitly set the version of the varnish instance we're connecting to @param string $version version from $_VERSIONS
[ "Explicitly", "set", "the", "version", "of", "the", "varnish", "instance", "we", "re", "connecting", "to" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin/Socket.php#L243-L249
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin/Socket.php
Nexcessnet_Turpentine_Model_Varnish_Admin_Socket._connect
protected function _connect() { $this->_varnishConn = fsockopen($this->_host, $this->_port, $errno, $errstr, $this->_timeout); if ( ! is_resource($this->_varnishConn)) { Mage::throwException(sprintf( 'Failed to connect to Varnish on [%s:%d]: (%d) %s', $this->_host, $this->_port, $errno, $errstr )); } stream_set_blocking($this->_varnishConn, 1); stream_set_timeout($this->_varnishConn, $this->_timeout); //varnish 2.0 doesn't spit out a banner on connection, this will need //to be changed if 2.0 support is ever added $banner = $this->_read(); if ($banner['code'] === self::CODE_AUTH) { $challenge = substr($banner['text'], 0, 32); $response = hash('sha256', sprintf("%s\n%s%s\n", $challenge, $this->_authSecret, $challenge)); $banner = $this->_command('auth', self::CODE_OK, $response); } if ($banner['code'] !== self::CODE_OK) { Mage::throwException('Varnish admin authentication failed: '. $banner['text']); } if ($this->_version == null) { // If autodetecting $this->_version = $this->_determineVersion($banner['text']); } return $this->isConnected(); }
php
protected function _connect() { $this->_varnishConn = fsockopen($this->_host, $this->_port, $errno, $errstr, $this->_timeout); if ( ! is_resource($this->_varnishConn)) { Mage::throwException(sprintf( 'Failed to connect to Varnish on [%s:%d]: (%d) %s', $this->_host, $this->_port, $errno, $errstr )); } stream_set_blocking($this->_varnishConn, 1); stream_set_timeout($this->_varnishConn, $this->_timeout); //varnish 2.0 doesn't spit out a banner on connection, this will need //to be changed if 2.0 support is ever added $banner = $this->_read(); if ($banner['code'] === self::CODE_AUTH) { $challenge = substr($banner['text'], 0, 32); $response = hash('sha256', sprintf("%s\n%s%s\n", $challenge, $this->_authSecret, $challenge)); $banner = $this->_command('auth', self::CODE_OK, $response); } if ($banner['code'] !== self::CODE_OK) { Mage::throwException('Varnish admin authentication failed: '. $banner['text']); } if ($this->_version == null) { // If autodetecting $this->_version = $this->_determineVersion($banner['text']); } return $this->isConnected(); }
[ "protected", "function", "_connect", "(", ")", "{", "$", "this", "->", "_varnishConn", "=", "fsockopen", "(", "$", "this", "->", "_host", ",", "$", "this", "->", "_port", ",", "$", "errno", ",", "$", "errstr", ",", "$", "this", "->", "_timeout", ")",...
Establish a connection to the configured Varnish instance @return boolean
[ "Establish", "a", "connection", "to", "the", "configured", "Varnish", "instance" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin/Socket.php#L321-L353
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin/Socket.php
Nexcessnet_Turpentine_Model_Varnish_Admin_Socket._write
protected function _write($data) { if (is_null($this->_varnishConn)) { $this->_connect(); } $data = rtrim($data).PHP_EOL; $dataLength = strlen($data); if ($dataLength >= self::CLI_CMD_LENGTH_LIMIT) { $cliBufferResponse = $this->param_show('cli_buffer'); $regexp = '~^cli_buffer\s+(\d+)\s+\[bytes\]~'; if ($this->getVersion() === '4.0' || $this->getVersion() === '4.1') { // Varnish4 supports "16k" style notation $regexp = '~^cli_buffer\s+Value is:\s+(\d+)([k|m|g|b]{1})?\s+\[bytes\]~'; } if (preg_match($regexp, $cliBufferResponse['text'], $match)) { $realLimit = (int) $match[1]; if (isset($match[2])) { $factors = array('b'=>0, 'k'=>1, 'm'=>2, 'g'=>3); $realLimit *= pow(1024, $factors[$match[2]]); } } else { Mage::helper('turpentine/debug')->logWarn( 'Failed to determine Varnish cli_buffer limit, using default' ); $realLimit = self::CLI_CMD_LENGTH_LIMIT; } if ($dataLength >= $realLimit) { Mage::throwException(sprintf( 'Varnish data to write over length limit by %d characters', $dataLength - $realLimit )); } } if (($byteCount = fwrite($this->_varnishConn, $data)) !== $dataLength) { Mage::throwException(sprintf('Varnish socket write error: %d != %d', $byteCount, $dataLength)); } return $this; }
php
protected function _write($data) { if (is_null($this->_varnishConn)) { $this->_connect(); } $data = rtrim($data).PHP_EOL; $dataLength = strlen($data); if ($dataLength >= self::CLI_CMD_LENGTH_LIMIT) { $cliBufferResponse = $this->param_show('cli_buffer'); $regexp = '~^cli_buffer\s+(\d+)\s+\[bytes\]~'; if ($this->getVersion() === '4.0' || $this->getVersion() === '4.1') { // Varnish4 supports "16k" style notation $regexp = '~^cli_buffer\s+Value is:\s+(\d+)([k|m|g|b]{1})?\s+\[bytes\]~'; } if (preg_match($regexp, $cliBufferResponse['text'], $match)) { $realLimit = (int) $match[1]; if (isset($match[2])) { $factors = array('b'=>0, 'k'=>1, 'm'=>2, 'g'=>3); $realLimit *= pow(1024, $factors[$match[2]]); } } else { Mage::helper('turpentine/debug')->logWarn( 'Failed to determine Varnish cli_buffer limit, using default' ); $realLimit = self::CLI_CMD_LENGTH_LIMIT; } if ($dataLength >= $realLimit) { Mage::throwException(sprintf( 'Varnish data to write over length limit by %d characters', $dataLength - $realLimit )); } } if (($byteCount = fwrite($this->_varnishConn, $data)) !== $dataLength) { Mage::throwException(sprintf('Varnish socket write error: %d != %d', $byteCount, $dataLength)); } return $this; }
[ "protected", "function", "_write", "(", "$", "data", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "_varnishConn", ")", ")", "{", "$", "this", "->", "_connect", "(", ")", ";", "}", "$", "data", "=", "rtrim", "(", "$", "data", ")", ".", ...
Write data to the Varnish instance, a newline is automatically appended @param string $data data to write @return $this
[ "Write", "data", "to", "the", "Varnish", "instance", "a", "newline", "is", "automatically", "appended" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin/Socket.php#L399-L434
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin/Socket.php
Nexcessnet_Turpentine_Model_Varnish_Admin_Socket._read
protected function _read() { $code = null; $len = -1; while ( ! feof($this->_varnishConn)) { $response = fgets($this->_varnishConn, self::READ_CHUNK_SIZE); if (empty($response)) { $streamMeta = stream_get_meta_data($this->_varnishConn); if ($streamMeta['timed_out']) { Mage::throwException('Varnish admin socket timeout'); } } if (preg_match('~^(\d{3}) (\d+)~', $response, $match)) { $code = (int) $match[1]; $len = (int) $match[2]; break; } } if (is_null($code)) { Mage::throwException('Failed to read response code from Varnish'); } else { $response = array('code' => $code, 'text' => ''); while ( ! feof($this->_varnishConn) && strlen($response['text']) < $len) { $response['text'] .= fgets($this->_varnishConn, self::READ_CHUNK_SIZE); } return $response; } }
php
protected function _read() { $code = null; $len = -1; while ( ! feof($this->_varnishConn)) { $response = fgets($this->_varnishConn, self::READ_CHUNK_SIZE); if (empty($response)) { $streamMeta = stream_get_meta_data($this->_varnishConn); if ($streamMeta['timed_out']) { Mage::throwException('Varnish admin socket timeout'); } } if (preg_match('~^(\d{3}) (\d+)~', $response, $match)) { $code = (int) $match[1]; $len = (int) $match[2]; break; } } if (is_null($code)) { Mage::throwException('Failed to read response code from Varnish'); } else { $response = array('code' => $code, 'text' => ''); while ( ! feof($this->_varnishConn) && strlen($response['text']) < $len) { $response['text'] .= fgets($this->_varnishConn, self::READ_CHUNK_SIZE); } return $response; } }
[ "protected", "function", "_read", "(", ")", "{", "$", "code", "=", "null", ";", "$", "len", "=", "-", "1", ";", "while", "(", "!", "feof", "(", "$", "this", "->", "_varnishConn", ")", ")", "{", "$", "response", "=", "fgets", "(", "$", "this", "...
Read a response from Varnish instance @return array tuple of the response (code, text)
[ "Read", "a", "response", "from", "Varnish", "instance" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin/Socket.php#L441-L470
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Block/Core/Messages.php
Nexcessnet_Turpentine_Block_Core_Messages.setMessages
public function setMessages(Mage_Core_Model_Message_Collection $messages) { if ($this->_fixMessages()) { $this->_saveMessages($messages->getItems()); } else { parent::setMessages($messages); } return $this; }
php
public function setMessages(Mage_Core_Model_Message_Collection $messages) { if ($this->_fixMessages()) { $this->_saveMessages($messages->getItems()); } else { parent::setMessages($messages); } return $this; }
[ "public", "function", "setMessages", "(", "Mage_Core_Model_Message_Collection", "$", "messages", ")", "{", "if", "(", "$", "this", "->", "_fixMessages", "(", ")", ")", "{", "$", "this", "->", "_saveMessages", "(", "$", "messages", "->", "getItems", "(", ")",...
Set messages collection @param Mage_Core_Model_Message_Collection $messages @return Mage_Core_Block_Messages
[ "Set", "messages", "collection" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Block/Core/Messages.php#L85-L92
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Block/Core/Messages.php
Nexcessnet_Turpentine_Block_Core_Messages.addMessage
public function addMessage(Mage_Core_Model_Message_Abstract $message) { if ($this->_fixMessages()) { $this->_saveMessages(array($message)); } else { parent::addMessage($message); } return $this; }
php
public function addMessage(Mage_Core_Model_Message_Abstract $message) { if ($this->_fixMessages()) { $this->_saveMessages(array($message)); } else { parent::addMessage($message); } return $this; }
[ "public", "function", "addMessage", "(", "Mage_Core_Model_Message_Abstract", "$", "message", ")", "{", "if", "(", "$", "this", "->", "_fixMessages", "(", ")", ")", "{", "$", "this", "->", "_saveMessages", "(", "array", "(", "$", "message", ")", ")", ";", ...
Adding new message to message collection @param Mage_Core_Model_Message_Abstract $message @return Mage_Core_Block_Messages
[ "Adding", "new", "message", "to", "message", "collection" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Block/Core/Messages.php#L115-L122
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Block/Core/Messages.php
Nexcessnet_Turpentine_Block_Core_Messages.getHtml
public function getHtml($type = self::NO_SINGLE_RENDER_TYPE) { $this->_singleRenderType = $type; return $this->_handleDirectCall('getHtml')->toHtml(); }
php
public function getHtml($type = self::NO_SINGLE_RENDER_TYPE) { $this->_singleRenderType = $type; return $this->_handleDirectCall('getHtml')->toHtml(); }
[ "public", "function", "getHtml", "(", "$", "type", "=", "self", "::", "NO_SINGLE_RENDER_TYPE", ")", "{", "$", "this", "->", "_singleRenderType", "=", "$", "type", ";", "return", "$", "this", "->", "_handleDirectCall", "(", "'getHtml'", ")", "->", "toHtml", ...
Override this in case some dumb layout decides to use it instead of the standard toHtml stuff @return string
[ "Override", "this", "in", "case", "some", "dumb", "layout", "decides", "to", "use", "it", "instead", "of", "the", "standard", "toHtml", "stuff" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Block/Core/Messages.php#L130-L133
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Block/Core/Messages.php
Nexcessnet_Turpentine_Block_Core_Messages._handleDirectCall
protected function _handleDirectCall($methodCalled) { // this doesn't actually do anything because _real_toHtml() won't be // called in this request context (unless the flash message isn't // actually supposed to be ajax/esi'd in) $this->_directCall = $methodCalled; if ($this->_fixMessages()) { $layout = $this->getLayout(); $layoutUpdate = $layout->getUpdate()->load('default'); if (Mage::app()->useCache('layout')) { // this is skipped in the layout update load() if the "layout" // cache is enabled, which seems to cause the esi layout stuff // to not load, so we manually do it here foreach ($layoutUpdate->getHandles() as $handle) { $layoutUpdate->merge($handle); } } $layout->generateXml(); $layoutShim = Mage::getSingleton('turpentine/shim_mage_core_layout'); foreach ($layout->getNode()->xpath( sprintf('//reference[@name=\'%s\']/action', $this->getNameInLayout()) ) as $node) { $layoutShim->shim_generateAction($node); } } return $this; }
php
protected function _handleDirectCall($methodCalled) { // this doesn't actually do anything because _real_toHtml() won't be // called in this request context (unless the flash message isn't // actually supposed to be ajax/esi'd in) $this->_directCall = $methodCalled; if ($this->_fixMessages()) { $layout = $this->getLayout(); $layoutUpdate = $layout->getUpdate()->load('default'); if (Mage::app()->useCache('layout')) { // this is skipped in the layout update load() if the "layout" // cache is enabled, which seems to cause the esi layout stuff // to not load, so we manually do it here foreach ($layoutUpdate->getHandles() as $handle) { $layoutUpdate->merge($handle); } } $layout->generateXml(); $layoutShim = Mage::getSingleton('turpentine/shim_mage_core_layout'); foreach ($layout->getNode()->xpath( sprintf('//reference[@name=\'%s\']/action', $this->getNameInLayout()) ) as $node) { $layoutShim->shim_generateAction($node); } } return $this; }
[ "protected", "function", "_handleDirectCall", "(", "$", "methodCalled", ")", "{", "// this doesn't actually do anything because _real_toHtml() won't be", "// called in this request context (unless the flash message isn't", "// actually supposed to be ajax/esi'd in)", "$", "this", "->", "...
Load layout options @param string $methodCalled @return Nexcessnet_Turpentine_Block_Core_Messages
[ "Load", "layout", "options" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Block/Core/Messages.php#L162-L187
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Block/Core/Messages.php
Nexcessnet_Turpentine_Block_Core_Messages._toHtml
protected function _toHtml() { if ($this->_fixMessages()) { if ($this->_shouldUseInjection()) { $html = $this->renderView(); } else { $this->_loadMessages(); $this->_loadSavedMessages(); if (count($this->getMessages())) { $html = $this->_real_toHtml(); } else { // Prevent returning an empty <ul></ul> $html = ''; } } } else { $html = $this->_real_toHtml(); } $this->_directCall = false; return $html; }
php
protected function _toHtml() { if ($this->_fixMessages()) { if ($this->_shouldUseInjection()) { $html = $this->renderView(); } else { $this->_loadMessages(); $this->_loadSavedMessages(); if (count($this->getMessages())) { $html = $this->_real_toHtml(); } else { // Prevent returning an empty <ul></ul> $html = ''; } } } else { $html = $this->_real_toHtml(); } $this->_directCall = false; return $html; }
[ "protected", "function", "_toHtml", "(", ")", "{", "if", "(", "$", "this", "->", "_fixMessages", "(", ")", ")", "{", "if", "(", "$", "this", "->", "_shouldUseInjection", "(", ")", ")", "{", "$", "html", "=", "$", "this", "->", "renderView", "(", ")...
Render the messages block @return string
[ "Render", "the", "messages", "block" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Block/Core/Messages.php#L194-L213
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Block/Core/Messages.php
Nexcessnet_Turpentine_Block_Core_Messages._saveMessages
protected function _saveMessages($messages) { if ($this->_fixMessages() && ! $this->_isEsiRequest()) { Mage::getSingleton('turpentine/session') ->saveMessages($this->getNameInLayout(), $messages); } }
php
protected function _saveMessages($messages) { if ($this->_fixMessages() && ! $this->_isEsiRequest()) { Mage::getSingleton('turpentine/session') ->saveMessages($this->getNameInLayout(), $messages); } }
[ "protected", "function", "_saveMessages", "(", "$", "messages", ")", "{", "if", "(", "$", "this", "->", "_fixMessages", "(", ")", "&&", "!", "$", "this", "->", "_isEsiRequest", "(", ")", ")", "{", "Mage", "::", "getSingleton", "(", "'turpentine/session'", ...
Preserve messages for later display @return null
[ "Preserve", "messages", "for", "later", "display" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Block/Core/Messages.php#L252-L257
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Block/Core/Messages.php
Nexcessnet_Turpentine_Block_Core_Messages._loadMessagesFromStorage
protected function _loadMessagesFromStorage($type) { foreach (Mage::getSingleton($type) ->getMessages(true)->getItems() as $msg) { parent::addMessage($msg); } }
php
protected function _loadMessagesFromStorage($type) { foreach (Mage::getSingleton($type) ->getMessages(true)->getItems() as $msg) { parent::addMessage($msg); } }
[ "protected", "function", "_loadMessagesFromStorage", "(", "$", "type", ")", "{", "foreach", "(", "Mage", "::", "getSingleton", "(", "$", "type", ")", "->", "getMessages", "(", "true", ")", "->", "getItems", "(", ")", "as", "$", "msg", ")", "{", "parent",...
Load messages from the specified session storage @param string $type @return null
[ "Load", "messages", "from", "the", "specified", "session", "storage" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Block/Core/Messages.php#L295-L300
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Block/Core/Messages.php
Nexcessnet_Turpentine_Block_Core_Messages._real_toHtml
protected function _real_toHtml() { if ( ! $this->_directCall) { $this->_directCall = 'getGroupedHtml'; } switch ($this->_directCall) { case 'getHtml': $html = parent::getHtml($this->_singleRenderType); $this->_singleRenderType = self::NO_SINGLE_RENDER_TYPE; break; case 'getGroupedHtml': default: $html = parent::getGroupedHtml(); break; } return $html; }
php
protected function _real_toHtml() { if ( ! $this->_directCall) { $this->_directCall = 'getGroupedHtml'; } switch ($this->_directCall) { case 'getHtml': $html = parent::getHtml($this->_singleRenderType); $this->_singleRenderType = self::NO_SINGLE_RENDER_TYPE; break; case 'getGroupedHtml': default: $html = parent::getGroupedHtml(); break; } return $html; }
[ "protected", "function", "_real_toHtml", "(", ")", "{", "if", "(", "!", "$", "this", "->", "_directCall", ")", "{", "$", "this", "->", "_directCall", "=", "'getGroupedHtml'", ";", "}", "switch", "(", "$", "this", "->", "_directCall", ")", "{", "case", ...
Render output using parent methods @return string
[ "Render", "output", "using", "parent", "methods" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Block/Core/Messages.php#L317-L332
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin.php
Nexcessnet_Turpentine_Model_Varnish_Admin.flushExpression
public function flushExpression() { $args = func_get_args(); $result = array(); foreach (Mage::helper('turpentine/varnish')->getSockets() as $socket) { $socketName = $socket->getConnectionString(); try { call_user_func_array(array($socket, 'ban'), $args); } catch (Mage_Core_Exception $e) { $result[$socketName] = $e->getMessage(); continue; } $result[$socketName] = true; } return $result; }
php
public function flushExpression() { $args = func_get_args(); $result = array(); foreach (Mage::helper('turpentine/varnish')->getSockets() as $socket) { $socketName = $socket->getConnectionString(); try { call_user_func_array(array($socket, 'ban'), $args); } catch (Mage_Core_Exception $e) { $result[$socketName] = $e->getMessage(); continue; } $result[$socketName] = true; } return $result; }
[ "public", "function", "flushExpression", "(", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "Mage", "::", "helper", "(", "'turpentine/varnish'", ")", "->", "getSockets", "(", ")", ...
Flush according to Varnish expression @param mixed ... @return array
[ "Flush", "according", "to", "Varnish", "expression" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin.php#L65-L79
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin.php
Nexcessnet_Turpentine_Model_Varnish_Admin.applyConfig
public function applyConfig() { $result = array(); $helper = Mage::helper('turpentine'); foreach (Mage::helper('turpentine/varnish')->getSockets() as $socket) { $cfgr = Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract::getFromSocket($socket); $socketName = $socket->getConnectionString(); if (is_null($cfgr)) { $result[$socketName] = 'Failed to load configurator'; } else { $vcl = $cfgr->generate($helper->shouldStripVclWhitespace('apply')); $vclName = 'vcl_' . Mage::helper('turpentine/data') ->secureHash(microtime()); try { $this->_testEsiSyntaxParam($socket); $socket->vcl_inline($vclName, $vcl); sleep(1); //this is probably not really needed $socket->vcl_use($vclName); } catch (Mage_Core_Exception $e) { $result[$socketName] = $e->getMessage(); continue; } $result[$socketName] = true; } } return $result; }
php
public function applyConfig() { $result = array(); $helper = Mage::helper('turpentine'); foreach (Mage::helper('turpentine/varnish')->getSockets() as $socket) { $cfgr = Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract::getFromSocket($socket); $socketName = $socket->getConnectionString(); if (is_null($cfgr)) { $result[$socketName] = 'Failed to load configurator'; } else { $vcl = $cfgr->generate($helper->shouldStripVclWhitespace('apply')); $vclName = 'vcl_' . Mage::helper('turpentine/data') ->secureHash(microtime()); try { $this->_testEsiSyntaxParam($socket); $socket->vcl_inline($vclName, $vcl); sleep(1); //this is probably not really needed $socket->vcl_use($vclName); } catch (Mage_Core_Exception $e) { $result[$socketName] = $e->getMessage(); continue; } $result[$socketName] = true; } } return $result; }
[ "public", "function", "applyConfig", "(", ")", "{", "$", "result", "=", "array", "(", ")", ";", "$", "helper", "=", "Mage", "::", "helper", "(", "'turpentine'", ")", ";", "foreach", "(", "Mage", "::", "helper", "(", "'turpentine/varnish'", ")", "->", "...
Generate and apply the config to the Varnish instances @return bool
[ "Generate", "and", "apply", "the", "config", "to", "the", "Varnish", "instances" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin.php#L97-L122
train
nexcess/magento-turpentine
app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin.php
Nexcessnet_Turpentine_Model_Varnish_Admin.getConfigurator
public function getConfigurator() { $sockets = Mage::helper('turpentine/varnish')->getSockets(); $cfgr = Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract::getFromSocket($sockets[0]); return $cfgr; }
php
public function getConfigurator() { $sockets = Mage::helper('turpentine/varnish')->getSockets(); $cfgr = Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract::getFromSocket($sockets[0]); return $cfgr; }
[ "public", "function", "getConfigurator", "(", ")", "{", "$", "sockets", "=", "Mage", "::", "helper", "(", "'turpentine/varnish'", ")", "->", "getSockets", "(", ")", ";", "$", "cfgr", "=", "Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract", "::", "getFromSoc...
Get a configurator based on the first socket in the server list @return Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract
[ "Get", "a", "configurator", "based", "on", "the", "first", "socket", "in", "the", "server", "list" ]
c670a492a18cf495d87699e0dbd712ad03fd84ad
https://github.com/nexcess/magento-turpentine/blob/c670a492a18cf495d87699e0dbd712ad03fd84ad/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin.php#L129-L133
train
aloha/laravel-twilio
src/Support/Laravel/L5ServiceProvider.php
L5ServiceProvider.boot
public function boot() { $this->publishes([ __DIR__.'/../../config/config.php' => config_path('twilio.php'), ], 'config'); $this->mergeConfigFrom(__DIR__.'/../../config/config.php', 'twilio'); $this->commands([ TwilioCallCommand::class, TwilioSmsCommand::class, ]); }
php
public function boot() { $this->publishes([ __DIR__.'/../../config/config.php' => config_path('twilio.php'), ], 'config'); $this->mergeConfigFrom(__DIR__.'/../../config/config.php', 'twilio'); $this->commands([ TwilioCallCommand::class, TwilioSmsCommand::class, ]); }
[ "public", "function", "boot", "(", ")", "{", "$", "this", "->", "publishes", "(", "[", "__DIR__", ".", "'/../../config/config.php'", "=>", "config_path", "(", "'twilio.php'", ")", ",", "]", ",", "'config'", ")", ";", "$", "this", "->", "mergeConfigFrom", "...
Boot method.
[ "Boot", "method", "." ]
0e5ad6f31f001fdcdc0b46dfc7cc2449e4c387eb
https://github.com/aloha/laravel-twilio/blob/0e5ad6f31f001fdcdc0b46dfc7cc2449e4c387eb/src/Support/Laravel/L5ServiceProvider.php#L15-L27
train
thephpleague/geotools
src/Coordinate/Ellipsoid.php
Ellipsoid.createFromName
public static function createFromName($name = self::WGS84) { $name = trim($name); if (empty($name)) { throw new InvalidArgumentException('Please provide an ellipsoid name !'); } if (!array_key_exists($name, self::$referenceEllipsoids)) { throw new InvalidArgumentException( sprintf('%s ellipsoid does not exist in selected reference ellipsoids !', $name) ); } return self::createFromArray(self::$referenceEllipsoids[$name]); }
php
public static function createFromName($name = self::WGS84) { $name = trim($name); if (empty($name)) { throw new InvalidArgumentException('Please provide an ellipsoid name !'); } if (!array_key_exists($name, self::$referenceEllipsoids)) { throw new InvalidArgumentException( sprintf('%s ellipsoid does not exist in selected reference ellipsoids !', $name) ); } return self::createFromArray(self::$referenceEllipsoids[$name]); }
[ "public", "static", "function", "createFromName", "(", "$", "name", "=", "self", "::", "WGS84", ")", "{", "$", "name", "=", "trim", "(", "$", "name", ")", ";", "if", "(", "empty", "(", "$", "name", ")", ")", "{", "throw", "new", "InvalidArgumentExcep...
Create the ellipsoid chosen by its name. @param string $name The name of the ellipsoid to create (optional). @return Ellipsoid
[ "Create", "the", "ellipsoid", "chosen", "by", "its", "name", "." ]
955a6337cc263148300290f059e8af9ee665c9b4
https://github.com/thephpleague/geotools/blob/955a6337cc263148300290f059e8af9ee665c9b4/src/Coordinate/Ellipsoid.php#L235-L250
train
thephpleague/geotools
src/Coordinate/Ellipsoid.php
Ellipsoid.createFromArray
public static function createFromArray(array $newEllipsoid) { if (!isset($newEllipsoid['name']) || !isset($newEllipsoid['a']) || !isset($newEllipsoid['invF']) || 3 !== count($newEllipsoid)) { throw new InvalidArgumentException('Ellipsoid arrays should contain `name`, `a` and `invF` keys !'); } return new self($newEllipsoid['name'], $newEllipsoid['a'], $newEllipsoid['invF']); }
php
public static function createFromArray(array $newEllipsoid) { if (!isset($newEllipsoid['name']) || !isset($newEllipsoid['a']) || !isset($newEllipsoid['invF']) || 3 !== count($newEllipsoid)) { throw new InvalidArgumentException('Ellipsoid arrays should contain `name`, `a` and `invF` keys !'); } return new self($newEllipsoid['name'], $newEllipsoid['a'], $newEllipsoid['invF']); }
[ "public", "static", "function", "createFromArray", "(", "array", "$", "newEllipsoid", ")", "{", "if", "(", "!", "isset", "(", "$", "newEllipsoid", "[", "'name'", "]", ")", "||", "!", "isset", "(", "$", "newEllipsoid", "[", "'a'", "]", ")", "||", "!", ...
Create an ellipsoid from an array. @param array $newEllipsoid The ellipsoid's parameters to create. @return Ellipsoid
[ "Create", "an", "ellipsoid", "from", "an", "array", "." ]
955a6337cc263148300290f059e8af9ee665c9b4
https://github.com/thephpleague/geotools/blob/955a6337cc263148300290f059e8af9ee665c9b4/src/Coordinate/Ellipsoid.php#L259-L267
train
thephpleague/geotools
src/Coordinate/Ellipsoid.php
Ellipsoid.checkCoordinatesEllipsoid
public static function checkCoordinatesEllipsoid(CoordinateInterface $a, CoordinateInterface $b) { if ($a->getEllipsoid() != $b->getEllipsoid()) { throw new NotMatchingEllipsoidException('The ellipsoids for both coordinates must match !'); } }
php
public static function checkCoordinatesEllipsoid(CoordinateInterface $a, CoordinateInterface $b) { if ($a->getEllipsoid() != $b->getEllipsoid()) { throw new NotMatchingEllipsoidException('The ellipsoids for both coordinates must match !'); } }
[ "public", "static", "function", "checkCoordinatesEllipsoid", "(", "CoordinateInterface", "$", "a", ",", "CoordinateInterface", "$", "b", ")", "{", "if", "(", "$", "a", "->", "getEllipsoid", "(", ")", "!=", "$", "b", "->", "getEllipsoid", "(", ")", ")", "{"...
Check if coordinates have the same ellipsoid. @param CoordinateInterface $a A coordinate. @param CoordinateInterface $b A coordinate. @throws NotMatchingEllipsoidException
[ "Check", "if", "coordinates", "have", "the", "same", "ellipsoid", "." ]
955a6337cc263148300290f059e8af9ee665c9b4
https://github.com/thephpleague/geotools/blob/955a6337cc263148300290f059e8af9ee665c9b4/src/Coordinate/Ellipsoid.php#L277-L282
train
thephpleague/geotools
src/Coordinate/Coordinate.php
Coordinate.setFromString
public function setFromString($coordinates) { if (!is_string($coordinates)) { throw new InvalidArgumentException('The given coordinates should be a string !'); } try { $inDecimalDegree = $this->toDecimalDegrees($coordinates); $this->setLatitude($inDecimalDegree[0]); $this->setLongitude($inDecimalDegree[1]); } catch (InvalidArgumentException $e) { throw $e; } }
php
public function setFromString($coordinates) { if (!is_string($coordinates)) { throw new InvalidArgumentException('The given coordinates should be a string !'); } try { $inDecimalDegree = $this->toDecimalDegrees($coordinates); $this->setLatitude($inDecimalDegree[0]); $this->setLongitude($inDecimalDegree[1]); } catch (InvalidArgumentException $e) { throw $e; } }
[ "public", "function", "setFromString", "(", "$", "coordinates", ")", "{", "if", "(", "!", "is_string", "(", "$", "coordinates", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'The given coordinates should be a string !'", ")", ";", "}", "try", ...
Creates a valid and acceptable geographic coordinates. @param string $coordinates @throws InvalidArgumentException
[ "Creates", "a", "valid", "and", "acceptable", "geographic", "coordinates", "." ]
955a6337cc263148300290f059e8af9ee665c9b4
https://github.com/thephpleague/geotools/blob/955a6337cc263148300290f059e8af9ee665c9b4/src/Coordinate/Coordinate.php#L152-L165
train
thephpleague/geotools
src/Coordinate/Coordinate.php
Coordinate.toDecimalDegrees
private function toDecimalDegrees($coordinates) { // 40.446195, -79.948862 if (preg_match('/(\-?[0-9]{1,2}\.?\d*)[, ] ?(\-?[0-9]{1,3}\.?\d*)$/', $coordinates, $match)) { return array($match[1], $match[2]); } // 40° 26.7717, -79° 56.93172 if (preg_match('/(\-?[0-9]{1,2})\D+([0-9]{1,2}\.?\d*)[, ] ?(\-?[0-9]{1,3})\D+([0-9]{1,2}\.?\d*)$/i', $coordinates, $match)) { return array( $match[1] < 0 ? $match[1] - $match[2] / 60 : $match[1] + $match[2] / 60, $match[3] < 0 ? $match[3] - $match[4] / 60 : $match[3] + $match[4] / 60 ); } // 40.446195N 79.948862W if (preg_match('/([0-9]{1,2}\.?\d*)\D*([ns]{1})[, ] ?([0-9]{1,3}\.?\d*)\D*([we]{1})$/i', $coordinates, $match)) { return array( 'N' === strtoupper($match[2]) ? $match[1] : -$match[1], 'E' === strtoupper($match[4]) ? $match[3] : -$match[3] ); } // 40°26.7717S 79°56.93172E // 25°59.86′N,21°09.81′W if (preg_match('/([0-9]{1,2})\D+([0-9]{1,2}\.?\d*)\D*([ns]{1})[, ] ?([0-9]{1,3})\D+([0-9]{1,2}\.?\d*)\D*([we]{1})$/i', $coordinates, $match)) { $latitude = $match[1] + $match[2] / 60; $longitude = $match[4] + $match[5] / 60; return array( 'N' === strtoupper($match[3]) ? $latitude : -$latitude, 'E' === strtoupper($match[6]) ? $longitude : -$longitude ); } // 40:26:46N, 079:56:55W // 40:26:46.302N 079:56:55.903W // 40°26′47″N 079°58′36″W // 40d 26′ 47″ N 079d 58′ 36″ W if (preg_match('/([0-9]{1,2})\D+([0-9]{1,2})\D+([0-9]{1,2}\.?\d*)\D*([ns]{1})[, ] ?([0-9]{1,3})\D+([0-9]{1,2})\D+([0-9]{1,2}\.?\d*)\D*([we]{1})$/i', $coordinates, $match)) { $latitude = $match[1] + ($match[2] * 60 + $match[3]) / 3600; $longitude = $match[5] + ($match[6] * 60 + $match[7]) / 3600; return array( 'N' === strtoupper($match[4]) ? $latitude : -$latitude, 'E' === strtoupper($match[8]) ? $longitude : -$longitude ); } throw new InvalidArgumentException( 'It should be a valid and acceptable ways to write geographic coordinates !' ); }
php
private function toDecimalDegrees($coordinates) { // 40.446195, -79.948862 if (preg_match('/(\-?[0-9]{1,2}\.?\d*)[, ] ?(\-?[0-9]{1,3}\.?\d*)$/', $coordinates, $match)) { return array($match[1], $match[2]); } // 40° 26.7717, -79° 56.93172 if (preg_match('/(\-?[0-9]{1,2})\D+([0-9]{1,2}\.?\d*)[, ] ?(\-?[0-9]{1,3})\D+([0-9]{1,2}\.?\d*)$/i', $coordinates, $match)) { return array( $match[1] < 0 ? $match[1] - $match[2] / 60 : $match[1] + $match[2] / 60, $match[3] < 0 ? $match[3] - $match[4] / 60 : $match[3] + $match[4] / 60 ); } // 40.446195N 79.948862W if (preg_match('/([0-9]{1,2}\.?\d*)\D*([ns]{1})[, ] ?([0-9]{1,3}\.?\d*)\D*([we]{1})$/i', $coordinates, $match)) { return array( 'N' === strtoupper($match[2]) ? $match[1] : -$match[1], 'E' === strtoupper($match[4]) ? $match[3] : -$match[3] ); } // 40°26.7717S 79°56.93172E // 25°59.86′N,21°09.81′W if (preg_match('/([0-9]{1,2})\D+([0-9]{1,2}\.?\d*)\D*([ns]{1})[, ] ?([0-9]{1,3})\D+([0-9]{1,2}\.?\d*)\D*([we]{1})$/i', $coordinates, $match)) { $latitude = $match[1] + $match[2] / 60; $longitude = $match[4] + $match[5] / 60; return array( 'N' === strtoupper($match[3]) ? $latitude : -$latitude, 'E' === strtoupper($match[6]) ? $longitude : -$longitude ); } // 40:26:46N, 079:56:55W // 40:26:46.302N 079:56:55.903W // 40°26′47″N 079°58′36″W // 40d 26′ 47″ N 079d 58′ 36″ W if (preg_match('/([0-9]{1,2})\D+([0-9]{1,2})\D+([0-9]{1,2}\.?\d*)\D*([ns]{1})[, ] ?([0-9]{1,3})\D+([0-9]{1,2})\D+([0-9]{1,2}\.?\d*)\D*([we]{1})$/i', $coordinates, $match)) { $latitude = $match[1] + ($match[2] * 60 + $match[3]) / 3600; $longitude = $match[5] + ($match[6] * 60 + $match[7]) / 3600; return array( 'N' === strtoupper($match[4]) ? $latitude : -$latitude, 'E' === strtoupper($match[8]) ? $longitude : -$longitude ); } throw new InvalidArgumentException( 'It should be a valid and acceptable ways to write geographic coordinates !' ); }
[ "private", "function", "toDecimalDegrees", "(", "$", "coordinates", ")", "{", "// 40.446195, -79.948862", "if", "(", "preg_match", "(", "'/(\\-?[0-9]{1,2}\\.?\\d*)[, ] ?(\\-?[0-9]{1,3}\\.?\\d*)$/'", ",", "$", "coordinates", ",", "$", "match", ")", ")", "{", "return", ...
Converts a valid and acceptable geographic coordinates to decimal degrees coordinate. @param string $coordinates A valid and acceptable geographic coordinates. @return array An array of coordinate in decimal degree. @throws InvalidArgumentException @see http://en.wikipedia.org/wiki/Geographic_coordinate_conversion
[ "Converts", "a", "valid", "and", "acceptable", "geographic", "coordinates", "to", "decimal", "degrees", "coordinate", "." ]
955a6337cc263148300290f059e8af9ee665c9b4
https://github.com/thephpleague/geotools/blob/955a6337cc263148300290f059e8af9ee665c9b4/src/Coordinate/Coordinate.php#L198-L257
train
thephpleague/geotools
src/Coordinate/Coordinate.php
Coordinate.isEqual
public function isEqual(Coordinate $coordinate) { return bccomp($this->latitude, $coordinate->getLatitude(), $this->getPrecision()) === 0 && bccomp($this->longitude, $coordinate->getLongitude(), $this->getPrecision()) === 0; }
php
public function isEqual(Coordinate $coordinate) { return bccomp($this->latitude, $coordinate->getLatitude(), $this->getPrecision()) === 0 && bccomp($this->longitude, $coordinate->getLongitude(), $this->getPrecision()) === 0; }
[ "public", "function", "isEqual", "(", "Coordinate", "$", "coordinate", ")", "{", "return", "bccomp", "(", "$", "this", "->", "latitude", ",", "$", "coordinate", "->", "getLatitude", "(", ")", ",", "$", "this", "->", "getPrecision", "(", ")", ")", "===", ...
Returns a boolean determining coordinates equality @param Coordinate $coordinate @return boolean
[ "Returns", "a", "boolean", "determining", "coordinates", "equality" ]
955a6337cc263148300290f059e8af9ee665c9b4
https://github.com/thephpleague/geotools/blob/955a6337cc263148300290f059e8af9ee665c9b4/src/Coordinate/Coordinate.php#L272-L274
train
thephpleague/geotools
src/Batch/BatchGeocoded.php
BatchGeocoded.fromArray
public function fromArray(array $data = []) { if (isset($data['providerName'])) { $this->providerName = $data['providerName']; } if (isset($data['query'])) { $this->query = $data['query']; } if (isset($data['exception'])) { $this->exception = $data['exception']; } //GeoCoder Address::createFromArray expects longitude/latitude keys $data['address']['longitude'] = $data['address']['coordinates']['longitude'] ?? null; $data['address']['latitude'] = $data['address']['coordinates']['latitude'] ?? null; // Shortcut to create the address and set it in this class $this->setAddress(Address::createFromArray($data['address'])); }
php
public function fromArray(array $data = []) { if (isset($data['providerName'])) { $this->providerName = $data['providerName']; } if (isset($data['query'])) { $this->query = $data['query']; } if (isset($data['exception'])) { $this->exception = $data['exception']; } //GeoCoder Address::createFromArray expects longitude/latitude keys $data['address']['longitude'] = $data['address']['coordinates']['longitude'] ?? null; $data['address']['latitude'] = $data['address']['coordinates']['latitude'] ?? null; // Shortcut to create the address and set it in this class $this->setAddress(Address::createFromArray($data['address'])); }
[ "public", "function", "fromArray", "(", "array", "$", "data", "=", "[", "]", ")", "{", "if", "(", "isset", "(", "$", "data", "[", "'providerName'", "]", ")", ")", "{", "$", "this", "->", "providerName", "=", "$", "data", "[", "'providerName'", "]", ...
Create an instance from an array, used from cache libraries. @param array $data
[ "Create", "an", "instance", "from", "an", "array", "used", "from", "cache", "libraries", "." ]
955a6337cc263148300290f059e8af9ee665c9b4
https://github.com/thephpleague/geotools/blob/955a6337cc263148300290f059e8af9ee665c9b4/src/Batch/BatchGeocoded.php#L180-L198
train
thephpleague/geotools
src/CLI/Command/Geocoder/Command.php
Command.getProvider
protected function getProvider($provider) { $provider = $this->lowerize((trim($provider))); $provider = array_key_exists($provider, $this->providers) ? $this->providers[$provider] : $this->providers['google_maps']; return '\\Geocoder\\Provider\\' . $provider . $provider; }
php
protected function getProvider($provider) { $provider = $this->lowerize((trim($provider))); $provider = array_key_exists($provider, $this->providers) ? $this->providers[$provider] : $this->providers['google_maps']; return '\\Geocoder\\Provider\\' . $provider . $provider; }
[ "protected", "function", "getProvider", "(", "$", "provider", ")", "{", "$", "provider", "=", "$", "this", "->", "lowerize", "(", "(", "trim", "(", "$", "provider", ")", ")", ")", ";", "$", "provider", "=", "array_key_exists", "(", "$", "provider", ","...
Returns the provider class name. The default provider is Google Maps. @param string $provider The name of the provider to use. @return string The name of the provider class to use.
[ "Returns", "the", "provider", "class", "name", ".", "The", "default", "provider", "is", "Google", "Maps", "." ]
955a6337cc263148300290f059e8af9ee665c9b4
https://github.com/thephpleague/geotools/blob/955a6337cc263148300290f059e8af9ee665c9b4/src/CLI/Command/Geocoder/Command.php#L97-L105
train
thephpleague/geotools
src/CLI/Command/Geocoder/Command.php
Command.getDumper
protected function getDumper($dumper) { $dumper = $this->lowerize((trim($dumper))); $dumper = array_key_exists($dumper, $this->dumpers) ? $this->dumpers[$dumper] : $this->dumpers['wkt']; return '\\Geocoder\\Dumper\\' . $dumper; }
php
protected function getDumper($dumper) { $dumper = $this->lowerize((trim($dumper))); $dumper = array_key_exists($dumper, $this->dumpers) ? $this->dumpers[$dumper] : $this->dumpers['wkt']; return '\\Geocoder\\Dumper\\' . $dumper; }
[ "protected", "function", "getDumper", "(", "$", "dumper", ")", "{", "$", "dumper", "=", "$", "this", "->", "lowerize", "(", "(", "trim", "(", "$", "dumper", ")", ")", ")", ";", "$", "dumper", "=", "array_key_exists", "(", "$", "dumper", ",", "$", "...
Returns the dumper class name. The default dumper is WktDumper. @param string $dumper The name of the dumper to use. @return string The name of the dumper class to use.
[ "Returns", "the", "dumper", "class", "name", ".", "The", "default", "dumper", "is", "WktDumper", "." ]
955a6337cc263148300290f059e8af9ee665c9b4
https://github.com/thephpleague/geotools/blob/955a6337cc263148300290f059e8af9ee665c9b4/src/CLI/Command/Geocoder/Command.php#L127-L135
train
thephpleague/geotools
src/Batch/Batch.php
Batch.isCached
public function isCached($providerName, $query) { if (null === $this->cache) { return false; } $item = $this->cache->getItem($this->getCacheKey($providerName, $query)); if ($item->isHit()) { return $item->get(); } return false; }
php
public function isCached($providerName, $query) { if (null === $this->cache) { return false; } $item = $this->cache->getItem($this->getCacheKey($providerName, $query)); if ($item->isHit()) { return $item->get(); } return false; }
[ "public", "function", "isCached", "(", "$", "providerName", ",", "$", "query", ")", "{", "if", "(", "null", "===", "$", "this", "->", "cache", ")", "{", "return", "false", ";", "}", "$", "item", "=", "$", "this", "->", "cache", "->", "getItem", "("...
Check against the cache instance if any. @param string $providerName The name of the provider. @param string $query The query string. @return boolean|BatchGeocoded The BatchGeocoded object from the query or the cache instance.
[ "Check", "against", "the", "cache", "instance", "if", "any", "." ]
955a6337cc263148300290f059e8af9ee665c9b4
https://github.com/thephpleague/geotools/blob/955a6337cc263148300290f059e8af9ee665c9b4/src/Batch/Batch.php#L68-L81
train
thephpleague/geotools
src/Batch/Batch.php
Batch.cache
public function cache(BatchGeocoded $geocoded) { if (isset($this->cache)) { $key = $this->getCacheKey($geocoded->getProviderName(), $geocoded->getQuery()); $item = $this->cache->getItem($key); $item->set($geocoded); $this->cache->save($item); } return $geocoded; }
php
public function cache(BatchGeocoded $geocoded) { if (isset($this->cache)) { $key = $this->getCacheKey($geocoded->getProviderName(), $geocoded->getQuery()); $item = $this->cache->getItem($key); $item->set($geocoded); $this->cache->save($item); } return $geocoded; }
[ "public", "function", "cache", "(", "BatchGeocoded", "$", "geocoded", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "cache", ")", ")", "{", "$", "key", "=", "$", "this", "->", "getCacheKey", "(", "$", "geocoded", "->", "getProviderName", "(", ...
Cache the BatchGeocoded object. @param BatchGeocoded $geocoded The BatchGeocoded object to cache. @return BatchGeocoded The BatchGeocoded object.
[ "Cache", "the", "BatchGeocoded", "object", "." ]
955a6337cc263148300290f059e8af9ee665c9b4
https://github.com/thephpleague/geotools/blob/955a6337cc263148300290f059e8af9ee665c9b4/src/Batch/Batch.php#L91-L101
train
thephpleague/geotools
src/Vertex/Vertex.php
Vertex.initialBearing
public function initialBearing() { Ellipsoid::checkCoordinatesEllipsoid($this->from, $this->to); $latA = deg2rad($this->from->getLatitude()); $latB = deg2rad($this->to->getLatitude()); $dLng = deg2rad($this->to->getLongitude() - $this->from->getLongitude()); $y = sin($dLng) * cos($latB); $x = cos($latA) * sin($latB) - sin($latA) * cos($latB) * cos($dLng); return (float) (rad2deg(atan2($y, $x)) + 360) % 360; }
php
public function initialBearing() { Ellipsoid::checkCoordinatesEllipsoid($this->from, $this->to); $latA = deg2rad($this->from->getLatitude()); $latB = deg2rad($this->to->getLatitude()); $dLng = deg2rad($this->to->getLongitude() - $this->from->getLongitude()); $y = sin($dLng) * cos($latB); $x = cos($latA) * sin($latB) - sin($latA) * cos($latB) * cos($dLng); return (float) (rad2deg(atan2($y, $x)) + 360) % 360; }
[ "public", "function", "initialBearing", "(", ")", "{", "Ellipsoid", "::", "checkCoordinatesEllipsoid", "(", "$", "this", "->", "from", ",", "$", "this", "->", "to", ")", ";", "$", "latA", "=", "deg2rad", "(", "$", "this", "->", "from", "->", "getLatitude...
Returns the initial bearing from the origin coordinate to the destination coordinate in degrees. @return float The initial bearing in degrees
[ "Returns", "the", "initial", "bearing", "from", "the", "origin", "coordinate", "to", "the", "destination", "coordinate", "in", "degrees", "." ]
955a6337cc263148300290f059e8af9ee665c9b4
https://github.com/thephpleague/geotools/blob/955a6337cc263148300290f059e8af9ee665c9b4/src/Vertex/Vertex.php#L145-L157
train
thephpleague/geotools
src/Vertex/Vertex.php
Vertex.isOnSameLine
public function isOnSameLine(Vertex $vertex) { if (is_null($this->getGradient()) && is_null($vertex->getGradient()) && $this->from->getLongitude() == $vertex->getFrom()->getLongitude()) { return true; } elseif (!is_null($this->getGradient()) && !is_null($vertex->getGradient())) { return ( bccomp($this->getGradient(), $vertex->getGradient(), $this->getPrecision()) === 0 && bccomp($this->getOrdinateIntercept(), $vertex->getOrdinateIntercept(), $this->getPrecision()) ===0 ); } else { return false; } }
php
public function isOnSameLine(Vertex $vertex) { if (is_null($this->getGradient()) && is_null($vertex->getGradient()) && $this->from->getLongitude() == $vertex->getFrom()->getLongitude()) { return true; } elseif (!is_null($this->getGradient()) && !is_null($vertex->getGradient())) { return ( bccomp($this->getGradient(), $vertex->getGradient(), $this->getPrecision()) === 0 && bccomp($this->getOrdinateIntercept(), $vertex->getOrdinateIntercept(), $this->getPrecision()) ===0 ); } else { return false; } }
[ "public", "function", "isOnSameLine", "(", "Vertex", "$", "vertex", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "getGradient", "(", ")", ")", "&&", "is_null", "(", "$", "vertex", "->", "getGradient", "(", ")", ")", "&&", "$", "this", "->"...
Returns true if the vertex passed on argument is on the same line as this object @param Vertex $vertex The vertex to compare @return boolean
[ "Returns", "true", "if", "the", "vertex", "passed", "on", "argument", "is", "on", "the", "same", "line", "as", "this", "object" ]
955a6337cc263148300290f059e8af9ee665c9b4
https://github.com/thephpleague/geotools/blob/955a6337cc263148300290f059e8af9ee665c9b4/src/Vertex/Vertex.php#L261-L273
train
thephpleague/geotools
src/Vertex/Vertex.php
Vertex.getOtherCoordinate
public function getOtherCoordinate(CoordinateInterface $coordinate) { if ($coordinate->isEqual($this->from)) { return $this->to; } else if ($coordinate->isEqual($this->to)) { return $this->from; } return null; }
php
public function getOtherCoordinate(CoordinateInterface $coordinate) { if ($coordinate->isEqual($this->from)) { return $this->to; } else if ($coordinate->isEqual($this->to)) { return $this->from; } return null; }
[ "public", "function", "getOtherCoordinate", "(", "CoordinateInterface", "$", "coordinate", ")", "{", "if", "(", "$", "coordinate", "->", "isEqual", "(", "$", "this", "->", "from", ")", ")", "{", "return", "$", "this", "->", "to", ";", "}", "else", "if", ...
Returns the other coordinate who is not the coordinate passed on argument @param CoordinateInterface $coordinate @return null|Coordinate
[ "Returns", "the", "other", "coordinate", "who", "is", "not", "the", "coordinate", "passed", "on", "argument" ]
955a6337cc263148300290f059e8af9ee665c9b4
https://github.com/thephpleague/geotools/blob/955a6337cc263148300290f059e8af9ee665c9b4/src/Vertex/Vertex.php#L280-L287
train
thephpleague/geotools
src/Convert/Convert.php
Convert.parseCoordinate
private function parseCoordinate($coordinate) { list($degrees) = explode('.', abs($coordinate)); list($minutes) = explode('.', (abs($coordinate) - $degrees) * 60); return [ 'positive' => $coordinate >= 0, 'degrees' => (string) $degrees, 'decimalMinutes' => (string) round((abs($coordinate) - $degrees) * 60, ConvertInterface::DECIMAL_MINUTES_PRECISION, ConvertInterface::DECIMAL_MINUTES_MODE), 'minutes' => (string) $minutes, 'seconds' => (string) round(((abs($coordinate) - $degrees) * 60 - $minutes) * 60), ]; }
php
private function parseCoordinate($coordinate) { list($degrees) = explode('.', abs($coordinate)); list($minutes) = explode('.', (abs($coordinate) - $degrees) * 60); return [ 'positive' => $coordinate >= 0, 'degrees' => (string) $degrees, 'decimalMinutes' => (string) round((abs($coordinate) - $degrees) * 60, ConvertInterface::DECIMAL_MINUTES_PRECISION, ConvertInterface::DECIMAL_MINUTES_MODE), 'minutes' => (string) $minutes, 'seconds' => (string) round(((abs($coordinate) - $degrees) * 60 - $minutes) * 60), ]; }
[ "private", "function", "parseCoordinate", "(", "$", "coordinate", ")", "{", "list", "(", "$", "degrees", ")", "=", "explode", "(", "'.'", ",", "abs", "(", "$", "coordinate", ")", ")", ";", "list", "(", "$", "minutes", ")", "=", "explode", "(", "'.'",...
Parse decimal degrees coordinate to degrees minutes seconds and decimal minutes coordinate. @param string $coordinate The coordinate to parse. @return array The replace pairs values.
[ "Parse", "decimal", "degrees", "coordinate", "to", "degrees", "minutes", "seconds", "and", "decimal", "minutes", "coordinate", "." ]
955a6337cc263148300290f059e8af9ee665c9b4
https://github.com/thephpleague/geotools/blob/955a6337cc263148300290f059e8af9ee665c9b4/src/Convert/Convert.php#L50-L64
train
Devristo/phpws
examples/remoteEvents.php
StackHandler.onConnect
public function onConnect(WebSocketTransportInterface $transport){ /** * @var $stackTransport StackTransport * @var $jsonTransport RemoteEventTransport */ $logger = $this->logger; $loop = $this->loop; $stackTransport = StackTransport::create($transport, array(function(TransportInterface $carrier) use($loop, $logger){ return new RemoteEventTransport($carrier, $loop, $logger); })); $jsonTransport = $stackTransport->getTopTransport(); $server = $transport->getHandshakeResponse()->getHeaders()->get('X-WebSocket-Server')->getFieldValue(); $greetingMessage = RemoteEventMessage::create(null, "greeting", "hello world from $server!"); $jsonTransport->whenResponseTo($greetingMessage, 0.1)->then(function(RemoteEventMessage $result) use ($logger, $server){ $logger->notice(sprintf("Got '%s' in response to 'hello world from $server!'", $result->getData())); }); $jsonTransport->remoteEvent()->on("greeting", function(RemoteEventMessage $message) use ($transport, $logger){ $logger->notice(sprintf("We got a greeting event from {$transport->getId()}")); }); }
php
public function onConnect(WebSocketTransportInterface $transport){ /** * @var $stackTransport StackTransport * @var $jsonTransport RemoteEventTransport */ $logger = $this->logger; $loop = $this->loop; $stackTransport = StackTransport::create($transport, array(function(TransportInterface $carrier) use($loop, $logger){ return new RemoteEventTransport($carrier, $loop, $logger); })); $jsonTransport = $stackTransport->getTopTransport(); $server = $transport->getHandshakeResponse()->getHeaders()->get('X-WebSocket-Server')->getFieldValue(); $greetingMessage = RemoteEventMessage::create(null, "greeting", "hello world from $server!"); $jsonTransport->whenResponseTo($greetingMessage, 0.1)->then(function(RemoteEventMessage $result) use ($logger, $server){ $logger->notice(sprintf("Got '%s' in response to 'hello world from $server!'", $result->getData())); }); $jsonTransport->remoteEvent()->on("greeting", function(RemoteEventMessage $message) use ($transport, $logger){ $logger->notice(sprintf("We got a greeting event from {$transport->getId()}")); }); }
[ "public", "function", "onConnect", "(", "WebSocketTransportInterface", "$", "transport", ")", "{", "/**\n * @var $stackTransport StackTransport\n * @var $jsonTransport RemoteEventTransport\n */", "$", "logger", "=", "$", "this", "->", "logger", ";", "$", ...
Notify everyone when a user has joined the chat @param StackTransport $stackTransport
[ "Notify", "everyone", "when", "a", "user", "has", "joined", "the", "chat" ]
c2eee395bf55d49405cfb635685fa8997f56dae1
https://github.com/Devristo/phpws/blob/c2eee395bf55d49405cfb635685fa8997f56dae1/examples/remoteEvents.php#L28-L52
train
Devristo/phpws
examples/chat.php
ChatHandler.onMessage
public function onMessage(WebSocketTransportInterface $user, WebSocketMessageInterface $msg) { $this->logger->notice("Broadcasting " . strlen($msg->getData()) . " bytes"); foreach($this->getConnections() as $client){ $client->sendString("User {$user->getId()} said: ".$msg->getData()); } }
php
public function onMessage(WebSocketTransportInterface $user, WebSocketMessageInterface $msg) { $this->logger->notice("Broadcasting " . strlen($msg->getData()) . " bytes"); foreach($this->getConnections() as $client){ $client->sendString("User {$user->getId()} said: ".$msg->getData()); } }
[ "public", "function", "onMessage", "(", "WebSocketTransportInterface", "$", "user", ",", "WebSocketMessageInterface", "$", "msg", ")", "{", "$", "this", "->", "logger", "->", "notice", "(", "\"Broadcasting \"", ".", "strlen", "(", "$", "msg", "->", "getData", ...
Broadcast messages sent by a user to everyone in the room @param WebSocketTransportInterface $user @param WebSocketMessageInterface $msg
[ "Broadcast", "messages", "sent", "by", "a", "user", "to", "everyone", "in", "the", "room" ]
c2eee395bf55d49405cfb635685fa8997f56dae1
https://github.com/Devristo/phpws/blob/c2eee395bf55d49405cfb635685fa8997f56dae1/examples/chat.php#L41-L47
train
Devristo/phpws
examples/tcp_proxy_example.php
ProxyHandler.onMessage
public function onMessage(WebSocketTransportInterface $user, WebSocketMessageInterface $msg) { try { $message = json_decode($msg->getData()); if ($message->command == 'connect') $this->requestConnect($user, $message); elseif ($message->command == 'write') $this->requestWrite($user, $message); elseif ($message->command == 'close') $this->requestClose($user, $message); } catch (Exception $e) { $this->logger->err($e->getMessage()); } }
php
public function onMessage(WebSocketTransportInterface $user, WebSocketMessageInterface $msg) { try { $message = json_decode($msg->getData()); if ($message->command == 'connect') $this->requestConnect($user, $message); elseif ($message->command == 'write') $this->requestWrite($user, $message); elseif ($message->command == 'close') $this->requestClose($user, $message); } catch (Exception $e) { $this->logger->err($e->getMessage()); } }
[ "public", "function", "onMessage", "(", "WebSocketTransportInterface", "$", "user", ",", "WebSocketMessageInterface", "$", "msg", ")", "{", "try", "{", "$", "message", "=", "json_decode", "(", "$", "msg", "->", "getData", "(", ")", ")", ";", "if", "(", "$"...
Entry point for all messages received from clients in this proxy 'room' @param WebSocketTransportInterface $user @param WebSocketMessageInterface $msg
[ "Entry", "point", "for", "all", "messages", "received", "from", "clients", "in", "this", "proxy", "room" ]
c2eee395bf55d49405cfb635685fa8997f56dae1
https://github.com/Devristo/phpws/blob/c2eee395bf55d49405cfb635685fa8997f56dae1/examples/tcp_proxy_example.php#L54-L69
train
Devristo/phpws
examples/tcp_proxy_example.php
ProxyHandler.requestConnect
protected function requestConnect(WebSocketTransportInterface $user, $message) { $address = $message->address; $this->logger->notice(sprintf("User %s requests connection to %s", $user->getId(), $address)); try { $dnsResolverFactory = new React\Dns\Resolver\Factory(); $dns = $dnsResolverFactory->createCached('8.8.8.8', $this->loop); $stream = new \React\SocketClient\Connector($this->loop, $dns); list($host, $port) = explode(":", $address); $logger = $this->logger; $that = $this; $stream->create($host, $port)->then(function (\React\Stream\Stream $stream) use($user, $logger, $message, $address, $that){ $id = uniqid("stream-$address-"); $that->addStream($user, $id, $stream); // Notify the user when the connection has been made $user->sendString(json_encode(array( 'connection' => $id, 'event' => 'connected', 'tag' => property_exists($message, 'tag') ? $message->tag : null ))); // Forward data back to the user $stream->on("data", function ($data) use ($stream, $id, $user, $logger){ $logger->notice("Forwarding ".strlen($data). " bytes from stream $id to {$user->getId()}"); $message = array( 'connection' => $id, 'event' => 'data', 'data' => $data ); $user->sendString(json_encode($message)); }); // When the stream closes, notify the user $stream->on("close", function() use($user, $id, $logger, $address){ $logger->notice(sprintf("Connection %s of user %s to %s has been closed", $id, $user->getId(), $address)); $message = array( 'connection' => $id, 'event' => 'close' ); $user->sendString(json_encode($message)); }); }); } catch (Exception $e) { $user->sendString(json_encode(array( 'event' => 'error', 'tag' => property_exists($message, 'tag') ? $message->tag : null, 'message' => $e->getMessage() ))); } }
php
protected function requestConnect(WebSocketTransportInterface $user, $message) { $address = $message->address; $this->logger->notice(sprintf("User %s requests connection to %s", $user->getId(), $address)); try { $dnsResolverFactory = new React\Dns\Resolver\Factory(); $dns = $dnsResolverFactory->createCached('8.8.8.8', $this->loop); $stream = new \React\SocketClient\Connector($this->loop, $dns); list($host, $port) = explode(":", $address); $logger = $this->logger; $that = $this; $stream->create($host, $port)->then(function (\React\Stream\Stream $stream) use($user, $logger, $message, $address, $that){ $id = uniqid("stream-$address-"); $that->addStream($user, $id, $stream); // Notify the user when the connection has been made $user->sendString(json_encode(array( 'connection' => $id, 'event' => 'connected', 'tag' => property_exists($message, 'tag') ? $message->tag : null ))); // Forward data back to the user $stream->on("data", function ($data) use ($stream, $id, $user, $logger){ $logger->notice("Forwarding ".strlen($data). " bytes from stream $id to {$user->getId()}"); $message = array( 'connection' => $id, 'event' => 'data', 'data' => $data ); $user->sendString(json_encode($message)); }); // When the stream closes, notify the user $stream->on("close", function() use($user, $id, $logger, $address){ $logger->notice(sprintf("Connection %s of user %s to %s has been closed", $id, $user->getId(), $address)); $message = array( 'connection' => $id, 'event' => 'close' ); $user->sendString(json_encode($message)); }); }); } catch (Exception $e) { $user->sendString(json_encode(array( 'event' => 'error', 'tag' => property_exists($message, 'tag') ? $message->tag : null, 'message' => $e->getMessage() ))); } }
[ "protected", "function", "requestConnect", "(", "WebSocketTransportInterface", "$", "user", ",", "$", "message", ")", "{", "$", "address", "=", "$", "message", "->", "address", ";", "$", "this", "->", "logger", "->", "notice", "(", "sprintf", "(", "\"User %s...
Handler called when a CONNECT message is sent by a client A React SocketClient will be created, Google DNS is used to resolve host names. When the connection is made several event listeners are attached. When data is received on the stream, it is forwarded to the client requesting the proxied TCP connection Other events forwarded are connect and close @param WebSocketTransportInterface $user @param $message
[ "Handler", "called", "when", "a", "CONNECT", "message", "is", "sent", "by", "a", "client" ]
c2eee395bf55d49405cfb635685fa8997f56dae1
https://github.com/Devristo/phpws/blob/c2eee395bf55d49405cfb635685fa8997f56dae1/examples/tcp_proxy_example.php#L83-L141
train
Devristo/phpws
examples/tcp_proxy_example.php
ProxyHandler.requestWrite
protected function requestWrite(WebSocketTransportInterface $user, $message) { $stream = $this->getStream($user, $message->connection); if($stream){ $this->logger->notice(sprintf("User %s writes %d bytes to connection %s", $user->getId(), strlen($message->data), $message->connection)); $stream->write($message->data); } }
php
protected function requestWrite(WebSocketTransportInterface $user, $message) { $stream = $this->getStream($user, $message->connection); if($stream){ $this->logger->notice(sprintf("User %s writes %d bytes to connection %s", $user->getId(), strlen($message->data), $message->connection)); $stream->write($message->data); } }
[ "protected", "function", "requestWrite", "(", "WebSocketTransportInterface", "$", "user", ",", "$", "message", ")", "{", "$", "stream", "=", "$", "this", "->", "getStream", "(", "$", "user", ",", "$", "message", "->", "connection", ")", ";", "if", "(", "...
Forward data send by the user over the specified TCP stream @param WebSocketTransportInterface $user @param $message
[ "Forward", "data", "send", "by", "the", "user", "over", "the", "specified", "TCP", "stream" ]
c2eee395bf55d49405cfb635685fa8997f56dae1
https://github.com/Devristo/phpws/blob/c2eee395bf55d49405cfb635685fa8997f56dae1/examples/tcp_proxy_example.php#L149-L157
train
Devristo/phpws
examples/tcp_proxy_example.php
ProxyHandler.requestClose
protected function requestClose(WebSocketTransportInterface $user, $message) { $stream = $this->getStream($user, $message->connection); if($stream){ $this->logger->notice(sprintf("User %s closes connection %s", $user->getId(), $message->connection)); $stream->close(); $this->removeStream($user, $message->connection); $user->sendString(json_encode(array( 'event' => 'close', 'connection' => $message->connection, 'tag' => property_exists($message, 'tag') ? $message->tag : null ))); } else { $user->sendString(json_encode(array( 'event' => 'error', 'tag' => property_exists($message, 'tag') ? $message->tag : null, 'message' => 'Connection was already closed' ))); } }
php
protected function requestClose(WebSocketTransportInterface $user, $message) { $stream = $this->getStream($user, $message->connection); if($stream){ $this->logger->notice(sprintf("User %s closes connection %s", $user->getId(), $message->connection)); $stream->close(); $this->removeStream($user, $message->connection); $user->sendString(json_encode(array( 'event' => 'close', 'connection' => $message->connection, 'tag' => property_exists($message, 'tag') ? $message->tag : null ))); } else { $user->sendString(json_encode(array( 'event' => 'error', 'tag' => property_exists($message, 'tag') ? $message->tag : null, 'message' => 'Connection was already closed' ))); } }
[ "protected", "function", "requestClose", "(", "WebSocketTransportInterface", "$", "user", ",", "$", "message", ")", "{", "$", "stream", "=", "$", "this", "->", "getStream", "(", "$", "user", ",", "$", "message", "->", "connection", ")", ";", "if", "(", "...
Close the stream specified by the user @param WebSocketTransportInterface $user @param $message
[ "Close", "the", "stream", "specified", "by", "the", "user" ]
c2eee395bf55d49405cfb635685fa8997f56dae1
https://github.com/Devristo/phpws/blob/c2eee395bf55d49405cfb635685fa8997f56dae1/examples/tcp_proxy_example.php#L165-L186
train
Devristo/phpws
src/Devristo/Phpws/Protocol/WebSocketTransportHybi.php
WebSocketTransportHybi.processMessageFrame
protected function processMessageFrame(WebSocketFrame $frame) { if ($this->_openMessage && $this->_openMessage->isFinalised() == false) { $this->_openMessage->takeFrame($frame); } else { $this->_openMessage = WebSocketMessage::fromFrame($frame); } if ($this->_openMessage && $this->_openMessage->isFinalised()) { $this->emit("message", array('message' => $this->_openMessage)); $this->_openMessage = null; } }
php
protected function processMessageFrame(WebSocketFrame $frame) { if ($this->_openMessage && $this->_openMessage->isFinalised() == false) { $this->_openMessage->takeFrame($frame); } else { $this->_openMessage = WebSocketMessage::fromFrame($frame); } if ($this->_openMessage && $this->_openMessage->isFinalised()) { $this->emit("message", array('message' => $this->_openMessage)); $this->_openMessage = null; } }
[ "protected", "function", "processMessageFrame", "(", "WebSocketFrame", "$", "frame", ")", "{", "if", "(", "$", "this", "->", "_openMessage", "&&", "$", "this", "->", "_openMessage", "->", "isFinalised", "(", ")", "==", "false", ")", "{", "$", "this", "->",...
Process a Message Frame Appends or creates a new message and attaches it to the user sending it. When the last frame of a message is received, the message is sent for processing to the abstract WebSocket::onMessage() method. @param WebSocketFrame $frame
[ "Process", "a", "Message", "Frame" ]
c2eee395bf55d49405cfb635685fa8997f56dae1
https://github.com/Devristo/phpws/blob/c2eee395bf55d49405cfb635685fa8997f56dae1/src/Devristo/Phpws/Protocol/WebSocketTransportHybi.php#L140-L152
train
Devristo/phpws
src/Devristo/Phpws/Protocol/WebSocketTransportHybi.php
WebSocketTransportHybi.processControlFrame
protected function processControlFrame(WebSocketFrame $frame) { switch ($frame->getType()) { case WebSocketOpcode::CloseFrame : $this->logger->notice("Got CLOSE frame"); $frame = WebSocketFrame::create(WebSocketOpcode::CloseFrame); $this->sendFrame($frame); $this->_socket->close(); break; case WebSocketOpcode::PingFrame : $frame = WebSocketFrame::create(WebSocketOpcode::PongFrame, $frame->getData()); $this->sendFrame($frame); break; } }
php
protected function processControlFrame(WebSocketFrame $frame) { switch ($frame->getType()) { case WebSocketOpcode::CloseFrame : $this->logger->notice("Got CLOSE frame"); $frame = WebSocketFrame::create(WebSocketOpcode::CloseFrame); $this->sendFrame($frame); $this->_socket->close(); break; case WebSocketOpcode::PingFrame : $frame = WebSocketFrame::create(WebSocketOpcode::PongFrame, $frame->getData()); $this->sendFrame($frame); break; } }
[ "protected", "function", "processControlFrame", "(", "WebSocketFrame", "$", "frame", ")", "{", "switch", "(", "$", "frame", "->", "getType", "(", ")", ")", "{", "case", "WebSocketOpcode", "::", "CloseFrame", ":", "$", "this", "->", "logger", "->", "notice", ...
Handle incoming control frames Sends Pong on Ping and closes the connection after a Close request. @param WebSocketFrame $frame
[ "Handle", "incoming", "control", "frames" ]
c2eee395bf55d49405cfb635685fa8997f56dae1
https://github.com/Devristo/phpws/blob/c2eee395bf55d49405cfb635685fa8997f56dae1/src/Devristo/Phpws/Protocol/WebSocketTransportHybi.php#L161-L177
train