id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
234,800
|
shopgate/cart-integration-sdk
|
src/core.php
|
ShopgateObject.recursiveToUtf8
|
public function recursiveToUtf8($subject, $sourceEncoding = 'ISO-8859-15', $force = false, $useIconv = false)
{
/** @var array $subject */
if (is_array($subject)) {
foreach ($subject as $key => $value) {
$subject[$key] = $this->recursiveToUtf8($value, $sourceEncoding, $force, $useIconv);
}
return $subject;
} elseif (is_object($subject)) {
/** @var \stdClass $subject */
$objectVars = get_object_vars($subject);
foreach ($objectVars as $property => $value) {
$subject->{$property} = $this->recursiveToUtf8($value, $sourceEncoding, $force, $useIconv);
}
return $subject;
} elseif (is_string($subject)) {
/** @var string $subject */
return $this->stringToUtf8($subject, $sourceEncoding, $force, $useIconv);
}
return $subject;
}
|
php
|
public function recursiveToUtf8($subject, $sourceEncoding = 'ISO-8859-15', $force = false, $useIconv = false)
{
/** @var array $subject */
if (is_array($subject)) {
foreach ($subject as $key => $value) {
$subject[$key] = $this->recursiveToUtf8($value, $sourceEncoding, $force, $useIconv);
}
return $subject;
} elseif (is_object($subject)) {
/** @var \stdClass $subject */
$objectVars = get_object_vars($subject);
foreach ($objectVars as $property => $value) {
$subject->{$property} = $this->recursiveToUtf8($value, $sourceEncoding, $force, $useIconv);
}
return $subject;
} elseif (is_string($subject)) {
/** @var string $subject */
return $this->stringToUtf8($subject, $sourceEncoding, $force, $useIconv);
}
return $subject;
}
|
[
"public",
"function",
"recursiveToUtf8",
"(",
"$",
"subject",
",",
"$",
"sourceEncoding",
"=",
"'ISO-8859-15'",
",",
"$",
"force",
"=",
"false",
",",
"$",
"useIconv",
"=",
"false",
")",
"{",
"/** @var array $subject */",
"if",
"(",
"is_array",
"(",
"$",
"subject",
")",
")",
"{",
"foreach",
"(",
"$",
"subject",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"subject",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"recursiveToUtf8",
"(",
"$",
"value",
",",
"$",
"sourceEncoding",
",",
"$",
"force",
",",
"$",
"useIconv",
")",
";",
"}",
"return",
"$",
"subject",
";",
"}",
"elseif",
"(",
"is_object",
"(",
"$",
"subject",
")",
")",
"{",
"/** @var \\stdClass $subject */",
"$",
"objectVars",
"=",
"get_object_vars",
"(",
"$",
"subject",
")",
";",
"foreach",
"(",
"$",
"objectVars",
"as",
"$",
"property",
"=>",
"$",
"value",
")",
"{",
"$",
"subject",
"->",
"{",
"$",
"property",
"}",
"=",
"$",
"this",
"->",
"recursiveToUtf8",
"(",
"$",
"value",
",",
"$",
"sourceEncoding",
",",
"$",
"force",
",",
"$",
"useIconv",
")",
";",
"}",
"return",
"$",
"subject",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"subject",
")",
")",
"{",
"/** @var string $subject */",
"return",
"$",
"this",
"->",
"stringToUtf8",
"(",
"$",
"subject",
",",
"$",
"sourceEncoding",
",",
"$",
"force",
",",
"$",
"useIconv",
")",
";",
"}",
"return",
"$",
"subject",
";",
"}"
] |
Encodes the values of an array, object or string from a given encoding to UTF-8 recursively.
If the subject is an array, the values will be encoded, keys will be preserved.
If the subject is an object, all accessible properties' values will be encoded.
If the subject is a string, it will simply be encoded.
If the subject is anything else, it will be returned as is.
@param mixed $subject The subject to encode
@param string|string[] $sourceEncoding The (possible) encoding(s) of $string
@param bool $force Set this true to enforce encoding even if the source encoding is already
UTF-8
@param bool $useIconv True to use iconv instead of mb_convert_encoding even if the mb library
is present
@return mixed UTF-8 encoded $subject
|
[
"Encodes",
"the",
"values",
"of",
"an",
"array",
"object",
"or",
"string",
"from",
"a",
"given",
"encoding",
"to",
"UTF",
"-",
"8",
"recursively",
"."
] |
cf12ecf8bdb8f4c407209000002fd00261e53b06
|
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L1314-L1337
|
234,801
|
shopgate/cart-integration-sdk
|
src/core.php
|
ShopgateObject.recursiveFromUtf8
|
public function recursiveFromUtf8($subject, $destinationEncoding = 'ISO-8859-15', $force = false, $useIconv = false)
{
if (is_array($subject)) {
/** @var array $subject */
foreach ($subject as $key => $value) {
$subject[$key] = $this->recursiveFromUtf8($value, $destinationEncoding, $force, $useIconv);
}
return $subject;
} elseif (is_object($subject)) {
/** @var \stdClass $subject */
$objectVars = get_object_vars($subject);
foreach ($objectVars as $property => $value) {
$subject->{$property} = $this->recursiveFromUtf8($value, $destinationEncoding, $force, $useIconv);
}
return $subject;
} elseif (is_string($subject)) {
/** @var string $subject */
return $this->stringFromUtf8($subject, $destinationEncoding, $force, $useIconv);
}
return $subject;
}
|
php
|
public function recursiveFromUtf8($subject, $destinationEncoding = 'ISO-8859-15', $force = false, $useIconv = false)
{
if (is_array($subject)) {
/** @var array $subject */
foreach ($subject as $key => $value) {
$subject[$key] = $this->recursiveFromUtf8($value, $destinationEncoding, $force, $useIconv);
}
return $subject;
} elseif (is_object($subject)) {
/** @var \stdClass $subject */
$objectVars = get_object_vars($subject);
foreach ($objectVars as $property => $value) {
$subject->{$property} = $this->recursiveFromUtf8($value, $destinationEncoding, $force, $useIconv);
}
return $subject;
} elseif (is_string($subject)) {
/** @var string $subject */
return $this->stringFromUtf8($subject, $destinationEncoding, $force, $useIconv);
}
return $subject;
}
|
[
"public",
"function",
"recursiveFromUtf8",
"(",
"$",
"subject",
",",
"$",
"destinationEncoding",
"=",
"'ISO-8859-15'",
",",
"$",
"force",
"=",
"false",
",",
"$",
"useIconv",
"=",
"false",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"subject",
")",
")",
"{",
"/** @var array $subject */",
"foreach",
"(",
"$",
"subject",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"subject",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"recursiveFromUtf8",
"(",
"$",
"value",
",",
"$",
"destinationEncoding",
",",
"$",
"force",
",",
"$",
"useIconv",
")",
";",
"}",
"return",
"$",
"subject",
";",
"}",
"elseif",
"(",
"is_object",
"(",
"$",
"subject",
")",
")",
"{",
"/** @var \\stdClass $subject */",
"$",
"objectVars",
"=",
"get_object_vars",
"(",
"$",
"subject",
")",
";",
"foreach",
"(",
"$",
"objectVars",
"as",
"$",
"property",
"=>",
"$",
"value",
")",
"{",
"$",
"subject",
"->",
"{",
"$",
"property",
"}",
"=",
"$",
"this",
"->",
"recursiveFromUtf8",
"(",
"$",
"value",
",",
"$",
"destinationEncoding",
",",
"$",
"force",
",",
"$",
"useIconv",
")",
";",
"}",
"return",
"$",
"subject",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"subject",
")",
")",
"{",
"/** @var string $subject */",
"return",
"$",
"this",
"->",
"stringFromUtf8",
"(",
"$",
"subject",
",",
"$",
"destinationEncoding",
",",
"$",
"force",
",",
"$",
"useIconv",
")",
";",
"}",
"return",
"$",
"subject",
";",
"}"
] |
Decodes the values of an array, object or string from UTF-8 to a given encoding recursively
If the subject is an array, the values will be decoded, keys will be preserved.
If the subject is an object, all accessible properties' values will be decoded.
If the subject is a string, it will simply be decoded.
If the subject is anything else, it will be returned as is.
@param mixed $subject The subject to decode
@param string $destinationEncoding The desired encoding of the return value
@param bool $force Set this true to enforce encoding even if the destination encoding is set to
UTF-8
@param bool $useIconv True to use iconv instead of mb_convert_encoding even if the mb library is
present
@return mixed UTF-8 decoded $subject
|
[
"Decodes",
"the",
"values",
"of",
"an",
"array",
"object",
"or",
"string",
"from",
"UTF",
"-",
"8",
"to",
"a",
"given",
"encoding",
"recursively"
] |
cf12ecf8bdb8f4c407209000002fd00261e53b06
|
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L1356-L1379
|
234,802
|
shopgate/cart-integration-sdk
|
src/core.php
|
ShopgateObject.convertEncoding
|
protected function convertEncoding($string, $destinationEncoding, $sourceEncoding, $useIconv = false)
{
if (function_exists('mb_convert_encoding') && !$useIconv) {
$convertedString = mb_convert_encoding($string, $destinationEncoding, $sourceEncoding);
} else {
// I have no excuse for the following. Please forgive me.
if (is_array($sourceEncoding)) {
$bestEncoding = '';
$bestScore = null;
foreach ($sourceEncoding as $encoding) {
$score = abs(strlen($string) - strlen(@iconv($encoding, $destinationEncoding, $string)));
if (is_null($bestScore) || ($score < $bestScore)) {
$bestScore = $score;
$bestEncoding = $encoding;
}
}
$sourceEncoding = $bestEncoding;
}
$convertedString = @iconv($sourceEncoding, $destinationEncoding . '//IGNORE', $string);
}
return $convertedString;
}
|
php
|
protected function convertEncoding($string, $destinationEncoding, $sourceEncoding, $useIconv = false)
{
if (function_exists('mb_convert_encoding') && !$useIconv) {
$convertedString = mb_convert_encoding($string, $destinationEncoding, $sourceEncoding);
} else {
// I have no excuse for the following. Please forgive me.
if (is_array($sourceEncoding)) {
$bestEncoding = '';
$bestScore = null;
foreach ($sourceEncoding as $encoding) {
$score = abs(strlen($string) - strlen(@iconv($encoding, $destinationEncoding, $string)));
if (is_null($bestScore) || ($score < $bestScore)) {
$bestScore = $score;
$bestEncoding = $encoding;
}
}
$sourceEncoding = $bestEncoding;
}
$convertedString = @iconv($sourceEncoding, $destinationEncoding . '//IGNORE', $string);
}
return $convertedString;
}
|
[
"protected",
"function",
"convertEncoding",
"(",
"$",
"string",
",",
"$",
"destinationEncoding",
",",
"$",
"sourceEncoding",
",",
"$",
"useIconv",
"=",
"false",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'mb_convert_encoding'",
")",
"&&",
"!",
"$",
"useIconv",
")",
"{",
"$",
"convertedString",
"=",
"mb_convert_encoding",
"(",
"$",
"string",
",",
"$",
"destinationEncoding",
",",
"$",
"sourceEncoding",
")",
";",
"}",
"else",
"{",
"// I have no excuse for the following. Please forgive me.",
"if",
"(",
"is_array",
"(",
"$",
"sourceEncoding",
")",
")",
"{",
"$",
"bestEncoding",
"=",
"''",
";",
"$",
"bestScore",
"=",
"null",
";",
"foreach",
"(",
"$",
"sourceEncoding",
"as",
"$",
"encoding",
")",
"{",
"$",
"score",
"=",
"abs",
"(",
"strlen",
"(",
"$",
"string",
")",
"-",
"strlen",
"(",
"@",
"iconv",
"(",
"$",
"encoding",
",",
"$",
"destinationEncoding",
",",
"$",
"string",
")",
")",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"bestScore",
")",
"||",
"(",
"$",
"score",
"<",
"$",
"bestScore",
")",
")",
"{",
"$",
"bestScore",
"=",
"$",
"score",
";",
"$",
"bestEncoding",
"=",
"$",
"encoding",
";",
"}",
"}",
"$",
"sourceEncoding",
"=",
"$",
"bestEncoding",
";",
"}",
"$",
"convertedString",
"=",
"@",
"iconv",
"(",
"$",
"sourceEncoding",
",",
"$",
"destinationEncoding",
".",
"'//IGNORE'",
",",
"$",
"string",
")",
";",
"}",
"return",
"$",
"convertedString",
";",
"}"
] |
Converts a string's encoding to another.
This wraps the mb_convert_encoding() and iconv() functions of PHP. If the mb_string extension is not installed,
iconv() will be used instead.
If iconv() must be used and an array is passed as $sourceEncoding all encodings will be tested and the
(probably)
best encoding will be used for conversion.
@see http://php.net/manual/en/function.mb-convert-encoding.php
@see http://php.net/manual/en/function.iconv.php
@param string $string The string to decode.
@param string $destinationEncoding The desired encoding of the return value.
@param string|string[] $sourceEncoding The (possible) encoding(s) of $string.
@param bool $useIconv True to use iconv instead of mb_convert_encoding even if the mb
library is present.
@return string The UTF-8 decoded string.
|
[
"Converts",
"a",
"string",
"s",
"encoding",
"to",
"another",
"."
] |
cf12ecf8bdb8f4c407209000002fd00261e53b06
|
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L1402-L1426
|
234,803
|
shopgate/cart-integration-sdk
|
src/core.php
|
ShopgateObject.user_print_r
|
protected function user_print_r($subject, $ignore = array(), $depth = 1, $refChain = array())
{
static $maxDepth = 5;
if ($depth > 20) {
return;
}
if (is_object($subject)) {
foreach ($refChain as $refVal) {
if ($refVal === $subject) {
echo "*RECURSION*\n";
return;
}
}
array_push($refChain, $subject);
echo get_class($subject) . " Object ( \n";
$subject = (array)$subject;
foreach ($subject as $key => $val) {
if (is_array($ignore) && !in_array($key, $ignore, 1)) {
echo str_repeat(" ", $depth * 4) . '[';
if ($key{0} == "\0") {
$keyParts = explode("\0", $key);
echo $keyParts[2] . (($keyParts[1] == '*')
? ':protected'
: ':private');
} else {
echo $key;
}
echo '] => ';
if ($depth == $maxDepth) {
return;
}
$this->user_print_r($val, $ignore, $depth + 1, $refChain);
}
}
echo str_repeat(" ", ($depth - 1) * 4) . ")\n";
array_pop($refChain);
} elseif (is_array($subject)) {
echo "Array ( \n";
foreach ($subject as $key => $val) {
if (is_array($ignore) && !in_array($key, $ignore, 1)) {
echo str_repeat(" ", $depth * 4) . '[' . $key . '] => ';
if ($depth == $maxDepth) {
return;
}
$this->user_print_r($val, $ignore, $depth + 1, $refChain);
}
}
echo str_repeat(" ", ($depth - 1) * 4) . ")\n";
} else {
echo $subject . "\n";
}
}
|
php
|
protected function user_print_r($subject, $ignore = array(), $depth = 1, $refChain = array())
{
static $maxDepth = 5;
if ($depth > 20) {
return;
}
if (is_object($subject)) {
foreach ($refChain as $refVal) {
if ($refVal === $subject) {
echo "*RECURSION*\n";
return;
}
}
array_push($refChain, $subject);
echo get_class($subject) . " Object ( \n";
$subject = (array)$subject;
foreach ($subject as $key => $val) {
if (is_array($ignore) && !in_array($key, $ignore, 1)) {
echo str_repeat(" ", $depth * 4) . '[';
if ($key{0} == "\0") {
$keyParts = explode("\0", $key);
echo $keyParts[2] . (($keyParts[1] == '*')
? ':protected'
: ':private');
} else {
echo $key;
}
echo '] => ';
if ($depth == $maxDepth) {
return;
}
$this->user_print_r($val, $ignore, $depth + 1, $refChain);
}
}
echo str_repeat(" ", ($depth - 1) * 4) . ")\n";
array_pop($refChain);
} elseif (is_array($subject)) {
echo "Array ( \n";
foreach ($subject as $key => $val) {
if (is_array($ignore) && !in_array($key, $ignore, 1)) {
echo str_repeat(" ", $depth * 4) . '[' . $key . '] => ';
if ($depth == $maxDepth) {
return;
}
$this->user_print_r($val, $ignore, $depth + 1, $refChain);
}
}
echo str_repeat(" ", ($depth - 1) * 4) . ")\n";
} else {
echo $subject . "\n";
}
}
|
[
"protected",
"function",
"user_print_r",
"(",
"$",
"subject",
",",
"$",
"ignore",
"=",
"array",
"(",
")",
",",
"$",
"depth",
"=",
"1",
",",
"$",
"refChain",
"=",
"array",
"(",
")",
")",
"{",
"static",
"$",
"maxDepth",
"=",
"5",
";",
"if",
"(",
"$",
"depth",
">",
"20",
")",
"{",
"return",
";",
"}",
"if",
"(",
"is_object",
"(",
"$",
"subject",
")",
")",
"{",
"foreach",
"(",
"$",
"refChain",
"as",
"$",
"refVal",
")",
"{",
"if",
"(",
"$",
"refVal",
"===",
"$",
"subject",
")",
"{",
"echo",
"\"*RECURSION*\\n\"",
";",
"return",
";",
"}",
"}",
"array_push",
"(",
"$",
"refChain",
",",
"$",
"subject",
")",
";",
"echo",
"get_class",
"(",
"$",
"subject",
")",
".",
"\" Object ( \\n\"",
";",
"$",
"subject",
"=",
"(",
"array",
")",
"$",
"subject",
";",
"foreach",
"(",
"$",
"subject",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"ignore",
")",
"&&",
"!",
"in_array",
"(",
"$",
"key",
",",
"$",
"ignore",
",",
"1",
")",
")",
"{",
"echo",
"str_repeat",
"(",
"\" \"",
",",
"$",
"depth",
"*",
"4",
")",
".",
"'['",
";",
"if",
"(",
"$",
"key",
"{",
"0",
"}",
"==",
"\"\\0\"",
")",
"{",
"$",
"keyParts",
"=",
"explode",
"(",
"\"\\0\"",
",",
"$",
"key",
")",
";",
"echo",
"$",
"keyParts",
"[",
"2",
"]",
".",
"(",
"(",
"$",
"keyParts",
"[",
"1",
"]",
"==",
"'*'",
")",
"?",
"':protected'",
":",
"':private'",
")",
";",
"}",
"else",
"{",
"echo",
"$",
"key",
";",
"}",
"echo",
"'] => '",
";",
"if",
"(",
"$",
"depth",
"==",
"$",
"maxDepth",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"user_print_r",
"(",
"$",
"val",
",",
"$",
"ignore",
",",
"$",
"depth",
"+",
"1",
",",
"$",
"refChain",
")",
";",
"}",
"}",
"echo",
"str_repeat",
"(",
"\" \"",
",",
"(",
"$",
"depth",
"-",
"1",
")",
"*",
"4",
")",
".",
"\")\\n\"",
";",
"array_pop",
"(",
"$",
"refChain",
")",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"subject",
")",
")",
"{",
"echo",
"\"Array ( \\n\"",
";",
"foreach",
"(",
"$",
"subject",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"ignore",
")",
"&&",
"!",
"in_array",
"(",
"$",
"key",
",",
"$",
"ignore",
",",
"1",
")",
")",
"{",
"echo",
"str_repeat",
"(",
"\" \"",
",",
"$",
"depth",
"*",
"4",
")",
".",
"'['",
".",
"$",
"key",
".",
"'] => '",
";",
"if",
"(",
"$",
"depth",
"==",
"$",
"maxDepth",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"user_print_r",
"(",
"$",
"val",
",",
"$",
"ignore",
",",
"$",
"depth",
"+",
"1",
",",
"$",
"refChain",
")",
";",
"}",
"}",
"echo",
"str_repeat",
"(",
"\" \"",
",",
"(",
"$",
"depth",
"-",
"1",
")",
"*",
"4",
")",
".",
"\")\\n\"",
";",
"}",
"else",
"{",
"echo",
"$",
"subject",
".",
"\"\\n\"",
";",
"}",
"}"
] |
Takes any big object that can contain recursion and dumps it to the output buffer
@param mixed $subject
@param array $ignore
@param int $depth
@param array $refChain
|
[
"Takes",
"any",
"big",
"object",
"that",
"can",
"contain",
"recursion",
"and",
"dumps",
"it",
"to",
"the",
"output",
"buffer"
] |
cf12ecf8bdb8f4c407209000002fd00261e53b06
|
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L1436-L1488
|
234,804
|
shopgate/cart-integration-sdk
|
src/core.php
|
ShopgateObject.getMemoryUsageString
|
protected function getMemoryUsageString()
{
switch (strtoupper(trim(ShopgateLogger::getInstance()->getMemoryAnalyserLoggingSizeUnit()))) {
case 'GB':
return (memory_get_usage() / (1024 * 1024 * 1024)) . " GB (real usage " . (memory_get_usage(
true
) / (1024 * 1024 * 1024)) . " GB)";
case 'MB':
return (memory_get_usage() / (1024 * 1024)) . " MB (real usage " . (memory_get_usage(
true
) / (1024 * 1024)) . " MB)";
case 'KB':
return (memory_get_usage() / 1024) . " KB (real usage " . (memory_get_usage(true) / 1024) . " KB)";
default:
return memory_get_usage() . " Bytes (real usage " . memory_get_usage(true) . " Bytes)";
}
}
|
php
|
protected function getMemoryUsageString()
{
switch (strtoupper(trim(ShopgateLogger::getInstance()->getMemoryAnalyserLoggingSizeUnit()))) {
case 'GB':
return (memory_get_usage() / (1024 * 1024 * 1024)) . " GB (real usage " . (memory_get_usage(
true
) / (1024 * 1024 * 1024)) . " GB)";
case 'MB':
return (memory_get_usage() / (1024 * 1024)) . " MB (real usage " . (memory_get_usage(
true
) / (1024 * 1024)) . " MB)";
case 'KB':
return (memory_get_usage() / 1024) . " KB (real usage " . (memory_get_usage(true) / 1024) . " KB)";
default:
return memory_get_usage() . " Bytes (real usage " . memory_get_usage(true) . " Bytes)";
}
}
|
[
"protected",
"function",
"getMemoryUsageString",
"(",
")",
"{",
"switch",
"(",
"strtoupper",
"(",
"trim",
"(",
"ShopgateLogger",
"::",
"getInstance",
"(",
")",
"->",
"getMemoryAnalyserLoggingSizeUnit",
"(",
")",
")",
")",
")",
"{",
"case",
"'GB'",
":",
"return",
"(",
"memory_get_usage",
"(",
")",
"/",
"(",
"1024",
"*",
"1024",
"*",
"1024",
")",
")",
".",
"\" GB (real usage \"",
".",
"(",
"memory_get_usage",
"(",
"true",
")",
"/",
"(",
"1024",
"*",
"1024",
"*",
"1024",
")",
")",
".",
"\" GB)\"",
";",
"case",
"'MB'",
":",
"return",
"(",
"memory_get_usage",
"(",
")",
"/",
"(",
"1024",
"*",
"1024",
")",
")",
".",
"\" MB (real usage \"",
".",
"(",
"memory_get_usage",
"(",
"true",
")",
"/",
"(",
"1024",
"*",
"1024",
")",
")",
".",
"\" MB)\"",
";",
"case",
"'KB'",
":",
"return",
"(",
"memory_get_usage",
"(",
")",
"/",
"1024",
")",
".",
"\" KB (real usage \"",
".",
"(",
"memory_get_usage",
"(",
"true",
")",
"/",
"1024",
")",
".",
"\" KB)\"",
";",
"default",
":",
"return",
"memory_get_usage",
"(",
")",
".",
"\" Bytes (real usage \"",
".",
"memory_get_usage",
"(",
"true",
")",
".",
"\" Bytes)\"",
";",
"}",
"}"
] |
Gets the used memory and real used memory and returns it as a string
@return string
|
[
"Gets",
"the",
"used",
"memory",
"and",
"real",
"used",
"memory",
"and",
"returns",
"it",
"as",
"a",
"string"
] |
cf12ecf8bdb8f4c407209000002fd00261e53b06
|
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L1516-L1532
|
234,805
|
shopgate/cart-integration-sdk
|
src/core.php
|
ShopgatePlugin.getCreateCsvLoaders
|
final private function getCreateCsvLoaders($subjectName)
{
$actions = array();
$subjectName = trim($subjectName);
if (!empty($subjectName)) {
$methodName = 'buildDefault' . $this->camelize($subjectName, true) . 'Row';
if (method_exists($this, $methodName)) {
foreach (array_keys($this->{$methodName}()) as $sKey) {
$actions[] = $subjectName . "Export" . $this->camelize($sKey, true);
}
}
}
return $actions;
}
|
php
|
final private function getCreateCsvLoaders($subjectName)
{
$actions = array();
$subjectName = trim($subjectName);
if (!empty($subjectName)) {
$methodName = 'buildDefault' . $this->camelize($subjectName, true) . 'Row';
if (method_exists($this, $methodName)) {
foreach (array_keys($this->{$methodName}()) as $sKey) {
$actions[] = $subjectName . "Export" . $this->camelize($sKey, true);
}
}
}
return $actions;
}
|
[
"final",
"private",
"function",
"getCreateCsvLoaders",
"(",
"$",
"subjectName",
")",
"{",
"$",
"actions",
"=",
"array",
"(",
")",
";",
"$",
"subjectName",
"=",
"trim",
"(",
"$",
"subjectName",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"subjectName",
")",
")",
"{",
"$",
"methodName",
"=",
"'buildDefault'",
".",
"$",
"this",
"->",
"camelize",
"(",
"$",
"subjectName",
",",
"true",
")",
".",
"'Row'",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"methodName",
")",
")",
"{",
"foreach",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"{",
"$",
"methodName",
"}",
"(",
")",
")",
"as",
"$",
"sKey",
")",
"{",
"$",
"actions",
"[",
"]",
"=",
"$",
"subjectName",
".",
"\"Export\"",
".",
"$",
"this",
"->",
"camelize",
"(",
"$",
"sKey",
",",
"true",
")",
";",
"}",
"}",
"}",
"return",
"$",
"actions",
";",
"}"
] |
Creates an array of corresponding helper method names, based on the export type given
@param string $subjectName
@return array
|
[
"Creates",
"an",
"array",
"of",
"corresponding",
"helper",
"method",
"names",
"based",
"on",
"the",
"export",
"type",
"given"
] |
cf12ecf8bdb8f4c407209000002fd00261e53b06
|
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L2391-L2405
|
234,806
|
shopgate/cart-integration-sdk
|
src/core.php
|
ShopgatePlugin.disableAction
|
public function disableAction($actionName)
{
$shopgateSettingsNew = array('enable_' . $actionName => 0);
$this->config->load($shopgateSettingsNew);
$this->config->save(array_keys($shopgateSettingsNew), true);
}
|
php
|
public function disableAction($actionName)
{
$shopgateSettingsNew = array('enable_' . $actionName => 0);
$this->config->load($shopgateSettingsNew);
$this->config->save(array_keys($shopgateSettingsNew), true);
}
|
[
"public",
"function",
"disableAction",
"(",
"$",
"actionName",
")",
"{",
"$",
"shopgateSettingsNew",
"=",
"array",
"(",
"'enable_'",
".",
"$",
"actionName",
"=>",
"0",
")",
";",
"$",
"this",
"->",
"config",
"->",
"load",
"(",
"$",
"shopgateSettingsNew",
")",
";",
"$",
"this",
"->",
"config",
"->",
"save",
"(",
"array_keys",
"(",
"$",
"shopgateSettingsNew",
")",
",",
"true",
")",
";",
"}"
] |
disables an API method in the local config
@param string $actionName
|
[
"disables",
"an",
"API",
"method",
"in",
"the",
"local",
"config"
] |
cf12ecf8bdb8f4c407209000002fd00261e53b06
|
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L2458-L2463
|
234,807
|
shopgate/cart-integration-sdk
|
src/core.php
|
ShopgatePlugin.createShopInfo
|
public function createShopInfo()
{
$shopInfo = array(
'category_count' => 0,
'item_count' => 0,
);
if ($this->config->getEnableGetReviewsCsv()) {
$shopInfo['review_count'] = 0;
}
if ($this->config->getEnableGetMediaCsv()) {
$shopInfo['media_count'] = array();
}
return $shopInfo;
}
|
php
|
public function createShopInfo()
{
$shopInfo = array(
'category_count' => 0,
'item_count' => 0,
);
if ($this->config->getEnableGetReviewsCsv()) {
$shopInfo['review_count'] = 0;
}
if ($this->config->getEnableGetMediaCsv()) {
$shopInfo['media_count'] = array();
}
return $shopInfo;
}
|
[
"public",
"function",
"createShopInfo",
"(",
")",
"{",
"$",
"shopInfo",
"=",
"array",
"(",
"'category_count'",
"=>",
"0",
",",
"'item_count'",
"=>",
"0",
",",
")",
";",
"if",
"(",
"$",
"this",
"->",
"config",
"->",
"getEnableGetReviewsCsv",
"(",
")",
")",
"{",
"$",
"shopInfo",
"[",
"'review_count'",
"]",
"=",
"0",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"config",
"->",
"getEnableGetMediaCsv",
"(",
")",
")",
"{",
"$",
"shopInfo",
"[",
"'media_count'",
"]",
"=",
"array",
"(",
")",
";",
"}",
"return",
"$",
"shopInfo",
";",
"}"
] |
Callback function for the Shopgate Plugin API ping action.
Override this to append additional information about shop system to the response of the ping action.
@return mixed[] An array with additional information.
|
[
"Callback",
"function",
"for",
"the",
"Shopgate",
"Plugin",
"API",
"ping",
"action",
".",
"Override",
"this",
"to",
"append",
"additional",
"information",
"about",
"shop",
"system",
"to",
"the",
"response",
"of",
"the",
"ping",
"action",
"."
] |
cf12ecf8bdb8f4c407209000002fd00261e53b06
|
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L2529-L2545
|
234,808
|
shopgate/cart-integration-sdk
|
src/core.php
|
ShopgatePlugin.redeemCoupons
|
public function redeemCoupons(ShopgateCart $cart)
{
$this->disableAction('redeem_coupons');
throw new ShopgateLibraryException(
ShopgateLibraryException::PLUGIN_API_DISABLED_ACTION,
'The requested action is disabled and no longer supported.',
true,
false
);
}
|
php
|
public function redeemCoupons(ShopgateCart $cart)
{
$this->disableAction('redeem_coupons');
throw new ShopgateLibraryException(
ShopgateLibraryException::PLUGIN_API_DISABLED_ACTION,
'The requested action is disabled and no longer supported.',
true,
false
);
}
|
[
"public",
"function",
"redeemCoupons",
"(",
"ShopgateCart",
"$",
"cart",
")",
"{",
"$",
"this",
"->",
"disableAction",
"(",
"'redeem_coupons'",
")",
";",
"throw",
"new",
"ShopgateLibraryException",
"(",
"ShopgateLibraryException",
"::",
"PLUGIN_API_DISABLED_ACTION",
",",
"'The requested action is disabled and no longer supported.'",
",",
"true",
",",
"false",
")",
";",
"}"
] |
Redeems coupons that are passed along with a ShopgateCart object.
@param ShopgateCart $cart The ShopgateCart object containing the coupons that should be redeemed.
@return array('external_coupons' => ShopgateExternalCoupon[])
@throws ShopgateLibraryException if an error occurs.
@see http://developer.shopgate.com/plugin_api/coupons
@deprecated no longer supported.
|
[
"Redeems",
"coupons",
"that",
"are",
"passed",
"along",
"with",
"a",
"ShopgateCart",
"object",
"."
] |
cf12ecf8bdb8f4c407209000002fd00261e53b06
|
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L2632-L2641
|
234,809
|
shopgate/cart-integration-sdk
|
src/core.php
|
ShopgateContainer.loadArray
|
public function loadArray(array $data = array())
{
$unmappedData = array();
if (is_array($data)) {
$methods = get_class_methods($this);
foreach ($data as $key => $value) {
$setter = 'set' . $this->camelize($key, true);
if (!in_array($setter, $methods)) {
$unmappedData[$key] = $value;
continue;
}
$this->$setter($value);
}
}
return $unmappedData;
}
|
php
|
public function loadArray(array $data = array())
{
$unmappedData = array();
if (is_array($data)) {
$methods = get_class_methods($this);
foreach ($data as $key => $value) {
$setter = 'set' . $this->camelize($key, true);
if (!in_array($setter, $methods)) {
$unmappedData[$key] = $value;
continue;
}
$this->$setter($value);
}
}
return $unmappedData;
}
|
[
"public",
"function",
"loadArray",
"(",
"array",
"$",
"data",
"=",
"array",
"(",
")",
")",
"{",
"$",
"unmappedData",
"=",
"array",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"$",
"methods",
"=",
"get_class_methods",
"(",
"$",
"this",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"setter",
"=",
"'set'",
".",
"$",
"this",
"->",
"camelize",
"(",
"$",
"key",
",",
"true",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"setter",
",",
"$",
"methods",
")",
")",
"{",
"$",
"unmappedData",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"continue",
";",
"}",
"$",
"this",
"->",
"$",
"setter",
"(",
"$",
"value",
")",
";",
"}",
"}",
"return",
"$",
"unmappedData",
";",
"}"
] |
Tries to map an associative array to the object's attributes.
The passed data must be an array, it's indices must be the un-camelized,
underscored names of the set* methods of the object.
Tha data that couldn't be mapped is returned as an array.
@param array <string, mixed> $data The data that should be mapped to the container object.
@return array<string, mixed> The part of the array that couldn't be mapped.
|
[
"Tries",
"to",
"map",
"an",
"associative",
"array",
"to",
"the",
"object",
"s",
"attributes",
"."
] |
cf12ecf8bdb8f4c407209000002fd00261e53b06
|
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L3207-L3224
|
234,810
|
shopgate/cart-integration-sdk
|
src/core.php
|
ShopgateContainer.compare
|
public function compare($obj, $obj2, $whitelist)
{
foreach ($whitelist as $acceptedField) {
if ($obj->{$this->camelize('get_' . $acceptedField)}() != $obj2->{$this->camelize('get_' . $acceptedField)}(
)) {
return false;
}
}
return true;
}
|
php
|
public function compare($obj, $obj2, $whitelist)
{
foreach ($whitelist as $acceptedField) {
if ($obj->{$this->camelize('get_' . $acceptedField)}() != $obj2->{$this->camelize('get_' . $acceptedField)}(
)) {
return false;
}
}
return true;
}
|
[
"public",
"function",
"compare",
"(",
"$",
"obj",
",",
"$",
"obj2",
",",
"$",
"whitelist",
")",
"{",
"foreach",
"(",
"$",
"whitelist",
"as",
"$",
"acceptedField",
")",
"{",
"if",
"(",
"$",
"obj",
"->",
"{",
"$",
"this",
"->",
"camelize",
"(",
"'get_'",
".",
"$",
"acceptedField",
")",
"}",
"(",
")",
"!=",
"$",
"obj2",
"->",
"{",
"$",
"this",
"->",
"camelize",
"(",
"'get_'",
".",
"$",
"acceptedField",
")",
"}",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Compares values of two containers.
@param ShopgateContainer $obj
@param ShopgateContainer $obj2
@param string[] $whitelist
@return bool
|
[
"Compares",
"values",
"of",
"two",
"containers",
"."
] |
cf12ecf8bdb8f4c407209000002fd00261e53b06
|
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L3235-L3245
|
234,811
|
shopgate/cart-integration-sdk
|
src/core.php
|
ShopgateContainer.utf8Encode
|
public function utf8Encode($sourceEncoding = 'ISO-8859-15', $force = false, $useIconv = false)
{
$visitor = new ShopgateContainerUtf8Visitor(
ShopgateContainerUtf8Visitor::MODE_ENCODE, $sourceEncoding,
$force,
$useIconv
);
$visitor->visitContainer($this);
return $visitor->getObject();
}
|
php
|
public function utf8Encode($sourceEncoding = 'ISO-8859-15', $force = false, $useIconv = false)
{
$visitor = new ShopgateContainerUtf8Visitor(
ShopgateContainerUtf8Visitor::MODE_ENCODE, $sourceEncoding,
$force,
$useIconv
);
$visitor->visitContainer($this);
return $visitor->getObject();
}
|
[
"public",
"function",
"utf8Encode",
"(",
"$",
"sourceEncoding",
"=",
"'ISO-8859-15'",
",",
"$",
"force",
"=",
"false",
",",
"$",
"useIconv",
"=",
"false",
")",
"{",
"$",
"visitor",
"=",
"new",
"ShopgateContainerUtf8Visitor",
"(",
"ShopgateContainerUtf8Visitor",
"::",
"MODE_ENCODE",
",",
"$",
"sourceEncoding",
",",
"$",
"force",
",",
"$",
"useIconv",
")",
";",
"$",
"visitor",
"->",
"visitContainer",
"(",
"$",
"this",
")",
";",
"return",
"$",
"visitor",
"->",
"getObject",
"(",
")",
";",
"}"
] |
Creates a new object of the same type with every value recursively utf-8 encoded.
@param String $sourceEncoding The source Encoding of the strings
@param bool $force Set this true to enforce encoding even if the source encoding is already UTF-8.
@param bool $useIconv True to use iconv instead of mb_convert_encoding even if the mb library is present.
@return ShopgateContainer The new object with utf-8 encoded values.
|
[
"Creates",
"a",
"new",
"object",
"of",
"the",
"same",
"type",
"with",
"every",
"value",
"recursively",
"utf",
"-",
"8",
"encoded",
"."
] |
cf12ecf8bdb8f4c407209000002fd00261e53b06
|
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L3269-L3279
|
234,812
|
shopgate/cart-integration-sdk
|
src/core.php
|
ShopgateContainer.utf8Decode
|
public function utf8Decode($destinationEncoding = 'ISO-8859-15', $force = false, $useIconv = false)
{
$visitor = new ShopgateContainerUtf8Visitor(
ShopgateContainerUtf8Visitor::MODE_DECODE,
$destinationEncoding,
$force, $useIconv
);
$visitor->visitContainer($this);
return $visitor->getObject();
}
|
php
|
public function utf8Decode($destinationEncoding = 'ISO-8859-15', $force = false, $useIconv = false)
{
$visitor = new ShopgateContainerUtf8Visitor(
ShopgateContainerUtf8Visitor::MODE_DECODE,
$destinationEncoding,
$force, $useIconv
);
$visitor->visitContainer($this);
return $visitor->getObject();
}
|
[
"public",
"function",
"utf8Decode",
"(",
"$",
"destinationEncoding",
"=",
"'ISO-8859-15'",
",",
"$",
"force",
"=",
"false",
",",
"$",
"useIconv",
"=",
"false",
")",
"{",
"$",
"visitor",
"=",
"new",
"ShopgateContainerUtf8Visitor",
"(",
"ShopgateContainerUtf8Visitor",
"::",
"MODE_DECODE",
",",
"$",
"destinationEncoding",
",",
"$",
"force",
",",
"$",
"useIconv",
")",
";",
"$",
"visitor",
"->",
"visitContainer",
"(",
"$",
"this",
")",
";",
"return",
"$",
"visitor",
"->",
"getObject",
"(",
")",
";",
"}"
] |
Creates a new object of the same type with every value recursively utf-8 decoded.
@param String $destinationEncoding The destination Encoding for the strings
@param bool $force Set this true to enforce encoding even if the destination encoding is set to
UTF-8.
@param bool $useIconv True to use iconv instead of mb_convert_encoding even if the mb library is
present.
@return ShopgateContainer The new object with utf-8 decoded values.
|
[
"Creates",
"a",
"new",
"object",
"of",
"the",
"same",
"type",
"with",
"every",
"value",
"recursively",
"utf",
"-",
"8",
"decoded",
"."
] |
cf12ecf8bdb8f4c407209000002fd00261e53b06
|
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L3292-L3302
|
234,813
|
shopgate/cart-integration-sdk
|
src/core.php
|
ShopgateContainer.buildProperties
|
public function buildProperties()
{
$methods = get_class_methods($this);
$properties = get_object_vars($this);
$filteredProperties = array();
// only properties that have getters should be extracted
foreach ($properties as $property => $value) {
$getter = 'get' . $this->camelize($property, true);
if (in_array($getter, $methods)) {
$filteredProperties[$property] = $this->{$getter}();
}
}
return $filteredProperties;
}
|
php
|
public function buildProperties()
{
$methods = get_class_methods($this);
$properties = get_object_vars($this);
$filteredProperties = array();
// only properties that have getters should be extracted
foreach ($properties as $property => $value) {
$getter = 'get' . $this->camelize($property, true);
if (in_array($getter, $methods)) {
$filteredProperties[$property] = $this->{$getter}();
}
}
return $filteredProperties;
}
|
[
"public",
"function",
"buildProperties",
"(",
")",
"{",
"$",
"methods",
"=",
"get_class_methods",
"(",
"$",
"this",
")",
";",
"$",
"properties",
"=",
"get_object_vars",
"(",
"$",
"this",
")",
";",
"$",
"filteredProperties",
"=",
"array",
"(",
")",
";",
"// only properties that have getters should be extracted",
"foreach",
"(",
"$",
"properties",
"as",
"$",
"property",
"=>",
"$",
"value",
")",
"{",
"$",
"getter",
"=",
"'get'",
".",
"$",
"this",
"->",
"camelize",
"(",
"$",
"property",
",",
"true",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"getter",
",",
"$",
"methods",
")",
")",
"{",
"$",
"filteredProperties",
"[",
"$",
"property",
"]",
"=",
"$",
"this",
"->",
"{",
"$",
"getter",
"}",
"(",
")",
";",
"}",
"}",
"return",
"$",
"filteredProperties",
";",
"}"
] |
Creates an array of all properties that have getters.
@return mixed[]
|
[
"Creates",
"an",
"array",
"of",
"all",
"properties",
"that",
"have",
"getters",
"."
] |
cf12ecf8bdb8f4c407209000002fd00261e53b06
|
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L3309-L3324
|
234,814
|
shpasser/GaeSupport
|
src/Shpasser/GaeSupport/Foundation/Application.php
|
Application.detectGae
|
protected function detectGae()
{
if (! class_exists(self::GAE_ID_SERVICE)) {
$this->runningOnGae = false;
$this->appId = null;
return;
}
$AppIdentityService = self::GAE_ID_SERVICE;
$this->appId = $AppIdentityService::getApplicationId();
$this->runningOnGae = ! preg_match('/dev~/', getenv('APPLICATION_ID'));
if ($this->runningOnGae) {
require_once(__DIR__ . '/gae_realpath.php');
}
}
|
php
|
protected function detectGae()
{
if (! class_exists(self::GAE_ID_SERVICE)) {
$this->runningOnGae = false;
$this->appId = null;
return;
}
$AppIdentityService = self::GAE_ID_SERVICE;
$this->appId = $AppIdentityService::getApplicationId();
$this->runningOnGae = ! preg_match('/dev~/', getenv('APPLICATION_ID'));
if ($this->runningOnGae) {
require_once(__DIR__ . '/gae_realpath.php');
}
}
|
[
"protected",
"function",
"detectGae",
"(",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"self",
"::",
"GAE_ID_SERVICE",
")",
")",
"{",
"$",
"this",
"->",
"runningOnGae",
"=",
"false",
";",
"$",
"this",
"->",
"appId",
"=",
"null",
";",
"return",
";",
"}",
"$",
"AppIdentityService",
"=",
"self",
"::",
"GAE_ID_SERVICE",
";",
"$",
"this",
"->",
"appId",
"=",
"$",
"AppIdentityService",
"::",
"getApplicationId",
"(",
")",
";",
"$",
"this",
"->",
"runningOnGae",
"=",
"!",
"preg_match",
"(",
"'/dev~/'",
",",
"getenv",
"(",
"'APPLICATION_ID'",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"runningOnGae",
")",
"{",
"require_once",
"(",
"__DIR__",
".",
"'/gae_realpath.php'",
")",
";",
"}",
"}"
] |
Detect if the application is running on GAE.
If we run on GAE then 'realpath()' function replacement
'gae_realpath()' is declared, so it won't fail with GAE
bucket paths.
In order for 'gae_realpath()' function to be called the code has
to be patched to use 'gae_realpath()' instead of 'realpath()'
using the command 'php artisan gae:deploy --config you@gmail.com'
from the terminal.
|
[
"Detect",
"if",
"the",
"application",
"is",
"running",
"on",
"GAE",
"."
] |
7f37f2bf177a4e8f1cbefdf04f49b51016e85ae3
|
https://github.com/shpasser/GaeSupport/blob/7f37f2bf177a4e8f1cbefdf04f49b51016e85ae3/src/Shpasser/GaeSupport/Foundation/Application.php#L51-L66
|
234,815
|
shpasser/GaeSupport
|
src/Shpasser/GaeSupport/Foundation/Application.php
|
Application.bindStoragePath
|
protected function bindStoragePath()
{
if ($this->runningOnGae) {
$buckets = ini_get('google_app_engine.allow_include_gs_buckets');
// Get the first bucket in the list.
$bucket = current(explode(', ', $buckets));
if ($bucket) {
$storagePath = "gs://{$bucket}/storage";
if (!file_exists($storagePath)) {
mkdir($storagePath);
}
$this->instance("path.storage", $storagePath);
}
}
}
|
php
|
protected function bindStoragePath()
{
if ($this->runningOnGae) {
$buckets = ini_get('google_app_engine.allow_include_gs_buckets');
// Get the first bucket in the list.
$bucket = current(explode(', ', $buckets));
if ($bucket) {
$storagePath = "gs://{$bucket}/storage";
if (!file_exists($storagePath)) {
mkdir($storagePath);
}
$this->instance("path.storage", $storagePath);
}
}
}
|
[
"protected",
"function",
"bindStoragePath",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"runningOnGae",
")",
"{",
"$",
"buckets",
"=",
"ini_get",
"(",
"'google_app_engine.allow_include_gs_buckets'",
")",
";",
"// Get the first bucket in the list.",
"$",
"bucket",
"=",
"current",
"(",
"explode",
"(",
"', '",
",",
"$",
"buckets",
")",
")",
";",
"if",
"(",
"$",
"bucket",
")",
"{",
"$",
"storagePath",
"=",
"\"gs://{$bucket}/storage\"",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"storagePath",
")",
")",
"{",
"mkdir",
"(",
"$",
"storagePath",
")",
";",
"}",
"$",
"this",
"->",
"instance",
"(",
"\"path.storage\"",
",",
"$",
"storagePath",
")",
";",
"}",
"}",
"}"
] |
Binds the GAE storage path if running on GAE.
The binding of the new storage path overrides the
original one which appears in the 'paths.php' file.
The GAE storage directory is created if it does
not exist already.
@return void
|
[
"Binds",
"the",
"GAE",
"storage",
"path",
"if",
"running",
"on",
"GAE",
".",
"The",
"binding",
"of",
"the",
"new",
"storage",
"path",
"overrides",
"the",
"original",
"one",
"which",
"appears",
"in",
"the",
"paths",
".",
"php",
"file",
"."
] |
7f37f2bf177a4e8f1cbefdf04f49b51016e85ae3
|
https://github.com/shpasser/GaeSupport/blob/7f37f2bf177a4e8f1cbefdf04f49b51016e85ae3/src/Shpasser/GaeSupport/Foundation/Application.php#L126-L143
|
234,816
|
potsky/microsoft-translator-php-sdk
|
src/MicrosoftTranslator/Logger.php
|
Logger.fatal
|
public function fatal( $object , $category , $message )
{
$this->message( self::getMessagePrefix( $object , $category , 'fatal' ) . $message , self::LEVEL_FATAL );
throw new Exception( $message );
}
|
php
|
public function fatal( $object , $category , $message )
{
$this->message( self::getMessagePrefix( $object , $category , 'fatal' ) . $message , self::LEVEL_FATAL );
throw new Exception( $message );
}
|
[
"public",
"function",
"fatal",
"(",
"$",
"object",
",",
"$",
"category",
",",
"$",
"message",
")",
"{",
"$",
"this",
"->",
"message",
"(",
"self",
"::",
"getMessagePrefix",
"(",
"$",
"object",
",",
"$",
"category",
",",
"'fatal'",
")",
".",
"$",
"message",
",",
"self",
"::",
"LEVEL_FATAL",
")",
";",
"throw",
"new",
"Exception",
"(",
"$",
"message",
")",
";",
"}"
] |
fatal message and throw an MicrosoftTranslator\Exception
@param string $object
@param string $category
@param string $message
@throws \MicrosoftTranslator\Exception
|
[
"fatal",
"message",
"and",
"throw",
"an",
"MicrosoftTranslator",
"\\",
"Exception"
] |
102f2411be5abb0e57a73c475f8e9e185a9f4859
|
https://github.com/potsky/microsoft-translator-php-sdk/blob/102f2411be5abb0e57a73c475f8e9e185a9f4859/src/MicrosoftTranslator/Logger.php#L147-L152
|
234,817
|
potsky/microsoft-translator-php-sdk
|
src/MicrosoftTranslator/Logger.php
|
Logger.message
|
private function message( $message , $message_level )
{
if ( $message_level <= (int)$this->log_level )
{
if ( empty( $this->log_file_path ) )
{
error_log( $message );
}
else
{
if ( @file_put_contents( $this->log_file_path , $message . "\n" , FILE_APPEND ) === false )
{
$message = sprintf( "Unable to write to log file %s" , $this->log_file_path );
error_log( self::getMessagePrefix( __CLASS__ , 'message' , 'fatal' ) . $message );
throw new Exception( $message );
}
}
return true;
}
return false;
}
|
php
|
private function message( $message , $message_level )
{
if ( $message_level <= (int)$this->log_level )
{
if ( empty( $this->log_file_path ) )
{
error_log( $message );
}
else
{
if ( @file_put_contents( $this->log_file_path , $message . "\n" , FILE_APPEND ) === false )
{
$message = sprintf( "Unable to write to log file %s" , $this->log_file_path );
error_log( self::getMessagePrefix( __CLASS__ , 'message' , 'fatal' ) . $message );
throw new Exception( $message );
}
}
return true;
}
return false;
}
|
[
"private",
"function",
"message",
"(",
"$",
"message",
",",
"$",
"message_level",
")",
"{",
"if",
"(",
"$",
"message_level",
"<=",
"(",
"int",
")",
"$",
"this",
"->",
"log_level",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"log_file_path",
")",
")",
"{",
"error_log",
"(",
"$",
"message",
")",
";",
"}",
"else",
"{",
"if",
"(",
"@",
"file_put_contents",
"(",
"$",
"this",
"->",
"log_file_path",
",",
"$",
"message",
".",
"\"\\n\"",
",",
"FILE_APPEND",
")",
"===",
"false",
")",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"\"Unable to write to log file %s\"",
",",
"$",
"this",
"->",
"log_file_path",
")",
";",
"error_log",
"(",
"self",
"::",
"getMessagePrefix",
"(",
"__CLASS__",
",",
"'message'",
",",
"'fatal'",
")",
".",
"$",
"message",
")",
";",
"throw",
"new",
"Exception",
"(",
"$",
"message",
")",
";",
"}",
"}",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Log a message using error_log if log level is compliant
@param string $message
@param integer $message_level
@return bool true if message has been logged
@throws \MicrosoftTranslator\Exception
|
[
"Log",
"a",
"message",
"using",
"error_log",
"if",
"log",
"level",
"is",
"compliant"
] |
102f2411be5abb0e57a73c475f8e9e185a9f4859
|
https://github.com/potsky/microsoft-translator-php-sdk/blob/102f2411be5abb0e57a73c475f8e9e185a9f4859/src/MicrosoftTranslator/Logger.php#L163-L187
|
234,818
|
makinacorpus/drupal-ucms
|
ucms_seo/src/Controller/StoreLocatorController.php
|
StoreLocatorController.renderFieldAction
|
public function renderFieldAction(NodeInterface $node, $type, $sub_area = null, $locality = null)
{
$type = $type === 'all' ? null : $type;
$sub_area = $sub_area === 'all' ? null : $sub_area;
/** @var StoreLocatorInterface $storeLocator */
$storeLocator = $this
->get('ucms_seo.store_locator_factory')
->create($node, $type, $sub_area, $locality);
$build = [];
if (node_is_page($node)) {
$title = $storeLocator->getTitle();
// @todo this is global state, therefore wrong
drupal_set_title($node->title.' '.$title);
// @todo this should be #attached
drupal_add_js([
'storeLocator' => ['items' => $storeLocator->getMapItems()],
], 'setting');
$build['map'] = [
'#theme' => 'ucms_seo_store_locator_map',
'#items' => $storeLocator->getMapItems(),
'#nodes' => $storeLocator->getNodes(),
'#type' => $storeLocator->getTypeLabel($type),
'#sub_area' => $storeLocator->getSubAreaLabel(),
'#locality' => $storeLocator->getLocalityLabel(),
];
}
$build['store_links'] = [
'#theme' => 'links__ucms_seo__store_locator',
'#links' => $storeLocator->getLinks(),
];
return $build;
}
|
php
|
public function renderFieldAction(NodeInterface $node, $type, $sub_area = null, $locality = null)
{
$type = $type === 'all' ? null : $type;
$sub_area = $sub_area === 'all' ? null : $sub_area;
/** @var StoreLocatorInterface $storeLocator */
$storeLocator = $this
->get('ucms_seo.store_locator_factory')
->create($node, $type, $sub_area, $locality);
$build = [];
if (node_is_page($node)) {
$title = $storeLocator->getTitle();
// @todo this is global state, therefore wrong
drupal_set_title($node->title.' '.$title);
// @todo this should be #attached
drupal_add_js([
'storeLocator' => ['items' => $storeLocator->getMapItems()],
], 'setting');
$build['map'] = [
'#theme' => 'ucms_seo_store_locator_map',
'#items' => $storeLocator->getMapItems(),
'#nodes' => $storeLocator->getNodes(),
'#type' => $storeLocator->getTypeLabel($type),
'#sub_area' => $storeLocator->getSubAreaLabel(),
'#locality' => $storeLocator->getLocalityLabel(),
];
}
$build['store_links'] = [
'#theme' => 'links__ucms_seo__store_locator',
'#links' => $storeLocator->getLinks(),
];
return $build;
}
|
[
"public",
"function",
"renderFieldAction",
"(",
"NodeInterface",
"$",
"node",
",",
"$",
"type",
",",
"$",
"sub_area",
"=",
"null",
",",
"$",
"locality",
"=",
"null",
")",
"{",
"$",
"type",
"=",
"$",
"type",
"===",
"'all'",
"?",
"null",
":",
"$",
"type",
";",
"$",
"sub_area",
"=",
"$",
"sub_area",
"===",
"'all'",
"?",
"null",
":",
"$",
"sub_area",
";",
"/** @var StoreLocatorInterface $storeLocator */",
"$",
"storeLocator",
"=",
"$",
"this",
"->",
"get",
"(",
"'ucms_seo.store_locator_factory'",
")",
"->",
"create",
"(",
"$",
"node",
",",
"$",
"type",
",",
"$",
"sub_area",
",",
"$",
"locality",
")",
";",
"$",
"build",
"=",
"[",
"]",
";",
"if",
"(",
"node_is_page",
"(",
"$",
"node",
")",
")",
"{",
"$",
"title",
"=",
"$",
"storeLocator",
"->",
"getTitle",
"(",
")",
";",
"// @todo this is global state, therefore wrong",
"drupal_set_title",
"(",
"$",
"node",
"->",
"title",
".",
"' '",
".",
"$",
"title",
")",
";",
"// @todo this should be #attached",
"drupal_add_js",
"(",
"[",
"'storeLocator'",
"=>",
"[",
"'items'",
"=>",
"$",
"storeLocator",
"->",
"getMapItems",
"(",
")",
"]",
",",
"]",
",",
"'setting'",
")",
";",
"$",
"build",
"[",
"'map'",
"]",
"=",
"[",
"'#theme'",
"=>",
"'ucms_seo_store_locator_map'",
",",
"'#items'",
"=>",
"$",
"storeLocator",
"->",
"getMapItems",
"(",
")",
",",
"'#nodes'",
"=>",
"$",
"storeLocator",
"->",
"getNodes",
"(",
")",
",",
"'#type'",
"=>",
"$",
"storeLocator",
"->",
"getTypeLabel",
"(",
"$",
"type",
")",
",",
"'#sub_area'",
"=>",
"$",
"storeLocator",
"->",
"getSubAreaLabel",
"(",
")",
",",
"'#locality'",
"=>",
"$",
"storeLocator",
"->",
"getLocalityLabel",
"(",
")",
",",
"]",
";",
"}",
"$",
"build",
"[",
"'store_links'",
"]",
"=",
"[",
"'#theme'",
"=>",
"'links__ucms_seo__store_locator'",
",",
"'#links'",
"=>",
"$",
"storeLocator",
"->",
"getLinks",
"(",
")",
",",
"]",
";",
"return",
"$",
"build",
";",
"}"
] |
This renders the field when viewing a store_locator bundle
|
[
"This",
"renders",
"the",
"field",
"when",
"viewing",
"a",
"store_locator",
"bundle"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/Controller/StoreLocatorController.php#L37-L75
|
234,819
|
makinacorpus/drupal-ucms
|
ucms_notification/src/EventDispatcher/ExtranetMemberEventSubscriber.php
|
ExtranetMemberEventSubscriber.notify
|
protected function notify(ExtranetMemberEvent $event, $action)
{
$userId = $event->getSubject()->id();
$siteId = $event->getSite()->getId();
$this->notificationService->notifyChannel('site:' . $siteId, 'member', $userId, $action, $event->getArguments());
}
|
php
|
protected function notify(ExtranetMemberEvent $event, $action)
{
$userId = $event->getSubject()->id();
$siteId = $event->getSite()->getId();
$this->notificationService->notifyChannel('site:' . $siteId, 'member', $userId, $action, $event->getArguments());
}
|
[
"protected",
"function",
"notify",
"(",
"ExtranetMemberEvent",
"$",
"event",
",",
"$",
"action",
")",
"{",
"$",
"userId",
"=",
"$",
"event",
"->",
"getSubject",
"(",
")",
"->",
"id",
"(",
")",
";",
"$",
"siteId",
"=",
"$",
"event",
"->",
"getSite",
"(",
")",
"->",
"getId",
"(",
")",
";",
"$",
"this",
"->",
"notificationService",
"->",
"notifyChannel",
"(",
"'site:'",
".",
"$",
"siteId",
",",
"'member'",
",",
"$",
"userId",
",",
"$",
"action",
",",
"$",
"event",
"->",
"getArguments",
"(",
")",
")",
";",
"}"
] |
Sends a notification on the site's channel.
@param ExtranetMemberEvent $event
@param string $action
|
[
"Sends",
"a",
"notification",
"on",
"the",
"site",
"s",
"channel",
"."
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_notification/src/EventDispatcher/ExtranetMemberEventSubscriber.php#L66-L72
|
234,820
|
makinacorpus/drupal-ucms
|
ucms_notification/src/NotificationService.php
|
NotificationService.getUserAccount
|
private function getUserAccount($userId)
{
$user = $this->entityManager->getStorage('user')->load($userId);
if (!$user) {
throw new \InvalidArgumentException(sprintf("User %d does not exist", $userId));
}
return $user;
}
|
php
|
private function getUserAccount($userId)
{
$user = $this->entityManager->getStorage('user')->load($userId);
if (!$user) {
throw new \InvalidArgumentException(sprintf("User %d does not exist", $userId));
}
return $user;
}
|
[
"private",
"function",
"getUserAccount",
"(",
"$",
"userId",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"getStorage",
"(",
"'user'",
")",
"->",
"load",
"(",
"$",
"userId",
")",
";",
"if",
"(",
"!",
"$",
"user",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"\"User %d does not exist\"",
",",
"$",
"userId",
")",
")",
";",
"}",
"return",
"$",
"user",
";",
"}"
] |
Get user account
@param int $userId
@return \Drupal\Core\Session\AccountInterface
|
[
"Get",
"user",
"account"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_notification/src/NotificationService.php#L47-L56
|
234,821
|
makinacorpus/drupal-ucms
|
ucms_notification/src/NotificationService.php
|
NotificationService.refreshSubscriptionsFor
|
public function refreshSubscriptionsFor($userId)
{
$valid = ['client:' . $userId];
$account = $this->getUserAccount($userId);
$default = [
'admin:client',
'admin:content',
'admin:label',
'admin:seo',
'admin:site',
];
if (!$account->isAuthenticated() || !$account->status) {
// Do not allow deactivated or anymous user to incidently have
// subscribed channels, it would be terrible performance loss
// for pretty much no reason.
$valid = [];
} else {
// Must handle user groupes instead
if ($this->groupManager) {
// @todo We MUST handle a role within the group instead of using
// global permissions, this must be fixed in a near future.
$accessList = $this->groupManager->getUserGroups($account);
if ($accessList) {
// Add group sites to user, but do not add anything else, when
// using the platform with groups, user with no groups are not
// considered and must not receive anything.
if ($account->hasPermission(Access::PERM_NOTIF_CONTENT)) {
foreach ($accessList as $access) {
$valid[] = 'admin:content:' . $access->getGroupId();
}
}
if ($account->hasPermission(Access::PERM_NOTIF_SITE)) {
foreach ($accessList as $access) {
$valid[] = 'admin:site:' . $access->getGroupId();
}
}
}
} else {
// Normal behaviors, when the group module is not enabled.
if ($account->hasPermission(Access::PERM_NOTIF_CONTENT)) {
$valid[] = 'admin:content';
}
if ($account->hasPermission(Access::PERM_NOTIF_SITE)) {
$valid[] = 'admin:site';
}
}
// Those three, as of today, are not group-dependent.
if ($account->hasPermission(Access::PERM_NOTIF_LABEL)) {
$valid[] = 'admin:label';
}
if ($account->hasPermission(Access::PERM_NOTIF_SEO)) {
$valid[] = 'admin:seo';
}
if ($account->hasPermission(Access::PERM_NOTIF_USER)) {
$valid[] = 'admin:client';
}
}
$remove = array_diff($default, $valid);
if ($valid) {
$subscriber = $this->notificationService->getSubscriber($userId);
foreach ($valid as $chanId) {
if ($subscriber->hasSubscriptionFor($chanId)) {
continue;
}
try {
$subscriber->subscribe($chanId);
} catch (ChannelDoesNotExistException $e) {
$this->notificationService->getBackend()->createChannel($chanId);
$subscriber->subscribe($chanId);
}
}
}
if ($remove) {
$this->deleteSubscriptionsFor($userId, $remove);
}
}
|
php
|
public function refreshSubscriptionsFor($userId)
{
$valid = ['client:' . $userId];
$account = $this->getUserAccount($userId);
$default = [
'admin:client',
'admin:content',
'admin:label',
'admin:seo',
'admin:site',
];
if (!$account->isAuthenticated() || !$account->status) {
// Do not allow deactivated or anymous user to incidently have
// subscribed channels, it would be terrible performance loss
// for pretty much no reason.
$valid = [];
} else {
// Must handle user groupes instead
if ($this->groupManager) {
// @todo We MUST handle a role within the group instead of using
// global permissions, this must be fixed in a near future.
$accessList = $this->groupManager->getUserGroups($account);
if ($accessList) {
// Add group sites to user, but do not add anything else, when
// using the platform with groups, user with no groups are not
// considered and must not receive anything.
if ($account->hasPermission(Access::PERM_NOTIF_CONTENT)) {
foreach ($accessList as $access) {
$valid[] = 'admin:content:' . $access->getGroupId();
}
}
if ($account->hasPermission(Access::PERM_NOTIF_SITE)) {
foreach ($accessList as $access) {
$valid[] = 'admin:site:' . $access->getGroupId();
}
}
}
} else {
// Normal behaviors, when the group module is not enabled.
if ($account->hasPermission(Access::PERM_NOTIF_CONTENT)) {
$valid[] = 'admin:content';
}
if ($account->hasPermission(Access::PERM_NOTIF_SITE)) {
$valid[] = 'admin:site';
}
}
// Those three, as of today, are not group-dependent.
if ($account->hasPermission(Access::PERM_NOTIF_LABEL)) {
$valid[] = 'admin:label';
}
if ($account->hasPermission(Access::PERM_NOTIF_SEO)) {
$valid[] = 'admin:seo';
}
if ($account->hasPermission(Access::PERM_NOTIF_USER)) {
$valid[] = 'admin:client';
}
}
$remove = array_diff($default, $valid);
if ($valid) {
$subscriber = $this->notificationService->getSubscriber($userId);
foreach ($valid as $chanId) {
if ($subscriber->hasSubscriptionFor($chanId)) {
continue;
}
try {
$subscriber->subscribe($chanId);
} catch (ChannelDoesNotExistException $e) {
$this->notificationService->getBackend()->createChannel($chanId);
$subscriber->subscribe($chanId);
}
}
}
if ($remove) {
$this->deleteSubscriptionsFor($userId, $remove);
}
}
|
[
"public",
"function",
"refreshSubscriptionsFor",
"(",
"$",
"userId",
")",
"{",
"$",
"valid",
"=",
"[",
"'client:'",
".",
"$",
"userId",
"]",
";",
"$",
"account",
"=",
"$",
"this",
"->",
"getUserAccount",
"(",
"$",
"userId",
")",
";",
"$",
"default",
"=",
"[",
"'admin:client'",
",",
"'admin:content'",
",",
"'admin:label'",
",",
"'admin:seo'",
",",
"'admin:site'",
",",
"]",
";",
"if",
"(",
"!",
"$",
"account",
"->",
"isAuthenticated",
"(",
")",
"||",
"!",
"$",
"account",
"->",
"status",
")",
"{",
"// Do not allow deactivated or anymous user to incidently have",
"// subscribed channels, it would be terrible performance loss",
"// for pretty much no reason.",
"$",
"valid",
"=",
"[",
"]",
";",
"}",
"else",
"{",
"// Must handle user groupes instead",
"if",
"(",
"$",
"this",
"->",
"groupManager",
")",
"{",
"// @todo We MUST handle a role within the group instead of using",
"// global permissions, this must be fixed in a near future.",
"$",
"accessList",
"=",
"$",
"this",
"->",
"groupManager",
"->",
"getUserGroups",
"(",
"$",
"account",
")",
";",
"if",
"(",
"$",
"accessList",
")",
"{",
"// Add group sites to user, but do not add anything else, when",
"// using the platform with groups, user with no groups are not",
"// considered and must not receive anything.",
"if",
"(",
"$",
"account",
"->",
"hasPermission",
"(",
"Access",
"::",
"PERM_NOTIF_CONTENT",
")",
")",
"{",
"foreach",
"(",
"$",
"accessList",
"as",
"$",
"access",
")",
"{",
"$",
"valid",
"[",
"]",
"=",
"'admin:content:'",
".",
"$",
"access",
"->",
"getGroupId",
"(",
")",
";",
"}",
"}",
"if",
"(",
"$",
"account",
"->",
"hasPermission",
"(",
"Access",
"::",
"PERM_NOTIF_SITE",
")",
")",
"{",
"foreach",
"(",
"$",
"accessList",
"as",
"$",
"access",
")",
"{",
"$",
"valid",
"[",
"]",
"=",
"'admin:site:'",
".",
"$",
"access",
"->",
"getGroupId",
"(",
")",
";",
"}",
"}",
"}",
"}",
"else",
"{",
"// Normal behaviors, when the group module is not enabled.",
"if",
"(",
"$",
"account",
"->",
"hasPermission",
"(",
"Access",
"::",
"PERM_NOTIF_CONTENT",
")",
")",
"{",
"$",
"valid",
"[",
"]",
"=",
"'admin:content'",
";",
"}",
"if",
"(",
"$",
"account",
"->",
"hasPermission",
"(",
"Access",
"::",
"PERM_NOTIF_SITE",
")",
")",
"{",
"$",
"valid",
"[",
"]",
"=",
"'admin:site'",
";",
"}",
"}",
"// Those three, as of today, are not group-dependent.",
"if",
"(",
"$",
"account",
"->",
"hasPermission",
"(",
"Access",
"::",
"PERM_NOTIF_LABEL",
")",
")",
"{",
"$",
"valid",
"[",
"]",
"=",
"'admin:label'",
";",
"}",
"if",
"(",
"$",
"account",
"->",
"hasPermission",
"(",
"Access",
"::",
"PERM_NOTIF_SEO",
")",
")",
"{",
"$",
"valid",
"[",
"]",
"=",
"'admin:seo'",
";",
"}",
"if",
"(",
"$",
"account",
"->",
"hasPermission",
"(",
"Access",
"::",
"PERM_NOTIF_USER",
")",
")",
"{",
"$",
"valid",
"[",
"]",
"=",
"'admin:client'",
";",
"}",
"}",
"$",
"remove",
"=",
"array_diff",
"(",
"$",
"default",
",",
"$",
"valid",
")",
";",
"if",
"(",
"$",
"valid",
")",
"{",
"$",
"subscriber",
"=",
"$",
"this",
"->",
"notificationService",
"->",
"getSubscriber",
"(",
"$",
"userId",
")",
";",
"foreach",
"(",
"$",
"valid",
"as",
"$",
"chanId",
")",
"{",
"if",
"(",
"$",
"subscriber",
"->",
"hasSubscriptionFor",
"(",
"$",
"chanId",
")",
")",
"{",
"continue",
";",
"}",
"try",
"{",
"$",
"subscriber",
"->",
"subscribe",
"(",
"$",
"chanId",
")",
";",
"}",
"catch",
"(",
"ChannelDoesNotExistException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"notificationService",
"->",
"getBackend",
"(",
")",
"->",
"createChannel",
"(",
"$",
"chanId",
")",
";",
"$",
"subscriber",
"->",
"subscribe",
"(",
"$",
"chanId",
")",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"remove",
")",
"{",
"$",
"this",
"->",
"deleteSubscriptionsFor",
"(",
"$",
"userId",
",",
"$",
"remove",
")",
";",
"}",
"}"
] |
Ensure user mandatory subscriptions
Always remember that having the view notifications permissions does not
imply that you can see the content, so users might receive notifications
about content they cannot see; doing otherwise would mean to recheck
all permissions/access rights for all users on every content update which
is not something doable at all.
@param int $userId
|
[
"Ensure",
"user",
"mandatory",
"subscriptions"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_notification/src/NotificationService.php#L69-L154
|
234,822
|
makinacorpus/drupal-ucms
|
ucms_notification/src/NotificationService.php
|
NotificationService.deleteSubscriptionsFor
|
public function deleteSubscriptionsFor($userId, $chanIdList = null)
{
$conditions = [
Field::SUBER_NAME => $this
->notificationService
->getSubscriberName($userId),
];
if ($chanIdList) {
$conditions[Field::CHAN_ID] = $chanIdList;
}
$this
->notificationService
->getBackend()
->fetchSubscriptions($conditions)
->delete()
;
}
|
php
|
public function deleteSubscriptionsFor($userId, $chanIdList = null)
{
$conditions = [
Field::SUBER_NAME => $this
->notificationService
->getSubscriberName($userId),
];
if ($chanIdList) {
$conditions[Field::CHAN_ID] = $chanIdList;
}
$this
->notificationService
->getBackend()
->fetchSubscriptions($conditions)
->delete()
;
}
|
[
"public",
"function",
"deleteSubscriptionsFor",
"(",
"$",
"userId",
",",
"$",
"chanIdList",
"=",
"null",
")",
"{",
"$",
"conditions",
"=",
"[",
"Field",
"::",
"SUBER_NAME",
"=>",
"$",
"this",
"->",
"notificationService",
"->",
"getSubscriberName",
"(",
"$",
"userId",
")",
",",
"]",
";",
"if",
"(",
"$",
"chanIdList",
")",
"{",
"$",
"conditions",
"[",
"Field",
"::",
"CHAN_ID",
"]",
"=",
"$",
"chanIdList",
";",
"}",
"$",
"this",
"->",
"notificationService",
"->",
"getBackend",
"(",
")",
"->",
"fetchSubscriptions",
"(",
"$",
"conditions",
")",
"->",
"delete",
"(",
")",
";",
"}"
] |
Delete user subscriptions
@param int $userId
@param string[] $chanIdList
|
[
"Delete",
"user",
"subscriptions"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_notification/src/NotificationService.php#L162-L180
|
234,823
|
accompli/accompli
|
src/Console/Command/InitCommand.php
|
InitCommand.interact
|
protected function interact(InputInterface $input, OutputInterface $output)
{
$io = $this->getIO($input, $output);
$io->write(Accompli::LOGO);
$io->writeln(' =========================');
$io->writeln(' Configuration generator');
$io->writeln(' =========================');
$accompli = new Accompli(new ParameterBag());
$accompli->initializeStreamWrapper();
$recipe = $io->choice('Select a recipe to extend from', $this->getAvailableRecipes(), 'defaults.json');
if ($recipe === 'Other') {
$this->configuration['$extend'] = $io->ask('Enter the path to the recipe');
} elseif ($recipe === 'None') {
unset($this->configuration['$extend']);
} else {
$this->configuration['$extend'] = 'accompli://recipe/'.$recipe;
}
$this->interactForHostConfigurations($io);
$this->interactForTaskConfigurations($io);
$io->writeln(' The generator will create the following configuration:');
$io->writeln($this->getJsonEncodedConfiguration());
$io->confirm('Do you wish to continue?');
}
|
php
|
protected function interact(InputInterface $input, OutputInterface $output)
{
$io = $this->getIO($input, $output);
$io->write(Accompli::LOGO);
$io->writeln(' =========================');
$io->writeln(' Configuration generator');
$io->writeln(' =========================');
$accompli = new Accompli(new ParameterBag());
$accompli->initializeStreamWrapper();
$recipe = $io->choice('Select a recipe to extend from', $this->getAvailableRecipes(), 'defaults.json');
if ($recipe === 'Other') {
$this->configuration['$extend'] = $io->ask('Enter the path to the recipe');
} elseif ($recipe === 'None') {
unset($this->configuration['$extend']);
} else {
$this->configuration['$extend'] = 'accompli://recipe/'.$recipe;
}
$this->interactForHostConfigurations($io);
$this->interactForTaskConfigurations($io);
$io->writeln(' The generator will create the following configuration:');
$io->writeln($this->getJsonEncodedConfiguration());
$io->confirm('Do you wish to continue?');
}
|
[
"protected",
"function",
"interact",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"io",
"=",
"$",
"this",
"->",
"getIO",
"(",
"$",
"input",
",",
"$",
"output",
")",
";",
"$",
"io",
"->",
"write",
"(",
"Accompli",
"::",
"LOGO",
")",
";",
"$",
"io",
"->",
"writeln",
"(",
"' ========================='",
")",
";",
"$",
"io",
"->",
"writeln",
"(",
"' Configuration generator'",
")",
";",
"$",
"io",
"->",
"writeln",
"(",
"' ========================='",
")",
";",
"$",
"accompli",
"=",
"new",
"Accompli",
"(",
"new",
"ParameterBag",
"(",
")",
")",
";",
"$",
"accompli",
"->",
"initializeStreamWrapper",
"(",
")",
";",
"$",
"recipe",
"=",
"$",
"io",
"->",
"choice",
"(",
"'Select a recipe to extend from'",
",",
"$",
"this",
"->",
"getAvailableRecipes",
"(",
")",
",",
"'defaults.json'",
")",
";",
"if",
"(",
"$",
"recipe",
"===",
"'Other'",
")",
"{",
"$",
"this",
"->",
"configuration",
"[",
"'$extend'",
"]",
"=",
"$",
"io",
"->",
"ask",
"(",
"'Enter the path to the recipe'",
")",
";",
"}",
"elseif",
"(",
"$",
"recipe",
"===",
"'None'",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"configuration",
"[",
"'$extend'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"configuration",
"[",
"'$extend'",
"]",
"=",
"'accompli://recipe/'",
".",
"$",
"recipe",
";",
"}",
"$",
"this",
"->",
"interactForHostConfigurations",
"(",
"$",
"io",
")",
";",
"$",
"this",
"->",
"interactForTaskConfigurations",
"(",
"$",
"io",
")",
";",
"$",
"io",
"->",
"writeln",
"(",
"' The generator will create the following configuration:'",
")",
";",
"$",
"io",
"->",
"writeln",
"(",
"$",
"this",
"->",
"getJsonEncodedConfiguration",
"(",
")",
")",
";",
"$",
"io",
"->",
"confirm",
"(",
"'Do you wish to continue?'",
")",
";",
"}"
] |
Interacts with the user to retrieve the configuration for an accompli.json file.
@param InputInterface $input
@param OutputInterface $output
|
[
"Interacts",
"with",
"the",
"user",
"to",
"retrieve",
"the",
"configuration",
"for",
"an",
"accompli",
".",
"json",
"file",
"."
] |
618f28377448d8caa90d63bfa5865a3ee15e49e7
|
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Console/Command/InitCommand.php#L66-L92
|
234,824
|
accompli/accompli
|
src/Console/Command/InitCommand.php
|
InitCommand.interactForHostConfigurations
|
private function interactForHostConfigurations(OutputStyle $io)
{
$io->writeln(' Add host configurations:');
$addHost = true;
while ($addHost) {
$stage = $io->choice('Stage', array(
Host::STAGE_PRODUCTION,
Host::STAGE_ACCEPTANCE,
Host::STAGE_TEST,
));
$hostname = $io->ask('Hostname');
$path = $io->ask('Workspace path');
$connectionType = $io->ask('Connection type (eg. local or ssh)');
$this->configuration['hosts'][] = array(
'stage' => $stage,
'connectionType' => $connectionType,
'hostname' => $hostname,
'path' => $path,
);
$addHost = $io->confirm('Add another host?');
}
}
|
php
|
private function interactForHostConfigurations(OutputStyle $io)
{
$io->writeln(' Add host configurations:');
$addHost = true;
while ($addHost) {
$stage = $io->choice('Stage', array(
Host::STAGE_PRODUCTION,
Host::STAGE_ACCEPTANCE,
Host::STAGE_TEST,
));
$hostname = $io->ask('Hostname');
$path = $io->ask('Workspace path');
$connectionType = $io->ask('Connection type (eg. local or ssh)');
$this->configuration['hosts'][] = array(
'stage' => $stage,
'connectionType' => $connectionType,
'hostname' => $hostname,
'path' => $path,
);
$addHost = $io->confirm('Add another host?');
}
}
|
[
"private",
"function",
"interactForHostConfigurations",
"(",
"OutputStyle",
"$",
"io",
")",
"{",
"$",
"io",
"->",
"writeln",
"(",
"' Add host configurations:'",
")",
";",
"$",
"addHost",
"=",
"true",
";",
"while",
"(",
"$",
"addHost",
")",
"{",
"$",
"stage",
"=",
"$",
"io",
"->",
"choice",
"(",
"'Stage'",
",",
"array",
"(",
"Host",
"::",
"STAGE_PRODUCTION",
",",
"Host",
"::",
"STAGE_ACCEPTANCE",
",",
"Host",
"::",
"STAGE_TEST",
",",
")",
")",
";",
"$",
"hostname",
"=",
"$",
"io",
"->",
"ask",
"(",
"'Hostname'",
")",
";",
"$",
"path",
"=",
"$",
"io",
"->",
"ask",
"(",
"'Workspace path'",
")",
";",
"$",
"connectionType",
"=",
"$",
"io",
"->",
"ask",
"(",
"'Connection type (eg. local or ssh)'",
")",
";",
"$",
"this",
"->",
"configuration",
"[",
"'hosts'",
"]",
"[",
"]",
"=",
"array",
"(",
"'stage'",
"=>",
"$",
"stage",
",",
"'connectionType'",
"=>",
"$",
"connectionType",
",",
"'hostname'",
"=>",
"$",
"hostname",
",",
"'path'",
"=>",
"$",
"path",
",",
")",
";",
"$",
"addHost",
"=",
"$",
"io",
"->",
"confirm",
"(",
"'Add another host?'",
")",
";",
"}",
"}"
] |
Interacts with the user to retrieve host configurations.
@param OutputStyle $io
|
[
"Interacts",
"with",
"the",
"user",
"to",
"retrieve",
"host",
"configurations",
"."
] |
618f28377448d8caa90d63bfa5865a3ee15e49e7
|
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Console/Command/InitCommand.php#L117-L141
|
234,825
|
accompli/accompli
|
src/Console/Command/InitCommand.php
|
InitCommand.interactForTaskConfigurations
|
private function interactForTaskConfigurations(OutputStyle $io)
{
$io->writeln(' Add tasks:');
$addTask = true;
while ($addTask) {
$taskQuestion = new Question('Search for a task');
$taskQuestion->setAutocompleterValues($this->getAvailableTasks());
$taskQuestion->setValidator(function ($answer) {
if (class_exists($answer) === false && class_exists('Accompli\\Task\\'.$answer) === true) {
$answer = 'Accompli\\Task\\'.$answer;
}
if (class_exists($answer) === false || in_array(TaskInterface::class, class_implements($answer)) === false) {
throw new InvalidArgumentException(sprintf('The task "%s" does not exist.', $answer));
}
return $answer;
});
$task = $io->askQuestion($taskQuestion);
$taskConfiguration = array_merge(
array(
'class' => $task,
),
$this->getTaskConfigurationParameters($task)
);
$this->configuration['events']['subscribers'][] = $taskConfiguration;
$addTask = $io->confirm('Add another task?');
}
}
|
php
|
private function interactForTaskConfigurations(OutputStyle $io)
{
$io->writeln(' Add tasks:');
$addTask = true;
while ($addTask) {
$taskQuestion = new Question('Search for a task');
$taskQuestion->setAutocompleterValues($this->getAvailableTasks());
$taskQuestion->setValidator(function ($answer) {
if (class_exists($answer) === false && class_exists('Accompli\\Task\\'.$answer) === true) {
$answer = 'Accompli\\Task\\'.$answer;
}
if (class_exists($answer) === false || in_array(TaskInterface::class, class_implements($answer)) === false) {
throw new InvalidArgumentException(sprintf('The task "%s" does not exist.', $answer));
}
return $answer;
});
$task = $io->askQuestion($taskQuestion);
$taskConfiguration = array_merge(
array(
'class' => $task,
),
$this->getTaskConfigurationParameters($task)
);
$this->configuration['events']['subscribers'][] = $taskConfiguration;
$addTask = $io->confirm('Add another task?');
}
}
|
[
"private",
"function",
"interactForTaskConfigurations",
"(",
"OutputStyle",
"$",
"io",
")",
"{",
"$",
"io",
"->",
"writeln",
"(",
"' Add tasks:'",
")",
";",
"$",
"addTask",
"=",
"true",
";",
"while",
"(",
"$",
"addTask",
")",
"{",
"$",
"taskQuestion",
"=",
"new",
"Question",
"(",
"'Search for a task'",
")",
";",
"$",
"taskQuestion",
"->",
"setAutocompleterValues",
"(",
"$",
"this",
"->",
"getAvailableTasks",
"(",
")",
")",
";",
"$",
"taskQuestion",
"->",
"setValidator",
"(",
"function",
"(",
"$",
"answer",
")",
"{",
"if",
"(",
"class_exists",
"(",
"$",
"answer",
")",
"===",
"false",
"&&",
"class_exists",
"(",
"'Accompli\\\\Task\\\\'",
".",
"$",
"answer",
")",
"===",
"true",
")",
"{",
"$",
"answer",
"=",
"'Accompli\\\\Task\\\\'",
".",
"$",
"answer",
";",
"}",
"if",
"(",
"class_exists",
"(",
"$",
"answer",
")",
"===",
"false",
"||",
"in_array",
"(",
"TaskInterface",
"::",
"class",
",",
"class_implements",
"(",
"$",
"answer",
")",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The task \"%s\" does not exist.'",
",",
"$",
"answer",
")",
")",
";",
"}",
"return",
"$",
"answer",
";",
"}",
")",
";",
"$",
"task",
"=",
"$",
"io",
"->",
"askQuestion",
"(",
"$",
"taskQuestion",
")",
";",
"$",
"taskConfiguration",
"=",
"array_merge",
"(",
"array",
"(",
"'class'",
"=>",
"$",
"task",
",",
")",
",",
"$",
"this",
"->",
"getTaskConfigurationParameters",
"(",
"$",
"task",
")",
")",
";",
"$",
"this",
"->",
"configuration",
"[",
"'events'",
"]",
"[",
"'subscribers'",
"]",
"[",
"]",
"=",
"$",
"taskConfiguration",
";",
"$",
"addTask",
"=",
"$",
"io",
"->",
"confirm",
"(",
"'Add another task?'",
")",
";",
"}",
"}"
] |
Interacts with the user to retrieve task configurations.
@param OutputStyle $io
|
[
"Interacts",
"with",
"the",
"user",
"to",
"retrieve",
"task",
"configurations",
"."
] |
618f28377448d8caa90d63bfa5865a3ee15e49e7
|
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Console/Command/InitCommand.php#L148-L180
|
234,826
|
accompli/accompli
|
src/Console/Command/InitCommand.php
|
InitCommand.getTaskConfigurationParameters
|
private function getTaskConfigurationParameters($taskClass)
{
$parameters = array();
$reflectionClass = new ReflectionClass($taskClass);
$reflectionConstructorMethod = $reflectionClass->getConstructor();
if ($reflectionConstructorMethod instanceof ReflectionMethod) {
foreach ($reflectionConstructorMethod->getParameters() as $reflectionParameter) {
if ($reflectionParameter instanceof ReflectionParameter && $reflectionParameter->isDefaultValueAvailable() === false) {
$parameterValue = '';
if ($reflectionParameter->isArray()) {
$parameterValue = array();
}
$parameters[$reflectionParameter->getName()] = $parameterValue;
}
}
}
return $parameters;
}
|
php
|
private function getTaskConfigurationParameters($taskClass)
{
$parameters = array();
$reflectionClass = new ReflectionClass($taskClass);
$reflectionConstructorMethod = $reflectionClass->getConstructor();
if ($reflectionConstructorMethod instanceof ReflectionMethod) {
foreach ($reflectionConstructorMethod->getParameters() as $reflectionParameter) {
if ($reflectionParameter instanceof ReflectionParameter && $reflectionParameter->isDefaultValueAvailable() === false) {
$parameterValue = '';
if ($reflectionParameter->isArray()) {
$parameterValue = array();
}
$parameters[$reflectionParameter->getName()] = $parameterValue;
}
}
}
return $parameters;
}
|
[
"private",
"function",
"getTaskConfigurationParameters",
"(",
"$",
"taskClass",
")",
"{",
"$",
"parameters",
"=",
"array",
"(",
")",
";",
"$",
"reflectionClass",
"=",
"new",
"ReflectionClass",
"(",
"$",
"taskClass",
")",
";",
"$",
"reflectionConstructorMethod",
"=",
"$",
"reflectionClass",
"->",
"getConstructor",
"(",
")",
";",
"if",
"(",
"$",
"reflectionConstructorMethod",
"instanceof",
"ReflectionMethod",
")",
"{",
"foreach",
"(",
"$",
"reflectionConstructorMethod",
"->",
"getParameters",
"(",
")",
"as",
"$",
"reflectionParameter",
")",
"{",
"if",
"(",
"$",
"reflectionParameter",
"instanceof",
"ReflectionParameter",
"&&",
"$",
"reflectionParameter",
"->",
"isDefaultValueAvailable",
"(",
")",
"===",
"false",
")",
"{",
"$",
"parameterValue",
"=",
"''",
";",
"if",
"(",
"$",
"reflectionParameter",
"->",
"isArray",
"(",
")",
")",
"{",
"$",
"parameterValue",
"=",
"array",
"(",
")",
";",
"}",
"$",
"parameters",
"[",
"$",
"reflectionParameter",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"parameterValue",
";",
"}",
"}",
"}",
"return",
"$",
"parameters",
";",
"}"
] |
Returns the required configuration parameters of the task.
@param string $taskClass
@return array
|
[
"Returns",
"the",
"required",
"configuration",
"parameters",
"of",
"the",
"task",
"."
] |
618f28377448d8caa90d63bfa5865a3ee15e49e7
|
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Console/Command/InitCommand.php#L189-L209
|
234,827
|
accompli/accompli
|
src/Console/Command/InitCommand.php
|
InitCommand.getIO
|
private function getIO(InputInterface $input, OutputInterface $output)
{
if ($this->io instanceof OutputStyle === false) {
$this->io = new SymfonyStyle($input, $output);
}
return $this->io;
}
|
php
|
private function getIO(InputInterface $input, OutputInterface $output)
{
if ($this->io instanceof OutputStyle === false) {
$this->io = new SymfonyStyle($input, $output);
}
return $this->io;
}
|
[
"private",
"function",
"getIO",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"io",
"instanceof",
"OutputStyle",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"io",
"=",
"new",
"SymfonyStyle",
"(",
"$",
"input",
",",
"$",
"output",
")",
";",
"}",
"return",
"$",
"this",
"->",
"io",
";",
"}"
] |
Returns the instance handling input and output of this command.
@param InputInterface $input
@param OutputInterface $output
@return OutputStyle
|
[
"Returns",
"the",
"instance",
"handling",
"input",
"and",
"output",
"of",
"this",
"command",
"."
] |
618f28377448d8caa90d63bfa5865a3ee15e49e7
|
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Console/Command/InitCommand.php#L229-L236
|
234,828
|
accompli/accompli
|
src/Console/Command/InitCommand.php
|
InitCommand.getAvailableTasks
|
private function getAvailableTasks()
{
$tasks = array_map(function ($task) {
return substr($task, 0, -4);
}, array_diff(scandir(__DIR__.'/../../Task'), array('.', '..')));
sort($tasks);
return $tasks;
}
|
php
|
private function getAvailableTasks()
{
$tasks = array_map(function ($task) {
return substr($task, 0, -4);
}, array_diff(scandir(__DIR__.'/../../Task'), array('.', '..')));
sort($tasks);
return $tasks;
}
|
[
"private",
"function",
"getAvailableTasks",
"(",
")",
"{",
"$",
"tasks",
"=",
"array_map",
"(",
"function",
"(",
"$",
"task",
")",
"{",
"return",
"substr",
"(",
"$",
"task",
",",
"0",
",",
"-",
"4",
")",
";",
"}",
",",
"array_diff",
"(",
"scandir",
"(",
"__DIR__",
".",
"'/../../Task'",
")",
",",
"array",
"(",
"'.'",
",",
"'..'",
")",
")",
")",
";",
"sort",
"(",
"$",
"tasks",
")",
";",
"return",
"$",
"tasks",
";",
"}"
] |
Returns the available tasks within Accompli.
@return array
|
[
"Returns",
"the",
"available",
"tasks",
"within",
"Accompli",
"."
] |
618f28377448d8caa90d63bfa5865a3ee15e49e7
|
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Console/Command/InitCommand.php#L258-L267
|
234,829
|
jeremyFreeAgent/Bitter
|
src/FreeAgent/Bitter/Bitter.php
|
Bitter.mark
|
public function mark($eventName, $id, DateTime $dateTime = null)
{
$dateTime = is_null($dateTime) ? new DateTime : $dateTime;
$eventData = array(
new Year($eventName, $dateTime),
new Month($eventName, $dateTime),
new Week($eventName, $dateTime),
new Day($eventName, $dateTime),
new Hour($eventName, $dateTime),
);
foreach ($eventData as $event) {
$key = $this->prefixKey . $event->getKey();
$this->getRedisClient()->setbit($key, $id, 1);
$this->getRedisClient()->sadd($this->prefixKey . 'keys', $key);
}
return $this;
}
|
php
|
public function mark($eventName, $id, DateTime $dateTime = null)
{
$dateTime = is_null($dateTime) ? new DateTime : $dateTime;
$eventData = array(
new Year($eventName, $dateTime),
new Month($eventName, $dateTime),
new Week($eventName, $dateTime),
new Day($eventName, $dateTime),
new Hour($eventName, $dateTime),
);
foreach ($eventData as $event) {
$key = $this->prefixKey . $event->getKey();
$this->getRedisClient()->setbit($key, $id, 1);
$this->getRedisClient()->sadd($this->prefixKey . 'keys', $key);
}
return $this;
}
|
[
"public",
"function",
"mark",
"(",
"$",
"eventName",
",",
"$",
"id",
",",
"DateTime",
"$",
"dateTime",
"=",
"null",
")",
"{",
"$",
"dateTime",
"=",
"is_null",
"(",
"$",
"dateTime",
")",
"?",
"new",
"DateTime",
":",
"$",
"dateTime",
";",
"$",
"eventData",
"=",
"array",
"(",
"new",
"Year",
"(",
"$",
"eventName",
",",
"$",
"dateTime",
")",
",",
"new",
"Month",
"(",
"$",
"eventName",
",",
"$",
"dateTime",
")",
",",
"new",
"Week",
"(",
"$",
"eventName",
",",
"$",
"dateTime",
")",
",",
"new",
"Day",
"(",
"$",
"eventName",
",",
"$",
"dateTime",
")",
",",
"new",
"Hour",
"(",
"$",
"eventName",
",",
"$",
"dateTime",
")",
",",
")",
";",
"foreach",
"(",
"$",
"eventData",
"as",
"$",
"event",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"prefixKey",
".",
"$",
"event",
"->",
"getKey",
"(",
")",
";",
"$",
"this",
"->",
"getRedisClient",
"(",
")",
"->",
"setbit",
"(",
"$",
"key",
",",
"$",
"id",
",",
"1",
")",
";",
"$",
"this",
"->",
"getRedisClient",
"(",
")",
"->",
"sadd",
"(",
"$",
"this",
"->",
"prefixKey",
".",
"'keys'",
",",
"$",
"key",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Marks an event for hours, days, weeks and months
@param string $eventName The name of the event, could be "active" or "new_signups"
@param integer $id An unique id, typically user id. The id should not be huge, read Redis documentation why (bitmaps)
@param DateTime $dateTime Which date should be used as a reference point, default is now
|
[
"Marks",
"an",
"event",
"for",
"hours",
"days",
"weeks",
"and",
"months"
] |
018742b098c937039909997e005f47201161686f
|
https://github.com/jeremyFreeAgent/Bitter/blob/018742b098c937039909997e005f47201161686f/src/FreeAgent/Bitter/Bitter.php#L62-L81
|
234,830
|
jeremyFreeAgent/Bitter
|
src/FreeAgent/Bitter/Bitter.php
|
Bitter.in
|
public function in($id, $key)
{
$key = $key instanceof UnitOfTimeInterface ? $this->prefixKey . $key->getKey() : $this->prefixTempKey . $key;
return (bool) $this->getRedisClient()->getbit($key, $id);
}
|
php
|
public function in($id, $key)
{
$key = $key instanceof UnitOfTimeInterface ? $this->prefixKey . $key->getKey() : $this->prefixTempKey . $key;
return (bool) $this->getRedisClient()->getbit($key, $id);
}
|
[
"public",
"function",
"in",
"(",
"$",
"id",
",",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"$",
"key",
"instanceof",
"UnitOfTimeInterface",
"?",
"$",
"this",
"->",
"prefixKey",
".",
"$",
"key",
"->",
"getKey",
"(",
")",
":",
"$",
"this",
"->",
"prefixTempKey",
".",
"$",
"key",
";",
"return",
"(",
"bool",
")",
"$",
"this",
"->",
"getRedisClient",
"(",
")",
"->",
"getbit",
"(",
"$",
"key",
",",
"$",
"id",
")",
";",
"}"
] |
Makes it possible to see if an id has been marked
@param integer $id An unique id
@param mixed $key The key or the event
@return boolean True if the id has been marked
|
[
"Makes",
"it",
"possible",
"to",
"see",
"if",
"an",
"id",
"has",
"been",
"marked"
] |
018742b098c937039909997e005f47201161686f
|
https://github.com/jeremyFreeAgent/Bitter/blob/018742b098c937039909997e005f47201161686f/src/FreeAgent/Bitter/Bitter.php#L90-L95
|
234,831
|
jeremyFreeAgent/Bitter
|
src/FreeAgent/Bitter/Bitter.php
|
Bitter.count
|
public function count($key)
{
$key = $key instanceof UnitOfTimeInterface ? $this->prefixKey . $key->getKey() : $this->prefixTempKey . $key;
return (int) $this->getRedisClient()->bitcount($key);
}
|
php
|
public function count($key)
{
$key = $key instanceof UnitOfTimeInterface ? $this->prefixKey . $key->getKey() : $this->prefixTempKey . $key;
return (int) $this->getRedisClient()->bitcount($key);
}
|
[
"public",
"function",
"count",
"(",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"$",
"key",
"instanceof",
"UnitOfTimeInterface",
"?",
"$",
"this",
"->",
"prefixKey",
".",
"$",
"key",
"->",
"getKey",
"(",
")",
":",
"$",
"this",
"->",
"prefixTempKey",
".",
"$",
"key",
";",
"return",
"(",
"int",
")",
"$",
"this",
"->",
"getRedisClient",
"(",
")",
"->",
"bitcount",
"(",
"$",
"key",
")",
";",
"}"
] |
Counts the number of marks
@param mixed $key The key or the event
@return integer The value of the count result
|
[
"Counts",
"the",
"number",
"of",
"marks"
] |
018742b098c937039909997e005f47201161686f
|
https://github.com/jeremyFreeAgent/Bitter/blob/018742b098c937039909997e005f47201161686f/src/FreeAgent/Bitter/Bitter.php#L103-L108
|
234,832
|
jeremyFreeAgent/Bitter
|
src/FreeAgent/Bitter/Bitter.php
|
Bitter.getIds
|
public function getIds($key)
{
$key = $key instanceof UnitOfTimeInterface ? $this->prefixKey . $key->getKey() : $this->prefixTempKey . $key;
$string = $this->getRedisClient()->get($key);
$data = $this->bitsetToString($string);
$ids = array();
while (false !== ($pos = strpos($data, '1'))) {
$data[$pos] = 0;
$ids[] = (int)($pos/8)*8 + abs(7-($pos%8));
}
sort($ids);
return $ids;
}
|
php
|
public function getIds($key)
{
$key = $key instanceof UnitOfTimeInterface ? $this->prefixKey . $key->getKey() : $this->prefixTempKey . $key;
$string = $this->getRedisClient()->get($key);
$data = $this->bitsetToString($string);
$ids = array();
while (false !== ($pos = strpos($data, '1'))) {
$data[$pos] = 0;
$ids[] = (int)($pos/8)*8 + abs(7-($pos%8));
}
sort($ids);
return $ids;
}
|
[
"public",
"function",
"getIds",
"(",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"$",
"key",
"instanceof",
"UnitOfTimeInterface",
"?",
"$",
"this",
"->",
"prefixKey",
".",
"$",
"key",
"->",
"getKey",
"(",
")",
":",
"$",
"this",
"->",
"prefixTempKey",
".",
"$",
"key",
";",
"$",
"string",
"=",
"$",
"this",
"->",
"getRedisClient",
"(",
")",
"->",
"get",
"(",
"$",
"key",
")",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"bitsetToString",
"(",
"$",
"string",
")",
";",
"$",
"ids",
"=",
"array",
"(",
")",
";",
"while",
"(",
"false",
"!==",
"(",
"$",
"pos",
"=",
"strpos",
"(",
"$",
"data",
",",
"'1'",
")",
")",
")",
"{",
"$",
"data",
"[",
"$",
"pos",
"]",
"=",
"0",
";",
"$",
"ids",
"[",
"]",
"=",
"(",
"int",
")",
"(",
"$",
"pos",
"/",
"8",
")",
"*",
"8",
"+",
"abs",
"(",
"7",
"-",
"(",
"$",
"pos",
"%",
"8",
")",
")",
";",
"}",
"sort",
"(",
"$",
"ids",
")",
";",
"return",
"$",
"ids",
";",
"}"
] |
Returns the ids of an key or event
@param mixed $key The key or the event
@return array The ids array
|
[
"Returns",
"the",
"ids",
"of",
"an",
"key",
"or",
"event"
] |
018742b098c937039909997e005f47201161686f
|
https://github.com/jeremyFreeAgent/Bitter/blob/018742b098c937039909997e005f47201161686f/src/FreeAgent/Bitter/Bitter.php#L199-L216
|
234,833
|
jeremyFreeAgent/Bitter
|
src/FreeAgent/Bitter/Bitter.php
|
Bitter.removeAll
|
public function removeAll()
{
$keys_chunk = array_chunk($this->getRedisClient()->smembers($this->prefixKey . 'keys'), 100);
foreach ($keys_chunk as $keys) {
$this->getRedisClient()->del($keys);
}
return $this;
}
|
php
|
public function removeAll()
{
$keys_chunk = array_chunk($this->getRedisClient()->smembers($this->prefixKey . 'keys'), 100);
foreach ($keys_chunk as $keys) {
$this->getRedisClient()->del($keys);
}
return $this;
}
|
[
"public",
"function",
"removeAll",
"(",
")",
"{",
"$",
"keys_chunk",
"=",
"array_chunk",
"(",
"$",
"this",
"->",
"getRedisClient",
"(",
")",
"->",
"smembers",
"(",
"$",
"this",
"->",
"prefixKey",
".",
"'keys'",
")",
",",
"100",
")",
";",
"foreach",
"(",
"$",
"keys_chunk",
"as",
"$",
"keys",
")",
"{",
"$",
"this",
"->",
"getRedisClient",
"(",
")",
"->",
"del",
"(",
"$",
"keys",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Removes all Bitter keys
|
[
"Removes",
"all",
"Bitter",
"keys"
] |
018742b098c937039909997e005f47201161686f
|
https://github.com/jeremyFreeAgent/Bitter/blob/018742b098c937039909997e005f47201161686f/src/FreeAgent/Bitter/Bitter.php#L226-L235
|
234,834
|
jeremyFreeAgent/Bitter
|
src/FreeAgent/Bitter/Bitter.php
|
Bitter.removeTemp
|
public function removeTemp()
{
$keys_chunk = array_chunk($this->getRedisClient()->smembers($this->prefixTempKey . 'keys'), 100);
foreach ($keys_chunk as $keys) {
$this->getRedisClient()->del($keys);
}
return $this;
}
|
php
|
public function removeTemp()
{
$keys_chunk = array_chunk($this->getRedisClient()->smembers($this->prefixTempKey . 'keys'), 100);
foreach ($keys_chunk as $keys) {
$this->getRedisClient()->del($keys);
}
return $this;
}
|
[
"public",
"function",
"removeTemp",
"(",
")",
"{",
"$",
"keys_chunk",
"=",
"array_chunk",
"(",
"$",
"this",
"->",
"getRedisClient",
"(",
")",
"->",
"smembers",
"(",
"$",
"this",
"->",
"prefixTempKey",
".",
"'keys'",
")",
",",
"100",
")",
";",
"foreach",
"(",
"$",
"keys_chunk",
"as",
"$",
"keys",
")",
"{",
"$",
"this",
"->",
"getRedisClient",
"(",
")",
"->",
"del",
"(",
"$",
"keys",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Removes all Bitter temp keys
|
[
"Removes",
"all",
"Bitter",
"temp",
"keys"
] |
018742b098c937039909997e005f47201161686f
|
https://github.com/jeremyFreeAgent/Bitter/blob/018742b098c937039909997e005f47201161686f/src/FreeAgent/Bitter/Bitter.php#L240-L249
|
234,835
|
potsky/microsoft-translator-php-sdk
|
src/MicrosoftTranslator/Http.php
|
Http.get
|
public function get($url, $access_token = null, $parameters = [], $contentType = 'text/xml')
{
return $this->doApiCall($url, 'GET', $access_token, $parameters, $contentType);
}
|
php
|
public function get($url, $access_token = null, $parameters = [], $contentType = 'text/xml')
{
return $this->doApiCall($url, 'GET', $access_token, $parameters, $contentType);
}
|
[
"public",
"function",
"get",
"(",
"$",
"url",
",",
"$",
"access_token",
"=",
"null",
",",
"$",
"parameters",
"=",
"[",
"]",
",",
"$",
"contentType",
"=",
"'text/xml'",
")",
"{",
"return",
"$",
"this",
"->",
"doApiCall",
"(",
"$",
"url",
",",
"'GET'",
",",
"$",
"access_token",
",",
"$",
"parameters",
",",
"$",
"contentType",
")",
";",
"}"
] |
GET API endpoint
@param string $url
@param string|null $access_token
@param array $parameters
@param string $contentType
@return array
|
[
"GET",
"API",
"endpoint"
] |
102f2411be5abb0e57a73c475f8e9e185a9f4859
|
https://github.com/potsky/microsoft-translator-php-sdk/blob/102f2411be5abb0e57a73c475f8e9e185a9f4859/src/MicrosoftTranslator/Http.php#L126-L129
|
234,836
|
potsky/microsoft-translator-php-sdk
|
src/MicrosoftTranslator/Http.php
|
Http.post
|
public function post($url, $access_token = null, $parameters = [], $contentType = 'text/xml')
{
return $this->doApiCall($url, 'POST', $access_token, $parameters, $contentType);
}
|
php
|
public function post($url, $access_token = null, $parameters = [], $contentType = 'text/xml')
{
return $this->doApiCall($url, 'POST', $access_token, $parameters, $contentType);
}
|
[
"public",
"function",
"post",
"(",
"$",
"url",
",",
"$",
"access_token",
"=",
"null",
",",
"$",
"parameters",
"=",
"[",
"]",
",",
"$",
"contentType",
"=",
"'text/xml'",
")",
"{",
"return",
"$",
"this",
"->",
"doApiCall",
"(",
"$",
"url",
",",
"'POST'",
",",
"$",
"access_token",
",",
"$",
"parameters",
",",
"$",
"contentType",
")",
";",
"}"
] |
POST API endpoint
@param string $url
@param string|null $access_token
@param string|array $parameters
@param string $contentType
@return array
|
[
"POST",
"API",
"endpoint"
] |
102f2411be5abb0e57a73c475f8e9e185a9f4859
|
https://github.com/potsky/microsoft-translator-php-sdk/blob/102f2411be5abb0e57a73c475f8e9e185a9f4859/src/MicrosoftTranslator/Http.php#L141-L144
|
234,837
|
potsky/microsoft-translator-php-sdk
|
src/MicrosoftTranslator/Http.php
|
Http.put
|
public function put($url, $access_token = null, $parameters = [], $contentType = 'text/xml')
{
return $this->doApiCall($url, 'PUT', $access_token, $parameters, $contentType);
}
|
php
|
public function put($url, $access_token = null, $parameters = [], $contentType = 'text/xml')
{
return $this->doApiCall($url, 'PUT', $access_token, $parameters, $contentType);
}
|
[
"public",
"function",
"put",
"(",
"$",
"url",
",",
"$",
"access_token",
"=",
"null",
",",
"$",
"parameters",
"=",
"[",
"]",
",",
"$",
"contentType",
"=",
"'text/xml'",
")",
"{",
"return",
"$",
"this",
"->",
"doApiCall",
"(",
"$",
"url",
",",
"'PUT'",
",",
"$",
"access_token",
",",
"$",
"parameters",
",",
"$",
"contentType",
")",
";",
"}"
] |
PUT API endpoint
@param string $url
@param string|null $access_token
@param string|array $parameters
@param string $contentType
@return array
|
[
"PUT",
"API",
"endpoint"
] |
102f2411be5abb0e57a73c475f8e9e185a9f4859
|
https://github.com/potsky/microsoft-translator-php-sdk/blob/102f2411be5abb0e57a73c475f8e9e185a9f4859/src/MicrosoftTranslator/Http.php#L156-L159
|
234,838
|
potsky/microsoft-translator-php-sdk
|
src/MicrosoftTranslator/Http.php
|
Http.delete
|
public function delete($url, $access_token = null, $parameters = [], $contentType = 'text/xml')
{
return $this->doApiCall($url, 'DELETE', $access_token, $parameters, $contentType);
}
|
php
|
public function delete($url, $access_token = null, $parameters = [], $contentType = 'text/xml')
{
return $this->doApiCall($url, 'DELETE', $access_token, $parameters, $contentType);
}
|
[
"public",
"function",
"delete",
"(",
"$",
"url",
",",
"$",
"access_token",
"=",
"null",
",",
"$",
"parameters",
"=",
"[",
"]",
",",
"$",
"contentType",
"=",
"'text/xml'",
")",
"{",
"return",
"$",
"this",
"->",
"doApiCall",
"(",
"$",
"url",
",",
"'DELETE'",
",",
"$",
"access_token",
",",
"$",
"parameters",
",",
"$",
"contentType",
")",
";",
"}"
] |
DELETE API endpoint
@param string $url
@param string|null $access_token
@param string|array $parameters
@param string $contentType
@return array
|
[
"DELETE",
"API",
"endpoint"
] |
102f2411be5abb0e57a73c475f8e9e185a9f4859
|
https://github.com/potsky/microsoft-translator-php-sdk/blob/102f2411be5abb0e57a73c475f8e9e185a9f4859/src/MicrosoftTranslator/Http.php#L171-L174
|
234,839
|
potsky/microsoft-translator-php-sdk
|
src/MicrosoftTranslator/Http.php
|
Http.execCurl
|
public function execCurl(array $config)
{
$config[CURLOPT_VERBOSE] = false;
$config[CURLOPT_SSL_VERIFYPEER] = false;
$config[CURLOPT_RETURNTRANSFER] = true;
if (defined('CURLOPT_IPRESOLVE')) // PHP5.3
{
$config[CURLOPT_IPRESOLVE] = CURL_IPRESOLVE_V4;
}
$ch = curl_init();
foreach ($config as $key => $value) {
curl_setopt($ch, $key, $value);
}
$result = curl_exec($ch);
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
$error_code = curl_errno($ch);
curl_close($ch);
return [$result, $status_code, $error, $error_code];
}
|
php
|
public function execCurl(array $config)
{
$config[CURLOPT_VERBOSE] = false;
$config[CURLOPT_SSL_VERIFYPEER] = false;
$config[CURLOPT_RETURNTRANSFER] = true;
if (defined('CURLOPT_IPRESOLVE')) // PHP5.3
{
$config[CURLOPT_IPRESOLVE] = CURL_IPRESOLVE_V4;
}
$ch = curl_init();
foreach ($config as $key => $value) {
curl_setopt($ch, $key, $value);
}
$result = curl_exec($ch);
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
$error_code = curl_errno($ch);
curl_close($ch);
return [$result, $status_code, $error, $error_code];
}
|
[
"public",
"function",
"execCurl",
"(",
"array",
"$",
"config",
")",
"{",
"$",
"config",
"[",
"CURLOPT_VERBOSE",
"]",
"=",
"false",
";",
"$",
"config",
"[",
"CURLOPT_SSL_VERIFYPEER",
"]",
"=",
"false",
";",
"$",
"config",
"[",
"CURLOPT_RETURNTRANSFER",
"]",
"=",
"true",
";",
"if",
"(",
"defined",
"(",
"'CURLOPT_IPRESOLVE'",
")",
")",
"// PHP5.3",
"{",
"$",
"config",
"[",
"CURLOPT_IPRESOLVE",
"]",
"=",
"CURL_IPRESOLVE_V4",
";",
"}",
"$",
"ch",
"=",
"curl_init",
"(",
")",
";",
"foreach",
"(",
"$",
"config",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"curl_setopt",
"(",
"$",
"ch",
",",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"$",
"result",
"=",
"curl_exec",
"(",
"$",
"ch",
")",
";",
"$",
"status_code",
"=",
"curl_getinfo",
"(",
"$",
"ch",
",",
"CURLINFO_HTTP_CODE",
")",
";",
"$",
"error",
"=",
"curl_error",
"(",
"$",
"ch",
")",
";",
"$",
"error_code",
"=",
"curl_errno",
"(",
"$",
"ch",
")",
";",
"curl_close",
"(",
"$",
"ch",
")",
";",
"return",
"[",
"$",
"result",
",",
"$",
"status_code",
",",
"$",
"error",
",",
"$",
"error_code",
"]",
";",
"}"
] |
Execute the request with cURL
Made public for unit tests, you can publicly call it but this method is not really interesting!
@param array $config
@return array
|
[
"Execute",
"the",
"request",
"with",
"cURL"
] |
102f2411be5abb0e57a73c475f8e9e185a9f4859
|
https://github.com/potsky/microsoft-translator-php-sdk/blob/102f2411be5abb0e57a73c475f8e9e185a9f4859/src/MicrosoftTranslator/Http.php#L185-L210
|
234,840
|
aimeos/ai-admin-extadm
|
controller/extjs/src/Controller/ExtJS/Product/Export/Text/Standard.php
|
Standard.addItem
|
protected function addItem( \Aimeos\MW\Container\Content\Iface $contentItem, \Aimeos\MShop\Product\Item\Iface $item, $langid )
{
$listTypes = [];
foreach( $item->getListItems( 'text' ) as $listItem ) {
$listTypes[$listItem->getRefId()] = $listItem->getType();
}
foreach( $this->getTextTypes( 'product' ) as $textTypeItem )
{
$textItems = $item->getRefItems( 'text', $textTypeItem->getCode() );
if( !empty( $textItems ) )
{
foreach( $textItems as $textItem )
{
$listType = ( isset( $listTypes[$textItem->getId()] ) ? $listTypes[$textItem->getId()] : '' );
$items = array( $langid, $item->getType(), $item->getCode(), $listType, $textTypeItem->getCode(), '', '' );
// use language of the text item because it may be null
if( ( $textItem->getLanguageId() == $langid || is_null( $textItem->getLanguageId() ) )
&& $textItem->getTypeId() == $textTypeItem->getId() )
{
$items[0] = $textItem->getLanguageId();
$items[5] = $textItem->getId();
$items[6] = $textItem->getContent();
}
$contentItem->add( $items );
}
}
else
{
$items = array( $langid, $item->getType(), $item->getCode(), 'default', $textTypeItem->getCode(), '', '' );
$contentItem->add( $items );
}
}
}
|
php
|
protected function addItem( \Aimeos\MW\Container\Content\Iface $contentItem, \Aimeos\MShop\Product\Item\Iface $item, $langid )
{
$listTypes = [];
foreach( $item->getListItems( 'text' ) as $listItem ) {
$listTypes[$listItem->getRefId()] = $listItem->getType();
}
foreach( $this->getTextTypes( 'product' ) as $textTypeItem )
{
$textItems = $item->getRefItems( 'text', $textTypeItem->getCode() );
if( !empty( $textItems ) )
{
foreach( $textItems as $textItem )
{
$listType = ( isset( $listTypes[$textItem->getId()] ) ? $listTypes[$textItem->getId()] : '' );
$items = array( $langid, $item->getType(), $item->getCode(), $listType, $textTypeItem->getCode(), '', '' );
// use language of the text item because it may be null
if( ( $textItem->getLanguageId() == $langid || is_null( $textItem->getLanguageId() ) )
&& $textItem->getTypeId() == $textTypeItem->getId() )
{
$items[0] = $textItem->getLanguageId();
$items[5] = $textItem->getId();
$items[6] = $textItem->getContent();
}
$contentItem->add( $items );
}
}
else
{
$items = array( $langid, $item->getType(), $item->getCode(), 'default', $textTypeItem->getCode(), '', '' );
$contentItem->add( $items );
}
}
}
|
[
"protected",
"function",
"addItem",
"(",
"\\",
"Aimeos",
"\\",
"MW",
"\\",
"Container",
"\\",
"Content",
"\\",
"Iface",
"$",
"contentItem",
",",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Product",
"\\",
"Item",
"\\",
"Iface",
"$",
"item",
",",
"$",
"langid",
")",
"{",
"$",
"listTypes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"item",
"->",
"getListItems",
"(",
"'text'",
")",
"as",
"$",
"listItem",
")",
"{",
"$",
"listTypes",
"[",
"$",
"listItem",
"->",
"getRefId",
"(",
")",
"]",
"=",
"$",
"listItem",
"->",
"getType",
"(",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"getTextTypes",
"(",
"'product'",
")",
"as",
"$",
"textTypeItem",
")",
"{",
"$",
"textItems",
"=",
"$",
"item",
"->",
"getRefItems",
"(",
"'text'",
",",
"$",
"textTypeItem",
"->",
"getCode",
"(",
")",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"textItems",
")",
")",
"{",
"foreach",
"(",
"$",
"textItems",
"as",
"$",
"textItem",
")",
"{",
"$",
"listType",
"=",
"(",
"isset",
"(",
"$",
"listTypes",
"[",
"$",
"textItem",
"->",
"getId",
"(",
")",
"]",
")",
"?",
"$",
"listTypes",
"[",
"$",
"textItem",
"->",
"getId",
"(",
")",
"]",
":",
"''",
")",
";",
"$",
"items",
"=",
"array",
"(",
"$",
"langid",
",",
"$",
"item",
"->",
"getType",
"(",
")",
",",
"$",
"item",
"->",
"getCode",
"(",
")",
",",
"$",
"listType",
",",
"$",
"textTypeItem",
"->",
"getCode",
"(",
")",
",",
"''",
",",
"''",
")",
";",
"// use language of the text item because it may be null",
"if",
"(",
"(",
"$",
"textItem",
"->",
"getLanguageId",
"(",
")",
"==",
"$",
"langid",
"||",
"is_null",
"(",
"$",
"textItem",
"->",
"getLanguageId",
"(",
")",
")",
")",
"&&",
"$",
"textItem",
"->",
"getTypeId",
"(",
")",
"==",
"$",
"textTypeItem",
"->",
"getId",
"(",
")",
")",
"{",
"$",
"items",
"[",
"0",
"]",
"=",
"$",
"textItem",
"->",
"getLanguageId",
"(",
")",
";",
"$",
"items",
"[",
"5",
"]",
"=",
"$",
"textItem",
"->",
"getId",
"(",
")",
";",
"$",
"items",
"[",
"6",
"]",
"=",
"$",
"textItem",
"->",
"getContent",
"(",
")",
";",
"}",
"$",
"contentItem",
"->",
"add",
"(",
"$",
"items",
")",
";",
"}",
"}",
"else",
"{",
"$",
"items",
"=",
"array",
"(",
"$",
"langid",
",",
"$",
"item",
"->",
"getType",
"(",
")",
",",
"$",
"item",
"->",
"getCode",
"(",
")",
",",
"'default'",
",",
"$",
"textTypeItem",
"->",
"getCode",
"(",
")",
",",
"''",
",",
"''",
")",
";",
"$",
"contentItem",
"->",
"add",
"(",
"$",
"items",
")",
";",
"}",
"}",
"}"
] |
Adds all texts belonging to an product item.
@param \Aimeos\MW\Container\Content\Iface $contentItem Content item
@param \Aimeos\MShop\Product\Item\Iface $item product item object
@param string $langid Language id
|
[
"Adds",
"all",
"texts",
"belonging",
"to",
"an",
"product",
"item",
"."
] |
594ee7cec90fd63a4773c05c93f353e66d9b3408
|
https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/Product/Export/Text/Standard.php#L315-L351
|
234,841
|
makinacorpus/drupal-ucms
|
ucms_tree/src/Datasource/TreeAdminDatasource.php
|
TreeAdminDatasource.getWebmasterSites
|
private function getWebmasterSites()
{
$ret = [];
foreach ($this->siteManager->loadWebmasterSites($this->account) as $site) {
$ret[$site->getId()] = check_plain($site->title);
}
return $ret;
}
|
php
|
private function getWebmasterSites()
{
$ret = [];
foreach ($this->siteManager->loadWebmasterSites($this->account) as $site) {
$ret[$site->getId()] = check_plain($site->title);
}
return $ret;
}
|
[
"private",
"function",
"getWebmasterSites",
"(",
")",
"{",
"$",
"ret",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"siteManager",
"->",
"loadWebmasterSites",
"(",
"$",
"this",
"->",
"account",
")",
"as",
"$",
"site",
")",
"{",
"$",
"ret",
"[",
"$",
"site",
"->",
"getId",
"(",
")",
"]",
"=",
"check_plain",
"(",
"$",
"site",
"->",
"title",
")",
";",
"}",
"return",
"$",
"ret",
";",
"}"
] |
Get current account sites he's webmaster on
@return string[]
|
[
"Get",
"current",
"account",
"sites",
"he",
"s",
"webmaster",
"on"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_tree/src/Datasource/TreeAdminDatasource.php#L40-L49
|
234,842
|
scriptotek/php-oai-pmh-client
|
src/Client.php
|
Client.urlBuilder
|
public function urlBuilder($verb, $arguments = array())
{
$qs = array(
'verb' => $verb,
'metadataPrefix' => $this->schema,
);
foreach ($arguments as $key => $value) {
$qs[$key] = $value;
if (is_null($value)) {
// Allow removal of default arguments like 'metadataPrefix'
unset($qs[$key]);
}
}
return $this->url . '?' . http_build_query($qs);
}
|
php
|
public function urlBuilder($verb, $arguments = array())
{
$qs = array(
'verb' => $verb,
'metadataPrefix' => $this->schema,
);
foreach ($arguments as $key => $value) {
$qs[$key] = $value;
if (is_null($value)) {
// Allow removal of default arguments like 'metadataPrefix'
unset($qs[$key]);
}
}
return $this->url . '?' . http_build_query($qs);
}
|
[
"public",
"function",
"urlBuilder",
"(",
"$",
"verb",
",",
"$",
"arguments",
"=",
"array",
"(",
")",
")",
"{",
"$",
"qs",
"=",
"array",
"(",
"'verb'",
"=>",
"$",
"verb",
",",
"'metadataPrefix'",
"=>",
"$",
"this",
"->",
"schema",
",",
")",
";",
"foreach",
"(",
"$",
"arguments",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"qs",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"if",
"(",
"is_null",
"(",
"$",
"value",
")",
")",
"{",
"// Allow removal of default arguments like 'metadataPrefix'",
"unset",
"(",
"$",
"qs",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"url",
".",
"'?'",
".",
"http_build_query",
"(",
"$",
"qs",
")",
";",
"}"
] |
Construct the URL for an OAI-PMH query
@param string $verb The OAI-PMH verb
@param array $arguments OAI-PMH arguments
@return string
|
[
"Construct",
"the",
"URL",
"for",
"an",
"OAI",
"-",
"PMH",
"query"
] |
c1da394ccad86962d0f1c2bc120152092e4c1c88
|
https://github.com/scriptotek/php-oai-pmh-client/blob/c1da394ccad86962d0f1c2bc120152092e4c1c88/src/Client.php#L125-L141
|
234,843
|
scriptotek/php-oai-pmh-client
|
src/Client.php
|
Client.request
|
public function request($verb, $arguments)
{
$this->emit('request.start', array(
'verb' => $verb,
'arguments' => $arguments
));
$url = $this->urlBuilder($verb, $arguments);
$attempt = 0;
while (true) {
try {
$res = $this->httpClient->get($url, $this->getHttpOptions());
break;
} catch (\GuzzleHttp\Exception\ConnectException $e) {
// Thrown in case of a networking error (connection timeout, DNS errors, etc.)
$this->emit('request.error', array(
'message' => $e->getMessage(),
));
time_nanosleep(intval($this->sleepTimeOnError), intval($this->sleepTimeOnError * 1000000000));
} catch (\GuzzleHttp\Exception\ServerException $e) {
// Thrown in case of 500 errors
$this->emit('request.error', array(
'message' => $e->getMessage(),
));
time_nanosleep(intval($this->sleepTimeOnError), intval($this->sleepTimeOnError * 1000000000));
}
$attempt++;
if ($attempt > $this->maxRetries) {
throw new ConnectionError('Failed to get a response from the server. Max retries (' . $this->maxRetries . ') exceeded.');
}
}
$body = (string) $res->getBody();
$this->emit('request.complete', array(
'verb' => $verb,
'arguments' => $arguments,
'response' => $body
));
return $body;
}
|
php
|
public function request($verb, $arguments)
{
$this->emit('request.start', array(
'verb' => $verb,
'arguments' => $arguments
));
$url = $this->urlBuilder($verb, $arguments);
$attempt = 0;
while (true) {
try {
$res = $this->httpClient->get($url, $this->getHttpOptions());
break;
} catch (\GuzzleHttp\Exception\ConnectException $e) {
// Thrown in case of a networking error (connection timeout, DNS errors, etc.)
$this->emit('request.error', array(
'message' => $e->getMessage(),
));
time_nanosleep(intval($this->sleepTimeOnError), intval($this->sleepTimeOnError * 1000000000));
} catch (\GuzzleHttp\Exception\ServerException $e) {
// Thrown in case of 500 errors
$this->emit('request.error', array(
'message' => $e->getMessage(),
));
time_nanosleep(intval($this->sleepTimeOnError), intval($this->sleepTimeOnError * 1000000000));
}
$attempt++;
if ($attempt > $this->maxRetries) {
throw new ConnectionError('Failed to get a response from the server. Max retries (' . $this->maxRetries . ') exceeded.');
}
}
$body = (string) $res->getBody();
$this->emit('request.complete', array(
'verb' => $verb,
'arguments' => $arguments,
'response' => $body
));
return $body;
}
|
[
"public",
"function",
"request",
"(",
"$",
"verb",
",",
"$",
"arguments",
")",
"{",
"$",
"this",
"->",
"emit",
"(",
"'request.start'",
",",
"array",
"(",
"'verb'",
"=>",
"$",
"verb",
",",
"'arguments'",
"=>",
"$",
"arguments",
")",
")",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"urlBuilder",
"(",
"$",
"verb",
",",
"$",
"arguments",
")",
";",
"$",
"attempt",
"=",
"0",
";",
"while",
"(",
"true",
")",
"{",
"try",
"{",
"$",
"res",
"=",
"$",
"this",
"->",
"httpClient",
"->",
"get",
"(",
"$",
"url",
",",
"$",
"this",
"->",
"getHttpOptions",
"(",
")",
")",
";",
"break",
";",
"}",
"catch",
"(",
"\\",
"GuzzleHttp",
"\\",
"Exception",
"\\",
"ConnectException",
"$",
"e",
")",
"{",
"// Thrown in case of a networking error (connection timeout, DNS errors, etc.)",
"$",
"this",
"->",
"emit",
"(",
"'request.error'",
",",
"array",
"(",
"'message'",
"=>",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
")",
")",
";",
"time_nanosleep",
"(",
"intval",
"(",
"$",
"this",
"->",
"sleepTimeOnError",
")",
",",
"intval",
"(",
"$",
"this",
"->",
"sleepTimeOnError",
"*",
"1000000000",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"GuzzleHttp",
"\\",
"Exception",
"\\",
"ServerException",
"$",
"e",
")",
"{",
"// Thrown in case of 500 errors",
"$",
"this",
"->",
"emit",
"(",
"'request.error'",
",",
"array",
"(",
"'message'",
"=>",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
")",
")",
";",
"time_nanosleep",
"(",
"intval",
"(",
"$",
"this",
"->",
"sleepTimeOnError",
")",
",",
"intval",
"(",
"$",
"this",
"->",
"sleepTimeOnError",
"*",
"1000000000",
")",
")",
";",
"}",
"$",
"attempt",
"++",
";",
"if",
"(",
"$",
"attempt",
">",
"$",
"this",
"->",
"maxRetries",
")",
"{",
"throw",
"new",
"ConnectionError",
"(",
"'Failed to get a response from the server. Max retries ('",
".",
"$",
"this",
"->",
"maxRetries",
".",
"') exceeded.'",
")",
";",
"}",
"}",
"$",
"body",
"=",
"(",
"string",
")",
"$",
"res",
"->",
"getBody",
"(",
")",
";",
"$",
"this",
"->",
"emit",
"(",
"'request.complete'",
",",
"array",
"(",
"'verb'",
"=>",
"$",
"verb",
",",
"'arguments'",
"=>",
"$",
"arguments",
",",
"'response'",
"=>",
"$",
"body",
")",
")",
";",
"return",
"$",
"body",
";",
"}"
] |
Perform a single OAI-PMH request
@param string $verb The OAI-PMH verb
@param array $arguments OAI-PMH arguments
@return string
@throws ConnectionError
|
[
"Perform",
"a",
"single",
"OAI",
"-",
"PMH",
"request"
] |
c1da394ccad86962d0f1c2bc120152092e4c1c88
|
https://github.com/scriptotek/php-oai-pmh-client/blob/c1da394ccad86962d0f1c2bc120152092e4c1c88/src/Client.php#L151-L188
|
234,844
|
scriptotek/php-oai-pmh-client
|
src/Client.php
|
Client.records
|
public function records($from, $until, $set, $resumptionToken = null, $extraParams = array())
{
return new Records($from, $until, $set, $this, $resumptionToken, $extraParams);
}
|
php
|
public function records($from, $until, $set, $resumptionToken = null, $extraParams = array())
{
return new Records($from, $until, $set, $this, $resumptionToken, $extraParams);
}
|
[
"public",
"function",
"records",
"(",
"$",
"from",
",",
"$",
"until",
",",
"$",
"set",
",",
"$",
"resumptionToken",
"=",
"null",
",",
"$",
"extraParams",
"=",
"array",
"(",
")",
")",
"{",
"return",
"new",
"Records",
"(",
"$",
"from",
",",
"$",
"until",
",",
"$",
"set",
",",
"$",
"this",
",",
"$",
"resumptionToken",
",",
"$",
"extraParams",
")",
";",
"}"
] |
Perform a ListRecords request and return an iterator over the records
@param string $from Start date
@param string $until End date
@param string $set Data set
@param string $resumptionToken To resume a harvest
@param array $extraParams Extra GET parameters
@return Records
|
[
"Perform",
"a",
"ListRecords",
"request",
"and",
"return",
"an",
"iterator",
"over",
"the",
"records"
] |
c1da394ccad86962d0f1c2bc120152092e4c1c88
|
https://github.com/scriptotek/php-oai-pmh-client/blob/c1da394ccad86962d0f1c2bc120152092e4c1c88/src/Client.php#L212-L215
|
234,845
|
fintech-fab/bank-emulator
|
src/controllers/DemoController.php
|
DemoController.term
|
public function term()
{
$terminal = Terminal::whereUserId($this->userId())->first();
if (!$terminal) {
$terminal = new Terminal;
$terminal->user_id = $this->userId();
$terminal->secret = md5($terminal->user_id . time() . uniqid());
$terminal->mode = Terminal::C_STATE_OFFLINE;
$terminal->save();
}
$this->make('term', compact('terminal'));
}
|
php
|
public function term()
{
$terminal = Terminal::whereUserId($this->userId())->first();
if (!$terminal) {
$terminal = new Terminal;
$terminal->user_id = $this->userId();
$terminal->secret = md5($terminal->user_id . time() . uniqid());
$terminal->mode = Terminal::C_STATE_OFFLINE;
$terminal->save();
}
$this->make('term', compact('terminal'));
}
|
[
"public",
"function",
"term",
"(",
")",
"{",
"$",
"terminal",
"=",
"Terminal",
"::",
"whereUserId",
"(",
"$",
"this",
"->",
"userId",
"(",
")",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"!",
"$",
"terminal",
")",
"{",
"$",
"terminal",
"=",
"new",
"Terminal",
";",
"$",
"terminal",
"->",
"user_id",
"=",
"$",
"this",
"->",
"userId",
"(",
")",
";",
"$",
"terminal",
"->",
"secret",
"=",
"md5",
"(",
"$",
"terminal",
"->",
"user_id",
".",
"time",
"(",
")",
".",
"uniqid",
"(",
")",
")",
";",
"$",
"terminal",
"->",
"mode",
"=",
"Terminal",
"::",
"C_STATE_OFFLINE",
";",
"$",
"terminal",
"->",
"save",
"(",
")",
";",
"}",
"$",
"this",
"->",
"make",
"(",
"'term'",
",",
"compact",
"(",
"'terminal'",
")",
")",
";",
"}"
] |
Terminal info
auto-create new term if not exists
|
[
"Terminal",
"info",
"auto",
"-",
"create",
"new",
"term",
"if",
"not",
"exists"
] |
6256be98509de0ff8e96b5683a0b0197acd67b9e
|
https://github.com/fintech-fab/bank-emulator/blob/6256be98509de0ff8e96b5683a0b0197acd67b9e/src/controllers/DemoController.php#L52-L64
|
234,846
|
fintech-fab/bank-emulator
|
src/controllers/DemoController.php
|
DemoController.postTerm
|
public function postTerm()
{
$terminal = Terminal::whereUserId($this->userId())->first();
$inputs = Input::get('input');
if (empty($inputs['url'])) {
$inputs['url'] = '';
}
if (empty($inputs['email'])) {
$inputs['email'] = '';
}
$validator = Validator::make(
$inputs,
array(
'url' => 'url',
'email' => 'email',
)
);
if ($terminal && $validator->passes()) {
$terminal->url = $inputs['url'];
$terminal->email = $inputs['email'];
$terminal->save();
return 'ok';
}
return 'error';
}
|
php
|
public function postTerm()
{
$terminal = Terminal::whereUserId($this->userId())->first();
$inputs = Input::get('input');
if (empty($inputs['url'])) {
$inputs['url'] = '';
}
if (empty($inputs['email'])) {
$inputs['email'] = '';
}
$validator = Validator::make(
$inputs,
array(
'url' => 'url',
'email' => 'email',
)
);
if ($terminal && $validator->passes()) {
$terminal->url = $inputs['url'];
$terminal->email = $inputs['email'];
$terminal->save();
return 'ok';
}
return 'error';
}
|
[
"public",
"function",
"postTerm",
"(",
")",
"{",
"$",
"terminal",
"=",
"Terminal",
"::",
"whereUserId",
"(",
"$",
"this",
"->",
"userId",
"(",
")",
")",
"->",
"first",
"(",
")",
";",
"$",
"inputs",
"=",
"Input",
"::",
"get",
"(",
"'input'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"inputs",
"[",
"'url'",
"]",
")",
")",
"{",
"$",
"inputs",
"[",
"'url'",
"]",
"=",
"''",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"inputs",
"[",
"'email'",
"]",
")",
")",
"{",
"$",
"inputs",
"[",
"'email'",
"]",
"=",
"''",
";",
"}",
"$",
"validator",
"=",
"Validator",
"::",
"make",
"(",
"$",
"inputs",
",",
"array",
"(",
"'url'",
"=>",
"'url'",
",",
"'email'",
"=>",
"'email'",
",",
")",
")",
";",
"if",
"(",
"$",
"terminal",
"&&",
"$",
"validator",
"->",
"passes",
"(",
")",
")",
"{",
"$",
"terminal",
"->",
"url",
"=",
"$",
"inputs",
"[",
"'url'",
"]",
";",
"$",
"terminal",
"->",
"email",
"=",
"$",
"inputs",
"[",
"'email'",
"]",
";",
"$",
"terminal",
"->",
"save",
"(",
")",
";",
"return",
"'ok'",
";",
"}",
"return",
"'error'",
";",
"}"
] |
Change term options
@return string
|
[
"Change",
"term",
"options"
] |
6256be98509de0ff8e96b5683a0b0197acd67b9e
|
https://github.com/fintech-fab/bank-emulator/blob/6256be98509de0ff8e96b5683a0b0197acd67b9e/src/controllers/DemoController.php#L71-L101
|
234,847
|
fintech-fab/bank-emulator
|
src/controllers/DemoController.php
|
DemoController.sign
|
public function sign()
{
$type = Input::get('type');
$input = Input::get('input');
$termId = $input['term'];
$term = Terminal::find($termId);
$input = Type::clearInput($type, $input);
Secure::sign($input, $type, $term->secret);
return $input['sign'];
}
|
php
|
public function sign()
{
$type = Input::get('type');
$input = Input::get('input');
$termId = $input['term'];
$term = Terminal::find($termId);
$input = Type::clearInput($type, $input);
Secure::sign($input, $type, $term->secret);
return $input['sign'];
}
|
[
"public",
"function",
"sign",
"(",
")",
"{",
"$",
"type",
"=",
"Input",
"::",
"get",
"(",
"'type'",
")",
";",
"$",
"input",
"=",
"Input",
"::",
"get",
"(",
"'input'",
")",
";",
"$",
"termId",
"=",
"$",
"input",
"[",
"'term'",
"]",
";",
"$",
"term",
"=",
"Terminal",
"::",
"find",
"(",
"$",
"termId",
")",
";",
"$",
"input",
"=",
"Type",
"::",
"clearInput",
"(",
"$",
"type",
",",
"$",
"input",
")",
";",
"Secure",
"::",
"sign",
"(",
"$",
"input",
",",
"$",
"type",
",",
"$",
"term",
"->",
"secret",
")",
";",
"return",
"$",
"input",
"[",
"'sign'",
"]",
";",
"}"
] |
Create signature for payment form
|
[
"Create",
"signature",
"for",
"payment",
"form"
] |
6256be98509de0ff8e96b5683a0b0197acd67b9e
|
https://github.com/fintech-fab/bank-emulator/blob/6256be98509de0ff8e96b5683a0b0197acd67b9e/src/controllers/DemoController.php#L114-L126
|
234,848
|
fintech-fab/bank-emulator
|
src/controllers/DemoController.php
|
DemoController.callback
|
public function callback()
{
Log::info('callback.url.pull', array(
'message' => 'Request callback url',
'rawInput' => Input::all(),
));
$input = $this->getVerifiedInput('callback', Input::get('type'), Input::all(), true);
if ($input) {
// your business processing
}
}
|
php
|
public function callback()
{
Log::info('callback.url.pull', array(
'message' => 'Request callback url',
'rawInput' => Input::all(),
));
$input = $this->getVerifiedInput('callback', Input::get('type'), Input::all(), true);
if ($input) {
// your business processing
}
}
|
[
"public",
"function",
"callback",
"(",
")",
"{",
"Log",
"::",
"info",
"(",
"'callback.url.pull'",
",",
"array",
"(",
"'message'",
"=>",
"'Request callback url'",
",",
"'rawInput'",
"=>",
"Input",
"::",
"all",
"(",
")",
",",
")",
")",
";",
"$",
"input",
"=",
"$",
"this",
"->",
"getVerifiedInput",
"(",
"'callback'",
",",
"Input",
"::",
"get",
"(",
"'type'",
")",
",",
"Input",
"::",
"all",
"(",
")",
",",
"true",
")",
";",
"if",
"(",
"$",
"input",
")",
"{",
"// your business processing",
"}",
"}"
] |
Pull payment callbacks
|
[
"Pull",
"payment",
"callbacks"
] |
6256be98509de0ff8e96b5683a0b0197acd67b9e
|
https://github.com/fintech-fab/bank-emulator/blob/6256be98509de0ff8e96b5683a0b0197acd67b9e/src/controllers/DemoController.php#L131-L144
|
234,849
|
fintech-fab/bank-emulator
|
src/controllers/DemoController.php
|
DemoController.shop
|
public function shop()
{
$terminal = Terminal::whereUserId($this->userId())->first();
$endpointParams = $this->getEndpointFields($terminal);
$status = Input::get('resultBankEmulatorPayment');
$statusSuccess = ($status === 'success');
$statusError = ($status === 'error');
$this->make('shop', compact(
'terminal',
'endpointParams',
'statusSuccess',
'statusError'
));
}
|
php
|
public function shop()
{
$terminal = Terminal::whereUserId($this->userId())->first();
$endpointParams = $this->getEndpointFields($terminal);
$status = Input::get('resultBankEmulatorPayment');
$statusSuccess = ($status === 'success');
$statusError = ($status === 'error');
$this->make('shop', compact(
'terminal',
'endpointParams',
'statusSuccess',
'statusError'
));
}
|
[
"public",
"function",
"shop",
"(",
")",
"{",
"$",
"terminal",
"=",
"Terminal",
"::",
"whereUserId",
"(",
"$",
"this",
"->",
"userId",
"(",
")",
")",
"->",
"first",
"(",
")",
";",
"$",
"endpointParams",
"=",
"$",
"this",
"->",
"getEndpointFields",
"(",
"$",
"terminal",
")",
";",
"$",
"status",
"=",
"Input",
"::",
"get",
"(",
"'resultBankEmulatorPayment'",
")",
";",
"$",
"statusSuccess",
"=",
"(",
"$",
"status",
"===",
"'success'",
")",
";",
"$",
"statusError",
"=",
"(",
"$",
"status",
"===",
"'error'",
")",
";",
"$",
"this",
"->",
"make",
"(",
"'shop'",
",",
"compact",
"(",
"'terminal'",
",",
"'endpointParams'",
",",
"'statusSuccess'",
",",
"'statusError'",
")",
")",
";",
"}"
] |
E-shop order page
|
[
"E",
"-",
"shop",
"order",
"page"
] |
6256be98509de0ff8e96b5683a0b0197acd67b9e
|
https://github.com/fintech-fab/bank-emulator/blob/6256be98509de0ff8e96b5683a0b0197acd67b9e/src/controllers/DemoController.php#L451-L468
|
234,850
|
makinacorpus/drupal-ucms
|
ucms_list/src/Impl/TypeContentListWidget.php
|
TypeContentListWidget.getContentTagsList
|
protected function getContentTagsList()
{
$ret = [];
if (!$this->labelManager) {
return;
}
$tagList = $this->labelManager->loadAllLabels();
if ($tagList) {
foreach ($tagList as $tag) {
$ret[$tag->tid] = $tag->name;
}
}
return $ret;
}
|
php
|
protected function getContentTagsList()
{
$ret = [];
if (!$this->labelManager) {
return;
}
$tagList = $this->labelManager->loadAllLabels();
if ($tagList) {
foreach ($tagList as $tag) {
$ret[$tag->tid] = $tag->name;
}
}
return $ret;
}
|
[
"protected",
"function",
"getContentTagsList",
"(",
")",
"{",
"$",
"ret",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"labelManager",
")",
"{",
"return",
";",
"}",
"$",
"tagList",
"=",
"$",
"this",
"->",
"labelManager",
"->",
"loadAllLabels",
"(",
")",
";",
"if",
"(",
"$",
"tagList",
")",
"{",
"foreach",
"(",
"$",
"tagList",
"as",
"$",
"tag",
")",
"{",
"$",
"ret",
"[",
"$",
"tag",
"->",
"tid",
"]",
"=",
"$",
"tag",
"->",
"name",
";",
"}",
"}",
"return",
"$",
"ret",
";",
"}"
] |
Get allowed tags list.
|
[
"Get",
"allowed",
"tags",
"list",
"."
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_list/src/Impl/TypeContentListWidget.php#L114-L131
|
234,851
|
mosbth/Anax-MVC
|
src/TConfigure.php
|
TConfigure.configure
|
public function configure($what)
{
if (is_array($what)) {
$options = $what;
} elseif (is_readable($what)) {
$options = include $what;
} else {
throw new Exception("Configure item '" . htmlentities($what)
. "' is not an array nor a readable file.");
}
$this->config = array_merge($this->config, $options);
return $this->config;
}
|
php
|
public function configure($what)
{
if (is_array($what)) {
$options = $what;
} elseif (is_readable($what)) {
$options = include $what;
} else {
throw new Exception("Configure item '" . htmlentities($what)
. "' is not an array nor a readable file.");
}
$this->config = array_merge($this->config, $options);
return $this->config;
}
|
[
"public",
"function",
"configure",
"(",
"$",
"what",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"what",
")",
")",
"{",
"$",
"options",
"=",
"$",
"what",
";",
"}",
"elseif",
"(",
"is_readable",
"(",
"$",
"what",
")",
")",
"{",
"$",
"options",
"=",
"include",
"$",
"what",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"\"Configure item '\"",
".",
"htmlentities",
"(",
"$",
"what",
")",
".",
"\"' is not an array nor a readable file.\"",
")",
";",
"}",
"$",
"this",
"->",
"config",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"config",
",",
"$",
"options",
")",
";",
"return",
"$",
"this",
"->",
"config",
";",
"}"
] |
Read configuration from file or array'.
@param array/string $what is an array with key/value config options or a file
to be included which returns such an array.
@return $this for chaining.
@throws Exception
|
[
"Read",
"configuration",
"from",
"file",
"or",
"array",
"."
] |
5574d105bcec9df8e57532a321585f6521b4581c
|
https://github.com/mosbth/Anax-MVC/blob/5574d105bcec9df8e57532a321585f6521b4581c/src/TConfigure.php#L27-L40
|
234,852
|
andkirby/multi-repo-composer
|
src/Downloader/GitMultiRepoDownloader.php
|
GitMultiRepoDownloader.getMultiRepositoryPath
|
protected function getMultiRepositoryPath($path)
{
if ($this->isPathOfMultiRepository($path)) {
return $path;
}
$packageDir = pathinfo($path, PATHINFO_BASENAME);
if (!strpos($packageDir, self::MULTI_REPO_DELIMITER)) {
//package cannot be used in multi-repo
return null;
}
$this->defaultPath = $path;
$arr = explode(self::MULTI_REPO_DELIMITER, $packageDir);
$baseName = array_shift($arr);
$customDir = $this->getParentMultiRepoDir();
if ($customDir) {
//get vendor name
$vendor = pathinfo(dirname($path), PATHINFO_BASENAME);
//get path based upon custom parent dir
$newPath = $customDir . DIRECTORY_SEPARATOR . $vendor . DIRECTORY_SEPARATOR
. $baseName . self::MULTI_REPO_DIRECTORY_SUFFIX;
if ($this->io->isVeryVerbose()) {
$this->io->write(' Multi-repository custom path found.');
}
} else {
//make full path to new general multi-repo directory
$newPath = str_replace(
$packageDir,
$baseName . self::MULTI_REPO_DIRECTORY_SUFFIX, //make repo dir name
$path
);
if ($this->io->isVeryVerbose()) {
$this->io->write(' Multi-repository path will be within the current vendor directory.');
}
}
$this->filesystem->ensureDirectoryExists($newPath);
return $newPath;
}
|
php
|
protected function getMultiRepositoryPath($path)
{
if ($this->isPathOfMultiRepository($path)) {
return $path;
}
$packageDir = pathinfo($path, PATHINFO_BASENAME);
if (!strpos($packageDir, self::MULTI_REPO_DELIMITER)) {
//package cannot be used in multi-repo
return null;
}
$this->defaultPath = $path;
$arr = explode(self::MULTI_REPO_DELIMITER, $packageDir);
$baseName = array_shift($arr);
$customDir = $this->getParentMultiRepoDir();
if ($customDir) {
//get vendor name
$vendor = pathinfo(dirname($path), PATHINFO_BASENAME);
//get path based upon custom parent dir
$newPath = $customDir . DIRECTORY_SEPARATOR . $vendor . DIRECTORY_SEPARATOR
. $baseName . self::MULTI_REPO_DIRECTORY_SUFFIX;
if ($this->io->isVeryVerbose()) {
$this->io->write(' Multi-repository custom path found.');
}
} else {
//make full path to new general multi-repo directory
$newPath = str_replace(
$packageDir,
$baseName . self::MULTI_REPO_DIRECTORY_SUFFIX, //make repo dir name
$path
);
if ($this->io->isVeryVerbose()) {
$this->io->write(' Multi-repository path will be within the current vendor directory.');
}
}
$this->filesystem->ensureDirectoryExists($newPath);
return $newPath;
}
|
[
"protected",
"function",
"getMultiRepositoryPath",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isPathOfMultiRepository",
"(",
"$",
"path",
")",
")",
"{",
"return",
"$",
"path",
";",
"}",
"$",
"packageDir",
"=",
"pathinfo",
"(",
"$",
"path",
",",
"PATHINFO_BASENAME",
")",
";",
"if",
"(",
"!",
"strpos",
"(",
"$",
"packageDir",
",",
"self",
"::",
"MULTI_REPO_DELIMITER",
")",
")",
"{",
"//package cannot be used in multi-repo",
"return",
"null",
";",
"}",
"$",
"this",
"->",
"defaultPath",
"=",
"$",
"path",
";",
"$",
"arr",
"=",
"explode",
"(",
"self",
"::",
"MULTI_REPO_DELIMITER",
",",
"$",
"packageDir",
")",
";",
"$",
"baseName",
"=",
"array_shift",
"(",
"$",
"arr",
")",
";",
"$",
"customDir",
"=",
"$",
"this",
"->",
"getParentMultiRepoDir",
"(",
")",
";",
"if",
"(",
"$",
"customDir",
")",
"{",
"//get vendor name",
"$",
"vendor",
"=",
"pathinfo",
"(",
"dirname",
"(",
"$",
"path",
")",
",",
"PATHINFO_BASENAME",
")",
";",
"//get path based upon custom parent dir",
"$",
"newPath",
"=",
"$",
"customDir",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"vendor",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"baseName",
".",
"self",
"::",
"MULTI_REPO_DIRECTORY_SUFFIX",
";",
"if",
"(",
"$",
"this",
"->",
"io",
"->",
"isVeryVerbose",
"(",
")",
")",
"{",
"$",
"this",
"->",
"io",
"->",
"write",
"(",
"' Multi-repository custom path found.'",
")",
";",
"}",
"}",
"else",
"{",
"//make full path to new general multi-repo directory",
"$",
"newPath",
"=",
"str_replace",
"(",
"$",
"packageDir",
",",
"$",
"baseName",
".",
"self",
"::",
"MULTI_REPO_DIRECTORY_SUFFIX",
",",
"//make repo dir name",
"$",
"path",
")",
";",
"if",
"(",
"$",
"this",
"->",
"io",
"->",
"isVeryVerbose",
"(",
")",
")",
"{",
"$",
"this",
"->",
"io",
"->",
"write",
"(",
"' Multi-repository path will be within the current vendor directory.'",
")",
";",
"}",
"}",
"$",
"this",
"->",
"filesystem",
"->",
"ensureDirectoryExists",
"(",
"$",
"newPath",
")",
";",
"return",
"$",
"newPath",
";",
"}"
] |
Get multi repository directory path
@param string $path
@return string
|
[
"Get",
"multi",
"repository",
"directory",
"path"
] |
2d9fed02edf7601f56f2998f9d99e646b713aef6
|
https://github.com/andkirby/multi-repo-composer/blob/2d9fed02edf7601f56f2998f9d99e646b713aef6/src/Downloader/GitMultiRepoDownloader.php#L85-L124
|
234,853
|
andkirby/multi-repo-composer
|
src/Downloader/GitMultiRepoDownloader.php
|
GitMultiRepoDownloader.getParentMultiRepoDir
|
protected function getParentMultiRepoDir()
{
$rootConfig = $this->config->get('root_extra_config');
if (!empty($rootConfig[self::KEY_MULTI_REPO_PARENT_DIR])) {
$rootConfig[self::KEY_MULTI_REPO_PARENT_DIR] = rtrim($rootConfig[self::KEY_MULTI_REPO_PARENT_DIR], '\\/');
if ($this->io->isVeryVerbose()) {
$this->io->write(' Multi-repository path will be in custom parent directory.');
}
return $rootConfig[self::KEY_MULTI_REPO_PARENT_DIR];
}
if (!isset($rootConfig[self::KEY_MULTI_REPO_IN_CACHE]) || $rootConfig[self::KEY_MULTI_REPO_IN_CACHE]) {
if ($this->io->isVeryVerbose()) {
$this->io->write(' Multi-repository path will be in "cache-repo-dir".');
}
return $this->config->get('cache-repo-dir');
}
return null;
}
|
php
|
protected function getParentMultiRepoDir()
{
$rootConfig = $this->config->get('root_extra_config');
if (!empty($rootConfig[self::KEY_MULTI_REPO_PARENT_DIR])) {
$rootConfig[self::KEY_MULTI_REPO_PARENT_DIR] = rtrim($rootConfig[self::KEY_MULTI_REPO_PARENT_DIR], '\\/');
if ($this->io->isVeryVerbose()) {
$this->io->write(' Multi-repository path will be in custom parent directory.');
}
return $rootConfig[self::KEY_MULTI_REPO_PARENT_DIR];
}
if (!isset($rootConfig[self::KEY_MULTI_REPO_IN_CACHE]) || $rootConfig[self::KEY_MULTI_REPO_IN_CACHE]) {
if ($this->io->isVeryVerbose()) {
$this->io->write(' Multi-repository path will be in "cache-repo-dir".');
}
return $this->config->get('cache-repo-dir');
}
return null;
}
|
[
"protected",
"function",
"getParentMultiRepoDir",
"(",
")",
"{",
"$",
"rootConfig",
"=",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'root_extra_config'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"rootConfig",
"[",
"self",
"::",
"KEY_MULTI_REPO_PARENT_DIR",
"]",
")",
")",
"{",
"$",
"rootConfig",
"[",
"self",
"::",
"KEY_MULTI_REPO_PARENT_DIR",
"]",
"=",
"rtrim",
"(",
"$",
"rootConfig",
"[",
"self",
"::",
"KEY_MULTI_REPO_PARENT_DIR",
"]",
",",
"'\\\\/'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"io",
"->",
"isVeryVerbose",
"(",
")",
")",
"{",
"$",
"this",
"->",
"io",
"->",
"write",
"(",
"' Multi-repository path will be in custom parent directory.'",
")",
";",
"}",
"return",
"$",
"rootConfig",
"[",
"self",
"::",
"KEY_MULTI_REPO_PARENT_DIR",
"]",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"rootConfig",
"[",
"self",
"::",
"KEY_MULTI_REPO_IN_CACHE",
"]",
")",
"||",
"$",
"rootConfig",
"[",
"self",
"::",
"KEY_MULTI_REPO_IN_CACHE",
"]",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"io",
"->",
"isVeryVerbose",
"(",
")",
")",
"{",
"$",
"this",
"->",
"io",
"->",
"write",
"(",
"' Multi-repository path will be in \"cache-repo-dir\".'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'cache-repo-dir'",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Get custom parent multi repository directory
@return string|null
|
[
"Get",
"custom",
"parent",
"multi",
"repository",
"directory"
] |
2d9fed02edf7601f56f2998f9d99e646b713aef6
|
https://github.com/andkirby/multi-repo-composer/blob/2d9fed02edf7601f56f2998f9d99e646b713aef6/src/Downloader/GitMultiRepoDownloader.php#L131-L148
|
234,854
|
andkirby/multi-repo-composer
|
src/Downloader/GitMultiRepoDownloader.php
|
GitMultiRepoDownloader.copyFilesToDefaultPath
|
protected function copyFilesToDefaultPath($source)
{
$target = $this->defaultPath;
if (!$target || $target == $source) {
return $this;
}
if (is_file($source)) {
//copy file
copy($source, $target);
return $this;
}
$it = new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS);
$ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::SELF_FIRST);
$this->cleanUpDir($target);
/** @var \SplFileInfo $file */
foreach ($ri as $file) {
if ('.git' . DIRECTORY_SEPARATOR == substr($ri->getSubPathName(), 0, 5)
|| '.git' == $ri->getSubPathName()
) {
//skip .git directory
continue;
}
$targetPath = $target . DIRECTORY_SEPARATOR . $ri->getSubPathName();
if ($file->isDir()) {
$this->filesystem->ensureDirectoryExists($targetPath);
} else {
copy($file->getPathname(), $targetPath);
}
}
return $this;
}
|
php
|
protected function copyFilesToDefaultPath($source)
{
$target = $this->defaultPath;
if (!$target || $target == $source) {
return $this;
}
if (is_file($source)) {
//copy file
copy($source, $target);
return $this;
}
$it = new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS);
$ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::SELF_FIRST);
$this->cleanUpDir($target);
/** @var \SplFileInfo $file */
foreach ($ri as $file) {
if ('.git' . DIRECTORY_SEPARATOR == substr($ri->getSubPathName(), 0, 5)
|| '.git' == $ri->getSubPathName()
) {
//skip .git directory
continue;
}
$targetPath = $target . DIRECTORY_SEPARATOR . $ri->getSubPathName();
if ($file->isDir()) {
$this->filesystem->ensureDirectoryExists($targetPath);
} else {
copy($file->getPathname(), $targetPath);
}
}
return $this;
}
|
[
"protected",
"function",
"copyFilesToDefaultPath",
"(",
"$",
"source",
")",
"{",
"$",
"target",
"=",
"$",
"this",
"->",
"defaultPath",
";",
"if",
"(",
"!",
"$",
"target",
"||",
"$",
"target",
"==",
"$",
"source",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"is_file",
"(",
"$",
"source",
")",
")",
"{",
"//copy file",
"copy",
"(",
"$",
"source",
",",
"$",
"target",
")",
";",
"return",
"$",
"this",
";",
"}",
"$",
"it",
"=",
"new",
"RecursiveDirectoryIterator",
"(",
"$",
"source",
",",
"RecursiveDirectoryIterator",
"::",
"SKIP_DOTS",
")",
";",
"$",
"ri",
"=",
"new",
"RecursiveIteratorIterator",
"(",
"$",
"it",
",",
"RecursiveIteratorIterator",
"::",
"SELF_FIRST",
")",
";",
"$",
"this",
"->",
"cleanUpDir",
"(",
"$",
"target",
")",
";",
"/** @var \\SplFileInfo $file */",
"foreach",
"(",
"$",
"ri",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"'.git'",
".",
"DIRECTORY_SEPARATOR",
"==",
"substr",
"(",
"$",
"ri",
"->",
"getSubPathName",
"(",
")",
",",
"0",
",",
"5",
")",
"||",
"'.git'",
"==",
"$",
"ri",
"->",
"getSubPathName",
"(",
")",
")",
"{",
"//skip .git directory",
"continue",
";",
"}",
"$",
"targetPath",
"=",
"$",
"target",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"ri",
"->",
"getSubPathName",
"(",
")",
";",
"if",
"(",
"$",
"file",
"->",
"isDir",
"(",
")",
")",
"{",
"$",
"this",
"->",
"filesystem",
"->",
"ensureDirectoryExists",
"(",
"$",
"targetPath",
")",
";",
"}",
"else",
"{",
"copy",
"(",
"$",
"file",
"->",
"getPathname",
"(",
")",
",",
"$",
"targetPath",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Copy files to default package directory
@param $source
@return $this
|
[
"Copy",
"files",
"to",
"default",
"package",
"directory"
] |
2d9fed02edf7601f56f2998f9d99e646b713aef6
|
https://github.com/andkirby/multi-repo-composer/blob/2d9fed02edf7601f56f2998f9d99e646b713aef6/src/Downloader/GitMultiRepoDownloader.php#L156-L190
|
234,855
|
andkirby/multi-repo-composer
|
src/Downloader/GitMultiRepoDownloader.php
|
GitMultiRepoDownloader.doDownload
|
public function doDownload(PackageInterface $package, $path, $url)
{
GitUtil::cleanEnv();
$path = $this->normalizePath($path);
if (!$this->isRequiredRepository($path, $url)) {
throw new FilesystemException('Unknown repository installed into ' . $path);
}
$ref = $package->getSourceReference();
if ($this->io->isVerbose()) {
$this->io->write(' Multi-repository path: ' . $path);
}
if (!$this->isRepositoryCloned($path)) {
$this->io->write(' Multi-repository GIT directory not found. Cloning...');
$this->cloneRepository($package, $path, $url);
} else {
$this->io->write(' Multi-repository GIT directory found. Fetching changes...');
$this->fetchRepositoryUpdates($package, $path, $url);
}
if ($newRef = $this->updateToCommit($path, $ref, $package->getPrettyVersion(), $package->getReleaseDate())) {
if ($package->getDistReference() === $package->getSourceReference()) {
$package->setDistReference($newRef);
}
$package->setSourceReference($newRef);
}
//copy file into required directory
$this->copyFilesToDefaultPath($path);
}
|
php
|
public function doDownload(PackageInterface $package, $path, $url)
{
GitUtil::cleanEnv();
$path = $this->normalizePath($path);
if (!$this->isRequiredRepository($path, $url)) {
throw new FilesystemException('Unknown repository installed into ' . $path);
}
$ref = $package->getSourceReference();
if ($this->io->isVerbose()) {
$this->io->write(' Multi-repository path: ' . $path);
}
if (!$this->isRepositoryCloned($path)) {
$this->io->write(' Multi-repository GIT directory not found. Cloning...');
$this->cloneRepository($package, $path, $url);
} else {
$this->io->write(' Multi-repository GIT directory found. Fetching changes...');
$this->fetchRepositoryUpdates($package, $path, $url);
}
if ($newRef = $this->updateToCommit($path, $ref, $package->getPrettyVersion(), $package->getReleaseDate())) {
if ($package->getDistReference() === $package->getSourceReference()) {
$package->setDistReference($newRef);
}
$package->setSourceReference($newRef);
}
//copy file into required directory
$this->copyFilesToDefaultPath($path);
}
|
[
"public",
"function",
"doDownload",
"(",
"PackageInterface",
"$",
"package",
",",
"$",
"path",
",",
"$",
"url",
")",
"{",
"GitUtil",
"::",
"cleanEnv",
"(",
")",
";",
"$",
"path",
"=",
"$",
"this",
"->",
"normalizePath",
"(",
"$",
"path",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isRequiredRepository",
"(",
"$",
"path",
",",
"$",
"url",
")",
")",
"{",
"throw",
"new",
"FilesystemException",
"(",
"'Unknown repository installed into '",
".",
"$",
"path",
")",
";",
"}",
"$",
"ref",
"=",
"$",
"package",
"->",
"getSourceReference",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"io",
"->",
"isVerbose",
"(",
")",
")",
"{",
"$",
"this",
"->",
"io",
"->",
"write",
"(",
"' Multi-repository path: '",
".",
"$",
"path",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"isRepositoryCloned",
"(",
"$",
"path",
")",
")",
"{",
"$",
"this",
"->",
"io",
"->",
"write",
"(",
"' Multi-repository GIT directory not found. Cloning...'",
")",
";",
"$",
"this",
"->",
"cloneRepository",
"(",
"$",
"package",
",",
"$",
"path",
",",
"$",
"url",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"io",
"->",
"write",
"(",
"' Multi-repository GIT directory found. Fetching changes...'",
")",
";",
"$",
"this",
"->",
"fetchRepositoryUpdates",
"(",
"$",
"package",
",",
"$",
"path",
",",
"$",
"url",
")",
";",
"}",
"if",
"(",
"$",
"newRef",
"=",
"$",
"this",
"->",
"updateToCommit",
"(",
"$",
"path",
",",
"$",
"ref",
",",
"$",
"package",
"->",
"getPrettyVersion",
"(",
")",
",",
"$",
"package",
"->",
"getReleaseDate",
"(",
")",
")",
")",
"{",
"if",
"(",
"$",
"package",
"->",
"getDistReference",
"(",
")",
"===",
"$",
"package",
"->",
"getSourceReference",
"(",
")",
")",
"{",
"$",
"package",
"->",
"setDistReference",
"(",
"$",
"newRef",
")",
";",
"}",
"$",
"package",
"->",
"setSourceReference",
"(",
"$",
"newRef",
")",
";",
"}",
"//copy file into required directory",
"$",
"this",
"->",
"copyFilesToDefaultPath",
"(",
"$",
"path",
")",
";",
"}"
] |
Downloads specific package into specific folder
VCS repository will be created in a separated folder.
@param PackageInterface $package
@param string $path
@param string $url
@throws FilesystemException
|
[
"Downloads",
"specific",
"package",
"into",
"specific",
"folder"
] |
2d9fed02edf7601f56f2998f9d99e646b713aef6
|
https://github.com/andkirby/multi-repo-composer/blob/2d9fed02edf7601f56f2998f9d99e646b713aef6/src/Downloader/GitMultiRepoDownloader.php#L202-L232
|
234,856
|
andkirby/multi-repo-composer
|
src/Downloader/GitMultiRepoDownloader.php
|
GitMultiRepoDownloader.initGitUtil
|
protected function initGitUtil()
{
$this->gitUtil = new GitUtil($this->io, $this->config, $this->process, $this->filesystem);
return $this;
}
|
php
|
protected function initGitUtil()
{
$this->gitUtil = new GitUtil($this->io, $this->config, $this->process, $this->filesystem);
return $this;
}
|
[
"protected",
"function",
"initGitUtil",
"(",
")",
"{",
"$",
"this",
"->",
"gitUtil",
"=",
"new",
"GitUtil",
"(",
"$",
"this",
"->",
"io",
",",
"$",
"this",
"->",
"config",
",",
"$",
"this",
"->",
"process",
",",
"$",
"this",
"->",
"filesystem",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Init GitUtil object
@return $this
|
[
"Init",
"GitUtil",
"object"
] |
2d9fed02edf7601f56f2998f9d99e646b713aef6
|
https://github.com/andkirby/multi-repo-composer/blob/2d9fed02edf7601f56f2998f9d99e646b713aef6/src/Downloader/GitMultiRepoDownloader.php#L257-L261
|
234,857
|
andkirby/multi-repo-composer
|
src/Downloader/GitMultiRepoDownloader.php
|
GitMultiRepoDownloader.getCloneCommandCallback
|
protected function getCloneCommandCallback($path, $ref, $command)
{
return function ($url) use ($ref, $path, $command) {
return sprintf($command, ProcessExecutor::escape($url), ProcessExecutor::escape($path), ProcessExecutor::escape($ref));
};
}
|
php
|
protected function getCloneCommandCallback($path, $ref, $command)
{
return function ($url) use ($ref, $path, $command) {
return sprintf($command, ProcessExecutor::escape($url), ProcessExecutor::escape($path), ProcessExecutor::escape($ref));
};
}
|
[
"protected",
"function",
"getCloneCommandCallback",
"(",
"$",
"path",
",",
"$",
"ref",
",",
"$",
"command",
")",
"{",
"return",
"function",
"(",
"$",
"url",
")",
"use",
"(",
"$",
"ref",
",",
"$",
"path",
",",
"$",
"command",
")",
"{",
"return",
"sprintf",
"(",
"$",
"command",
",",
"ProcessExecutor",
"::",
"escape",
"(",
"$",
"url",
")",
",",
"ProcessExecutor",
"::",
"escape",
"(",
"$",
"path",
")",
",",
"ProcessExecutor",
"::",
"escape",
"(",
"$",
"ref",
")",
")",
";",
"}",
";",
"}"
] |
Get command callback for cloning
@param string $path
@param string $ref
@param string $command
@return callable
|
[
"Get",
"command",
"callback",
"for",
"cloning"
] |
2d9fed02edf7601f56f2998f9d99e646b713aef6
|
https://github.com/andkirby/multi-repo-composer/blob/2d9fed02edf7601f56f2998f9d99e646b713aef6/src/Downloader/GitMultiRepoDownloader.php#L280-L285
|
234,858
|
andkirby/multi-repo-composer
|
src/Downloader/GitMultiRepoDownloader.php
|
GitMultiRepoDownloader.fetchRepositoryUpdates
|
protected function fetchRepositoryUpdates(PackageInterface $package, $path, $url)
{
/**
* Copy-pasted from doUpdate
*
* @see GitDownloader::doUpdate()
*/
$this->io->write(' Checking out ' . $package->getSourceReference());
$command = $this->getFetchCommand();
$commandCallable = function ($url) use ($command) {
return sprintf($command, ProcessExecutor::escape($url));
};
$this->gitUtil->runCommand($commandCallable, $url, $path);
return $this;
}
|
php
|
protected function fetchRepositoryUpdates(PackageInterface $package, $path, $url)
{
/**
* Copy-pasted from doUpdate
*
* @see GitDownloader::doUpdate()
*/
$this->io->write(' Checking out ' . $package->getSourceReference());
$command = $this->getFetchCommand();
$commandCallable = function ($url) use ($command) {
return sprintf($command, ProcessExecutor::escape($url));
};
$this->gitUtil->runCommand($commandCallable, $url, $path);
return $this;
}
|
[
"protected",
"function",
"fetchRepositoryUpdates",
"(",
"PackageInterface",
"$",
"package",
",",
"$",
"path",
",",
"$",
"url",
")",
"{",
"/**\n * Copy-pasted from doUpdate\n *\n * @see GitDownloader::doUpdate()\n */",
"$",
"this",
"->",
"io",
"->",
"write",
"(",
"' Checking out '",
".",
"$",
"package",
"->",
"getSourceReference",
"(",
")",
")",
";",
"$",
"command",
"=",
"$",
"this",
"->",
"getFetchCommand",
"(",
")",
";",
"$",
"commandCallable",
"=",
"function",
"(",
"$",
"url",
")",
"use",
"(",
"$",
"command",
")",
"{",
"return",
"sprintf",
"(",
"$",
"command",
",",
"ProcessExecutor",
"::",
"escape",
"(",
"$",
"url",
")",
")",
";",
"}",
";",
"$",
"this",
"->",
"gitUtil",
"->",
"runCommand",
"(",
"$",
"commandCallable",
",",
"$",
"url",
",",
"$",
"path",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Fetch remote VCS repository updates
@param PackageInterface $package
@param string $path
@param string $url
@return $this
|
[
"Fetch",
"remote",
"VCS",
"repository",
"updates"
] |
2d9fed02edf7601f56f2998f9d99e646b713aef6
|
https://github.com/andkirby/multi-repo-composer/blob/2d9fed02edf7601f56f2998f9d99e646b713aef6/src/Downloader/GitMultiRepoDownloader.php#L305-L319
|
234,859
|
andkirby/multi-repo-composer
|
src/Downloader/GitMultiRepoDownloader.php
|
GitMultiRepoDownloader.isRequiredRepository
|
protected function isRequiredRepository($path, $url)
{
if ($this->isMultiRepository() && $this->isRepositoryCloned($path)) {
$this->process->execute(sprintf('git config --get remote.origin.url'), $output, $path);
return $url == trim($output);
}
return true; //empty directory
}
|
php
|
protected function isRequiredRepository($path, $url)
{
if ($this->isMultiRepository() && $this->isRepositoryCloned($path)) {
$this->process->execute(sprintf('git config --get remote.origin.url'), $output, $path);
return $url == trim($output);
}
return true; //empty directory
}
|
[
"protected",
"function",
"isRequiredRepository",
"(",
"$",
"path",
",",
"$",
"url",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isMultiRepository",
"(",
")",
"&&",
"$",
"this",
"->",
"isRepositoryCloned",
"(",
"$",
"path",
")",
")",
"{",
"$",
"this",
"->",
"process",
"->",
"execute",
"(",
"sprintf",
"(",
"'git config --get remote.origin.url'",
")",
",",
"$",
"output",
",",
"$",
"path",
")",
";",
"return",
"$",
"url",
"==",
"trim",
"(",
"$",
"output",
")",
";",
"}",
"return",
"true",
";",
"//empty directory",
"}"
] |
Check mismatch of exists repository URL in remote origin
@param string $path
@param string $url
@return bool
|
[
"Check",
"mismatch",
"of",
"exists",
"repository",
"URL",
"in",
"remote",
"origin"
] |
2d9fed02edf7601f56f2998f9d99e646b713aef6
|
https://github.com/andkirby/multi-repo-composer/blob/2d9fed02edf7601f56f2998f9d99e646b713aef6/src/Downloader/GitMultiRepoDownloader.php#L361-L368
|
234,860
|
andkirby/multi-repo-composer
|
src/Downloader/GitMultiRepoDownloader.php
|
GitMultiRepoDownloader.cleanUpDir
|
protected function cleanUpDir($directory)
{
$this->filesystem->removeDirectory($directory);
$this->filesystem->ensureDirectoryExists($directory);
return $this;
}
|
php
|
protected function cleanUpDir($directory)
{
$this->filesystem->removeDirectory($directory);
$this->filesystem->ensureDirectoryExists($directory);
return $this;
}
|
[
"protected",
"function",
"cleanUpDir",
"(",
"$",
"directory",
")",
"{",
"$",
"this",
"->",
"filesystem",
"->",
"removeDirectory",
"(",
"$",
"directory",
")",
";",
"$",
"this",
"->",
"filesystem",
"->",
"ensureDirectoryExists",
"(",
"$",
"directory",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Clean up directory
@param string $directory
@return $this
|
[
"Clean",
"up",
"directory"
] |
2d9fed02edf7601f56f2998f9d99e646b713aef6
|
https://github.com/andkirby/multi-repo-composer/blob/2d9fed02edf7601f56f2998f9d99e646b713aef6/src/Downloader/GitMultiRepoDownloader.php#L386-L391
|
234,861
|
runcmf/runbb
|
src/RunBB/Core/Statical/Manager.php
|
Manager.addProxyService
|
public function addProxyService($alias, $proxy, $container, $id = null, $namespace = null)
{
$proxy = Input::checkNamespace($proxy);
$container = Input::checkContainer($container);
$id = $id ?: strtolower($alias);
$this->addProxy($proxy, $id, $container);
$this->aliasManager->add($proxy, $alias);
if ($namespace) {
$this->addNamespace($alias, $namespace);
}
}
|
php
|
public function addProxyService($alias, $proxy, $container, $id = null, $namespace = null)
{
$proxy = Input::checkNamespace($proxy);
$container = Input::checkContainer($container);
$id = $id ?: strtolower($alias);
$this->addProxy($proxy, $id, $container);
$this->aliasManager->add($proxy, $alias);
if ($namespace) {
$this->addNamespace($alias, $namespace);
}
}
|
[
"public",
"function",
"addProxyService",
"(",
"$",
"alias",
",",
"$",
"proxy",
",",
"$",
"container",
",",
"$",
"id",
"=",
"null",
",",
"$",
"namespace",
"=",
"null",
")",
"{",
"$",
"proxy",
"=",
"Input",
"::",
"checkNamespace",
"(",
"$",
"proxy",
")",
";",
"$",
"container",
"=",
"Input",
"::",
"checkContainer",
"(",
"$",
"container",
")",
";",
"$",
"id",
"=",
"$",
"id",
"?",
":",
"strtolower",
"(",
"$",
"alias",
")",
";",
"$",
"this",
"->",
"addProxy",
"(",
"$",
"proxy",
",",
"$",
"id",
",",
"$",
"container",
")",
";",
"$",
"this",
"->",
"aliasManager",
"->",
"add",
"(",
"$",
"proxy",
",",
"$",
"alias",
")",
";",
"if",
"(",
"$",
"namespace",
")",
"{",
"$",
"this",
"->",
"addNamespace",
"(",
"$",
"alias",
",",
"$",
"namespace",
")",
";",
"}",
"}"
] |
Adds a service as a proxy target
If $id is null then the lower-cased alias will be used.
@param string $alias The statical name you call
@param string $proxy The namespaced proxy class
@param mixed $container Reference to a container
@param mixed $id The id of the target in the container
@param mixed $namespace Optional namespace
|
[
"Adds",
"a",
"service",
"as",
"a",
"proxy",
"target"
] |
d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463
|
https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Statical/Manager.php#L99-L111
|
234,862
|
runcmf/runbb
|
src/RunBB/Core/Statical/Manager.php
|
Manager.addProxyInstance
|
public function addProxyInstance($alias, $proxy, $target, $namespace = null)
{
$proxy = Input::checkNamespace($proxy);
if (!is_object($target)) {
throw new \InvalidArgumentException('Target must be an instance or closure.');
}
$this->addProxy($proxy, null, $target);
$this->aliasManager->add($proxy, $alias);
if ($namespace) {
$this->addNamespace($alias, $namespace);
}
}
|
php
|
public function addProxyInstance($alias, $proxy, $target, $namespace = null)
{
$proxy = Input::checkNamespace($proxy);
if (!is_object($target)) {
throw new \InvalidArgumentException('Target must be an instance or closure.');
}
$this->addProxy($proxy, null, $target);
$this->aliasManager->add($proxy, $alias);
if ($namespace) {
$this->addNamespace($alias, $namespace);
}
}
|
[
"public",
"function",
"addProxyInstance",
"(",
"$",
"alias",
",",
"$",
"proxy",
",",
"$",
"target",
",",
"$",
"namespace",
"=",
"null",
")",
"{",
"$",
"proxy",
"=",
"Input",
"::",
"checkNamespace",
"(",
"$",
"proxy",
")",
";",
"if",
"(",
"!",
"is_object",
"(",
"$",
"target",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Target must be an instance or closure.'",
")",
";",
"}",
"$",
"this",
"->",
"addProxy",
"(",
"$",
"proxy",
",",
"null",
",",
"$",
"target",
")",
";",
"$",
"this",
"->",
"aliasManager",
"->",
"add",
"(",
"$",
"proxy",
",",
"$",
"alias",
")",
";",
"if",
"(",
"$",
"namespace",
")",
"{",
"$",
"this",
"->",
"addNamespace",
"(",
"$",
"alias",
",",
"$",
"namespace",
")",
";",
"}",
"}"
] |
Adds an instance or closure as a proxy target
@param string $alias The statical name you call
@param string $proxy The namespaced proxy class
@param mixed $target The target instance or closure
@param mixed $namespace Optional namespace
|
[
"Adds",
"an",
"instance",
"or",
"closure",
"as",
"a",
"proxy",
"target"
] |
d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463
|
https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Statical/Manager.php#L121-L135
|
234,863
|
runcmf/runbb
|
src/RunBB/Core/Statical/Manager.php
|
Manager.addNamespaceGroup
|
public function addNamespaceGroup($group, $alias, $namespace = null)
{
$namespace = Input::formatNamespace($namespace, $group);
$this->aliasManager->addNamespace($alias, $namespace);
}
|
php
|
public function addNamespaceGroup($group, $alias, $namespace = null)
{
$namespace = Input::formatNamespace($namespace, $group);
$this->aliasManager->addNamespace($alias, $namespace);
}
|
[
"public",
"function",
"addNamespaceGroup",
"(",
"$",
"group",
",",
"$",
"alias",
",",
"$",
"namespace",
"=",
"null",
")",
"{",
"$",
"namespace",
"=",
"Input",
"::",
"formatNamespace",
"(",
"$",
"namespace",
",",
"$",
"group",
")",
";",
"$",
"this",
"->",
"aliasManager",
"->",
"addNamespace",
"(",
"$",
"alias",
",",
"$",
"namespace",
")",
";",
"}"
] |
Adds a namespace group for a single, or all aliases
The $alias can either be a single value or the wildcard '*' value, which
allows any registered alias in the namespace.
The group can be one of the following:
'name' - the alias can be called in the $namespace
'path' - the alias can be called in the $namespace and any descendants
'any' - the alias can be called in any namespace
Namespace can either be a single string value, an array of values, or
missing in the case of group 'any'.
@param string $group
@param string $alias
@param mixed $namespace
|
[
"Adds",
"a",
"namespace",
"group",
"for",
"a",
"single",
"or",
"all",
"aliases"
] |
d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463
|
https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Statical/Manager.php#L178-L182
|
234,864
|
NicolasMahe/Laravel-SlackOutput
|
src/Library/JobFailed.php
|
JobFailed.output
|
static public function output(JB $event, $channel)
{
$message = "Job '" . $event->job->getName() . "' failed.";
Artisan::call('slack:post', [
'to' => $channel,
'message' => $message
]);
}
|
php
|
static public function output(JB $event, $channel)
{
$message = "Job '" . $event->job->getName() . "' failed.";
Artisan::call('slack:post', [
'to' => $channel,
'message' => $message
]);
}
|
[
"static",
"public",
"function",
"output",
"(",
"JB",
"$",
"event",
",",
"$",
"channel",
")",
"{",
"$",
"message",
"=",
"\"Job '\"",
".",
"$",
"event",
"->",
"job",
"->",
"getName",
"(",
")",
".",
"\"' failed.\"",
";",
"Artisan",
"::",
"call",
"(",
"'slack:post'",
",",
"[",
"'to'",
"=>",
"$",
"channel",
",",
"'message'",
"=>",
"$",
"message",
"]",
")",
";",
"}"
] |
Output a failed job to slack
@param JB $event
@param $channel
|
[
"Output",
"a",
"failed",
"job",
"to",
"slack"
] |
fc3722ba64a0ce4d833555bb1a27513e13959b34
|
https://github.com/NicolasMahe/Laravel-SlackOutput/blob/fc3722ba64a0ce4d833555bb1a27513e13959b34/src/Library/JobFailed.php#L17-L24
|
234,865
|
artkonekt/gears
|
src/Repository/PreferenceRepository.php
|
PreferenceRepository.get
|
public function get($key, $user = null)
{
$preference = $this->getPreferenceOrFail($key);
$value = $this->backend->getPreference($key, $this->getUserId($user));
return is_null($value) ? $preference->default() : $value;
}
|
php
|
public function get($key, $user = null)
{
$preference = $this->getPreferenceOrFail($key);
$value = $this->backend->getPreference($key, $this->getUserId($user));
return is_null($value) ? $preference->default() : $value;
}
|
[
"public",
"function",
"get",
"(",
"$",
"key",
",",
"$",
"user",
"=",
"null",
")",
"{",
"$",
"preference",
"=",
"$",
"this",
"->",
"getPreferenceOrFail",
"(",
"$",
"key",
")",
";",
"$",
"value",
"=",
"$",
"this",
"->",
"backend",
"->",
"getPreference",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"getUserId",
"(",
"$",
"user",
")",
")",
";",
"return",
"is_null",
"(",
"$",
"value",
")",
"?",
"$",
"preference",
"->",
"default",
"(",
")",
":",
"$",
"value",
";",
"}"
] |
Returns the value of a preference
@param string $key
@param int|Authenticatable|null $user
@return mixed
@throws UnregisteredPreferenceException
|
[
"Returns",
"the",
"value",
"of",
"a",
"preference"
] |
6c006a3e8e334d8100aab768a2a5e807bcac5695
|
https://github.com/artkonekt/gears/blob/6c006a3e8e334d8100aab768a2a5e807bcac5695/src/Repository/PreferenceRepository.php#L48-L55
|
234,866
|
artkonekt/gears
|
src/Repository/PreferenceRepository.php
|
PreferenceRepository.set
|
public function set($key, $value, $user = null)
{
$this->getPreferenceOrFail($key);
$this->backend->setPreference($key, $value, $this->getUserId($user));
}
|
php
|
public function set($key, $value, $user = null)
{
$this->getPreferenceOrFail($key);
$this->backend->setPreference($key, $value, $this->getUserId($user));
}
|
[
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"user",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"getPreferenceOrFail",
"(",
"$",
"key",
")",
";",
"$",
"this",
"->",
"backend",
"->",
"setPreference",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"this",
"->",
"getUserId",
"(",
"$",
"user",
")",
")",
";",
"}"
] |
Updates the value of a preference
@param string $key
@param mixed $value
@param int|Authenticatable|null $user
@throws UnregisteredPreferenceException
|
[
"Updates",
"the",
"value",
"of",
"a",
"preference"
] |
6c006a3e8e334d8100aab768a2a5e807bcac5695
|
https://github.com/artkonekt/gears/blob/6c006a3e8e334d8100aab768a2a5e807bcac5695/src/Repository/PreferenceRepository.php#L65-L70
|
234,867
|
artkonekt/gears
|
src/Repository/PreferenceRepository.php
|
PreferenceRepository.forget
|
public function forget($key, $user = null)
{
$this->getPreferenceOrFail($key);
$this->backend->removePreference($key, $this->getUserId($user));
}
|
php
|
public function forget($key, $user = null)
{
$this->getPreferenceOrFail($key);
$this->backend->removePreference($key, $this->getUserId($user));
}
|
[
"public",
"function",
"forget",
"(",
"$",
"key",
",",
"$",
"user",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"getPreferenceOrFail",
"(",
"$",
"key",
")",
";",
"$",
"this",
"->",
"backend",
"->",
"removePreference",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"getUserId",
"(",
"$",
"user",
")",
")",
";",
"}"
] |
Deletes the value of a preference
@param string $key
@param int|Authenticatable|null $user
@throws UnregisteredPreferenceException
|
[
"Deletes",
"the",
"value",
"of",
"a",
"preference"
] |
6c006a3e8e334d8100aab768a2a5e807bcac5695
|
https://github.com/artkonekt/gears/blob/6c006a3e8e334d8100aab768a2a5e807bcac5695/src/Repository/PreferenceRepository.php#L79-L84
|
234,868
|
artkonekt/gears
|
src/Repository/PreferenceRepository.php
|
PreferenceRepository.update
|
public function update(array $preferences, $user = null)
{
foreach ($preferences as $key => $value) {
$this->getPreferenceOrFail($key);
}
$this->backend->setPreferences($preferences, $this->getUserId($user));
}
|
php
|
public function update(array $preferences, $user = null)
{
foreach ($preferences as $key => $value) {
$this->getPreferenceOrFail($key);
}
$this->backend->setPreferences($preferences, $this->getUserId($user));
}
|
[
"public",
"function",
"update",
"(",
"array",
"$",
"preferences",
",",
"$",
"user",
"=",
"null",
")",
"{",
"foreach",
"(",
"$",
"preferences",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"getPreferenceOrFail",
"(",
"$",
"key",
")",
";",
"}",
"$",
"this",
"->",
"backend",
"->",
"setPreferences",
"(",
"$",
"preferences",
",",
"$",
"this",
"->",
"getUserId",
"(",
"$",
"user",
")",
")",
";",
"}"
] |
Update multiple preferences at once. It's OK to pass preferences that have no saved values yet
@param array $preferences Pass key/value pairs
@param int|Authenticatable|null $user
@throws UnregisteredPreferenceException
|
[
"Update",
"multiple",
"preferences",
"at",
"once",
".",
"It",
"s",
"OK",
"to",
"pass",
"preferences",
"that",
"have",
"no",
"saved",
"values",
"yet"
] |
6c006a3e8e334d8100aab768a2a5e807bcac5695
|
https://github.com/artkonekt/gears/blob/6c006a3e8e334d8100aab768a2a5e807bcac5695/src/Repository/PreferenceRepository.php#L108-L115
|
234,869
|
artkonekt/gears
|
src/Repository/PreferenceRepository.php
|
PreferenceRepository.reset
|
public function reset(array $keys, $user = null)
{
foreach ($keys as $key) {
$this->getPreferenceOrFail($key);
}
$this->backend->removePreferences($keys, $this->getUserId($user));
}
|
php
|
public function reset(array $keys, $user = null)
{
foreach ($keys as $key) {
$this->getPreferenceOrFail($key);
}
$this->backend->removePreferences($keys, $this->getUserId($user));
}
|
[
"public",
"function",
"reset",
"(",
"array",
"$",
"keys",
",",
"$",
"user",
"=",
"null",
")",
"{",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"$",
"this",
"->",
"getPreferenceOrFail",
"(",
"$",
"key",
")",
";",
"}",
"$",
"this",
"->",
"backend",
"->",
"removePreferences",
"(",
"$",
"keys",
",",
"$",
"this",
"->",
"getUserId",
"(",
"$",
"user",
")",
")",
";",
"}"
] |
Reset values of multiple preferences at once.
@param array $keys Pass an array of keys
@param int|Authenticatable|null $user
@throws UnregisteredPreferenceException
|
[
"Reset",
"values",
"of",
"multiple",
"preferences",
"at",
"once",
"."
] |
6c006a3e8e334d8100aab768a2a5e807bcac5695
|
https://github.com/artkonekt/gears/blob/6c006a3e8e334d8100aab768a2a5e807bcac5695/src/Repository/PreferenceRepository.php#L124-L131
|
234,870
|
artkonekt/gears
|
src/Repository/PreferenceRepository.php
|
PreferenceRepository.getPreferenceOrFail
|
protected function getPreferenceOrFail(string $key)
{
if (!$this->registry->has($key)) {
throw new UnregisteredPreferenceException(
sprintf(
'There\'s no setting registered with key `%s`',
$key
)
);
}
return $this->registry->get($key);
}
|
php
|
protected function getPreferenceOrFail(string $key)
{
if (!$this->registry->has($key)) {
throw new UnregisteredPreferenceException(
sprintf(
'There\'s no setting registered with key `%s`',
$key
)
);
}
return $this->registry->get($key);
}
|
[
"protected",
"function",
"getPreferenceOrFail",
"(",
"string",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"registry",
"->",
"has",
"(",
"$",
"key",
")",
")",
"{",
"throw",
"new",
"UnregisteredPreferenceException",
"(",
"sprintf",
"(",
"'There\\'s no setting registered with key `%s`'",
",",
"$",
"key",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"registry",
"->",
"get",
"(",
"$",
"key",
")",
";",
"}"
] |
Returns the preference registered with the given key and throws an exception if not found
@param string $key
@return \Konekt\Gears\Contracts\Preference
@throws UnregisteredPreferenceException
|
[
"Returns",
"the",
"preference",
"registered",
"with",
"the",
"given",
"key",
"and",
"throws",
"an",
"exception",
"if",
"not",
"found"
] |
6c006a3e8e334d8100aab768a2a5e807bcac5695
|
https://github.com/artkonekt/gears/blob/6c006a3e8e334d8100aab768a2a5e807bcac5695/src/Repository/PreferenceRepository.php#L152-L164
|
234,871
|
shopgate/cart-integration-sdk
|
src/helper/error_handling/ErrorHandler.php
|
Shopgate_Helper_Error_Handling_ErrorHandler.handle
|
public function handle(
$severity,
$message,
$file,
$line = -1,
/** @noinspection PhpUnusedParameterInspection */
array $context = array()
) {
// on error supression with '@' do not log
if ($severity === 0) {
return $this->skipInternalErrorHandler;
}
$this->logging->log(
$this->severityName($severity) . ': ' . $message . ' in ' . $file . ' on line ' . $line,
Shopgate_Helper_Logging_Strategy_LoggingInterface::LOGTYPE_ERROR,
$this->stackTraceGenerator->generate(
new Exception('Wrapped around the actual error by Shopgate error handler.')
)
);
return $this->skipInternalErrorHandler;
}
|
php
|
public function handle(
$severity,
$message,
$file,
$line = -1,
/** @noinspection PhpUnusedParameterInspection */
array $context = array()
) {
// on error supression with '@' do not log
if ($severity === 0) {
return $this->skipInternalErrorHandler;
}
$this->logging->log(
$this->severityName($severity) . ': ' . $message . ' in ' . $file . ' on line ' . $line,
Shopgate_Helper_Logging_Strategy_LoggingInterface::LOGTYPE_ERROR,
$this->stackTraceGenerator->generate(
new Exception('Wrapped around the actual error by Shopgate error handler.')
)
);
return $this->skipInternalErrorHandler;
}
|
[
"public",
"function",
"handle",
"(",
"$",
"severity",
",",
"$",
"message",
",",
"$",
"file",
",",
"$",
"line",
"=",
"-",
"1",
",",
"/** @noinspection PhpUnusedParameterInspection */",
"array",
"$",
"context",
"=",
"array",
"(",
")",
")",
"{",
"// on error supression with '@' do not log",
"if",
"(",
"$",
"severity",
"===",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"skipInternalErrorHandler",
";",
"}",
"$",
"this",
"->",
"logging",
"->",
"log",
"(",
"$",
"this",
"->",
"severityName",
"(",
"$",
"severity",
")",
".",
"': '",
".",
"$",
"message",
".",
"' in '",
".",
"$",
"file",
".",
"' on line '",
".",
"$",
"line",
",",
"Shopgate_Helper_Logging_Strategy_LoggingInterface",
"::",
"LOGTYPE_ERROR",
",",
"$",
"this",
"->",
"stackTraceGenerator",
"->",
"generate",
"(",
"new",
"Exception",
"(",
"'Wrapped around the actual error by Shopgate error handler.'",
")",
")",
")",
";",
"return",
"$",
"this",
"->",
"skipInternalErrorHandler",
";",
"}"
] |
Handles non-fatal errors.
This will generate a stack trace and log it to the error log on any error it receives, unless the line in which
the error occured was prefixed with an '@'.
Severity of errors being logged depends on how this handler was set using set_error_handler() and types E_ERROR
E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING and most of E_STRICT cannot be handled
by this handler.
@param int $severity
@param string $message
@param string $file
@param int $line
@param array $context
@return bool
@see http://php.net/manual/en/function.set-error-handler.php
|
[
"Handles",
"non",
"-",
"fatal",
"errors",
"."
] |
cf12ecf8bdb8f4c407209000002fd00261e53b06
|
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/helper/error_handling/ErrorHandler.php#L83-L105
|
234,872
|
tremendus/amazon-mws
|
src/MarketplaceWebServiceOrders/Client.php
|
MarketplaceWebServiceOrders_Client.getServiceStatus
|
public function getServiceStatus($request)
{
if (!($request instanceof MarketplaceWebServiceOrders_Model_GetServiceStatusRequest)) {
// // require_once (dirname(__FILE__) . '/Model/GetServiceStatusRequest.php');
$request = new MarketplaceWebServiceOrders_Model_GetServiceStatusRequest($request);
}
$parameters = $request->toQueryParameterArray();
$parameters['Action'] = 'GetServiceStatus';
$httpResponse = $this->_invoke($parameters);
// // require_once (dirname(__FILE__) . '/Model/GetServiceStatusResponse.php');
$response = MarketplaceWebServiceOrders_Model_GetServiceStatusResponse::fromXML($httpResponse['ResponseBody']);
$response->setResponseHeaderMetadata($httpResponse['ResponseHeaderMetadata']);
return $response;
}
|
php
|
public function getServiceStatus($request)
{
if (!($request instanceof MarketplaceWebServiceOrders_Model_GetServiceStatusRequest)) {
// // require_once (dirname(__FILE__) . '/Model/GetServiceStatusRequest.php');
$request = new MarketplaceWebServiceOrders_Model_GetServiceStatusRequest($request);
}
$parameters = $request->toQueryParameterArray();
$parameters['Action'] = 'GetServiceStatus';
$httpResponse = $this->_invoke($parameters);
// // require_once (dirname(__FILE__) . '/Model/GetServiceStatusResponse.php');
$response = MarketplaceWebServiceOrders_Model_GetServiceStatusResponse::fromXML($httpResponse['ResponseBody']);
$response->setResponseHeaderMetadata($httpResponse['ResponseHeaderMetadata']);
return $response;
}
|
[
"public",
"function",
"getServiceStatus",
"(",
"$",
"request",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"request",
"instanceof",
"MarketplaceWebServiceOrders_Model_GetServiceStatusRequest",
")",
")",
"{",
"// // require_once (dirname(__FILE__) . '/Model/GetServiceStatusRequest.php');",
"$",
"request",
"=",
"new",
"MarketplaceWebServiceOrders_Model_GetServiceStatusRequest",
"(",
"$",
"request",
")",
";",
"}",
"$",
"parameters",
"=",
"$",
"request",
"->",
"toQueryParameterArray",
"(",
")",
";",
"$",
"parameters",
"[",
"'Action'",
"]",
"=",
"'GetServiceStatus'",
";",
"$",
"httpResponse",
"=",
"$",
"this",
"->",
"_invoke",
"(",
"$",
"parameters",
")",
";",
"// // require_once (dirname(__FILE__) . '/Model/GetServiceStatusResponse.php');",
"$",
"response",
"=",
"MarketplaceWebServiceOrders_Model_GetServiceStatusResponse",
"::",
"fromXML",
"(",
"$",
"httpResponse",
"[",
"'ResponseBody'",
"]",
")",
";",
"$",
"response",
"->",
"setResponseHeaderMetadata",
"(",
"$",
"httpResponse",
"[",
"'ResponseHeaderMetadata'",
"]",
")",
";",
"return",
"$",
"response",
";",
"}"
] |
Get Service Status
Returns the service status of a particular MWS API section. The operation
takes no input.
@param mixed $request array of parameters for MarketplaceWebServiceOrders_Model_GetServiceStatus request or MarketplaceWebServiceOrders_Model_GetServiceStatus object itself
@see MarketplaceWebServiceOrders_Model_GetServiceStatusRequest
@return MarketplaceWebServiceOrders_Model_GetServiceStatusResponse
@throws MarketplaceWebServiceOrders_Exception
|
[
"Get",
"Service",
"Status",
"Returns",
"the",
"service",
"status",
"of",
"a",
"particular",
"MWS",
"API",
"section",
".",
"The",
"operation",
"takes",
"no",
"input",
"."
] |
465312b0b75fb91ff9ae4ce63b6c299b6f7e030d
|
https://github.com/tremendus/amazon-mws/blob/465312b0b75fb91ff9ae4ce63b6c299b6f7e030d/src/MarketplaceWebServiceOrders/Client.php#L114-L128
|
234,873
|
tremendus/amazon-mws
|
src/MarketplaceWebServiceOrders/Client.php
|
MarketplaceWebServiceOrders_Client.listOrderItemsByNextToken
|
public function listOrderItemsByNextToken($request)
{
if (!($request instanceof MarketplaceWebServiceOrders_Model_ListOrderItemsByNextTokenRequest)) {
// // require_once (dirname(__FILE__) . '/Model/ListOrderItemsByNextTokenRequest.php');
$request = new MarketplaceWebServiceOrders_Model_ListOrderItemsByNextTokenRequest($request);
}
$parameters = $request->toQueryParameterArray();
$parameters['Action'] = 'ListOrderItemsByNextToken';
$httpResponse = $this->_invoke($parameters);
// // require_once (dirname(__FILE__) . '/Model/ListOrderItemsByNextTokenResponse.php');
$response = MarketplaceWebServiceOrders_Model_ListOrderItemsByNextTokenResponse::fromXML($httpResponse['ResponseBody']);
$response->setResponseHeaderMetadata($httpResponse['ResponseHeaderMetadata']);
return $response;
}
|
php
|
public function listOrderItemsByNextToken($request)
{
if (!($request instanceof MarketplaceWebServiceOrders_Model_ListOrderItemsByNextTokenRequest)) {
// // require_once (dirname(__FILE__) . '/Model/ListOrderItemsByNextTokenRequest.php');
$request = new MarketplaceWebServiceOrders_Model_ListOrderItemsByNextTokenRequest($request);
}
$parameters = $request->toQueryParameterArray();
$parameters['Action'] = 'ListOrderItemsByNextToken';
$httpResponse = $this->_invoke($parameters);
// // require_once (dirname(__FILE__) . '/Model/ListOrderItemsByNextTokenResponse.php');
$response = MarketplaceWebServiceOrders_Model_ListOrderItemsByNextTokenResponse::fromXML($httpResponse['ResponseBody']);
$response->setResponseHeaderMetadata($httpResponse['ResponseHeaderMetadata']);
return $response;
}
|
[
"public",
"function",
"listOrderItemsByNextToken",
"(",
"$",
"request",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"request",
"instanceof",
"MarketplaceWebServiceOrders_Model_ListOrderItemsByNextTokenRequest",
")",
")",
"{",
"// // require_once (dirname(__FILE__) . '/Model/ListOrderItemsByNextTokenRequest.php');",
"$",
"request",
"=",
"new",
"MarketplaceWebServiceOrders_Model_ListOrderItemsByNextTokenRequest",
"(",
"$",
"request",
")",
";",
"}",
"$",
"parameters",
"=",
"$",
"request",
"->",
"toQueryParameterArray",
"(",
")",
";",
"$",
"parameters",
"[",
"'Action'",
"]",
"=",
"'ListOrderItemsByNextToken'",
";",
"$",
"httpResponse",
"=",
"$",
"this",
"->",
"_invoke",
"(",
"$",
"parameters",
")",
";",
"// // require_once (dirname(__FILE__) . '/Model/ListOrderItemsByNextTokenResponse.php');",
"$",
"response",
"=",
"MarketplaceWebServiceOrders_Model_ListOrderItemsByNextTokenResponse",
"::",
"fromXML",
"(",
"$",
"httpResponse",
"[",
"'ResponseBody'",
"]",
")",
";",
"$",
"response",
"->",
"setResponseHeaderMetadata",
"(",
"$",
"httpResponse",
"[",
"'ResponseHeaderMetadata'",
"]",
")",
";",
"return",
"$",
"response",
";",
"}"
] |
List Order Items By Next Token
If ListOrderItems cannot return all the order items in one go, it will
provide a nextToken. That nextToken can be used with this operation to
retrive the next batch of items for that order.
@param mixed $request array of parameters for MarketplaceWebServiceOrders_Model_ListOrderItemsByNextToken request or MarketplaceWebServiceOrders_Model_ListOrderItemsByNextToken object itself
@see MarketplaceWebServiceOrders_Model_ListOrderItemsByNextTokenRequest
@return MarketplaceWebServiceOrders_Model_ListOrderItemsByNextTokenResponse
@throws MarketplaceWebServiceOrders_Exception
|
[
"List",
"Order",
"Items",
"By",
"Next",
"Token",
"If",
"ListOrderItems",
"cannot",
"return",
"all",
"the",
"order",
"items",
"in",
"one",
"go",
"it",
"will",
"provide",
"a",
"nextToken",
".",
"That",
"nextToken",
"can",
"be",
"used",
"with",
"this",
"operation",
"to",
"retrive",
"the",
"next",
"batch",
"of",
"items",
"for",
"that",
"order",
"."
] |
465312b0b75fb91ff9ae4ce63b6c299b6f7e030d
|
https://github.com/tremendus/amazon-mws/blob/465312b0b75fb91ff9ae4ce63b6c299b6f7e030d/src/MarketplaceWebServiceOrders/Client.php#L210-L224
|
234,874
|
stephweb/daw-php-orm
|
src/DawPhpOrm/Support/String/Str.php
|
Str.convertCamelCaseToSnakeCase
|
public static function convertCamelCaseToSnakeCase(string $value): string
{
if (isset(self::$snakeCache[$value])) {
return self::$snakeCache[$value];
}
$withUpperArray = str_split($value);
$snake_case = '';
foreach ($withUpperArray as $letter) {
if (preg_match("/[A-Z]/", $letter)) {
$snake_case .= '_'.mb_strtolower($letter);
} else {
$snake_case .= $letter;
}
}
return self::$snakeCache[$value] = $snake_case;
}
|
php
|
public static function convertCamelCaseToSnakeCase(string $value): string
{
if (isset(self::$snakeCache[$value])) {
return self::$snakeCache[$value];
}
$withUpperArray = str_split($value);
$snake_case = '';
foreach ($withUpperArray as $letter) {
if (preg_match("/[A-Z]/", $letter)) {
$snake_case .= '_'.mb_strtolower($letter);
} else {
$snake_case .= $letter;
}
}
return self::$snakeCache[$value] = $snake_case;
}
|
[
"public",
"static",
"function",
"convertCamelCaseToSnakeCase",
"(",
"string",
"$",
"value",
")",
":",
"string",
"{",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"snakeCache",
"[",
"$",
"value",
"]",
")",
")",
"{",
"return",
"self",
"::",
"$",
"snakeCache",
"[",
"$",
"value",
"]",
";",
"}",
"$",
"withUpperArray",
"=",
"str_split",
"(",
"$",
"value",
")",
";",
"$",
"snake_case",
"=",
"''",
";",
"foreach",
"(",
"$",
"withUpperArray",
"as",
"$",
"letter",
")",
"{",
"if",
"(",
"preg_match",
"(",
"\"/[A-Z]/\"",
",",
"$",
"letter",
")",
")",
"{",
"$",
"snake_case",
".=",
"'_'",
".",
"mb_strtolower",
"(",
"$",
"letter",
")",
";",
"}",
"else",
"{",
"$",
"snake_case",
".=",
"$",
"letter",
";",
"}",
"}",
"return",
"self",
"::",
"$",
"snakeCache",
"[",
"$",
"value",
"]",
"=",
"$",
"snake_case",
";",
"}"
] |
Pour remplacer format camelCase par format snake_case
@param string $value - snake_case
@return string
|
[
"Pour",
"remplacer",
"format",
"camelCase",
"par",
"format",
"snake_case"
] |
0c37e3baa1420cf9e3feff122016329de3764bcc
|
https://github.com/stephweb/daw-php-orm/blob/0c37e3baa1420cf9e3feff122016329de3764bcc/src/DawPhpOrm/Support/String/Str.php#L41-L59
|
234,875
|
stephweb/daw-php-orm
|
src/DawPhpOrm/Support/String/Str.php
|
Str.snakePlural
|
public static function snakePlural(string $value): string
{
if (isset(self::$snakePluralCache[$value])) {
return self::$snakePluralCache[$value];
}
$snake_case = self::convertCamelCaseToSnakeCase($value);
$snakeCaseEx = explode('_', $snake_case);
$plural = '';
foreach ($snakeCaseEx as $word) {
if ($word !== '') {
if (substr($word, -1, mb_strlen($word)) === 'y') { // si finit par "y" ...
$w = substr($word, 0, -1);
$test = substr($word, -2, mb_strlen($word));
if (preg_match("/^[BCDFGHJKLMNPQRSTVWXZ]+y$/i", $test)) {
$plural .= '_'.$w.'ies'; // ... si finit par "consonne + y" -> mettre "ies" à la place
} else {
$plural .= '_'.$word.'s'; // ... si finit par "voyelle + y" -> mettre "ys" à la place
}
} elseif (substr($word, -1, mb_strlen($word)) === 'o') {
$plural .= '_'.$word.'es'; // si finit par "o" -> mettre "oes" à la place
} else {
$plural .= '_'.$word.'s'; // si non, ajouter un "s"
}
}
}
return self::$snakePluralCache[$value] = trim($plural, '_');
}
|
php
|
public static function snakePlural(string $value): string
{
if (isset(self::$snakePluralCache[$value])) {
return self::$snakePluralCache[$value];
}
$snake_case = self::convertCamelCaseToSnakeCase($value);
$snakeCaseEx = explode('_', $snake_case);
$plural = '';
foreach ($snakeCaseEx as $word) {
if ($word !== '') {
if (substr($word, -1, mb_strlen($word)) === 'y') { // si finit par "y" ...
$w = substr($word, 0, -1);
$test = substr($word, -2, mb_strlen($word));
if (preg_match("/^[BCDFGHJKLMNPQRSTVWXZ]+y$/i", $test)) {
$plural .= '_'.$w.'ies'; // ... si finit par "consonne + y" -> mettre "ies" à la place
} else {
$plural .= '_'.$word.'s'; // ... si finit par "voyelle + y" -> mettre "ys" à la place
}
} elseif (substr($word, -1, mb_strlen($word)) === 'o') {
$plural .= '_'.$word.'es'; // si finit par "o" -> mettre "oes" à la place
} else {
$plural .= '_'.$word.'s'; // si non, ajouter un "s"
}
}
}
return self::$snakePluralCache[$value] = trim($plural, '_');
}
|
[
"public",
"static",
"function",
"snakePlural",
"(",
"string",
"$",
"value",
")",
":",
"string",
"{",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"snakePluralCache",
"[",
"$",
"value",
"]",
")",
")",
"{",
"return",
"self",
"::",
"$",
"snakePluralCache",
"[",
"$",
"value",
"]",
";",
"}",
"$",
"snake_case",
"=",
"self",
"::",
"convertCamelCaseToSnakeCase",
"(",
"$",
"value",
")",
";",
"$",
"snakeCaseEx",
"=",
"explode",
"(",
"'_'",
",",
"$",
"snake_case",
")",
";",
"$",
"plural",
"=",
"''",
";",
"foreach",
"(",
"$",
"snakeCaseEx",
"as",
"$",
"word",
")",
"{",
"if",
"(",
"$",
"word",
"!==",
"''",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"word",
",",
"-",
"1",
",",
"mb_strlen",
"(",
"$",
"word",
")",
")",
"===",
"'y'",
")",
"{",
"// si finit par \"y\" ...\r",
"$",
"w",
"=",
"substr",
"(",
"$",
"word",
",",
"0",
",",
"-",
"1",
")",
";",
"$",
"test",
"=",
"substr",
"(",
"$",
"word",
",",
"-",
"2",
",",
"mb_strlen",
"(",
"$",
"word",
")",
")",
";",
"if",
"(",
"preg_match",
"(",
"\"/^[BCDFGHJKLMNPQRSTVWXZ]+y$/i\"",
",",
"$",
"test",
")",
")",
"{",
"$",
"plural",
".=",
"'_'",
".",
"$",
"w",
".",
"'ies'",
";",
"// ... si finit par \"consonne + y\" -> mettre \"ies\" à la place\r",
"}",
"else",
"{",
"$",
"plural",
".=",
"'_'",
".",
"$",
"word",
".",
"'s'",
";",
"// ... si finit par \"voyelle + y\" -> mettre \"ys\" à la place\r",
"}",
"}",
"elseif",
"(",
"substr",
"(",
"$",
"word",
",",
"-",
"1",
",",
"mb_strlen",
"(",
"$",
"word",
")",
")",
"===",
"'o'",
")",
"{",
"$",
"plural",
".=",
"'_'",
".",
"$",
"word",
".",
"'es'",
";",
"// si finit par \"o\" -> mettre \"oes\" à la place\r",
"}",
"else",
"{",
"$",
"plural",
".=",
"'_'",
".",
"$",
"word",
".",
"'s'",
";",
"// si non, ajouter un \"s\"\r",
"}",
"}",
"}",
"return",
"self",
"::",
"$",
"snakePluralCache",
"[",
"$",
"value",
"]",
"=",
"trim",
"(",
"$",
"plural",
",",
"'_'",
")",
";",
"}"
] |
Obtenir en snake_case la forme plurielle d'un mot anglais
@param string $value
@return string
|
[
"Obtenir",
"en",
"snake_case",
"la",
"forme",
"plurielle",
"d",
"un",
"mot",
"anglais"
] |
0c37e3baa1420cf9e3feff122016329de3764bcc
|
https://github.com/stephweb/daw-php-orm/blob/0c37e3baa1420cf9e3feff122016329de3764bcc/src/DawPhpOrm/Support/String/Str.php#L67-L96
|
234,876
|
stephweb/daw-php-orm
|
src/DawPhpOrm/Support/String/Str.php
|
Str.convertSnakeCaseToCamelCase
|
public static function convertSnakeCaseToCamelCase(string $value): string
{
if (isset(self::$camelCache[$value])) {
return self::$camelCache[$value];
}
return self::$camelCache[$value] = str_replace(' ', '', ucwords(str_replace('_', ' ', $value)));
}
|
php
|
public static function convertSnakeCaseToCamelCase(string $value): string
{
if (isset(self::$camelCache[$value])) {
return self::$camelCache[$value];
}
return self::$camelCache[$value] = str_replace(' ', '', ucwords(str_replace('_', ' ', $value)));
}
|
[
"public",
"static",
"function",
"convertSnakeCaseToCamelCase",
"(",
"string",
"$",
"value",
")",
":",
"string",
"{",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"camelCache",
"[",
"$",
"value",
"]",
")",
")",
"{",
"return",
"self",
"::",
"$",
"camelCache",
"[",
"$",
"value",
"]",
";",
"}",
"return",
"self",
"::",
"$",
"camelCache",
"[",
"$",
"value",
"]",
"=",
"str_replace",
"(",
"' '",
",",
"''",
",",
"ucwords",
"(",
"str_replace",
"(",
"'_'",
",",
"' '",
",",
"$",
"value",
")",
")",
")",
";",
"}"
] |
Pour remplacer format snake_case par format camelCase
@param string $value - camelCase
@return string
|
[
"Pour",
"remplacer",
"format",
"snake_case",
"par",
"format",
"camelCase"
] |
0c37e3baa1420cf9e3feff122016329de3764bcc
|
https://github.com/stephweb/daw-php-orm/blob/0c37e3baa1420cf9e3feff122016329de3764bcc/src/DawPhpOrm/Support/String/Str.php#L104-L111
|
234,877
|
accompli/accompli
|
src/DataCollector/EventDataCollector.php
|
EventDataCollector.hasCountedLogLevel
|
public function hasCountedLogLevel($logLevel)
{
if (isset($this->logLevelCount[$logLevel])) {
return $this->logLevelCount[$logLevel] > 0;
}
return false;
}
|
php
|
public function hasCountedLogLevel($logLevel)
{
if (isset($this->logLevelCount[$logLevel])) {
return $this->logLevelCount[$logLevel] > 0;
}
return false;
}
|
[
"public",
"function",
"hasCountedLogLevel",
"(",
"$",
"logLevel",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"logLevelCount",
"[",
"$",
"logLevel",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"logLevelCount",
"[",
"$",
"logLevel",
"]",
">",
"0",
";",
"}",
"return",
"false",
";",
"}"
] |
Returns true if LogEvent instances are counted for a certain LogLevel.
@param string $logLevel
@return bool
|
[
"Returns",
"true",
"if",
"LogEvent",
"instances",
"are",
"counted",
"for",
"a",
"certain",
"LogLevel",
"."
] |
618f28377448d8caa90d63bfa5865a3ee15e49e7
|
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/DataCollector/EventDataCollector.php#L60-L67
|
234,878
|
makinacorpus/drupal-ucms
|
ucms_search/src/SearchFactory.php
|
SearchFactory.create
|
public function create($index)
{
$realname = $this->storage->getIndexRealname($index);
$search = (new Search($this->client))->setIndex($realname);
if ($this->dispatcher) {
$this->dispatcher->dispatch('ucms_search.search_create', new GenericEvent($search));
}
return $search;
}
|
php
|
public function create($index)
{
$realname = $this->storage->getIndexRealname($index);
$search = (new Search($this->client))->setIndex($realname);
if ($this->dispatcher) {
$this->dispatcher->dispatch('ucms_search.search_create', new GenericEvent($search));
}
return $search;
}
|
[
"public",
"function",
"create",
"(",
"$",
"index",
")",
"{",
"$",
"realname",
"=",
"$",
"this",
"->",
"storage",
"->",
"getIndexRealname",
"(",
"$",
"index",
")",
";",
"$",
"search",
"=",
"(",
"new",
"Search",
"(",
"$",
"this",
"->",
"client",
")",
")",
"->",
"setIndex",
"(",
"$",
"realname",
")",
";",
"if",
"(",
"$",
"this",
"->",
"dispatcher",
")",
"{",
"$",
"this",
"->",
"dispatcher",
"->",
"dispatch",
"(",
"'ucms_search.search_create'",
",",
"new",
"GenericEvent",
"(",
"$",
"search",
")",
")",
";",
"}",
"return",
"$",
"search",
";",
"}"
] |
Create a new search
@param string $index
@return Search
|
[
"Create",
"a",
"new",
"search"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_search/src/SearchFactory.php#L46-L57
|
234,879
|
runcmf/runbb
|
src/RunBB/Model/Forum.php
|
Forum.getForumInfo
|
public function getForumInfo($id)
{
$id = Container::get('hooks')->fire('model.forum.get_info_forum_start', $id);
$cur_forum['where'] = [
['fp.read_forum' => 'IS NULL'],
['fp.read_forum' => '1']
];
if (!User::get()->is_guest) {
$cur_forum['select'] = [
'f.forum_name',
'f.redirect_url',
'f.moderators',
'f.num_topics',
'f.sort_by',
'fp.post_topics',
'is_subscribed' => 's.user_id'
];
$cur_forum = DB::forTable('forums')->table_alias('f')
->select_many($cur_forum['select'])
// ->left_outer_join(DB::prefix().'forum_subscriptions',
// array('f.id', '=', 's.forum_id'), 's')
// ->left_outer_join(DB::prefix().'forum_subscriptions',
// array('s.user_id', '=', User::get()->id), null, true)
->left_outer_join(
DB::prefix().'forum_subscriptions',
'(f.id = s.forum_id AND s.user_id = '.User::get()->id.')',
's'
)
// ->left_outer_join(DB::prefix().'forum_perms',
// array('fp.forum_id', '=', 'f.id'), 'fp')
// ->left_outer_join(DB::prefix().'forum_perms',
// array('fp.group_id', '=', User::get()->g_id), null, true)
->left_outer_join(
DB::prefix().'forum_perms',
'(fp.forum_id = f.id AND fp.group_id = '.User::get()->g_id.')',
'fp'
)
->where_raw('(fp.read_forum IS NULL OR fp.read_forum=1)')
// ->where_any_is($cur_forum['where'])
->where('f.id', $id);
} else {
$cur_forum['select'] = [
'f.forum_name',
'f.redirect_url',
'f.moderators',
'f.num_topics',
'f.sort_by',
'fp.post_topics'
];
$cur_forum = DB::forTable('forums')->table_alias('f')
->select_many($cur_forum['select'])
->select_expr(0, 'is_subscribed')
// ->left_outer_join(DB::prefix().'forum_perms',
// array('fp.forum_id', '=', 'f.id'), 'fp')
// ->left_outer_join(DB::prefix().'forum_perms',
// array('fp.group_id', '=', User::get()->g_id), null, true)
->left_outer_join(
DB::prefix().'forum_perms',
'(fp.forum_id = f.id AND fp.group_id = '.User::get()->g_id.')',
'fp'
)
// ->where_any_is($cur_forum['where'])
->where_raw('(fp.read_forum IS NULL OR fp.read_forum=1)')
->where('f.id', $id);
}
$cur_forum = Container::get('hooks')->fireDB('model.forum.get_info_forum_query', $cur_forum);
$cur_forum = $cur_forum->find_one();
if (!$cur_forum) {
throw new RunBBException(__('Bad request'), '404');
}
$cur_forum = Container::get('hooks')->fire('model.forum.get_info_forum', $cur_forum);
return $cur_forum;
}
|
php
|
public function getForumInfo($id)
{
$id = Container::get('hooks')->fire('model.forum.get_info_forum_start', $id);
$cur_forum['where'] = [
['fp.read_forum' => 'IS NULL'],
['fp.read_forum' => '1']
];
if (!User::get()->is_guest) {
$cur_forum['select'] = [
'f.forum_name',
'f.redirect_url',
'f.moderators',
'f.num_topics',
'f.sort_by',
'fp.post_topics',
'is_subscribed' => 's.user_id'
];
$cur_forum = DB::forTable('forums')->table_alias('f')
->select_many($cur_forum['select'])
// ->left_outer_join(DB::prefix().'forum_subscriptions',
// array('f.id', '=', 's.forum_id'), 's')
// ->left_outer_join(DB::prefix().'forum_subscriptions',
// array('s.user_id', '=', User::get()->id), null, true)
->left_outer_join(
DB::prefix().'forum_subscriptions',
'(f.id = s.forum_id AND s.user_id = '.User::get()->id.')',
's'
)
// ->left_outer_join(DB::prefix().'forum_perms',
// array('fp.forum_id', '=', 'f.id'), 'fp')
// ->left_outer_join(DB::prefix().'forum_perms',
// array('fp.group_id', '=', User::get()->g_id), null, true)
->left_outer_join(
DB::prefix().'forum_perms',
'(fp.forum_id = f.id AND fp.group_id = '.User::get()->g_id.')',
'fp'
)
->where_raw('(fp.read_forum IS NULL OR fp.read_forum=1)')
// ->where_any_is($cur_forum['where'])
->where('f.id', $id);
} else {
$cur_forum['select'] = [
'f.forum_name',
'f.redirect_url',
'f.moderators',
'f.num_topics',
'f.sort_by',
'fp.post_topics'
];
$cur_forum = DB::forTable('forums')->table_alias('f')
->select_many($cur_forum['select'])
->select_expr(0, 'is_subscribed')
// ->left_outer_join(DB::prefix().'forum_perms',
// array('fp.forum_id', '=', 'f.id'), 'fp')
// ->left_outer_join(DB::prefix().'forum_perms',
// array('fp.group_id', '=', User::get()->g_id), null, true)
->left_outer_join(
DB::prefix().'forum_perms',
'(fp.forum_id = f.id AND fp.group_id = '.User::get()->g_id.')',
'fp'
)
// ->where_any_is($cur_forum['where'])
->where_raw('(fp.read_forum IS NULL OR fp.read_forum=1)')
->where('f.id', $id);
}
$cur_forum = Container::get('hooks')->fireDB('model.forum.get_info_forum_query', $cur_forum);
$cur_forum = $cur_forum->find_one();
if (!$cur_forum) {
throw new RunBBException(__('Bad request'), '404');
}
$cur_forum = Container::get('hooks')->fire('model.forum.get_info_forum', $cur_forum);
return $cur_forum;
}
|
[
"public",
"function",
"getForumInfo",
"(",
"$",
"id",
")",
"{",
"$",
"id",
"=",
"Container",
"::",
"get",
"(",
"'hooks'",
")",
"->",
"fire",
"(",
"'model.forum.get_info_forum_start'",
",",
"$",
"id",
")",
";",
"$",
"cur_forum",
"[",
"'where'",
"]",
"=",
"[",
"[",
"'fp.read_forum'",
"=>",
"'IS NULL'",
"]",
",",
"[",
"'fp.read_forum'",
"=>",
"'1'",
"]",
"]",
";",
"if",
"(",
"!",
"User",
"::",
"get",
"(",
")",
"->",
"is_guest",
")",
"{",
"$",
"cur_forum",
"[",
"'select'",
"]",
"=",
"[",
"'f.forum_name'",
",",
"'f.redirect_url'",
",",
"'f.moderators'",
",",
"'f.num_topics'",
",",
"'f.sort_by'",
",",
"'fp.post_topics'",
",",
"'is_subscribed'",
"=>",
"'s.user_id'",
"]",
";",
"$",
"cur_forum",
"=",
"DB",
"::",
"forTable",
"(",
"'forums'",
")",
"->",
"table_alias",
"(",
"'f'",
")",
"->",
"select_many",
"(",
"$",
"cur_forum",
"[",
"'select'",
"]",
")",
"// ->left_outer_join(DB::prefix().'forum_subscriptions',",
"// array('f.id', '=', 's.forum_id'), 's')",
"// ->left_outer_join(DB::prefix().'forum_subscriptions',",
"// array('s.user_id', '=', User::get()->id), null, true)",
"->",
"left_outer_join",
"(",
"DB",
"::",
"prefix",
"(",
")",
".",
"'forum_subscriptions'",
",",
"'(f.id = s.forum_id AND s.user_id = '",
".",
"User",
"::",
"get",
"(",
")",
"->",
"id",
".",
"')'",
",",
"'s'",
")",
"// ->left_outer_join(DB::prefix().'forum_perms',",
"// array('fp.forum_id', '=', 'f.id'), 'fp')",
"// ->left_outer_join(DB::prefix().'forum_perms',",
"// array('fp.group_id', '=', User::get()->g_id), null, true)",
"->",
"left_outer_join",
"(",
"DB",
"::",
"prefix",
"(",
")",
".",
"'forum_perms'",
",",
"'(fp.forum_id = f.id AND fp.group_id = '",
".",
"User",
"::",
"get",
"(",
")",
"->",
"g_id",
".",
"')'",
",",
"'fp'",
")",
"->",
"where_raw",
"(",
"'(fp.read_forum IS NULL OR fp.read_forum=1)'",
")",
"// ->where_any_is($cur_forum['where'])",
"->",
"where",
"(",
"'f.id'",
",",
"$",
"id",
")",
";",
"}",
"else",
"{",
"$",
"cur_forum",
"[",
"'select'",
"]",
"=",
"[",
"'f.forum_name'",
",",
"'f.redirect_url'",
",",
"'f.moderators'",
",",
"'f.num_topics'",
",",
"'f.sort_by'",
",",
"'fp.post_topics'",
"]",
";",
"$",
"cur_forum",
"=",
"DB",
"::",
"forTable",
"(",
"'forums'",
")",
"->",
"table_alias",
"(",
"'f'",
")",
"->",
"select_many",
"(",
"$",
"cur_forum",
"[",
"'select'",
"]",
")",
"->",
"select_expr",
"(",
"0",
",",
"'is_subscribed'",
")",
"// ->left_outer_join(DB::prefix().'forum_perms',",
"// array('fp.forum_id', '=', 'f.id'), 'fp')",
"// ->left_outer_join(DB::prefix().'forum_perms',",
"// array('fp.group_id', '=', User::get()->g_id), null, true)",
"->",
"left_outer_join",
"(",
"DB",
"::",
"prefix",
"(",
")",
".",
"'forum_perms'",
",",
"'(fp.forum_id = f.id AND fp.group_id = '",
".",
"User",
"::",
"get",
"(",
")",
"->",
"g_id",
".",
"')'",
",",
"'fp'",
")",
"// ->where_any_is($cur_forum['where'])",
"->",
"where_raw",
"(",
"'(fp.read_forum IS NULL OR fp.read_forum=1)'",
")",
"->",
"where",
"(",
"'f.id'",
",",
"$",
"id",
")",
";",
"}",
"$",
"cur_forum",
"=",
"Container",
"::",
"get",
"(",
"'hooks'",
")",
"->",
"fireDB",
"(",
"'model.forum.get_info_forum_query'",
",",
"$",
"cur_forum",
")",
";",
"$",
"cur_forum",
"=",
"$",
"cur_forum",
"->",
"find_one",
"(",
")",
";",
"if",
"(",
"!",
"$",
"cur_forum",
")",
"{",
"throw",
"new",
"RunBBException",
"(",
"__",
"(",
"'Bad request'",
")",
",",
"'404'",
")",
";",
"}",
"$",
"cur_forum",
"=",
"Container",
"::",
"get",
"(",
"'hooks'",
")",
"->",
"fire",
"(",
"'model.forum.get_info_forum'",
",",
"$",
"cur_forum",
")",
";",
"return",
"$",
"cur_forum",
";",
"}"
] |
Returns basic informations about the forum
|
[
"Returns",
"basic",
"informations",
"about",
"the",
"forum"
] |
d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463
|
https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Model/Forum.php#L20-L100
|
234,880
|
runcmf/runbb
|
src/RunBB/Model/Forum.php
|
Forum.sortForumBy
|
public function sortForumBy($sort_by_sql)
{
$sort_by_sql = Container::get('hooks')->fire('model.forum.sort_forum_by_start', $sort_by_sql);
switch ($sort_by_sql) {
case 0:
$sort_by = 'last_post DESC';
break;
case 1:
$sort_by = 'posted DESC';
break;
case 2:
$sort_by = 'subject ASC';
break;
default:
$sort_by = 'last_post DESC';
break;
}
$sort_by = Container::get('hooks')->fire('model.forum.sort_forum_by', $sort_by);
return $sort_by;
}
|
php
|
public function sortForumBy($sort_by_sql)
{
$sort_by_sql = Container::get('hooks')->fire('model.forum.sort_forum_by_start', $sort_by_sql);
switch ($sort_by_sql) {
case 0:
$sort_by = 'last_post DESC';
break;
case 1:
$sort_by = 'posted DESC';
break;
case 2:
$sort_by = 'subject ASC';
break;
default:
$sort_by = 'last_post DESC';
break;
}
$sort_by = Container::get('hooks')->fire('model.forum.sort_forum_by', $sort_by);
return $sort_by;
}
|
[
"public",
"function",
"sortForumBy",
"(",
"$",
"sort_by_sql",
")",
"{",
"$",
"sort_by_sql",
"=",
"Container",
"::",
"get",
"(",
"'hooks'",
")",
"->",
"fire",
"(",
"'model.forum.sort_forum_by_start'",
",",
"$",
"sort_by_sql",
")",
";",
"switch",
"(",
"$",
"sort_by_sql",
")",
"{",
"case",
"0",
":",
"$",
"sort_by",
"=",
"'last_post DESC'",
";",
"break",
";",
"case",
"1",
":",
"$",
"sort_by",
"=",
"'posted DESC'",
";",
"break",
";",
"case",
"2",
":",
"$",
"sort_by",
"=",
"'subject ASC'",
";",
"break",
";",
"default",
":",
"$",
"sort_by",
"=",
"'last_post DESC'",
";",
"break",
";",
"}",
"$",
"sort_by",
"=",
"Container",
"::",
"get",
"(",
"'hooks'",
")",
"->",
"fire",
"(",
"'model.forum.sort_forum_by'",
",",
"$",
"sort_by",
")",
";",
"return",
"$",
"sort_by",
";",
"}"
] |
Returns the text required by the query to sort the forum
|
[
"Returns",
"the",
"text",
"required",
"by",
"the",
"query",
"to",
"sort",
"the",
"forum"
] |
d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463
|
https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Model/Forum.php#L118-L140
|
234,881
|
jonnnnyw/craft-awss3assets
|
src/JonnyW/AWSS3Assets/S3Bucket.php
|
S3Bucket.getInstance
|
public static function getInstance($region, $name, $key = null, $secret = null)
{
if (!self::$instance instanceof \JonnyW\AWSS3Assets\S3Bucket) {
$args = array(
'version' => 'latest',
'region' => $region
);
if (!empty($key) && !empty($secret)) {
$args['credentials'] = new Credentials($key, $secret);
}
$client = new S3Client($args);
self::$instance = new static(
$client,
$name
);
}
return self::$instance;
}
|
php
|
public static function getInstance($region, $name, $key = null, $secret = null)
{
if (!self::$instance instanceof \JonnyW\AWSS3Assets\S3Bucket) {
$args = array(
'version' => 'latest',
'region' => $region
);
if (!empty($key) && !empty($secret)) {
$args['credentials'] = new Credentials($key, $secret);
}
$client = new S3Client($args);
self::$instance = new static(
$client,
$name
);
}
return self::$instance;
}
|
[
"public",
"static",
"function",
"getInstance",
"(",
"$",
"region",
",",
"$",
"name",
",",
"$",
"key",
"=",
"null",
",",
"$",
"secret",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"$",
"instance",
"instanceof",
"\\",
"JonnyW",
"\\",
"AWSS3Assets",
"\\",
"S3Bucket",
")",
"{",
"$",
"args",
"=",
"array",
"(",
"'version'",
"=>",
"'latest'",
",",
"'region'",
"=>",
"$",
"region",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"key",
")",
"&&",
"!",
"empty",
"(",
"$",
"secret",
")",
")",
"{",
"$",
"args",
"[",
"'credentials'",
"]",
"=",
"new",
"Credentials",
"(",
"$",
"key",
",",
"$",
"secret",
")",
";",
"}",
"$",
"client",
"=",
"new",
"S3Client",
"(",
"$",
"args",
")",
";",
"self",
"::",
"$",
"instance",
"=",
"new",
"static",
"(",
"$",
"client",
",",
"$",
"name",
")",
";",
"}",
"return",
"self",
"::",
"$",
"instance",
";",
"}"
] |
Get singleton instance.
@access public
@static
@param string $region
@param string $name
@param string $key (default: null)
@param string $secret (default: null)
@return \JonnyW\AWSS3Assets\S3Bucket
|
[
"Get",
"singleton",
"instance",
"."
] |
6bc146a8f3496f148c28d431cd8a9e7dc8199a9d
|
https://github.com/jonnnnyw/craft-awss3assets/blob/6bc146a8f3496f148c28d431cd8a9e7dc8199a9d/src/JonnyW/AWSS3Assets/S3Bucket.php#L71-L93
|
234,882
|
jonnnnyw/craft-awss3assets
|
src/JonnyW/AWSS3Assets/S3Bucket.php
|
S3Bucket.cp
|
public function cp($path, $filename)
{
if (!file_exists($path)) {
return false;
}
$type = mime_content_type($path);
$handle = fopen($path, 'r');
$body = fread($handle, filesize($path));
fclose($handle);
$result = $this->client
->putObject(array(
'Bucket' => $this->name,
'Key' => $filename,
'ContentType' => $type,
'Body' => $body
));
return $result;
}
|
php
|
public function cp($path, $filename)
{
if (!file_exists($path)) {
return false;
}
$type = mime_content_type($path);
$handle = fopen($path, 'r');
$body = fread($handle, filesize($path));
fclose($handle);
$result = $this->client
->putObject(array(
'Bucket' => $this->name,
'Key' => $filename,
'ContentType' => $type,
'Body' => $body
));
return $result;
}
|
[
"public",
"function",
"cp",
"(",
"$",
"path",
",",
"$",
"filename",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"type",
"=",
"mime_content_type",
"(",
"$",
"path",
")",
";",
"$",
"handle",
"=",
"fopen",
"(",
"$",
"path",
",",
"'r'",
")",
";",
"$",
"body",
"=",
"fread",
"(",
"$",
"handle",
",",
"filesize",
"(",
"$",
"path",
")",
")",
";",
"fclose",
"(",
"$",
"handle",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"client",
"->",
"putObject",
"(",
"array",
"(",
"'Bucket'",
"=>",
"$",
"this",
"->",
"name",
",",
"'Key'",
"=>",
"$",
"filename",
",",
"'ContentType'",
"=>",
"$",
"type",
",",
"'Body'",
"=>",
"$",
"body",
")",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Copy media.
@access public
@param string $path
@param string $filename
@return \Aws\Result|false
|
[
"Copy",
"media",
"."
] |
6bc146a8f3496f148c28d431cd8a9e7dc8199a9d
|
https://github.com/jonnnnyw/craft-awss3assets/blob/6bc146a8f3496f148c28d431cd8a9e7dc8199a9d/src/JonnyW/AWSS3Assets/S3Bucket.php#L103-L125
|
234,883
|
jonnnnyw/craft-awss3assets
|
src/JonnyW/AWSS3Assets/S3Bucket.php
|
S3Bucket.rm
|
public function rm($filename)
{
$result = $this->client
->deleteObject(array(
'Bucket' => $this->name,
'Key' => $filename
));
return $result;
}
|
php
|
public function rm($filename)
{
$result = $this->client
->deleteObject(array(
'Bucket' => $this->name,
'Key' => $filename
));
return $result;
}
|
[
"public",
"function",
"rm",
"(",
"$",
"filename",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"client",
"->",
"deleteObject",
"(",
"array",
"(",
"'Bucket'",
"=>",
"$",
"this",
"->",
"name",
",",
"'Key'",
"=>",
"$",
"filename",
")",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Remove media.
@access public
@param string $filename
@return \Aws\Result
|
[
"Remove",
"media",
"."
] |
6bc146a8f3496f148c28d431cd8a9e7dc8199a9d
|
https://github.com/jonnnnyw/craft-awss3assets/blob/6bc146a8f3496f148c28d431cd8a9e7dc8199a9d/src/JonnyW/AWSS3Assets/S3Bucket.php#L134-L143
|
234,884
|
runcmf/runbb
|
src/RunBB/Controller/Install.php
|
Install.getLangs
|
public static function getLangs($folder = '')
{
$langs = [];
$iterator = new \DirectoryIterator(ForumEnv::get('FORUM_ROOT').'lang/');
foreach ($iterator as $child) {
if (!$child->isDot() && $child->isDir() &&
file_exists($child->getPathname().DIRECTORY_SEPARATOR.'install.po')) {
// If the lang pack is well formed, add it to the list
$langs[] = $child->getFileName();
}
}
natcasesort($langs);
return $langs;
}
|
php
|
public static function getLangs($folder = '')
{
$langs = [];
$iterator = new \DirectoryIterator(ForumEnv::get('FORUM_ROOT').'lang/');
foreach ($iterator as $child) {
if (!$child->isDot() && $child->isDir() &&
file_exists($child->getPathname().DIRECTORY_SEPARATOR.'install.po')) {
// If the lang pack is well formed, add it to the list
$langs[] = $child->getFileName();
}
}
natcasesort($langs);
return $langs;
}
|
[
"public",
"static",
"function",
"getLangs",
"(",
"$",
"folder",
"=",
"''",
")",
"{",
"$",
"langs",
"=",
"[",
"]",
";",
"$",
"iterator",
"=",
"new",
"\\",
"DirectoryIterator",
"(",
"ForumEnv",
"::",
"get",
"(",
"'FORUM_ROOT'",
")",
".",
"'lang/'",
")",
";",
"foreach",
"(",
"$",
"iterator",
"as",
"$",
"child",
")",
"{",
"if",
"(",
"!",
"$",
"child",
"->",
"isDot",
"(",
")",
"&&",
"$",
"child",
"->",
"isDir",
"(",
")",
"&&",
"file_exists",
"(",
"$",
"child",
"->",
"getPathname",
"(",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"'install.po'",
")",
")",
"{",
"// If the lang pack is well formed, add it to the list",
"$",
"langs",
"[",
"]",
"=",
"$",
"child",
"->",
"getFileName",
"(",
")",
";",
"}",
"}",
"natcasesort",
"(",
"$",
"langs",
")",
";",
"return",
"$",
"langs",
";",
"}"
] |
Get available langs
|
[
"Get",
"available",
"langs"
] |
d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463
|
https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Controller/Install.php#L447-L462
|
234,885
|
shopgate/cart-integration-sdk
|
src/models/XmlResultObject.php
|
Shopgate_Model_XmlResultObject.addAttribute
|
public function addAttribute($name, $value = null, $namespace = null)
{
if (isset($value)) {
parent::addAttribute($name, $value, $namespace);
}
}
|
php
|
public function addAttribute($name, $value = null, $namespace = null)
{
if (isset($value)) {
parent::addAttribute($name, $value, $namespace);
}
}
|
[
"public",
"function",
"addAttribute",
"(",
"$",
"name",
",",
"$",
"value",
"=",
"null",
",",
"$",
"namespace",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"value",
")",
")",
"{",
"parent",
"::",
"addAttribute",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"namespace",
")",
";",
"}",
"}"
] |
Adds an attribute to the SimpleXML element is value not empty
@param string $name
@param string $value
@param string $namespace
|
[
"Adds",
"an",
"attribute",
"to",
"the",
"SimpleXML",
"element",
"is",
"value",
"not",
"empty"
] |
cf12ecf8bdb8f4c407209000002fd00261e53b06
|
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/models/XmlResultObject.php#L114-L119
|
234,886
|
makinacorpus/drupal-ucms
|
ucms_user/src/TokenManager.php
|
TokenManager.createToken
|
public function createToken(AccountInterface $user)
{
$lifespan = variable_get('user_password_reset_timeout', 86400);
$token = new Token();
$token->uid = $user->id();
$token->expiration_date = (new \DateTime())->add(new \DateInterval('PT' . $lifespan . 'S'));
$token->generateKey();
$this->saveToken($token);
return $token;
}
|
php
|
public function createToken(AccountInterface $user)
{
$lifespan = variable_get('user_password_reset_timeout', 86400);
$token = new Token();
$token->uid = $user->id();
$token->expiration_date = (new \DateTime())->add(new \DateInterval('PT' . $lifespan . 'S'));
$token->generateKey();
$this->saveToken($token);
return $token;
}
|
[
"public",
"function",
"createToken",
"(",
"AccountInterface",
"$",
"user",
")",
"{",
"$",
"lifespan",
"=",
"variable_get",
"(",
"'user_password_reset_timeout'",
",",
"86400",
")",
";",
"$",
"token",
"=",
"new",
"Token",
"(",
")",
";",
"$",
"token",
"->",
"uid",
"=",
"$",
"user",
"->",
"id",
"(",
")",
";",
"$",
"token",
"->",
"expiration_date",
"=",
"(",
"new",
"\\",
"DateTime",
"(",
")",
")",
"->",
"add",
"(",
"new",
"\\",
"DateInterval",
"(",
"'PT'",
".",
"$",
"lifespan",
".",
"'S'",
")",
")",
";",
"$",
"token",
"->",
"generateKey",
"(",
")",
";",
"$",
"this",
"->",
"saveToken",
"(",
"$",
"token",
")",
";",
"return",
"$",
"token",
";",
"}"
] |
Creates and saves a new token for the given user.
@param AccountInterface $user
@return Token
|
[
"Creates",
"and",
"saves",
"a",
"new",
"token",
"for",
"the",
"given",
"user",
"."
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_user/src/TokenManager.php#L39-L50
|
234,887
|
makinacorpus/drupal-ucms
|
ucms_user/src/TokenManager.php
|
TokenManager.loadToken
|
public function loadToken($key)
{
$token = $this->db
->select('ucms_user_token', 'ut')
->fields('ut')
->condition('token', $key)
->range(0, 1)
->execute()
->fetchObject('MakinaCorpus\\Ucms\\User\\Token');
if (!$token) {
return null;
}
$token->expiration_date = new \DateTime($token->expiration_date);
return $token;
}
|
php
|
public function loadToken($key)
{
$token = $this->db
->select('ucms_user_token', 'ut')
->fields('ut')
->condition('token', $key)
->range(0, 1)
->execute()
->fetchObject('MakinaCorpus\\Ucms\\User\\Token');
if (!$token) {
return null;
}
$token->expiration_date = new \DateTime($token->expiration_date);
return $token;
}
|
[
"public",
"function",
"loadToken",
"(",
"$",
"key",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"db",
"->",
"select",
"(",
"'ucms_user_token'",
",",
"'ut'",
")",
"->",
"fields",
"(",
"'ut'",
")",
"->",
"condition",
"(",
"'token'",
",",
"$",
"key",
")",
"->",
"range",
"(",
"0",
",",
"1",
")",
"->",
"execute",
"(",
")",
"->",
"fetchObject",
"(",
"'MakinaCorpus\\\\Ucms\\\\User\\\\Token'",
")",
";",
"if",
"(",
"!",
"$",
"token",
")",
"{",
"return",
"null",
";",
"}",
"$",
"token",
"->",
"expiration_date",
"=",
"new",
"\\",
"DateTime",
"(",
"$",
"token",
"->",
"expiration_date",
")",
";",
"return",
"$",
"token",
";",
"}"
] |
Loads a token.
@param string $key
@return Token
|
[
"Loads",
"a",
"token",
"."
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_user/src/TokenManager.php#L59-L75
|
234,888
|
makinacorpus/drupal-ucms
|
ucms_user/src/TokenManager.php
|
TokenManager.saveToken
|
public function saveToken(Token $token)
{
$this->db
->merge('ucms_user_token')
->key(['uid' => $token->uid])
->fields([
'token' => $token->token,
'expiration_date' => $token->expiration_date->format('Y-m-d H:i:s'),
])
->execute();
}
|
php
|
public function saveToken(Token $token)
{
$this->db
->merge('ucms_user_token')
->key(['uid' => $token->uid])
->fields([
'token' => $token->token,
'expiration_date' => $token->expiration_date->format('Y-m-d H:i:s'),
])
->execute();
}
|
[
"public",
"function",
"saveToken",
"(",
"Token",
"$",
"token",
")",
"{",
"$",
"this",
"->",
"db",
"->",
"merge",
"(",
"'ucms_user_token'",
")",
"->",
"key",
"(",
"[",
"'uid'",
"=>",
"$",
"token",
"->",
"uid",
"]",
")",
"->",
"fields",
"(",
"[",
"'token'",
"=>",
"$",
"token",
"->",
"token",
",",
"'expiration_date'",
"=>",
"$",
"token",
"->",
"expiration_date",
"->",
"format",
"(",
"'Y-m-d H:i:s'",
")",
",",
"]",
")",
"->",
"execute",
"(",
")",
";",
"}"
] |
Saves the given token.
@param Token $token
@param int $lifespan
Life duration in seconds.
If not provided wa assume the expiration date is already defined.
|
[
"Saves",
"the",
"given",
"token",
"."
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_user/src/TokenManager.php#L86-L96
|
234,889
|
makinacorpus/drupal-ucms
|
ucms_user/src/TokenManager.php
|
TokenManager.deleteToken
|
public function deleteToken(Token $token)
{
$this->db
->delete('ucms_user_token')
->condition('uid', $token->uid)
->execute();
}
|
php
|
public function deleteToken(Token $token)
{
$this->db
->delete('ucms_user_token')
->condition('uid', $token->uid)
->execute();
}
|
[
"public",
"function",
"deleteToken",
"(",
"Token",
"$",
"token",
")",
"{",
"$",
"this",
"->",
"db",
"->",
"delete",
"(",
"'ucms_user_token'",
")",
"->",
"condition",
"(",
"'uid'",
",",
"$",
"token",
"->",
"uid",
")",
"->",
"execute",
"(",
")",
";",
"}"
] |
Deletes the given token.
@param Token $token
|
[
"Deletes",
"the",
"given",
"token",
"."
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_user/src/TokenManager.php#L104-L110
|
234,890
|
makinacorpus/drupal-ucms
|
ucms_user/src/TokenManager.php
|
TokenManager.sendTokenMail
|
public function sendTokenMail(AccountInterface $user, $mailModule, $mailKey, array $params = [])
{
global $language;
$token = $this->createToken($user);
$params = ['user' => $user, 'token' => $token] + $params;
drupal_mail($mailModule, $mailKey, $user->getEmail(), $language, $params);
}
|
php
|
public function sendTokenMail(AccountInterface $user, $mailModule, $mailKey, array $params = [])
{
global $language;
$token = $this->createToken($user);
$params = ['user' => $user, 'token' => $token] + $params;
drupal_mail($mailModule, $mailKey, $user->getEmail(), $language, $params);
}
|
[
"public",
"function",
"sendTokenMail",
"(",
"AccountInterface",
"$",
"user",
",",
"$",
"mailModule",
",",
"$",
"mailKey",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"global",
"$",
"language",
";",
"$",
"token",
"=",
"$",
"this",
"->",
"createToken",
"(",
"$",
"user",
")",
";",
"$",
"params",
"=",
"[",
"'user'",
"=>",
"$",
"user",
",",
"'token'",
"=>",
"$",
"token",
"]",
"+",
"$",
"params",
";",
"drupal_mail",
"(",
"$",
"mailModule",
",",
"$",
"mailKey",
",",
"$",
"user",
"->",
"getEmail",
"(",
")",
",",
"$",
"language",
",",
"$",
"params",
")",
";",
"}"
] |
Sends the asked mail type including a token generated for the given user.
@global $language
@param AccountInterface $user
The recipient of the mail.
@param string $mailModule
Name of the module containing the type of mail.
@param string $mailKey
Key of the type of mail you want to send.
@param mixed[] $params
Additional parameters for the mail generation.
@see ucms_user_mail()
|
[
"Sends",
"the",
"asked",
"mail",
"type",
"including",
"a",
"token",
"generated",
"for",
"the",
"given",
"user",
"."
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_user/src/TokenManager.php#L140-L148
|
234,891
|
runcmf/runbb
|
src/RunBB/Core/Interfaces/SlimStatic.php
|
SlimStatic.boot
|
public static function boot(App $slim)
{
// set Slim application for syntactic-sugar proxies
SlimSugar::$slim = $slim;
// create a new Manager
$manager = new Manager();
// Add proxies that use the Slim instance
$aliases = ['Config', 'Route', 'Router', 'ForumEnv', 'ForumSettings', 'User', 'Lang', 'DB'];
static::addInstances($aliases, $manager, $slim);
// Add special-case Slim container instance
$aliases = ['Container'];
static::addInstances($aliases, $manager, $slim->getContainer());
// Add services that are resolved out of the Slim container
static::addServices($manager, $slim);
return $manager;
}
|
php
|
public static function boot(App $slim)
{
// set Slim application for syntactic-sugar proxies
SlimSugar::$slim = $slim;
// create a new Manager
$manager = new Manager();
// Add proxies that use the Slim instance
$aliases = ['Config', 'Route', 'Router', 'ForumEnv', 'ForumSettings', 'User', 'Lang', 'DB'];
static::addInstances($aliases, $manager, $slim);
// Add special-case Slim container instance
$aliases = ['Container'];
static::addInstances($aliases, $manager, $slim->getContainer());
// Add services that are resolved out of the Slim container
static::addServices($manager, $slim);
return $manager;
}
|
[
"public",
"static",
"function",
"boot",
"(",
"App",
"$",
"slim",
")",
"{",
"// set Slim application for syntactic-sugar proxies",
"SlimSugar",
"::",
"$",
"slim",
"=",
"$",
"slim",
";",
"// create a new Manager",
"$",
"manager",
"=",
"new",
"Manager",
"(",
")",
";",
"// Add proxies that use the Slim instance",
"$",
"aliases",
"=",
"[",
"'Config'",
",",
"'Route'",
",",
"'Router'",
",",
"'ForumEnv'",
",",
"'ForumSettings'",
",",
"'User'",
",",
"'Lang'",
",",
"'DB'",
"]",
";",
"static",
"::",
"addInstances",
"(",
"$",
"aliases",
",",
"$",
"manager",
",",
"$",
"slim",
")",
";",
"// Add special-case Slim container instance",
"$",
"aliases",
"=",
"[",
"'Container'",
"]",
";",
"static",
"::",
"addInstances",
"(",
"$",
"aliases",
",",
"$",
"manager",
",",
"$",
"slim",
"->",
"getContainer",
"(",
")",
")",
";",
"// Add services that are resolved out of the Slim container",
"static",
"::",
"addServices",
"(",
"$",
"manager",
",",
"$",
"slim",
")",
";",
"return",
"$",
"manager",
";",
"}"
] |
Boots up SlimStatic by registering its proxies with Statical.
@param \Slim\App $slim
@return \RunBB\Core\Statical\Manager
|
[
"Boots",
"up",
"SlimStatic",
"by",
"registering",
"its",
"proxies",
"with",
"Statical",
"."
] |
d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463
|
https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Interfaces/SlimStatic.php#L15-L35
|
234,892
|
runcmf/runbb
|
src/RunBB/Core/Interfaces/SlimStatic.php
|
SlimStatic.addInstances
|
protected static function addInstances($aliases, $manager, $instance)
{
foreach ($aliases as $alias) {
$proxy = __NAMESPACE__.'\\'.$alias;
$manager->addProxyInstance($alias, $proxy, $instance);
}
}
|
php
|
protected static function addInstances($aliases, $manager, $instance)
{
foreach ($aliases as $alias) {
$proxy = __NAMESPACE__.'\\'.$alias;
$manager->addProxyInstance($alias, $proxy, $instance);
}
}
|
[
"protected",
"static",
"function",
"addInstances",
"(",
"$",
"aliases",
",",
"$",
"manager",
",",
"$",
"instance",
")",
"{",
"foreach",
"(",
"$",
"aliases",
"as",
"$",
"alias",
")",
"{",
"$",
"proxy",
"=",
"__NAMESPACE__",
".",
"'\\\\'",
".",
"$",
"alias",
";",
"$",
"manager",
"->",
"addProxyInstance",
"(",
"$",
"alias",
",",
"$",
"proxy",
",",
"$",
"instance",
")",
";",
"}",
"}"
] |
Adds instances to the Statical Manager
@param string[] $aliases
@param \RunBB\Core\Statical\Manager $manager
@param object $instance
|
[
"Adds",
"instances",
"to",
"the",
"Statical",
"Manager"
] |
d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463
|
https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Interfaces/SlimStatic.php#L44-L50
|
234,893
|
runcmf/runbb
|
src/RunBB/Core/Interfaces/SlimStatic.php
|
SlimStatic.addServices
|
protected static function addServices($manager, $slim)
{
$services = [
'Input' => 'request',
'Request' => 'request',
'Response' => 'response',
'View' => 'template',
'Menu' => 'menu',
'Url' => 'url',
'Log' => 'log'
];
$container = $slim->getContainer();
foreach ($services as $alias => $id) {
$proxy = __NAMESPACE__.'\\'.$alias;
$manager->addProxyService($alias, $proxy, $container, $id);
}
}
|
php
|
protected static function addServices($manager, $slim)
{
$services = [
'Input' => 'request',
'Request' => 'request',
'Response' => 'response',
'View' => 'template',
'Menu' => 'menu',
'Url' => 'url',
'Log' => 'log'
];
$container = $slim->getContainer();
foreach ($services as $alias => $id) {
$proxy = __NAMESPACE__.'\\'.$alias;
$manager->addProxyService($alias, $proxy, $container, $id);
}
}
|
[
"protected",
"static",
"function",
"addServices",
"(",
"$",
"manager",
",",
"$",
"slim",
")",
"{",
"$",
"services",
"=",
"[",
"'Input'",
"=>",
"'request'",
",",
"'Request'",
"=>",
"'request'",
",",
"'Response'",
"=>",
"'response'",
",",
"'View'",
"=>",
"'template'",
",",
"'Menu'",
"=>",
"'menu'",
",",
"'Url'",
"=>",
"'url'",
",",
"'Log'",
"=>",
"'log'",
"]",
";",
"$",
"container",
"=",
"$",
"slim",
"->",
"getContainer",
"(",
")",
";",
"foreach",
"(",
"$",
"services",
"as",
"$",
"alias",
"=>",
"$",
"id",
")",
"{",
"$",
"proxy",
"=",
"__NAMESPACE__",
".",
"'\\\\'",
".",
"$",
"alias",
";",
"$",
"manager",
"->",
"addProxyService",
"(",
"$",
"alias",
",",
"$",
"proxy",
",",
"$",
"container",
",",
"$",
"id",
")",
";",
"}",
"}"
] |
Adds services to the Statical Manager
@param \RunBB\Core\Statical\Manager $manager
@param \Slim\App $slim
|
[
"Adds",
"services",
"to",
"the",
"Statical",
"Manager"
] |
d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463
|
https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Interfaces/SlimStatic.php#L58-L76
|
234,894
|
PHPixie/HTTP
|
src/PHPixie/HTTP/Data/Headers/Editable.php
|
Editable.set
|
public function set($name, $value)
{
$value = $this->normalizeValue($value);
$this->remove($name);
$this->setHeader($name, $value);
}
|
php
|
public function set($name, $value)
{
$value = $this->normalizeValue($value);
$this->remove($name);
$this->setHeader($name, $value);
}
|
[
"public",
"function",
"set",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"normalizeValue",
"(",
"$",
"value",
")",
";",
"$",
"this",
"->",
"remove",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
"setHeader",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}"
] |
Set header replacing all headers with the same name
@param string $name
@param string|array $value
|
[
"Set",
"header",
"replacing",
"all",
"headers",
"with",
"the",
"same",
"name"
] |
581c0df452fd07ca4ea0b3e24e8ddee8dddc2912
|
https://github.com/PHPixie/HTTP/blob/581c0df452fd07ca4ea0b3e24e8ddee8dddc2912/src/PHPixie/HTTP/Data/Headers/Editable.php#L15-L21
|
234,895
|
PHPixie/HTTP
|
src/PHPixie/HTTP/Data/Headers/Editable.php
|
Editable.add
|
public function add($name, $value)
{
$this->requireNames();
$value = $this->normalizeValue($value);
$lower = strtolower($name);
if(array_key_exists($lower, $this->names)) {
$name = $this->names[$lower];
foreach($value as $line) {
$this->headers[$name][] = $line;
}
}else{
$this->setHeader($name, $value);
}
}
|
php
|
public function add($name, $value)
{
$this->requireNames();
$value = $this->normalizeValue($value);
$lower = strtolower($name);
if(array_key_exists($lower, $this->names)) {
$name = $this->names[$lower];
foreach($value as $line) {
$this->headers[$name][] = $line;
}
}else{
$this->setHeader($name, $value);
}
}
|
[
"public",
"function",
"add",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"requireNames",
"(",
")",
";",
"$",
"value",
"=",
"$",
"this",
"->",
"normalizeValue",
"(",
"$",
"value",
")",
";",
"$",
"lower",
"=",
"strtolower",
"(",
"$",
"name",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"lower",
",",
"$",
"this",
"->",
"names",
")",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"names",
"[",
"$",
"lower",
"]",
";",
"foreach",
"(",
"$",
"value",
"as",
"$",
"line",
")",
"{",
"$",
"this",
"->",
"headers",
"[",
"$",
"name",
"]",
"[",
"]",
"=",
"$",
"line",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"setHeader",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}",
"}"
] |
Add header value
@param string $name
@param string|array $value
|
[
"Add",
"header",
"value"
] |
581c0df452fd07ca4ea0b3e24e8ddee8dddc2912
|
https://github.com/PHPixie/HTTP/blob/581c0df452fd07ca4ea0b3e24e8ddee8dddc2912/src/PHPixie/HTTP/Data/Headers/Editable.php#L28-L42
|
234,896
|
PHPixie/HTTP
|
src/PHPixie/HTTP/Data/Headers/Editable.php
|
Editable.remove
|
public function remove($name)
{
$this->requireNames();
$lower = strtolower($name);
if(array_key_exists($lower, $this->names)) {
$name = $this->names[$lower];
unset($this->names[$lower]);
unset($this->headers[$name]);
}
}
|
php
|
public function remove($name)
{
$this->requireNames();
$lower = strtolower($name);
if(array_key_exists($lower, $this->names)) {
$name = $this->names[$lower];
unset($this->names[$lower]);
unset($this->headers[$name]);
}
}
|
[
"public",
"function",
"remove",
"(",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"requireNames",
"(",
")",
";",
"$",
"lower",
"=",
"strtolower",
"(",
"$",
"name",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"lower",
",",
"$",
"this",
"->",
"names",
")",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"names",
"[",
"$",
"lower",
"]",
";",
"unset",
"(",
"$",
"this",
"->",
"names",
"[",
"$",
"lower",
"]",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"headers",
"[",
"$",
"name",
"]",
")",
";",
"}",
"}"
] |
Remove all header values
@param string $name
|
[
"Remove",
"all",
"header",
"values"
] |
581c0df452fd07ca4ea0b3e24e8ddee8dddc2912
|
https://github.com/PHPixie/HTTP/blob/581c0df452fd07ca4ea0b3e24e8ddee8dddc2912/src/PHPixie/HTTP/Data/Headers/Editable.php#L48-L58
|
234,897
|
tremendus/amazon-mws
|
src/FBAInventoryServiceMWS/Client.php
|
FBAInventoryServiceMWS_Client._convertListInventorySupply
|
private function _convertListInventorySupply($request) {
$parameters = array();
$parameters['Action'] = 'ListInventorySupply';
if ($request->isSetSellerId()) {
$parameters['SellerId'] = $request->getSellerId();
}
if ($request->isSetMWSAuthToken()) {
$parameters['MWSAuthToken'] = $request->getMWSAuthToken();
}
if ($request->isSetMarketplace()) {
$parameters['Marketplace'] = $request->getMarketplace();
}
if ($request->isSetSupplyRegion()) {
$parameters['SupplyRegion'] = $request->getSupplyRegion();
}
if ($request->isSetSellerSkus()) {
$SellerSkusListInventorySupplyRequest = $request->getSellerSkus();
foreach ($SellerSkusListInventorySupplyRequest->getmember() as $memberSellerSkusIndex => $memberSellerSkus) {
$parameters['SellerSkus' . '.' . 'member' . '.' . ($memberSellerSkusIndex + 1)] = $memberSellerSkus;
}
}
if ($request->isSetQueryStartDateTime()) {
$parameters['QueryStartDateTime'] = $request->getQueryStartDateTime();
}
if ($request->isSetResponseGroup()) {
$parameters['ResponseGroup'] = $request->getResponseGroup();
}
return $parameters;
}
|
php
|
private function _convertListInventorySupply($request) {
$parameters = array();
$parameters['Action'] = 'ListInventorySupply';
if ($request->isSetSellerId()) {
$parameters['SellerId'] = $request->getSellerId();
}
if ($request->isSetMWSAuthToken()) {
$parameters['MWSAuthToken'] = $request->getMWSAuthToken();
}
if ($request->isSetMarketplace()) {
$parameters['Marketplace'] = $request->getMarketplace();
}
if ($request->isSetSupplyRegion()) {
$parameters['SupplyRegion'] = $request->getSupplyRegion();
}
if ($request->isSetSellerSkus()) {
$SellerSkusListInventorySupplyRequest = $request->getSellerSkus();
foreach ($SellerSkusListInventorySupplyRequest->getmember() as $memberSellerSkusIndex => $memberSellerSkus) {
$parameters['SellerSkus' . '.' . 'member' . '.' . ($memberSellerSkusIndex + 1)] = $memberSellerSkus;
}
}
if ($request->isSetQueryStartDateTime()) {
$parameters['QueryStartDateTime'] = $request->getQueryStartDateTime();
}
if ($request->isSetResponseGroup()) {
$parameters['ResponseGroup'] = $request->getResponseGroup();
}
return $parameters;
}
|
[
"private",
"function",
"_convertListInventorySupply",
"(",
"$",
"request",
")",
"{",
"$",
"parameters",
"=",
"array",
"(",
")",
";",
"$",
"parameters",
"[",
"'Action'",
"]",
"=",
"'ListInventorySupply'",
";",
"if",
"(",
"$",
"request",
"->",
"isSetSellerId",
"(",
")",
")",
"{",
"$",
"parameters",
"[",
"'SellerId'",
"]",
"=",
"$",
"request",
"->",
"getSellerId",
"(",
")",
";",
"}",
"if",
"(",
"$",
"request",
"->",
"isSetMWSAuthToken",
"(",
")",
")",
"{",
"$",
"parameters",
"[",
"'MWSAuthToken'",
"]",
"=",
"$",
"request",
"->",
"getMWSAuthToken",
"(",
")",
";",
"}",
"if",
"(",
"$",
"request",
"->",
"isSetMarketplace",
"(",
")",
")",
"{",
"$",
"parameters",
"[",
"'Marketplace'",
"]",
"=",
"$",
"request",
"->",
"getMarketplace",
"(",
")",
";",
"}",
"if",
"(",
"$",
"request",
"->",
"isSetSupplyRegion",
"(",
")",
")",
"{",
"$",
"parameters",
"[",
"'SupplyRegion'",
"]",
"=",
"$",
"request",
"->",
"getSupplyRegion",
"(",
")",
";",
"}",
"if",
"(",
"$",
"request",
"->",
"isSetSellerSkus",
"(",
")",
")",
"{",
"$",
"SellerSkusListInventorySupplyRequest",
"=",
"$",
"request",
"->",
"getSellerSkus",
"(",
")",
";",
"foreach",
"(",
"$",
"SellerSkusListInventorySupplyRequest",
"->",
"getmember",
"(",
")",
"as",
"$",
"memberSellerSkusIndex",
"=>",
"$",
"memberSellerSkus",
")",
"{",
"$",
"parameters",
"[",
"'SellerSkus'",
".",
"'.'",
".",
"'member'",
".",
"'.'",
".",
"(",
"$",
"memberSellerSkusIndex",
"+",
"1",
")",
"]",
"=",
"$",
"memberSellerSkus",
";",
"}",
"}",
"if",
"(",
"$",
"request",
"->",
"isSetQueryStartDateTime",
"(",
")",
")",
"{",
"$",
"parameters",
"[",
"'QueryStartDateTime'",
"]",
"=",
"$",
"request",
"->",
"getQueryStartDateTime",
"(",
")",
";",
"}",
"if",
"(",
"$",
"request",
"->",
"isSetResponseGroup",
"(",
")",
")",
"{",
"$",
"parameters",
"[",
"'ResponseGroup'",
"]",
"=",
"$",
"request",
"->",
"getResponseGroup",
"(",
")",
";",
"}",
"return",
"$",
"parameters",
";",
"}"
] |
Convert ListInventorySupplyRequest to name value pairs
|
[
"Convert",
"ListInventorySupplyRequest",
"to",
"name",
"value",
"pairs"
] |
465312b0b75fb91ff9ae4ce63b6c299b6f7e030d
|
https://github.com/tremendus/amazon-mws/blob/465312b0b75fb91ff9ae4ce63b6c299b6f7e030d/src/FBAInventoryServiceMWS/Client.php#L165-L195
|
234,898
|
tremendus/amazon-mws
|
src/FBAInventoryServiceMWS/Client.php
|
FBAInventoryServiceMWS_Client.listInventorySupplyByNextToken
|
public function listInventorySupplyByNextToken($request)
{
if (!($request instanceof FBAInventoryServiceMWS_Model_ListInventorySupplyByNextTokenRequest)) {
require_once (dirname(__FILE__) . '/Model/ListInventorySupplyByNextTokenRequest.php');
$request = new FBAInventoryServiceMWS_Model_ListInventorySupplyByNextTokenRequest($request);
}
$parameters = $request->toQueryParameterArray();
$parameters['Action'] = 'ListInventorySupplyByNextToken';
$httpResponse = $this->_invoke($parameters);
require_once (dirname(__FILE__) . '/Model/ListInventorySupplyByNextTokenResponse.php');
$response = FBAInventoryServiceMWS_Model_ListInventorySupplyByNextTokenResponse::fromXML($httpResponse['ResponseBody']);
$response->setResponseHeaderMetadata($httpResponse['ResponseHeaderMetadata']);
return $response;
}
|
php
|
public function listInventorySupplyByNextToken($request)
{
if (!($request instanceof FBAInventoryServiceMWS_Model_ListInventorySupplyByNextTokenRequest)) {
require_once (dirname(__FILE__) . '/Model/ListInventorySupplyByNextTokenRequest.php');
$request = new FBAInventoryServiceMWS_Model_ListInventorySupplyByNextTokenRequest($request);
}
$parameters = $request->toQueryParameterArray();
$parameters['Action'] = 'ListInventorySupplyByNextToken';
$httpResponse = $this->_invoke($parameters);
require_once (dirname(__FILE__) . '/Model/ListInventorySupplyByNextTokenResponse.php');
$response = FBAInventoryServiceMWS_Model_ListInventorySupplyByNextTokenResponse::fromXML($httpResponse['ResponseBody']);
$response->setResponseHeaderMetadata($httpResponse['ResponseHeaderMetadata']);
return $response;
}
|
[
"public",
"function",
"listInventorySupplyByNextToken",
"(",
"$",
"request",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"request",
"instanceof",
"FBAInventoryServiceMWS_Model_ListInventorySupplyByNextTokenRequest",
")",
")",
"{",
"require_once",
"(",
"dirname",
"(",
"__FILE__",
")",
".",
"'/Model/ListInventorySupplyByNextTokenRequest.php'",
")",
";",
"$",
"request",
"=",
"new",
"FBAInventoryServiceMWS_Model_ListInventorySupplyByNextTokenRequest",
"(",
"$",
"request",
")",
";",
"}",
"$",
"parameters",
"=",
"$",
"request",
"->",
"toQueryParameterArray",
"(",
")",
";",
"$",
"parameters",
"[",
"'Action'",
"]",
"=",
"'ListInventorySupplyByNextToken'",
";",
"$",
"httpResponse",
"=",
"$",
"this",
"->",
"_invoke",
"(",
"$",
"parameters",
")",
";",
"require_once",
"(",
"dirname",
"(",
"__FILE__",
")",
".",
"'/Model/ListInventorySupplyByNextTokenResponse.php'",
")",
";",
"$",
"response",
"=",
"FBAInventoryServiceMWS_Model_ListInventorySupplyByNextTokenResponse",
"::",
"fromXML",
"(",
"$",
"httpResponse",
"[",
"'ResponseBody'",
"]",
")",
";",
"$",
"response",
"->",
"setResponseHeaderMetadata",
"(",
"$",
"httpResponse",
"[",
"'ResponseHeaderMetadata'",
"]",
")",
";",
"return",
"$",
"response",
";",
"}"
] |
List Inventory Supply By Next Token
Continues pagination over a resultset of inventory data for inventory
items.
This operation is used in conjunction with ListUpdatedInventorySupply.
Please refer to documentation for that operation for further details.
@param mixed $request array of parameters for FBAInventoryServiceMWS_Model_ListInventorySupplyByNextToken request or FBAInventoryServiceMWS_Model_ListInventorySupplyByNextToken object itself
@see FBAInventoryServiceMWS_Model_ListInventorySupplyByNextTokenRequest
@return FBAInventoryServiceMWS_Model_ListInventorySupplyByNextTokenResponse
@throws FBAInventoryServiceMWS_Exception
|
[
"List",
"Inventory",
"Supply",
"By",
"Next",
"Token",
"Continues",
"pagination",
"over",
"a",
"resultset",
"of",
"inventory",
"data",
"for",
"inventory",
"items",
"."
] |
465312b0b75fb91ff9ae4ce63b6c299b6f7e030d
|
https://github.com/tremendus/amazon-mws/blob/465312b0b75fb91ff9ae4ce63b6c299b6f7e030d/src/FBAInventoryServiceMWS/Client.php#L212-L226
|
234,899
|
tremendus/amazon-mws
|
src/FBAInventoryServiceMWS/Client.php
|
FBAInventoryServiceMWS_Client._convertListInventorySupplyByNextToken
|
private function _convertListInventorySupplyByNextToken($request) {
$parameters = array();
$parameters['Action'] = 'ListInventorySupplyByNextToken';
if ($request->isSetSellerId()) {
$parameters['SellerId'] = $request->getSellerId();
}
if ($request->isSetMWSAuthToken()) {
$parameters['MWSAuthToken'] = $request->getMWSAuthToken();
}
if ($request->isSetMarketplace()) {
$parameters['Marketplace'] = $request->getMarketplace();
}
if ($request->isSetSupplyRegion()) {
$parameters['SupplyRegion'] = $request->getSupplyRegion();
}
if ($request->isSetNextToken()) {
$parameters['NextToken'] = $request->getNextToken();
}
return $parameters;
}
|
php
|
private function _convertListInventorySupplyByNextToken($request) {
$parameters = array();
$parameters['Action'] = 'ListInventorySupplyByNextToken';
if ($request->isSetSellerId()) {
$parameters['SellerId'] = $request->getSellerId();
}
if ($request->isSetMWSAuthToken()) {
$parameters['MWSAuthToken'] = $request->getMWSAuthToken();
}
if ($request->isSetMarketplace()) {
$parameters['Marketplace'] = $request->getMarketplace();
}
if ($request->isSetSupplyRegion()) {
$parameters['SupplyRegion'] = $request->getSupplyRegion();
}
if ($request->isSetNextToken()) {
$parameters['NextToken'] = $request->getNextToken();
}
return $parameters;
}
|
[
"private",
"function",
"_convertListInventorySupplyByNextToken",
"(",
"$",
"request",
")",
"{",
"$",
"parameters",
"=",
"array",
"(",
")",
";",
"$",
"parameters",
"[",
"'Action'",
"]",
"=",
"'ListInventorySupplyByNextToken'",
";",
"if",
"(",
"$",
"request",
"->",
"isSetSellerId",
"(",
")",
")",
"{",
"$",
"parameters",
"[",
"'SellerId'",
"]",
"=",
"$",
"request",
"->",
"getSellerId",
"(",
")",
";",
"}",
"if",
"(",
"$",
"request",
"->",
"isSetMWSAuthToken",
"(",
")",
")",
"{",
"$",
"parameters",
"[",
"'MWSAuthToken'",
"]",
"=",
"$",
"request",
"->",
"getMWSAuthToken",
"(",
")",
";",
"}",
"if",
"(",
"$",
"request",
"->",
"isSetMarketplace",
"(",
")",
")",
"{",
"$",
"parameters",
"[",
"'Marketplace'",
"]",
"=",
"$",
"request",
"->",
"getMarketplace",
"(",
")",
";",
"}",
"if",
"(",
"$",
"request",
"->",
"isSetSupplyRegion",
"(",
")",
")",
"{",
"$",
"parameters",
"[",
"'SupplyRegion'",
"]",
"=",
"$",
"request",
"->",
"getSupplyRegion",
"(",
")",
";",
"}",
"if",
"(",
"$",
"request",
"->",
"isSetNextToken",
"(",
")",
")",
"{",
"$",
"parameters",
"[",
"'NextToken'",
"]",
"=",
"$",
"request",
"->",
"getNextToken",
"(",
")",
";",
"}",
"return",
"$",
"parameters",
";",
"}"
] |
Convert ListInventorySupplyByNextTokenRequest to name value pairs
|
[
"Convert",
"ListInventorySupplyByNextTokenRequest",
"to",
"name",
"value",
"pairs"
] |
465312b0b75fb91ff9ae4ce63b6c299b6f7e030d
|
https://github.com/tremendus/amazon-mws/blob/465312b0b75fb91ff9ae4ce63b6c299b6f7e030d/src/FBAInventoryServiceMWS/Client.php#L232-L253
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.