repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
shopgate/cart-integration-sdk
src/helper/redirect/JsScriptBuilder.php
Shopgate_Helper_Redirect_JsScriptBuilder.buildTags
public function buildTags( $pageType, $parameters = array() ) { if ($this->settingsManager->isMobileHeaderDisabled()) { return ''; } $parameters = $this->siteParameters + $parameters; $parameters['link_tags'] = $this->tagsGenerator->getTagsFor($pageType, $parameters); $parameters['redirect_code'] = $this->getRedirectCode($pageType); $parameters['shop_number'] = $this->shopNumber; $parameters += $this->settingsManager->getShopgateStaticUrl(); // pre-process the additional parameters to add in the correct JS variables $variable = new Shopgate_Model_Redirect_HtmlTagVariable(); $variable->setName('additional_parameters'); $jsTemplate = $this->templateParser->process( @file_get_contents($this->jsTemplateFilePath), $variable, $this->getAdditionalParameters($pageType) ); // process all variables left in the template (and those added with the processing of 'additional_parameters'. $variables = $this->templateParser->getVariables($jsTemplate); foreach ($variables as $variable) { $replacement = !empty($parameters[$variable->getName()]) ? $parameters[$variable->getName()] : ''; $jsTemplate = $this->templateParser->process($jsTemplate, $variable, $replacement); } return $jsTemplate; }
php
public function buildTags( $pageType, $parameters = array() ) { if ($this->settingsManager->isMobileHeaderDisabled()) { return ''; } $parameters = $this->siteParameters + $parameters; $parameters['link_tags'] = $this->tagsGenerator->getTagsFor($pageType, $parameters); $parameters['redirect_code'] = $this->getRedirectCode($pageType); $parameters['shop_number'] = $this->shopNumber; $parameters += $this->settingsManager->getShopgateStaticUrl(); // pre-process the additional parameters to add in the correct JS variables $variable = new Shopgate_Model_Redirect_HtmlTagVariable(); $variable->setName('additional_parameters'); $jsTemplate = $this->templateParser->process( @file_get_contents($this->jsTemplateFilePath), $variable, $this->getAdditionalParameters($pageType) ); // process all variables left in the template (and those added with the processing of 'additional_parameters'. $variables = $this->templateParser->getVariables($jsTemplate); foreach ($variables as $variable) { $replacement = !empty($parameters[$variable->getName()]) ? $parameters[$variable->getName()] : ''; $jsTemplate = $this->templateParser->process($jsTemplate, $variable, $replacement); } return $jsTemplate; }
[ "public", "function", "buildTags", "(", "$", "pageType", ",", "$", "parameters", "=", "array", "(", ")", ")", "{", "if", "(", "$", "this", "->", "settingsManager", "->", "isMobileHeaderDisabled", "(", ")", ")", "{", "return", "''", ";", "}", "$", "para...
@param string $pageType @param array $parameters [string, string] @return string
[ "@param", "string", "$pageType", "@param", "array", "$parameters", "[", "string", "string", "]" ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/helper/redirect/JsScriptBuilder.php#L85-L120
shopgate/cart-integration-sdk
src/helper/redirect/JsScriptBuilder.php
Shopgate_Helper_Redirect_JsScriptBuilder.setSiteParameters
public function setSiteParameters($params) { foreach ($params as $key => $param) { $this->setSiteParameter($key, $param); } return $this; }
php
public function setSiteParameters($params) { foreach ($params as $key => $param) { $this->setSiteParameter($key, $param); } return $this; }
[ "public", "function", "setSiteParameters", "(", "$", "params", ")", "{", "foreach", "(", "$", "params", "as", "$", "key", "=>", "$", "param", ")", "{", "$", "this", "->", "setSiteParameter", "(", "$", "key", ",", "$", "param", ")", ";", "}", "return"...
Helps set all parameters at once @param array $params - array(key => value) @return Shopgate_Helper_Redirect_JsScriptBuilder
[ "Helps", "set", "all", "parameters", "at", "once" ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/helper/redirect/JsScriptBuilder.php#L144-L151
shopgate/cart-integration-sdk
src/helper/redirect/JsScriptBuilder.php
Shopgate_Helper_Redirect_JsScriptBuilder.getAdditionalParameters
protected function getAdditionalParameters($pageType) { $additionalParameters = ''; $defaultRedirect = $this->settingsManager->isDefaultRedirectDisabled() ? 'false' : 'true'; $jsRedirect = $this->suppressRedirectJavascript ? 'false' : 'true'; $additionalParameters .= "_shopgate.is_default_redirect_disabled = {$defaultRedirect};\n"; $additionalParameters .= " _shopgate.redirect_to_webapp = {$jsRedirect};\n"; switch ($pageType) { case Shopgate_Helper_Redirect_TagsGeneratorInterface::PAGE_TYPE_CATEGORY: $additionalParameters .= '_shopgate.category_number = "{category_uid}";'; break; case Shopgate_Helper_Redirect_TagsGeneratorInterface::PAGE_TYPE_PRODUCT: $additionalParameters .= '_shopgate.item_number = "{product_uid}";'; break; case Shopgate_Helper_Redirect_TagsGeneratorInterface::PAGE_TYPE_CMS: $additionalParameters .= '_shopgate.cms_page = "{page_uid}";'; break; case Shopgate_Helper_Redirect_TagsGeneratorInterface::PAGE_TYPE_BRAND: $additionalParameters .= '_shopgate.brand_name = "{brand_name}";'; break; case Shopgate_Helper_Redirect_TagsGeneratorInterface::PAGE_TYPE_SEARCH: $additionalParameters .= '_shopgate.search_query = "{search_query:escaped}";'; break; } return $additionalParameters . "\n"; }
php
protected function getAdditionalParameters($pageType) { $additionalParameters = ''; $defaultRedirect = $this->settingsManager->isDefaultRedirectDisabled() ? 'false' : 'true'; $jsRedirect = $this->suppressRedirectJavascript ? 'false' : 'true'; $additionalParameters .= "_shopgate.is_default_redirect_disabled = {$defaultRedirect};\n"; $additionalParameters .= " _shopgate.redirect_to_webapp = {$jsRedirect};\n"; switch ($pageType) { case Shopgate_Helper_Redirect_TagsGeneratorInterface::PAGE_TYPE_CATEGORY: $additionalParameters .= '_shopgate.category_number = "{category_uid}";'; break; case Shopgate_Helper_Redirect_TagsGeneratorInterface::PAGE_TYPE_PRODUCT: $additionalParameters .= '_shopgate.item_number = "{product_uid}";'; break; case Shopgate_Helper_Redirect_TagsGeneratorInterface::PAGE_TYPE_CMS: $additionalParameters .= '_shopgate.cms_page = "{page_uid}";'; break; case Shopgate_Helper_Redirect_TagsGeneratorInterface::PAGE_TYPE_BRAND: $additionalParameters .= '_shopgate.brand_name = "{brand_name}";'; break; case Shopgate_Helper_Redirect_TagsGeneratorInterface::PAGE_TYPE_SEARCH: $additionalParameters .= '_shopgate.search_query = "{search_query:escaped}";'; break; } return $additionalParameters . "\n"; }
[ "protected", "function", "getAdditionalParameters", "(", "$", "pageType", ")", "{", "$", "additionalParameters", "=", "''", ";", "$", "defaultRedirect", "=", "$", "this", "->", "settingsManager", "->", "isDefaultRedirectDisabled", "(", ")", "?", "'false'", ":", ...
@param string $pageType @return string
[ "@param", "string", "$pageType" ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/helper/redirect/JsScriptBuilder.php#L198-L235
shopgate/cart-integration-sdk
src/helper/redirect/JsScriptBuilder.php
Shopgate_Helper_Redirect_JsScriptBuilder.getRedirectCode
protected function getRedirectCode($pageType) { return isset($this->pageTypeToRedirectMapping[$pageType]) ? $this->pageTypeToRedirectMapping[$pageType] : $pageType; }
php
protected function getRedirectCode($pageType) { return isset($this->pageTypeToRedirectMapping[$pageType]) ? $this->pageTypeToRedirectMapping[$pageType] : $pageType; }
[ "protected", "function", "getRedirectCode", "(", "$", "pageType", ")", "{", "return", "isset", "(", "$", "this", "->", "pageTypeToRedirectMapping", "[", "$", "pageType", "]", ")", "?", "$", "this", "->", "pageTypeToRedirectMapping", "[", "$", "pageType", "]", ...
@param string $pageType @return bool
[ "@param", "string", "$pageType" ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/helper/redirect/JsScriptBuilder.php#L273-L278
makinacorpus/drupal-ucms
ucms_search/src/Lucene/AbstractFuzzyQuery.php
AbstractFuzzyQuery.setFuzzyness
public function setFuzzyness($fuzzyness) { if ($fuzzyness != NULL && (! is_numeric($fuzzyness) || $fuzzyness < 0)) { throw new \InvalidArgumentException("Fuzyness/roaming value must be a positive integer, " . print_r($fuzzyness, TRUE) . " given"); } $this->fuzzyness = $fuzzyness; return $this; }
php
public function setFuzzyness($fuzzyness) { if ($fuzzyness != NULL && (! is_numeric($fuzzyness) || $fuzzyness < 0)) { throw new \InvalidArgumentException("Fuzyness/roaming value must be a positive integer, " . print_r($fuzzyness, TRUE) . " given"); } $this->fuzzyness = $fuzzyness; return $this; }
[ "public", "function", "setFuzzyness", "(", "$", "fuzzyness", ")", "{", "if", "(", "$", "fuzzyness", "!=", "NULL", "&&", "(", "!", "is_numeric", "(", "$", "fuzzyness", ")", "||", "$", "fuzzyness", "<", "0", ")", ")", "{", "throw", "new", "\\", "Invali...
Set fuzzyness or roaming value, both uses the same operator, only the type of data (phrase or term) on which you apply it matters @param int $fuzzyness Positive integer or null to unset @return AbstractFuzzyQuery
[ "Set", "fuzzyness", "or", "roaming", "value", "both", "uses", "the", "same", "operator", "only", "the", "type", "of", "data", "(", "phrase", "or", "term", ")", "on", "which", "you", "apply", "it", "matters" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_search/src/Lucene/AbstractFuzzyQuery.php#L19-L28
qloog/yaf-library
src/Events/Manager.php
Manager.attach
public function attach($eventType, $handler, $priority = 100) { if (!isset($this->listeners[$eventType])) { if ($this->enablePriorities) { $priorityQueue = new PriorityQueue(); $priorityQueue->setExtractFlags(PriorityQueue::EXTR_DATA); } else { $priorityQueue = []; } $this->listeners[$eventType] = $priorityQueue; } if (is_object($this->listeners[$eventType])) { /** @var PriorityQueue $priorityQueue */ $priorityQueue = &$this->listeners[$eventType]; $priorityQueue->insert($handler, $priority); } else { $this->listeners[$eventType][] = $handler; } }
php
public function attach($eventType, $handler, $priority = 100) { if (!isset($this->listeners[$eventType])) { if ($this->enablePriorities) { $priorityQueue = new PriorityQueue(); $priorityQueue->setExtractFlags(PriorityQueue::EXTR_DATA); } else { $priorityQueue = []; } $this->listeners[$eventType] = $priorityQueue; } if (is_object($this->listeners[$eventType])) { /** @var PriorityQueue $priorityQueue */ $priorityQueue = &$this->listeners[$eventType]; $priorityQueue->insert($handler, $priority); } else { $this->listeners[$eventType][] = $handler; } }
[ "public", "function", "attach", "(", "$", "eventType", ",", "$", "handler", ",", "$", "priority", "=", "100", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "listeners", "[", "$", "eventType", "]", ")", ")", "{", "if", "(", "$", "this...
添加事件监听者 @param string $eventType 事件类型 @param object|callable|string $handler 事件处理对象或回调对象或类名 @param int $priority 优先级, 数值越大优先级越高 @throws \Exception
[ "添加事件监听者" ]
train
https://github.com/qloog/yaf-library/blob/8e7dc276ffb335adfb298dffce9c0b533e14bd93/src/Events/Manager.php#L55-L75
qloog/yaf-library
src/Events/Manager.php
Manager.detach
public function detach($eventType, $handler) { if (!isset($this->listeners[$eventType])) { return; } if (is_object($this->listeners[$eventType])) { // @attention PriorityQueue不支持移除 $newPriorityQueue = new PriorityQueue(); $newPriorityQueue->setExtractFlags(PriorityQueue::EXTR_DATA); /** @var PriorityQueue $oldPriorityQueue */ $oldPriorityQueue = &$this->listeners[$eventType]; $oldPriorityQueue->setExtractFlags(PriorityQueue::EXTR_BOTH); $oldPriorityQueue->top(); foreach ($oldPriorityQueue as $currHandler) { if ($currHandler['data'] !== $handler) { $newPriorityQueue->insert($currHandler['data'], $currHandler['priority']); } } $this->listeners[$eventType] = $newPriorityQueue; } else { if (($idx = array_search($handler, $this->listeners[$eventType], true)) !== false) { unset($this->listeners[$eventType][$idx]); } } }
php
public function detach($eventType, $handler) { if (!isset($this->listeners[$eventType])) { return; } if (is_object($this->listeners[$eventType])) { // @attention PriorityQueue不支持移除 $newPriorityQueue = new PriorityQueue(); $newPriorityQueue->setExtractFlags(PriorityQueue::EXTR_DATA); /** @var PriorityQueue $oldPriorityQueue */ $oldPriorityQueue = &$this->listeners[$eventType]; $oldPriorityQueue->setExtractFlags(PriorityQueue::EXTR_BOTH); $oldPriorityQueue->top(); foreach ($oldPriorityQueue as $currHandler) { if ($currHandler['data'] !== $handler) { $newPriorityQueue->insert($currHandler['data'], $currHandler['priority']); } } $this->listeners[$eventType] = $newPriorityQueue; } else { if (($idx = array_search($handler, $this->listeners[$eventType], true)) !== false) { unset($this->listeners[$eventType][$idx]); } } }
[ "public", "function", "detach", "(", "$", "eventType", ",", "$", "handler", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "listeners", "[", "$", "eventType", "]", ")", ")", "{", "return", ";", "}", "if", "(", "is_object", "(", "$", "...
移除事件监听者 @param string $eventType @param object|callable|string $handler @throws \Exception
[ "移除事件监听者" ]
train
https://github.com/qloog/yaf-library/blob/8e7dc276ffb335adfb298dffce9c0b533e14bd93/src/Events/Manager.php#L85-L113
qloog/yaf-library
src/Events/Manager.php
Manager.detachAll
public function detachAll($type = null) { if ($type === null) { $this->listeners = []; } else { if (isset($this->listeners[$type])) { unset($this->listeners[$type]); } } }
php
public function detachAll($type = null) { if ($type === null) { $this->listeners = []; } else { if (isset($this->listeners[$type])) { unset($this->listeners[$type]); } } }
[ "public", "function", "detachAll", "(", "$", "type", "=", "null", ")", "{", "if", "(", "$", "type", "===", "null", ")", "{", "$", "this", "->", "listeners", "=", "[", "]", ";", "}", "else", "{", "if", "(", "isset", "(", "$", "this", "->", "list...
移除对应事件所有监听者 @param string $type
[ "移除对应事件所有监听者" ]
train
https://github.com/qloog/yaf-library/blob/8e7dc276ffb335adfb298dffce9c0b533e14bd93/src/Events/Manager.php#L148-L157
qloog/yaf-library
src/Events/Manager.php
Manager.fire
public function fire($eventType, $source, $data = null, $cancelable = true) { if (!$this->listeners) { return; } if (strpos($eventType, ':') === false) { throw new \Exception('事件类型字符串必须使用":"分隔'); } list($type, $eventName) = explode(':', $eventType); if (!isset($this->listeners[$type]) && !isset($this->listeners[$eventType])) { return; } $event = new Event($eventName, $source, $data, $cancelable); // 总类型(如"db")对应的事件处理 if (isset($this->listeners[$type])) { $this->performEventHandlers($this->listeners[$type], $event); } // 分类型(如"db:beforeQuery")对应的事件处理 if (isset($this->listeners[$eventType])) { $this->performEventHandlers($this->listeners[$eventType], $event); } }
php
public function fire($eventType, $source, $data = null, $cancelable = true) { if (!$this->listeners) { return; } if (strpos($eventType, ':') === false) { throw new \Exception('事件类型字符串必须使用":"分隔'); } list($type, $eventName) = explode(':', $eventType); if (!isset($this->listeners[$type]) && !isset($this->listeners[$eventType])) { return; } $event = new Event($eventName, $source, $data, $cancelable); // 总类型(如"db")对应的事件处理 if (isset($this->listeners[$type])) { $this->performEventHandlers($this->listeners[$type], $event); } // 分类型(如"db:beforeQuery")对应的事件处理 if (isset($this->listeners[$eventType])) { $this->performEventHandlers($this->listeners[$eventType], $event); } }
[ "public", "function", "fire", "(", "$", "eventType", ",", "$", "source", ",", "$", "data", "=", "null", ",", "$", "cancelable", "=", "true", ")", "{", "if", "(", "!", "$", "this", "->", "listeners", ")", "{", "return", ";", "}", "if", "(", "strpo...
触发事件, 通知相关监听者执行响应处理 @param string $eventType 触发的事件类型, 必须包括":", 如"db:beforeQuery" @param object $source 事件来源对象 @param mixed $data 附加的事件数据 @param bool $cancelable 是否可取消, 停止往后传播 @throws \Exception
[ "触发事件", "通知相关监听者执行响应处理" ]
train
https://github.com/qloog/yaf-library/blob/8e7dc276ffb335adfb298dffce9c0b533e14bd93/src/Events/Manager.php#L169-L196
qloog/yaf-library
src/Events/Manager.php
Manager.performEventHandlers
private function performEventHandlers($handlers, $event) { if (is_object($handlers)) { // clone并重置到起始位置, 防止影响其他触发响应处理 /** @var PriorityQueue $handlers */ $handlers = clone $handlers; $handlers->top(); } $cancelable = $event->getCancelable(); foreach ($handlers as $handler) { $this->performEventHandler($event, $handler); if ($cancelable && $event->isStopped()) { break; } } }
php
private function performEventHandlers($handlers, $event) { if (is_object($handlers)) { // clone并重置到起始位置, 防止影响其他触发响应处理 /** @var PriorityQueue $handlers */ $handlers = clone $handlers; $handlers->top(); } $cancelable = $event->getCancelable(); foreach ($handlers as $handler) { $this->performEventHandler($event, $handler); if ($cancelable && $event->isStopped()) { break; } } }
[ "private", "function", "performEventHandlers", "(", "$", "handlers", ",", "$", "event", ")", "{", "if", "(", "is_object", "(", "$", "handlers", ")", ")", "{", "// clone并重置到起始位置, 防止影响其他触发响应处理", "/** @var PriorityQueue $handlers */", "$", "handlers", "=", "clone", "...
执行事件响应处理 @param PriorityQueue|array $handlers @param Event $event
[ "执行事件响应处理" ]
train
https://github.com/qloog/yaf-library/blob/8e7dc276ffb335adfb298dffce9c0b533e14bd93/src/Events/Manager.php#L204-L222
accompli/accompli
src/Report/AbstractReport.php
AbstractReport.generate
public function generate(ConsoleLoggerInterface $logger) { $logLevel = LogLevel::NOTICE; $style = TitleBlock::STYLE_SUCCESS; if ($this->eventDataCollector->hasCountedFailedEvents()) { $logLevel = LogLevel::ERROR; $style = TitleBlock::STYLE_FAILURE; } elseif ($this->eventDataCollector->hasCountedLogLevel(LogLevel::EMERGENCY) || $this->eventDataCollector->hasCountedLogLevel(LogLevel::ALERT) || $this->eventDataCollector->hasCountedLogLevel(LogLevel::CRITICAL) || $this->eventDataCollector->hasCountedLogLevel(LogLevel::ERROR) || $this->eventDataCollector->hasCountedLogLevel(LogLevel::WARNING)) { $logLevel = LogLevel::WARNING; $style = TitleBlock::STYLE_ERRORED_SUCCESS; } $output = $logger->getOutput($logLevel); $titleBlock = new TitleBlock($output, $this->messages[$style], $style); $titleBlock->render(); $dataCollectorsData = array(); foreach ($this->dataCollectors as $dataCollector) { $data = $dataCollector->getData($logger->getVerbosity()); foreach ($data as $label => $value) { $dataCollectorsData[] = array($label, $value); } } $table = new Table($output); $table->setRows($dataCollectorsData); $table->setStyle('symfony-style-guide'); $table->render(); $output->writeln(''); }
php
public function generate(ConsoleLoggerInterface $logger) { $logLevel = LogLevel::NOTICE; $style = TitleBlock::STYLE_SUCCESS; if ($this->eventDataCollector->hasCountedFailedEvents()) { $logLevel = LogLevel::ERROR; $style = TitleBlock::STYLE_FAILURE; } elseif ($this->eventDataCollector->hasCountedLogLevel(LogLevel::EMERGENCY) || $this->eventDataCollector->hasCountedLogLevel(LogLevel::ALERT) || $this->eventDataCollector->hasCountedLogLevel(LogLevel::CRITICAL) || $this->eventDataCollector->hasCountedLogLevel(LogLevel::ERROR) || $this->eventDataCollector->hasCountedLogLevel(LogLevel::WARNING)) { $logLevel = LogLevel::WARNING; $style = TitleBlock::STYLE_ERRORED_SUCCESS; } $output = $logger->getOutput($logLevel); $titleBlock = new TitleBlock($output, $this->messages[$style], $style); $titleBlock->render(); $dataCollectorsData = array(); foreach ($this->dataCollectors as $dataCollector) { $data = $dataCollector->getData($logger->getVerbosity()); foreach ($data as $label => $value) { $dataCollectorsData[] = array($label, $value); } } $table = new Table($output); $table->setRows($dataCollectorsData); $table->setStyle('symfony-style-guide'); $table->render(); $output->writeln(''); }
[ "public", "function", "generate", "(", "ConsoleLoggerInterface", "$", "logger", ")", "{", "$", "logLevel", "=", "LogLevel", "::", "NOTICE", ";", "$", "style", "=", "TitleBlock", "::", "STYLE_SUCCESS", ";", "if", "(", "$", "this", "->", "eventDataCollector", ...
Generates the output for the report. @param ConsoleLoggerInterface $logger
[ "Generates", "the", "output", "for", "the", "report", "." ]
train
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Report/AbstractReport.php#L61-L92
makinacorpus/drupal-ucms
ucms_seo/src/Path/AliasCacheLookup.php
AliasCacheLookup.write
public function write() { if ($this->isModified && $this->cacheKey) { $this->cache->set($this->cacheKey, $this->queried); $this->isModified = false; } }
php
public function write() { if ($this->isModified && $this->cacheKey) { $this->cache->set($this->cacheKey, $this->queried); $this->isModified = false; } }
[ "public", "function", "write", "(", ")", "{", "if", "(", "$", "this", "->", "isModified", "&&", "$", "this", "->", "cacheKey", ")", "{", "$", "this", "->", "cache", "->", "set", "(", "$", "this", "->", "cacheKey", ",", "$", "this", "->", "queried",...
Write current cache This will be called by a terminate event
[ "Write", "current", "cache" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/Path/AliasCacheLookup.php#L93-L99
makinacorpus/drupal-ucms
ucms_seo/src/Path/AliasCacheLookup.php
AliasCacheLookup.fetchAlias
private function fetchAlias($nodeId, $siteId) { // We have no source loaded yet, attempt to find it properly and // populate the cache, even if there's nothing to load $alias = $this->aliasManager->getPathAlias($nodeId, $siteId); $this->isModified = true; if ($alias) { $this->loaded[$nodeId][$siteId] = $alias; } return $alias; }
php
private function fetchAlias($nodeId, $siteId) { // We have no source loaded yet, attempt to find it properly and // populate the cache, even if there's nothing to load $alias = $this->aliasManager->getPathAlias($nodeId, $siteId); $this->isModified = true; if ($alias) { $this->loaded[$nodeId][$siteId] = $alias; } return $alias; }
[ "private", "function", "fetchAlias", "(", "$", "nodeId", ",", "$", "siteId", ")", "{", "// We have no source loaded yet, attempt to find it properly and", "// populate the cache, even if there's nothing to load", "$", "alias", "=", "$", "this", "->", "aliasManager", "->", "...
Fetch alias for node using the manager, and store it into cache @param int $nodeId @param int $siteId @return string
[ "Fetch", "alias", "for", "node", "using", "the", "manager", "and", "store", "it", "into", "cache" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/Path/AliasCacheLookup.php#L109-L122
makinacorpus/drupal-ucms
ucms_seo/src/Path/AliasCacheLookup.php
AliasCacheLookup.lookup
public function lookup($nodeId, $siteId) { if (!$this->isLoaded) { $this->load(); $this->isLoaded = true; } // Build the array we will store at the end of the query if we have // anything changed during the request if ($this->queriedCount < self::MAX_CACHE_SIZE) { $this->queried[$nodeId][$siteId] = true; } $this->queriedCount++; if (!isset($this->loaded[$nodeId][$siteId])) { // We already have cached this path in the past, or it was not in // original cache source array, or it is non existing anymore or // outdated, our cache is broken, we need to lookup and update return $this->fetchAlias($nodeId, $siteId) ?? 'node/' . $nodeId; } // Best case scenario, it exists! return $this->loaded[$nodeId][$siteId]; }
php
public function lookup($nodeId, $siteId) { if (!$this->isLoaded) { $this->load(); $this->isLoaded = true; } // Build the array we will store at the end of the query if we have // anything changed during the request if ($this->queriedCount < self::MAX_CACHE_SIZE) { $this->queried[$nodeId][$siteId] = true; } $this->queriedCount++; if (!isset($this->loaded[$nodeId][$siteId])) { // We already have cached this path in the past, or it was not in // original cache source array, or it is non existing anymore or // outdated, our cache is broken, we need to lookup and update return $this->fetchAlias($nodeId, $siteId) ?? 'node/' . $nodeId; } // Best case scenario, it exists! return $this->loaded[$nodeId][$siteId]; }
[ "public", "function", "lookup", "(", "$", "nodeId", ",", "$", "siteId", ")", "{", "if", "(", "!", "$", "this", "->", "isLoaded", ")", "{", "$", "this", "->", "load", "(", ")", ";", "$", "this", "->", "isLoaded", "=", "true", ";", "}", "// Build t...
Lookup for given source @param int $source @param int $siteId @return string
[ "Lookup", "for", "given", "source" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/Path/AliasCacheLookup.php#L132-L155
makinacorpus/drupal-ucms
ucms_seo/src/Path/AliasCacheLookup.php
AliasCacheLookup.load
private function load() { $this->loaded = []; $this->queried = []; $this->queriedCount = 0; // Sorry, this is nothing to load if (!$this->cacheKey) { return; } $cached = $this->cache->get($this->cacheKey); // Cache might be invalid, just don't let it broke everything, if not // attempt a graceful preload of all routes that are not outdated yet if ($cached && is_array($cached->data)) { // We need both node identifiers and site identifiers $nodeIdList = []; $siteIdList = []; foreach ($cached->data as $nodeId => $data) { $nodeIdList[] = $nodeId; foreach ($data as $siteId) { if (!isset($siteIdList[$siteId])) { $siteIdList[$siteId] = $siteId; } } } $query = $this ->database ->select('ucms_seo_route', 'r') ->fields('r', ['node_id', 'site_id', 'route']) ->condition('r.site_id', $siteIdList) ->condition('r.node_id', $nodeIdList) ; if (!$this->allowInvalid) { $query->condition('r.is_outdated', 0); } $rows = $query->execute(); foreach ($rows as $row) { $this->loaded[$row->node_id][$row->site_id] = $row->route; } } }
php
private function load() { $this->loaded = []; $this->queried = []; $this->queriedCount = 0; // Sorry, this is nothing to load if (!$this->cacheKey) { return; } $cached = $this->cache->get($this->cacheKey); // Cache might be invalid, just don't let it broke everything, if not // attempt a graceful preload of all routes that are not outdated yet if ($cached && is_array($cached->data)) { // We need both node identifiers and site identifiers $nodeIdList = []; $siteIdList = []; foreach ($cached->data as $nodeId => $data) { $nodeIdList[] = $nodeId; foreach ($data as $siteId) { if (!isset($siteIdList[$siteId])) { $siteIdList[$siteId] = $siteId; } } } $query = $this ->database ->select('ucms_seo_route', 'r') ->fields('r', ['node_id', 'site_id', 'route']) ->condition('r.site_id', $siteIdList) ->condition('r.node_id', $nodeIdList) ; if (!$this->allowInvalid) { $query->condition('r.is_outdated', 0); } $rows = $query->execute(); foreach ($rows as $row) { $this->loaded[$row->node_id][$row->site_id] = $row->route; } } }
[ "private", "function", "load", "(", ")", "{", "$", "this", "->", "loaded", "=", "[", "]", ";", "$", "this", "->", "queried", "=", "[", "]", ";", "$", "this", "->", "queriedCount", "=", "0", ";", "// Sorry, this is nothing to load", "if", "(", "!", "$...
Load cache
[ "Load", "cache" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/Path/AliasCacheLookup.php#L160-L207
makinacorpus/drupal-ucms
ucms_seo/src/Path/AliasCacheLookup.php
AliasCacheLookup.refresh
public function refresh($siteId = null) { // @sorry for this, but Drupal 8 does not handle prefixes // and we don't have a fallback for tags yet in sf_dic if ($siteId) { cache_clear_all('alias#master#', 'cache', true); cache_clear_all('alias#' . $siteId . '#', 'cache', true); } else { cache_clear_all('alias#', 'cache', true); } }
php
public function refresh($siteId = null) { // @sorry for this, but Drupal 8 does not handle prefixes // and we don't have a fallback for tags yet in sf_dic if ($siteId) { cache_clear_all('alias#master#', 'cache', true); cache_clear_all('alias#' . $siteId . '#', 'cache', true); } else { cache_clear_all('alias#', 'cache', true); } }
[ "public", "function", "refresh", "(", "$", "siteId", "=", "null", ")", "{", "// @sorry for this, but Drupal 8 does not handle prefixes", "// and we don't have a fallback for tags yet in sf_dic", "if", "(", "$", "siteId", ")", "{", "cache_clear_all", "(", "'alias#master#'", ...
Clear caches for site This will always refresh cache for master as well. @param int $siteId If set, refresh only for this site, delete all otherwise
[ "Clear", "caches", "for", "site" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/Path/AliasCacheLookup.php#L217-L227
makinacorpus/drupal-ucms
ucms_seo/src/Path/AliasCacheLookup.php
AliasCacheLookup.setEnvironment
public function setEnvironment($siteId, $path, $query = []) { if (null === $siteId) { $cacheKey = 'alias#master#' . $path; } else { $cacheKey = 'alias#' . $siteId . '#' . $path; } if ($cacheKey === $this->cacheKey) { return; } $this->cacheKey = $cacheKey; $this->isLoaded = false; }
php
public function setEnvironment($siteId, $path, $query = []) { if (null === $siteId) { $cacheKey = 'alias#master#' . $path; } else { $cacheKey = 'alias#' . $siteId . '#' . $path; } if ($cacheKey === $this->cacheKey) { return; } $this->cacheKey = $cacheKey; $this->isLoaded = false; }
[ "public", "function", "setEnvironment", "(", "$", "siteId", ",", "$", "path", ",", "$", "query", "=", "[", "]", ")", "{", "if", "(", "null", "===", "$", "siteId", ")", "{", "$", "cacheKey", "=", "'alias#master#'", ".", "$", "path", ";", "}", "else"...
Set internals This will be called on site init event @param int|string $siteId @param string $path
[ "Set", "internals" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/Path/AliasCacheLookup.php#L237-L251
isfonzar/sentiment-thermometer
src/Providers/SentimentAnalytics.php
SentimentAnalytics.analyze
public function analyze($results) { $sentimentResponse = new SentimentResponse(); if (empty($results)) { return $sentimentResponse; } foreach ($results as $sentence) { $sentenceAnalysis = $this->sentimentProvider->score($sentence); $sentimentResponse ->sumPositive($sentenceAnalysis['pos']) ->sumNegative($sentenceAnalysis['neg']) ->sumNeutral($sentenceAnalysis['neu']); } $sentimentResponse->divideAllFields(count($results)); return $sentimentResponse; }
php
public function analyze($results) { $sentimentResponse = new SentimentResponse(); if (empty($results)) { return $sentimentResponse; } foreach ($results as $sentence) { $sentenceAnalysis = $this->sentimentProvider->score($sentence); $sentimentResponse ->sumPositive($sentenceAnalysis['pos']) ->sumNegative($sentenceAnalysis['neg']) ->sumNeutral($sentenceAnalysis['neu']); } $sentimentResponse->divideAllFields(count($results)); return $sentimentResponse; }
[ "public", "function", "analyze", "(", "$", "results", ")", "{", "$", "sentimentResponse", "=", "new", "SentimentResponse", "(", ")", ";", "if", "(", "empty", "(", "$", "results", ")", ")", "{", "return", "$", "sentimentResponse", ";", "}", "foreach", "("...
@param $results @return \iiiicaro\SentimentThermometer\Providers\DataModels\SentimentResponse
[ "@param", "$results" ]
train
https://github.com/isfonzar/sentiment-thermometer/blob/457bf2b0b1e6bd287b069f32f8decb77dc5d59fc/src/Providers/SentimentAnalytics.php#L30-L52
makinacorpus/drupal-ucms
ucms_search/src/Mapping/DateType.php
DateType.convert
public function convert($value) { if ($value instanceof \DateTime) { return $value->format(\DateTime::ISO8601); } if (is_string($value)) { if ($date = new \DateTime($value)) { return $date->format(\DateTime::ISO8601); } } if (is_int($value)) { if ($date = new \DateTime('@' . $value)) { return $date->format(\DateTime::ISO8601); } } return (string)$value; }
php
public function convert($value) { if ($value instanceof \DateTime) { return $value->format(\DateTime::ISO8601); } if (is_string($value)) { if ($date = new \DateTime($value)) { return $date->format(\DateTime::ISO8601); } } if (is_int($value)) { if ($date = new \DateTime('@' . $value)) { return $date->format(\DateTime::ISO8601); } } return (string)$value; }
[ "public", "function", "convert", "(", "$", "value", ")", "{", "if", "(", "$", "value", "instanceof", "\\", "DateTime", ")", "{", "return", "$", "value", "->", "format", "(", "\\", "DateTime", "::", "ISO8601", ")", ";", "}", "if", "(", "is_string", "(...
{@inheritdoc}
[ "{" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_search/src/Mapping/DateType.php#L10-L29
qloog/yaf-library
src/Databases/RedisDb.php
RedisDb.getInstance
public static function getInstance($name = 'default') { if (isset(self::$instance[$name])) { return self::$instance[$name]; } $config = Registry::get('config'); $config = $config['redis']; if (!isset($config[$name], $config[$name]['host'])) { throw new ConfigException('No redis config!'); } $config = $config[$name]; $connectType = isset($config['pconnect']) && $config['pconnect'] ? 'pconnect' : 'connect'; $redis = new self; if (!$redis->$connectType( $config['host'], isset($config['port']) ? $config['port'] : 6379, isset($config['timeout']) ? $config['timeout'] : 1 )) { throw new RedisException('Redis server went away!'); } if (isset($config['prefix'])) { $redis->setOption(Redis::OPT_PREFIX, $config['prefix']); } return self::$instance[$name] = $redis; }
php
public static function getInstance($name = 'default') { if (isset(self::$instance[$name])) { return self::$instance[$name]; } $config = Registry::get('config'); $config = $config['redis']; if (!isset($config[$name], $config[$name]['host'])) { throw new ConfigException('No redis config!'); } $config = $config[$name]; $connectType = isset($config['pconnect']) && $config['pconnect'] ? 'pconnect' : 'connect'; $redis = new self; if (!$redis->$connectType( $config['host'], isset($config['port']) ? $config['port'] : 6379, isset($config['timeout']) ? $config['timeout'] : 1 )) { throw new RedisException('Redis server went away!'); } if (isset($config['prefix'])) { $redis->setOption(Redis::OPT_PREFIX, $config['prefix']); } return self::$instance[$name] = $redis; }
[ "public", "static", "function", "getInstance", "(", "$", "name", "=", "'default'", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "instance", "[", "$", "name", "]", ")", ")", "{", "return", "self", "::", "$", "instance", "[", "$", "name", "]...
获取Redis链接实例 @param string $name @throws ConfigException|RedisException @return self
[ "获取Redis链接实例" ]
train
https://github.com/qloog/yaf-library/blob/8e7dc276ffb335adfb298dffce9c0b533e14bd93/src/Databases/RedisDb.php#L29-L58
shopgate/cart-integration-sdk
src/models/catalog/Shipping.php
Shopgate_Model_Catalog_Shipping.asXml
public function asXml(Shopgate_Model_XmlResultObject $itemNode) { /** * @var Shopgate_Model_XmlResultObject $shippingNode */ $shippingNode = $itemNode->addChild('shipping'); $shippingNode->addChild('costs_per_order', $this->getCostsPerOrder(), null, false); $shippingNode->addChild('additional_costs_per_unit', $this->getAdditionalCostsPerUnit(), null, false); $shippingNode->addChild('is_free', (int)$this->getIsFree()); return $itemNode; }
php
public function asXml(Shopgate_Model_XmlResultObject $itemNode) { /** * @var Shopgate_Model_XmlResultObject $shippingNode */ $shippingNode = $itemNode->addChild('shipping'); $shippingNode->addChild('costs_per_order', $this->getCostsPerOrder(), null, false); $shippingNode->addChild('additional_costs_per_unit', $this->getAdditionalCostsPerUnit(), null, false); $shippingNode->addChild('is_free', (int)$this->getIsFree()); return $itemNode; }
[ "public", "function", "asXml", "(", "Shopgate_Model_XmlResultObject", "$", "itemNode", ")", "{", "/**\n * @var Shopgate_Model_XmlResultObject $shippingNode\n */", "$", "shippingNode", "=", "$", "itemNode", "->", "addChild", "(", "'shipping'", ")", ";", "$", ...
@param Shopgate_Model_XmlResultObject $itemNode @return Shopgate_Model_XmlResultObject
[ "@param", "Shopgate_Model_XmlResultObject", "$itemNode" ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/models/catalog/Shipping.php#L55-L66
makinacorpus/drupal-ucms
ucms_seo/src/Action/RedirectActionProvider.php
RedirectActionProvider.getActions
public function getActions($item, $primaryOnly = false, array $groups = []) { $ret = []; /** @var \MakinaCorpus\Ucms\Seo\Path\Redirect $item */ $siteId = $item->getSiteId(); $uri = $this->siteManager->getUrlGenerator()->generateUrl($siteId, 'node/' . $item->getNodeId()); $ret[] = new Action($this->t("Go to site"), $uri, null, 'external-link'); return $ret; }
php
public function getActions($item, $primaryOnly = false, array $groups = []) { $ret = []; /** @var \MakinaCorpus\Ucms\Seo\Path\Redirect $item */ $siteId = $item->getSiteId(); $uri = $this->siteManager->getUrlGenerator()->generateUrl($siteId, 'node/' . $item->getNodeId()); $ret[] = new Action($this->t("Go to site"), $uri, null, 'external-link'); return $ret; }
[ "public", "function", "getActions", "(", "$", "item", ",", "$", "primaryOnly", "=", "false", ",", "array", "$", "groups", "=", "[", "]", ")", "{", "$", "ret", "=", "[", "]", ";", "/** @var \\MakinaCorpus\\Ucms\\Seo\\Path\\Redirect $item */", "$", "siteId", "...
{inheritdoc}
[ "{", "inheritdoc", "}" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/Action/RedirectActionProvider.php#L33-L44
makinacorpus/drupal-ucms
ucms_search/src/Admin/IndexListForm.php
IndexListForm.buildForm
public function buildForm(array $form, FormStateInterface $form_state) { $header = [ $this->t("Id"), $this->t("Name"), $this->t("Total"), $this->t("Queued"), $this->t("Indexed"), $this->t("Size"), '' ]; $indices = $this->indexStorage->names(); $stats = null; $aliases = []; foreach (array_keys($indices) as $index) { $aliases[$index] = $this->indexStorage->getIndexRealname($index); } $q = $this->db->select('ucms_search_status', 's'); $q->fields('s', ['index_key']); $q->addExpression("COUNT(index_key)", 'count'); $waiting = $q ->condition('s.needs_reindex', 0, '<>') ->groupBy('s.index_key') ->execute() ->fetchAllKeyed() ; $q = $this->db->select('ucms_search_status', 's'); $q->fields('s', ['index_key']); $q->addExpression("COUNT(index_key)", 'count'); $total = $q ->groupBy('s.index_key') ->execute() ->fetchAllKeyed() ; try { $stats = $this->client->indices()->status(['index' => implode(',', $aliases)]); } catch (\Exception $e) { watchdog_exception(__FUNCTION__, $e); } $rows = []; foreach ($indices as $index => $name) { $alias = $aliases[$index]; $row = [ check_plain($index), check_plain($name), ]; $row[] = isset($total[$index]) ? number_format($total[$index]) : 0; $row[] = isset($waiting[$index]) ? number_format($waiting[$index]) : 0; if ($stats && $stats['indices'][$alias]) { $row[] = number_format($stats['indices'][$alias]['docs']['num_docs']); $row[] = $this->formatBytes($stats['indices'][$alias]['index']['size_in_bytes']); } else { $row[] = $row[] = '<em>' . $this->t("Error") . '</em>'; } $actions = $this->getIndexOperations($index); $row[] = drupal_render($actions); $rows[$index] = $row; } $form['indices'] = [ '#type' => 'tableselect', '#header' => $header, '#options' => $rows, '#required' => true, ]; $form['actions']['#type'] = 'actions'; $form['actions']['reindex'] = [ '#type' => 'submit', '#value' => $this->t("Re-index selected"), '#submit' => ['::reindexSubmit'], ]; $form['actions']['index'] = [ '#type' => 'submit', '#value' => $this->t("Index missing"), '#submit' => ['::indexMissingSubmit'], ]; return $form; }
php
public function buildForm(array $form, FormStateInterface $form_state) { $header = [ $this->t("Id"), $this->t("Name"), $this->t("Total"), $this->t("Queued"), $this->t("Indexed"), $this->t("Size"), '' ]; $indices = $this->indexStorage->names(); $stats = null; $aliases = []; foreach (array_keys($indices) as $index) { $aliases[$index] = $this->indexStorage->getIndexRealname($index); } $q = $this->db->select('ucms_search_status', 's'); $q->fields('s', ['index_key']); $q->addExpression("COUNT(index_key)", 'count'); $waiting = $q ->condition('s.needs_reindex', 0, '<>') ->groupBy('s.index_key') ->execute() ->fetchAllKeyed() ; $q = $this->db->select('ucms_search_status', 's'); $q->fields('s', ['index_key']); $q->addExpression("COUNT(index_key)", 'count'); $total = $q ->groupBy('s.index_key') ->execute() ->fetchAllKeyed() ; try { $stats = $this->client->indices()->status(['index' => implode(',', $aliases)]); } catch (\Exception $e) { watchdog_exception(__FUNCTION__, $e); } $rows = []; foreach ($indices as $index => $name) { $alias = $aliases[$index]; $row = [ check_plain($index), check_plain($name), ]; $row[] = isset($total[$index]) ? number_format($total[$index]) : 0; $row[] = isset($waiting[$index]) ? number_format($waiting[$index]) : 0; if ($stats && $stats['indices'][$alias]) { $row[] = number_format($stats['indices'][$alias]['docs']['num_docs']); $row[] = $this->formatBytes($stats['indices'][$alias]['index']['size_in_bytes']); } else { $row[] = $row[] = '<em>' . $this->t("Error") . '</em>'; } $actions = $this->getIndexOperations($index); $row[] = drupal_render($actions); $rows[$index] = $row; } $form['indices'] = [ '#type' => 'tableselect', '#header' => $header, '#options' => $rows, '#required' => true, ]; $form['actions']['#type'] = 'actions'; $form['actions']['reindex'] = [ '#type' => 'submit', '#value' => $this->t("Re-index selected"), '#submit' => ['::reindexSubmit'], ]; $form['actions']['index'] = [ '#type' => 'submit', '#value' => $this->t("Index missing"), '#submit' => ['::indexMissingSubmit'], ]; return $form; }
[ "public", "function", "buildForm", "(", "array", "$", "form", ",", "FormStateInterface", "$", "form_state", ")", "{", "$", "header", "=", "[", "$", "this", "->", "t", "(", "\"Id\"", ")", ",", "$", "this", "->", "t", "(", "\"Name\"", ")", ",", "$", ...
{inheritdoc}
[ "{", "inheritdoc", "}" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_search/src/Admin/IndexListForm.php#L119-L209
makinacorpus/drupal-ucms
ucms_search/src/Admin/IndexListForm.php
IndexListForm.reindexSubmit
public function reindexSubmit(array &$form, FormStateInterface $form_state) { $operations = []; foreach ($form_state->getValue('indices') as $index => $value) { if ($value && $value === $index) { $operations[] = ['ucms_search_admin_reindex_batch_operation', [$index]]; } } batch_set([ 'title' => $this->t("Re-indexing"), 'file' => drupal_get_path('module', 'ucms_search') . '/ucms_search.admin.inc', 'operations' => $operations, ]); }
php
public function reindexSubmit(array &$form, FormStateInterface $form_state) { $operations = []; foreach ($form_state->getValue('indices') as $index => $value) { if ($value && $value === $index) { $operations[] = ['ucms_search_admin_reindex_batch_operation', [$index]]; } } batch_set([ 'title' => $this->t("Re-indexing"), 'file' => drupal_get_path('module', 'ucms_search') . '/ucms_search.admin.inc', 'operations' => $operations, ]); }
[ "public", "function", "reindexSubmit", "(", "array", "&", "$", "form", ",", "FormStateInterface", "$", "form_state", ")", "{", "$", "operations", "=", "[", "]", ";", "foreach", "(", "$", "form_state", "->", "getValue", "(", "'indices'", ")", "as", "$", "...
Reindex submit
[ "Reindex", "submit" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_search/src/Admin/IndexListForm.php#L214-L228
makinacorpus/drupal-ucms
ucms_layout/src/Context.php
Context.commit
public function commit() { // Throws a nice exception if no token $this->getToken(); if (!$this->layout instanceof Layout) { throw new \LogicException("No contextual instance is set, cannot commit"); } // This gets the temporary storage until now $this->getStorage()->delete($this->layout->getId()); // Loaded instance is supposed to be the false one $this->storage->save($this->layout); $this->setToken(null); return $this; }
php
public function commit() { // Throws a nice exception if no token $this->getToken(); if (!$this->layout instanceof Layout) { throw new \LogicException("No contextual instance is set, cannot commit"); } // This gets the temporary storage until now $this->getStorage()->delete($this->layout->getId()); // Loaded instance is supposed to be the false one $this->storage->save($this->layout); $this->setToken(null); return $this; }
[ "public", "function", "commit", "(", ")", "{", "// Throws a nice exception if no token", "$", "this", "->", "getToken", "(", ")", ";", "if", "(", "!", "$", "this", "->", "layout", "instanceof", "Layout", ")", "{", "throw", "new", "\\", "LogicException", "(",...
Commit session changes and restore storage @return Context
[ "Commit", "session", "changes", "and", "restore", "storage" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_layout/src/Context.php#L56-L73
makinacorpus/drupal-ucms
ucms_layout/src/Context.php
Context.rollback
public function rollback() { // Throws a nice exception if no token $this->getToken(); if (!$this->layout instanceof Layout) { throw new \LogicException("No contextual instance is set, cannot commit"); } // Loaded instance is supposed to be the false one // This gets the temporary storage until now $this->getStorage()->delete($this->layout->getId()); $this->setToken(null); // Reload the real layout $this->layout = $this->storage->load($this->layout->getId()); return $this; }
php
public function rollback() { // Throws a nice exception if no token $this->getToken(); if (!$this->layout instanceof Layout) { throw new \LogicException("No contextual instance is set, cannot commit"); } // Loaded instance is supposed to be the false one // This gets the temporary storage until now $this->getStorage()->delete($this->layout->getId()); $this->setToken(null); // Reload the real layout $this->layout = $this->storage->load($this->layout->getId()); return $this; }
[ "public", "function", "rollback", "(", ")", "{", "// Throws a nice exception if no token", "$", "this", "->", "getToken", "(", ")", ";", "if", "(", "!", "$", "this", "->", "layout", "instanceof", "Layout", ")", "{", "throw", "new", "\\", "LogicException", "(...
Rollback session changes and restore storage @return Context
[ "Rollback", "session", "changes", "and", "restore", "storage" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_layout/src/Context.php#L80-L99
makinacorpus/drupal-ucms
ucms_layout/src/Context.php
Context.getCurrentLayout
public function getCurrentLayout() { if (!$this->layout && $this->layoutNodeId) { $this->layout = $this->getStorage()->findForNodeOnSite($this->layoutNodeId, $this->layoutSiteId, true); } return $this->layout; }
php
public function getCurrentLayout() { if (!$this->layout && $this->layoutNodeId) { $this->layout = $this->getStorage()->findForNodeOnSite($this->layoutNodeId, $this->layoutSiteId, true); } return $this->layout; }
[ "public", "function", "getCurrentLayout", "(", ")", "{", "if", "(", "!", "$", "this", "->", "layout", "&&", "$", "this", "->", "layoutNodeId", ")", "{", "$", "this", "->", "layout", "=", "$", "this", "->", "getStorage", "(", ")", "->", "findForNodeOnSi...
Get current layout
[ "Get", "current", "layout" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_layout/src/Context.php#L118-L125
makinacorpus/drupal-ucms
ucms_layout/src/Context.php
Context.setCurrentLayoutNodeId
public function setCurrentLayoutNodeId($nid, $siteId) { if ($this->layoutNodeId) { throw new \LogicException("You can't change the current layout node ID."); } $this->layoutNodeId = $nid; $this->layoutSiteId = $siteId; }
php
public function setCurrentLayoutNodeId($nid, $siteId) { if ($this->layoutNodeId) { throw new \LogicException("You can't change the current layout node ID."); } $this->layoutNodeId = $nid; $this->layoutSiteId = $siteId; }
[ "public", "function", "setCurrentLayoutNodeId", "(", "$", "nid", ",", "$", "siteId", ")", "{", "if", "(", "$", "this", "->", "layoutNodeId", ")", "{", "throw", "new", "\\", "LogicException", "(", "\"You can't change the current layout node ID.\"", ")", ";", "}",...
Set current layout node ID @param int $nid @param int $siteId
[ "Set", "current", "layout", "node", "ID" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_layout/src/Context.php#L133-L141
makinacorpus/drupal-ucms
ucms_layout/src/Context.php
Context.getStorage
public function getStorage() { if ($this->hasToken()) { return $this->temporaryStorage->setToken($this->getToken()); } return $this->storage; }
php
public function getStorage() { if ($this->hasToken()) { return $this->temporaryStorage->setToken($this->getToken()); } return $this->storage; }
[ "public", "function", "getStorage", "(", ")", "{", "if", "(", "$", "this", "->", "hasToken", "(", ")", ")", "{", "return", "$", "this", "->", "temporaryStorage", "->", "setToken", "(", "$", "this", "->", "getToken", "(", ")", ")", ";", "}", "return",...
Get real life storage @return StorageInterface
[ "Get", "real", "life", "storage" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_layout/src/Context.php#L158-L165
makinacorpus/drupal-ucms
ucms_notification/src/Formatter/UserDelete.php
UserDelete.getVariations
protected function getVariations(NotificationInterface $notification, array &$args = []) { $data = $notification->getData(); $args['@title'] = $data['name']; if ($name = $this->getUserAccountName($notification)) { $args['@name'] = $name; return [ "@title has been deleted by @name", "@title have been deleted by @name", ]; } else { return [ "@title has been deleted", "@title have been deleted", ]; } }
php
protected function getVariations(NotificationInterface $notification, array &$args = []) { $data = $notification->getData(); $args['@title'] = $data['name']; if ($name = $this->getUserAccountName($notification)) { $args['@name'] = $name; return [ "@title has been deleted by @name", "@title have been deleted by @name", ]; } else { return [ "@title has been deleted", "@title have been deleted", ]; } }
[ "protected", "function", "getVariations", "(", "NotificationInterface", "$", "notification", ",", "array", "&", "$", "args", "=", "[", "]", ")", "{", "$", "data", "=", "$", "notification", "->", "getData", "(", ")", ";", "$", "args", "[", "'@title'", "]"...
{inheritdoc}
[ "{", "inheritdoc", "}" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_notification/src/Formatter/UserDelete.php#L24-L42
mosbth/Anax-MVC
src/HTMLForm/CFormExample.php
CFormExample.callbackSubmit
public function callbackSubmit() { $this->AddOutput("<p>DoSubmit(): Form was submitted.<p>"); $this->AddOutput("<p>Do stuff (save to database) and return true (success) or false (failed processing)</p>"); $this->AddOutput("<p><b>Name: " . $this->Value('name') . "</b></p>"); $this->AddOutput("<p><b>Email: " . $this->Value('email') . "</b></p>"); $this->AddOutput("<p><b>Phone: " . $this->Value('phone') . "</b></p>"); $this->saveInSession = true; return true; }
php
public function callbackSubmit() { $this->AddOutput("<p>DoSubmit(): Form was submitted.<p>"); $this->AddOutput("<p>Do stuff (save to database) and return true (success) or false (failed processing)</p>"); $this->AddOutput("<p><b>Name: " . $this->Value('name') . "</b></p>"); $this->AddOutput("<p><b>Email: " . $this->Value('email') . "</b></p>"); $this->AddOutput("<p><b>Phone: " . $this->Value('phone') . "</b></p>"); $this->saveInSession = true; return true; }
[ "public", "function", "callbackSubmit", "(", ")", "{", "$", "this", "->", "AddOutput", "(", "\"<p>DoSubmit(): Form was submitted.<p>\"", ")", ";", "$", "this", "->", "AddOutput", "(", "\"<p>Do stuff (save to database) and return true (success) or false (failed processing)</p>\"...
Callback for submit-button.
[ "Callback", "for", "submit", "-", "button", "." ]
train
https://github.com/mosbth/Anax-MVC/blob/5574d105bcec9df8e57532a321585f6521b4581c/src/HTMLForm/CFormExample.php#L69-L78
stephweb/daw-php-orm
example/core/Controller/BaseController.php
BaseController.view
final protected function view(string $view, array $data = []) { if ($data) extract($data); ob_start(); require base_path().'/app/views/'.$view.'.php'; $contentInLayout = ob_get_clean(); require base_path().'/app/views/layouts/'.$this->layout.'.php'; exit(); }
php
final protected function view(string $view, array $data = []) { if ($data) extract($data); ob_start(); require base_path().'/app/views/'.$view.'.php'; $contentInLayout = ob_get_clean(); require base_path().'/app/views/layouts/'.$this->layout.'.php'; exit(); }
[ "final", "protected", "function", "view", "(", "string", "$", "view", ",", "array", "$", "data", "=", "[", "]", ")", "{", "if", "(", "$", "data", ")", "extract", "(", "$", "data", ")", ";", "ob_start", "(", ")", ";", "require", "base_path", "(", ...
Return vue @param string $view - Fichier View à charger @param array $data - Pour passer d'éventuels données à la vue
[ "Return", "vue" ]
train
https://github.com/stephweb/daw-php-orm/blob/0c37e3baa1420cf9e3feff122016329de3764bcc/example/core/Controller/BaseController.php#L43-L54
stephweb/daw-php-orm
example/core/Controller/BaseController.php
BaseController.header
final protected function header(string $content, string $type = null) { Response::header($content, $type); }
php
final protected function header(string $content, string $type = null) { Response::header($content, $type); }
[ "final", "protected", "function", "header", "(", "string", "$", "content", ",", "string", "$", "type", "=", "null", ")", "{", "Response", "::", "header", "(", "$", "content", ",", "$", "type", ")", ";", "}" ]
Spécifier l'en-tête HTTP de l'affichage d'une vue @param string $content @param string|null $type
[ "Spécifier", "l", "en", "-", "tête", "HTTP", "de", "l", "affichage", "d", "une", "vue" ]
train
https://github.com/stephweb/daw-php-orm/blob/0c37e3baa1420cf9e3feff122016329de3764bcc/example/core/Controller/BaseController.php#L62-L65
huang-yi/swoole-watcher
src/Watcher.php
Watcher.watch
public function watch() { foreach ($this->directories as $directory) { if (is_dir($directory)) { $this->watchAllDirectories($directory); } } }
php
public function watch() { foreach ($this->directories as $directory) { if (is_dir($directory)) { $this->watchAllDirectories($directory); } } }
[ "public", "function", "watch", "(", ")", "{", "foreach", "(", "$", "this", "->", "directories", "as", "$", "directory", ")", "{", "if", "(", "is_dir", "(", "$", "directory", ")", ")", "{", "$", "this", "->", "watchAllDirectories", "(", "$", "directory"...
Run watcher.
[ "Run", "watcher", "." ]
train
https://github.com/huang-yi/swoole-watcher/blob/44ca253453c5f04d7300553bddb736706fbc957a/src/Watcher.php#L90-L97
huang-yi/swoole-watcher
src/Watcher.php
Watcher.stop
public function stop() { swoole_event_del($this->inotify); swoole_event_exit(); fclose($this->inotify); $this->watchedDirectories = []; }
php
public function stop() { swoole_event_del($this->inotify); swoole_event_exit(); fclose($this->inotify); $this->watchedDirectories = []; }
[ "public", "function", "stop", "(", ")", "{", "swoole_event_del", "(", "$", "this", "->", "inotify", ")", ";", "swoole_event_exit", "(", ")", ";", "fclose", "(", "$", "this", "->", "inotify", ")", ";", "$", "this", "->", "watchedDirectories", "=", "[", ...
Stop watcher.
[ "Stop", "watcher", "." ]
train
https://github.com/huang-yi/swoole-watcher/blob/44ca253453c5f04d7300553bddb736706fbc957a/src/Watcher.php#L112-L120
huang-yi/swoole-watcher
src/Watcher.php
Watcher.watchHandler
public function watchHandler() { if (! $events = inotify_read($this->inotify)) { return; } foreach ($events as $event) { if (! empty($event['name']) && ! $this->inWatchedSuffixes($event['name'])) { continue; } if (! $this->handle($event)) { break; } } }
php
public function watchHandler() { if (! $events = inotify_read($this->inotify)) { return; } foreach ($events as $event) { if (! empty($event['name']) && ! $this->inWatchedSuffixes($event['name'])) { continue; } if (! $this->handle($event)) { break; } } }
[ "public", "function", "watchHandler", "(", ")", "{", "if", "(", "!", "$", "events", "=", "inotify_read", "(", "$", "this", "->", "inotify", ")", ")", "{", "return", ";", "}", "foreach", "(", "$", "events", "as", "$", "event", ")", "{", "if", "(", ...
Watch handler.
[ "Watch", "handler", "." ]
train
https://github.com/huang-yi/swoole-watcher/blob/44ca253453c5f04d7300553bddb736706fbc957a/src/Watcher.php#L135-L150
huang-yi/swoole-watcher
src/Watcher.php
Watcher.watchAllDirectories
protected function watchAllDirectories($directory) { $directory = rtrim($directory, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; if (! $this->watchDirectory($directory)) { return false; } $names = scandir($directory); foreach ($names as $name) { if (in_array($name, ['.', '..'], true)) { continue; } $subdirectory = $directory . $name; if (is_dir($subdirectory)) { $this->watchAllDirectories($subdirectory); } } return true; }
php
protected function watchAllDirectories($directory) { $directory = rtrim($directory, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; if (! $this->watchDirectory($directory)) { return false; } $names = scandir($directory); foreach ($names as $name) { if (in_array($name, ['.', '..'], true)) { continue; } $subdirectory = $directory . $name; if (is_dir($subdirectory)) { $this->watchAllDirectories($subdirectory); } } return true; }
[ "protected", "function", "watchAllDirectories", "(", "$", "directory", ")", "{", "$", "directory", "=", "rtrim", "(", "$", "directory", ",", "DIRECTORY_SEPARATOR", ")", ".", "DIRECTORY_SEPARATOR", ";", "if", "(", "!", "$", "this", "->", "watchDirectory", "(", ...
Watch the directory and all subdirectories under the directory. @param string $directory @return bool
[ "Watch", "the", "directory", "and", "all", "subdirectories", "under", "the", "directory", "." ]
train
https://github.com/huang-yi/swoole-watcher/blob/44ca253453c5f04d7300553bddb736706fbc957a/src/Watcher.php#L158-L181
huang-yi/swoole-watcher
src/Watcher.php
Watcher.watchDirectory
protected function watchDirectory($directory) { if ($this->isExcluded($directory)) { return false; } if (! $this->isWatched($directory)) { $wd = inotify_add_watch($this->inotify, $directory, $this->getMaskValue()); $this->watchedDirectories[$wd] = $directory; } return true; }
php
protected function watchDirectory($directory) { if ($this->isExcluded($directory)) { return false; } if (! $this->isWatched($directory)) { $wd = inotify_add_watch($this->inotify, $directory, $this->getMaskValue()); $this->watchedDirectories[$wd] = $directory; } return true; }
[ "protected", "function", "watchDirectory", "(", "$", "directory", ")", "{", "if", "(", "$", "this", "->", "isExcluded", "(", "$", "directory", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "$", "this", "->", "isWatched", "(", "$", "dire...
Watch directory. @param string $directory @return bool
[ "Watch", "directory", "." ]
train
https://github.com/huang-yi/swoole-watcher/blob/44ca253453c5f04d7300553bddb736706fbc957a/src/Watcher.php#L189-L201
huang-yi/swoole-watcher
src/Watcher.php
Watcher.inWatchedSuffixes
protected function inWatchedSuffixes($file) { foreach ($this->suffixes as $suffix) { $start = strlen($suffix); if (substr($file, -$start, $start) === $suffix) { return true; } } return false; }
php
protected function inWatchedSuffixes($file) { foreach ($this->suffixes as $suffix) { $start = strlen($suffix); if (substr($file, -$start, $start) === $suffix) { return true; } } return false; }
[ "protected", "function", "inWatchedSuffixes", "(", "$", "file", ")", "{", "foreach", "(", "$", "this", "->", "suffixes", "as", "$", "suffix", ")", "{", "$", "start", "=", "strlen", "(", "$", "suffix", ")", ";", "if", "(", "substr", "(", "$", "file", ...
Determine if the file type should be watched. @param string $file @return bool
[ "Determine", "if", "the", "file", "type", "should", "be", "watched", "." ]
train
https://github.com/huang-yi/swoole-watcher/blob/44ca253453c5f04d7300553bddb736706fbc957a/src/Watcher.php#L231-L242
huang-yi/swoole-watcher
src/Watcher.php
Watcher.setMasks
public function setMasks($masks) { $this->masks = (array) $masks; $this->maskValue = array_reduce($this->masks, function ($maskValue, $mask) { return $maskValue | $mask; }); return $this; }
php
public function setMasks($masks) { $this->masks = (array) $masks; $this->maskValue = array_reduce($this->masks, function ($maskValue, $mask) { return $maskValue | $mask; }); return $this; }
[ "public", "function", "setMasks", "(", "$", "masks", ")", "{", "$", "this", "->", "masks", "=", "(", "array", ")", "$", "masks", ";", "$", "this", "->", "maskValue", "=", "array_reduce", "(", "$", "this", "->", "masks", ",", "function", "(", "$", "...
Set the watched masks. @param array $masks @return $this
[ "Set", "the", "watched", "masks", "." ]
train
https://github.com/huang-yi/swoole-watcher/blob/44ca253453c5f04d7300553bddb736706fbc957a/src/Watcher.php#L365-L373
shopgate/cart-integration-sdk
src/core.php
ShopgateLibraryException.getMessageFor
public static function getMessageFor($code) { if (isset(self::$errorMessages[$code])) { $message = self::$errorMessages[$code]; } else { $message = 'Unknown error code: "' . $code . '"'; } return $message; }
php
public static function getMessageFor($code) { if (isset(self::$errorMessages[$code])) { $message = self::$errorMessages[$code]; } else { $message = 'Unknown error code: "' . $code . '"'; } return $message; }
[ "public", "static", "function", "getMessageFor", "(", "$", "code", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "errorMessages", "[", "$", "code", "]", ")", ")", "{", "$", "message", "=", "self", "::", "$", "errorMessages", "[", "$", "code",...
Gets the error message for an error code. @param int $code One of the constants in this class. @return string
[ "Gets", "the", "error", "message", "for", "an", "error", "code", "." ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L425-L434
shopgate/cart-integration-sdk
src/core.php
ShopgateLibraryException.buildLogMessageFor
public static function buildLogMessageFor($code, $additionalInformation) { $e = new ShopgateLibraryException($code, $additionalInformation, false, false); return $e->buildLogMessage(); }
php
public static function buildLogMessageFor($code, $additionalInformation) { $e = new ShopgateLibraryException($code, $additionalInformation, false, false); return $e->buildLogMessage(); }
[ "public", "static", "function", "buildLogMessageFor", "(", "$", "code", ",", "$", "additionalInformation", ")", "{", "$", "e", "=", "new", "ShopgateLibraryException", "(", "$", "code", ",", "$", "additionalInformation", ",", "false", ",", "false", ")", ";", ...
Builds the message that would be logged if a ShopgateLibraryException was thrown with the same parameters and returns it. This is a convenience method for cases where logging is desired but the script should not abort. By using this function an empty try-catch-statement can be avoided. Just pass the returned string to ShopgateLogger::log(). @param int $code One of the constants defined in ShopgateLibraryException. @param string $additionalInformation More detailed information on what exactly went wrong. @return string @deprecated
[ "Builds", "the", "message", "that", "would", "be", "logged", "if", "a", "ShopgateLibraryException", "was", "thrown", "with", "the", "same", "parameters", "and", "returns", "it", "." ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L449-L454
shopgate/cart-integration-sdk
src/core.php
ShopgateLibraryException.buildLogMessage
protected function buildLogMessage($appendAdditionalInformation = true) { $logMessage = $this->getMessage(); if ($appendAdditionalInformation && !empty($this->additionalInformation)) { $logMessage .= ': ' . $this->additionalInformation; } $logMessage .= "\n"; // Add tracing information to the message $previous = $this->getPreviousException(); $trace = $previous ? $previous->getTraceAsString() : $this->getTraceAsString(); $line = $previous ? $previous->getLine() : $this->getLine(); $file = $previous ? $previous->getFile() : $this->getFile(); $class = $previous ? get_class($previous) : get_class($this); $traceLines = explode("\n", $trace); array_unshift($traceLines, "## $file($line): throw $class"); $i = 0; foreach ($traceLines as $traceLine) { $i++; if ($i > 20) { $logMessage .= "\t(...)"; break; } $logMessage .= "\t$traceLine\n"; } return $logMessage; }
php
protected function buildLogMessage($appendAdditionalInformation = true) { $logMessage = $this->getMessage(); if ($appendAdditionalInformation && !empty($this->additionalInformation)) { $logMessage .= ': ' . $this->additionalInformation; } $logMessage .= "\n"; // Add tracing information to the message $previous = $this->getPreviousException(); $trace = $previous ? $previous->getTraceAsString() : $this->getTraceAsString(); $line = $previous ? $previous->getLine() : $this->getLine(); $file = $previous ? $previous->getFile() : $this->getFile(); $class = $previous ? get_class($previous) : get_class($this); $traceLines = explode("\n", $trace); array_unshift($traceLines, "## $file($line): throw $class"); $i = 0; foreach ($traceLines as $traceLine) { $i++; if ($i > 20) { $logMessage .= "\t(...)"; break; } $logMessage .= "\t$traceLine\n"; } return $logMessage; }
[ "protected", "function", "buildLogMessage", "(", "$", "appendAdditionalInformation", "=", "true", ")", "{", "$", "logMessage", "=", "$", "this", "->", "getMessage", "(", ")", ";", "if", "(", "$", "appendAdditionalInformation", "&&", "!", "empty", "(", "$", "...
Builds the message that will be logged to the error log. @param bool $appendAdditionalInformation @return string
[ "Builds", "the", "message", "that", "will", "be", "logged", "to", "the", "error", "log", "." ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L463-L502
shopgate/cart-integration-sdk
src/core.php
ShopgateBuilder.buildLibraryFor
public function buildLibraryFor(ShopgatePlugin $plugin) { // set error handler if configured if ($this->config->getUseCustomErrorHandler()) { set_error_handler('ShopgateErrorHandler'); } // instantiate API stuff // -> MerchantAPI auth service (needs to be initialized first, since the config still can change along with the authentication information switch ($this->config->getSmaAuthServiceClassName()) { case ShopgateConfigInterface::SHOPGATE_AUTH_SERVICE_CLASS_NAME_SHOPGATE: $smaAuthService = new ShopgateAuthenticationServiceShopgate( $this->config->getCustomerNumber(), $this->config->getApikey() ); $smaAuthService->setup($this->config); $merchantApi = new ShopgateMerchantApi( $smaAuthService, $this->config->getShopNumber(), $this->config->getApiUrl() ); break; case ShopgateConfigInterface::SHOPGATE_AUTH_SERVICE_CLASS_NAME_OAUTH: $smaAuthService = new ShopgateAuthenticationServiceOAuth($this->config->getOauthAccessToken()); $smaAuthService->setup($this->config); $merchantApi = new ShopgateMerchantApi($smaAuthService, null, $this->config->getApiUrl()); break; default: // undefined auth service return trigger_error( 'Invalid SMA-Auth-Service defined - this should not happen with valid plugin code', E_USER_ERROR ); } // -> PluginAPI auth service (currently the plugin API supports only one auth service) $spaAuthService = new ShopgateAuthenticationServiceShopgate( $this->config->getCustomerNumber(), $this->config->getApikey() ); $pluginApi = new ShopgatePluginApi( $this->config, $spaAuthService, $merchantApi, $plugin, null, $this->buildStackTraceGenerator(), $this->logging ); if ($this->config->getExportConvertEncoding()) { array_splice(ShopgateObject::$sourceEncodings, 1, 0, $this->config->getEncoding()); ShopgateObject::$sourceEncodings = array_unique(ShopgateObject::$sourceEncodings); } if ($this->config->getForceSourceEncoding()) { ShopgateObject::$sourceEncodings = array($this->config->getEncoding()); } // instantiate export file buffer if (!empty($_REQUEST['action']) && (($_REQUEST['action'] == 'get_items') || ($_REQUEST['action'] == 'get_categories') || ($_REQUEST['action'] == 'get_reviews'))) { $xmlModelNames = array( 'get_items' => 'Shopgate_Model_Catalog_Product', 'get_categories' => 'Shopgate_Model_Catalog_Category', 'get_reviews' => 'Shopgate_Model_Review', ); $format = (!empty($_REQUEST['response_type'])) ? $_REQUEST['response_type'] : ''; switch ($format) { default: case 'xml': /* @var $xmlModel Shopgate_Model_AbstractExport */ $xmlModel = new $xmlModelNames[$_REQUEST['action']](); $xmlNode = new Shopgate_Model_XmlResultObject($xmlModel->getItemNodeIdentifier()); $fileBuffer = new ShopgateFileBufferXml( $xmlModel, $xmlNode, $this->config->getExportBufferCapacity(), $this->config->getExportConvertEncoding(), ShopgateObject::$sourceEncodings ); break; case 'json': $fileBuffer = new ShopgateFileBufferJson( $this->config->getExportBufferCapacity(), $this->config->getExportConvertEncoding(), ShopgateObject::$sourceEncodings ); break; } } else { if (!empty($_REQUEST['action']) && (($_REQUEST['action'] == 'get_items_csv') || ($_REQUEST['action'] == 'get_categories_csv') || ($_REQUEST['action'] == 'get_reviews_csv'))) { $fileBuffer = new ShopgateFileBufferCsv( $this->config->getExportBufferCapacity(), $this->config->getExportConvertEncoding(), ShopgateObject::$sourceEncodings ); } else { $fileBuffer = new ShopgateFileBufferCsv( $this->config->getExportBufferCapacity(), $this->config->getExportConvertEncoding(), ShopgateObject::$sourceEncodings ); } } // inject apis into plugin $plugin->setConfig($this->config); $plugin->setMerchantApi($merchantApi); $plugin->setPluginApi($pluginApi); $plugin->setBuffer($fileBuffer); }
php
public function buildLibraryFor(ShopgatePlugin $plugin) { // set error handler if configured if ($this->config->getUseCustomErrorHandler()) { set_error_handler('ShopgateErrorHandler'); } // instantiate API stuff // -> MerchantAPI auth service (needs to be initialized first, since the config still can change along with the authentication information switch ($this->config->getSmaAuthServiceClassName()) { case ShopgateConfigInterface::SHOPGATE_AUTH_SERVICE_CLASS_NAME_SHOPGATE: $smaAuthService = new ShopgateAuthenticationServiceShopgate( $this->config->getCustomerNumber(), $this->config->getApikey() ); $smaAuthService->setup($this->config); $merchantApi = new ShopgateMerchantApi( $smaAuthService, $this->config->getShopNumber(), $this->config->getApiUrl() ); break; case ShopgateConfigInterface::SHOPGATE_AUTH_SERVICE_CLASS_NAME_OAUTH: $smaAuthService = new ShopgateAuthenticationServiceOAuth($this->config->getOauthAccessToken()); $smaAuthService->setup($this->config); $merchantApi = new ShopgateMerchantApi($smaAuthService, null, $this->config->getApiUrl()); break; default: // undefined auth service return trigger_error( 'Invalid SMA-Auth-Service defined - this should not happen with valid plugin code', E_USER_ERROR ); } // -> PluginAPI auth service (currently the plugin API supports only one auth service) $spaAuthService = new ShopgateAuthenticationServiceShopgate( $this->config->getCustomerNumber(), $this->config->getApikey() ); $pluginApi = new ShopgatePluginApi( $this->config, $spaAuthService, $merchantApi, $plugin, null, $this->buildStackTraceGenerator(), $this->logging ); if ($this->config->getExportConvertEncoding()) { array_splice(ShopgateObject::$sourceEncodings, 1, 0, $this->config->getEncoding()); ShopgateObject::$sourceEncodings = array_unique(ShopgateObject::$sourceEncodings); } if ($this->config->getForceSourceEncoding()) { ShopgateObject::$sourceEncodings = array($this->config->getEncoding()); } // instantiate export file buffer if (!empty($_REQUEST['action']) && (($_REQUEST['action'] == 'get_items') || ($_REQUEST['action'] == 'get_categories') || ($_REQUEST['action'] == 'get_reviews'))) { $xmlModelNames = array( 'get_items' => 'Shopgate_Model_Catalog_Product', 'get_categories' => 'Shopgate_Model_Catalog_Category', 'get_reviews' => 'Shopgate_Model_Review', ); $format = (!empty($_REQUEST['response_type'])) ? $_REQUEST['response_type'] : ''; switch ($format) { default: case 'xml': /* @var $xmlModel Shopgate_Model_AbstractExport */ $xmlModel = new $xmlModelNames[$_REQUEST['action']](); $xmlNode = new Shopgate_Model_XmlResultObject($xmlModel->getItemNodeIdentifier()); $fileBuffer = new ShopgateFileBufferXml( $xmlModel, $xmlNode, $this->config->getExportBufferCapacity(), $this->config->getExportConvertEncoding(), ShopgateObject::$sourceEncodings ); break; case 'json': $fileBuffer = new ShopgateFileBufferJson( $this->config->getExportBufferCapacity(), $this->config->getExportConvertEncoding(), ShopgateObject::$sourceEncodings ); break; } } else { if (!empty($_REQUEST['action']) && (($_REQUEST['action'] == 'get_items_csv') || ($_REQUEST['action'] == 'get_categories_csv') || ($_REQUEST['action'] == 'get_reviews_csv'))) { $fileBuffer = new ShopgateFileBufferCsv( $this->config->getExportBufferCapacity(), $this->config->getExportConvertEncoding(), ShopgateObject::$sourceEncodings ); } else { $fileBuffer = new ShopgateFileBufferCsv( $this->config->getExportBufferCapacity(), $this->config->getExportConvertEncoding(), ShopgateObject::$sourceEncodings ); } } // inject apis into plugin $plugin->setConfig($this->config); $plugin->setMerchantApi($merchantApi); $plugin->setPluginApi($pluginApi); $plugin->setBuffer($fileBuffer); }
[ "public", "function", "buildLibraryFor", "(", "ShopgatePlugin", "$", "plugin", ")", "{", "// set error handler if configured", "if", "(", "$", "this", "->", "config", "->", "getUseCustomErrorHandler", "(", ")", ")", "{", "set_error_handler", "(", "'ShopgateErrorHandle...
Builds the Shopgate Cart Integration SDK object graph for a given ShopgatePlugin object. This initializes all necessary objects of the library, wires them together and injects them into the plugin class via its set* methods. @param ShopgatePlugin $plugin The ShopgatePlugin instance that should be wired to the framework.
[ "Builds", "the", "Shopgate", "Cart", "Integration", "SDK", "object", "graph", "for", "a", "given", "ShopgatePlugin", "object", "." ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L752-L860
shopgate/cart-integration-sdk
src/core.php
ShopgateBuilder.buildMerchantApi
public function buildMerchantApi() { $merchantApi = null; switch ($smaAuthServiceClassName = $this->config->getSmaAuthServiceClassName()) { case ShopgateConfigInterface::SHOPGATE_AUTH_SERVICE_CLASS_NAME_SHOPGATE: $smaAuthService = new ShopgateAuthenticationServiceShopgate( $this->config->getCustomerNumber(), $this->config->getApikey() ); $smaAuthService->setup($this->config); $merchantApi = new ShopgateMerchantApi( $smaAuthService, $this->config->getShopNumber(), $this->config->getApiUrl() ); break; case ShopgateConfigInterface::SHOPGATE_AUTH_SERVICE_CLASS_NAME_OAUTH: $smaAuthService = new ShopgateAuthenticationServiceOAuth($this->config->getOauthAccessToken()); $smaAuthService->setup($this->config); $merchantApi = new ShopgateMerchantApi($smaAuthService, null, $this->config->getApiUrl()); break; default: // undefined auth service trigger_error( 'Invalid SMA-Auth-Service defined - this should not happen with valid plugin code', E_USER_ERROR ); break; } return $merchantApi; }
php
public function buildMerchantApi() { $merchantApi = null; switch ($smaAuthServiceClassName = $this->config->getSmaAuthServiceClassName()) { case ShopgateConfigInterface::SHOPGATE_AUTH_SERVICE_CLASS_NAME_SHOPGATE: $smaAuthService = new ShopgateAuthenticationServiceShopgate( $this->config->getCustomerNumber(), $this->config->getApikey() ); $smaAuthService->setup($this->config); $merchantApi = new ShopgateMerchantApi( $smaAuthService, $this->config->getShopNumber(), $this->config->getApiUrl() ); break; case ShopgateConfigInterface::SHOPGATE_AUTH_SERVICE_CLASS_NAME_OAUTH: $smaAuthService = new ShopgateAuthenticationServiceOAuth($this->config->getOauthAccessToken()); $smaAuthService->setup($this->config); $merchantApi = new ShopgateMerchantApi($smaAuthService, null, $this->config->getApiUrl()); break; default: // undefined auth service trigger_error( 'Invalid SMA-Auth-Service defined - this should not happen with valid plugin code', E_USER_ERROR ); break; } return $merchantApi; }
[ "public", "function", "buildMerchantApi", "(", ")", "{", "$", "merchantApi", "=", "null", ";", "switch", "(", "$", "smaAuthServiceClassName", "=", "$", "this", "->", "config", "->", "getSmaAuthServiceClassName", "(", ")", ")", "{", "case", "ShopgateConfigInterfa...
Builds the Shopgate Cart Integration SDK object graph for ShopgateMerchantApi and returns the instance. @return ShopgateMerchantApi
[ "Builds", "the", "Shopgate", "Cart", "Integration", "SDK", "object", "graph", "for", "ShopgateMerchantApi", "and", "returns", "the", "instance", "." ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L878-L908
shopgate/cart-integration-sdk
src/core.php
ShopgateBuilder.buildRedirect
public function buildRedirect() { $merchantApi = $this->buildMerchantApi(); $settingsManager = new Shopgate_Helper_Redirect_SettingsManager( $this->config, $_GET, $_COOKIE ); $templateParser = new Shopgate_Helper_Redirect_TemplateParser(); $linkBuilder = new Shopgate_Helper_Redirect_LinkBuilder( $settingsManager, $templateParser ); $tagsGenerator = new Shopgate_Helper_Redirect_TagsGenerator( $linkBuilder, $templateParser ); $redirect = new ShopgateMobileRedirect( $this->config, $merchantApi, $tagsGenerator ); return $redirect; }
php
public function buildRedirect() { $merchantApi = $this->buildMerchantApi(); $settingsManager = new Shopgate_Helper_Redirect_SettingsManager( $this->config, $_GET, $_COOKIE ); $templateParser = new Shopgate_Helper_Redirect_TemplateParser(); $linkBuilder = new Shopgate_Helper_Redirect_LinkBuilder( $settingsManager, $templateParser ); $tagsGenerator = new Shopgate_Helper_Redirect_TagsGenerator( $linkBuilder, $templateParser ); $redirect = new ShopgateMobileRedirect( $this->config, $merchantApi, $tagsGenerator ); return $redirect; }
[ "public", "function", "buildRedirect", "(", ")", "{", "$", "merchantApi", "=", "$", "this", "->", "buildMerchantApi", "(", ")", ";", "$", "settingsManager", "=", "new", "Shopgate_Helper_Redirect_SettingsManager", "(", "$", "this", "->", "config", ",", "$", "_G...
Builds the Shopgate Cart Integration SDK object graph for Shopgate mobile redirect and returns the instance. @return ShopgateMobileRedirect @deprecated Will be removed in 3.0.0. Use SopgateBuilder::buildMobileRedirect() instead.
[ "Builds", "the", "Shopgate", "Cart", "Integration", "SDK", "object", "graph", "for", "Shopgate", "mobile", "redirect", "and", "returns", "the", "instance", "." ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L917-L945
shopgate/cart-integration-sdk
src/core.php
ShopgateBuilder.buildMobileRedirect
public function buildMobileRedirect($userAgent, array $get, array $cookie) { $settingsManager = new Shopgate_Helper_Redirect_SettingsManager($this->config, $get, $cookie); $templateParser = new Shopgate_Helper_Redirect_TemplateParser(); $linkBuilder = new Shopgate_Helper_Redirect_LinkBuilder( $settingsManager, $templateParser ); $redirector = new Shopgate_Helper_Redirect_Redirector( $settingsManager, new Shopgate_Helper_Redirect_KeywordsManager( $this->buildMerchantApi(), $this->config->getRedirectKeywordCachePath(), $this->config->getRedirectSkipKeywordCachePath() ), $linkBuilder, $userAgent ); $tagsGenerator = new Shopgate_Helper_Redirect_TagsGenerator( $linkBuilder, $templateParser ); return new Shopgate_Helper_Redirect_MobileRedirect( $redirector, $tagsGenerator, $settingsManager, $templateParser, dirname(__FILE__) . '/../assets/js_header.html', $this->config->getShopNumber() ); }
php
public function buildMobileRedirect($userAgent, array $get, array $cookie) { $settingsManager = new Shopgate_Helper_Redirect_SettingsManager($this->config, $get, $cookie); $templateParser = new Shopgate_Helper_Redirect_TemplateParser(); $linkBuilder = new Shopgate_Helper_Redirect_LinkBuilder( $settingsManager, $templateParser ); $redirector = new Shopgate_Helper_Redirect_Redirector( $settingsManager, new Shopgate_Helper_Redirect_KeywordsManager( $this->buildMerchantApi(), $this->config->getRedirectKeywordCachePath(), $this->config->getRedirectSkipKeywordCachePath() ), $linkBuilder, $userAgent ); $tagsGenerator = new Shopgate_Helper_Redirect_TagsGenerator( $linkBuilder, $templateParser ); return new Shopgate_Helper_Redirect_MobileRedirect( $redirector, $tagsGenerator, $settingsManager, $templateParser, dirname(__FILE__) . '/../assets/js_header.html', $this->config->getShopNumber() ); }
[ "public", "function", "buildMobileRedirect", "(", "$", "userAgent", ",", "array", "$", "get", ",", "array", "$", "cookie", ")", "{", "$", "settingsManager", "=", "new", "Shopgate_Helper_Redirect_SettingsManager", "(", "$", "this", "->", "config", ",", "$", "ge...
Builds the Shopgate Cart Integration SDK object graph for Shopgate mobile redirect and returns the instance. @param string $userAgent The requesting entity's user agent, e.g. $_SERVER['HTTP_USER_AGENT'] @param array $get [string, mixed] A copy of $_GET or the query string in the form of $_GET. @param array $cookie [string, mixed] A copy of $_COOKIE or the request cookies in the form of $_COOKIE. @return Shopgate_Helper_Redirect_MobileRedirect @deprecated 3.0.0 - deprecated as of 2.9.51 @see buildJsRedirect() @see buildHttpRedirect()
[ "Builds", "the", "Shopgate", "Cart", "Integration", "SDK", "object", "graph", "for", "Shopgate", "mobile", "redirect", "and", "returns", "the", "instance", "." ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L960-L994
shopgate/cart-integration-sdk
src/core.php
ShopgateBuilder.buildJsRedirect
public function buildJsRedirect(array $get, array $cookie) { $settingsManager = new Shopgate_Helper_Redirect_SettingsManager($this->config, $get, $cookie); $templateParser = new Shopgate_Helper_Redirect_TemplateParser(); $linkBuilder = new Shopgate_Helper_Redirect_LinkBuilder( $settingsManager, $templateParser ); $tagsGenerator = new Shopgate_Helper_Redirect_TagsGenerator( $linkBuilder, $templateParser ); $jsBuilder = new Shopgate_Helper_Redirect_JsScriptBuilder( $tagsGenerator, $settingsManager, $templateParser, dirname(__FILE__) . '/../assets/js_header.html', $this->config->getShopNumber() ); $jsType = new Shopgate_Helper_Redirect_Type_Js($jsBuilder); return $jsType; }
php
public function buildJsRedirect(array $get, array $cookie) { $settingsManager = new Shopgate_Helper_Redirect_SettingsManager($this->config, $get, $cookie); $templateParser = new Shopgate_Helper_Redirect_TemplateParser(); $linkBuilder = new Shopgate_Helper_Redirect_LinkBuilder( $settingsManager, $templateParser ); $tagsGenerator = new Shopgate_Helper_Redirect_TagsGenerator( $linkBuilder, $templateParser ); $jsBuilder = new Shopgate_Helper_Redirect_JsScriptBuilder( $tagsGenerator, $settingsManager, $templateParser, dirname(__FILE__) . '/../assets/js_header.html', $this->config->getShopNumber() ); $jsType = new Shopgate_Helper_Redirect_Type_Js($jsBuilder); return $jsType; }
[ "public", "function", "buildJsRedirect", "(", "array", "$", "get", ",", "array", "$", "cookie", ")", "{", "$", "settingsManager", "=", "new", "Shopgate_Helper_Redirect_SettingsManager", "(", "$", "this", "->", "config", ",", "$", "get", ",", "$", "cookie", "...
Generates JavaScript code to redirect the current page Shopgate mobile site @param array $get @param array $cookie @return Shopgate_Helper_Redirect_Type_Js
[ "Generates", "JavaScript", "code", "to", "redirect", "the", "current", "page", "Shopgate", "mobile", "site" ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L1005-L1030
shopgate/cart-integration-sdk
src/core.php
ShopgateBuilder.buildHttpRedirect
public function buildHttpRedirect($userAgent, array $get, array $cookie) { $settingsManager = new Shopgate_Helper_Redirect_SettingsManager($this->config, $get, $cookie); $templateParser = new Shopgate_Helper_Redirect_TemplateParser(); $linkBuilder = new Shopgate_Helper_Redirect_LinkBuilder( $settingsManager, $templateParser ); $redirector = new Shopgate_Helper_Redirect_Redirector( $settingsManager, new Shopgate_Helper_Redirect_KeywordsManager( $this->buildMerchantApi(), $this->config->getRedirectKeywordCachePath(), $this->config->getRedirectSkipKeywordCachePath() ), $linkBuilder, $userAgent ); return new Shopgate_Helper_Redirect_Type_Http($redirector); }
php
public function buildHttpRedirect($userAgent, array $get, array $cookie) { $settingsManager = new Shopgate_Helper_Redirect_SettingsManager($this->config, $get, $cookie); $templateParser = new Shopgate_Helper_Redirect_TemplateParser(); $linkBuilder = new Shopgate_Helper_Redirect_LinkBuilder( $settingsManager, $templateParser ); $redirector = new Shopgate_Helper_Redirect_Redirector( $settingsManager, new Shopgate_Helper_Redirect_KeywordsManager( $this->buildMerchantApi(), $this->config->getRedirectKeywordCachePath(), $this->config->getRedirectSkipKeywordCachePath() ), $linkBuilder, $userAgent ); return new Shopgate_Helper_Redirect_Type_Http($redirector); }
[ "public", "function", "buildHttpRedirect", "(", "$", "userAgent", ",", "array", "$", "get", ",", "array", "$", "cookie", ")", "{", "$", "settingsManager", "=", "new", "Shopgate_Helper_Redirect_SettingsManager", "(", "$", "this", "->", "config", ",", "$", "get"...
Attempts to redirect via an HTTP header call before the page is loaded @param string $userAgent - browser agent string @param array $get @param array $cookie @return Shopgate_Helper_Redirect_Type_Http
[ "Attempts", "to", "redirect", "via", "an", "HTTP", "header", "call", "before", "the", "page", "is", "loaded" ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L1042-L1064
shopgate/cart-integration-sdk
src/core.php
ShopgateBuilder.determineErrorReporting
private function determineErrorReporting($request) { // determine desired error reporting (default to 0) $errorReporting = (isset($request['error_reporting'])) ? $request['error_reporting'] : 0; // determine error reporting for the current stage (custom, pg => E_ALL; the previously requested otherwise) $serverTypesAdvancedErrorLogging = array('custom', 'pg'); $errorReporting = (isset($serverTypesAdvancedErrorLogging[$this->config->getServer()])) ? 32767 : $errorReporting; return $errorReporting; }
php
private function determineErrorReporting($request) { // determine desired error reporting (default to 0) $errorReporting = (isset($request['error_reporting'])) ? $request['error_reporting'] : 0; // determine error reporting for the current stage (custom, pg => E_ALL; the previously requested otherwise) $serverTypesAdvancedErrorLogging = array('custom', 'pg'); $errorReporting = (isset($serverTypesAdvancedErrorLogging[$this->config->getServer()])) ? 32767 : $errorReporting; return $errorReporting; }
[ "private", "function", "determineErrorReporting", "(", "$", "request", ")", "{", "// determine desired error reporting (default to 0)", "$", "errorReporting", "=", "(", "isset", "(", "$", "request", "[", "'error_reporting'", "]", ")", ")", "?", "$", "request", "[", ...
@param array $request The request parameters. @return int
[ "@param", "array", "$request", "The", "request", "parameters", "." ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L1071-L1085
shopgate/cart-integration-sdk
src/core.php
ShopgateObject.getHelper
protected function getHelper($helperName) { if (array_key_exists($helperName, $this->helperClassInstances)) { $helperClassName = "Shopgate_Helper_" . $helperName; if (!isset($this->helperClassInstances[$helperClassName])) { $this->helperClassInstances[$helperClassName] = new $helperClassName(); } return $this->helperClassInstances[$helperClassName]; } throw new ShopgateLibraryException( "Helper function {$helperName} not found", ShopgateLibraryException::SHOPGATE_HELPER_FUNCTION_NOT_FOUND_EXCEPTION ); }
php
protected function getHelper($helperName) { if (array_key_exists($helperName, $this->helperClassInstances)) { $helperClassName = "Shopgate_Helper_" . $helperName; if (!isset($this->helperClassInstances[$helperClassName])) { $this->helperClassInstances[$helperClassName] = new $helperClassName(); } return $this->helperClassInstances[$helperClassName]; } throw new ShopgateLibraryException( "Helper function {$helperName} not found", ShopgateLibraryException::SHOPGATE_HELPER_FUNCTION_NOT_FOUND_EXCEPTION ); }
[ "protected", "function", "getHelper", "(", "$", "helperName", ")", "{", "if", "(", "array_key_exists", "(", "$", "helperName", ",", "$", "this", "->", "helperClassInstances", ")", ")", "{", "$", "helperClassName", "=", "\"Shopgate_Helper_\"", ".", "$", "helper...
get a instance of an Shopgate helper class depending on the committed name @param $helperName string defined by constants in this class(ShopgateObject) @return Shopgate_Helper_DataStructure|Shopgate_Helper_Pricing|Shopgate_Helper_String returns the requested helper instance @throws ShopgateLibraryException
[ "get", "a", "instance", "of", "an", "Shopgate", "helper", "class", "depending", "on", "the", "committed", "name" ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L1152-L1166
shopgate/cart-integration-sdk
src/core.php
ShopgateObject.log
public function log($msg, $type = ShopgateLogger::LOGTYPE_ERROR) { return ShopgateLogger::getInstance()->log($msg, $type); }
php
public function log($msg, $type = ShopgateLogger::LOGTYPE_ERROR) { return ShopgateLogger::getInstance()->log($msg, $type); }
[ "public", "function", "log", "(", "$", "msg", ",", "$", "type", "=", "ShopgateLogger", "::", "LOGTYPE_ERROR", ")", "{", "return", "ShopgateLogger", "::", "getInstance", "(", ")", "->", "log", "(", "$", "msg", ",", "$", "type", ")", ";", "}" ]
Convenience method for logging to the ShopgateLogger. @param string $msg The error message. @param string $type The log type, that would be one of the ShopgateLogger::LOGTYPE_* constants. @return bool True on success, false on error.
[ "Convenience", "method", "for", "logging", "to", "the", "ShopgateLogger", "." ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L1176-L1179
shopgate/cart-integration-sdk
src/core.php
ShopgateObject.camelize
public function camelize($str, $capitalizeFirst = false) { $hash = md5($str . $capitalizeFirst); if (empty($this->camelizeCache[$hash])) { $str = strtolower($str); if ($capitalizeFirst) { $str[0] = strtoupper($str[0]); } $this->camelizeCache[$hash] = preg_replace_callback('/_([a-z0-9])/', array($this, 'camelizeHelper'), $str); } return $this->camelizeCache[$hash]; }
php
public function camelize($str, $capitalizeFirst = false) { $hash = md5($str . $capitalizeFirst); if (empty($this->camelizeCache[$hash])) { $str = strtolower($str); if ($capitalizeFirst) { $str[0] = strtoupper($str[0]); } $this->camelizeCache[$hash] = preg_replace_callback('/_([a-z0-9])/', array($this, 'camelizeHelper'), $str); } return $this->camelizeCache[$hash]; }
[ "public", "function", "camelize", "(", "$", "str", ",", "$", "capitalizeFirst", "=", "false", ")", "{", "$", "hash", "=", "md5", "(", "$", "str", ".", "$", "capitalizeFirst", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "camelizeCache", "[",...
Converts a an underscored string to a camelized one. e.g.:<br /> $this->camelize("get_categories_csv") returns "getCategoriesCsv"<br /> $this->camelize("shopgate_library", true) returns "ShopgateLibrary"<br /> @param string $str The underscored string. @param bool $capitalizeFirst Set true to capitalize the first letter (e.g. for class names). Default: false. @return string The camelized string.
[ "Converts", "a", "an", "underscored", "string", "to", "a", "camelized", "one", "." ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L1193-L1206
shopgate/cart-integration-sdk
src/core.php
ShopgateObject.jsonEncode
public function jsonEncode($value) { try { return $this->getHelper(self::HELPER_DATASTRUCTURE)->jsonEncode($value); } catch (ShopgateLibraryException $ignore) { // will not happen return ''; } }
php
public function jsonEncode($value) { try { return $this->getHelper(self::HELPER_DATASTRUCTURE)->jsonEncode($value); } catch (ShopgateLibraryException $ignore) { // will not happen return ''; } }
[ "public", "function", "jsonEncode", "(", "$", "value", ")", "{", "try", "{", "return", "$", "this", "->", "getHelper", "(", "self", "::", "HELPER_DATASTRUCTURE", ")", "->", "jsonEncode", "(", "$", "value", ")", ";", "}", "catch", "(", "ShopgateLibraryExcep...
Creates a JSON string from any passed value. Uses json_encode() if present, otherwise falls back to Zend's JSON encoder. @param mixed $value @return string | bool in case an error happened false will be returned @deprecated use Shopgate_Helper_DataStructure::jsonEncode() instead
[ "Creates", "a", "JSON", "string", "from", "any", "passed", "value", ".", "Uses", "json_encode", "()", "if", "present", "otherwise", "falls", "back", "to", "Zend", "s", "JSON", "encoder", "." ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L1223-L1231
shopgate/cart-integration-sdk
src/core.php
ShopgateObject.jsonDecode
public function jsonDecode($json, $assoc = false) { try { return $this->getHelper(self::HELPER_DATASTRUCTURE)->jsonDecode($json, $assoc); } catch (ShopgateLibraryException $ignore) { // will not happen return ''; } }
php
public function jsonDecode($json, $assoc = false) { try { return $this->getHelper(self::HELPER_DATASTRUCTURE)->jsonDecode($json, $assoc); } catch (ShopgateLibraryException $ignore) { // will not happen return ''; } }
[ "public", "function", "jsonDecode", "(", "$", "json", ",", "$", "assoc", "=", "false", ")", "{", "try", "{", "return", "$", "this", "->", "getHelper", "(", "self", "::", "HELPER_DATASTRUCTURE", ")", "->", "jsonDecode", "(", "$", "json", ",", "$", "asso...
Creates a variable, array or object from any passed JSON string. Uses json_decode() if present, otherwise falls back to Zend's JSON decoder. @param string $json @param bool $assoc @return mixed @deprecated use Shopgate_Helper_DataStructure::jsonDecode() instead
[ "Creates", "a", "variable", "array", "or", "object", "from", "any", "passed", "JSON", "string", ".", "Uses", "json_decode", "()", "if", "present", "otherwise", "falls", "back", "to", "Zend", "s", "JSON", "decoder", "." ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L1244-L1252
shopgate/cart-integration-sdk
src/core.php
ShopgateObject.stringToUtf8
public function stringToUtf8($string, $sourceEncoding = 'ISO-8859-15', $force = false, $useIconv = false) { $conditions = is_string($sourceEncoding) && ($sourceEncoding == SHOPGATE_LIBRARY_ENCODING) && !$force; return ($conditions) ? $string : $this->convertEncoding($string, SHOPGATE_LIBRARY_ENCODING, $sourceEncoding, $useIconv); }
php
public function stringToUtf8($string, $sourceEncoding = 'ISO-8859-15', $force = false, $useIconv = false) { $conditions = is_string($sourceEncoding) && ($sourceEncoding == SHOPGATE_LIBRARY_ENCODING) && !$force; return ($conditions) ? $string : $this->convertEncoding($string, SHOPGATE_LIBRARY_ENCODING, $sourceEncoding, $useIconv); }
[ "public", "function", "stringToUtf8", "(", "$", "string", ",", "$", "sourceEncoding", "=", "'ISO-8859-15'", ",", "$", "force", "=", "false", ",", "$", "useIconv", "=", "false", ")", "{", "$", "conditions", "=", "is_string", "(", "$", "sourceEncoding", ")",...
Encodes a string from a given encoding to UTF-8. @param string $string The string to encode. @param string|string[] $sourceEncoding The (possible) encoding(s) of $string. @param bool $force Set this true to enforce encoding even if the source encoding is already UTF-8. @param bool $useIconv True to use iconv instead of mb_convert_encoding even if the mb library is present. @return string The UTF-8 encoded string.
[ "Encodes", "a", "string", "from", "a", "given", "encoding", "to", "UTF", "-", "8", "." ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L1266-L1276
shopgate/cart-integration-sdk
src/core.php
ShopgateObject.stringFromUtf8
public function stringFromUtf8($string, $destinationEncoding = 'ISO-8859-15', $force = false, $useIconv = false) { return ($destinationEncoding == SHOPGATE_LIBRARY_ENCODING) && !$force ? $string : $this->convertEncoding($string, $destinationEncoding, SHOPGATE_LIBRARY_ENCODING, $useIconv); }
php
public function stringFromUtf8($string, $destinationEncoding = 'ISO-8859-15', $force = false, $useIconv = false) { return ($destinationEncoding == SHOPGATE_LIBRARY_ENCODING) && !$force ? $string : $this->convertEncoding($string, $destinationEncoding, SHOPGATE_LIBRARY_ENCODING, $useIconv); }
[ "public", "function", "stringFromUtf8", "(", "$", "string", ",", "$", "destinationEncoding", "=", "'ISO-8859-15'", ",", "$", "force", "=", "false", ",", "$", "useIconv", "=", "false", ")", "{", "return", "(", "$", "destinationEncoding", "==", "SHOPGATE_LIBRARY...
Decodes a string from UTF-8 to a given encoding. @param string $string The string to decode. @param string $destinationEncoding The desired encoding of the return value. @param bool $force Set this true to enforce encoding even if the destination encoding is set to UTF-8. @param bool $useIconv True to use iconv instead of mb_convert_encoding even if the mb library is present. @return string The UTF-8 decoded string.
[ "Decodes", "a", "string", "from", "UTF", "-", "8", "to", "a", "given", "encoding", "." ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L1290-L1295
shopgate/cart-integration-sdk
src/core.php
ShopgateObject.recursiveToUtf8
public function recursiveToUtf8($subject, $sourceEncoding = 'ISO-8859-15', $force = false, $useIconv = false) { /** @var array $subject */ if (is_array($subject)) { foreach ($subject as $key => $value) { $subject[$key] = $this->recursiveToUtf8($value, $sourceEncoding, $force, $useIconv); } return $subject; } elseif (is_object($subject)) { /** @var \stdClass $subject */ $objectVars = get_object_vars($subject); foreach ($objectVars as $property => $value) { $subject->{$property} = $this->recursiveToUtf8($value, $sourceEncoding, $force, $useIconv); } return $subject; } elseif (is_string($subject)) { /** @var string $subject */ return $this->stringToUtf8($subject, $sourceEncoding, $force, $useIconv); } return $subject; }
php
public function recursiveToUtf8($subject, $sourceEncoding = 'ISO-8859-15', $force = false, $useIconv = false) { /** @var array $subject */ if (is_array($subject)) { foreach ($subject as $key => $value) { $subject[$key] = $this->recursiveToUtf8($value, $sourceEncoding, $force, $useIconv); } return $subject; } elseif (is_object($subject)) { /** @var \stdClass $subject */ $objectVars = get_object_vars($subject); foreach ($objectVars as $property => $value) { $subject->{$property} = $this->recursiveToUtf8($value, $sourceEncoding, $force, $useIconv); } return $subject; } elseif (is_string($subject)) { /** @var string $subject */ return $this->stringToUtf8($subject, $sourceEncoding, $force, $useIconv); } return $subject; }
[ "public", "function", "recursiveToUtf8", "(", "$", "subject", ",", "$", "sourceEncoding", "=", "'ISO-8859-15'", ",", "$", "force", "=", "false", ",", "$", "useIconv", "=", "false", ")", "{", "/** @var array $subject */", "if", "(", "is_array", "(", "$", "sub...
Encodes the values of an array, object or string from a given encoding to UTF-8 recursively. If the subject is an array, the values will be encoded, keys will be preserved. If the subject is an object, all accessible properties' values will be encoded. If the subject is a string, it will simply be encoded. If the subject is anything else, it will be returned as is. @param mixed $subject The subject to encode @param string|string[] $sourceEncoding The (possible) encoding(s) of $string @param bool $force Set this true to enforce encoding even if the source encoding is already UTF-8 @param bool $useIconv True to use iconv instead of mb_convert_encoding even if the mb library is present @return mixed UTF-8 encoded $subject
[ "Encodes", "the", "values", "of", "an", "array", "object", "or", "string", "from", "a", "given", "encoding", "to", "UTF", "-", "8", "recursively", "." ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L1314-L1337
shopgate/cart-integration-sdk
src/core.php
ShopgateObject.recursiveFromUtf8
public function recursiveFromUtf8($subject, $destinationEncoding = 'ISO-8859-15', $force = false, $useIconv = false) { if (is_array($subject)) { /** @var array $subject */ foreach ($subject as $key => $value) { $subject[$key] = $this->recursiveFromUtf8($value, $destinationEncoding, $force, $useIconv); } return $subject; } elseif (is_object($subject)) { /** @var \stdClass $subject */ $objectVars = get_object_vars($subject); foreach ($objectVars as $property => $value) { $subject->{$property} = $this->recursiveFromUtf8($value, $destinationEncoding, $force, $useIconv); } return $subject; } elseif (is_string($subject)) { /** @var string $subject */ return $this->stringFromUtf8($subject, $destinationEncoding, $force, $useIconv); } return $subject; }
php
public function recursiveFromUtf8($subject, $destinationEncoding = 'ISO-8859-15', $force = false, $useIconv = false) { if (is_array($subject)) { /** @var array $subject */ foreach ($subject as $key => $value) { $subject[$key] = $this->recursiveFromUtf8($value, $destinationEncoding, $force, $useIconv); } return $subject; } elseif (is_object($subject)) { /** @var \stdClass $subject */ $objectVars = get_object_vars($subject); foreach ($objectVars as $property => $value) { $subject->{$property} = $this->recursiveFromUtf8($value, $destinationEncoding, $force, $useIconv); } return $subject; } elseif (is_string($subject)) { /** @var string $subject */ return $this->stringFromUtf8($subject, $destinationEncoding, $force, $useIconv); } return $subject; }
[ "public", "function", "recursiveFromUtf8", "(", "$", "subject", ",", "$", "destinationEncoding", "=", "'ISO-8859-15'", ",", "$", "force", "=", "false", ",", "$", "useIconv", "=", "false", ")", "{", "if", "(", "is_array", "(", "$", "subject", ")", ")", "{...
Decodes the values of an array, object or string from UTF-8 to a given encoding recursively If the subject is an array, the values will be decoded, keys will be preserved. If the subject is an object, all accessible properties' values will be decoded. If the subject is a string, it will simply be decoded. If the subject is anything else, it will be returned as is. @param mixed $subject The subject to decode @param string $destinationEncoding The desired encoding of the return value @param bool $force Set this true to enforce encoding even if the destination encoding is set to UTF-8 @param bool $useIconv True to use iconv instead of mb_convert_encoding even if the mb library is present @return mixed UTF-8 decoded $subject
[ "Decodes", "the", "values", "of", "an", "array", "object", "or", "string", "from", "UTF", "-", "8", "to", "a", "given", "encoding", "recursively" ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L1356-L1379
shopgate/cart-integration-sdk
src/core.php
ShopgateObject.convertEncoding
protected function convertEncoding($string, $destinationEncoding, $sourceEncoding, $useIconv = false) { if (function_exists('mb_convert_encoding') && !$useIconv) { $convertedString = mb_convert_encoding($string, $destinationEncoding, $sourceEncoding); } else { // I have no excuse for the following. Please forgive me. if (is_array($sourceEncoding)) { $bestEncoding = ''; $bestScore = null; foreach ($sourceEncoding as $encoding) { $score = abs(strlen($string) - strlen(@iconv($encoding, $destinationEncoding, $string))); if (is_null($bestScore) || ($score < $bestScore)) { $bestScore = $score; $bestEncoding = $encoding; } } $sourceEncoding = $bestEncoding; } $convertedString = @iconv($sourceEncoding, $destinationEncoding . '//IGNORE', $string); } return $convertedString; }
php
protected function convertEncoding($string, $destinationEncoding, $sourceEncoding, $useIconv = false) { if (function_exists('mb_convert_encoding') && !$useIconv) { $convertedString = mb_convert_encoding($string, $destinationEncoding, $sourceEncoding); } else { // I have no excuse for the following. Please forgive me. if (is_array($sourceEncoding)) { $bestEncoding = ''; $bestScore = null; foreach ($sourceEncoding as $encoding) { $score = abs(strlen($string) - strlen(@iconv($encoding, $destinationEncoding, $string))); if (is_null($bestScore) || ($score < $bestScore)) { $bestScore = $score; $bestEncoding = $encoding; } } $sourceEncoding = $bestEncoding; } $convertedString = @iconv($sourceEncoding, $destinationEncoding . '//IGNORE', $string); } return $convertedString; }
[ "protected", "function", "convertEncoding", "(", "$", "string", ",", "$", "destinationEncoding", ",", "$", "sourceEncoding", ",", "$", "useIconv", "=", "false", ")", "{", "if", "(", "function_exists", "(", "'mb_convert_encoding'", ")", "&&", "!", "$", "useIcon...
Converts a string's encoding to another. This wraps the mb_convert_encoding() and iconv() functions of PHP. If the mb_string extension is not installed, iconv() will be used instead. If iconv() must be used and an array is passed as $sourceEncoding all encodings will be tested and the (probably) best encoding will be used for conversion. @see http://php.net/manual/en/function.mb-convert-encoding.php @see http://php.net/manual/en/function.iconv.php @param string $string The string to decode. @param string $destinationEncoding The desired encoding of the return value. @param string|string[] $sourceEncoding The (possible) encoding(s) of $string. @param bool $useIconv True to use iconv instead of mb_convert_encoding even if the mb library is present. @return string The UTF-8 decoded string.
[ "Converts", "a", "string", "s", "encoding", "to", "another", "." ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L1402-L1426
shopgate/cart-integration-sdk
src/core.php
ShopgateObject.user_print_r
protected function user_print_r($subject, $ignore = array(), $depth = 1, $refChain = array()) { static $maxDepth = 5; if ($depth > 20) { return; } if (is_object($subject)) { foreach ($refChain as $refVal) { if ($refVal === $subject) { echo "*RECURSION*\n"; return; } } array_push($refChain, $subject); echo get_class($subject) . " Object ( \n"; $subject = (array)$subject; foreach ($subject as $key => $val) { if (is_array($ignore) && !in_array($key, $ignore, 1)) { echo str_repeat(" ", $depth * 4) . '['; if ($key{0} == "\0") { $keyParts = explode("\0", $key); echo $keyParts[2] . (($keyParts[1] == '*') ? ':protected' : ':private'); } else { echo $key; } echo '] => '; if ($depth == $maxDepth) { return; } $this->user_print_r($val, $ignore, $depth + 1, $refChain); } } echo str_repeat(" ", ($depth - 1) * 4) . ")\n"; array_pop($refChain); } elseif (is_array($subject)) { echo "Array ( \n"; foreach ($subject as $key => $val) { if (is_array($ignore) && !in_array($key, $ignore, 1)) { echo str_repeat(" ", $depth * 4) . '[' . $key . '] => '; if ($depth == $maxDepth) { return; } $this->user_print_r($val, $ignore, $depth + 1, $refChain); } } echo str_repeat(" ", ($depth - 1) * 4) . ")\n"; } else { echo $subject . "\n"; } }
php
protected function user_print_r($subject, $ignore = array(), $depth = 1, $refChain = array()) { static $maxDepth = 5; if ($depth > 20) { return; } if (is_object($subject)) { foreach ($refChain as $refVal) { if ($refVal === $subject) { echo "*RECURSION*\n"; return; } } array_push($refChain, $subject); echo get_class($subject) . " Object ( \n"; $subject = (array)$subject; foreach ($subject as $key => $val) { if (is_array($ignore) && !in_array($key, $ignore, 1)) { echo str_repeat(" ", $depth * 4) . '['; if ($key{0} == "\0") { $keyParts = explode("\0", $key); echo $keyParts[2] . (($keyParts[1] == '*') ? ':protected' : ':private'); } else { echo $key; } echo '] => '; if ($depth == $maxDepth) { return; } $this->user_print_r($val, $ignore, $depth + 1, $refChain); } } echo str_repeat(" ", ($depth - 1) * 4) . ")\n"; array_pop($refChain); } elseif (is_array($subject)) { echo "Array ( \n"; foreach ($subject as $key => $val) { if (is_array($ignore) && !in_array($key, $ignore, 1)) { echo str_repeat(" ", $depth * 4) . '[' . $key . '] => '; if ($depth == $maxDepth) { return; } $this->user_print_r($val, $ignore, $depth + 1, $refChain); } } echo str_repeat(" ", ($depth - 1) * 4) . ")\n"; } else { echo $subject . "\n"; } }
[ "protected", "function", "user_print_r", "(", "$", "subject", ",", "$", "ignore", "=", "array", "(", ")", ",", "$", "depth", "=", "1", ",", "$", "refChain", "=", "array", "(", ")", ")", "{", "static", "$", "maxDepth", "=", "5", ";", "if", "(", "$...
Takes any big object that can contain recursion and dumps it to the output buffer @param mixed $subject @param array $ignore @param int $depth @param array $refChain
[ "Takes", "any", "big", "object", "that", "can", "contain", "recursion", "and", "dumps", "it", "to", "the", "output", "buffer" ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L1436-L1488
shopgate/cart-integration-sdk
src/core.php
ShopgateObject.getMemoryUsageString
protected function getMemoryUsageString() { switch (strtoupper(trim(ShopgateLogger::getInstance()->getMemoryAnalyserLoggingSizeUnit()))) { case 'GB': return (memory_get_usage() / (1024 * 1024 * 1024)) . " GB (real usage " . (memory_get_usage( true ) / (1024 * 1024 * 1024)) . " GB)"; case 'MB': return (memory_get_usage() / (1024 * 1024)) . " MB (real usage " . (memory_get_usage( true ) / (1024 * 1024)) . " MB)"; case 'KB': return (memory_get_usage() / 1024) . " KB (real usage " . (memory_get_usage(true) / 1024) . " KB)"; default: return memory_get_usage() . " Bytes (real usage " . memory_get_usage(true) . " Bytes)"; } }
php
protected function getMemoryUsageString() { switch (strtoupper(trim(ShopgateLogger::getInstance()->getMemoryAnalyserLoggingSizeUnit()))) { case 'GB': return (memory_get_usage() / (1024 * 1024 * 1024)) . " GB (real usage " . (memory_get_usage( true ) / (1024 * 1024 * 1024)) . " GB)"; case 'MB': return (memory_get_usage() / (1024 * 1024)) . " MB (real usage " . (memory_get_usage( true ) / (1024 * 1024)) . " MB)"; case 'KB': return (memory_get_usage() / 1024) . " KB (real usage " . (memory_get_usage(true) / 1024) . " KB)"; default: return memory_get_usage() . " Bytes (real usage " . memory_get_usage(true) . " Bytes)"; } }
[ "protected", "function", "getMemoryUsageString", "(", ")", "{", "switch", "(", "strtoupper", "(", "trim", "(", "ShopgateLogger", "::", "getInstance", "(", ")", "->", "getMemoryAnalyserLoggingSizeUnit", "(", ")", ")", ")", ")", "{", "case", "'GB'", ":", "return...
Gets the used memory and real used memory and returns it as a string @return string
[ "Gets", "the", "used", "memory", "and", "real", "used", "memory", "and", "returns", "it", "as", "a", "string" ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L1516-L1532
shopgate/cart-integration-sdk
src/core.php
ShopgatePlugin.getEnabledPluginActions
public function getEnabledPluginActions() { $enabledActionsList = array(); $configValues = $this->config->toArray(); // find all settings that start with "enable_" in the config-value-name and collect all active ones $searchKeyPart = 'enable_'; foreach ($configValues as $key => $val) { if (substr($key, 0, strlen($searchKeyPart)) == $searchKeyPart) { if ($val) { $enabledActionsList[$key] = $val; } } } return $enabledActionsList; }
php
public function getEnabledPluginActions() { $enabledActionsList = array(); $configValues = $this->config->toArray(); // find all settings that start with "enable_" in the config-value-name and collect all active ones $searchKeyPart = 'enable_'; foreach ($configValues as $key => $val) { if (substr($key, 0, strlen($searchKeyPart)) == $searchKeyPart) { if ($val) { $enabledActionsList[$key] = $val; } } } return $enabledActionsList; }
[ "public", "function", "getEnabledPluginActions", "(", ")", "{", "$", "enabledActionsList", "=", "array", "(", ")", ";", "$", "configValues", "=", "$", "this", "->", "config", "->", "toArray", "(", ")", ";", "// find all settings that start with \"enable_\" in the co...
Checks the config for every 'enabled_<action-name>' setting and returns all active as an indexed list @return array
[ "Checks", "the", "config", "for", "every", "enabled_<action", "-", "name", ">", "setting", "and", "returns", "all", "active", "as", "an", "indexed", "list" ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L1738-L1755
shopgate/cart-integration-sdk
src/core.php
ShopgatePlugin.startGetItemsCsv
final public function startGetItemsCsv() { $this->buffer->setFile($this->config->getItemsCsvPath()); $this->createItemsCsv(); $this->buffer->finish(); }
php
final public function startGetItemsCsv() { $this->buffer->setFile($this->config->getItemsCsvPath()); $this->createItemsCsv(); $this->buffer->finish(); }
[ "final", "public", "function", "startGetItemsCsv", "(", ")", "{", "$", "this", "->", "buffer", "->", "setFile", "(", "$", "this", "->", "config", "->", "getItemsCsvPath", "(", ")", ")", ";", "$", "this", "->", "createItemsCsv", "(", ")", ";", "$", "thi...
Takes care of buffer and file handlers and calls ShopgatePlugin::createItemsCsv(). @throws ShopgateLibraryException
[ "Takes", "care", "of", "buffer", "and", "file", "handlers", "and", "calls", "ShopgatePlugin", "::", "createItemsCsv", "()", "." ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L1762-L1767
shopgate/cart-integration-sdk
src/core.php
ShopgatePlugin.startGetMediaCsv
final public function startGetMediaCsv() { $this->buffer->setFile($this->config->getMediaCsvPath()); $this->createMediaCsv(); $this->buffer->finish(); }
php
final public function startGetMediaCsv() { $this->buffer->setFile($this->config->getMediaCsvPath()); $this->createMediaCsv(); $this->buffer->finish(); }
[ "final", "public", "function", "startGetMediaCsv", "(", ")", "{", "$", "this", "->", "buffer", "->", "setFile", "(", "$", "this", "->", "config", "->", "getMediaCsvPath", "(", ")", ")", ";", "$", "this", "->", "createMediaCsv", "(", ")", ";", "$", "thi...
Takes care of buffer and file handlers and calls ShopgatePlugin::createItemsCsv(). @throws ShopgateLibraryException
[ "Takes", "care", "of", "buffer", "and", "file", "handlers", "and", "calls", "ShopgatePlugin", "::", "createItemsCsv", "()", "." ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L1774-L1779
shopgate/cart-integration-sdk
src/core.php
ShopgatePlugin.startGetCategoriesCsv
final public function startGetCategoriesCsv() { $this->buffer->setFile($this->config->getCategoriesCsvPath()); $this->createCategoriesCsv(); $this->buffer->finish(); }
php
final public function startGetCategoriesCsv() { $this->buffer->setFile($this->config->getCategoriesCsvPath()); $this->createCategoriesCsv(); $this->buffer->finish(); }
[ "final", "public", "function", "startGetCategoriesCsv", "(", ")", "{", "$", "this", "->", "buffer", "->", "setFile", "(", "$", "this", "->", "config", "->", "getCategoriesCsvPath", "(", ")", ")", ";", "$", "this", "->", "createCategoriesCsv", "(", ")", ";"...
Takes care of buffer and file handlers and calls ShopgatePlugin::createCategoriesCsv(). @throws ShopgateLibraryException
[ "Takes", "care", "of", "buffer", "and", "file", "handlers", "and", "calls", "ShopgatePlugin", "::", "createCategoriesCsv", "()", "." ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L1786-L1791
shopgate/cart-integration-sdk
src/core.php
ShopgatePlugin.startGetReviewsCsv
final public function startGetReviewsCsv() { $this->buffer->setFile($this->config->getReviewsCsvPath()); $this->createReviewsCsv(); $this->buffer->finish(); }
php
final public function startGetReviewsCsv() { $this->buffer->setFile($this->config->getReviewsCsvPath()); $this->createReviewsCsv(); $this->buffer->finish(); }
[ "final", "public", "function", "startGetReviewsCsv", "(", ")", "{", "$", "this", "->", "buffer", "->", "setFile", "(", "$", "this", "->", "config", "->", "getReviewsCsvPath", "(", ")", ")", ";", "$", "this", "->", "createReviewsCsv", "(", ")", ";", "$", ...
Takes care of buffer and file handlers and calls ShopgatePlugin::createReviewsCsv(). @throws ShopgateLibraryException
[ "Takes", "care", "of", "buffer", "and", "file", "handlers", "and", "calls", "ShopgatePlugin", "::", "createReviewsCsv", "()", "." ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L1798-L1803
shopgate/cart-integration-sdk
src/core.php
ShopgatePlugin.startGetItems
final public function startGetItems($limit = null, $offset = null, array $uids = array(), $responseType = 'xml') { switch ($responseType) { default: case 'xml': $this->buffer->setFile($this->config->getItemsXmlPath()); break; case 'json': $this->buffer->setFile($this->config->getItemsJsonPath()); break; } $this->createItems($limit, $offset, $uids); $this->buffer->finish(); }
php
final public function startGetItems($limit = null, $offset = null, array $uids = array(), $responseType = 'xml') { switch ($responseType) { default: case 'xml': $this->buffer->setFile($this->config->getItemsXmlPath()); break; case 'json': $this->buffer->setFile($this->config->getItemsJsonPath()); break; } $this->createItems($limit, $offset, $uids); $this->buffer->finish(); }
[ "final", "public", "function", "startGetItems", "(", "$", "limit", "=", "null", ",", "$", "offset", "=", "null", ",", "array", "$", "uids", "=", "array", "(", ")", ",", "$", "responseType", "=", "'xml'", ")", "{", "switch", "(", "$", "responseType", ...
Takes care of buffer and file handlers and calls ShopgatePlugin::createPagesCsv(). @param int $limit @param int $offset @param array $uids @param string $responseType
[ "Takes", "care", "of", "buffer", "and", "file", "handlers", "and", "calls", "ShopgatePlugin", "::", "createPagesCsv", "()", "." ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L1813-L1828
shopgate/cart-integration-sdk
src/core.php
ShopgatePlugin.startGetCategories
final public function startGetCategories( $limit = null, $offset = null, array $uids = array(), $responseType = 'xml' ) { switch ($responseType) { default: case 'xml': $this->buffer->setFile($this->config->getCategoriesXmlPath()); break; case 'json': $this->buffer->setFile($this->config->getCategoriesJsonPath()); break; } $this->createCategories($limit, $offset, $uids); $this->buffer->finish(); }
php
final public function startGetCategories( $limit = null, $offset = null, array $uids = array(), $responseType = 'xml' ) { switch ($responseType) { default: case 'xml': $this->buffer->setFile($this->config->getCategoriesXmlPath()); break; case 'json': $this->buffer->setFile($this->config->getCategoriesJsonPath()); break; } $this->createCategories($limit, $offset, $uids); $this->buffer->finish(); }
[ "final", "public", "function", "startGetCategories", "(", "$", "limit", "=", "null", ",", "$", "offset", "=", "null", ",", "array", "$", "uids", "=", "array", "(", ")", ",", "$", "responseType", "=", "'xml'", ")", "{", "switch", "(", "$", "responseType...
Takes care of buffer and file handlers and calls ShopgatePlugin::createCategories(). @param int $limit @param int $offset @param array $uids @param string $responseType
[ "Takes", "care", "of", "buffer", "and", "file", "handlers", "and", "calls", "ShopgatePlugin", "::", "createCategories", "()", "." ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L1838-L1857
shopgate/cart-integration-sdk
src/core.php
ShopgatePlugin.startGetReviews
final public function startGetReviews($limit = null, $offset = null, array $uids = array(), $responseType = 'xml') { switch ($responseType) { default: case 'xml': $this->buffer->setFile($this->config->getReviewsXmlPath()); break; case 'json': $this->buffer->setFile($this->config->getReviewsJsonPath()); break; } $this->createReviews($limit, $offset, $uids); $this->buffer->finish(); }
php
final public function startGetReviews($limit = null, $offset = null, array $uids = array(), $responseType = 'xml') { switch ($responseType) { default: case 'xml': $this->buffer->setFile($this->config->getReviewsXmlPath()); break; case 'json': $this->buffer->setFile($this->config->getReviewsJsonPath()); break; } $this->createReviews($limit, $offset, $uids); $this->buffer->finish(); }
[ "final", "public", "function", "startGetReviews", "(", "$", "limit", "=", "null", ",", "$", "offset", "=", "null", ",", "array", "$", "uids", "=", "array", "(", ")", ",", "$", "responseType", "=", "'xml'", ")", "{", "switch", "(", "$", "responseType", ...
Takes care of buffer and file handlers and calls ShopgatePlugin::createReviews(). @param int $limit @param int $offset @param array $uids @param string $responseType
[ "Takes", "care", "of", "buffer", "and", "file", "handlers", "and", "calls", "ShopgatePlugin", "::", "createReviews", "()", "." ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L1867-L1882
shopgate/cart-integration-sdk
src/core.php
ShopgatePlugin.removeTagsFromString
protected function removeTagsFromString($string, $removeTags = array(), $additionalAllowedTags = array()) { $helper = $this->getHelper(self::HELPER_STRING); return $helper->removeTagsFromString($string, $removeTags, $additionalAllowedTags); }
php
protected function removeTagsFromString($string, $removeTags = array(), $additionalAllowedTags = array()) { $helper = $this->getHelper(self::HELPER_STRING); return $helper->removeTagsFromString($string, $removeTags, $additionalAllowedTags); }
[ "protected", "function", "removeTagsFromString", "(", "$", "string", ",", "$", "removeTags", "=", "array", "(", ")", ",", "$", "additionalAllowedTags", "=", "array", "(", ")", ")", "{", "$", "helper", "=", "$", "this", "->", "getHelper", "(", "self", "::...
Removes all disallowed HTML tags from a given string. By default the following are allowed: "ADDRESS", "AREA", "A", "BASE", "BASEFONT", "BIG", "BLOCKQUOTE", "BODY", "BR", "B", "CAPTION", "CENTER", "CITE", "CODE", "DD", "DFN", "DIR", "DIV", "DL", "DT", "EM", "FONT", "FORM", "H1", "H2", "H3", "H4", "H5", "H6", "HEAD", "HR", "HTML", "ISINDEX", "I", "KBD", "LINK", "LI", "MAP", "MENU", "META", "OL", "OPTION", "PARAM", "PRE", "IMG", "INPUT", "P", "SAMP", "SELECT", "SMALL", "STRIKE", "STRONG", "STYLE", "SUB", "SUP", "TABLE", "TD", "TEXTAREA", "TH", "TITLE", "TR", "TT", "UL", "U", "VAR" @param string $string The input string to be filtered. @param string[] $removeTags The tags to be removed. @param string[] $additionalAllowedTags Additional tags to be allowed. @return string The sanititzed string.
[ "Removes", "all", "disallowed", "HTML", "tags", "from", "a", "given", "string", "." ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L2272-L2277
shopgate/cart-integration-sdk
src/core.php
ShopgatePlugin.formatPriceNumber
protected function formatPriceNumber($price, $digits = 2, $decimalPoint = ".", $thousandPoints = "") { $helper = $this->getHelper(self::HELPER_PRICING); return $helper->formatPriceNumber($price, $digits, $decimalPoint, $thousandPoints); }
php
protected function formatPriceNumber($price, $digits = 2, $decimalPoint = ".", $thousandPoints = "") { $helper = $this->getHelper(self::HELPER_PRICING); return $helper->formatPriceNumber($price, $digits, $decimalPoint, $thousandPoints); }
[ "protected", "function", "formatPriceNumber", "(", "$", "price", ",", "$", "digits", "=", "2", ",", "$", "decimalPoint", "=", "\".\"", ",", "$", "thousandPoints", "=", "\"\"", ")", "{", "$", "helper", "=", "$", "this", "->", "getHelper", "(", "self", "...
Rounds and formats a price. @param float $price The price of an item. @param int $digits The number of digits after the decimal separator. @param string $decimalPoint The decimal separator. @param string $thousandPoints The thousands separator. @return float|string
[ "Rounds", "and", "formats", "a", "price", "." ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L2289-L2294
shopgate/cart-integration-sdk
src/core.php
ShopgatePlugin.arrayCross
protected function arrayCross(array $src, $enableFirstRow = false) { $helper = $this->getHelper(self::HELPER_DATASTRUCTURE); return $helper->arrayCross($src, $enableFirstRow); }
php
protected function arrayCross(array $src, $enableFirstRow = false) { $helper = $this->getHelper(self::HELPER_DATASTRUCTURE); return $helper->arrayCross($src, $enableFirstRow); }
[ "protected", "function", "arrayCross", "(", "array", "$", "src", ",", "$", "enableFirstRow", "=", "false", ")", "{", "$", "helper", "=", "$", "this", "->", "getHelper", "(", "self", "::", "HELPER_DATASTRUCTURE", ")", ";", "return", "$", "helper", "->", "...
Takes an array of arrays that contain all elements which are taken to create a cross-product of all elements. The resulting array is an array-list with each possible combination as array. An Element itself can be anything (including a whole array that is not torn apart, but instead treated as a whole) By setting the second parameter to true, the keys of the source array is added as an array at the front of the resulting array Sample input: array( 'group-1-key' => array('a', 'b'), 'group-2-key' => array('x'), 7 => array('l', 'm', 'n'), ); Output of sample: Array ( [0] => Array ( [group-1-key] => a [group-2-key] => x [7] => l ) [1] => Array ( [group-1-key] => b [group-2-key] => x [7] => l ) [2] => Array ( [group-1-key] => a [group-2-key] => x [7] => m ) [...] and so on ... (total of count(src[0])*count(src[1])*...*count(src[N]) elements) [=> 2*1*3 elements in this case] ) @param array $src : The (at least) double dimensioned array input @param bool $enableFirstRow : Disabled by default @return array[][]:
[ "Takes", "an", "array", "of", "arrays", "that", "contain", "all", "elements", "which", "are", "taken", "to", "create", "a", "cross", "-", "product", "of", "all", "elements", ".", "The", "resulting", "array", "is", "an", "array", "-", "list", "with", "eac...
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L2332-L2337
shopgate/cart-integration-sdk
src/core.php
ShopgatePlugin.executeLoaders
final protected function executeLoaders(array $loaders) { $arguments = func_get_args(); array_shift($arguments); foreach ($loaders as $method) { if (method_exists($this, $method)) { $this->log( "Calling function \"{$method}\": Actual memory usage before method: " . $this->getMemoryUsageString( ), ShopgateLogger::LOGTYPE_DEBUG ); try { $result = call_user_func_array(array($this, $method), $arguments); } catch (ShopgateLibraryException $e) { // pass through known Shopgate Cart Integration SDK Exceptions throw $e; } catch (Exception $e) { $msg = "An unknown exception has been thrown in loader method \"{$method}\". Memory usage " . $this->getMemoryUsageString() . " Exception '" . get_class( $e ) . "': [Code: {$e->getCode()}] {$e->getMessage()}"; throw new ShopgateLibraryException( ShopgateLibraryException::UNKNOWN_ERROR_CODE, $msg, true, true, $e ); } if ($result) { $arguments[0] = $result; } } } return $arguments[0]; }
php
final protected function executeLoaders(array $loaders) { $arguments = func_get_args(); array_shift($arguments); foreach ($loaders as $method) { if (method_exists($this, $method)) { $this->log( "Calling function \"{$method}\": Actual memory usage before method: " . $this->getMemoryUsageString( ), ShopgateLogger::LOGTYPE_DEBUG ); try { $result = call_user_func_array(array($this, $method), $arguments); } catch (ShopgateLibraryException $e) { // pass through known Shopgate Cart Integration SDK Exceptions throw $e; } catch (Exception $e) { $msg = "An unknown exception has been thrown in loader method \"{$method}\". Memory usage " . $this->getMemoryUsageString() . " Exception '" . get_class( $e ) . "': [Code: {$e->getCode()}] {$e->getMessage()}"; throw new ShopgateLibraryException( ShopgateLibraryException::UNKNOWN_ERROR_CODE, $msg, true, true, $e ); } if ($result) { $arguments[0] = $result; } } } return $arguments[0]; }
[ "final", "protected", "function", "executeLoaders", "(", "array", "$", "loaders", ")", "{", "$", "arguments", "=", "func_get_args", "(", ")", ";", "array_shift", "(", "$", "arguments", ")", ";", "foreach", "(", "$", "loaders", "as", "$", "method", ")", "...
@param array $loaders @return mixed @throws ShopgateLibraryException
[ "@param", "array", "$loaders" ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L2345-L2382
shopgate/cart-integration-sdk
src/core.php
ShopgatePlugin.getCreateCsvLoaders
final private function getCreateCsvLoaders($subjectName) { $actions = array(); $subjectName = trim($subjectName); if (!empty($subjectName)) { $methodName = 'buildDefault' . $this->camelize($subjectName, true) . 'Row'; if (method_exists($this, $methodName)) { foreach (array_keys($this->{$methodName}()) as $sKey) { $actions[] = $subjectName . "Export" . $this->camelize($sKey, true); } } } return $actions; }
php
final private function getCreateCsvLoaders($subjectName) { $actions = array(); $subjectName = trim($subjectName); if (!empty($subjectName)) { $methodName = 'buildDefault' . $this->camelize($subjectName, true) . 'Row'; if (method_exists($this, $methodName)) { foreach (array_keys($this->{$methodName}()) as $sKey) { $actions[] = $subjectName . "Export" . $this->camelize($sKey, true); } } } return $actions; }
[ "final", "private", "function", "getCreateCsvLoaders", "(", "$", "subjectName", ")", "{", "$", "actions", "=", "array", "(", ")", ";", "$", "subjectName", "=", "trim", "(", "$", "subjectName", ")", ";", "if", "(", "!", "empty", "(", "$", "subjectName", ...
Creates an array of corresponding helper method names, based on the export type given @param string $subjectName @return array
[ "Creates", "an", "array", "of", "corresponding", "helper", "method", "names", "based", "on", "the", "export", "type", "given" ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L2391-L2405
shopgate/cart-integration-sdk
src/core.php
ShopgatePlugin.disableAction
public function disableAction($actionName) { $shopgateSettingsNew = array('enable_' . $actionName => 0); $this->config->load($shopgateSettingsNew); $this->config->save(array_keys($shopgateSettingsNew), true); }
php
public function disableAction($actionName) { $shopgateSettingsNew = array('enable_' . $actionName => 0); $this->config->load($shopgateSettingsNew); $this->config->save(array_keys($shopgateSettingsNew), true); }
[ "public", "function", "disableAction", "(", "$", "actionName", ")", "{", "$", "shopgateSettingsNew", "=", "array", "(", "'enable_'", ".", "$", "actionName", "=>", "0", ")", ";", "$", "this", "->", "config", "->", "load", "(", "$", "shopgateSettingsNew", ")...
disables an API method in the local config @param string $actionName
[ "disables", "an", "API", "method", "in", "the", "local", "config" ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L2458-L2463
shopgate/cart-integration-sdk
src/core.php
ShopgatePlugin.createShopInfo
public function createShopInfo() { $shopInfo = array( 'category_count' => 0, 'item_count' => 0, ); if ($this->config->getEnableGetReviewsCsv()) { $shopInfo['review_count'] = 0; } if ($this->config->getEnableGetMediaCsv()) { $shopInfo['media_count'] = array(); } return $shopInfo; }
php
public function createShopInfo() { $shopInfo = array( 'category_count' => 0, 'item_count' => 0, ); if ($this->config->getEnableGetReviewsCsv()) { $shopInfo['review_count'] = 0; } if ($this->config->getEnableGetMediaCsv()) { $shopInfo['media_count'] = array(); } return $shopInfo; }
[ "public", "function", "createShopInfo", "(", ")", "{", "$", "shopInfo", "=", "array", "(", "'category_count'", "=>", "0", ",", "'item_count'", "=>", "0", ",", ")", ";", "if", "(", "$", "this", "->", "config", "->", "getEnableGetReviewsCsv", "(", ")", ")"...
Callback function for the Shopgate Plugin API ping action. Override this to append additional information about shop system to the response of the ping action. @return mixed[] An array with additional information.
[ "Callback", "function", "for", "the", "Shopgate", "Plugin", "API", "ping", "action", ".", "Override", "this", "to", "append", "additional", "information", "about", "shop", "system", "to", "the", "response", "of", "the", "ping", "action", "." ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L2529-L2545
shopgate/cart-integration-sdk
src/core.php
ShopgatePlugin.redeemCoupons
public function redeemCoupons(ShopgateCart $cart) { $this->disableAction('redeem_coupons'); throw new ShopgateLibraryException( ShopgateLibraryException::PLUGIN_API_DISABLED_ACTION, 'The requested action is disabled and no longer supported.', true, false ); }
php
public function redeemCoupons(ShopgateCart $cart) { $this->disableAction('redeem_coupons'); throw new ShopgateLibraryException( ShopgateLibraryException::PLUGIN_API_DISABLED_ACTION, 'The requested action is disabled and no longer supported.', true, false ); }
[ "public", "function", "redeemCoupons", "(", "ShopgateCart", "$", "cart", ")", "{", "$", "this", "->", "disableAction", "(", "'redeem_coupons'", ")", ";", "throw", "new", "ShopgateLibraryException", "(", "ShopgateLibraryException", "::", "PLUGIN_API_DISABLED_ACTION", "...
Redeems coupons that are passed along with a ShopgateCart object. @param ShopgateCart $cart The ShopgateCart object containing the coupons that should be redeemed. @return array('external_coupons' => ShopgateExternalCoupon[]) @throws ShopgateLibraryException if an error occurs. @see http://developer.shopgate.com/plugin_api/coupons @deprecated no longer supported.
[ "Redeems", "coupons", "that", "are", "passed", "along", "with", "a", "ShopgateCart", "object", "." ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L2632-L2641
shopgate/cart-integration-sdk
src/core.php
ShopgateFileBuffer.flush
protected function flush() { if (empty($this->buffer) && ftell($this->fileHandle) == 0) { throw new ShopgateLibraryException(ShopgateLibraryException::PLUGIN_FILE_EMPTY_BUFFER, null, false, false); } // perform prerequisites on first call if (ftell($this->fileHandle) == 0) { $this->onStart(); } // perform response type specific flushing $this->onFlush(); // clear buffer $this->buffer = array(); }
php
protected function flush() { if (empty($this->buffer) && ftell($this->fileHandle) == 0) { throw new ShopgateLibraryException(ShopgateLibraryException::PLUGIN_FILE_EMPTY_BUFFER, null, false, false); } // perform prerequisites on first call if (ftell($this->fileHandle) == 0) { $this->onStart(); } // perform response type specific flushing $this->onFlush(); // clear buffer $this->buffer = array(); }
[ "protected", "function", "flush", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "buffer", ")", "&&", "ftell", "(", "$", "this", "->", "fileHandle", ")", "==", "0", ")", "{", "throw", "new", "ShopgateLibraryException", "(", "ShopgateLibraryEx...
Flushes buffer to the currently opened file handle in $this->fileHandle. The data is converted to utf-8 if mb_convert_encoding() exists. @throws ShopgateLibraryException if the buffer and file are empty.
[ "Flushes", "buffer", "to", "the", "currently", "opened", "file", "handle", "in", "$this", "-", ">", "fileHandle", "." ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L2990-L3006
shopgate/cart-integration-sdk
src/core.php
ShopgateContainer.loadArray
public function loadArray(array $data = array()) { $unmappedData = array(); if (is_array($data)) { $methods = get_class_methods($this); foreach ($data as $key => $value) { $setter = 'set' . $this->camelize($key, true); if (!in_array($setter, $methods)) { $unmappedData[$key] = $value; continue; } $this->$setter($value); } } return $unmappedData; }
php
public function loadArray(array $data = array()) { $unmappedData = array(); if (is_array($data)) { $methods = get_class_methods($this); foreach ($data as $key => $value) { $setter = 'set' . $this->camelize($key, true); if (!in_array($setter, $methods)) { $unmappedData[$key] = $value; continue; } $this->$setter($value); } } return $unmappedData; }
[ "public", "function", "loadArray", "(", "array", "$", "data", "=", "array", "(", ")", ")", "{", "$", "unmappedData", "=", "array", "(", ")", ";", "if", "(", "is_array", "(", "$", "data", ")", ")", "{", "$", "methods", "=", "get_class_methods", "(", ...
Tries to map an associative array to the object's attributes. The passed data must be an array, it's indices must be the un-camelized, underscored names of the set* methods of the object. Tha data that couldn't be mapped is returned as an array. @param array <string, mixed> $data The data that should be mapped to the container object. @return array<string, mixed> The part of the array that couldn't be mapped.
[ "Tries", "to", "map", "an", "associative", "array", "to", "the", "object", "s", "attributes", "." ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L3207-L3224
shopgate/cart-integration-sdk
src/core.php
ShopgateContainer.compare
public function compare($obj, $obj2, $whitelist) { foreach ($whitelist as $acceptedField) { if ($obj->{$this->camelize('get_' . $acceptedField)}() != $obj2->{$this->camelize('get_' . $acceptedField)}( )) { return false; } } return true; }
php
public function compare($obj, $obj2, $whitelist) { foreach ($whitelist as $acceptedField) { if ($obj->{$this->camelize('get_' . $acceptedField)}() != $obj2->{$this->camelize('get_' . $acceptedField)}( )) { return false; } } return true; }
[ "public", "function", "compare", "(", "$", "obj", ",", "$", "obj2", ",", "$", "whitelist", ")", "{", "foreach", "(", "$", "whitelist", "as", "$", "acceptedField", ")", "{", "if", "(", "$", "obj", "->", "{", "$", "this", "->", "camelize", "(", "'get...
Compares values of two containers. @param ShopgateContainer $obj @param ShopgateContainer $obj2 @param string[] $whitelist @return bool
[ "Compares", "values", "of", "two", "containers", "." ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L3235-L3245
shopgate/cart-integration-sdk
src/core.php
ShopgateContainer.utf8Encode
public function utf8Encode($sourceEncoding = 'ISO-8859-15', $force = false, $useIconv = false) { $visitor = new ShopgateContainerUtf8Visitor( ShopgateContainerUtf8Visitor::MODE_ENCODE, $sourceEncoding, $force, $useIconv ); $visitor->visitContainer($this); return $visitor->getObject(); }
php
public function utf8Encode($sourceEncoding = 'ISO-8859-15', $force = false, $useIconv = false) { $visitor = new ShopgateContainerUtf8Visitor( ShopgateContainerUtf8Visitor::MODE_ENCODE, $sourceEncoding, $force, $useIconv ); $visitor->visitContainer($this); return $visitor->getObject(); }
[ "public", "function", "utf8Encode", "(", "$", "sourceEncoding", "=", "'ISO-8859-15'", ",", "$", "force", "=", "false", ",", "$", "useIconv", "=", "false", ")", "{", "$", "visitor", "=", "new", "ShopgateContainerUtf8Visitor", "(", "ShopgateContainerUtf8Visitor", ...
Creates a new object of the same type with every value recursively utf-8 encoded. @param String $sourceEncoding The source Encoding of the strings @param bool $force Set this true to enforce encoding even if the source encoding is already UTF-8. @param bool $useIconv True to use iconv instead of mb_convert_encoding even if the mb library is present. @return ShopgateContainer The new object with utf-8 encoded values.
[ "Creates", "a", "new", "object", "of", "the", "same", "type", "with", "every", "value", "recursively", "utf", "-", "8", "encoded", "." ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L3269-L3279
shopgate/cart-integration-sdk
src/core.php
ShopgateContainer.utf8Decode
public function utf8Decode($destinationEncoding = 'ISO-8859-15', $force = false, $useIconv = false) { $visitor = new ShopgateContainerUtf8Visitor( ShopgateContainerUtf8Visitor::MODE_DECODE, $destinationEncoding, $force, $useIconv ); $visitor->visitContainer($this); return $visitor->getObject(); }
php
public function utf8Decode($destinationEncoding = 'ISO-8859-15', $force = false, $useIconv = false) { $visitor = new ShopgateContainerUtf8Visitor( ShopgateContainerUtf8Visitor::MODE_DECODE, $destinationEncoding, $force, $useIconv ); $visitor->visitContainer($this); return $visitor->getObject(); }
[ "public", "function", "utf8Decode", "(", "$", "destinationEncoding", "=", "'ISO-8859-15'", ",", "$", "force", "=", "false", ",", "$", "useIconv", "=", "false", ")", "{", "$", "visitor", "=", "new", "ShopgateContainerUtf8Visitor", "(", "ShopgateContainerUtf8Visitor...
Creates a new object of the same type with every value recursively utf-8 decoded. @param String $destinationEncoding The destination Encoding for the strings @param bool $force Set this true to enforce encoding even if the destination encoding is set to UTF-8. @param bool $useIconv True to use iconv instead of mb_convert_encoding even if the mb library is present. @return ShopgateContainer The new object with utf-8 decoded values.
[ "Creates", "a", "new", "object", "of", "the", "same", "type", "with", "every", "value", "recursively", "utf", "-", "8", "decoded", "." ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L3292-L3302
shopgate/cart-integration-sdk
src/core.php
ShopgateContainer.buildProperties
public function buildProperties() { $methods = get_class_methods($this); $properties = get_object_vars($this); $filteredProperties = array(); // only properties that have getters should be extracted foreach ($properties as $property => $value) { $getter = 'get' . $this->camelize($property, true); if (in_array($getter, $methods)) { $filteredProperties[$property] = $this->{$getter}(); } } return $filteredProperties; }
php
public function buildProperties() { $methods = get_class_methods($this); $properties = get_object_vars($this); $filteredProperties = array(); // only properties that have getters should be extracted foreach ($properties as $property => $value) { $getter = 'get' . $this->camelize($property, true); if (in_array($getter, $methods)) { $filteredProperties[$property] = $this->{$getter}(); } } return $filteredProperties; }
[ "public", "function", "buildProperties", "(", ")", "{", "$", "methods", "=", "get_class_methods", "(", "$", "this", ")", ";", "$", "properties", "=", "get_object_vars", "(", "$", "this", ")", ";", "$", "filteredProperties", "=", "array", "(", ")", ";", "...
Creates an array of all properties that have getters. @return mixed[]
[ "Creates", "an", "array", "of", "all", "properties", "that", "have", "getters", "." ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L3309-L3324
shpasser/GaeSupport
src/Shpasser/GaeSupport/Foundation/Application.php
Application.detectGae
protected function detectGae() { if (! class_exists(self::GAE_ID_SERVICE)) { $this->runningOnGae = false; $this->appId = null; return; } $AppIdentityService = self::GAE_ID_SERVICE; $this->appId = $AppIdentityService::getApplicationId(); $this->runningOnGae = ! preg_match('/dev~/', getenv('APPLICATION_ID')); if ($this->runningOnGae) { require_once(__DIR__ . '/gae_realpath.php'); } }
php
protected function detectGae() { if (! class_exists(self::GAE_ID_SERVICE)) { $this->runningOnGae = false; $this->appId = null; return; } $AppIdentityService = self::GAE_ID_SERVICE; $this->appId = $AppIdentityService::getApplicationId(); $this->runningOnGae = ! preg_match('/dev~/', getenv('APPLICATION_ID')); if ($this->runningOnGae) { require_once(__DIR__ . '/gae_realpath.php'); } }
[ "protected", "function", "detectGae", "(", ")", "{", "if", "(", "!", "class_exists", "(", "self", "::", "GAE_ID_SERVICE", ")", ")", "{", "$", "this", "->", "runningOnGae", "=", "false", ";", "$", "this", "->", "appId", "=", "null", ";", "return", ";", ...
Detect if the application is running on GAE. If we run on GAE then 'realpath()' function replacement 'gae_realpath()' is declared, so it won't fail with GAE bucket paths. In order for 'gae_realpath()' function to be called the code has to be patched to use 'gae_realpath()' instead of 'realpath()' using the command 'php artisan gae:deploy --config you@gmail.com' from the terminal.
[ "Detect", "if", "the", "application", "is", "running", "on", "GAE", "." ]
train
https://github.com/shpasser/GaeSupport/blob/7f37f2bf177a4e8f1cbefdf04f49b51016e85ae3/src/Shpasser/GaeSupport/Foundation/Application.php#L51-L66
shpasser/GaeSupport
src/Shpasser/GaeSupport/Foundation/Application.php
Application.bindInstallPaths
public function bindInstallPaths(array $paths) { if ($this->runningOnGae) { $this->instance('path', gae_realpath($paths['app'])); // Here we will bind the install paths into the container as strings that can be // accessed from any point in the system. Each path key is prefixed with path // so that they have the consistent naming convention inside the container. foreach (array_except($paths, array('app', 'storage')) as $key => $value) { $this->instance("path.{$key}", gae_realpath($value)); } $this->bindStoragePath(); } else { parent::bindInstallPaths($paths); } }
php
public function bindInstallPaths(array $paths) { if ($this->runningOnGae) { $this->instance('path', gae_realpath($paths['app'])); // Here we will bind the install paths into the container as strings that can be // accessed from any point in the system. Each path key is prefixed with path // so that they have the consistent naming convention inside the container. foreach (array_except($paths, array('app', 'storage')) as $key => $value) { $this->instance("path.{$key}", gae_realpath($value)); } $this->bindStoragePath(); } else { parent::bindInstallPaths($paths); } }
[ "public", "function", "bindInstallPaths", "(", "array", "$", "paths", ")", "{", "if", "(", "$", "this", "->", "runningOnGae", ")", "{", "$", "this", "->", "instance", "(", "'path'", ",", "gae_realpath", "(", "$", "paths", "[", "'app'", "]", ")", ")", ...
Bind the installation paths to the application. @param array $paths @return void
[ "Bind", "the", "installation", "paths", "to", "the", "application", "." ]
train
https://github.com/shpasser/GaeSupport/blob/7f37f2bf177a4e8f1cbefdf04f49b51016e85ae3/src/Shpasser/GaeSupport/Foundation/Application.php#L94-L114
shpasser/GaeSupport
src/Shpasser/GaeSupport/Foundation/Application.php
Application.bindStoragePath
protected function bindStoragePath() { if ($this->runningOnGae) { $buckets = ini_get('google_app_engine.allow_include_gs_buckets'); // Get the first bucket in the list. $bucket = current(explode(', ', $buckets)); if ($bucket) { $storagePath = "gs://{$bucket}/storage"; if (!file_exists($storagePath)) { mkdir($storagePath); } $this->instance("path.storage", $storagePath); } } }
php
protected function bindStoragePath() { if ($this->runningOnGae) { $buckets = ini_get('google_app_engine.allow_include_gs_buckets'); // Get the first bucket in the list. $bucket = current(explode(', ', $buckets)); if ($bucket) { $storagePath = "gs://{$bucket}/storage"; if (!file_exists($storagePath)) { mkdir($storagePath); } $this->instance("path.storage", $storagePath); } } }
[ "protected", "function", "bindStoragePath", "(", ")", "{", "if", "(", "$", "this", "->", "runningOnGae", ")", "{", "$", "buckets", "=", "ini_get", "(", "'google_app_engine.allow_include_gs_buckets'", ")", ";", "// Get the first bucket in the list.", "$", "bucket", "...
Binds the GAE storage path if running on GAE. The binding of the new storage path overrides the original one which appears in the 'paths.php' file. The GAE storage directory is created if it does not exist already. @return void
[ "Binds", "the", "GAE", "storage", "path", "if", "running", "on", "GAE", ".", "The", "binding", "of", "the", "new", "storage", "path", "overrides", "the", "original", "one", "which", "appears", "in", "the", "paths", ".", "php", "file", "." ]
train
https://github.com/shpasser/GaeSupport/blob/7f37f2bf177a4e8f1cbefdf04f49b51016e85ae3/src/Shpasser/GaeSupport/Foundation/Application.php#L126-L143
potsky/microsoft-translator-php-sdk
src/MicrosoftTranslator/Logger.php
Logger.getMessagePrefix
private static function getMessagePrefix( $object , $category , $severity ) { return '[' . date( 'Y/m/d H:i:s' ) . '][' . $severity. '][' . self::getClassNameWithoutNameSpace( $object ) . '][' . $category . '] '; }
php
private static function getMessagePrefix( $object , $category , $severity ) { return '[' . date( 'Y/m/d H:i:s' ) . '][' . $severity. '][' . self::getClassNameWithoutNameSpace( $object ) . '][' . $category . '] '; }
[ "private", "static", "function", "getMessagePrefix", "(", "$", "object", ",", "$", "category", ",", "$", "severity", ")", "{", "return", "'['", ".", "date", "(", "'Y/m/d H:i:s'", ")", ".", "']['", ".", "$", "severity", ".", "']['", ".", "self", "::", "...
@param string $object @param string $category @param string $severity @return string
[ "@param", "string", "$object", "@param", "string", "$category", "@param", "string", "$severity" ]
train
https://github.com/potsky/microsoft-translator-php-sdk/blob/102f2411be5abb0e57a73c475f8e9e185a9f4859/src/MicrosoftTranslator/Logger.php#L76-L79
potsky/microsoft-translator-php-sdk
src/MicrosoftTranslator/Logger.php
Logger.info
public function info( $object , $category , $message ) { return $this->message( self::getMessagePrefix( $object , $category , 'info' ) . $message , self::LEVEL_INFO ); }
php
public function info( $object , $category , $message ) { return $this->message( self::getMessagePrefix( $object , $category , 'info' ) . $message , self::LEVEL_INFO ); }
[ "public", "function", "info", "(", "$", "object", ",", "$", "category", ",", "$", "message", ")", "{", "return", "$", "this", "->", "message", "(", "self", "::", "getMessagePrefix", "(", "$", "object", ",", "$", "category", ",", "'info'", ")", ".", "...
Info message @param string $object @param string $category @param string $message @return bool
[ "Info", "message" ]
train
https://github.com/potsky/microsoft-translator-php-sdk/blob/102f2411be5abb0e57a73c475f8e9e185a9f4859/src/MicrosoftTranslator/Logger.php#L91-L94
potsky/microsoft-translator-php-sdk
src/MicrosoftTranslator/Logger.php
Logger.warning
public function warning( $object , $category , $message ) { return $this->message( self::getMessagePrefix( $object , $category , 'warn' ) . $message , self::LEVEL_WARNING ); }
php
public function warning( $object , $category , $message ) { return $this->message( self::getMessagePrefix( $object , $category , 'warn' ) . $message , self::LEVEL_WARNING ); }
[ "public", "function", "warning", "(", "$", "object", ",", "$", "category", ",", "$", "message", ")", "{", "return", "$", "this", "->", "message", "(", "self", "::", "getMessagePrefix", "(", "$", "object", ",", "$", "category", ",", "'warn'", ")", ".", ...
Warning message @param string $object @param string $category @param string $message @return bool
[ "Warning", "message" ]
train
https://github.com/potsky/microsoft-translator-php-sdk/blob/102f2411be5abb0e57a73c475f8e9e185a9f4859/src/MicrosoftTranslator/Logger.php#L105-L108
potsky/microsoft-translator-php-sdk
src/MicrosoftTranslator/Logger.php
Logger.debug
public function debug( $object , $category , $message ) { return $this->message( self::getMessagePrefix( $object , $category , 'debug' ) . $message , self::LEVEL_DEBUG ); }
php
public function debug( $object , $category , $message ) { return $this->message( self::getMessagePrefix( $object , $category , 'debug' ) . $message , self::LEVEL_DEBUG ); }
[ "public", "function", "debug", "(", "$", "object", ",", "$", "category", ",", "$", "message", ")", "{", "return", "$", "this", "->", "message", "(", "self", "::", "getMessagePrefix", "(", "$", "object", ",", "$", "category", ",", "'debug'", ")", ".", ...
Debug message @param string $object @param string $category @param string $message @return bool
[ "Debug", "message" ]
train
https://github.com/potsky/microsoft-translator-php-sdk/blob/102f2411be5abb0e57a73c475f8e9e185a9f4859/src/MicrosoftTranslator/Logger.php#L119-L122
potsky/microsoft-translator-php-sdk
src/MicrosoftTranslator/Logger.php
Logger.error
public function error( $object , $category , $message ) { return $this->message( self::getMessagePrefix( $object , $category , 'error' ) . $message , self::LEVEL_ERROR ); }
php
public function error( $object , $category , $message ) { return $this->message( self::getMessagePrefix( $object , $category , 'error' ) . $message , self::LEVEL_ERROR ); }
[ "public", "function", "error", "(", "$", "object", ",", "$", "category", ",", "$", "message", ")", "{", "return", "$", "this", "->", "message", "(", "self", "::", "getMessagePrefix", "(", "$", "object", ",", "$", "category", ",", "'error'", ")", ".", ...
Error message @param string $object @param string $category @param string $message @return bool
[ "Error", "message" ]
train
https://github.com/potsky/microsoft-translator-php-sdk/blob/102f2411be5abb0e57a73c475f8e9e185a9f4859/src/MicrosoftTranslator/Logger.php#L133-L136
potsky/microsoft-translator-php-sdk
src/MicrosoftTranslator/Logger.php
Logger.fatal
public function fatal( $object , $category , $message ) { $this->message( self::getMessagePrefix( $object , $category , 'fatal' ) . $message , self::LEVEL_FATAL ); throw new Exception( $message ); }
php
public function fatal( $object , $category , $message ) { $this->message( self::getMessagePrefix( $object , $category , 'fatal' ) . $message , self::LEVEL_FATAL ); throw new Exception( $message ); }
[ "public", "function", "fatal", "(", "$", "object", ",", "$", "category", ",", "$", "message", ")", "{", "$", "this", "->", "message", "(", "self", "::", "getMessagePrefix", "(", "$", "object", ",", "$", "category", ",", "'fatal'", ")", ".", "$", "mes...
fatal message and throw an MicrosoftTranslator\Exception @param string $object @param string $category @param string $message @throws \MicrosoftTranslator\Exception
[ "fatal", "message", "and", "throw", "an", "MicrosoftTranslator", "\\", "Exception" ]
train
https://github.com/potsky/microsoft-translator-php-sdk/blob/102f2411be5abb0e57a73c475f8e9e185a9f4859/src/MicrosoftTranslator/Logger.php#L147-L152
potsky/microsoft-translator-php-sdk
src/MicrosoftTranslator/Logger.php
Logger.message
private function message( $message , $message_level ) { if ( $message_level <= (int)$this->log_level ) { if ( empty( $this->log_file_path ) ) { error_log( $message ); } else { if ( @file_put_contents( $this->log_file_path , $message . "\n" , FILE_APPEND ) === false ) { $message = sprintf( "Unable to write to log file %s" , $this->log_file_path ); error_log( self::getMessagePrefix( __CLASS__ , 'message' , 'fatal' ) . $message ); throw new Exception( $message ); } } return true; } return false; }
php
private function message( $message , $message_level ) { if ( $message_level <= (int)$this->log_level ) { if ( empty( $this->log_file_path ) ) { error_log( $message ); } else { if ( @file_put_contents( $this->log_file_path , $message . "\n" , FILE_APPEND ) === false ) { $message = sprintf( "Unable to write to log file %s" , $this->log_file_path ); error_log( self::getMessagePrefix( __CLASS__ , 'message' , 'fatal' ) . $message ); throw new Exception( $message ); } } return true; } return false; }
[ "private", "function", "message", "(", "$", "message", ",", "$", "message_level", ")", "{", "if", "(", "$", "message_level", "<=", "(", "int", ")", "$", "this", "->", "log_level", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "log_file_path", ...
Log a message using error_log if log level is compliant @param string $message @param integer $message_level @return bool true if message has been logged @throws \MicrosoftTranslator\Exception
[ "Log", "a", "message", "using", "error_log", "if", "log", "level", "is", "compliant" ]
train
https://github.com/potsky/microsoft-translator-php-sdk/blob/102f2411be5abb0e57a73c475f8e9e185a9f4859/src/MicrosoftTranslator/Logger.php#L163-L187
makinacorpus/drupal-ucms
ucms_seo/src/Controller/StoreLocatorController.php
StoreLocatorController.renderPageAction
public function renderPageAction(NodeInterface $node, $type, $sub_area = null, $locality = null) { /** @var SiteManager $siteManager */ $siteManager = $this->get('ucms_site.manager'); if ($siteManager->hasContext()) { /** @var ContextManager $layoutContext */ $layoutContext = $this->get('ucms_layout.context_manager'); $layoutContext->getPageContext() ->setCurrentLayoutNodeId($node->id(), $siteManager->getContext()->getId()) ; } return node_view($node); }
php
public function renderPageAction(NodeInterface $node, $type, $sub_area = null, $locality = null) { /** @var SiteManager $siteManager */ $siteManager = $this->get('ucms_site.manager'); if ($siteManager->hasContext()) { /** @var ContextManager $layoutContext */ $layoutContext = $this->get('ucms_layout.context_manager'); $layoutContext->getPageContext() ->setCurrentLayoutNodeId($node->id(), $siteManager->getContext()->getId()) ; } return node_view($node); }
[ "public", "function", "renderPageAction", "(", "NodeInterface", "$", "node", ",", "$", "type", ",", "$", "sub_area", "=", "null", ",", "$", "locality", "=", "null", ")", "{", "/** @var SiteManager $siteManager */", "$", "siteManager", "=", "$", "this", "->", ...
This renders the route node/%/sotre-locator
[ "This", "renders", "the", "route", "node", "/", "%", "/", "sotre", "-", "locator" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/Controller/StoreLocatorController.php#L19-L32
makinacorpus/drupal-ucms
ucms_seo/src/Controller/StoreLocatorController.php
StoreLocatorController.renderFieldAction
public function renderFieldAction(NodeInterface $node, $type, $sub_area = null, $locality = null) { $type = $type === 'all' ? null : $type; $sub_area = $sub_area === 'all' ? null : $sub_area; /** @var StoreLocatorInterface $storeLocator */ $storeLocator = $this ->get('ucms_seo.store_locator_factory') ->create($node, $type, $sub_area, $locality); $build = []; if (node_is_page($node)) { $title = $storeLocator->getTitle(); // @todo this is global state, therefore wrong drupal_set_title($node->title.' '.$title); // @todo this should be #attached drupal_add_js([ 'storeLocator' => ['items' => $storeLocator->getMapItems()], ], 'setting'); $build['map'] = [ '#theme' => 'ucms_seo_store_locator_map', '#items' => $storeLocator->getMapItems(), '#nodes' => $storeLocator->getNodes(), '#type' => $storeLocator->getTypeLabel($type), '#sub_area' => $storeLocator->getSubAreaLabel(), '#locality' => $storeLocator->getLocalityLabel(), ]; } $build['store_links'] = [ '#theme' => 'links__ucms_seo__store_locator', '#links' => $storeLocator->getLinks(), ]; return $build; }
php
public function renderFieldAction(NodeInterface $node, $type, $sub_area = null, $locality = null) { $type = $type === 'all' ? null : $type; $sub_area = $sub_area === 'all' ? null : $sub_area; /** @var StoreLocatorInterface $storeLocator */ $storeLocator = $this ->get('ucms_seo.store_locator_factory') ->create($node, $type, $sub_area, $locality); $build = []; if (node_is_page($node)) { $title = $storeLocator->getTitle(); // @todo this is global state, therefore wrong drupal_set_title($node->title.' '.$title); // @todo this should be #attached drupal_add_js([ 'storeLocator' => ['items' => $storeLocator->getMapItems()], ], 'setting'); $build['map'] = [ '#theme' => 'ucms_seo_store_locator_map', '#items' => $storeLocator->getMapItems(), '#nodes' => $storeLocator->getNodes(), '#type' => $storeLocator->getTypeLabel($type), '#sub_area' => $storeLocator->getSubAreaLabel(), '#locality' => $storeLocator->getLocalityLabel(), ]; } $build['store_links'] = [ '#theme' => 'links__ucms_seo__store_locator', '#links' => $storeLocator->getLinks(), ]; return $build; }
[ "public", "function", "renderFieldAction", "(", "NodeInterface", "$", "node", ",", "$", "type", ",", "$", "sub_area", "=", "null", ",", "$", "locality", "=", "null", ")", "{", "$", "type", "=", "$", "type", "===", "'all'", "?", "null", ":", "$", "typ...
This renders the field when viewing a store_locator bundle
[ "This", "renders", "the", "field", "when", "viewing", "a", "store_locator", "bundle" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/Controller/StoreLocatorController.php#L37-L75
aimeos/ai-admin-extadm
controller/extjs/src/Controller/ExtJS/JsonRpc.php
JsonRpc.getJsonItemSchemas
public function getJsonItemSchemas() { $list = []; foreach( $this->getControllers() as $name => $controller ) { $list[$name] = $controller->getItemSchema(); } if( ( $json = json_encode( $list ) ) === null ) { throw new \RuntimeException( 'Unable to encode schemas to JSON' ); } return $json; }
php
public function getJsonItemSchemas() { $list = []; foreach( $this->getControllers() as $name => $controller ) { $list[$name] = $controller->getItemSchema(); } if( ( $json = json_encode( $list ) ) === null ) { throw new \RuntimeException( 'Unable to encode schemas to JSON' ); } return $json; }
[ "public", "function", "getJsonItemSchemas", "(", ")", "{", "$", "list", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getControllers", "(", ")", "as", "$", "name", "=>", "$", "controller", ")", "{", "$", "list", "[", "$", "name", "]", "="...
Creates a JSON encoded list of item and search schemas. @return string JSON encoded list of item and search schemas
[ "Creates", "a", "JSON", "encoded", "list", "of", "item", "and", "search", "schemas", "." ]
train
https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/JsonRpc.php#L48-L61
aimeos/ai-admin-extadm
controller/extjs/src/Controller/ExtJS/JsonRpc.php
JsonRpc.getJsonSearchSchemas
public function getJsonSearchSchemas() { $list = []; foreach( $this->getControllers() as $name => $controller ) { $list[$name] = $controller->getSearchSchema(); } if( ( $json = json_encode( $list ) ) === null ) { throw new \RuntimeException( 'Unable to encode schemas to JSON' ); } return $json; }
php
public function getJsonSearchSchemas() { $list = []; foreach( $this->getControllers() as $name => $controller ) { $list[$name] = $controller->getSearchSchema(); } if( ( $json = json_encode( $list ) ) === null ) { throw new \RuntimeException( 'Unable to encode schemas to JSON' ); } return $json; }
[ "public", "function", "getJsonSearchSchemas", "(", ")", "{", "$", "list", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getControllers", "(", ")", "as", "$", "name", "=>", "$", "controller", ")", "{", "$", "list", "[", "$", "name", "]", "...
Creates a JSON encoded list of item and search schemas. @return string JSON encoded list of item and search schemas
[ "Creates", "a", "JSON", "encoded", "list", "of", "item", "and", "search", "schemas", "." ]
train
https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/JsonRpc.php#L69-L82
aimeos/ai-admin-extadm
controller/extjs/src/Controller/ExtJS/JsonRpc.php
JsonRpc.getJsonSmd
public function getJsonSmd( $clientUrl ) { $services = []; $transport = array( 'envelope' => 'JSON-RPC-2.0', 'transport' => 'POST' ); foreach( $this->getControllers() as $controller ) { foreach( $controller->getServiceDescription() as $method => $entry ) { $services[$method] = $entry + $transport; } } $smd = array( 'transport' => 'POST', 'envelope' => 'JSON-RPC-2.0', 'contentType' => 'application/json', 'SMDVersion' => '2.0', 'target' => $clientUrl, 'services' => $services, ); if( ( $json = json_encode( $smd ) ) === null ) { throw new \RuntimeException( 'Unable to encode service mapping description to JSON' ); } return $json; }
php
public function getJsonSmd( $clientUrl ) { $services = []; $transport = array( 'envelope' => 'JSON-RPC-2.0', 'transport' => 'POST' ); foreach( $this->getControllers() as $controller ) { foreach( $controller->getServiceDescription() as $method => $entry ) { $services[$method] = $entry + $transport; } } $smd = array( 'transport' => 'POST', 'envelope' => 'JSON-RPC-2.0', 'contentType' => 'application/json', 'SMDVersion' => '2.0', 'target' => $clientUrl, 'services' => $services, ); if( ( $json = json_encode( $smd ) ) === null ) { throw new \RuntimeException( 'Unable to encode service mapping description to JSON' ); } return $json; }
[ "public", "function", "getJsonSmd", "(", "$", "clientUrl", ")", "{", "$", "services", "=", "[", "]", ";", "$", "transport", "=", "array", "(", "'envelope'", "=>", "'JSON-RPC-2.0'", ",", "'transport'", "=>", "'POST'", ")", ";", "foreach", "(", "$", "this"...
Creates a JSON encoded service map description. @param string $clientUrl URL of the dispatcher action @return string JSON encoded service map description
[ "Creates", "a", "JSON", "encoded", "service", "map", "description", "." ]
train
https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/JsonRpc.php#L91-L117
aimeos/ai-admin-extadm
controller/extjs/src/Controller/ExtJS/JsonRpc.php
JsonRpc.process
public function process( array $reqparams, $content ) { if( isset( $reqparams['jsonrpc'] ) || !isset( $reqparams['method'] ) ) { return $this->processStream( $content ); } return $this->processRequest( $reqparams ); }
php
public function process( array $reqparams, $content ) { if( isset( $reqparams['jsonrpc'] ) || !isset( $reqparams['method'] ) ) { return $this->processStream( $content ); } return $this->processRequest( $reqparams ); }
[ "public", "function", "process", "(", "array", "$", "reqparams", ",", "$", "content", ")", "{", "if", "(", "isset", "(", "$", "reqparams", "[", "'jsonrpc'", "]", ")", "||", "!", "isset", "(", "$", "reqparams", "[", "'method'", "]", ")", ")", "{", "...
Single entry point for all ExtJS requests. @param array $reqparams Associative list of request parameters (usually $_REQUEST) @param string $content Content sent with the HTTP request @return string|null JSON RPC 2.0 message response
[ "Single", "entry", "point", "for", "all", "ExtJS", "requests", "." ]
train
https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/JsonRpc.php#L127-L134