repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
camspiers/silverstripe-loggerbridge
src/Camspiers/LoggerBridge/LoggerBridge.php
LoggerBridge.errorHandler
public function errorHandler($errno, $errstr, $errfile, $errline) { // Honour error suppression through @ if (($errorReporting = error_reporting()) === 0) { return true; } $logType = null; foreach ($this->errorLogGroups as $candidateLogType => $errorTypes) { if (in_array($errno, $errorTypes)) { $logType = $candidateLogType; break; } } if (is_null($logType)) { throw new \Exception(sprintf( "No log type found for errno '%s'", $errno )); } $exception = $this->createException($errstr, $errno, $errfile, $errline); // Log all errors regardless of type $context = array( 'file' => $errfile, 'line' => $errline ); if ($this->reportBacktrace) { $context['backtrace'] = $this->getBacktraceReporter()->getBacktrace(); } if ($this->exceptionInContext) { $context['exception'] = $exception; } $this->logger->$logType($errstr, $context); // Check the error_reporting level in comparison with the $errno (honouring the environment) // And check that $showErrors is on or the site is live if (($errno & $errorReporting) === $errno && ($this->showErrors || $this->getEnvReporter()->isLive())) { $this->getErrorReporter()->reportError($exception); } if (in_array($errno, $this->terminatingErrors)) { $this->terminate(); } // ignore the usually handling of this type of error return true; }
php
public function errorHandler($errno, $errstr, $errfile, $errline) { // Honour error suppression through @ if (($errorReporting = error_reporting()) === 0) { return true; } $logType = null; foreach ($this->errorLogGroups as $candidateLogType => $errorTypes) { if (in_array($errno, $errorTypes)) { $logType = $candidateLogType; break; } } if (is_null($logType)) { throw new \Exception(sprintf( "No log type found for errno '%s'", $errno )); } $exception = $this->createException($errstr, $errno, $errfile, $errline); // Log all errors regardless of type $context = array( 'file' => $errfile, 'line' => $errline ); if ($this->reportBacktrace) { $context['backtrace'] = $this->getBacktraceReporter()->getBacktrace(); } if ($this->exceptionInContext) { $context['exception'] = $exception; } $this->logger->$logType($errstr, $context); // Check the error_reporting level in comparison with the $errno (honouring the environment) // And check that $showErrors is on or the site is live if (($errno & $errorReporting) === $errno && ($this->showErrors || $this->getEnvReporter()->isLive())) { $this->getErrorReporter()->reportError($exception); } if (in_array($errno, $this->terminatingErrors)) { $this->terminate(); } // ignore the usually handling of this type of error return true; }
[ "public", "function", "errorHandler", "(", "$", "errno", ",", "$", "errstr", ",", "$", "errfile", ",", "$", "errline", ")", "{", "// Honour error suppression through @", "if", "(", "(", "$", "errorReporting", "=", "error_reporting", "(", ")", ")", "===", "0"...
Handles general errors, user, warn and notice @param $errno @param $errstr @param $errfile @param $errline @return bool|string|void
[ "Handles", "general", "errors", "user", "warn", "and", "notice" ]
16891556ff2e9eb7c2f94e42106044fb28bde33d
https://github.com/camspiers/silverstripe-loggerbridge/blob/16891556ff2e9eb7c2f94e42106044fb28bde33d/src/Camspiers/LoggerBridge/LoggerBridge.php#L416-L470
train
camspiers/silverstripe-loggerbridge
src/Camspiers/LoggerBridge/LoggerBridge.php
LoggerBridge.fatalHandler
public function fatalHandler() { $error = $this->getLastError(); if ($this->isRegistered() && $this->isFatalError($error)) { if (defined('FRAMEWORK_PATH')) { chdir(FRAMEWORK_PATH); } if ($this->isMemoryExhaustedError($error)) { // We can safely change the memory limit be the reserve amount because if suhosin is relevant // the memory will have been decreased prior to exhaustion $this->changeMemoryLimit($this->reserveMemory); } $exception = $this->createException( $error['message'], $error['type'], $error['file'], $error['line'] ); $context = array( 'file' => $error['file'], 'line' => $error['line'] ); if ($this->reportBacktrace) { $context['backtrace'] = $this->getBacktraceReporter()->getBacktrace(); } if ($this->exceptionInContext) { $context['exception'] = $exception; } $this->logger->critical($error['message'], $context); // Fatal errors should be reported when live as they stop the display of regular output if ($this->showErrors || $this->getEnvReporter()->isLive()) { $this->getErrorReporter()->reportError($exception); } } }
php
public function fatalHandler() { $error = $this->getLastError(); if ($this->isRegistered() && $this->isFatalError($error)) { if (defined('FRAMEWORK_PATH')) { chdir(FRAMEWORK_PATH); } if ($this->isMemoryExhaustedError($error)) { // We can safely change the memory limit be the reserve amount because if suhosin is relevant // the memory will have been decreased prior to exhaustion $this->changeMemoryLimit($this->reserveMemory); } $exception = $this->createException( $error['message'], $error['type'], $error['file'], $error['line'] ); $context = array( 'file' => $error['file'], 'line' => $error['line'] ); if ($this->reportBacktrace) { $context['backtrace'] = $this->getBacktraceReporter()->getBacktrace(); } if ($this->exceptionInContext) { $context['exception'] = $exception; } $this->logger->critical($error['message'], $context); // Fatal errors should be reported when live as they stop the display of regular output if ($this->showErrors || $this->getEnvReporter()->isLive()) { $this->getErrorReporter()->reportError($exception); } } }
[ "public", "function", "fatalHandler", "(", ")", "{", "$", "error", "=", "$", "this", "->", "getLastError", "(", ")", ";", "if", "(", "$", "this", "->", "isRegistered", "(", ")", "&&", "$", "this", "->", "isFatalError", "(", "$", "error", ")", ")", ...
Handles fatal errors If we are registered, and there is a fatal error then log and try to gracefully handle error output In cases where memory is exhausted increase the memory_limit to allow for logging
[ "Handles", "fatal", "errors", "If", "we", "are", "registered", "and", "there", "is", "a", "fatal", "error", "then", "log", "and", "try", "to", "gracefully", "handle", "error", "output", "In", "cases", "where", "memory", "is", "exhausted", "increase", "the", ...
16891556ff2e9eb7c2f94e42106044fb28bde33d
https://github.com/camspiers/silverstripe-loggerbridge/blob/16891556ff2e9eb7c2f94e42106044fb28bde33d/src/Camspiers/LoggerBridge/LoggerBridge.php#L508-L550
train
camspiers/silverstripe-loggerbridge
src/Camspiers/LoggerBridge/LoggerBridge.php
LoggerBridge.isMemoryExhaustedError
protected function isMemoryExhaustedError($error) { return isset($error['message']) && stripos($error['message'], 'memory') !== false && stripos($error['message'], 'exhausted') !== false; }
php
protected function isMemoryExhaustedError($error) { return isset($error['message']) && stripos($error['message'], 'memory') !== false && stripos($error['message'], 'exhausted') !== false; }
[ "protected", "function", "isMemoryExhaustedError", "(", "$", "error", ")", "{", "return", "isset", "(", "$", "error", "[", "'message'", "]", ")", "&&", "stripos", "(", "$", "error", "[", "'message'", "]", ",", "'memory'", ")", "!==", "false", "&&", "stri...
Returns whether or not the passed in error is a memory exhausted error @param $error array @return bool
[ "Returns", "whether", "or", "not", "the", "passed", "in", "error", "is", "a", "memory", "exhausted", "error" ]
16891556ff2e9eb7c2f94e42106044fb28bde33d
https://github.com/camspiers/silverstripe-loggerbridge/blob/16891556ff2e9eb7c2f94e42106044fb28bde33d/src/Camspiers/LoggerBridge/LoggerBridge.php#L611-L617
train
camspiers/silverstripe-loggerbridge
src/Camspiers/LoggerBridge/LoggerBridge.php
LoggerBridge.translateMemoryLimit
protected function translateMemoryLimit($memoryLimit) { $unit = strtolower(substr($memoryLimit, -1, 1)); $memoryLimit = (int) $memoryLimit; switch ($unit) { case 'g': $memoryLimit *= 1024; // intentional case 'm': $memoryLimit *= 1024; // intentional case 'k': $memoryLimit *= 1024; // intentional } return $memoryLimit; }
php
protected function translateMemoryLimit($memoryLimit) { $unit = strtolower(substr($memoryLimit, -1, 1)); $memoryLimit = (int) $memoryLimit; switch ($unit) { case 'g': $memoryLimit *= 1024; // intentional case 'm': $memoryLimit *= 1024; // intentional case 'k': $memoryLimit *= 1024; // intentional } return $memoryLimit; }
[ "protected", "function", "translateMemoryLimit", "(", "$", "memoryLimit", ")", "{", "$", "unit", "=", "strtolower", "(", "substr", "(", "$", "memoryLimit", ",", "-", "1", ",", "1", ")", ")", ";", "$", "memoryLimit", "=", "(", "int", ")", "$", "memoryLi...
Translate the memory limit string to a int in bytes. @param $memoryLimit @return int
[ "Translate", "the", "memory", "limit", "string", "to", "a", "int", "in", "bytes", "." ]
16891556ff2e9eb7c2f94e42106044fb28bde33d
https://github.com/camspiers/silverstripe-loggerbridge/blob/16891556ff2e9eb7c2f94e42106044fb28bde33d/src/Camspiers/LoggerBridge/LoggerBridge.php#L636-L653
train
shopgate/cart-integration-magento2-base
src/Helper/Product/Type/Configurable.php
Configurable.getItemId
public function getItemId() { if ($this->getProductCustomOption()) { return $this->getItem()->getData('product_id') . '-' . $this->getProductCustomOption()->getProduct()->getId(); } return parent::getItemId(); }
php
public function getItemId() { if ($this->getProductCustomOption()) { return $this->getItem()->getData('product_id') . '-' . $this->getProductCustomOption()->getProduct()->getId(); } return parent::getItemId(); }
[ "public", "function", "getItemId", "(", ")", "{", "if", "(", "$", "this", "->", "getProductCustomOption", "(", ")", ")", "{", "return", "$", "this", "->", "getItem", "(", ")", "->", "getData", "(", "'product_id'", ")", ".", "'-'", ".", "$", "this", "...
Retrieve parent-child pairing @inheritdoc
[ "Retrieve", "parent", "-", "child", "pairing" ]
e7f8dec935aa9b23cd5b434484bc45033e62d270
https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Helper/Product/Type/Configurable.php#L107-L115
train
shopgate/cart-integration-magento2-base
src/Model/Config.php
Config.startup
public function startup() { /** @var \Shopgate\Base\Helper\Initializer\Config $initializer */ $manager = ObjectManager::getInstance(); $initializer = $manager->get('Shopgate\Base\Helper\Initializer\Config'); $this->storeManager = $initializer->getStoreManager(); $this->logger = $initializer->getLogger(); $this->directory = $initializer->getDirectory(); $this->sgCoreConfig = $initializer->getSgCoreConfig(); $this->coreConfig = $initializer->getCoreConfig(); $this->cache = $initializer->getCache(); $this->configResource = $initializer->getConfigResource(); $this->configMapping = $initializer->getConfigMapping(); $this->configMethods = $initializer->getConfigMethods(); $this->registry = $initializer->getRegistry(); $this->configHelper = $initializer->getHelper(); $this->plugin_name = 'magento2'; $this->configMapping += $this->configHelper->loadUndefinedConfigPaths(); $this->loadArray($this->configMethods); return true; }
php
public function startup() { /** @var \Shopgate\Base\Helper\Initializer\Config $initializer */ $manager = ObjectManager::getInstance(); $initializer = $manager->get('Shopgate\Base\Helper\Initializer\Config'); $this->storeManager = $initializer->getStoreManager(); $this->logger = $initializer->getLogger(); $this->directory = $initializer->getDirectory(); $this->sgCoreConfig = $initializer->getSgCoreConfig(); $this->coreConfig = $initializer->getCoreConfig(); $this->cache = $initializer->getCache(); $this->configResource = $initializer->getConfigResource(); $this->configMapping = $initializer->getConfigMapping(); $this->configMethods = $initializer->getConfigMethods(); $this->registry = $initializer->getRegistry(); $this->configHelper = $initializer->getHelper(); $this->plugin_name = 'magento2'; $this->configMapping += $this->configHelper->loadUndefinedConfigPaths(); $this->loadArray($this->configMethods); return true; }
[ "public", "function", "startup", "(", ")", "{", "/** @var \\Shopgate\\Base\\Helper\\Initializer\\Config $initializer */", "$", "manager", "=", "ObjectManager", "::", "getInstance", "(", ")", ";", "$", "initializer", "=", "$", "manager", "->", "get", "(", "'Shopgate\\B...
Assists with initializing @return bool
[ "Assists", "with", "initializing" ]
e7f8dec935aa9b23cd5b434484bc45033e62d270
https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Config.php#L77-L98
train
shopgate/cart-integration-magento2-base
src/Model/Config.php
Config.load
public function load(array $settings = null) { $classVars = array_keys(get_class_vars(get_class($this))); foreach ($settings as $name => $value) { if (in_array($name, $this->blacklistConfig, true)) { continue; } if (in_array($name, $classVars, true)) { $method = 'set' . SimpleDataObjectConverter::snakeCaseToUpperCamelCase($name); if (method_exists($this, $method)) { $this->configMapping += $this->configHelper->getNewSettingPath($name); $this->{$method}($this->castToType($value, $name)); } else { $this->logger->debug( 'The evaluated method "' . $method . '" is not available in class ' . __CLASS__ ); } } else { if (array_key_exists($name, $this->additionalSettings)) { $this->additionalSettings[$name] = $value; } else { $this->logger->debug( 'The given setting property "' . $name . '" is not available in class ' . __CLASS__ ); } } } }
php
public function load(array $settings = null) { $classVars = array_keys(get_class_vars(get_class($this))); foreach ($settings as $name => $value) { if (in_array($name, $this->blacklistConfig, true)) { continue; } if (in_array($name, $classVars, true)) { $method = 'set' . SimpleDataObjectConverter::snakeCaseToUpperCamelCase($name); if (method_exists($this, $method)) { $this->configMapping += $this->configHelper->getNewSettingPath($name); $this->{$method}($this->castToType($value, $name)); } else { $this->logger->debug( 'The evaluated method "' . $method . '" is not available in class ' . __CLASS__ ); } } else { if (array_key_exists($name, $this->additionalSettings)) { $this->additionalSettings[$name] = $value; } else { $this->logger->debug( 'The given setting property "' . $name . '" is not available in class ' . __CLASS__ ); } } } }
[ "public", "function", "load", "(", "array", "$", "settings", "=", "null", ")", "{", "$", "classVars", "=", "array_keys", "(", "get_class_vars", "(", "get_class", "(", "$", "this", ")", ")", ")", ";", "foreach", "(", "$", "settings", "as", "$", "name", ...
Prepares values to be saved. Note that we use the += operator intentionally @param array|null $settings @throws \ReflectionException
[ "Prepares", "values", "to", "be", "saved", ".", "Note", "that", "we", "use", "the", "+", "=", "operator", "intentionally" ]
e7f8dec935aa9b23cd5b434484bc45033e62d270
https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Config.php#L108-L137
train
shopgate/cart-integration-magento2-base
src/Model/Config.php
Config.castToType
protected function castToType($value, $property) { $type = $this->getPropertyType($property); switch ($type) { case 'array': return is_array($value) ? $value : explode(",", $value); case 'bool': case 'boolean': return (boolean) $value; case 'int': case 'integer': return (int) $value; case 'string': return (string) $value; default: return $value; } }
php
protected function castToType($value, $property) { $type = $this->getPropertyType($property); switch ($type) { case 'array': return is_array($value) ? $value : explode(",", $value); case 'bool': case 'boolean': return (boolean) $value; case 'int': case 'integer': return (int) $value; case 'string': return (string) $value; default: return $value; } }
[ "protected", "function", "castToType", "(", "$", "value", ",", "$", "property", ")", "{", "$", "type", "=", "$", "this", "->", "getPropertyType", "(", "$", "property", ")", ";", "switch", "(", "$", "type", ")", "{", "case", "'array'", ":", "return", ...
Cast a given property value to the matching property type @param mixed $value @param string $property @return boolean|number|string|integer @throws \ReflectionException
[ "Cast", "a", "given", "property", "value", "to", "the", "matching", "property", "type" ]
e7f8dec935aa9b23cd5b434484bc45033e62d270
https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Config.php#L148-L166
train
shopgate/cart-integration-magento2-base
src/Model/Config.php
Config.getPropertyType
protected function getPropertyType($property) { if (!array_key_exists($property, get_class_vars('ShopgateConfig'))) { return 'string'; } $r = new \ReflectionProperty('ShopgateConfig', $property); $doc = $r->getDocComment(); preg_match_all('#@var ([a-zA-Z-_]*(\[\])?)(.*?)\n#s', $doc, $annotations); $value = 'string'; if (count($annotations) > 0 && isset($annotations[1][0])) { $value = $annotations[1][0]; } return $value; }
php
protected function getPropertyType($property) { if (!array_key_exists($property, get_class_vars('ShopgateConfig'))) { return 'string'; } $r = new \ReflectionProperty('ShopgateConfig', $property); $doc = $r->getDocComment(); preg_match_all('#@var ([a-zA-Z-_]*(\[\])?)(.*?)\n#s', $doc, $annotations); $value = 'string'; if (count($annotations) > 0 && isset($annotations[1][0])) { $value = $annotations[1][0]; } return $value; }
[ "protected", "function", "getPropertyType", "(", "$", "property", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "property", ",", "get_class_vars", "(", "'ShopgateConfig'", ")", ")", ")", "{", "return", "'string'", ";", "}", "$", "r", "=", "new", ...
Fetches the property type described in phpdoc annotation @param string $property @return string @throws \ReflectionException
[ "Fetches", "the", "property", "type", "described", "in", "phpdoc", "annotation" ]
e7f8dec935aa9b23cd5b434484bc45033e62d270
https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Config.php#L176-L192
train
shopgate/cart-integration-magento2-base
src/Model/Config.php
Config.loadConfig
public function loadConfig() { if (!$this->registry->isRedirect()) { $storeId = $this->sgCoreConfig->getStoreId($this->getShopNumber()); $this->storeManager->setCurrentStore($storeId); } $this->loadArray($this->toArray()); $this->setExportTmpAndLogSettings(); }
php
public function loadConfig() { if (!$this->registry->isRedirect()) { $storeId = $this->sgCoreConfig->getStoreId($this->getShopNumber()); $this->storeManager->setCurrentStore($storeId); } $this->loadArray($this->toArray()); $this->setExportTmpAndLogSettings(); }
[ "public", "function", "loadConfig", "(", ")", "{", "if", "(", "!", "$", "this", "->", "registry", "->", "isRedirect", "(", ")", ")", "{", "$", "storeId", "=", "$", "this", "->", "sgCoreConfig", "->", "getStoreId", "(", "$", "this", "->", "getShopNumber...
Load general information and values. Use shop number to determine store only when it is not a frontend call @throws \Magento\Framework\Exception\FileSystemException @throws \ReflectionException
[ "Load", "general", "information", "and", "values", ".", "Use", "shop", "number", "to", "determine", "store", "only", "when", "it", "is", "not", "a", "frontend", "call" ]
e7f8dec935aa9b23cd5b434484bc45033e62d270
https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Config.php#L201-L209
train
shopgate/cart-integration-magento2-base
src/Model/Config.php
Config.getShopNumber
public function getShopNumber() { if ($this->shop_number === null) { $this->shop_number = $this->configHelper->getShopNumber(); } return $this->shop_number; }
php
public function getShopNumber() { if ($this->shop_number === null) { $this->shop_number = $this->configHelper->getShopNumber(); } return $this->shop_number; }
[ "public", "function", "getShopNumber", "(", ")", "{", "if", "(", "$", "this", "->", "shop_number", "===", "null", ")", "{", "$", "this", "->", "shop_number", "=", "$", "this", "->", "configHelper", "->", "getShopNumber", "(", ")", ";", "}", "return", "...
Retrieve the shop number of the current request
[ "Retrieve", "the", "shop", "number", "of", "the", "current", "request" ]
e7f8dec935aa9b23cd5b434484bc45033e62d270
https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Config.php#L214-L221
train
shopgate/cart-integration-magento2-base
src/Model/Config.php
Config.setExportTmpAndLogSettings
protected function setExportTmpAndLogSettings() { $this->setExportFolderPath( $this->directory->getPath(DirectoryList::TMP) . DS . 'shopgate' . DS . $this->getShopNumber() ); $this->createFolderIfNotExist($this->getExportFolderPath()); $this->setLogFolderPath( $this->directory->getPath(DirectoryList::LOG) . DS . 'shopgate' . DS . $this->getShopNumber() ); $this->createFolderIfNotExist($this->getLogFolderPath()); $this->setCacheFolderPath( $this->directory->getPath(DirectoryList::TMP) . DS . 'shopgate' . DS . $this->getShopNumber() ); $this->createFolderIfNotExist($this->getCacheFolderPath()); }
php
protected function setExportTmpAndLogSettings() { $this->setExportFolderPath( $this->directory->getPath(DirectoryList::TMP) . DS . 'shopgate' . DS . $this->getShopNumber() ); $this->createFolderIfNotExist($this->getExportFolderPath()); $this->setLogFolderPath( $this->directory->getPath(DirectoryList::LOG) . DS . 'shopgate' . DS . $this->getShopNumber() ); $this->createFolderIfNotExist($this->getLogFolderPath()); $this->setCacheFolderPath( $this->directory->getPath(DirectoryList::TMP) . DS . 'shopgate' . DS . $this->getShopNumber() ); $this->createFolderIfNotExist($this->getCacheFolderPath()); }
[ "protected", "function", "setExportTmpAndLogSettings", "(", ")", "{", "$", "this", "->", "setExportFolderPath", "(", "$", "this", "->", "directory", "->", "getPath", "(", "DirectoryList", "::", "TMP", ")", ".", "DS", ".", "'shopgate'", ".", "DS", ".", "$", ...
Setup export, log and tmp folder and check if need to create them @throws \Magento\Framework\Exception\FileSystemException
[ "Setup", "export", "log", "and", "tmp", "folder", "and", "check", "if", "need", "to", "create", "them" ]
e7f8dec935aa9b23cd5b434484bc45033e62d270
https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Config.php#L228-L244
train
shopgate/cart-integration-magento2-base
src/Model/Config.php
Config.methodLoader
private function methodLoader(array $classProperties) { $result = []; foreach ($classProperties as $propertyName => $nullVal) { $result[$propertyName] = $this->getPropertyValue($propertyName); } return $result; }
php
private function methodLoader(array $classProperties) { $result = []; foreach ($classProperties as $propertyName => $nullVal) { $result[$propertyName] = $this->getPropertyValue($propertyName); } return $result; }
[ "private", "function", "methodLoader", "(", "array", "$", "classProperties", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "classProperties", "as", "$", "propertyName", "=>", "$", "nullVal", ")", "{", "$", "result", "[", "$", "propert...
Uses the keys of the array as camelCase methods, calls them and retrieves the data @param array $classProperties - where array('hello' => '') calls $this->getHello() @return array - where we get $return['hello'] = $this->getHello()
[ "Uses", "the", "keys", "of", "the", "array", "as", "camelCase", "methods", "calls", "them", "and", "retrieves", "the", "data" ]
e7f8dec935aa9b23cd5b434484bc45033e62d270
https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Config.php#L290-L298
train
shopgate/cart-integration-magento2-base
src/Model/Config.php
Config.getPropertyValue
private function getPropertyValue($property) { $value = null; $getter = 'get' . SimpleDataObjectConverter::snakeCaseToUpperCamelCase($property); if (method_exists($this, $getter)) { $value = $this->{$getter}(); } elseif ($this->returnAdditionalSetting($property)) { $value = $this->returnAdditionalSetting($property); } return $value; }
php
private function getPropertyValue($property) { $value = null; $getter = 'get' . SimpleDataObjectConverter::snakeCaseToUpperCamelCase($property); if (method_exists($this, $getter)) { $value = $this->{$getter}(); } elseif ($this->returnAdditionalSetting($property)) { $value = $this->returnAdditionalSetting($property); } return $value; }
[ "private", "function", "getPropertyValue", "(", "$", "property", ")", "{", "$", "value", "=", "null", ";", "$", "getter", "=", "'get'", ".", "SimpleDataObjectConverter", "::", "snakeCaseToUpperCamelCase", "(", "$", "property", ")", ";", "if", "(", "method_exis...
Calls the properties getter method to retrieve the value @param $property @return null
[ "Calls", "the", "properties", "getter", "method", "to", "retrieve", "the", "value" ]
e7f8dec935aa9b23cd5b434484bc45033e62d270
https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Config.php#L309-L321
train
shopgate/cart-integration-magento2-base
src/Model/Config.php
Config.getCoreConfigMap
private function getCoreConfigMap(array $map) { $result = []; foreach ($map as $key => $path) { $value = $this->coreConfig->getConfigByPath($path)->getData('value'); if ($value !== null) { $result[$key] = $this->castToType($value, $key); } } return $result; }
php
private function getCoreConfigMap(array $map) { $result = []; foreach ($map as $key => $path) { $value = $this->coreConfig->getConfigByPath($path)->getData('value'); if ($value !== null) { $result[$key] = $this->castToType($value, $key); } } return $result; }
[ "private", "function", "getCoreConfigMap", "(", "array", "$", "map", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "map", "as", "$", "key", "=>", "$", "path", ")", "{", "$", "value", "=", "$", "this", "->", "coreConfig", "->", ...
Traverses the config and retrieves data from magento core_config_data table @param array $map - where key is Library defined property name & value is core_config_data path @return array - $return['key'] = (cast type) value @throws \ReflectionException
[ "Traverses", "the", "config", "and", "retrieves", "data", "from", "magento", "core_config_data", "table" ]
e7f8dec935aa9b23cd5b434484bc45033e62d270
https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Config.php#L333-L345
train
shopgate/cart-integration-magento2-base
src/Model/Config.php
Config.save
public function save(array $fieldList, $validate = true) { $this->logger->debug('# setSettings save start'); if ($validate) { $this->validate($fieldList); } foreach ($fieldList as $property) { if (in_array($property, $this->blacklistConfig, true)) { continue; } if (isset($this->configMapping[$property])) { $config = $this->sgCoreConfig->getSaveScope($this->configMapping[$property], $this->getShopNumber()); $this->saveField( $this->configMapping[$property], $property, $config->getScope(), $config->getScopeId() ); } } $this->clearCache(); $this->logger->debug('# setSettings save end'); }
php
public function save(array $fieldList, $validate = true) { $this->logger->debug('# setSettings save start'); if ($validate) { $this->validate($fieldList); } foreach ($fieldList as $property) { if (in_array($property, $this->blacklistConfig, true)) { continue; } if (isset($this->configMapping[$property])) { $config = $this->sgCoreConfig->getSaveScope($this->configMapping[$property], $this->getShopNumber()); $this->saveField( $this->configMapping[$property], $property, $config->getScope(), $config->getScopeId() ); } } $this->clearCache(); $this->logger->debug('# setSettings save end'); }
[ "public", "function", "save", "(", "array", "$", "fieldList", ",", "$", "validate", "=", "true", ")", "{", "$", "this", "->", "logger", "->", "debug", "(", "'# setSettings save start'", ")", ";", "if", "(", "$", "validate", ")", "{", "$", "this", "->",...
Writes the given fields to magento @param array $fieldList @param boolean $validate @throws \Exception @throws \ShopgateLibraryException
[ "Writes", "the", "given", "fields", "to", "magento" ]
e7f8dec935aa9b23cd5b434484bc45033e62d270
https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Config.php#L356-L383
train
shopgate/cart-integration-magento2-base
src/Model/Config.php
Config.saveField
protected function saveField($path, $property, $scope, $scopeId, $value = null) { if ($value === null) { if (isset($this->configMapping[$property])) { $value = $this->getPropertyValue($property); } else { $this->logger->error('The specified property "' . $property . '" is not in the DI list'); } } if ($value !== null) { $this->logger->debug( ' Saving config field \'' . $property . '\' with value \'' . $value . '\' to scope {\'' . $scope . '\':\'' . $scopeId . '\'}' ); $value = $this->prepareForDatabase($property, $value); $this->configResource->saveConfig($path, $value, $scope, $scopeId); } }
php
protected function saveField($path, $property, $scope, $scopeId, $value = null) { if ($value === null) { if (isset($this->configMapping[$property])) { $value = $this->getPropertyValue($property); } else { $this->logger->error('The specified property "' . $property . '" is not in the DI list'); } } if ($value !== null) { $this->logger->debug( ' Saving config field \'' . $property . '\' with value \'' . $value . '\' to scope {\'' . $scope . '\':\'' . $scopeId . '\'}' ); $value = $this->prepareForDatabase($property, $value); $this->configResource->saveConfig($path, $value, $scope, $scopeId); } }
[ "protected", "function", "saveField", "(", "$", "path", ",", "$", "property", ",", "$", "scope", ",", "$", "scopeId", ",", "$", "value", "=", "null", ")", "{", "if", "(", "$", "value", "===", "null", ")", "{", "if", "(", "isset", "(", "$", "this"...
Saves this property to magento core_config_data @param string $path @param string $property @param string $scope @param int $scopeId @param mixed $value @throws \Exception
[ "Saves", "this", "property", "to", "magento", "core_config_data" ]
e7f8dec935aa9b23cd5b434484bc45033e62d270
https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Config.php#L396-L414
train
shopgate/cart-integration-magento2-base
src/Model/Config.php
Config.prepareForDatabase
protected function prepareForDatabase($property, $value) { $type = $this->getPropertyType($property); if ($type == 'array' && is_array($value)) { return implode(",", $value); } if (is_bool($value)) { $value = (int) $value; } return $value; }
php
protected function prepareForDatabase($property, $value) { $type = $this->getPropertyType($property); if ($type == 'array' && is_array($value)) { return implode(",", $value); } if (is_bool($value)) { $value = (int) $value; } return $value; }
[ "protected", "function", "prepareForDatabase", "(", "$", "property", ",", "$", "value", ")", "{", "$", "type", "=", "$", "this", "->", "getPropertyType", "(", "$", "property", ")", ";", "if", "(", "$", "type", "==", "'array'", "&&", "is_array", "(", "$...
Converts values into a core_config_data compatible format @param string $property @param mixed $value @return mixed
[ "Converts", "values", "into", "a", "core_config_data", "compatible", "format" ]
e7f8dec935aa9b23cd5b434484bc45033e62d270
https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Config.php#L424-L436
train
shopgate/cart-integration-magento2-base
src/Model/Config.php
Config.clearCache
protected function clearCache() { $result = $this->cache->clean([\Magento\Framework\App\Config::CACHE_TAG]); $this->logger->debug( ' Config cache cleared with result: ' . ($result ? '[OK]' : '[ERROR]') ); }
php
protected function clearCache() { $result = $this->cache->clean([\Magento\Framework\App\Config::CACHE_TAG]); $this->logger->debug( ' Config cache cleared with result: ' . ($result ? '[OK]' : '[ERROR]') ); }
[ "protected", "function", "clearCache", "(", ")", "{", "$", "result", "=", "$", "this", "->", "cache", "->", "clean", "(", "[", "\\", "Magento", "\\", "Framework", "\\", "App", "\\", "Config", "::", "CACHE_TAG", "]", ")", ";", "$", "this", "->", "logg...
Clears config cache after saving altered configuration
[ "Clears", "config", "cache", "after", "saving", "altered", "configuration" ]
e7f8dec935aa9b23cd5b434484bc45033e62d270
https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Config.php#L443-L449
train
shopgate/cart-integration-magento2-base
src/Model/ResourceModel/Shopgate/Order.php
Order.getByOrderNumber
public function getByOrderNumber($number) { $connection = $this->getConnection(); $select = $connection->select()->from($this->getMainTable())->where('shopgate_order_number = :number'); $bind = [':number' => (string) $number]; return $connection->fetchRow($select, $bind); }
php
public function getByOrderNumber($number) { $connection = $this->getConnection(); $select = $connection->select()->from($this->getMainTable())->where('shopgate_order_number = :number'); $bind = [':number' => (string) $number]; return $connection->fetchRow($select, $bind); }
[ "public", "function", "getByOrderNumber", "(", "$", "number", ")", "{", "$", "connection", "=", "$", "this", "->", "getConnection", "(", ")", ";", "$", "select", "=", "$", "connection", "->", "select", "(", ")", "->", "from", "(", "$", "this", "->", ...
Gets order data using shopgate order number @param string $number @return array @throws LocalizedException
[ "Gets", "order", "data", "using", "shopgate", "order", "number" ]
e7f8dec935aa9b23cd5b434484bc45033e62d270
https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/ResourceModel/Shopgate/Order.php#L48-L55
train
shopgate/cart-integration-magento2-base
src/Model/ResourceModel/Shopgate/Order.php
Order.getByOrderId
public function getByOrderId($id) { $connection = $this->getConnection(); $select = $connection->select()->from($this->getMainTable())->where('order_id = :internal_order_id'); $bind = [':internal_order_id' => (string) $id]; return $connection->fetchRow($select, $bind); }
php
public function getByOrderId($id) { $connection = $this->getConnection(); $select = $connection->select()->from($this->getMainTable())->where('order_id = :internal_order_id'); $bind = [':internal_order_id' => (string) $id]; return $connection->fetchRow($select, $bind); }
[ "public", "function", "getByOrderId", "(", "$", "id", ")", "{", "$", "connection", "=", "$", "this", "->", "getConnection", "(", ")", ";", "$", "select", "=", "$", "connection", "->", "select", "(", ")", "->", "from", "(", "$", "this", "->", "getMain...
Gets order data using magento increment id @param string $id @return array @throws LocalizedException
[ "Gets", "order", "data", "using", "magento", "increment", "id" ]
e7f8dec935aa9b23cd5b434484bc45033e62d270
https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/ResourceModel/Shopgate/Order.php#L65-L72
train
webeweb/core-library
src/ThirdParty/SkiData/Parser/CardParser.php
CardParser.parseEntity
public function parseEntity(Card $entity) { $output = [ $this->encodeString($entity->getTicketNumber(), 23), $this->encodeInteger($entity->getUserNumber(), 9), $this->encodeInteger($entity->getArticleNumber(), 3), $this->encodeDate($entity->getValidFrom()), $this->encodeDate($entity->getExpires()), $this->encodeBoolean($entity->getBlocked()), $this->encodeDate($entity->getBlockedDate()), $this->encodeInteger($entity->getProductionState(), 1), $this->encodeInteger($entity->getReasonProduction(), 1), $this->encodeInteger($entity->getProductionCounter(), 4), $this->encodeBoolean($entity->getNeutral()), $this->encodeBoolean($entity->getRetainTicketEntry()), $this->encodeBoolean($entity->getEntryBarrierClosed()), $this->encodeBoolean($entity->getExitBarrierClosed()), $this->encodeBoolean($entity->getRetainTicketExit()), $this->encodeBoolean($entity->getDisplayText()), $this->encodeString($entity->getDisplayText1(), 16), $this->encodeString($entity->getDisplayText2(), 16), $this->encodeInteger($entity->getPersonnalNo(), 4), $this->encodeInteger($entity->getResidualValue(), 12), $this->encodeString($entity->getSerialNumberKeyCardSwatch(), 20), $this->encodeString($entity->getCurrencyResidualValue(), 3), $this->encodeInteger($entity->getTicketType(), 1), $this->encodeString($entity->getTicketSubType(), 5), $this->encodeString($entity->getSerialNo(), 30), $this->encodeDate($entity->getSuspendPeriodFrom()), $this->encodeDate($entity->getSuspendPeriodUntil()), $this->encodeBoolean($entity->getUseValidCarParks()), $this->encodeInteger($entity->getProductionFacilityNumber(), 7), ]; return implode(";", $output); }
php
public function parseEntity(Card $entity) { $output = [ $this->encodeString($entity->getTicketNumber(), 23), $this->encodeInteger($entity->getUserNumber(), 9), $this->encodeInteger($entity->getArticleNumber(), 3), $this->encodeDate($entity->getValidFrom()), $this->encodeDate($entity->getExpires()), $this->encodeBoolean($entity->getBlocked()), $this->encodeDate($entity->getBlockedDate()), $this->encodeInteger($entity->getProductionState(), 1), $this->encodeInteger($entity->getReasonProduction(), 1), $this->encodeInteger($entity->getProductionCounter(), 4), $this->encodeBoolean($entity->getNeutral()), $this->encodeBoolean($entity->getRetainTicketEntry()), $this->encodeBoolean($entity->getEntryBarrierClosed()), $this->encodeBoolean($entity->getExitBarrierClosed()), $this->encodeBoolean($entity->getRetainTicketExit()), $this->encodeBoolean($entity->getDisplayText()), $this->encodeString($entity->getDisplayText1(), 16), $this->encodeString($entity->getDisplayText2(), 16), $this->encodeInteger($entity->getPersonnalNo(), 4), $this->encodeInteger($entity->getResidualValue(), 12), $this->encodeString($entity->getSerialNumberKeyCardSwatch(), 20), $this->encodeString($entity->getCurrencyResidualValue(), 3), $this->encodeInteger($entity->getTicketType(), 1), $this->encodeString($entity->getTicketSubType(), 5), $this->encodeString($entity->getSerialNo(), 30), $this->encodeDate($entity->getSuspendPeriodFrom()), $this->encodeDate($entity->getSuspendPeriodUntil()), $this->encodeBoolean($entity->getUseValidCarParks()), $this->encodeInteger($entity->getProductionFacilityNumber(), 7), ]; return implode(";", $output); }
[ "public", "function", "parseEntity", "(", "Card", "$", "entity", ")", "{", "$", "output", "=", "[", "$", "this", "->", "encodeString", "(", "$", "entity", "->", "getTicketNumber", "(", ")", ",", "23", ")", ",", "$", "this", "->", "encodeInteger", "(", ...
Parse a card entity. @param Card $entity The card. @return string Returns the parsed card. @throws TooLongDataException Throws a too long data exception if a data is too long.
[ "Parse", "a", "card", "entity", "." ]
bd454a47f6a28fbf6029635ee77ed01c9995cf60
https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/ThirdParty/SkiData/Parser/CardParser.php#L42-L77
train
PatternBuilder/pattern-builder-lib-php
src/Schema/Schema.php
Schema.load
public function load($schema_shortname, $component_class = 'PatternBuilder\Property\Component\Component') { $cid = $this->getCid($schema_shortname); if ($this->use_cache && $cache = $this->getCache($cid)) { return clone $cache; } else { if (empty($this->schemaFiles)) { $this->schemaFiles = $this->getSchemaFiles(); } if (!isset($this->schemaFiles[$schema_shortname])) { $message = sprintf('JSON shortname of %s was not found.', $schema_shortname); $this->logger->error($message); return false; } // Loading is limited to this branch of the IF to limit disk IO if ($json = $this->loadSchema($this->schemaFiles[$schema_shortname])) { $schema_path = $this->schemaFiles[$schema_shortname]; $component = new $component_class($json, $this->configuration, $schema_shortname, $schema_path); $this->setCache($cid, $component); return $component; } else { return false; } } }
php
public function load($schema_shortname, $component_class = 'PatternBuilder\Property\Component\Component') { $cid = $this->getCid($schema_shortname); if ($this->use_cache && $cache = $this->getCache($cid)) { return clone $cache; } else { if (empty($this->schemaFiles)) { $this->schemaFiles = $this->getSchemaFiles(); } if (!isset($this->schemaFiles[$schema_shortname])) { $message = sprintf('JSON shortname of %s was not found.', $schema_shortname); $this->logger->error($message); return false; } // Loading is limited to this branch of the IF to limit disk IO if ($json = $this->loadSchema($this->schemaFiles[$schema_shortname])) { $schema_path = $this->schemaFiles[$schema_shortname]; $component = new $component_class($json, $this->configuration, $schema_shortname, $schema_path); $this->setCache($cid, $component); return $component; } else { return false; } } }
[ "public", "function", "load", "(", "$", "schema_shortname", ",", "$", "component_class", "=", "'PatternBuilder\\Property\\Component\\Component'", ")", "{", "$", "cid", "=", "$", "this", "->", "getCid", "(", "$", "schema_shortname", ")", ";", "if", "(", "$", "t...
Loads a object either from file or from cache. @param string $schema_shortname Path to the schema JSON file. @param string $component_class Type of class to be returned on successful object creation. @return mixed Either an object or FALSE on error.
[ "Loads", "a", "object", "either", "from", "file", "or", "from", "cache", "." ]
6cdbb4e62a560e05b29ebfbd223581be2ace9176
https://github.com/PatternBuilder/pattern-builder-lib-php/blob/6cdbb4e62a560e05b29ebfbd223581be2ace9176/src/Schema/Schema.php#L84-L112
train
PatternBuilder/pattern-builder-lib-php
src/Schema/Schema.php
Schema.getCache
protected function getCache($cid) { if (isset($this->localCache[$cid])) { $cache = $this->localCache[$cid]; } else { $cache = $this->loadCache($cid); if ($cache !== false) { $this->localCache[$cid] = $cache; } } return $cache; }
php
protected function getCache($cid) { if (isset($this->localCache[$cid])) { $cache = $this->localCache[$cid]; } else { $cache = $this->loadCache($cid); if ($cache !== false) { $this->localCache[$cid] = $cache; } } return $cache; }
[ "protected", "function", "getCache", "(", "$", "cid", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "localCache", "[", "$", "cid", "]", ")", ")", "{", "$", "cache", "=", "$", "this", "->", "localCache", "[", "$", "cid", "]", ";", "}", "...
Returns the object from local or extended cache. @param string $cid Cache ID. @return mixed Returns the object or FALSE if not found in cache.
[ "Returns", "the", "object", "from", "local", "or", "extended", "cache", "." ]
6cdbb4e62a560e05b29ebfbd223581be2ace9176
https://github.com/PatternBuilder/pattern-builder-lib-php/blob/6cdbb4e62a560e05b29ebfbd223581be2ace9176/src/Schema/Schema.php#L121-L133
train
PatternBuilder/pattern-builder-lib-php
src/Schema/Schema.php
Schema.setCache
protected function setCache($cid, $component_obj) { $this->localCache[$cid] = $component_obj; $this->saveCache($cid, $component_obj); }
php
protected function setCache($cid, $component_obj) { $this->localCache[$cid] = $component_obj; $this->saveCache($cid, $component_obj); }
[ "protected", "function", "setCache", "(", "$", "cid", ",", "$", "component_obj", ")", "{", "$", "this", "->", "localCache", "[", "$", "cid", "]", "=", "$", "component_obj", ";", "$", "this", "->", "saveCache", "(", "$", "cid", ",", "$", "component_obj"...
Sets the local and extended cache. @param string $cid Path to JSON file. @param object $component_obj Object to be stored in cache.
[ "Sets", "the", "local", "and", "extended", "cache", "." ]
6cdbb4e62a560e05b29ebfbd223581be2ace9176
https://github.com/PatternBuilder/pattern-builder-lib-php/blob/6cdbb4e62a560e05b29ebfbd223581be2ace9176/src/Schema/Schema.php#L141-L145
train
PatternBuilder/pattern-builder-lib-php
src/Schema/Schema.php
Schema.loadSchema
protected function loadSchema($schema_path) { $json = false; if (file_exists($schema_path)) { $contents = file_get_contents($schema_path); $json = json_decode($contents); if ($json == false) { $message = sprintf('Error decoding %s.', $schema_path); $this->logger->error($message); } } else { $message = sprintf('Could not load file %s.', $schema_path); $this->logger->error($message); } return $json; }
php
protected function loadSchema($schema_path) { $json = false; if (file_exists($schema_path)) { $contents = file_get_contents($schema_path); $json = json_decode($contents); if ($json == false) { $message = sprintf('Error decoding %s.', $schema_path); $this->logger->error($message); } } else { $message = sprintf('Could not load file %s.', $schema_path); $this->logger->error($message); } return $json; }
[ "protected", "function", "loadSchema", "(", "$", "schema_path", ")", "{", "$", "json", "=", "false", ";", "if", "(", "file_exists", "(", "$", "schema_path", ")", ")", "{", "$", "contents", "=", "file_get_contents", "(", "$", "schema_path", ")", ";", "$",...
Load the JSON file from disk. @param string $schema_path Path to JSON file. @return mixed A PHP object from the JSON or FALSE if file not found.
[ "Load", "the", "JSON", "file", "from", "disk", "." ]
6cdbb4e62a560e05b29ebfbd223581be2ace9176
https://github.com/PatternBuilder/pattern-builder-lib-php/blob/6cdbb4e62a560e05b29ebfbd223581be2ace9176/src/Schema/Schema.php#L154-L170
train
PatternBuilder/pattern-builder-lib-php
src/Schema/Schema.php
Schema.clearCacheByName
public function clearCacheByName($short_name) { $cid = $this->getCid($short_name); unset($this->schemaFiles[$short_name]); $this->clearCache($cid); }
php
public function clearCacheByName($short_name) { $cid = $this->getCid($short_name); unset($this->schemaFiles[$short_name]); $this->clearCache($cid); }
[ "public", "function", "clearCacheByName", "(", "$", "short_name", ")", "{", "$", "cid", "=", "$", "this", "->", "getCid", "(", "$", "short_name", ")", ";", "unset", "(", "$", "this", "->", "schemaFiles", "[", "$", "short_name", "]", ")", ";", "$", "t...
Clear the cached objects for the give schema short name. @param string $short_name The schema short machine name.
[ "Clear", "the", "cached", "objects", "for", "the", "give", "schema", "short", "name", "." ]
6cdbb4e62a560e05b29ebfbd223581be2ace9176
https://github.com/PatternBuilder/pattern-builder-lib-php/blob/6cdbb4e62a560e05b29ebfbd223581be2ace9176/src/Schema/Schema.php#L200-L205
train
PatternBuilder/pattern-builder-lib-php
src/Schema/Schema.php
Schema.warmCache
public function warmCache($render_class = 'PatternBuilder\Property\Component\Component') { $this->schemaFiles = $this->getSchemaFiles(); foreach ($this->schemaFiles as $key => $schema_file) { if ($json = $this->loadSchema($schema_file)) { $cid = $this->getCid($key); $component = new $render_class($json); $this->setCache($cid, $component); } } }
php
public function warmCache($render_class = 'PatternBuilder\Property\Component\Component') { $this->schemaFiles = $this->getSchemaFiles(); foreach ($this->schemaFiles as $key => $schema_file) { if ($json = $this->loadSchema($schema_file)) { $cid = $this->getCid($key); $component = new $render_class($json); $this->setCache($cid, $component); } } }
[ "public", "function", "warmCache", "(", "$", "render_class", "=", "'PatternBuilder\\Property\\Component\\Component'", ")", "{", "$", "this", "->", "schemaFiles", "=", "$", "this", "->", "getSchemaFiles", "(", ")", ";", "foreach", "(", "$", "this", "->", "schemaF...
Pre-load and create all objects to be cached. @param string $render_class Type of class to be returned on successful object creation.
[ "Pre", "-", "load", "and", "create", "all", "objects", "to", "be", "cached", "." ]
6cdbb4e62a560e05b29ebfbd223581be2ace9176
https://github.com/PatternBuilder/pattern-builder-lib-php/blob/6cdbb4e62a560e05b29ebfbd223581be2ace9176/src/Schema/Schema.php#L221-L231
train
Burthorpe/runescape-api
src/Burthorpe/Runescape/RS3/Stats/Repository.php
Repository.factory
public static function factory($rawFeed) { $repository = new static; $skills = new SkillsRepository(); $exploded = explode("\n", $rawFeed); $spliced = array_splice( $exploded, 0, $skills->count() ); for ($id = 0; $id < count($spliced); $id++) { list($rank, $level, $experience) = explode(',', $spliced[$id]); $skill = $skills->find($id); $repository->push( new Stat( $skill, $level, $rank, $experience ) ); } return $repository; }
php
public static function factory($rawFeed) { $repository = new static; $skills = new SkillsRepository(); $exploded = explode("\n", $rawFeed); $spliced = array_splice( $exploded, 0, $skills->count() ); for ($id = 0; $id < count($spliced); $id++) { list($rank, $level, $experience) = explode(',', $spliced[$id]); $skill = $skills->find($id); $repository->push( new Stat( $skill, $level, $rank, $experience ) ); } return $repository; }
[ "public", "static", "function", "factory", "(", "$", "rawFeed", ")", "{", "$", "repository", "=", "new", "static", ";", "$", "skills", "=", "new", "SkillsRepository", "(", ")", ";", "$", "exploded", "=", "explode", "(", "\"\\n\"", ",", "$", "rawFeed", ...
Creates an \Burthorpe\Runescape\RS3\Stats\Repository instance from a raw feed directly from Jagex @param $rawFeed string Raw feed directly from Jagex @return \Burthorpe\Runescape\RS3\Stats\Repository
[ "Creates", "an", "\\", "Burthorpe", "\\", "Runescape", "\\", "RS3", "\\", "Stats", "\\", "Repository", "instance", "from", "a", "raw", "feed", "directly", "from", "Jagex" ]
b192d3ccb390a60dc23b02d501405edcf908d77d
https://github.com/Burthorpe/runescape-api/blob/b192d3ccb390a60dc23b02d501405edcf908d77d/src/Burthorpe/Runescape/RS3/Stats/Repository.php#L16-L44
train
Burthorpe/runescape-api
src/Burthorpe/Runescape/RS3/Stats/Repository.php
Repository.find
public function find($id) { return $this->filter(function (Contract $stat) use ($id) { return $stat->getSkill()->getId() === $id; })->first(); }
php
public function find($id) { return $this->filter(function (Contract $stat) use ($id) { return $stat->getSkill()->getId() === $id; })->first(); }
[ "public", "function", "find", "(", "$", "id", ")", "{", "return", "$", "this", "->", "filter", "(", "function", "(", "Contract", "$", "stat", ")", "use", "(", "$", "id", ")", "{", "return", "$", "stat", "->", "getSkill", "(", ")", "->", "getId", ...
Find a stat by the given skill ID @param $id @return \Burthorpe\Runescape\RS3\Stats\Contract|null
[ "Find", "a", "stat", "by", "the", "given", "skill", "ID" ]
b192d3ccb390a60dc23b02d501405edcf908d77d
https://github.com/Burthorpe/runescape-api/blob/b192d3ccb390a60dc23b02d501405edcf908d77d/src/Burthorpe/Runescape/RS3/Stats/Repository.php#L52-L57
train
Burthorpe/runescape-api
src/Burthorpe/Runescape/RS3/Stats/Repository.php
Repository.findByName
public function findByName($name) { return $this->filter(function (Contract $stat) use ($name) { return $stat->getSkill()->getName() === $name; })->first(); }
php
public function findByName($name) { return $this->filter(function (Contract $stat) use ($name) { return $stat->getSkill()->getName() === $name; })->first(); }
[ "public", "function", "findByName", "(", "$", "name", ")", "{", "return", "$", "this", "->", "filter", "(", "function", "(", "Contract", "$", "stat", ")", "use", "(", "$", "name", ")", "{", "return", "$", "stat", "->", "getSkill", "(", ")", "->", "...
Find a stat by the given skill name @param $name @return \Burthorpe\Runescape\RS3\Stats\Contract|null
[ "Find", "a", "stat", "by", "the", "given", "skill", "name" ]
b192d3ccb390a60dc23b02d501405edcf908d77d
https://github.com/Burthorpe/runescape-api/blob/b192d3ccb390a60dc23b02d501405edcf908d77d/src/Burthorpe/Runescape/RS3/Stats/Repository.php#L65-L70
train
Burthorpe/runescape-api
src/Burthorpe/Runescape/RS3/API.php
API.stats
public function stats($rsn) { $request = new Request('GET', sprintf($this->endpoints['hiscores'], $rsn)); try { $response = $this->guzzle->send($request); } catch (RequestException $e) { throw new UnknownPlayerException($rsn); } return StatsRepository::factory($response->getBody()); }
php
public function stats($rsn) { $request = new Request('GET', sprintf($this->endpoints['hiscores'], $rsn)); try { $response = $this->guzzle->send($request); } catch (RequestException $e) { throw new UnknownPlayerException($rsn); } return StatsRepository::factory($response->getBody()); }
[ "public", "function", "stats", "(", "$", "rsn", ")", "{", "$", "request", "=", "new", "Request", "(", "'GET'", ",", "sprintf", "(", "$", "this", "->", "endpoints", "[", "'hiscores'", "]", ",", "$", "rsn", ")", ")", ";", "try", "{", "$", "response",...
Get a players statistics from the hiscores API feed @return \Burthorpe\Runescape\RS3\Stats\Repository|bool @throws \Burthorpe\Exception\UnknownPlayerException
[ "Get", "a", "players", "statistics", "from", "the", "hiscores", "API", "feed" ]
b192d3ccb390a60dc23b02d501405edcf908d77d
https://github.com/Burthorpe/runescape-api/blob/b192d3ccb390a60dc23b02d501405edcf908d77d/src/Burthorpe/Runescape/RS3/API.php#L56-L67
train
Burthorpe/runescape-api
src/Burthorpe/Runescape/RS3/API.php
API.calculateCombatLevel
public function calculateCombatLevel($attack, $strength, $magic, $ranged, $defence, $constitution, $prayer, $summoning, $float = false) { $highest = max(($attack + $strength), (2 * $magic), (2 * $ranged)); $cmb = floor(0.25 * ((1.3 * $highest) + $defence + $constitution + floor(0.5 * $prayer) + floor(0.5 * $summoning))); return $float ? $cmb : (int) $cmb; }
php
public function calculateCombatLevel($attack, $strength, $magic, $ranged, $defence, $constitution, $prayer, $summoning, $float = false) { $highest = max(($attack + $strength), (2 * $magic), (2 * $ranged)); $cmb = floor(0.25 * ((1.3 * $highest) + $defence + $constitution + floor(0.5 * $prayer) + floor(0.5 * $summoning))); return $float ? $cmb : (int) $cmb; }
[ "public", "function", "calculateCombatLevel", "(", "$", "attack", ",", "$", "strength", ",", "$", "magic", ",", "$", "ranged", ",", "$", "defence", ",", "$", "constitution", ",", "$", "prayer", ",", "$", "summoning", ",", "$", "float", "=", "false", ")...
Calculates a players combat level @param int $attack @param int $strength @param int $magic @param int $ranged @param int $defence @param int $constitution @param int $prayer @param int $summoning @param bool $float @return int
[ "Calculates", "a", "players", "combat", "level" ]
b192d3ccb390a60dc23b02d501405edcf908d77d
https://github.com/Burthorpe/runescape-api/blob/b192d3ccb390a60dc23b02d501405edcf908d77d/src/Burthorpe/Runescape/RS3/API.php#L93-L100
train
hyyan/jaguar
src/Jaguar/Format/Gif.php
Gif.isGifFile
public static function isGifFile($filename) { try { $image = new ImageFile($filename); if (strtolower($image->getMime()) !== @image_type_to_mime_type(IMAGETYPE_GIF)) { return false; } return true; } catch (\RuntimeException $ex) { return false; } }
php
public static function isGifFile($filename) { try { $image = new ImageFile($filename); if (strtolower($image->getMime()) !== @image_type_to_mime_type(IMAGETYPE_GIF)) { return false; } return true; } catch (\RuntimeException $ex) { return false; } }
[ "public", "static", "function", "isGifFile", "(", "$", "filename", ")", "{", "try", "{", "$", "image", "=", "new", "ImageFile", "(", "$", "filename", ")", ";", "if", "(", "strtolower", "(", "$", "image", "->", "getMime", "(", ")", ")", "!==", "@", ...
Check if the given file is gif file @param string $filename @return boolean true if gif file,false otherwise
[ "Check", "if", "the", "given", "file", "is", "gif", "file" ]
ddfe1e65838e86aea4e9cf36a588fe7dcf853576
https://github.com/hyyan/jaguar/blob/ddfe1e65838e86aea4e9cf36a588fe7dcf853576/src/Jaguar/Format/Gif.php#L27-L39
train
kz/lifx-php
src/Lifx.php
Lifx.sendRequest
public function sendRequest($request, $options = []) { $client = $this->client; $response = $client->send($request, $options); return $response; }
php
public function sendRequest($request, $options = []) { $client = $this->client; $response = $client->send($request, $options); return $response; }
[ "public", "function", "sendRequest", "(", "$", "request", ",", "$", "options", "=", "[", "]", ")", "{", "$", "client", "=", "$", "this", "->", "client", ";", "$", "response", "=", "$", "client", "->", "send", "(", "$", "request", ",", "$", "options...
Sends a request to the LIFX HTTP API. @param $request @param array $options @return \Psr\Http\Message\ResponseInterface
[ "Sends", "a", "request", "to", "the", "LIFX", "HTTP", "API", "." ]
bdeec25901c956345d390e64404a922f31948105
https://github.com/kz/lifx-php/blob/bdeec25901c956345d390e64404a922f31948105/src/Lifx.php#L44-L50
train
kz/lifx-php
src/Lifx.php
Lifx.getLights
public function getLights($selector = 'all') { $request = new Request('GET', 'lights/' . $selector); $response = $this->sendRequest($request); return $response->getBody(); }
php
public function getLights($selector = 'all') { $request = new Request('GET', 'lights/' . $selector); $response = $this->sendRequest($request); return $response->getBody(); }
[ "public", "function", "getLights", "(", "$", "selector", "=", "'all'", ")", "{", "$", "request", "=", "new", "Request", "(", "'GET'", ",", "'lights/'", ".", "$", "selector", ")", ";", "$", "response", "=", "$", "this", "->", "sendRequest", "(", "$", ...
Gets lights belonging to the authenticated account. @param string $selector Selector used to filter lights. Defaults to `all`. @return \Psr\Http\Message\StreamInterface
[ "Gets", "lights", "belonging", "to", "the", "authenticated", "account", "." ]
bdeec25901c956345d390e64404a922f31948105
https://github.com/kz/lifx-php/blob/bdeec25901c956345d390e64404a922f31948105/src/Lifx.php#L58-L64
train
kz/lifx-php
src/Lifx.php
Lifx.toggleLights
public function toggleLights($selector = 'all') { $request = new Request('POST', 'lights/' . $selector . '/toggle'); $response = $this->sendRequest($request); return $response->getBody(); }
php
public function toggleLights($selector = 'all') { $request = new Request('POST', 'lights/' . $selector . '/toggle'); $response = $this->sendRequest($request); return $response->getBody(); }
[ "public", "function", "toggleLights", "(", "$", "selector", "=", "'all'", ")", "{", "$", "request", "=", "new", "Request", "(", "'POST'", ",", "'lights/'", ".", "$", "selector", ".", "'/toggle'", ")", ";", "$", "response", "=", "$", "this", "->", "send...
Toggle off lights if they are on, or turn them on if they are off. Physically powered off lights are ignored. @param string $selector Selector used to filter lights. Defaults to `all`. @return \Psr\Http\Message\StreamInterface
[ "Toggle", "off", "lights", "if", "they", "are", "on", "or", "turn", "them", "on", "if", "they", "are", "off", ".", "Physically", "powered", "off", "lights", "are", "ignored", "." ]
bdeec25901c956345d390e64404a922f31948105
https://github.com/kz/lifx-php/blob/bdeec25901c956345d390e64404a922f31948105/src/Lifx.php#L73-L79
train
kz/lifx-php
src/Lifx.php
Lifx.setLights
public function setLights($selector = 'all', $state = 'on', $duration = 1.0) { $request = new Request('PUT', 'lights/' . $selector . '/state'); $response = $this->sendRequest($request, [ 'query' => [ 'power' => $state, 'duration' => $duration ] ]); return $response->getBody(); }
php
public function setLights($selector = 'all', $state = 'on', $duration = 1.0) { $request = new Request('PUT', 'lights/' . $selector . '/state'); $response = $this->sendRequest($request, [ 'query' => [ 'power' => $state, 'duration' => $duration ] ]); return $response->getBody(); }
[ "public", "function", "setLights", "(", "$", "selector", "=", "'all'", ",", "$", "state", "=", "'on'", ",", "$", "duration", "=", "1.0", ")", "{", "$", "request", "=", "new", "Request", "(", "'PUT'", ",", "'lights/'", ".", "$", "selector", ".", "'/st...
Turn lights on or off. @param string $selector Selector used to filter lights. Defaults to `all`. @param string $state State of 'on' or 'off'. @param float $duration (Optional) Fade to the given `state` over a duration of seconds. Defaults to `1.0`. @return \Psr\Http\Message\StreamInterface
[ "Turn", "lights", "on", "or", "off", "." ]
bdeec25901c956345d390e64404a922f31948105
https://github.com/kz/lifx-php/blob/bdeec25901c956345d390e64404a922f31948105/src/Lifx.php#L89-L100
train
kz/lifx-php
src/Lifx.php
Lifx.setColor
public function setColor($selector = 'all', $color = 'white', $duration = 1.0, $power_on = true) { $request = new Request('PUT', 'lights/' . $selector . '/state'); $response = $this->sendRequest($request, [ 'query' => [ 'color' => $color, 'duration' => $duration, 'power_on' => $power_on, ] ]); return $response->getBody(); }
php
public function setColor($selector = 'all', $color = 'white', $duration = 1.0, $power_on = true) { $request = new Request('PUT', 'lights/' . $selector . '/state'); $response = $this->sendRequest($request, [ 'query' => [ 'color' => $color, 'duration' => $duration, 'power_on' => $power_on, ] ]); return $response->getBody(); }
[ "public", "function", "setColor", "(", "$", "selector", "=", "'all'", ",", "$", "color", "=", "'white'", ",", "$", "duration", "=", "1.0", ",", "$", "power_on", "=", "true", ")", "{", "$", "request", "=", "new", "Request", "(", "'PUT'", ",", "'lights...
Set lights to any color. @param string $selector Selector used to filter lights. Defaults to `all`. @param string $color Color the lights should be set to. Defaults to `white`. @param float $duration (Optional) Fade to the given `state` over a duration of seconds. Defaults to `1.0`. @param bool $power_on (Optional) Whether to turn light on first. Defaults to `true`. @return \Psr\Http\Message\StreamInterface
[ "Set", "lights", "to", "any", "color", "." ]
bdeec25901c956345d390e64404a922f31948105
https://github.com/kz/lifx-php/blob/bdeec25901c956345d390e64404a922f31948105/src/Lifx.php#L111-L123
train
kz/lifx-php
src/Lifx.php
Lifx.breatheLights
public function breatheLights( $selector = 'all', $color = 'purple', $from_color = null, $period = 1.0, $cycles = 1.0, $persist = 'false', $power_on = 'true', $peak = 0.5 ) { $request = new Request('POST', 'lights/' . $selector . '/effects/breathe'); $response = $this->sendRequest($request, [ 'query' => [ 'color' => $color, 'from_color' => $from_color, 'period' => $period, 'cycles' => $cycles, 'persist' => $persist, 'power_on' => $power_on, 'peak' => $peak, ] ]); return $response->getBody(); }
php
public function breatheLights( $selector = 'all', $color = 'purple', $from_color = null, $period = 1.0, $cycles = 1.0, $persist = 'false', $power_on = 'true', $peak = 0.5 ) { $request = new Request('POST', 'lights/' . $selector . '/effects/breathe'); $response = $this->sendRequest($request, [ 'query' => [ 'color' => $color, 'from_color' => $from_color, 'period' => $period, 'cycles' => $cycles, 'persist' => $persist, 'power_on' => $power_on, 'peak' => $peak, ] ]); return $response->getBody(); }
[ "public", "function", "breatheLights", "(", "$", "selector", "=", "'all'", ",", "$", "color", "=", "'purple'", ",", "$", "from_color", "=", "null", ",", "$", "period", "=", "1.0", ",", "$", "cycles", "=", "1.0", ",", "$", "persist", "=", "'false'", "...
Performs a breathe effect by slowly fading between the given colors. If `from_color` is omitted then the current color is used in its place. @param string $selector Selector used to filter lights. Defaults to `all`. @param string $color Color the lights should be set to. Defaults to `purple`. @param string|null $from_color (Optional) From color of the waveform. Defaults to `null`. @param float $period (Optional) Period of the waveform in seconds. Defaults to `1.0`. @param float $cycles (Optional) Number of times to repeat, cycle counts. Defaults to `1.0`. @param bool $persist (Optional) Whether to keep state at the end of the effect. Defaults to `false`. @param bool $power_on (Optional) Whether to turn light on first. Defaults to `true`. @param float $peak (Optional) Defines where in a period the target color is at its maximum. Defaults to `0.5`. Minimum `0.0`, maximum `1.0`. @return \Psr\Http\Message\StreamInterface
[ "Performs", "a", "breathe", "effect", "by", "slowly", "fading", "between", "the", "given", "colors", ".", "If", "from_color", "is", "omitted", "then", "the", "current", "color", "is", "used", "in", "its", "place", "." ]
bdeec25901c956345d390e64404a922f31948105
https://github.com/kz/lifx-php/blob/bdeec25901c956345d390e64404a922f31948105/src/Lifx.php#L139-L163
train
kz/lifx-php
src/Lifx.php
Lifx.pulseLights
public function pulseLights( $selector = 'all', $color = 'purple', $from_color = null, $period = 1.0, $cycles = 1.0, $persist = 'false', $power_on = 'true', $duty_cycle = 0.5 ) { $request = new Request('POST', 'lights/' . $selector . '/effects/pulse'); $response = $this->sendRequest($request, [ 'query' => [ 'selector' => $selector, 'color' => $color, 'from_color' => $from_color, 'period' => $period, 'cycles' => $cycles, 'persist' => $persist, 'power_on' => $power_on, 'duty_cycle' => $duty_cycle, ] ]); return $response->getBody(); }
php
public function pulseLights( $selector = 'all', $color = 'purple', $from_color = null, $period = 1.0, $cycles = 1.0, $persist = 'false', $power_on = 'true', $duty_cycle = 0.5 ) { $request = new Request('POST', 'lights/' . $selector . '/effects/pulse'); $response = $this->sendRequest($request, [ 'query' => [ 'selector' => $selector, 'color' => $color, 'from_color' => $from_color, 'period' => $period, 'cycles' => $cycles, 'persist' => $persist, 'power_on' => $power_on, 'duty_cycle' => $duty_cycle, ] ]); return $response->getBody(); }
[ "public", "function", "pulseLights", "(", "$", "selector", "=", "'all'", ",", "$", "color", "=", "'purple'", ",", "$", "from_color", "=", "null", ",", "$", "period", "=", "1.0", ",", "$", "cycles", "=", "1.0", ",", "$", "persist", "=", "'false'", ","...
Performs a pulse effect by quickly flashing between the given colors. If `from_color` is omitted then the current color is used in its place. @param string $selector Selector used to filter lights. Defaults to `all`. @param string $color Color the lights should be set to. Defaults to `purple`. @param string|null $from_color (Optional) From color of the waveform. Defaults to `null`. @param float $period (Optional) Period of the waveform in seconds. Defaults to `1.0`. @param float $cycles (Optional) Number of times to repeat, cycle counts. Defaults to `1.0`. @param bool $persist (Optional) Whether to keep state at the end of the effect. Defaults to `false`. @param bool $power_on (Optional) Whether to turn light on first. Defaults to `true`. @param float $duty_cycle (Optional) Ratio of the period where color is active. Defaults to `0.5`. Minimum `0.0`, maximum `1.0`. @return \Psr\Http\Message\StreamInterface
[ "Performs", "a", "pulse", "effect", "by", "quickly", "flashing", "between", "the", "given", "colors", ".", "If", "from_color", "is", "omitted", "then", "the", "current", "color", "is", "used", "in", "its", "place", "." ]
bdeec25901c956345d390e64404a922f31948105
https://github.com/kz/lifx-php/blob/bdeec25901c956345d390e64404a922f31948105/src/Lifx.php#L179-L204
train
techdivision/import-product-url-rewrite
src/Observers/UrlRewriteObserver.php
UrlRewriteObserver.resolveCategoryIds
protected function resolveCategoryIds($categoryId, $topLevel = false, $storeViewCode = StoreViewCodes::ADMIN) { // return immediately if this is the absolute root node if ((integer) $categoryId === 1) { return; } // load the data of the category with the passed ID $category = $this->getCategory($categoryId, $storeViewCode); // query whether or not the product has already been related if (!in_array($categoryId, $this->productCategoryIds)) { if ($topLevel) { // relate it, if the category is top level $this->productCategoryIds[] = $categoryId; } elseif ((integer) $category[MemberNames::IS_ANCHOR] === 1) { // also relate it, if the category is not top level, but has the anchor flag set $this->productCategoryIds[] = $categoryId; } else { $this->getSubject() ->getSystemLogger() ->debug(sprintf('Don\'t create URL rewrite for category "%s" because of missing anchor flag', $category[MemberNames::PATH])); } } // load the root category $rootCategory = $this->getRootCategory(); // try to resolve the parent category IDs if ($rootCategory[MemberNames::ENTITY_ID] !== ($parentId = $category[MemberNames::PARENT_ID])) { $this->resolveCategoryIds($parentId, false); } }
php
protected function resolveCategoryIds($categoryId, $topLevel = false, $storeViewCode = StoreViewCodes::ADMIN) { // return immediately if this is the absolute root node if ((integer) $categoryId === 1) { return; } // load the data of the category with the passed ID $category = $this->getCategory($categoryId, $storeViewCode); // query whether or not the product has already been related if (!in_array($categoryId, $this->productCategoryIds)) { if ($topLevel) { // relate it, if the category is top level $this->productCategoryIds[] = $categoryId; } elseif ((integer) $category[MemberNames::IS_ANCHOR] === 1) { // also relate it, if the category is not top level, but has the anchor flag set $this->productCategoryIds[] = $categoryId; } else { $this->getSubject() ->getSystemLogger() ->debug(sprintf('Don\'t create URL rewrite for category "%s" because of missing anchor flag', $category[MemberNames::PATH])); } } // load the root category $rootCategory = $this->getRootCategory(); // try to resolve the parent category IDs if ($rootCategory[MemberNames::ENTITY_ID] !== ($parentId = $category[MemberNames::PARENT_ID])) { $this->resolveCategoryIds($parentId, false); } }
[ "protected", "function", "resolveCategoryIds", "(", "$", "categoryId", ",", "$", "topLevel", "=", "false", ",", "$", "storeViewCode", "=", "StoreViewCodes", "::", "ADMIN", ")", "{", "// return immediately if this is the absolute root node", "if", "(", "(", "integer", ...
Resolve's the parent categories of the category with the passed ID and relate's it with the product with the passed ID, if the category is top level OR has the anchor flag set. @param integer $categoryId The ID of the category to resolve the parents @param boolean $topLevel TRUE if the passed category has top level, else FALSE @param string $storeViewCode The store view code to resolve the category IDs for @return void
[ "Resolve", "s", "the", "parent", "categories", "of", "the", "category", "with", "the", "passed", "ID", "and", "relate", "s", "it", "with", "the", "product", "with", "the", "passed", "ID", "if", "the", "category", "is", "top", "level", "OR", "has", "the",...
e3a4d2de04bfc0bc3c98b059e9609a2663608229
https://github.com/techdivision/import-product-url-rewrite/blob/e3a4d2de04bfc0bc3c98b059e9609a2663608229/src/Observers/UrlRewriteObserver.php#L395-L428
train
techdivision/import-product-url-rewrite
src/Observers/UrlRewriteObserver.php
UrlRewriteObserver.prepareUrlRewriteProductCategoryAttributes
protected function prepareUrlRewriteProductCategoryAttributes() { // return the prepared product return $this->initializeEntity( array( MemberNames::PRODUCT_ID => $this->entityId, MemberNames::CATEGORY_ID => $this->categoryId, MemberNames::URL_REWRITE_ID => $this->urlRewriteId ) ); }
php
protected function prepareUrlRewriteProductCategoryAttributes() { // return the prepared product return $this->initializeEntity( array( MemberNames::PRODUCT_ID => $this->entityId, MemberNames::CATEGORY_ID => $this->categoryId, MemberNames::URL_REWRITE_ID => $this->urlRewriteId ) ); }
[ "protected", "function", "prepareUrlRewriteProductCategoryAttributes", "(", ")", "{", "// return the prepared product", "return", "$", "this", "->", "initializeEntity", "(", "array", "(", "MemberNames", "::", "PRODUCT_ID", "=>", "$", "this", "->", "entityId", ",", "Me...
Prepare's the URL rewrite product => category relation attributes. @return array The prepared attributes
[ "Prepare", "s", "the", "URL", "rewrite", "product", "=", ">", "category", "relation", "attributes", "." ]
e3a4d2de04bfc0bc3c98b059e9609a2663608229
https://github.com/techdivision/import-product-url-rewrite/blob/e3a4d2de04bfc0bc3c98b059e9609a2663608229/src/Observers/UrlRewriteObserver.php#L472-L483
train
techdivision/import-product-url-rewrite
src/Observers/UrlRewriteObserver.php
UrlRewriteObserver.prepareTargetPath
protected function prepareTargetPath(array $category) { // query whether or not, the category is the root category if ($this->isRootCategory($category)) { $targetPath = sprintf('catalog/product/view/id/%d', $this->entityId); } else { $targetPath = sprintf('catalog/product/view/id/%d/category/%d', $this->entityId, $category[MemberNames::ENTITY_ID]); } // return the target path return $targetPath; }
php
protected function prepareTargetPath(array $category) { // query whether or not, the category is the root category if ($this->isRootCategory($category)) { $targetPath = sprintf('catalog/product/view/id/%d', $this->entityId); } else { $targetPath = sprintf('catalog/product/view/id/%d/category/%d', $this->entityId, $category[MemberNames::ENTITY_ID]); } // return the target path return $targetPath; }
[ "protected", "function", "prepareTargetPath", "(", "array", "$", "category", ")", "{", "// query whether or not, the category is the root category", "if", "(", "$", "this", "->", "isRootCategory", "(", "$", "category", ")", ")", "{", "$", "targetPath", "=", "sprintf...
Prepare's the target path for a URL rewrite. @param array $category The categroy with the URL path @return string The target path
[ "Prepare", "s", "the", "target", "path", "for", "a", "URL", "rewrite", "." ]
e3a4d2de04bfc0bc3c98b059e9609a2663608229
https://github.com/techdivision/import-product-url-rewrite/blob/e3a4d2de04bfc0bc3c98b059e9609a2663608229/src/Observers/UrlRewriteObserver.php#L492-L504
train
techdivision/import-product-url-rewrite
src/Observers/UrlRewriteObserver.php
UrlRewriteObserver.prepareMetadata
protected function prepareMetadata(array $category) { // initialize the metadata $metadata = array(); // query whether or not, the passed category IS the root category if ($this->isRootCategory($category)) { return; } // if not, set the category ID in the metadata $metadata[UrlRewriteObserver::CATEGORY_ID] = (integer) $category[MemberNames::ENTITY_ID]; // return the metadata return $metadata; }
php
protected function prepareMetadata(array $category) { // initialize the metadata $metadata = array(); // query whether or not, the passed category IS the root category if ($this->isRootCategory($category)) { return; } // if not, set the category ID in the metadata $metadata[UrlRewriteObserver::CATEGORY_ID] = (integer) $category[MemberNames::ENTITY_ID]; // return the metadata return $metadata; }
[ "protected", "function", "prepareMetadata", "(", "array", "$", "category", ")", "{", "// initialize the metadata", "$", "metadata", "=", "array", "(", ")", ";", "// query whether or not, the passed category IS the root category", "if", "(", "$", "this", "->", "isRootCat...
Prepare's the URL rewrite's metadata with the passed category values. @param array $category The category used for preparation @return array|null The metadata
[ "Prepare", "s", "the", "URL", "rewrite", "s", "metadata", "with", "the", "passed", "category", "values", "." ]
e3a4d2de04bfc0bc3c98b059e9609a2663608229
https://github.com/techdivision/import-product-url-rewrite/blob/e3a4d2de04bfc0bc3c98b059e9609a2663608229/src/Observers/UrlRewriteObserver.php#L549-L565
train
techdivision/import-product-url-rewrite
src/Observers/UrlRewriteObserver.php
UrlRewriteObserver.isRootCategory
protected function isRootCategory(array $category) { // load the root category $rootCategory = $this->getRootCategory(); // compare the entity IDs and return the result return $rootCategory[MemberNames::ENTITY_ID] === $category[MemberNames::ENTITY_ID]; }
php
protected function isRootCategory(array $category) { // load the root category $rootCategory = $this->getRootCategory(); // compare the entity IDs and return the result return $rootCategory[MemberNames::ENTITY_ID] === $category[MemberNames::ENTITY_ID]; }
[ "protected", "function", "isRootCategory", "(", "array", "$", "category", ")", "{", "// load the root category", "$", "rootCategory", "=", "$", "this", "->", "getRootCategory", "(", ")", ";", "// compare the entity IDs and return the result", "return", "$", "rootCategor...
Return's TRUE if the passed category IS the root category, else FALSE. @param array $category The category to query @return boolean TRUE if the passed category IS the root category
[ "Return", "s", "TRUE", "if", "the", "passed", "category", "IS", "the", "root", "category", "else", "FALSE", "." ]
e3a4d2de04bfc0bc3c98b059e9609a2663608229
https://github.com/techdivision/import-product-url-rewrite/blob/e3a4d2de04bfc0bc3c98b059e9609a2663608229/src/Observers/UrlRewriteObserver.php#L609-L617
train
redirectionio/proxy-sdk-php
src/Client.php
Client.fwrite
private function fwrite($stream, $bytes) { if (!\strlen($bytes)) { return 0; } $result = @fwrite($stream, $bytes); if (0 !== $result) { // In cases where some bytes are witten (`$result > 0`) or // an error occurs (`$result === false`), the behavior of fwrite() is // correct. We can return the value as-is. return $result; } // If we make it here, we performed a 0-length write. Try to distinguish // between EAGAIN and EPIPE. To do this, we're going to `stream_select()` // the stream, write to it again if PHP claims that it's writable, and // consider the pipe broken if the write fails. $read = []; $write = [$stream]; $except = []; @stream_select($read, $write, $except, 0); if (!$write) { // The stream isn't writable, so we conclude that it probably really is // blocked and the underlying error was EAGAIN. Return 0 to indicate that // no data could be written yet. return 0; } // If we make it here, PHP **just** claimed that this stream is writable, so // perform a write. If the write also fails, conclude that these failures are // EPIPE or some other permanent failure. $result = @fwrite($stream, $bytes); if (0 !== $result) { // The write worked or failed explicitly. This value is fine to return. return $result; } // We performed a 0-length write, were told that the stream was writable, and // then immediately performed another 0-length write. Conclude that the pipe // is broken and return `false`. return false; }
php
private function fwrite($stream, $bytes) { if (!\strlen($bytes)) { return 0; } $result = @fwrite($stream, $bytes); if (0 !== $result) { // In cases where some bytes are witten (`$result > 0`) or // an error occurs (`$result === false`), the behavior of fwrite() is // correct. We can return the value as-is. return $result; } // If we make it here, we performed a 0-length write. Try to distinguish // between EAGAIN and EPIPE. To do this, we're going to `stream_select()` // the stream, write to it again if PHP claims that it's writable, and // consider the pipe broken if the write fails. $read = []; $write = [$stream]; $except = []; @stream_select($read, $write, $except, 0); if (!$write) { // The stream isn't writable, so we conclude that it probably really is // blocked and the underlying error was EAGAIN. Return 0 to indicate that // no data could be written yet. return 0; } // If we make it here, PHP **just** claimed that this stream is writable, so // perform a write. If the write also fails, conclude that these failures are // EPIPE or some other permanent failure. $result = @fwrite($stream, $bytes); if (0 !== $result) { // The write worked or failed explicitly. This value is fine to return. return $result; } // We performed a 0-length write, were told that the stream was writable, and // then immediately performed another 0-length write. Conclude that the pipe // is broken and return `false`. return false; }
[ "private", "function", "fwrite", "(", "$", "stream", ",", "$", "bytes", ")", "{", "if", "(", "!", "\\", "strlen", "(", "$", "bytes", ")", ")", "{", "return", "0", ";", "}", "$", "result", "=", "@", "fwrite", "(", "$", "stream", ",", "$", "bytes...
Replace fwrite behavior as API is broken in PHP. @see https://secure.phabricator.com/rPHU69490c53c9c2ef2002bc2dd4cecfe9a4b080b497 @param resource $stream The stream resource @param string $bytes Bytes written in the stream @return bool|int false if pipe is broken, number of bytes written otherwise
[ "Replace", "fwrite", "behavior", "as", "API", "is", "broken", "in", "PHP", "." ]
d4073d0dcbf6befc4477d0dfcf835e9b46e51df2
https://github.com/redirectionio/proxy-sdk-php/blob/d4073d0dcbf6befc4477d0dfcf835e9b46e51df2/src/Client.php#L268-L306
train
mvccore/mvccore
src/MvcCore/Route/GettersSetters.php
GettersSetters.&
public function & GetFilters () { $filters = []; foreach ($this->filters as $direction => $handler) $filters[$direction] = $handler[1]; return $filters; }
php
public function & GetFilters () { $filters = []; foreach ($this->filters as $direction => $handler) $filters[$direction] = $handler[1]; return $filters; }
[ "public", "function", "&", "GetFilters", "(", ")", "{", "$", "filters", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "filters", "as", "$", "direction", "=>", "$", "handler", ")", "$", "filters", "[", "$", "direction", "]", "=", "$", "hand...
Get URL address params filters to filter URL params in and out. By route filters you can change incoming request params into application and out from application. For example to translate the values or anything else. Filters are `callable`s and always in this array under keys `"in"` and `"out"` accepting arguments: - `$params` associative array with params from requested URL address for in filter and associative array with params to build URL address for out filter. - `$defaultParams` associative array with default params to store any custom value necessary to filter effectively. - `$request` current request instance implements `\MvcCore\IRequest`. `Callable` filter must return associative `array` with filtered params. There is possible to call any `callable` as closure function in variable except forms like `'ClassName::methodName'` and `['childClassName', 'parent::methodName']` and `[$childInstance, 'parent::methodName']`. @return array|\callable[]
[ "Get", "URL", "address", "params", "filters", "to", "filter", "URL", "params", "in", "and", "out", ".", "By", "route", "filters", "you", "can", "change", "incoming", "request", "params", "into", "application", "and", "out", "from", "application", ".", "For",...
5e580a2803bbccea8168316c4c6b963e1910e0bf
https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Route/GettersSetters.php#L418-L423
train
mvccore/mvccore
src/MvcCore/Route/GettersSetters.php
GettersSetters.&
public function & SetFilters (array $filters = []) { foreach ($filters as $direction => $handler) $this->SetFilter($handler, $direction); /** @var $this \MvcCore\Route */ return $this; }
php
public function & SetFilters (array $filters = []) { foreach ($filters as $direction => $handler) $this->SetFilter($handler, $direction); /** @var $this \MvcCore\Route */ return $this; }
[ "public", "function", "&", "SetFilters", "(", "array", "$", "filters", "=", "[", "]", ")", "{", "foreach", "(", "$", "filters", "as", "$", "direction", "=>", "$", "handler", ")", "$", "this", "->", "SetFilter", "(", "$", "handler", ",", "$", "directi...
Set URL address params filters to filter URL params in and out. By route filters you can change incoming request params into application and out from application. For example to translate the values or anything else. Filters are `callable`s and always in this array under keys `"in"` and `"out"` accepting arguments: - `$params` associative array with params from requested URL address for in filter and associative array with params to build URL address for out filter. - `$defaultParams` associative array with default params to store any custom value necessary to filter effectively. - `$request` current request instance implements `\MvcCore\IRequest`. `Callable` filter must return associative `array` with filtered params. There is possible to call any `callable` as closure function in variable except forms like `'ClassName::methodName'` and `['childClassName', 'parent::methodName']` and `[$childInstance, 'parent::methodName']`. @param array|\callable[] $filters @return \MvcCore\Route
[ "Set", "URL", "address", "params", "filters", "to", "filter", "URL", "params", "in", "and", "out", ".", "By", "route", "filters", "you", "can", "change", "incoming", "request", "params", "into", "application", "and", "out", "from", "application", ".", "For",...
5e580a2803bbccea8168316c4c6b963e1910e0bf
https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Route/GettersSetters.php#L447-L452
train
mvccore/mvccore
src/MvcCore/Route/GettersSetters.php
GettersSetters.GetFilter
public function GetFilter ($direction = \MvcCore\IRoute::CONFIG_FILTER_IN) { return isset($this->filters[$direction]) ? $this->filters[$direction] : NULL; }
php
public function GetFilter ($direction = \MvcCore\IRoute::CONFIG_FILTER_IN) { return isset($this->filters[$direction]) ? $this->filters[$direction] : NULL; }
[ "public", "function", "GetFilter", "(", "$", "direction", "=", "\\", "MvcCore", "\\", "IRoute", "::", "CONFIG_FILTER_IN", ")", "{", "return", "isset", "(", "$", "this", "->", "filters", "[", "$", "direction", "]", ")", "?", "$", "this", "->", "filters", ...
Get URL address params filter to filter URL params in and out. By route filter you can change incoming request params into application and out from application. For example to translate the values or anything else. Filter is `callable` accepting arguments: - `$params` associative array with params from requested URL address for in filter and associative array with params to build URL address for out filter. - `$defaultParams` associative array with default params to store any custom value necessary to filter effectively. - `$request` current request instance implements `\MvcCore\IRequest`. `Callable` filter must return associative `array` with filtered params. There is possible to call any `callable` as closure function in variable except forms like `'ClassName::methodName'` and `['childClassName', 'parent::methodName']` and `[$childInstance, 'parent::methodName']`. @return \callable|NULL
[ "Get", "URL", "address", "params", "filter", "to", "filter", "URL", "params", "in", "and", "out", ".", "By", "route", "filter", "you", "can", "change", "incoming", "request", "params", "into", "application", "and", "out", "from", "application", ".", "For", ...
5e580a2803bbccea8168316c4c6b963e1910e0bf
https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Route/GettersSetters.php#L474-L478
train
mvccore/mvccore
src/MvcCore/Route/GettersSetters.php
GettersSetters.&
public function & SetFilter ($handler, $direction = \MvcCore\IRoute::CONFIG_FILTER_IN) { // there is possible to call any `callable` as closure function in variable // except forms like `'ClassName::methodName'` and `['childClassName', 'parent::methodName']` // and `[$childInstance, 'parent::methodName']`. $closureCalling = ( (is_string($handler) && strpos($handler, '::') !== FALSE) || (is_array($handler) && strpos($handler[1], '::') !== FALSE) ) ? FALSE : TRUE; /** @var $this \MvcCore\Route */ $this->filters[$direction] = [$closureCalling, $handler]; return $this; }
php
public function & SetFilter ($handler, $direction = \MvcCore\IRoute::CONFIG_FILTER_IN) { // there is possible to call any `callable` as closure function in variable // except forms like `'ClassName::methodName'` and `['childClassName', 'parent::methodName']` // and `[$childInstance, 'parent::methodName']`. $closureCalling = ( (is_string($handler) && strpos($handler, '::') !== FALSE) || (is_array($handler) && strpos($handler[1], '::') !== FALSE) ) ? FALSE : TRUE; /** @var $this \MvcCore\Route */ $this->filters[$direction] = [$closureCalling, $handler]; return $this; }
[ "public", "function", "&", "SetFilter", "(", "$", "handler", ",", "$", "direction", "=", "\\", "MvcCore", "\\", "IRoute", "::", "CONFIG_FILTER_IN", ")", "{", "// there is possible to call any `callable` as closure function in variable", "// except forms like `'ClassName::meth...
Set URL address params filter to filter URL params in and out. By route filter you can change incoming request params into application and out from application. For example to translate the values or anything else. Filter is `callable` accepting arguments: - `$params` associative array with params from requested URL address for in filter and associative array with params to build URL address for out filter. - `$defaultParams` associative array with default params to store any custom value necessary to filter effectively. - `$request` current request instance implements `\MvcCore\IRequest`. `Callable` filter must return associative `array` with filtered params. There is possible to call any `callable` as closure function in variable except forms like `'ClassName::methodName'` and `['childClassName', 'parent::methodName']` and `[$childInstance, 'parent::methodName']`. @param \callable $handler @param string $direction @return \MvcCore\Route
[ "Set", "URL", "address", "params", "filter", "to", "filter", "URL", "params", "in", "and", "out", ".", "By", "route", "filter", "you", "can", "change", "incoming", "request", "params", "into", "application", "and", "out", "from", "application", ".", "For", ...
5e580a2803bbccea8168316c4c6b963e1910e0bf
https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Route/GettersSetters.php#L502-L513
train
hyyan/jaguar
src/Jaguar/Action/Flip.php
Flip.setDirection
public function setDirection($direction) { if (!in_array($direction, self::$supportedFlipDirection)) { throw new \InvalidArgumentException(sprintf( '"%s" Is Not Valid Flip Direction', (string) $direction )); } $this->flipDirection = $direction; return $this; }
php
public function setDirection($direction) { if (!in_array($direction, self::$supportedFlipDirection)) { throw new \InvalidArgumentException(sprintf( '"%s" Is Not Valid Flip Direction', (string) $direction )); } $this->flipDirection = $direction; return $this; }
[ "public", "function", "setDirection", "(", "$", "direction", ")", "{", "if", "(", "!", "in_array", "(", "$", "direction", ",", "self", "::", "$", "supportedFlipDirection", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", ...
Set flip direction @param string $direction any of Flip::FLIP_* @return \Jaguar\Action\Flip @throws \InvalidArgumentException
[ "Set", "flip", "direction" ]
ddfe1e65838e86aea4e9cf36a588fe7dcf853576
https://github.com/hyyan/jaguar/blob/ddfe1e65838e86aea4e9cf36a588fe7dcf853576/src/Jaguar/Action/Flip.php#L48-L58
train
cpliakas/psolr
src/PSolr/Request/Facet.php
Facet.buildParam
public function buildParam($facetParam, $field) { $param = ''; // Parameter is per-field if ($field !== null) { $param .= 'f.' . $field . '.'; } $param .= $facetParam; return $param; }
php
public function buildParam($facetParam, $field) { $param = ''; // Parameter is per-field if ($field !== null) { $param .= 'f.' . $field . '.'; } $param .= $facetParam; return $param; }
[ "public", "function", "buildParam", "(", "$", "facetParam", ",", "$", "field", ")", "{", "$", "param", "=", "''", ";", "// Parameter is per-field", "if", "(", "$", "field", "!==", "null", ")", "{", "$", "param", ".=", "'f.'", ".", "$", "field", ".", ...
Helper function that builds a facet param based on whether it is global or per-field. If the field is null, the param is global. @param string $facetParam @param string|null $field @return string @see http://wiki.apache.org/solr/SimpleFacetParameters#Parameters
[ "Helper", "function", "that", "builds", "a", "facet", "param", "based", "on", "whether", "it", "is", "global", "or", "per", "-", "field", ".", "If", "the", "field", "is", "null", "the", "param", "is", "global", "." ]
43098fa346a706f481e7a1408664d4582f7ce675
https://github.com/cpliakas/psolr/blob/43098fa346a706f481e7a1408664d4582f7ce675/src/PSolr/Request/Facet.php#L57-L68
train
techdivision/import-product-url-rewrite
src/Observers/UrlRewriteUpdateObserver.php
UrlRewriteUpdateObserver.removeExistingUrlRewrite
protected function removeExistingUrlRewrite(array $urlRewrite) { // load request path $requestPath = $urlRewrite[MemberNames::REQUEST_PATH]; // query whether or not the URL rewrite exists and remove it, if available if (isset($this->existingUrlRewrites[$requestPath])) { unset($this->existingUrlRewrites[$requestPath]); } }
php
protected function removeExistingUrlRewrite(array $urlRewrite) { // load request path $requestPath = $urlRewrite[MemberNames::REQUEST_PATH]; // query whether or not the URL rewrite exists and remove it, if available if (isset($this->existingUrlRewrites[$requestPath])) { unset($this->existingUrlRewrites[$requestPath]); } }
[ "protected", "function", "removeExistingUrlRewrite", "(", "array", "$", "urlRewrite", ")", "{", "// load request path", "$", "requestPath", "=", "$", "urlRewrite", "[", "MemberNames", "::", "REQUEST_PATH", "]", ";", "// query whether or not the URL rewrite exists and remove...
Remove's the passed URL rewrite from the existing one's. @param array $urlRewrite The URL rewrite to remove @return void
[ "Remove", "s", "the", "passed", "URL", "rewrite", "from", "the", "existing", "one", "s", "." ]
e3a4d2de04bfc0bc3c98b059e9609a2663608229
https://github.com/techdivision/import-product-url-rewrite/blob/e3a4d2de04bfc0bc3c98b059e9609a2663608229/src/Observers/UrlRewriteUpdateObserver.php#L172-L182
train
techdivision/import-product-url-rewrite
src/Observers/UrlRewriteUpdateObserver.php
UrlRewriteUpdateObserver.getCategoryIdFromMetadata
protected function getCategoryIdFromMetadata(array $attr) { // load the metadata of the passed URL rewrite entity $metadata = $this->getMetadata($attr); // return the category ID from the metadata return (integer) $metadata[UrlRewriteObserver::CATEGORY_ID]; }
php
protected function getCategoryIdFromMetadata(array $attr) { // load the metadata of the passed URL rewrite entity $metadata = $this->getMetadata($attr); // return the category ID from the metadata return (integer) $metadata[UrlRewriteObserver::CATEGORY_ID]; }
[ "protected", "function", "getCategoryIdFromMetadata", "(", "array", "$", "attr", ")", "{", "// load the metadata of the passed URL rewrite entity", "$", "metadata", "=", "$", "this", "->", "getMetadata", "(", "$", "attr", ")", ";", "// return the category ID from the meta...
Extracts the category ID of the passed URL rewrite entity, if available, and return's it. @param array $attr The URL rewrite entity to extract and return the category ID for @return integer|null The category ID if available, else NULL
[ "Extracts", "the", "category", "ID", "of", "the", "passed", "URL", "rewrite", "entity", "if", "available", "and", "return", "s", "it", "." ]
e3a4d2de04bfc0bc3c98b059e9609a2663608229
https://github.com/techdivision/import-product-url-rewrite/blob/e3a4d2de04bfc0bc3c98b059e9609a2663608229/src/Observers/UrlRewriteUpdateObserver.php#L259-L267
train
techdivision/import-product-url-rewrite
src/Observers/UrlRewriteUpdateObserver.php
UrlRewriteUpdateObserver.initializeUrlRewriteProductCategory
protected function initializeUrlRewriteProductCategory($attr) { // try to load the URL rewrite product category relation if ($urlRewriteProductCategory = $this->loadUrlRewriteProductCategory($attr[MemberNames::URL_REWRITE_ID])) { return $this->mergeEntity($urlRewriteProductCategory, $attr); } // simple return the URL rewrite product category return $attr; }
php
protected function initializeUrlRewriteProductCategory($attr) { // try to load the URL rewrite product category relation if ($urlRewriteProductCategory = $this->loadUrlRewriteProductCategory($attr[MemberNames::URL_REWRITE_ID])) { return $this->mergeEntity($urlRewriteProductCategory, $attr); } // simple return the URL rewrite product category return $attr; }
[ "protected", "function", "initializeUrlRewriteProductCategory", "(", "$", "attr", ")", "{", "// try to load the URL rewrite product category relation", "if", "(", "$", "urlRewriteProductCategory", "=", "$", "this", "->", "loadUrlRewriteProductCategory", "(", "$", "attr", "[...
Initialize the URL rewrite product => category relation with the passed attributes and returns an instance. @param array $attr The URL rewrite product => category relation attributes @return array|null The initialized URL rewrite product => category relation
[ "Initialize", "the", "URL", "rewrite", "product", "=", ">", "category", "relation", "with", "the", "passed", "attributes", "and", "returns", "an", "instance", "." ]
e3a4d2de04bfc0bc3c98b059e9609a2663608229
https://github.com/techdivision/import-product-url-rewrite/blob/e3a4d2de04bfc0bc3c98b059e9609a2663608229/src/Observers/UrlRewriteUpdateObserver.php#L277-L287
train
techdivision/import-product-url-rewrite
src/Observers/UrlRewriteUpdateObserver.php
UrlRewriteUpdateObserver.getMetadata
protected function getMetadata($urlRewrite) { // initialize the array with the metaddata $metadata = array(); // try to unserialize the metadata from the passed URL rewrite if (isset($urlRewrite[MemberNames::METADATA])) { $metadata = json_decode($urlRewrite[MemberNames::METADATA], true); } // query whether or not a category ID has been found if (isset($metadata[UrlRewriteObserver::CATEGORY_ID])) { // if yes, return the metadata return $metadata; } // if not, append the ID of the root category $rootCategory = $this->getRootCategory(); $metadata[UrlRewriteObserver::CATEGORY_ID] = (integer) $rootCategory[MemberNames::ENTITY_ID]; // and return the metadata return $metadata; }
php
protected function getMetadata($urlRewrite) { // initialize the array with the metaddata $metadata = array(); // try to unserialize the metadata from the passed URL rewrite if (isset($urlRewrite[MemberNames::METADATA])) { $metadata = json_decode($urlRewrite[MemberNames::METADATA], true); } // query whether or not a category ID has been found if (isset($metadata[UrlRewriteObserver::CATEGORY_ID])) { // if yes, return the metadata return $metadata; } // if not, append the ID of the root category $rootCategory = $this->getRootCategory(); $metadata[UrlRewriteObserver::CATEGORY_ID] = (integer) $rootCategory[MemberNames::ENTITY_ID]; // and return the metadata return $metadata; }
[ "protected", "function", "getMetadata", "(", "$", "urlRewrite", ")", "{", "// initialize the array with the metaddata", "$", "metadata", "=", "array", "(", ")", ";", "// try to unserialize the metadata from the passed URL rewrite", "if", "(", "isset", "(", "$", "urlRewrit...
Return's the unserialized metadata of the passed URL rewrite. If the metadata doesn't contain a category ID, the category ID of the root category will be added. @param array $urlRewrite The URL rewrite to return the metadata for @return array The metadata of the passed URL rewrite
[ "Return", "s", "the", "unserialized", "metadata", "of", "the", "passed", "URL", "rewrite", ".", "If", "the", "metadata", "doesn", "t", "contain", "a", "category", "ID", "the", "category", "ID", "of", "the", "root", "category", "will", "be", "added", "." ]
e3a4d2de04bfc0bc3c98b059e9609a2663608229
https://github.com/techdivision/import-product-url-rewrite/blob/e3a4d2de04bfc0bc3c98b059e9609a2663608229/src/Observers/UrlRewriteUpdateObserver.php#L298-L321
train
phpcr/phpcr-migrations
lib/VersionCollection.php
VersionCollection.getNextVersion
public function getNextVersion($from) { $found = false; foreach (array_keys($this->versions) as $timestamp) { if ($from === null) { return $timestamp; } if ($timestamp == $from) { $found = true; continue; } if ($found) { return $timestamp; } } return; }
php
public function getNextVersion($from) { $found = false; foreach (array_keys($this->versions) as $timestamp) { if ($from === null) { return $timestamp; } if ($timestamp == $from) { $found = true; continue; } if ($found) { return $timestamp; } } return; }
[ "public", "function", "getNextVersion", "(", "$", "from", ")", "{", "$", "found", "=", "false", ";", "foreach", "(", "array_keys", "(", "$", "this", "->", "versions", ")", "as", "$", "timestamp", ")", "{", "if", "(", "$", "from", "===", "null", ")", ...
Return the version after the given version. @param string $from
[ "Return", "the", "version", "after", "the", "given", "version", "." ]
4c407440632a8689c889534216066ed53ed27142
https://github.com/phpcr/phpcr-migrations/blob/4c407440632a8689c889534216066ed53ed27142/lib/VersionCollection.php#L91-L110
train
phpcr/phpcr-migrations
lib/VersionCollection.php
VersionCollection.getPreviousVersion
public function getPreviousVersion($from) { $lastTimestamp = 0; foreach (array_keys($this->versions) as $timestamp) { if ($timestamp == $from) { return $lastTimestamp; } $lastTimestamp = $timestamp; } return 0; }
php
public function getPreviousVersion($from) { $lastTimestamp = 0; foreach (array_keys($this->versions) as $timestamp) { if ($timestamp == $from) { return $lastTimestamp; } $lastTimestamp = $timestamp; } return 0; }
[ "public", "function", "getPreviousVersion", "(", "$", "from", ")", "{", "$", "lastTimestamp", "=", "0", ";", "foreach", "(", "array_keys", "(", "$", "this", "->", "versions", ")", "as", "$", "timestamp", ")", "{", "if", "(", "$", "timestamp", "==", "$"...
Return the version before the given version. @param string $from
[ "Return", "the", "version", "before", "the", "given", "version", "." ]
4c407440632a8689c889534216066ed53ed27142
https://github.com/phpcr/phpcr-migrations/blob/4c407440632a8689c889534216066ed53ed27142/lib/VersionCollection.php#L117-L128
train
Brotzka/Laravel-Translation-Manager
src/module/Console/Commands/TranslationToFile.php
TranslationToFile.getAllLanguagesFromTable
protected function getAllLanguagesFromTable(): void { foreach($this->translations as $entry){ if(!in_array($entry->language, $this->languages)){ array_push($this->languages, $entry->language); } } $this->compareLanguages(); }
php
protected function getAllLanguagesFromTable(): void { foreach($this->translations as $entry){ if(!in_array($entry->language, $this->languages)){ array_push($this->languages, $entry->language); } } $this->compareLanguages(); }
[ "protected", "function", "getAllLanguagesFromTable", "(", ")", ":", "void", "{", "foreach", "(", "$", "this", "->", "translations", "as", "$", "entry", ")", "{", "if", "(", "!", "in_array", "(", "$", "entry", "->", "language", ",", "$", "this", "->", "...
Collects all languages from the Database @return void
[ "Collects", "all", "languages", "from", "the", "Database" ]
46275f605bd25f81f5645e91b78496eea46d04ce
https://github.com/Brotzka/Laravel-Translation-Manager/blob/46275f605bd25f81f5645e91b78496eea46d04ce/src/module/Console/Commands/TranslationToFile.php#L66-L74
train
Brotzka/Laravel-Translation-Manager
src/module/Console/Commands/TranslationToFile.php
TranslationToFile.generateGroupFiles
protected function generateGroupFiles(): void { foreach($this->languages as $language){ foreach($this->translation_groups as $group){ $file = $this->language_folder . $language . "\\" . $group->name . ".php"; if(!file_exists($file)){ $new_file = fopen($file, "a"); fclose($new_file); $this->info("Created translation group - $group->name - for language $language."); } } } }
php
protected function generateGroupFiles(): void { foreach($this->languages as $language){ foreach($this->translation_groups as $group){ $file = $this->language_folder . $language . "\\" . $group->name . ".php"; if(!file_exists($file)){ $new_file = fopen($file, "a"); fclose($new_file); $this->info("Created translation group - $group->name - for language $language."); } } } }
[ "protected", "function", "generateGroupFiles", "(", ")", ":", "void", "{", "foreach", "(", "$", "this", "->", "languages", "as", "$", "language", ")", "{", "foreach", "(", "$", "this", "->", "translation_groups", "as", "$", "group", ")", "{", "$", "file"...
Generates translation group files for each language if not exists @return void
[ "Generates", "translation", "group", "files", "for", "each", "language", "if", "not", "exists" ]
46275f605bd25f81f5645e91b78496eea46d04ce
https://github.com/Brotzka/Laravel-Translation-Manager/blob/46275f605bd25f81f5645e91b78496eea46d04ce/src/module/Console/Commands/TranslationToFile.php#L113-L125
train
Brotzka/Laravel-Translation-Manager
src/module/Console/Commands/TranslationToFile.php
TranslationToFile.addTranslationsToArray
private function addTranslationsToArray($array = []): array { foreach($array as $language => $groups){ foreach($groups as $groupname => $entries){ $group_model = TranslationGroup::where('name', $groupname)->first(); $first_level_translations = Translation::where([ ['parent', '=', NULL], ['translation_group', '=', $group_model->id], ['language', '=', $language] ])->get(); foreach($first_level_translations as $translation){ $array[$language][$groupname][$translation->key] = $this->getValue($language, $translation, $group_model); } } } return $array; }
php
private function addTranslationsToArray($array = []): array { foreach($array as $language => $groups){ foreach($groups as $groupname => $entries){ $group_model = TranslationGroup::where('name', $groupname)->first(); $first_level_translations = Translation::where([ ['parent', '=', NULL], ['translation_group', '=', $group_model->id], ['language', '=', $language] ])->get(); foreach($first_level_translations as $translation){ $array[$language][$groupname][$translation->key] = $this->getValue($language, $translation, $group_model); } } } return $array; }
[ "private", "function", "addTranslationsToArray", "(", "$", "array", "=", "[", "]", ")", ":", "array", "{", "foreach", "(", "$", "array", "as", "$", "language", "=>", "$", "groups", ")", "{", "foreach", "(", "$", "groups", "as", "$", "groupname", "=>", ...
Collects all relevant translations from database and writes them to the correct array-field. @return array
[ "Collects", "all", "relevant", "translations", "from", "database", "and", "writes", "them", "to", "the", "correct", "array", "-", "field", "." ]
46275f605bd25f81f5645e91b78496eea46d04ce
https://github.com/Brotzka/Laravel-Translation-Manager/blob/46275f605bd25f81f5645e91b78496eea46d04ce/src/module/Console/Commands/TranslationToFile.php#L155-L173
train
Brotzka/Laravel-Translation-Manager
src/module/Console/Commands/TranslationToFile.php
TranslationToFile.addTranslationGroupsToArray
private function addTranslationGroupsToArray($array = []): array { foreach(array_keys($array) as $language){ foreach($this->translation_groups as $group){ $array[$language][$group->name] = []; } } return $array; }
php
private function addTranslationGroupsToArray($array = []): array { foreach(array_keys($array) as $language){ foreach($this->translation_groups as $group){ $array[$language][$group->name] = []; } } return $array; }
[ "private", "function", "addTranslationGroupsToArray", "(", "$", "array", "=", "[", "]", ")", ":", "array", "{", "foreach", "(", "array_keys", "(", "$", "array", ")", "as", "$", "language", ")", "{", "foreach", "(", "$", "this", "->", "translation_groups", ...
Adds translation groups to the given array. @return array
[ "Adds", "translation", "groups", "to", "the", "given", "array", "." ]
46275f605bd25f81f5645e91b78496eea46d04ce
https://github.com/Brotzka/Laravel-Translation-Manager/blob/46275f605bd25f81f5645e91b78496eea46d04ce/src/module/Console/Commands/TranslationToFile.php#L193-L201
train
hyyan/jaguar
src/Jaguar/Canvas.php
Canvas.setFormat
public function setFormat($name) { if (!$this->hasFactory($name)) { throw new \InvalidArgumentException(sprintf( 'Invalid Canvas Factory "%s"', $name )); } $this->activeFactoryName = $name; $this->activeCanvas = $this->getFactory($name)->getCanvas(); return $this; }
php
public function setFormat($name) { if (!$this->hasFactory($name)) { throw new \InvalidArgumentException(sprintf( 'Invalid Canvas Factory "%s"', $name )); } $this->activeFactoryName = $name; $this->activeCanvas = $this->getFactory($name)->getCanvas(); return $this; }
[ "public", "function", "setFormat", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "hasFactory", "(", "$", "name", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Invalid Canvas Factory \"%s\"'", ",", ...
Set canvas factory @param string $name factory's name @return \Jaguar\Canvas @throws \InvalidArgumentException
[ "Set", "canvas", "factory" ]
ddfe1e65838e86aea4e9cf36a588fe7dcf853576
https://github.com/hyyan/jaguar/blob/ddfe1e65838e86aea4e9cf36a588fe7dcf853576/src/Jaguar/Canvas.php#L66-L77
train
hyyan/jaguar
src/Jaguar/Canvas.php
Canvas.setFactory
public function setFactory(array $factories) { foreach ($factories as $name => $factory) { $this->addFactory($name, $factory); } return $this; }
php
public function setFactory(array $factories) { foreach ($factories as $name => $factory) { $this->addFactory($name, $factory); } return $this; }
[ "public", "function", "setFactory", "(", "array", "$", "factories", ")", "{", "foreach", "(", "$", "factories", "as", "$", "name", "=>", "$", "factory", ")", "{", "$", "this", "->", "addFactory", "(", "$", "name", ",", "$", "factory", ")", ";", "}", ...
Add array of factories @param array $factories @return \Jaguar\Canvas
[ "Add", "array", "of", "factories" ]
ddfe1e65838e86aea4e9cf36a588fe7dcf853576
https://github.com/hyyan/jaguar/blob/ddfe1e65838e86aea4e9cf36a588fe7dcf853576/src/Jaguar/Canvas.php#L131-L138
train
hyyan/jaguar
src/Jaguar/Canvas.php
Canvas.removeFactory
public function removeFactory($name) { if ($this->hasFactory($name)) { unset($this->factories[$name]); return true; } return false; }
php
public function removeFactory($name) { if ($this->hasFactory($name)) { unset($this->factories[$name]); return true; } return false; }
[ "public", "function", "removeFactory", "(", "$", "name", ")", "{", "if", "(", "$", "this", "->", "hasFactory", "(", "$", "name", ")", ")", "{", "unset", "(", "$", "this", "->", "factories", "[", "$", "name", "]", ")", ";", "return", "true", ";", ...
Remove factory by its name @param string $name factory name @return boolean true if removed false otherwise
[ "Remove", "factory", "by", "its", "name" ]
ddfe1e65838e86aea4e9cf36a588fe7dcf853576
https://github.com/hyyan/jaguar/blob/ddfe1e65838e86aea4e9cf36a588fe7dcf853576/src/Jaguar/Canvas.php#L163-L172
train
hyyan/jaguar
src/Jaguar/Canvas.php
Canvas.show
public function show() { try { header(sprintf('Content-Type: %s', $this->getMimeType(), true)); $this->save(null); } catch (\Exception $ex) { header(sprintf('Content-Type: text/html'), true); /* rethrow it */ throw $ex; } }
php
public function show() { try { header(sprintf('Content-Type: %s', $this->getMimeType(), true)); $this->save(null); } catch (\Exception $ex) { header(sprintf('Content-Type: text/html'), true); /* rethrow it */ throw $ex; } }
[ "public", "function", "show", "(", ")", "{", "try", "{", "header", "(", "sprintf", "(", "'Content-Type: %s'", ",", "$", "this", "->", "getMimeType", "(", ")", ",", "true", ")", ")", ";", "$", "this", "->", "save", "(", "null", ")", ";", "}", "catch...
Output raw canvas directly to the browser <b>Note : </b> The write header for every canvas Format will be send also
[ "Output", "raw", "canvas", "directly", "to", "the", "browser" ]
ddfe1e65838e86aea4e9cf36a588fe7dcf853576
https://github.com/hyyan/jaguar/blob/ddfe1e65838e86aea4e9cf36a588fe7dcf853576/src/Jaguar/Canvas.php#L223-L233
train
cpliakas/psolr
src/PSolr/Request/Update.php
Update.buildAttribute
public function buildAttribute($property) { $attribute = ''; if (isset($this->$property)) { $attribute .= ' ' . $property . '="'; if (is_bool($this->$property)) { $attribute .= ($this->$property) ? 'true' : 'false'; } else { $attribute .= SolrRequest::escapeXml($this->$property); } $attribute .= '"'; } return $attribute; }
php
public function buildAttribute($property) { $attribute = ''; if (isset($this->$property)) { $attribute .= ' ' . $property . '="'; if (is_bool($this->$property)) { $attribute .= ($this->$property) ? 'true' : 'false'; } else { $attribute .= SolrRequest::escapeXml($this->$property); } $attribute .= '"'; } return $attribute; }
[ "public", "function", "buildAttribute", "(", "$", "property", ")", "{", "$", "attribute", "=", "''", ";", "if", "(", "isset", "(", "$", "this", "->", "$", "property", ")", ")", "{", "$", "attribute", ".=", "' '", ".", "$", "property", ".", "'=\"'", ...
Builds an attribute from a class property if it is set. @param string $property @return string
[ "Builds", "an", "attribute", "from", "a", "class", "property", "if", "it", "is", "set", "." ]
43098fa346a706f481e7a1408664d4582f7ce675
https://github.com/cpliakas/psolr/blob/43098fa346a706f481e7a1408664d4582f7ce675/src/PSolr/Request/Update.php#L98-L111
train
PatternBuilder/pattern-builder-lib-php
src/Property/PropertyAbstract.php
PropertyAbstract.setPropertyDefaultValue
public function setPropertyDefaultValue($property) { if (isset($property->default)) { // Use the defined default. return true; } elseif (isset($property->enum) && count($property->enum) == 1) { // Set default to single enum. $property->default = reset($property->enum); return true; } return false; }
php
public function setPropertyDefaultValue($property) { if (isset($property->default)) { // Use the defined default. return true; } elseif (isset($property->enum) && count($property->enum) == 1) { // Set default to single enum. $property->default = reset($property->enum); return true; } return false; }
[ "public", "function", "setPropertyDefaultValue", "(", "$", "property", ")", "{", "if", "(", "isset", "(", "$", "property", "->", "default", ")", ")", "{", "// Use the defined default.", "return", "true", ";", "}", "elseif", "(", "isset", "(", "$", "property"...
Set the default value for the property schema. @param object $property The property JSON object. @return bool True if the default is set.
[ "Set", "the", "default", "value", "for", "the", "property", "schema", "." ]
6cdbb4e62a560e05b29ebfbd223581be2ace9176
https://github.com/PatternBuilder/pattern-builder-lib-php/blob/6cdbb4e62a560e05b29ebfbd223581be2ace9176/src/Property/PropertyAbstract.php#L101-L114
train
PatternBuilder/pattern-builder-lib-php
src/Property/PropertyAbstract.php
PropertyAbstract.prepareFactory
protected function prepareFactory() { if (empty($this->componentFactory) && isset($this->configuration)) { $this->componentFactory = new ComponentFactory($this->configuration); } }
php
protected function prepareFactory() { if (empty($this->componentFactory) && isset($this->configuration)) { $this->componentFactory = new ComponentFactory($this->configuration); } }
[ "protected", "function", "prepareFactory", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "componentFactory", ")", "&&", "isset", "(", "$", "this", "->", "configuration", ")", ")", "{", "$", "this", "->", "componentFactory", "=", "new", "Comp...
Prepare an instance of a component factory for usage.
[ "Prepare", "an", "instance", "of", "a", "component", "factory", "for", "usage", "." ]
6cdbb4e62a560e05b29ebfbd223581be2ace9176
https://github.com/PatternBuilder/pattern-builder-lib-php/blob/6cdbb4e62a560e05b29ebfbd223581be2ace9176/src/Property/PropertyAbstract.php#L157-L162
train
PatternBuilder/pattern-builder-lib-php
src/Property/PropertyAbstract.php
PropertyAbstract.getValidator
public function getValidator() { if (!isset($this->validator) && isset($this->configuration)) { // Initialize JSON validator. $resolver = $this->configuration->getResolver(); if ($resolver && ($retriever = $resolver->getUriRetriever())) { $check_mode = JsonSchema\Validator::CHECK_MODE_NORMAL; $this->validator = new JsonSchema\Validator($check_mode, $retriever); } } return $this->validator; }
php
public function getValidator() { if (!isset($this->validator) && isset($this->configuration)) { // Initialize JSON validator. $resolver = $this->configuration->getResolver(); if ($resolver && ($retriever = $resolver->getUriRetriever())) { $check_mode = JsonSchema\Validator::CHECK_MODE_NORMAL; $this->validator = new JsonSchema\Validator($check_mode, $retriever); } } return $this->validator; }
[ "public", "function", "getValidator", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "validator", ")", "&&", "isset", "(", "$", "this", "->", "configuration", ")", ")", "{", "// Initialize JSON validator.", "$", "resolver", "=", "$", "th...
Return an instance of the component configuration. @return Configuration
[ "Return", "an", "instance", "of", "the", "component", "configuration", "." ]
6cdbb4e62a560e05b29ebfbd223581be2ace9176
https://github.com/PatternBuilder/pattern-builder-lib-php/blob/6cdbb4e62a560e05b29ebfbd223581be2ace9176/src/Property/PropertyAbstract.php#L191-L203
train
PatternBuilder/pattern-builder-lib-php
src/Property/PropertyAbstract.php
PropertyAbstract.isEmpty
public function isEmpty($property_name = null) { $value = $this->get($property_name); return Inspector::isEmpty($value); }
php
public function isEmpty($property_name = null) { $value = $this->get($property_name); return Inspector::isEmpty($value); }
[ "public", "function", "isEmpty", "(", "$", "property_name", "=", "null", ")", "{", "$", "value", "=", "$", "this", "->", "get", "(", "$", "property_name", ")", ";", "return", "Inspector", "::", "isEmpty", "(", "$", "value", ")", ";", "}" ]
Determine if a given property contains data. @param string $property_name The property to check. @return bool true if empty, false otherwise.
[ "Determine", "if", "a", "given", "property", "contains", "data", "." ]
6cdbb4e62a560e05b29ebfbd223581be2ace9176
https://github.com/PatternBuilder/pattern-builder-lib-php/blob/6cdbb4e62a560e05b29ebfbd223581be2ace9176/src/Property/PropertyAbstract.php#L212-L217
train
laravie/profiler
src/Timer.php
Timer.endIf
public function endIf(bool $condition, ?callable $callback = null): void { if ((bool) $condition) { $this->end($callback); } }
php
public function endIf(bool $condition, ?callable $callback = null): void { if ((bool) $condition) { $this->end($callback); } }
[ "public", "function", "endIf", "(", "bool", "$", "condition", ",", "?", "callable", "$", "callback", "=", "null", ")", ":", "void", "{", "if", "(", "(", "bool", ")", "$", "condition", ")", "{", "$", "this", "->", "end", "(", "$", "callback", ")", ...
End the timer if condition is matched. @param bool $condition @param callable|null $callback @return void
[ "End", "the", "timer", "if", "condition", "is", "matched", "." ]
1528727352fb847ecfba5d274a3a1c9fc42df640
https://github.com/laravie/profiler/blob/1528727352fb847ecfba5d274a3a1c9fc42df640/src/Timer.php#L85-L90
train
laravie/profiler
src/Timer.php
Timer.endUnless
public function endUnless(bool $condition, ?callable $callback = null): void { $this->endIf(! $condition, $callback); }
php
public function endUnless(bool $condition, ?callable $callback = null): void { $this->endIf(! $condition, $callback); }
[ "public", "function", "endUnless", "(", "bool", "$", "condition", ",", "?", "callable", "$", "callback", "=", "null", ")", ":", "void", "{", "$", "this", "->", "endIf", "(", "!", "$", "condition", ",", "$", "callback", ")", ";", "}" ]
End the timer unless condition is matched. @param bool $condition @param callable|null $callback @return void
[ "End", "the", "timer", "unless", "condition", "is", "matched", "." ]
1528727352fb847ecfba5d274a3a1c9fc42df640
https://github.com/laravie/profiler/blob/1528727352fb847ecfba5d274a3a1c9fc42df640/src/Timer.php#L100-L103
train
mvccore/mvccore
src/MvcCore/Config/IniRead.php
IniRead.&
protected function & iniReadFilterEnvironmentSections (array & $rawIniData, $environment) { $iniData = []; foreach ($rawIniData as $keyOrSectionName => $valueOrSectionValues) { if (is_array($valueOrSectionValues)) { if (strpos($keyOrSectionName, '>') !== FALSE) { list($envNamesStrLocal, $keyOrSectionName) = explode('>', str_replace(' ', '', $keyOrSectionName)); if (!in_array($environment, explode(',', $envNamesStrLocal))) continue; } $sectionValues = []; foreach ($valueOrSectionValues as $key => $value) $sectionValues[$keyOrSectionName.'.'.$key] = $value; $iniData = array_merge($iniData, $sectionValues); } else { $iniData[$keyOrSectionName] = $valueOrSectionValues; } } return $iniData; }
php
protected function & iniReadFilterEnvironmentSections (array & $rawIniData, $environment) { $iniData = []; foreach ($rawIniData as $keyOrSectionName => $valueOrSectionValues) { if (is_array($valueOrSectionValues)) { if (strpos($keyOrSectionName, '>') !== FALSE) { list($envNamesStrLocal, $keyOrSectionName) = explode('>', str_replace(' ', '', $keyOrSectionName)); if (!in_array($environment, explode(',', $envNamesStrLocal))) continue; } $sectionValues = []; foreach ($valueOrSectionValues as $key => $value) $sectionValues[$keyOrSectionName.'.'.$key] = $value; $iniData = array_merge($iniData, $sectionValues); } else { $iniData[$keyOrSectionName] = $valueOrSectionValues; } } return $iniData; }
[ "protected", "function", "&", "iniReadFilterEnvironmentSections", "(", "array", "&", "$", "rawIniData", ",", "$", "environment", ")", "{", "$", "iniData", "=", "[", "]", ";", "foreach", "(", "$", "rawIniData", "as", "$", "keyOrSectionName", "=>", "$", "value...
Align all raw INI data to single level array, filtered for only current environment data items. @param array $rawIniData @param string $environment @return array
[ "Align", "all", "raw", "INI", "data", "to", "single", "level", "array", "filtered", "for", "only", "current", "environment", "data", "items", "." ]
5e580a2803bbccea8168316c4c6b963e1910e0bf
https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Config/IniRead.php#L77-L93
train
mvccore/mvccore
src/MvcCore/Config/IniRead.php
IniRead.iniReadExpandLevelsAndReType
protected function iniReadExpandLevelsAndReType (array & $iniData) { //$this->objectTypes[''] = [0, & $this->data]; $oldIniScannerMode = $this->_iniScannerMode === 1; foreach ($iniData as $rawKey => $rawValue) { $current = & $this->data; // prepare keys to build levels and configure stdClass/array types $rawKeys = []; $lastRawKey = $rawKey; $lastDotPos = strrpos($rawKey, '.'); if ($lastDotPos !== FALSE) { $rawKeys = explode('.', substr($rawKey, 0, $lastDotPos)); $lastRawKey = substr($rawKey, $lastDotPos + 1); } // prepare levels structure and configure stdClass or array type change where necessary $levelKey = ''; $prevLevelKey = ''; foreach ($rawKeys as $key) { $prevLevelKey = $levelKey; $levelKey .= ($levelKey ? '.' : '') . $key; if (!isset($current[$key])) { $current[$key] = []; $this->objectTypes[$levelKey] = [1, & $current[$key]]; // object type switch -> object by default if (is_numeric($key) && isset($this->objectTypes[$prevLevelKey])) { $this->objectTypes[$prevLevelKey][0] = 0; // object type switch -> set array if it was object } } $current = & $current[$key]; } // set up value into levels structure and configure type into array if necessary if ($oldIniScannerMode) { $typedValue = $this->getTypedValue($rawValue); } else { $typedValue = $rawValue; } if (isset($current[$lastRawKey])) { $current[$lastRawKey][] = $typedValue; $this->objectTypes[$levelKey ? $levelKey : $lastRawKey][0] = 0; // object type switch -> set array } else { if (!is_array($current)) { $current = [$current]; $this->objectTypes[$levelKey] = [0, & $current]; // object type switch -> set array } $current[$lastRawKey] = $typedValue; if (is_numeric($lastRawKey)) $this->objectTypes[$levelKey][0] = 0; // object type switch -> set array } } }
php
protected function iniReadExpandLevelsAndReType (array & $iniData) { //$this->objectTypes[''] = [0, & $this->data]; $oldIniScannerMode = $this->_iniScannerMode === 1; foreach ($iniData as $rawKey => $rawValue) { $current = & $this->data; // prepare keys to build levels and configure stdClass/array types $rawKeys = []; $lastRawKey = $rawKey; $lastDotPos = strrpos($rawKey, '.'); if ($lastDotPos !== FALSE) { $rawKeys = explode('.', substr($rawKey, 0, $lastDotPos)); $lastRawKey = substr($rawKey, $lastDotPos + 1); } // prepare levels structure and configure stdClass or array type change where necessary $levelKey = ''; $prevLevelKey = ''; foreach ($rawKeys as $key) { $prevLevelKey = $levelKey; $levelKey .= ($levelKey ? '.' : '') . $key; if (!isset($current[$key])) { $current[$key] = []; $this->objectTypes[$levelKey] = [1, & $current[$key]]; // object type switch -> object by default if (is_numeric($key) && isset($this->objectTypes[$prevLevelKey])) { $this->objectTypes[$prevLevelKey][0] = 0; // object type switch -> set array if it was object } } $current = & $current[$key]; } // set up value into levels structure and configure type into array if necessary if ($oldIniScannerMode) { $typedValue = $this->getTypedValue($rawValue); } else { $typedValue = $rawValue; } if (isset($current[$lastRawKey])) { $current[$lastRawKey][] = $typedValue; $this->objectTypes[$levelKey ? $levelKey : $lastRawKey][0] = 0; // object type switch -> set array } else { if (!is_array($current)) { $current = [$current]; $this->objectTypes[$levelKey] = [0, & $current]; // object type switch -> set array } $current[$lastRawKey] = $typedValue; if (is_numeric($lastRawKey)) $this->objectTypes[$levelKey][0] = 0; // object type switch -> set array } } }
[ "protected", "function", "iniReadExpandLevelsAndReType", "(", "array", "&", "$", "iniData", ")", "{", "//$this->objectTypes[''] = [0, & $this->data];", "$", "oldIniScannerMode", "=", "$", "this", "->", "_iniScannerMode", "===", "1", ";", "foreach", "(", "$", "iniData"...
Process single level array with dotted keys into tree structure and complete object type switches about tree records to complete journal about final `\stdClass`es or `array`s types. @param array $iniData @return void
[ "Process", "single", "level", "array", "with", "dotted", "keys", "into", "tree", "structure", "and", "complete", "object", "type", "switches", "about", "tree", "records", "to", "complete", "journal", "about", "final", "\\", "stdClass", "es", "or", "array", "s"...
5e580a2803bbccea8168316c4c6b963e1910e0bf
https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Config/IniRead.php#L102-L148
train
mvccore/mvccore
src/MvcCore/Config/IniRead.php
IniRead.getTypedValue
protected function getTypedValue ($rawValue) { if (gettype($rawValue) == "array") { foreach ($rawValue as $key => $value) { $rawValue[$key] = $this->getTypedValue($value); } return $rawValue; // array } else if (mb_strlen($rawValue) > 0) { if (is_numeric($rawValue)) { return $this->getTypedValueFloatOrInt($rawValue); } else { return $this->getTypedSpecialValueOrString($rawValue); } } else { return $this->getTypedSpecialValueOrString($rawValue); } }
php
protected function getTypedValue ($rawValue) { if (gettype($rawValue) == "array") { foreach ($rawValue as $key => $value) { $rawValue[$key] = $this->getTypedValue($value); } return $rawValue; // array } else if (mb_strlen($rawValue) > 0) { if (is_numeric($rawValue)) { return $this->getTypedValueFloatOrInt($rawValue); } else { return $this->getTypedSpecialValueOrString($rawValue); } } else { return $this->getTypedSpecialValueOrString($rawValue); } }
[ "protected", "function", "getTypedValue", "(", "$", "rawValue", ")", "{", "if", "(", "gettype", "(", "$", "rawValue", ")", "==", "\"array\"", ")", "{", "foreach", "(", "$", "rawValue", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "rawValue", ...
Retype raw INI value into `array` with retyped it's own values or retype raw INI value into `float`, `int` or `string`. @param string|array $rawValue @return array|float|int|string
[ "Retype", "raw", "INI", "value", "into", "array", "with", "retyped", "it", "s", "own", "values", "or", "retype", "raw", "INI", "value", "into", "float", "int", "or", "string", "." ]
5e580a2803bbccea8168316c4c6b963e1910e0bf
https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Config/IniRead.php#L156-L171
train
mvccore/mvccore
src/MvcCore/Config/IniRead.php
IniRead.getTypedValueFloatOrInt
protected function getTypedValueFloatOrInt ($rawValue) { if (strpos($rawValue, '.') !== FALSE || strpos($rawValue, 'e') !== FALSE || strpos($rawValue, 'E') !== FALSE) { return floatval($rawValue); // float } else { // int or string if integer is too high (more then PHP max/min: 2147483647/-2147483647) $intVal = intval($rawValue); return (string) $intVal === $rawValue ? $intVal : $rawValue; } }
php
protected function getTypedValueFloatOrInt ($rawValue) { if (strpos($rawValue, '.') !== FALSE || strpos($rawValue, 'e') !== FALSE || strpos($rawValue, 'E') !== FALSE) { return floatval($rawValue); // float } else { // int or string if integer is too high (more then PHP max/min: 2147483647/-2147483647) $intVal = intval($rawValue); return (string) $intVal === $rawValue ? $intVal : $rawValue; } }
[ "protected", "function", "getTypedValueFloatOrInt", "(", "$", "rawValue", ")", "{", "if", "(", "strpos", "(", "$", "rawValue", ",", "'.'", ")", "!==", "FALSE", "||", "strpos", "(", "$", "rawValue", ",", "'e'", ")", "!==", "FALSE", "||", "strpos", "(", ...
Retype raw INI value into `float` or `int`. @param string $rawValue @return float|int|string
[ "Retype", "raw", "INI", "value", "into", "float", "or", "int", "." ]
5e580a2803bbccea8168316c4c6b963e1910e0bf
https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Config/IniRead.php#L178-L188
train
mvccore/mvccore
src/MvcCore/Config/IniRead.php
IniRead.getTypedSpecialValueOrString
protected function getTypedSpecialValueOrString ($rawValue) { $lowerRawValue = strtolower($rawValue); if (isset(static::$specialValues[$lowerRawValue])) { return static::$specialValues[$lowerRawValue]; // bool or null } else { return trim($rawValue); // string } }
php
protected function getTypedSpecialValueOrString ($rawValue) { $lowerRawValue = strtolower($rawValue); if (isset(static::$specialValues[$lowerRawValue])) { return static::$specialValues[$lowerRawValue]; // bool or null } else { return trim($rawValue); // string } }
[ "protected", "function", "getTypedSpecialValueOrString", "(", "$", "rawValue", ")", "{", "$", "lowerRawValue", "=", "strtolower", "(", "$", "rawValue", ")", ";", "if", "(", "isset", "(", "static", "::", "$", "specialValues", "[", "$", "lowerRawValue", "]", "...
Retype raw INI value into `bool`, `NULL` or `string`. @param string $rawValue @return bool|NULL|string
[ "Retype", "raw", "INI", "value", "into", "bool", "NULL", "or", "string", "." ]
5e580a2803bbccea8168316c4c6b963e1910e0bf
https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Config/IniRead.php#L195-L202
train
mvccore/mvccore
src/MvcCore/Session/Starting.php
Starting.GetStarted
public static function GetStarted () { if (static::$started === NULL) { $req = self::$req ?: self::$req = & \MvcCore\Application::GetInstance()->GetRequest(); if (!$req->IsCli()) { $alreadyStarted = session_status() === PHP_SESSION_ACTIVE && session_id() !== ''; if ($alreadyStarted) { // if already started but `static::$started` property is `NULL`: static::$sessionStartTime = time(); static::$sessionMaxTime = static::$sessionStartTime; static::setUpMeta(); static::setUpData(); } static::$started = $alreadyStarted; } } return static::$started; }
php
public static function GetStarted () { if (static::$started === NULL) { $req = self::$req ?: self::$req = & \MvcCore\Application::GetInstance()->GetRequest(); if (!$req->IsCli()) { $alreadyStarted = session_status() === PHP_SESSION_ACTIVE && session_id() !== ''; if ($alreadyStarted) { // if already started but `static::$started` property is `NULL`: static::$sessionStartTime = time(); static::$sessionMaxTime = static::$sessionStartTime; static::setUpMeta(); static::setUpData(); } static::$started = $alreadyStarted; } } return static::$started; }
[ "public", "static", "function", "GetStarted", "(", ")", "{", "if", "(", "static", "::", "$", "started", "===", "NULL", ")", "{", "$", "req", "=", "self", "::", "$", "req", "?", ":", "self", "::", "$", "req", "=", "&", "\\", "MvcCore", "\\", "Appl...
Get static boolean about if session has been already started or not. @return bool
[ "Get", "static", "boolean", "about", "if", "session", "has", "been", "already", "started", "or", "not", "." ]
5e580a2803bbccea8168316c4c6b963e1910e0bf
https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Session/Starting.php#L50-L66
train
hyyan/jaguar
src/Jaguar/Box.php
Box.scale
public function scale($ratio) { $this->getDimension() ->setWidth( round($ratio * $this->getDimension()->getWidth()) )->setHeight( round($ratio * $this->getDimension()->getHeight()) ); return $this; }
php
public function scale($ratio) { $this->getDimension() ->setWidth( round($ratio * $this->getDimension()->getWidth()) )->setHeight( round($ratio * $this->getDimension()->getHeight()) ); return $this; }
[ "public", "function", "scale", "(", "$", "ratio", ")", "{", "$", "this", "->", "getDimension", "(", ")", "->", "setWidth", "(", "round", "(", "$", "ratio", "*", "$", "this", "->", "getDimension", "(", ")", "->", "getWidth", "(", ")", ")", ")", "->"...
Scale the box by the given ratio @param number $ratio @return \Jaguar\Box
[ "Scale", "the", "box", "by", "the", "given", "ratio" ]
ddfe1e65838e86aea4e9cf36a588fe7dcf853576
https://github.com/hyyan/jaguar/blob/ddfe1e65838e86aea4e9cf36a588fe7dcf853576/src/Jaguar/Box.php#L88-L98
train
mvccore/mvccore
src/MvcCore/Controller/Dispatching.php
Dispatching.Init
public function Init () { if ($this->dispatchState > 0) return; self::$allControllers[spl_object_hash($this)] = & $this; if ($this->parentController === NULL && !$this->request->IsCli()) { if ($this->autoStartSession) $this->application->SessionStart(); $responseContentType = $this->ajax ? 'text/javascript' : 'text/html'; $this->response->SetHeader('Content-Type', $responseContentType); } if ($this->autoInitProperties) $this->processAutoInitProperties(); foreach ($this->childControllers as $controller) { $controller->Init(); if ($controller->dispatchState == 5) break; } if ($this->dispatchState === 0) $this->dispatchState = 1; }
php
public function Init () { if ($this->dispatchState > 0) return; self::$allControllers[spl_object_hash($this)] = & $this; if ($this->parentController === NULL && !$this->request->IsCli()) { if ($this->autoStartSession) $this->application->SessionStart(); $responseContentType = $this->ajax ? 'text/javascript' : 'text/html'; $this->response->SetHeader('Content-Type', $responseContentType); } if ($this->autoInitProperties) $this->processAutoInitProperties(); foreach ($this->childControllers as $controller) { $controller->Init(); if ($controller->dispatchState == 5) break; } if ($this->dispatchState === 0) $this->dispatchState = 1; }
[ "public", "function", "Init", "(", ")", "{", "if", "(", "$", "this", "->", "dispatchState", ">", "0", ")", "return", ";", "self", "::", "$", "allControllers", "[", "spl_object_hash", "(", "$", "this", ")", "]", "=", "&", "$", "this", ";", "if", "("...
Application controllers initialization. This is best time to initialize language, locale, session etc. There is also called auto initialization processing - instance creation on each controller class member implementing `\MvcCore\IController` and marked in doc comments as `@autoinit`. then there is of course called `\MvcCore\Controller::Init();` method on each automatically created sub-controller. @return void
[ "Application", "controllers", "initialization", ".", "This", "is", "best", "time", "to", "initialize", "language", "locale", "session", "etc", ".", "There", "is", "also", "called", "auto", "initialization", "processing", "-", "instance", "creation", "on", "each", ...
5e580a2803bbccea8168316c4c6b963e1910e0bf
https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Controller/Dispatching.php#L137-L154
train
mvccore/mvccore
src/MvcCore/Controller/Dispatching.php
Dispatching.processAutoInitProperties
protected function processAutoInitProperties () { $type = new \ReflectionClass($this); /** @var $props \ReflectionProperty[] */ $props = $type->getProperties( \ReflectionProperty::IS_PUBLIC | \ReflectionProperty::IS_PROTECTED | \ReflectionProperty::IS_PRIVATE ); $toolsClass = $this->application->GetToolClass(); foreach ($props as $prop) { $docComment = $prop->getDocComment(); if (mb_strpos($docComment, '@autoinit') === FALSE) continue; $propName = $prop->getName(); $methodName = 'create' . ucfirst($propName); $hasMethod = $type->hasMethod($methodName); if (!$hasMethod) { $methodName = '_'.$methodName; $hasMethod = $type->hasMethod($methodName); } if ($hasMethod) { $method = $type->getMethod($methodName); if (!$method->isPublic()) $method->setAccessible(TRUE); $instance = $method->invoke($this); $implementsController = $instance instanceof \MvcCore\IController; } else { $pos = mb_strpos($docComment, '@var '); if ($pos === FALSE) continue; $docComment = str_replace(["\r","\n","\t", "*/"], " ", mb_substr($docComment, $pos + 5)); $pos = mb_strpos($docComment, ' '); if ($pos === FALSE) continue; $className = trim(mb_substr($docComment, 0, $pos)); if (!@class_exists($className)) { $className = $prop->getDeclaringClass()->getNamespaceName() . '\\' . $className; if (!@class_exists($className)) continue; } $implementsController = $toolsClass::CheckClassInterface( $className, 'MvcCore\IController', FALSE, FALSE ); if ($implementsController) { $instance = $className::CreateInstance(); } else { $instance = new $className(); } } if ($implementsController) $this->AddChildController($instance, $propName); if (!$prop->isPublic()) $prop->setAccessible(TRUE); $prop->setValue($this, $instance); } }
php
protected function processAutoInitProperties () { $type = new \ReflectionClass($this); /** @var $props \ReflectionProperty[] */ $props = $type->getProperties( \ReflectionProperty::IS_PUBLIC | \ReflectionProperty::IS_PROTECTED | \ReflectionProperty::IS_PRIVATE ); $toolsClass = $this->application->GetToolClass(); foreach ($props as $prop) { $docComment = $prop->getDocComment(); if (mb_strpos($docComment, '@autoinit') === FALSE) continue; $propName = $prop->getName(); $methodName = 'create' . ucfirst($propName); $hasMethod = $type->hasMethod($methodName); if (!$hasMethod) { $methodName = '_'.$methodName; $hasMethod = $type->hasMethod($methodName); } if ($hasMethod) { $method = $type->getMethod($methodName); if (!$method->isPublic()) $method->setAccessible(TRUE); $instance = $method->invoke($this); $implementsController = $instance instanceof \MvcCore\IController; } else { $pos = mb_strpos($docComment, '@var '); if ($pos === FALSE) continue; $docComment = str_replace(["\r","\n","\t", "*/"], " ", mb_substr($docComment, $pos + 5)); $pos = mb_strpos($docComment, ' '); if ($pos === FALSE) continue; $className = trim(mb_substr($docComment, 0, $pos)); if (!@class_exists($className)) { $className = $prop->getDeclaringClass()->getNamespaceName() . '\\' . $className; if (!@class_exists($className)) continue; } $implementsController = $toolsClass::CheckClassInterface( $className, 'MvcCore\IController', FALSE, FALSE ); if ($implementsController) { $instance = $className::CreateInstance(); } else { $instance = new $className(); } } if ($implementsController) $this->AddChildController($instance, $propName); if (!$prop->isPublic()) $prop->setAccessible(TRUE); $prop->setValue($this, $instance); } }
[ "protected", "function", "processAutoInitProperties", "(", ")", "{", "$", "type", "=", "new", "\\", "ReflectionClass", "(", "$", "this", ")", ";", "/** @var $props \\ReflectionProperty[] */", "$", "props", "=", "$", "type", "->", "getProperties", "(", "\\", "Ref...
Initialize all members implementing `\MvcCore\IController` marked in doc comments as `@autoinit` into `\MvcCore\Controller::$controllers` array and into member property itself. This method is always called inside `\MvcCore\Controller::Init();` method, after session has been started. Create every new instance by calling existing method named as `[_]create<PascalCasePropertyName>` and returning new instance or by doc comment type defined by `@var` over static method `$ClassName::CreateInstance()`. @return void
[ "Initialize", "all", "members", "implementing", "\\", "MvcCore", "\\", "IController", "marked", "in", "doc", "comments", "as" ]
5e580a2803bbccea8168316c4c6b963e1910e0bf
https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Controller/Dispatching.php#L166-L215
train
mvccore/mvccore
src/MvcCore/Controller/Dispatching.php
Dispatching.AssetAction
public function AssetAction () { $ext = ''; $path = $this->GetParam('path', 'a-zA-Z0-9_\-\/\.'); $path = '/' . ltrim(str_replace('..', '', $path), '/'); if ( strpos($path, static::$staticPath) !== 0 && strpos($path, static::$tmpPath) !== 0 ) { throw new \ErrorException("[".get_class($this)."] File path: '$path' is not allowed.", 500); } $path = $this->request->GetAppRoot() . $path; if (!file_exists($path)) { throw new \ErrorException("[".get_class($this)."] File not found: '$path'.", 404); } $lastDotPos = strrpos($path, '.'); if ($lastDotPos !== FALSE) { $ext = substr($path, $lastDotPos + 1); } if (isset(self::$_assetsMimeTypes[$ext])) { header('Content-Type: ' . self::$_assetsMimeTypes[$ext]); } header_remove('X-Powered-By'); header('Vary: Accept-Encoding'); $assetMTime = @filemtime($path); if ($assetMTime) header('Last-Modified: ' . gmdate('D, d M Y H:i:s T', $assetMTime)); readfile($path); exit; }
php
public function AssetAction () { $ext = ''; $path = $this->GetParam('path', 'a-zA-Z0-9_\-\/\.'); $path = '/' . ltrim(str_replace('..', '', $path), '/'); if ( strpos($path, static::$staticPath) !== 0 && strpos($path, static::$tmpPath) !== 0 ) { throw new \ErrorException("[".get_class($this)."] File path: '$path' is not allowed.", 500); } $path = $this->request->GetAppRoot() . $path; if (!file_exists($path)) { throw new \ErrorException("[".get_class($this)."] File not found: '$path'.", 404); } $lastDotPos = strrpos($path, '.'); if ($lastDotPos !== FALSE) { $ext = substr($path, $lastDotPos + 1); } if (isset(self::$_assetsMimeTypes[$ext])) { header('Content-Type: ' . self::$_assetsMimeTypes[$ext]); } header_remove('X-Powered-By'); header('Vary: Accept-Encoding'); $assetMTime = @filemtime($path); if ($assetMTime) header('Last-Modified: ' . gmdate('D, d M Y H:i:s T', $assetMTime)); readfile($path); exit; }
[ "public", "function", "AssetAction", "(", ")", "{", "$", "ext", "=", "''", ";", "$", "path", "=", "$", "this", "->", "GetParam", "(", "'path'", ",", "'a-zA-Z0-9_\\-\\/\\.'", ")", ";", "$", "path", "=", "'/'", ".", "ltrim", "(", "str_replace", "(", "'...
Return small assets content with proper headers in single file application mode and immediately exit. @throws \Exception If file path is not allowed (500) or file not found (404). @return void
[ "Return", "small", "assets", "content", "with", "proper", "headers", "in", "single", "file", "application", "mode", "and", "immediately", "exit", "." ]
5e580a2803bbccea8168316c4c6b963e1910e0bf
https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Controller/Dispatching.php#L329-L356
train
htmlburger/wpemerge-theme-core
src/Theme/Theme.php
Theme.bootstrapApplication
protected function bootstrapApplication( $config ) { if ( ! isset( $config['providers'] ) ) { $config['providers'] = []; } $config['providers'] = array_merge( $config['providers'], $this->service_providers ); Application::bootstrap( $config ); }
php
protected function bootstrapApplication( $config ) { if ( ! isset( $config['providers'] ) ) { $config['providers'] = []; } $config['providers'] = array_merge( $config['providers'], $this->service_providers ); Application::bootstrap( $config ); }
[ "protected", "function", "bootstrapApplication", "(", "$", "config", ")", "{", "if", "(", "!", "isset", "(", "$", "config", "[", "'providers'", "]", ")", ")", "{", "$", "config", "[", "'providers'", "]", "=", "[", "]", ";", "}", "$", "config", "[", ...
Bootstrap WPEmerge. @param array $config @return void
[ "Bootstrap", "WPEmerge", "." ]
2e8532c9e9b4b7173476c1a11ca645a74895d0b5
https://github.com/htmlburger/wpemerge-theme-core/blob/2e8532c9e9b4b7173476c1a11ca645a74895d0b5/src/Theme/Theme.php#L54-L65
train
htmlburger/wpemerge-theme-core
src/Theme/Theme.php
Theme.bootstrap
public function bootstrap( $config = [] ) { if ( $this->isBootstrapped() ) { throw new ConfigurationException( static::class . ' already bootstrapped.' ); } $this->bootstrapped = true; $this->bootstrapApplication( $config ); }
php
public function bootstrap( $config = [] ) { if ( $this->isBootstrapped() ) { throw new ConfigurationException( static::class . ' already bootstrapped.' ); } $this->bootstrapped = true; $this->bootstrapApplication( $config ); }
[ "public", "function", "bootstrap", "(", "$", "config", "=", "[", "]", ")", "{", "if", "(", "$", "this", "->", "isBootstrapped", "(", ")", ")", "{", "throw", "new", "ConfigurationException", "(", "static", "::", "class", ".", "' already bootstrapped.'", ")"...
Bootstrap the theme. @param array $config @return void
[ "Bootstrap", "the", "theme", "." ]
2e8532c9e9b4b7173476c1a11ca645a74895d0b5
https://github.com/htmlburger/wpemerge-theme-core/blob/2e8532c9e9b4b7173476c1a11ca645a74895d0b5/src/Theme/Theme.php#L73-L80
train
mvccore/mvccore
src/MvcCore/Config/Environment.php
Environment.EnvironmentDetectByIps
public static function EnvironmentDetectByIps () { if (static::$environment === NULL) { $request = & \MvcCore\Application::GetInstance()->GetRequest(); $serverAddress = $request->GetServerIp(); $remoteAddress = $request->GetClientIp(); if ($serverAddress == $remoteAddress) { static::$environment = static::ENVIRONMENT_DEVELOPMENT; } else { static::$environment = static::ENVIRONMENT_PRODUCTION; } } return static::$environment; }
php
public static function EnvironmentDetectByIps () { if (static::$environment === NULL) { $request = & \MvcCore\Application::GetInstance()->GetRequest(); $serverAddress = $request->GetServerIp(); $remoteAddress = $request->GetClientIp(); if ($serverAddress == $remoteAddress) { static::$environment = static::ENVIRONMENT_DEVELOPMENT; } else { static::$environment = static::ENVIRONMENT_PRODUCTION; } } return static::$environment; }
[ "public", "static", "function", "EnvironmentDetectByIps", "(", ")", "{", "if", "(", "static", "::", "$", "environment", "===", "NULL", ")", "{", "$", "request", "=", "&", "\\", "MvcCore", "\\", "Application", "::", "GetInstance", "(", ")", "->", "GetReques...
First environment value setup - by server and client IP address. @return string Detected environment string.
[ "First", "environment", "value", "setup", "-", "by", "server", "and", "client", "IP", "address", "." ]
5e580a2803bbccea8168316c4c6b963e1910e0bf
https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Config/Environment.php#L97-L109
train
mvccore/mvccore
src/MvcCore/Config/Environment.php
Environment.EnvironmentDetectBySystemConfig
public static function EnvironmentDetectBySystemConfig (array $environmentsSectionData = []) { $environment = NULL; $app = self::$app ?: self::$app = & \MvcCore\Application::GetInstance(); $request = $app->GetRequest(); $clientIp = NULL; $serverHostName = NULL; $serverGlobals = NULL; foreach ((array) $environmentsSectionData as $environmentName => $environmentSection) { $sectionData = static::envDetectParseSysConfigEnvSectionData($environmentSection); $detected = static::envDetectBySystemConfigEnvSection( $sectionData, $request, $clientIp, $serverHostName, $serverGlobals ); if ($detected) { $environment = $environmentName; break; } } if ($environment && !static::$environment) { static::SetEnvironment($environment); } else if (!static::$environment) { static::SetEnvironment('production'); } return static::$environment; }
php
public static function EnvironmentDetectBySystemConfig (array $environmentsSectionData = []) { $environment = NULL; $app = self::$app ?: self::$app = & \MvcCore\Application::GetInstance(); $request = $app->GetRequest(); $clientIp = NULL; $serverHostName = NULL; $serverGlobals = NULL; foreach ((array) $environmentsSectionData as $environmentName => $environmentSection) { $sectionData = static::envDetectParseSysConfigEnvSectionData($environmentSection); $detected = static::envDetectBySystemConfigEnvSection( $sectionData, $request, $clientIp, $serverHostName, $serverGlobals ); if ($detected) { $environment = $environmentName; break; } } if ($environment && !static::$environment) { static::SetEnvironment($environment); } else if (!static::$environment) { static::SetEnvironment('production'); } return static::$environment; }
[ "public", "static", "function", "EnvironmentDetectBySystemConfig", "(", "array", "$", "environmentsSectionData", "=", "[", "]", ")", "{", "$", "environment", "=", "NULL", ";", "$", "app", "=", "self", "::", "$", "app", "?", ":", "self", "::", "$", "app", ...
Second environment value setup - by system config data environment record. @param array $environmentsSectionData System config environment section data part. @return string Detected environment string.
[ "Second", "environment", "value", "setup", "-", "by", "system", "config", "data", "environment", "record", "." ]
5e580a2803bbccea8168316c4c6b963e1910e0bf
https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Config/Environment.php#L116-L139
train
mvccore/mvccore
src/MvcCore/Config/Environment.php
Environment.envDetectParseSysConfigEnvSectionData
protected static function envDetectParseSysConfigEnvSectionData ($environmentSection) { $data = (object) [ 'clientIps' => (object) [ 'check' => FALSE, 'values' => [], 'regExeps' => [] ], 'serverHostNames' => (object) [ 'check' => FALSE, 'values' => [], 'regExeps' => [] ], 'serverVariables' => (object) [ 'check' => FALSE, 'existence' => [], 'values' => [], 'regExeps' => [] ] ]; if (is_string($environmentSection) && strlen($environmentSection) > 0) { // if there is only string provided, value is probably only // about the most and simple way - to describe client IPS: static::envDetectParseSysConfigClientIps($data, $environmentSection); } else if (is_array($environmentSection) || $environmentSection instanceof \stdClass) { foreach ((array) $environmentSection as $key => $value) { if (is_numeric($key) || $key == 'clients') { // if key is only numeric key provided, value is probably // only one regular expression to match client IP or // the strings list with the most and simple way - to describe client IPS: // of if key has `clients` value, there could be list of clients IPs // or list of clients IPs regular expressions static::envDetectParseSysConfigClientIps($data, $value); } else if ($key == 'servers') { // if key is `servers`, there could be string with single regular // expression to match hostname or string with comma separated hostnames // or list with hostnames and hostname regular expressions static::envDetectParseSysConfigServerNames($data, $value); } else if ($key == 'variables') { // if key is `variables`, there could be string with `$_SERVER` variable // names to check if they exists or key => value object with variable // name and value, which could be also regular expression to match static::envDetectParseSysConfigVariables($data, $value); } } } return $data; }
php
protected static function envDetectParseSysConfigEnvSectionData ($environmentSection) { $data = (object) [ 'clientIps' => (object) [ 'check' => FALSE, 'values' => [], 'regExeps' => [] ], 'serverHostNames' => (object) [ 'check' => FALSE, 'values' => [], 'regExeps' => [] ], 'serverVariables' => (object) [ 'check' => FALSE, 'existence' => [], 'values' => [], 'regExeps' => [] ] ]; if (is_string($environmentSection) && strlen($environmentSection) > 0) { // if there is only string provided, value is probably only // about the most and simple way - to describe client IPS: static::envDetectParseSysConfigClientIps($data, $environmentSection); } else if (is_array($environmentSection) || $environmentSection instanceof \stdClass) { foreach ((array) $environmentSection as $key => $value) { if (is_numeric($key) || $key == 'clients') { // if key is only numeric key provided, value is probably // only one regular expression to match client IP or // the strings list with the most and simple way - to describe client IPS: // of if key has `clients` value, there could be list of clients IPs // or list of clients IPs regular expressions static::envDetectParseSysConfigClientIps($data, $value); } else if ($key == 'servers') { // if key is `servers`, there could be string with single regular // expression to match hostname or string with comma separated hostnames // or list with hostnames and hostname regular expressions static::envDetectParseSysConfigServerNames($data, $value); } else if ($key == 'variables') { // if key is `variables`, there could be string with `$_SERVER` variable // names to check if they exists or key => value object with variable // name and value, which could be also regular expression to match static::envDetectParseSysConfigVariables($data, $value); } } } return $data; }
[ "protected", "static", "function", "envDetectParseSysConfigEnvSectionData", "(", "$", "environmentSection", ")", "{", "$", "data", "=", "(", "object", ")", "[", "'clientIps'", "=>", "(", "object", ")", "[", "'check'", "=>", "FALSE", ",", "'values'", "=>", "[",...
Parse system config environment section data from various declarations into specific detection structure. @param mixed $environmentSection @return \stdClass
[ "Parse", "system", "config", "environment", "section", "data", "from", "various", "declarations", "into", "specific", "detection", "structure", "." ]
5e580a2803bbccea8168316c4c6b963e1910e0bf
https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Config/Environment.php#L147-L193
train
mvccore/mvccore
src/MvcCore/Config/Environment.php
Environment.envDetectParseSysConfigClientIps
protected static function envDetectParseSysConfigClientIps (& $data, $rawClientIps) { $data->clientIps->check = TRUE; if (is_string($rawClientIps)) { if (substr($rawClientIps, 0, 1) == '/') { $data->clientIps->regExeps[] = $rawClientIps; } else { $data->clientIps->values = array_merge( $data->clientIps->values, explode(',', str_replace(' ', '', $rawClientIps)) ); } } else if (is_array($rawClientIps) || $rawClientIps instanceof \stdClass) { foreach ((array) $rawClientIps as $rawClientIpsItem) { if (substr($rawClientIpsItem, 0, 1) == '/') { $data->clientIps->regExeps[] = $rawClientIpsItem; } else { $data->clientIps->values = array_merge( $data->clientIps->values, explode(',', str_replace(' ', '', $rawClientIpsItem)) ); } } } }
php
protected static function envDetectParseSysConfigClientIps (& $data, $rawClientIps) { $data->clientIps->check = TRUE; if (is_string($rawClientIps)) { if (substr($rawClientIps, 0, 1) == '/') { $data->clientIps->regExeps[] = $rawClientIps; } else { $data->clientIps->values = array_merge( $data->clientIps->values, explode(',', str_replace(' ', '', $rawClientIps)) ); } } else if (is_array($rawClientIps) || $rawClientIps instanceof \stdClass) { foreach ((array) $rawClientIps as $rawClientIpsItem) { if (substr($rawClientIpsItem, 0, 1) == '/') { $data->clientIps->regExeps[] = $rawClientIpsItem; } else { $data->clientIps->values = array_merge( $data->clientIps->values, explode(',', str_replace(' ', '', $rawClientIpsItem)) ); } } } }
[ "protected", "static", "function", "envDetectParseSysConfigClientIps", "(", "&", "$", "data", ",", "$", "rawClientIps", ")", "{", "$", "data", "->", "clientIps", "->", "check", "=", "TRUE", ";", "if", "(", "is_string", "(", "$", "rawClientIps", ")", ")", "...
Parse system config environment section data from various declarations about client IP addresses into specific detection structure. @param \stdClass $data @param mixed $rawClientIps @return void
[ "Parse", "system", "config", "environment", "section", "data", "from", "various", "declarations", "about", "client", "IP", "addresses", "into", "specific", "detection", "structure", "." ]
5e580a2803bbccea8168316c4c6b963e1910e0bf
https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Config/Environment.php#L202-L225
train
mvccore/mvccore
src/MvcCore/Config/Environment.php
Environment.envDetectParseSysConfigServerNames
protected static function envDetectParseSysConfigServerNames (& $data, $rawHostNames) { $data->serverHostNames->check = TRUE; if (is_string($rawHostNames)) { if (substr($rawHostNames, 0, 1) == '/') { $data->serverHostNames->regExeps[] = $rawHostNames; } else { $data->serverHostNames->values = array_merge( $data->serverHostNames->values, explode(',', str_replace(' ', '', $rawHostNames)) ); } } else if (is_array($rawHostNames) || $rawHostNames instanceof \stdClass) { foreach ((array) $rawHostNames as $rawHostNamesItem) { if (substr($rawHostNamesItem, 0, 1) == '/') { $data->serverHostNames->regExeps[] = $rawHostNamesItem; } else { $data->serverHostNames->values = array_merge( $data->serverHostNames->values, explode(',', str_replace(' ', '', $rawHostNamesItem)) ); } } } }
php
protected static function envDetectParseSysConfigServerNames (& $data, $rawHostNames) { $data->serverHostNames->check = TRUE; if (is_string($rawHostNames)) { if (substr($rawHostNames, 0, 1) == '/') { $data->serverHostNames->regExeps[] = $rawHostNames; } else { $data->serverHostNames->values = array_merge( $data->serverHostNames->values, explode(',', str_replace(' ', '', $rawHostNames)) ); } } else if (is_array($rawHostNames) || $rawHostNames instanceof \stdClass) { foreach ((array) $rawHostNames as $rawHostNamesItem) { if (substr($rawHostNamesItem, 0, 1) == '/') { $data->serverHostNames->regExeps[] = $rawHostNamesItem; } else { $data->serverHostNames->values = array_merge( $data->serverHostNames->values, explode(',', str_replace(' ', '', $rawHostNamesItem)) ); } } } }
[ "protected", "static", "function", "envDetectParseSysConfigServerNames", "(", "&", "$", "data", ",", "$", "rawHostNames", ")", "{", "$", "data", "->", "serverHostNames", "->", "check", "=", "TRUE", ";", "if", "(", "is_string", "(", "$", "rawHostNames", ")", ...
Parse system config environment section data from various declarations about server host names into specific detection structure. @param \stdClass $data @param mixed $rawHostNames @return void
[ "Parse", "system", "config", "environment", "section", "data", "from", "various", "declarations", "about", "server", "host", "names", "into", "specific", "detection", "structure", "." ]
5e580a2803bbccea8168316c4c6b963e1910e0bf
https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Config/Environment.php#L234-L257
train
mvccore/mvccore
src/MvcCore/Config/Environment.php
Environment.envDetectParseSysConfigVariables
protected static function envDetectParseSysConfigVariables (& $data, $rawServerVariable) { $data->serverVariables->check = TRUE; if (is_string($rawServerVariable)) { $data->serverVariables->existence[] = $rawServerVariable; } else if (is_array($rawServerVariable) || $rawServerVariable instanceof \stdClass) { foreach ((array) $rawServerVariable as $key => $value) { if (is_numeric($key)) { $data->serverVariables->existence[] = $value; } else if (substr($value, 0, 1) == '/') { $data->serverVariables->regExeps[$key] = $value; } else { $data->serverVariables->values[$key] = $value; } } } }
php
protected static function envDetectParseSysConfigVariables (& $data, $rawServerVariable) { $data->serverVariables->check = TRUE; if (is_string($rawServerVariable)) { $data->serverVariables->existence[] = $rawServerVariable; } else if (is_array($rawServerVariable) || $rawServerVariable instanceof \stdClass) { foreach ((array) $rawServerVariable as $key => $value) { if (is_numeric($key)) { $data->serverVariables->existence[] = $value; } else if (substr($value, 0, 1) == '/') { $data->serverVariables->regExeps[$key] = $value; } else { $data->serverVariables->values[$key] = $value; } } } }
[ "protected", "static", "function", "envDetectParseSysConfigVariables", "(", "&", "$", "data", ",", "$", "rawServerVariable", ")", "{", "$", "data", "->", "serverVariables", "->", "check", "=", "TRUE", ";", "if", "(", "is_string", "(", "$", "rawServerVariable", ...
Parse system config environment section data from various declarations about server environment variables into specific detection structure. @param \stdClass $data @param mixed $rawServerVariable @return void
[ "Parse", "system", "config", "environment", "section", "data", "from", "various", "declarations", "about", "server", "environment", "variables", "into", "specific", "detection", "structure", "." ]
5e580a2803bbccea8168316c4c6b963e1910e0bf
https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Config/Environment.php#L266-L281
train
mvccore/mvccore
src/MvcCore/Tool/Helpers.php
Helpers.EncodeJson
public static function EncodeJson (& $data) { $flags = JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | (defined('JSON_UNESCAPED_SLASHES') ? JSON_UNESCAPED_SLASHES : 0) | (defined('JSON_UNESCAPED_UNICODE') ? JSON_UNESCAPED_UNICODE : 0) | (defined('JSON_PRESERVE_ZERO_FRACTION') ? JSON_PRESERVE_ZERO_FRACTION : 0); $json = json_encode($data, $flags); if ($errorCode = json_last_error()) { $selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__; throw new \RuntimeException("[".$selfClass."] ".json_last_error_msg(), $errorCode); } if (PHP_VERSION_ID < 70100) { $json = strtr($json, [ "\xe2\x80\xa8" => '\u2028', "\xe2\x80\xa9" => '\u2029', ]); } return $json; }
php
public static function EncodeJson (& $data) { $flags = JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | (defined('JSON_UNESCAPED_SLASHES') ? JSON_UNESCAPED_SLASHES : 0) | (defined('JSON_UNESCAPED_UNICODE') ? JSON_UNESCAPED_UNICODE : 0) | (defined('JSON_PRESERVE_ZERO_FRACTION') ? JSON_PRESERVE_ZERO_FRACTION : 0); $json = json_encode($data, $flags); if ($errorCode = json_last_error()) { $selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__; throw new \RuntimeException("[".$selfClass."] ".json_last_error_msg(), $errorCode); } if (PHP_VERSION_ID < 70100) { $json = strtr($json, [ "\xe2\x80\xa8" => '\u2028', "\xe2\x80\xa9" => '\u2029', ]); } return $json; }
[ "public", "static", "function", "EncodeJson", "(", "&", "$", "data", ")", "{", "$", "flags", "=", "JSON_HEX_TAG", "|", "JSON_HEX_APOS", "|", "JSON_HEX_QUOT", "|", "JSON_HEX_AMP", "|", "(", "defined", "(", "'JSON_UNESCAPED_SLASHES'", ")", "?", "JSON_UNESCAPED_SLA...
Safely encode json string from php value. @param mixed $data @throws \Exception JSON encoding error. @return string
[ "Safely", "encode", "json", "string", "from", "php", "value", "." ]
5e580a2803bbccea8168316c4c6b963e1910e0bf
https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Tool/Helpers.php#L30-L47
train
mvccore/mvccore
src/MvcCore/Tool/Helpers.php
Helpers.GetSystemTmpDir
public static function GetSystemTmpDir () { if (self::$tmpDir === NULL) { $tmpDir = sys_get_temp_dir(); if (strtolower(substr(PHP_OS, 0, 3)) == 'win') { // Windows: $sysRoot = getenv('SystemRoot'); // do not store anything directly in C:\Windows, use C\windows\Temp instead if (!$tmpDir || $tmpDir === $sysRoot) { $tmpDir = !empty($_SERVER['TEMP']) ? $_SERVER['TEMP'] : (!empty($_SERVER['TMP']) ? $_SERVER['TMP'] : (!empty($_SERVER['WINDIR']) ? $_SERVER['WINDIR'] . '/Temp' : $sysRoot . '/Temp' ) ); } $tmpDir = str_replace('\\', '/', $tmpDir); } else if (!$tmpDir) { // Other systems $tmpDir = !empty($_SERVER['TMPDIR']) ? $_SERVER['TMPDIR'] : (!empty($_SERVER['TMP']) ? $_SERVER['TMP'] : (!empty(ini_get('sys_temp_dir')) ? ini_get('sys_temp_dir') : '/tmp' ) ); } self::$tmpDir = $tmpDir; } return self::$tmpDir; }
php
public static function GetSystemTmpDir () { if (self::$tmpDir === NULL) { $tmpDir = sys_get_temp_dir(); if (strtolower(substr(PHP_OS, 0, 3)) == 'win') { // Windows: $sysRoot = getenv('SystemRoot'); // do not store anything directly in C:\Windows, use C\windows\Temp instead if (!$tmpDir || $tmpDir === $sysRoot) { $tmpDir = !empty($_SERVER['TEMP']) ? $_SERVER['TEMP'] : (!empty($_SERVER['TMP']) ? $_SERVER['TMP'] : (!empty($_SERVER['WINDIR']) ? $_SERVER['WINDIR'] . '/Temp' : $sysRoot . '/Temp' ) ); } $tmpDir = str_replace('\\', '/', $tmpDir); } else if (!$tmpDir) { // Other systems $tmpDir = !empty($_SERVER['TMPDIR']) ? $_SERVER['TMPDIR'] : (!empty($_SERVER['TMP']) ? $_SERVER['TMP'] : (!empty(ini_get('sys_temp_dir')) ? ini_get('sys_temp_dir') : '/tmp' ) ); } self::$tmpDir = $tmpDir; } return self::$tmpDir; }
[ "public", "static", "function", "GetSystemTmpDir", "(", ")", "{", "if", "(", "self", "::", "$", "tmpDir", "===", "NULL", ")", "{", "$", "tmpDir", "=", "sys_get_temp_dir", "(", ")", ";", "if", "(", "strtolower", "(", "substr", "(", "PHP_OS", ",", "0", ...
Returns the OS-specific directory for temporary files. @return string
[ "Returns", "the", "OS", "-", "specific", "directory", "for", "temporary", "files", "." ]
5e580a2803bbccea8168316c4c6b963e1910e0bf
https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Tool/Helpers.php#L122-L156
train
mvccore/mvccore
src/MvcCore/Route/UrlBuilding.php
UrlBuilding.urlAbsPartAndSplit
protected function urlAbsPartAndSplit (\MvcCore\IRequest & $request, $resultUrl, & $domainParams, $splitUrl) { $domainParamsFlag = $this->flags[1]; $basePathInReverse = FALSE; if ($domainParamsFlag >= static::FLAG_HOST_BASEPATH) { $basePathInReverse = TRUE; $domainParamsFlag -= static::FLAG_HOST_BASEPATH; } if ($this->flags[0]) { // route is defined as absolute with possible `%domain%` and other params // process possible replacements in reverse result - `%host%`, `%domain%`, `%tld%` and `%sld%` $this->urlReplaceDomainReverseParams($request, $resultUrl, $domainParams, $domainParamsFlag); // try to find URL position after domain part and after base path part if ($basePathInReverse) { return $this->urlAbsPartAndSplitByReverseBasePath($request, $resultUrl, $domainParams, $splitUrl); } else { return $this->urlAbsPartAndSplitByRequestedBasePath($request, $resultUrl, $splitUrl); } } else { // route is not defined as absolute, there could be only flag // in domain params array to complete absolute URL by developer // and there could be also `basePath` param defined. return $this->urlAbsPartAndSplitByGlobalSwitchOrBasePath( $request, $resultUrl, $domainParams, $domainParamsFlag, $splitUrl ); } }
php
protected function urlAbsPartAndSplit (\MvcCore\IRequest & $request, $resultUrl, & $domainParams, $splitUrl) { $domainParamsFlag = $this->flags[1]; $basePathInReverse = FALSE; if ($domainParamsFlag >= static::FLAG_HOST_BASEPATH) { $basePathInReverse = TRUE; $domainParamsFlag -= static::FLAG_HOST_BASEPATH; } if ($this->flags[0]) { // route is defined as absolute with possible `%domain%` and other params // process possible replacements in reverse result - `%host%`, `%domain%`, `%tld%` and `%sld%` $this->urlReplaceDomainReverseParams($request, $resultUrl, $domainParams, $domainParamsFlag); // try to find URL position after domain part and after base path part if ($basePathInReverse) { return $this->urlAbsPartAndSplitByReverseBasePath($request, $resultUrl, $domainParams, $splitUrl); } else { return $this->urlAbsPartAndSplitByRequestedBasePath($request, $resultUrl, $splitUrl); } } else { // route is not defined as absolute, there could be only flag // in domain params array to complete absolute URL by developer // and there could be also `basePath` param defined. return $this->urlAbsPartAndSplitByGlobalSwitchOrBasePath( $request, $resultUrl, $domainParams, $domainParamsFlag, $splitUrl ); } }
[ "protected", "function", "urlAbsPartAndSplit", "(", "\\", "MvcCore", "\\", "IRequest", "&", "$", "request", ",", "$", "resultUrl", ",", "&", "$", "domainParams", ",", "$", "splitUrl", ")", "{", "$", "domainParamsFlag", "=", "$", "this", "->", "flags", "[",...
After final URL is completed, split result URL into two parts. First part as scheme, domain part and base path and second part as application request path and query string. @param \MvcCore\IRequest $request A request object. @param string $resultUrl Result URL to split. REsult URL still could contain domain part or base path replacements. @param array $domainParams Array with params for first URL part (scheme, domain, base path). @param bool $splitUrl Boolean value about to split completed result URL into two parts or not. Default is FALSE to return a string array with only one record - the result URL. If `TRUE`, result url is split into two parts and function return array with two items. @return \string[] Result URL address in array. If last argument is `FALSE` by default, this function returns only single item array with result URL. If last argument is `TRUE`, function returns result URL in two parts - domain part with base path and path part with query string.
[ "After", "final", "URL", "is", "completed", "split", "result", "URL", "into", "two", "parts", ".", "First", "part", "as", "scheme", "domain", "part", "and", "base", "path", "and", "second", "part", "as", "application", "request", "path", "and", "query", "s...
5e580a2803bbccea8168316c4c6b963e1910e0bf
https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Route/UrlBuilding.php#L224-L249
train
mvccore/mvccore
src/MvcCore/Route/UrlBuilding.php
UrlBuilding.urlAbsPartAndSplitByReverseBasePath
protected function urlAbsPartAndSplitByReverseBasePath (\MvcCore\IRequest & $request, $resultUrl, & $domainParams, $splitUrl) { $doubleSlashPos = mb_strpos($resultUrl, '//'); $doubleSlashPos = $doubleSlashPos === FALSE ? 0 : $doubleSlashPos + 2; $router = & $this->router; $basePathPlaceHolderPos = mb_strpos($resultUrl, static::PLACEHOLDER_BASEPATH, $doubleSlashPos); if ($basePathPlaceHolderPos === FALSE) { return $this->urlAbsPartAndSplitByRequestedBasePath( $request, $resultUrl, $splitUrl ); } $pathPart = mb_substr($resultUrl, $basePathPlaceHolderPos + mb_strlen(static::PLACEHOLDER_BASEPATH)); $pathPart = str_replace('//', '/', $pathPart); $basePart = mb_substr($resultUrl, 0, $basePathPlaceHolderPos); $basePathParamName = $router::URL_PARAM_BASEPATH; $basePart .= isset($domainParams[$basePathParamName]) ? $domainParams[$basePathParamName] : $request->GetBasePath(); if ($this->flags[0] === static::FLAG_SCHEME_ANY) $basePart = $request->GetScheme() . $basePart; if ($splitUrl) return [$basePart, $pathPart]; return [$basePart . $pathPart]; }
php
protected function urlAbsPartAndSplitByReverseBasePath (\MvcCore\IRequest & $request, $resultUrl, & $domainParams, $splitUrl) { $doubleSlashPos = mb_strpos($resultUrl, '//'); $doubleSlashPos = $doubleSlashPos === FALSE ? 0 : $doubleSlashPos + 2; $router = & $this->router; $basePathPlaceHolderPos = mb_strpos($resultUrl, static::PLACEHOLDER_BASEPATH, $doubleSlashPos); if ($basePathPlaceHolderPos === FALSE) { return $this->urlAbsPartAndSplitByRequestedBasePath( $request, $resultUrl, $splitUrl ); } $pathPart = mb_substr($resultUrl, $basePathPlaceHolderPos + mb_strlen(static::PLACEHOLDER_BASEPATH)); $pathPart = str_replace('//', '/', $pathPart); $basePart = mb_substr($resultUrl, 0, $basePathPlaceHolderPos); $basePathParamName = $router::URL_PARAM_BASEPATH; $basePart .= isset($domainParams[$basePathParamName]) ? $domainParams[$basePathParamName] : $request->GetBasePath(); if ($this->flags[0] === static::FLAG_SCHEME_ANY) $basePart = $request->GetScheme() . $basePart; if ($splitUrl) return [$basePart, $pathPart]; return [$basePart . $pathPart]; }
[ "protected", "function", "urlAbsPartAndSplitByReverseBasePath", "(", "\\", "MvcCore", "\\", "IRequest", "&", "$", "request", ",", "$", "resultUrl", ",", "&", "$", "domainParams", ",", "$", "splitUrl", ")", "{", "$", "doubleSlashPos", "=", "mb_strpos", "(", "$"...
After final URL is completed, split result URL into two parts if there is contained domain part and base path in reverse, what is base material to complete result URL. If there is found base path percentage replacement in result url, split url after that percentage replacement and replace that part with domain param value or request base path value. @param \MvcCore\IRequest $request A request object. @param string $resultUrl Result URL to split. Result URL still could contain domain part or base path replacements. @param array $domainParams Array with params for first URL part (scheme, domain, base path). @param bool $splitUrl Boolean value about to split completed result URL into two parts or not. Default is FALSE to return a string array with only one record - the result URL. If `TRUE`, result url is split into two parts and function return array with two items. @return \string[] Result URL address in array. If last argument is `FALSE` by default, this function returns only single item array with result URL. If last argument is `TRUE`, function returns result URL in two parts - domain part with base path and path part with query string.
[ "After", "final", "URL", "is", "completed", "split", "result", "URL", "into", "two", "parts", "if", "there", "is", "contained", "domain", "part", "and", "base", "path", "in", "reverse", "what", "is", "base", "material", "to", "complete", "result", "URL", "...
5e580a2803bbccea8168316c4c6b963e1910e0bf
https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Route/UrlBuilding.php#L340-L363
train
mvccore/mvccore
src/MvcCore/Route/UrlBuilding.php
UrlBuilding.urlAbsPartAndSplitByRequestedBasePath
protected function urlAbsPartAndSplitByRequestedBasePath (\MvcCore\IRequest & $request, $resultUrl, $splitUrl) { $doubleSlashPos = mb_strpos($resultUrl, '//'); $doubleSlashPos = $doubleSlashPos === FALSE ? 0 : $doubleSlashPos + 2; if (!$splitUrl) { $resultSchemePart = mb_substr($resultUrl, 0, $doubleSlashPos); $resultAfterScheme = mb_substr($resultUrl, $doubleSlashPos); $resultAfterScheme = str_replace('//', '/', $resultAfterScheme); if ($this->flags[0] === static::FLAG_SCHEME_ANY) { $resultUrl = $request->GetScheme() . '//' . $resultAfterScheme; } else { $resultUrl = $resultSchemePart . $resultAfterScheme; } return [$resultUrl]; } else { $nextSlashPos = mb_strpos($resultUrl, '/', $doubleSlashPos); if ($nextSlashPos === FALSE) { $queryStringPos = mb_strpos($resultUrl, '?', $doubleSlashPos); $baseUrlPartEndPos = $queryStringPos === FALSE ? mb_strlen($resultUrl) : $queryStringPos; } else { $baseUrlPartEndPos = $nextSlashPos; } $requestedBasePath = $request->GetBasePath(); $basePathLength = mb_strlen($requestedBasePath); if ($basePathLength > 0) { $basePathPos = mb_strpos($resultUrl, $requestedBasePath, $baseUrlPartEndPos); if ($basePathPos === $baseUrlPartEndPos) $baseUrlPartEndPos += $basePathLength; } $basePart = mb_substr($resultUrl, 0, $baseUrlPartEndPos); if ($this->flags[0] === static::FLAG_SCHEME_ANY) $basePart = $request->GetScheme() . $basePart; $pathAndQueryPart = str_replace('//', '/', mb_substr($resultUrl, $baseUrlPartEndPos)); return [$basePart, $pathAndQueryPart]; } }
php
protected function urlAbsPartAndSplitByRequestedBasePath (\MvcCore\IRequest & $request, $resultUrl, $splitUrl) { $doubleSlashPos = mb_strpos($resultUrl, '//'); $doubleSlashPos = $doubleSlashPos === FALSE ? 0 : $doubleSlashPos + 2; if (!$splitUrl) { $resultSchemePart = mb_substr($resultUrl, 0, $doubleSlashPos); $resultAfterScheme = mb_substr($resultUrl, $doubleSlashPos); $resultAfterScheme = str_replace('//', '/', $resultAfterScheme); if ($this->flags[0] === static::FLAG_SCHEME_ANY) { $resultUrl = $request->GetScheme() . '//' . $resultAfterScheme; } else { $resultUrl = $resultSchemePart . $resultAfterScheme; } return [$resultUrl]; } else { $nextSlashPos = mb_strpos($resultUrl, '/', $doubleSlashPos); if ($nextSlashPos === FALSE) { $queryStringPos = mb_strpos($resultUrl, '?', $doubleSlashPos); $baseUrlPartEndPos = $queryStringPos === FALSE ? mb_strlen($resultUrl) : $queryStringPos; } else { $baseUrlPartEndPos = $nextSlashPos; } $requestedBasePath = $request->GetBasePath(); $basePathLength = mb_strlen($requestedBasePath); if ($basePathLength > 0) { $basePathPos = mb_strpos($resultUrl, $requestedBasePath, $baseUrlPartEndPos); if ($basePathPos === $baseUrlPartEndPos) $baseUrlPartEndPos += $basePathLength; } $basePart = mb_substr($resultUrl, 0, $baseUrlPartEndPos); if ($this->flags[0] === static::FLAG_SCHEME_ANY) $basePart = $request->GetScheme() . $basePart; $pathAndQueryPart = str_replace('//', '/', mb_substr($resultUrl, $baseUrlPartEndPos)); return [$basePart, $pathAndQueryPart]; } }
[ "protected", "function", "urlAbsPartAndSplitByRequestedBasePath", "(", "\\", "MvcCore", "\\", "IRequest", "&", "$", "request", ",", "$", "resultUrl", ",", "$", "splitUrl", ")", "{", "$", "doubleSlashPos", "=", "mb_strpos", "(", "$", "resultUrl", ",", "'//'", "...
After final URL is completed, split result URL into two parts if there is contained domain part and base path in reverse, what is base material to complete result URL. Try to found the point in result URL, where is base path end and application request path begin. By that point split and return result URL. @param \MvcCore\IRequest $request A request object. @param string $resultUrl Result URL to split. Result URL still could contain domain part or base path replacements. @param bool $splitUrl Boolean value about to split completed result URL into two parts or not. Default is FALSE to return a string array with only one record - the result URL. If `TRUE`, result url is split into two parts and function return array with two items. @return \string[] Result URL address in array. If last argument is `FALSE` by default, this function returns only single item array with result URL. If last argument is `TRUE`, function returns result URL in two parts - domain part with base path and path part with query string.
[ "After", "final", "URL", "is", "completed", "split", "result", "URL", "into", "two", "parts", "if", "there", "is", "contained", "domain", "part", "and", "base", "path", "in", "reverse", "what", "is", "base", "material", "to", "complete", "result", "URL", "...
5e580a2803bbccea8168316c4c6b963e1910e0bf
https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Route/UrlBuilding.php#L389-L427
train
htmlburger/wpemerge-theme-core
src/Avatar/Avatar.php
Avatar.removeUserMetaKey
public function removeUserMetaKey( $user_meta_key ) { $filter = function( $meta_key ) use ( $user_meta_key ) { return $meta_key !== $user_meta_key; }; $this->avatar_user_meta_keys = array_filter( $this->avatar_user_meta_keys, $filter ); }
php
public function removeUserMetaKey( $user_meta_key ) { $filter = function( $meta_key ) use ( $user_meta_key ) { return $meta_key !== $user_meta_key; }; $this->avatar_user_meta_keys = array_filter( $this->avatar_user_meta_keys, $filter ); }
[ "public", "function", "removeUserMetaKey", "(", "$", "user_meta_key", ")", "{", "$", "filter", "=", "function", "(", "$", "meta_key", ")", "use", "(", "$", "user_meta_key", ")", "{", "return", "$", "meta_key", "!==", "$", "user_meta_key", ";", "}", ";", ...
Remove a previously added meta key @param string $user_meta_key @return void
[ "Remove", "a", "previously", "added", "meta", "key" ]
2e8532c9e9b4b7173476c1a11ca645a74895d0b5
https://github.com/htmlburger/wpemerge-theme-core/blob/2e8532c9e9b4b7173476c1a11ca645a74895d0b5/src/Avatar/Avatar.php#L57-L62
train
htmlburger/wpemerge-theme-core
src/Avatar/Avatar.php
Avatar.idOrEmailToId
protected function idOrEmailToId( $id_or_email ) { if ( is_a( $id_or_email, WP_Comment::class ) ) { return intval( $id_or_email->user_id ); } if ( ! is_numeric( $id_or_email ) ) { $user = get_user_by( 'email', $id_or_email ); if ( $user ) { return intval( $user->ID ); } } return strval( $id_or_email ); }
php
protected function idOrEmailToId( $id_or_email ) { if ( is_a( $id_or_email, WP_Comment::class ) ) { return intval( $id_or_email->user_id ); } if ( ! is_numeric( $id_or_email ) ) { $user = get_user_by( 'email', $id_or_email ); if ( $user ) { return intval( $user->ID ); } } return strval( $id_or_email ); }
[ "protected", "function", "idOrEmailToId", "(", "$", "id_or_email", ")", "{", "if", "(", "is_a", "(", "$", "id_or_email", ",", "WP_Comment", "::", "class", ")", ")", "{", "return", "intval", "(", "$", "id_or_email", "->", "user_id", ")", ";", "}", "if", ...
Converts an id_or_email to an ID if possible. @param integer|string|WP_Comment $id_or_email @return integer|string
[ "Converts", "an", "id_or_email", "to", "an", "ID", "if", "possible", "." ]
2e8532c9e9b4b7173476c1a11ca645a74895d0b5
https://github.com/htmlburger/wpemerge-theme-core/blob/2e8532c9e9b4b7173476c1a11ca645a74895d0b5/src/Avatar/Avatar.php#L70-L83
train
htmlburger/wpemerge-theme-core
src/Avatar/Avatar.php
Avatar.getAttachmentFallbackChain
protected function getAttachmentFallbackChain( $user_id ) { $chain = []; foreach ( $this->avatar_user_meta_keys as $user_meta_key ) { $attachment_id = get_user_meta( $user_id, $user_meta_key, true ); if ( is_numeric( $attachment_id ) ) { $chain[] = intval( $attachment_id ); } } if ( $this->default_avatar_id !== 0 ) { $chain[] = $this->default_avatar_id; } return $chain; }
php
protected function getAttachmentFallbackChain( $user_id ) { $chain = []; foreach ( $this->avatar_user_meta_keys as $user_meta_key ) { $attachment_id = get_user_meta( $user_id, $user_meta_key, true ); if ( is_numeric( $attachment_id ) ) { $chain[] = intval( $attachment_id ); } } if ( $this->default_avatar_id !== 0 ) { $chain[] = $this->default_avatar_id; } return $chain; }
[ "protected", "function", "getAttachmentFallbackChain", "(", "$", "user_id", ")", "{", "$", "chain", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "avatar_user_meta_keys", "as", "$", "user_meta_key", ")", "{", "$", "attachment_id", "=", "get_user_meta"...
Get attachment fallback chain for the user avatar. @param integer $user_id @return array<integer>
[ "Get", "attachment", "fallback", "chain", "for", "the", "user", "avatar", "." ]
2e8532c9e9b4b7173476c1a11ca645a74895d0b5
https://github.com/htmlburger/wpemerge-theme-core/blob/2e8532c9e9b4b7173476c1a11ca645a74895d0b5/src/Avatar/Avatar.php#L109-L124
train