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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
chameleon-system/chameleon-shop | src/ShopBundle/objects/WebModules/MTShopArticleCatalogCore/MTShopArticleCatalogCoreEndPoint.class.php | MTShopArticleCatalogCoreEndPoint.GetActiveShopModuleArticlelistOrderbyId | public function GetActiveShopModuleArticlelistOrderbyId($sInstanceId = '')
{
$iActiveShopModuleArticlelistOrderbyId = null;
$oGlobal = TGlobal::instance();
if ($oGlobal->UserDataExists(self::URL_ORDER_BY)) {
$iActiveShopModuleArticlelistOrderbyId = $oGlobal->GetUserData(self::URL_ORDER_BY);
} else {
if (array_key_exists(self::SESSION_ACTIVE_ORDER_BY.$sInstanceId, $_SESSION)) {
$iActiveShopModuleArticlelistOrderbyId = $_SESSION[self::SESSION_ACTIVE_ORDER_BY.$sInstanceId];
}
}
return $iActiveShopModuleArticlelistOrderbyId;
} | php | public function GetActiveShopModuleArticlelistOrderbyId($sInstanceId = '')
{
$iActiveShopModuleArticlelistOrderbyId = null;
$oGlobal = TGlobal::instance();
if ($oGlobal->UserDataExists(self::URL_ORDER_BY)) {
$iActiveShopModuleArticlelistOrderbyId = $oGlobal->GetUserData(self::URL_ORDER_BY);
} else {
if (array_key_exists(self::SESSION_ACTIVE_ORDER_BY.$sInstanceId, $_SESSION)) {
$iActiveShopModuleArticlelistOrderbyId = $_SESSION[self::SESSION_ACTIVE_ORDER_BY.$sInstanceId];
}
}
return $iActiveShopModuleArticlelistOrderbyId;
} | [
"public",
"function",
"GetActiveShopModuleArticlelistOrderbyId",
"(",
"$",
"sInstanceId",
"=",
"''",
")",
"{",
"$",
"iActiveShopModuleArticlelistOrderbyId",
"=",
"null",
";",
"$",
"oGlobal",
"=",
"TGlobal",
"::",
"instance",
"(",
")",
";",
"if",
"(",
"$",
"oGlob... | return the active order by id based on session or url parameter.
@return int | [
"return",
"the",
"active",
"order",
"by",
"id",
"based",
"on",
"session",
"or",
"url",
"parameter",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/WebModules/MTShopArticleCatalogCore/MTShopArticleCatalogCoreEndPoint.class.php#L514-L527 | train |
chameleon-system/chameleon-shop | src/ShopBundle/objects/WebModules/MTShopArticleCatalogCore/MTShopArticleCatalogCoreEndPoint.class.php | MTShopArticleCatalogCoreEndPoint.GetActiveOrderByString | public function GetActiveOrderByString($sDefaultActiveShopModuleArticlelistOrderbyId = null, $sInstanceId = '')
{
static $oOrderBy = null;
if (is_null($oOrderBy)) {
// remove default order by - for performance reason we should be allowed to sort by nothing
$sOrder = ''; //`shop_article`.`list_rank` DESC, `shop_article`.`name` ASC';
$iActiveShopModuleArticlelistOrderbyId = $this->GetActiveShopModuleArticlelistOrderbyId($sInstanceId);
if (is_null($iActiveShopModuleArticlelistOrderbyId)) {
$iActiveShopModuleArticlelistOrderbyId = $sDefaultActiveShopModuleArticlelistOrderbyId;
}
if (!is_null($iActiveShopModuleArticlelistOrderbyId)) {
$oOrderBy = TdbShopModuleArticlelistOrderby::GetNewInstance();
/** @var $oOrderBy TdbShopModuleArticlelistOrderby */
if (!$oOrderBy->Load($iActiveShopModuleArticlelistOrderbyId)) {
$oOrderBy = null;
}
}
if (is_null($oOrderBy)) {
$oShop = TdbShop::GetInstance();
$oOrderBy = &$oShop->GetFieldShopModuleArticlelistOrderby();
}
if (!is_null($oOrderBy)) {
$sOrder = $oOrderBy->GetOrderByString();
$_SESSION[self::SESSION_ACTIVE_ORDER_BY.$sInstanceId] = $iActiveShopModuleArticlelistOrderbyId;
}
} else {
$sOrder = $oOrderBy->GetOrderByString();
}
return $sOrder;
} | php | public function GetActiveOrderByString($sDefaultActiveShopModuleArticlelistOrderbyId = null, $sInstanceId = '')
{
static $oOrderBy = null;
if (is_null($oOrderBy)) {
// remove default order by - for performance reason we should be allowed to sort by nothing
$sOrder = ''; //`shop_article`.`list_rank` DESC, `shop_article`.`name` ASC';
$iActiveShopModuleArticlelistOrderbyId = $this->GetActiveShopModuleArticlelistOrderbyId($sInstanceId);
if (is_null($iActiveShopModuleArticlelistOrderbyId)) {
$iActiveShopModuleArticlelistOrderbyId = $sDefaultActiveShopModuleArticlelistOrderbyId;
}
if (!is_null($iActiveShopModuleArticlelistOrderbyId)) {
$oOrderBy = TdbShopModuleArticlelistOrderby::GetNewInstance();
/** @var $oOrderBy TdbShopModuleArticlelistOrderby */
if (!$oOrderBy->Load($iActiveShopModuleArticlelistOrderbyId)) {
$oOrderBy = null;
}
}
if (is_null($oOrderBy)) {
$oShop = TdbShop::GetInstance();
$oOrderBy = &$oShop->GetFieldShopModuleArticlelistOrderby();
}
if (!is_null($oOrderBy)) {
$sOrder = $oOrderBy->GetOrderByString();
$_SESSION[self::SESSION_ACTIVE_ORDER_BY.$sInstanceId] = $iActiveShopModuleArticlelistOrderbyId;
}
} else {
$sOrder = $oOrderBy->GetOrderByString();
}
return $sOrder;
} | [
"public",
"function",
"GetActiveOrderByString",
"(",
"$",
"sDefaultActiveShopModuleArticlelistOrderbyId",
"=",
"null",
",",
"$",
"sInstanceId",
"=",
"''",
")",
"{",
"static",
"$",
"oOrderBy",
"=",
"null",
";",
"if",
"(",
"is_null",
"(",
"$",
"oOrderBy",
")",
"... | return the current order string for the article lists.
@return string | [
"return",
"the",
"current",
"order",
"string",
"for",
"the",
"article",
"lists",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/WebModules/MTShopArticleCatalogCore/MTShopArticleCatalogCoreEndPoint.class.php#L534-L565 | train |
edmondscommerce/doctrine-static-meta | src/CodeGeneration/Generator/FileCreationTransaction.php | FileCreationTransaction.registerShutdownFunction | private static function registerShutdownFunction(): bool
{
self::$startTime = microtime(true);
register_shutdown_function(
function () {
$error = error_get_last();
if ($error === E_ERROR && count(self::$pathsCreated) > 0) {
self::echoDirtyTransactionCleanupCommands();
}
}
);
return true;
} | php | private static function registerShutdownFunction(): bool
{
self::$startTime = microtime(true);
register_shutdown_function(
function () {
$error = error_get_last();
if ($error === E_ERROR && count(self::$pathsCreated) > 0) {
self::echoDirtyTransactionCleanupCommands();
}
}
);
return true;
} | [
"private",
"static",
"function",
"registerShutdownFunction",
"(",
")",
":",
"bool",
"{",
"self",
"::",
"$",
"startTime",
"=",
"microtime",
"(",
"true",
")",
";",
"register_shutdown_function",
"(",
"function",
"(",
")",
"{",
"$",
"error",
"=",
"error_get_last",... | Registers our shutdown function. Will attempt to echo out the dirty file clean up commands on a fatal error
@return bool | [
"Registers",
"our",
"shutdown",
"function",
".",
"Will",
"attempt",
"to",
"echo",
"out",
"the",
"dirty",
"file",
"clean",
"up",
"commands",
"on",
"a",
"fatal",
"error"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/CodeGeneration/Generator/FileCreationTransaction.php#L59-L72 | train |
edmondscommerce/doctrine-static-meta | src/CodeGeneration/Generator/FileCreationTransaction.php | FileCreationTransaction.echoDirtyTransactionCleanupCommands | public static function echoDirtyTransactionCleanupCommands($handle = STDERR): void
{
if (0 === count(self::$pathsCreated)) {
return;
}
$sinceTimeSeconds = ceil(microtime(true) - self::$startTime);
// why, because of xdebug break - you could easily spend over 1 minute stepping through
$sinceTimeMinutes = ceil($sinceTimeSeconds / 60);
$pathsToSearch = [];
foreach (self::$pathsCreated as $path) {
$realPath = realpath($path);
if ($realPath) {
$pathsToSearch[$realPath] = $realPath;
}
}
if (0 === count($pathsToSearch)) {
return;
}
$findCommand = 'find ' . implode(' ', $pathsToSearch) . " -mmin -$sinceTimeMinutes";
$line = str_repeat('-', 15);
$deleteCommand = "$findCommand -exec rm -rf";
fwrite(
$handle,
"\n$line\n"
. "\n\nUnclean File Creation Transaction:"
. "\n\nTo find created files:\n$findCommand"
. "\n\nTo remove created files:\n$deleteCommand"
. "\n\n$line\n\n"
);
} | php | public static function echoDirtyTransactionCleanupCommands($handle = STDERR): void
{
if (0 === count(self::$pathsCreated)) {
return;
}
$sinceTimeSeconds = ceil(microtime(true) - self::$startTime);
// why, because of xdebug break - you could easily spend over 1 minute stepping through
$sinceTimeMinutes = ceil($sinceTimeSeconds / 60);
$pathsToSearch = [];
foreach (self::$pathsCreated as $path) {
$realPath = realpath($path);
if ($realPath) {
$pathsToSearch[$realPath] = $realPath;
}
}
if (0 === count($pathsToSearch)) {
return;
}
$findCommand = 'find ' . implode(' ', $pathsToSearch) . " -mmin -$sinceTimeMinutes";
$line = str_repeat('-', 15);
$deleteCommand = "$findCommand -exec rm -rf";
fwrite(
$handle,
"\n$line\n"
. "\n\nUnclean File Creation Transaction:"
. "\n\nTo find created files:\n$findCommand"
. "\n\nTo remove created files:\n$deleteCommand"
. "\n\n$line\n\n"
);
} | [
"public",
"static",
"function",
"echoDirtyTransactionCleanupCommands",
"(",
"$",
"handle",
"=",
"STDERR",
")",
":",
"void",
"{",
"if",
"(",
"0",
"===",
"count",
"(",
"self",
"::",
"$",
"pathsCreated",
")",
")",
"{",
"return",
";",
"}",
"$",
"sinceTimeSecon... | Echos out bash find commands to find and delete created paths
@param bool|resource $handle | [
"Echos",
"out",
"bash",
"find",
"commands",
"to",
"find",
"and",
"delete",
"created",
"paths"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/CodeGeneration/Generator/FileCreationTransaction.php#L79-L108 | train |
PGB-LIV/php-ms | src/experimental/MzMlMerge.php | MzMlMerge.merge | public function merge()
{
// TODO: verify analysis phase run
foreach ($this->dataFiles as $replicate => $fractions) {
$firstFile = current($fractions);
// Write header
$this->writeHeader($firstFile['path'], $this->spectrumCount[$replicate], $this->outputFiles[$replicate]);
// Resets vars
$this->spectrumIdRef = array();
$this->timeOffset = 0;
$this->indexOffset = 0;
$this->idOffset = 0;
foreach ($fractions as $fractionIndex => $file) {
$this->writeSpectrum($file['path'], $this->outputFiles[$replicate],
$this->fractionOffsets[$fractionIndex]);
}
$this->writeFooter($firstFile['path'], $this->outputFiles[$replicate]);
}
} | php | public function merge()
{
// TODO: verify analysis phase run
foreach ($this->dataFiles as $replicate => $fractions) {
$firstFile = current($fractions);
// Write header
$this->writeHeader($firstFile['path'], $this->spectrumCount[$replicate], $this->outputFiles[$replicate]);
// Resets vars
$this->spectrumIdRef = array();
$this->timeOffset = 0;
$this->indexOffset = 0;
$this->idOffset = 0;
foreach ($fractions as $fractionIndex => $file) {
$this->writeSpectrum($file['path'], $this->outputFiles[$replicate],
$this->fractionOffsets[$fractionIndex]);
}
$this->writeFooter($firstFile['path'], $this->outputFiles[$replicate]);
}
} | [
"public",
"function",
"merge",
"(",
")",
"{",
"// TODO: verify analysis phase run",
"foreach",
"(",
"$",
"this",
"->",
"dataFiles",
"as",
"$",
"replicate",
"=>",
"$",
"fractions",
")",
"{",
"$",
"firstFile",
"=",
"current",
"(",
"$",
"fractions",
")",
";",
... | Merges the MzML files specified in the constructor into a single MzML file and writes the data to the output file specified in the constructor | [
"Merges",
"the",
"MzML",
"files",
"specified",
"in",
"the",
"constructor",
"into",
"a",
"single",
"MzML",
"file",
"and",
"writes",
"the",
"data",
"to",
"the",
"output",
"file",
"specified",
"in",
"the",
"constructor"
] | 091751eb12512f4bc6ada07bda745ce49331e24f | https://github.com/PGB-LIV/php-ms/blob/091751eb12512f4bc6ada07bda745ce49331e24f/src/experimental/MzMlMerge.php#L193-L214 | train |
edmondscommerce/doctrine-static-meta | src/DoctrineStaticMeta.php | DoctrineStaticMeta.getStaticMethods | public function getStaticMethods(): array
{
if (null !== $this->staticMethods) {
return $this->staticMethods;
}
$this->staticMethods = $this->reflectionClass->getMethods(
\ReflectionMethod::IS_STATIC
);
return $this->staticMethods;
} | php | public function getStaticMethods(): array
{
if (null !== $this->staticMethods) {
return $this->staticMethods;
}
$this->staticMethods = $this->reflectionClass->getMethods(
\ReflectionMethod::IS_STATIC
);
return $this->staticMethods;
} | [
"public",
"function",
"getStaticMethods",
"(",
")",
":",
"array",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"staticMethods",
")",
"{",
"return",
"$",
"this",
"->",
"staticMethods",
";",
"}",
"$",
"this",
"->",
"staticMethods",
"=",
"$",
"this",
... | Get an array of all static methods implemented by the current class
Merges trait methods
Filters out this trait
@return array|ReflectionMethod[]
@throws \ReflectionException | [
"Get",
"an",
"array",
"of",
"all",
"static",
"methods",
"implemented",
"by",
"the",
"current",
"class"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/DoctrineStaticMeta.php#L149-L159 | train |
edmondscommerce/doctrine-static-meta | src/DoctrineStaticMeta.php | DoctrineStaticMeta.setTableName | private function setTableName(ClassMetadataBuilder $builder): void
{
$tableName = MappingHelper::getTableNameForEntityFqn($this->reflectionClass->getName());
$builder->setTable($tableName);
} | php | private function setTableName(ClassMetadataBuilder $builder): void
{
$tableName = MappingHelper::getTableNameForEntityFqn($this->reflectionClass->getName());
$builder->setTable($tableName);
} | [
"private",
"function",
"setTableName",
"(",
"ClassMetadataBuilder",
"$",
"builder",
")",
":",
"void",
"{",
"$",
"tableName",
"=",
"MappingHelper",
"::",
"getTableNameForEntityFqn",
"(",
"$",
"this",
"->",
"reflectionClass",
"->",
"getName",
"(",
")",
")",
";",
... | Sets the table name for the class
@param ClassMetadataBuilder $builder
@SuppressWarnings(PHPMD.StaticAccess) | [
"Sets",
"the",
"table",
"name",
"for",
"the",
"class"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/DoctrineStaticMeta.php#L168-L172 | train |
edmondscommerce/doctrine-static-meta | src/DoctrineStaticMeta.php | DoctrineStaticMeta.getRequiredRelationProperties | public function getRequiredRelationProperties(): array
{
if (null !== $this->requiredRelationProperties) {
return $this->requiredRelationProperties;
}
$traits = $this->reflectionClass->getTraits();
$return = [];
foreach ($traits as $traitName => $traitReflection) {
if (false === \ts\stringContains($traitName, '\\HasRequired')) {
continue;
}
if (false === \ts\stringContains($traitName, '\\Entity\\Relations\\')) {
continue;
}
$property = $traitReflection->getProperties()[0]->getName();
$return[$property] = $this->getTypesFromVarComment(
$property,
$this->getReflectionHelper()->getTraitProvidingProperty($traitReflection, $property)
);
}
$this->requiredRelationProperties = $return;
return $return;
} | php | public function getRequiredRelationProperties(): array
{
if (null !== $this->requiredRelationProperties) {
return $this->requiredRelationProperties;
}
$traits = $this->reflectionClass->getTraits();
$return = [];
foreach ($traits as $traitName => $traitReflection) {
if (false === \ts\stringContains($traitName, '\\HasRequired')) {
continue;
}
if (false === \ts\stringContains($traitName, '\\Entity\\Relations\\')) {
continue;
}
$property = $traitReflection->getProperties()[0]->getName();
$return[$property] = $this->getTypesFromVarComment(
$property,
$this->getReflectionHelper()->getTraitProvidingProperty($traitReflection, $property)
);
}
$this->requiredRelationProperties = $return;
return $return;
} | [
"public",
"function",
"getRequiredRelationProperties",
"(",
")",
":",
"array",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"requiredRelationProperties",
")",
"{",
"return",
"$",
"this",
"->",
"requiredRelationProperties",
";",
"}",
"$",
"traits",
"=",
"$... | Get an array of required relation properties, keyed by the property name and the value being an array of FQNs
for the declared types
@return array [ propertyName => [...types]]
@throws \ReflectionException | [
"Get",
"an",
"array",
"of",
"required",
"relation",
"properties",
"keyed",
"by",
"the",
"property",
"name",
"and",
"the",
"value",
"being",
"an",
"array",
"of",
"FQNs",
"for",
"the",
"declared",
"types"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/DoctrineStaticMeta.php#L199-L223 | train |
edmondscommerce/doctrine-static-meta | src/DoctrineStaticMeta.php | DoctrineStaticMeta.getTypesFromVarComment | private function getTypesFromVarComment(string $property, ReflectionClass $traitReflection): array
{
$docComment = $this->reflectionClass->getProperty($property)->getDocComment();
\preg_match('%@var\s*?(.+)%', $docComment, $matches);
$traitCode = \ts\file_get_contents($traitReflection->getFileName());
$types = \explode('|', $matches[1]);
$return = [];
foreach ($types as $type) {
$type = \trim($type);
if ('null' === $type) {
continue;
}
if ('ArrayCollection' === $type) {
continue;
}
$arrayNotation = '';
if ('[]' === substr($type, -2)) {
$type = substr($type, 0, -2);
$arrayNotation = '[]';
}
$pattern = "%^use (.+?)\\\\${type}(;| |\[)%m";
\preg_match($pattern, $traitCode, $matches);
if (!isset($matches[1])) {
throw new \RuntimeException(
'Failed finding match for type ' . $type . ' in ' . $traitReflection->getFileName()
);
}
$return[] = $matches[1] . '\\' . $type . $arrayNotation;
}
return $return;
} | php | private function getTypesFromVarComment(string $property, ReflectionClass $traitReflection): array
{
$docComment = $this->reflectionClass->getProperty($property)->getDocComment();
\preg_match('%@var\s*?(.+)%', $docComment, $matches);
$traitCode = \ts\file_get_contents($traitReflection->getFileName());
$types = \explode('|', $matches[1]);
$return = [];
foreach ($types as $type) {
$type = \trim($type);
if ('null' === $type) {
continue;
}
if ('ArrayCollection' === $type) {
continue;
}
$arrayNotation = '';
if ('[]' === substr($type, -2)) {
$type = substr($type, 0, -2);
$arrayNotation = '[]';
}
$pattern = "%^use (.+?)\\\\${type}(;| |\[)%m";
\preg_match($pattern, $traitCode, $matches);
if (!isset($matches[1])) {
throw new \RuntimeException(
'Failed finding match for type ' . $type . ' in ' . $traitReflection->getFileName()
);
}
$return[] = $matches[1] . '\\' . $type . $arrayNotation;
}
return $return;
} | [
"private",
"function",
"getTypesFromVarComment",
"(",
"string",
"$",
"property",
",",
"ReflectionClass",
"$",
"traitReflection",
")",
":",
"array",
"{",
"$",
"docComment",
"=",
"$",
"this",
"->",
"reflectionClass",
"->",
"getProperty",
"(",
"$",
"property",
")",... | Parse the docblock for a property and get the type, then read the source code to resolve the short type to the
FQN of the type. Roll on PHP 7.3
@param string $property
@param ReflectionClass $traitReflection
@return array | [
"Parse",
"the",
"docblock",
"for",
"a",
"property",
"and",
"get",
"the",
"type",
"then",
"read",
"the",
"source",
"code",
"to",
"resolve",
"the",
"short",
"type",
"to",
"the",
"FQN",
"of",
"the",
"type",
".",
"Roll",
"on",
"PHP",
"7",
".",
"3"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/DoctrineStaticMeta.php#L235-L266 | train |
edmondscommerce/doctrine-static-meta | src/DoctrineStaticMeta.php | DoctrineStaticMeta.getEmbeddableProperties | public function getEmbeddableProperties(): array
{
if (null !== $this->embeddableProperties) {
return $this->embeddableProperties;
}
$traits = $this->reflectionClass->getTraits();
$return = [];
foreach ($traits as $traitName => $traitReflection) {
if (\ts\stringContains($traitName, '\\Entity\\Embeddable\\Traits')) {
$property = $traitReflection->getProperties()[0]->getName();
$embeddableObjectInterfaceFqn = $this->getTypesFromVarComment(
$property,
$this->getReflectionHelper()->getTraitProvidingProperty($traitReflection, $property)
)[0];
$embeddableObject = $this->getNamespaceHelper()
->getEmbeddableObjectFqnFromEmbeddableObjectInterfaceFqn(
$embeddableObjectInterfaceFqn
);
$return[$property] = $embeddableObject;
}
}
return $return;
} | php | public function getEmbeddableProperties(): array
{
if (null !== $this->embeddableProperties) {
return $this->embeddableProperties;
}
$traits = $this->reflectionClass->getTraits();
$return = [];
foreach ($traits as $traitName => $traitReflection) {
if (\ts\stringContains($traitName, '\\Entity\\Embeddable\\Traits')) {
$property = $traitReflection->getProperties()[0]->getName();
$embeddableObjectInterfaceFqn = $this->getTypesFromVarComment(
$property,
$this->getReflectionHelper()->getTraitProvidingProperty($traitReflection, $property)
)[0];
$embeddableObject = $this->getNamespaceHelper()
->getEmbeddableObjectFqnFromEmbeddableObjectInterfaceFqn(
$embeddableObjectInterfaceFqn
);
$return[$property] = $embeddableObject;
}
}
return $return;
} | [
"public",
"function",
"getEmbeddableProperties",
"(",
")",
":",
"array",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"embeddableProperties",
")",
"{",
"return",
"$",
"this",
"->",
"embeddableProperties",
";",
"}",
"$",
"traits",
"=",
"$",
"this",
"->... | Get an array of property names that contain embeddable objects
@return array
@throws \ReflectionException | [
"Get",
"an",
"array",
"of",
"property",
"names",
"that",
"contain",
"embeddable",
"objects"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/DoctrineStaticMeta.php#L292-L315 | train |
edmondscommerce/doctrine-static-meta | src/DoctrineStaticMeta.php | DoctrineStaticMeta.getPlural | public function getPlural(): string
{
try {
if (null === $this->plural) {
$singular = $this->getSingular();
$this->plural = Inflector::pluralize($singular);
}
return $this->plural;
} catch (\Exception $e) {
throw new DoctrineStaticMetaException(
'Exception in ' . __METHOD__ . ': ' . $e->getMessage(),
$e->getCode(),
$e
);
}
} | php | public function getPlural(): string
{
try {
if (null === $this->plural) {
$singular = $this->getSingular();
$this->plural = Inflector::pluralize($singular);
}
return $this->plural;
} catch (\Exception $e) {
throw new DoctrineStaticMetaException(
'Exception in ' . __METHOD__ . ': ' . $e->getMessage(),
$e->getCode(),
$e
);
}
} | [
"public",
"function",
"getPlural",
"(",
")",
":",
"string",
"{",
"try",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"plural",
")",
"{",
"$",
"singular",
"=",
"$",
"this",
"->",
"getSingular",
"(",
")",
";",
"$",
"this",
"->",
"plural",
"=",
... | Get the property name the Entity is mapped by when plural
Override it in your entity class if you are using an Entity class name that doesn't pluralize nicely
@return string
@throws DoctrineStaticMetaException
@SuppressWarnings(PHPMD.StaticAccess) | [
"Get",
"the",
"property",
"name",
"the",
"Entity",
"is",
"mapped",
"by",
"when",
"plural"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/DoctrineStaticMeta.php#L326-L342 | train |
edmondscommerce/doctrine-static-meta | src/DoctrineStaticMeta.php | DoctrineStaticMeta.getSingular | public function getSingular(): string
{
try {
if (null === $this->singular) {
$reflectionClass = $this->getReflectionClass();
$shortName = $reflectionClass->getShortName();
$singularShortName = MappingHelper::singularize($shortName);
$namespaceName = $reflectionClass->getNamespaceName();
$namespaceParts = \explode(AbstractGenerator::ENTITIES_FOLDER_NAME, $namespaceName);
$entityNamespace = \array_pop($namespaceParts);
$namespacedShortName = \preg_replace(
'/\\\\/',
'',
$entityNamespace . $singularShortName
);
$this->singular = \lcfirst($namespacedShortName);
}
return $this->singular;
} catch (\Exception $e) {
throw new DoctrineStaticMetaException(
'Exception in ' . __METHOD__ . ': ' . $e->getMessage(),
$e->getCode(),
$e
);
}
} | php | public function getSingular(): string
{
try {
if (null === $this->singular) {
$reflectionClass = $this->getReflectionClass();
$shortName = $reflectionClass->getShortName();
$singularShortName = MappingHelper::singularize($shortName);
$namespaceName = $reflectionClass->getNamespaceName();
$namespaceParts = \explode(AbstractGenerator::ENTITIES_FOLDER_NAME, $namespaceName);
$entityNamespace = \array_pop($namespaceParts);
$namespacedShortName = \preg_replace(
'/\\\\/',
'',
$entityNamespace . $singularShortName
);
$this->singular = \lcfirst($namespacedShortName);
}
return $this->singular;
} catch (\Exception $e) {
throw new DoctrineStaticMetaException(
'Exception in ' . __METHOD__ . ': ' . $e->getMessage(),
$e->getCode(),
$e
);
}
} | [
"public",
"function",
"getSingular",
"(",
")",
":",
"string",
"{",
"try",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"singular",
")",
"{",
"$",
"reflectionClass",
"=",
"$",
"this",
"->",
"getReflectionClass",
"(",
")",
";",
"$",
"shortName",
"="... | Get the property the name the Entity is mapped by when singular
@return string
@throws DoctrineStaticMetaException
@SuppressWarnings(PHPMD.StaticAccess) | [
"Get",
"the",
"property",
"the",
"name",
"the",
"Entity",
"is",
"mapped",
"by",
"when",
"singular"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/DoctrineStaticMeta.php#L351-L381 | train |
edmondscommerce/doctrine-static-meta | src/DoctrineStaticMeta.php | DoctrineStaticMeta.getSetters | public function getSetters(): array
{
if (null !== $this->setters) {
return $this->setters;
}
$skip = [
'addPropertyChangedListener' => true,
'setEntityCollectionAndNotify' => true,
'addToEntityCollectionAndNotify' => true,
'setEntityAndNotify' => true,
];
$this->setters = [];
$reflectionClass = $this->getReflectionClass();
foreach ($reflectionClass->getMethods(
\ReflectionMethod::IS_PRIVATE | \ReflectionMethod::IS_PUBLIC
) as $method) {
$methodName = $method->getName();
if (isset($skip[$methodName])) {
continue;
}
if (\ts\stringStartsWith($methodName, 'set')) {
$this->setters[$this->getGetterForSetter($methodName)] = $methodName;
continue;
}
}
return $this->setters;
} | php | public function getSetters(): array
{
if (null !== $this->setters) {
return $this->setters;
}
$skip = [
'addPropertyChangedListener' => true,
'setEntityCollectionAndNotify' => true,
'addToEntityCollectionAndNotify' => true,
'setEntityAndNotify' => true,
];
$this->setters = [];
$reflectionClass = $this->getReflectionClass();
foreach ($reflectionClass->getMethods(
\ReflectionMethod::IS_PRIVATE | \ReflectionMethod::IS_PUBLIC
) as $method) {
$methodName = $method->getName();
if (isset($skip[$methodName])) {
continue;
}
if (\ts\stringStartsWith($methodName, 'set')) {
$this->setters[$this->getGetterForSetter($methodName)] = $methodName;
continue;
}
}
return $this->setters;
} | [
"public",
"function",
"getSetters",
"(",
")",
":",
"array",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"setters",
")",
"{",
"return",
"$",
"this",
"->",
"setters",
";",
"}",
"$",
"skip",
"=",
"[",
"'addPropertyChangedListener'",
"=>",
"true",
",... | Get an array of setters by name
@return array|string[] | [
"Get",
"an",
"array",
"of",
"setters",
"by",
"name"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/DoctrineStaticMeta.php#L407-L434 | train |
edmondscommerce/doctrine-static-meta | src/DoctrineStaticMeta.php | DoctrineStaticMeta.getGetters | public function getGetters(): array
{
if (null !== $this->getters) {
return $this->getters;
}
$skip = [
'getEntityFqn' => true,
'getDoctrineStaticMeta' => true,
'isValid' => true,
'getValidator' => true,
];
$this->getters = [];
$reflectionClass = $this->getReflectionClass();
foreach ($reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
$methodName = $method->getName();
if (isset($skip[$methodName])) {
continue;
}
if (\ts\stringStartsWith($methodName, 'get')) {
$this->getters[] = $methodName;
continue;
}
if (\ts\stringStartsWith($methodName, 'is')) {
$this->getters[] = $methodName;
continue;
}
if (\ts\stringStartsWith($methodName, 'has')) {
$this->getters[] = $methodName;
continue;
}
}
return $this->getters;
} | php | public function getGetters(): array
{
if (null !== $this->getters) {
return $this->getters;
}
$skip = [
'getEntityFqn' => true,
'getDoctrineStaticMeta' => true,
'isValid' => true,
'getValidator' => true,
];
$this->getters = [];
$reflectionClass = $this->getReflectionClass();
foreach ($reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
$methodName = $method->getName();
if (isset($skip[$methodName])) {
continue;
}
if (\ts\stringStartsWith($methodName, 'get')) {
$this->getters[] = $methodName;
continue;
}
if (\ts\stringStartsWith($methodName, 'is')) {
$this->getters[] = $methodName;
continue;
}
if (\ts\stringStartsWith($methodName, 'has')) {
$this->getters[] = $methodName;
continue;
}
}
return $this->getters;
} | [
"public",
"function",
"getGetters",
"(",
")",
":",
"array",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"getters",
")",
"{",
"return",
"$",
"this",
"->",
"getters",
";",
"}",
"$",
"skip",
"=",
"[",
"'getEntityFqn'",
"=>",
"true",
",",
"'getDoct... | Get an array of getters by name
@return array|string[]
@throws \ReflectionException | [
"Get",
"an",
"array",
"of",
"getters",
"by",
"name"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/DoctrineStaticMeta.php#L471-L505 | train |
chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopDiscount.class.php | TShopDiscount.IsActive | public function IsActive()
{
$sToday = date('Y-m-d H:i:s');
$bIsActive = ($this->fieldActive && ($this->fieldActiveFrom <= $sToday && ($this->fieldActiveTo >= $sToday || '0000-00-00 00:00:00' == $this->fieldActiveTo)));
return $bIsActive;
} | php | public function IsActive()
{
$sToday = date('Y-m-d H:i:s');
$bIsActive = ($this->fieldActive && ($this->fieldActiveFrom <= $sToday && ($this->fieldActiveTo >= $sToday || '0000-00-00 00:00:00' == $this->fieldActiveTo)));
return $bIsActive;
} | [
"public",
"function",
"IsActive",
"(",
")",
"{",
"$",
"sToday",
"=",
"date",
"(",
"'Y-m-d H:i:s'",
")",
";",
"$",
"bIsActive",
"=",
"(",
"$",
"this",
"->",
"fieldActive",
"&&",
"(",
"$",
"this",
"->",
"fieldActiveFrom",
"<=",
"$",
"sToday",
"&&",
"(",
... | return true if the discount is active.
@return bool | [
"return",
"true",
"if",
"the",
"discount",
"is",
"active",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopDiscount.class.php#L70-L76 | train |
chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopDiscount.class.php | TShopDiscount.GetValue | public function GetValue()
{
$dValue = $this->fieldValue;
$oBasket = TShopBasket::GetInstance();
$dBasketValueApplicableForDiscount = $oBasket->GetBasketSumForDiscount($this);
$dValue = $this->GetValueForBasketValue($dBasketValueApplicableForDiscount);
return $dValue;
} | php | public function GetValue()
{
$dValue = $this->fieldValue;
$oBasket = TShopBasket::GetInstance();
$dBasketValueApplicableForDiscount = $oBasket->GetBasketSumForDiscount($this);
$dValue = $this->GetValueForBasketValue($dBasketValueApplicableForDiscount);
return $dValue;
} | [
"public",
"function",
"GetValue",
"(",
")",
"{",
"$",
"dValue",
"=",
"$",
"this",
"->",
"fieldValue",
";",
"$",
"oBasket",
"=",
"TShopBasket",
"::",
"GetInstance",
"(",
")",
";",
"$",
"dBasketValueApplicableForDiscount",
"=",
"$",
"oBasket",
"->",
"GetBasket... | Returns the value of the discount - takes the current basket and user into consideration.
@return float | [
"Returns",
"the",
"value",
"of",
"the",
"discount",
"-",
"takes",
"the",
"current",
"basket",
"and",
"user",
"into",
"consideration",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopDiscount.class.php#L173-L181 | train |
chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopDiscount.class.php | TShopDiscount.AllowDiscountForArticle | public function AllowDiscountForArticle(TdbShopArticle $oArticle)
{
$bMayBeUsed = true;
if ($oArticle->fieldExcludeFromDiscounts) {
$bMayBeUsed = false;
}
// check article restrictions
if ($bMayBeUsed) {
$aArticleRestrictions = $this->GetFieldShopArticleWithInverseEmptySelectionLogicIdList();
if (null === $aArticleRestrictions || (count($aArticleRestrictions) > 0 && !in_array($oArticle->id, $aArticleRestrictions))) {
$bMayBeUsed = false;
}
}
// check category restrictions
if ($bMayBeUsed) {
$aCategoryRestrictions = $this->GetFieldShopCategoryWithInverseEmptySelectionLogicIdList();
if (null === $aCategoryRestrictions || (count($aCategoryRestrictions) > 0 && !$oArticle->IsInCategory($aCategoryRestrictions))) {
$bMayBeUsed = false;
}
}
return $bMayBeUsed;
} | php | public function AllowDiscountForArticle(TdbShopArticle $oArticle)
{
$bMayBeUsed = true;
if ($oArticle->fieldExcludeFromDiscounts) {
$bMayBeUsed = false;
}
// check article restrictions
if ($bMayBeUsed) {
$aArticleRestrictions = $this->GetFieldShopArticleWithInverseEmptySelectionLogicIdList();
if (null === $aArticleRestrictions || (count($aArticleRestrictions) > 0 && !in_array($oArticle->id, $aArticleRestrictions))) {
$bMayBeUsed = false;
}
}
// check category restrictions
if ($bMayBeUsed) {
$aCategoryRestrictions = $this->GetFieldShopCategoryWithInverseEmptySelectionLogicIdList();
if (null === $aCategoryRestrictions || (count($aCategoryRestrictions) > 0 && !$oArticle->IsInCategory($aCategoryRestrictions))) {
$bMayBeUsed = false;
}
}
return $bMayBeUsed;
} | [
"public",
"function",
"AllowDiscountForArticle",
"(",
"TdbShopArticle",
"$",
"oArticle",
")",
"{",
"$",
"bMayBeUsed",
"=",
"true",
";",
"if",
"(",
"$",
"oArticle",
"->",
"fieldExcludeFromDiscounts",
")",
"{",
"$",
"bMayBeUsed",
"=",
"false",
";",
"}",
"// chec... | return true if the discount may be used for the article.
@param TdbShopArticle $oArticle
@return bool | [
"return",
"true",
"if",
"the",
"discount",
"may",
"be",
"used",
"for",
"the",
"article",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopDiscount.class.php#L212-L236 | train |
chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopDiscount.class.php | TShopDiscount.ClearCacheOnAllAffectedArticles | public function ClearCacheOnAllAffectedArticles()
{
$iStartOperation = time();
$aArticleRestrictions = $this->GetMLTIdList('shop_article_mlt');
foreach ($aArticleRestrictions as $sArticelId) {
TCacheManager::PerformeTableChange('shop_article', $sArticelId);
}
$aCategoryRestrictons = $this->GetMLTIdList('shop_category_mlt');
$databaseConnection = $this->getDatabaseConnection();
if (count($aCategoryRestrictons) > 0) {
$quotedCategoryRestrictions = implode(',', array_map(array($databaseConnection, 'quote'), $aCategoryRestrictons));
$query = "SELECT `shop_article`.`id`
FROM `shop_article`
LEFT JOIN `shop_article_shop_category_mlt` ON `shop_article`.`id` = `shop_article_shop_category_mlt`.`source_id`
WHERE `shop_article`.`shop_category_id` IN ($quotedCategoryRestrictions)
OR `shop_article_shop_category_mlt`.`target_id` IN ($quotedCategoryRestrictions)
GROUP BY `shop_article`.`id`
";
$tRes = MySqlLegacySupport::getInstance()->query($query);
while ($aRes = MySqlLegacySupport::getInstance()->fetch_assoc($tRes)) {
TCacheManager::PerformeTableChange('shop_article', $aRes['id']);
}
}
if (0 === count($aArticleRestrictions) && 0 === count($aCategoryRestrictons)) {
TCacheManager::PerformeTableChange('shop_article', null);
}
$databaseConnection->update($this->table, array(
'cache_clear_last_executed' => date('Y-m-d H:i:s', $iStartOperation),
), array(
'id' => $this->id,
));
} | php | public function ClearCacheOnAllAffectedArticles()
{
$iStartOperation = time();
$aArticleRestrictions = $this->GetMLTIdList('shop_article_mlt');
foreach ($aArticleRestrictions as $sArticelId) {
TCacheManager::PerformeTableChange('shop_article', $sArticelId);
}
$aCategoryRestrictons = $this->GetMLTIdList('shop_category_mlt');
$databaseConnection = $this->getDatabaseConnection();
if (count($aCategoryRestrictons) > 0) {
$quotedCategoryRestrictions = implode(',', array_map(array($databaseConnection, 'quote'), $aCategoryRestrictons));
$query = "SELECT `shop_article`.`id`
FROM `shop_article`
LEFT JOIN `shop_article_shop_category_mlt` ON `shop_article`.`id` = `shop_article_shop_category_mlt`.`source_id`
WHERE `shop_article`.`shop_category_id` IN ($quotedCategoryRestrictions)
OR `shop_article_shop_category_mlt`.`target_id` IN ($quotedCategoryRestrictions)
GROUP BY `shop_article`.`id`
";
$tRes = MySqlLegacySupport::getInstance()->query($query);
while ($aRes = MySqlLegacySupport::getInstance()->fetch_assoc($tRes)) {
TCacheManager::PerformeTableChange('shop_article', $aRes['id']);
}
}
if (0 === count($aArticleRestrictions) && 0 === count($aCategoryRestrictons)) {
TCacheManager::PerformeTableChange('shop_article', null);
}
$databaseConnection->update($this->table, array(
'cache_clear_last_executed' => date('Y-m-d H:i:s', $iStartOperation),
), array(
'id' => $this->id,
));
} | [
"public",
"function",
"ClearCacheOnAllAffectedArticles",
"(",
")",
"{",
"$",
"iStartOperation",
"=",
"time",
"(",
")",
";",
"$",
"aArticleRestrictions",
"=",
"$",
"this",
"->",
"GetMLTIdList",
"(",
"'shop_article_mlt'",
")",
";",
"foreach",
"(",
"$",
"aArticleRe... | trigger a clear cache on all related articles. | [
"trigger",
"a",
"clear",
"cache",
"on",
"all",
"related",
"articles",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopDiscount.class.php#L345-L379 | train |
chameleon-system/chameleon-shop | src/ShopBundle/mappers/order/TPkgShopMapper_OrderArticleList.class.php | TPkgShopMapper_OrderArticleList.getArticleImageId | protected function getArticleImageId(TdbShopArticle $oArticle, IMapperCacheTriggerRestricted $oCacheTriggerManager, $bCachingEnabled, $sImageSizeName = 'basket')
{
$sImageId = '';
if (null !== $oArticle) {
$oImage = $oArticle->GetImagePreviewObject($sImageSizeName);
if (null !== $oImage) {
$sImageId = $oImage->fieldCmsMediaId;
}
if (empty($sImageId) || (is_numeric($sImageId) && $sImageId < 100)) {
$oPrimaryImage = $oArticle->GetPrimaryImage();
if (null !== $oPrimaryImage) {
$oImage = $oPrimaryImage->GetImage(0, 'images', true);
if (null !== $oImage) {
$sImageId = $oImage->id;
if ($bCachingEnabled) {
$oCacheTriggerManager->addTrigger('cms_media', $sImageId);
}
}
}
} else {
if ($bCachingEnabled) {
$oCacheTriggerManager->addTrigger('cms_media', $sImageId);
}
}
}
return $sImageId;
} | php | protected function getArticleImageId(TdbShopArticle $oArticle, IMapperCacheTriggerRestricted $oCacheTriggerManager, $bCachingEnabled, $sImageSizeName = 'basket')
{
$sImageId = '';
if (null !== $oArticle) {
$oImage = $oArticle->GetImagePreviewObject($sImageSizeName);
if (null !== $oImage) {
$sImageId = $oImage->fieldCmsMediaId;
}
if (empty($sImageId) || (is_numeric($sImageId) && $sImageId < 100)) {
$oPrimaryImage = $oArticle->GetPrimaryImage();
if (null !== $oPrimaryImage) {
$oImage = $oPrimaryImage->GetImage(0, 'images', true);
if (null !== $oImage) {
$sImageId = $oImage->id;
if ($bCachingEnabled) {
$oCacheTriggerManager->addTrigger('cms_media', $sImageId);
}
}
}
} else {
if ($bCachingEnabled) {
$oCacheTriggerManager->addTrigger('cms_media', $sImageId);
}
}
}
return $sImageId;
} | [
"protected",
"function",
"getArticleImageId",
"(",
"TdbShopArticle",
"$",
"oArticle",
",",
"IMapperCacheTriggerRestricted",
"$",
"oCacheTriggerManager",
",",
"$",
"bCachingEnabled",
",",
"$",
"sImageSizeName",
"=",
"'basket'",
")",
"{",
"$",
"sImageId",
"=",
"''",
"... | get the image id of connected article for given order item in the dimensions defined by the given image size identifier.
@param TdbShopArticle $oArticle
@param IMapperCacheTriggerRestricted $oCacheTriggerManager
@param bool $bCachingEnabled
@param string $sImageSizeName
@return string empty string or image id | [
"get",
"the",
"image",
"id",
"of",
"connected",
"article",
"for",
"given",
"order",
"item",
"in",
"the",
"dimensions",
"defined",
"by",
"the",
"given",
"image",
"size",
"identifier",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/mappers/order/TPkgShopMapper_OrderArticleList.class.php#L109-L136 | train |
Erebot/Erebot | src/Config/Proxy.php | Proxy.parseBoolHelper | public static function parseBoolHelper($value)
{
$value = strtolower($value);
if (in_array($value, array('true', '1', 'on', 'yes'), true)) {
return true;
}
if (in_array($value, array('false', '0', 'off', 'no'), true)) {
return false;
}
return null;
} | php | public static function parseBoolHelper($value)
{
$value = strtolower($value);
if (in_array($value, array('true', '1', 'on', 'yes'), true)) {
return true;
}
if (in_array($value, array('false', '0', 'off', 'no'), true)) {
return false;
}
return null;
} | [
"public",
"static",
"function",
"parseBoolHelper",
"(",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"strtolower",
"(",
"$",
"value",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"value",
",",
"array",
"(",
"'true'",
",",
"'1'",
",",
"'on'",
",",
"'yes'"... | Parses a text and tries to extract a boolean value.
\param string $value
The text from which a boolean should be extracted.
\retval bool
If a boolean could be extracted from the $value provided,
it is returned as the corresponding PHP boolean value
(either \b true or \b false).
\retval null
No boolean could be extracted.
\note
Currently, the following texts are recognized as \b true:
"true", "1", "on" & "yes", while the values
"false", "0", "off" & "no" are recognized as \b false.
The comparison is case-insensitive (ie. "true" == "TrUe"). | [
"Parses",
"a",
"text",
"and",
"tries",
"to",
"extract",
"a",
"boolean",
"value",
"."
] | 691fc3fa8bc6f07061ff2b3798fec76bc3a039aa | https://github.com/Erebot/Erebot/blob/691fc3fa8bc6f07061ff2b3798fec76bc3a039aa/src/Config/Proxy.php#L203-L213 | train |
Erebot/Erebot | src/Config/Proxy.php | Proxy.parseIntHelper | public static function parseIntHelper($value)
{
if ($value == '') {
return null;
}
if (is_int($value)) {
return $value;
}
if (ctype_digit($value)) {
return (int) $value;
}
if (strpos('+-', $value[0]) !== false && ctype_digit(substr($value, 1))) {
return (int) $value;
}
return null;
} | php | public static function parseIntHelper($value)
{
if ($value == '') {
return null;
}
if (is_int($value)) {
return $value;
}
if (ctype_digit($value)) {
return (int) $value;
}
if (strpos('+-', $value[0]) !== false && ctype_digit(substr($value, 1))) {
return (int) $value;
}
return null;
} | [
"public",
"static",
"function",
"parseIntHelper",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"==",
"''",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"is_int",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"if... | Parses a text and tries to extract an integer value.
\param string $value
The text from which an integer should be extracted.
\retval int
If an integer could be extracted from the $value provided,
it is returned as the corresponding PHP (signed) integer value.
\retval null
If no integer could be extracted. | [
"Parses",
"a",
"text",
"and",
"tries",
"to",
"extract",
"an",
"integer",
"value",
"."
] | 691fc3fa8bc6f07061ff2b3798fec76bc3a039aa | https://github.com/Erebot/Erebot/blob/691fc3fa8bc6f07061ff2b3798fec76bc3a039aa/src/Config/Proxy.php#L228-L247 | train |
Erebot/Erebot | src/Config/Proxy.php | Proxy.parseSomething | protected function parseSomething(
$module,
$param,
$default,
callable $parser,
$origin,
callable $checker
) {
try {
if (!isset($this->modules[$module])) {
throw new \Erebot\NotFoundException('No such module');
}
$value = $this->modules[$module]->getParam($param);
$value = $parser($value);
if ($value !== null) {
return $value;
}
throw new \Erebot\InvalidValueException(
'Bad value in configuration'
);
} catch (\Erebot\NotFoundException $e) {
if ($this->proxified !== $this) {
return $this->proxified->$origin($module, $param, $default);
}
if ($default === null) {
throw new \Erebot\NotFoundException('No such parameter "' .
$param . '" for module "' .
$module . '"');
}
if ($checker($default)) {
return $default;
}
throw new \Erebot\InvalidValueException('Bad default value');
}
} | php | protected function parseSomething(
$module,
$param,
$default,
callable $parser,
$origin,
callable $checker
) {
try {
if (!isset($this->modules[$module])) {
throw new \Erebot\NotFoundException('No such module');
}
$value = $this->modules[$module]->getParam($param);
$value = $parser($value);
if ($value !== null) {
return $value;
}
throw new \Erebot\InvalidValueException(
'Bad value in configuration'
);
} catch (\Erebot\NotFoundException $e) {
if ($this->proxified !== $this) {
return $this->proxified->$origin($module, $param, $default);
}
if ($default === null) {
throw new \Erebot\NotFoundException('No such parameter "' .
$param . '" for module "' .
$module . '"');
}
if ($checker($default)) {
return $default;
}
throw new \Erebot\InvalidValueException('Bad default value');
}
} | [
"protected",
"function",
"parseSomething",
"(",
"$",
"module",
",",
"$",
"param",
",",
"$",
"default",
",",
"callable",
"$",
"parser",
",",
"$",
"origin",
",",
"callable",
"$",
"checker",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this... | Returns the typed value for a module's parameter.
\param string $module
The name of the module.
\param string $param
The name of the parameter to fetch
from the module's settings.
\param mixed $default
Default value if no value has been
defined in the module's settings,
or \b null if there is no default value.
\param callable $parser
Object that will be used to parse the parameter.
It will receive the value of that parameter as a
string and should convert it to the proper type.
\param string $origin
Name of the method the request to parse
the parameter originated from.
\param callable $checker
Object that will be passed the parsed value
and should return \b true if it respects the
type constraints defined by this checker,
or \b false if it does not.
\retval mixed
Value as parsed from the module's settings,
or the default value if no value existed in
the settings and it passed the type check.
\throw Erebot::InvalidValueException
The value parsed or the default value did not
pass the type check.
\throw Erebot::NotFoundException | [
"Returns",
"the",
"typed",
"value",
"for",
"a",
"module",
"s",
"parameter",
"."
] | 691fc3fa8bc6f07061ff2b3798fec76bc3a039aa | https://github.com/Erebot/Erebot/blob/691fc3fa8bc6f07061ff2b3798fec76bc3a039aa/src/Config/Proxy.php#L313-L349 | train |
CHH/sirel | lib/Sirel/InsertManager.php | InsertManager.values | function values(array $values)
{
$cols = array();
$vals = array();
foreach ($values as $col => $val) {
if (null !== $val) {
$cols[] = $col;
$vals[] = $val;
}
}
foreach ($cols as &$col) {
$this->nodes->columns[] = new UnqualifiedColumn($col);
}
$this->nodes->values = array_merge($this->nodes->values, $vals);
return $this;
} | php | function values(array $values)
{
$cols = array();
$vals = array();
foreach ($values as $col => $val) {
if (null !== $val) {
$cols[] = $col;
$vals[] = $val;
}
}
foreach ($cols as &$col) {
$this->nodes->columns[] = new UnqualifiedColumn($col);
}
$this->nodes->values = array_merge($this->nodes->values, $vals);
return $this;
} | [
"function",
"values",
"(",
"array",
"$",
"values",
")",
"{",
"$",
"cols",
"=",
"array",
"(",
")",
";",
"$",
"vals",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"col",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"null",
"... | Column-Value-Pairs
@param array $values
@return InsertManager | [
"Column",
"-",
"Value",
"-",
"Pairs"
] | 7c32b8ed3b975dc18c0e5e257edfd11207e5c8a8 | https://github.com/CHH/sirel/blob/7c32b8ed3b975dc18c0e5e257edfd11207e5c8a8/lib/Sirel/InsertManager.php#L45-L63 | train |
CHH/sirel | lib/Sirel/InsertManager.php | InsertManager.columns | function columns(array $columns)
{
foreach ($columns as &$col) {
if (!$col instanceof Attribute) {
$col = new UnqualifiedColumn($col);
}
}
$this->nodes->columns = $columns;
return $this;
} | php | function columns(array $columns)
{
foreach ($columns as &$col) {
if (!$col instanceof Attribute) {
$col = new UnqualifiedColumn($col);
}
}
$this->nodes->columns = $columns;
return $this;
} | [
"function",
"columns",
"(",
"array",
"$",
"columns",
")",
"{",
"foreach",
"(",
"$",
"columns",
"as",
"&",
"$",
"col",
")",
"{",
"if",
"(",
"!",
"$",
"col",
"instanceof",
"Attribute",
")",
"{",
"$",
"col",
"=",
"new",
"UnqualifiedColumn",
"(",
"$",
... | Sets columns for this insert
@param array $columns
@return InsertManager | [
"Sets",
"columns",
"for",
"this",
"insert"
] | 7c32b8ed3b975dc18c0e5e257edfd11207e5c8a8 | https://github.com/CHH/sirel/blob/7c32b8ed3b975dc18c0e5e257edfd11207e5c8a8/lib/Sirel/InsertManager.php#L71-L80 | train |
chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopPaymentHandler/TShopPaymentHandlerDataTrans_SwissPostFinance.class.php | TShopPaymentHandlerDataTrans_SwissPostFinance.GetPaymentParameter | protected function GetPaymentParameter()
{
$aParameter = parent::GetPaymentParameter();
$aParameter['paymentmethod'] = 'POS';
$aParameter['paymenttype'] = self::PAYMENT_TYPE;
$aParameter['currency'] = 'CHF';
return $aParameter;
} | php | protected function GetPaymentParameter()
{
$aParameter = parent::GetPaymentParameter();
$aParameter['paymentmethod'] = 'POS';
$aParameter['paymenttype'] = self::PAYMENT_TYPE;
$aParameter['currency'] = 'CHF';
return $aParameter;
} | [
"protected",
"function",
"GetPaymentParameter",
"(",
")",
"{",
"$",
"aParameter",
"=",
"parent",
"::",
"GetPaymentParameter",
"(",
")",
";",
"$",
"aParameter",
"[",
"'paymentmethod'",
"]",
"=",
"'POS'",
";",
"$",
"aParameter",
"[",
"'paymenttype'",
"]",
"=",
... | Get hidden field parameter needed for payment.
Add payment type to hidden parameter to. was needed to check correct
payment method in authorisation response.
@return array | [
"Get",
"hidden",
"field",
"parameter",
"needed",
"for",
"payment",
".",
"Add",
"payment",
"type",
"to",
"hidden",
"parameter",
"to",
".",
"was",
"needed",
"to",
"check",
"correct",
"payment",
"method",
"in",
"authorisation",
"response",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopPaymentHandler/TShopPaymentHandlerDataTrans_SwissPostFinance.class.php#L90-L98 | train |
chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopPaymentHandler/TShopPaymentHandlerDataTrans_SwissPostFinance.class.php | TShopPaymentHandlerDataTrans_SwissPostFinance.AllowUse | public function AllowUse(TdbShopPaymentMethod &$oPaymentMethod)
{
$bAllowUse = parent::AllowUse($oPaymentMethod);
if ($bAllowUse) {
if (preg_match('/Chrome/i', $_SERVER['HTTP_USER_AGENT']) || preg_match('/Opera/i', $_SERVER['HTTP_USER_AGENT'])) {
$bAllowUse = false;
}
}
return $bAllowUse;
} | php | public function AllowUse(TdbShopPaymentMethod &$oPaymentMethod)
{
$bAllowUse = parent::AllowUse($oPaymentMethod);
if ($bAllowUse) {
if (preg_match('/Chrome/i', $_SERVER['HTTP_USER_AGENT']) || preg_match('/Opera/i', $_SERVER['HTTP_USER_AGENT'])) {
$bAllowUse = false;
}
}
return $bAllowUse;
} | [
"public",
"function",
"AllowUse",
"(",
"TdbShopPaymentMethod",
"&",
"$",
"oPaymentMethod",
")",
"{",
"$",
"bAllowUse",
"=",
"parent",
"::",
"AllowUse",
"(",
"$",
"oPaymentMethod",
")",
";",
"if",
"(",
"$",
"bAllowUse",
")",
"{",
"if",
"(",
"preg_match",
"(... | return true if the the payment handler may be used by the payment method passed.
you can use this hook to disable payment methods based on basket contents, payment method, user data, ...
Don't show payment PostFinance if user browser is Chrome or Opera. because PostFinance wont work with them.
@param TdbShopPaymentMethod $oPaymentMethod
@return bool | [
"return",
"true",
"if",
"the",
"the",
"payment",
"handler",
"may",
"be",
"used",
"by",
"the",
"payment",
"method",
"passed",
".",
"you",
"can",
"use",
"this",
"hook",
"to",
"disable",
"payment",
"methods",
"based",
"on",
"basket",
"contents",
"payment",
"m... | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopPaymentHandler/TShopPaymentHandlerDataTrans_SwissPostFinance.class.php#L142-L152 | train |
Firesphere/silverstripe-bootstrapmfa | src/Generators/CodeGenerator.php | CodeGenerator.generate | public function generate()
{
$chars = $this->validChars();
$numChars = strlen($chars) - 1;
$length = $this->getLength();
$code = array();
for ($i = 0; $i < $length; ++$i) {
$code[] = $chars[random_int(0, $numChars)];
}
return implode('', $code);
} | php | public function generate()
{
$chars = $this->validChars();
$numChars = strlen($chars) - 1;
$length = $this->getLength();
$code = array();
for ($i = 0; $i < $length; ++$i) {
$code[] = $chars[random_int(0, $numChars)];
}
return implode('', $code);
} | [
"public",
"function",
"generate",
"(",
")",
"{",
"$",
"chars",
"=",
"$",
"this",
"->",
"validChars",
"(",
")",
";",
"$",
"numChars",
"=",
"strlen",
"(",
"$",
"chars",
")",
"-",
"1",
";",
"$",
"length",
"=",
"$",
"this",
"->",
"getLength",
"(",
")... | Generate a random resulting string
@return string | [
"Generate",
"a",
"random",
"resulting",
"string"
] | 8d2d6c6f2f918c8fa157da91550b897816495a4b | https://github.com/Firesphere/silverstripe-bootstrapmfa/blob/8d2d6c6f2f918c8fa157da91550b897816495a4b/src/Generators/CodeGenerator.php#L127-L138 | train |
chameleon-system/chameleon-shop | src/ShopWishlistBundle/objects/db/TPkgShopWishlistArticle.class.php | TPkgShopWishlistArticle.GetCommentAsHTML | public function GetCommentAsHTML()
{
$sText = trim($this->fieldComment);
$sText = TGlobal::OutHTML($sText);
$sText = nl2br($sText);
return $sText;
} | php | public function GetCommentAsHTML()
{
$sText = trim($this->fieldComment);
$sText = TGlobal::OutHTML($sText);
$sText = nl2br($sText);
return $sText;
} | [
"public",
"function",
"GetCommentAsHTML",
"(",
")",
"{",
"$",
"sText",
"=",
"trim",
"(",
"$",
"this",
"->",
"fieldComment",
")",
";",
"$",
"sText",
"=",
"TGlobal",
"::",
"OutHTML",
"(",
"$",
"sText",
")",
";",
"$",
"sText",
"=",
"nl2br",
"(",
"$",
... | return comment text as html.
@return string | [
"return",
"comment",
"text",
"as",
"html",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopWishlistBundle/objects/db/TPkgShopWishlistArticle.class.php#L21-L28 | train |
chameleon-system/chameleon-shop | src/ShopWishlistBundle/objects/db/TPkgShopWishlistArticle.class.php | TPkgShopWishlistArticle.GetRemoveFromWishlistLink | public function GetRemoveFromWishlistLink($bIncludePortalLink = false)
{
$oShopConfig = TdbShop::GetInstance();
$aParameters = array('module_fnc['.$oShopConfig->GetBasketModuleSpotName().']' => 'RemoveFromWishlist', MTShopBasketCore::URL_ITEM_ID => $this->id, MTShopBasketCore::URL_MESSAGE_CONSUMER => MTShopBasketCore::MSG_CONSUMER_NAME);
return $this->getActivePageService()->getLinkToActivePageRelative($aParameters);
} | php | public function GetRemoveFromWishlistLink($bIncludePortalLink = false)
{
$oShopConfig = TdbShop::GetInstance();
$aParameters = array('module_fnc['.$oShopConfig->GetBasketModuleSpotName().']' => 'RemoveFromWishlist', MTShopBasketCore::URL_ITEM_ID => $this->id, MTShopBasketCore::URL_MESSAGE_CONSUMER => MTShopBasketCore::MSG_CONSUMER_NAME);
return $this->getActivePageService()->getLinkToActivePageRelative($aParameters);
} | [
"public",
"function",
"GetRemoveFromWishlistLink",
"(",
"$",
"bIncludePortalLink",
"=",
"false",
")",
"{",
"$",
"oShopConfig",
"=",
"TdbShop",
"::",
"GetInstance",
"(",
")",
";",
"$",
"aParameters",
"=",
"array",
"(",
"'module_fnc['",
".",
"$",
"oShopConfig",
... | get link to remove item from wishlist.
@param bool $bIncludePortalLink
@return string | [
"get",
"link",
"to",
"remove",
"item",
"from",
"wishlist",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopWishlistBundle/objects/db/TPkgShopWishlistArticle.class.php#L37-L43 | train |
edmondscommerce/doctrine-static-meta | src/CodeGeneration/Action/CreateEmbeddableAction.php | CreateEmbeddableAction.run | public function run(): void
{
if ('' === (string)$this->catName) {
throw new \RuntimeException('You must call setCatName before running this action');
}
if ('' === (string)$this->name) {
throw new \RuntimeException('You must call setName before running this action');
}
$this->fakerDataCreator->setCatName($this->catName)->setName($this->name)->createTargetFileObject()->write();
$this->interfaceCreator->setCatName($this->catName)->setName($this->name)->createTargetFileObject()->write();
$this->hasInterfaceCreator->setCatName($this->catName)->setName($this->name)->createTargetFileObject()->write();
$this->embeddableCreator->setCatName($this->catName)->setName($this->name)->createTargetFileObject()->write();
$this->hasCreator->setCatName($this->catName)->setName($this->name)->createTargetFileObject()->write();
} | php | public function run(): void
{
if ('' === (string)$this->catName) {
throw new \RuntimeException('You must call setCatName before running this action');
}
if ('' === (string)$this->name) {
throw new \RuntimeException('You must call setName before running this action');
}
$this->fakerDataCreator->setCatName($this->catName)->setName($this->name)->createTargetFileObject()->write();
$this->interfaceCreator->setCatName($this->catName)->setName($this->name)->createTargetFileObject()->write();
$this->hasInterfaceCreator->setCatName($this->catName)->setName($this->name)->createTargetFileObject()->write();
$this->embeddableCreator->setCatName($this->catName)->setName($this->name)->createTargetFileObject()->write();
$this->hasCreator->setCatName($this->catName)->setName($this->name)->createTargetFileObject()->write();
} | [
"public",
"function",
"run",
"(",
")",
":",
"void",
"{",
"if",
"(",
"''",
"===",
"(",
"string",
")",
"$",
"this",
"->",
"catName",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'You must call setCatName before running this action'",
")",
";",
"}"... | This must be the method that actually performs the action
All your requirements, configuration and dependencies must be called with individual setters | [
"This",
"must",
"be",
"the",
"method",
"that",
"actually",
"performs",
"the",
"action"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/CodeGeneration/Action/CreateEmbeddableAction.php#L65-L78 | train |
chameleon-system/chameleon-shop | src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/Samples/SimpleCheckoutExample.php | SimpleCheckoutExample.calculateOrderTotalBasedOnBuyerDetails | public function calculateOrderTotalBasedOnBuyerDetails($orderReferenceDetails, $orderAmountPreTaxAndShipping, $shippingType)
{
return $this->_shippingAndTaxCostHelper->calculateTotalAmount($orderReferenceDetails,
$orderAmountPreTaxAndShipping, $shippingType);
} | php | public function calculateOrderTotalBasedOnBuyerDetails($orderReferenceDetails, $orderAmountPreTaxAndShipping, $shippingType)
{
return $this->_shippingAndTaxCostHelper->calculateTotalAmount($orderReferenceDetails,
$orderAmountPreTaxAndShipping, $shippingType);
} | [
"public",
"function",
"calculateOrderTotalBasedOnBuyerDetails",
"(",
"$",
"orderReferenceDetails",
",",
"$",
"orderAmountPreTaxAndShipping",
",",
"$",
"shippingType",
")",
"{",
"return",
"$",
"this",
"->",
"_shippingAndTaxCostHelper",
"->",
"calculateTotalAmount",
"(",
"$... | Calculate the total amount to charge the buyer for this order,
based on the buyer destination address
Note that until the order is confirmed, the name & address fields will
not be returned to the client
@param OffAmazonPaymentsService_Model_OrderReferenceDetails $orderReferenceDetails response
@param string $orderAmountPreTaxAndShipping order amount
@param int $shippingType shipping type
@return float total amount for the order, with shipping and tax included | [
"Calculate",
"the",
"total",
"amount",
"to",
"charge",
"the",
"buyer",
"for",
"this",
"order",
"based",
"on",
"the",
"buyer",
"destination",
"address"
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/Samples/SimpleCheckoutExample.php#L115-L119 | train |
chameleon-system/chameleon-shop | src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/Samples/SimpleCheckoutExample.php | SimpleCheckoutExample.confirmOrderReference | public function confirmOrderReference()
{
$confirmOrderReferenceRequest
= new OffAmazonPaymentsService_Model_ConfirmOrderReferenceRequest();
$confirmOrderReferenceRequest
->setAmazonOrderReferenceId($this->_amazonOrderReferenceId);
$confirmOrderReferenceRequest->setSellerId($this->_sellerId);
return $this->_service->confirmOrderReference($confirmOrderReferenceRequest);
} | php | public function confirmOrderReference()
{
$confirmOrderReferenceRequest
= new OffAmazonPaymentsService_Model_ConfirmOrderReferenceRequest();
$confirmOrderReferenceRequest
->setAmazonOrderReferenceId($this->_amazonOrderReferenceId);
$confirmOrderReferenceRequest->setSellerId($this->_sellerId);
return $this->_service->confirmOrderReference($confirmOrderReferenceRequest);
} | [
"public",
"function",
"confirmOrderReference",
"(",
")",
"{",
"$",
"confirmOrderReferenceRequest",
"=",
"new",
"OffAmazonPaymentsService_Model_ConfirmOrderReferenceRequest",
"(",
")",
";",
"$",
"confirmOrderReferenceRequest",
"->",
"setAmazonOrderReferenceId",
"(",
"$",
"this... | Confirm the order reference information, allowing for
authorizations and captures to be created
@return OffAmazonPaymentsService_Model_ConfirmOrderReferenceResponse service response | [
"Confirm",
"the",
"order",
"reference",
"information",
"allowing",
"for",
"authorizations",
"and",
"captures",
"to",
"be",
"created"
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/Samples/SimpleCheckoutExample.php#L157-L166 | train |
chameleon-system/chameleon-shop | src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/Samples/SimpleCheckoutExample.php | SimpleCheckoutExample.captureOrderAmount | public function captureOrderAmount($captureAmount, $amazonAuthorizationId)
{
$captureRequest = new OffAmazonPaymentsService_Model_CaptureRequest();
$captureRequest->setSellerId($this->_sellerId);
$captureRequest->setAmazonAuthorizationId($amazonAuthorizationId);
$captureRequest->setCaptureReferenceId($this->_captureReferenceId);
$captureRequest->setCaptureAmount(new OffAmazonPaymentsService_Model_Price());
$captureRequest->getCaptureAmount()->setAmount($captureAmount);
$captureRequest->getCaptureAmount()->setCurrencyCode($this->_service->getMerchantValues()->getCurrency());
return $this->_service->capture($captureRequest);
} | php | public function captureOrderAmount($captureAmount, $amazonAuthorizationId)
{
$captureRequest = new OffAmazonPaymentsService_Model_CaptureRequest();
$captureRequest->setSellerId($this->_sellerId);
$captureRequest->setAmazonAuthorizationId($amazonAuthorizationId);
$captureRequest->setCaptureReferenceId($this->_captureReferenceId);
$captureRequest->setCaptureAmount(new OffAmazonPaymentsService_Model_Price());
$captureRequest->getCaptureAmount()->setAmount($captureAmount);
$captureRequest->getCaptureAmount()->setCurrencyCode($this->_service->getMerchantValues()->getCurrency());
return $this->_service->capture($captureRequest);
} | [
"public",
"function",
"captureOrderAmount",
"(",
"$",
"captureAmount",
",",
"$",
"amazonAuthorizationId",
")",
"{",
"$",
"captureRequest",
"=",
"new",
"OffAmazonPaymentsService_Model_CaptureRequest",
"(",
")",
";",
"$",
"captureRequest",
"->",
"setSellerId",
"(",
"$",... | Perform the capture call for the order
@param float $captureAmount amount to capture from the buyer
@param string $amazonAuthorizationId auth id to perform the capture on
@return OffAmazonPaymentsService_Model_CaptureResponse service response | [
"Perform",
"the",
"capture",
"call",
"for",
"the",
"order"
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/Samples/SimpleCheckoutExample.php#L248-L259 | train |
chameleon-system/chameleon-shop | src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/Samples/SimpleCheckoutExample.php | SimpleCheckoutExample.closeOrderReference | public function closeOrderReference()
{
$closeOrderReferenceRequest = new OffAmazonPaymentsService_Model_CloseOrderReferenceRequest();
$closeOrderReferenceRequest->setSellerId($this->_sellerId);
$closeOrderReferenceRequest->setAmazonOrderReferenceId($this->_amazonOrderReferenceId);
$closeOrderReferenceRequest->setClosureReason("Order complete");
return $this->_service->closeOrderReference($closeOrderReferenceRequest);
} | php | public function closeOrderReference()
{
$closeOrderReferenceRequest = new OffAmazonPaymentsService_Model_CloseOrderReferenceRequest();
$closeOrderReferenceRequest->setSellerId($this->_sellerId);
$closeOrderReferenceRequest->setAmazonOrderReferenceId($this->_amazonOrderReferenceId);
$closeOrderReferenceRequest->setClosureReason("Order complete");
return $this->_service->closeOrderReference($closeOrderReferenceRequest);
} | [
"public",
"function",
"closeOrderReference",
"(",
")",
"{",
"$",
"closeOrderReferenceRequest",
"=",
"new",
"OffAmazonPaymentsService_Model_CloseOrderReferenceRequest",
"(",
")",
";",
"$",
"closeOrderReferenceRequest",
"->",
"setSellerId",
"(",
"$",
"this",
"->",
"_sellerI... | Close this order reference to indicate that the order is complete, and
no further authorizations and captures will be performed on this order
@return OffAmazonPaymentsService_Model_CloseOrderReferenceResponse service response | [
"Close",
"this",
"order",
"reference",
"to",
"indicate",
"that",
"the",
"order",
"is",
"complete",
"and",
"no",
"further",
"authorizations",
"and",
"captures",
"will",
"be",
"performed",
"on",
"this",
"order"
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/Samples/SimpleCheckoutExample.php#L285-L293 | train |
chameleon-system/chameleon-shop | src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/RegionSpecificProperties.php | OffAmazonPaymentsService_RegionSpecificProperties.getWidgetUrlFor | public function getWidgetUrlFor($region, $environment, $merchantId, $overrideUrl)
{
return sprintf(self::WIDGET_FORMAT_STRING,
$this->_getWidgetHostFor($region, $overrideUrl),
$this->_getWidgetRegionFor($region),
$this->_getWidgetEnvironmentFor($environment),
urlencode($merchantId));
} | php | public function getWidgetUrlFor($region, $environment, $merchantId, $overrideUrl)
{
return sprintf(self::WIDGET_FORMAT_STRING,
$this->_getWidgetHostFor($region, $overrideUrl),
$this->_getWidgetRegionFor($region),
$this->_getWidgetEnvironmentFor($environment),
urlencode($merchantId));
} | [
"public",
"function",
"getWidgetUrlFor",
"(",
"$",
"region",
",",
"$",
"environment",
",",
"$",
"merchantId",
",",
"$",
"overrideUrl",
")",
"{",
"return",
"sprintf",
"(",
"self",
"::",
"WIDGET_FORMAT_STRING",
",",
"$",
"this",
"->",
"_getWidgetHostFor",
"(",
... | Return the correct widget url for the javascript widget
@param string $region
@param string $environment
@param string $merchantId
@param string $overrideUrl
@return string widgetUrl | [
"Return",
"the",
"correct",
"widget",
"url",
"for",
"the",
"javascript",
"widget"
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/RegionSpecificProperties.php#L69-L76 | train |
chameleon-system/chameleon-shop | src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/RegionSpecificProperties.php | OffAmazonPaymentsService_RegionSpecificProperties.getServiceUrlFor | public function getServiceUrlFor($region, $environment, $overrideUrl)
{
return sprintf(self::SERVICE_FORMAT_STRING,
$this->_getServiceHostFor($region, $overrideUrl),
$this->_getSectionNameFor($environment),
OffAmazonPaymentsService_Client::SERVICE_VERSION);
} | php | public function getServiceUrlFor($region, $environment, $overrideUrl)
{
return sprintf(self::SERVICE_FORMAT_STRING,
$this->_getServiceHostFor($region, $overrideUrl),
$this->_getSectionNameFor($environment),
OffAmazonPaymentsService_Client::SERVICE_VERSION);
} | [
"public",
"function",
"getServiceUrlFor",
"(",
"$",
"region",
",",
"$",
"environment",
",",
"$",
"overrideUrl",
")",
"{",
"return",
"sprintf",
"(",
"self",
"::",
"SERVICE_FORMAT_STRING",
",",
"$",
"this",
"->",
"_getServiceHostFor",
"(",
"$",
"region",
",",
... | Return the mws service for this region
@param string $region merchant region - us, na, uk, de
@param string $environment service - live, sandbox
@param string $overrideUrl override url
@return string mws service url | [
"Return",
"the",
"mws",
"service",
"for",
"this",
"region"
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/RegionSpecificProperties.php#L87-L93 | train |
chameleon-system/chameleon-shop | src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/RegionSpecificProperties.php | OffAmazonPaymentsService_RegionSpecificProperties.getCurrencyFor | public function getCurrencyFor($region)
{
$this->_validateRegionIsDefined($region, $this->_currencyCodes);
return $this->_currencyCodes[$region];
} | php | public function getCurrencyFor($region)
{
$this->_validateRegionIsDefined($region, $this->_currencyCodes);
return $this->_currencyCodes[$region];
} | [
"public",
"function",
"getCurrencyFor",
"(",
"$",
"region",
")",
"{",
"$",
"this",
"->",
"_validateRegionIsDefined",
"(",
"$",
"region",
",",
"$",
"this",
"->",
"_currencyCodes",
")",
";",
"return",
"$",
"this",
"->",
"_currencyCodes",
"[",
"$",
"region",
... | Get the currency code for the given region
@param string $region us,uk,de,na
@return string currency code | [
"Get",
"the",
"currency",
"code",
"for",
"the",
"given",
"region"
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/RegionSpecificProperties.php#L102-L106 | train |
chameleon-system/chameleon-shop | src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/RegionSpecificProperties.php | OffAmazonPaymentsService_RegionSpecificProperties._getWidgetHostFor | private function _getWidgetHostFor($region, $overrideUrl)
{
if (empty($overrideUrl)) {
return $this->_getRegionPropertyFor($region, $this->_widgetUrls);
}
return $overrideUrl;
} | php | private function _getWidgetHostFor($region, $overrideUrl)
{
if (empty($overrideUrl)) {
return $this->_getRegionPropertyFor($region, $this->_widgetUrls);
}
return $overrideUrl;
} | [
"private",
"function",
"_getWidgetHostFor",
"(",
"$",
"region",
",",
"$",
"overrideUrl",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"overrideUrl",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_getRegionPropertyFor",
"(",
"$",
"region",
",",
"$",
"this",
"->... | Return the correct host for the widget url based on the region
@param string $region us,uk,de,na
@param string $overrideUrl override string for widget host
@return string widget host | [
"Return",
"the",
"correct",
"host",
"for",
"the",
"widget",
"url",
"based",
"on",
"the",
"region"
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/RegionSpecificProperties.php#L116-L123 | train |
chameleon-system/chameleon-shop | src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/RegionSpecificProperties.php | OffAmazonPaymentsService_RegionSpecificProperties._getServiceHostFor | private function _getServiceHostFor($region, $overrideUrl)
{
if (empty($overrideUrl)) {
return $this->_getRegionPropertyFor($region, $this->_serviceUrls);
}
return $overrideUrl;
} | php | private function _getServiceHostFor($region, $overrideUrl)
{
if (empty($overrideUrl)) {
return $this->_getRegionPropertyFor($region, $this->_serviceUrls);
}
return $overrideUrl;
} | [
"private",
"function",
"_getServiceHostFor",
"(",
"$",
"region",
",",
"$",
"overrideUrl",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"overrideUrl",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_getRegionPropertyFor",
"(",
"$",
"region",
",",
"$",
"this",
"-... | Return the correct host for the service url based on the region
@param string $region us,uk,de,na
@param string $overrideUrl override string for service host
@return string mws host | [
"Return",
"the",
"correct",
"host",
"for",
"the",
"service",
"url",
"based",
"on",
"the",
"region"
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/RegionSpecificProperties.php#L133-L140 | train |
chameleon-system/chameleon-shop | src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/RegionSpecificProperties.php | OffAmazonPaymentsService_RegionSpecificProperties._getRegionPropertyFor | private function _getRegionPropertyFor($region, $properties)
{
$this->_validateRegionIsDefined($region, $this->_regionMappings);
return $properties[$this->_regionMappings[$region]];
} | php | private function _getRegionPropertyFor($region, $properties)
{
$this->_validateRegionIsDefined($region, $this->_regionMappings);
return $properties[$this->_regionMappings[$region]];
} | [
"private",
"function",
"_getRegionPropertyFor",
"(",
"$",
"region",
",",
"$",
"properties",
")",
"{",
"$",
"this",
"->",
"_validateRegionIsDefined",
"(",
"$",
"region",
",",
"$",
"this",
"->",
"_regionMappings",
")",
";",
"return",
"$",
"properties",
"[",
"$... | Return the correct value for this region from an
associate array keyed by realms
@param string $region us,uk,de,na
@param array $properties associate array of realms to property values
@return string property for region | [
"Return",
"the",
"correct",
"value",
"for",
"this",
"region",
"from",
"an",
"associate",
"array",
"keyed",
"by",
"realms"
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/RegionSpecificProperties.php#L151-L155 | train |
chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopShippingGroup.class.php | TShopShippingGroup.& | public function &GetValidPaymentMethods($bRefresh = false)
{
if (is_null($this->oValidPaymentMethods) || $bRefresh) {
$this->oValidPaymentMethods = &TdbShopPaymentMethodList::GetAvailableMethods($this->id);
$this->oValidPaymentMethods->bAllowItemCache = true;
}
if (!is_null($this->oValidPaymentMethods)) {
$this->oValidPaymentMethods->GoToStart();
}
return $this->oValidPaymentMethods;
} | php | public function &GetValidPaymentMethods($bRefresh = false)
{
if (is_null($this->oValidPaymentMethods) || $bRefresh) {
$this->oValidPaymentMethods = &TdbShopPaymentMethodList::GetAvailableMethods($this->id);
$this->oValidPaymentMethods->bAllowItemCache = true;
}
if (!is_null($this->oValidPaymentMethods)) {
$this->oValidPaymentMethods->GoToStart();
}
return $this->oValidPaymentMethods;
} | [
"public",
"function",
"&",
"GetValidPaymentMethods",
"(",
"$",
"bRefresh",
"=",
"false",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"oValidPaymentMethods",
")",
"||",
"$",
"bRefresh",
")",
"{",
"$",
"this",
"->",
"oValidPaymentMethods",
"=",
"... | return list of valid payment methods.
@param bool $bRefresh - set to true to force a regeneration of the list
@return TdbShopPaymentMethodList | [
"return",
"list",
"of",
"valid",
"payment",
"methods",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopShippingGroup.class.php#L340-L351 | train |
chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopShippingGroup.class.php | TShopShippingGroup.GetVat | public function GetVat()
{
$oVat = $this->GetFromInternalCache('ovat');
if (is_null($oVat)) {
$oVat = null;
$oShopConf = TdbShop::GetInstance();
if (!$oShopConf->fieldShippingVatDependsOnBasketContents) {
$oVat = $this->GetFieldShopVat();
if (is_null($oVat)) {
$oShopConf = TdbShop::GetInstance();
$oVat = $oShopConf->GetVat();
}
$this->SetInternalCache('ovat', $oVat);
} else {
// use max vat in basket... if we have contents
$oBasket = TShopBasket::GetInstance();
$oVat = $oBasket->GetLargestVATObject();
}
}
return $oVat;
} | php | public function GetVat()
{
$oVat = $this->GetFromInternalCache('ovat');
if (is_null($oVat)) {
$oVat = null;
$oShopConf = TdbShop::GetInstance();
if (!$oShopConf->fieldShippingVatDependsOnBasketContents) {
$oVat = $this->GetFieldShopVat();
if (is_null($oVat)) {
$oShopConf = TdbShop::GetInstance();
$oVat = $oShopConf->GetVat();
}
$this->SetInternalCache('ovat', $oVat);
} else {
// use max vat in basket... if we have contents
$oBasket = TShopBasket::GetInstance();
$oVat = $oBasket->GetLargestVATObject();
}
}
return $oVat;
} | [
"public",
"function",
"GetVat",
"(",
")",
"{",
"$",
"oVat",
"=",
"$",
"this",
"->",
"GetFromInternalCache",
"(",
"'ovat'",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"oVat",
")",
")",
"{",
"$",
"oVat",
"=",
"null",
";",
"$",
"oShopConf",
"=",
"TdbSh... | return the vat group for this shipping group.
@return TdbShopVat | [
"return",
"the",
"vat",
"group",
"for",
"this",
"shipping",
"group",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopShippingGroup.class.php#L420-L441 | train |
chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopShippingGroup.class.php | TShopShippingGroup.GetValidPaymentMethodsSelectableByTheUser | public function GetValidPaymentMethodsSelectableByTheUser()
{
$oPaymentMethods = clone $this->GetValidPaymentMethods(true);
$aInvalidMethods = array();
$oPaymentMethods->GoToStart();
while ($oPaymentMethod = $oPaymentMethods->Next()) {
$oHandler = $oPaymentMethod->GetFieldShopPaymentHandler();
if ($oHandler && $oHandler->isBlockForUserSelection()) {
$aInvalidMethods[] = MySqlLegacySupport::getInstance()->real_escape_string($oPaymentMethod->id);
}
}
if (count($aInvalidMethods) > 0) {
$oPaymentMethods->AddFilterString("`shop_payment_method`.`id` NOT IN ('".implode("','", $aInvalidMethods)."')");
}
$oPaymentMethods->GoToStart();
return $oPaymentMethods;
} | php | public function GetValidPaymentMethodsSelectableByTheUser()
{
$oPaymentMethods = clone $this->GetValidPaymentMethods(true);
$aInvalidMethods = array();
$oPaymentMethods->GoToStart();
while ($oPaymentMethod = $oPaymentMethods->Next()) {
$oHandler = $oPaymentMethod->GetFieldShopPaymentHandler();
if ($oHandler && $oHandler->isBlockForUserSelection()) {
$aInvalidMethods[] = MySqlLegacySupport::getInstance()->real_escape_string($oPaymentMethod->id);
}
}
if (count($aInvalidMethods) > 0) {
$oPaymentMethods->AddFilterString("`shop_payment_method`.`id` NOT IN ('".implode("','", $aInvalidMethods)."')");
}
$oPaymentMethods->GoToStart();
return $oPaymentMethods;
} | [
"public",
"function",
"GetValidPaymentMethodsSelectableByTheUser",
"(",
")",
"{",
"$",
"oPaymentMethods",
"=",
"clone",
"$",
"this",
"->",
"GetValidPaymentMethods",
"(",
"true",
")",
";",
"$",
"aInvalidMethods",
"=",
"array",
"(",
")",
";",
"$",
"oPaymentMethods",... | return a the active list of payment handlers reduced to those, that the user may select in the payment step.
@return TdbShopPaymentMethodList | [
"return",
"a",
"the",
"active",
"list",
"of",
"payment",
"handlers",
"reduced",
"to",
"those",
"that",
"the",
"user",
"may",
"select",
"in",
"the",
"payment",
"step",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopShippingGroup.class.php#L472-L489 | train |
chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopShippingGroup.class.php | TShopShippingGroup.GetValidShippingTypesForBasketArticleListAndCountry | public function GetValidShippingTypesForBasketArticleListAndCountry($oBasketArticleList, $sDataCountryId)
{
$oValidShippingTypes = new TIterator();
/** @var $oValidShippingTypes TIterator* */
$oShippingTypes = $this->GetFieldShopShippingTypeList('position');
while ($oShippingType = $oShippingTypes->Next()) {
$bIsValid = $oShippingType->IsActive();
$bIsValid = $bIsValid && $oShippingType->isValidForCurrentPortal();
$bIsValid = $bIsValid && $oShippingType->IsValidForCurrentUser(false);
$bIsValid = $bIsValid && $oShippingType->IsValidForCountry($sDataCountryId);
if ($bIsValid) {
$oAffectedArticles = $oBasketArticleList->GetArticlesAffectedByShippingType($oShippingType);
$bIsValid = ($oAffectedArticles->Length() > 0);
}
if ($bIsValid) {
$oValidShippingTypes->AddItem($oShippingType);
}
}
return $oValidShippingTypes;
} | php | public function GetValidShippingTypesForBasketArticleListAndCountry($oBasketArticleList, $sDataCountryId)
{
$oValidShippingTypes = new TIterator();
/** @var $oValidShippingTypes TIterator* */
$oShippingTypes = $this->GetFieldShopShippingTypeList('position');
while ($oShippingType = $oShippingTypes->Next()) {
$bIsValid = $oShippingType->IsActive();
$bIsValid = $bIsValid && $oShippingType->isValidForCurrentPortal();
$bIsValid = $bIsValid && $oShippingType->IsValidForCurrentUser(false);
$bIsValid = $bIsValid && $oShippingType->IsValidForCountry($sDataCountryId);
if ($bIsValid) {
$oAffectedArticles = $oBasketArticleList->GetArticlesAffectedByShippingType($oShippingType);
$bIsValid = ($oAffectedArticles->Length() > 0);
}
if ($bIsValid) {
$oValidShippingTypes->AddItem($oShippingType);
}
}
return $oValidShippingTypes;
} | [
"public",
"function",
"GetValidShippingTypesForBasketArticleListAndCountry",
"(",
"$",
"oBasketArticleList",
",",
"$",
"sDataCountryId",
")",
"{",
"$",
"oValidShippingTypes",
"=",
"new",
"TIterator",
"(",
")",
";",
"/** @var $oValidShippingTypes TIterator* */",
"$",
"oShipp... | Get a list of shipping types based on a basket article list and the desired shipping country id.
@param TShopBasketArticleList $oBasketArticleList
@param string $sDataCountryId
@return TIterator | [
"Get",
"a",
"list",
"of",
"shipping",
"types",
"based",
"on",
"a",
"basket",
"article",
"list",
"and",
"the",
"desired",
"shipping",
"country",
"id",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopShippingGroup.class.php#L515-L535 | train |
chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopShippingGroup.class.php | TShopShippingGroup.GetShippingCostsForBasketArticleListAndCountry | public function GetShippingCostsForBasketArticleListAndCountry($oBasketArticleList, $sDataCountryId)
{
/** @var Request $request */
$request = \ChameleonSystem\CoreBundle\ServiceLocator::get('request_stack')->getCurrentRequest();
$oBasketArticleList->GoToStart();
$oOldBasket = clone TShopBasket::GetInstance();
$oOldUser = clone TdbDataExtranetUser::GetInstance();
$oTmpBasket = new TShopBasket();
$request->getSession()->set(TShopBasket::SESSION_KEY_NAME, $oTmpBasket);
$oTmpUser = TdbDataExtranetUser::GetNewInstance();
$oTmpShippingAddress = TdbDataExtranetUserAddress::GetNewInstance();
$oTmpShippingAddress->fieldDataCountryId = $sDataCountryId;
$oTmpShippingAddress->sqlData['data_country_id'] = $sDataCountryId;
$oTmpShippingAddress->sqlData['lastname'] = 'Dummy';
$oTmpShippingAddress->fieldLastname = 'Dummy';
$oTmpShippingAddress->sqlData['city'] = 'Dummy';
$oTmpUser->setFakedShippingAddressForUser($oTmpShippingAddress);
$oTmpUser->fieldDataCountryId = $sDataCountryId;
$oTmpUser->sqlData['data_country_id'] = $sDataCountryId;
$oTmpUser->sqlData['lastname'] = 'Dummy';
$oTmpUser->sqlData['city'] = 'Dummy';
$request->getSession()->set(TdbDataExtranetUser::SESSION_KEY_NAME, $oTmpUser);
while ($oBasketArticle = $oBasketArticleList->Next()) {
$oTmpBasket->AddItem($oBasketArticle);
}
$oTmpBasket->SetActiveShippingGroup($this);
$oTmpBasket->RecalculateBasket();
$oTmpBasket->ResetAllShippingMarkers();
$dShippingCosts = $oTmpBasket->dCostShipping;
$request->getSession()->set(TShopBasket::SESSION_KEY_NAME, $oOldBasket);
$request->getSession()->set(TdbDataExtranetUser::SESSION_KEY_NAME, $oOldUser);
return $dShippingCosts;
} | php | public function GetShippingCostsForBasketArticleListAndCountry($oBasketArticleList, $sDataCountryId)
{
/** @var Request $request */
$request = \ChameleonSystem\CoreBundle\ServiceLocator::get('request_stack')->getCurrentRequest();
$oBasketArticleList->GoToStart();
$oOldBasket = clone TShopBasket::GetInstance();
$oOldUser = clone TdbDataExtranetUser::GetInstance();
$oTmpBasket = new TShopBasket();
$request->getSession()->set(TShopBasket::SESSION_KEY_NAME, $oTmpBasket);
$oTmpUser = TdbDataExtranetUser::GetNewInstance();
$oTmpShippingAddress = TdbDataExtranetUserAddress::GetNewInstance();
$oTmpShippingAddress->fieldDataCountryId = $sDataCountryId;
$oTmpShippingAddress->sqlData['data_country_id'] = $sDataCountryId;
$oTmpShippingAddress->sqlData['lastname'] = 'Dummy';
$oTmpShippingAddress->fieldLastname = 'Dummy';
$oTmpShippingAddress->sqlData['city'] = 'Dummy';
$oTmpUser->setFakedShippingAddressForUser($oTmpShippingAddress);
$oTmpUser->fieldDataCountryId = $sDataCountryId;
$oTmpUser->sqlData['data_country_id'] = $sDataCountryId;
$oTmpUser->sqlData['lastname'] = 'Dummy';
$oTmpUser->sqlData['city'] = 'Dummy';
$request->getSession()->set(TdbDataExtranetUser::SESSION_KEY_NAME, $oTmpUser);
while ($oBasketArticle = $oBasketArticleList->Next()) {
$oTmpBasket->AddItem($oBasketArticle);
}
$oTmpBasket->SetActiveShippingGroup($this);
$oTmpBasket->RecalculateBasket();
$oTmpBasket->ResetAllShippingMarkers();
$dShippingCosts = $oTmpBasket->dCostShipping;
$request->getSession()->set(TShopBasket::SESSION_KEY_NAME, $oOldBasket);
$request->getSession()->set(TdbDataExtranetUser::SESSION_KEY_NAME, $oOldUser);
return $dShippingCosts;
} | [
"public",
"function",
"GetShippingCostsForBasketArticleListAndCountry",
"(",
"$",
"oBasketArticleList",
",",
"$",
"sDataCountryId",
")",
"{",
"/** @var Request $request */",
"$",
"request",
"=",
"\\",
"ChameleonSystem",
"\\",
"CoreBundle",
"\\",
"ServiceLocator",
"::",
"g... | Calculate the shipping costs for a basket article list to be expected for a certain shipping country id.
@param TShopBasketArticleList $oBasketArticleList
@param string $sDataCountryId
@return float | [
"Calculate",
"the",
"shipping",
"costs",
"for",
"a",
"basket",
"article",
"list",
"to",
"be",
"expected",
"for",
"a",
"certain",
"shipping",
"country",
"id",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopShippingGroup.class.php#L545-L591 | train |
chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopVoucherSeries.class.php | TShopVoucherSeries.NumberOfTimesUsedByUser | public function NumberOfTimesUsedByUser($iDataExtranetUserId = null, $aExcludeVouchers = array())
{
$iNumberOfVouchersUsed = 0;
if (is_null($iDataExtranetUserId)) {
$oUser = TdbDataExtranetUser::GetInstance();
$iDataExtranetUserId = $oUser->id;
}
$sRestriction = '';
if (count($aExcludeVouchers) > 0) {
$aExcludeVouchers = TTools::MysqlRealEscapeArray($aExcludeVouchers);
$sRestriction = "AND `shop_voucher`.`id` NOT IN ('".implode("','", $aExcludeVouchers)."')";
}
$query = "SELECT COUNT(DISTINCT `shop_voucher`.`id`) AS number_of_vouchers
FROM `shop_voucher_use`
INNER JOIN `shop_voucher` ON `shop_voucher_use`.`shop_voucher_id` = `shop_voucher`.`id`
INNER JOIN `shop_order` ON `shop_voucher_use`.`shop_order_id` = `shop_order`.`id`
WHERE `shop_order`.`data_extranet_user_id` = '".MySqlLegacySupport::getInstance()->real_escape_string($iDataExtranetUserId)."'
AND `shop_voucher`.`shop_voucher_series_id` = '".MySqlLegacySupport::getInstance()->real_escape_string($this->id)."'
{$sRestriction}
GROUP BY `shop_voucher`.`shop_voucher_series_id`
";
if ($aTmpRow = MySqlLegacySupport::getInstance()->fetch_assoc(MySqlLegacySupport::getInstance()->query($query))) {
$iNumberOfVouchersUsed = $aTmpRow['number_of_vouchers'];
}
return $iNumberOfVouchersUsed;
} | php | public function NumberOfTimesUsedByUser($iDataExtranetUserId = null, $aExcludeVouchers = array())
{
$iNumberOfVouchersUsed = 0;
if (is_null($iDataExtranetUserId)) {
$oUser = TdbDataExtranetUser::GetInstance();
$iDataExtranetUserId = $oUser->id;
}
$sRestriction = '';
if (count($aExcludeVouchers) > 0) {
$aExcludeVouchers = TTools::MysqlRealEscapeArray($aExcludeVouchers);
$sRestriction = "AND `shop_voucher`.`id` NOT IN ('".implode("','", $aExcludeVouchers)."')";
}
$query = "SELECT COUNT(DISTINCT `shop_voucher`.`id`) AS number_of_vouchers
FROM `shop_voucher_use`
INNER JOIN `shop_voucher` ON `shop_voucher_use`.`shop_voucher_id` = `shop_voucher`.`id`
INNER JOIN `shop_order` ON `shop_voucher_use`.`shop_order_id` = `shop_order`.`id`
WHERE `shop_order`.`data_extranet_user_id` = '".MySqlLegacySupport::getInstance()->real_escape_string($iDataExtranetUserId)."'
AND `shop_voucher`.`shop_voucher_series_id` = '".MySqlLegacySupport::getInstance()->real_escape_string($this->id)."'
{$sRestriction}
GROUP BY `shop_voucher`.`shop_voucher_series_id`
";
if ($aTmpRow = MySqlLegacySupport::getInstance()->fetch_assoc(MySqlLegacySupport::getInstance()->query($query))) {
$iNumberOfVouchersUsed = $aTmpRow['number_of_vouchers'];
}
return $iNumberOfVouchersUsed;
} | [
"public",
"function",
"NumberOfTimesUsedByUser",
"(",
"$",
"iDataExtranetUserId",
"=",
"null",
",",
"$",
"aExcludeVouchers",
"=",
"array",
"(",
")",
")",
"{",
"$",
"iNumberOfVouchersUsed",
"=",
"0",
";",
"if",
"(",
"is_null",
"(",
"$",
"iDataExtranetUserId",
"... | returns the number of vouchers from that series that have been used by the user (note, we count
also the vouchers that have been used in part only.
@param int $iDataExtranetUserId (if null, use the current user)
@param array $aExcludeVouchers - the voucher ids to exclude from the count
@return int | [
"returns",
"the",
"number",
"of",
"vouchers",
"from",
"that",
"series",
"that",
"have",
"been",
"used",
"by",
"the",
"user",
"(",
"note",
"we",
"count",
"also",
"the",
"vouchers",
"that",
"have",
"been",
"used",
"in",
"part",
"only",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopVoucherSeries.class.php#L44-L73 | train |
chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopVoucherSeries.class.php | TShopVoucherSeries.CreateNewVoucher | public function CreateNewVoucher($sCode = null)
{
if (is_null($sCode)) {
$bCodeUnique = false;
$dMaxTry = 15;
$sCode = '';
while (!$bCodeUnique && $dMaxTry > 0) {
--$dMaxTry;
$sCode = TdbShopVoucher::GenerateVoucherCode();
$query = "SELECT * FROM `shop_voucher` WHERE `code` = '".MySqlLegacySupport::getInstance()->real_escape_string($sCode)."'";
$tRes = MySqlLegacySupport::getInstance()->query($query);
if (0 == MySqlLegacySupport::getInstance()->num_rows($tRes)) {
$bCodeUnique = true;
}
}
}
$aData = array('shop_voucher_series_id' => $this->id, 'code' => $sCode, 'datecreated' => date('Y-m-d H:i:s'));
$oVoucher = TdbShopVoucher::GetNewInstance();
$oVoucher->LoadFromRow($aData);
$oVoucher->AllowEditByAll();
$oVoucher->Save();
return $oVoucher;
} | php | public function CreateNewVoucher($sCode = null)
{
if (is_null($sCode)) {
$bCodeUnique = false;
$dMaxTry = 15;
$sCode = '';
while (!$bCodeUnique && $dMaxTry > 0) {
--$dMaxTry;
$sCode = TdbShopVoucher::GenerateVoucherCode();
$query = "SELECT * FROM `shop_voucher` WHERE `code` = '".MySqlLegacySupport::getInstance()->real_escape_string($sCode)."'";
$tRes = MySqlLegacySupport::getInstance()->query($query);
if (0 == MySqlLegacySupport::getInstance()->num_rows($tRes)) {
$bCodeUnique = true;
}
}
}
$aData = array('shop_voucher_series_id' => $this->id, 'code' => $sCode, 'datecreated' => date('Y-m-d H:i:s'));
$oVoucher = TdbShopVoucher::GetNewInstance();
$oVoucher->LoadFromRow($aData);
$oVoucher->AllowEditByAll();
$oVoucher->Save();
return $oVoucher;
} | [
"public",
"function",
"CreateNewVoucher",
"(",
"$",
"sCode",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"sCode",
")",
")",
"{",
"$",
"bCodeUnique",
"=",
"false",
";",
"$",
"dMaxTry",
"=",
"15",
";",
"$",
"sCode",
"=",
"''",
";",
"while"... | create a new voucher.
@param string $sCode - code to create
@return TdbShopVoucher | [
"create",
"a",
"new",
"voucher",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopVoucherSeries.class.php#L82-L105 | train |
Erebot/Erebot | src/CLI.php | CLI.cleanupPidfile | public static function cleanupPidfile($handle, $pidfile)
{
flock($handle, LOCK_UN);
@unlink($pidfile);
$logger = \Plop\Plop::getInstance();
$logger->debug(
'Removed lock on pidfile (%(pidfile)s)',
array('pidfile' => $pidfile)
);
} | php | public static function cleanupPidfile($handle, $pidfile)
{
flock($handle, LOCK_UN);
@unlink($pidfile);
$logger = \Plop\Plop::getInstance();
$logger->debug(
'Removed lock on pidfile (%(pidfile)s)',
array('pidfile' => $pidfile)
);
} | [
"public",
"static",
"function",
"cleanupPidfile",
"(",
"$",
"handle",
",",
"$",
"pidfile",
")",
"{",
"flock",
"(",
"$",
"handle",
",",
"LOCK_UN",
")",
";",
"@",
"unlink",
"(",
"$",
"pidfile",
")",
";",
"$",
"logger",
"=",
"\\",
"Plop",
"\\",
"Plop",
... | Called after the bot has finished its execution
to perform cleanup tasks.
\param resource $handle
Open file handle on the pidfile.
\param string $pidfile
Name of the pidfile.
\return
This method does not return anything. | [
"Called",
"after",
"the",
"bot",
"has",
"finished",
"its",
"execution",
"to",
"perform",
"cleanup",
"tasks",
"."
] | 691fc3fa8bc6f07061ff2b3798fec76bc3a039aa | https://github.com/Erebot/Erebot/blob/691fc3fa8bc6f07061ff2b3798fec76bc3a039aa/src/CLI.php#L68-L77 | train |
chameleon-system/chameleon-shop | src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsNotifications/Impl/OpenSslVerifySignature.php | OpenSslVerifySignature.verifySignatureIsCorrect | public function verifySignatureIsCorrect($data, $signature, $certificatePath)
{
$cert = $this->_getCertificateFromCertifcatePath($certificatePath);
$certKey = openssl_get_publickey($cert);
if ($certKey === False) {
throw new OffAmazonPaymentsNotifications_InvalidMessageException(
"Unable to extract public key from cert " . $cert);
}
$result = -1;
try {
$result = openssl_verify($data, $signature, $certKey, OPENSSL_ALGO_SHA1);
} catch (Exception $ex) {
throw new OffAmazonPaymentsNotifications_InvalidMessageException(
"Unable to verify signature - error with the verification algorithm",
null, $ex
);
}
return ($result > 0);
} | php | public function verifySignatureIsCorrect($data, $signature, $certificatePath)
{
$cert = $this->_getCertificateFromCertifcatePath($certificatePath);
$certKey = openssl_get_publickey($cert);
if ($certKey === False) {
throw new OffAmazonPaymentsNotifications_InvalidMessageException(
"Unable to extract public key from cert " . $cert);
}
$result = -1;
try {
$result = openssl_verify($data, $signature, $certKey, OPENSSL_ALGO_SHA1);
} catch (Exception $ex) {
throw new OffAmazonPaymentsNotifications_InvalidMessageException(
"Unable to verify signature - error with the verification algorithm",
null, $ex
);
}
return ($result > 0);
} | [
"public",
"function",
"verifySignatureIsCorrect",
"(",
"$",
"data",
",",
"$",
"signature",
",",
"$",
"certificatePath",
")",
"{",
"$",
"cert",
"=",
"$",
"this",
"->",
"_getCertificateFromCertifcatePath",
"(",
"$",
"certificatePath",
")",
";",
"$",
"certKey",
"... | Verify that the signature is correct for the given data and
public key
@param string $data data to validate
@param string $signature decoded signature to compare against
@param string $certificatePath path to certificate, can be file or url
@throws OffAmazonPaymentsNotifications_InvalidMessageException if there
is an error
with the call
@return bool true if valid | [
"Verify",
"that",
"the",
"signature",
"is",
"correct",
"for",
"the",
"given",
"data",
"and",
"public",
"key"
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsNotifications/Impl/OpenSslVerifySignature.php#L53-L75 | train |
chameleon-system/chameleon-shop | src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsNotifications/Impl/OpenSslVerifySignature.php | OpenSslVerifySignature._getCertificateFromCertifcatePath | private function _getCertificateFromCertifcatePath($certificatePath)
{
$this->_validateUrl($certificatePath); //ADDED EXTRA CHECK
try {
$cert = file_get_contents($certificatePath);
} catch (Exception $ex) {
throw new OffAmazonPaymentsNotifications_InvalidMessageException(
"Error with signature validation - unable to request signing ".
"certificate at " . $certificatePath, null, $ex
);
}
if ($cert === false) {
throw new OffAmazonPaymentsNotifications_InvalidMessageException(
"Error with signature validation - unable to request signing ".
"certificate at " . $certificatePath
);
}
return $cert;
} | php | private function _getCertificateFromCertifcatePath($certificatePath)
{
$this->_validateUrl($certificatePath); //ADDED EXTRA CHECK
try {
$cert = file_get_contents($certificatePath);
} catch (Exception $ex) {
throw new OffAmazonPaymentsNotifications_InvalidMessageException(
"Error with signature validation - unable to request signing ".
"certificate at " . $certificatePath, null, $ex
);
}
if ($cert === false) {
throw new OffAmazonPaymentsNotifications_InvalidMessageException(
"Error with signature validation - unable to request signing ".
"certificate at " . $certificatePath
);
}
return $cert;
} | [
"private",
"function",
"_getCertificateFromCertifcatePath",
"(",
"$",
"certificatePath",
")",
"{",
"$",
"this",
"->",
"_validateUrl",
"(",
"$",
"certificatePath",
")",
";",
"//ADDED EXTRA CHECK",
"try",
"{",
"$",
"cert",
"=",
"file_get_contents",
"(",
"$",
"certif... | Request the signing certificate from the given path, in order to
get the public key
@param string $certificatePath certificate path to retreive
@throws OffAmazonPaymentsNotifications_InvalidMessageException
@return void | [
"Request",
"the",
"signing",
"certificate",
"from",
"the",
"given",
"path",
"in",
"order",
"to",
"get",
"the",
"public",
"key"
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsNotifications/Impl/OpenSslVerifySignature.php#L87-L107 | train |
edmondscommerce/doctrine-static-meta | src/Entity/Savers/EntitySaverFactory.php | EntitySaverFactory.getSaverForEntity | public function getSaverForEntity(
EntityInterface $entity
): EntitySaverInterface {
$fqn = $this->getEntityNamespace($entity);
return $this->getSaverForEntityFqn($fqn);
} | php | public function getSaverForEntity(
EntityInterface $entity
): EntitySaverInterface {
$fqn = $this->getEntityNamespace($entity);
return $this->getSaverForEntityFqn($fqn);
} | [
"public",
"function",
"getSaverForEntity",
"(",
"EntityInterface",
"$",
"entity",
")",
":",
"EntitySaverInterface",
"{",
"$",
"fqn",
"=",
"$",
"this",
"->",
"getEntityNamespace",
"(",
"$",
"entity",
")",
";",
"return",
"$",
"this",
"->",
"getSaverForEntityFqn",
... | Gets the Entity Specific Saver if one is defined, otherwise the standard Entity Saver
@param EntityInterface $entity
@return EntitySaverInterface | [
"Gets",
"the",
"Entity",
"Specific",
"Saver",
"if",
"one",
"is",
"defined",
"otherwise",
"the",
"standard",
"Entity",
"Saver"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/Entity/Savers/EntitySaverFactory.php#L47-L53 | train |
edmondscommerce/doctrine-static-meta | src/Entity/Savers/EntitySaverFactory.php | EntitySaverFactory.getEntityNamespace | private function getEntityNamespace(EntityInterface $entity): string
{
if ($entity instanceof Proxy) {
$proxyFqn = \get_class($entity);
$namespace = $this->entityManager->getConfiguration()->getProxyNamespace();
$marker = \Doctrine\Common\Persistence\Proxy::MARKER;
return str_replace($namespace . '\\' . $marker . '\\', '', $proxyFqn);
}
return $this->namespaceHelper->getObjectFqn($entity);
} | php | private function getEntityNamespace(EntityInterface $entity): string
{
if ($entity instanceof Proxy) {
$proxyFqn = \get_class($entity);
$namespace = $this->entityManager->getConfiguration()->getProxyNamespace();
$marker = \Doctrine\Common\Persistence\Proxy::MARKER;
return str_replace($namespace . '\\' . $marker . '\\', '', $proxyFqn);
}
return $this->namespaceHelper->getObjectFqn($entity);
} | [
"private",
"function",
"getEntityNamespace",
"(",
"EntityInterface",
"$",
"entity",
")",
":",
"string",
"{",
"if",
"(",
"$",
"entity",
"instanceof",
"Proxy",
")",
"{",
"$",
"proxyFqn",
"=",
"\\",
"get_class",
"(",
"$",
"entity",
")",
";",
"$",
"namespace",... | It is possible to pass a proxy to the class which will trigger a fatal error due to autoloading problems.
This will resolve the namespace to that of the entity, rather than the proxy. May need to update this to handle
other cases
@param EntityInterface $entity
@return string | [
"It",
"is",
"possible",
"to",
"pass",
"a",
"proxy",
"to",
"the",
"class",
"which",
"will",
"trigger",
"a",
"fatal",
"error",
"due",
"to",
"autoloading",
"problems",
"."
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/Entity/Savers/EntitySaverFactory.php#L65-L76 | train |
chameleon-system/chameleon-shop | src/ShopBundle/objects/TCMSTableEditor/TCMSTableEditorShopArticleReview.class.php | TCMSTableEditorShopArticleReview.UpdateArticleReviewStats | protected function UpdateArticleReviewStats($iArticleId)
{
$oArticle = TdbShopArticle::GetNewInstance();
/** @var $oArticle TdbShopArticle */
if ($oArticle->Load($iArticleId)) {
$oArticle->UpdateStatsReviews();
}
} | php | protected function UpdateArticleReviewStats($iArticleId)
{
$oArticle = TdbShopArticle::GetNewInstance();
/** @var $oArticle TdbShopArticle */
if ($oArticle->Load($iArticleId)) {
$oArticle->UpdateStatsReviews();
}
} | [
"protected",
"function",
"UpdateArticleReviewStats",
"(",
"$",
"iArticleId",
")",
"{",
"$",
"oArticle",
"=",
"TdbShopArticle",
"::",
"GetNewInstance",
"(",
")",
";",
"/** @var $oArticle TdbShopArticle */",
"if",
"(",
"$",
"oArticle",
"->",
"Load",
"(",
"$",
"iArti... | updates the review stats for the article connected to the review item. | [
"updates",
"the",
"review",
"stats",
"for",
"the",
"article",
"connected",
"to",
"the",
"review",
"item",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/TCMSTableEditor/TCMSTableEditorShopArticleReview.class.php#L29-L36 | train |
symbiote/silverstripe-cdncontent | code/dataobjects/CdnImage.php | CdnImage.createResampledAsset | protected function createResampledAsset($filename) {
$fullpath = Director::baseFolder() . '/' . $filename;
$asset = ContentServiceAsset::get()->filter('Filename', $filename)->first();
if(!$asset) {
$asset = new ContentServiceAsset();
}
$this->service = singleton('ContentService');
$asset->Filename = $filename;
$asset->SourceID = $this->ID;
$asset->ParentID = $this->ParentID;
$mtime = time();
$writer = $this->service->getWriterFor($asset, 'FilePointer', $this->targetStore());
if ($writer) {
if (file_exists($fullpath)) {
// likely that cached image never got built correctly.
$name = \Controller::join_links(dirname($filename), $mtime, basename($filename));
$writer->write(fopen($fullpath, 'r'), $name);
$asset->FilePointer = $writer->getContentId();
$asset->write();
$reader = $writer->getReader();
if ($reader && $reader->exists()) {
singleton('ContentDeliveryService')->removeLocalFile($fullpath);
}
} else {
$asset = null;
}
} else {
$asset = null;
}
return $asset;
} | php | protected function createResampledAsset($filename) {
$fullpath = Director::baseFolder() . '/' . $filename;
$asset = ContentServiceAsset::get()->filter('Filename', $filename)->first();
if(!$asset) {
$asset = new ContentServiceAsset();
}
$this->service = singleton('ContentService');
$asset->Filename = $filename;
$asset->SourceID = $this->ID;
$asset->ParentID = $this->ParentID;
$mtime = time();
$writer = $this->service->getWriterFor($asset, 'FilePointer', $this->targetStore());
if ($writer) {
if (file_exists($fullpath)) {
// likely that cached image never got built correctly.
$name = \Controller::join_links(dirname($filename), $mtime, basename($filename));
$writer->write(fopen($fullpath, 'r'), $name);
$asset->FilePointer = $writer->getContentId();
$asset->write();
$reader = $writer->getReader();
if ($reader && $reader->exists()) {
singleton('ContentDeliveryService')->removeLocalFile($fullpath);
}
} else {
$asset = null;
}
} else {
$asset = null;
}
return $asset;
} | [
"protected",
"function",
"createResampledAsset",
"(",
"$",
"filename",
")",
"{",
"$",
"fullpath",
"=",
"Director",
"::",
"baseFolder",
"(",
")",
".",
"'/'",
".",
"$",
"filename",
";",
"$",
"asset",
"=",
"ContentServiceAsset",
"::",
"get",
"(",
")",
"->",
... | Creates a content service asset object based on a given resampled file path
@param type $filename
@return ContentServiceAsset | [
"Creates",
"a",
"content",
"service",
"asset",
"object",
"based",
"on",
"a",
"given",
"resampled",
"file",
"path"
] | a5f82e802e9addaf98d506cf305a621b873a5c9b | https://github.com/symbiote/silverstripe-cdncontent/blob/a5f82e802e9addaf98d506cf305a621b873a5c9b/code/dataobjects/CdnImage.php#L103-L141 | train |
symbiote/silverstripe-cdncontent | code/dataobjects/CdnImage.php | CdnImage.deleteResamplings | protected function deleteResamplings() {
$children = ContentServiceAsset::get()->filter('SourceID', $this->ID);
$numDeleted = 0;
foreach ($children as $child) {
$child->SourceID = -1;
// we _DONT_ do a hard delete; if content has this image cached, it should be able to
// hold it for a while. Instead, mark deleted and allow a cleanup job to collect it later
$child->Filename = 'deleted';
$child->write();
$numDeleted++;
}
$this->Resamplings = array();
return $numDeleted;
} | php | protected function deleteResamplings() {
$children = ContentServiceAsset::get()->filter('SourceID', $this->ID);
$numDeleted = 0;
foreach ($children as $child) {
$child->SourceID = -1;
// we _DONT_ do a hard delete; if content has this image cached, it should be able to
// hold it for a while. Instead, mark deleted and allow a cleanup job to collect it later
$child->Filename = 'deleted';
$child->write();
$numDeleted++;
}
$this->Resamplings = array();
return $numDeleted;
} | [
"protected",
"function",
"deleteResamplings",
"(",
")",
"{",
"$",
"children",
"=",
"ContentServiceAsset",
"::",
"get",
"(",
")",
"->",
"filter",
"(",
"'SourceID'",
",",
"$",
"this",
"->",
"ID",
")",
";",
"$",
"numDeleted",
"=",
"0",
";",
"foreach",
"(",
... | Mark content service assets as being deleted, and reset our Resamplings value
for update later
@return int | [
"Mark",
"content",
"service",
"assets",
"as",
"being",
"deleted",
"and",
"reset",
"our",
"Resamplings",
"value",
"for",
"update",
"later"
] | a5f82e802e9addaf98d506cf305a621b873a5c9b | https://github.com/symbiote/silverstripe-cdncontent/blob/a5f82e802e9addaf98d506cf305a621b873a5c9b/code/dataobjects/CdnImage.php#L175-L191 | train |
symbiote/silverstripe-cdncontent | code/dataobjects/CdnImage.php | CdnImage.getDimensions | public function getDimensions($dim = "string") {
if(!$this->getField('Filename')) {
return null;
}
$imageDimensions = $this->getDimensionsFromDB($dim);
if ($imageDimensions !== null) {
return $imageDimensions;
}
// Download file from S3/CDN if we do not have dimensions stored in the DB
$pointer = $this->obj('CDNFile');
if($this->ID && $pointer->exists()) {
$this->ensureLocalFile();
}
if (!$this->localFileExists()) {
return null;
}
// Store in 'ImageDim' field and write if they've changed.
$this->storeDimensions();
if ($this->isChanged('ImageDim', \DataObject::CHANGE_VALUE)) {
$this->write();
}
// Load dimensions
return $this->getDimensionsFromDB($dim);
} | php | public function getDimensions($dim = "string") {
if(!$this->getField('Filename')) {
return null;
}
$imageDimensions = $this->getDimensionsFromDB($dim);
if ($imageDimensions !== null) {
return $imageDimensions;
}
// Download file from S3/CDN if we do not have dimensions stored in the DB
$pointer = $this->obj('CDNFile');
if($this->ID && $pointer->exists()) {
$this->ensureLocalFile();
}
if (!$this->localFileExists()) {
return null;
}
// Store in 'ImageDim' field and write if they've changed.
$this->storeDimensions();
if ($this->isChanged('ImageDim', \DataObject::CHANGE_VALUE)) {
$this->write();
}
// Load dimensions
return $this->getDimensionsFromDB($dim);
} | [
"public",
"function",
"getDimensions",
"(",
"$",
"dim",
"=",
"\"string\"",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getField",
"(",
"'Filename'",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"imageDimensions",
"=",
"$",
"this",
"->",
"getDimens... | Captures the image dimensions in a db field to avoid needing to download the file all the time
@param type $dim
@return int|string | [
"Captures",
"the",
"image",
"dimensions",
"in",
"a",
"db",
"field",
"to",
"avoid",
"needing",
"to",
"download",
"the",
"file",
"all",
"the",
"time"
] | a5f82e802e9addaf98d506cf305a621b873a5c9b | https://github.com/symbiote/silverstripe-cdncontent/blob/a5f82e802e9addaf98d506cf305a621b873a5c9b/code/dataobjects/CdnImage.php#L199-L226 | train |
symbiote/silverstripe-cdncontent | code/dataobjects/CdnImage.php | CdnImage.getDimensionsFromDB | private function getDimensionsFromDB($dim = "string") {
$imageDimensions = $this->ImageDim;
if (!$imageDimensions) {
return null;
}
if ($dim === 'string') {
return $imageDimensions;
}
$widthAndHeight = explode('x', $imageDimensions);
if (!isset($widthAndHeight[$dim])) {
return null;
}
return (int)$widthAndHeight[$dim];
} | php | private function getDimensionsFromDB($dim = "string") {
$imageDimensions = $this->ImageDim;
if (!$imageDimensions) {
return null;
}
if ($dim === 'string') {
return $imageDimensions;
}
$widthAndHeight = explode('x', $imageDimensions);
if (!isset($widthAndHeight[$dim])) {
return null;
}
return (int)$widthAndHeight[$dim];
} | [
"private",
"function",
"getDimensionsFromDB",
"(",
"$",
"dim",
"=",
"\"string\"",
")",
"{",
"$",
"imageDimensions",
"=",
"$",
"this",
"->",
"ImageDim",
";",
"if",
"(",
"!",
"$",
"imageDimensions",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"$",
"... | Get the dimensions of this Image.
@param string $dim If this is equal to "string", return the dimensions in string form,
if it is 0 return the height, if it is 1 return the width.
@return string|int|null | [
"Get",
"the",
"dimensions",
"of",
"this",
"Image",
"."
] | a5f82e802e9addaf98d506cf305a621b873a5c9b | https://github.com/symbiote/silverstripe-cdncontent/blob/a5f82e802e9addaf98d506cf305a621b873a5c9b/code/dataobjects/CdnImage.php#L235-L248 | train |
symbiote/silverstripe-cdncontent | code/dataobjects/CdnImage.php | CdnImage.getCMSFields | public function getCMSFields() {
$fields = parent::getCMSFields();
$previewField = new LiteralField("SecureImageFull",
"<img id='thumbnailImage' class='thumbnail-preview' src='".$this->Link()."' alt='Secured File' />\n"
);
$url = $this->Link();// 5 minute link expire
$link = ReadonlyField::create('CDNUrl', 'CDN reference', $this->CDNFile);
$link->dontEscape = true;
if ($top = $fields->fieldByName('Root.Main.FilePreview')) {
$field = $top->fieldByName('FilePreviewImage');
$field->insertBefore($previewField, 'ImageFull');
$field->removeByName('ImageFull');
$top->replaceField('CDNUrl', $link);
}
return $fields;
} | php | public function getCMSFields() {
$fields = parent::getCMSFields();
$previewField = new LiteralField("SecureImageFull",
"<img id='thumbnailImage' class='thumbnail-preview' src='".$this->Link()."' alt='Secured File' />\n"
);
$url = $this->Link();// 5 minute link expire
$link = ReadonlyField::create('CDNUrl', 'CDN reference', $this->CDNFile);
$link->dontEscape = true;
if ($top = $fields->fieldByName('Root.Main.FilePreview')) {
$field = $top->fieldByName('FilePreviewImage');
$field->insertBefore($previewField, 'ImageFull');
$field->removeByName('ImageFull');
$top->replaceField('CDNUrl', $link);
}
return $fields;
} | [
"public",
"function",
"getCMSFields",
"(",
")",
"{",
"$",
"fields",
"=",
"parent",
"::",
"getCMSFields",
"(",
")",
";",
"$",
"previewField",
"=",
"new",
"LiteralField",
"(",
"\"SecureImageFull\"",
",",
"\"<img id='thumbnailImage' class='thumbnail-preview' src='\"",
".... | Replaces the Preview Image and Link with secured links if the file is secured.
@return FieldList | [
"Replaces",
"the",
"Preview",
"Image",
"and",
"Link",
"with",
"secured",
"links",
"if",
"the",
"file",
"is",
"secured",
"."
] | a5f82e802e9addaf98d506cf305a621b873a5c9b | https://github.com/symbiote/silverstripe-cdncontent/blob/a5f82e802e9addaf98d506cf305a621b873a5c9b/code/dataobjects/CdnImage.php#L262-L282 | train |
chameleon-system/chameleon-shop | src/ShopBundle/objects/TShopBasket/TShopBasketVoucherCoreList.class.php | TShopBasketVoucherCoreList.GetUniqueItemKey | protected function GetUniqueItemKey()
{
$iCurrentPointer = $this->getItemPointer();
$this->GoToStart();
$aItemKeyList = array();
while ($oItem = $this->Next()) {
$aItemKeyList[] = $oItem->sBasketVoucherKey;
}
// now generate a key
do {
$sKey = md5(uniqid(rand(), true));
} while (in_array($sKey, $aItemKeyList));
return $sKey;
} | php | protected function GetUniqueItemKey()
{
$iCurrentPointer = $this->getItemPointer();
$this->GoToStart();
$aItemKeyList = array();
while ($oItem = $this->Next()) {
$aItemKeyList[] = $oItem->sBasketVoucherKey;
}
// now generate a key
do {
$sKey = md5(uniqid(rand(), true));
} while (in_array($sKey, $aItemKeyList));
return $sKey;
} | [
"protected",
"function",
"GetUniqueItemKey",
"(",
")",
"{",
"$",
"iCurrentPointer",
"=",
"$",
"this",
"->",
"getItemPointer",
"(",
")",
";",
"$",
"this",
"->",
"GoToStart",
"(",
")",
";",
"$",
"aItemKeyList",
"=",
"array",
"(",
")",
";",
"while",
"(",
... | return a unique sBasketVoucherKey for the current list.
@return string | [
"return",
"a",
"unique",
"sBasketVoucherKey",
"for",
"the",
"current",
"list",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/TShopBasket/TShopBasketVoucherCoreList.class.php#L33-L48 | train |
chameleon-system/chameleon-shop | src/ShopBundle/objects/TShopBasket/TShopBasketVoucherCoreList.class.php | TShopBasketVoucherCoreList.GetVoucherValue | public function GetVoucherValue($bSponsoredVouchers = false)
{
$dValue = 0;
$oBasket = TShopBasket::GetInstance();
$iTmpPointer = $this->getItemPointer();
$this->GoToStart();
$maxValueShippingCostAdjustment = true === $bSponsoredVouchers ? $oBasket->dCostShipping : 0;
while ($oVoucher = $this->Next()) {
if (($bSponsoredVouchers && $oVoucher->IsSponsored()) || (false == $bSponsoredVouchers && false == $oVoucher->IsSponsored())) {
$dMaxValue = ($oBasket->dCostArticlesTotalAfterDiscounts + $maxValueShippingCostAdjustment) - $dValue;
$dValue += $oVoucher->GetValue(true, $dMaxValue, $bSponsoredVouchers);
}
}
$this->setItemPointer($iTmpPointer);
return $dValue;
} | php | public function GetVoucherValue($bSponsoredVouchers = false)
{
$dValue = 0;
$oBasket = TShopBasket::GetInstance();
$iTmpPointer = $this->getItemPointer();
$this->GoToStart();
$maxValueShippingCostAdjustment = true === $bSponsoredVouchers ? $oBasket->dCostShipping : 0;
while ($oVoucher = $this->Next()) {
if (($bSponsoredVouchers && $oVoucher->IsSponsored()) || (false == $bSponsoredVouchers && false == $oVoucher->IsSponsored())) {
$dMaxValue = ($oBasket->dCostArticlesTotalAfterDiscounts + $maxValueShippingCostAdjustment) - $dValue;
$dValue += $oVoucher->GetValue(true, $dMaxValue, $bSponsoredVouchers);
}
}
$this->setItemPointer($iTmpPointer);
return $dValue;
} | [
"public",
"function",
"GetVoucherValue",
"(",
"$",
"bSponsoredVouchers",
"=",
"false",
")",
"{",
"$",
"dValue",
"=",
"0",
";",
"$",
"oBasket",
"=",
"TShopBasket",
"::",
"GetInstance",
"(",
")",
";",
"$",
"iTmpPointer",
"=",
"$",
"this",
"->",
"getItemPoint... | return the total voucher value for all active vouchers. note that the method will fetch the current basket
using the baskets singleton factory.
@param bool $bSponsoredVouchers - set to true: only sponsored vouchers, false only none sponsored vouchers
@return float | [
"return",
"the",
"total",
"voucher",
"value",
"for",
"all",
"active",
"vouchers",
".",
"note",
"that",
"the",
"method",
"will",
"fetch",
"the",
"current",
"basket",
"using",
"the",
"baskets",
"singleton",
"factory",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/TShopBasket/TShopBasketVoucherCoreList.class.php#L68-L86 | train |
chameleon-system/chameleon-shop | src/ShopBundle/objects/TShopBasket/TShopBasketVoucherCoreList.class.php | TShopBasketVoucherCoreList.RemoveInvalidVouchers | public function RemoveInvalidVouchers($sMessangerName, $oBasket = null)
{
// since the min value of the basket for which a voucher may work is affected by other vouchers,
// we need to remove the vouchers first, and then add them one by one back to the basket
// we suppress the add messages, but keep the negative messages
if (is_null($oBasket)) {
$oBasket = TShopBasket::GetInstance();
}
$oMessageManager = TCMSMessageManager::GetInstance();
// get copy of vouchers
$aVoucherList = $this->_items;
$this->Destroy();
$bInvalidVouchersFound = false;
foreach ($aVoucherList as $iVoucherKey => $oVoucher) {
/** @var $oVoucher TdbShopVoucher */
$cVoucherAllowUseCode = $oVoucher->AllowUseOfVoucher();
if (TdbShopVoucher::ALLOW_USE == $cVoucherAllowUseCode) {
$this->AddItem($oVoucher);
} else {
$bInvalidVouchersFound = true;
$this->RemoveInvalidVoucherHook($oVoucher, $oBasket);
// send message that the voucher was removed
$aMessageData = $oVoucher->GetObjectPropertiesAsArray();
$aMessageData['iRemoveReasoneCode'] = $cVoucherAllowUseCode;
$oMessageManager->AddMessage($sMessangerName, 'VOUCHER-ERROR-NO-LONGER-VALID-FOR-BASKET', $aMessageData);
}
}
if ($bInvalidVouchersFound) {
// recalculate the basket
$oBasket->RecalculateBasket();
}
} | php | public function RemoveInvalidVouchers($sMessangerName, $oBasket = null)
{
// since the min value of the basket for which a voucher may work is affected by other vouchers,
// we need to remove the vouchers first, and then add them one by one back to the basket
// we suppress the add messages, but keep the negative messages
if (is_null($oBasket)) {
$oBasket = TShopBasket::GetInstance();
}
$oMessageManager = TCMSMessageManager::GetInstance();
// get copy of vouchers
$aVoucherList = $this->_items;
$this->Destroy();
$bInvalidVouchersFound = false;
foreach ($aVoucherList as $iVoucherKey => $oVoucher) {
/** @var $oVoucher TdbShopVoucher */
$cVoucherAllowUseCode = $oVoucher->AllowUseOfVoucher();
if (TdbShopVoucher::ALLOW_USE == $cVoucherAllowUseCode) {
$this->AddItem($oVoucher);
} else {
$bInvalidVouchersFound = true;
$this->RemoveInvalidVoucherHook($oVoucher, $oBasket);
// send message that the voucher was removed
$aMessageData = $oVoucher->GetObjectPropertiesAsArray();
$aMessageData['iRemoveReasoneCode'] = $cVoucherAllowUseCode;
$oMessageManager->AddMessage($sMessangerName, 'VOUCHER-ERROR-NO-LONGER-VALID-FOR-BASKET', $aMessageData);
}
}
if ($bInvalidVouchersFound) {
// recalculate the basket
$oBasket->RecalculateBasket();
}
} | [
"public",
"function",
"RemoveInvalidVouchers",
"(",
"$",
"sMessangerName",
",",
"$",
"oBasket",
"=",
"null",
")",
"{",
"// since the min value of the basket for which a voucher may work is affected by other vouchers,",
"// we need to remove the vouchers first, and then add them one by on... | Removes all vouchers from the basket, that are not valid based on the contents of the basket and the current user
Returns the number of vouchers removed.
@param string $sMessangerName
@param TShopBasket $oBasket
@return int | [
"Removes",
"all",
"vouchers",
"from",
"the",
"basket",
"that",
"are",
"not",
"valid",
"based",
"on",
"the",
"contents",
"of",
"the",
"basket",
"and",
"the",
"current",
"user",
"Returns",
"the",
"number",
"of",
"vouchers",
"removed",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/TShopBasket/TShopBasketVoucherCoreList.class.php#L97-L131 | train |
chameleon-system/chameleon-shop | src/ShopBundle/objects/TShopBasket/TShopBasketVoucherCoreList.class.php | TShopBasketVoucherCoreList.HasFreeShippingVoucher | public function HasFreeShippingVoucher()
{
$bHasFreeShipping = false;
$tmpCurrentPointer = $this->getItemPointer();
$this->GoToStart();
while (!$bHasFreeShipping && ($oItem = &$this->Next())) {
$oVoucherSeries = &$oItem->GetFieldShopVoucherSeries();
if ($oVoucherSeries->fieldFreeShipping) {
$bHasFreeShipping = true;
}
}
$this->setItemPointer($tmpCurrentPointer);
return $bHasFreeShipping;
} | php | public function HasFreeShippingVoucher()
{
$bHasFreeShipping = false;
$tmpCurrentPointer = $this->getItemPointer();
$this->GoToStart();
while (!$bHasFreeShipping && ($oItem = &$this->Next())) {
$oVoucherSeries = &$oItem->GetFieldShopVoucherSeries();
if ($oVoucherSeries->fieldFreeShipping) {
$bHasFreeShipping = true;
}
}
$this->setItemPointer($tmpCurrentPointer);
return $bHasFreeShipping;
} | [
"public",
"function",
"HasFreeShippingVoucher",
"(",
")",
"{",
"$",
"bHasFreeShipping",
"=",
"false",
";",
"$",
"tmpCurrentPointer",
"=",
"$",
"this",
"->",
"getItemPointer",
"(",
")",
";",
"$",
"this",
"->",
"GoToStart",
"(",
")",
";",
"while",
"(",
"!",
... | returns true if at least one voucher has free shipping.
@return bool | [
"returns",
"true",
"if",
"at",
"least",
"one",
"voucher",
"has",
"free",
"shipping",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/TShopBasket/TShopBasketVoucherCoreList.class.php#L149-L164 | train |
chameleon-system/chameleon-shop | src/ExtranetRegistrationGuestBundle/pkgExtranet/objects/db/TPkgExtranetRegistrationGuest_TDataExtranetUser.class.php | TPkgExtranetRegistrationGuest_TDataExtranetUser.RegistrationGuestIsAllowed | public function RegistrationGuestIsAllowed($oLastBoughtUser)
{
$bRegistrationGuestIsAllowed = false;
if (!is_null($oLastBoughtUser) && !$this->IsLoggedIn() && !$oLastBoughtUser->LoginExists()) {
$bRegistrationGuestIsAllowed = true;
}
return $bRegistrationGuestIsAllowed;
} | php | public function RegistrationGuestIsAllowed($oLastBoughtUser)
{
$bRegistrationGuestIsAllowed = false;
if (!is_null($oLastBoughtUser) && !$this->IsLoggedIn() && !$oLastBoughtUser->LoginExists()) {
$bRegistrationGuestIsAllowed = true;
}
return $bRegistrationGuestIsAllowed;
} | [
"public",
"function",
"RegistrationGuestIsAllowed",
"(",
"$",
"oLastBoughtUser",
")",
"{",
"$",
"bRegistrationGuestIsAllowed",
"=",
"false",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"oLastBoughtUser",
")",
"&&",
"!",
"$",
"this",
"->",
"IsLoggedIn",
"(",
")",... | Checks if active user and given last bought user.
@param TdbDataExtranetUser $oLastBoughtUser
@return bool | [
"Checks",
"if",
"active",
"user",
"and",
"given",
"last",
"bought",
"user",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ExtranetRegistrationGuestBundle/pkgExtranet/objects/db/TPkgExtranetRegistrationGuest_TDataExtranetUser.class.php#L23-L31 | train |
chameleon-system/chameleon-shop | src/ExtranetRegistrationGuestBundle/pkgExtranet/objects/db/TPkgExtranetRegistrationGuest_TDataExtranetUser.class.php | TPkgExtranetRegistrationGuest_TDataExtranetUser.GetLinkForRegistrationGuest | public function GetLinkForRegistrationGuest()
{
$oURLData = &TCMSSmartURLData::GetActive();
$oShop = &TdbShop::GetInstance($oURLData->iPortalId);
$sRegisterPath = $oShop->GetLinkToSystemPage(self::NAME_SYSTEM_PAGE);
return $sRegisterPath;
} | php | public function GetLinkForRegistrationGuest()
{
$oURLData = &TCMSSmartURLData::GetActive();
$oShop = &TdbShop::GetInstance($oURLData->iPortalId);
$sRegisterPath = $oShop->GetLinkToSystemPage(self::NAME_SYSTEM_PAGE);
return $sRegisterPath;
} | [
"public",
"function",
"GetLinkForRegistrationGuest",
"(",
")",
"{",
"$",
"oURLData",
"=",
"&",
"TCMSSmartURLData",
"::",
"GetActive",
"(",
")",
";",
"$",
"oShop",
"=",
"&",
"TdbShop",
"::",
"GetInstance",
"(",
"$",
"oURLData",
"->",
"iPortalId",
")",
";",
... | Returns the link to registration guest page.
@return string | [
"Returns",
"the",
"link",
"to",
"registration",
"guest",
"page",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ExtranetRegistrationGuestBundle/pkgExtranet/objects/db/TPkgExtranetRegistrationGuest_TDataExtranetUser.class.php#L38-L45 | train |
edmondscommerce/doctrine-static-meta | src/Entity/Validation/EntityDataValidator.php | EntityDataValidator.getErrorsAsString | public function getErrorsAsString(): string
{
$errors = $this->getErrors();
if (0 === $errors->count()) {
return '';
}
$message = 'found ' . $errors->count() . ' errors validating '
. \get_class($this->dataObject);
foreach ($errors as $error) {
$message .= "\n\n" . $error->getPropertyPath() . ': ' . $error->getMessage();
}
return $message;
} | php | public function getErrorsAsString(): string
{
$errors = $this->getErrors();
if (0 === $errors->count()) {
return '';
}
$message = 'found ' . $errors->count() . ' errors validating '
. \get_class($this->dataObject);
foreach ($errors as $error) {
$message .= "\n\n" . $error->getPropertyPath() . ': ' . $error->getMessage();
}
return $message;
} | [
"public",
"function",
"getErrorsAsString",
"(",
")",
":",
"string",
"{",
"$",
"errors",
"=",
"$",
"this",
"->",
"getErrors",
"(",
")",
";",
"if",
"(",
"0",
"===",
"$",
"errors",
"->",
"count",
"(",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"m... | Perform validation and then return a message that details the number and the details of the errors
Will return an empty string if there are no errors
@return string | [
"Perform",
"validation",
"and",
"then",
"return",
"a",
"message",
"that",
"details",
"the",
"number",
"and",
"the",
"details",
"of",
"the",
"errors"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/Entity/Validation/EntityDataValidator.php#L85-L98 | train |
edmondscommerce/doctrine-static-meta | src/Entity/Validation/EntityDataValidator.php | EntityDataValidator.validateProperty | public function validateProperty(string $propertyName): void
{
$errors = $this->validator->validateProperty($this->dataObject, $propertyName);
$this->throwExceptionIfErrors($errors);
} | php | public function validateProperty(string $propertyName): void
{
$errors = $this->validator->validateProperty($this->dataObject, $propertyName);
$this->throwExceptionIfErrors($errors);
} | [
"public",
"function",
"validateProperty",
"(",
"string",
"$",
"propertyName",
")",
":",
"void",
"{",
"$",
"errors",
"=",
"$",
"this",
"->",
"validator",
"->",
"validateProperty",
"(",
"$",
"this",
"->",
"dataObject",
",",
"$",
"propertyName",
")",
";",
"$"... | Validate a single entity property
@param string $propertyName
@throws ValidationException | [
"Validate",
"a",
"single",
"entity",
"property"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/Entity/Validation/EntityDataValidator.php#L132-L136 | train |
chameleon-system/chameleon-shop | src/ShopAffiliateBundle/objects/db/TPkgShopAffiliate.class.php | TPkgShopAffiliate.GetInstance | public static function GetInstance($sId)
{
$oElement = TdbPkgShopAffiliate::GetNewInstance();
$oElement->Load($sId);
if (!empty($oElement->sqlData['class'])) {
$sClassName = $oElement->sqlData['class'];
$oElementNew = new $sClassName();
$oElementNew->LoadFromRow($oElement->sqlData);
$oElement = $oElementNew;
}
return $oElement;
} | php | public static function GetInstance($sId)
{
$oElement = TdbPkgShopAffiliate::GetNewInstance();
$oElement->Load($sId);
if (!empty($oElement->sqlData['class'])) {
$sClassName = $oElement->sqlData['class'];
$oElementNew = new $sClassName();
$oElementNew->LoadFromRow($oElement->sqlData);
$oElement = $oElementNew;
}
return $oElement;
} | [
"public",
"static",
"function",
"GetInstance",
"(",
"$",
"sId",
")",
"{",
"$",
"oElement",
"=",
"TdbPkgShopAffiliate",
"::",
"GetNewInstance",
"(",
")",
";",
"$",
"oElement",
"->",
"Load",
"(",
"$",
"sId",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
... | return instance of class (casted as correct type.
@param string $sId
@return TdbPkgShopAffiliate | [
"return",
"instance",
"of",
"class",
"(",
"casted",
"as",
"correct",
"type",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopAffiliateBundle/objects/db/TPkgShopAffiliate.class.php#L28-L40 | train |
chameleon-system/chameleon-shop | src/ShopAffiliateBundle/objects/db/TPkgShopAffiliate.class.php | TPkgShopAffiliate.RenderOrderSuccessHTMLCode | public static function RenderOrderSuccessHTMLCode()
{
$sHTML = '';
$oUserOrder = &TShopBasket::GetLastCreatedOrder();
$oProgram = TdbPkgShopAffiliate::GetActiveInstance();
if ($oUserOrder && $oProgram) {
$sHTML = $oProgram->RenderHTMLCode($oUserOrder);
}
return $sHTML;
} | php | public static function RenderOrderSuccessHTMLCode()
{
$sHTML = '';
$oUserOrder = &TShopBasket::GetLastCreatedOrder();
$oProgram = TdbPkgShopAffiliate::GetActiveInstance();
if ($oUserOrder && $oProgram) {
$sHTML = $oProgram->RenderHTMLCode($oUserOrder);
}
return $sHTML;
} | [
"public",
"static",
"function",
"RenderOrderSuccessHTMLCode",
"(",
")",
"{",
"$",
"sHTML",
"=",
"''",
";",
"$",
"oUserOrder",
"=",
"&",
"TShopBasket",
"::",
"GetLastCreatedOrder",
"(",
")",
";",
"$",
"oProgram",
"=",
"TdbPkgShopAffiliate",
"::",
"GetActiveInstan... | call this method in the order success view to generate the success html for the partner program.
@return string | [
"call",
"this",
"method",
"in",
"the",
"order",
"success",
"view",
"to",
"generate",
"the",
"success",
"html",
"for",
"the",
"partner",
"program",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopAffiliateBundle/objects/db/TPkgShopAffiliate.class.php#L203-L213 | train |
chameleon-system/chameleon-shop | src/ShopBundle/mappers/WizardStep/TCMSWizardStepMapper_UserProfile.class.php | TCMSWizardStepMapper_UserProfile.GetMessageForField | protected function GetMessageForField($sFieldName, $aFieldMessages)
{
$sMessage = '';
if (is_array($aFieldMessages) && isset($aFieldMessages[$sFieldName])) {
$sMessage = $aFieldMessages[$sFieldName];
}
return $sMessage;
} | php | protected function GetMessageForField($sFieldName, $aFieldMessages)
{
$sMessage = '';
if (is_array($aFieldMessages) && isset($aFieldMessages[$sFieldName])) {
$sMessage = $aFieldMessages[$sFieldName];
}
return $sMessage;
} | [
"protected",
"function",
"GetMessageForField",
"(",
"$",
"sFieldName",
",",
"$",
"aFieldMessages",
")",
"{",
"$",
"sMessage",
"=",
"''",
";",
"if",
"(",
"is_array",
"(",
"$",
"aFieldMessages",
")",
"&&",
"isset",
"(",
"$",
"aFieldMessages",
"[",
"$",
"sFie... | Get field message for given field in given array.
@param string $sFieldName
@param array $aFieldMessages
@return string | [
"Get",
"field",
"message",
"for",
"given",
"field",
"in",
"given",
"array",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/mappers/WizardStep/TCMSWizardStepMapper_UserProfile.class.php#L52-L60 | train |
chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopModuleArticlelistOrderby.class.php | TShopModuleArticlelistOrderby.GetOrderByString | public function GetOrderByString($sDirection = null)
{
if (is_null($sDirection)) {
$sDirection = $this->fieldOrderDirection;
}
$sOrderBy = '';
if (!empty($this->fieldSqlOrderBy)) {
$sOrderBy = $this->fieldSqlOrderBy.' '.$sDirection;
}
if (!empty($this->fieldSqlSecondaryOrderByString)) {
$sOrderBy .= ', '.$this->fieldSqlSecondaryOrderByString;
}
return $sOrderBy;
} | php | public function GetOrderByString($sDirection = null)
{
if (is_null($sDirection)) {
$sDirection = $this->fieldOrderDirection;
}
$sOrderBy = '';
if (!empty($this->fieldSqlOrderBy)) {
$sOrderBy = $this->fieldSqlOrderBy.' '.$sDirection;
}
if (!empty($this->fieldSqlSecondaryOrderByString)) {
$sOrderBy .= ', '.$this->fieldSqlSecondaryOrderByString;
}
return $sOrderBy;
} | [
"public",
"function",
"GetOrderByString",
"(",
"$",
"sDirection",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"sDirection",
")",
")",
"{",
"$",
"sDirection",
"=",
"$",
"this",
"->",
"fieldOrderDirection",
";",
"}",
"$",
"sOrderBy",
"=",
"''",
... | return order by string.
@param string $sDirection - ASC or DESC. if set to NULL the value set in the class will be used
@return string | [
"return",
"order",
"by",
"string",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopModuleArticlelistOrderby.class.php#L21-L36 | train |
Erebot/Erebot | src/Event/Match/Type.php | Type.setType | public function setType($types)
{
if (!is_array($types)) {
$types = array($types);
}
$finalTypes = array();
foreach ($types as $type) {
if (is_object($type)) {
$type = get_class($type);
}
if (!is_string($type)) {
throw new \Erebot\InvalidValueException('Not a valid type');
}
$finalTypes[] = $type;
}
$this->type = $finalTypes;
} | php | public function setType($types)
{
if (!is_array($types)) {
$types = array($types);
}
$finalTypes = array();
foreach ($types as $type) {
if (is_object($type)) {
$type = get_class($type);
}
if (!is_string($type)) {
throw new \Erebot\InvalidValueException('Not a valid type');
}
$finalTypes[] = $type;
}
$this->type = $finalTypes;
} | [
"public",
"function",
"setType",
"(",
"$",
"types",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"types",
")",
")",
"{",
"$",
"types",
"=",
"array",
"(",
"$",
"types",
")",
";",
"}",
"$",
"finalTypes",
"=",
"array",
"(",
")",
";",
"foreach",
... | Sets the type used in comparisons.
\param $types string|object|array
Type(s) to match incoming events against,
either as a string or as an instance
of the type of match against.
An array of strings/objects may also be passed;
The filter will match if the incoming event
is of any of the types given.
\throw Erebot::InvalidValueException
The given type is invalid. | [
"Sets",
"the",
"type",
"used",
"in",
"comparisons",
"."
] | 691fc3fa8bc6f07061ff2b3798fec76bc3a039aa | https://github.com/Erebot/Erebot/blob/691fc3fa8bc6f07061ff2b3798fec76bc3a039aa/src/Event/Match/Type.php#L68-L87 | train |
chameleon-system/chameleon-shop | src/ShopBundle/mappers/article/TPkgShopMapper_ArticleTeaserBase.class.php | TPkgShopMapper_ArticleTeaserBase.GetVariantInfo | protected function GetVariantInfo($oArticle, $aData, IMapperCacheTriggerRestricted $oCacheTriggerManager, $bCachingEnabled)
{
$aColors = array();
$aVariantTypeList = array();
if ($oArticle->HasVariants()) {
$oVariantSet = $oArticle->GetFieldShopVariantSet();
if ($oVariantSet && $bCachingEnabled) {
$oCacheTriggerManager->addTrigger($oVariantSet->table, $oVariantSet->id);
}
$oVariantTypes = $oVariantSet->GetFieldShopVariantTypeList();
$bLoadInactiveItems = false;
$oShop = TShop::GetInstance();
if (property_exists($oShop, 'fieldLoadInactiveVariants') && $oShop->fieldLoadInactiveVariants) {
$bLoadInactiveItems = true;
}
while ($oVariantType = $oVariantTypes->Next()) {
if ($bCachingEnabled) {
$oCacheTriggerManager->addTrigger($oVariantType->table, $oVariantType->id);
}
if ($bLoadInactiveItems) {
$oAvailableValues = $oArticle->GetVariantValuesAvailableForTypeIncludingInActive($oVariantType);
} else {
$oAvailableValues = $oArticle->GetVariantValuesAvailableForType($oVariantType);
}
if (!$oAvailableValues) {
continue;
}
if ('color' == $oVariantType->fieldIdentifier) {
while ($oValue = $oAvailableValues->Next()) {
if ($bCachingEnabled) {
$oCacheTriggerManager->addTrigger($oValue->table, $oValue->id);
}
$aColors[] = array(
'sLink' => $oValue->fieldUrlName,
'sHex' => '#'.$oValue->fieldColorCode,
'cms_media_id' => $oValue->fieldCmsMediaId,
);
}
} else {
$aType = array(
'sTitle' => $oVariantType->fieldName,
'sSystemName' => $oVariantType->fieldIdentifier,
'cms_media_id' => $oVariantType->fieldCmsMediaId,
'aItems' => array(),
'bAllowSelection' => true,
);
$aItems = array();
while ($oValue = $oAvailableValues->Next()) {
if ($bCachingEnabled) {
$oCacheTriggerManager->addTrigger($oValue->table, $oValue->id);
}
$aItem = array(
'sTitle' => $oValue->fieldName,
'sColor' => $oValue->fieldColorCode,
'cms_media_id' => $oValue->fieldCmsMediaId,
'bIsActive' => false, // currently selected article variant (shows activate state)
'bArticleIsActive' => '1',
'sSelectLink' => '',
);
if ($bLoadInactiveItems) {
if (isset($oValue->sqlData['articleactive']) && $oValue->sqlData['articleactive'] > 0) {
$aItem['bArticleIsActive'] = '1'; // if 0 the variant is not active and the variant values should be rendered as non-available
} else {
$aItem['bArticleIsActive'] = '0';
}
}
$aItems[] = $aItem;
}
$aType['aItems'] = $aItems;
$aVariantTypeList[] = $aType;
}
}
}
$aData['aColors'] = $aColors;
$aData['aVariantTypes'] = $aVariantTypeList;
return $aData;
} | php | protected function GetVariantInfo($oArticle, $aData, IMapperCacheTriggerRestricted $oCacheTriggerManager, $bCachingEnabled)
{
$aColors = array();
$aVariantTypeList = array();
if ($oArticle->HasVariants()) {
$oVariantSet = $oArticle->GetFieldShopVariantSet();
if ($oVariantSet && $bCachingEnabled) {
$oCacheTriggerManager->addTrigger($oVariantSet->table, $oVariantSet->id);
}
$oVariantTypes = $oVariantSet->GetFieldShopVariantTypeList();
$bLoadInactiveItems = false;
$oShop = TShop::GetInstance();
if (property_exists($oShop, 'fieldLoadInactiveVariants') && $oShop->fieldLoadInactiveVariants) {
$bLoadInactiveItems = true;
}
while ($oVariantType = $oVariantTypes->Next()) {
if ($bCachingEnabled) {
$oCacheTriggerManager->addTrigger($oVariantType->table, $oVariantType->id);
}
if ($bLoadInactiveItems) {
$oAvailableValues = $oArticle->GetVariantValuesAvailableForTypeIncludingInActive($oVariantType);
} else {
$oAvailableValues = $oArticle->GetVariantValuesAvailableForType($oVariantType);
}
if (!$oAvailableValues) {
continue;
}
if ('color' == $oVariantType->fieldIdentifier) {
while ($oValue = $oAvailableValues->Next()) {
if ($bCachingEnabled) {
$oCacheTriggerManager->addTrigger($oValue->table, $oValue->id);
}
$aColors[] = array(
'sLink' => $oValue->fieldUrlName,
'sHex' => '#'.$oValue->fieldColorCode,
'cms_media_id' => $oValue->fieldCmsMediaId,
);
}
} else {
$aType = array(
'sTitle' => $oVariantType->fieldName,
'sSystemName' => $oVariantType->fieldIdentifier,
'cms_media_id' => $oVariantType->fieldCmsMediaId,
'aItems' => array(),
'bAllowSelection' => true,
);
$aItems = array();
while ($oValue = $oAvailableValues->Next()) {
if ($bCachingEnabled) {
$oCacheTriggerManager->addTrigger($oValue->table, $oValue->id);
}
$aItem = array(
'sTitle' => $oValue->fieldName,
'sColor' => $oValue->fieldColorCode,
'cms_media_id' => $oValue->fieldCmsMediaId,
'bIsActive' => false, // currently selected article variant (shows activate state)
'bArticleIsActive' => '1',
'sSelectLink' => '',
);
if ($bLoadInactiveItems) {
if (isset($oValue->sqlData['articleactive']) && $oValue->sqlData['articleactive'] > 0) {
$aItem['bArticleIsActive'] = '1'; // if 0 the variant is not active and the variant values should be rendered as non-available
} else {
$aItem['bArticleIsActive'] = '0';
}
}
$aItems[] = $aItem;
}
$aType['aItems'] = $aItems;
$aVariantTypeList[] = $aType;
}
}
}
$aData['aColors'] = $aColors;
$aData['aVariantTypes'] = $aVariantTypeList;
return $aData;
} | [
"protected",
"function",
"GetVariantInfo",
"(",
"$",
"oArticle",
",",
"$",
"aData",
",",
"IMapperCacheTriggerRestricted",
"$",
"oCacheTriggerManager",
",",
"$",
"bCachingEnabled",
")",
"{",
"$",
"aColors",
"=",
"array",
"(",
")",
";",
"$",
"aVariantTypeList",
"=... | Add color variant data if available for article
Add all other available article variants in separate data.
@param TdbShopArticle $oArticle
@param array $aData
@param IMapperCacheTriggerRestricted $oCacheTriggerManager
@param bool $bCachingEnabled
@return array | [
"Add",
"color",
"variant",
"data",
"if",
"available",
"for",
"article",
"Add",
"all",
"other",
"available",
"article",
"variants",
"in",
"separate",
"data",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/mappers/article/TPkgShopMapper_ArticleTeaserBase.class.php#L91-L174 | train |
Erebot/Erebot | src/Core.php | Core.handleSignal | public function handleSignal($signum)
{
$consts = get_defined_constants(true);
$signame = '???';
foreach ($consts['pcntl'] as $name => $value) {
if (!strncmp($name, 'SIG', 3) &&
strncmp($name, 'SIG_', 4) &&
$signum == $value) {
$signame = $name;
break;
}
}
$logger = \Plop\Plop::getInstance();
$logger->info(
$this->gettext(
'Received signal #%(signum)d (%(signame)s)'
),
array(
'signum' => $signum,
'signame' => $signame,
)
);
// Print some statistics.
if (function_exists('memory_get_peak_usage')) {
$logger->debug($this->gettext('Memory usage:'));
$limit = trim(ini_get('memory_limit'));
$limit = \Erebot\Utils::parseHumanSize($limit."B");
$stats = array(
(string) $this->gettext("Allocated:") =>
\Erebot\Utils::humanSize(memory_get_peak_usage(true)),
(string) $this->gettext("Used:") =>
\Erebot\Utils::humanSize(memory_get_peak_usage(false)),
(string) $this->gettext("Limit:") =>
\Erebot\Utils::humanSize($limit),
);
foreach ($stats as $key => $value) {
$logger->debug(
'%(key)-16s%(value)10s',
array(
'key' => $key,
'value' => $value,
)
);
}
}
$this->stop();
} | php | public function handleSignal($signum)
{
$consts = get_defined_constants(true);
$signame = '???';
foreach ($consts['pcntl'] as $name => $value) {
if (!strncmp($name, 'SIG', 3) &&
strncmp($name, 'SIG_', 4) &&
$signum == $value) {
$signame = $name;
break;
}
}
$logger = \Plop\Plop::getInstance();
$logger->info(
$this->gettext(
'Received signal #%(signum)d (%(signame)s)'
),
array(
'signum' => $signum,
'signame' => $signame,
)
);
// Print some statistics.
if (function_exists('memory_get_peak_usage')) {
$logger->debug($this->gettext('Memory usage:'));
$limit = trim(ini_get('memory_limit'));
$limit = \Erebot\Utils::parseHumanSize($limit."B");
$stats = array(
(string) $this->gettext("Allocated:") =>
\Erebot\Utils::humanSize(memory_get_peak_usage(true)),
(string) $this->gettext("Used:") =>
\Erebot\Utils::humanSize(memory_get_peak_usage(false)),
(string) $this->gettext("Limit:") =>
\Erebot\Utils::humanSize($limit),
);
foreach ($stats as $key => $value) {
$logger->debug(
'%(key)-16s%(value)10s',
array(
'key' => $key,
'value' => $value,
)
);
}
}
$this->stop();
} | [
"public",
"function",
"handleSignal",
"(",
"$",
"signum",
")",
"{",
"$",
"consts",
"=",
"get_defined_constants",
"(",
"true",
")",
";",
"$",
"signame",
"=",
"'???'",
";",
"foreach",
"(",
"$",
"consts",
"[",
"'pcntl'",
"]",
"as",
"$",
"name",
"=>",
"$",... | Handles request for a graceful shutdown of the bot.
Such requests are received as signals.
\param int $signum
The number of the signal. | [
"Handles",
"request",
"for",
"a",
"graceful",
"shutdown",
"of",
"the",
"bot",
".",
"Such",
"requests",
"are",
"received",
"as",
"signals",
"."
] | 691fc3fa8bc6f07061ff2b3798fec76bc3a039aa | https://github.com/Erebot/Erebot/blob/691fc3fa8bc6f07061ff2b3798fec76bc3a039aa/src/Core.php#L361-L412 | train |
Erebot/Erebot | src/Core.php | Core.reload | public function reload(\Erebot\Interfaces\Config\Main $config = null)
{
$logger = \Plop\Plop::getInstance();
$msg = $this->gettext('Reloading the configuration');
$logger->info($msg);
if (!count($this->connections)) {
$logger->info($this->gettext('No active connections... Aborting.'));
return;
}
if ($config === null) {
$configFile = $this->mainCfg->getConfigFile();
if ($configFile === null) {
$msg = $this->gettext('No configuration file to reload');
$logger->info($msg);
return;
}
/// @TODO: dependency injection
$config = new \Erebot\Config\Main(
$configFile,
\Erebot\Interfaces\Config\Main::LOAD_FROM_FILE
);
}
$connectionCls = get_class($this->connections[0]);
$this->createConnections($connectionCls, $config);
$msg = $this->gettext('Successfully reloaded the configuration');
$logger->info($msg);
} | php | public function reload(\Erebot\Interfaces\Config\Main $config = null)
{
$logger = \Plop\Plop::getInstance();
$msg = $this->gettext('Reloading the configuration');
$logger->info($msg);
if (!count($this->connections)) {
$logger->info($this->gettext('No active connections... Aborting.'));
return;
}
if ($config === null) {
$configFile = $this->mainCfg->getConfigFile();
if ($configFile === null) {
$msg = $this->gettext('No configuration file to reload');
$logger->info($msg);
return;
}
/// @TODO: dependency injection
$config = new \Erebot\Config\Main(
$configFile,
\Erebot\Interfaces\Config\Main::LOAD_FROM_FILE
);
}
$connectionCls = get_class($this->connections[0]);
$this->createConnections($connectionCls, $config);
$msg = $this->gettext('Successfully reloaded the configuration');
$logger->info($msg);
} | [
"public",
"function",
"reload",
"(",
"\\",
"Erebot",
"\\",
"Interfaces",
"\\",
"Config",
"\\",
"Main",
"$",
"config",
"=",
"null",
")",
"{",
"$",
"logger",
"=",
"\\",
"Plop",
"\\",
"Plop",
"::",
"getInstance",
"(",
")",
";",
"$",
"msg",
"=",
"$",
"... | Reload this instance of the bot.
This method makes the bot reload most of the data
it currently relies on, such as configuration files.
\param Erebot::Interfaces::Config::MainInterface $config
(optional) The new configuration to use.
If omitted, the configuration file currently in use
is reloaded. | [
"Reload",
"this",
"instance",
"of",
"the",
"bot",
"."
] | 691fc3fa8bc6f07061ff2b3798fec76bc3a039aa | https://github.com/Erebot/Erebot/blob/691fc3fa8bc6f07061ff2b3798fec76bc3a039aa/src/Core.php#L505-L536 | train |
edmondscommerce/doctrine-static-meta | src/Entity/Traits/UsesPHPMetaDataTrait.php | UsesPHPMetaDataTrait.runInitMethods | private function runInitMethods(): void
{
$reflectionClass = self::getDoctrineStaticMeta()->getReflectionClass();
$methods = $reflectionClass->getMethods(\ReflectionMethod::IS_PRIVATE);
foreach ($methods as $method) {
if ($method instanceof ReflectionMethod) {
$method = $method->getName();
}
if (\ts\stringContains($method, UsesPHPMetaDataInterface::METHOD_PREFIX_INIT)
&& \ts\stringStartsWith($method, UsesPHPMetaDataInterface::METHOD_PREFIX_INIT)
) {
$this->$method();
}
}
} | php | private function runInitMethods(): void
{
$reflectionClass = self::getDoctrineStaticMeta()->getReflectionClass();
$methods = $reflectionClass->getMethods(\ReflectionMethod::IS_PRIVATE);
foreach ($methods as $method) {
if ($method instanceof ReflectionMethod) {
$method = $method->getName();
}
if (\ts\stringContains($method, UsesPHPMetaDataInterface::METHOD_PREFIX_INIT)
&& \ts\stringStartsWith($method, UsesPHPMetaDataInterface::METHOD_PREFIX_INIT)
) {
$this->$method();
}
}
} | [
"private",
"function",
"runInitMethods",
"(",
")",
":",
"void",
"{",
"$",
"reflectionClass",
"=",
"self",
"::",
"getDoctrineStaticMeta",
"(",
")",
"->",
"getReflectionClass",
"(",
")",
";",
"$",
"methods",
"=",
"$",
"reflectionClass",
"->",
"getMethods",
"(",
... | Find and run all init methods
- defined in relationship traits and generally to init ArrayCollection properties
@throws \ReflectionException | [
"Find",
"and",
"run",
"all",
"init",
"methods",
"-",
"defined",
"in",
"relationship",
"traits",
"and",
"generally",
"to",
"init",
"ArrayCollection",
"properties"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/Entity/Traits/UsesPHPMetaDataTrait.php#L35-L49 | train |
edmondscommerce/doctrine-static-meta | src/Entity/Traits/UsesPHPMetaDataTrait.php | UsesPHPMetaDataTrait.loadMetadata | public static function loadMetadata(DoctrineClassMetaData $metaData): void
{
try {
self::getDoctrineStaticMeta()->setMetaData($metaData)->buildMetaData();
} catch (\Exception $e) {
throw new DoctrineStaticMetaException(
'Exception in ' . __METHOD__ . ': ' . $e->getMessage(),
$e->getCode(),
$e
);
}
} | php | public static function loadMetadata(DoctrineClassMetaData $metaData): void
{
try {
self::getDoctrineStaticMeta()->setMetaData($metaData)->buildMetaData();
} catch (\Exception $e) {
throw new DoctrineStaticMetaException(
'Exception in ' . __METHOD__ . ': ' . $e->getMessage(),
$e->getCode(),
$e
);
}
} | [
"public",
"static",
"function",
"loadMetadata",
"(",
"DoctrineClassMetaData",
"$",
"metaData",
")",
":",
"void",
"{",
"try",
"{",
"self",
"::",
"getDoctrineStaticMeta",
"(",
")",
"->",
"setMetaData",
"(",
"$",
"metaData",
")",
"->",
"buildMetaData",
"(",
")",
... | Loads the class and property meta data in the class
This is the method called by Doctrine to load the meta data
@param DoctrineClassMetaData $metaData
@throws DoctrineStaticMetaException
@SuppressWarnings(PHPMD.StaticAccess) | [
"Loads",
"the",
"class",
"and",
"property",
"meta",
"data",
"in",
"the",
"class"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/Entity/Traits/UsesPHPMetaDataTrait.php#L79-L90 | train |
PGB-LIV/php-ms | src/Writer/MzIdentMlWriter.php | MzIdentMlWriter.addCv | public function addCv($name, $version, $uri, $cvRef)
{
$this->cvList[] = array(
'fullName' => $name,
'version' => $version,
'uri' => $uri,
'id' => $cvRef
);
// read in obo file
$handle = fopen($uri, 'r');
$lineReader = new LineReader($handle);
// parse file
$parser = new Parser($lineReader);
$parser->retainTrailingComments(true);
$parser->getDocument()->mergeStanzas(false); // speed tip
$parser->parse();
$terms = array();
foreach ($parser->getDocument()->getStanzas('Term') as $term) {
$id = $term->get('id');
$name = $term->get('name');
$terms[$id] = $name;
}
$this->oboRef[$cvRef] = $terms;
} | php | public function addCv($name, $version, $uri, $cvRef)
{
$this->cvList[] = array(
'fullName' => $name,
'version' => $version,
'uri' => $uri,
'id' => $cvRef
);
// read in obo file
$handle = fopen($uri, 'r');
$lineReader = new LineReader($handle);
// parse file
$parser = new Parser($lineReader);
$parser->retainTrailingComments(true);
$parser->getDocument()->mergeStanzas(false); // speed tip
$parser->parse();
$terms = array();
foreach ($parser->getDocument()->getStanzas('Term') as $term) {
$id = $term->get('id');
$name = $term->get('name');
$terms[$id] = $name;
}
$this->oboRef[$cvRef] = $terms;
} | [
"public",
"function",
"addCv",
"(",
"$",
"name",
",",
"$",
"version",
",",
"$",
"uri",
",",
"$",
"cvRef",
")",
"{",
"$",
"this",
"->",
"cvList",
"[",
"]",
"=",
"array",
"(",
"'fullName'",
"=>",
"$",
"name",
",",
"'version'",
"=>",
"$",
"version",
... | CV terms must be added prior to open being called
@param string $name
@param string $version
@param string $uri
@param string $id | [
"CV",
"terms",
"must",
"be",
"added",
"prior",
"to",
"open",
"being",
"called"
] | 091751eb12512f4bc6ada07bda745ce49331e24f | https://github.com/PGB-LIV/php-ms/blob/091751eb12512f4bc6ada07bda745ce49331e24f/src/Writer/MzIdentMlWriter.php#L145-L172 | train |
PGB-LIV/php-ms | src/Writer/MzIdentMlWriter.php | MzIdentMlWriter.writeAttributeNotNull | private function writeAttributeNotNull($attribute, $value)
{
if (is_null($value)) {
return;
}
$this->stream->writeAttribute($attribute, $value);
} | php | private function writeAttributeNotNull($attribute, $value)
{
if (is_null($value)) {
return;
}
$this->stream->writeAttribute($attribute, $value);
} | [
"private",
"function",
"writeAttributeNotNull",
"(",
"$",
"attribute",
",",
"$",
"value",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"value",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"stream",
"->",
"writeAttribute",
"(",
"$",
"attribute",
... | Writes the attribute for as long as the value is not null
@param string $attribute
@param mixed $value | [
"Writes",
"the",
"attribute",
"for",
"as",
"long",
"as",
"the",
"value",
"is",
"not",
"null"
] | 091751eb12512f4bc6ada07bda745ce49331e24f | https://github.com/PGB-LIV/php-ms/blob/091751eb12512f4bc6ada07bda745ce49331e24f/src/Writer/MzIdentMlWriter.php#L1002-L1009 | train |
chameleon-system/chameleon-shop | src/ShopCurrencyBundle/pkgShop/objects/db/TPkgShopCurrency_ShopVoucher.class.php | TPkgShopCurrency_ShopVoucher.CommitVoucherUseForCurrentUserPreSaveHook | protected function CommitVoucherUseForCurrentUserPreSaveHook(&$aData)
{
// value used is converted to the base currency - euro
$oCurrency = TdbPkgShopCurrency::GetBaseCurrency();
$oActive = TdbPkgShopCurrency::GetActiveInstance();
$aData['value_used_in_order_currency'] = $aData['value_used'];
if (false !== $oCurrency) {
$aData['pkg_shop_currency_id'] = $oCurrency->id;
}
if ($oCurrency && $oActive && $oActive->id != $oCurrency->id) {
$aData['pkg_shop_currency_id'] = $oActive->id;
$aData['value_used'] = round($oCurrency->Convert($aData['value_used'], $oActive), 2);
}
} | php | protected function CommitVoucherUseForCurrentUserPreSaveHook(&$aData)
{
// value used is converted to the base currency - euro
$oCurrency = TdbPkgShopCurrency::GetBaseCurrency();
$oActive = TdbPkgShopCurrency::GetActiveInstance();
$aData['value_used_in_order_currency'] = $aData['value_used'];
if (false !== $oCurrency) {
$aData['pkg_shop_currency_id'] = $oCurrency->id;
}
if ($oCurrency && $oActive && $oActive->id != $oCurrency->id) {
$aData['pkg_shop_currency_id'] = $oActive->id;
$aData['value_used'] = round($oCurrency->Convert($aData['value_used'], $oActive), 2);
}
} | [
"protected",
"function",
"CommitVoucherUseForCurrentUserPreSaveHook",
"(",
"&",
"$",
"aData",
")",
"{",
"// value used is converted to the base currency - euro",
"$",
"oCurrency",
"=",
"TdbPkgShopCurrency",
"::",
"GetBaseCurrency",
"(",
")",
";",
"$",
"oActive",
"=",
"Tdb... | method can be used to process the use data before the commit is called
we use it here to convert the value of the voucher used back to the base currency (since that is what we want to store.
@param array $aData | [
"method",
"can",
"be",
"used",
"to",
"process",
"the",
"use",
"data",
"before",
"the",
"commit",
"is",
"called",
"we",
"use",
"it",
"here",
"to",
"convert",
"the",
"value",
"of",
"the",
"voucher",
"used",
"back",
"to",
"the",
"base",
"currency",
"(",
"... | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopCurrencyBundle/pkgShop/objects/db/TPkgShopCurrency_ShopVoucher.class.php#L30-L43 | train |
chameleon-system/chameleon-shop | src/ShopBundle/objects/WebModules/MTShopSearchTagsCore/MTShopSearchTagsCore.class.php | MTShopSearchTagsCore.& | protected function &GetSearchKeywordCloud()
{
$iSize = 13;
$aCustomWords = array();
$oCustomList = &TdbShopSearchCloudWordList::GetList();
while ($oWord = &$oCustomList->Next()) {
$aCustomWords[$oWord->fieldName] = $oWord->fieldWeight;
}
$iSize = $iSize - count($aCustomWords);
if ($iSize < 0) {
$iSize = 0;
}
$activeLanguage = $this->getLanguageService()->getActiveLanguageId();
$query = 'SELECT COUNT(`shop_search_log`.`id`) AS '.TCMSTagCloud::QUERY_ITEM_COUNT_NAME.',
`shop_search_log`.`name` AS '.TCMSTagCloud::QUERY_ITEM_KEY_NAME.",
`shop_search_log`.*
FROM `shop_search_log`
WHERE `cms_language_id` = '".MySqlLegacySupport::getInstance()->real_escape_string($activeLanguage)."' OR `cms_language_id` = ''
GROUP BY `shop_search_log`.`name`
HAVING ".TCMSTagCloud::QUERY_ITEM_COUNT_NAME.' > 0
ORDER BY '.TCMSTagCloud::QUERY_ITEM_COUNT_NAME." DESC
LIMIT 0,{$iSize}
";
// add custom words...
return TCMSTagCloud::GetCloud($query, 'TdbShopSearchLog', $aCustomWords);
} | php | protected function &GetSearchKeywordCloud()
{
$iSize = 13;
$aCustomWords = array();
$oCustomList = &TdbShopSearchCloudWordList::GetList();
while ($oWord = &$oCustomList->Next()) {
$aCustomWords[$oWord->fieldName] = $oWord->fieldWeight;
}
$iSize = $iSize - count($aCustomWords);
if ($iSize < 0) {
$iSize = 0;
}
$activeLanguage = $this->getLanguageService()->getActiveLanguageId();
$query = 'SELECT COUNT(`shop_search_log`.`id`) AS '.TCMSTagCloud::QUERY_ITEM_COUNT_NAME.',
`shop_search_log`.`name` AS '.TCMSTagCloud::QUERY_ITEM_KEY_NAME.",
`shop_search_log`.*
FROM `shop_search_log`
WHERE `cms_language_id` = '".MySqlLegacySupport::getInstance()->real_escape_string($activeLanguage)."' OR `cms_language_id` = ''
GROUP BY `shop_search_log`.`name`
HAVING ".TCMSTagCloud::QUERY_ITEM_COUNT_NAME.' > 0
ORDER BY '.TCMSTagCloud::QUERY_ITEM_COUNT_NAME." DESC
LIMIT 0,{$iSize}
";
// add custom words...
return TCMSTagCloud::GetCloud($query, 'TdbShopSearchLog', $aCustomWords);
} | [
"protected",
"function",
"&",
"GetSearchKeywordCloud",
"(",
")",
"{",
"$",
"iSize",
"=",
"13",
";",
"$",
"aCustomWords",
"=",
"array",
"(",
")",
";",
"$",
"oCustomList",
"=",
"&",
"TdbShopSearchCloudWordList",
"::",
"GetList",
"(",
")",
";",
"while",
"(",
... | return cloud for search keywords.
@return TCMSTagCloud | [
"return",
"cloud",
"for",
"search",
"keywords",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/WebModules/MTShopSearchTagsCore/MTShopSearchTagsCore.class.php#L36-L62 | train |
edmondscommerce/doctrine-static-meta | src/CodeGeneration/Filesystem/Factory/FileFactory.php | FileFactory.createFromExistingPath | public function createFromExistingPath(string $path): File
{
$file = new File($path);
if (false === $file->exists()) {
throw new DoctrineStaticMetaException('File does not exist at ' . $path);
}
return $file;
} | php | public function createFromExistingPath(string $path): File
{
$file = new File($path);
if (false === $file->exists()) {
throw new DoctrineStaticMetaException('File does not exist at ' . $path);
}
return $file;
} | [
"public",
"function",
"createFromExistingPath",
"(",
"string",
"$",
"path",
")",
":",
"File",
"{",
"$",
"file",
"=",
"new",
"File",
"(",
"$",
"path",
")",
";",
"if",
"(",
"false",
"===",
"$",
"file",
"->",
"exists",
"(",
")",
")",
"{",
"throw",
"ne... | Create a new file object from an existing file path
@param string $path
@return File
@throws DoctrineStaticMetaException | [
"Create",
"a",
"new",
"file",
"object",
"from",
"an",
"existing",
"file",
"path"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/CodeGeneration/Filesystem/Factory/FileFactory.php#L54-L62 | train |
edmondscommerce/doctrine-static-meta | src/CodeGeneration/Filesystem/Factory/FileFactory.php | FileFactory.createFromNonExistantPath | public function createFromNonExistantPath(string $path): File
{
$file = new File($path);
if (true === $file->exists()) {
throw new DoctrineStaticMetaException('File exists at ' . $path);
}
return $file;
} | php | public function createFromNonExistantPath(string $path): File
{
$file = new File($path);
if (true === $file->exists()) {
throw new DoctrineStaticMetaException('File exists at ' . $path);
}
return $file;
} | [
"public",
"function",
"createFromNonExistantPath",
"(",
"string",
"$",
"path",
")",
":",
"File",
"{",
"$",
"file",
"=",
"new",
"File",
"(",
"$",
"path",
")",
";",
"if",
"(",
"true",
"===",
"$",
"file",
"->",
"exists",
"(",
")",
")",
"{",
"throw",
"... | Create a new file object that should not already exist at the specified path
@param string $path
@return File
@throws DoctrineStaticMetaException | [
"Create",
"a",
"new",
"file",
"object",
"that",
"should",
"not",
"already",
"exist",
"at",
"the",
"specified",
"path"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/CodeGeneration/Filesystem/Factory/FileFactory.php#L72-L80 | train |
edmondscommerce/doctrine-static-meta | src/CodeGeneration/Filesystem/Factory/FileFactory.php | FileFactory.createFromFqn | public function createFromFqn(string $fqn, $srcOrTestSubFolder = CreatorInterface::SRC_FOLDER): File
{
list($className, , $subDirectories) = $this->namespaceHelper->parseFullyQualifiedName(
$fqn,
$srcOrTestSubFolder,
$this->projectRootNamespace
);
$path = $this->projectRootDirectory
. '/' . implode('/', $subDirectories) . '/' . $className . '.php';
return new File($path);
} | php | public function createFromFqn(string $fqn, $srcOrTestSubFolder = CreatorInterface::SRC_FOLDER): File
{
list($className, , $subDirectories) = $this->namespaceHelper->parseFullyQualifiedName(
$fqn,
$srcOrTestSubFolder,
$this->projectRootNamespace
);
$path = $this->projectRootDirectory
. '/' . implode('/', $subDirectories) . '/' . $className . '.php';
return new File($path);
} | [
"public",
"function",
"createFromFqn",
"(",
"string",
"$",
"fqn",
",",
"$",
"srcOrTestSubFolder",
"=",
"CreatorInterface",
"::",
"SRC_FOLDER",
")",
":",
"File",
"{",
"list",
"(",
"$",
"className",
",",
",",
"$",
"subDirectories",
")",
"=",
"$",
"this",
"->... | Create a new file object from a fully qualified name, may or may not exist
@param string $fqn
@param string $srcOrTestSubFolder
@return File
@throws DoctrineStaticMetaException | [
"Create",
"a",
"new",
"file",
"object",
"from",
"a",
"fully",
"qualified",
"name",
"may",
"or",
"may",
"not",
"exist"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/CodeGeneration/Filesystem/Factory/FileFactory.php#L91-L102 | train |
chameleon-system/chameleon-shop | src/ShopListFilterBundle/objects/db/TPkgShopListfilter.class.php | TPkgShopListfilter.GetCurrentFilterAsArray | public function GetCurrentFilterAsArray()
{
$aFilterAsArray = $this->GetFromInternalCache('aFilterAsArray');
if (is_null($aFilterAsArray)) {
$oList = &$this->GetFieldPkgShopListfilterItemList();
$aFilterAsArray = $oList->GetListSettingAsArray();
$this->SetInternalCache('aFilterAsArray', $aFilterAsArray);
}
return $aFilterAsArray;
} | php | public function GetCurrentFilterAsArray()
{
$aFilterAsArray = $this->GetFromInternalCache('aFilterAsArray');
if (is_null($aFilterAsArray)) {
$oList = &$this->GetFieldPkgShopListfilterItemList();
$aFilterAsArray = $oList->GetListSettingAsArray();
$this->SetInternalCache('aFilterAsArray', $aFilterAsArray);
}
return $aFilterAsArray;
} | [
"public",
"function",
"GetCurrentFilterAsArray",
"(",
")",
"{",
"$",
"aFilterAsArray",
"=",
"$",
"this",
"->",
"GetFromInternalCache",
"(",
"'aFilterAsArray'",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"aFilterAsArray",
")",
")",
"{",
"$",
"oList",
"=",
"&",... | return the current active filter as an array.
@return array | [
"return",
"the",
"current",
"active",
"filter",
"as",
"an",
"array",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopListFilterBundle/objects/db/TPkgShopListfilter.class.php#L308-L318 | train |
chameleon-system/chameleon-shop | src/ShopListFilterBundle/objects/db/TPkgShopListfilter.class.php | TPkgShopListfilter.GetFilterValuesForFilterType | public function GetFilterValuesForFilterType($sFilterSystemName)
{
$aActiveFilter = $this->GetFromInternalCache('aFilterDataAsArrayFor'.$sFilterSystemName);
if (is_null($aActiveFilter)) {
$aActiveFilter = false;
$aFilterData = $this->GetCurrentFilterAsArray();
if (is_array($aFilterData) && array_key_exists(TdbPkgShopListfilterItem::URL_PARAMETER_FILTER_DATA, $aFilterData) && is_array($aFilterData[TdbPkgShopListfilterItem::URL_PARAMETER_FILTER_DATA]) && count($aFilterData[TdbPkgShopListfilterItem::URL_PARAMETER_FILTER_DATA]) > 0) {
$aFilterData = $aFilterData[TdbPkgShopListfilterItem::URL_PARAMETER_FILTER_DATA];
$oFilterId = TdbPkgShopListfilterItem::GetNewInstance();
if ($oFilterId->LoadFromFields(array('pkg_shop_listfilter_id' => $this->id, 'systemname' => $sFilterSystemName))) {
if (is_array($aFilterData) && array_key_exists($oFilterId->id, $aFilterData)) {
if (is_array($aFilterData[$oFilterId->id]) && count($aFilterData[$oFilterId->id]) > 0) {
$aActiveFilter = $aFilterData[$oFilterId->id];
}
}
}
}
$this->SetInternalCache('aFilterDataAsArrayFor'.$sFilterSystemName, $aActiveFilter);
}
return $aActiveFilter;
} | php | public function GetFilterValuesForFilterType($sFilterSystemName)
{
$aActiveFilter = $this->GetFromInternalCache('aFilterDataAsArrayFor'.$sFilterSystemName);
if (is_null($aActiveFilter)) {
$aActiveFilter = false;
$aFilterData = $this->GetCurrentFilterAsArray();
if (is_array($aFilterData) && array_key_exists(TdbPkgShopListfilterItem::URL_PARAMETER_FILTER_DATA, $aFilterData) && is_array($aFilterData[TdbPkgShopListfilterItem::URL_PARAMETER_FILTER_DATA]) && count($aFilterData[TdbPkgShopListfilterItem::URL_PARAMETER_FILTER_DATA]) > 0) {
$aFilterData = $aFilterData[TdbPkgShopListfilterItem::URL_PARAMETER_FILTER_DATA];
$oFilterId = TdbPkgShopListfilterItem::GetNewInstance();
if ($oFilterId->LoadFromFields(array('pkg_shop_listfilter_id' => $this->id, 'systemname' => $sFilterSystemName))) {
if (is_array($aFilterData) && array_key_exists($oFilterId->id, $aFilterData)) {
if (is_array($aFilterData[$oFilterId->id]) && count($aFilterData[$oFilterId->id]) > 0) {
$aActiveFilter = $aFilterData[$oFilterId->id];
}
}
}
}
$this->SetInternalCache('aFilterDataAsArrayFor'.$sFilterSystemName, $aActiveFilter);
}
return $aActiveFilter;
} | [
"public",
"function",
"GetFilterValuesForFilterType",
"(",
"$",
"sFilterSystemName",
")",
"{",
"$",
"aActiveFilter",
"=",
"$",
"this",
"->",
"GetFromInternalCache",
"(",
"'aFilterDataAsArrayFor'",
".",
"$",
"sFilterSystemName",
")",
";",
"if",
"(",
"is_null",
"(",
... | return the filter values set for the filter with the given system name. return false if none are set.
@param array $sFilterSystemName
@return array | [
"return",
"the",
"filter",
"values",
"set",
"for",
"the",
"filter",
"with",
"the",
"given",
"system",
"name",
".",
"return",
"false",
"if",
"none",
"are",
"set",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopListFilterBundle/objects/db/TPkgShopListfilter.class.php#L327-L349 | train |
chameleon-system/chameleon-shop | src/AmazonPaymentBundle/ReferenceIdMapping/AmazonReferenceIdManager.php | AmazonReferenceIdManager.createFromRecordList | public static function createFromRecordList(array $recordList)
{
$manager = null;
foreach ($recordList as $row) {
if (null === $manager) {
$manager = new self($row['amazon_order_reference_id'], $row['shop_order_id']);
}
$item = self::createItemFromRow($row);
$manager->idLists[$item->getType()]->addItem($item);
}
return $manager;
} | php | public static function createFromRecordList(array $recordList)
{
$manager = null;
foreach ($recordList as $row) {
if (null === $manager) {
$manager = new self($row['amazon_order_reference_id'], $row['shop_order_id']);
}
$item = self::createItemFromRow($row);
$manager->idLists[$item->getType()]->addItem($item);
}
return $manager;
} | [
"public",
"static",
"function",
"createFromRecordList",
"(",
"array",
"$",
"recordList",
")",
"{",
"$",
"manager",
"=",
"null",
";",
"foreach",
"(",
"$",
"recordList",
"as",
"$",
"row",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"manager",
")",
"{",
"$",... | the items are loaded in the order they are passed - so make sure to provide them in the correct order.
@param array $recordList
@return AmazonReferenceIdManager|null | [
"the",
"items",
"are",
"loaded",
"in",
"the",
"order",
"they",
"are",
"passed",
"-",
"so",
"make",
"sure",
"to",
"provide",
"them",
"in",
"the",
"correct",
"order",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/AmazonPaymentBundle/ReferenceIdMapping/AmazonReferenceIdManager.php#L247-L259 | train |
chameleon-system/chameleon-shop | src/AmazonPaymentBundle/ReferenceIdMapping/AmazonReferenceIdManager.php | AmazonReferenceIdManager.getListOfAuthorizations | public function getListOfAuthorizations()
{
if (0 === count($this->idLists[IAmazonReferenceId::TYPE_AUTHORIZE])) {
return null;
}
return $this->idLists[IAmazonReferenceId::TYPE_AUTHORIZE];
} | php | public function getListOfAuthorizations()
{
if (0 === count($this->idLists[IAmazonReferenceId::TYPE_AUTHORIZE])) {
return null;
}
return $this->idLists[IAmazonReferenceId::TYPE_AUTHORIZE];
} | [
"public",
"function",
"getListOfAuthorizations",
"(",
")",
"{",
"if",
"(",
"0",
"===",
"count",
"(",
"$",
"this",
"->",
"idLists",
"[",
"IAmazonReferenceId",
"::",
"TYPE_AUTHORIZE",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"... | returns a list of all authorizations for which there are no captures.
@return IAmazonReferenceIdList | [
"returns",
"a",
"list",
"of",
"all",
"authorizations",
"for",
"which",
"there",
"are",
"no",
"captures",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/AmazonPaymentBundle/ReferenceIdMapping/AmazonReferenceIdManager.php#L322-L329 | train |
Erebot/Erebot | src/Identd/Worker.php | Worker.handleMessage | protected function handleMessage($line)
{
if (!is_string($line)) {
return false;
}
$parts = array_map('trim', explode(',', $line));
if (count($parts) != 2) {
return false;
}
$line = implode(" , ", $parts);
if (!ctype_digit($parts[0]) || !ctype_digit($parts[1])) {
return $line . " : ERROR : INVALID-PORT";
}
$cport = (int) $parts[0];
$sport = (int) $parts[1];
if ($sport <= 0 || $sport > 65535 || $cport <= 0 || $cport > 65535) {
return $line . " : ERROR : INVALID-PORT";
}
foreach ($this->bot->getConnections() as $connection) {
if ($connection == $this) {
continue;
}
$socket = $connection->getSocket();
$rport = (int) substr(strrchr(stream_socket_get_name($socket, true), ':'), 1);
if ($rport != $sport) {
continue;
}
$lport = (int) substr(strrchr(stream_socket_get_name($socket, false), ':'), 1);
if ($lport != $cport) {
continue;
}
try {
$config = $connection->getConfig(null);
$identity = $config->parseString(
'\\Erebot\\Module\\IrcConnector',
'identity',
''
);
return $line . " : USERID : UNIX : " . $identity;
} catch (\Erebot\Exception $e) {
return $line . " : ERROR : HIDDEN-USER ";
}
}
return $line . " : ERROR : NO-USER";
} | php | protected function handleMessage($line)
{
if (!is_string($line)) {
return false;
}
$parts = array_map('trim', explode(',', $line));
if (count($parts) != 2) {
return false;
}
$line = implode(" , ", $parts);
if (!ctype_digit($parts[0]) || !ctype_digit($parts[1])) {
return $line . " : ERROR : INVALID-PORT";
}
$cport = (int) $parts[0];
$sport = (int) $parts[1];
if ($sport <= 0 || $sport > 65535 || $cport <= 0 || $cport > 65535) {
return $line . " : ERROR : INVALID-PORT";
}
foreach ($this->bot->getConnections() as $connection) {
if ($connection == $this) {
continue;
}
$socket = $connection->getSocket();
$rport = (int) substr(strrchr(stream_socket_get_name($socket, true), ':'), 1);
if ($rport != $sport) {
continue;
}
$lport = (int) substr(strrchr(stream_socket_get_name($socket, false), ':'), 1);
if ($lport != $cport) {
continue;
}
try {
$config = $connection->getConfig(null);
$identity = $config->parseString(
'\\Erebot\\Module\\IrcConnector',
'identity',
''
);
return $line . " : USERID : UNIX : " . $identity;
} catch (\Erebot\Exception $e) {
return $line . " : ERROR : HIDDEN-USER ";
}
}
return $line . " : ERROR : NO-USER";
} | [
"protected",
"function",
"handleMessage",
"(",
"$",
"line",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"line",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"parts",
"=",
"array_map",
"(",
"'trim'",
",",
"explode",
"(",
"','",
",",
"$",
"l... | Handles an IdentD request.
\param string $line
IdentD request to handle.
\retval string
Message to send as the response
to this request.
\retval false
The request was malformed. | [
"Handles",
"an",
"IdentD",
"request",
"."
] | 691fc3fa8bc6f07061ff2b3798fec76bc3a039aa | https://github.com/Erebot/Erebot/blob/691fc3fa8bc6f07061ff2b3798fec76bc3a039aa/src/Identd/Worker.php#L123-L177 | train |
PGB-LIV/php-ms | src/Reader/HupoPsi/PsiXmlTrait.php | PsiXmlTrait.getCvParam | protected function getCvParam($xml)
{
$cvParam = array();
// Required fields
$cvParam['cvRef'] = (string) $xml->attributes()->cvRef;
$cvParam[PsiVerb::CV_ACCESSION] = (string) $xml->attributes()->accession;
$cvParam[PsiVerb::CV_NAME] = (string) $xml->attributes()->name;
if (! isset($this->cvParamIndex[$cvParam[PsiVerb::CV_ACCESSION]])) {
$this->cvParamIndex[$cvParam[PsiVerb::CV_ACCESSION]] = $cvParam['name'];
}
// Optional fields
if (isset($xml->attributes()->value)) {
$cvParam[PsiVerb::CV_VALUE] = (string) $xml->attributes()->value;
}
if (isset($xml->attributes()->unitAccession)) {
$cvParam[PsiVerb::CV_UNITACCESSION] = (string) $xml->attributes()->unitAccession;
}
if (isset($xml->attributes()->unitName)) {
$cvParam['unitName'] = (string) $xml->attributes()->unitName;
}
if (isset($xml->attributes()->unitCvRef)) {
$cvParam['unitCvRef'] = (string) $xml->attributes()->unitCvRef;
}
return $cvParam;
} | php | protected function getCvParam($xml)
{
$cvParam = array();
// Required fields
$cvParam['cvRef'] = (string) $xml->attributes()->cvRef;
$cvParam[PsiVerb::CV_ACCESSION] = (string) $xml->attributes()->accession;
$cvParam[PsiVerb::CV_NAME] = (string) $xml->attributes()->name;
if (! isset($this->cvParamIndex[$cvParam[PsiVerb::CV_ACCESSION]])) {
$this->cvParamIndex[$cvParam[PsiVerb::CV_ACCESSION]] = $cvParam['name'];
}
// Optional fields
if (isset($xml->attributes()->value)) {
$cvParam[PsiVerb::CV_VALUE] = (string) $xml->attributes()->value;
}
if (isset($xml->attributes()->unitAccession)) {
$cvParam[PsiVerb::CV_UNITACCESSION] = (string) $xml->attributes()->unitAccession;
}
if (isset($xml->attributes()->unitName)) {
$cvParam['unitName'] = (string) $xml->attributes()->unitName;
}
if (isset($xml->attributes()->unitCvRef)) {
$cvParam['unitCvRef'] = (string) $xml->attributes()->unitCvRef;
}
return $cvParam;
} | [
"protected",
"function",
"getCvParam",
"(",
"$",
"xml",
")",
"{",
"$",
"cvParam",
"=",
"array",
"(",
")",
";",
"// Required fields",
"$",
"cvParam",
"[",
"'cvRef'",
"]",
"=",
"(",
"string",
")",
"$",
"xml",
"->",
"attributes",
"(",
")",
"->",
"cvRef",
... | Creates an array object from a CvParam object
@param \SimpleXMLElement $xml | [
"Creates",
"an",
"array",
"object",
"from",
"a",
"CvParam",
"object"
] | 091751eb12512f4bc6ada07bda745ce49331e24f | https://github.com/PGB-LIV/php-ms/blob/091751eb12512f4bc6ada07bda745ce49331e24f/src/Reader/HupoPsi/PsiXmlTrait.php#L57-L88 | train |
chameleon-system/chameleon-shop | src/ShopOrderStatusBundle/objects/data/TPkgShopOrderStatusDataEndPoint.class.php | TPkgShopOrderStatusDataEndPoint.getDataAsTdbArray | public function getDataAsTdbArray()
{
$data = (null === $this->getStatusData()) ? array() : $this->getStatusData()->all();
$data = serialize($data);
return array(
'shop_order_id' => $this->getOrder()->id,
'shop_order_status_code_id' => $this->getShopOrderStatusCodeObject()->id,
'status_date' => date('Y-m-d H:i:s', $this->getStatusTimestamp()),
'info' => $this->getInfo(),
'data' => $data,
);
} | php | public function getDataAsTdbArray()
{
$data = (null === $this->getStatusData()) ? array() : $this->getStatusData()->all();
$data = serialize($data);
return array(
'shop_order_id' => $this->getOrder()->id,
'shop_order_status_code_id' => $this->getShopOrderStatusCodeObject()->id,
'status_date' => date('Y-m-d H:i:s', $this->getStatusTimestamp()),
'info' => $this->getInfo(),
'data' => $data,
);
} | [
"public",
"function",
"getDataAsTdbArray",
"(",
")",
"{",
"$",
"data",
"=",
"(",
"null",
"===",
"$",
"this",
"->",
"getStatusData",
"(",
")",
")",
"?",
"array",
"(",
")",
":",
"$",
"this",
"->",
"getStatusData",
"(",
")",
"->",
"all",
"(",
")",
";"... | returns an assoc array with the data of the object mapped to to the tdb fields.
@return array | [
"returns",
"an",
"assoc",
"array",
"with",
"the",
"data",
"of",
"the",
"object",
"mapped",
"to",
"to",
"the",
"tdb",
"fields",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopOrderStatusBundle/objects/data/TPkgShopOrderStatusDataEndPoint.class.php#L226-L238 | train |
chameleon-system/chameleon-shop | src/ShopBundle/objects/BackendModules/CMSShopArticleIndex/CMSShopArticleIndex.class.php | CMSShopArticleIndex.ClearSearchCacheTables | public function ClearSearchCacheTables()
{
$sQuery = 'TRUNCATE TABLE `shop_search_cache_item`';
\MySqlLegacySupport::getInstance()->query($sQuery);
$sQuery = 'TRUNCATE TABLE `shop_search_cache`';
\MySqlLegacySupport::getInstance()->query($sQuery);
} | php | public function ClearSearchCacheTables()
{
$sQuery = 'TRUNCATE TABLE `shop_search_cache_item`';
\MySqlLegacySupport::getInstance()->query($sQuery);
$sQuery = 'TRUNCATE TABLE `shop_search_cache`';
\MySqlLegacySupport::getInstance()->query($sQuery);
} | [
"public",
"function",
"ClearSearchCacheTables",
"(",
")",
"{",
"$",
"sQuery",
"=",
"'TRUNCATE TABLE `shop_search_cache_item`'",
";",
"\\",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"query",
"(",
"$",
"sQuery",
")",
";",
"$",
"sQuery",
"=",
"'TRU... | Deletes the system's search cache tables. This method is called after
the successfull creation of the shop's search article index. | [
"Deletes",
"the",
"system",
"s",
"search",
"cache",
"tables",
".",
"This",
"method",
"is",
"called",
"after",
"the",
"successfull",
"creation",
"of",
"the",
"shop",
"s",
"search",
"article",
"index",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/BackendModules/CMSShopArticleIndex/CMSShopArticleIndex.class.php#L64-L70 | train |
chameleon-system/chameleon-shop | src/ShopBundle/objects/TCMSInterface/TShopInterface_ImportOrderStatus.class.php | TShopInterface_ImportOrderStatus.ProcessRow | protected function ProcessRow($aRow)
{
// update order
$sOrderNr = '';
$sStatusCode = '';
if (array_key_exists($this->GetParameter('sFieldOrderNr'), $aRow)) {
$sOrderNr = $aRow[$this->GetParameter('sFieldOrderNr')];
}
if (array_key_exists($this->GetParameter('sFieldStatusCode'), $aRow)) {
$sStatusCode = $aRow[$this->GetParameter('sFieldStatusCode')];
}
if (!empty($sOrderNr) && !empty($sStatusCode)) {
$sDate = date('Y-m-d H:i:s');
$oOrder = TdbShopOrder::GetNewInstance();
if ($oOrder->LoadFromField('ordernumber', $sOrderNr)) { // order found.
$oStatusData = new TPkgShopOrderStatusData($oOrder, $sStatusCode, time());
$oStatus = new TPkgShopOrderStatusManager();
$oStatus->addStatus($oStatusData);
}
}
} | php | protected function ProcessRow($aRow)
{
// update order
$sOrderNr = '';
$sStatusCode = '';
if (array_key_exists($this->GetParameter('sFieldOrderNr'), $aRow)) {
$sOrderNr = $aRow[$this->GetParameter('sFieldOrderNr')];
}
if (array_key_exists($this->GetParameter('sFieldStatusCode'), $aRow)) {
$sStatusCode = $aRow[$this->GetParameter('sFieldStatusCode')];
}
if (!empty($sOrderNr) && !empty($sStatusCode)) {
$sDate = date('Y-m-d H:i:s');
$oOrder = TdbShopOrder::GetNewInstance();
if ($oOrder->LoadFromField('ordernumber', $sOrderNr)) { // order found.
$oStatusData = new TPkgShopOrderStatusData($oOrder, $sStatusCode, time());
$oStatus = new TPkgShopOrderStatusManager();
$oStatus->addStatus($oStatusData);
}
}
} | [
"protected",
"function",
"ProcessRow",
"(",
"$",
"aRow",
")",
"{",
"// update order",
"$",
"sOrderNr",
"=",
"''",
";",
"$",
"sStatusCode",
"=",
"''",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"this",
"->",
"GetParameter",
"(",
"'sFieldOrderNr'",
")",
"... | process one row from the file.
@param array $aRow | [
"process",
"one",
"row",
"from",
"the",
"file",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/TCMSInterface/TShopInterface_ImportOrderStatus.class.php#L63-L83 | train |
chameleon-system/chameleon-shop | src/ShopBundle/objects/TCMSInterface/TShopInterface_ImportOrderStatus.class.php | TShopInterface_ImportOrderStatus.GetLine | protected function GetLine()
{
$sLine = fgets($this->fp, 2048 * 16);
if (false === $sLine) {
return $sLine;
}
// find out if the line contains an uneven number of '"'. if so, we assume, that the line contains a line break
$sLine = trim($sLine);
$aTmpParts = explode('"', $sLine);
if (1 != (count($aTmpParts) % 2)) {
// need to read until we find the first '"'...
$bDone = false;
do {
$sTmpLine = fgets($this->fp, 2048 * 16);
if (false === $sTmpLine) {
$bDone = true;
} else {
$sTmpLine = trim($sTmpLine);
$sLine .= "\n".$sTmpLine;
$aTmpParts = explode('"', $sTmpLine);
if (1 != (count($aTmpParts) % 2)) {
$bDone = true;
}
}
} while (!$bDone);
}
$sLine = utf8_encode($sLine);
$aParts = explode($this->sLineSplit, $sLine);
// strip quotes
foreach (array_keys($aParts) as $sIndex) {
$aParts[$sIndex] = trim($aParts[$sIndex]);
if ('"' == substr($aParts[$sIndex], 0, 1) && '"' == substr($aParts[$sIndex], -1)) {
$aParts[$sIndex] = substr($aParts[$sIndex], 1, -1);
}
}
reset($aParts);
return $aParts;
} | php | protected function GetLine()
{
$sLine = fgets($this->fp, 2048 * 16);
if (false === $sLine) {
return $sLine;
}
// find out if the line contains an uneven number of '"'. if so, we assume, that the line contains a line break
$sLine = trim($sLine);
$aTmpParts = explode('"', $sLine);
if (1 != (count($aTmpParts) % 2)) {
// need to read until we find the first '"'...
$bDone = false;
do {
$sTmpLine = fgets($this->fp, 2048 * 16);
if (false === $sTmpLine) {
$bDone = true;
} else {
$sTmpLine = trim($sTmpLine);
$sLine .= "\n".$sTmpLine;
$aTmpParts = explode('"', $sTmpLine);
if (1 != (count($aTmpParts) % 2)) {
$bDone = true;
}
}
} while (!$bDone);
}
$sLine = utf8_encode($sLine);
$aParts = explode($this->sLineSplit, $sLine);
// strip quotes
foreach (array_keys($aParts) as $sIndex) {
$aParts[$sIndex] = trim($aParts[$sIndex]);
if ('"' == substr($aParts[$sIndex], 0, 1) && '"' == substr($aParts[$sIndex], -1)) {
$aParts[$sIndex] = substr($aParts[$sIndex], 1, -1);
}
}
reset($aParts);
return $aParts;
} | [
"protected",
"function",
"GetLine",
"(",
")",
"{",
"$",
"sLine",
"=",
"fgets",
"(",
"$",
"this",
"->",
"fp",
",",
"2048",
"*",
"16",
")",
";",
"if",
"(",
"false",
"===",
"$",
"sLine",
")",
"{",
"return",
"$",
"sLine",
";",
"}",
"// find out if the ... | get a line from the file.
@return array | [
"get",
"a",
"line",
"from",
"the",
"file",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/TCMSInterface/TShopInterface_ImportOrderStatus.class.php#L90-L129 | train |
chameleon-system/chameleon-shop | src/ShopProductExportBundle/objects/TPkgShopProductExportXMLEndPoint.class.php | TPkgShopProductExportXMLEndPoint.CleanContent | protected function CleanContent($sValue)
{
$sValue = parent::CleanContent($sValue);
$sValue = str_replace('"', '"', $sValue);
$sValue = str_replace('&', '&', $sValue);
$sValue = str_replace('>', '>', $sValue);
$sValue = str_replace('<', '<', $sValue);
$sValue = str_replace("'", ''', $sValue);
return $sValue;
} | php | protected function CleanContent($sValue)
{
$sValue = parent::CleanContent($sValue);
$sValue = str_replace('"', '"', $sValue);
$sValue = str_replace('&', '&', $sValue);
$sValue = str_replace('>', '>', $sValue);
$sValue = str_replace('<', '<', $sValue);
$sValue = str_replace("'", ''', $sValue);
return $sValue;
} | [
"protected",
"function",
"CleanContent",
"(",
"$",
"sValue",
")",
"{",
"$",
"sValue",
"=",
"parent",
"::",
"CleanContent",
"(",
"$",
"sValue",
")",
";",
"$",
"sValue",
"=",
"str_replace",
"(",
"'\"'",
",",
"'"'",
",",
"$",
"sValue",
")",
";",
"$",... | clean up the content replace all characters that could cause errors in the xml.
@param $sValue
@return string | [
"clean",
"up",
"the",
"content",
"replace",
"all",
"characters",
"that",
"could",
"cause",
"errors",
"in",
"the",
"xml",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopProductExportBundle/objects/TPkgShopProductExportXMLEndPoint.class.php#L51-L62 | train |
edmondscommerce/doctrine-static-meta | src/CodeGeneration/TypeHelper.php | TypeHelper.normaliseValueToType | public function normaliseValueToType($value, string $expectedType)
{
if (null === $value) {
return null;
}
switch ($expectedType) {
case 'string':
return $this->normaliseString($value);
case 'bool':
return $this->normaliseBool($value);
case 'int':
return $this->normaliseInt($value);
case 'float':
return $this->normaliseFloat($value);
case MappingHelper::PHP_TYPE_DATETIME:
return $this->normaliseDateTime($value);
default:
throw new \RuntimeException('hit unexpected type ' . $expectedType . ' in ' . __METHOD__);
}
} | php | public function normaliseValueToType($value, string $expectedType)
{
if (null === $value) {
return null;
}
switch ($expectedType) {
case 'string':
return $this->normaliseString($value);
case 'bool':
return $this->normaliseBool($value);
case 'int':
return $this->normaliseInt($value);
case 'float':
return $this->normaliseFloat($value);
case MappingHelper::PHP_TYPE_DATETIME:
return $this->normaliseDateTime($value);
default:
throw new \RuntimeException('hit unexpected type ' . $expectedType . ' in ' . __METHOD__);
}
} | [
"public",
"function",
"normaliseValueToType",
"(",
"$",
"value",
",",
"string",
"$",
"expectedType",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"value",
")",
"{",
"return",
"null",
";",
"}",
"switch",
"(",
"$",
"expectedType",
")",
"{",
"case",
"'string'",... | When a default is passed in via CLI then the type can not be expected to be set correctly
This function takes the string value and normalises it into the correct value based on the expected type
@param mixed $value
@param string $expectedType
@return mixed | [
"When",
"a",
"default",
"is",
"passed",
"in",
"via",
"CLI",
"then",
"the",
"type",
"can",
"not",
"be",
"expected",
"to",
"be",
"set",
"correctly"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/CodeGeneration/TypeHelper.php#L46-L65 | train |
CHH/sirel | lib/Sirel/Table.php | Table.project | function project($projections)
{
$select = $this->from();
if (1 === func_num_args() and is_array($projections)) {
return $select->project($projections);
} else {
return $select->project(func_get_args());
}
} | php | function project($projections)
{
$select = $this->from();
if (1 === func_num_args() and is_array($projections)) {
return $select->project($projections);
} else {
return $select->project(func_get_args());
}
} | [
"function",
"project",
"(",
"$",
"projections",
")",
"{",
"$",
"select",
"=",
"$",
"this",
"->",
"from",
"(",
")",
";",
"if",
"(",
"1",
"===",
"func_num_args",
"(",
")",
"and",
"is_array",
"(",
"$",
"projections",
")",
")",
"{",
"return",
"$",
"sel... | Returns a new Select Manager and adds the given expressions as projections
@param array $projections|mixed $projection,...
@return SelectManager | [
"Returns",
"a",
"new",
"Select",
"Manager",
"and",
"adds",
"the",
"given",
"expressions",
"as",
"projections"
] | 7c32b8ed3b975dc18c0e5e257edfd11207e5c8a8 | https://github.com/CHH/sirel/blob/7c32b8ed3b975dc18c0e5e257edfd11207e5c8a8/lib/Sirel/Table.php#L137-L145 | train |
CHH/sirel | lib/Sirel/Table.php | Table.where | function where($expr)
{
$select = $this->from();
foreach (func_get_args() as $expr) {
$select->where($expr);
}
return $select;
} | php | function where($expr)
{
$select = $this->from();
foreach (func_get_args() as $expr) {
$select->where($expr);
}
return $select;
} | [
"function",
"where",
"(",
"$",
"expr",
")",
"{",
"$",
"select",
"=",
"$",
"this",
"->",
"from",
"(",
")",
";",
"foreach",
"(",
"func_get_args",
"(",
")",
"as",
"$",
"expr",
")",
"{",
"$",
"select",
"->",
"where",
"(",
"$",
"expr",
")",
";",
"}"... | Create a new Select Manager and add the given expressions
to its restrictions.
@param mixed $expr,...
@return SelectManager | [
"Create",
"a",
"new",
"Select",
"Manager",
"and",
"add",
"the",
"given",
"expressions",
"to",
"its",
"restrictions",
"."
] | 7c32b8ed3b975dc18c0e5e257edfd11207e5c8a8 | https://github.com/CHH/sirel/blob/7c32b8ed3b975dc18c0e5e257edfd11207e5c8a8/lib/Sirel/Table.php#L165-L172 | train |
CHH/sirel | lib/Sirel/Table.php | Table.order | function order($expr, $direction = \Sirel\Node\Order::ASC)
{
return $this->from()->order($expr, $direction);
} | php | function order($expr, $direction = \Sirel\Node\Order::ASC)
{
return $this->from()->order($expr, $direction);
} | [
"function",
"order",
"(",
"$",
"expr",
",",
"$",
"direction",
"=",
"\\",
"Sirel",
"\\",
"Node",
"\\",
"Order",
"::",
"ASC",
")",
"{",
"return",
"$",
"this",
"->",
"from",
"(",
")",
"->",
"order",
"(",
"$",
"expr",
",",
"$",
"direction",
")",
";",... | Create a new Select Manager and with an Order Expression
@param mixed $expr Order Expression or Sort Column
@param string $direction Optional, Order Direction if an Sort Column
is given as first argument
@return SelectManager | [
"Create",
"a",
"new",
"Select",
"Manager",
"and",
"with",
"an",
"Order",
"Expression"
] | 7c32b8ed3b975dc18c0e5e257edfd11207e5c8a8 | https://github.com/CHH/sirel/blob/7c32b8ed3b975dc18c0e5e257edfd11207e5c8a8/lib/Sirel/Table.php#L182-L185 | train |
CHH/sirel | lib/Sirel/Table.php | Table.addAttribute | function addAttribute(Attribute $attribute)
{
$attribute->setRelation($this);
$this->attributes[$attribute->getName()] = $attribute;
return $this;
} | php | function addAttribute(Attribute $attribute)
{
$attribute->setRelation($this);
$this->attributes[$attribute->getName()] = $attribute;
return $this;
} | [
"function",
"addAttribute",
"(",
"Attribute",
"$",
"attribute",
")",
"{",
"$",
"attribute",
"->",
"setRelation",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"attributes",
"[",
"$",
"attribute",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"attribute",
... | Predefine an Attribute with the given Instance
@param Attribute $attribute
@return Table | [
"Predefine",
"an",
"Attribute",
"with",
"the",
"given",
"Instance"
] | 7c32b8ed3b975dc18c0e5e257edfd11207e5c8a8 | https://github.com/CHH/sirel/blob/7c32b8ed3b975dc18c0e5e257edfd11207e5c8a8/lib/Sirel/Table.php#L238-L243 | train |
CHH/sirel | lib/Sirel/Table.php | Table.offsetGet | function offsetGet($offset)
{
if (empty($this->attributes[$offset])) {
if ($this->strictScheme) {
throw new UnexpectedValueException(
"Strict Scheme: Attribute $offset is not defined."
);
}
$this->attributes[$offset] = new Attribute($offset, $this);
}
return $this->attributes[$offset];
} | php | function offsetGet($offset)
{
if (empty($this->attributes[$offset])) {
if ($this->strictScheme) {
throw new UnexpectedValueException(
"Strict Scheme: Attribute $offset is not defined."
);
}
$this->attributes[$offset] = new Attribute($offset, $this);
}
return $this->attributes[$offset];
} | [
"function",
"offsetGet",
"(",
"$",
"offset",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"attributes",
"[",
"$",
"offset",
"]",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"strictScheme",
")",
"{",
"throw",
"new",
"UnexpectedValueException",... | Allow to access Table Attributes as array offsets on the table object
@thorws UnexpectedValueException If $strictScheme is ON and the
Offset is not defined
@return Attribute | [
"Allow",
"to",
"access",
"Table",
"Attributes",
"as",
"array",
"offsets",
"on",
"the",
"table",
"object"
] | 7c32b8ed3b975dc18c0e5e257edfd11207e5c8a8 | https://github.com/CHH/sirel/blob/7c32b8ed3b975dc18c0e5e257edfd11207e5c8a8/lib/Sirel/Table.php#L287-L298 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.