id
int32 0
241k
| 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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
222,700
|
basarevych/dynamic-table
|
php/DynamicTable/Table.php
|
Table.fetch
|
public function fetch()
{
$adapter = $this->getAdapter();
if (!$adapter)
throw new \Exception("Adapter property is not set");
$adapter->check($this);
$adapter->filter($this);
$adapter->sort($this);
$result = $adapter->paginate($this);
$filters = $this->getFilters();
return [
'sort_column' => $this->getSortColumn(),
'sort_dir' => $this->getSortDir(),
'page_number' => $this->getPageNumber(),
'page_size' => $this->getPageSize(),
'total_pages' => $this->getTotalPages(),
'filters' => count($filters) ? $filters : new \StdClass(),
'rows' => $result,
];
}
|
php
|
public function fetch()
{
$adapter = $this->getAdapter();
if (!$adapter)
throw new \Exception("Adapter property is not set");
$adapter->check($this);
$adapter->filter($this);
$adapter->sort($this);
$result = $adapter->paginate($this);
$filters = $this->getFilters();
return [
'sort_column' => $this->getSortColumn(),
'sort_dir' => $this->getSortDir(),
'page_number' => $this->getPageNumber(),
'page_size' => $this->getPageSize(),
'total_pages' => $this->getTotalPages(),
'filters' => count($filters) ? $filters : new \StdClass(),
'rows' => $result,
];
}
|
[
"public",
"function",
"fetch",
"(",
")",
"{",
"$",
"adapter",
"=",
"$",
"this",
"->",
"getAdapter",
"(",
")",
";",
"if",
"(",
"!",
"$",
"adapter",
")",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Adapter property is not set\"",
")",
";",
"$",
"adapter",
"->",
"check",
"(",
"$",
"this",
")",
";",
"$",
"adapter",
"->",
"filter",
"(",
"$",
"this",
")",
";",
"$",
"adapter",
"->",
"sort",
"(",
"$",
"this",
")",
";",
"$",
"result",
"=",
"$",
"adapter",
"->",
"paginate",
"(",
"$",
"this",
")",
";",
"$",
"filters",
"=",
"$",
"this",
"->",
"getFilters",
"(",
")",
";",
"return",
"[",
"'sort_column'",
"=>",
"$",
"this",
"->",
"getSortColumn",
"(",
")",
",",
"'sort_dir'",
"=>",
"$",
"this",
"->",
"getSortDir",
"(",
")",
",",
"'page_number'",
"=>",
"$",
"this",
"->",
"getPageNumber",
"(",
")",
",",
"'page_size'",
"=>",
"$",
"this",
"->",
"getPageSize",
"(",
")",
",",
"'total_pages'",
"=>",
"$",
"this",
"->",
"getTotalPages",
"(",
")",
",",
"'filters'",
"=>",
"count",
"(",
"$",
"filters",
")",
"?",
"$",
"filters",
":",
"new",
"\\",
"StdClass",
"(",
")",
",",
"'rows'",
"=>",
"$",
"result",
",",
"]",
";",
"}"
] |
Fetch data and feed it to front-end
@return array
|
[
"Fetch",
"data",
"and",
"feed",
"it",
"to",
"front",
"-",
"end"
] |
227eafab0d4dafabe0d2ceaa881ab3befe994d9c
|
https://github.com/basarevych/dynamic-table/blob/227eafab0d4dafabe0d2ceaa881ab3befe994d9c/php/DynamicTable/Table.php#L472-L493
|
222,701
|
basarevych/dynamic-table
|
php/DynamicTable/Table.php
|
Table.getAvailableTypes
|
public static function getAvailableTypes()
{
return [
self::TYPE_STRING,
self::TYPE_INTEGER,
self::TYPE_FLOAT,
self::TYPE_BOOLEAN,
self::TYPE_DATETIME,
];
}
|
php
|
public static function getAvailableTypes()
{
return [
self::TYPE_STRING,
self::TYPE_INTEGER,
self::TYPE_FLOAT,
self::TYPE_BOOLEAN,
self::TYPE_DATETIME,
];
}
|
[
"public",
"static",
"function",
"getAvailableTypes",
"(",
")",
"{",
"return",
"[",
"self",
"::",
"TYPE_STRING",
",",
"self",
"::",
"TYPE_INTEGER",
",",
"self",
"::",
"TYPE_FLOAT",
",",
"self",
"::",
"TYPE_BOOLEAN",
",",
"self",
"::",
"TYPE_DATETIME",
",",
"]",
";",
"}"
] |
List column types
@return array
|
[
"List",
"column",
"types"
] |
227eafab0d4dafabe0d2ceaa881ab3befe994d9c
|
https://github.com/basarevych/dynamic-table/blob/227eafab0d4dafabe0d2ceaa881ab3befe994d9c/php/DynamicTable/Table.php#L500-L509
|
222,702
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Helper/Data.php
|
EcomDev_Varnish_Helper_Data.getAjaxReloadUrl
|
public function getAjaxReloadUrl()
{
if ($this->_ajaxReloadUrl === null) {
$this->_ajaxReloadUrl = $this->_getUrl('varnish/ajax/reload', array(
'_secure' => Mage::app()->getStore()->isCurrentlySecure()
));
}
return $this->_ajaxReloadUrl;
}
|
php
|
public function getAjaxReloadUrl()
{
if ($this->_ajaxReloadUrl === null) {
$this->_ajaxReloadUrl = $this->_getUrl('varnish/ajax/reload', array(
'_secure' => Mage::app()->getStore()->isCurrentlySecure()
));
}
return $this->_ajaxReloadUrl;
}
|
[
"public",
"function",
"getAjaxReloadUrl",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_ajaxReloadUrl",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"_ajaxReloadUrl",
"=",
"$",
"this",
"->",
"_getUrl",
"(",
"'varnish/ajax/reload'",
",",
"array",
"(",
"'_secure'",
"=>",
"Mage",
"::",
"app",
"(",
")",
"->",
"getStore",
"(",
")",
"->",
"isCurrentlySecure",
"(",
")",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_ajaxReloadUrl",
";",
"}"
] |
Returns a url for reloading
@return string
|
[
"Returns",
"a",
"url",
"for",
"reloading"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Helper/Data.php#L137-L146
|
222,703
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Helper/Data.php
|
EcomDev_Varnish_Helper_Data._initDefaultVarnishHeaders
|
protected function _initDefaultVarnishHeaders($withoutTags)
{
// Add TTL header if any of them have been specified
if (!$withoutTags && $this->_ttlList) {
$this->setVarnishHeader(self::HEADER_TTL, min($this->_ttlList) . 's');
}
// Add object tags header only if it is not added
if (!$withoutTags && $this->_objectTags && !$this->hasVarnishHeader(self::HEADER_OBJECTS)) {
$objects = array_map(
array($this, 'formatObjectTag'),
$this->_objectTags
);
$headerValue = array();
foreach (array_chunk($objects, self::HEADER_OBJECTS_ITEMS) as $objectSubset) {
$headerValue[] = implode(',', $objectSubset);
}
$this->setVarnishHeader(
self::HEADER_OBJECTS,
$headerValue
);
}
if (!$this->hasVarnishHeader(self::HEADER_SEGMENT)) {
$this->setVarnishHeader(self::HEADER_SEGMENT, $this->hashData($this->getCustomerSegment()));
}
if (!$this->hasVarnishHeader(self::HEADER_STORE)) {
$this->setVarnishHeader(self::HEADER_STORE, Mage::app()->getStore()->getCode());
}
if (!$this->hasVarnishHeader(self::HEADER_COOKIE_DOMAIN)) {
/** @var Mage_Core_Model_Cookie $cookieModel */
$cookieModel = Mage::getSingleton('core/cookie');
$this->setVarnishHeader(self::HEADER_COOKIE_DOMAIN, $cookieModel->getDomain());
}
if (Mage::getStoreConfigFlag(self::XML_PATH_GZIP)
&& !$this->hasVarnishHeader(self::HEADER_GZIP)) {
$this->setVarnishHeader(self::HEADER_GZIP, '1');
}
return $this;
}
|
php
|
protected function _initDefaultVarnishHeaders($withoutTags)
{
// Add TTL header if any of them have been specified
if (!$withoutTags && $this->_ttlList) {
$this->setVarnishHeader(self::HEADER_TTL, min($this->_ttlList) . 's');
}
// Add object tags header only if it is not added
if (!$withoutTags && $this->_objectTags && !$this->hasVarnishHeader(self::HEADER_OBJECTS)) {
$objects = array_map(
array($this, 'formatObjectTag'),
$this->_objectTags
);
$headerValue = array();
foreach (array_chunk($objects, self::HEADER_OBJECTS_ITEMS) as $objectSubset) {
$headerValue[] = implode(',', $objectSubset);
}
$this->setVarnishHeader(
self::HEADER_OBJECTS,
$headerValue
);
}
if (!$this->hasVarnishHeader(self::HEADER_SEGMENT)) {
$this->setVarnishHeader(self::HEADER_SEGMENT, $this->hashData($this->getCustomerSegment()));
}
if (!$this->hasVarnishHeader(self::HEADER_STORE)) {
$this->setVarnishHeader(self::HEADER_STORE, Mage::app()->getStore()->getCode());
}
if (!$this->hasVarnishHeader(self::HEADER_COOKIE_DOMAIN)) {
/** @var Mage_Core_Model_Cookie $cookieModel */
$cookieModel = Mage::getSingleton('core/cookie');
$this->setVarnishHeader(self::HEADER_COOKIE_DOMAIN, $cookieModel->getDomain());
}
if (Mage::getStoreConfigFlag(self::XML_PATH_GZIP)
&& !$this->hasVarnishHeader(self::HEADER_GZIP)) {
$this->setVarnishHeader(self::HEADER_GZIP, '1');
}
return $this;
}
|
[
"protected",
"function",
"_initDefaultVarnishHeaders",
"(",
"$",
"withoutTags",
")",
"{",
"// Add TTL header if any of them have been specified",
"if",
"(",
"!",
"$",
"withoutTags",
"&&",
"$",
"this",
"->",
"_ttlList",
")",
"{",
"$",
"this",
"->",
"setVarnishHeader",
"(",
"self",
"::",
"HEADER_TTL",
",",
"min",
"(",
"$",
"this",
"->",
"_ttlList",
")",
".",
"'s'",
")",
";",
"}",
"// Add object tags header only if it is not added",
"if",
"(",
"!",
"$",
"withoutTags",
"&&",
"$",
"this",
"->",
"_objectTags",
"&&",
"!",
"$",
"this",
"->",
"hasVarnishHeader",
"(",
"self",
"::",
"HEADER_OBJECTS",
")",
")",
"{",
"$",
"objects",
"=",
"array_map",
"(",
"array",
"(",
"$",
"this",
",",
"'formatObjectTag'",
")",
",",
"$",
"this",
"->",
"_objectTags",
")",
";",
"$",
"headerValue",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"array_chunk",
"(",
"$",
"objects",
",",
"self",
"::",
"HEADER_OBJECTS_ITEMS",
")",
"as",
"$",
"objectSubset",
")",
"{",
"$",
"headerValue",
"[",
"]",
"=",
"implode",
"(",
"','",
",",
"$",
"objectSubset",
")",
";",
"}",
"$",
"this",
"->",
"setVarnishHeader",
"(",
"self",
"::",
"HEADER_OBJECTS",
",",
"$",
"headerValue",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"hasVarnishHeader",
"(",
"self",
"::",
"HEADER_SEGMENT",
")",
")",
"{",
"$",
"this",
"->",
"setVarnishHeader",
"(",
"self",
"::",
"HEADER_SEGMENT",
",",
"$",
"this",
"->",
"hashData",
"(",
"$",
"this",
"->",
"getCustomerSegment",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"hasVarnishHeader",
"(",
"self",
"::",
"HEADER_STORE",
")",
")",
"{",
"$",
"this",
"->",
"setVarnishHeader",
"(",
"self",
"::",
"HEADER_STORE",
",",
"Mage",
"::",
"app",
"(",
")",
"->",
"getStore",
"(",
")",
"->",
"getCode",
"(",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"hasVarnishHeader",
"(",
"self",
"::",
"HEADER_COOKIE_DOMAIN",
")",
")",
"{",
"/** @var Mage_Core_Model_Cookie $cookieModel */",
"$",
"cookieModel",
"=",
"Mage",
"::",
"getSingleton",
"(",
"'core/cookie'",
")",
";",
"$",
"this",
"->",
"setVarnishHeader",
"(",
"self",
"::",
"HEADER_COOKIE_DOMAIN",
",",
"$",
"cookieModel",
"->",
"getDomain",
"(",
")",
")",
";",
"}",
"if",
"(",
"Mage",
"::",
"getStoreConfigFlag",
"(",
"self",
"::",
"XML_PATH_GZIP",
")",
"&&",
"!",
"$",
"this",
"->",
"hasVarnishHeader",
"(",
"self",
"::",
"HEADER_GZIP",
")",
")",
"{",
"$",
"this",
"->",
"setVarnishHeader",
"(",
"self",
"::",
"HEADER_GZIP",
",",
"'1'",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Init default varnish headers
@return $this
|
[
"Init",
"default",
"varnish",
"headers"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Helper/Data.php#L163-L209
|
222,704
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Helper/Data.php
|
EcomDev_Varnish_Helper_Data.getCurrentPageInfo
|
public function getCurrentPageInfo()
{
$result = array(
'handle' => $this->getCurrentPage()
);
if (Mage::registry('current_category') instanceof Mage_Catalog_Model_Category) {
$result['category'] = Mage::registry('current_category')->getId();
}
if (Mage::registry('current_product') instanceof Mage_Catalog_Model_Product) {
$result['product'] = Mage::registry('current_product')->getId();
}
return $result;
}
|
php
|
public function getCurrentPageInfo()
{
$result = array(
'handle' => $this->getCurrentPage()
);
if (Mage::registry('current_category') instanceof Mage_Catalog_Model_Category) {
$result['category'] = Mage::registry('current_category')->getId();
}
if (Mage::registry('current_product') instanceof Mage_Catalog_Model_Product) {
$result['product'] = Mage::registry('current_product')->getId();
}
return $result;
}
|
[
"public",
"function",
"getCurrentPageInfo",
"(",
")",
"{",
"$",
"result",
"=",
"array",
"(",
"'handle'",
"=>",
"$",
"this",
"->",
"getCurrentPage",
"(",
")",
")",
";",
"if",
"(",
"Mage",
"::",
"registry",
"(",
"'current_category'",
")",
"instanceof",
"Mage_Catalog_Model_Category",
")",
"{",
"$",
"result",
"[",
"'category'",
"]",
"=",
"Mage",
"::",
"registry",
"(",
"'current_category'",
")",
"->",
"getId",
"(",
")",
";",
"}",
"if",
"(",
"Mage",
"::",
"registry",
"(",
"'current_product'",
")",
"instanceof",
"Mage_Catalog_Model_Product",
")",
"{",
"$",
"result",
"[",
"'product'",
"]",
"=",
"Mage",
"::",
"registry",
"(",
"'current_product'",
")",
"->",
"getId",
"(",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Returns current page info
|
[
"Returns",
"current",
"page",
"info"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Helper/Data.php#L216-L231
|
222,705
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Helper/Data.php
|
EcomDev_Varnish_Helper_Data.addVarnishHeader
|
public function addVarnishHeader($name, $value)
{
$header = $value;
if ($this->hasVarnishHeader($name)) {
$header = $this->getVarnishHeader($name);
if (!is_array($header)) {
$header = array($header);
}
$header[] = $value;
}
$this->setVarnishHeader($name, $header);
return $this;
}
|
php
|
public function addVarnishHeader($name, $value)
{
$header = $value;
if ($this->hasVarnishHeader($name)) {
$header = $this->getVarnishHeader($name);
if (!is_array($header)) {
$header = array($header);
}
$header[] = $value;
}
$this->setVarnishHeader($name, $header);
return $this;
}
|
[
"public",
"function",
"addVarnishHeader",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"$",
"header",
"=",
"$",
"value",
";",
"if",
"(",
"$",
"this",
"->",
"hasVarnishHeader",
"(",
"$",
"name",
")",
")",
"{",
"$",
"header",
"=",
"$",
"this",
"->",
"getVarnishHeader",
"(",
"$",
"name",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"header",
")",
")",
"{",
"$",
"header",
"=",
"array",
"(",
"$",
"header",
")",
";",
"}",
"$",
"header",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"$",
"this",
"->",
"setVarnishHeader",
"(",
"$",
"name",
",",
"$",
"header",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds varnish header
@param string $name
@param string $value
@return $this
|
[
"Adds",
"varnish",
"header"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Helper/Data.php#L307-L324
|
222,706
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Helper/Data.php
|
EcomDev_Varnish_Helper_Data._initAllowedPages
|
protected function _initAllowedPages()
{
if ($this->_allowedPages === null) {
$this->_allowedPages = array();
foreach (Mage::getConfig()->getNode(self::XML_PATH_ALLOWED_PAGES)->children() as $page => $info) {
$module = ($info->getAttribute('module') ? $info->getAttribute('module') : 'ecomdev_varnish');
$this->_allowedPages[$page] = Mage::helper($module)->__((string)$info->label);
}
}
return $this;
}
|
php
|
protected function _initAllowedPages()
{
if ($this->_allowedPages === null) {
$this->_allowedPages = array();
foreach (Mage::getConfig()->getNode(self::XML_PATH_ALLOWED_PAGES)->children() as $page => $info) {
$module = ($info->getAttribute('module') ? $info->getAttribute('module') : 'ecomdev_varnish');
$this->_allowedPages[$page] = Mage::helper($module)->__((string)$info->label);
}
}
return $this;
}
|
[
"protected",
"function",
"_initAllowedPages",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_allowedPages",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"_allowedPages",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"Mage",
"::",
"getConfig",
"(",
")",
"->",
"getNode",
"(",
"self",
"::",
"XML_PATH_ALLOWED_PAGES",
")",
"->",
"children",
"(",
")",
"as",
"$",
"page",
"=>",
"$",
"info",
")",
"{",
"$",
"module",
"=",
"(",
"$",
"info",
"->",
"getAttribute",
"(",
"'module'",
")",
"?",
"$",
"info",
"->",
"getAttribute",
"(",
"'module'",
")",
":",
"'ecomdev_varnish'",
")",
";",
"$",
"this",
"->",
"_allowedPages",
"[",
"$",
"page",
"]",
"=",
"Mage",
"::",
"helper",
"(",
"$",
"module",
")",
"->",
"__",
"(",
"(",
"string",
")",
"$",
"info",
"->",
"label",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Init allowed pages from configuration
@return $this
|
[
"Init",
"allowed",
"pages",
"from",
"configuration"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Helper/Data.php#L473-L485
|
222,707
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Helper/Data.php
|
EcomDev_Varnish_Helper_Data.isAllowedCurrentPage
|
public function isAllowedCurrentPage()
{
if (!$this->isActive()) {
return false;
}
$this->_initAllowedPages();
if (!$this->getCurrentPage()) {
return false;
}
return isset($this->_allowedPages[$this->getCurrentPage()]);
}
|
php
|
public function isAllowedCurrentPage()
{
if (!$this->isActive()) {
return false;
}
$this->_initAllowedPages();
if (!$this->getCurrentPage()) {
return false;
}
return isset($this->_allowedPages[$this->getCurrentPage()]);
}
|
[
"public",
"function",
"isAllowedCurrentPage",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isActive",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"_initAllowedPages",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"getCurrentPage",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"isset",
"(",
"$",
"this",
"->",
"_allowedPages",
"[",
"$",
"this",
"->",
"getCurrentPage",
"(",
")",
"]",
")",
";",
"}"
] |
Checks if current page is not allowed for varnish cache
@return bool
|
[
"Checks",
"if",
"current",
"page",
"is",
"not",
"allowed",
"for",
"varnish",
"cache"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Helper/Data.php#L503-L516
|
222,708
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Helper/Data.php
|
EcomDev_Varnish_Helper_Data.getCurrentPageTtl
|
public function getCurrentPageTtl()
{
if ($this->getCurrentPage()) {
$cacheTtl = (int)Mage::getStoreConfig(sprintf(self::XML_PATH_PAGE_TTL, $this->getCurrentPage()));
if ($cacheTtl) {
return $cacheTtl*60;
}
}
return false;
}
|
php
|
public function getCurrentPageTtl()
{
if ($this->getCurrentPage()) {
$cacheTtl = (int)Mage::getStoreConfig(sprintf(self::XML_PATH_PAGE_TTL, $this->getCurrentPage()));
if ($cacheTtl) {
return $cacheTtl*60;
}
}
return false;
}
|
[
"public",
"function",
"getCurrentPageTtl",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getCurrentPage",
"(",
")",
")",
"{",
"$",
"cacheTtl",
"=",
"(",
"int",
")",
"Mage",
"::",
"getStoreConfig",
"(",
"sprintf",
"(",
"self",
"::",
"XML_PATH_PAGE_TTL",
",",
"$",
"this",
"->",
"getCurrentPage",
"(",
")",
")",
")",
";",
"if",
"(",
"$",
"cacheTtl",
")",
"{",
"return",
"$",
"cacheTtl",
"*",
"60",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Returns current page TTL in seconds
@return bool|int
|
[
"Returns",
"current",
"page",
"TTL",
"in",
"seconds"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Helper/Data.php#L545-L555
|
222,709
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Helper/Data.php
|
EcomDev_Varnish_Helper_Data.getCustomerSegment
|
public function getCustomerSegment()
{
$segment = new Varien_Object();
$segmentValues = $this->_getSegmentValues();
foreach ($segmentValues as $field => $configCallbackPair) {
if (is_array($configCallbackPair) && Mage::getStoreConfigFlag($configCallbackPair[0])) {
$segment->setData($field, $configCallbackPair[1]());
} elseif (is_string($configCallbackPair)) {
$segment->setData($field, $configCallbackPair);
}
}
Mage::dispatchEvent('ecomdev_varnish_customer_segment', array('segment' => $segment));
return $segment->getData();
}
|
php
|
public function getCustomerSegment()
{
$segment = new Varien_Object();
$segmentValues = $this->_getSegmentValues();
foreach ($segmentValues as $field => $configCallbackPair) {
if (is_array($configCallbackPair) && Mage::getStoreConfigFlag($configCallbackPair[0])) {
$segment->setData($field, $configCallbackPair[1]());
} elseif (is_string($configCallbackPair)) {
$segment->setData($field, $configCallbackPair);
}
}
Mage::dispatchEvent('ecomdev_varnish_customer_segment', array('segment' => $segment));
return $segment->getData();
}
|
[
"public",
"function",
"getCustomerSegment",
"(",
")",
"{",
"$",
"segment",
"=",
"new",
"Varien_Object",
"(",
")",
";",
"$",
"segmentValues",
"=",
"$",
"this",
"->",
"_getSegmentValues",
"(",
")",
";",
"foreach",
"(",
"$",
"segmentValues",
"as",
"$",
"field",
"=>",
"$",
"configCallbackPair",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"configCallbackPair",
")",
"&&",
"Mage",
"::",
"getStoreConfigFlag",
"(",
"$",
"configCallbackPair",
"[",
"0",
"]",
")",
")",
"{",
"$",
"segment",
"->",
"setData",
"(",
"$",
"field",
",",
"$",
"configCallbackPair",
"[",
"1",
"]",
"(",
")",
")",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"configCallbackPair",
")",
")",
"{",
"$",
"segment",
"->",
"setData",
"(",
"$",
"field",
",",
"$",
"configCallbackPair",
")",
";",
"}",
"}",
"Mage",
"::",
"dispatchEvent",
"(",
"'ecomdev_varnish_customer_segment'",
",",
"array",
"(",
"'segment'",
"=>",
"$",
"segment",
")",
")",
";",
"return",
"$",
"segment",
"->",
"getData",
"(",
")",
";",
"}"
] |
Returns customer segment data, used as cache segment
@return string[]
|
[
"Returns",
"customer",
"segment",
"data",
"used",
"as",
"cache",
"segment"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Helper/Data.php#L605-L622
|
222,710
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Helper/Data.php
|
EcomDev_Varnish_Helper_Data._getSegmentValues
|
protected function _getSegmentValues()
{
return array(
'customer_group_id' => array(self::XML_PATH_SEGMENT_CUSTOMER_GROUP, function () {
return $this->_noSessionCall ? 0 : Mage::getSingleton('customer/session')->getCustomerGroupId();
}),
'store_id' => array(self::XML_PATH_SEGMENT_STORE, function () {
return Mage::app()->getStore()->getId();
}),
'currency' => array(self::XML_PATH_SEGMENT_CURRENCY, function () {
return Mage::app()->getStore()->getCurrentCurrencyCode();
})
);
}
|
php
|
protected function _getSegmentValues()
{
return array(
'customer_group_id' => array(self::XML_PATH_SEGMENT_CUSTOMER_GROUP, function () {
return $this->_noSessionCall ? 0 : Mage::getSingleton('customer/session')->getCustomerGroupId();
}),
'store_id' => array(self::XML_PATH_SEGMENT_STORE, function () {
return Mage::app()->getStore()->getId();
}),
'currency' => array(self::XML_PATH_SEGMENT_CURRENCY, function () {
return Mage::app()->getStore()->getCurrentCurrencyCode();
})
);
}
|
[
"protected",
"function",
"_getSegmentValues",
"(",
")",
"{",
"return",
"array",
"(",
"'customer_group_id'",
"=>",
"array",
"(",
"self",
"::",
"XML_PATH_SEGMENT_CUSTOMER_GROUP",
",",
"function",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"_noSessionCall",
"?",
"0",
":",
"Mage",
"::",
"getSingleton",
"(",
"'customer/session'",
")",
"->",
"getCustomerGroupId",
"(",
")",
";",
"}",
")",
",",
"'store_id'",
"=>",
"array",
"(",
"self",
"::",
"XML_PATH_SEGMENT_STORE",
",",
"function",
"(",
")",
"{",
"return",
"Mage",
"::",
"app",
"(",
")",
"->",
"getStore",
"(",
")",
"->",
"getId",
"(",
")",
";",
"}",
")",
",",
"'currency'",
"=>",
"array",
"(",
"self",
"::",
"XML_PATH_SEGMENT_CURRENCY",
",",
"function",
"(",
")",
"{",
"return",
"Mage",
"::",
"app",
"(",
")",
"->",
"getStore",
"(",
")",
"->",
"getCurrentCurrencyCode",
"(",
")",
";",
"}",
")",
")",
";",
"}"
] |
Returns list of segment values callbacks
If array key is a string, than value added directly
@return array
|
[
"Returns",
"list",
"of",
"segment",
"values",
"callbacks"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Helper/Data.php#L631-L644
|
222,711
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Helper/Data.php
|
EcomDev_Varnish_Helper_Data.hashData
|
public function hashData($hashData, $addDeviceType = true)
{
if (is_array($hashData)) {
$hashData = json_encode($hashData);
}
if ($addDeviceType) {
// Add device type
$hashData .= $this->_getRequest()->getServer('HTTP_X_UA_DEVICE');
}
return md5($hashData);
}
|
php
|
public function hashData($hashData, $addDeviceType = true)
{
if (is_array($hashData)) {
$hashData = json_encode($hashData);
}
if ($addDeviceType) {
// Add device type
$hashData .= $this->_getRequest()->getServer('HTTP_X_UA_DEVICE');
}
return md5($hashData);
}
|
[
"public",
"function",
"hashData",
"(",
"$",
"hashData",
",",
"$",
"addDeviceType",
"=",
"true",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"hashData",
")",
")",
"{",
"$",
"hashData",
"=",
"json_encode",
"(",
"$",
"hashData",
")",
";",
"}",
"if",
"(",
"$",
"addDeviceType",
")",
"{",
"// Add device type",
"$",
"hashData",
".=",
"$",
"this",
"->",
"_getRequest",
"(",
")",
"->",
"getServer",
"(",
"'HTTP_X_UA_DEVICE'",
")",
";",
"}",
"return",
"md5",
"(",
"$",
"hashData",
")",
";",
"}"
] |
Hashes data for varnish
@param string $hashData
@param bool $addDeviceType
@return string
|
[
"Hashes",
"data",
"for",
"varnish"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Helper/Data.php#L653-L665
|
222,712
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Helper/Data.php
|
EcomDev_Varnish_Helper_Data.cachedHelperCall
|
public function cachedHelperCall($helper, $method, $cachedValue, $args = array())
{
if ($this->isActive() && !$this->getIsInternal()) {
return $cachedValue;
}
$helper = Mage::helper($helper);
if (!empty($args)) {
return call_user_func_array(array($helper, $method), $args);
}
return $helper->$method();
}
|
php
|
public function cachedHelperCall($helper, $method, $cachedValue, $args = array())
{
if ($this->isActive() && !$this->getIsInternal()) {
return $cachedValue;
}
$helper = Mage::helper($helper);
if (!empty($args)) {
return call_user_func_array(array($helper, $method), $args);
}
return $helper->$method();
}
|
[
"public",
"function",
"cachedHelperCall",
"(",
"$",
"helper",
",",
"$",
"method",
",",
"$",
"cachedValue",
",",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isActive",
"(",
")",
"&&",
"!",
"$",
"this",
"->",
"getIsInternal",
"(",
")",
")",
"{",
"return",
"$",
"cachedValue",
";",
"}",
"$",
"helper",
"=",
"Mage",
"::",
"helper",
"(",
"$",
"helper",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"args",
")",
")",
"{",
"return",
"call_user_func_array",
"(",
"array",
"(",
"$",
"helper",
",",
"$",
"method",
")",
",",
"$",
"args",
")",
";",
"}",
"return",
"$",
"helper",
"->",
"$",
"method",
"(",
")",
";",
"}"
] |
Calls a helper depending on internal level of cache of the page
@param string $helper
@param string $method
@param mixed $cachedValue
@param array $args
@return mixed
|
[
"Calls",
"a",
"helper",
"depending",
"on",
"internal",
"level",
"of",
"cache",
"of",
"the",
"page"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Helper/Data.php#L676-L689
|
222,713
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Helper/Data.php
|
EcomDev_Varnish_Helper_Data.getChecksum
|
public function getChecksum($data)
{
$data['salt'] = $this->getEsiKey();
ksort($data);
return md5(json_encode($data));
}
|
php
|
public function getChecksum($data)
{
$data['salt'] = $this->getEsiKey();
ksort($data);
return md5(json_encode($data));
}
|
[
"public",
"function",
"getChecksum",
"(",
"$",
"data",
")",
"{",
"$",
"data",
"[",
"'salt'",
"]",
"=",
"$",
"this",
"->",
"getEsiKey",
"(",
")",
";",
"ksort",
"(",
"$",
"data",
")",
";",
"return",
"md5",
"(",
"json_encode",
"(",
"$",
"data",
")",
")",
";",
"}"
] |
Returns checksum for supplied data array
@param array $data
@return string
|
[
"Returns",
"checksum",
"for",
"supplied",
"data",
"array"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Helper/Data.php#L697-L702
|
222,714
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Helper/Data.php
|
EcomDev_Varnish_Helper_Data.validateChecksum
|
public function validateChecksum($data)
{
if (!isset($data['checksum']) || !$this->getEsiKey()) {
return false;
}
$suppliedChecksum = $data['checksum'];
unset($data['checksum']);
return $suppliedChecksum === $this->getChecksum($data);
}
|
php
|
public function validateChecksum($data)
{
if (!isset($data['checksum']) || !$this->getEsiKey()) {
return false;
}
$suppliedChecksum = $data['checksum'];
unset($data['checksum']);
return $suppliedChecksum === $this->getChecksum($data);
}
|
[
"public",
"function",
"validateChecksum",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"data",
"[",
"'checksum'",
"]",
")",
"||",
"!",
"$",
"this",
"->",
"getEsiKey",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"suppliedChecksum",
"=",
"$",
"data",
"[",
"'checksum'",
"]",
";",
"unset",
"(",
"$",
"data",
"[",
"'checksum'",
"]",
")",
";",
"return",
"$",
"suppliedChecksum",
"===",
"$",
"this",
"->",
"getChecksum",
"(",
"$",
"data",
")",
";",
"}"
] |
Validates checksum of esi request
@param array $data
@return bool
|
[
"Validates",
"checksum",
"of",
"esi",
"request"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Helper/Data.php#L710-L719
|
222,715
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Helper/Data.php
|
EcomDev_Varnish_Helper_Data.generateToken
|
public function generateToken()
{
$token = Mage::helper('core')->getRandomString(16);
$this->addCookie(self::COOKIE_TOKEN, $token);
$this->addCookie(self::COOKIE_TOKEN_CHECKSUM, $this->getChecksum(array('token' => $token)));
return $this;
}
|
php
|
public function generateToken()
{
$token = Mage::helper('core')->getRandomString(16);
$this->addCookie(self::COOKIE_TOKEN, $token);
$this->addCookie(self::COOKIE_TOKEN_CHECKSUM, $this->getChecksum(array('token' => $token)));
return $this;
}
|
[
"public",
"function",
"generateToken",
"(",
")",
"{",
"$",
"token",
"=",
"Mage",
"::",
"helper",
"(",
"'core'",
")",
"->",
"getRandomString",
"(",
"16",
")",
";",
"$",
"this",
"->",
"addCookie",
"(",
"self",
"::",
"COOKIE_TOKEN",
",",
"$",
"token",
")",
";",
"$",
"this",
"->",
"addCookie",
"(",
"self",
"::",
"COOKIE_TOKEN_CHECKSUM",
",",
"$",
"this",
"->",
"getChecksum",
"(",
"array",
"(",
"'token'",
"=>",
"$",
"token",
")",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Generates CSRF token for a user
@return $this
|
[
"Generates",
"CSRF",
"token",
"for",
"a",
"user"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Helper/Data.php#L726-L732
|
222,716
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Helper/Data.php
|
EcomDev_Varnish_Helper_Data.validateToken
|
public function validateToken($token)
{
$tokenChecksum = Mage::getSingleton('ecomdev_varnish/cookie')->get(self::COOKIE_TOKEN_CHECKSUM);
if ($tokenChecksum === $this->getChecksum(array('token' => $token))) {
return true;
}
return false;
}
|
php
|
public function validateToken($token)
{
$tokenChecksum = Mage::getSingleton('ecomdev_varnish/cookie')->get(self::COOKIE_TOKEN_CHECKSUM);
if ($tokenChecksum === $this->getChecksum(array('token' => $token))) {
return true;
}
return false;
}
|
[
"public",
"function",
"validateToken",
"(",
"$",
"token",
")",
"{",
"$",
"tokenChecksum",
"=",
"Mage",
"::",
"getSingleton",
"(",
"'ecomdev_varnish/cookie'",
")",
"->",
"get",
"(",
"self",
"::",
"COOKIE_TOKEN_CHECKSUM",
")",
";",
"if",
"(",
"$",
"tokenChecksum",
"===",
"$",
"this",
"->",
"getChecksum",
"(",
"array",
"(",
"'token'",
"=>",
"$",
"token",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Validates a token value
@param string $token
@return bool
|
[
"Validates",
"a",
"token",
"value"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Helper/Data.php#L740-L748
|
222,717
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Model/Cookie.php
|
EcomDev_Varnish_Model_Cookie.set
|
public function set($cookie, $value, $httpOnly = false)
{
$this->_cookies[$cookie] = array('value' => $value, 'http_only' => $httpOnly);
return $this;
}
|
php
|
public function set($cookie, $value, $httpOnly = false)
{
$this->_cookies[$cookie] = array('value' => $value, 'http_only' => $httpOnly);
return $this;
}
|
[
"public",
"function",
"set",
"(",
"$",
"cookie",
",",
"$",
"value",
",",
"$",
"httpOnly",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"_cookies",
"[",
"$",
"cookie",
"]",
"=",
"array",
"(",
"'value'",
"=>",
"$",
"value",
",",
"'http_only'",
"=>",
"$",
"httpOnly",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Stores a cookie for scheduled set cookie calls
@param string $cookie
@param string $value
@param bool $httpOnly
@return $this
|
[
"Stores",
"a",
"cookie",
"for",
"scheduled",
"set",
"cookie",
"calls"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Model/Cookie.php#L24-L28
|
222,718
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Model/Cookie.php
|
EcomDev_Varnish_Model_Cookie.get
|
public function get($cookie)
{
if (!$this->has($cookie)) {
if ($this->getRequest()) {
return $this->getRequest()->getCookie($cookie);
}
return null;
}
return $this->_cookies[$cookie]['value'];
}
|
php
|
public function get($cookie)
{
if (!$this->has($cookie)) {
if ($this->getRequest()) {
return $this->getRequest()->getCookie($cookie);
}
return null;
}
return $this->_cookies[$cookie]['value'];
}
|
[
"public",
"function",
"get",
"(",
"$",
"cookie",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"has",
"(",
"$",
"cookie",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getRequest",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"getCookie",
"(",
"$",
"cookie",
")",
";",
"}",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"_cookies",
"[",
"$",
"cookie",
"]",
"[",
"'value'",
"]",
";",
"}"
] |
Retrieves a cookie value from scheduled list or request cookie
@param string $cookie
@return mixed|null
|
[
"Retrieves",
"a",
"cookie",
"value",
"from",
"scheduled",
"list",
"or",
"request",
"cookie"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Model/Cookie.php#L47-L58
|
222,719
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Model/Cookie.php
|
EcomDev_Varnish_Model_Cookie.apply
|
public function apply()
{
Mage::dispatchEvent('ecomdev_varnish_cookie_apply_before', array('cookie' => $this));
foreach ($this->getAll() as $cookieName => $data) {
Mage::getSingleton('core/cookie')->set(
$cookieName,
$data['value'],
null,
null,
null,
null,
$data['http_only']
);
}
Mage::dispatchEvent('ecomdev_varnish_cookie_apply_after', array('cookie' => $this));
}
|
php
|
public function apply()
{
Mage::dispatchEvent('ecomdev_varnish_cookie_apply_before', array('cookie' => $this));
foreach ($this->getAll() as $cookieName => $data) {
Mage::getSingleton('core/cookie')->set(
$cookieName,
$data['value'],
null,
null,
null,
null,
$data['http_only']
);
}
Mage::dispatchEvent('ecomdev_varnish_cookie_apply_after', array('cookie' => $this));
}
|
[
"public",
"function",
"apply",
"(",
")",
"{",
"Mage",
"::",
"dispatchEvent",
"(",
"'ecomdev_varnish_cookie_apply_before'",
",",
"array",
"(",
"'cookie'",
"=>",
"$",
"this",
")",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getAll",
"(",
")",
"as",
"$",
"cookieName",
"=>",
"$",
"data",
")",
"{",
"Mage",
"::",
"getSingleton",
"(",
"'core/cookie'",
")",
"->",
"set",
"(",
"$",
"cookieName",
",",
"$",
"data",
"[",
"'value'",
"]",
",",
"null",
",",
"null",
",",
"null",
",",
"null",
",",
"$",
"data",
"[",
"'http_only'",
"]",
")",
";",
"}",
"Mage",
"::",
"dispatchEvent",
"(",
"'ecomdev_varnish_cookie_apply_after'",
",",
"array",
"(",
"'cookie'",
"=>",
"$",
"this",
")",
")",
";",
"}"
] |
Applies cookies to be set
|
[
"Applies",
"cookies",
"to",
"be",
"set"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Model/Cookie.php#L90-L107
|
222,720
|
basarevych/dynamic-table
|
php/DynamicTable/Adapter/ArrayAdapter.php
|
ArrayAdapter.checkFilter
|
protected function checkFilter($filter, $type, $test, $real)
{
if ($type == Table::TYPE_DATETIME) {
if ($filter == Table::FILTER_BETWEEN
&& is_array($test) && count($test) == 2) {
$test = [
$test[0] ? new \DateTime('@' . $test[0]) : null,
$test[1] ? new \DateTime('@' . $test[1]) : null,
];
if ($test[0] && $this->getDbTimezone())
$test[0]->setTimezone(new \DateTimeZone($this->getDbTimezone()));
if ($test[1] && $this->getDbTimezone())
$test[1]->setTimezone(new \DateTimeZone($this->getDbTimezone()));
} else if ($filter != Table::FILTER_BETWEEN
&& is_scalar($test)) {
$test = new \DateTime('@' . $test);
if ($this->getDbTimezone())
$test->setTimezone(new \DateTimeZone($this->getDbTimezone()));
} else {
return null;
}
} else {
if ($filter == Table::FILTER_BETWEEN) {
if (!is_array($test) || count($test) != 2)
return null;
} else if (!is_scalar($test)) {
return null;
}
}
switch ($filter) {
case Table::FILTER_LIKE:
return $real !== null && strpos($real, $test) !== false;
case Table::FILTER_EQUAL:
return $real !== null && $test == $real;
case Table::FILTER_BETWEEN:
if ($real === null)
return false;
if ($test[0] !== null && $real < $test[0])
return false;
if ($test[1] !== null && $real > $test[1])
return false;
return true;
case Table::FILTER_NULL:
return $real === null;
default:
throw new \Exception("Unknown filter: $filter");
}
return false;
}
|
php
|
protected function checkFilter($filter, $type, $test, $real)
{
if ($type == Table::TYPE_DATETIME) {
if ($filter == Table::FILTER_BETWEEN
&& is_array($test) && count($test) == 2) {
$test = [
$test[0] ? new \DateTime('@' . $test[0]) : null,
$test[1] ? new \DateTime('@' . $test[1]) : null,
];
if ($test[0] && $this->getDbTimezone())
$test[0]->setTimezone(new \DateTimeZone($this->getDbTimezone()));
if ($test[1] && $this->getDbTimezone())
$test[1]->setTimezone(new \DateTimeZone($this->getDbTimezone()));
} else if ($filter != Table::FILTER_BETWEEN
&& is_scalar($test)) {
$test = new \DateTime('@' . $test);
if ($this->getDbTimezone())
$test->setTimezone(new \DateTimeZone($this->getDbTimezone()));
} else {
return null;
}
} else {
if ($filter == Table::FILTER_BETWEEN) {
if (!is_array($test) || count($test) != 2)
return null;
} else if (!is_scalar($test)) {
return null;
}
}
switch ($filter) {
case Table::FILTER_LIKE:
return $real !== null && strpos($real, $test) !== false;
case Table::FILTER_EQUAL:
return $real !== null && $test == $real;
case Table::FILTER_BETWEEN:
if ($real === null)
return false;
if ($test[0] !== null && $real < $test[0])
return false;
if ($test[1] !== null && $real > $test[1])
return false;
return true;
case Table::FILTER_NULL:
return $real === null;
default:
throw new \Exception("Unknown filter: $filter");
}
return false;
}
|
[
"protected",
"function",
"checkFilter",
"(",
"$",
"filter",
",",
"$",
"type",
",",
"$",
"test",
",",
"$",
"real",
")",
"{",
"if",
"(",
"$",
"type",
"==",
"Table",
"::",
"TYPE_DATETIME",
")",
"{",
"if",
"(",
"$",
"filter",
"==",
"Table",
"::",
"FILTER_BETWEEN",
"&&",
"is_array",
"(",
"$",
"test",
")",
"&&",
"count",
"(",
"$",
"test",
")",
"==",
"2",
")",
"{",
"$",
"test",
"=",
"[",
"$",
"test",
"[",
"0",
"]",
"?",
"new",
"\\",
"DateTime",
"(",
"'@'",
".",
"$",
"test",
"[",
"0",
"]",
")",
":",
"null",
",",
"$",
"test",
"[",
"1",
"]",
"?",
"new",
"\\",
"DateTime",
"(",
"'@'",
".",
"$",
"test",
"[",
"1",
"]",
")",
":",
"null",
",",
"]",
";",
"if",
"(",
"$",
"test",
"[",
"0",
"]",
"&&",
"$",
"this",
"->",
"getDbTimezone",
"(",
")",
")",
"$",
"test",
"[",
"0",
"]",
"->",
"setTimezone",
"(",
"new",
"\\",
"DateTimeZone",
"(",
"$",
"this",
"->",
"getDbTimezone",
"(",
")",
")",
")",
";",
"if",
"(",
"$",
"test",
"[",
"1",
"]",
"&&",
"$",
"this",
"->",
"getDbTimezone",
"(",
")",
")",
"$",
"test",
"[",
"1",
"]",
"->",
"setTimezone",
"(",
"new",
"\\",
"DateTimeZone",
"(",
"$",
"this",
"->",
"getDbTimezone",
"(",
")",
")",
")",
";",
"}",
"else",
"if",
"(",
"$",
"filter",
"!=",
"Table",
"::",
"FILTER_BETWEEN",
"&&",
"is_scalar",
"(",
"$",
"test",
")",
")",
"{",
"$",
"test",
"=",
"new",
"\\",
"DateTime",
"(",
"'@'",
".",
"$",
"test",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getDbTimezone",
"(",
")",
")",
"$",
"test",
"->",
"setTimezone",
"(",
"new",
"\\",
"DateTimeZone",
"(",
"$",
"this",
"->",
"getDbTimezone",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"$",
"filter",
"==",
"Table",
"::",
"FILTER_BETWEEN",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"test",
")",
"||",
"count",
"(",
"$",
"test",
")",
"!=",
"2",
")",
"return",
"null",
";",
"}",
"else",
"if",
"(",
"!",
"is_scalar",
"(",
"$",
"test",
")",
")",
"{",
"return",
"null",
";",
"}",
"}",
"switch",
"(",
"$",
"filter",
")",
"{",
"case",
"Table",
"::",
"FILTER_LIKE",
":",
"return",
"$",
"real",
"!==",
"null",
"&&",
"strpos",
"(",
"$",
"real",
",",
"$",
"test",
")",
"!==",
"false",
";",
"case",
"Table",
"::",
"FILTER_EQUAL",
":",
"return",
"$",
"real",
"!==",
"null",
"&&",
"$",
"test",
"==",
"$",
"real",
";",
"case",
"Table",
"::",
"FILTER_BETWEEN",
":",
"if",
"(",
"$",
"real",
"===",
"null",
")",
"return",
"false",
";",
"if",
"(",
"$",
"test",
"[",
"0",
"]",
"!==",
"null",
"&&",
"$",
"real",
"<",
"$",
"test",
"[",
"0",
"]",
")",
"return",
"false",
";",
"if",
"(",
"$",
"test",
"[",
"1",
"]",
"!==",
"null",
"&&",
"$",
"real",
">",
"$",
"test",
"[",
"1",
"]",
")",
"return",
"false",
";",
"return",
"true",
";",
"case",
"Table",
"::",
"FILTER_NULL",
":",
"return",
"$",
"real",
"===",
"null",
";",
"default",
":",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Unknown filter: $filter\"",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Check and apply filter
@param string $filter
@param string $type
@param mixed $test
@param mixed $real
|
[
"Check",
"and",
"apply",
"filter"
] |
227eafab0d4dafabe0d2ceaa881ab3befe994d9c
|
https://github.com/basarevych/dynamic-table/blob/227eafab0d4dafabe0d2ceaa881ab3befe994d9c/php/DynamicTable/Adapter/ArrayAdapter.php#L229-L279
|
222,721
|
FriendsOfOuro/geteventstore-php-core
|
src/ValueObjects/Enum/Enum.php
|
Enum.sameValueAs
|
public function sameValueAs(ValueObjectInterface $enum)
{
if (false === Util::classEquals($this, $enum)) {
return false;
}
return $this->toNative() === $enum->toNative();
}
|
php
|
public function sameValueAs(ValueObjectInterface $enum)
{
if (false === Util::classEquals($this, $enum)) {
return false;
}
return $this->toNative() === $enum->toNative();
}
|
[
"public",
"function",
"sameValueAs",
"(",
"ValueObjectInterface",
"$",
"enum",
")",
"{",
"if",
"(",
"false",
"===",
"Util",
"::",
"classEquals",
"(",
"$",
"this",
",",
"$",
"enum",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"this",
"->",
"toNative",
"(",
")",
"===",
"$",
"enum",
"->",
"toNative",
"(",
")",
";",
"}"
] |
Tells whether two Enum objects are sameValueAs by comparing their values.
@param Enum $enum
@return bool
|
[
"Tells",
"whether",
"two",
"Enum",
"objects",
"are",
"sameValueAs",
"by",
"comparing",
"their",
"values",
"."
] |
76aac24ce7a688f8232f76ba24b3549222f20332
|
https://github.com/FriendsOfOuro/geteventstore-php-core/blob/76aac24ce7a688f8232f76ba24b3549222f20332/src/ValueObjects/Enum/Enum.php#L39-L46
|
222,722
|
eosnewmedia/JSON-API-Server
|
src/JsonApiServer.php
|
JsonApiServer.addHandler
|
public function addHandler(string $type, RequestHandlerInterface $handler): void
{
$this->handlers[$type] = $handler;
}
|
php
|
public function addHandler(string $type, RequestHandlerInterface $handler): void
{
$this->handlers[$type] = $handler;
}
|
[
"public",
"function",
"addHandler",
"(",
"string",
"$",
"type",
",",
"RequestHandlerInterface",
"$",
"handler",
")",
":",
"void",
"{",
"$",
"this",
"->",
"handlers",
"[",
"$",
"type",
"]",
"=",
"$",
"handler",
";",
"}"
] |
Adds a request handler
@param string $type
@param RequestHandlerInterface $handler
|
[
"Adds",
"a",
"request",
"handler"
] |
6fe8a6b605faebdda5597ee5069357a5ed1f23d9
|
https://github.com/eosnewmedia/JSON-API-Server/blob/6fe8a6b605faebdda5597ee5069357a5ed1f23d9/src/JsonApiServer.php#L70-L73
|
222,723
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Model/Vcl/Config/Array.php
|
EcomDev_Varnish_Model_Vcl_Config_Array.getConfigArrayOption
|
protected function getConfigArrayOption($optionName, $defaultValue = null)
{
if (!isset($this->config[$optionName])) {
return $defaultValue;
}
return $this->config[$optionName];
}
|
php
|
protected function getConfigArrayOption($optionName, $defaultValue = null)
{
if (!isset($this->config[$optionName])) {
return $defaultValue;
}
return $this->config[$optionName];
}
|
[
"protected",
"function",
"getConfigArrayOption",
"(",
"$",
"optionName",
",",
"$",
"defaultValue",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"config",
"[",
"$",
"optionName",
"]",
")",
")",
"{",
"return",
"$",
"defaultValue",
";",
"}",
"return",
"$",
"this",
"->",
"config",
"[",
"$",
"optionName",
"]",
";",
"}"
] |
Returns configuration array option
@param $optionName
@param mixed $defaultValue
@return mixed
|
[
"Returns",
"configuration",
"array",
"option"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Model/Vcl/Config/Array.php#L76-L83
|
222,724
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Model/Vcl/Config/Array.php
|
EcomDev_Varnish_Model_Vcl_Config_Array.initBackend
|
protected function initBackend()
{
$this->backendList = array();
$this->balancedBackendList = array();
foreach ($this->getConfigArrayOption('backend', array()) as $backendName => $option) {
if (!isset($option['ip']) || !isset($option['port'])) {
continue;
}
$this->backendList[$backendName] = array($option['ip'], $option['port']);
if (!empty($option['balanced'])) {
$this->balancedBackendList[] = $backendName;
}
if (!empty($option['admin'])) {
$this->adminBackend = $backendName;
}
}
if ($this->adminBackend === null) {
$this->adminBackend = key($this->backendList);
}
return $this;
}
|
php
|
protected function initBackend()
{
$this->backendList = array();
$this->balancedBackendList = array();
foreach ($this->getConfigArrayOption('backend', array()) as $backendName => $option) {
if (!isset($option['ip']) || !isset($option['port'])) {
continue;
}
$this->backendList[$backendName] = array($option['ip'], $option['port']);
if (!empty($option['balanced'])) {
$this->balancedBackendList[] = $backendName;
}
if (!empty($option['admin'])) {
$this->adminBackend = $backendName;
}
}
if ($this->adminBackend === null) {
$this->adminBackend = key($this->backendList);
}
return $this;
}
|
[
"protected",
"function",
"initBackend",
"(",
")",
"{",
"$",
"this",
"->",
"backendList",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"balancedBackendList",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getConfigArrayOption",
"(",
"'backend'",
",",
"array",
"(",
")",
")",
"as",
"$",
"backendName",
"=>",
"$",
"option",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"option",
"[",
"'ip'",
"]",
")",
"||",
"!",
"isset",
"(",
"$",
"option",
"[",
"'port'",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"this",
"->",
"backendList",
"[",
"$",
"backendName",
"]",
"=",
"array",
"(",
"$",
"option",
"[",
"'ip'",
"]",
",",
"$",
"option",
"[",
"'port'",
"]",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"option",
"[",
"'balanced'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"balancedBackendList",
"[",
"]",
"=",
"$",
"backendName",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"option",
"[",
"'admin'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"adminBackend",
"=",
"$",
"backendName",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"adminBackend",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"adminBackend",
"=",
"key",
"(",
"$",
"this",
"->",
"backendList",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Initializes backend options
@return $this
|
[
"Initializes",
"backend",
"options"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Model/Vcl/Config/Array.php#L90-L115
|
222,725
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Model/Vcl/Config/Array.php
|
EcomDev_Varnish_Model_Vcl_Config_Array.getBackendOption
|
public function getBackendOption($backendName, $option, $defaultOption = null)
{
$backendConfig = $this->getConfigArrayOption('backend', array());
if (isset($backendConfig[$backendName][$option])) {
return $backendConfig[$backendName][$option];
}
$optionConfig = $this->getConfigArrayOption('default_backend_option', array());
if (isset($optionConfig[$option])) {
return $optionConfig[$option];
}
return $defaultOption;
}
|
php
|
public function getBackendOption($backendName, $option, $defaultOption = null)
{
$backendConfig = $this->getConfigArrayOption('backend', array());
if (isset($backendConfig[$backendName][$option])) {
return $backendConfig[$backendName][$option];
}
$optionConfig = $this->getConfigArrayOption('default_backend_option', array());
if (isset($optionConfig[$option])) {
return $optionConfig[$option];
}
return $defaultOption;
}
|
[
"public",
"function",
"getBackendOption",
"(",
"$",
"backendName",
",",
"$",
"option",
",",
"$",
"defaultOption",
"=",
"null",
")",
"{",
"$",
"backendConfig",
"=",
"$",
"this",
"->",
"getConfigArrayOption",
"(",
"'backend'",
",",
"array",
"(",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"backendConfig",
"[",
"$",
"backendName",
"]",
"[",
"$",
"option",
"]",
")",
")",
"{",
"return",
"$",
"backendConfig",
"[",
"$",
"backendName",
"]",
"[",
"$",
"option",
"]",
";",
"}",
"$",
"optionConfig",
"=",
"$",
"this",
"->",
"getConfigArrayOption",
"(",
"'default_backend_option'",
",",
"array",
"(",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"optionConfig",
"[",
"$",
"option",
"]",
")",
")",
"{",
"return",
"$",
"optionConfig",
"[",
"$",
"option",
"]",
";",
"}",
"return",
"$",
"defaultOption",
";",
"}"
] |
Returns backend option from configuration
@param string $backendName a identifier from array keys of backend list
@param string $option
@return string
|
[
"Returns",
"backend",
"option",
"from",
"configuration"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Model/Vcl/Config/Array.php#L140-L154
|
222,726
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Model/Vcl/Config/Array.php
|
EcomDev_Varnish_Model_Vcl_Config_Array.getCookieName
|
public function getCookieName($type)
{
$defaultCookieNames = $this->getConfigArrayOption(
'default_cookie_names',
[
'segment' => EcomDev_Varnish_Model_Customer_Observer::COOKIE_SEGMENT
]
);
$cookieNames = $this->getConfigArrayOption(
'cookie_names',
[]
);
$cookieNames = $defaultCookieNames + $cookieNames;
if (isset($cookieNames[$type])) {
return $cookieNames[$type];
}
return $type;
}
|
php
|
public function getCookieName($type)
{
$defaultCookieNames = $this->getConfigArrayOption(
'default_cookie_names',
[
'segment' => EcomDev_Varnish_Model_Customer_Observer::COOKIE_SEGMENT
]
);
$cookieNames = $this->getConfigArrayOption(
'cookie_names',
[]
);
$cookieNames = $defaultCookieNames + $cookieNames;
if (isset($cookieNames[$type])) {
return $cookieNames[$type];
}
return $type;
}
|
[
"public",
"function",
"getCookieName",
"(",
"$",
"type",
")",
"{",
"$",
"defaultCookieNames",
"=",
"$",
"this",
"->",
"getConfigArrayOption",
"(",
"'default_cookie_names'",
",",
"[",
"'segment'",
"=>",
"EcomDev_Varnish_Model_Customer_Observer",
"::",
"COOKIE_SEGMENT",
"]",
")",
";",
"$",
"cookieNames",
"=",
"$",
"this",
"->",
"getConfigArrayOption",
"(",
"'cookie_names'",
",",
"[",
"]",
")",
";",
"$",
"cookieNames",
"=",
"$",
"defaultCookieNames",
"+",
"$",
"cookieNames",
";",
"if",
"(",
"isset",
"(",
"$",
"cookieNames",
"[",
"$",
"type",
"]",
")",
")",
"{",
"return",
"$",
"cookieNames",
"[",
"$",
"type",
"]",
";",
"}",
"return",
"$",
"type",
";",
"}"
] |
Returns cookie name for VCL configuration
@param string $type
@return string
|
[
"Returns",
"cookie",
"name",
"for",
"VCL",
"configuration"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Model/Vcl/Config/Array.php#L306-L328
|
222,727
|
TerbiumLibs/dbConfig
|
src/Terbium/DbConfig/DbProvider.php
|
DbProvider.load
|
public function load($collection = null)
{
$items = array();
$list = DB::table($this->table);
if ($collection !== null) {
$list = $list->where('key', 'LIKE', $collection . '%');
}
$list = $list->pluck('value', 'key');
// convert dotted list back to multidimensional array
foreach ($list as $key => $value) {
$value = json_decode($value);
array_set($items, $key, $value);
}
return $items;
}
|
php
|
public function load($collection = null)
{
$items = array();
$list = DB::table($this->table);
if ($collection !== null) {
$list = $list->where('key', 'LIKE', $collection . '%');
}
$list = $list->pluck('value', 'key');
// convert dotted list back to multidimensional array
foreach ($list as $key => $value) {
$value = json_decode($value);
array_set($items, $key, $value);
}
return $items;
}
|
[
"public",
"function",
"load",
"(",
"$",
"collection",
"=",
"null",
")",
"{",
"$",
"items",
"=",
"array",
"(",
")",
";",
"$",
"list",
"=",
"DB",
"::",
"table",
"(",
"$",
"this",
"->",
"table",
")",
";",
"if",
"(",
"$",
"collection",
"!==",
"null",
")",
"{",
"$",
"list",
"=",
"$",
"list",
"->",
"where",
"(",
"'key'",
",",
"'LIKE'",
",",
"$",
"collection",
".",
"'%'",
")",
";",
"}",
"$",
"list",
"=",
"$",
"list",
"->",
"pluck",
"(",
"'value'",
",",
"'key'",
")",
";",
"// convert dotted list back to multidimensional array",
"foreach",
"(",
"$",
"list",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"json_decode",
"(",
"$",
"value",
")",
";",
"array_set",
"(",
"$",
"items",
",",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"items",
";",
"}"
] |
Load the given configuration collection.
@param string $collection
@return array
|
[
"Load",
"the",
"given",
"configuration",
"collection",
"."
] |
c418de91cf13af8bce107e9da6226abc9a0167c6
|
https://github.com/TerbiumLibs/dbConfig/blob/c418de91cf13af8bce107e9da6226abc9a0167c6/src/Terbium/DbConfig/DbProvider.php#L33-L54
|
222,728
|
TerbiumLibs/dbConfig
|
src/Terbium/DbConfig/DbProvider.php
|
DbProvider.store
|
public function store($key, $value)
{
if (!is_array($value)) {
$value = array($key => $value);
} else {
$value = array_dot($value);
foreach ($value as $k => $v) {
$value[$key . '.' . $k] = $v;
unset($value[$k]);
}
}
foreach ($value as $k => $v) {
$this->_store($k, $v);
}
}
|
php
|
public function store($key, $value)
{
if (!is_array($value)) {
$value = array($key => $value);
} else {
$value = array_dot($value);
foreach ($value as $k => $v) {
$value[$key . '.' . $k] = $v;
unset($value[$k]);
}
}
foreach ($value as $k => $v) {
$this->_store($k, $v);
}
}
|
[
"public",
"function",
"store",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"array",
"(",
"$",
"key",
"=>",
"$",
"value",
")",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"array_dot",
"(",
"$",
"value",
")",
";",
"foreach",
"(",
"$",
"value",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"value",
"[",
"$",
"key",
".",
"'.'",
".",
"$",
"k",
"]",
"=",
"$",
"v",
";",
"unset",
"(",
"$",
"value",
"[",
"$",
"k",
"]",
")",
";",
"}",
"}",
"foreach",
"(",
"$",
"value",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"this",
"->",
"_store",
"(",
"$",
"k",
",",
"$",
"v",
")",
";",
"}",
"}"
] |
Save item to the database or update the existing one
@param string $key
@param mixed $value
@return void
@throws Exceptions\SaveException
|
[
"Save",
"item",
"to",
"the",
"database",
"or",
"update",
"the",
"existing",
"one"
] |
c418de91cf13af8bce107e9da6226abc9a0167c6
|
https://github.com/TerbiumLibs/dbConfig/blob/c418de91cf13af8bce107e9da6226abc9a0167c6/src/Terbium/DbConfig/DbProvider.php#L66-L84
|
222,729
|
TerbiumLibs/dbConfig
|
src/Terbium/DbConfig/DbProvider.php
|
DbProvider.clear
|
public function clear()
{
try {
DB::table($this->table)->truncate();
} catch (\Exception $e) {
throw new SaveException("Cannot clear database: " . $e->getMessage());
}
}
|
php
|
public function clear()
{
try {
DB::table($this->table)->truncate();
} catch (\Exception $e) {
throw new SaveException("Cannot clear database: " . $e->getMessage());
}
}
|
[
"public",
"function",
"clear",
"(",
")",
"{",
"try",
"{",
"DB",
"::",
"table",
"(",
"$",
"this",
"->",
"table",
")",
"->",
"truncate",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"SaveException",
"(",
"\"Cannot clear database: \"",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] |
Clear the table with settings
@return void
@throws Exceptions\SaveException
|
[
"Clear",
"the",
"table",
"with",
"settings"
] |
c418de91cf13af8bce107e9da6226abc9a0167c6
|
https://github.com/TerbiumLibs/dbConfig/blob/c418de91cf13af8bce107e9da6226abc9a0167c6/src/Terbium/DbConfig/DbProvider.php#L170-L183
|
222,730
|
TerbiumLibs/dbConfig
|
src/Terbium/DbConfig/DbProvider.php
|
DbProvider.listDb
|
public function listDb($wildcard = null)
{
$query = DB::table($this->table);
if (!empty($wildcard)) {
$query = $query->where('key', 'LIKE', $wildcard . '%');
}
return $query;
}
|
php
|
public function listDb($wildcard = null)
{
$query = DB::table($this->table);
if (!empty($wildcard)) {
$query = $query->where('key', 'LIKE', $wildcard . '%');
}
return $query;
}
|
[
"public",
"function",
"listDb",
"(",
"$",
"wildcard",
"=",
"null",
")",
"{",
"$",
"query",
"=",
"DB",
"::",
"table",
"(",
"$",
"this",
"->",
"table",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"wildcard",
")",
")",
"{",
"$",
"query",
"=",
"$",
"query",
"->",
"where",
"(",
"'key'",
",",
"'LIKE'",
",",
"$",
"wildcard",
".",
"'%'",
")",
";",
"}",
"return",
"$",
"query",
";",
"}"
] |
Return query builder with list of settings from database
@param string $wildcard
@return Illuminate\Database\Query\Builder
|
[
"Return",
"query",
"builder",
"with",
"list",
"of",
"settings",
"from",
"database"
] |
c418de91cf13af8bce107e9da6226abc9a0167c6
|
https://github.com/TerbiumLibs/dbConfig/blob/c418de91cf13af8bce107e9da6226abc9a0167c6/src/Terbium/DbConfig/DbProvider.php#L193-L203
|
222,731
|
FriendsOfOuro/geteventstore-php-core
|
src/ValueObjects/Identity/UUID.php
|
UUID.sameValueAs
|
public function sameValueAs(ValueObjectInterface $uuid)
{
if (false === Util::classEquals($this, $uuid)) {
return false;
}
return $this->toNative() === $uuid->toNative();
}
|
php
|
public function sameValueAs(ValueObjectInterface $uuid)
{
if (false === Util::classEquals($this, $uuid)) {
return false;
}
return $this->toNative() === $uuid->toNative();
}
|
[
"public",
"function",
"sameValueAs",
"(",
"ValueObjectInterface",
"$",
"uuid",
")",
"{",
"if",
"(",
"false",
"===",
"Util",
"::",
"classEquals",
"(",
"$",
"this",
",",
"$",
"uuid",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"this",
"->",
"toNative",
"(",
")",
"===",
"$",
"uuid",
"->",
"toNative",
"(",
")",
";",
"}"
] |
Tells whether two UUID are equal by comparing their values.
@param UUID $uuid
@return bool
|
[
"Tells",
"whether",
"two",
"UUID",
"are",
"equal",
"by",
"comparing",
"their",
"values",
"."
] |
76aac24ce7a688f8232f76ba24b3549222f20332
|
https://github.com/FriendsOfOuro/geteventstore-php-core/blob/76aac24ce7a688f8232f76ba24b3549222f20332/src/ValueObjects/Identity/UUID.php#L68-L75
|
222,732
|
iMi-digital/laravel-transsid
|
src/StartSessionMiddleware.php
|
StartSessionMiddleware.validate
|
protected function validate($session, $request)
{
$locked = $session->get(self::LOCKED_FIELD);
return !($locked['ip'] != $request->getClientIp()
|| $locked['agent'] != md5($request->server('HTTP_USER_AGENT')));
}
|
php
|
protected function validate($session, $request)
{
$locked = $session->get(self::LOCKED_FIELD);
return !($locked['ip'] != $request->getClientIp()
|| $locked['agent'] != md5($request->server('HTTP_USER_AGENT')));
}
|
[
"protected",
"function",
"validate",
"(",
"$",
"session",
",",
"$",
"request",
")",
"{",
"$",
"locked",
"=",
"$",
"session",
"->",
"get",
"(",
"self",
"::",
"LOCKED_FIELD",
")",
";",
"return",
"!",
"(",
"$",
"locked",
"[",
"'ip'",
"]",
"!=",
"$",
"request",
"->",
"getClientIp",
"(",
")",
"||",
"$",
"locked",
"[",
"'agent'",
"]",
"!=",
"md5",
"(",
"$",
"request",
"->",
"server",
"(",
"'HTTP_USER_AGENT'",
")",
")",
")",
";",
"}"
] |
Check if IP or Agent changed
@param $session
@param $request
@return bool
|
[
"Check",
"if",
"IP",
"or",
"Agent",
"changed"
] |
d1898a3d620ddd5eab17c26fca879b32df2c6810
|
https://github.com/iMi-digital/laravel-transsid/blob/d1898a3d620ddd5eab17c26fca879b32df2c6810/src/StartSessionMiddleware.php#L32-L37
|
222,733
|
compropago/compropago-php
|
src/Resources/Webhook.php
|
Webhook.getAll
|
public function getAll()
{
$endpoint = "{$this->apiUrl}/webhooks/stores";
$res = Requests::get(
$endpoint,
array(),
$this->options
);
$this->validateResponse($res);
return json_decode($res->body, true);
}
|
php
|
public function getAll()
{
$endpoint = "{$this->apiUrl}/webhooks/stores";
$res = Requests::get(
$endpoint,
array(),
$this->options
);
$this->validateResponse($res);
return json_decode($res->body, true);
}
|
[
"public",
"function",
"getAll",
"(",
")",
"{",
"$",
"endpoint",
"=",
"\"{$this->apiUrl}/webhooks/stores\"",
";",
"$",
"res",
"=",
"Requests",
"::",
"get",
"(",
"$",
"endpoint",
",",
"array",
"(",
")",
",",
"$",
"this",
"->",
"options",
")",
";",
"$",
"this",
"->",
"validateResponse",
"(",
"$",
"res",
")",
";",
"return",
"json_decode",
"(",
"$",
"res",
"->",
"body",
",",
"true",
")",
";",
"}"
] |
Returns a list of all registed webhooks
@return array Webhook structure
@throws \Exception Request error or exception
|
[
"Returns",
"a",
"list",
"of",
"all",
"registed",
"webhooks"
] |
dc11d7cba778123bbf84860b4bb5d8dbfb78598f
|
https://github.com/compropago/compropago-php/blob/dc11d7cba778123bbf84860b4bb5d8dbfb78598f/src/Resources/Webhook.php#L26-L38
|
222,734
|
xcaliber-tech/omnipay-skrill
|
src/Omnipay/Skrill/Message/Request.php
|
Request.sendData
|
public function sendData($data)
{
$url = $this->getEndpoint() . '?' . http_build_query($data);
$httpResponse = $this->httpClient->get($url)->send();
$xml = $httpResponse->xml();
return $this->createResponse($xml);
}
|
php
|
public function sendData($data)
{
$url = $this->getEndpoint() . '?' . http_build_query($data);
$httpResponse = $this->httpClient->get($url)->send();
$xml = $httpResponse->xml();
return $this->createResponse($xml);
}
|
[
"public",
"function",
"sendData",
"(",
"$",
"data",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"getEndpoint",
"(",
")",
".",
"'?'",
".",
"http_build_query",
"(",
"$",
"data",
")",
";",
"$",
"httpResponse",
"=",
"$",
"this",
"->",
"httpClient",
"->",
"get",
"(",
"$",
"url",
")",
"->",
"send",
"(",
")",
";",
"$",
"xml",
"=",
"$",
"httpResponse",
"->",
"xml",
"(",
")",
";",
"return",
"$",
"this",
"->",
"createResponse",
"(",
"$",
"xml",
")",
";",
"}"
] |
Send the skrill request.
@return Response
|
[
"Send",
"the",
"skrill",
"request",
"."
] |
f90a185b5e26fb5b4150d664f01ad8048b460bcf
|
https://github.com/xcaliber-tech/omnipay-skrill/blob/f90a185b5e26fb5b4150d664f01ad8048b460bcf/src/Omnipay/Skrill/Message/Request.php#L56-L63
|
222,735
|
xcaliber-tech/omnipay-skrill
|
src/Omnipay/Skrill/Message/Request.php
|
Request.createResponse
|
protected function createResponse($xml)
{
$requestClass = get_class($this);
$responseClass = substr($requestClass, 0, -7) . 'Response';
return $this->response = new $responseClass($this, $xml);
}
|
php
|
protected function createResponse($xml)
{
$requestClass = get_class($this);
$responseClass = substr($requestClass, 0, -7) . 'Response';
return $this->response = new $responseClass($this, $xml);
}
|
[
"protected",
"function",
"createResponse",
"(",
"$",
"xml",
")",
"{",
"$",
"requestClass",
"=",
"get_class",
"(",
"$",
"this",
")",
";",
"$",
"responseClass",
"=",
"substr",
"(",
"$",
"requestClass",
",",
"0",
",",
"-",
"7",
")",
".",
"'Response'",
";",
"return",
"$",
"this",
"->",
"response",
"=",
"new",
"$",
"responseClass",
"(",
"$",
"this",
",",
"$",
"xml",
")",
";",
"}"
] |
Create a proper response based on the request.
@param \SimpleXMLElement $xml raw response
@return Response response for this request
|
[
"Create",
"a",
"proper",
"response",
"based",
"on",
"the",
"request",
"."
] |
f90a185b5e26fb5b4150d664f01ad8048b460bcf
|
https://github.com/xcaliber-tech/omnipay-skrill/blob/f90a185b5e26fb5b4150d664f01ad8048b460bcf/src/Omnipay/Skrill/Message/Request.php#L71-L76
|
222,736
|
stanislav-web/phalcon-uploader
|
src/Uploader/Helpers/Format.php
|
Format.bytes
|
public static function bytes($bytes, $precision = 2)
{
$size = array('bytes', 'kb', 'mb', 'gb', 'tb', 'pb', 'eb', 'zb', 'yb');
$factor = floor((strlen($bytes) - 1) / 3);
return sprintf("%.{$precision}f", $bytes / pow(1024, $factor)) . ' ' . @$size[$factor];
}
|
php
|
public static function bytes($bytes, $precision = 2)
{
$size = array('bytes', 'kb', 'mb', 'gb', 'tb', 'pb', 'eb', 'zb', 'yb');
$factor = floor((strlen($bytes) - 1) / 3);
return sprintf("%.{$precision}f", $bytes / pow(1024, $factor)) . ' ' . @$size[$factor];
}
|
[
"public",
"static",
"function",
"bytes",
"(",
"$",
"bytes",
",",
"$",
"precision",
"=",
"2",
")",
"{",
"$",
"size",
"=",
"array",
"(",
"'bytes'",
",",
"'kb'",
",",
"'mb'",
",",
"'gb'",
",",
"'tb'",
",",
"'pb'",
",",
"'eb'",
",",
"'zb'",
",",
"'yb'",
")",
";",
"$",
"factor",
"=",
"floor",
"(",
"(",
"strlen",
"(",
"$",
"bytes",
")",
"-",
"1",
")",
"/",
"3",
")",
";",
"return",
"sprintf",
"(",
"\"%.{$precision}f\"",
",",
"$",
"bytes",
"/",
"pow",
"(",
"1024",
",",
"$",
"factor",
")",
")",
".",
"' '",
".",
"@",
"$",
"size",
"[",
"$",
"factor",
"]",
";",
"}"
] |
Format byte code to human understand
@param int $bytes number of bytes
@param int $precision after comma numbers
@return string
|
[
"Format",
"byte",
"code",
"to",
"human",
"understand"
] |
3e46aba5d6f51b52b7830eae21c0d3fe1e524c90
|
https://github.com/stanislav-web/phalcon-uploader/blob/3e46aba5d6f51b52b7830eae21c0d3fe1e524c90/src/Uploader/Helpers/Format.php#L45-L50
|
222,737
|
stanislav-web/phalcon-uploader
|
src/Uploader/Helpers/Format.php
|
Format.toLatin
|
public static function toLatin($string, $separator = '', $clean = false)
{
$cyrillicCount = count(self::$cyr);
for ($i = 0; $i < $cyrillicCount; $i++) {
$string = str_replace(self::$cyr[$i], self::$lat[$i], $string);
}
$string = preg_replace("/([qwrtpsdfghklzxcvbnmQWRTPSDFGHKLZXCVBNM]+)[jJ]e/", "\${1}e", $string);
$string = preg_replace("/([qwrtpsdfghklzxcvbnmQWRTPSDFGHKLZXCVBNM]+)[jJ]/", "\${1}y", $string);
$string = preg_replace("/([eyuioaEYUIOA]+)[Kk]h/", "\${1}h", $string);
$string = preg_replace("/^kh/", "h", $string);
$string = preg_replace("/^Kh/", "H", $string);
$string = trim($string);
if (empty($separator) === false) {
$string = str_replace(' ', $separator, $string);
$string = preg_replace('/['.$separator.']{2,}/', '', $string);
}
if ($clean !== false) {
$string = strtolower($string);
$string = preg_replace('/[^-_a-z0-9.]+/', '', $string);
}
return $string;
}
|
php
|
public static function toLatin($string, $separator = '', $clean = false)
{
$cyrillicCount = count(self::$cyr);
for ($i = 0; $i < $cyrillicCount; $i++) {
$string = str_replace(self::$cyr[$i], self::$lat[$i], $string);
}
$string = preg_replace("/([qwrtpsdfghklzxcvbnmQWRTPSDFGHKLZXCVBNM]+)[jJ]e/", "\${1}e", $string);
$string = preg_replace("/([qwrtpsdfghklzxcvbnmQWRTPSDFGHKLZXCVBNM]+)[jJ]/", "\${1}y", $string);
$string = preg_replace("/([eyuioaEYUIOA]+)[Kk]h/", "\${1}h", $string);
$string = preg_replace("/^kh/", "h", $string);
$string = preg_replace("/^Kh/", "H", $string);
$string = trim($string);
if (empty($separator) === false) {
$string = str_replace(' ', $separator, $string);
$string = preg_replace('/['.$separator.']{2,}/', '', $string);
}
if ($clean !== false) {
$string = strtolower($string);
$string = preg_replace('/[^-_a-z0-9.]+/', '', $string);
}
return $string;
}
|
[
"public",
"static",
"function",
"toLatin",
"(",
"$",
"string",
",",
"$",
"separator",
"=",
"''",
",",
"$",
"clean",
"=",
"false",
")",
"{",
"$",
"cyrillicCount",
"=",
"count",
"(",
"self",
"::",
"$",
"cyr",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"cyrillicCount",
";",
"$",
"i",
"++",
")",
"{",
"$",
"string",
"=",
"str_replace",
"(",
"self",
"::",
"$",
"cyr",
"[",
"$",
"i",
"]",
",",
"self",
"::",
"$",
"lat",
"[",
"$",
"i",
"]",
",",
"$",
"string",
")",
";",
"}",
"$",
"string",
"=",
"preg_replace",
"(",
"\"/([qwrtpsdfghklzxcvbnmQWRTPSDFGHKLZXCVBNM]+)[jJ]e/\"",
",",
"\"\\${1}e\"",
",",
"$",
"string",
")",
";",
"$",
"string",
"=",
"preg_replace",
"(",
"\"/([qwrtpsdfghklzxcvbnmQWRTPSDFGHKLZXCVBNM]+)[jJ]/\"",
",",
"\"\\${1}y\"",
",",
"$",
"string",
")",
";",
"$",
"string",
"=",
"preg_replace",
"(",
"\"/([eyuioaEYUIOA]+)[Kk]h/\"",
",",
"\"\\${1}h\"",
",",
"$",
"string",
")",
";",
"$",
"string",
"=",
"preg_replace",
"(",
"\"/^kh/\"",
",",
"\"h\"",
",",
"$",
"string",
")",
";",
"$",
"string",
"=",
"preg_replace",
"(",
"\"/^Kh/\"",
",",
"\"H\"",
",",
"$",
"string",
")",
";",
"$",
"string",
"=",
"trim",
"(",
"$",
"string",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"separator",
")",
"===",
"false",
")",
"{",
"$",
"string",
"=",
"str_replace",
"(",
"' '",
",",
"$",
"separator",
",",
"$",
"string",
")",
";",
"$",
"string",
"=",
"preg_replace",
"(",
"'/['",
".",
"$",
"separator",
".",
"']{2,}/'",
",",
"''",
",",
"$",
"string",
")",
";",
"}",
"if",
"(",
"$",
"clean",
"!==",
"false",
")",
"{",
"$",
"string",
"=",
"strtolower",
"(",
"$",
"string",
")",
";",
"$",
"string",
"=",
"preg_replace",
"(",
"'/[^-_a-z0-9.]+/'",
",",
"''",
",",
"$",
"string",
")",
";",
"}",
"return",
"$",
"string",
";",
"}"
] |
Transliterate cyrillic to latin
@param string $string original string
@param string $separator word separator
@param boolean $clean to lower & all non understand symbols remove
@return string
|
[
"Transliterate",
"cyrillic",
"to",
"latin"
] |
3e46aba5d6f51b52b7830eae21c0d3fe1e524c90
|
https://github.com/stanislav-web/phalcon-uploader/blob/3e46aba5d6f51b52b7830eae21c0d3fe1e524c90/src/Uploader/Helpers/Format.php#L60-L89
|
222,738
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Model/AbstractProcessor.php
|
EcomDev_Varnish_Model_AbstractProcessor.getTags
|
public function getTags($object)
{
$tags = $this->_collectTags($object);
if (is_string($tags)) {
$tags = array(
$tags => $tags
);
} elseif (!is_array($tags)) {
return array();
}
return $tags;
}
|
php
|
public function getTags($object)
{
$tags = $this->_collectTags($object);
if (is_string($tags)) {
$tags = array(
$tags => $tags
);
} elseif (!is_array($tags)) {
return array();
}
return $tags;
}
|
[
"public",
"function",
"getTags",
"(",
"$",
"object",
")",
"{",
"$",
"tags",
"=",
"$",
"this",
"->",
"_collectTags",
"(",
"$",
"object",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"tags",
")",
")",
"{",
"$",
"tags",
"=",
"array",
"(",
"$",
"tags",
"=>",
"$",
"tags",
")",
";",
"}",
"elseif",
"(",
"!",
"is_array",
"(",
"$",
"tags",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"return",
"$",
"tags",
";",
"}"
] |
Collects list of objects that can be used by object retrievers
@param Mage_Core_Model_Abstract $object
@return string[]
|
[
"Collects",
"list",
"of",
"objects",
"that",
"can",
"be",
"used",
"by",
"object",
"retrievers"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Model/AbstractProcessor.php#L42-L55
|
222,739
|
commerceguys/pricing
|
src/Price.php
|
Price.assertSameCurrency
|
protected function assertSameCurrency(Price $a, Price $b)
{
if ($a->getCurrency() != $b->getCurrency()) {
throw new CurrencyMismatchException;
}
}
|
php
|
protected function assertSameCurrency(Price $a, Price $b)
{
if ($a->getCurrency() != $b->getCurrency()) {
throw new CurrencyMismatchException;
}
}
|
[
"protected",
"function",
"assertSameCurrency",
"(",
"Price",
"$",
"a",
",",
"Price",
"$",
"b",
")",
"{",
"if",
"(",
"$",
"a",
"->",
"getCurrency",
"(",
")",
"!=",
"$",
"b",
"->",
"getCurrency",
"(",
")",
")",
"{",
"throw",
"new",
"CurrencyMismatchException",
";",
"}",
"}"
] |
Ensures that the two Price instances have the same currency.
@param \CommerceGuys\Pricing\Price $a
@param \CommerceGuys\Pricing\Price $b
@throws \CommerceGuys\Pricing\CurrencyMismatchException
|
[
"Ensures",
"that",
"the",
"two",
"Price",
"instances",
"have",
"the",
"same",
"currency",
"."
] |
55269e9603d28cf1de644f49d7af7c1d36b5864d
|
https://github.com/commerceguys/pricing/blob/55269e9603d28cf1de644f49d7af7c1d36b5864d/src/Price.php#L176-L181
|
222,740
|
commerceguys/pricing
|
src/Price.php
|
Price.assertAmountFormat
|
protected function assertAmountFormat($amount)
{
if (is_float($amount)) {
throw new InvalidArgumentException(sprintf('The provided amount "%s" must be a string, not a float.', $amount));
}
if (!is_numeric($amount)) {
throw new InvalidArgumentException(sprintf('The provided amount "%s" must be a valid string.', $amount));
}
}
|
php
|
protected function assertAmountFormat($amount)
{
if (is_float($amount)) {
throw new InvalidArgumentException(sprintf('The provided amount "%s" must be a string, not a float.', $amount));
}
if (!is_numeric($amount)) {
throw new InvalidArgumentException(sprintf('The provided amount "%s" must be a valid string.', $amount));
}
}
|
[
"protected",
"function",
"assertAmountFormat",
"(",
"$",
"amount",
")",
"{",
"if",
"(",
"is_float",
"(",
"$",
"amount",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The provided amount \"%s\" must be a string, not a float.'",
",",
"$",
"amount",
")",
")",
";",
"}",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"amount",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The provided amount \"%s\" must be a valid string.'",
",",
"$",
"amount",
")",
")",
";",
"}",
"}"
] |
Ensures that the provided amount is a numeric string.
Prevents the passing of floats and strings that can't be
understood by bcmath (due to spaces or commas).
@param string $amount
@throws \CommerceGuys\Pricing\InvalidArgumentException
|
[
"Ensures",
"that",
"the",
"provided",
"amount",
"is",
"a",
"numeric",
"string",
"."
] |
55269e9603d28cf1de644f49d7af7c1d36b5864d
|
https://github.com/commerceguys/pricing/blob/55269e9603d28cf1de644f49d7af7c1d36b5864d/src/Price.php#L193-L201
|
222,741
|
commerceguys/pricing
|
src/Price.php
|
Price.newPrice
|
protected function newPrice($amount, $currency = null)
{
if (strpos($amount, '.') != FALSE) {
// The number is decimal, strip trailing zeroes.
// If no digits remain after the decimal point, strip it as well.
$amount = rtrim($amount, '0');
$amount = rtrim($amount, '.');
}
$currency = $currency ?: $this->currency;
return new static($amount, $currency);
}
|
php
|
protected function newPrice($amount, $currency = null)
{
if (strpos($amount, '.') != FALSE) {
// The number is decimal, strip trailing zeroes.
// If no digits remain after the decimal point, strip it as well.
$amount = rtrim($amount, '0');
$amount = rtrim($amount, '.');
}
$currency = $currency ?: $this->currency;
return new static($amount, $currency);
}
|
[
"protected",
"function",
"newPrice",
"(",
"$",
"amount",
",",
"$",
"currency",
"=",
"null",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"amount",
",",
"'.'",
")",
"!=",
"FALSE",
")",
"{",
"// The number is decimal, strip trailing zeroes.",
"// If no digits remain after the decimal point, strip it as well.",
"$",
"amount",
"=",
"rtrim",
"(",
"$",
"amount",
",",
"'0'",
")",
";",
"$",
"amount",
"=",
"rtrim",
"(",
"$",
"amount",
",",
"'.'",
")",
";",
"}",
"$",
"currency",
"=",
"$",
"currency",
"?",
":",
"$",
"this",
"->",
"currency",
";",
"return",
"new",
"static",
"(",
"$",
"amount",
",",
"$",
"currency",
")",
";",
"}"
] |
Creates a new Price instance using the provided amount.
Used in calculation methods to store the result in a new instance.
@param string $amount
@param \CommerceGuys\Intl\Currency\CurrencyInterface $currency
@return \CommerceGuys\Pricing\Price The new Price instance.
|
[
"Creates",
"a",
"new",
"Price",
"instance",
"using",
"the",
"provided",
"amount",
"."
] |
55269e9603d28cf1de644f49d7af7c1d36b5864d
|
https://github.com/commerceguys/pricing/blob/55269e9603d28cf1de644f49d7af7c1d36b5864d/src/Price.php#L213-L224
|
222,742
|
rtlopez/decimal
|
src/RtLopez/Decimal.php
|
Decimal.same
|
public function same($value = 0, $prec = null)
{
if($value instanceof $this && $value->prec == $this->prec && ($prec === null || $value->prec == $prec))
{
return $value;
}
$class = get_class($this);
return new $class($value, $prec);
}
|
php
|
public function same($value = 0, $prec = null)
{
if($value instanceof $this && $value->prec == $this->prec && ($prec === null || $value->prec == $prec))
{
return $value;
}
$class = get_class($this);
return new $class($value, $prec);
}
|
[
"public",
"function",
"same",
"(",
"$",
"value",
"=",
"0",
",",
"$",
"prec",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"$",
"this",
"&&",
"$",
"value",
"->",
"prec",
"==",
"$",
"this",
"->",
"prec",
"&&",
"(",
"$",
"prec",
"===",
"null",
"||",
"$",
"value",
"->",
"prec",
"==",
"$",
"prec",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"$",
"class",
"=",
"get_class",
"(",
"$",
"this",
")",
";",
"return",
"new",
"$",
"class",
"(",
"$",
"value",
",",
"$",
"prec",
")",
";",
"}"
] |
Make the same type object
@param number $value
@param string $prec
@return \RtLopez\Decimal
|
[
"Make",
"the",
"same",
"type",
"object"
] |
854e182c6023fb2ac6c7893a7ba4cade967f0c4c
|
https://github.com/rtlopez/decimal/blob/854e182c6023fb2ac6c7893a7ba4cade967f0c4c/src/RtLopez/Decimal.php#L61-L69
|
222,743
|
rtlopez/decimal
|
src/RtLopez/Decimal.php
|
Decimal.add
|
public function add($op)
{
$dst = clone $this;
$dst->value = $this->_fix($this->_add($this->same($op, $this->prec)));
return $dst;
}
|
php
|
public function add($op)
{
$dst = clone $this;
$dst->value = $this->_fix($this->_add($this->same($op, $this->prec)));
return $dst;
}
|
[
"public",
"function",
"add",
"(",
"$",
"op",
")",
"{",
"$",
"dst",
"=",
"clone",
"$",
"this",
";",
"$",
"dst",
"->",
"value",
"=",
"$",
"this",
"->",
"_fix",
"(",
"$",
"this",
"->",
"_add",
"(",
"$",
"this",
"->",
"same",
"(",
"$",
"op",
",",
"$",
"this",
"->",
"prec",
")",
")",
")",
";",
"return",
"$",
"dst",
";",
"}"
] |
Add two numbers
@param int|float|string|Decimal $op operand
@return Decimal
|
[
"Add",
"two",
"numbers"
] |
854e182c6023fb2ac6c7893a7ba4cade967f0c4c
|
https://github.com/rtlopez/decimal/blob/854e182c6023fb2ac6c7893a7ba4cade967f0c4c/src/RtLopez/Decimal.php#L159-L164
|
222,744
|
rtlopez/decimal
|
src/RtLopez/Decimal.php
|
Decimal.sub
|
public function sub($op)
{
$dst = clone $this;
$dst->value = $this->_fix($this->_sub($this->same($op, $this->prec)));
return $dst;
}
|
php
|
public function sub($op)
{
$dst = clone $this;
$dst->value = $this->_fix($this->_sub($this->same($op, $this->prec)));
return $dst;
}
|
[
"public",
"function",
"sub",
"(",
"$",
"op",
")",
"{",
"$",
"dst",
"=",
"clone",
"$",
"this",
";",
"$",
"dst",
"->",
"value",
"=",
"$",
"this",
"->",
"_fix",
"(",
"$",
"this",
"->",
"_sub",
"(",
"$",
"this",
"->",
"same",
"(",
"$",
"op",
",",
"$",
"this",
"->",
"prec",
")",
")",
")",
";",
"return",
"$",
"dst",
";",
"}"
] |
Substract two numbers
@param int|float|string|Decimal $op operand
@return Decimal
|
[
"Substract",
"two",
"numbers"
] |
854e182c6023fb2ac6c7893a7ba4cade967f0c4c
|
https://github.com/rtlopez/decimal/blob/854e182c6023fb2ac6c7893a7ba4cade967f0c4c/src/RtLopez/Decimal.php#L171-L176
|
222,745
|
rtlopez/decimal
|
src/RtLopez/Decimal.php
|
Decimal.mul
|
public function mul($op)
{
$dst = clone $this;
$dst->value = $this->_fix($this->_mul($this->same($op, $this->prec)));
return $dst;
}
|
php
|
public function mul($op)
{
$dst = clone $this;
$dst->value = $this->_fix($this->_mul($this->same($op, $this->prec)));
return $dst;
}
|
[
"public",
"function",
"mul",
"(",
"$",
"op",
")",
"{",
"$",
"dst",
"=",
"clone",
"$",
"this",
";",
"$",
"dst",
"->",
"value",
"=",
"$",
"this",
"->",
"_fix",
"(",
"$",
"this",
"->",
"_mul",
"(",
"$",
"this",
"->",
"same",
"(",
"$",
"op",
",",
"$",
"this",
"->",
"prec",
")",
")",
")",
";",
"return",
"$",
"dst",
";",
"}"
] |
Multiply two numbers
@param int|float|string|Decimal $op operand
@return Decimal
|
[
"Multiply",
"two",
"numbers"
] |
854e182c6023fb2ac6c7893a7ba4cade967f0c4c
|
https://github.com/rtlopez/decimal/blob/854e182c6023fb2ac6c7893a7ba4cade967f0c4c/src/RtLopez/Decimal.php#L183-L188
|
222,746
|
rtlopez/decimal
|
src/RtLopez/Decimal.php
|
Decimal.div
|
public function div($op)
{
$dst = clone $this;
$op = $this->same($op, $this->prec);
if($op->eq(0)) throw new ArithmeticException(sprintf('Division by zero (%s)', json_encode($op)));
$dst->value = $this->_fix($this->_div($op));
return $dst;
}
|
php
|
public function div($op)
{
$dst = clone $this;
$op = $this->same($op, $this->prec);
if($op->eq(0)) throw new ArithmeticException(sprintf('Division by zero (%s)', json_encode($op)));
$dst->value = $this->_fix($this->_div($op));
return $dst;
}
|
[
"public",
"function",
"div",
"(",
"$",
"op",
")",
"{",
"$",
"dst",
"=",
"clone",
"$",
"this",
";",
"$",
"op",
"=",
"$",
"this",
"->",
"same",
"(",
"$",
"op",
",",
"$",
"this",
"->",
"prec",
")",
";",
"if",
"(",
"$",
"op",
"->",
"eq",
"(",
"0",
")",
")",
"throw",
"new",
"ArithmeticException",
"(",
"sprintf",
"(",
"'Division by zero (%s)'",
",",
"json_encode",
"(",
"$",
"op",
")",
")",
")",
";",
"$",
"dst",
"->",
"value",
"=",
"$",
"this",
"->",
"_fix",
"(",
"$",
"this",
"->",
"_div",
"(",
"$",
"op",
")",
")",
";",
"return",
"$",
"dst",
";",
"}"
] |
Divide number by operand
@param int|float|string|Decimal $op operand
@return Decimal
|
[
"Divide",
"number",
"by",
"operand"
] |
854e182c6023fb2ac6c7893a7ba4cade967f0c4c
|
https://github.com/rtlopez/decimal/blob/854e182c6023fb2ac6c7893a7ba4cade967f0c4c/src/RtLopez/Decimal.php#L195-L202
|
222,747
|
rtlopez/decimal
|
src/RtLopez/Decimal.php
|
Decimal.mod
|
public function mod($op)
{
$dst = clone $this;
$op = $this->same($op, $this->prec)->truncate();
if($op->eq(0)) throw new ArithmeticException(sprintf('Division by zero (%s)', json_encode($op)));
$dst->value = $this->_fix($this->_mod($op));
return $dst;
}
|
php
|
public function mod($op)
{
$dst = clone $this;
$op = $this->same($op, $this->prec)->truncate();
if($op->eq(0)) throw new ArithmeticException(sprintf('Division by zero (%s)', json_encode($op)));
$dst->value = $this->_fix($this->_mod($op));
return $dst;
}
|
[
"public",
"function",
"mod",
"(",
"$",
"op",
")",
"{",
"$",
"dst",
"=",
"clone",
"$",
"this",
";",
"$",
"op",
"=",
"$",
"this",
"->",
"same",
"(",
"$",
"op",
",",
"$",
"this",
"->",
"prec",
")",
"->",
"truncate",
"(",
")",
";",
"if",
"(",
"$",
"op",
"->",
"eq",
"(",
"0",
")",
")",
"throw",
"new",
"ArithmeticException",
"(",
"sprintf",
"(",
"'Division by zero (%s)'",
",",
"json_encode",
"(",
"$",
"op",
")",
")",
")",
";",
"$",
"dst",
"->",
"value",
"=",
"$",
"this",
"->",
"_fix",
"(",
"$",
"this",
"->",
"_mod",
"(",
"$",
"op",
")",
")",
";",
"return",
"$",
"dst",
";",
"}"
] |
Module of division
@param int|float|string|Decimal $op operand
@return Decimal
|
[
"Module",
"of",
"division"
] |
854e182c6023fb2ac6c7893a7ba4cade967f0c4c
|
https://github.com/rtlopez/decimal/blob/854e182c6023fb2ac6c7893a7ba4cade967f0c4c/src/RtLopez/Decimal.php#L209-L216
|
222,748
|
rtlopez/decimal
|
src/RtLopez/Decimal.php
|
Decimal.pow
|
public function pow($op)
{
$dst = clone $this;
$op = $this->same($op, $this->prec)->truncate();
$dst->value = $this->_fix($this->_pow($op));
return $dst;
}
|
php
|
public function pow($op)
{
$dst = clone $this;
$op = $this->same($op, $this->prec)->truncate();
$dst->value = $this->_fix($this->_pow($op));
return $dst;
}
|
[
"public",
"function",
"pow",
"(",
"$",
"op",
")",
"{",
"$",
"dst",
"=",
"clone",
"$",
"this",
";",
"$",
"op",
"=",
"$",
"this",
"->",
"same",
"(",
"$",
"op",
",",
"$",
"this",
"->",
"prec",
")",
"->",
"truncate",
"(",
")",
";",
"$",
"dst",
"->",
"value",
"=",
"$",
"this",
"->",
"_fix",
"(",
"$",
"this",
"->",
"_pow",
"(",
"$",
"op",
")",
")",
";",
"return",
"$",
"dst",
";",
"}"
] |
Power of number
@note operand will be truncated first (cutted to integer)
@param int|float|string|Decimal $op operand
@return Decimal
|
[
"Power",
"of",
"number"
] |
854e182c6023fb2ac6c7893a7ba4cade967f0c4c
|
https://github.com/rtlopez/decimal/blob/854e182c6023fb2ac6c7893a7ba4cade967f0c4c/src/RtLopez/Decimal.php#L224-L230
|
222,749
|
rtlopez/decimal
|
src/RtLopez/Decimal.php
|
Decimal.sqrt
|
public function sqrt()
{
$dst = clone $this;
$dst->value = $this->_fix($this->_sqrt());
return $dst;
}
|
php
|
public function sqrt()
{
$dst = clone $this;
$dst->value = $this->_fix($this->_sqrt());
return $dst;
}
|
[
"public",
"function",
"sqrt",
"(",
")",
"{",
"$",
"dst",
"=",
"clone",
"$",
"this",
";",
"$",
"dst",
"->",
"value",
"=",
"$",
"this",
"->",
"_fix",
"(",
"$",
"this",
"->",
"_sqrt",
"(",
")",
")",
";",
"return",
"$",
"dst",
";",
"}"
] |
Square root of number
@param int|float|string|Decimal $op operand
@return Decimal
|
[
"Square",
"root",
"of",
"number"
] |
854e182c6023fb2ac6c7893a7ba4cade967f0c4c
|
https://github.com/rtlopez/decimal/blob/854e182c6023fb2ac6c7893a7ba4cade967f0c4c/src/RtLopez/Decimal.php#L237-L242
|
222,750
|
rtlopez/decimal
|
src/RtLopez/Decimal.php
|
Decimal.round
|
public function round($prec = 0)
{
$dst = clone $this;
$dst->value = $this->_round($this->value, $prec);
return $dst;
}
|
php
|
public function round($prec = 0)
{
$dst = clone $this;
$dst->value = $this->_round($this->value, $prec);
return $dst;
}
|
[
"public",
"function",
"round",
"(",
"$",
"prec",
"=",
"0",
")",
"{",
"$",
"dst",
"=",
"clone",
"$",
"this",
";",
"$",
"dst",
"->",
"value",
"=",
"$",
"this",
"->",
"_round",
"(",
"$",
"this",
"->",
"value",
",",
"$",
"prec",
")",
";",
"return",
"$",
"dst",
";",
"}"
] |
Round number with specific precision
@param int|float|string|Decimal $op operand
@return Decimal
|
[
"Round",
"number",
"with",
"specific",
"precision"
] |
854e182c6023fb2ac6c7893a7ba4cade967f0c4c
|
https://github.com/rtlopez/decimal/blob/854e182c6023fb2ac6c7893a7ba4cade967f0c4c/src/RtLopez/Decimal.php#L249-L254
|
222,751
|
rtlopez/decimal
|
src/RtLopez/Decimal.php
|
Decimal.ceil
|
public function ceil($prec = 0)
{
$dst = clone $this;
$dst->value = $this->_ceil($this->value, $prec);
return $dst;
}
|
php
|
public function ceil($prec = 0)
{
$dst = clone $this;
$dst->value = $this->_ceil($this->value, $prec);
return $dst;
}
|
[
"public",
"function",
"ceil",
"(",
"$",
"prec",
"=",
"0",
")",
"{",
"$",
"dst",
"=",
"clone",
"$",
"this",
";",
"$",
"dst",
"->",
"value",
"=",
"$",
"this",
"->",
"_ceil",
"(",
"$",
"this",
"->",
"value",
",",
"$",
"prec",
")",
";",
"return",
"$",
"dst",
";",
"}"
] |
Ceil number with specific precision
@param int|float|string|Decimal $op operand
@return Decimal
|
[
"Ceil",
"number",
"with",
"specific",
"precision"
] |
854e182c6023fb2ac6c7893a7ba4cade967f0c4c
|
https://github.com/rtlopez/decimal/blob/854e182c6023fb2ac6c7893a7ba4cade967f0c4c/src/RtLopez/Decimal.php#L261-L266
|
222,752
|
rtlopez/decimal
|
src/RtLopez/Decimal.php
|
Decimal.floor
|
public function floor($prec = 0)
{
$dst = clone $this;
$dst->value = $this->_floor($this->value, $prec);
return $dst;
}
|
php
|
public function floor($prec = 0)
{
$dst = clone $this;
$dst->value = $this->_floor($this->value, $prec);
return $dst;
}
|
[
"public",
"function",
"floor",
"(",
"$",
"prec",
"=",
"0",
")",
"{",
"$",
"dst",
"=",
"clone",
"$",
"this",
";",
"$",
"dst",
"->",
"value",
"=",
"$",
"this",
"->",
"_floor",
"(",
"$",
"this",
"->",
"value",
",",
"$",
"prec",
")",
";",
"return",
"$",
"dst",
";",
"}"
] |
Floor number with specific precision
@param int|float|string|Decimal $op operand
@return Decimal
|
[
"Floor",
"number",
"with",
"specific",
"precision"
] |
854e182c6023fb2ac6c7893a7ba4cade967f0c4c
|
https://github.com/rtlopez/decimal/blob/854e182c6023fb2ac6c7893a7ba4cade967f0c4c/src/RtLopez/Decimal.php#L273-L278
|
222,753
|
rtlopez/decimal
|
src/RtLopez/Decimal.php
|
Decimal.min
|
public function min($op)
{
$op = $this->same($op, $this->prec);
return $this->lt($op) ? clone $this : $op;
}
|
php
|
public function min($op)
{
$op = $this->same($op, $this->prec);
return $this->lt($op) ? clone $this : $op;
}
|
[
"public",
"function",
"min",
"(",
"$",
"op",
")",
"{",
"$",
"op",
"=",
"$",
"this",
"->",
"same",
"(",
"$",
"op",
",",
"$",
"this",
"->",
"prec",
")",
";",
"return",
"$",
"this",
"->",
"lt",
"(",
"$",
"op",
")",
"?",
"clone",
"$",
"this",
":",
"$",
"op",
";",
"}"
] |
Find the minimum of two numbers
@param int|float|string|Decimal $op operand
@return Decimal
|
[
"Find",
"the",
"minimum",
"of",
"two",
"numbers"
] |
854e182c6023fb2ac6c7893a7ba4cade967f0c4c
|
https://github.com/rtlopez/decimal/blob/854e182c6023fb2ac6c7893a7ba4cade967f0c4c/src/RtLopez/Decimal.php#L315-L319
|
222,754
|
rtlopez/decimal
|
src/RtLopez/Decimal.php
|
Decimal.max
|
public function max($op)
{
$op = $this->same($op, $this->prec);
return $this->gt($op) ? clone $this : $op;
}
|
php
|
public function max($op)
{
$op = $this->same($op, $this->prec);
return $this->gt($op) ? clone $this : $op;
}
|
[
"public",
"function",
"max",
"(",
"$",
"op",
")",
"{",
"$",
"op",
"=",
"$",
"this",
"->",
"same",
"(",
"$",
"op",
",",
"$",
"this",
"->",
"prec",
")",
";",
"return",
"$",
"this",
"->",
"gt",
"(",
"$",
"op",
")",
"?",
"clone",
"$",
"this",
":",
"$",
"op",
";",
"}"
] |
Find the maximum of two numbers
@param int|float|string|Decimal $op operand
@return Decimal
|
[
"Find",
"the",
"maximum",
"of",
"two",
"numbers"
] |
854e182c6023fb2ac6c7893a7ba4cade967f0c4c
|
https://github.com/rtlopez/decimal/blob/854e182c6023fb2ac6c7893a7ba4cade967f0c4c/src/RtLopez/Decimal.php#L326-L330
|
222,755
|
rtlopez/decimal
|
src/RtLopez/Decimal.php
|
Decimal.epsilon
|
public function epsilon()
{
$half = $this->same('0.5', $this->prec + 1);
$factor = $this->same('10', 0)->pow($this->prec);
return $half->div($factor);
}
|
php
|
public function epsilon()
{
$half = $this->same('0.5', $this->prec + 1);
$factor = $this->same('10', 0)->pow($this->prec);
return $half->div($factor);
}
|
[
"public",
"function",
"epsilon",
"(",
")",
"{",
"$",
"half",
"=",
"$",
"this",
"->",
"same",
"(",
"'0.5'",
",",
"$",
"this",
"->",
"prec",
"+",
"1",
")",
";",
"$",
"factor",
"=",
"$",
"this",
"->",
"same",
"(",
"'10'",
",",
"0",
")",
"->",
"pow",
"(",
"$",
"this",
"->",
"prec",
")",
";",
"return",
"$",
"half",
"->",
"div",
"(",
"$",
"factor",
")",
";",
"}"
] |
Calcualate epsilon for float comparision
@note returned precision is greater by one than original
@param int|float|string|Decimal $op operand
@return Decimal
|
[
"Calcualate",
"epsilon",
"for",
"float",
"comparision"
] |
854e182c6023fb2ac6c7893a7ba4cade967f0c4c
|
https://github.com/rtlopez/decimal/blob/854e182c6023fb2ac6c7893a7ba4cade967f0c4c/src/RtLopez/Decimal.php#L368-L373
|
222,756
|
xcaliber-tech/omnipay-skrill
|
src/Omnipay/Skrill/Message/PaymentRequest.php
|
PaymentRequest.setReturnUrlTarget
|
public function setReturnUrlTarget($value)
{
switch ($value) {
case '_top':
$value = 1;
break;
case '_parent':
$value = 2;
break;
case '_self':
$value = 3;
break;
case '_blank':
$value = 4;
break;
default:
$value = (int)$value;
}
return $this->setParameter('returnUrlTarget', $value);
}
|
php
|
public function setReturnUrlTarget($value)
{
switch ($value) {
case '_top':
$value = 1;
break;
case '_parent':
$value = 2;
break;
case '_self':
$value = 3;
break;
case '_blank':
$value = 4;
break;
default:
$value = (int)$value;
}
return $this->setParameter('returnUrlTarget', $value);
}
|
[
"public",
"function",
"setReturnUrlTarget",
"(",
"$",
"value",
")",
"{",
"switch",
"(",
"$",
"value",
")",
"{",
"case",
"'_top'",
":",
"$",
"value",
"=",
"1",
";",
"break",
";",
"case",
"'_parent'",
":",
"$",
"value",
"=",
"2",
";",
"break",
";",
"case",
"'_self'",
":",
"$",
"value",
"=",
"3",
";",
"break",
";",
"case",
"'_blank'",
":",
"$",
"value",
"=",
"4",
";",
"break",
";",
"default",
":",
"$",
"value",
"=",
"(",
"int",
")",
"$",
"value",
";",
"}",
"return",
"$",
"this",
"->",
"setParameter",
"(",
"'returnUrlTarget'",
",",
"$",
"value",
")",
";",
"}"
] |
Set the target in which the return url value is displayed upon successful payment
from the customer.
Default value is 1.
* 1 = _top
* 2 = _parent
* 3 = _self
* 4 = _blank
@param int $value return url target
@return $this
|
[
"Set",
"the",
"target",
"in",
"which",
"the",
"return",
"url",
"value",
"is",
"displayed",
"upon",
"successful",
"payment",
"from",
"the",
"customer",
"."
] |
f90a185b5e26fb5b4150d664f01ad8048b460bcf
|
https://github.com/xcaliber-tech/omnipay-skrill/blob/f90a185b5e26fb5b4150d664f01ad8048b460bcf/src/Omnipay/Skrill/Message/PaymentRequest.php#L155-L179
|
222,757
|
xcaliber-tech/omnipay-skrill
|
src/Omnipay/Skrill/Message/PaymentRequest.php
|
PaymentRequest.setCancelUrlTarget
|
public function setCancelUrlTarget($value)
{
switch ($value) {
case '_top':
$value = 1;
break;
case '_parent':
$value = 2;
break;
case '_self':
$value = 3;
break;
case '_blank':
$value = 4;
break;
default:
$value = (int)$value;
}
return $this->setParameter('cancelUrlTarget', $value);
}
|
php
|
public function setCancelUrlTarget($value)
{
switch ($value) {
case '_top':
$value = 1;
break;
case '_parent':
$value = 2;
break;
case '_self':
$value = 3;
break;
case '_blank':
$value = 4;
break;
default:
$value = (int)$value;
}
return $this->setParameter('cancelUrlTarget', $value);
}
|
[
"public",
"function",
"setCancelUrlTarget",
"(",
"$",
"value",
")",
"{",
"switch",
"(",
"$",
"value",
")",
"{",
"case",
"'_top'",
":",
"$",
"value",
"=",
"1",
";",
"break",
";",
"case",
"'_parent'",
":",
"$",
"value",
"=",
"2",
";",
"break",
";",
"case",
"'_self'",
":",
"$",
"value",
"=",
"3",
";",
"break",
";",
"case",
"'_blank'",
":",
"$",
"value",
"=",
"4",
";",
"break",
";",
"default",
":",
"$",
"value",
"=",
"(",
"int",
")",
"$",
"value",
";",
"}",
"return",
"$",
"this",
"->",
"setParameter",
"(",
"'cancelUrlTarget'",
",",
"$",
"value",
")",
";",
"}"
] |
Set the target in which the cancel url value is displayed upon cancellation of
payment by the customer.
Default value is 1.
* 1 = _top
* 2 = _parent
* 3 = _self
* 4 = _blank
@param int $value cancel url target
@return $this
|
[
"Set",
"the",
"target",
"in",
"which",
"the",
"cancel",
"url",
"value",
"is",
"displayed",
"upon",
"cancellation",
"of",
"payment",
"by",
"the",
"customer",
"."
] |
f90a185b5e26fb5b4150d664f01ad8048b460bcf
|
https://github.com/xcaliber-tech/omnipay-skrill/blob/f90a185b5e26fb5b4150d664f01ad8048b460bcf/src/Omnipay/Skrill/Message/PaymentRequest.php#L233-L257
|
222,758
|
FriendsOfOuro/geteventstore-php-core
|
src/EventStore.php
|
EventStore.navigateStreamFeed
|
public function navigateStreamFeed(StreamFeed $streamFeed, LinkRelation $relation): ?StreamFeed
{
$url = $streamFeed->getLinkUrl($relation);
if (empty($url)) {
return null;
}
return $this->readStreamFeed($url, $streamFeed->getEntryEmbedMode());
}
|
php
|
public function navigateStreamFeed(StreamFeed $streamFeed, LinkRelation $relation): ?StreamFeed
{
$url = $streamFeed->getLinkUrl($relation);
if (empty($url)) {
return null;
}
return $this->readStreamFeed($url, $streamFeed->getEntryEmbedMode());
}
|
[
"public",
"function",
"navigateStreamFeed",
"(",
"StreamFeed",
"$",
"streamFeed",
",",
"LinkRelation",
"$",
"relation",
")",
":",
"?",
"StreamFeed",
"{",
"$",
"url",
"=",
"$",
"streamFeed",
"->",
"getLinkUrl",
"(",
"$",
"relation",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"url",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"readStreamFeed",
"(",
"$",
"url",
",",
"$",
"streamFeed",
"->",
"getEntryEmbedMode",
"(",
")",
")",
";",
"}"
] |
Navigates a stream feed through link relations.
@param StreamFeed $streamFeed
@param LinkRelation $relation
@return StreamFeed|null
@throws StreamDeletedException
@throws StreamNotFoundException
|
[
"Navigates",
"a",
"stream",
"feed",
"through",
"link",
"relations",
"."
] |
76aac24ce7a688f8232f76ba24b3549222f20332
|
https://github.com/FriendsOfOuro/geteventstore-php-core/blob/76aac24ce7a688f8232f76ba24b3549222f20332/src/EventStore.php#L104-L113
|
222,759
|
FriendsOfOuro/geteventstore-php-core
|
src/EventStore.php
|
EventStore.openStreamFeed
|
public function openStreamFeed($streamName, EntryEmbedMode $embedMode = null): StreamFeed
{
$url = $this->getStreamUrl($streamName);
return $this->readStreamFeed($url, $embedMode);
}
|
php
|
public function openStreamFeed($streamName, EntryEmbedMode $embedMode = null): StreamFeed
{
$url = $this->getStreamUrl($streamName);
return $this->readStreamFeed($url, $embedMode);
}
|
[
"public",
"function",
"openStreamFeed",
"(",
"$",
"streamName",
",",
"EntryEmbedMode",
"$",
"embedMode",
"=",
"null",
")",
":",
"StreamFeed",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"getStreamUrl",
"(",
"$",
"streamName",
")",
";",
"return",
"$",
"this",
"->",
"readStreamFeed",
"(",
"$",
"url",
",",
"$",
"embedMode",
")",
";",
"}"
] |
Opens a stream feed for read and navigation.
@param string $streamName
@param EntryEmbedMode|null $embedMode
@return StreamFeed
@throws StreamDeletedException
@throws StreamNotFoundException
|
[
"Opens",
"a",
"stream",
"feed",
"for",
"read",
"and",
"navigation",
"."
] |
76aac24ce7a688f8232f76ba24b3549222f20332
|
https://github.com/FriendsOfOuro/geteventstore-php-core/blob/76aac24ce7a688f8232f76ba24b3549222f20332/src/EventStore.php#L126-L131
|
222,760
|
FriendsOfOuro/geteventstore-php-core
|
src/EventStore.php
|
EventStore.readEvent
|
public function readEvent($eventUrl): Event
{
$request = $this->getJsonRequest($eventUrl);
$this->sendRequest($request);
$this->ensureStatusCodeIsGood($eventUrl);
$jsonResponse = $this->lastResponseAsJson();
return $this->createEventFromResponseContent($jsonResponse['content']);
}
|
php
|
public function readEvent($eventUrl): Event
{
$request = $this->getJsonRequest($eventUrl);
$this->sendRequest($request);
$this->ensureStatusCodeIsGood($eventUrl);
$jsonResponse = $this->lastResponseAsJson();
return $this->createEventFromResponseContent($jsonResponse['content']);
}
|
[
"public",
"function",
"readEvent",
"(",
"$",
"eventUrl",
")",
":",
"Event",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"getJsonRequest",
"(",
"$",
"eventUrl",
")",
";",
"$",
"this",
"->",
"sendRequest",
"(",
"$",
"request",
")",
";",
"$",
"this",
"->",
"ensureStatusCodeIsGood",
"(",
"$",
"eventUrl",
")",
";",
"$",
"jsonResponse",
"=",
"$",
"this",
"->",
"lastResponseAsJson",
"(",
")",
";",
"return",
"$",
"this",
"->",
"createEventFromResponseContent",
"(",
"$",
"jsonResponse",
"[",
"'content'",
"]",
")",
";",
"}"
] |
Read a single event.
@param string $eventUrl
@return Event
@throws StreamDeletedException
@throws StreamNotFoundException
@throws UnauthorizedException
|
[
"Read",
"a",
"single",
"event",
"."
] |
76aac24ce7a688f8232f76ba24b3549222f20332
|
https://github.com/FriendsOfOuro/geteventstore-php-core/blob/76aac24ce7a688f8232f76ba24b3549222f20332/src/EventStore.php#L144-L154
|
222,761
|
FriendsOfOuro/geteventstore-php-core
|
src/EventStore.php
|
EventStore.readEventBatch
|
public function readEventBatch(array $eventUrls): array
{
$requests = array_map(
function ($eventUrl) {
return $this->getJsonRequest($eventUrl);
},
$eventUrls
);
$responses = $this->httpClient->sendRequestBatch($requests);
return array_map(
function ($response) {
$data = json_decode($response->getBody(), true);
if (!isset($data['content'])) {
return null;
}
return $this->createEventFromResponseContent(
$data['content']
);
},
$responses
);
}
|
php
|
public function readEventBatch(array $eventUrls): array
{
$requests = array_map(
function ($eventUrl) {
return $this->getJsonRequest($eventUrl);
},
$eventUrls
);
$responses = $this->httpClient->sendRequestBatch($requests);
return array_map(
function ($response) {
$data = json_decode($response->getBody(), true);
if (!isset($data['content'])) {
return null;
}
return $this->createEventFromResponseContent(
$data['content']
);
},
$responses
);
}
|
[
"public",
"function",
"readEventBatch",
"(",
"array",
"$",
"eventUrls",
")",
":",
"array",
"{",
"$",
"requests",
"=",
"array_map",
"(",
"function",
"(",
"$",
"eventUrl",
")",
"{",
"return",
"$",
"this",
"->",
"getJsonRequest",
"(",
"$",
"eventUrl",
")",
";",
"}",
",",
"$",
"eventUrls",
")",
";",
"$",
"responses",
"=",
"$",
"this",
"->",
"httpClient",
"->",
"sendRequestBatch",
"(",
"$",
"requests",
")",
";",
"return",
"array_map",
"(",
"function",
"(",
"$",
"response",
")",
"{",
"$",
"data",
"=",
"json_decode",
"(",
"$",
"response",
"->",
"getBody",
"(",
")",
",",
"true",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"data",
"[",
"'content'",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"createEventFromResponseContent",
"(",
"$",
"data",
"[",
"'content'",
"]",
")",
";",
"}",
",",
"$",
"responses",
")",
";",
"}"
] |
Reads a batch of events.
@param array $eventUrls
@return array
|
[
"Reads",
"a",
"batch",
"of",
"events",
"."
] |
76aac24ce7a688f8232f76ba24b3549222f20332
|
https://github.com/FriendsOfOuro/geteventstore-php-core/blob/76aac24ce7a688f8232f76ba24b3549222f20332/src/EventStore.php#L163-L187
|
222,762
|
FriendsOfOuro/geteventstore-php-core
|
src/EventStore.php
|
EventStore.extractStreamVersionFromLastResponse
|
private function extractStreamVersionFromLastResponse(string $streamUrl)
{
$locationHeaders = $this->getLastResponse()->getHeader('Location');
if (
!empty($locationHeaders[0])
&& 0 === strpos($locationHeaders[0], $streamUrl)
) {
$version = substr($locationHeaders[0], strlen($streamUrl));
return (int)trim($version, '/');
}
return false;
}
|
php
|
private function extractStreamVersionFromLastResponse(string $streamUrl)
{
$locationHeaders = $this->getLastResponse()->getHeader('Location');
if (
!empty($locationHeaders[0])
&& 0 === strpos($locationHeaders[0], $streamUrl)
) {
$version = substr($locationHeaders[0], strlen($streamUrl));
return (int)trim($version, '/');
}
return false;
}
|
[
"private",
"function",
"extractStreamVersionFromLastResponse",
"(",
"string",
"$",
"streamUrl",
")",
"{",
"$",
"locationHeaders",
"=",
"$",
"this",
"->",
"getLastResponse",
"(",
")",
"->",
"getHeader",
"(",
"'Location'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"locationHeaders",
"[",
"0",
"]",
")",
"&&",
"0",
"===",
"strpos",
"(",
"$",
"locationHeaders",
"[",
"0",
"]",
",",
"$",
"streamUrl",
")",
")",
"{",
"$",
"version",
"=",
"substr",
"(",
"$",
"locationHeaders",
"[",
"0",
"]",
",",
"strlen",
"(",
"$",
"streamUrl",
")",
")",
";",
"return",
"(",
"int",
")",
"trim",
"(",
"$",
"version",
",",
"'/'",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Extracts created version after writing to a stream.
The Event Store responds with a HTTP message containing a Location
header pointing to the newly created stream. This method extracts
the last part of that URI an returns the value.
http://127.0.0.1:2113/streams/newstream/13 -> 13
@param string $streamUrl
@return bool|int
|
[
"Extracts",
"created",
"version",
"after",
"writing",
"to",
"a",
"stream",
"."
] |
76aac24ce7a688f8232f76ba24b3549222f20332
|
https://github.com/FriendsOfOuro/geteventstore-php-core/blob/76aac24ce7a688f8232f76ba24b3549222f20332/src/EventStore.php#L398-L412
|
222,763
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Model/Observer.php
|
EcomDev_Varnish_Model_Observer.controllerActionPredispatch
|
public function controllerActionPredispatch(Varien_Event_Observer $observer)
{
if (!$this->_getHelper()->isActive()) {
return $this;
}
/* @var $controllerAction Mage_Core_Controller_Front_Action */
$controllerAction = $observer->getControllerAction();
$this->_getHelper()->setCurrentPage(
strtolower($controllerAction->getFullActionName('_'))
);
$surrogateCompatibility = $controllerAction->getRequest()->getServer('HTTP_SURROGATE_CAPABILITY', '');
if (strpos($surrogateCompatibility, 'ESI/') !== false) {
$this->_getHelper()->setIsEsiAllowed(true);
}
if ($this->_getHelper()->isAllowedCurrentPage()
|| $this->_getHelper()->getIsInternal()) {
// Disable ?__SID=U in urls
Mage::app()->setUseSessionVar(false);
Mage::app()->setUseSessionInUrl(false);
}
Mage::getSingleton('ecomdev_varnish/cookie')->setRequest($controllerAction->getRequest());
if ($token = $controllerAction->getRequest()->getParam('form_key')) {
if ($this->_getHelper()->validateToken($token)) {
Mage::getSingleton('core/session')->setData('_form_key', $token);
// After we set token, it is not valid anymore for next request, so we need to generate a new one
$this->_getHelper()->generateToken();
}
}
return $this;
}
|
php
|
public function controllerActionPredispatch(Varien_Event_Observer $observer)
{
if (!$this->_getHelper()->isActive()) {
return $this;
}
/* @var $controllerAction Mage_Core_Controller_Front_Action */
$controllerAction = $observer->getControllerAction();
$this->_getHelper()->setCurrentPage(
strtolower($controllerAction->getFullActionName('_'))
);
$surrogateCompatibility = $controllerAction->getRequest()->getServer('HTTP_SURROGATE_CAPABILITY', '');
if (strpos($surrogateCompatibility, 'ESI/') !== false) {
$this->_getHelper()->setIsEsiAllowed(true);
}
if ($this->_getHelper()->isAllowedCurrentPage()
|| $this->_getHelper()->getIsInternal()) {
// Disable ?__SID=U in urls
Mage::app()->setUseSessionVar(false);
Mage::app()->setUseSessionInUrl(false);
}
Mage::getSingleton('ecomdev_varnish/cookie')->setRequest($controllerAction->getRequest());
if ($token = $controllerAction->getRequest()->getParam('form_key')) {
if ($this->_getHelper()->validateToken($token)) {
Mage::getSingleton('core/session')->setData('_form_key', $token);
// After we set token, it is not valid anymore for next request, so we need to generate a new one
$this->_getHelper()->generateToken();
}
}
return $this;
}
|
[
"public",
"function",
"controllerActionPredispatch",
"(",
"Varien_Event_Observer",
"$",
"observer",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_getHelper",
"(",
")",
"->",
"isActive",
"(",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"/* @var $controllerAction Mage_Core_Controller_Front_Action */",
"$",
"controllerAction",
"=",
"$",
"observer",
"->",
"getControllerAction",
"(",
")",
";",
"$",
"this",
"->",
"_getHelper",
"(",
")",
"->",
"setCurrentPage",
"(",
"strtolower",
"(",
"$",
"controllerAction",
"->",
"getFullActionName",
"(",
"'_'",
")",
")",
")",
";",
"$",
"surrogateCompatibility",
"=",
"$",
"controllerAction",
"->",
"getRequest",
"(",
")",
"->",
"getServer",
"(",
"'HTTP_SURROGATE_CAPABILITY'",
",",
"''",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"surrogateCompatibility",
",",
"'ESI/'",
")",
"!==",
"false",
")",
"{",
"$",
"this",
"->",
"_getHelper",
"(",
")",
"->",
"setIsEsiAllowed",
"(",
"true",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"_getHelper",
"(",
")",
"->",
"isAllowedCurrentPage",
"(",
")",
"||",
"$",
"this",
"->",
"_getHelper",
"(",
")",
"->",
"getIsInternal",
"(",
")",
")",
"{",
"// Disable ?__SID=U in urls",
"Mage",
"::",
"app",
"(",
")",
"->",
"setUseSessionVar",
"(",
"false",
")",
";",
"Mage",
"::",
"app",
"(",
")",
"->",
"setUseSessionInUrl",
"(",
"false",
")",
";",
"}",
"Mage",
"::",
"getSingleton",
"(",
"'ecomdev_varnish/cookie'",
")",
"->",
"setRequest",
"(",
"$",
"controllerAction",
"->",
"getRequest",
"(",
")",
")",
";",
"if",
"(",
"$",
"token",
"=",
"$",
"controllerAction",
"->",
"getRequest",
"(",
")",
"->",
"getParam",
"(",
"'form_key'",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_getHelper",
"(",
")",
"->",
"validateToken",
"(",
"$",
"token",
")",
")",
"{",
"Mage",
"::",
"getSingleton",
"(",
"'core/session'",
")",
"->",
"setData",
"(",
"'_form_key'",
",",
"$",
"token",
")",
";",
"// After we set token, it is not valid anymore for next request, so we need to generate a new one",
"$",
"this",
"->",
"_getHelper",
"(",
")",
"->",
"generateToken",
"(",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Sets the current page on pre dispatch
@param Varien_Event_Observer $observer
@return $this
|
[
"Sets",
"the",
"current",
"page",
"on",
"pre",
"dispatch"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Model/Observer.php#L78-L115
|
222,764
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Model/Observer.php
|
EcomDev_Varnish_Model_Observer.controllerActionLayoutLoadBefore
|
public function controllerActionLayoutLoadBefore(Varien_Event_Observer $observer)
{
if (!$this->_getHelper()->isActive()) {
return;
}
$updateModel = $observer->getLayout()->getUpdate();
$handles = $updateModel->getHandles();
$allowedEsi = $this->_getHelper()->getIsEsiAllowed();
foreach ($handles as $handle) {
if ($handle == 'customer_logged_in'
&& !$this->_getHelper()->getIsInternal()) {
$updateModel->removeHandle($handle);
// Emulate always guest session
$updateModel->addHandle('customer_logged_out');
}
if ($handle == 'default' && !$this->_getHelper()->getIsInternal()) {
$updateModel->addHandle('default_varnish');
}
if ($allowedEsi && strtolower($handle) === $handle) {
// Add handle only if handle is not starting from UPPERCASE code
$updateModel->addHandle($handle . '_esi');
}
}
}
|
php
|
public function controllerActionLayoutLoadBefore(Varien_Event_Observer $observer)
{
if (!$this->_getHelper()->isActive()) {
return;
}
$updateModel = $observer->getLayout()->getUpdate();
$handles = $updateModel->getHandles();
$allowedEsi = $this->_getHelper()->getIsEsiAllowed();
foreach ($handles as $handle) {
if ($handle == 'customer_logged_in'
&& !$this->_getHelper()->getIsInternal()) {
$updateModel->removeHandle($handle);
// Emulate always guest session
$updateModel->addHandle('customer_logged_out');
}
if ($handle == 'default' && !$this->_getHelper()->getIsInternal()) {
$updateModel->addHandle('default_varnish');
}
if ($allowedEsi && strtolower($handle) === $handle) {
// Add handle only if handle is not starting from UPPERCASE code
$updateModel->addHandle($handle . '_esi');
}
}
}
|
[
"public",
"function",
"controllerActionLayoutLoadBefore",
"(",
"Varien_Event_Observer",
"$",
"observer",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_getHelper",
"(",
")",
"->",
"isActive",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"updateModel",
"=",
"$",
"observer",
"->",
"getLayout",
"(",
")",
"->",
"getUpdate",
"(",
")",
";",
"$",
"handles",
"=",
"$",
"updateModel",
"->",
"getHandles",
"(",
")",
";",
"$",
"allowedEsi",
"=",
"$",
"this",
"->",
"_getHelper",
"(",
")",
"->",
"getIsEsiAllowed",
"(",
")",
";",
"foreach",
"(",
"$",
"handles",
"as",
"$",
"handle",
")",
"{",
"if",
"(",
"$",
"handle",
"==",
"'customer_logged_in'",
"&&",
"!",
"$",
"this",
"->",
"_getHelper",
"(",
")",
"->",
"getIsInternal",
"(",
")",
")",
"{",
"$",
"updateModel",
"->",
"removeHandle",
"(",
"$",
"handle",
")",
";",
"// Emulate always guest session",
"$",
"updateModel",
"->",
"addHandle",
"(",
"'customer_logged_out'",
")",
";",
"}",
"if",
"(",
"$",
"handle",
"==",
"'default'",
"&&",
"!",
"$",
"this",
"->",
"_getHelper",
"(",
")",
"->",
"getIsInternal",
"(",
")",
")",
"{",
"$",
"updateModel",
"->",
"addHandle",
"(",
"'default_varnish'",
")",
";",
"}",
"if",
"(",
"$",
"allowedEsi",
"&&",
"strtolower",
"(",
"$",
"handle",
")",
"===",
"$",
"handle",
")",
"{",
"// Add handle only if handle is not starting from UPPERCASE code",
"$",
"updateModel",
"->",
"addHandle",
"(",
"$",
"handle",
".",
"'_esi'",
")",
";",
"}",
"}",
"}"
] |
Adds ESI to the layout cache
|
[
"Adds",
"ESI",
"to",
"the",
"layout",
"cache"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Model/Observer.php#L121-L147
|
222,765
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Model/Observer.php
|
EcomDev_Varnish_Model_Observer._addResponseHeaders
|
protected function _addResponseHeaders($controllerAction)
{
if ($this->_getHelper()->isDebug()) {
$controllerAction->getResponse()->setHeader('X-Debug', '1');
}
if ($this->_getHelper()->getIsEsiUsed()) {
$controllerAction->getResponse()->setHeader(
'Surrogate-Control', 'key=ESI/1.0'
);
}
if (!$this->_getHelper()->isAllowedCurrentPage()) {
$this->performBan();
} else {
if ($ttl = $this->_getHelper()->getCurrentPageTtl()) {
$this->_getHelper()->addTtl($ttl);
}
foreach ($this->_collectedObjects as $object) {
$this->_getHelper()->addObjectTags(
$this->_getProcessor()->getTags($object)
);
}
$this->_collectedObjects = array();
}
if ($controllerAction->getResponse()->canSendHeaders()) {
foreach (Mage::helper('ecomdev_varnish')->getVarnishHeaders(
!$this->_getHelper()->isAllowedCurrentPage()
) as $name => $value) {
if (is_array($value)) {
foreach ($value as $val) {
$controllerAction->getResponse()->setHeader($name, $val);
}
} else {
$controllerAction->getResponse()->setHeader($name, $value, true);
}
}
}
return $this;
}
|
php
|
protected function _addResponseHeaders($controllerAction)
{
if ($this->_getHelper()->isDebug()) {
$controllerAction->getResponse()->setHeader('X-Debug', '1');
}
if ($this->_getHelper()->getIsEsiUsed()) {
$controllerAction->getResponse()->setHeader(
'Surrogate-Control', 'key=ESI/1.0'
);
}
if (!$this->_getHelper()->isAllowedCurrentPage()) {
$this->performBan();
} else {
if ($ttl = $this->_getHelper()->getCurrentPageTtl()) {
$this->_getHelper()->addTtl($ttl);
}
foreach ($this->_collectedObjects as $object) {
$this->_getHelper()->addObjectTags(
$this->_getProcessor()->getTags($object)
);
}
$this->_collectedObjects = array();
}
if ($controllerAction->getResponse()->canSendHeaders()) {
foreach (Mage::helper('ecomdev_varnish')->getVarnishHeaders(
!$this->_getHelper()->isAllowedCurrentPage()
) as $name => $value) {
if (is_array($value)) {
foreach ($value as $val) {
$controllerAction->getResponse()->setHeader($name, $val);
}
} else {
$controllerAction->getResponse()->setHeader($name, $value, true);
}
}
}
return $this;
}
|
[
"protected",
"function",
"_addResponseHeaders",
"(",
"$",
"controllerAction",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_getHelper",
"(",
")",
"->",
"isDebug",
"(",
")",
")",
"{",
"$",
"controllerAction",
"->",
"getResponse",
"(",
")",
"->",
"setHeader",
"(",
"'X-Debug'",
",",
"'1'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"_getHelper",
"(",
")",
"->",
"getIsEsiUsed",
"(",
")",
")",
"{",
"$",
"controllerAction",
"->",
"getResponse",
"(",
")",
"->",
"setHeader",
"(",
"'Surrogate-Control'",
",",
"'key=ESI/1.0'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"_getHelper",
"(",
")",
"->",
"isAllowedCurrentPage",
"(",
")",
")",
"{",
"$",
"this",
"->",
"performBan",
"(",
")",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"ttl",
"=",
"$",
"this",
"->",
"_getHelper",
"(",
")",
"->",
"getCurrentPageTtl",
"(",
")",
")",
"{",
"$",
"this",
"->",
"_getHelper",
"(",
")",
"->",
"addTtl",
"(",
"$",
"ttl",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"_collectedObjects",
"as",
"$",
"object",
")",
"{",
"$",
"this",
"->",
"_getHelper",
"(",
")",
"->",
"addObjectTags",
"(",
"$",
"this",
"->",
"_getProcessor",
"(",
")",
"->",
"getTags",
"(",
"$",
"object",
")",
")",
";",
"}",
"$",
"this",
"->",
"_collectedObjects",
"=",
"array",
"(",
")",
";",
"}",
"if",
"(",
"$",
"controllerAction",
"->",
"getResponse",
"(",
")",
"->",
"canSendHeaders",
"(",
")",
")",
"{",
"foreach",
"(",
"Mage",
"::",
"helper",
"(",
"'ecomdev_varnish'",
")",
"->",
"getVarnishHeaders",
"(",
"!",
"$",
"this",
"->",
"_getHelper",
"(",
")",
"->",
"isAllowedCurrentPage",
"(",
")",
")",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"foreach",
"(",
"$",
"value",
"as",
"$",
"val",
")",
"{",
"$",
"controllerAction",
"->",
"getResponse",
"(",
")",
"->",
"setHeader",
"(",
"$",
"name",
",",
"$",
"val",
")",
";",
"}",
"}",
"else",
"{",
"$",
"controllerAction",
"->",
"getResponse",
"(",
")",
"->",
"setHeader",
"(",
"$",
"name",
",",
"$",
"value",
",",
"true",
")",
";",
"}",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Adds varnish response headers
@param Mage_Core_Controller_Front_Action $controllerAction
@return $this
|
[
"Adds",
"varnish",
"response",
"headers"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Model/Observer.php#L167-L213
|
222,766
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Model/Observer.php
|
EcomDev_Varnish_Model_Observer.controllerActionPostdispatch
|
public function controllerActionPostdispatch(Varien_Event_Observer $observer)
{
if (!$this->_getHelper()->isActive()) {
return;
}
/* @var $controllerAction Mage_Core_Controller_Front_Action */
$controllerAction = $observer->getControllerAction();
if (!Mage::app()->getStore()->isAdmin()
&& $controllerAction->getResponse()->canSendHeaders(false)) {
if (!$controllerAction->getRequest()->getHeader('X-Esi-Include')) {
$this->_addCookies();
}
$this->_addResponseHeaders($controllerAction);
}
return $this;
}
|
php
|
public function controllerActionPostdispatch(Varien_Event_Observer $observer)
{
if (!$this->_getHelper()->isActive()) {
return;
}
/* @var $controllerAction Mage_Core_Controller_Front_Action */
$controllerAction = $observer->getControllerAction();
if (!Mage::app()->getStore()->isAdmin()
&& $controllerAction->getResponse()->canSendHeaders(false)) {
if (!$controllerAction->getRequest()->getHeader('X-Esi-Include')) {
$this->_addCookies();
}
$this->_addResponseHeaders($controllerAction);
}
return $this;
}
|
[
"public",
"function",
"controllerActionPostdispatch",
"(",
"Varien_Event_Observer",
"$",
"observer",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_getHelper",
"(",
")",
"->",
"isActive",
"(",
")",
")",
"{",
"return",
";",
"}",
"/* @var $controllerAction Mage_Core_Controller_Front_Action */",
"$",
"controllerAction",
"=",
"$",
"observer",
"->",
"getControllerAction",
"(",
")",
";",
"if",
"(",
"!",
"Mage",
"::",
"app",
"(",
")",
"->",
"getStore",
"(",
")",
"->",
"isAdmin",
"(",
")",
"&&",
"$",
"controllerAction",
"->",
"getResponse",
"(",
")",
"->",
"canSendHeaders",
"(",
"false",
")",
")",
"{",
"if",
"(",
"!",
"$",
"controllerAction",
"->",
"getRequest",
"(",
")",
"->",
"getHeader",
"(",
"'X-Esi-Include'",
")",
")",
"{",
"$",
"this",
"->",
"_addCookies",
"(",
")",
";",
"}",
"$",
"this",
"->",
"_addResponseHeaders",
"(",
"$",
"controllerAction",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Observes all controller post dispatches
@param Varien_Event_Observer $observer
@return $this
|
[
"Observes",
"all",
"controller",
"post",
"dispatches"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Model/Observer.php#L221-L241
|
222,767
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Model/Observer.php
|
EcomDev_Varnish_Model_Observer.performBan
|
public function performBan()
{
if (!$this->_getHelper()->isActive()) {
return $this;
}
$tagsToBan = array_unique($this->_getProcessor()->getTagsToBan());
if ($tagsToBan) {
try {
$tagsToBan = array_map(
array(Mage::helper('ecomdev_varnish'), 'formatObjectTag'),
$tagsToBan
);
$queue = Mage::app()->getCache()->load(self::VARNISH_CACHE_QUEUE, true);
if ($queue) {
$queue = unserialize($queue);
foreach ($tagsToBan as $tag) {
$queue[] = $tag;
}
} else {
$queue = $tagsToBan;
}
$queue = serialize($queue);
Mage::app()->getCache()->save($queue, self::VARNISH_CACHE_QUEUE);
} catch (Exception $e) {
Mage::logException($e);
}
}
return $this;
}
|
php
|
public function performBan()
{
if (!$this->_getHelper()->isActive()) {
return $this;
}
$tagsToBan = array_unique($this->_getProcessor()->getTagsToBan());
if ($tagsToBan) {
try {
$tagsToBan = array_map(
array(Mage::helper('ecomdev_varnish'), 'formatObjectTag'),
$tagsToBan
);
$queue = Mage::app()->getCache()->load(self::VARNISH_CACHE_QUEUE, true);
if ($queue) {
$queue = unserialize($queue);
foreach ($tagsToBan as $tag) {
$queue[] = $tag;
}
} else {
$queue = $tagsToBan;
}
$queue = serialize($queue);
Mage::app()->getCache()->save($queue, self::VARNISH_CACHE_QUEUE);
} catch (Exception $e) {
Mage::logException($e);
}
}
return $this;
}
|
[
"public",
"function",
"performBan",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_getHelper",
"(",
")",
"->",
"isActive",
"(",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"tagsToBan",
"=",
"array_unique",
"(",
"$",
"this",
"->",
"_getProcessor",
"(",
")",
"->",
"getTagsToBan",
"(",
")",
")",
";",
"if",
"(",
"$",
"tagsToBan",
")",
"{",
"try",
"{",
"$",
"tagsToBan",
"=",
"array_map",
"(",
"array",
"(",
"Mage",
"::",
"helper",
"(",
"'ecomdev_varnish'",
")",
",",
"'formatObjectTag'",
")",
",",
"$",
"tagsToBan",
")",
";",
"$",
"queue",
"=",
"Mage",
"::",
"app",
"(",
")",
"->",
"getCache",
"(",
")",
"->",
"load",
"(",
"self",
"::",
"VARNISH_CACHE_QUEUE",
",",
"true",
")",
";",
"if",
"(",
"$",
"queue",
")",
"{",
"$",
"queue",
"=",
"unserialize",
"(",
"$",
"queue",
")",
";",
"foreach",
"(",
"$",
"tagsToBan",
"as",
"$",
"tag",
")",
"{",
"$",
"queue",
"[",
"]",
"=",
"$",
"tag",
";",
"}",
"}",
"else",
"{",
"$",
"queue",
"=",
"$",
"tagsToBan",
";",
"}",
"$",
"queue",
"=",
"serialize",
"(",
"$",
"queue",
")",
";",
"Mage",
"::",
"app",
"(",
")",
"->",
"getCache",
"(",
")",
"->",
"save",
"(",
"$",
"queue",
",",
"self",
"::",
"VARNISH_CACHE_QUEUE",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"Mage",
"::",
"logException",
"(",
"$",
"e",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Performs Varnish BAN of object tags, if they exists
|
[
"Performs",
"Varnish",
"BAN",
"of",
"object",
"tags",
"if",
"they",
"exists"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Model/Observer.php#L246-L280
|
222,768
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Model/Observer.php
|
EcomDev_Varnish_Model_Observer.backgroundBan
|
public function backgroundBan()
{
$queue = Mage::app()->getCache()->load(self::VARNISH_CACHE_QUEUE, true);
if ($queue) {
$queue = unserialize($queue);
// Run cleaning process separately if amount of stored tags too large
$chunks = array_chunk(
$queue,
500
);
foreach ($chunks as $tags) {
Mage::getSingleton('ecomdev_varnish/connector')->banTags($tags);
}
Mage::app()->getCache()->remove(self::VARNISH_CACHE_QUEUE);
}
}
|
php
|
public function backgroundBan()
{
$queue = Mage::app()->getCache()->load(self::VARNISH_CACHE_QUEUE, true);
if ($queue) {
$queue = unserialize($queue);
// Run cleaning process separately if amount of stored tags too large
$chunks = array_chunk(
$queue,
500
);
foreach ($chunks as $tags) {
Mage::getSingleton('ecomdev_varnish/connector')->banTags($tags);
}
Mage::app()->getCache()->remove(self::VARNISH_CACHE_QUEUE);
}
}
|
[
"public",
"function",
"backgroundBan",
"(",
")",
"{",
"$",
"queue",
"=",
"Mage",
"::",
"app",
"(",
")",
"->",
"getCache",
"(",
")",
"->",
"load",
"(",
"self",
"::",
"VARNISH_CACHE_QUEUE",
",",
"true",
")",
";",
"if",
"(",
"$",
"queue",
")",
"{",
"$",
"queue",
"=",
"unserialize",
"(",
"$",
"queue",
")",
";",
"// Run cleaning process separately if amount of stored tags too large",
"$",
"chunks",
"=",
"array_chunk",
"(",
"$",
"queue",
",",
"500",
")",
";",
"foreach",
"(",
"$",
"chunks",
"as",
"$",
"tags",
")",
"{",
"Mage",
"::",
"getSingleton",
"(",
"'ecomdev_varnish/connector'",
")",
"->",
"banTags",
"(",
"$",
"tags",
")",
";",
"}",
"Mage",
"::",
"app",
"(",
")",
"->",
"getCache",
"(",
")",
"->",
"remove",
"(",
"self",
"::",
"VARNISH_CACHE_QUEUE",
")",
";",
"}",
"}"
] |
Background clean up of the cache tags
|
[
"Background",
"clean",
"up",
"of",
"the",
"cache",
"tags"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Model/Observer.php#L286-L304
|
222,769
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Model/Observer.php
|
EcomDev_Varnish_Model_Observer.coreBlockAbstractToHtmlAfter
|
public function coreBlockAbstractToHtmlAfter(Varien_Event_Observer $observer)
{
if (!$this->_getHelper()->isAllowedCurrentPage()) {
return $this;
}
$block = $observer->getBlock();
$objects = $this->_getCollector()->collect($block);
array_splice($this->_collectedObjects, count($this->_collectedObjects), 0, $objects);
return $this;
}
|
php
|
public function coreBlockAbstractToHtmlAfter(Varien_Event_Observer $observer)
{
if (!$this->_getHelper()->isAllowedCurrentPage()) {
return $this;
}
$block = $observer->getBlock();
$objects = $this->_getCollector()->collect($block);
array_splice($this->_collectedObjects, count($this->_collectedObjects), 0, $objects);
return $this;
}
|
[
"public",
"function",
"coreBlockAbstractToHtmlAfter",
"(",
"Varien_Event_Observer",
"$",
"observer",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_getHelper",
"(",
")",
"->",
"isAllowedCurrentPage",
"(",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"block",
"=",
"$",
"observer",
"->",
"getBlock",
"(",
")",
";",
"$",
"objects",
"=",
"$",
"this",
"->",
"_getCollector",
"(",
")",
"->",
"collect",
"(",
"$",
"block",
")",
";",
"array_splice",
"(",
"$",
"this",
"->",
"_collectedObjects",
",",
"count",
"(",
"$",
"this",
"->",
"_collectedObjects",
")",
",",
"0",
",",
"$",
"objects",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Checks what have been rendered via collectors for passing data later on to processors
@param Varien_Event_Observer $observer
@return $this
|
[
"Checks",
"what",
"have",
"been",
"rendered",
"via",
"collectors",
"for",
"passing",
"data",
"later",
"on",
"to",
"processors"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Model/Observer.php#L312-L322
|
222,770
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Model/Observer.php
|
EcomDev_Varnish_Model_Observer.updateMessageBlock
|
public function updateMessageBlock(Varien_Event_Observer $observer)
{
$block = $observer->getBlock();
if ($block instanceof Mage_Core_Block_Messages
&& !($block instanceof EcomDev_Varnish_Block_MessagesInterface)) {
if (!$this->_getHelper()->isAllowedCurrentPage()) {
return $this;
}
// Add missing core session messages to our message model
Mage::getSingleton('ecomdev_varnish/message')->addMessages(
$block->getMessages(), 'core/session'
);
}
return $this;
}
|
php
|
public function updateMessageBlock(Varien_Event_Observer $observer)
{
$block = $observer->getBlock();
if ($block instanceof Mage_Core_Block_Messages
&& !($block instanceof EcomDev_Varnish_Block_MessagesInterface)) {
if (!$this->_getHelper()->isAllowedCurrentPage()) {
return $this;
}
// Add missing core session messages to our message model
Mage::getSingleton('ecomdev_varnish/message')->addMessages(
$block->getMessages(), 'core/session'
);
}
return $this;
}
|
[
"public",
"function",
"updateMessageBlock",
"(",
"Varien_Event_Observer",
"$",
"observer",
")",
"{",
"$",
"block",
"=",
"$",
"observer",
"->",
"getBlock",
"(",
")",
";",
"if",
"(",
"$",
"block",
"instanceof",
"Mage_Core_Block_Messages",
"&&",
"!",
"(",
"$",
"block",
"instanceof",
"EcomDev_Varnish_Block_MessagesInterface",
")",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_getHelper",
"(",
")",
"->",
"isAllowedCurrentPage",
"(",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"// Add missing core session messages to our message model",
"Mage",
"::",
"getSingleton",
"(",
"'ecomdev_varnish/message'",
")",
"->",
"addMessages",
"(",
"$",
"block",
"->",
"getMessages",
"(",
")",
",",
"'core/session'",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Updates message block
@param Varien_Event_Observer $observer
@return $this
|
[
"Updates",
"message",
"block"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Model/Observer.php#L366-L382
|
222,771
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Model/Customer/Observer.php
|
EcomDev_Varnish_Model_Customer_Observer.setCardCookie
|
public function setCardCookie($observer)
{
$quoteData = $observer->getQuote()->debug();
unset($quoteData['updated_at']);
$this->setCookies(array(
self::COOKIE_CART => $this->_hashData($quoteData),
self::COOKIE_SEGMENT => $this->_hashData($this->_getHelper()->getCustomerSegment())
));
}
|
php
|
public function setCardCookie($observer)
{
$quoteData = $observer->getQuote()->debug();
unset($quoteData['updated_at']);
$this->setCookies(array(
self::COOKIE_CART => $this->_hashData($quoteData),
self::COOKIE_SEGMENT => $this->_hashData($this->_getHelper()->getCustomerSegment())
));
}
|
[
"public",
"function",
"setCardCookie",
"(",
"$",
"observer",
")",
"{",
"$",
"quoteData",
"=",
"$",
"observer",
"->",
"getQuote",
"(",
")",
"->",
"debug",
"(",
")",
";",
"unset",
"(",
"$",
"quoteData",
"[",
"'updated_at'",
"]",
")",
";",
"$",
"this",
"->",
"setCookies",
"(",
"array",
"(",
"self",
"::",
"COOKIE_CART",
"=>",
"$",
"this",
"->",
"_hashData",
"(",
"$",
"quoteData",
")",
",",
"self",
"::",
"COOKIE_SEGMENT",
"=>",
"$",
"this",
"->",
"_hashData",
"(",
"$",
"this",
"->",
"_getHelper",
"(",
")",
"->",
"getCustomerSegment",
"(",
")",
")",
")",
")",
";",
"}"
] |
Sets card cookie
@param Varien_Event_Observer $observer
|
[
"Sets",
"card",
"cookie"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Model/Customer/Observer.php#L56-L64
|
222,772
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Model/Customer/Observer.php
|
EcomDev_Varnish_Model_Customer_Observer.setLoginCookie
|
public function setLoginCookie()
{
$this->setCookies(array(
self::COOKIE_CART => $this->_hashData(Varien_Date::now()),
self::COOKIE_SEGMENT => $this->_hashData($this->_getHelper()->getCustomerSegment()),
self::COOKIE_CUSTOMER => $this->_hashData(Varien_Date::now()),
self::COOKIE_IS_LOGGED_IN => 1
));
}
|
php
|
public function setLoginCookie()
{
$this->setCookies(array(
self::COOKIE_CART => $this->_hashData(Varien_Date::now()),
self::COOKIE_SEGMENT => $this->_hashData($this->_getHelper()->getCustomerSegment()),
self::COOKIE_CUSTOMER => $this->_hashData(Varien_Date::now()),
self::COOKIE_IS_LOGGED_IN => 1
));
}
|
[
"public",
"function",
"setLoginCookie",
"(",
")",
"{",
"$",
"this",
"->",
"setCookies",
"(",
"array",
"(",
"self",
"::",
"COOKIE_CART",
"=>",
"$",
"this",
"->",
"_hashData",
"(",
"Varien_Date",
"::",
"now",
"(",
")",
")",
",",
"self",
"::",
"COOKIE_SEGMENT",
"=>",
"$",
"this",
"->",
"_hashData",
"(",
"$",
"this",
"->",
"_getHelper",
"(",
")",
"->",
"getCustomerSegment",
"(",
")",
")",
",",
"self",
"::",
"COOKIE_CUSTOMER",
"=>",
"$",
"this",
"->",
"_hashData",
"(",
"Varien_Date",
"::",
"now",
"(",
")",
")",
",",
"self",
"::",
"COOKIE_IS_LOGGED_IN",
"=>",
"1",
")",
")",
";",
"}"
] |
Sets login cookie
|
[
"Sets",
"login",
"cookie"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Model/Customer/Observer.php#L77-L85
|
222,773
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Block/Js/Wrapper.php
|
EcomDev_Varnish_Block_Js_Wrapper.setBlockName
|
public function setBlockName($blockName)
{
$this->setData('block_name', $blockName);
$this->append($this->getLayout()->getBlock($blockName));
return $this;
}
|
php
|
public function setBlockName($blockName)
{
$this->setData('block_name', $blockName);
$this->append($this->getLayout()->getBlock($blockName));
return $this;
}
|
[
"public",
"function",
"setBlockName",
"(",
"$",
"blockName",
")",
"{",
"$",
"this",
"->",
"setData",
"(",
"'block_name'",
",",
"$",
"blockName",
")",
";",
"$",
"this",
"->",
"append",
"(",
"$",
"this",
"->",
"getLayout",
"(",
")",
"->",
"getBlock",
"(",
"$",
"blockName",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets block name
@param string $blockName
@return $this
|
[
"Sets",
"block",
"name"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Block/Js/Wrapper.php#L34-L39
|
222,774
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Block/Js/Wrapper.php
|
EcomDev_Varnish_Block_Js_Wrapper.setAdditionalCookie
|
public function setAdditionalCookie($cookie, $expectedValue = false)
{
$additionalCookie = $this->_getData('_additional_cookie');
if (!$additionalCookie || !is_array($additionalCookie)) {
$additionalCookie = array();
}
$additionalCookie[$cookie] = $expectedValue;
$this->setData('_additional_cookie', $additionalCookie);
return $this;
}
|
php
|
public function setAdditionalCookie($cookie, $expectedValue = false)
{
$additionalCookie = $this->_getData('_additional_cookie');
if (!$additionalCookie || !is_array($additionalCookie)) {
$additionalCookie = array();
}
$additionalCookie[$cookie] = $expectedValue;
$this->setData('_additional_cookie', $additionalCookie);
return $this;
}
|
[
"public",
"function",
"setAdditionalCookie",
"(",
"$",
"cookie",
",",
"$",
"expectedValue",
"=",
"false",
")",
"{",
"$",
"additionalCookie",
"=",
"$",
"this",
"->",
"_getData",
"(",
"'_additional_cookie'",
")",
";",
"if",
"(",
"!",
"$",
"additionalCookie",
"||",
"!",
"is_array",
"(",
"$",
"additionalCookie",
")",
")",
"{",
"$",
"additionalCookie",
"=",
"array",
"(",
")",
";",
"}",
"$",
"additionalCookie",
"[",
"$",
"cookie",
"]",
"=",
"$",
"expectedValue",
";",
"$",
"this",
"->",
"setData",
"(",
"'_additional_cookie'",
",",
"$",
"additionalCookie",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets additional cookie for block
@param $cookie
@param bool|false $expectedValue
@return $this
|
[
"Sets",
"additional",
"cookie",
"for",
"block"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Block/Js/Wrapper.php#L74-L84
|
222,775
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Block/Js/Wrapper.php
|
EcomDev_Varnish_Block_Js_Wrapper.removeAdditionalCookie
|
public function removeAdditionalCookie($cookie)
{
$additionalCookie = $this->_getData('_additional_cookie');
if (!$additionalCookie || !is_array($additionalCookie)) {
return $this;
}
if (isset($additionalCookie[$cookie])) {
unset($additionalCookie[$cookie]);
}
$this->setData('_additional_cookie', $additionalCookie);
return $this;
}
|
php
|
public function removeAdditionalCookie($cookie)
{
$additionalCookie = $this->_getData('_additional_cookie');
if (!$additionalCookie || !is_array($additionalCookie)) {
return $this;
}
if (isset($additionalCookie[$cookie])) {
unset($additionalCookie[$cookie]);
}
$this->setData('_additional_cookie', $additionalCookie);
return $this;
}
|
[
"public",
"function",
"removeAdditionalCookie",
"(",
"$",
"cookie",
")",
"{",
"$",
"additionalCookie",
"=",
"$",
"this",
"->",
"_getData",
"(",
"'_additional_cookie'",
")",
";",
"if",
"(",
"!",
"$",
"additionalCookie",
"||",
"!",
"is_array",
"(",
"$",
"additionalCookie",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"additionalCookie",
"[",
"$",
"cookie",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"additionalCookie",
"[",
"$",
"cookie",
"]",
")",
";",
"}",
"$",
"this",
"->",
"setData",
"(",
"'_additional_cookie'",
",",
"$",
"additionalCookie",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Removes additional cookie from block
@param string $cookie
@return $this
|
[
"Removes",
"additional",
"cookie",
"from",
"block"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Block/Js/Wrapper.php#L92-L105
|
222,776
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Block/Js/Token.php
|
EcomDev_Varnish_Block_Js_Token.setTokenInputName
|
public function setTokenInputName($tokenInputName = null)
{
if ($tokenInputName === null) {
$tokenInputName = 'form_key';
}
$this->setData('token_input_name', $tokenInputName);
return $this;
}
|
php
|
public function setTokenInputName($tokenInputName = null)
{
if ($tokenInputName === null) {
$tokenInputName = 'form_key';
}
$this->setData('token_input_name', $tokenInputName);
return $this;
}
|
[
"public",
"function",
"setTokenInputName",
"(",
"$",
"tokenInputName",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"tokenInputName",
"===",
"null",
")",
"{",
"$",
"tokenInputName",
"=",
"'form_key'",
";",
"}",
"$",
"this",
"->",
"setData",
"(",
"'token_input_name'",
",",
"$",
"tokenInputName",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets token input name
@param string|null $tokenInputName
@return $this
|
[
"Sets",
"token",
"input",
"name"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Block/Js/Token.php#L36-L44
|
222,777
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Block/Js/Token.php
|
EcomDev_Varnish_Block_Js_Token.removeObservedCssRule
|
public function removeObservedCssRule($rule)
{
if (isset($this->observedCssRules[$rule])) {
unset($this->observedCssRules[$rule]);
}
return $this;
}
|
php
|
public function removeObservedCssRule($rule)
{
if (isset($this->observedCssRules[$rule])) {
unset($this->observedCssRules[$rule]);
}
return $this;
}
|
[
"public",
"function",
"removeObservedCssRule",
"(",
"$",
"rule",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"observedCssRules",
"[",
"$",
"rule",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"observedCssRules",
"[",
"$",
"rule",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Removes observed css rule
@param string $rule
@return $this
|
[
"Removes",
"observed",
"css",
"rule"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Block/Js/Token.php#L77-L84
|
222,778
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Block/Js/Token.php
|
EcomDev_Varnish_Block_Js_Token.setUrlKeyParam
|
public function setUrlKeyParam($urlKeyParam = null)
{
if ($urlKeyParam === null) {
$urlKeyParam = $this->getTokenInputName();
}
$this->setData('url_key_param', $urlKeyParam);
return $this;
}
|
php
|
public function setUrlKeyParam($urlKeyParam = null)
{
if ($urlKeyParam === null) {
$urlKeyParam = $this->getTokenInputName();
}
$this->setData('url_key_param', $urlKeyParam);
return $this;
}
|
[
"public",
"function",
"setUrlKeyParam",
"(",
"$",
"urlKeyParam",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"urlKeyParam",
"===",
"null",
")",
"{",
"$",
"urlKeyParam",
"=",
"$",
"this",
"->",
"getTokenInputName",
"(",
")",
";",
"}",
"$",
"this",
"->",
"setData",
"(",
"'url_key_param'",
",",
"$",
"urlKeyParam",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets url key param name
@param string|null $urlKeyParam
@return $this
|
[
"Sets",
"url",
"key",
"param",
"name"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Block/Js/Token.php#L116-L124
|
222,779
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Block/Js/Token.php
|
EcomDev_Varnish_Block_Js_Token.setCookieName
|
public function setCookieName($cookieName = null)
{
if ($cookieName === null) {
$cookieName = EcomDev_Varnish_Helper_Data::COOKIE_TOKEN;
}
$this->setData('cookie_name', $cookieName);
return $this;
}
|
php
|
public function setCookieName($cookieName = null)
{
if ($cookieName === null) {
$cookieName = EcomDev_Varnish_Helper_Data::COOKIE_TOKEN;
}
$this->setData('cookie_name', $cookieName);
return $this;
}
|
[
"public",
"function",
"setCookieName",
"(",
"$",
"cookieName",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"cookieName",
"===",
"null",
")",
"{",
"$",
"cookieName",
"=",
"EcomDev_Varnish_Helper_Data",
"::",
"COOKIE_TOKEN",
";",
"}",
"$",
"this",
"->",
"setData",
"(",
"'cookie_name'",
",",
"$",
"cookieName",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets cookie name for token retrieval
@param string|null $cookieName
@return $this
|
[
"Sets",
"cookie",
"name",
"for",
"token",
"retrieval"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Block/Js/Token.php#L146-L154
|
222,780
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Block/Js/Token.php
|
EcomDev_Varnish_Block_Js_Token.getJson
|
public function getJson()
{
$json = array(
'urlKeyParam' => $this->getUrlKeyParam(),
'inputFieldName' => $this->getTokenInputName(),
'observedCssRules' => $this->getObservedCssRules(),
'requestUrl' => $this->getTokenUrl(),
'cookieName' => $this->getCookieName()
);
return json_encode($json);
}
|
php
|
public function getJson()
{
$json = array(
'urlKeyParam' => $this->getUrlKeyParam(),
'inputFieldName' => $this->getTokenInputName(),
'observedCssRules' => $this->getObservedCssRules(),
'requestUrl' => $this->getTokenUrl(),
'cookieName' => $this->getCookieName()
);
return json_encode($json);
}
|
[
"public",
"function",
"getJson",
"(",
")",
"{",
"$",
"json",
"=",
"array",
"(",
"'urlKeyParam'",
"=>",
"$",
"this",
"->",
"getUrlKeyParam",
"(",
")",
",",
"'inputFieldName'",
"=>",
"$",
"this",
"->",
"getTokenInputName",
"(",
")",
",",
"'observedCssRules'",
"=>",
"$",
"this",
"->",
"getObservedCssRules",
"(",
")",
",",
"'requestUrl'",
"=>",
"$",
"this",
"->",
"getTokenUrl",
"(",
")",
",",
"'cookieName'",
"=>",
"$",
"this",
"->",
"getCookieName",
"(",
")",
")",
";",
"return",
"json_encode",
"(",
"$",
"json",
")",
";",
"}"
] |
Returns json for JavaScript class
@return string
|
[
"Returns",
"json",
"for",
"JavaScript",
"class"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Block/Js/Token.php#L161-L172
|
222,781
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Model/AbstractApplicable.php
|
EcomDev_Varnish_Model_AbstractApplicable.isApplicable
|
public function isApplicable($object)
{
foreach ($this->_applicableClasses as $className) {
if ($object instanceof $className) {
return true;
}
}
return false;
}
|
php
|
public function isApplicable($object)
{
foreach ($this->_applicableClasses as $className) {
if ($object instanceof $className) {
return true;
}
}
return false;
}
|
[
"public",
"function",
"isApplicable",
"(",
"$",
"object",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_applicableClasses",
"as",
"$",
"className",
")",
"{",
"if",
"(",
"$",
"object",
"instanceof",
"$",
"className",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Returns true if one of the object is an instance of applicable class
@param object $object
@return bool
|
[
"Returns",
"true",
"if",
"one",
"of",
"the",
"object",
"is",
"an",
"instance",
"of",
"applicable",
"class"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Model/AbstractApplicable.php#L38-L47
|
222,782
|
gordalina/easypay-php
|
src/Gordalina/Easypay/Payment/Payment.php
|
Payment.setMaxDate
|
public function setMaxDate($maxDate)
{
$date = \DateTime::createFromFormat(self::MAX_DATE_FORMAT, $maxDate);
$isValid = $date && $date->format(self::MAX_DATE_FORMAT) == $maxDate;
if (!$isValid) {
throw new \InvalidArgumentException('Maximum payment date must be in that format: '.self::MAX_DATE_FORMAT);
}
$this->maxDate = $maxDate;
}
|
php
|
public function setMaxDate($maxDate)
{
$date = \DateTime::createFromFormat(self::MAX_DATE_FORMAT, $maxDate);
$isValid = $date && $date->format(self::MAX_DATE_FORMAT) == $maxDate;
if (!$isValid) {
throw new \InvalidArgumentException('Maximum payment date must be in that format: '.self::MAX_DATE_FORMAT);
}
$this->maxDate = $maxDate;
}
|
[
"public",
"function",
"setMaxDate",
"(",
"$",
"maxDate",
")",
"{",
"$",
"date",
"=",
"\\",
"DateTime",
"::",
"createFromFormat",
"(",
"self",
"::",
"MAX_DATE_FORMAT",
",",
"$",
"maxDate",
")",
";",
"$",
"isValid",
"=",
"$",
"date",
"&&",
"$",
"date",
"->",
"format",
"(",
"self",
"::",
"MAX_DATE_FORMAT",
")",
"==",
"$",
"maxDate",
";",
"if",
"(",
"!",
"$",
"isValid",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Maximum payment date must be in that format: '",
".",
"self",
"::",
"MAX_DATE_FORMAT",
")",
";",
"}",
"$",
"this",
"->",
"maxDate",
"=",
"$",
"maxDate",
";",
"}"
] |
This method will define a due date for the payment
@param $maxDate
@throws \InvalidArgumentException If maxDate is not in the format defined in Payment::MAX_DATE_FORMAT
|
[
"This",
"method",
"will",
"define",
"a",
"due",
"date",
"for",
"the",
"payment"
] |
23e8d462f33834233cad4e9fbe9fc57267c1e573
|
https://github.com/gordalina/easypay-php/blob/23e8d462f33834233cad4e9fbe9fc57267c1e573/src/Gordalina/Easypay/Payment/Payment.php#L104-L114
|
222,783
|
FriendsOfOuro/geteventstore-php-core
|
src/ValueObjects/StringLiteral/StringLiteral.php
|
StringLiteral.sameValueAs
|
public function sameValueAs(ValueObjectInterface $stringLiteral)
{
if (false === Util::classEquals($this, $stringLiteral)) {
return false;
}
return $this->toNative() === $stringLiteral->toNative();
}
|
php
|
public function sameValueAs(ValueObjectInterface $stringLiteral)
{
if (false === Util::classEquals($this, $stringLiteral)) {
return false;
}
return $this->toNative() === $stringLiteral->toNative();
}
|
[
"public",
"function",
"sameValueAs",
"(",
"ValueObjectInterface",
"$",
"stringLiteral",
")",
"{",
"if",
"(",
"false",
"===",
"Util",
"::",
"classEquals",
"(",
"$",
"this",
",",
"$",
"stringLiteral",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"this",
"->",
"toNative",
"(",
")",
"===",
"$",
"stringLiteral",
"->",
"toNative",
"(",
")",
";",
"}"
] |
Tells whether two string literals are equal by comparing their values.
@param ValueObjectInterface $stringLiteral
@return bool
|
[
"Tells",
"whether",
"two",
"string",
"literals",
"are",
"equal",
"by",
"comparing",
"their",
"values",
"."
] |
76aac24ce7a688f8232f76ba24b3549222f20332
|
https://github.com/FriendsOfOuro/geteventstore-php-core/blob/76aac24ce7a688f8232f76ba24b3549222f20332/src/ValueObjects/StringLiteral/StringLiteral.php#L57-L64
|
222,784
|
compropago/compropago-php
|
src/Resources/Payments/Cash.php
|
Cash.getDefaultProviders
|
public function getDefaultProviders()
{
$endpoint = "{$this->apiUrl}/providers/true";
$res = Requests::get($endpoint);
$this->validateResponse($res);
return json_decode($res->body, true);
}
|
php
|
public function getDefaultProviders()
{
$endpoint = "{$this->apiUrl}/providers/true";
$res = Requests::get($endpoint);
$this->validateResponse($res);
return json_decode($res->body, true);
}
|
[
"public",
"function",
"getDefaultProviders",
"(",
")",
"{",
"$",
"endpoint",
"=",
"\"{$this->apiUrl}/providers/true\"",
";",
"$",
"res",
"=",
"Requests",
"::",
"get",
"(",
"$",
"endpoint",
")",
";",
"$",
"this",
"->",
"validateResponse",
"(",
"$",
"res",
")",
";",
"return",
"json_decode",
"(",
"$",
"res",
"->",
"body",
",",
"true",
")",
";",
"}"
] |
Return a list of the default Cash Providers of ComproPago
@return array List of all posible providers
@throws \Exception Request error or exception
|
[
"Return",
"a",
"list",
"of",
"the",
"default",
"Cash",
"Providers",
"of",
"ComproPago"
] |
dc11d7cba778123bbf84860b4bb5d8dbfb78598f
|
https://github.com/compropago/compropago-php/blob/dc11d7cba778123bbf84860b4bb5d8dbfb78598f/src/Resources/Payments/Cash.php#L26-L34
|
222,785
|
compropago/compropago-php
|
src/Resources/Payments/Cash.php
|
Cash.getProviders
|
public function getProviders($limit = 0, $currency = 'MXN')
{
$endpoint = "{$this->apiUrl}/providers";
if ($limit > 0) {
$endpoint .= '?order_total='.$limit;
}
if ($limit > 0 && !empty($currency) && $currency != 'MXN') {
$endpoint .= '¤cy='.$currency;
}
$res = Requests::get($endpoint, [], $this->options);
$this->validateResponse($res);
return json_decode($res->body, true);
}
|
php
|
public function getProviders($limit = 0, $currency = 'MXN')
{
$endpoint = "{$this->apiUrl}/providers";
if ($limit > 0) {
$endpoint .= '?order_total='.$limit;
}
if ($limit > 0 && !empty($currency) && $currency != 'MXN') {
$endpoint .= '¤cy='.$currency;
}
$res = Requests::get($endpoint, [], $this->options);
$this->validateResponse($res);
return json_decode($res->body, true);
}
|
[
"public",
"function",
"getProviders",
"(",
"$",
"limit",
"=",
"0",
",",
"$",
"currency",
"=",
"'MXN'",
")",
"{",
"$",
"endpoint",
"=",
"\"{$this->apiUrl}/providers\"",
";",
"if",
"(",
"$",
"limit",
">",
"0",
")",
"{",
"$",
"endpoint",
".=",
"'?order_total='",
".",
"$",
"limit",
";",
"}",
"if",
"(",
"$",
"limit",
">",
"0",
"&&",
"!",
"empty",
"(",
"$",
"currency",
")",
"&&",
"$",
"currency",
"!=",
"'MXN'",
")",
"{",
"$",
"endpoint",
".=",
"'¤cy='",
".",
"$",
"currency",
";",
"}",
"$",
"res",
"=",
"Requests",
"::",
"get",
"(",
"$",
"endpoint",
",",
"[",
"]",
",",
"$",
"this",
"->",
"options",
")",
";",
"$",
"this",
"->",
"validateResponse",
"(",
"$",
"res",
")",
";",
"return",
"json_decode",
"(",
"$",
"res",
"->",
"body",
",",
"true",
")",
";",
"}"
] |
Return a specific providers filtered by CP keys and order amounr
@param float $limit Minimum limit amount that the provider has to support
@param string $currency Currency of the limit amount
@return array List of filtered providers
@throws \Exception Request error or exception
|
[
"Return",
"a",
"specific",
"providers",
"filtered",
"by",
"CP",
"keys",
"and",
"order",
"amounr"
] |
dc11d7cba778123bbf84860b4bb5d8dbfb78598f
|
https://github.com/compropago/compropago-php/blob/dc11d7cba778123bbf84860b4bb5d8dbfb78598f/src/Resources/Payments/Cash.php#L46-L62
|
222,786
|
compropago/compropago-php
|
src/Resources/Payments/Cash.php
|
Cash.createOrder
|
public function createOrder($data)
{
$endpoint = "{$this->apiUrl}/charges";
$res = Requests::post(
$endpoint,
$this->headers,
json_encode($data),
$this->options
);
$this->validateResponse($res);
return json_decode($res->body, true);
}
|
php
|
public function createOrder($data)
{
$endpoint = "{$this->apiUrl}/charges";
$res = Requests::post(
$endpoint,
$this->headers,
json_encode($data),
$this->options
);
$this->validateResponse($res);
return json_decode($res->body, true);
}
|
[
"public",
"function",
"createOrder",
"(",
"$",
"data",
")",
"{",
"$",
"endpoint",
"=",
"\"{$this->apiUrl}/charges\"",
";",
"$",
"res",
"=",
"Requests",
"::",
"post",
"(",
"$",
"endpoint",
",",
"$",
"this",
"->",
"headers",
",",
"json_encode",
"(",
"$",
"data",
")",
",",
"$",
"this",
"->",
"options",
")",
";",
"$",
"this",
"->",
"validateResponse",
"(",
"$",
"res",
")",
";",
"return",
"json_decode",
"(",
"$",
"res",
"->",
"body",
",",
"true",
")",
";",
"}"
] |
Create a cash order in ComproPago
@param array $data Order information like customer data, price currency an product
@return array Structure with order details
@throws \Exception Request error or exception
|
[
"Create",
"a",
"cash",
"order",
"in",
"ComproPago"
] |
dc11d7cba778123bbf84860b4bb5d8dbfb78598f
|
https://github.com/compropago/compropago-php/blob/dc11d7cba778123bbf84860b4bb5d8dbfb78598f/src/Resources/Payments/Cash.php#L73-L86
|
222,787
|
compropago/compropago-php
|
src/Resources/Payments/Cash.php
|
Cash.verifyOrder
|
public function verifyOrder($orderId)
{
$endpoint = "{$this->apiUrl}/charges/{$orderId}";
$res = Requests::get(
$endpoint,
array(),
$this->options
);
$this->validateResponse($res);
return json_decode($res->body, true);
}
|
php
|
public function verifyOrder($orderId)
{
$endpoint = "{$this->apiUrl}/charges/{$orderId}";
$res = Requests::get(
$endpoint,
array(),
$this->options
);
$this->validateResponse($res);
return json_decode($res->body, true);
}
|
[
"public",
"function",
"verifyOrder",
"(",
"$",
"orderId",
")",
"{",
"$",
"endpoint",
"=",
"\"{$this->apiUrl}/charges/{$orderId}\"",
";",
"$",
"res",
"=",
"Requests",
"::",
"get",
"(",
"$",
"endpoint",
",",
"array",
"(",
")",
",",
"$",
"this",
"->",
"options",
")",
";",
"$",
"this",
"->",
"validateResponse",
"(",
"$",
"res",
")",
";",
"return",
"json_decode",
"(",
"$",
"res",
"->",
"body",
",",
"true",
")",
";",
"}"
] |
Verify order status by id
@param string $orderId Order id
@return array Structure with order details
@throws \Exception Request error or exception
|
[
"Verify",
"order",
"status",
"by",
"id"
] |
dc11d7cba778123bbf84860b4bb5d8dbfb78598f
|
https://github.com/compropago/compropago-php/blob/dc11d7cba778123bbf84860b4bb5d8dbfb78598f/src/Resources/Payments/Cash.php#L97-L109
|
222,788
|
gordalina/easypay-php
|
src/Gordalina/Easypay/Client.php
|
Client.normalizeArray
|
protected static function normalizeArray(array $content)
{
foreach ($content as $key => $value) {
if ($value instanceof \SimpleXMLElement) {
if ($value->count()) {
$content[$key] = static::normalizeArray((array) $value);
} else {
$content[$key] = null;
}
} elseif (is_array($value)) {
$content[$key] = static::normalizeArray($value);
}
}
return $content;
}
|
php
|
protected static function normalizeArray(array $content)
{
foreach ($content as $key => $value) {
if ($value instanceof \SimpleXMLElement) {
if ($value->count()) {
$content[$key] = static::normalizeArray((array) $value);
} else {
$content[$key] = null;
}
} elseif (is_array($value)) {
$content[$key] = static::normalizeArray($value);
}
}
return $content;
}
|
[
"protected",
"static",
"function",
"normalizeArray",
"(",
"array",
"$",
"content",
")",
"{",
"foreach",
"(",
"$",
"content",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"\\",
"SimpleXMLElement",
")",
"{",
"if",
"(",
"$",
"value",
"->",
"count",
"(",
")",
")",
"{",
"$",
"content",
"[",
"$",
"key",
"]",
"=",
"static",
"::",
"normalizeArray",
"(",
"(",
"array",
")",
"$",
"value",
")",
";",
"}",
"else",
"{",
"$",
"content",
"[",
"$",
"key",
"]",
"=",
"null",
";",
"}",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"content",
"[",
"$",
"key",
"]",
"=",
"static",
"::",
"normalizeArray",
"(",
"$",
"value",
")",
";",
"}",
"}",
"return",
"$",
"content",
";",
"}"
] |
Server returns everything in XML within the automb tag so a simple
implementation to translate it to an array is enough
Current implementation does not work with nested xml tags
@static
@param $content string
@return array
|
[
"Server",
"returns",
"everything",
"in",
"XML",
"within",
"the",
"automb",
"tag",
"so",
"a",
"simple",
"implementation",
"to",
"translate",
"it",
"to",
"an",
"array",
"is",
"enough"
] |
23e8d462f33834233cad4e9fbe9fc57267c1e573
|
https://github.com/gordalina/easypay-php/blob/23e8d462f33834233cad4e9fbe9fc57267c1e573/src/Gordalina/Easypay/Client.php#L118-L133
|
222,789
|
compropago/compropago-php
|
src/Resources/Sms.php
|
Sms.sendToOrder
|
public function sendToOrder($orderId, $phone)
{
$endpoint = "{$this->apiUrl}/charges/{$orderId}/sms";
$data = [
"customer_phone" => $phone
];
$res = Requests::post(
$endpoint,
$this->headers,
json_encode($data),
$this->options
);
$this->validateResponse($res);
return json_decode($res->body, true);
}
|
php
|
public function sendToOrder($orderId, $phone)
{
$endpoint = "{$this->apiUrl}/charges/{$orderId}/sms";
$data = [
"customer_phone" => $phone
];
$res = Requests::post(
$endpoint,
$this->headers,
json_encode($data),
$this->options
);
$this->validateResponse($res);
return json_decode($res->body, true);
}
|
[
"public",
"function",
"sendToOrder",
"(",
"$",
"orderId",
",",
"$",
"phone",
")",
"{",
"$",
"endpoint",
"=",
"\"{$this->apiUrl}/charges/{$orderId}/sms\"",
";",
"$",
"data",
"=",
"[",
"\"customer_phone\"",
"=>",
"$",
"phone",
"]",
";",
"$",
"res",
"=",
"Requests",
"::",
"post",
"(",
"$",
"endpoint",
",",
"$",
"this",
"->",
"headers",
",",
"json_encode",
"(",
"$",
"data",
")",
",",
"$",
"this",
"->",
"options",
")",
";",
"$",
"this",
"->",
"validateResponse",
"(",
"$",
"res",
")",
";",
"return",
"json_decode",
"(",
"$",
"res",
"->",
"body",
",",
"true",
")",
";",
"}"
] |
Send SMS instructions for a specific order
@param string $orderId ComproPago Order ID (ch_xxxxx-xxx-xx-xxxx-xxxx)
@param string $phone Phone number to send the message
@return array Structure with SMS information
@throws \Exception Request error or exception
|
[
"Send",
"SMS",
"instructions",
"for",
"a",
"specific",
"order"
] |
dc11d7cba778123bbf84860b4bb5d8dbfb78598f
|
https://github.com/compropago/compropago-php/blob/dc11d7cba778123bbf84860b4bb5d8dbfb78598f/src/Resources/Sms.php#L29-L45
|
222,790
|
stanislav-web/phalcon-uploader
|
src/Uploader/Validator.php
|
Validator.checkMinsize
|
public function checkMinsize(\Phalcon\Http\Request\File $file, $value)
{
// conversion to the desired format
if (is_array($value) === true) {
$value = $value[key($value)];
}
// check
if ($file->getSize() < (int) $value) {
$this->errors[] = sprintf(Message::get('INVALID_MIN_SIZE'), $file->getName(), Format::bytes($value));
return false;
}
return true;
}
|
php
|
public function checkMinsize(\Phalcon\Http\Request\File $file, $value)
{
// conversion to the desired format
if (is_array($value) === true) {
$value = $value[key($value)];
}
// check
if ($file->getSize() < (int) $value) {
$this->errors[] = sprintf(Message::get('INVALID_MIN_SIZE'), $file->getName(), Format::bytes($value));
return false;
}
return true;
}
|
[
"public",
"function",
"checkMinsize",
"(",
"\\",
"Phalcon",
"\\",
"Http",
"\\",
"Request",
"\\",
"File",
"$",
"file",
",",
"$",
"value",
")",
"{",
"// conversion to the desired format",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
"===",
"true",
")",
"{",
"$",
"value",
"=",
"$",
"value",
"[",
"key",
"(",
"$",
"value",
")",
"]",
";",
"}",
"// check",
"if",
"(",
"$",
"file",
"->",
"getSize",
"(",
")",
"<",
"(",
"int",
")",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"errors",
"[",
"]",
"=",
"sprintf",
"(",
"Message",
"::",
"get",
"(",
"'INVALID_MIN_SIZE'",
")",
",",
"$",
"file",
"->",
"getName",
"(",
")",
",",
"Format",
"::",
"bytes",
"(",
"$",
"value",
")",
")",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Check minimum file size
@param \Phalcon\Http\Request\File $file
@param $value
@return bool
|
[
"Check",
"minimum",
"file",
"size"
] |
3e46aba5d6f51b52b7830eae21c0d3fe1e524c90
|
https://github.com/stanislav-web/phalcon-uploader/blob/3e46aba5d6f51b52b7830eae21c0d3fe1e524c90/src/Uploader/Validator.php#L32-L49
|
222,791
|
stanislav-web/phalcon-uploader
|
src/Uploader/Validator.php
|
Validator.checkDirectory
|
public function checkDirectory(\Phalcon\Http\Request\File $file = null, $value)
{
// conversion to the desired format
if (is_array($value) === true) {
$value = $value[key($value)];
}
if (file_exists($value) === false) {
$this->errors[] = sprintf(Message::get('INVALID_UPLOAD_DIR'), $value);
return false;
}
if (is_writable($value) === false) {
$this->errors[] = sprintf(Message::get('INVALID_PERMISSION_DIR'), $value);
return false;
}
return true;
}
|
php
|
public function checkDirectory(\Phalcon\Http\Request\File $file = null, $value)
{
// conversion to the desired format
if (is_array($value) === true) {
$value = $value[key($value)];
}
if (file_exists($value) === false) {
$this->errors[] = sprintf(Message::get('INVALID_UPLOAD_DIR'), $value);
return false;
}
if (is_writable($value) === false) {
$this->errors[] = sprintf(Message::get('INVALID_PERMISSION_DIR'), $value);
return false;
}
return true;
}
|
[
"public",
"function",
"checkDirectory",
"(",
"\\",
"Phalcon",
"\\",
"Http",
"\\",
"Request",
"\\",
"File",
"$",
"file",
"=",
"null",
",",
"$",
"value",
")",
"{",
"// conversion to the desired format",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
"===",
"true",
")",
"{",
"$",
"value",
"=",
"$",
"value",
"[",
"key",
"(",
"$",
"value",
")",
"]",
";",
"}",
"if",
"(",
"file_exists",
"(",
"$",
"value",
")",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"errors",
"[",
"]",
"=",
"sprintf",
"(",
"Message",
"::",
"get",
"(",
"'INVALID_UPLOAD_DIR'",
")",
",",
"$",
"value",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"is_writable",
"(",
"$",
"value",
")",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"errors",
"[",
"]",
"=",
"sprintf",
"(",
"Message",
"::",
"get",
"(",
"'INVALID_PERMISSION_DIR'",
")",
",",
"$",
"value",
")",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Check upload directory
@param null|\Phalcon\Http\Request\File $file
@param mixed $value
@param $value
@return bool
|
[
"Check",
"upload",
"directory"
] |
3e46aba5d6f51b52b7830eae21c0d3fe1e524c90
|
https://github.com/stanislav-web/phalcon-uploader/blob/3e46aba5d6f51b52b7830eae21c0d3fe1e524c90/src/Uploader/Validator.php#L137-L158
|
222,792
|
stanislav-web/phalcon-uploader
|
src/Uploader/Validator.php
|
Validator.checkDynamic
|
public function checkDynamic(\Phalcon\Http\Request\File $file = null, $directory, $permission = 0777)
{
if (is_dir($directory) === false && file_exists($directory) === false) {
mkdir(rtrim($directory,'/') . DIRECTORY_SEPARATOR, $permission, true);
}
return true;
}
|
php
|
public function checkDynamic(\Phalcon\Http\Request\File $file = null, $directory, $permission = 0777)
{
if (is_dir($directory) === false && file_exists($directory) === false) {
mkdir(rtrim($directory,'/') . DIRECTORY_SEPARATOR, $permission, true);
}
return true;
}
|
[
"public",
"function",
"checkDynamic",
"(",
"\\",
"Phalcon",
"\\",
"Http",
"\\",
"Request",
"\\",
"File",
"$",
"file",
"=",
"null",
",",
"$",
"directory",
",",
"$",
"permission",
"=",
"0777",
")",
"{",
"if",
"(",
"is_dir",
"(",
"$",
"directory",
")",
"===",
"false",
"&&",
"file_exists",
"(",
"$",
"directory",
")",
"===",
"false",
")",
"{",
"mkdir",
"(",
"rtrim",
"(",
"$",
"directory",
",",
"'/'",
")",
".",
"DIRECTORY_SEPARATOR",
",",
"$",
"permission",
",",
"true",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
Create Directory if not exist
@param null|\Phalcon\Http\Request\File $file
@param string $directory
@param int $permission
@version v1.4
@author Mahdi-Mohammadi
@return bool
|
[
"Create",
"Directory",
"if",
"not",
"exist"
] |
3e46aba5d6f51b52b7830eae21c0d3fe1e524c90
|
https://github.com/stanislav-web/phalcon-uploader/blob/3e46aba5d6f51b52b7830eae21c0d3fe1e524c90/src/Uploader/Validator.php#L170-L177
|
222,793
|
compropago/compropago-php
|
src/Helpers/ValidationHelper.php
|
ValidationHelper.validateResponse
|
public function validateResponse(Requests_Response $res)
{
$body = json_decode($res->body, true);
if ($res->status_code != 200 || (isset($body['code']) && $body['code'] != 200)) {
$message = sprintf('Request Error [%d]: %s', $res->status_code, $res->body);
throw new \Exception($message, $res->status_code);
}
}
|
php
|
public function validateResponse(Requests_Response $res)
{
$body = json_decode($res->body, true);
if ($res->status_code != 200 || (isset($body['code']) && $body['code'] != 200)) {
$message = sprintf('Request Error [%d]: %s', $res->status_code, $res->body);
throw new \Exception($message, $res->status_code);
}
}
|
[
"public",
"function",
"validateResponse",
"(",
"Requests_Response",
"$",
"res",
")",
"{",
"$",
"body",
"=",
"json_decode",
"(",
"$",
"res",
"->",
"body",
",",
"true",
")",
";",
"if",
"(",
"$",
"res",
"->",
"status_code",
"!=",
"200",
"||",
"(",
"isset",
"(",
"$",
"body",
"[",
"'code'",
"]",
")",
"&&",
"$",
"body",
"[",
"'code'",
"]",
"!=",
"200",
")",
")",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"'Request Error [%d]: %s'",
",",
"$",
"res",
"->",
"status_code",
",",
"$",
"res",
"->",
"body",
")",
";",
"throw",
"new",
"\\",
"Exception",
"(",
"$",
"message",
",",
"$",
"res",
"->",
"status_code",
")",
";",
"}",
"}"
] |
Validate if the response of the ComproPago API is a success response or an error response
@param Requests_Response $res Response object from Requests library
@return void
@throws \Exception Request error or exception
|
[
"Validate",
"if",
"the",
"response",
"of",
"the",
"ComproPago",
"API",
"is",
"a",
"success",
"response",
"or",
"an",
"error",
"response"
] |
dc11d7cba778123bbf84860b4bb5d8dbfb78598f
|
https://github.com/compropago/compropago-php/blob/dc11d7cba778123bbf84860b4bb5d8dbfb78598f/src/Helpers/ValidationHelper.php#L18-L26
|
222,794
|
xcaliber-tech/omnipay-skrill
|
src/Omnipay/Skrill/Message/AuthorizeResponse.php
|
AuthorizeResponse.getSessionId
|
public function getSessionId()
{
return isset($this->data->sid)
? (string) $this->data->sid
: null;
}
|
php
|
public function getSessionId()
{
return isset($this->data->sid)
? (string) $this->data->sid
: null;
}
|
[
"public",
"function",
"getSessionId",
"(",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"data",
"->",
"sid",
")",
"?",
"(",
"string",
")",
"$",
"this",
"->",
"data",
"->",
"sid",
":",
"null",
";",
"}"
] |
Get the session identifier to be submitted at the next step.
@return string session id
|
[
"Get",
"the",
"session",
"identifier",
"to",
"be",
"submitted",
"at",
"the",
"next",
"step",
"."
] |
f90a185b5e26fb5b4150d664f01ad8048b460bcf
|
https://github.com/xcaliber-tech/omnipay-skrill/blob/f90a185b5e26fb5b4150d664f01ad8048b460bcf/src/Omnipay/Skrill/Message/AuthorizeResponse.php#L19-L24
|
222,795
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Model/Connector.php
|
EcomDev_Varnish_Model_Connector._initVarnishPool
|
protected function _initVarnishPool()
{
$this->pool = new VarnishPool();
$addresses = Mage::getStoreConfig(self::XML_PATH_VARNISH_SERVER);
$secret = Mage::getStoreConfig(self::XML_PATH_VARNISH_SECRET);
if (Mage::getStoreConfigFlag(self::XML_PATH_VARNISH_SECRET_NEWLINE)) {
$secret .= "\n";
}
$lines = explode("\n", $addresses);
$instantiated = array();
foreach ($lines as $line) {
$line = trim($line);
if (!preg_match('/^[a-z0-9_\-\.]+:\d+$/', $line)
|| isset($instantiated[$line])) {
continue;
}
list($host, $port) = explode(':', $line);
try {
$this->pool->addServer(new VarnishAdmin($host, $port, $secret));
} catch (VarnishException $e) {
Mage::logException($e);
}
$instantiated[$line] = true;
}
$this->pool->setIgnoreOnFail(true);
return $this;
}
|
php
|
protected function _initVarnishPool()
{
$this->pool = new VarnishPool();
$addresses = Mage::getStoreConfig(self::XML_PATH_VARNISH_SERVER);
$secret = Mage::getStoreConfig(self::XML_PATH_VARNISH_SECRET);
if (Mage::getStoreConfigFlag(self::XML_PATH_VARNISH_SECRET_NEWLINE)) {
$secret .= "\n";
}
$lines = explode("\n", $addresses);
$instantiated = array();
foreach ($lines as $line) {
$line = trim($line);
if (!preg_match('/^[a-z0-9_\-\.]+:\d+$/', $line)
|| isset($instantiated[$line])) {
continue;
}
list($host, $port) = explode(':', $line);
try {
$this->pool->addServer(new VarnishAdmin($host, $port, $secret));
} catch (VarnishException $e) {
Mage::logException($e);
}
$instantiated[$line] = true;
}
$this->pool->setIgnoreOnFail(true);
return $this;
}
|
[
"protected",
"function",
"_initVarnishPool",
"(",
")",
"{",
"$",
"this",
"->",
"pool",
"=",
"new",
"VarnishPool",
"(",
")",
";",
"$",
"addresses",
"=",
"Mage",
"::",
"getStoreConfig",
"(",
"self",
"::",
"XML_PATH_VARNISH_SERVER",
")",
";",
"$",
"secret",
"=",
"Mage",
"::",
"getStoreConfig",
"(",
"self",
"::",
"XML_PATH_VARNISH_SECRET",
")",
";",
"if",
"(",
"Mage",
"::",
"getStoreConfigFlag",
"(",
"self",
"::",
"XML_PATH_VARNISH_SECRET_NEWLINE",
")",
")",
"{",
"$",
"secret",
".=",
"\"\\n\"",
";",
"}",
"$",
"lines",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"addresses",
")",
";",
"$",
"instantiated",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"lines",
"as",
"$",
"line",
")",
"{",
"$",
"line",
"=",
"trim",
"(",
"$",
"line",
")",
";",
"if",
"(",
"!",
"preg_match",
"(",
"'/^[a-z0-9_\\-\\.]+:\\d+$/'",
",",
"$",
"line",
")",
"||",
"isset",
"(",
"$",
"instantiated",
"[",
"$",
"line",
"]",
")",
")",
"{",
"continue",
";",
"}",
"list",
"(",
"$",
"host",
",",
"$",
"port",
")",
"=",
"explode",
"(",
"':'",
",",
"$",
"line",
")",
";",
"try",
"{",
"$",
"this",
"->",
"pool",
"->",
"addServer",
"(",
"new",
"VarnishAdmin",
"(",
"$",
"host",
",",
"$",
"port",
",",
"$",
"secret",
")",
")",
";",
"}",
"catch",
"(",
"VarnishException",
"$",
"e",
")",
"{",
"Mage",
"::",
"logException",
"(",
"$",
"e",
")",
";",
"}",
"$",
"instantiated",
"[",
"$",
"line",
"]",
"=",
"true",
";",
"}",
"$",
"this",
"->",
"pool",
"->",
"setIgnoreOnFail",
"(",
"true",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Initializes varnish pool
@return $this
@throws VarnishException
|
[
"Initializes",
"varnish",
"pool"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Model/Connector.php#L74-L109
|
222,796
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Model/Connector.php
|
EcomDev_Varnish_Model_Connector.banTags
|
public function banTags($tags)
{
try {
$this->getVarnishPool()->ban('obj.http.' . self::HEADER_OBJECTS . ' ~ ' . implode('|', $tags));
} catch (VarnishException $e) {
Mage::logException($e);
}
return $this;
}
|
php
|
public function banTags($tags)
{
try {
$this->getVarnishPool()->ban('obj.http.' . self::HEADER_OBJECTS . ' ~ ' . implode('|', $tags));
} catch (VarnishException $e) {
Mage::logException($e);
}
return $this;
}
|
[
"public",
"function",
"banTags",
"(",
"$",
"tags",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"getVarnishPool",
"(",
")",
"->",
"ban",
"(",
"'obj.http.'",
".",
"self",
"::",
"HEADER_OBJECTS",
".",
"' ~ '",
".",
"implode",
"(",
"'|'",
",",
"$",
"tags",
")",
")",
";",
"}",
"catch",
"(",
"VarnishException",
"$",
"e",
")",
"{",
"Mage",
"::",
"logException",
"(",
"$",
"e",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Ban list of tags
@param array $tags
@return $this
|
[
"Ban",
"list",
"of",
"tags"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Model/Connector.php#L117-L126
|
222,797
|
EcomDev/EcomDev_Varnish
|
src/app/code/community/EcomDev/Varnish/Model/Connector.php
|
EcomDev_Varnish_Model_Connector.walk
|
public function walk($method, $firstArg = null, $secondArg = null)
{
if ($method === 'purge') {
$method = 'ban';
}
if ($firstArg === null && $secondArg === null) {
$this->getVarnishPool()->$method();
} elseif ($secondArg === null) {
$this->getVarnishPool()->$method($firstArg);
} else {
$this->getVarnishPool()->$method($firstArg, $secondArg);
}
return $this;
}
|
php
|
public function walk($method, $firstArg = null, $secondArg = null)
{
if ($method === 'purge') {
$method = 'ban';
}
if ($firstArg === null && $secondArg === null) {
$this->getVarnishPool()->$method();
} elseif ($secondArg === null) {
$this->getVarnishPool()->$method($firstArg);
} else {
$this->getVarnishPool()->$method($firstArg, $secondArg);
}
return $this;
}
|
[
"public",
"function",
"walk",
"(",
"$",
"method",
",",
"$",
"firstArg",
"=",
"null",
",",
"$",
"secondArg",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"method",
"===",
"'purge'",
")",
"{",
"$",
"method",
"=",
"'ban'",
";",
"}",
"if",
"(",
"$",
"firstArg",
"===",
"null",
"&&",
"$",
"secondArg",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"getVarnishPool",
"(",
")",
"->",
"$",
"method",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"secondArg",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"getVarnishPool",
"(",
")",
"->",
"$",
"method",
"(",
"$",
"firstArg",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"getVarnishPool",
"(",
")",
"->",
"$",
"method",
"(",
"$",
"firstArg",
",",
"$",
"secondArg",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Invokes method on each adapter.
@param string $method
@param null|string|int $firstArg
@param null|string|int $secondArg
@return $this
@deprecated since 2.0.0
|
[
"Invokes",
"method",
"on",
"each",
"adapter",
"."
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/app/code/community/EcomDev/Varnish/Model/Connector.php#L137-L152
|
222,798
|
gordalina/easypay-php
|
src/Gordalina/Easypay/Payment/PaymentResult.php
|
PaymentResult.toArray
|
public function toArray()
{
return array(
'e' => $this->entity,
'r' => $this->reference,
'v' => $this->value,
'k' => $this->authorizationKey,
's' => $this->status,
't_key' => $this->key,
);
}
|
php
|
public function toArray()
{
return array(
'e' => $this->entity,
'r' => $this->reference,
'v' => $this->value,
'k' => $this->authorizationKey,
's' => $this->status,
't_key' => $this->key,
);
}
|
[
"public",
"function",
"toArray",
"(",
")",
"{",
"return",
"array",
"(",
"'e'",
"=>",
"$",
"this",
"->",
"entity",
",",
"'r'",
"=>",
"$",
"this",
"->",
"reference",
",",
"'v'",
"=>",
"$",
"this",
"->",
"value",
",",
"'k'",
"=>",
"$",
"this",
"->",
"authorizationKey",
",",
"'s'",
"=>",
"$",
"this",
"->",
"status",
",",
"'t_key'",
"=>",
"$",
"this",
"->",
"key",
",",
")",
";",
"}"
] |
Return array representation
@return array
|
[
"Return",
"array",
"representation"
] |
23e8d462f33834233cad4e9fbe9fc57267c1e573
|
https://github.com/gordalina/easypay-php/blob/23e8d462f33834233cad4e9fbe9fc57267c1e573/src/Gordalina/Easypay/Payment/PaymentResult.php#L152-L162
|
222,799
|
EcomDev/EcomDev_Varnish
|
src/shell/ecomdev-varnish.php
|
EcomDev_Varnish_Shell._parseArgs
|
protected function _parseArgs()
{
foreach ($_SERVER['argv'] as $index => $argument) {
if (isset($this->_actionArgsMap[$argument])) {
$this->_action = $argument;
unset($_SERVER['argv'][$index]);
break;
}
unset($_SERVER['argv'][$index]);
}
parent::_parseArgs();
}
|
php
|
protected function _parseArgs()
{
foreach ($_SERVER['argv'] as $index => $argument) {
if (isset($this->_actionArgsMap[$argument])) {
$this->_action = $argument;
unset($_SERVER['argv'][$index]);
break;
}
unset($_SERVER['argv'][$index]);
}
parent::_parseArgs();
}
|
[
"protected",
"function",
"_parseArgs",
"(",
")",
"{",
"foreach",
"(",
"$",
"_SERVER",
"[",
"'argv'",
"]",
"as",
"$",
"index",
"=>",
"$",
"argument",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_actionArgsMap",
"[",
"$",
"argument",
"]",
")",
")",
"{",
"$",
"this",
"->",
"_action",
"=",
"$",
"argument",
";",
"unset",
"(",
"$",
"_SERVER",
"[",
"'argv'",
"]",
"[",
"$",
"index",
"]",
")",
";",
"break",
";",
"}",
"unset",
"(",
"$",
"_SERVER",
"[",
"'argv'",
"]",
"[",
"$",
"index",
"]",
")",
";",
"}",
"parent",
"::",
"_parseArgs",
"(",
")",
";",
"}"
] |
Parses actions for shell script
|
[
"Parses",
"actions",
"for",
"shell",
"script"
] |
228b7b1bdaae15c1895f2533667fffa515447915
|
https://github.com/EcomDev/EcomDev_Varnish/blob/228b7b1bdaae15c1895f2533667fffa515447915/src/shell/ecomdev-varnish.php#L83-L95
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.