repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_code_tokens
sequencelengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
sequencelengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
danielgp/network-components | source/NetworkComponentsByDanielGP.php | NetworkComponentsByDanielGP.checkIpIsInRange | public function checkIpIsInRange($ipGiven, $ipStart, $ipEnd)
{
$sReturn = 'out';
$startNo = $this->convertIpToNumber($ipStart);
$endNo = $this->convertIpToNumber($ipEnd);
$evaluatedNo = $this->convertIpToNumber($ipGiven);
if ($sReturn == 'out') {
if (($evaluatedNo >= $startNo) && ($evaluatedNo <= $endNo)) {
$sReturn = 'in';
}
}
return $sReturn;
} | php | public function checkIpIsInRange($ipGiven, $ipStart, $ipEnd)
{
$sReturn = 'out';
$startNo = $this->convertIpToNumber($ipStart);
$endNo = $this->convertIpToNumber($ipEnd);
$evaluatedNo = $this->convertIpToNumber($ipGiven);
if ($sReturn == 'out') {
if (($evaluatedNo >= $startNo) && ($evaluatedNo <= $endNo)) {
$sReturn = 'in';
}
}
return $sReturn;
} | [
"public",
"function",
"checkIpIsInRange",
"(",
"$",
"ipGiven",
",",
"$",
"ipStart",
",",
"$",
"ipEnd",
")",
"{",
"$",
"sReturn",
"=",
"'out'",
";",
"$",
"startNo",
"=",
"$",
"this",
"->",
"convertIpToNumber",
"(",
"$",
"ipStart",
")",
";",
"$",
"endNo",
"=",
"$",
"this",
"->",
"convertIpToNumber",
"(",
"$",
"ipEnd",
")",
";",
"$",
"evaluatedNo",
"=",
"$",
"this",
"->",
"convertIpToNumber",
"(",
"$",
"ipGiven",
")",
";",
"if",
"(",
"$",
"sReturn",
"==",
"'out'",
")",
"{",
"if",
"(",
"(",
"$",
"evaluatedNo",
">=",
"$",
"startNo",
")",
"&&",
"(",
"$",
"evaluatedNo",
"<=",
"$",
"endNo",
")",
")",
"{",
"$",
"sReturn",
"=",
"'in'",
";",
"}",
"}",
"return",
"$",
"sReturn",
";",
"}"
] | Determines if a given IP is with a defined range
@param ipv4 $ipGiven
@param ipv4 $ipStart
@param ipv4 $ipEnd
@return string | [
"Determines",
"if",
"a",
"given",
"IP",
"is",
"with",
"a",
"defined",
"range"
] | train | https://github.com/danielgp/network-components/blob/96d3f8247b2aac6db951ec9d76626e7ab8b824e4/source/NetworkComponentsByDanielGP.php#L42-L54 |
danielgp/network-components | source/NetworkComponentsByDanielGP.php | NetworkComponentsByDanielGP.checkIpIsPrivate | public function checkIpIsPrivate($ipGiven)
{
if (filter_var($ipGiven, FILTER_VALIDATE_IP)) {
if (!filter_var($ipGiven, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE | FILTER_FLAG_NO_PRIV_RANGE)) {
return 'private';
}
return 'public';
}
return 'invalid IP';
} | php | public function checkIpIsPrivate($ipGiven)
{
if (filter_var($ipGiven, FILTER_VALIDATE_IP)) {
if (!filter_var($ipGiven, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE | FILTER_FLAG_NO_PRIV_RANGE)) {
return 'private';
}
return 'public';
}
return 'invalid IP';
} | [
"public",
"function",
"checkIpIsPrivate",
"(",
"$",
"ipGiven",
")",
"{",
"if",
"(",
"filter_var",
"(",
"$",
"ipGiven",
",",
"FILTER_VALIDATE_IP",
")",
")",
"{",
"if",
"(",
"!",
"filter_var",
"(",
"$",
"ipGiven",
",",
"FILTER_VALIDATE_IP",
",",
"FILTER_FLAG_NO_RES_RANGE",
"|",
"FILTER_FLAG_NO_PRIV_RANGE",
")",
")",
"{",
"return",
"'private'",
";",
"}",
"return",
"'public'",
";",
"}",
"return",
"'invalid IP'",
";",
"}"
] | Checks if given IP is a private or public one
@param ipv4 $ipGiven
@return string | [
"Checks",
"if",
"given",
"IP",
"is",
"a",
"private",
"or",
"public",
"one"
] | train | https://github.com/danielgp/network-components/blob/96d3f8247b2aac6db951ec9d76626e7ab8b824e4/source/NetworkComponentsByDanielGP.php#L62-L71 |
danielgp/network-components | source/NetworkComponentsByDanielGP.php | NetworkComponentsByDanielGP.checkIpIsV4OrV6 | public function checkIpIsV4OrV6($ipGiven)
{
if (filter_var($ipGiven, FILTER_VALIDATE_IP)) {
if (filter_var($ipGiven, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
return 'V4';
} elseif (filter_var($ipGiven, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
return 'V6';
}
}
return 'invalid IP';
} | php | public function checkIpIsV4OrV6($ipGiven)
{
if (filter_var($ipGiven, FILTER_VALIDATE_IP)) {
if (filter_var($ipGiven, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
return 'V4';
} elseif (filter_var($ipGiven, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
return 'V6';
}
}
return 'invalid IP';
} | [
"public",
"function",
"checkIpIsV4OrV6",
"(",
"$",
"ipGiven",
")",
"{",
"if",
"(",
"filter_var",
"(",
"$",
"ipGiven",
",",
"FILTER_VALIDATE_IP",
")",
")",
"{",
"if",
"(",
"filter_var",
"(",
"$",
"ipGiven",
",",
"FILTER_VALIDATE_IP",
",",
"FILTER_FLAG_IPV4",
")",
")",
"{",
"return",
"'V4'",
";",
"}",
"elseif",
"(",
"filter_var",
"(",
"$",
"ipGiven",
",",
"FILTER_VALIDATE_IP",
",",
"FILTER_FLAG_IPV6",
")",
")",
"{",
"return",
"'V6'",
";",
"}",
"}",
"return",
"'invalid IP'",
";",
"}"
] | Checks if given IP is a V4 or V6
@param ipv4 $ipGiven
@return string | [
"Checks",
"if",
"given",
"IP",
"is",
"a",
"V4",
"or",
"V6"
] | train | https://github.com/danielgp/network-components/blob/96d3f8247b2aac6db951ec9d76626e7ab8b824e4/source/NetworkComponentsByDanielGP.php#L79-L89 |
danielgp/network-components | source/NetworkComponentsByDanielGP.php | NetworkComponentsByDanielGP.convertIpToNumber | public function convertIpToNumber($ipGiven)
{
if (filter_var($ipGiven, FILTER_VALIDATE_IP)) {
if (filter_var($ipGiven, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
$ips = explode('.', $ipGiven);
return $ips[3] + $ips[2] * 256 + $ips[1] * 65536 + $ips[0] * 16777216;
} elseif (filter_var($ipGiven, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
return $this->convertIpV6ToNumber($ipGiven);
}
}
return 'invalid IP';
} | php | public function convertIpToNumber($ipGiven)
{
if (filter_var($ipGiven, FILTER_VALIDATE_IP)) {
if (filter_var($ipGiven, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
$ips = explode('.', $ipGiven);
return $ips[3] + $ips[2] * 256 + $ips[1] * 65536 + $ips[0] * 16777216;
} elseif (filter_var($ipGiven, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
return $this->convertIpV6ToNumber($ipGiven);
}
}
return 'invalid IP';
} | [
"public",
"function",
"convertIpToNumber",
"(",
"$",
"ipGiven",
")",
"{",
"if",
"(",
"filter_var",
"(",
"$",
"ipGiven",
",",
"FILTER_VALIDATE_IP",
")",
")",
"{",
"if",
"(",
"filter_var",
"(",
"$",
"ipGiven",
",",
"FILTER_VALIDATE_IP",
",",
"FILTER_FLAG_IPV4",
")",
")",
"{",
"$",
"ips",
"=",
"explode",
"(",
"'.'",
",",
"$",
"ipGiven",
")",
";",
"return",
"$",
"ips",
"[",
"3",
"]",
"+",
"$",
"ips",
"[",
"2",
"]",
"*",
"256",
"+",
"$",
"ips",
"[",
"1",
"]",
"*",
"65536",
"+",
"$",
"ips",
"[",
"0",
"]",
"*",
"16777216",
";",
"}",
"elseif",
"(",
"filter_var",
"(",
"$",
"ipGiven",
",",
"FILTER_VALIDATE_IP",
",",
"FILTER_FLAG_IPV6",
")",
")",
"{",
"return",
"$",
"this",
"->",
"convertIpV6ToNumber",
"(",
"$",
"ipGiven",
")",
";",
"}",
"}",
"return",
"'invalid IP'",
";",
"}"
] | Converts IP to a number
@param type $ipGiven
@return string|int | [
"Converts",
"IP",
"to",
"a",
"number"
] | train | https://github.com/danielgp/network-components/blob/96d3f8247b2aac6db951ec9d76626e7ab8b824e4/source/NetworkComponentsByDanielGP.php#L97-L108 |
Xsaven/laravel-intelect-admin | src/Addons/Modules/Repository.php | Repository.getScanPaths | public function getScanPaths() : array
{
$paths = $this->paths;
$paths[] = $this->getPath();
if ($this->config('scan.enabled')) {
$paths = array_merge($paths, $this->config('scan.paths'));
}
$paths = array_map(function ($path) {
return ends_with($path, '/*') ? $path : str_finish($path, '/*');
}, $paths);
return $paths;
} | php | public function getScanPaths() : array
{
$paths = $this->paths;
$paths[] = $this->getPath();
if ($this->config('scan.enabled')) {
$paths = array_merge($paths, $this->config('scan.paths'));
}
$paths = array_map(function ($path) {
return ends_with($path, '/*') ? $path : str_finish($path, '/*');
}, $paths);
return $paths;
} | [
"public",
"function",
"getScanPaths",
"(",
")",
":",
"array",
"{",
"$",
"paths",
"=",
"$",
"this",
"->",
"paths",
";",
"$",
"paths",
"[",
"]",
"=",
"$",
"this",
"->",
"getPath",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"config",
"(",
"'scan.enabled'",
")",
")",
"{",
"$",
"paths",
"=",
"array_merge",
"(",
"$",
"paths",
",",
"$",
"this",
"->",
"config",
"(",
"'scan.paths'",
")",
")",
";",
"}",
"$",
"paths",
"=",
"array_map",
"(",
"function",
"(",
"$",
"path",
")",
"{",
"return",
"ends_with",
"(",
"$",
"path",
",",
"'/*'",
")",
"?",
"$",
"path",
":",
"str_finish",
"(",
"$",
"path",
",",
"'/*'",
")",
";",
"}",
",",
"$",
"paths",
")",
";",
"return",
"$",
"paths",
";",
"}"
] | Get scanned modules paths.
@return array | [
"Get",
"scanned",
"modules",
"paths",
"."
] | train | https://github.com/Xsaven/laravel-intelect-admin/blob/592574633d12c74cf25b43dd6694fee496abefcb/src/Addons/Modules/Repository.php#L91-L106 |
Xsaven/laravel-intelect-admin | src/Addons/Modules/Repository.php | Repository.asset | public function asset($asset) : string
{
if (str_contains($asset, ':') === false) {
throw InvalidAssetPath::missingModuleName($asset);
}
list($name, $url) = explode(':', $asset);
if(\File::isDirectory(public_path($name.'_assets'))) {
$asset_path = public_path($name.'_assets');
$baseUrl = str_replace(public_path() . DIRECTORY_SEPARATOR, '', $asset_path);
$url = $this->app['url']->asset($baseUrl . "/" . $url);
} else {
$asset_path = $this->getAssetsPath();
$baseUrl = str_replace(public_path() . DIRECTORY_SEPARATOR, '', $asset_path);
$url = $this->app['url']->asset($baseUrl . "/{$name}/" . $url);
}
return str_replace(['http://', 'https://'], '//', $url);
} | php | public function asset($asset) : string
{
if (str_contains($asset, ':') === false) {
throw InvalidAssetPath::missingModuleName($asset);
}
list($name, $url) = explode(':', $asset);
if(\File::isDirectory(public_path($name.'_assets'))) {
$asset_path = public_path($name.'_assets');
$baseUrl = str_replace(public_path() . DIRECTORY_SEPARATOR, '', $asset_path);
$url = $this->app['url']->asset($baseUrl . "/" . $url);
} else {
$asset_path = $this->getAssetsPath();
$baseUrl = str_replace(public_path() . DIRECTORY_SEPARATOR, '', $asset_path);
$url = $this->app['url']->asset($baseUrl . "/{$name}/" . $url);
}
return str_replace(['http://', 'https://'], '//', $url);
} | [
"public",
"function",
"asset",
"(",
"$",
"asset",
")",
":",
"string",
"{",
"if",
"(",
"str_contains",
"(",
"$",
"asset",
",",
"':'",
")",
"===",
"false",
")",
"{",
"throw",
"InvalidAssetPath",
"::",
"missingModuleName",
"(",
"$",
"asset",
")",
";",
"}",
"list",
"(",
"$",
"name",
",",
"$",
"url",
")",
"=",
"explode",
"(",
"':'",
",",
"$",
"asset",
")",
";",
"if",
"(",
"\\",
"File",
"::",
"isDirectory",
"(",
"public_path",
"(",
"$",
"name",
".",
"'_assets'",
")",
")",
")",
"{",
"$",
"asset_path",
"=",
"public_path",
"(",
"$",
"name",
".",
"'_assets'",
")",
";",
"$",
"baseUrl",
"=",
"str_replace",
"(",
"public_path",
"(",
")",
".",
"DIRECTORY_SEPARATOR",
",",
"''",
",",
"$",
"asset_path",
")",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"app",
"[",
"'url'",
"]",
"->",
"asset",
"(",
"$",
"baseUrl",
".",
"\"/\"",
".",
"$",
"url",
")",
";",
"}",
"else",
"{",
"$",
"asset_path",
"=",
"$",
"this",
"->",
"getAssetsPath",
"(",
")",
";",
"$",
"baseUrl",
"=",
"str_replace",
"(",
"public_path",
"(",
")",
".",
"DIRECTORY_SEPARATOR",
",",
"''",
",",
"$",
"asset_path",
")",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"app",
"[",
"'url'",
"]",
"->",
"asset",
"(",
"$",
"baseUrl",
".",
"\"/{$name}/\"",
".",
"$",
"url",
")",
";",
"}",
"return",
"str_replace",
"(",
"[",
"'http://'",
",",
"'https://'",
"]",
",",
"'//'",
",",
"$",
"url",
")",
";",
"}"
] | Get asset url from a specific module.
@param string $asset
@return string
@throws InvalidAssetPath | [
"Get",
"asset",
"url",
"from",
"a",
"specific",
"module",
"."
] | train | https://github.com/Xsaven/laravel-intelect-admin/blob/592574633d12c74cf25b43dd6694fee496abefcb/src/Addons/Modules/Repository.php#L523-L541 |
joalcapa/Fundamentary | src/Http/Request.php | Request.prepareURL | private function prepareURL() {
$this->url = $_SERVER['REQUEST_URI'];
$this->rootUrl = false;
if($this->url == '/api/auth' || $this->url == '/api/auth/' )
$this->login = true;
if($this->url == '/api/auth/reset-password' || $this->url == '/api/auth/reset-password/' )
$this->resetPassword = true;
$this->urlApi = str_replace('/api', '', $this->url);
if(strpos($this->url, '?'))
strstr($this->url, '?', true);
if(strpos($this->url, 'api/') !== false)
$strSearch = 'api/';
else {
if (strpos($this->url, 'api') !== false)
$strSearch = 'api';
else
$this->rootUrl = true;
}
if($this->login || $this->resetPassword) return;
if(empty($strSearch)) return;
$tokens2 = explode($strSearch, $this->url);
if($tokens2[1] != '') {
$tokens = explode("/", $tokens2[1]);
switch(count($tokens)) {
case 1:
$this->model = ucwords(strtolower($tokens[0]));
break;
case 2:
$this->model = ucwords(strtolower($tokens[0]));
$this->requiredParameter = $tokens[1];
break;
case 3:
$this->relationalModel = ucwords(strtolower($tokens[0]));
$this->relationalParameter = $tokens[1];
$this->model = ucwords(strtolower($tokens[2]));
break;
default:
$this->relationalModel = ucwords(strtolower($tokens[0]));
$this->relationalParameter = $tokens[1];
$this->model = ucwords(strtolower($tokens[2]));
$this->requiredParameter = $tokens[3];
break;
}
} else
$this->rootUrl = true;
} | php | private function prepareURL() {
$this->url = $_SERVER['REQUEST_URI'];
$this->rootUrl = false;
if($this->url == '/api/auth' || $this->url == '/api/auth/' )
$this->login = true;
if($this->url == '/api/auth/reset-password' || $this->url == '/api/auth/reset-password/' )
$this->resetPassword = true;
$this->urlApi = str_replace('/api', '', $this->url);
if(strpos($this->url, '?'))
strstr($this->url, '?', true);
if(strpos($this->url, 'api/') !== false)
$strSearch = 'api/';
else {
if (strpos($this->url, 'api') !== false)
$strSearch = 'api';
else
$this->rootUrl = true;
}
if($this->login || $this->resetPassword) return;
if(empty($strSearch)) return;
$tokens2 = explode($strSearch, $this->url);
if($tokens2[1] != '') {
$tokens = explode("/", $tokens2[1]);
switch(count($tokens)) {
case 1:
$this->model = ucwords(strtolower($tokens[0]));
break;
case 2:
$this->model = ucwords(strtolower($tokens[0]));
$this->requiredParameter = $tokens[1];
break;
case 3:
$this->relationalModel = ucwords(strtolower($tokens[0]));
$this->relationalParameter = $tokens[1];
$this->model = ucwords(strtolower($tokens[2]));
break;
default:
$this->relationalModel = ucwords(strtolower($tokens[0]));
$this->relationalParameter = $tokens[1];
$this->model = ucwords(strtolower($tokens[2]));
$this->requiredParameter = $tokens[3];
break;
}
} else
$this->rootUrl = true;
} | [
"private",
"function",
"prepareURL",
"(",
")",
"{",
"$",
"this",
"->",
"url",
"=",
"$",
"_SERVER",
"[",
"'REQUEST_URI'",
"]",
";",
"$",
"this",
"->",
"rootUrl",
"=",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"url",
"==",
"'/api/auth'",
"||",
"$",
"this",
"->",
"url",
"==",
"'/api/auth/'",
")",
"$",
"this",
"->",
"login",
"=",
"true",
";",
"if",
"(",
"$",
"this",
"->",
"url",
"==",
"'/api/auth/reset-password'",
"||",
"$",
"this",
"->",
"url",
"==",
"'/api/auth/reset-password/'",
")",
"$",
"this",
"->",
"resetPassword",
"=",
"true",
";",
"$",
"this",
"->",
"urlApi",
"=",
"str_replace",
"(",
"'/api'",
",",
"''",
",",
"$",
"this",
"->",
"url",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"this",
"->",
"url",
",",
"'?'",
")",
")",
"strstr",
"(",
"$",
"this",
"->",
"url",
",",
"'?'",
",",
"true",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"this",
"->",
"url",
",",
"'api/'",
")",
"!==",
"false",
")",
"$",
"strSearch",
"=",
"'api/'",
";",
"else",
"{",
"if",
"(",
"strpos",
"(",
"$",
"this",
"->",
"url",
",",
"'api'",
")",
"!==",
"false",
")",
"$",
"strSearch",
"=",
"'api'",
";",
"else",
"$",
"this",
"->",
"rootUrl",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"login",
"||",
"$",
"this",
"->",
"resetPassword",
")",
"return",
";",
"if",
"(",
"empty",
"(",
"$",
"strSearch",
")",
")",
"return",
";",
"$",
"tokens2",
"=",
"explode",
"(",
"$",
"strSearch",
",",
"$",
"this",
"->",
"url",
")",
";",
"if",
"(",
"$",
"tokens2",
"[",
"1",
"]",
"!=",
"''",
")",
"{",
"$",
"tokens",
"=",
"explode",
"(",
"\"/\"",
",",
"$",
"tokens2",
"[",
"1",
"]",
")",
";",
"switch",
"(",
"count",
"(",
"$",
"tokens",
")",
")",
"{",
"case",
"1",
":",
"$",
"this",
"->",
"model",
"=",
"ucwords",
"(",
"strtolower",
"(",
"$",
"tokens",
"[",
"0",
"]",
")",
")",
";",
"break",
";",
"case",
"2",
":",
"$",
"this",
"->",
"model",
"=",
"ucwords",
"(",
"strtolower",
"(",
"$",
"tokens",
"[",
"0",
"]",
")",
")",
";",
"$",
"this",
"->",
"requiredParameter",
"=",
"$",
"tokens",
"[",
"1",
"]",
";",
"break",
";",
"case",
"3",
":",
"$",
"this",
"->",
"relationalModel",
"=",
"ucwords",
"(",
"strtolower",
"(",
"$",
"tokens",
"[",
"0",
"]",
")",
")",
";",
"$",
"this",
"->",
"relationalParameter",
"=",
"$",
"tokens",
"[",
"1",
"]",
";",
"$",
"this",
"->",
"model",
"=",
"ucwords",
"(",
"strtolower",
"(",
"$",
"tokens",
"[",
"2",
"]",
")",
")",
";",
"break",
";",
"default",
":",
"$",
"this",
"->",
"relationalModel",
"=",
"ucwords",
"(",
"strtolower",
"(",
"$",
"tokens",
"[",
"0",
"]",
")",
")",
";",
"$",
"this",
"->",
"relationalParameter",
"=",
"$",
"tokens",
"[",
"1",
"]",
";",
"$",
"this",
"->",
"model",
"=",
"ucwords",
"(",
"strtolower",
"(",
"$",
"tokens",
"[",
"2",
"]",
")",
")",
";",
"$",
"this",
"->",
"requiredParameter",
"=",
"$",
"tokens",
"[",
"3",
"]",
";",
"break",
";",
"}",
"}",
"else",
"$",
"this",
"->",
"rootUrl",
"=",
"true",
";",
"}"
] | Preparación de las variables necesarias para el procedimiento REST. | [
"Preparación",
"de",
"las",
"variables",
"necesarias",
"para",
"el",
"procedimiento",
"REST",
"."
] | train | https://github.com/joalcapa/Fundamentary/blob/fd83dea5f90a92a38b42e3f5516f31137349601f/src/Http/Request.php#L55-L108 |
joalcapa/Fundamentary | src/Http/Request.php | Request.bodyRequest | public function bodyRequest($forApi = false) {
$json = file_get_contents('php://input');
$data = json_decode($json);
$forApi ? $requestWithBodyRequest = $this->getInteractionsRequestForApi() : $requestWithBodyRequest = $this->getInteractionsRequest();
foreach ($data as $key => $value)
$requestWithBodyRequest->$key = $value;
return $requestWithBodyRequest;
} | php | public function bodyRequest($forApi = false) {
$json = file_get_contents('php://input');
$data = json_decode($json);
$forApi ? $requestWithBodyRequest = $this->getInteractionsRequestForApi() : $requestWithBodyRequest = $this->getInteractionsRequest();
foreach ($data as $key => $value)
$requestWithBodyRequest->$key = $value;
return $requestWithBodyRequest;
} | [
"public",
"function",
"bodyRequest",
"(",
"$",
"forApi",
"=",
"false",
")",
"{",
"$",
"json",
"=",
"file_get_contents",
"(",
"'php://input'",
")",
";",
"$",
"data",
"=",
"json_decode",
"(",
"$",
"json",
")",
";",
"$",
"forApi",
"?",
"$",
"requestWithBodyRequest",
"=",
"$",
"this",
"->",
"getInteractionsRequestForApi",
"(",
")",
":",
"$",
"requestWithBodyRequest",
"=",
"$",
"this",
"->",
"getInteractionsRequest",
"(",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"$",
"requestWithBodyRequest",
"->",
"$",
"key",
"=",
"$",
"value",
";",
"return",
"$",
"requestWithBodyRequest",
";",
"}"
] | Retorno del cuerpo de Request.
@return array | [
"Retorno",
"del",
"cuerpo",
"de",
"Request",
"."
] | train | https://github.com/joalcapa/Fundamentary/blob/fd83dea5f90a92a38b42e3f5516f31137349601f/src/Http/Request.php#L160-L169 |
joalcapa/Fundamentary | src/Http/Request.php | Request.input | public function input($input) {
if(isset($this->inputs->$input))
return $this->inputs->$input;
return null;
} | php | public function input($input) {
if(isset($this->inputs->$input))
return $this->inputs->$input;
return null;
} | [
"public",
"function",
"input",
"(",
"$",
"input",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"inputs",
"->",
"$",
"input",
")",
")",
"return",
"$",
"this",
"->",
"inputs",
"->",
"$",
"input",
";",
"return",
"null",
";",
"}"
] | Retorno de la variable enviada por el cliente.
@return string | [
"Retorno",
"de",
"la",
"variable",
"enviada",
"por",
"el",
"cliente",
"."
] | train | https://github.com/joalcapa/Fundamentary/blob/fd83dea5f90a92a38b42e3f5516f31137349601f/src/Http/Request.php#L176-L180 |
joalcapa/Fundamentary | src/Http/Request.php | Request.authorizationToken | public function authorizationToken() {
$headers = apache_request_headers();
foreach ($headers as $header => $value)
if($header == 'Authorization') {
$tokens = explode(" ", $value);
if($tokens[0] != 'Bearer' || empty($tokens[1]))
killer('511');
return $tokens[1];
}
killer('401');
} | php | public function authorizationToken() {
$headers = apache_request_headers();
foreach ($headers as $header => $value)
if($header == 'Authorization') {
$tokens = explode(" ", $value);
if($tokens[0] != 'Bearer' || empty($tokens[1]))
killer('511');
return $tokens[1];
}
killer('401');
} | [
"public",
"function",
"authorizationToken",
"(",
")",
"{",
"$",
"headers",
"=",
"apache_request_headers",
"(",
")",
";",
"foreach",
"(",
"$",
"headers",
"as",
"$",
"header",
"=>",
"$",
"value",
")",
"if",
"(",
"$",
"header",
"==",
"'Authorization'",
")",
"{",
"$",
"tokens",
"=",
"explode",
"(",
"\" \"",
",",
"$",
"value",
")",
";",
"if",
"(",
"$",
"tokens",
"[",
"0",
"]",
"!=",
"'Bearer'",
"||",
"empty",
"(",
"$",
"tokens",
"[",
"1",
"]",
")",
")",
"killer",
"(",
"'511'",
")",
";",
"return",
"$",
"tokens",
"[",
"1",
"]",
";",
"}",
"killer",
"(",
"'401'",
")",
";",
"}"
] | Retorno del token de autenticación presente en el header authorization.
@return string | [
"Retorno",
"del",
"token",
"de",
"autenticación",
"presente",
"en",
"el",
"header",
"authorization",
"."
] | train | https://github.com/joalcapa/Fundamentary/blob/fd83dea5f90a92a38b42e3f5516f31137349601f/src/Http/Request.php#L227-L237 |
Vectrex/vxPHP | src/Http/ParameterBag.php | ParameterBag.get | public function get($path, $default = NULL, $deep = FALSE) {
return array_key_exists($path, $this->parameters) ? $this->parameters[$path] : $default;
} | php | public function get($path, $default = NULL, $deep = FALSE) {
return array_key_exists($path, $this->parameters) ? $this->parameters[$path] : $default;
} | [
"public",
"function",
"get",
"(",
"$",
"path",
",",
"$",
"default",
"=",
"NULL",
",",
"$",
"deep",
"=",
"FALSE",
")",
"{",
"return",
"array_key_exists",
"(",
"$",
"path",
",",
"$",
"this",
"->",
"parameters",
")",
"?",
"$",
"this",
"->",
"parameters",
"[",
"$",
"path",
"]",
":",
"$",
"default",
";",
"}"
] | Returns a parameter by name.
@param string $path The key
@param mixed $default The default value if the parameter key does not exist
@return mixed | [
"Returns",
"a",
"parameter",
"by",
"name",
"."
] | train | https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Http/ParameterBag.php#L88-L92 |
Vectrex/vxPHP | src/Http/ParameterBag.php | ParameterBag.filter | public function filter($key, $default = NULL, $filter = FILTER_DEFAULT, $options = array()) {
$value = $this->get($key, $default);
// Always turn $options into an array - this allows filter_var option shortcuts.
if (!is_array($options) && $options) {
$options = array('flags' => $options);
}
// Add a convenience check for arrays.
if (is_array($value) && !isset($options['flags'])) {
$options['flags'] = FILTER_REQUIRE_ARRAY;
}
return filter_var($value, $filter, $options);
} | php | public function filter($key, $default = NULL, $filter = FILTER_DEFAULT, $options = array()) {
$value = $this->get($key, $default);
// Always turn $options into an array - this allows filter_var option shortcuts.
if (!is_array($options) && $options) {
$options = array('flags' => $options);
}
// Add a convenience check for arrays.
if (is_array($value) && !isset($options['flags'])) {
$options['flags'] = FILTER_REQUIRE_ARRAY;
}
return filter_var($value, $filter, $options);
} | [
"public",
"function",
"filter",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"NULL",
",",
"$",
"filter",
"=",
"FILTER_DEFAULT",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"key",
",",
"$",
"default",
")",
";",
"// Always turn $options into an array - this allows filter_var option shortcuts.",
"if",
"(",
"!",
"is_array",
"(",
"$",
"options",
")",
"&&",
"$",
"options",
")",
"{",
"$",
"options",
"=",
"array",
"(",
"'flags'",
"=>",
"$",
"options",
")",
";",
"}",
"// Add a convenience check for arrays.",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
"&&",
"!",
"isset",
"(",
"$",
"options",
"[",
"'flags'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'flags'",
"]",
"=",
"FILTER_REQUIRE_ARRAY",
";",
"}",
"return",
"filter_var",
"(",
"$",
"value",
",",
"$",
"filter",
",",
"$",
"options",
")",
";",
"}"
] | Filter key.
@param string $key Key.
@param mixed $default Default = NULL.
@param integer $filter FILTER_* constant.
@param mixed $options Filter options.
@see http://php.net/manual/en/function.filter-var.php
@return mixed | [
"Filter",
"key",
"."
] | train | https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Http/ParameterBag.php#L213-L231 |
g4code/runner | src/RunnerAbstract.php | RunnerAbstract.run | public final function run()
{
$this->route();
$this->parseApplicationMethod();
$this->application = new Application($this);
$this->logger->logRequest($this->application);
$this->application->run();
$contentType = new ContentType($this->getDataTransfer(), $this->headerAccept);
(new Presenter($this->responseFormatter, $contentType))->render();
$this->logger->logResponse($this->application, $this->profiler);
} | php | public final function run()
{
$this->route();
$this->parseApplicationMethod();
$this->application = new Application($this);
$this->logger->logRequest($this->application);
$this->application->run();
$contentType = new ContentType($this->getDataTransfer(), $this->headerAccept);
(new Presenter($this->responseFormatter, $contentType))->render();
$this->logger->logResponse($this->application, $this->profiler);
} | [
"public",
"final",
"function",
"run",
"(",
")",
"{",
"$",
"this",
"->",
"route",
"(",
")",
";",
"$",
"this",
"->",
"parseApplicationMethod",
"(",
")",
";",
"$",
"this",
"->",
"application",
"=",
"new",
"Application",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"logRequest",
"(",
"$",
"this",
"->",
"application",
")",
";",
"$",
"this",
"->",
"application",
"->",
"run",
"(",
")",
";",
"$",
"contentType",
"=",
"new",
"ContentType",
"(",
"$",
"this",
"->",
"getDataTransfer",
"(",
")",
",",
"$",
"this",
"->",
"headerAccept",
")",
";",
"(",
"new",
"Presenter",
"(",
"$",
"this",
"->",
"responseFormatter",
",",
"$",
"contentType",
")",
")",
"->",
"render",
"(",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"logResponse",
"(",
"$",
"this",
"->",
"application",
",",
"$",
"this",
"->",
"profiler",
")",
";",
"}"
] | TODO: Drasko: refactor this! | [
"TODO",
":",
"Drasko",
":",
"refactor",
"this!"
] | train | https://github.com/g4code/runner/blob/a151eb79d16bec235f4d2ff9d9137ef9b7fa05d4/src/RunnerAbstract.php#L147-L163 |
zapheus/zapheus | src/Http/Message/Message.php | Message.header | public function header($name)
{
$exists = isset($this->headers[$name]);
return $exists ? $this->headers[$name] : array();
// getHeader
} | php | public function header($name)
{
$exists = isset($this->headers[$name]);
return $exists ? $this->headers[$name] : array();
// getHeader
} | [
"public",
"function",
"header",
"(",
"$",
"name",
")",
"{",
"$",
"exists",
"=",
"isset",
"(",
"$",
"this",
"->",
"headers",
"[",
"$",
"name",
"]",
")",
";",
"return",
"$",
"exists",
"?",
"$",
"this",
"->",
"headers",
"[",
"$",
"name",
"]",
":",
"array",
"(",
")",
";",
"// getHeader",
"}"
] | Returns a message header value by the given case-insensitive name.
@param string $name
@return array | [
"Returns",
"a",
"message",
"header",
"value",
"by",
"the",
"given",
"case",
"-",
"insensitive",
"name",
"."
] | train | https://github.com/zapheus/zapheus/blob/96618b5cee7d20b6700d0475e4334ae4b5163a6b/src/Http/Message/Message.php#L59-L66 |
qingbing/php-database | src/supports/Builder/Traits/BuilderFind.php | BuilderFind.setDistinct | public function setDistinct($isDistinct)
{
if (true === $isDistinct) {
$this->query['distinct'] = true;
} else {
$this->query['distinct'] = false;
}
return $this;
} | php | public function setDistinct($isDistinct)
{
if (true === $isDistinct) {
$this->query['distinct'] = true;
} else {
$this->query['distinct'] = false;
}
return $this;
} | [
"public",
"function",
"setDistinct",
"(",
"$",
"isDistinct",
")",
"{",
"if",
"(",
"true",
"===",
"$",
"isDistinct",
")",
"{",
"$",
"this",
"->",
"query",
"[",
"'distinct'",
"]",
"=",
"true",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"query",
"[",
"'distinct'",
"]",
"=",
"false",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | 设置 SELECT-distinct 子句
@param bool $isDistinct
@return $this | [
"设置",
"SELECT",
"-",
"distinct",
"子句"
] | train | https://github.com/qingbing/php-database/blob/cfd915c9d25dbe5d5cdd9b4c93eca5fd63cb7015/src/supports/Builder/Traits/BuilderFind.php#L21-L29 |
qingbing/php-database | src/supports/Builder/Traits/BuilderFind.php | BuilderFind.addSelect | public function addSelect($select)
{
if (null === $select) {
return $this;
}
if (is_array($select)) {
$t = [];
foreach ($select as $field => $alias) {
if (is_int($field)) {
$alias = $this->quoteColumnName($alias);
array_push($t, "{$alias}");
} else {
$field = $this->quoteColumnName($field);
$alias = $this->quoteColumnName($alias);
array_push($t, "{$field} AS {$alias}");
}
}
$select = implode(',', $t);
}
if (isset($this->query['select']) && !empty($this->query['select'])) {
$select = "{$this->query['select']},{$select}";
}
$this->query['select'] = $select;
return $this;
} | php | public function addSelect($select)
{
if (null === $select) {
return $this;
}
if (is_array($select)) {
$t = [];
foreach ($select as $field => $alias) {
if (is_int($field)) {
$alias = $this->quoteColumnName($alias);
array_push($t, "{$alias}");
} else {
$field = $this->quoteColumnName($field);
$alias = $this->quoteColumnName($alias);
array_push($t, "{$field} AS {$alias}");
}
}
$select = implode(',', $t);
}
if (isset($this->query['select']) && !empty($this->query['select'])) {
$select = "{$this->query['select']},{$select}";
}
$this->query['select'] = $select;
return $this;
} | [
"public",
"function",
"addSelect",
"(",
"$",
"select",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"select",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"select",
")",
")",
"{",
"$",
"t",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"select",
"as",
"$",
"field",
"=>",
"$",
"alias",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"field",
")",
")",
"{",
"$",
"alias",
"=",
"$",
"this",
"->",
"quoteColumnName",
"(",
"$",
"alias",
")",
";",
"array_push",
"(",
"$",
"t",
",",
"\"{$alias}\"",
")",
";",
"}",
"else",
"{",
"$",
"field",
"=",
"$",
"this",
"->",
"quoteColumnName",
"(",
"$",
"field",
")",
";",
"$",
"alias",
"=",
"$",
"this",
"->",
"quoteColumnName",
"(",
"$",
"alias",
")",
";",
"array_push",
"(",
"$",
"t",
",",
"\"{$field} AS {$alias}\"",
")",
";",
"}",
"}",
"$",
"select",
"=",
"implode",
"(",
"','",
",",
"$",
"t",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"query",
"[",
"'select'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"query",
"[",
"'select'",
"]",
")",
")",
"{",
"$",
"select",
"=",
"\"{$this->query['select']},{$select}\"",
";",
"}",
"$",
"this",
"->",
"query",
"[",
"'select'",
"]",
"=",
"$",
"select",
";",
"return",
"$",
"this",
";",
"}"
] | 添加 SELECT-select 内容
@param mixed $select
@return $this | [
"添加",
"SELECT",
"-",
"select",
"内容"
] | train | https://github.com/qingbing/php-database/blob/cfd915c9d25dbe5d5cdd9b4c93eca5fd63cb7015/src/supports/Builder/Traits/BuilderFind.php#L47-L71 |
qingbing/php-database | src/supports/Builder/Traits/BuilderFind.php | BuilderFind.setAlias | public function setAlias($alias = null)
{
if (!empty($alias)) {
$this->query['alias'] = $alias;
} else {
unset($this->query['alias']);
}
return $this;
} | php | public function setAlias($alias = null)
{
if (!empty($alias)) {
$this->query['alias'] = $alias;
} else {
unset($this->query['alias']);
}
return $this;
} | [
"public",
"function",
"setAlias",
"(",
"$",
"alias",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"alias",
")",
")",
"{",
"$",
"this",
"->",
"query",
"[",
"'alias'",
"]",
"=",
"$",
"alias",
";",
"}",
"else",
"{",
"unset",
"(",
"$",
"this",
"->",
"query",
"[",
"'alias'",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | 设置 SQL 语句主表别名
@param string $alias
@return $this | [
"设置",
"SQL",
"语句主表别名"
] | train | https://github.com/qingbing/php-database/blob/cfd915c9d25dbe5d5cdd9b4c93eca5fd63cb7015/src/supports/Builder/Traits/BuilderFind.php#L78-L86 |
qingbing/php-database | src/supports/Builder/Traits/BuilderFind.php | BuilderFind.addJoin | public function addJoin($join)
{
if (null === $join)
return $this;
if (!isset($this->query['join'])) {
$this->query['join'] = [];
}
$this->query['join'][] = $join;
return $this;
} | php | public function addJoin($join)
{
if (null === $join)
return $this;
if (!isset($this->query['join'])) {
$this->query['join'] = [];
}
$this->query['join'][] = $join;
return $this;
} | [
"public",
"function",
"addJoin",
"(",
"$",
"join",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"join",
")",
"return",
"$",
"this",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"query",
"[",
"'join'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"query",
"[",
"'join'",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"this",
"->",
"query",
"[",
"'join'",
"]",
"[",
"]",
"=",
"$",
"join",
";",
"return",
"$",
"this",
";",
"}"
] | 添加 SELECT-join 内容
@param string $join
@return $this | [
"添加",
"SELECT",
"-",
"join",
"内容"
] | train | https://github.com/qingbing/php-database/blob/cfd915c9d25dbe5d5cdd9b4c93eca5fd63cb7015/src/supports/Builder/Traits/BuilderFind.php#L104-L113 |
qingbing/php-database | src/supports/Builder/Traits/BuilderFind.php | BuilderFind.setGroup | public function setGroup($group)
{
if (!empty($group)) {
$this->query['group'] = $group;
} else {
unset($this->query['group']);
}
return $this;
} | php | public function setGroup($group)
{
if (!empty($group)) {
$this->query['group'] = $group;
} else {
unset($this->query['group']);
}
return $this;
} | [
"public",
"function",
"setGroup",
"(",
"$",
"group",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"group",
")",
")",
"{",
"$",
"this",
"->",
"query",
"[",
"'group'",
"]",
"=",
"$",
"group",
";",
"}",
"else",
"{",
"unset",
"(",
"$",
"this",
"->",
"query",
"[",
"'group'",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | 设置 SELECT-group 子句
@param string $group
@return $this | [
"设置",
"SELECT",
"-",
"group",
"子句"
] | train | https://github.com/qingbing/php-database/blob/cfd915c9d25dbe5d5cdd9b4c93eca5fd63cb7015/src/supports/Builder/Traits/BuilderFind.php#L120-L128 |
qingbing/php-database | src/supports/Builder/Traits/BuilderFind.php | BuilderFind.setHaving | public function setHaving($having)
{
if (!empty($having)) {
$this->query['having'] = $having;
} else {
unset($this->query['having']);
}
return $this;
} | php | public function setHaving($having)
{
if (!empty($having)) {
$this->query['having'] = $having;
} else {
unset($this->query['having']);
}
return $this;
} | [
"public",
"function",
"setHaving",
"(",
"$",
"having",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"having",
")",
")",
"{",
"$",
"this",
"->",
"query",
"[",
"'having'",
"]",
"=",
"$",
"having",
";",
"}",
"else",
"{",
"unset",
"(",
"$",
"this",
"->",
"query",
"[",
"'having'",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | 设置 SELECT-having 子句
@param string $having
@return $this | [
"设置",
"SELECT",
"-",
"having",
"子句"
] | train | https://github.com/qingbing/php-database/blob/cfd915c9d25dbe5d5cdd9b4c93eca5fd63cb7015/src/supports/Builder/Traits/BuilderFind.php#L135-L143 |
qingbing/php-database | src/supports/Builder/Traits/BuilderFind.php | BuilderFind.addUnion | public function addUnion($union)
{
if (null === $union)
return $this;
if (!isset($this->query['union'])) {
$this->query['union'] = [];
}
$this->query['union'][] = $union;
return $this;
} | php | public function addUnion($union)
{
if (null === $union)
return $this;
if (!isset($this->query['union'])) {
$this->query['union'] = [];
}
$this->query['union'][] = $union;
return $this;
} | [
"public",
"function",
"addUnion",
"(",
"$",
"union",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"union",
")",
"return",
"$",
"this",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"query",
"[",
"'union'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"query",
"[",
"'union'",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"this",
"->",
"query",
"[",
"'union'",
"]",
"[",
"]",
"=",
"$",
"union",
";",
"return",
"$",
"this",
";",
"}"
] | 添加 SELECT-union 内容
@param string $union
@return $this | [
"添加",
"SELECT",
"-",
"union",
"内容"
] | train | https://github.com/qingbing/php-database/blob/cfd915c9d25dbe5d5cdd9b4c93eca5fd63cb7015/src/supports/Builder/Traits/BuilderFind.php#L161-L170 |
qingbing/php-database | src/supports/Builder/Traits/BuilderFind.php | BuilderFind.setOrder | public function setOrder($order)
{
if (!empty($order)) {
$this->query['order'] = $order;
} else {
unset($this->query['order']);
}
return $this;
} | php | public function setOrder($order)
{
if (!empty($order)) {
$this->query['order'] = $order;
} else {
unset($this->query['order']);
}
return $this;
} | [
"public",
"function",
"setOrder",
"(",
"$",
"order",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"order",
")",
")",
"{",
"$",
"this",
"->",
"query",
"[",
"'order'",
"]",
"=",
"$",
"order",
";",
"}",
"else",
"{",
"unset",
"(",
"$",
"this",
"->",
"query",
"[",
"'order'",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | 设置 SELECT-order 子句
@param string $order
@return $this | [
"设置",
"SELECT",
"-",
"order",
"子句"
] | train | https://github.com/qingbing/php-database/blob/cfd915c9d25dbe5d5cdd9b4c93eca5fd63cb7015/src/supports/Builder/Traits/BuilderFind.php#L177-L185 |
qingbing/php-database | src/supports/Builder/Traits/BuilderFind.php | BuilderFind.addCriteria | public function addCriteria($criteria, $operator = 'AND')
{
if (!$criteria instanceof Criteria) {
return $this;
}
$query = $criteria->getQuery();
// distinct
isset($query['distinct']) && $this->setDistinct($query['distinct']);
// select
isset($query['select']) && !empty($query['select']) && $this->addSelect($query['select']);
// table
isset($query['table']) && !empty($query['table']) && $this->setTable($query['table']);
// alias
isset($query['alias']) && !empty($query['alias']) && $this->setAlias($query['alias']);
// join
if (isset($query['join']) && !empty($query['join'])) {
foreach ($query['join'] as $join) {
$this->addJoin($join);
}
}
// where
// 添加 WHERE 条件
isset($query['where']) && $this->addWhere($query['where'], [], $operator);
// group
isset($query['group']) && !empty($query['group']) && $this->setGroup($query['group']);
// having
isset($query['having']) && !empty($query['having']) && $this->setHaving($query['having']);
// union
if (isset($query['union']) && !empty($query['union'])) {
foreach ($query['union'] as $union) {
$this->addUnion($union);
}
}
// order
isset($query['order']) && !empty($query['order']) && $this->setOrder($query['order']);
// limit
isset($query['limit']) && $this->setLimit($query['limit']);
// offset
isset($query['offset']) && $this->setOffset($query['offset']);
// bind params
$this->addParams($criteria->getParams());
return $this;
} | php | public function addCriteria($criteria, $operator = 'AND')
{
if (!$criteria instanceof Criteria) {
return $this;
}
$query = $criteria->getQuery();
// distinct
isset($query['distinct']) && $this->setDistinct($query['distinct']);
// select
isset($query['select']) && !empty($query['select']) && $this->addSelect($query['select']);
// table
isset($query['table']) && !empty($query['table']) && $this->setTable($query['table']);
// alias
isset($query['alias']) && !empty($query['alias']) && $this->setAlias($query['alias']);
// join
if (isset($query['join']) && !empty($query['join'])) {
foreach ($query['join'] as $join) {
$this->addJoin($join);
}
}
// where
// 添加 WHERE 条件
isset($query['where']) && $this->addWhere($query['where'], [], $operator);
// group
isset($query['group']) && !empty($query['group']) && $this->setGroup($query['group']);
// having
isset($query['having']) && !empty($query['having']) && $this->setHaving($query['having']);
// union
if (isset($query['union']) && !empty($query['union'])) {
foreach ($query['union'] as $union) {
$this->addUnion($union);
}
}
// order
isset($query['order']) && !empty($query['order']) && $this->setOrder($query['order']);
// limit
isset($query['limit']) && $this->setLimit($query['limit']);
// offset
isset($query['offset']) && $this->setOffset($query['offset']);
// bind params
$this->addParams($criteria->getParams());
return $this;
} | [
"public",
"function",
"addCriteria",
"(",
"$",
"criteria",
",",
"$",
"operator",
"=",
"'AND'",
")",
"{",
"if",
"(",
"!",
"$",
"criteria",
"instanceof",
"Criteria",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"query",
"=",
"$",
"criteria",
"->",
"getQuery",
"(",
")",
";",
"// distinct\r",
"isset",
"(",
"$",
"query",
"[",
"'distinct'",
"]",
")",
"&&",
"$",
"this",
"->",
"setDistinct",
"(",
"$",
"query",
"[",
"'distinct'",
"]",
")",
";",
"// select\r",
"isset",
"(",
"$",
"query",
"[",
"'select'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"query",
"[",
"'select'",
"]",
")",
"&&",
"$",
"this",
"->",
"addSelect",
"(",
"$",
"query",
"[",
"'select'",
"]",
")",
";",
"// table\r",
"isset",
"(",
"$",
"query",
"[",
"'table'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"query",
"[",
"'table'",
"]",
")",
"&&",
"$",
"this",
"->",
"setTable",
"(",
"$",
"query",
"[",
"'table'",
"]",
")",
";",
"// alias\r",
"isset",
"(",
"$",
"query",
"[",
"'alias'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"query",
"[",
"'alias'",
"]",
")",
"&&",
"$",
"this",
"->",
"setAlias",
"(",
"$",
"query",
"[",
"'alias'",
"]",
")",
";",
"// join\r",
"if",
"(",
"isset",
"(",
"$",
"query",
"[",
"'join'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"query",
"[",
"'join'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"query",
"[",
"'join'",
"]",
"as",
"$",
"join",
")",
"{",
"$",
"this",
"->",
"addJoin",
"(",
"$",
"join",
")",
";",
"}",
"}",
"// where\r",
"// 添加 WHERE 条件\r",
"isset",
"(",
"$",
"query",
"[",
"'where'",
"]",
")",
"&&",
"$",
"this",
"->",
"addWhere",
"(",
"$",
"query",
"[",
"'where'",
"]",
",",
"[",
"]",
",",
"$",
"operator",
")",
";",
"// group\r",
"isset",
"(",
"$",
"query",
"[",
"'group'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"query",
"[",
"'group'",
"]",
")",
"&&",
"$",
"this",
"->",
"setGroup",
"(",
"$",
"query",
"[",
"'group'",
"]",
")",
";",
"// having\r",
"isset",
"(",
"$",
"query",
"[",
"'having'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"query",
"[",
"'having'",
"]",
")",
"&&",
"$",
"this",
"->",
"setHaving",
"(",
"$",
"query",
"[",
"'having'",
"]",
")",
";",
"// union\r",
"if",
"(",
"isset",
"(",
"$",
"query",
"[",
"'union'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"query",
"[",
"'union'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"query",
"[",
"'union'",
"]",
"as",
"$",
"union",
")",
"{",
"$",
"this",
"->",
"addUnion",
"(",
"$",
"union",
")",
";",
"}",
"}",
"// order\r",
"isset",
"(",
"$",
"query",
"[",
"'order'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"query",
"[",
"'order'",
"]",
")",
"&&",
"$",
"this",
"->",
"setOrder",
"(",
"$",
"query",
"[",
"'order'",
"]",
")",
";",
"// limit\r",
"isset",
"(",
"$",
"query",
"[",
"'limit'",
"]",
")",
"&&",
"$",
"this",
"->",
"setLimit",
"(",
"$",
"query",
"[",
"'limit'",
"]",
")",
";",
"// offset\r",
"isset",
"(",
"$",
"query",
"[",
"'offset'",
"]",
")",
"&&",
"$",
"this",
"->",
"setOffset",
"(",
"$",
"query",
"[",
"'offset'",
"]",
")",
";",
"// bind params\r",
"$",
"this",
"->",
"addParams",
"(",
"$",
"criteria",
"->",
"getParams",
"(",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | 添加SQL标准
@param Criteria $criteria
@param string $operator
@return $this | [
"添加SQL标准"
] | train | https://github.com/qingbing/php-database/blob/cfd915c9d25dbe5d5cdd9b4c93eca5fd63cb7015/src/supports/Builder/Traits/BuilderFind.php#L223-L266 |
teonsystems/php-base | src/Model/Doctrine/GetterSetterTrait.php | GetterSetterTrait.___getterSetterGetEntity | protected function ___getterSetterGetEntity ()
{
// Determine entity name
$entityName = $this->___getterSetterGetEntityPropertyName();
// Check if entity exists
if (!isset($this->{$entityName})) {
throw new Exception("Entity property is not set: $entityName");
}
// Check if entity is of proper class
$requestedClass = $this->___getterSetterGetEntityClass();
if (false !== $requestedClass) {
if (!($this->{$entityName} instanceof $requestedClass)) {
throw new Exception("Entity is not an instance of requested class: $requestedClass");
}
}
return $this->{$entityName};
} | php | protected function ___getterSetterGetEntity ()
{
// Determine entity name
$entityName = $this->___getterSetterGetEntityPropertyName();
// Check if entity exists
if (!isset($this->{$entityName})) {
throw new Exception("Entity property is not set: $entityName");
}
// Check if entity is of proper class
$requestedClass = $this->___getterSetterGetEntityClass();
if (false !== $requestedClass) {
if (!($this->{$entityName} instanceof $requestedClass)) {
throw new Exception("Entity is not an instance of requested class: $requestedClass");
}
}
return $this->{$entityName};
} | [
"protected",
"function",
"___getterSetterGetEntity",
"(",
")",
"{",
"// Determine entity name",
"$",
"entityName",
"=",
"$",
"this",
"->",
"___getterSetterGetEntityPropertyName",
"(",
")",
";",
"// Check if entity exists",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"{",
"$",
"entityName",
"}",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Entity property is not set: $entityName\"",
")",
";",
"}",
"// Check if entity is of proper class",
"$",
"requestedClass",
"=",
"$",
"this",
"->",
"___getterSetterGetEntityClass",
"(",
")",
";",
"if",
"(",
"false",
"!==",
"$",
"requestedClass",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"this",
"->",
"{",
"$",
"entityName",
"}",
"instanceof",
"$",
"requestedClass",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Entity is not an instance of requested class: $requestedClass\"",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"{",
"$",
"entityName",
"}",
";",
"}"
] | Get entity object
Determines entity object name, returns it if it exists
@throws Exception If entity object is not found
@return \Zend\Db\Row\RowGateway | [
"Get",
"entity",
"object"
] | train | https://github.com/teonsystems/php-base/blob/010418fd9df3c447a74b36cf0d31e2d38a6527ac/src/Model/Doctrine/GetterSetterTrait.php#L251-L270 |
teonsystems/php-base | src/Model/Doctrine/GetterSetterTrait.php | GetterSetterTrait.___getterSetterCheckAccess | protected function ___getterSetterCheckAccess ($type, $name)
{
// Check for explicit definition
if (isset($this->_getterSetterAccessMap)) {
if (array_key_exists($name, $this->_getterSetterAccessMap)) {
if (array_key_exists($type, $this->_getterSetterAccessMap[$name])) {
return $this->_getterSetterAccessMap[$name][$type];
}
}
}
// Check for default privilege setting
$typeUcf = ucfirst($type);
$defaultAccessPropertyName = "_getterSetterDefault{$typeUcf}Allow";
if (isset($this->{$defaultAccessPropertyName})) {
return $this->{$defaultAccessPropertyName};
}
// Otherwise return default sensible answer (write no, read yes)
if ('read' == $type) {
return true;
} else {
return false;
}
} | php | protected function ___getterSetterCheckAccess ($type, $name)
{
// Check for explicit definition
if (isset($this->_getterSetterAccessMap)) {
if (array_key_exists($name, $this->_getterSetterAccessMap)) {
if (array_key_exists($type, $this->_getterSetterAccessMap[$name])) {
return $this->_getterSetterAccessMap[$name][$type];
}
}
}
// Check for default privilege setting
$typeUcf = ucfirst($type);
$defaultAccessPropertyName = "_getterSetterDefault{$typeUcf}Allow";
if (isset($this->{$defaultAccessPropertyName})) {
return $this->{$defaultAccessPropertyName};
}
// Otherwise return default sensible answer (write no, read yes)
if ('read' == $type) {
return true;
} else {
return false;
}
} | [
"protected",
"function",
"___getterSetterCheckAccess",
"(",
"$",
"type",
",",
"$",
"name",
")",
"{",
"// Check for explicit definition",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_getterSetterAccessMap",
")",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"_getterSetterAccessMap",
")",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"type",
",",
"$",
"this",
"->",
"_getterSetterAccessMap",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_getterSetterAccessMap",
"[",
"$",
"name",
"]",
"[",
"$",
"type",
"]",
";",
"}",
"}",
"}",
"// Check for default privilege setting",
"$",
"typeUcf",
"=",
"ucfirst",
"(",
"$",
"type",
")",
";",
"$",
"defaultAccessPropertyName",
"=",
"\"_getterSetterDefault{$typeUcf}Allow\"",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"{",
"$",
"defaultAccessPropertyName",
"}",
")",
")",
"{",
"return",
"$",
"this",
"->",
"{",
"$",
"defaultAccessPropertyName",
"}",
";",
"}",
"// Otherwise return default sensible answer (write no, read yes)",
"if",
"(",
"'read'",
"==",
"$",
"type",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] | Check GENERAL access to the property
@param string Type of access to check for
@param string Property name to check access for
@return bool | [
"Check",
"GENERAL",
"access",
"to",
"the",
"property"
] | train | https://github.com/teonsystems/php-base/blob/010418fd9df3c447a74b36cf0d31e2d38a6527ac/src/Model/Doctrine/GetterSetterTrait.php#L342-L366 |
miaoxing/user | src/Plugin.php | Plugin.onAsyncUserCreate | public function onAsyncUserCreate(User $user)
{
if ($user['groupId']) {
return;
}
$defaultGroupId = wei()->setting('user.defaultGroupId', 0);
if ($defaultGroupId) {
$user->updateGroup($defaultGroupId);
}
} | php | public function onAsyncUserCreate(User $user)
{
if ($user['groupId']) {
return;
}
$defaultGroupId = wei()->setting('user.defaultGroupId', 0);
if ($defaultGroupId) {
$user->updateGroup($defaultGroupId);
}
} | [
"public",
"function",
"onAsyncUserCreate",
"(",
"User",
"$",
"user",
")",
"{",
"if",
"(",
"$",
"user",
"[",
"'groupId'",
"]",
")",
"{",
"return",
";",
"}",
"$",
"defaultGroupId",
"=",
"wei",
"(",
")",
"->",
"setting",
"(",
"'user.defaultGroupId'",
",",
"0",
")",
";",
"if",
"(",
"$",
"defaultGroupId",
")",
"{",
"$",
"user",
"->",
"updateGroup",
"(",
"$",
"defaultGroupId",
")",
";",
"}",
"}"
] | 创建用户后,将用户移到默认分组
@param User $user | [
"创建用户后",
"将用户移到默认分组"
] | train | https://github.com/miaoxing/user/blob/d94e52f64a0151ba7202c857b373394ad09e06ce/src/Plugin.php#L100-L110 |
zodream/database | src/Schema/Column.php | Column.timestamp | public function timestamp($arg = null) {
$sql = 'TIMESTAMP';
if (!empty($arg)) {
$sql .= '('.intval($arg).')';
}
return $this->addData(self::KIND, $sql);
} | php | public function timestamp($arg = null) {
$sql = 'TIMESTAMP';
if (!empty($arg)) {
$sql .= '('.intval($arg).')';
}
return $this->addData(self::KIND, $sql);
} | [
"public",
"function",
"timestamp",
"(",
"$",
"arg",
"=",
"null",
")",
"{",
"$",
"sql",
"=",
"'TIMESTAMP'",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"arg",
")",
")",
"{",
"$",
"sql",
".=",
"'('",
".",
"intval",
"(",
"$",
"arg",
")",
".",
"')'",
";",
"}",
"return",
"$",
"this",
"->",
"addData",
"(",
"self",
"::",
"KIND",
",",
"$",
"sql",
")",
";",
"}"
] | 时间戳
@param integer $arg
@return Column | [
"时间戳"
] | train | https://github.com/zodream/database/blob/03712219c057799d07350a3a2650c55bcc92c28e/src/Schema/Column.php#L244-L250 |
bytic/MediaLibrary | src/Media/Media.php | Media.getUrl | public function getUrl(string $conversionName = ''): string
{
if ($this->hasFile()) {
return $this->getFile()->getUrl();
}
return $this->getCollection()->getDefaultMediaUrl();
// $urlGenerator = UrlGeneratorFactory::createForMedia($this);
// if ($conversionName !== '') {
//// $conversion = ConversionCollection::createForMedia($this)->getByName($conversionName);
//// $urlGenerator->setConversion($conversion);
// }
// return $urlGenerator->getUrl();
} | php | public function getUrl(string $conversionName = ''): string
{
if ($this->hasFile()) {
return $this->getFile()->getUrl();
}
return $this->getCollection()->getDefaultMediaUrl();
// $urlGenerator = UrlGeneratorFactory::createForMedia($this);
// if ($conversionName !== '') {
//// $conversion = ConversionCollection::createForMedia($this)->getByName($conversionName);
//// $urlGenerator->setConversion($conversion);
// }
// return $urlGenerator->getUrl();
} | [
"public",
"function",
"getUrl",
"(",
"string",
"$",
"conversionName",
"=",
"''",
")",
":",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"hasFile",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getFile",
"(",
")",
"->",
"getUrl",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"getCollection",
"(",
")",
"->",
"getDefaultMediaUrl",
"(",
")",
";",
"// $urlGenerator = UrlGeneratorFactory::createForMedia($this);",
"// if ($conversionName !== '') {",
"//// $conversion = ConversionCollection::createForMedia($this)->getByName($conversionName);",
"//// $urlGenerator->setConversion($conversion);",
"// }",
"// return $urlGenerator->getUrl();",
"}"
] | Get the url to a original media file.
@param string $conversionName
@return string | [
"Get",
"the",
"url",
"to",
"a",
"original",
"media",
"file",
"."
] | train | https://github.com/bytic/MediaLibrary/blob/c52783e726b512184bd72e04d829d6f93242a61d/src/Media/Media.php#L92-L104 |
tonis-io-legacy/router | src/RouteCollection.php | RouteCollection.offsetGet | public function offsetGet($offset)
{
if (!$this->offsetExists($offset)) {
throw new RouteDoesNotExistException($offset);
}
return $this->routes[$offset];
} | php | public function offsetGet($offset)
{
if (!$this->offsetExists($offset)) {
throw new RouteDoesNotExistException($offset);
}
return $this->routes[$offset];
} | [
"public",
"function",
"offsetGet",
"(",
"$",
"offset",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"offsetExists",
"(",
"$",
"offset",
")",
")",
"{",
"throw",
"new",
"RouteDoesNotExistException",
"(",
"$",
"offset",
")",
";",
"}",
"return",
"$",
"this",
"->",
"routes",
"[",
"$",
"offset",
"]",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/tonis-io-legacy/router/blob/f56115e9cca8f89a1282cd2f7609a917d13a4d9e/src/RouteCollection.php#L39-L45 |
tonis-io-legacy/router | src/RouteCollection.php | RouteCollection.offsetSet | public function offsetSet($offset, $value)
{
if (!$value instanceof Route) {
throw new InvalidRouteException;
}
if (null === $offset) {
$this->routes[] = $value;
} elseif (!isset($this->routes[$offset])) {
$this->routes[$offset] = $value;
} else {
throw new RouteExistsException($offset);
}
} | php | public function offsetSet($offset, $value)
{
if (!$value instanceof Route) {
throw new InvalidRouteException;
}
if (null === $offset) {
$this->routes[] = $value;
} elseif (!isset($this->routes[$offset])) {
$this->routes[$offset] = $value;
} else {
throw new RouteExistsException($offset);
}
} | [
"public",
"function",
"offsetSet",
"(",
"$",
"offset",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"$",
"value",
"instanceof",
"Route",
")",
"{",
"throw",
"new",
"InvalidRouteException",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"offset",
")",
"{",
"$",
"this",
"->",
"routes",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"elseif",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"routes",
"[",
"$",
"offset",
"]",
")",
")",
"{",
"$",
"this",
"->",
"routes",
"[",
"$",
"offset",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"throw",
"new",
"RouteExistsException",
"(",
"$",
"offset",
")",
";",
"}",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/tonis-io-legacy/router/blob/f56115e9cca8f89a1282cd2f7609a917d13a4d9e/src/RouteCollection.php#L50-L62 |
tonis-io-legacy/router | src/RouteCollection.php | RouteCollection.offsetUnset | public function offsetUnset($offset)
{
if (!$this->offsetExists($offset)) {
throw new RouteDoesNotExistException($offset);
}
unset($this->routes[$offset]);
} | php | public function offsetUnset($offset)
{
if (!$this->offsetExists($offset)) {
throw new RouteDoesNotExistException($offset);
}
unset($this->routes[$offset]);
} | [
"public",
"function",
"offsetUnset",
"(",
"$",
"offset",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"offsetExists",
"(",
"$",
"offset",
")",
")",
"{",
"throw",
"new",
"RouteDoesNotExistException",
"(",
"$",
"offset",
")",
";",
"}",
"unset",
"(",
"$",
"this",
"->",
"routes",
"[",
"$",
"offset",
"]",
")",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/tonis-io-legacy/router/blob/f56115e9cca8f89a1282cd2f7609a917d13a4d9e/src/RouteCollection.php#L67-L73 |
pipaslot/forms | src/Forms/FormFactory.php | FormFactory.create | public function create($secured = true)
{
$form = new Form();
if ($secured) $form->addProtection('Vypršel časový limit, odešlete formulář znovu');
$form->setTranslator($this->translator);
return $form;
} | php | public function create($secured = true)
{
$form = new Form();
if ($secured) $form->addProtection('Vypršel časový limit, odešlete formulář znovu');
$form->setTranslator($this->translator);
return $form;
} | [
"public",
"function",
"create",
"(",
"$",
"secured",
"=",
"true",
")",
"{",
"$",
"form",
"=",
"new",
"Form",
"(",
")",
";",
"if",
"(",
"$",
"secured",
")",
"$",
"form",
"->",
"addProtection",
"(",
"'Vypršel časový limit, odešlete formulář znovu');",
"",
"",
"$",
"form",
"->",
"setTranslator",
"(",
"$",
"this",
"->",
"translator",
")",
";",
"return",
"$",
"form",
";",
"}"
] | Create standard Nette form
@param bool|true $secured Enable Cross-Site Request Forgery Protection
@return Form|IForm | [
"Create",
"standard",
"Nette",
"form"
] | train | https://github.com/pipaslot/forms/blob/9e1d48db512f843270fd4079ed3ff1b1729c951b/src/Forms/FormFactory.php#L37-L43 |
pipaslot/forms | src/Forms/FormFactory.php | FormFactory.createBootstrap | public function createBootstrap($secured = true)
{
$form = $this->create($secured);
$form->setRenderer(new Bootstrap3Renderer());
return $form;
} | php | public function createBootstrap($secured = true)
{
$form = $this->create($secured);
$form->setRenderer(new Bootstrap3Renderer());
return $form;
} | [
"public",
"function",
"createBootstrap",
"(",
"$",
"secured",
"=",
"true",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"create",
"(",
"$",
"secured",
")",
";",
"$",
"form",
"->",
"setRenderer",
"(",
"new",
"Bootstrap3Renderer",
"(",
")",
")",
";",
"return",
"$",
"form",
";",
"}"
] | Create Form with Bootstrap styling
@param bool|true $secured
@return Form|IForm | [
"Create",
"Form",
"with",
"Bootstrap",
"styling"
] | train | https://github.com/pipaslot/forms/blob/9e1d48db512f843270fd4079ed3ff1b1729c951b/src/Forms/FormFactory.php#L50-L55 |
pipaslot/forms | src/Forms/FormFactory.php | FormFactory.createBootstrapInline | public function createBootstrapInline($secured = true)
{
$form = $this->create($secured);
$form->setRenderer(new Bootstrap3InlineRenderer());
return $form;
} | php | public function createBootstrapInline($secured = true)
{
$form = $this->create($secured);
$form->setRenderer(new Bootstrap3InlineRenderer());
return $form;
} | [
"public",
"function",
"createBootstrapInline",
"(",
"$",
"secured",
"=",
"true",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"create",
"(",
"$",
"secured",
")",
";",
"$",
"form",
"->",
"setRenderer",
"(",
"new",
"Bootstrap3InlineRenderer",
"(",
")",
")",
";",
"return",
"$",
"form",
";",
"}"
] | Create Form with inline Bootstrap styling
@param bool|true $secured
@return Form|IForm | [
"Create",
"Form",
"with",
"inline",
"Bootstrap",
"styling"
] | train | https://github.com/pipaslot/forms/blob/9e1d48db512f843270fd4079ed3ff1b1729c951b/src/Forms/FormFactory.php#L62-L67 |
pipaslot/forms | src/Forms/FormFactory.php | FormFactory.createBootstrapStacked | public function createBootstrapStacked($secured = true)
{
$form = $this->create($secured);
$form->setRenderer(new Bootstrap3StackRenderer());
return $form;
} | php | public function createBootstrapStacked($secured = true)
{
$form = $this->create($secured);
$form->setRenderer(new Bootstrap3StackRenderer());
return $form;
} | [
"public",
"function",
"createBootstrapStacked",
"(",
"$",
"secured",
"=",
"true",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"create",
"(",
"$",
"secured",
")",
";",
"$",
"form",
"->",
"setRenderer",
"(",
"new",
"Bootstrap3StackRenderer",
"(",
")",
")",
";",
"return",
"$",
"form",
";",
"}"
] | One column form where labels are placed to controls
@param bool|true $secured
@return Form|IForm | [
"One",
"column",
"form",
"where",
"labels",
"are",
"placed",
"to",
"controls"
] | train | https://github.com/pipaslot/forms/blob/9e1d48db512f843270fd4079ed3ff1b1729c951b/src/Forms/FormFactory.php#L74-L79 |
raykolbe/CKEditorModule | src/CKEditorModule/Module.php | Module.getViewHelperConfig | public function getViewHelperConfig()
{
return array(
'factories' => array(
'ckeditor' => function($sm) {
$config = $sm->getServiceLocator()->get('config');
return new View\Helper\CKEditor(
new Options($config['ckeditor'])
);
}
)
);
} | php | public function getViewHelperConfig()
{
return array(
'factories' => array(
'ckeditor' => function($sm) {
$config = $sm->getServiceLocator()->get('config');
return new View\Helper\CKEditor(
new Options($config['ckeditor'])
);
}
)
);
} | [
"public",
"function",
"getViewHelperConfig",
"(",
")",
"{",
"return",
"array",
"(",
"'factories'",
"=>",
"array",
"(",
"'ckeditor'",
"=>",
"function",
"(",
"$",
"sm",
")",
"{",
"$",
"config",
"=",
"$",
"sm",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'config'",
")",
";",
"return",
"new",
"View",
"\\",
"Helper",
"\\",
"CKEditor",
"(",
"new",
"Options",
"(",
"$",
"config",
"[",
"'ckeditor'",
"]",
")",
")",
";",
"}",
")",
")",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/raykolbe/CKEditorModule/blob/5088cc4ab085ee1e4ba9ee9d0209c27082c90259/src/CKEditorModule/Module.php#L19-L31 |
jenskooij/cloudcontrol | src/storage/factories/ImageFactory.php | ImageFactory.createImageFromPostValues | public static function createImageFromPostValues($postValues, $filename, $fileNames)
{
$imageObject = new \stdClass();
$imageObject->file = $filename;
$imageObject->type = $postValues['type'];
$imageObject->size = $postValues['size'];
$imageObject->set = $fileNames;
return new Image($imageObject);
} | php | public static function createImageFromPostValues($postValues, $filename, $fileNames)
{
$imageObject = new \stdClass();
$imageObject->file = $filename;
$imageObject->type = $postValues['type'];
$imageObject->size = $postValues['size'];
$imageObject->set = $fileNames;
return new Image($imageObject);
} | [
"public",
"static",
"function",
"createImageFromPostValues",
"(",
"$",
"postValues",
",",
"$",
"filename",
",",
"$",
"fileNames",
")",
"{",
"$",
"imageObject",
"=",
"new",
"\\",
"stdClass",
"(",
")",
";",
"$",
"imageObject",
"->",
"file",
"=",
"$",
"filename",
";",
"$",
"imageObject",
"->",
"type",
"=",
"$",
"postValues",
"[",
"'type'",
"]",
";",
"$",
"imageObject",
"->",
"size",
"=",
"$",
"postValues",
"[",
"'size'",
"]",
";",
"$",
"imageObject",
"->",
"set",
"=",
"$",
"fileNames",
";",
"return",
"new",
"Image",
"(",
"$",
"imageObject",
")",
";",
"}"
] | @param $postValues
@param $filename
@param $fileNames
@return Image | [
"@param",
"$postValues",
"@param",
"$filename",
"@param",
"$fileNames"
] | train | https://github.com/jenskooij/cloudcontrol/blob/76e5d9ac8f9c50d06d39a995d13cc03742536548/src/storage/factories/ImageFactory.php#L20-L29 |
DeimosProject/Helper | src/Helper/Helpers/Arr/KeyTrait.php | KeyTrait.oddKey | public function oddKey(array $storage)
{
return $this->filter($storage, function ($value, $key)
{
return $this->helper->math()->isOdd($key);
});
} | php | public function oddKey(array $storage)
{
return $this->filter($storage, function ($value, $key)
{
return $this->helper->math()->isOdd($key);
});
} | [
"public",
"function",
"oddKey",
"(",
"array",
"$",
"storage",
")",
"{",
"return",
"$",
"this",
"->",
"filter",
"(",
"$",
"storage",
",",
"function",
"(",
"$",
"value",
",",
"$",
"key",
")",
"{",
"return",
"$",
"this",
"->",
"helper",
"->",
"math",
"(",
")",
"->",
"isOdd",
"(",
"$",
"key",
")",
";",
"}",
")",
";",
"}"
] | 0=>'', 2=> ''...
@param array $storage
@return array | [
"0",
"=",
">",
"2",
"=",
">",
"..."
] | train | https://github.com/DeimosProject/Helper/blob/39c67de21a87c7c6391b2f98416063f41c94e26f/src/Helper/Helpers/Arr/KeyTrait.php#L50-L56 |
DeimosProject/Helper | src/Helper/Helpers/Arr/KeyTrait.php | KeyTrait.evenKey | public function evenKey(array $storage)
{
return $this->filter($storage, function ($value, $key)
{
return $this->helper->math()->isEven($key);
});
} | php | public function evenKey(array $storage)
{
return $this->filter($storage, function ($value, $key)
{
return $this->helper->math()->isEven($key);
});
} | [
"public",
"function",
"evenKey",
"(",
"array",
"$",
"storage",
")",
"{",
"return",
"$",
"this",
"->",
"filter",
"(",
"$",
"storage",
",",
"function",
"(",
"$",
"value",
",",
"$",
"key",
")",
"{",
"return",
"$",
"this",
"->",
"helper",
"->",
"math",
"(",
")",
"->",
"isEven",
"(",
"$",
"key",
")",
";",
"}",
")",
";",
"}"
] | 1=>'', 3=>''...
@param array $storage
@return array | [
"1",
"=",
">",
"3",
"=",
">",
"..."
] | train | https://github.com/DeimosProject/Helper/blob/39c67de21a87c7c6391b2f98416063f41c94e26f/src/Helper/Helpers/Arr/KeyTrait.php#L65-L71 |
qingbing/php-helper | src/lib/File.php | File.pathinfo | public function pathinfo($option = null)
{
if (null === $option) {
return pathinfo($this->_filePath);
}
return pathinfo($this->_filePath, $option);
} | php | public function pathinfo($option = null)
{
if (null === $option) {
return pathinfo($this->_filePath);
}
return pathinfo($this->_filePath, $option);
} | [
"public",
"function",
"pathinfo",
"(",
"$",
"option",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"option",
")",
"{",
"return",
"pathinfo",
"(",
"$",
"this",
"->",
"_filePath",
")",
";",
"}",
"return",
"pathinfo",
"(",
"$",
"this",
"->",
"_filePath",
",",
"$",
"option",
")",
";",
"}"
] | 获取文件的相应属性,文件不一定存在
@param null|int $option
PATHINFO_DIRNAME
PATHINFO_BASENAME
PATHINFO_EXTENSION
PATHINFO_FILENAME
@return mixed | [
"获取文件的相应属性,文件不一定存在"
] | train | https://github.com/qingbing/php-helper/blob/112d54ed2377db9f25604877b1a82e464f4ffd14/src/lib/File.php#L55-L61 |
qingbing/php-helper | src/lib/File.php | File.append | public function append($content, $needLine = false)
{
if ($needLine) {
$this->_stringBuffer .= "\r\n";
}
$this->_stringBuffer .= $content;
return $this;
} | php | public function append($content, $needLine = false)
{
if ($needLine) {
$this->_stringBuffer .= "\r\n";
}
$this->_stringBuffer .= $content;
return $this;
} | [
"public",
"function",
"append",
"(",
"$",
"content",
",",
"$",
"needLine",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"needLine",
")",
"{",
"$",
"this",
"->",
"_stringBuffer",
".=",
"\"\\r\\n\"",
";",
"}",
"$",
"this",
"->",
"_stringBuffer",
".=",
"$",
"content",
";",
"return",
"$",
"this",
";",
"}"
] | 将字符串追加到缓冲字符串中
@param string $content
@param bool $needLine
@return $this | [
"将字符串追加到缓冲字符串中"
] | train | https://github.com/qingbing/php-helper/blob/112d54ed2377db9f25604877b1a82e464f4ffd14/src/lib/File.php#L105-L112 |
qingbing/php-helper | src/lib/File.php | File.flush | public function flush()
{
if (false !== $many = $this->put($this->_stringBuffer, FILE_APPEND)) {
$this->_stringBuffer = "";
return $many;
}
throw new Exception("文件写入失败+", 100100302);
} | php | public function flush()
{
if (false !== $many = $this->put($this->_stringBuffer, FILE_APPEND)) {
$this->_stringBuffer = "";
return $many;
}
throw new Exception("文件写入失败+", 100100302);
} | [
"public",
"function",
"flush",
"(",
")",
"{",
"if",
"(",
"false",
"!==",
"$",
"many",
"=",
"$",
"this",
"->",
"put",
"(",
"$",
"this",
"->",
"_stringBuffer",
",",
"FILE_APPEND",
")",
")",
"{",
"$",
"this",
"->",
"_stringBuffer",
"=",
"\"\"",
";",
"return",
"$",
"many",
";",
"}",
"throw",
"new",
"Exception",
"(",
"\"文件写入失败+\", 100100302)",
";",
"",
"",
"",
"}"
] | 将缓冲内容追加到文件中
@return bool|int
@throws Exception | [
"将缓冲内容追加到文件中"
] | train | https://github.com/qingbing/php-helper/blob/112d54ed2377db9f25604877b1a82e464f4ffd14/src/lib/File.php#L119-L126 |
prolic/HumusMvc | src/HumusMvc/Translate/Service/TranslatorFactory.php | TranslatorFactory.createService | public function createService(ServiceLocatorInterface $serviceLocator)
{
$config = $serviceLocator->get('Config');
if (!isset($config['translator'])) {
throw new Exception\RuntimeException(
'No translator config found.'
);
}
$allOptions = $config['translator'];
foreach ($allOptions as $module => $options) {
if (!isset($options['content']) && !isset($options['data'])) {
throw new Exception\RuntimeException('No translation source data provided.');
} else if (array_key_exists('content', $options) && array_key_exists('data', $options)) {
throw new Exception\RuntimeException(
'Conflict on translation source data: choose only one key between content and data.'
);
}
if (empty($options['adapter'])) {
$options['adapter'] = Zend_Translate::AN_ARRAY;
}
if (!empty($options['data'])) {
$options['content'] = $options['data'];
unset($options['data']);
}
if (isset($options['options'])) {
foreach($options['options'] as $key => $value) {
$options[$key] = $value;
}
}
if (!empty($options['cache']) && is_string($options['cache'])) {
$cacheManager = $serviceLocator->get('CacheManager');
if ($cacheManager->hasCache($options['cache'])) {
$options['cache'] = $cacheManager->getCache($options['cache']);
}
}
if ($this->translator instanceof Zend_Translate_Adapter) {
$this->translator->addTranslation($options);
} else {
$translate = new Zend_Translate($options);
$this->translator = $translate->getAdapter();
}
}
return $this->translator;
} | php | public function createService(ServiceLocatorInterface $serviceLocator)
{
$config = $serviceLocator->get('Config');
if (!isset($config['translator'])) {
throw new Exception\RuntimeException(
'No translator config found.'
);
}
$allOptions = $config['translator'];
foreach ($allOptions as $module => $options) {
if (!isset($options['content']) && !isset($options['data'])) {
throw new Exception\RuntimeException('No translation source data provided.');
} else if (array_key_exists('content', $options) && array_key_exists('data', $options)) {
throw new Exception\RuntimeException(
'Conflict on translation source data: choose only one key between content and data.'
);
}
if (empty($options['adapter'])) {
$options['adapter'] = Zend_Translate::AN_ARRAY;
}
if (!empty($options['data'])) {
$options['content'] = $options['data'];
unset($options['data']);
}
if (isset($options['options'])) {
foreach($options['options'] as $key => $value) {
$options[$key] = $value;
}
}
if (!empty($options['cache']) && is_string($options['cache'])) {
$cacheManager = $serviceLocator->get('CacheManager');
if ($cacheManager->hasCache($options['cache'])) {
$options['cache'] = $cacheManager->getCache($options['cache']);
}
}
if ($this->translator instanceof Zend_Translate_Adapter) {
$this->translator->addTranslation($options);
} else {
$translate = new Zend_Translate($options);
$this->translator = $translate->getAdapter();
}
}
return $this->translator;
} | [
"public",
"function",
"createService",
"(",
"ServiceLocatorInterface",
"$",
"serviceLocator",
")",
"{",
"$",
"config",
"=",
"$",
"serviceLocator",
"->",
"get",
"(",
"'Config'",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"[",
"'translator'",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"RuntimeException",
"(",
"'No translator config found.'",
")",
";",
"}",
"$",
"allOptions",
"=",
"$",
"config",
"[",
"'translator'",
"]",
";",
"foreach",
"(",
"$",
"allOptions",
"as",
"$",
"module",
"=>",
"$",
"options",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"'content'",
"]",
")",
"&&",
"!",
"isset",
"(",
"$",
"options",
"[",
"'data'",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"RuntimeException",
"(",
"'No translation source data provided.'",
")",
";",
"}",
"else",
"if",
"(",
"array_key_exists",
"(",
"'content'",
",",
"$",
"options",
")",
"&&",
"array_key_exists",
"(",
"'data'",
",",
"$",
"options",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"RuntimeException",
"(",
"'Conflict on translation source data: choose only one key between content and data.'",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"options",
"[",
"'adapter'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'adapter'",
"]",
"=",
"Zend_Translate",
"::",
"AN_ARRAY",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'data'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'content'",
"]",
"=",
"$",
"options",
"[",
"'data'",
"]",
";",
"unset",
"(",
"$",
"options",
"[",
"'data'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'options'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"options",
"[",
"'options'",
"]",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"options",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'cache'",
"]",
")",
"&&",
"is_string",
"(",
"$",
"options",
"[",
"'cache'",
"]",
")",
")",
"{",
"$",
"cacheManager",
"=",
"$",
"serviceLocator",
"->",
"get",
"(",
"'CacheManager'",
")",
";",
"if",
"(",
"$",
"cacheManager",
"->",
"hasCache",
"(",
"$",
"options",
"[",
"'cache'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'cache'",
"]",
"=",
"$",
"cacheManager",
"->",
"getCache",
"(",
"$",
"options",
"[",
"'cache'",
"]",
")",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"translator",
"instanceof",
"Zend_Translate_Adapter",
")",
"{",
"$",
"this",
"->",
"translator",
"->",
"addTranslation",
"(",
"$",
"options",
")",
";",
"}",
"else",
"{",
"$",
"translate",
"=",
"new",
"Zend_Translate",
"(",
"$",
"options",
")",
";",
"$",
"this",
"->",
"translator",
"=",
"$",
"translate",
"->",
"getAdapter",
"(",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"translator",
";",
"}"
] | Create translator adapter
@param ServiceLocatorInterface $serviceLocator
@return Zend_Translate_Adapter
@throws Exception\RuntimeException | [
"Create",
"translator",
"adapter"
] | train | https://github.com/prolic/HumusMvc/blob/09e8c6422d84b57745cc643047e10761be2a21a7/src/HumusMvc/Translate/Service/TranslatorFactory.php#L41-L89 |
phossa/phossa-di | src/Phossa/Di/Extension/Delegate/DelegateExtension.php | DelegateExtension.setDelegator | public function setDelegator(DelegatorInterface $delegator)
{
$this->delegator = $delegator->addContainer($this->getContainer());
return $this;
} | php | public function setDelegator(DelegatorInterface $delegator)
{
$this->delegator = $delegator->addContainer($this->getContainer());
return $this;
} | [
"public",
"function",
"setDelegator",
"(",
"DelegatorInterface",
"$",
"delegator",
")",
"{",
"$",
"this",
"->",
"delegator",
"=",
"$",
"delegator",
"->",
"addContainer",
"(",
"$",
"this",
"->",
"getContainer",
"(",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set delegator
@param DelegatorInterface $delegator
@return self
@access public
@internal | [
"Set",
"delegator"
] | train | https://github.com/phossa/phossa-di/blob/bbe1e95b081068e2bc49c6cd465f38aab0374be5/src/Phossa/Di/Extension/Delegate/DelegateExtension.php#L56-L60 |
native5/native5-sdk-client-php | src/Native5/Security/RequestChecker.php | RequestChecker.isAuthorized | public static function isAuthorized()
{
$headers = apache_request_headers();
if (isset($_SESSION['uid'])) {
return true;
}
if(!isset($headers['N5-Api-Sig']))
return FALSE;
$salt = "N@t1v3";
$request_sig = $headers['N5-Api-Sig'];
$string = $headers['N5-Api-Key'].$salt;
if(hash('sha256', $string) == $request_sig)
return TRUE;
return FALSE;
} | php | public static function isAuthorized()
{
$headers = apache_request_headers();
if (isset($_SESSION['uid'])) {
return true;
}
if(!isset($headers['N5-Api-Sig']))
return FALSE;
$salt = "N@t1v3";
$request_sig = $headers['N5-Api-Sig'];
$string = $headers['N5-Api-Key'].$salt;
if(hash('sha256', $string) == $request_sig)
return TRUE;
return FALSE;
} | [
"public",
"static",
"function",
"isAuthorized",
"(",
")",
"{",
"$",
"headers",
"=",
"apache_request_headers",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"'uid'",
"]",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"headers",
"[",
"'N5-Api-Sig'",
"]",
")",
")",
"return",
"FALSE",
";",
"$",
"salt",
"=",
"\"N@t1v3\"",
";",
"$",
"request_sig",
"=",
"$",
"headers",
"[",
"'N5-Api-Sig'",
"]",
";",
"$",
"string",
"=",
"$",
"headers",
"[",
"'N5-Api-Key'",
"]",
".",
"$",
"salt",
";",
"if",
"(",
"hash",
"(",
"'sha256'",
",",
"$",
"string",
")",
"==",
"$",
"request_sig",
")",
"return",
"TRUE",
";",
"return",
"FALSE",
";",
"}"
] | isAuthorized
@static
@access public
@return void | [
"isAuthorized"
] | train | https://github.com/native5/native5-sdk-client-php/blob/e1f598cf27654d81bb5facace1990b737242a2f9/src/Native5/Security/RequestChecker.php#L48-L62 |
zenodorus-tools/filesystem | src/Filesystem/Directories.php | Directories.isBeneath | public static function isBeneath(string $child, string $parent)
{
if ((strlen($child) >= strlen($parent))
&& strpos($child, $parent) === 0) {
return true;
}
return false;
} | php | public static function isBeneath(string $child, string $parent)
{
if ((strlen($child) >= strlen($parent))
&& strpos($child, $parent) === 0) {
return true;
}
return false;
} | [
"public",
"static",
"function",
"isBeneath",
"(",
"string",
"$",
"child",
",",
"string",
"$",
"parent",
")",
"{",
"if",
"(",
"(",
"strlen",
"(",
"$",
"child",
")",
">=",
"strlen",
"(",
"$",
"parent",
")",
")",
"&&",
"strpos",
"(",
"$",
"child",
",",
"$",
"parent",
")",
"===",
"0",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Determine if a path is beneath another path.
This is strictly string comparison; it does no path validation or path
checking.
@param string $child
@param string $parent
@return boolean | [
"Determine",
"if",
"a",
"path",
"is",
"beneath",
"another",
"path",
"."
] | train | https://github.com/zenodorus-tools/filesystem/blob/210d098fa9cc7f261d68402667763497cba1fba0/src/Filesystem/Directories.php#L17-L25 |
zenodorus-tools/filesystem | src/Filesystem/Directories.php | Directories.isBeneathResolve | public static function isBeneathResolve(
string $child,
string $parent
) {
$args = [
'child' => $child,
'parent' => $parent,
];
array_walk($args, function (&$dir) {
$dir = Filesystem::resolve($dir);
});
return Directories::isBeneath($args['child'], $args['parent']);
} | php | public static function isBeneathResolve(
string $child,
string $parent
) {
$args = [
'child' => $child,
'parent' => $parent,
];
array_walk($args, function (&$dir) {
$dir = Filesystem::resolve($dir);
});
return Directories::isBeneath($args['child'], $args['parent']);
} | [
"public",
"static",
"function",
"isBeneathResolve",
"(",
"string",
"$",
"child",
",",
"string",
"$",
"parent",
")",
"{",
"$",
"args",
"=",
"[",
"'child'",
"=>",
"$",
"child",
",",
"'parent'",
"=>",
"$",
"parent",
",",
"]",
";",
"array_walk",
"(",
"$",
"args",
",",
"function",
"(",
"&",
"$",
"dir",
")",
"{",
"$",
"dir",
"=",
"Filesystem",
"::",
"resolve",
"(",
"$",
"dir",
")",
";",
"}",
")",
";",
"return",
"Directories",
"::",
"isBeneath",
"(",
"$",
"args",
"[",
"'child'",
"]",
",",
"$",
"args",
"[",
"'parent'",
"]",
")",
";",
"}"
] | Determine if a path is beneath another path.
This is strictly string comparison via `Filesystem::resolve()`; it does
no path validation or path checking.
@see Filesystem::resolve()
@param string $child
@param string $parent
@return boolean | [
"Determine",
"if",
"a",
"path",
"is",
"beneath",
"another",
"path",
"."
] | train | https://github.com/zenodorus-tools/filesystem/blob/210d098fa9cc7f261d68402667763497cba1fba0/src/Filesystem/Directories.php#L39-L53 |
zenodorus-tools/filesystem | src/Filesystem/Directories.php | Directories.isBeneathReal | public static function isBeneathReal(
string $child,
string $parent,
string $childDir = null,
string $parentDir = null
) {
$realChildPath = Filesystem::resolveReal($child, $childDir);
$realParentPath = Filesystem::resolveReal($parent, $parentDir);
if ($realChildPath && $realParentPath) {
return Directories::isBeneath($realChildPath, $realParentPath);
}
return false;
} | php | public static function isBeneathReal(
string $child,
string $parent,
string $childDir = null,
string $parentDir = null
) {
$realChildPath = Filesystem::resolveReal($child, $childDir);
$realParentPath = Filesystem::resolveReal($parent, $parentDir);
if ($realChildPath && $realParentPath) {
return Directories::isBeneath($realChildPath, $realParentPath);
}
return false;
} | [
"public",
"static",
"function",
"isBeneathReal",
"(",
"string",
"$",
"child",
",",
"string",
"$",
"parent",
",",
"string",
"$",
"childDir",
"=",
"null",
",",
"string",
"$",
"parentDir",
"=",
"null",
")",
"{",
"$",
"realChildPath",
"=",
"Filesystem",
"::",
"resolveReal",
"(",
"$",
"child",
",",
"$",
"childDir",
")",
";",
"$",
"realParentPath",
"=",
"Filesystem",
"::",
"resolveReal",
"(",
"$",
"parent",
",",
"$",
"parentDir",
")",
";",
"if",
"(",
"$",
"realChildPath",
"&&",
"$",
"realParentPath",
")",
"{",
"return",
"Directories",
"::",
"isBeneath",
"(",
"$",
"realChildPath",
",",
"$",
"realParentPath",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Determine if a real path is beneath another path.
The files/directories passed to this method are checked to make sure
they exists, so the results returned by this method can be trusted.
@see Filesystem::resolveReal()
@see Filesystem\Directories::isBeneath()
@param string $child
@param string $parent
@param string $childDir
@param string $parentDir
@return boolean | [
"Determine",
"if",
"a",
"real",
"path",
"is",
"beneath",
"another",
"path",
"."
] | train | https://github.com/zenodorus-tools/filesystem/blob/210d098fa9cc7f261d68402667763497cba1fba0/src/Filesystem/Directories.php#L70-L84 |
mtils/cmsable | src/Cmsable/Resource/Distributor.php | Distributor.form | public function form($model=null, $resource=null)
{
$resource = $this->passedOrCurrent($resource);
if (!$formClass = $this->formClass($resource)) {
return '';
}
return $this->makeForm($resource, $formClass, $model);
} | php | public function form($model=null, $resource=null)
{
$resource = $this->passedOrCurrent($resource);
if (!$formClass = $this->formClass($resource)) {
return '';
}
return $this->makeForm($resource, $formClass, $model);
} | [
"public",
"function",
"form",
"(",
"$",
"model",
"=",
"null",
",",
"$",
"resource",
"=",
"null",
")",
"{",
"$",
"resource",
"=",
"$",
"this",
"->",
"passedOrCurrent",
"(",
"$",
"resource",
")",
";",
"if",
"(",
"!",
"$",
"formClass",
"=",
"$",
"this",
"->",
"formClass",
"(",
"$",
"resource",
")",
")",
"{",
"return",
"''",
";",
"}",
"return",
"$",
"this",
"->",
"makeForm",
"(",
"$",
"resource",
",",
"$",
"formClass",
",",
"$",
"model",
")",
";",
"}"
] | {@inheritdoc}
@param mixed $model (optional)
@param string $resource (optional)
@return \FormObject\Form | [
"{",
"@inheritdoc",
"}"
] | train | https://github.com/mtils/cmsable/blob/03ae84ee3c7d46146f2a1cf687e5c29d6de4286d/src/Cmsable/Resource/Distributor.php#L48-L59 |
mtils/cmsable | src/Cmsable/Resource/Distributor.php | Distributor.searchForm | public function searchForm($resource=null)
{
$resource = $this->passedOrCurrent($resource);
if (!$formClass = $this->searchFormClass($resource)) {
return '';
}
return $this->makeSearchForm($resource, $formClass);
} | php | public function searchForm($resource=null)
{
$resource = $this->passedOrCurrent($resource);
if (!$formClass = $this->searchFormClass($resource)) {
return '';
}
return $this->makeSearchForm($resource, $formClass);
} | [
"public",
"function",
"searchForm",
"(",
"$",
"resource",
"=",
"null",
")",
"{",
"$",
"resource",
"=",
"$",
"this",
"->",
"passedOrCurrent",
"(",
"$",
"resource",
")",
";",
"if",
"(",
"!",
"$",
"formClass",
"=",
"$",
"this",
"->",
"searchFormClass",
"(",
"$",
"resource",
")",
")",
"{",
"return",
"''",
";",
"}",
"return",
"$",
"this",
"->",
"makeSearchForm",
"(",
"$",
"resource",
",",
"$",
"formClass",
")",
";",
"}"
] | {@inheritdoc}
@param string $resource (optional)
@return \FormObject\Form | [
"{",
"@inheritdoc",
"}"
] | train | https://github.com/mtils/cmsable/blob/03ae84ee3c7d46146f2a1cf687e5c29d6de4286d/src/Cmsable/Resource/Distributor.php#L78-L89 |
mtils/cmsable | src/Cmsable/Resource/Distributor.php | Distributor.validator | public function validator($resource=null)
{
$resource = $this->passedOrCurrent($resource);
if ($class = $this->mapper->validatorClass($resource)) {
return $this->makeValidator($resource, $class);
}
$modelClass = class_basename($this->modelClass($resource));
if ($class = $this->finder->validatorClass($resource, $modelClass)) {
return $this->makeValidator($resource, $class);;
}
$class = 'Cmsable\Resource\GenericResourceValidator';
if ($rules = $this->getManualRules($resource)) {
$validator = $this->makeValidator($resource, $class);
return $validator->setRules($rules);
}
// Support for rules inside forms
if (!$this->hasForm($resource)) {
throw new RuntimeException('No validator for resource $resource found');
}
if ($rules = $this->formRules($this->form(null, $resource))) {
$validator = $this->makeValidator($resource, $class);
return $validator->setRules($rules);
}
throw new RuntimeException('No validator for resource $resource found');
} | php | public function validator($resource=null)
{
$resource = $this->passedOrCurrent($resource);
if ($class = $this->mapper->validatorClass($resource)) {
return $this->makeValidator($resource, $class);
}
$modelClass = class_basename($this->modelClass($resource));
if ($class = $this->finder->validatorClass($resource, $modelClass)) {
return $this->makeValidator($resource, $class);;
}
$class = 'Cmsable\Resource\GenericResourceValidator';
if ($rules = $this->getManualRules($resource)) {
$validator = $this->makeValidator($resource, $class);
return $validator->setRules($rules);
}
// Support for rules inside forms
if (!$this->hasForm($resource)) {
throw new RuntimeException('No validator for resource $resource found');
}
if ($rules = $this->formRules($this->form(null, $resource))) {
$validator = $this->makeValidator($resource, $class);
return $validator->setRules($rules);
}
throw new RuntimeException('No validator for resource $resource found');
} | [
"public",
"function",
"validator",
"(",
"$",
"resource",
"=",
"null",
")",
"{",
"$",
"resource",
"=",
"$",
"this",
"->",
"passedOrCurrent",
"(",
"$",
"resource",
")",
";",
"if",
"(",
"$",
"class",
"=",
"$",
"this",
"->",
"mapper",
"->",
"validatorClass",
"(",
"$",
"resource",
")",
")",
"{",
"return",
"$",
"this",
"->",
"makeValidator",
"(",
"$",
"resource",
",",
"$",
"class",
")",
";",
"}",
"$",
"modelClass",
"=",
"class_basename",
"(",
"$",
"this",
"->",
"modelClass",
"(",
"$",
"resource",
")",
")",
";",
"if",
"(",
"$",
"class",
"=",
"$",
"this",
"->",
"finder",
"->",
"validatorClass",
"(",
"$",
"resource",
",",
"$",
"modelClass",
")",
")",
"{",
"return",
"$",
"this",
"->",
"makeValidator",
"(",
"$",
"resource",
",",
"$",
"class",
")",
";",
";",
"}",
"$",
"class",
"=",
"'Cmsable\\Resource\\GenericResourceValidator'",
";",
"if",
"(",
"$",
"rules",
"=",
"$",
"this",
"->",
"getManualRules",
"(",
"$",
"resource",
")",
")",
"{",
"$",
"validator",
"=",
"$",
"this",
"->",
"makeValidator",
"(",
"$",
"resource",
",",
"$",
"class",
")",
";",
"return",
"$",
"validator",
"->",
"setRules",
"(",
"$",
"rules",
")",
";",
"}",
"// Support for rules inside forms",
"if",
"(",
"!",
"$",
"this",
"->",
"hasForm",
"(",
"$",
"resource",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'No validator for resource $resource found'",
")",
";",
"}",
"if",
"(",
"$",
"rules",
"=",
"$",
"this",
"->",
"formRules",
"(",
"$",
"this",
"->",
"form",
"(",
"null",
",",
"$",
"resource",
")",
")",
")",
"{",
"$",
"validator",
"=",
"$",
"this",
"->",
"makeValidator",
"(",
"$",
"resource",
",",
"$",
"class",
")",
";",
"return",
"$",
"validator",
"->",
"setRules",
"(",
"$",
"rules",
")",
";",
"}",
"throw",
"new",
"RuntimeException",
"(",
"'No validator for resource $resource found'",
")",
";",
"}"
] | {@inheritdoc}
@param string $resource (optional)
@return \Cmsable\Resource\Contracts\Validator | [
"{",
"@inheritdoc",
"}"
] | train | https://github.com/mtils/cmsable/blob/03ae84ee3c7d46146f2a1cf687e5c29d6de4286d/src/Cmsable/Resource/Distributor.php#L108-L144 |
mtils/cmsable | src/Cmsable/Resource/Distributor.php | Distributor.modelClass | public function modelClass($resource=null)
{
$resource = $this->passedOrCurrent($resource);
if ($modelClass = $this->mapper->modelClass($resource)) {
return $modelClass;
}
if ($modelClass = $this->finder->modelClass($resource)) {
return $modelClass;
}
} | php | public function modelClass($resource=null)
{
$resource = $this->passedOrCurrent($resource);
if ($modelClass = $this->mapper->modelClass($resource)) {
return $modelClass;
}
if ($modelClass = $this->finder->modelClass($resource)) {
return $modelClass;
}
} | [
"public",
"function",
"modelClass",
"(",
"$",
"resource",
"=",
"null",
")",
"{",
"$",
"resource",
"=",
"$",
"this",
"->",
"passedOrCurrent",
"(",
"$",
"resource",
")",
";",
"if",
"(",
"$",
"modelClass",
"=",
"$",
"this",
"->",
"mapper",
"->",
"modelClass",
"(",
"$",
"resource",
")",
")",
"{",
"return",
"$",
"modelClass",
";",
"}",
"if",
"(",
"$",
"modelClass",
"=",
"$",
"this",
"->",
"finder",
"->",
"modelClass",
"(",
"$",
"resource",
")",
")",
"{",
"return",
"$",
"modelClass",
";",
"}",
"}"
] | This returns the model class for $resource. Caution: Not in interface
@param string $resource (optional)
@return string | [
"This",
"returns",
"the",
"model",
"class",
"for",
"$resource",
".",
"Caution",
":",
"Not",
"in",
"interface"
] | train | https://github.com/mtils/cmsable/blob/03ae84ee3c7d46146f2a1cf687e5c29d6de4286d/src/Cmsable/Resource/Distributor.php#L181-L194 |
mtils/cmsable | src/Cmsable/Resource/Distributor.php | Distributor.formClass | public function formClass($resource=null)
{
$resource = $this->passedOrCurrent($resource);
if ($formClass = $this->mapper->formClass($resource)) {
return $formClass;
}
$modelClass = class_basename($this->modelClass($resource));
if ($formClass = $this->finder->formClass($resource, $modelClass)) {
return $formClass;
}
return '';
} | php | public function formClass($resource=null)
{
$resource = $this->passedOrCurrent($resource);
if ($formClass = $this->mapper->formClass($resource)) {
return $formClass;
}
$modelClass = class_basename($this->modelClass($resource));
if ($formClass = $this->finder->formClass($resource, $modelClass)) {
return $formClass;
}
return '';
} | [
"public",
"function",
"formClass",
"(",
"$",
"resource",
"=",
"null",
")",
"{",
"$",
"resource",
"=",
"$",
"this",
"->",
"passedOrCurrent",
"(",
"$",
"resource",
")",
";",
"if",
"(",
"$",
"formClass",
"=",
"$",
"this",
"->",
"mapper",
"->",
"formClass",
"(",
"$",
"resource",
")",
")",
"{",
"return",
"$",
"formClass",
";",
"}",
"$",
"modelClass",
"=",
"class_basename",
"(",
"$",
"this",
"->",
"modelClass",
"(",
"$",
"resource",
")",
")",
";",
"if",
"(",
"$",
"formClass",
"=",
"$",
"this",
"->",
"finder",
"->",
"formClass",
"(",
"$",
"resource",
",",
"$",
"modelClass",
")",
")",
"{",
"return",
"$",
"formClass",
";",
"}",
"return",
"''",
";",
"}"
] | This returns the form class for $resource. Caution: Not in interface
@param string $resource (optional)
@return string | [
"This",
"returns",
"the",
"form",
"class",
"for",
"$resource",
".",
"Caution",
":",
"Not",
"in",
"interface"
] | train | https://github.com/mtils/cmsable/blob/03ae84ee3c7d46146f2a1cf687e5c29d6de4286d/src/Cmsable/Resource/Distributor.php#L202-L218 |
mtils/cmsable | src/Cmsable/Resource/Distributor.php | Distributor.getCurrentResource | public function getCurrentResource()
{
if (!$this->currentResource) {
$request = $this->container->make('request');
$this->currentResource = $this->detector->resourceByRequest($request);
}
return $this->currentResource;
} | php | public function getCurrentResource()
{
if (!$this->currentResource) {
$request = $this->container->make('request');
$this->currentResource = $this->detector->resourceByRequest($request);
}
return $this->currentResource;
} | [
"public",
"function",
"getCurrentResource",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"currentResource",
")",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"container",
"->",
"make",
"(",
"'request'",
")",
";",
"$",
"this",
"->",
"currentResource",
"=",
"$",
"this",
"->",
"detector",
"->",
"resourceByRequest",
"(",
"$",
"request",
")",
";",
"}",
"return",
"$",
"this",
"->",
"currentResource",
";",
"}"
] | {@inheritdoc}
@return string | [
"{",
"@inheritdoc",
"}"
] | train | https://github.com/mtils/cmsable/blob/03ae84ee3c7d46146f2a1cf687e5c29d6de4286d/src/Cmsable/Resource/Distributor.php#L248-L256 |
mtils/cmsable | src/Cmsable/Resource/Distributor.php | Distributor.makeForm | protected function makeForm($resource, $class, $model)
{
$form = $this->container->make($class);
if (!$this->formRules($form) && $rules = $this->rules($resource)) {
$form->getValidator()->setRules($rules);
}
if ($model) {
$form->setModel($model);
}
$this->publish($resource, 'form.created', [$form]);
return $form;
} | php | protected function makeForm($resource, $class, $model)
{
$form = $this->container->make($class);
if (!$this->formRules($form) && $rules = $this->rules($resource)) {
$form->getValidator()->setRules($rules);
}
if ($model) {
$form->setModel($model);
}
$this->publish($resource, 'form.created', [$form]);
return $form;
} | [
"protected",
"function",
"makeForm",
"(",
"$",
"resource",
",",
"$",
"class",
",",
"$",
"model",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"container",
"->",
"make",
"(",
"$",
"class",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"formRules",
"(",
"$",
"form",
")",
"&&",
"$",
"rules",
"=",
"$",
"this",
"->",
"rules",
"(",
"$",
"resource",
")",
")",
"{",
"$",
"form",
"->",
"getValidator",
"(",
")",
"->",
"setRules",
"(",
"$",
"rules",
")",
";",
"}",
"if",
"(",
"$",
"model",
")",
"{",
"$",
"form",
"->",
"setModel",
"(",
"$",
"model",
")",
";",
"}",
"$",
"this",
"->",
"publish",
"(",
"$",
"resource",
",",
"'form.created'",
",",
"[",
"$",
"form",
"]",
")",
";",
"return",
"$",
"form",
";",
"}"
] | Creates the form and fires an event
@param string $resource
@param string $class
@param mixed $model
@return \FormObject\Form | [
"Creates",
"the",
"form",
"and",
"fires",
"an",
"event"
] | train | https://github.com/mtils/cmsable/blob/03ae84ee3c7d46146f2a1cf687e5c29d6de4286d/src/Cmsable/Resource/Distributor.php#L289-L304 |
mtils/cmsable | src/Cmsable/Resource/Distributor.php | Distributor.makeSearchForm | protected function makeSearchForm($resource, $class)
{
$form = $this->container->make($class);
$this->publish($resource, 'search-form.created', [$form]);
$form->addCssClass('search-form');
return $form;
} | php | protected function makeSearchForm($resource, $class)
{
$form = $this->container->make($class);
$this->publish($resource, 'search-form.created', [$form]);
$form->addCssClass('search-form');
return $form;
} | [
"protected",
"function",
"makeSearchForm",
"(",
"$",
"resource",
",",
"$",
"class",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"container",
"->",
"make",
"(",
"$",
"class",
")",
";",
"$",
"this",
"->",
"publish",
"(",
"$",
"resource",
",",
"'search-form.created'",
",",
"[",
"$",
"form",
"]",
")",
";",
"$",
"form",
"->",
"addCssClass",
"(",
"'search-form'",
")",
";",
"return",
"$",
"form",
";",
"}"
] | Creates the search form and fires an event
@param string $resource
@param string $class
@return \FormObject\Form | [
"Creates",
"the",
"search",
"form",
"and",
"fires",
"an",
"event"
] | train | https://github.com/mtils/cmsable/blob/03ae84ee3c7d46146f2a1cf687e5c29d6de4286d/src/Cmsable/Resource/Distributor.php#L313-L319 |
mtils/cmsable | src/Cmsable/Resource/Distributor.php | Distributor.makeValidator | protected function makeValidator($resource, $class)
{
$validator = $this->container->make($class);
if (method_exists($validator, 'setResourceName')) {
$validator->setResourceName($resource);
}
$this->publish($resource, 'validator.created', [$validator]);
return $validator;
} | php | protected function makeValidator($resource, $class)
{
$validator = $this->container->make($class);
if (method_exists($validator, 'setResourceName')) {
$validator->setResourceName($resource);
}
$this->publish($resource, 'validator.created', [$validator]);
return $validator;
} | [
"protected",
"function",
"makeValidator",
"(",
"$",
"resource",
",",
"$",
"class",
")",
"{",
"$",
"validator",
"=",
"$",
"this",
"->",
"container",
"->",
"make",
"(",
"$",
"class",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"validator",
",",
"'setResourceName'",
")",
")",
"{",
"$",
"validator",
"->",
"setResourceName",
"(",
"$",
"resource",
")",
";",
"}",
"$",
"this",
"->",
"publish",
"(",
"$",
"resource",
",",
"'validator.created'",
",",
"[",
"$",
"validator",
"]",
")",
";",
"return",
"$",
"validator",
";",
"}"
] | Creates the validator and fires an event
@param string $resource
@param string $class
@return \Cmsable\Resource\Contracts\Validator | [
"Creates",
"the",
"validator",
"and",
"fires",
"an",
"event"
] | train | https://github.com/mtils/cmsable/blob/03ae84ee3c7d46146f2a1cf687e5c29d6de4286d/src/Cmsable/Resource/Distributor.php#L328-L337 |
mtils/cmsable | src/Cmsable/Resource/Distributor.php | Distributor.publish | protected function publish($resource, $event, array $params=[])
{
$eventName = $this->eventName("$resource.$event");
$this->callOnListeners($eventName, $params);
} | php | protected function publish($resource, $event, array $params=[])
{
$eventName = $this->eventName("$resource.$event");
$this->callOnListeners($eventName, $params);
} | [
"protected",
"function",
"publish",
"(",
"$",
"resource",
",",
"$",
"event",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"eventName",
"=",
"$",
"this",
"->",
"eventName",
"(",
"\"$resource.$event\"",
")",
";",
"$",
"this",
"->",
"callOnListeners",
"(",
"$",
"eventName",
",",
"$",
"params",
")",
";",
"}"
] | Publishes an event on the event bus
@param string $resource
@param string $event
@param array $params | [
"Publishes",
"an",
"event",
"on",
"the",
"event",
"bus"
] | train | https://github.com/mtils/cmsable/blob/03ae84ee3c7d46146f2a1cf687e5c29d6de4286d/src/Cmsable/Resource/Distributor.php#L360-L365 |
foxslider/cmg-plugin | admin/controllers/SliderController.php | SliderController.init | public function init() {
parent::init();
// Permissions
$this->crudPermission = FxsCoreGlobal::PERM_SLIDER;
// Config
$this->apixBase = 'foxslider';
// Sidebar
$this->sidebar = [ 'parent' => 'sidebar-fxslider', 'child' => 'slider' ];
// Services
$this->modelService = Yii::$app->factory->get( 'fxSliderService' );
$this->slideService = Yii::$app->factory->get( 'fxSlideService' );
// Return Url
$this->returnUrl = Url::previous( 'fxsliders' );
$this->returnUrl = isset( $this->returnUrl ) ? $this->returnUrl : Url::toRoute( [ '/foxslider/slider/all' ], true );
// Breadcrumbs
$this->breadcrumbs = [
'base' => [
[ 'label' => 'Home', 'url' => Url::toRoute( '/dashboard' ) ]
],
'all' => [ [ 'label' => 'Sliders' ] ],
'create' => [ [ 'label' => 'Sliders', 'url' => $this->returnUrl ], [ 'label' => 'Add' ] ],
'update' => [ [ 'label' => 'Sliders', 'url' => $this->returnUrl ], [ 'label' => 'Update' ] ],
'delete' => [ [ 'label' => 'Sliders', 'url' => $this->returnUrl ], [ 'label' => 'Delete' ] ],
'slides' => [ [ 'label' => 'Sliders', 'url' => $this->returnUrl ], [ 'label' => 'Slides' ] ],
'settings' => [ [ 'label' => 'Sliders', 'url' => $this->returnUrl ], [ 'label' => 'Settings' ] ]
];
} | php | public function init() {
parent::init();
// Permissions
$this->crudPermission = FxsCoreGlobal::PERM_SLIDER;
// Config
$this->apixBase = 'foxslider';
// Sidebar
$this->sidebar = [ 'parent' => 'sidebar-fxslider', 'child' => 'slider' ];
// Services
$this->modelService = Yii::$app->factory->get( 'fxSliderService' );
$this->slideService = Yii::$app->factory->get( 'fxSlideService' );
// Return Url
$this->returnUrl = Url::previous( 'fxsliders' );
$this->returnUrl = isset( $this->returnUrl ) ? $this->returnUrl : Url::toRoute( [ '/foxslider/slider/all' ], true );
// Breadcrumbs
$this->breadcrumbs = [
'base' => [
[ 'label' => 'Home', 'url' => Url::toRoute( '/dashboard' ) ]
],
'all' => [ [ 'label' => 'Sliders' ] ],
'create' => [ [ 'label' => 'Sliders', 'url' => $this->returnUrl ], [ 'label' => 'Add' ] ],
'update' => [ [ 'label' => 'Sliders', 'url' => $this->returnUrl ], [ 'label' => 'Update' ] ],
'delete' => [ [ 'label' => 'Sliders', 'url' => $this->returnUrl ], [ 'label' => 'Delete' ] ],
'slides' => [ [ 'label' => 'Sliders', 'url' => $this->returnUrl ], [ 'label' => 'Slides' ] ],
'settings' => [ [ 'label' => 'Sliders', 'url' => $this->returnUrl ], [ 'label' => 'Settings' ] ]
];
} | [
"public",
"function",
"init",
"(",
")",
"{",
"parent",
"::",
"init",
"(",
")",
";",
"// Permissions",
"$",
"this",
"->",
"crudPermission",
"=",
"FxsCoreGlobal",
"::",
"PERM_SLIDER",
";",
"// Config",
"$",
"this",
"->",
"apixBase",
"=",
"'foxslider'",
";",
"// Sidebar",
"$",
"this",
"->",
"sidebar",
"=",
"[",
"'parent'",
"=>",
"'sidebar-fxslider'",
",",
"'child'",
"=>",
"'slider'",
"]",
";",
"// Services",
"$",
"this",
"->",
"modelService",
"=",
"Yii",
"::",
"$",
"app",
"->",
"factory",
"->",
"get",
"(",
"'fxSliderService'",
")",
";",
"$",
"this",
"->",
"slideService",
"=",
"Yii",
"::",
"$",
"app",
"->",
"factory",
"->",
"get",
"(",
"'fxSlideService'",
")",
";",
"// Return Url",
"$",
"this",
"->",
"returnUrl",
"=",
"Url",
"::",
"previous",
"(",
"'fxsliders'",
")",
";",
"$",
"this",
"->",
"returnUrl",
"=",
"isset",
"(",
"$",
"this",
"->",
"returnUrl",
")",
"?",
"$",
"this",
"->",
"returnUrl",
":",
"Url",
"::",
"toRoute",
"(",
"[",
"'/foxslider/slider/all'",
"]",
",",
"true",
")",
";",
"// Breadcrumbs",
"$",
"this",
"->",
"breadcrumbs",
"=",
"[",
"'base'",
"=>",
"[",
"[",
"'label'",
"=>",
"'Home'",
",",
"'url'",
"=>",
"Url",
"::",
"toRoute",
"(",
"'/dashboard'",
")",
"]",
"]",
",",
"'all'",
"=>",
"[",
"[",
"'label'",
"=>",
"'Sliders'",
"]",
"]",
",",
"'create'",
"=>",
"[",
"[",
"'label'",
"=>",
"'Sliders'",
",",
"'url'",
"=>",
"$",
"this",
"->",
"returnUrl",
"]",
",",
"[",
"'label'",
"=>",
"'Add'",
"]",
"]",
",",
"'update'",
"=>",
"[",
"[",
"'label'",
"=>",
"'Sliders'",
",",
"'url'",
"=>",
"$",
"this",
"->",
"returnUrl",
"]",
",",
"[",
"'label'",
"=>",
"'Update'",
"]",
"]",
",",
"'delete'",
"=>",
"[",
"[",
"'label'",
"=>",
"'Sliders'",
",",
"'url'",
"=>",
"$",
"this",
"->",
"returnUrl",
"]",
",",
"[",
"'label'",
"=>",
"'Delete'",
"]",
"]",
",",
"'slides'",
"=>",
"[",
"[",
"'label'",
"=>",
"'Sliders'",
",",
"'url'",
"=>",
"$",
"this",
"->",
"returnUrl",
"]",
",",
"[",
"'label'",
"=>",
"'Slides'",
"]",
"]",
",",
"'settings'",
"=>",
"[",
"[",
"'label'",
"=>",
"'Sliders'",
",",
"'url'",
"=>",
"$",
"this",
"->",
"returnUrl",
"]",
",",
"[",
"'label'",
"=>",
"'Settings'",
"]",
"]",
"]",
";",
"}"
] | Constructor and Initialisation ------------------------------ | [
"Constructor",
"and",
"Initialisation",
"------------------------------"
] | train | https://github.com/foxslider/cmg-plugin/blob/843f723ebb512ab833feff581beb9714df4e41bd/admin/controllers/SliderController.php#L49-L82 |
foxslider/cmg-plugin | admin/controllers/SliderController.php | SliderController.actionAll | public function actionAll( $config = [] ) {
Url::remember( Yii::$app->request->getUrl(), 'fxsliders' );
$dataProvider = $this->modelService->getPage();
return $this->render( 'all', [
'dataProvider' => $dataProvider,
'statusMap' => Slider::$statusMap
]);
} | php | public function actionAll( $config = [] ) {
Url::remember( Yii::$app->request->getUrl(), 'fxsliders' );
$dataProvider = $this->modelService->getPage();
return $this->render( 'all', [
'dataProvider' => $dataProvider,
'statusMap' => Slider::$statusMap
]);
} | [
"public",
"function",
"actionAll",
"(",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"Url",
"::",
"remember",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"getUrl",
"(",
")",
",",
"'fxsliders'",
")",
";",
"$",
"dataProvider",
"=",
"$",
"this",
"->",
"modelService",
"->",
"getPage",
"(",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"'all'",
",",
"[",
"'dataProvider'",
"=>",
"$",
"dataProvider",
",",
"'statusMap'",
"=>",
"Slider",
"::",
"$",
"statusMap",
"]",
")",
";",
"}"
] | SliderController ---------------------- | [
"SliderController",
"----------------------"
] | train | https://github.com/foxslider/cmg-plugin/blob/843f723ebb512ab833feff581beb9714df4e41bd/admin/controllers/SliderController.php#L111-L121 |
lightwerk/SurfCaptain | Classes/Lightwerk/SurfCaptain/Domain/Repository/Preset/AbstractRepository.php | AbstractRepository.add | public function add($identifier, array $configuration)
{
$presets = $this->loadPresets();
if (!empty($presets[$identifier])) {
throw new Exception('Preset exists already', 1410552459);
}
if (empty($configuration)) {
throw new Exception('Empty configuration is not allowed', 1410595656);
}
$presets[$identifier] = $configuration;
ksort($presets);
$this->savePresets($presets, 'Adds preset with identifier "' . $identifier . '"');
} | php | public function add($identifier, array $configuration)
{
$presets = $this->loadPresets();
if (!empty($presets[$identifier])) {
throw new Exception('Preset exists already', 1410552459);
}
if (empty($configuration)) {
throw new Exception('Empty configuration is not allowed', 1410595656);
}
$presets[$identifier] = $configuration;
ksort($presets);
$this->savePresets($presets, 'Adds preset with identifier "' . $identifier . '"');
} | [
"public",
"function",
"add",
"(",
"$",
"identifier",
",",
"array",
"$",
"configuration",
")",
"{",
"$",
"presets",
"=",
"$",
"this",
"->",
"loadPresets",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"presets",
"[",
"$",
"identifier",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Preset exists already'",
",",
"1410552459",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"configuration",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Empty configuration is not allowed'",
",",
"1410595656",
")",
";",
"}",
"$",
"presets",
"[",
"$",
"identifier",
"]",
"=",
"$",
"configuration",
";",
"ksort",
"(",
"$",
"presets",
")",
";",
"$",
"this",
"->",
"savePresets",
"(",
"$",
"presets",
",",
"'Adds preset with identifier \"'",
".",
"$",
"identifier",
".",
"'\"'",
")",
";",
"}"
] | Adds a preset to this repository.
@param string $identifier
@param array $configuration
@return void
@throws Exception | [
"Adds",
"a",
"preset",
"to",
"this",
"repository",
"."
] | train | https://github.com/lightwerk/SurfCaptain/blob/2865e963fd634504d8923902cf422873749a0940/Classes/Lightwerk/SurfCaptain/Domain/Repository/Preset/AbstractRepository.php#L31-L43 |
lightwerk/SurfCaptain | Classes/Lightwerk/SurfCaptain/Domain/Repository/Preset/AbstractRepository.php | AbstractRepository.update | public function update($identifier, array $configuration)
{
$presets = $this->loadPresets();
if (empty($presets[$identifier])) {
throw new Exception('Could not find preset', 1410552339);
}
if (empty($configuration)) {
throw new Exception('Empty configuration is not allowed', 1410595612);
}
$presets[$identifier] = $configuration;
$this->savePresets($presets, 'Updates preset with identifier "' . $identifier . '"');
} | php | public function update($identifier, array $configuration)
{
$presets = $this->loadPresets();
if (empty($presets[$identifier])) {
throw new Exception('Could not find preset', 1410552339);
}
if (empty($configuration)) {
throw new Exception('Empty configuration is not allowed', 1410595612);
}
$presets[$identifier] = $configuration;
$this->savePresets($presets, 'Updates preset with identifier "' . $identifier . '"');
} | [
"public",
"function",
"update",
"(",
"$",
"identifier",
",",
"array",
"$",
"configuration",
")",
"{",
"$",
"presets",
"=",
"$",
"this",
"->",
"loadPresets",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"presets",
"[",
"$",
"identifier",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Could not find preset'",
",",
"1410552339",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"configuration",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Empty configuration is not allowed'",
",",
"1410595612",
")",
";",
"}",
"$",
"presets",
"[",
"$",
"identifier",
"]",
"=",
"$",
"configuration",
";",
"$",
"this",
"->",
"savePresets",
"(",
"$",
"presets",
",",
"'Updates preset with identifier \"'",
".",
"$",
"identifier",
".",
"'\"'",
")",
";",
"}"
] | Updates a given preset.
@param string $identifier
@param array $configuration
@return void
@throws Exception | [
"Updates",
"a",
"given",
"preset",
"."
] | train | https://github.com/lightwerk/SurfCaptain/blob/2865e963fd634504d8923902cf422873749a0940/Classes/Lightwerk/SurfCaptain/Domain/Repository/Preset/AbstractRepository.php#L69-L80 |
lightwerk/SurfCaptain | Classes/Lightwerk/SurfCaptain/Domain/Repository/Preset/AbstractRepository.php | AbstractRepository.remove | public function remove($identifier)
{
$presets = $this->loadPresets();
if (empty($presets[$identifier])) {
throw new Exception('Could not find preset', 1410549993);
}
unset($presets[$identifier]);
$this->savePresets($presets, 'Removes preset with identifier "' . $identifier . '"');
} | php | public function remove($identifier)
{
$presets = $this->loadPresets();
if (empty($presets[$identifier])) {
throw new Exception('Could not find preset', 1410549993);
}
unset($presets[$identifier]);
$this->savePresets($presets, 'Removes preset with identifier "' . $identifier . '"');
} | [
"public",
"function",
"remove",
"(",
"$",
"identifier",
")",
"{",
"$",
"presets",
"=",
"$",
"this",
"->",
"loadPresets",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"presets",
"[",
"$",
"identifier",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Could not find preset'",
",",
"1410549993",
")",
";",
"}",
"unset",
"(",
"$",
"presets",
"[",
"$",
"identifier",
"]",
")",
";",
"$",
"this",
"->",
"savePresets",
"(",
"$",
"presets",
",",
"'Removes preset with identifier \"'",
".",
"$",
"identifier",
".",
"'\"'",
")",
";",
"}"
] | Removes a preset from this repository.
@param string $identifier
@return void
@throws Exception | [
"Removes",
"a",
"preset",
"from",
"this",
"repository",
"."
] | train | https://github.com/lightwerk/SurfCaptain/blob/2865e963fd634504d8923902cf422873749a0940/Classes/Lightwerk/SurfCaptain/Domain/Repository/Preset/AbstractRepository.php#L89-L97 |
lightwerk/SurfCaptain | Classes/Lightwerk/SurfCaptain/Domain/Repository/Preset/AbstractRepository.php | AbstractRepository.findByIdentifier | public function findByIdentifier($identifier)
{
$presets = $this->loadPresets();
if (empty($presets[$identifier])) {
throw new Exception('Could not find preset', 1410549868);
}
return $presets[$identifier];
} | php | public function findByIdentifier($identifier)
{
$presets = $this->loadPresets();
if (empty($presets[$identifier])) {
throw new Exception('Could not find preset', 1410549868);
}
return $presets[$identifier];
} | [
"public",
"function",
"findByIdentifier",
"(",
"$",
"identifier",
")",
"{",
"$",
"presets",
"=",
"$",
"this",
"->",
"loadPresets",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"presets",
"[",
"$",
"identifier",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Could not find preset'",
",",
"1410549868",
")",
";",
"}",
"return",
"$",
"presets",
"[",
"$",
"identifier",
"]",
";",
"}"
] | Finds a preset matching the given identifier.
@param string $identifier
@return array $configuration
@throws Exception | [
"Finds",
"a",
"preset",
"matching",
"the",
"given",
"identifier",
"."
] | train | https://github.com/lightwerk/SurfCaptain/blob/2865e963fd634504d8923902cf422873749a0940/Classes/Lightwerk/SurfCaptain/Domain/Repository/Preset/AbstractRepository.php#L116-L123 |
lightwerk/SurfCaptain | Classes/Lightwerk/SurfCaptain/Domain/Repository/Preset/AbstractRepository.php | AbstractRepository.findByRepositoryUrl | public function findByRepositoryUrl($repositoryUrl)
{
$presets = $this->loadPresets();
$repositoryPresets = [];
foreach ($presets as $key => $preset) {
foreach ($preset['applications'] as $application) {
if (!empty($application['options']['repositoryUrl']) && $repositoryUrl === $application['options']['repositoryUrl']) {
$repositoryPresets[$key] = $preset;
}
}
}
return $repositoryPresets;
} | php | public function findByRepositoryUrl($repositoryUrl)
{
$presets = $this->loadPresets();
$repositoryPresets = [];
foreach ($presets as $key => $preset) {
foreach ($preset['applications'] as $application) {
if (!empty($application['options']['repositoryUrl']) && $repositoryUrl === $application['options']['repositoryUrl']) {
$repositoryPresets[$key] = $preset;
}
}
}
return $repositoryPresets;
} | [
"public",
"function",
"findByRepositoryUrl",
"(",
"$",
"repositoryUrl",
")",
"{",
"$",
"presets",
"=",
"$",
"this",
"->",
"loadPresets",
"(",
")",
";",
"$",
"repositoryPresets",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"presets",
"as",
"$",
"key",
"=>",
"$",
"preset",
")",
"{",
"foreach",
"(",
"$",
"preset",
"[",
"'applications'",
"]",
"as",
"$",
"application",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"application",
"[",
"'options'",
"]",
"[",
"'repositoryUrl'",
"]",
")",
"&&",
"$",
"repositoryUrl",
"===",
"$",
"application",
"[",
"'options'",
"]",
"[",
"'repositoryUrl'",
"]",
")",
"{",
"$",
"repositoryPresets",
"[",
"$",
"key",
"]",
"=",
"$",
"preset",
";",
"}",
"}",
"}",
"return",
"$",
"repositoryPresets",
";",
"}"
] | Find presets matching the given repositoryUrl.
@param string $repositoryUrl
@return array $presets | [
"Find",
"presets",
"matching",
"the",
"given",
"repositoryUrl",
"."
] | train | https://github.com/lightwerk/SurfCaptain/blob/2865e963fd634504d8923902cf422873749a0940/Classes/Lightwerk/SurfCaptain/Domain/Repository/Preset/AbstractRepository.php#L131-L143 |
lightwerk/SurfCaptain | Classes/Lightwerk/SurfCaptain/Domain/Repository/Preset/AbstractRepository.php | AbstractRepository.findGlobals | public function findGlobals()
{
$presets = $this->loadPresets();
$globalPresets = [];
foreach ($presets as $key => $preset) {
foreach ($preset['applications'] as $application) {
if (empty($application['options']['repositoryUrl'])) {
$globalPresets[$key] = $preset;
}
}
}
return $globalPresets;
} | php | public function findGlobals()
{
$presets = $this->loadPresets();
$globalPresets = [];
foreach ($presets as $key => $preset) {
foreach ($preset['applications'] as $application) {
if (empty($application['options']['repositoryUrl'])) {
$globalPresets[$key] = $preset;
}
}
}
return $globalPresets;
} | [
"public",
"function",
"findGlobals",
"(",
")",
"{",
"$",
"presets",
"=",
"$",
"this",
"->",
"loadPresets",
"(",
")",
";",
"$",
"globalPresets",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"presets",
"as",
"$",
"key",
"=>",
"$",
"preset",
")",
"{",
"foreach",
"(",
"$",
"preset",
"[",
"'applications'",
"]",
"as",
"$",
"application",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"application",
"[",
"'options'",
"]",
"[",
"'repositoryUrl'",
"]",
")",
")",
"{",
"$",
"globalPresets",
"[",
"$",
"key",
"]",
"=",
"$",
"preset",
";",
"}",
"}",
"}",
"return",
"$",
"globalPresets",
";",
"}"
] | Finds all presets without a repositoryUrl.
@return array $presets | [
"Finds",
"all",
"presets",
"without",
"a",
"repositoryUrl",
"."
] | train | https://github.com/lightwerk/SurfCaptain/blob/2865e963fd634504d8923902cf422873749a0940/Classes/Lightwerk/SurfCaptain/Domain/Repository/Preset/AbstractRepository.php#L150-L162 |
codeblanche/Depend | src/Depend/InjectorFactory.php | InjectorFactory.create | public function create($methodName, $params)
{
$newInstance = clone $this->injectorPrototype;
if (!is_array($params)) {
$params = array($params);
}
return $newInstance->setMethodName($methodName)->setParams($params);
} | php | public function create($methodName, $params)
{
$newInstance = clone $this->injectorPrototype;
if (!is_array($params)) {
$params = array($params);
}
return $newInstance->setMethodName($methodName)->setParams($params);
} | [
"public",
"function",
"create",
"(",
"$",
"methodName",
",",
"$",
"params",
")",
"{",
"$",
"newInstance",
"=",
"clone",
"$",
"this",
"->",
"injectorPrototype",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"params",
")",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"$",
"params",
")",
";",
"}",
"return",
"$",
"newInstance",
"->",
"setMethodName",
"(",
"$",
"methodName",
")",
"->",
"setParams",
"(",
"$",
"params",
")",
";",
"}"
] | @param string $methodName
@param mixed $params
@return InjectorInterface | [
"@param",
"string",
"$methodName",
"@param",
"mixed",
"$params"
] | train | https://github.com/codeblanche/Depend/blob/6520d010ec71f5b2ea0d622b8abae2e029ef7f16/src/Depend/InjectorFactory.php#L29-L38 |
kambalabs/KmbZendDbInfrastructure | src/KmbZendDbInfrastructure/Proxy/GroupClassProxy.php | GroupClassProxy.getGroup | public function getGroup()
{
if ($this->group === null) {
$this->setGroup($this->groupRepository->getByClass($this));
}
return $this->group;
} | php | public function getGroup()
{
if ($this->group === null) {
$this->setGroup($this->groupRepository->getByClass($this));
}
return $this->group;
} | [
"public",
"function",
"getGroup",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"group",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"setGroup",
"(",
"$",
"this",
"->",
"groupRepository",
"->",
"getByClass",
"(",
"$",
"this",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"group",
";",
"}"
] | Get Group.
@return \KmbDomain\Model\GroupInterface | [
"Get",
"Group",
"."
] | train | https://github.com/kambalabs/KmbZendDbInfrastructure/blob/9bf4df4272d2064965202d0e689f944d56a4c6bb/src/KmbZendDbInfrastructure/Proxy/GroupClassProxy.php#L119-L125 |
Palmabit-IT/library | src/Palmabit/Library/Views/Helper.php | Helper.get_active_route_name | public static function get_active_route_name($match, $active = 'active')
{
$route_name = Route::currentRouteName();
return (strcasecmp(static::get_base_route_name($route_name), $match) == 0) ? $active : '';
} | php | public static function get_active_route_name($match, $active = 'active')
{
$route_name = Route::currentRouteName();
return (strcasecmp(static::get_base_route_name($route_name), $match) == 0) ? $active : '';
} | [
"public",
"static",
"function",
"get_active_route_name",
"(",
"$",
"match",
",",
"$",
"active",
"=",
"'active'",
")",
"{",
"$",
"route_name",
"=",
"Route",
"::",
"currentRouteName",
"(",
")",
";",
"return",
"(",
"strcasecmp",
"(",
"static",
"::",
"get_base_route_name",
"(",
"$",
"route_name",
")",
",",
"$",
"match",
")",
"==",
"0",
")",
"?",
"$",
"active",
":",
"''",
";",
"}"
] | Check if route name is the same as the current url and returns active state
@param $match
@param $active | [
"Check",
"if",
"route",
"name",
"is",
"the",
"same",
"as",
"the",
"current",
"url",
"and",
"returns",
"active",
"state"
] | train | https://github.com/Palmabit-IT/library/blob/ec49a3c333eb4e94d9610a0f58d82c9ea1ade4b9/src/Palmabit/Library/Views/Helper.php#L28-L32 |
MatiasNAmendola/slimpower-jwt | src/JWT.php | JWT.decode | public static function decode($jwt, $key, $allowedAlgs = array()) {
$timestamp = is_null(static::$timestamp) ? time() : static::$timestamp;
if (empty($key)) {
throw new \InvalidArgumentException('Key may not be empty');
}
if (!is_array($allowedAlgs)) {
throw new \InvalidArgumentException('Algorithm not allowed');
}
$tks = explode('.', $jwt);
if (count($tks) != 3) {
throw new \UnexpectedValueException('Wrong number of segments');
}
list($headb64, $bodyb64, $cryptob64) = $tks;
if (null === ($header = static::jsonDecode(static::urlsafeB64Decode($headb64)))) {
throw new \UnexpectedValueException('Invalid header encoding');
}
if (null === $payload = static::jsonDecode(static::urlsafeB64Decode($bodyb64))) {
throw new \UnexpectedValueException('Invalid claims encoding');
}
$sig = static::urlsafeB64Decode($cryptob64);
if (empty($header->alg)) {
throw new \UnexpectedValueException('Empty algorithm');
}
if (empty(static::$supported_algs[$header->alg])) {
throw new \UnexpectedValueException('Algorithm not supported');
}
if (!in_array($header->alg, $allowedAlgs)) {
throw new \UnexpectedValueException('Algorithm not allowed');
}
if (is_array($key) || $key instanceof \ArrayAccess) {
if (isset($header->kid)) {
$key = $key[$header->kid];
} else {
throw new \UnexpectedValueException('"kid" empty, unable to lookup correct key');
}
}
// Check the signature
if (!static::verify("$headb64.$bodyb64", $sig, $key, $header->alg)) {
throw new SignatureInvalidException('Signature verification failed');
}
// Check if the nbf if it is defined. This is the time that the
// token can actually be used. If it's not yet that time, abort.
if (isset($payload->nbf) && $payload->nbf > ($timestamp + static::$leeway)) {
throw new BeforeValidException(
'Cannot handle token prior to ' . date(\DateTime::ISO8601, $payload->nbf)
);
}
// Check that this token has been created before 'now'. This prevents
// using tokens that have been created for later use (and haven't
// correctly used the nbf claim).
if (isset($payload->iat) && $payload->iat > ($timestamp + static::$leeway)) {
throw new BeforeValidException(
'Cannot handle token prior to ' . date(\DateTime::ISO8601, $payload->iat)
);
}
// Check if this token has expired.
if (isset($payload->exp) && ($timestamp - static::$leeway) >= $payload->exp) {
throw new ExpiredException('Expired token');
}
return $payload;
} | php | public static function decode($jwt, $key, $allowedAlgs = array()) {
$timestamp = is_null(static::$timestamp) ? time() : static::$timestamp;
if (empty($key)) {
throw new \InvalidArgumentException('Key may not be empty');
}
if (!is_array($allowedAlgs)) {
throw new \InvalidArgumentException('Algorithm not allowed');
}
$tks = explode('.', $jwt);
if (count($tks) != 3) {
throw new \UnexpectedValueException('Wrong number of segments');
}
list($headb64, $bodyb64, $cryptob64) = $tks;
if (null === ($header = static::jsonDecode(static::urlsafeB64Decode($headb64)))) {
throw new \UnexpectedValueException('Invalid header encoding');
}
if (null === $payload = static::jsonDecode(static::urlsafeB64Decode($bodyb64))) {
throw new \UnexpectedValueException('Invalid claims encoding');
}
$sig = static::urlsafeB64Decode($cryptob64);
if (empty($header->alg)) {
throw new \UnexpectedValueException('Empty algorithm');
}
if (empty(static::$supported_algs[$header->alg])) {
throw new \UnexpectedValueException('Algorithm not supported');
}
if (!in_array($header->alg, $allowedAlgs)) {
throw new \UnexpectedValueException('Algorithm not allowed');
}
if (is_array($key) || $key instanceof \ArrayAccess) {
if (isset($header->kid)) {
$key = $key[$header->kid];
} else {
throw new \UnexpectedValueException('"kid" empty, unable to lookup correct key');
}
}
// Check the signature
if (!static::verify("$headb64.$bodyb64", $sig, $key, $header->alg)) {
throw new SignatureInvalidException('Signature verification failed');
}
// Check if the nbf if it is defined. This is the time that the
// token can actually be used. If it's not yet that time, abort.
if (isset($payload->nbf) && $payload->nbf > ($timestamp + static::$leeway)) {
throw new BeforeValidException(
'Cannot handle token prior to ' . date(\DateTime::ISO8601, $payload->nbf)
);
}
// Check that this token has been created before 'now'. This prevents
// using tokens that have been created for later use (and haven't
// correctly used the nbf claim).
if (isset($payload->iat) && $payload->iat > ($timestamp + static::$leeway)) {
throw new BeforeValidException(
'Cannot handle token prior to ' . date(\DateTime::ISO8601, $payload->iat)
);
}
// Check if this token has expired.
if (isset($payload->exp) && ($timestamp - static::$leeway) >= $payload->exp) {
throw new ExpiredException('Expired token');
}
return $payload;
} | [
"public",
"static",
"function",
"decode",
"(",
"$",
"jwt",
",",
"$",
"key",
",",
"$",
"allowedAlgs",
"=",
"array",
"(",
")",
")",
"{",
"$",
"timestamp",
"=",
"is_null",
"(",
"static",
"::",
"$",
"timestamp",
")",
"?",
"time",
"(",
")",
":",
"static",
"::",
"$",
"timestamp",
";",
"if",
"(",
"empty",
"(",
"$",
"key",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Key may not be empty'",
")",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"allowedAlgs",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Algorithm not allowed'",
")",
";",
"}",
"$",
"tks",
"=",
"explode",
"(",
"'.'",
",",
"$",
"jwt",
")",
";",
"if",
"(",
"count",
"(",
"$",
"tks",
")",
"!=",
"3",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"'Wrong number of segments'",
")",
";",
"}",
"list",
"(",
"$",
"headb64",
",",
"$",
"bodyb64",
",",
"$",
"cryptob64",
")",
"=",
"$",
"tks",
";",
"if",
"(",
"null",
"===",
"(",
"$",
"header",
"=",
"static",
"::",
"jsonDecode",
"(",
"static",
"::",
"urlsafeB64Decode",
"(",
"$",
"headb64",
")",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"'Invalid header encoding'",
")",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"payload",
"=",
"static",
"::",
"jsonDecode",
"(",
"static",
"::",
"urlsafeB64Decode",
"(",
"$",
"bodyb64",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"'Invalid claims encoding'",
")",
";",
"}",
"$",
"sig",
"=",
"static",
"::",
"urlsafeB64Decode",
"(",
"$",
"cryptob64",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"header",
"->",
"alg",
")",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"'Empty algorithm'",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"static",
"::",
"$",
"supported_algs",
"[",
"$",
"header",
"->",
"alg",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"'Algorithm not supported'",
")",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"$",
"header",
"->",
"alg",
",",
"$",
"allowedAlgs",
")",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"'Algorithm not allowed'",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"key",
")",
"||",
"$",
"key",
"instanceof",
"\\",
"ArrayAccess",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"header",
"->",
"kid",
")",
")",
"{",
"$",
"key",
"=",
"$",
"key",
"[",
"$",
"header",
"->",
"kid",
"]",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"'\"kid\" empty, unable to lookup correct key'",
")",
";",
"}",
"}",
"// Check the signature",
"if",
"(",
"!",
"static",
"::",
"verify",
"(",
"\"$headb64.$bodyb64\"",
",",
"$",
"sig",
",",
"$",
"key",
",",
"$",
"header",
"->",
"alg",
")",
")",
"{",
"throw",
"new",
"SignatureInvalidException",
"(",
"'Signature verification failed'",
")",
";",
"}",
"// Check if the nbf if it is defined. This is the time that the",
"// token can actually be used. If it's not yet that time, abort.",
"if",
"(",
"isset",
"(",
"$",
"payload",
"->",
"nbf",
")",
"&&",
"$",
"payload",
"->",
"nbf",
">",
"(",
"$",
"timestamp",
"+",
"static",
"::",
"$",
"leeway",
")",
")",
"{",
"throw",
"new",
"BeforeValidException",
"(",
"'Cannot handle token prior to '",
".",
"date",
"(",
"\\",
"DateTime",
"::",
"ISO8601",
",",
"$",
"payload",
"->",
"nbf",
")",
")",
";",
"}",
"// Check that this token has been created before 'now'. This prevents",
"// using tokens that have been created for later use (and haven't",
"// correctly used the nbf claim).",
"if",
"(",
"isset",
"(",
"$",
"payload",
"->",
"iat",
")",
"&&",
"$",
"payload",
"->",
"iat",
">",
"(",
"$",
"timestamp",
"+",
"static",
"::",
"$",
"leeway",
")",
")",
"{",
"throw",
"new",
"BeforeValidException",
"(",
"'Cannot handle token prior to '",
".",
"date",
"(",
"\\",
"DateTime",
"::",
"ISO8601",
",",
"$",
"payload",
"->",
"iat",
")",
")",
";",
"}",
"// Check if this token has expired.",
"if",
"(",
"isset",
"(",
"$",
"payload",
"->",
"exp",
")",
"&&",
"(",
"$",
"timestamp",
"-",
"static",
"::",
"$",
"leeway",
")",
">=",
"$",
"payload",
"->",
"exp",
")",
"{",
"throw",
"new",
"ExpiredException",
"(",
"'Expired token'",
")",
";",
"}",
"return",
"$",
"payload",
";",
"}"
] | Decodes a JWT string into a PHP object.
@param string $jwt The JWT
@param string|array $key The key, or map of keys.
If the algorithm used is asymmetric, this is the public key
@param array $allowedAlgs List of supported verification algorithms
Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256'
@return object The JWT's payload as a PHP object
@throws \UnexpectedValueException Provided JWT was invalid
@throws SignatureInvalidException Provided JWT was invalid because the signature verification failed
@throws BeforeValidException Provided JWT is trying to be used before it's eligible as defined by 'nbf'
@throws BeforeValidException Provided JWT is trying to be used before it's been created as defined by 'iat'
@throws ExpiredException Provided JWT has since expired, as defined by the 'exp' claim
@uses jsonDecode
@uses urlsafeB64Decode | [
"Decodes",
"a",
"JWT",
"string",
"into",
"a",
"PHP",
"object",
"."
] | train | https://github.com/MatiasNAmendola/slimpower-jwt/blob/5afc151e8a37b06fe6cb6a44ff776e7ec9f40e98/src/JWT.php#L84-L161 |
ColonelBlimp/NsanjaConfig | src/Nsanja/Platform/Config/Configuration.php | Configuration.getSiteUrl | public function getSiteUrl(): string
{
$url = $this->getStringValue(PlatformConfigurationInterface::KEY_SITE_URL);
if (empty($url)) {
$scheme = \filter_input(INPUT_SERVER, 'REQUEST_SCHEME');
$server = \filter_input(INPUT_SERVER, 'SERVER_NAME');
$url = $scheme.'://'.$server;
}
return $url;
} | php | public function getSiteUrl(): string
{
$url = $this->getStringValue(PlatformConfigurationInterface::KEY_SITE_URL);
if (empty($url)) {
$scheme = \filter_input(INPUT_SERVER, 'REQUEST_SCHEME');
$server = \filter_input(INPUT_SERVER, 'SERVER_NAME');
$url = $scheme.'://'.$server;
}
return $url;
} | [
"public",
"function",
"getSiteUrl",
"(",
")",
":",
"string",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"getStringValue",
"(",
"PlatformConfigurationInterface",
"::",
"KEY_SITE_URL",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"url",
")",
")",
"{",
"$",
"scheme",
"=",
"\\",
"filter_input",
"(",
"INPUT_SERVER",
",",
"'REQUEST_SCHEME'",
")",
";",
"$",
"server",
"=",
"\\",
"filter_input",
"(",
"INPUT_SERVER",
",",
"'SERVER_NAME'",
")",
";",
"$",
"url",
"=",
"$",
"scheme",
".",
"'://'",
".",
"$",
"server",
";",
"}",
"return",
"$",
"url",
";",
"}"
] | {@inheritDoc}
@see \Nsanja\Core\Config\PlatformConfigurationInterface::getSiteUrl() | [
"{"
] | train | https://github.com/ColonelBlimp/NsanjaConfig/blob/d23609c6cd00f7c524f122b16c532681b8c489be/src/Nsanja/Platform/Config/Configuration.php#L43-L54 |
Hnto/nuki | src/Handlers/Security/Crypter.php | Crypter.encrypt | public function encrypt($data, $key) {
$this->validateData($data);
$this->validateKey($key);
$iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length(self::CIPHER_METHOD));
$encrypted = openssl_encrypt($data, self::CIPHER_METHOD, $key, 0, $iv);
$encoded = base64_encode($encrypted . self::ENCRYPTED_IV_SEPERATOR . $iv);
return new Encrypted($encoded);
} | php | public function encrypt($data, $key) {
$this->validateData($data);
$this->validateKey($key);
$iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length(self::CIPHER_METHOD));
$encrypted = openssl_encrypt($data, self::CIPHER_METHOD, $key, 0, $iv);
$encoded = base64_encode($encrypted . self::ENCRYPTED_IV_SEPERATOR . $iv);
return new Encrypted($encoded);
} | [
"public",
"function",
"encrypt",
"(",
"$",
"data",
",",
"$",
"key",
")",
"{",
"$",
"this",
"->",
"validateData",
"(",
"$",
"data",
")",
";",
"$",
"this",
"->",
"validateKey",
"(",
"$",
"key",
")",
";",
"$",
"iv",
"=",
"openssl_random_pseudo_bytes",
"(",
"openssl_cipher_iv_length",
"(",
"self",
"::",
"CIPHER_METHOD",
")",
")",
";",
"$",
"encrypted",
"=",
"openssl_encrypt",
"(",
"$",
"data",
",",
"self",
"::",
"CIPHER_METHOD",
",",
"$",
"key",
",",
"0",
",",
"$",
"iv",
")",
";",
"$",
"encoded",
"=",
"base64_encode",
"(",
"$",
"encrypted",
".",
"self",
"::",
"ENCRYPTED_IV_SEPERATOR",
".",
"$",
"iv",
")",
";",
"return",
"new",
"Encrypted",
"(",
"$",
"encoded",
")",
";",
"}"
] | Encrypt data by key
@param string $data
@param string $key
@return Encrypted | [
"Encrypt",
"data",
"by",
"key"
] | train | https://github.com/Hnto/nuki/blob/c3fb16244e8d611c335a88e3b9c9ee7d81fafc0c/src/Handlers/Security/Crypter.php#L39-L49 |
Hnto/nuki | src/Handlers/Security/Crypter.php | Crypter.decrypt | public function decrypt($data, $key) : string {
$this->validateData($data);
$this->validateKey($key);
if (empty($data)) {
return '';
}
list($encrypted, $iv) = explode(self::ENCRYPTED_IV_SEPERATOR, base64_decode($data), 2);
return openssl_decrypt($encrypted, self::CIPHER_METHOD, $key, 0, $iv);
} | php | public function decrypt($data, $key) : string {
$this->validateData($data);
$this->validateKey($key);
if (empty($data)) {
return '';
}
list($encrypted, $iv) = explode(self::ENCRYPTED_IV_SEPERATOR, base64_decode($data), 2);
return openssl_decrypt($encrypted, self::CIPHER_METHOD, $key, 0, $iv);
} | [
"public",
"function",
"decrypt",
"(",
"$",
"data",
",",
"$",
"key",
")",
":",
"string",
"{",
"$",
"this",
"->",
"validateData",
"(",
"$",
"data",
")",
";",
"$",
"this",
"->",
"validateKey",
"(",
"$",
"key",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"data",
")",
")",
"{",
"return",
"''",
";",
"}",
"list",
"(",
"$",
"encrypted",
",",
"$",
"iv",
")",
"=",
"explode",
"(",
"self",
"::",
"ENCRYPTED_IV_SEPERATOR",
",",
"base64_decode",
"(",
"$",
"data",
")",
",",
"2",
")",
";",
"return",
"openssl_decrypt",
"(",
"$",
"encrypted",
",",
"self",
"::",
"CIPHER_METHOD",
",",
"$",
"key",
",",
"0",
",",
"$",
"iv",
")",
";",
"}"
] | Decrypt data by key
@param mixed $data
@param string $key
@return string | [
"Decrypt",
"data",
"by",
"key"
] | train | https://github.com/Hnto/nuki/blob/c3fb16244e8d611c335a88e3b9c9ee7d81fafc0c/src/Handlers/Security/Crypter.php#L58-L69 |
Hnto/nuki | src/Handlers/Security/Crypter.php | Crypter.validateKey | private function validateKey($key) : bool {
if (!hash_equals($this->appKey, $key)) {
throw new \Nuki\Exceptions\Base('Used key does not equal the known application key');
}
return true;
} | php | private function validateKey($key) : bool {
if (!hash_equals($this->appKey, $key)) {
throw new \Nuki\Exceptions\Base('Used key does not equal the known application key');
}
return true;
} | [
"private",
"function",
"validateKey",
"(",
"$",
"key",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"hash_equals",
"(",
"$",
"this",
"->",
"appKey",
",",
"$",
"key",
")",
")",
"{",
"throw",
"new",
"\\",
"Nuki",
"\\",
"Exceptions",
"\\",
"Base",
"(",
"'Used key does not equal the known application key'",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Validate the crypter application key against the used key
@param string $key
@return boolean
@throws \Nuki\Exceptions\Base | [
"Validate",
"the",
"crypter",
"application",
"key",
"against",
"the",
"used",
"key"
] | train | https://github.com/Hnto/nuki/blob/c3fb16244e8d611c335a88e3b9c9ee7d81fafc0c/src/Handlers/Security/Crypter.php#L78-L84 |
craig-mcmahon/google-helper | src/GoogleHelper/Apps/EmailHelper.php | EmailHelper.getSignature | public function getSignature($domain, $user)
{
$url = self::BASE_URL . "{$domain}/{$user}/signature";
$request = new \Google_Http_Request($url, 'GET', null, null);
$httpRequest = $this->helper->getClient()
->getAuth()
->authenticatedRequest($request);
if ($httpRequest->getResponseHttpCode() == 200) {
$xmlResponse = new \SimpleXMLElement($httpRequest->getResponseBody(), 0, false, 'apps', true);
return (string)$xmlResponse->children('apps', true)
->attributes()->value;
} else {
// An error occurred.
return null;
}
} | php | public function getSignature($domain, $user)
{
$url = self::BASE_URL . "{$domain}/{$user}/signature";
$request = new \Google_Http_Request($url, 'GET', null, null);
$httpRequest = $this->helper->getClient()
->getAuth()
->authenticatedRequest($request);
if ($httpRequest->getResponseHttpCode() == 200) {
$xmlResponse = new \SimpleXMLElement($httpRequest->getResponseBody(), 0, false, 'apps', true);
return (string)$xmlResponse->children('apps', true)
->attributes()->value;
} else {
// An error occurred.
return null;
}
} | [
"public",
"function",
"getSignature",
"(",
"$",
"domain",
",",
"$",
"user",
")",
"{",
"$",
"url",
"=",
"self",
"::",
"BASE_URL",
".",
"\"{$domain}/{$user}/signature\"",
";",
"$",
"request",
"=",
"new",
"\\",
"Google_Http_Request",
"(",
"$",
"url",
",",
"'GET'",
",",
"null",
",",
"null",
")",
";",
"$",
"httpRequest",
"=",
"$",
"this",
"->",
"helper",
"->",
"getClient",
"(",
")",
"->",
"getAuth",
"(",
")",
"->",
"authenticatedRequest",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"httpRequest",
"->",
"getResponseHttpCode",
"(",
")",
"==",
"200",
")",
"{",
"$",
"xmlResponse",
"=",
"new",
"\\",
"SimpleXMLElement",
"(",
"$",
"httpRequest",
"->",
"getResponseBody",
"(",
")",
",",
"0",
",",
"false",
",",
"'apps'",
",",
"true",
")",
";",
"return",
"(",
"string",
")",
"$",
"xmlResponse",
"->",
"children",
"(",
"'apps'",
",",
"true",
")",
"->",
"attributes",
"(",
")",
"->",
"value",
";",
"}",
"else",
"{",
"// An error occurred.",
"return",
"null",
";",
"}",
"}"
] | Get a Users email signature
@param string $domain
@param string $user
@return string|null Signature or null on error | [
"Get",
"a",
"Users",
"email",
"signature"
] | train | https://github.com/craig-mcmahon/google-helper/blob/6b877efd7c9827555ecac65ee01e337849db6611/src/GoogleHelper/Apps/EmailHelper.php#L17-L34 |
craig-mcmahon/google-helper | src/GoogleHelper/Apps/EmailHelper.php | EmailHelper.setSignature | public function setSignature($domain, $user, $signature)
{
$url = self::BASE_URL . "{$domain}/{$user}/signature";
$request = <<<XML
<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">
<apps:property name="signature" value="{$signature}" />
</atom:entry>
XML;
$request = new \Google_Http_Request($url, 'PUT', array('Content-Type' => 'application/atom+xml'),
$request);
$httpRequest = $this->helper->getClient()
->getAuth()
->authenticatedRequest($request);
return ($httpRequest->getResponseHttpCode() == 200);
} | php | public function setSignature($domain, $user, $signature)
{
$url = self::BASE_URL . "{$domain}/{$user}/signature";
$request = <<<XML
<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">
<apps:property name="signature" value="{$signature}" />
</atom:entry>
XML;
$request = new \Google_Http_Request($url, 'PUT', array('Content-Type' => 'application/atom+xml'),
$request);
$httpRequest = $this->helper->getClient()
->getAuth()
->authenticatedRequest($request);
return ($httpRequest->getResponseHttpCode() == 200);
} | [
"public",
"function",
"setSignature",
"(",
"$",
"domain",
",",
"$",
"user",
",",
"$",
"signature",
")",
"{",
"$",
"url",
"=",
"self",
"::",
"BASE_URL",
".",
"\"{$domain}/{$user}/signature\"",
";",
"$",
"request",
"=",
" <<<XML\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<atom:entry xmlns:atom=\"http://www.w3.org/2005/Atom\" xmlns:apps=\"http://schemas.google.com/apps/2006\">\n <apps:property name=\"signature\" value=\"{$signature}\" />\n</atom:entry>\nXML",
";",
"$",
"request",
"=",
"new",
"\\",
"Google_Http_Request",
"(",
"$",
"url",
",",
"'PUT'",
",",
"array",
"(",
"'Content-Type'",
"=>",
"'application/atom+xml'",
")",
",",
"$",
"request",
")",
";",
"$",
"httpRequest",
"=",
"$",
"this",
"->",
"helper",
"->",
"getClient",
"(",
")",
"->",
"getAuth",
"(",
")",
"->",
"authenticatedRequest",
"(",
"$",
"request",
")",
";",
"return",
"(",
"$",
"httpRequest",
"->",
"getResponseHttpCode",
"(",
")",
"==",
"200",
")",
";",
"}"
] | Set a Users email signature
@param string $domain
@param string $user
@param string $signature
@return bool success | [
"Set",
"a",
"Users",
"email",
"signature"
] | train | https://github.com/craig-mcmahon/google-helper/blob/6b877efd7c9827555ecac65ee01e337849db6611/src/GoogleHelper/Apps/EmailHelper.php#L43-L59 |
craig-mcmahon/google-helper | src/GoogleHelper/Apps/EmailHelper.php | EmailHelper.setSendAsAlias | public function setSendAsAlias($domain, $user, $name, $address, $replyTo = null, $makeDefault = false)
{
$url = self::BASE_URL . "{$domain}/{$user}/sendas";
$request = <<<XML
<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">
<apps:property name="name" value="{$name}" />
<apps:property name="address" value="{$address}" />
XML;
if ($replyTo !== null) {
$request .= "<apps:property name=\"replyTo\" value=\"{$replyTo}\" />";
}
if ($makeDefault) {
$request .= "<apps:property name=\"makeDefault\" value=\"true\" />";
}
$request .= "</atom:entry>";
$request = new \Google_Http_Request($url, 'POST', array('Content-Type' => 'application/atom+xml'),
$request);
$httpRequest = $this->helper->getClient()
->getAuth()
->authenticatedRequest($request);
return ($httpRequest->getResponseHttpCode() == 201);
} | php | public function setSendAsAlias($domain, $user, $name, $address, $replyTo = null, $makeDefault = false)
{
$url = self::BASE_URL . "{$domain}/{$user}/sendas";
$request = <<<XML
<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">
<apps:property name="name" value="{$name}" />
<apps:property name="address" value="{$address}" />
XML;
if ($replyTo !== null) {
$request .= "<apps:property name=\"replyTo\" value=\"{$replyTo}\" />";
}
if ($makeDefault) {
$request .= "<apps:property name=\"makeDefault\" value=\"true\" />";
}
$request .= "</atom:entry>";
$request = new \Google_Http_Request($url, 'POST', array('Content-Type' => 'application/atom+xml'),
$request);
$httpRequest = $this->helper->getClient()
->getAuth()
->authenticatedRequest($request);
return ($httpRequest->getResponseHttpCode() == 201);
} | [
"public",
"function",
"setSendAsAlias",
"(",
"$",
"domain",
",",
"$",
"user",
",",
"$",
"name",
",",
"$",
"address",
",",
"$",
"replyTo",
"=",
"null",
",",
"$",
"makeDefault",
"=",
"false",
")",
"{",
"$",
"url",
"=",
"self",
"::",
"BASE_URL",
".",
"\"{$domain}/{$user}/sendas\"",
";",
"$",
"request",
"=",
" <<<XML\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<atom:entry xmlns:atom=\"http://www.w3.org/2005/Atom\" xmlns:apps=\"http://schemas.google.com/apps/2006\">\n <apps:property name=\"name\" value=\"{$name}\" />\n <apps:property name=\"address\" value=\"{$address}\" />\nXML",
";",
"if",
"(",
"$",
"replyTo",
"!==",
"null",
")",
"{",
"$",
"request",
".=",
"\"<apps:property name=\\\"replyTo\\\" value=\\\"{$replyTo}\\\" />\"",
";",
"}",
"if",
"(",
"$",
"makeDefault",
")",
"{",
"$",
"request",
".=",
"\"<apps:property name=\\\"makeDefault\\\" value=\\\"true\\\" />\"",
";",
"}",
"$",
"request",
".=",
"\"</atom:entry>\"",
";",
"$",
"request",
"=",
"new",
"\\",
"Google_Http_Request",
"(",
"$",
"url",
",",
"'POST'",
",",
"array",
"(",
"'Content-Type'",
"=>",
"'application/atom+xml'",
")",
",",
"$",
"request",
")",
";",
"$",
"httpRequest",
"=",
"$",
"this",
"->",
"helper",
"->",
"getClient",
"(",
")",
"->",
"getAuth",
"(",
")",
"->",
"authenticatedRequest",
"(",
"$",
"request",
")",
";",
"return",
"(",
"$",
"httpRequest",
"->",
"getResponseHttpCode",
"(",
")",
"==",
"201",
")",
";",
"}"
] | Add a Send-as Alias
@param string $domain
@param string $user
@param string $name
@param string $address
@param string|null $replyTo
@param bool $makeDefault
@return bool Success | [
"Add",
"a",
"Send",
"-",
"as",
"Alias"
] | train | https://github.com/craig-mcmahon/google-helper/blob/6b877efd7c9827555ecac65ee01e337849db6611/src/GoogleHelper/Apps/EmailHelper.php#L71-L95 |
shampeak/GraceServer | src/Cache/Cache.php | Cache.set | public function set($key, $value, $ttl = null)
{
return $this->_instance->set($key, $value, $ttl);
} | php | public function set($key, $value, $ttl = null)
{
return $this->_instance->set($key, $value, $ttl);
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"ttl",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"_instance",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"ttl",
")",
";",
"}"
] | * Add a value to the cache under a unique key
@param string $key
@param mixed $value
@param int $ttl | [
"*",
"Add",
"a",
"value",
"to",
"the",
"cache",
"under",
"a",
"unique",
"key"
] | train | https://github.com/shampeak/GraceServer/blob/e69891de3daae7d228c803c06213eb248fc88594/src/Cache/Cache.php#L74-L77 |
shampeak/GraceServer | src/Cache/Cache.php | Cache.setAdapter | public function setAdapter(\Desarrolla2\Cache\Adapter\AdapterInterface $adapter)
{
return $this->_instance->setAdapter($adapter);
} | php | public function setAdapter(\Desarrolla2\Cache\Adapter\AdapterInterface $adapter)
{
return $this->_instance->setAdapter($adapter);
} | [
"public",
"function",
"setAdapter",
"(",
"\\",
"Desarrolla2",
"\\",
"Cache",
"\\",
"Adapter",
"\\",
"AdapterInterface",
"$",
"adapter",
")",
"{",
"return",
"$",
"this",
"->",
"_instance",
"->",
"setAdapter",
"(",
"$",
"adapter",
")",
";",
"}"
] | Set Adapter interface
@param \Desarrolla2\Cache\Adapter\AdapterInterface $adapter | [
"Set",
"Adapter",
"interface"
] | train | https://github.com/shampeak/GraceServer/blob/e69891de3daae7d228c803c06213eb248fc88594/src/Cache/Cache.php#L84-L87 |
vanilla/garden-daemon | src/ErrorHandler.php | ErrorHandler.removerHandler | public function removerHandler(callable $handler) {
foreach ($this->handlers as $i => $oldHandler) {
if ($handler == $oldHandler['handler']) {
unset($this->handlers[$i]);
}
}
} | php | public function removerHandler(callable $handler) {
foreach ($this->handlers as $i => $oldHandler) {
if ($handler == $oldHandler['handler']) {
unset($this->handlers[$i]);
}
}
} | [
"public",
"function",
"removerHandler",
"(",
"callable",
"$",
"handler",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"handlers",
"as",
"$",
"i",
"=>",
"$",
"oldHandler",
")",
"{",
"if",
"(",
"$",
"handler",
"==",
"$",
"oldHandler",
"[",
"'handler'",
"]",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"handlers",
"[",
"$",
"i",
"]",
")",
";",
"}",
"}",
"}"
] | Remove handler
@param \Callable $handler | [
"Remove",
"handler"
] | train | https://github.com/vanilla/garden-daemon/blob/13a5cbbac08ab6473e4b11bf00179fe1e26235a6/src/ErrorHandler.php#L59-L65 |
vanilla/garden-daemon | src/ErrorHandler.php | ErrorHandler.error | public function error($errorNumber, $message, $file, $line, $context) {
$errorReporting = error_reporting();
$errorEnabled = (bool)($errorReporting & $errorNumber);
// Ignore errors that are below the current error reporting level.
if (!$errorEnabled) {
return false;
}
$backtrace = debug_backtrace();
throw new ErrorException($message, $errorNumber, $file, $line, $context, $backtrace);
} | php | public function error($errorNumber, $message, $file, $line, $context) {
$errorReporting = error_reporting();
$errorEnabled = (bool)($errorReporting & $errorNumber);
// Ignore errors that are below the current error reporting level.
if (!$errorEnabled) {
return false;
}
$backtrace = debug_backtrace();
throw new ErrorException($message, $errorNumber, $file, $line, $context, $backtrace);
} | [
"public",
"function",
"error",
"(",
"$",
"errorNumber",
",",
"$",
"message",
",",
"$",
"file",
",",
"$",
"line",
",",
"$",
"context",
")",
"{",
"$",
"errorReporting",
"=",
"error_reporting",
"(",
")",
";",
"$",
"errorEnabled",
"=",
"(",
"bool",
")",
"(",
"$",
"errorReporting",
"&",
"$",
"errorNumber",
")",
";",
"// Ignore errors that are below the current error reporting level.",
"if",
"(",
"!",
"$",
"errorEnabled",
")",
"{",
"return",
"false",
";",
"}",
"$",
"backtrace",
"=",
"debug_backtrace",
"(",
")",
";",
"throw",
"new",
"ErrorException",
"(",
"$",
"message",
",",
"$",
"errorNumber",
",",
"$",
"file",
",",
"$",
"line",
",",
"$",
"context",
",",
"$",
"backtrace",
")",
";",
"}"
] | Handle error
@param int $errorNumber
@param string $message
@param string $file
@param int $line
@param array $context | [
"Handle",
"error"
] | train | https://github.com/vanilla/garden-daemon/blob/13a5cbbac08ab6473e4b11bf00179fe1e26235a6/src/ErrorHandler.php#L76-L87 |
vanilla/garden-daemon | src/ErrorHandler.php | ErrorHandler.exception | public function exception(\Throwable $exception) {
if (count($this->handlers)) {
foreach ($this->handlers as $handler) {
$handlerMask = $handler['error_mask'];
$errorEnabled = $exception->getCode() === 0 || (bool)($handlerMask & $exception->getCode());
if ($errorEnabled) {
$context = method_exists($exception, 'getContext') ? $exception->getContext() : [];
$continue = $this->di->call($handler['handler'], [$exception->getCode(), $exception->getMessage(), $exception->getFile(), $exception->getLine(), $context]);
if ($continue === false) {
break;
}
}
}
}
} | php | public function exception(\Throwable $exception) {
if (count($this->handlers)) {
foreach ($this->handlers as $handler) {
$handlerMask = $handler['error_mask'];
$errorEnabled = $exception->getCode() === 0 || (bool)($handlerMask & $exception->getCode());
if ($errorEnabled) {
$context = method_exists($exception, 'getContext') ? $exception->getContext() : [];
$continue = $this->di->call($handler['handler'], [$exception->getCode(), $exception->getMessage(), $exception->getFile(), $exception->getLine(), $context]);
if ($continue === false) {
break;
}
}
}
}
} | [
"public",
"function",
"exception",
"(",
"\\",
"Throwable",
"$",
"exception",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"handlers",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"handlers",
"as",
"$",
"handler",
")",
"{",
"$",
"handlerMask",
"=",
"$",
"handler",
"[",
"'error_mask'",
"]",
";",
"$",
"errorEnabled",
"=",
"$",
"exception",
"->",
"getCode",
"(",
")",
"===",
"0",
"||",
"(",
"bool",
")",
"(",
"$",
"handlerMask",
"&",
"$",
"exception",
"->",
"getCode",
"(",
")",
")",
";",
"if",
"(",
"$",
"errorEnabled",
")",
"{",
"$",
"context",
"=",
"method_exists",
"(",
"$",
"exception",
",",
"'getContext'",
")",
"?",
"$",
"exception",
"->",
"getContext",
"(",
")",
":",
"[",
"]",
";",
"$",
"continue",
"=",
"$",
"this",
"->",
"di",
"->",
"call",
"(",
"$",
"handler",
"[",
"'handler'",
"]",
",",
"[",
"$",
"exception",
"->",
"getCode",
"(",
")",
",",
"$",
"exception",
"->",
"getMessage",
"(",
")",
",",
"$",
"exception",
"->",
"getFile",
"(",
")",
",",
"$",
"exception",
"->",
"getLine",
"(",
")",
",",
"$",
"context",
"]",
")",
";",
"if",
"(",
"$",
"continue",
"===",
"false",
")",
"{",
"break",
";",
"}",
"}",
"}",
"}",
"}"
] | Handle exception
@param \Throwable $exception | [
"Handle",
"exception"
] | train | https://github.com/vanilla/garden-daemon/blob/13a5cbbac08ab6473e4b11bf00179fe1e26235a6/src/ErrorHandler.php#L94-L110 |
nochso/ORM2 | src/DBA/DBA.php | DBA.execute | public static function execute($sql, $data = [])
{
$statement = self::$pdo->prepare($sql);
$statement->execute($data);
return $statement;
} | php | public static function execute($sql, $data = [])
{
$statement = self::$pdo->prepare($sql);
$statement->execute($data);
return $statement;
} | [
"public",
"static",
"function",
"execute",
"(",
"$",
"sql",
",",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"statement",
"=",
"self",
"::",
"$",
"pdo",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"$",
"statement",
"->",
"execute",
"(",
"$",
"data",
")",
";",
"return",
"$",
"statement",
";",
"}"
] | @param string $sql
@param array $data optional
@return \PDOStatement | [
"@param",
"string",
"$sql",
"@param",
"array",
"$data",
"optional"
] | train | https://github.com/nochso/ORM2/blob/89f9a5c61ad5f575fbdd52990171b52d54f8bfbc/src/DBA/DBA.php#L40-L45 |
nochso/ORM2 | src/DBA/DBA.php | DBA.escapeLike | public static function escapeLike($string, $escapeChar = '=')
{
return str_replace(
[
$escapeChar,
'_',
'%',
],
[
$escapeChar . $escapeChar,
$escapeChar . '_',
$escapeChar . '%',
],
$string
);
} | php | public static function escapeLike($string, $escapeChar = '=')
{
return str_replace(
[
$escapeChar,
'_',
'%',
],
[
$escapeChar . $escapeChar,
$escapeChar . '_',
$escapeChar . '%',
],
$string
);
} | [
"public",
"static",
"function",
"escapeLike",
"(",
"$",
"string",
",",
"$",
"escapeChar",
"=",
"'='",
")",
"{",
"return",
"str_replace",
"(",
"[",
"$",
"escapeChar",
",",
"'_'",
",",
"'%'",
",",
"]",
",",
"[",
"$",
"escapeChar",
".",
"$",
"escapeChar",
",",
"$",
"escapeChar",
".",
"'_'",
",",
"$",
"escapeChar",
".",
"'%'",
",",
"]",
",",
"$",
"string",
")",
";",
"}"
] | SQLite dialog: escaping of wild card characters
@param string $string Unsafe input
@param string $escapeChar
@return string | [
"SQLite",
"dialog",
":",
"escaping",
"of",
"wild",
"card",
"characters"
] | train | https://github.com/nochso/ORM2/blob/89f9a5c61ad5f575fbdd52990171b52d54f8bfbc/src/DBA/DBA.php#L55-L70 |
nochso/ORM2 | src/DBA/DBA.php | DBA.getLog | public static function getLog($empty = false)
{
$log = self::$log;
if ($empty) {
self::emptyLog();
}
return $log;
} | php | public static function getLog($empty = false)
{
$log = self::$log;
if ($empty) {
self::emptyLog();
}
return $log;
} | [
"public",
"static",
"function",
"getLog",
"(",
"$",
"empty",
"=",
"false",
")",
"{",
"$",
"log",
"=",
"self",
"::",
"$",
"log",
";",
"if",
"(",
"$",
"empty",
")",
"{",
"self",
"::",
"emptyLog",
"(",
")",
";",
"}",
"return",
"$",
"log",
";",
"}"
] | Returns all log entries and optionally removes them
@param bool $empty
@return LogEntry[] | [
"Returns",
"all",
"log",
"entries",
"and",
"optionally",
"removes",
"them"
] | train | https://github.com/nochso/ORM2/blob/89f9a5c61ad5f575fbdd52990171b52d54f8bfbc/src/DBA/DBA.php#L116-L123 |
MindyPHP/Pagination | PaginationFactory.php | PaginationFactory.createPagination | public function createPagination($source, array $parameters, PaginationHandlerInterface $handler = null)
{
return new Pagination(
$source,
$parameters,
$handler ? $handler : new NativePaginationHandler(),
$this->findDataSource($source)
);
} | php | public function createPagination($source, array $parameters, PaginationHandlerInterface $handler = null)
{
return new Pagination(
$source,
$parameters,
$handler ? $handler : new NativePaginationHandler(),
$this->findDataSource($source)
);
} | [
"public",
"function",
"createPagination",
"(",
"$",
"source",
",",
"array",
"$",
"parameters",
",",
"PaginationHandlerInterface",
"$",
"handler",
"=",
"null",
")",
"{",
"return",
"new",
"Pagination",
"(",
"$",
"source",
",",
"$",
"parameters",
",",
"$",
"handler",
"?",
"$",
"handler",
":",
"new",
"NativePaginationHandler",
"(",
")",
",",
"$",
"this",
"->",
"findDataSource",
"(",
"$",
"source",
")",
")",
";",
"}"
] | @param array|DataSourceInterface|mixed $source
@param array $parameters
@param PaginationHandlerInterface|null $handler
@return Pagination | [
"@param",
"array|DataSourceInterface|mixed",
"$source",
"@param",
"array",
"$parameters",
"@param",
"PaginationHandlerInterface|null",
"$handler"
] | train | https://github.com/MindyPHP/Pagination/blob/9f38cc7ac219ea2639b88d9f45351c7b24ea8322/PaginationFactory.php#L35-L43 |
MindyPHP/Pagination | PaginationFactory.php | PaginationFactory.findDataSource | protected function findDataSource($source)
{
foreach ($this->dataSources as $dataSource) {
if ($dataSource->supports($source)) {
return $dataSource;
}
}
throw new \RuntimeException('Unknown source type');
} | php | protected function findDataSource($source)
{
foreach ($this->dataSources as $dataSource) {
if ($dataSource->supports($source)) {
return $dataSource;
}
}
throw new \RuntimeException('Unknown source type');
} | [
"protected",
"function",
"findDataSource",
"(",
"$",
"source",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"dataSources",
"as",
"$",
"dataSource",
")",
"{",
"if",
"(",
"$",
"dataSource",
"->",
"supports",
"(",
"$",
"source",
")",
")",
"{",
"return",
"$",
"dataSource",
";",
"}",
"}",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Unknown source type'",
")",
";",
"}"
] | @param $source
@return DataSourceInterface | [
"@param",
"$source"
] | train | https://github.com/MindyPHP/Pagination/blob/9f38cc7ac219ea2639b88d9f45351c7b24ea8322/PaginationFactory.php#L50-L59 |
KDF5000/EasyThink | src/ThinkPHP/Library/Think/Model/RelationModel.php | RelationModel.getRelationTableName | public function getRelationTableName($relation) {
$relationTable = !empty($this->tablePrefix) ? $this->tablePrefix : '';
$relationTable .= $this->tableName?$this->tableName:$this->name;
$relationTable .= '_'.$relation->getModelName();
return strtolower($relationTable);
} | php | public function getRelationTableName($relation) {
$relationTable = !empty($this->tablePrefix) ? $this->tablePrefix : '';
$relationTable .= $this->tableName?$this->tableName:$this->name;
$relationTable .= '_'.$relation->getModelName();
return strtolower($relationTable);
} | [
"public",
"function",
"getRelationTableName",
"(",
"$",
"relation",
")",
"{",
"$",
"relationTable",
"=",
"!",
"empty",
"(",
"$",
"this",
"->",
"tablePrefix",
")",
"?",
"$",
"this",
"->",
"tablePrefix",
":",
"''",
";",
"$",
"relationTable",
".=",
"$",
"this",
"->",
"tableName",
"?",
"$",
"this",
"->",
"tableName",
":",
"$",
"this",
"->",
"name",
";",
"$",
"relationTable",
".=",
"'_'",
".",
"$",
"relation",
"->",
"getModelName",
"(",
")",
";",
"return",
"strtolower",
"(",
"$",
"relationTable",
")",
";",
"}"
] | 得到关联的数据表名
@access public
@return string | [
"得到关联的数据表名"
] | train | https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Think/Model/RelationModel.php#L50-L55 |
KDF5000/EasyThink | src/ThinkPHP/Library/Think/Model/RelationModel.php | RelationModel.getRelations | protected function getRelations(&$resultSet,$name='') {
// 获取记录集的主键列表
foreach($resultSet as $key=>$val) {
$val = $this->getRelation($val,$name);
$resultSet[$key] = $val;
}
return $resultSet;
} | php | protected function getRelations(&$resultSet,$name='') {
// 获取记录集的主键列表
foreach($resultSet as $key=>$val) {
$val = $this->getRelation($val,$name);
$resultSet[$key] = $val;
}
return $resultSet;
} | [
"protected",
"function",
"getRelations",
"(",
"&",
"$",
"resultSet",
",",
"$",
"name",
"=",
"''",
")",
"{",
"// 获取记录集的主键列表",
"foreach",
"(",
"$",
"resultSet",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"$",
"val",
"=",
"$",
"this",
"->",
"getRelation",
"(",
"$",
"val",
",",
"$",
"name",
")",
";",
"$",
"resultSet",
"[",
"$",
"key",
"]",
"=",
"$",
"val",
";",
"}",
"return",
"$",
"resultSet",
";",
"}"
] | 获取返回数据集的关联记录
@access protected
@param array $resultSet 返回数据
@param string|array $name 关联名称
@return array | [
"获取返回数据集的关联记录"
] | train | https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Think/Model/RelationModel.php#L110-L117 |
KDF5000/EasyThink | src/ThinkPHP/Library/Think/Model/RelationModel.php | RelationModel.getRelation | protected function getRelation(&$result,$name='',$return=false) {
if(!empty($this->_link)) {
foreach($this->_link as $key=>$val) {
$mappingName = !empty($val['mapping_name'])?$val['mapping_name']:$key; // 映射名称
if(empty($name) || true === $name || $mappingName == $name || (is_array($name) && in_array($mappingName,$name))) {
$mappingType = !empty($val['mapping_type'])?$val['mapping_type']:$val; // 关联类型
$mappingClass = !empty($val['class_name'])?$val['class_name']:$key; // 关联类名
$mappingFields = !empty($val['mapping_fields'])?$val['mapping_fields']:'*'; // 映射字段
$mappingCondition = !empty($val['condition'])?$val['condition']:'1=1'; // 关联条件
$mappingKey =!empty($val['mapping_key'])? $val['mapping_key'] : $this->getPk(); // 关联键名
if(strtoupper($mappingClass)==strtoupper($this->name)) {
// 自引用关联 获取父键名
$mappingFk = !empty($val['parent_key'])? $val['parent_key'] : 'parent_id';
}else{
$mappingFk = !empty($val['foreign_key'])?$val['foreign_key']:strtolower($this->name).'_id'; // 关联外键
}
// 获取关联模型对象
$model = D($mappingClass);
switch($mappingType) {
case self::HAS_ONE:
$pk = $result[$mappingKey];
$mappingCondition .= " AND {$mappingFk}='{$pk}'";
$relationData = $model->where($mappingCondition)->field($mappingFields)->find();
if (!empty($val['relation_deep'])){
$model->getRelation($relationData,$val['relation_deep']);
}
break;
case self::BELONGS_TO:
if(strtoupper($mappingClass)==strtoupper($this->name)) {
// 自引用关联 获取父键名
$mappingFk = !empty($val['parent_key'])? $val['parent_key'] : 'parent_id';
}else{
$mappingFk = !empty($val['foreign_key'])?$val['foreign_key']:strtolower($model->getModelName()).'_id'; // 关联外键
}
$fk = $result[$mappingFk];
$mappingCondition .= " AND {$model->getPk()}='{$fk}'";
$relationData = $model->where($mappingCondition)->field($mappingFields)->find();
if (!empty($val['relation_deep'])){
$model->getRelation($relationData,$val['relation_deep']);
}
break;
case self::HAS_MANY:
$pk = $result[$mappingKey];
$mappingCondition .= " AND {$mappingFk}='{$pk}'";
$mappingOrder = !empty($val['mapping_order'])?$val['mapping_order']:'';
$mappingLimit = !empty($val['mapping_limit'])?$val['mapping_limit']:'';
// 延时获取关联记录
$relationData = $model->where($mappingCondition)->field($mappingFields)->order($mappingOrder)->limit($mappingLimit)->select();
if (!empty($val['relation_deep'])){
foreach($relationData as $key=>$data){
$model->getRelation($data,$val['relation_deep']);
$relationData[$key] = $data;
}
}
break;
case self::MANY_TO_MANY:
$pk = $result[$mappingKey];
$prefix = $this->tablePrefix;
$mappingCondition = " {$mappingFk}='{$pk}'";
$mappingOrder = $val['mapping_order'];
$mappingLimit = $val['mapping_limit'];
$mappingRelationFk = $val['relation_foreign_key']?$val['relation_foreign_key']:$model->getModelName().'_id';
if(isset($val['relation_table'])){
$mappingRelationTable = preg_replace_callback("/__([A-Z_-]+)__/sU", function($match) use($prefix){ return $prefix.strtolower($match[1]);}, $val['relation_table']);
}else{
$mappingRelationTable = $this->getRelationTableName($model);
}
$sql = "SELECT b.{$mappingFields} FROM {$mappingRelationTable} AS a, ".$model->getTableName()." AS b WHERE a.{$mappingRelationFk} = b.{$model->getPk()} AND a.{$mappingCondition}";
if(!empty($val['condition'])) {
$sql .= ' AND '.$val['condition'];
}
if(!empty($mappingOrder)) {
$sql .= ' ORDER BY '.$mappingOrder;
}
if(!empty($mappingLimit)) {
$sql .= ' LIMIT '.$mappingLimit;
}
$relationData = $this->query($sql);
if (!empty($val['relation_deep'])){
foreach($relationData as $key=>$data){
$model->getRelation($data,$val['relation_deep']);
$relationData[$key] = $data;
}
}
break;
}
if(!$return){
if(isset($val['as_fields']) && in_array($mappingType,array(self::HAS_ONE,self::BELONGS_TO)) ) {
// 支持直接把关联的字段值映射成数据对象中的某个字段
// 仅仅支持HAS_ONE BELONGS_TO
$fields = explode(',',$val['as_fields']);
foreach ($fields as $field){
if(strpos($field,':')) {
list($relationName,$nick) = explode(':',$field);
$result[$nick] = $relationData[$relationName];
}else{
$result[$field] = $relationData[$field];
}
}
}else{
$result[$mappingName] = $relationData;
}
unset($relationData);
}else{
return $relationData;
}
}
}
}
return $result;
} | php | protected function getRelation(&$result,$name='',$return=false) {
if(!empty($this->_link)) {
foreach($this->_link as $key=>$val) {
$mappingName = !empty($val['mapping_name'])?$val['mapping_name']:$key; // 映射名称
if(empty($name) || true === $name || $mappingName == $name || (is_array($name) && in_array($mappingName,$name))) {
$mappingType = !empty($val['mapping_type'])?$val['mapping_type']:$val; // 关联类型
$mappingClass = !empty($val['class_name'])?$val['class_name']:$key; // 关联类名
$mappingFields = !empty($val['mapping_fields'])?$val['mapping_fields']:'*'; // 映射字段
$mappingCondition = !empty($val['condition'])?$val['condition']:'1=1'; // 关联条件
$mappingKey =!empty($val['mapping_key'])? $val['mapping_key'] : $this->getPk(); // 关联键名
if(strtoupper($mappingClass)==strtoupper($this->name)) {
// 自引用关联 获取父键名
$mappingFk = !empty($val['parent_key'])? $val['parent_key'] : 'parent_id';
}else{
$mappingFk = !empty($val['foreign_key'])?$val['foreign_key']:strtolower($this->name).'_id'; // 关联外键
}
// 获取关联模型对象
$model = D($mappingClass);
switch($mappingType) {
case self::HAS_ONE:
$pk = $result[$mappingKey];
$mappingCondition .= " AND {$mappingFk}='{$pk}'";
$relationData = $model->where($mappingCondition)->field($mappingFields)->find();
if (!empty($val['relation_deep'])){
$model->getRelation($relationData,$val['relation_deep']);
}
break;
case self::BELONGS_TO:
if(strtoupper($mappingClass)==strtoupper($this->name)) {
// 自引用关联 获取父键名
$mappingFk = !empty($val['parent_key'])? $val['parent_key'] : 'parent_id';
}else{
$mappingFk = !empty($val['foreign_key'])?$val['foreign_key']:strtolower($model->getModelName()).'_id'; // 关联外键
}
$fk = $result[$mappingFk];
$mappingCondition .= " AND {$model->getPk()}='{$fk}'";
$relationData = $model->where($mappingCondition)->field($mappingFields)->find();
if (!empty($val['relation_deep'])){
$model->getRelation($relationData,$val['relation_deep']);
}
break;
case self::HAS_MANY:
$pk = $result[$mappingKey];
$mappingCondition .= " AND {$mappingFk}='{$pk}'";
$mappingOrder = !empty($val['mapping_order'])?$val['mapping_order']:'';
$mappingLimit = !empty($val['mapping_limit'])?$val['mapping_limit']:'';
// 延时获取关联记录
$relationData = $model->where($mappingCondition)->field($mappingFields)->order($mappingOrder)->limit($mappingLimit)->select();
if (!empty($val['relation_deep'])){
foreach($relationData as $key=>$data){
$model->getRelation($data,$val['relation_deep']);
$relationData[$key] = $data;
}
}
break;
case self::MANY_TO_MANY:
$pk = $result[$mappingKey];
$prefix = $this->tablePrefix;
$mappingCondition = " {$mappingFk}='{$pk}'";
$mappingOrder = $val['mapping_order'];
$mappingLimit = $val['mapping_limit'];
$mappingRelationFk = $val['relation_foreign_key']?$val['relation_foreign_key']:$model->getModelName().'_id';
if(isset($val['relation_table'])){
$mappingRelationTable = preg_replace_callback("/__([A-Z_-]+)__/sU", function($match) use($prefix){ return $prefix.strtolower($match[1]);}, $val['relation_table']);
}else{
$mappingRelationTable = $this->getRelationTableName($model);
}
$sql = "SELECT b.{$mappingFields} FROM {$mappingRelationTable} AS a, ".$model->getTableName()." AS b WHERE a.{$mappingRelationFk} = b.{$model->getPk()} AND a.{$mappingCondition}";
if(!empty($val['condition'])) {
$sql .= ' AND '.$val['condition'];
}
if(!empty($mappingOrder)) {
$sql .= ' ORDER BY '.$mappingOrder;
}
if(!empty($mappingLimit)) {
$sql .= ' LIMIT '.$mappingLimit;
}
$relationData = $this->query($sql);
if (!empty($val['relation_deep'])){
foreach($relationData as $key=>$data){
$model->getRelation($data,$val['relation_deep']);
$relationData[$key] = $data;
}
}
break;
}
if(!$return){
if(isset($val['as_fields']) && in_array($mappingType,array(self::HAS_ONE,self::BELONGS_TO)) ) {
// 支持直接把关联的字段值映射成数据对象中的某个字段
// 仅仅支持HAS_ONE BELONGS_TO
$fields = explode(',',$val['as_fields']);
foreach ($fields as $field){
if(strpos($field,':')) {
list($relationName,$nick) = explode(':',$field);
$result[$nick] = $relationData[$relationName];
}else{
$result[$field] = $relationData[$field];
}
}
}else{
$result[$mappingName] = $relationData;
}
unset($relationData);
}else{
return $relationData;
}
}
}
}
return $result;
} | [
"protected",
"function",
"getRelation",
"(",
"&",
"$",
"result",
",",
"$",
"name",
"=",
"''",
",",
"$",
"return",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"_link",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_link",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"$",
"mappingName",
"=",
"!",
"empty",
"(",
"$",
"val",
"[",
"'mapping_name'",
"]",
")",
"?",
"$",
"val",
"[",
"'mapping_name'",
"]",
":",
"$",
"key",
";",
"// 映射名称",
"if",
"(",
"empty",
"(",
"$",
"name",
")",
"||",
"true",
"===",
"$",
"name",
"||",
"$",
"mappingName",
"==",
"$",
"name",
"||",
"(",
"is_array",
"(",
"$",
"name",
")",
"&&",
"in_array",
"(",
"$",
"mappingName",
",",
"$",
"name",
")",
")",
")",
"{",
"$",
"mappingType",
"=",
"!",
"empty",
"(",
"$",
"val",
"[",
"'mapping_type'",
"]",
")",
"?",
"$",
"val",
"[",
"'mapping_type'",
"]",
":",
"$",
"val",
";",
"// 关联类型",
"$",
"mappingClass",
"=",
"!",
"empty",
"(",
"$",
"val",
"[",
"'class_name'",
"]",
")",
"?",
"$",
"val",
"[",
"'class_name'",
"]",
":",
"$",
"key",
";",
"// 关联类名",
"$",
"mappingFields",
"=",
"!",
"empty",
"(",
"$",
"val",
"[",
"'mapping_fields'",
"]",
")",
"?",
"$",
"val",
"[",
"'mapping_fields'",
"]",
":",
"'*'",
";",
"// 映射字段",
"$",
"mappingCondition",
"=",
"!",
"empty",
"(",
"$",
"val",
"[",
"'condition'",
"]",
")",
"?",
"$",
"val",
"[",
"'condition'",
"]",
":",
"'1=1'",
";",
"// 关联条件",
"$",
"mappingKey",
"=",
"!",
"empty",
"(",
"$",
"val",
"[",
"'mapping_key'",
"]",
")",
"?",
"$",
"val",
"[",
"'mapping_key'",
"]",
":",
"$",
"this",
"->",
"getPk",
"(",
")",
";",
"// 关联键名",
"if",
"(",
"strtoupper",
"(",
"$",
"mappingClass",
")",
"==",
"strtoupper",
"(",
"$",
"this",
"->",
"name",
")",
")",
"{",
"// 自引用关联 获取父键名",
"$",
"mappingFk",
"=",
"!",
"empty",
"(",
"$",
"val",
"[",
"'parent_key'",
"]",
")",
"?",
"$",
"val",
"[",
"'parent_key'",
"]",
":",
"'parent_id'",
";",
"}",
"else",
"{",
"$",
"mappingFk",
"=",
"!",
"empty",
"(",
"$",
"val",
"[",
"'foreign_key'",
"]",
")",
"?",
"$",
"val",
"[",
"'foreign_key'",
"]",
":",
"strtolower",
"(",
"$",
"this",
"->",
"name",
")",
".",
"'_id'",
";",
"// 关联外键",
"}",
"// 获取关联模型对象",
"$",
"model",
"=",
"D",
"(",
"$",
"mappingClass",
")",
";",
"switch",
"(",
"$",
"mappingType",
")",
"{",
"case",
"self",
"::",
"HAS_ONE",
":",
"$",
"pk",
"=",
"$",
"result",
"[",
"$",
"mappingKey",
"]",
";",
"$",
"mappingCondition",
".=",
"\" AND {$mappingFk}='{$pk}'\"",
";",
"$",
"relationData",
"=",
"$",
"model",
"->",
"where",
"(",
"$",
"mappingCondition",
")",
"->",
"field",
"(",
"$",
"mappingFields",
")",
"->",
"find",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"val",
"[",
"'relation_deep'",
"]",
")",
")",
"{",
"$",
"model",
"->",
"getRelation",
"(",
"$",
"relationData",
",",
"$",
"val",
"[",
"'relation_deep'",
"]",
")",
";",
"}",
"break",
";",
"case",
"self",
"::",
"BELONGS_TO",
":",
"if",
"(",
"strtoupper",
"(",
"$",
"mappingClass",
")",
"==",
"strtoupper",
"(",
"$",
"this",
"->",
"name",
")",
")",
"{",
"// 自引用关联 获取父键名",
"$",
"mappingFk",
"=",
"!",
"empty",
"(",
"$",
"val",
"[",
"'parent_key'",
"]",
")",
"?",
"$",
"val",
"[",
"'parent_key'",
"]",
":",
"'parent_id'",
";",
"}",
"else",
"{",
"$",
"mappingFk",
"=",
"!",
"empty",
"(",
"$",
"val",
"[",
"'foreign_key'",
"]",
")",
"?",
"$",
"val",
"[",
"'foreign_key'",
"]",
":",
"strtolower",
"(",
"$",
"model",
"->",
"getModelName",
"(",
")",
")",
".",
"'_id'",
";",
"// 关联外键",
"}",
"$",
"fk",
"=",
"$",
"result",
"[",
"$",
"mappingFk",
"]",
";",
"$",
"mappingCondition",
".=",
"\" AND {$model->getPk()}='{$fk}'\"",
";",
"$",
"relationData",
"=",
"$",
"model",
"->",
"where",
"(",
"$",
"mappingCondition",
")",
"->",
"field",
"(",
"$",
"mappingFields",
")",
"->",
"find",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"val",
"[",
"'relation_deep'",
"]",
")",
")",
"{",
"$",
"model",
"->",
"getRelation",
"(",
"$",
"relationData",
",",
"$",
"val",
"[",
"'relation_deep'",
"]",
")",
";",
"}",
"break",
";",
"case",
"self",
"::",
"HAS_MANY",
":",
"$",
"pk",
"=",
"$",
"result",
"[",
"$",
"mappingKey",
"]",
";",
"$",
"mappingCondition",
".=",
"\" AND {$mappingFk}='{$pk}'\"",
";",
"$",
"mappingOrder",
"=",
"!",
"empty",
"(",
"$",
"val",
"[",
"'mapping_order'",
"]",
")",
"?",
"$",
"val",
"[",
"'mapping_order'",
"]",
":",
"''",
";",
"$",
"mappingLimit",
"=",
"!",
"empty",
"(",
"$",
"val",
"[",
"'mapping_limit'",
"]",
")",
"?",
"$",
"val",
"[",
"'mapping_limit'",
"]",
":",
"''",
";",
"// 延时获取关联记录",
"$",
"relationData",
"=",
"$",
"model",
"->",
"where",
"(",
"$",
"mappingCondition",
")",
"->",
"field",
"(",
"$",
"mappingFields",
")",
"->",
"order",
"(",
"$",
"mappingOrder",
")",
"->",
"limit",
"(",
"$",
"mappingLimit",
")",
"->",
"select",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"val",
"[",
"'relation_deep'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"relationData",
"as",
"$",
"key",
"=>",
"$",
"data",
")",
"{",
"$",
"model",
"->",
"getRelation",
"(",
"$",
"data",
",",
"$",
"val",
"[",
"'relation_deep'",
"]",
")",
";",
"$",
"relationData",
"[",
"$",
"key",
"]",
"=",
"$",
"data",
";",
"}",
"}",
"break",
";",
"case",
"self",
"::",
"MANY_TO_MANY",
":",
"$",
"pk",
"=",
"$",
"result",
"[",
"$",
"mappingKey",
"]",
";",
"$",
"prefix",
"=",
"$",
"this",
"->",
"tablePrefix",
";",
"$",
"mappingCondition",
"=",
"\" {$mappingFk}='{$pk}'\"",
";",
"$",
"mappingOrder",
"=",
"$",
"val",
"[",
"'mapping_order'",
"]",
";",
"$",
"mappingLimit",
"=",
"$",
"val",
"[",
"'mapping_limit'",
"]",
";",
"$",
"mappingRelationFk",
"=",
"$",
"val",
"[",
"'relation_foreign_key'",
"]",
"?",
"$",
"val",
"[",
"'relation_foreign_key'",
"]",
":",
"$",
"model",
"->",
"getModelName",
"(",
")",
".",
"'_id'",
";",
"if",
"(",
"isset",
"(",
"$",
"val",
"[",
"'relation_table'",
"]",
")",
")",
"{",
"$",
"mappingRelationTable",
"=",
"preg_replace_callback",
"(",
"\"/__([A-Z_-]+)__/sU\"",
",",
"function",
"(",
"$",
"match",
")",
"use",
"(",
"$",
"prefix",
")",
"{",
"return",
"$",
"prefix",
".",
"strtolower",
"(",
"$",
"match",
"[",
"1",
"]",
")",
";",
"}",
",",
"$",
"val",
"[",
"'relation_table'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"mappingRelationTable",
"=",
"$",
"this",
"->",
"getRelationTableName",
"(",
"$",
"model",
")",
";",
"}",
"$",
"sql",
"=",
"\"SELECT b.{$mappingFields} FROM {$mappingRelationTable} AS a, \"",
".",
"$",
"model",
"->",
"getTableName",
"(",
")",
".",
"\" AS b WHERE a.{$mappingRelationFk} = b.{$model->getPk()} AND a.{$mappingCondition}\"",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"val",
"[",
"'condition'",
"]",
")",
")",
"{",
"$",
"sql",
".=",
"' AND '",
".",
"$",
"val",
"[",
"'condition'",
"]",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"mappingOrder",
")",
")",
"{",
"$",
"sql",
".=",
"' ORDER BY '",
".",
"$",
"mappingOrder",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"mappingLimit",
")",
")",
"{",
"$",
"sql",
".=",
"' LIMIT '",
".",
"$",
"mappingLimit",
";",
"}",
"$",
"relationData",
"=",
"$",
"this",
"->",
"query",
"(",
"$",
"sql",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"val",
"[",
"'relation_deep'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"relationData",
"as",
"$",
"key",
"=>",
"$",
"data",
")",
"{",
"$",
"model",
"->",
"getRelation",
"(",
"$",
"data",
",",
"$",
"val",
"[",
"'relation_deep'",
"]",
")",
";",
"$",
"relationData",
"[",
"$",
"key",
"]",
"=",
"$",
"data",
";",
"}",
"}",
"break",
";",
"}",
"if",
"(",
"!",
"$",
"return",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"val",
"[",
"'as_fields'",
"]",
")",
"&&",
"in_array",
"(",
"$",
"mappingType",
",",
"array",
"(",
"self",
"::",
"HAS_ONE",
",",
"self",
"::",
"BELONGS_TO",
")",
")",
")",
"{",
"// 支持直接把关联的字段值映射成数据对象中的某个字段",
"// 仅仅支持HAS_ONE BELONGS_TO",
"$",
"fields",
"=",
"explode",
"(",
"','",
",",
"$",
"val",
"[",
"'as_fields'",
"]",
")",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"field",
",",
"':'",
")",
")",
"{",
"list",
"(",
"$",
"relationName",
",",
"$",
"nick",
")",
"=",
"explode",
"(",
"':'",
",",
"$",
"field",
")",
";",
"$",
"result",
"[",
"$",
"nick",
"]",
"=",
"$",
"relationData",
"[",
"$",
"relationName",
"]",
";",
"}",
"else",
"{",
"$",
"result",
"[",
"$",
"field",
"]",
"=",
"$",
"relationData",
"[",
"$",
"field",
"]",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"result",
"[",
"$",
"mappingName",
"]",
"=",
"$",
"relationData",
";",
"}",
"unset",
"(",
"$",
"relationData",
")",
";",
"}",
"else",
"{",
"return",
"$",
"relationData",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | 获取返回数据的关联记录
@access protected
@param mixed $result 返回数据
@param string|array $name 关联名称
@param boolean $return 是否返回关联数据本身
@return array | [
"获取返回数据的关联记录"
] | train | https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Think/Model/RelationModel.php#L127-L237 |
JumpGateio/Core | src/JumpGate/Core/Abstracts/Seeder.php | Seeder.truncate | protected function truncate($table)
{
if ($this->db->connection()->getConfig('driver') === 'mysql') {
$this->db->statement('SET FOREIGN_KEY_CHECKS=0;');
$this->db->table($table)->truncate();
$this->db->statement('SET FOREIGN_KEY_CHECKS=1;');
}
} | php | protected function truncate($table)
{
if ($this->db->connection()->getConfig('driver') === 'mysql') {
$this->db->statement('SET FOREIGN_KEY_CHECKS=0;');
$this->db->table($table)->truncate();
$this->db->statement('SET FOREIGN_KEY_CHECKS=1;');
}
} | [
"protected",
"function",
"truncate",
"(",
"$",
"table",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"db",
"->",
"connection",
"(",
")",
"->",
"getConfig",
"(",
"'driver'",
")",
"===",
"'mysql'",
")",
"{",
"$",
"this",
"->",
"db",
"->",
"statement",
"(",
"'SET FOREIGN_KEY_CHECKS=0;'",
")",
";",
"$",
"this",
"->",
"db",
"->",
"table",
"(",
"$",
"table",
")",
"->",
"truncate",
"(",
")",
";",
"$",
"this",
"->",
"db",
"->",
"statement",
"(",
"'SET FOREIGN_KEY_CHECKS=1;'",
")",
";",
"}",
"}"
] | Truncate the existing table of all records.
@param string $table | [
"Truncate",
"the",
"existing",
"table",
"of",
"all",
"records",
"."
] | train | https://github.com/JumpGateio/Core/blob/485b5cf03b3072267bffbee428b81e48d407d6b6/src/JumpGate/Core/Abstracts/Seeder.php#L22-L29 |
praxigento/mobi_mod_downline | Ui/DataProvider/Grid/Transaction/Query.php | Query.getQueryItems | protected function getQueryItems()
{
/* this is primary query builder, not extender */
$result = parent::getQueryItems();
/* define tables aliases for internal usage (in this method) */
$asAccCred = self::AS_ACC_CREDIT;
$asAccDeb = self::AS_ACC_DEBIT;
$asDwnlCred = self::AS_DWNL_CRED;
$asDwnlDeb = self::AS_DWNL_DEB;
/* LEFT JOIN prxgt_dwnl_customer as debit */
$tbl = $this->resource->getTableName(self::E_DWNL_CUST);
$as = $asDwnlDeb;
$cols = [
self::A_MLM_ID_DEBIT => EDownline::A_MLM_ID
];
$cond = "$as." . EDownline::A_CUSTOMER_REF . '=' . $asAccDeb . '.' . EAccount::A_CUST_ID;
$result->joinLeft([$as => $tbl], $cond, $cols);
/* LEFT JOIN prxgt_dwnl_customer as credit */
$tbl = $this->resource->getTableName(self::E_DWNL_CUST);
$as = $asDwnlCred;
$cols = [
self::A_MLM_ID_CREDIT => EDownline::A_MLM_ID
];
$cond = "$as." . EDownline::A_CUSTOMER_REF . '=' . $asAccCred . '.' . EAccount::A_CUST_ID;
$result->joinLeft([$as => $tbl], $cond, $cols);
/* return result */
return $result;
} | php | protected function getQueryItems()
{
/* this is primary query builder, not extender */
$result = parent::getQueryItems();
/* define tables aliases for internal usage (in this method) */
$asAccCred = self::AS_ACC_CREDIT;
$asAccDeb = self::AS_ACC_DEBIT;
$asDwnlCred = self::AS_DWNL_CRED;
$asDwnlDeb = self::AS_DWNL_DEB;
/* LEFT JOIN prxgt_dwnl_customer as debit */
$tbl = $this->resource->getTableName(self::E_DWNL_CUST);
$as = $asDwnlDeb;
$cols = [
self::A_MLM_ID_DEBIT => EDownline::A_MLM_ID
];
$cond = "$as." . EDownline::A_CUSTOMER_REF . '=' . $asAccDeb . '.' . EAccount::A_CUST_ID;
$result->joinLeft([$as => $tbl], $cond, $cols);
/* LEFT JOIN prxgt_dwnl_customer as credit */
$tbl = $this->resource->getTableName(self::E_DWNL_CUST);
$as = $asDwnlCred;
$cols = [
self::A_MLM_ID_CREDIT => EDownline::A_MLM_ID
];
$cond = "$as." . EDownline::A_CUSTOMER_REF . '=' . $asAccCred . '.' . EAccount::A_CUST_ID;
$result->joinLeft([$as => $tbl], $cond, $cols);
/* return result */
return $result;
} | [
"protected",
"function",
"getQueryItems",
"(",
")",
"{",
"/* this is primary query builder, not extender */",
"$",
"result",
"=",
"parent",
"::",
"getQueryItems",
"(",
")",
";",
"/* define tables aliases for internal usage (in this method) */",
"$",
"asAccCred",
"=",
"self",
"::",
"AS_ACC_CREDIT",
";",
"$",
"asAccDeb",
"=",
"self",
"::",
"AS_ACC_DEBIT",
";",
"$",
"asDwnlCred",
"=",
"self",
"::",
"AS_DWNL_CRED",
";",
"$",
"asDwnlDeb",
"=",
"self",
"::",
"AS_DWNL_DEB",
";",
"/* LEFT JOIN prxgt_dwnl_customer as debit */",
"$",
"tbl",
"=",
"$",
"this",
"->",
"resource",
"->",
"getTableName",
"(",
"self",
"::",
"E_DWNL_CUST",
")",
";",
"$",
"as",
"=",
"$",
"asDwnlDeb",
";",
"$",
"cols",
"=",
"[",
"self",
"::",
"A_MLM_ID_DEBIT",
"=>",
"EDownline",
"::",
"A_MLM_ID",
"]",
";",
"$",
"cond",
"=",
"\"$as.\"",
".",
"EDownline",
"::",
"A_CUSTOMER_REF",
".",
"'='",
".",
"$",
"asAccDeb",
".",
"'.'",
".",
"EAccount",
"::",
"A_CUST_ID",
";",
"$",
"result",
"->",
"joinLeft",
"(",
"[",
"$",
"as",
"=>",
"$",
"tbl",
"]",
",",
"$",
"cond",
",",
"$",
"cols",
")",
";",
"/* LEFT JOIN prxgt_dwnl_customer as credit */",
"$",
"tbl",
"=",
"$",
"this",
"->",
"resource",
"->",
"getTableName",
"(",
"self",
"::",
"E_DWNL_CUST",
")",
";",
"$",
"as",
"=",
"$",
"asDwnlCred",
";",
"$",
"cols",
"=",
"[",
"self",
"::",
"A_MLM_ID_CREDIT",
"=>",
"EDownline",
"::",
"A_MLM_ID",
"]",
";",
"$",
"cond",
"=",
"\"$as.\"",
".",
"EDownline",
"::",
"A_CUSTOMER_REF",
".",
"'='",
".",
"$",
"asAccCred",
".",
"'.'",
".",
"EAccount",
"::",
"A_CUST_ID",
";",
"$",
"result",
"->",
"joinLeft",
"(",
"[",
"$",
"as",
"=>",
"$",
"tbl",
"]",
",",
"$",
"cond",
",",
"$",
"cols",
")",
";",
"/* return result */",
"return",
"$",
"result",
";",
"}"
] | SELECT
...
FROM
`prxgt_acc_transaction` AS `pat`
LEFT JOIN `prxgt_acc_account` AS `paa_db` ON
paa_db.id = pat.debit_acc_id
LEFT JOIN `customer_entity` AS `ce_db` ON
ce_db.entity_id = paa_db.customer_id
LEFT JOIN `prxgt_acc_account` AS `paa_cr` ON
paa_cr.id = pat.credit_acc_id
LEFT JOIN `customer_entity` AS `ce_cr` ON
ce_cr.entity_id = paa_cr.customer_id
LEFT JOIN `prxgt_acc_type_asset` AS `pata` ON
pata.id = paa_db.asset_type_id
LEFT JOIN `prxgt_dwnl_customer` AS `dwnlDebit` ON
dwnlDebit.customer_ref = paa_db.customer_id
LEFT JOIN `prxgt_dwnl_customer` AS `dwnlCredit` ON
dwnlCredit.customer_ref = paa_cr.customer_id | [
"SELECT",
"...",
"FROM",
"prxgt_acc_transaction",
"AS",
"pat",
"LEFT",
"JOIN",
"prxgt_acc_account",
"AS",
"paa_db",
"ON",
"paa_db",
".",
"id",
"=",
"pat",
".",
"debit_acc_id",
"LEFT",
"JOIN",
"customer_entity",
"AS",
"ce_db",
"ON",
"ce_db",
".",
"entity_id",
"=",
"paa_db",
".",
"customer_id",
"LEFT",
"JOIN",
"prxgt_acc_account",
"AS",
"paa_cr",
"ON",
"paa_cr",
".",
"id",
"=",
"pat",
".",
"credit_acc_id",
"LEFT",
"JOIN",
"customer_entity",
"AS",
"ce_cr",
"ON",
"ce_cr",
".",
"entity_id",
"=",
"paa_cr",
".",
"customer_id",
"LEFT",
"JOIN",
"prxgt_acc_type_asset",
"AS",
"pata",
"ON",
"pata",
".",
"id",
"=",
"paa_db",
".",
"asset_type_id",
"LEFT",
"JOIN",
"prxgt_dwnl_customer",
"AS",
"dwnlDebit",
"ON",
"dwnlDebit",
".",
"customer_ref",
"=",
"paa_db",
".",
"customer_id",
"LEFT",
"JOIN",
"prxgt_dwnl_customer",
"AS",
"dwnlCredit",
"ON",
"dwnlCredit",
".",
"customer_ref",
"=",
"paa_cr",
".",
"customer_id"
] | train | https://github.com/praxigento/mobi_mod_downline/blob/0f3c276dfff1aa029f9fd205ccfc56f207a2e75b/Ui/DataProvider/Grid/Transaction/Query.php#L66-L97 |
vperyod/vperyod.session-handler | src/SessionHandler.php | SessionHandler.newSession | protected function newSession(Request $request)
{
$factory = $this->sessionFactory;
$cookie = $request->getCookieParams();
return $factory->newInstance($cookie);
} | php | protected function newSession(Request $request)
{
$factory = $this->sessionFactory;
$cookie = $request->getCookieParams();
return $factory->newInstance($cookie);
} | [
"protected",
"function",
"newSession",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"factory",
"=",
"$",
"this",
"->",
"sessionFactory",
";",
"$",
"cookie",
"=",
"$",
"request",
"->",
"getCookieParams",
"(",
")",
";",
"return",
"$",
"factory",
"->",
"newInstance",
"(",
"$",
"cookie",
")",
";",
"}"
] | Create new session
@param Request $request PSR7 Request
@return Session\Session
@access protected | [
"Create",
"new",
"session"
] | train | https://github.com/vperyod/vperyod.session-handler/blob/61a607be009296b69bdb328ed3a26940e1b925bb/src/SessionHandler.php#L87-L92 |
bytic/dispatcher | src/Resolver/Pipeline/ActionBuilder.php | ActionBuilder.build | public function build(ProcessorInterface $processor = null): PipelineInterface
{
if ($processor == null) {
$processor = new InterruptibleProcessor(
function (Command $command) {
return !$command->hasReturn();
}
);
}
return parent::build($processor);
} | php | public function build(ProcessorInterface $processor = null): PipelineInterface
{
if ($processor == null) {
$processor = new InterruptibleProcessor(
function (Command $command) {
return !$command->hasReturn();
}
);
}
return parent::build($processor);
} | [
"public",
"function",
"build",
"(",
"ProcessorInterface",
"$",
"processor",
"=",
"null",
")",
":",
"PipelineInterface",
"{",
"if",
"(",
"$",
"processor",
"==",
"null",
")",
"{",
"$",
"processor",
"=",
"new",
"InterruptibleProcessor",
"(",
"function",
"(",
"Command",
"$",
"command",
")",
"{",
"return",
"!",
"$",
"command",
"->",
"hasReturn",
"(",
")",
";",
"}",
")",
";",
"}",
"return",
"parent",
"::",
"build",
"(",
"$",
"processor",
")",
";",
"}"
] | Build a new Pipeline object
@param ProcessorInterface|null $processor
@return PipelineInterface | [
"Build",
"a",
"new",
"Pipeline",
"object"
] | train | https://github.com/bytic/dispatcher/blob/06a00c99d377e44eed94778f72edbc40b8b8281c/src/Resolver/Pipeline/ActionBuilder.php#L40-L50 |
CaliCastle/socialite | src/One/AbstractProvider.php | AbstractProvider.redirect | public function redirect()
{
$this->request->getSession()->set(
'oauth.temp', $temp = $this->server->getTemporaryCredentials()
);
return new RedirectResponse($this->server->getAuthorizationUrl($temp));
} | php | public function redirect()
{
$this->request->getSession()->set(
'oauth.temp', $temp = $this->server->getTemporaryCredentials()
);
return new RedirectResponse($this->server->getAuthorizationUrl($temp));
} | [
"public",
"function",
"redirect",
"(",
")",
"{",
"$",
"this",
"->",
"request",
"->",
"getSession",
"(",
")",
"->",
"set",
"(",
"'oauth.temp'",
",",
"$",
"temp",
"=",
"$",
"this",
"->",
"server",
"->",
"getTemporaryCredentials",
"(",
")",
")",
";",
"return",
"new",
"RedirectResponse",
"(",
"$",
"this",
"->",
"server",
"->",
"getAuthorizationUrl",
"(",
"$",
"temp",
")",
")",
";",
"}"
] | Redirect the user to the authentication page for the provider.
@return \Symfony\Component\HttpFoundation\RedirectResponse | [
"Redirect",
"the",
"user",
"to",
"the",
"authentication",
"page",
"for",
"the",
"provider",
"."
] | train | https://github.com/CaliCastle/socialite/blob/68acdf290c7e3afbc3db08b3a197230a3f6b0370/src/One/AbstractProvider.php#L45-L52 |
CaliCastle/socialite | src/One/AbstractProvider.php | AbstractProvider.getToken | protected function getToken()
{
$temp = $this->request->getSession()->get('oauth.temp');
return $this->server->getTokenCredentials(
$temp, $this->request->get('oauth_token'), $this->request->get('oauth_verifier')
);
} | php | protected function getToken()
{
$temp = $this->request->getSession()->get('oauth.temp');
return $this->server->getTokenCredentials(
$temp, $this->request->get('oauth_token'), $this->request->get('oauth_verifier')
);
} | [
"protected",
"function",
"getToken",
"(",
")",
"{",
"$",
"temp",
"=",
"$",
"this",
"->",
"request",
"->",
"getSession",
"(",
")",
"->",
"get",
"(",
"'oauth.temp'",
")",
";",
"return",
"$",
"this",
"->",
"server",
"->",
"getTokenCredentials",
"(",
"$",
"temp",
",",
"$",
"this",
"->",
"request",
"->",
"get",
"(",
"'oauth_token'",
")",
",",
"$",
"this",
"->",
"request",
"->",
"get",
"(",
"'oauth_verifier'",
")",
")",
";",
"}"
] | Get the token credentials for the request.
@return \League\OAuth1\Client\Credentials\TokenCredentials | [
"Get",
"the",
"token",
"credentials",
"for",
"the",
"request",
"."
] | train | https://github.com/CaliCastle/socialite/blob/68acdf290c7e3afbc3db08b3a197230a3f6b0370/src/One/AbstractProvider.php#L82-L89 |
miaoxing/wechat | src/Plugin.php | Plugin.onWechatScan | public function onWechatScan(WeChatApp $app, User $user)
{
$sceneId = $app->getScanSceneId();
if (!$sceneId) {
return;
}
/** @var WeChatQrcode $qrcode */
$qrcode = wei()->weChatQrcode->findAndCacheBySceneId($sceneId);
if (!$qrcode || !$qrcode->hasReply()) {
return;
}
if ($app->getEvent() === 'subscribe') {
$this->handleSubscribeReply($app, $user, $qrcode);
} else {
$this->handleScanReply($app, $user, $qrcode);
}
} | php | public function onWechatScan(WeChatApp $app, User $user)
{
$sceneId = $app->getScanSceneId();
if (!$sceneId) {
return;
}
/** @var WeChatQrcode $qrcode */
$qrcode = wei()->weChatQrcode->findAndCacheBySceneId($sceneId);
if (!$qrcode || !$qrcode->hasReply()) {
return;
}
if ($app->getEvent() === 'subscribe') {
$this->handleSubscribeReply($app, $user, $qrcode);
} else {
$this->handleScanReply($app, $user, $qrcode);
}
} | [
"public",
"function",
"onWechatScan",
"(",
"WeChatApp",
"$",
"app",
",",
"User",
"$",
"user",
")",
"{",
"$",
"sceneId",
"=",
"$",
"app",
"->",
"getScanSceneId",
"(",
")",
";",
"if",
"(",
"!",
"$",
"sceneId",
")",
"{",
"return",
";",
"}",
"/** @var WeChatQrcode $qrcode */",
"$",
"qrcode",
"=",
"wei",
"(",
")",
"->",
"weChatQrcode",
"->",
"findAndCacheBySceneId",
"(",
"$",
"sceneId",
")",
";",
"if",
"(",
"!",
"$",
"qrcode",
"||",
"!",
"$",
"qrcode",
"->",
"hasReply",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"app",
"->",
"getEvent",
"(",
")",
"===",
"'subscribe'",
")",
"{",
"$",
"this",
"->",
"handleSubscribeReply",
"(",
"$",
"app",
",",
"$",
"user",
",",
"$",
"qrcode",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"handleScanReply",
"(",
"$",
"app",
",",
"$",
"user",
",",
"$",
"qrcode",
")",
";",
"}",
"}"
] | 扫描二维码关注后的操作
@param WeChatApp $app
@param User $user | [
"扫描二维码关注后的操作"
] | train | https://github.com/miaoxing/wechat/blob/8620f7788cd0b6b9d20d436cede1f9f2fd24925f/src/Plugin.php#L124-L142 |
MatiasNAmendola/slimpower-slim | src/Libs/Net.php | Net.getLocalIP | public static function getLocalIP() {
$s = &$_SERVER;
$ipAddress = $s['REMOTE_ADDR'];
if (array_key_exists('HTTP_X_FORWARDED_FOR', $s)) {
$temp = explode(',', $s['HTTP_X_FORWARDED_FOR']);
$ipAddress = array_pop($temp);
}
$result = $ipAddress == '::1' ? "127.0.0.1" : $ipAddress;
return $result;
} | php | public static function getLocalIP() {
$s = &$_SERVER;
$ipAddress = $s['REMOTE_ADDR'];
if (array_key_exists('HTTP_X_FORWARDED_FOR', $s)) {
$temp = explode(',', $s['HTTP_X_FORWARDED_FOR']);
$ipAddress = array_pop($temp);
}
$result = $ipAddress == '::1' ? "127.0.0.1" : $ipAddress;
return $result;
} | [
"public",
"static",
"function",
"getLocalIP",
"(",
")",
"{",
"$",
"s",
"=",
"&",
"$",
"_SERVER",
";",
"$",
"ipAddress",
"=",
"$",
"s",
"[",
"'REMOTE_ADDR'",
"]",
";",
"if",
"(",
"array_key_exists",
"(",
"'HTTP_X_FORWARDED_FOR'",
",",
"$",
"s",
")",
")",
"{",
"$",
"temp",
"=",
"explode",
"(",
"','",
",",
"$",
"s",
"[",
"'HTTP_X_FORWARDED_FOR'",
"]",
")",
";",
"$",
"ipAddress",
"=",
"array_pop",
"(",
"$",
"temp",
")",
";",
"}",
"$",
"result",
"=",
"$",
"ipAddress",
"==",
"'::1'",
"?",
"\"127.0.0.1\"",
":",
"$",
"ipAddress",
";",
"return",
"$",
"result",
";",
"}"
] | Get local IP
@return string | [
"Get",
"local",
"IP"
] | train | https://github.com/MatiasNAmendola/slimpower-slim/blob/c78ebbd4124d75ec82fe19b6dd62504da097fd15/src/Libs/Net.php#L40-L53 |
MatiasNAmendola/slimpower-slim | src/Libs/Net.php | Net.getFullPath | public static function getFullPath() {
$s = &$_SERVER;
$ssl = (!empty($s['HTTPS']) && $s['HTTPS'] == 'on') ? true : false;
$sp = strtolower($s['SERVER_PROTOCOL']);
$protocol = substr($sp, 0, strpos($sp, '/')) . (($ssl) ? 's' : '');
$port = $s['SERVER_PORT'];
$port = ((!$ssl && $port == '80') || ($ssl && $port == '443')) ? '' : ':' . $port;
$host = isset($s['HTTP_X_FORWARDED_HOST']) ? $s['HTTP_X_FORWARDED_HOST'] : (isset($s['HTTP_HOST']) ? $s['HTTP_HOST'] : null);
$host = isset($host) ? $host : $s['SERVER_NAME'] . $port;
$uri = $protocol . '://' . $host . $s['REQUEST_URI'];
$segments = explode('?', $uri, 2);
$url = $segments[0];
return $url;
} | php | public static function getFullPath() {
$s = &$_SERVER;
$ssl = (!empty($s['HTTPS']) && $s['HTTPS'] == 'on') ? true : false;
$sp = strtolower($s['SERVER_PROTOCOL']);
$protocol = substr($sp, 0, strpos($sp, '/')) . (($ssl) ? 's' : '');
$port = $s['SERVER_PORT'];
$port = ((!$ssl && $port == '80') || ($ssl && $port == '443')) ? '' : ':' . $port;
$host = isset($s['HTTP_X_FORWARDED_HOST']) ? $s['HTTP_X_FORWARDED_HOST'] : (isset($s['HTTP_HOST']) ? $s['HTTP_HOST'] : null);
$host = isset($host) ? $host : $s['SERVER_NAME'] . $port;
$uri = $protocol . '://' . $host . $s['REQUEST_URI'];
$segments = explode('?', $uri, 2);
$url = $segments[0];
return $url;
} | [
"public",
"static",
"function",
"getFullPath",
"(",
")",
"{",
"$",
"s",
"=",
"&",
"$",
"_SERVER",
";",
"$",
"ssl",
"=",
"(",
"!",
"empty",
"(",
"$",
"s",
"[",
"'HTTPS'",
"]",
")",
"&&",
"$",
"s",
"[",
"'HTTPS'",
"]",
"==",
"'on'",
")",
"?",
"true",
":",
"false",
";",
"$",
"sp",
"=",
"strtolower",
"(",
"$",
"s",
"[",
"'SERVER_PROTOCOL'",
"]",
")",
";",
"$",
"protocol",
"=",
"substr",
"(",
"$",
"sp",
",",
"0",
",",
"strpos",
"(",
"$",
"sp",
",",
"'/'",
")",
")",
".",
"(",
"(",
"$",
"ssl",
")",
"?",
"'s'",
":",
"''",
")",
";",
"$",
"port",
"=",
"$",
"s",
"[",
"'SERVER_PORT'",
"]",
";",
"$",
"port",
"=",
"(",
"(",
"!",
"$",
"ssl",
"&&",
"$",
"port",
"==",
"'80'",
")",
"||",
"(",
"$",
"ssl",
"&&",
"$",
"port",
"==",
"'443'",
")",
")",
"?",
"''",
":",
"':'",
".",
"$",
"port",
";",
"$",
"host",
"=",
"isset",
"(",
"$",
"s",
"[",
"'HTTP_X_FORWARDED_HOST'",
"]",
")",
"?",
"$",
"s",
"[",
"'HTTP_X_FORWARDED_HOST'",
"]",
":",
"(",
"isset",
"(",
"$",
"s",
"[",
"'HTTP_HOST'",
"]",
")",
"?",
"$",
"s",
"[",
"'HTTP_HOST'",
"]",
":",
"null",
")",
";",
"$",
"host",
"=",
"isset",
"(",
"$",
"host",
")",
"?",
"$",
"host",
":",
"$",
"s",
"[",
"'SERVER_NAME'",
"]",
".",
"$",
"port",
";",
"$",
"uri",
"=",
"$",
"protocol",
".",
"'://'",
".",
"$",
"host",
".",
"$",
"s",
"[",
"'REQUEST_URI'",
"]",
";",
"$",
"segments",
"=",
"explode",
"(",
"'?'",
",",
"$",
"uri",
",",
"2",
")",
";",
"$",
"url",
"=",
"$",
"segments",
"[",
"0",
"]",
";",
"return",
"$",
"url",
";",
"}"
] | Get full path
@return string URL | [
"Get",
"full",
"path"
] | train | https://github.com/MatiasNAmendola/slimpower-slim/blob/c78ebbd4124d75ec82fe19b6dd62504da097fd15/src/Libs/Net.php#L75-L88 |
MatiasNAmendola/slimpower-slim | src/Libs/Net.php | Net.isSecure | public static function isSecure() {
$s = &$_SERVER;
$ssl = (!empty($s['HTTPS']) && $s['HTTPS'] == 'on') ? true : false;
return $ssl;
} | php | public static function isSecure() {
$s = &$_SERVER;
$ssl = (!empty($s['HTTPS']) && $s['HTTPS'] == 'on') ? true : false;
return $ssl;
} | [
"public",
"static",
"function",
"isSecure",
"(",
")",
"{",
"$",
"s",
"=",
"&",
"$",
"_SERVER",
";",
"$",
"ssl",
"=",
"(",
"!",
"empty",
"(",
"$",
"s",
"[",
"'HTTPS'",
"]",
")",
"&&",
"$",
"s",
"[",
"'HTTPS'",
"]",
"==",
"'on'",
")",
"?",
"true",
":",
"false",
";",
"return",
"$",
"ssl",
";",
"}"
] | Evaluate the Safety Scope of Application.
@return boolean | [
"Evaluate",
"the",
"Safety",
"Scope",
"of",
"Application",
"."
] | train | https://github.com/MatiasNAmendola/slimpower-slim/blob/c78ebbd4124d75ec82fe19b6dd62504da097fd15/src/Libs/Net.php#L94-L98 |
Subsets and Splits