repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_code_tokens
listlengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
listlengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
yuncms/framework
|
src/helpers/StringHelper.php
|
StringHelper.UUID
|
public static function UUID(): string
{
// $data = Yii::$app->security->generateRandomKey(16);
// assert(strlen($data) == 16);
// $data[6] = chr(ord($data[6]) & 0x0f | 0x40); // set version to 0100
// $data[8] = chr(ord($data[8]) & 0x3f | 0x80); // set bits 6-7 to 10
// return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
// 32 bits for "time_low"
random_int(0, 0xffff), random_int(0, 0xffff),
// 16 bits for "time_mid"
random_int(0, 0xffff),
// 16 bits for "time_hi_and_version", four most significant bits holds version number 4
random_int(0, 0x0fff) | 0x4000,
// 16 bits, 8 bits for "clk_seq_hi_res", 8 bits for "clk_seq_low", two most significant bits holds zero and
// one for variant DCE1.1
random_int(0, 0x3fff) | 0x8000,
// 48 bits for "node"
random_int(0, 0xffff), random_int(0, 0xffff), random_int(0, 0xffff)
);
}
|
php
|
public static function UUID(): string
{
// $data = Yii::$app->security->generateRandomKey(16);
// assert(strlen($data) == 16);
// $data[6] = chr(ord($data[6]) & 0x0f | 0x40); // set version to 0100
// $data[8] = chr(ord($data[8]) & 0x3f | 0x80); // set bits 6-7 to 10
// return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
// 32 bits for "time_low"
random_int(0, 0xffff), random_int(0, 0xffff),
// 16 bits for "time_mid"
random_int(0, 0xffff),
// 16 bits for "time_hi_and_version", four most significant bits holds version number 4
random_int(0, 0x0fff) | 0x4000,
// 16 bits, 8 bits for "clk_seq_hi_res", 8 bits for "clk_seq_low", two most significant bits holds zero and
// one for variant DCE1.1
random_int(0, 0x3fff) | 0x8000,
// 48 bits for "node"
random_int(0, 0xffff), random_int(0, 0xffff), random_int(0, 0xffff)
);
}
|
[
"public",
"static",
"function",
"UUID",
"(",
")",
":",
"string",
"{",
"// $data = Yii::$app->security->generateRandomKey(16);",
"// assert(strlen($data) == 16);",
"// $data[6] = chr(ord($data[6]) & 0x0f | 0x40); // set version to 0100",
"// $data[8] = chr(ord($data[8]) & 0x3f | 0x80); // set bits 6-7 to 10",
"// return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));",
"return",
"sprintf",
"(",
"'%04x%04x-%04x-%04x-%04x-%04x%04x%04x'",
",",
"// 32 bits for \"time_low\"",
"random_int",
"(",
"0",
",",
"0xffff",
")",
",",
"random_int",
"(",
"0",
",",
"0xffff",
")",
",",
"// 16 bits for \"time_mid\"",
"random_int",
"(",
"0",
",",
"0xffff",
")",
",",
"// 16 bits for \"time_hi_and_version\", four most significant bits holds version number 4",
"random_int",
"(",
"0",
",",
"0x0fff",
")",
"|",
"0x4000",
",",
"// 16 bits, 8 bits for \"clk_seq_hi_res\", 8 bits for \"clk_seq_low\", two most significant bits holds zero and",
"// one for variant DCE1.1",
"random_int",
"(",
"0",
",",
"0x3fff",
")",
"|",
"0x8000",
",",
"// 48 bits for \"node\"",
"random_int",
"(",
"0",
",",
"0xffff",
")",
",",
"random_int",
"(",
"0",
",",
"0xffff",
")",
",",
"random_int",
"(",
"0",
",",
"0xffff",
")",
")",
";",
"}"
] |
Generates a valid v4 UUID string. See [http://stackoverflow.com/a/2040279/684]
@return string The UUID.
@throws \Exception
|
[
"Generates",
"a",
"valid",
"v4",
"UUID",
"string",
".",
"See",
"[",
"http",
":",
"//",
"stackoverflow",
".",
"com",
"/",
"a",
"/",
"2040279",
"/",
"684",
"]"
] |
train
|
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/helpers/StringHelper.php#L914-L940
|
yuncms/framework
|
src/helpers/StringHelper.php
|
StringHelper.asciiCharMap
|
public static function asciiCharMap(): array
{
if (self::$_asciiCharMap !== null) {
return self::$_asciiCharMap;
}
// Get the map from Stringy.
self::$_asciiCharMap = (new Stringy(''))->getAsciiCharMap();
return self::$_asciiCharMap;
}
|
php
|
public static function asciiCharMap(): array
{
if (self::$_asciiCharMap !== null) {
return self::$_asciiCharMap;
}
// Get the map from Stringy.
self::$_asciiCharMap = (new Stringy(''))->getAsciiCharMap();
return self::$_asciiCharMap;
}
|
[
"public",
"static",
"function",
"asciiCharMap",
"(",
")",
":",
"array",
"{",
"if",
"(",
"self",
"::",
"$",
"_asciiCharMap",
"!==",
"null",
")",
"{",
"return",
"self",
"::",
"$",
"_asciiCharMap",
";",
"}",
"// Get the map from Stringy.",
"self",
"::",
"$",
"_asciiCharMap",
"=",
"(",
"new",
"Stringy",
"(",
"''",
")",
")",
"->",
"getAsciiCharMap",
"(",
")",
";",
"return",
"self",
"::",
"$",
"_asciiCharMap",
";",
"}"
] |
Returns ASCII character mappings, merging in any custom defined mappings from the 'customAsciiCharMappings'
config setting.
@return array The fully merged ASCII character mappings.
|
[
"Returns",
"ASCII",
"character",
"mappings",
"merging",
"in",
"any",
"custom",
"defined",
"mappings",
"from",
"the",
"customAsciiCharMappings",
"config",
"setting",
"."
] |
train
|
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/helpers/StringHelper.php#L948-L958
|
yuncms/framework
|
src/helpers/StringHelper.php
|
StringHelper.convertToUtf8
|
public static function convertToUtf8(string $string): string
{
// If it's already a UTF8 string, just clean and return it
if (static::isUtf8($string)) {
return HtmlPurifier::cleanUtf8($string);
}
// Otherwise set HTMLPurifier to the actual string encoding
$config = \HTMLPurifier_Config::createDefault();
$config->set('Core.Encoding', static::encoding($string));
// Clean it
$string = HtmlPurifier::cleanUtf8($string);
// Convert it to UTF8 if possible
if (function_exists('iconv') && \HTMLPurifier_Encoder::testIconvTruncateBug() === \HTMLPurifier_Encoder::ICONV_OK) {
$string = HtmlPurifier::convertToUtf8($string, $config);
} else {
$encoding = static::encoding($string);
$string = mb_convert_encoding($string, 'utf-8', $encoding);
}
return $string;
}
|
php
|
public static function convertToUtf8(string $string): string
{
// If it's already a UTF8 string, just clean and return it
if (static::isUtf8($string)) {
return HtmlPurifier::cleanUtf8($string);
}
// Otherwise set HTMLPurifier to the actual string encoding
$config = \HTMLPurifier_Config::createDefault();
$config->set('Core.Encoding', static::encoding($string));
// Clean it
$string = HtmlPurifier::cleanUtf8($string);
// Convert it to UTF8 if possible
if (function_exists('iconv') && \HTMLPurifier_Encoder::testIconvTruncateBug() === \HTMLPurifier_Encoder::ICONV_OK) {
$string = HtmlPurifier::convertToUtf8($string, $config);
} else {
$encoding = static::encoding($string);
$string = mb_convert_encoding($string, 'utf-8', $encoding);
}
return $string;
}
|
[
"public",
"static",
"function",
"convertToUtf8",
"(",
"string",
"$",
"string",
")",
":",
"string",
"{",
"// If it's already a UTF8 string, just clean and return it",
"if",
"(",
"static",
"::",
"isUtf8",
"(",
"$",
"string",
")",
")",
"{",
"return",
"HtmlPurifier",
"::",
"cleanUtf8",
"(",
"$",
"string",
")",
";",
"}",
"// Otherwise set HTMLPurifier to the actual string encoding",
"$",
"config",
"=",
"\\",
"HTMLPurifier_Config",
"::",
"createDefault",
"(",
")",
";",
"$",
"config",
"->",
"set",
"(",
"'Core.Encoding'",
",",
"static",
"::",
"encoding",
"(",
"$",
"string",
")",
")",
";",
"// Clean it",
"$",
"string",
"=",
"HtmlPurifier",
"::",
"cleanUtf8",
"(",
"$",
"string",
")",
";",
"// Convert it to UTF8 if possible",
"if",
"(",
"function_exists",
"(",
"'iconv'",
")",
"&&",
"\\",
"HTMLPurifier_Encoder",
"::",
"testIconvTruncateBug",
"(",
")",
"===",
"\\",
"HTMLPurifier_Encoder",
"::",
"ICONV_OK",
")",
"{",
"$",
"string",
"=",
"HtmlPurifier",
"::",
"convertToUtf8",
"(",
"$",
"string",
",",
"$",
"config",
")",
";",
"}",
"else",
"{",
"$",
"encoding",
"=",
"static",
"::",
"encoding",
"(",
"$",
"string",
")",
";",
"$",
"string",
"=",
"mb_convert_encoding",
"(",
"$",
"string",
",",
"'utf-8'",
",",
"$",
"encoding",
")",
";",
"}",
"return",
"$",
"string",
";",
"}"
] |
Attempts to convert a string to UTF-8 and clean any non-valid UTF-8 characters.
@param string $string
@return string
|
[
"Attempts",
"to",
"convert",
"a",
"string",
"to",
"UTF",
"-",
"8",
"and",
"clean",
"any",
"non",
"-",
"valid",
"UTF",
"-",
"8",
"characters",
"."
] |
train
|
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/helpers/StringHelper.php#L978-L1001
|
yuncms/framework
|
src/helpers/StringHelper.php
|
StringHelper.encodeMb4
|
public static function encodeMb4(string $string): string
{
// Does this string have any 4+ byte Unicode chars?
if (max(array_map('ord', str_split($string))) >= 240) {
$string = preg_replace_callback('/./u', function (array $match) {
if (strlen($match[0]) >= 4) {
// (Logic pulled from WP's wp_encode_emoji() function)
// UTF-32's hex encoding is the same as HTML's hex encoding.
// So, by converting from UTF-8 to UTF-32, we magically
// get the correct hex encoding.
$unpacked = unpack('H*', mb_convert_encoding($match[0], 'UTF-32', 'UTF-8'));
return isset($unpacked[1]) ? '&#x' . ltrim($unpacked[1], '0') . ';' : '';
}
return $match[0];
}, $string);
}
return $string;
}
|
php
|
public static function encodeMb4(string $string): string
{
// Does this string have any 4+ byte Unicode chars?
if (max(array_map('ord', str_split($string))) >= 240) {
$string = preg_replace_callback('/./u', function (array $match) {
if (strlen($match[0]) >= 4) {
// (Logic pulled from WP's wp_encode_emoji() function)
// UTF-32's hex encoding is the same as HTML's hex encoding.
// So, by converting from UTF-8 to UTF-32, we magically
// get the correct hex encoding.
$unpacked = unpack('H*', mb_convert_encoding($match[0], 'UTF-32', 'UTF-8'));
return isset($unpacked[1]) ? '&#x' . ltrim($unpacked[1], '0') . ';' : '';
}
return $match[0];
}, $string);
}
return $string;
}
|
[
"public",
"static",
"function",
"encodeMb4",
"(",
"string",
"$",
"string",
")",
":",
"string",
"{",
"// Does this string have any 4+ byte Unicode chars?",
"if",
"(",
"max",
"(",
"array_map",
"(",
"'ord'",
",",
"str_split",
"(",
"$",
"string",
")",
")",
")",
">=",
"240",
")",
"{",
"$",
"string",
"=",
"preg_replace_callback",
"(",
"'/./u'",
",",
"function",
"(",
"array",
"$",
"match",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"match",
"[",
"0",
"]",
")",
">=",
"4",
")",
"{",
"// (Logic pulled from WP's wp_encode_emoji() function)",
"// UTF-32's hex encoding is the same as HTML's hex encoding.",
"// So, by converting from UTF-8 to UTF-32, we magically",
"// get the correct hex encoding.",
"$",
"unpacked",
"=",
"unpack",
"(",
"'H*'",
",",
"mb_convert_encoding",
"(",
"$",
"match",
"[",
"0",
"]",
",",
"'UTF-32'",
",",
"'UTF-8'",
")",
")",
";",
"return",
"isset",
"(",
"$",
"unpacked",
"[",
"1",
"]",
")",
"?",
"'&#x'",
".",
"ltrim",
"(",
"$",
"unpacked",
"[",
"1",
"]",
",",
"'0'",
")",
".",
"';'",
":",
"''",
";",
"}",
"return",
"$",
"match",
"[",
"0",
"]",
";",
"}",
",",
"$",
"string",
")",
";",
"}",
"return",
"$",
"string",
";",
"}"
] |
HTML-encodes any 4-byte UTF-8 characters.
@param string $string The string
@return string The string with converted 4-byte UTF-8 characters
@see http://stackoverflow.com/a/16496730/1688568
|
[
"HTML",
"-",
"encodes",
"any",
"4",
"-",
"byte",
"UTF",
"-",
"8",
"characters",
"."
] |
train
|
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/helpers/StringHelper.php#L1032-L1052
|
yuncms/framework
|
src/helpers/StringHelper.php
|
StringHelper._prepStringForCasing
|
private static function _prepStringForCasing(string $string, bool $lower = true, bool $removePunctuation = true): array
{
if ($lower) {
// Make it lowercase
$string = static::toLowerCase($string);
}
if ($removePunctuation) {
$string = str_replace(['.', '_', '-'], ' ', $string);
}
// Remove inner-word punctuation.
$string = preg_replace('/[\'"‘’“”\[\]\(\)\{\}:]/u', '', $string);
// Split on the words and return
return static::splitOnWords($string);
}
|
php
|
private static function _prepStringForCasing(string $string, bool $lower = true, bool $removePunctuation = true): array
{
if ($lower) {
// Make it lowercase
$string = static::toLowerCase($string);
}
if ($removePunctuation) {
$string = str_replace(['.', '_', '-'], ' ', $string);
}
// Remove inner-word punctuation.
$string = preg_replace('/[\'"‘’“”\[\]\(\)\{\}:]/u', '', $string);
// Split on the words and return
return static::splitOnWords($string);
}
|
[
"private",
"static",
"function",
"_prepStringForCasing",
"(",
"string",
"$",
"string",
",",
"bool",
"$",
"lower",
"=",
"true",
",",
"bool",
"$",
"removePunctuation",
"=",
"true",
")",
":",
"array",
"{",
"if",
"(",
"$",
"lower",
")",
"{",
"// Make it lowercase",
"$",
"string",
"=",
"static",
"::",
"toLowerCase",
"(",
"$",
"string",
")",
";",
"}",
"if",
"(",
"$",
"removePunctuation",
")",
"{",
"$",
"string",
"=",
"str_replace",
"(",
"[",
"'.'",
",",
"'_'",
",",
"'-'",
"]",
",",
"' '",
",",
"$",
"string",
")",
";",
"}",
"// Remove inner-word punctuation.",
"$",
"string",
"=",
"preg_replace",
"(",
"'/[\\'\"‘’“”\\[\\]\\(\\)\\{\\}:]/u', '', $s",
"t",
"in",
"g",
";",
"",
"",
"",
"// Split on the words and return",
"return",
"static",
"::",
"splitOnWords",
"(",
"$",
"string",
")",
";",
"}"
] |
Prepares a string for casing routines.
@param string $string The string
@param bool $lower
@param bool $removePunctuation Whether punctuation marks should be removed (default is true)
@return string[] The prepped words in the string
@see toKebabCase()
@see toCamelCase()
@see toPascalCase()
@see toSnakeCase()
|
[
"Prepares",
"a",
"string",
"for",
"casing",
"routines",
"."
] |
train
|
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/helpers/StringHelper.php#L1068-L1081
|
askupasoftware/amarkal
|
Extensions/WordPress/Admin/AdminPage.php
|
AdminPage.add_page
|
public function add_page( $config )
{
foreach( $this->required_params() as $param )
{
if( !isset( $config[$param] ) )
{
throw new \RuntimeException( 'Missing required parameter "'.$param.'" for submenu' );
}
}
$this->config['submenu-pages'][] = $config;
}
|
php
|
public function add_page( $config )
{
foreach( $this->required_params() as $param )
{
if( !isset( $config[$param] ) )
{
throw new \RuntimeException( 'Missing required parameter "'.$param.'" for submenu' );
}
}
$this->config['submenu-pages'][] = $config;
}
|
[
"public",
"function",
"add_page",
"(",
"$",
"config",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"required_params",
"(",
")",
"as",
"$",
"param",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"[",
"$",
"param",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Missing required parameter \"'",
".",
"$",
"param",
".",
"'\" for submenu'",
")",
";",
"}",
"}",
"$",
"this",
"->",
"config",
"[",
"'submenu-pages'",
"]",
"[",
"]",
"=",
"$",
"config",
";",
"}"
] |
Add a page to this menu.
If there is only one page set for this menu, no submenu will be created.
If there is more than one page set for this menu, a submenu will
automatically be created with all the pages of this menu.
Possible options are:
title: (Required) Submenu title AND submenu page title tag.
capability: (Required) The capability required for this menu to be displayed to the user.
content: (Required) The function that displays the page content for the menu page.
@param mixed[] $config The page's configuration.
@throws \RuntimeException If one of the required options was not set.
|
[
"Add",
"a",
"page",
"to",
"this",
"menu",
"."
] |
train
|
https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Extensions/WordPress/Admin/AdminPage.php#L64-L74
|
askupasoftware/amarkal
|
Extensions/WordPress/Admin/AdminPage.php
|
AdminPage.set_config
|
private function set_config( $config )
{
if( !isset( $config['title'] ) )
{
throw new \RuntimeException( 'Missing required parameter "title" for menu' );
}
if( !isset( $config['slug'] ) || '' == $config['slug'] )
{
$config['slug'] = \Amarkal\Common\Tools::strtoslug( $config['title'] );
}
$this->config = array_merge( $this->get_defaults(), $config );
}
|
php
|
private function set_config( $config )
{
if( !isset( $config['title'] ) )
{
throw new \RuntimeException( 'Missing required parameter "title" for menu' );
}
if( !isset( $config['slug'] ) || '' == $config['slug'] )
{
$config['slug'] = \Amarkal\Common\Tools::strtoslug( $config['title'] );
}
$this->config = array_merge( $this->get_defaults(), $config );
}
|
[
"private",
"function",
"set_config",
"(",
"$",
"config",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"[",
"'title'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Missing required parameter \"title\" for menu'",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"[",
"'slug'",
"]",
")",
"||",
"''",
"==",
"$",
"config",
"[",
"'slug'",
"]",
")",
"{",
"$",
"config",
"[",
"'slug'",
"]",
"=",
"\\",
"Amarkal",
"\\",
"Common",
"\\",
"Tools",
"::",
"strtoslug",
"(",
"$",
"config",
"[",
"'title'",
"]",
")",
";",
"}",
"$",
"this",
"->",
"config",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"get_defaults",
"(",
")",
",",
"$",
"config",
")",
";",
"}"
] |
Set the configuration for this menu page.
Validates that all the required parameters have been provided.
Auto generates a slug if none was provided.
@param mixed[] $config The configuraion.
@throws \RuntimeException If one of the required options was not provided.
|
[
"Set",
"the",
"configuration",
"for",
"this",
"menu",
"page",
"."
] |
train
|
https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Extensions/WordPress/Admin/AdminPage.php#L124-L136
|
askupasoftware/amarkal
|
Extensions/WordPress/Admin/AdminPage.php
|
AdminPage.add_menu_page
|
public function add_menu_page()
{
extract( $this->config );
$icon .= '' != $class ? '" class="'.$class : '';
$icon .= array() != $style ? '" style="'.$this->array_to_css($style) : '';
$page = $this->config['submenu-pages'][0];
\add_menu_page(
$title,
$title,
$page['capability'],
$slug,
$page['content'],
$icon,
$position
);
if( count($this->config['submenu-pages']) > 1 )
{
$this->add_submenu_pages();
}
}
|
php
|
public function add_menu_page()
{
extract( $this->config );
$icon .= '' != $class ? '" class="'.$class : '';
$icon .= array() != $style ? '" style="'.$this->array_to_css($style) : '';
$page = $this->config['submenu-pages'][0];
\add_menu_page(
$title,
$title,
$page['capability'],
$slug,
$page['content'],
$icon,
$position
);
if( count($this->config['submenu-pages']) > 1 )
{
$this->add_submenu_pages();
}
}
|
[
"public",
"function",
"add_menu_page",
"(",
")",
"{",
"extract",
"(",
"$",
"this",
"->",
"config",
")",
";",
"$",
"icon",
".=",
"''",
"!=",
"$",
"class",
"?",
"'\" class=\"'",
".",
"$",
"class",
":",
"''",
";",
"$",
"icon",
".=",
"array",
"(",
")",
"!=",
"$",
"style",
"?",
"'\" style=\"'",
".",
"$",
"this",
"->",
"array_to_css",
"(",
"$",
"style",
")",
":",
"''",
";",
"$",
"page",
"=",
"$",
"this",
"->",
"config",
"[",
"'submenu-pages'",
"]",
"[",
"0",
"]",
";",
"\\",
"add_menu_page",
"(",
"$",
"title",
",",
"$",
"title",
",",
"$",
"page",
"[",
"'capability'",
"]",
",",
"$",
"slug",
",",
"$",
"page",
"[",
"'content'",
"]",
",",
"$",
"icon",
",",
"$",
"position",
")",
";",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"config",
"[",
"'submenu-pages'",
"]",
")",
">",
"1",
")",
"{",
"$",
"this",
"->",
"add_submenu_pages",
"(",
")",
";",
"}",
"}"
] |
Add this page, and all it's submenus, to the admin sidebar.
Internally used when the admin_menu action is called.
This function is called by AdminPage::register().
|
[
"Add",
"this",
"page",
"and",
"all",
"it",
"s",
"submenus",
"to",
"the",
"admin",
"sidebar",
"."
] |
train
|
https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Extensions/WordPress/Admin/AdminPage.php#L144-L165
|
askupasoftware/amarkal
|
Extensions/WordPress/Admin/AdminPage.php
|
AdminPage.array_to_css
|
private function array_to_css( array $rules )
{
$css = '';
foreach( $rules as $rule => $value )
{
$css .= $rule.':'.$value.';';
}
return $css;
}
|
php
|
private function array_to_css( array $rules )
{
$css = '';
foreach( $rules as $rule => $value )
{
$css .= $rule.':'.$value.';';
}
return $css;
}
|
[
"private",
"function",
"array_to_css",
"(",
"array",
"$",
"rules",
")",
"{",
"$",
"css",
"=",
"''",
";",
"foreach",
"(",
"$",
"rules",
"as",
"$",
"rule",
"=>",
"$",
"value",
")",
"{",
"$",
"css",
".=",
"$",
"rule",
".",
"':'",
".",
"$",
"value",
".",
"';'",
";",
"}",
"return",
"$",
"css",
";",
"}"
] |
Array to CSS.
Converts an array of rule => value into proper CSS formatted rules.
@param string[] $rules The CSS rules.
@return string The CSS formatted string.
|
[
"Array",
"to",
"CSS",
"."
] |
train
|
https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Extensions/WordPress/Admin/AdminPage.php#L199-L207
|
milkyway-multimedia/ss-mwm-formfields
|
src/RecordMapField.php
|
RecordMapField.available_map_fields
|
public static function available_map_fields($class)
{
if (!in_array($class, self::config()->allowed_classes) || !\ClassInfo::exists($class))
return false;
$available = \Config::inst()->get($class, 'public_fields') ? \Config::inst()->get($class, 'public_fields') : array_keys(singleton($class)->summaryFields());
$fields = array_diff($available, self::config()->disable_map_fields);
return count($fields) ? $fields : false;
}
|
php
|
public static function available_map_fields($class)
{
if (!in_array($class, self::config()->allowed_classes) || !\ClassInfo::exists($class))
return false;
$available = \Config::inst()->get($class, 'public_fields') ? \Config::inst()->get($class, 'public_fields') : array_keys(singleton($class)->summaryFields());
$fields = array_diff($available, self::config()->disable_map_fields);
return count($fields) ? $fields : false;
}
|
[
"public",
"static",
"function",
"available_map_fields",
"(",
"$",
"class",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"class",
",",
"self",
"::",
"config",
"(",
")",
"->",
"allowed_classes",
")",
"||",
"!",
"\\",
"ClassInfo",
"::",
"exists",
"(",
"$",
"class",
")",
")",
"return",
"false",
";",
"$",
"available",
"=",
"\\",
"Config",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"$",
"class",
",",
"'public_fields'",
")",
"?",
"\\",
"Config",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"$",
"class",
",",
"'public_fields'",
")",
":",
"array_keys",
"(",
"singleton",
"(",
"$",
"class",
")",
"->",
"summaryFields",
"(",
")",
")",
";",
"$",
"fields",
"=",
"array_diff",
"(",
"$",
"available",
",",
"self",
"::",
"config",
"(",
")",
"->",
"disable_map_fields",
")",
";",
"return",
"count",
"(",
"$",
"fields",
")",
"?",
"$",
"fields",
":",
"false",
";",
"}"
] |
Return an array of fields that can be mapped to a class name
Looks for public_fields set via config, otherwise defaults to summary_fields
@param string $class
@return array|bool
|
[
"Return",
"an",
"array",
"of",
"fields",
"that",
"can",
"be",
"mapped",
"to",
"a",
"class",
"name",
"Looks",
"for",
"public_fields",
"set",
"via",
"config",
"otherwise",
"defaults",
"to",
"summary_fields"
] |
train
|
https://github.com/milkyway-multimedia/ss-mwm-formfields/blob/b98d84d494c92d6881dcea50c9c8334e5f487e1d/src/RecordMapField.php#L66-L76
|
jfusion/org.jfusion.framework
|
src/User/Sync.php
|
Sync.init
|
private static function init() {
ob_start();
set_time_limit(0);
ini_set('memory_limit', '256M');
ini_set('upload_max_filesize', '128M');
ini_set('post_max_size', '256M');
ini_set('max_input_time', '7200');
ini_set('max_execution_time', '0');
ini_set('expect.timeout', '7200');
ini_set('default_socket_timeout', '7200');
ob_end_clean();
}
|
php
|
private static function init() {
ob_start();
set_time_limit(0);
ini_set('memory_limit', '256M');
ini_set('upload_max_filesize', '128M');
ini_set('post_max_size', '256M');
ini_set('max_input_time', '7200');
ini_set('max_execution_time', '0');
ini_set('expect.timeout', '7200');
ini_set('default_socket_timeout', '7200');
ob_end_clean();
}
|
[
"private",
"static",
"function",
"init",
"(",
")",
"{",
"ob_start",
"(",
")",
";",
"set_time_limit",
"(",
"0",
")",
";",
"ini_set",
"(",
"'memory_limit'",
",",
"'256M'",
")",
";",
"ini_set",
"(",
"'upload_max_filesize'",
",",
"'128M'",
")",
";",
"ini_set",
"(",
"'post_max_size'",
",",
"'256M'",
")",
";",
"ini_set",
"(",
"'max_input_time'",
",",
"'7200'",
")",
";",
"ini_set",
"(",
"'max_execution_time'",
",",
"'0'",
")",
";",
"ini_set",
"(",
"'expect.timeout'",
",",
"'7200'",
")",
";",
"ini_set",
"(",
"'default_socket_timeout'",
",",
"'7200'",
")",
";",
"ob_end_clean",
"(",
")",
";",
"}"
] |
function will attempt to alocate more resources to run the sync
|
[
"function",
"will",
"attempt",
"to",
"alocate",
"more",
"resources",
"to",
"run",
"the",
"sync"
] |
train
|
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/User/Sync.php#L42-L54
|
jfusion/org.jfusion.framework
|
src/User/Sync.php
|
Sync.initData
|
public static function initData($syncid, $action)
{
if ($syncid) {
//clear sync in progress catch in case we manually stopped the sync so that the sync will continue
self::changeStatus($syncid, 0);
}
$syncdata = new Registry();
$syncdata->set('completed', false);
$syncdata->set('sync_errors', 0);
$syncdata->set('total_to_sync', 0);
$syncdata->set('synced_users', 0);
$syncdata->set('userbatch', 1);
$syncdata->set('user_offset', 0);
$syncdata->set('syncid', $syncid);
$syncdata->set('action', $action);
return $syncdata;
}
|
php
|
public static function initData($syncid, $action)
{
if ($syncid) {
//clear sync in progress catch in case we manually stopped the sync so that the sync will continue
self::changeStatus($syncid, 0);
}
$syncdata = new Registry();
$syncdata->set('completed', false);
$syncdata->set('sync_errors', 0);
$syncdata->set('total_to_sync', 0);
$syncdata->set('synced_users', 0);
$syncdata->set('userbatch', 1);
$syncdata->set('user_offset', 0);
$syncdata->set('syncid', $syncid);
$syncdata->set('action', $action);
return $syncdata;
}
|
[
"public",
"static",
"function",
"initData",
"(",
"$",
"syncid",
",",
"$",
"action",
")",
"{",
"if",
"(",
"$",
"syncid",
")",
"{",
"//clear sync in progress catch in case we manually stopped the sync so that the sync will continue",
"self",
"::",
"changeStatus",
"(",
"$",
"syncid",
",",
"0",
")",
";",
"}",
"$",
"syncdata",
"=",
"new",
"Registry",
"(",
")",
";",
"$",
"syncdata",
"->",
"set",
"(",
"'completed'",
",",
"false",
")",
";",
"$",
"syncdata",
"->",
"set",
"(",
"'sync_errors'",
",",
"0",
")",
";",
"$",
"syncdata",
"->",
"set",
"(",
"'total_to_sync'",
",",
"0",
")",
";",
"$",
"syncdata",
"->",
"set",
"(",
"'synced_users'",
",",
"0",
")",
";",
"$",
"syncdata",
"->",
"set",
"(",
"'userbatch'",
",",
"1",
")",
";",
"$",
"syncdata",
"->",
"set",
"(",
"'user_offset'",
",",
"0",
")",
";",
"$",
"syncdata",
"->",
"set",
"(",
"'syncid'",
",",
"$",
"syncid",
")",
";",
"$",
"syncdata",
"->",
"set",
"(",
"'action'",
",",
"$",
"action",
")",
";",
"return",
"$",
"syncdata",
";",
"}"
] |
Count log data
@param string $syncid the usersync id
@param string $action
@return Registry
|
[
"Count",
"log",
"data"
] |
train
|
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/User/Sync.php#L64-L83
|
jfusion/org.jfusion.framework
|
src/User/Sync.php
|
Sync.initiate
|
public static function initiate($syncdata, $slaves)
{
$syncid = $syncdata->get('syncid');
$action = $syncdata->get('action');
if (!self::getStatus($syncid)) {
//sync has not started, lets get going :)
$master = Framework::getMaster();
if (!$master) {
throw new RuntimeException(Text::_('SYNC_NOMAMASTER'));
} else if (empty($slaves)) {
throw new RuntimeException(Text::_('SYNC_NODATA'));
} else {
$JFusionMaster = Factory::getAdmin($master->name);
//initialise the slave data array
$slave_data = array();
//lets find out which slaves need to be imported into the Master
foreach ($slaves as $jname => $slave) {
if ($slave == $jname) {
$temp_data = new stdClass();
$temp_data->jname = $jname;
$JFusionPlugin = Factory::getAdmin($jname);
if ($action == 'master') {
$temp_data->total = $JFusionPlugin->getUserCount();
} else {
$temp_data->total = $JFusionMaster->getUserCount();
}
$total_to_sync = $syncdata->get('total_to_sync', 0);
$total_to_sync += $temp_data->total;
$syncdata->set('total_to_sync', $total_to_sync);
//this doesn't change and used by usersync when limiting the number of users to grab at a time
$temp_data->total_to_sync = $temp_data->total;
$temp_data->created = 0;
$temp_data->deleted = 0;
$temp_data->updated = 0;
$temp_data->error = 0;
$temp_data->unchanged = 0;
//save the data
$slave_data[] = $temp_data;
//reset the variables
unset($temp_data, $JFusionPlugin);
}
}
//format the syncdata for storage in the JFusion sync table
$syncdata->set('master', $master->name);
$syncdata->set('slave_data', $slave_data);
//save the submitted syncdata in order for AJAX updates to work
self::saveData($syncdata);
//start the usersync
self::execute($syncdata, $action);
}
}
return $syncdata;
}
|
php
|
public static function initiate($syncdata, $slaves)
{
$syncid = $syncdata->get('syncid');
$action = $syncdata->get('action');
if (!self::getStatus($syncid)) {
//sync has not started, lets get going :)
$master = Framework::getMaster();
if (!$master) {
throw new RuntimeException(Text::_('SYNC_NOMAMASTER'));
} else if (empty($slaves)) {
throw new RuntimeException(Text::_('SYNC_NODATA'));
} else {
$JFusionMaster = Factory::getAdmin($master->name);
//initialise the slave data array
$slave_data = array();
//lets find out which slaves need to be imported into the Master
foreach ($slaves as $jname => $slave) {
if ($slave == $jname) {
$temp_data = new stdClass();
$temp_data->jname = $jname;
$JFusionPlugin = Factory::getAdmin($jname);
if ($action == 'master') {
$temp_data->total = $JFusionPlugin->getUserCount();
} else {
$temp_data->total = $JFusionMaster->getUserCount();
}
$total_to_sync = $syncdata->get('total_to_sync', 0);
$total_to_sync += $temp_data->total;
$syncdata->set('total_to_sync', $total_to_sync);
//this doesn't change and used by usersync when limiting the number of users to grab at a time
$temp_data->total_to_sync = $temp_data->total;
$temp_data->created = 0;
$temp_data->deleted = 0;
$temp_data->updated = 0;
$temp_data->error = 0;
$temp_data->unchanged = 0;
//save the data
$slave_data[] = $temp_data;
//reset the variables
unset($temp_data, $JFusionPlugin);
}
}
//format the syncdata for storage in the JFusion sync table
$syncdata->set('master', $master->name);
$syncdata->set('slave_data', $slave_data);
//save the submitted syncdata in order for AJAX updates to work
self::saveData($syncdata);
//start the usersync
self::execute($syncdata, $action);
}
}
return $syncdata;
}
|
[
"public",
"static",
"function",
"initiate",
"(",
"$",
"syncdata",
",",
"$",
"slaves",
")",
"{",
"$",
"syncid",
"=",
"$",
"syncdata",
"->",
"get",
"(",
"'syncid'",
")",
";",
"$",
"action",
"=",
"$",
"syncdata",
"->",
"get",
"(",
"'action'",
")",
";",
"if",
"(",
"!",
"self",
"::",
"getStatus",
"(",
"$",
"syncid",
")",
")",
"{",
"//sync has not started, lets get going :)",
"$",
"master",
"=",
"Framework",
"::",
"getMaster",
"(",
")",
";",
"if",
"(",
"!",
"$",
"master",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"Text",
"::",
"_",
"(",
"'SYNC_NOMAMASTER'",
")",
")",
";",
"}",
"else",
"if",
"(",
"empty",
"(",
"$",
"slaves",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"Text",
"::",
"_",
"(",
"'SYNC_NODATA'",
")",
")",
";",
"}",
"else",
"{",
"$",
"JFusionMaster",
"=",
"Factory",
"::",
"getAdmin",
"(",
"$",
"master",
"->",
"name",
")",
";",
"//initialise the slave data array",
"$",
"slave_data",
"=",
"array",
"(",
")",
";",
"//lets find out which slaves need to be imported into the Master",
"foreach",
"(",
"$",
"slaves",
"as",
"$",
"jname",
"=>",
"$",
"slave",
")",
"{",
"if",
"(",
"$",
"slave",
"==",
"$",
"jname",
")",
"{",
"$",
"temp_data",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"temp_data",
"->",
"jname",
"=",
"$",
"jname",
";",
"$",
"JFusionPlugin",
"=",
"Factory",
"::",
"getAdmin",
"(",
"$",
"jname",
")",
";",
"if",
"(",
"$",
"action",
"==",
"'master'",
")",
"{",
"$",
"temp_data",
"->",
"total",
"=",
"$",
"JFusionPlugin",
"->",
"getUserCount",
"(",
")",
";",
"}",
"else",
"{",
"$",
"temp_data",
"->",
"total",
"=",
"$",
"JFusionMaster",
"->",
"getUserCount",
"(",
")",
";",
"}",
"$",
"total_to_sync",
"=",
"$",
"syncdata",
"->",
"get",
"(",
"'total_to_sync'",
",",
"0",
")",
";",
"$",
"total_to_sync",
"+=",
"$",
"temp_data",
"->",
"total",
";",
"$",
"syncdata",
"->",
"set",
"(",
"'total_to_sync'",
",",
"$",
"total_to_sync",
")",
";",
"//this doesn't change and used by usersync when limiting the number of users to grab at a time",
"$",
"temp_data",
"->",
"total_to_sync",
"=",
"$",
"temp_data",
"->",
"total",
";",
"$",
"temp_data",
"->",
"created",
"=",
"0",
";",
"$",
"temp_data",
"->",
"deleted",
"=",
"0",
";",
"$",
"temp_data",
"->",
"updated",
"=",
"0",
";",
"$",
"temp_data",
"->",
"error",
"=",
"0",
";",
"$",
"temp_data",
"->",
"unchanged",
"=",
"0",
";",
"//save the data",
"$",
"slave_data",
"[",
"]",
"=",
"$",
"temp_data",
";",
"//reset the variables",
"unset",
"(",
"$",
"temp_data",
",",
"$",
"JFusionPlugin",
")",
";",
"}",
"}",
"//format the syncdata for storage in the JFusion sync table",
"$",
"syncdata",
"->",
"set",
"(",
"'master'",
",",
"$",
"master",
"->",
"name",
")",
";",
"$",
"syncdata",
"->",
"set",
"(",
"'slave_data'",
",",
"$",
"slave_data",
")",
";",
"//save the submitted syncdata in order for AJAX updates to work",
"self",
"::",
"saveData",
"(",
"$",
"syncdata",
")",
";",
"//start the usersync",
"self",
"::",
"execute",
"(",
"$",
"syncdata",
",",
"$",
"action",
")",
";",
"}",
"}",
"return",
"$",
"syncdata",
";",
"}"
] |
@param Registry $syncdata
@param array $slaves
@return Registry
@throws \RuntimeException
|
[
"@param",
"Registry",
"$syncdata",
"@param",
"array",
"$slaves"
] |
train
|
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/User/Sync.php#L92-L148
|
jfusion/org.jfusion.framework
|
src/User/Sync.php
|
Sync.getLogData
|
public static function getLogData($syncid, $type = 'all', $limitstart = null, $limit = null, $sort = 'id', $dir = 'ASC')
{
$db = Factory::getDBO();
$query = $db->getQuery(true)
->select('*')
->from('#__jfusion_sync_details')
->where('syncid = ' . $db->quote($syncid));
if (!empty($sort)) {
$query->order($sort . ' ' . $dir);
}
if ($type != 'all') {
$query->where('action = ' . $db->quote($type));
}
$db->setQuery($query, $limitstart, $limit);
$results = $db->loadObjectList('id');
return $results;
}
|
php
|
public static function getLogData($syncid, $type = 'all', $limitstart = null, $limit = null, $sort = 'id', $dir = 'ASC')
{
$db = Factory::getDBO();
$query = $db->getQuery(true)
->select('*')
->from('#__jfusion_sync_details')
->where('syncid = ' . $db->quote($syncid));
if (!empty($sort)) {
$query->order($sort . ' ' . $dir);
}
if ($type != 'all') {
$query->where('action = ' . $db->quote($type));
}
$db->setQuery($query, $limitstart, $limit);
$results = $db->loadObjectList('id');
return $results;
}
|
[
"public",
"static",
"function",
"getLogData",
"(",
"$",
"syncid",
",",
"$",
"type",
"=",
"'all'",
",",
"$",
"limitstart",
"=",
"null",
",",
"$",
"limit",
"=",
"null",
",",
"$",
"sort",
"=",
"'id'",
",",
"$",
"dir",
"=",
"'ASC'",
")",
"{",
"$",
"db",
"=",
"Factory",
"::",
"getDBO",
"(",
")",
";",
"$",
"query",
"=",
"$",
"db",
"->",
"getQuery",
"(",
"true",
")",
"->",
"select",
"(",
"'*'",
")",
"->",
"from",
"(",
"'#__jfusion_sync_details'",
")",
"->",
"where",
"(",
"'syncid = '",
".",
"$",
"db",
"->",
"quote",
"(",
"$",
"syncid",
")",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"sort",
")",
")",
"{",
"$",
"query",
"->",
"order",
"(",
"$",
"sort",
".",
"' '",
".",
"$",
"dir",
")",
";",
"}",
"if",
"(",
"$",
"type",
"!=",
"'all'",
")",
"{",
"$",
"query",
"->",
"where",
"(",
"'action = '",
".",
"$",
"db",
"->",
"quote",
"(",
"$",
"type",
")",
")",
";",
"}",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
",",
"$",
"limitstart",
",",
"$",
"limit",
")",
";",
"$",
"results",
"=",
"$",
"db",
"->",
"loadObjectList",
"(",
"'id'",
")",
";",
"return",
"$",
"results",
";",
"}"
] |
Retrieve log data
@param string $syncid the usersync id
@param string $type
@param int $limitstart
@param int $limit
@param string $sort
@param string $dir
@return stdClass[] nothing
|
[
"Retrieve",
"log",
"data"
] |
train
|
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/User/Sync.php#L162-L183
|
jfusion/org.jfusion.framework
|
src/User/Sync.php
|
Sync.countLogData
|
public static function countLogData($syncid, $type = 'all')
{
$db = Factory::getDBO();
$query = $db->getQuery(true)
->select('COUNT(*)')
->from('#__jfusion_sync_details')
->where('syncid = ' . $db->quote($syncid));
if ($type != 'all') {
$query->where('action = ' . $db->quote($type));
}
$db->setQuery($query);
return (int)$db->loadResult();
}
|
php
|
public static function countLogData($syncid, $type = 'all')
{
$db = Factory::getDBO();
$query = $db->getQuery(true)
->select('COUNT(*)')
->from('#__jfusion_sync_details')
->where('syncid = ' . $db->quote($syncid));
if ($type != 'all') {
$query->where('action = ' . $db->quote($type));
}
$db->setQuery($query);
return (int)$db->loadResult();
}
|
[
"public",
"static",
"function",
"countLogData",
"(",
"$",
"syncid",
",",
"$",
"type",
"=",
"'all'",
")",
"{",
"$",
"db",
"=",
"Factory",
"::",
"getDBO",
"(",
")",
";",
"$",
"query",
"=",
"$",
"db",
"->",
"getQuery",
"(",
"true",
")",
"->",
"select",
"(",
"'COUNT(*)'",
")",
"->",
"from",
"(",
"'#__jfusion_sync_details'",
")",
"->",
"where",
"(",
"'syncid = '",
".",
"$",
"db",
"->",
"quote",
"(",
"$",
"syncid",
")",
")",
";",
"if",
"(",
"$",
"type",
"!=",
"'all'",
")",
"{",
"$",
"query",
"->",
"where",
"(",
"'action = '",
".",
"$",
"db",
"->",
"quote",
"(",
"$",
"type",
")",
")",
";",
"}",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"return",
"(",
"int",
")",
"$",
"db",
"->",
"loadResult",
"(",
")",
";",
"}"
] |
Count log data
@param string $syncid the usersync id
@param string $type
@return int count results
|
[
"Count",
"log",
"data"
] |
train
|
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/User/Sync.php#L193-L207
|
jfusion/org.jfusion.framework
|
src/User/Sync.php
|
Sync.saveData
|
public static function saveData(Registry $syncdata)
{
$db = Factory::getDBO();
$data = new stdClass;
$data->syncdata = $syncdata->toString();
$data->syncid = $syncdata->get('syncid');
$data->time_start = time();
$data->action = $syncdata->get('action');
$db->insertObject('#__jfusion_sync', $data);
}
|
php
|
public static function saveData(Registry $syncdata)
{
$db = Factory::getDBO();
$data = new stdClass;
$data->syncdata = $syncdata->toString();
$data->syncid = $syncdata->get('syncid');
$data->time_start = time();
$data->action = $syncdata->get('action');
$db->insertObject('#__jfusion_sync', $data);
}
|
[
"public",
"static",
"function",
"saveData",
"(",
"Registry",
"$",
"syncdata",
")",
"{",
"$",
"db",
"=",
"Factory",
"::",
"getDBO",
"(",
")",
";",
"$",
"data",
"=",
"new",
"stdClass",
";",
"$",
"data",
"->",
"syncdata",
"=",
"$",
"syncdata",
"->",
"toString",
"(",
")",
";",
"$",
"data",
"->",
"syncid",
"=",
"$",
"syncdata",
"->",
"get",
"(",
"'syncid'",
")",
";",
"$",
"data",
"->",
"time_start",
"=",
"time",
"(",
")",
";",
"$",
"data",
"->",
"action",
"=",
"$",
"syncdata",
"->",
"get",
"(",
"'action'",
")",
";",
"$",
"db",
"->",
"insertObject",
"(",
"'#__jfusion_sync'",
",",
"$",
"data",
")",
";",
"}"
] |
Save sync data
@param Registry &$syncdata the actual syncdata
@return string nothing
|
[
"Save",
"sync",
"data"
] |
train
|
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/User/Sync.php#L216-L226
|
jfusion/org.jfusion.framework
|
src/User/Sync.php
|
Sync.updateData
|
public static function updateData(Registry $syncdata)
{
//find out if the syncid already exists
$db = Factory::getDBO();
$query = $db->getQuery(true)
->update('#__jfusion_sync')
->set('syncdata = ' . $db->quote($syncdata->toString()))
->where('syncid = ' . $db->quote($syncdata->get('syncid')));
$db->setQuery($query);
$db->execute();
}
|
php
|
public static function updateData(Registry $syncdata)
{
//find out if the syncid already exists
$db = Factory::getDBO();
$query = $db->getQuery(true)
->update('#__jfusion_sync')
->set('syncdata = ' . $db->quote($syncdata->toString()))
->where('syncid = ' . $db->quote($syncdata->get('syncid')));
$db->setQuery($query);
$db->execute();
}
|
[
"public",
"static",
"function",
"updateData",
"(",
"Registry",
"$",
"syncdata",
")",
"{",
"//find out if the syncid already exists",
"$",
"db",
"=",
"Factory",
"::",
"getDBO",
"(",
")",
";",
"$",
"query",
"=",
"$",
"db",
"->",
"getQuery",
"(",
"true",
")",
"->",
"update",
"(",
"'#__jfusion_sync'",
")",
"->",
"set",
"(",
"'syncdata = '",
".",
"$",
"db",
"->",
"quote",
"(",
"$",
"syncdata",
"->",
"toString",
"(",
")",
")",
")",
"->",
"where",
"(",
"'syncid = '",
".",
"$",
"db",
"->",
"quote",
"(",
"$",
"syncdata",
"->",
"get",
"(",
"'syncid'",
")",
")",
")",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"$",
"db",
"->",
"execute",
"(",
")",
";",
"}"
] |
Update syncdata
@param Registry &$syncdata the actual syncdata
|
[
"Update",
"syncdata"
] |
train
|
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/User/Sync.php#L233-L245
|
jfusion/org.jfusion.framework
|
src/User/Sync.php
|
Sync.getData
|
public static function getData($syncid)
{
if ($syncid) {
$db = Factory::getDBO();
$query = $db->getQuery(true)
->select('syncdata')
->from('#__jfusion_sync')
->where('syncid = ' . $db->quote($syncid));
$db->setQuery($query);
$data = $db->loadResult();
if ($data) {
return new Registry($data);
}
}
return null;
}
|
php
|
public static function getData($syncid)
{
if ($syncid) {
$db = Factory::getDBO();
$query = $db->getQuery(true)
->select('syncdata')
->from('#__jfusion_sync')
->where('syncid = ' . $db->quote($syncid));
$db->setQuery($query);
$data = $db->loadResult();
if ($data) {
return new Registry($data);
}
}
return null;
}
|
[
"public",
"static",
"function",
"getData",
"(",
"$",
"syncid",
")",
"{",
"if",
"(",
"$",
"syncid",
")",
"{",
"$",
"db",
"=",
"Factory",
"::",
"getDBO",
"(",
")",
";",
"$",
"query",
"=",
"$",
"db",
"->",
"getQuery",
"(",
"true",
")",
"->",
"select",
"(",
"'syncdata'",
")",
"->",
"from",
"(",
"'#__jfusion_sync'",
")",
"->",
"where",
"(",
"'syncid = '",
".",
"$",
"db",
"->",
"quote",
"(",
"$",
"syncid",
")",
")",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"$",
"data",
"=",
"$",
"db",
"->",
"loadResult",
"(",
")",
";",
"if",
"(",
"$",
"data",
")",
"{",
"return",
"new",
"Registry",
"(",
"$",
"data",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Get syncdata
@param string $syncid the usersync id
@return Registry|null
|
[
"Get",
"syncdata"
] |
train
|
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/User/Sync.php#L254-L271
|
jfusion/org.jfusion.framework
|
src/User/Sync.php
|
Sync.resolveError
|
public static function resolveError($syncid, $syncError, $limitstart, $limit)
{
$synclog = static::getLogData($syncid, 'error', $limitstart, $limit);
foreach ($syncError as $id => $error) {
try {
if (isset($error['action']) && isset($synclog[$id]) && $error['action']) {
$data = json_decode($synclog[$id]->data);
$conflictuserinfo = $data->conflict->userinfo;
$useruserinfo = $data->user->userinfo;
$conflictjname = $data->conflict->jname;
$userjname = $data->user->jname;
if ($conflictuserinfo instanceof Userinfo && $useruserinfo instanceof Userinfo) {
switch ($error['action']) {
case '1':
$userinfo = Factory::getUser($conflictjname)->getUser($conflictuserinfo);
if ($userinfo instanceof Userinfo) {
$userPlugin = Factory::getUser($userjname);
$userPlugin->resetDebugger();
if ($userPlugin->validateUser($userinfo)) {
$userPlugin->updateUser($userinfo, 1);
$status = $userPlugin->debugger->get();
if (!empty($status[LogLevel::ERROR])) {
Framework::raise(LogLevel::ERROR, $status[LogLevel::ERROR], $userjname . ' ' . Text::_('USER') . ' ' . Text::_('UPDATE'));
} else {
Framework::raise(LogLevel::INFO, Text::_('USER') . ' ' . $userinfo->username . ' ' . Text::_('UPDATE'), $userjname);
static::markResolved($id);
$userPlugin->updateLookup($useruserinfo, $userinfo);
}
}
}
break;
case '2':
$userinfo = Factory::getUser($userjname)->getUser($useruserinfo);
if ($userinfo instanceof Userinfo) {
$userPlugin = Factory::getUser($conflictjname);
$userPlugin->resetDebugger();
if ($userPlugin->validateUser($userinfo)) {
$userPlugin->updateUser($userinfo, 1);
$status = $userPlugin->debugger->get();
if (!empty($status[LogLevel::ERROR])) {
Framework::raise(LogLevel::ERROR, $status[LogLevel::ERROR], $conflictjname . ' ' . Text::_('USER') . ' ' . Text::_('UPDATE'));
} else {
Framework::raise(LogLevel::INFO, Text::_('USER') . ' ' . $userinfo->username . ' ' . Text::_('UPDATE'), $conflictjname);
static::markResolved($id);
$userPlugin->updateLookup($userinfo, $useruserinfo);
}
}
}
break;
case '3':
//delete the first entity
//prevent Joomla from deleting all the slaves via the user plugin if it is set as master
Factory::getStatus()->set('active.jfusion', true);
$userPlugin = Factory::getUser($data->user->jname);
$userPlugin->deleteUser($useruserinfo);
$status = $userPlugin->debugger->get();
if (!empty($status[LogLevel::ERROR])) {
Framework::raise(LogLevel::ERROR, $status[LogLevel::ERROR], $data->user->jname . ' ' . Text::_('USER_DELETION_ERROR') . ': ' . $data->user->username);
} else {
static::markResolved($id);
Framework::raise(LogLevel::INFO, Text::_('SUCCESS') . ' ' . Text::_('DELETING') . ' ' . Text::_('USER') . ' ' . $data->user->username, $data->user->jname);
$userPlugin->deleteLookup($useruserinfo);
}
break;
case '4':
//delete the second entity (conflicting plugin)
//prevent Joomla from deleting all the slaves via the user plugin if it is set as master
Factory::getStatus()->set('active.jfusion', true);
$userPlugin = Factory::getUser($data->conflict->jname);
$userPlugin->deleteUser($conflictuserinfo);
$status = $userPlugin->debugger->get();
if (!empty($status[LogLevel::ERROR])) {
Framework::raise(LogLevel::ERROR, $status[LogLevel::ERROR], $data->conflict->jname . ' ' . Text::_('USER_DELETION_ERROR') . ': ' . $data->conflict->username);
} else {
static::markResolved($id);
Framework::raise(LogLevel::INFO, Text::_('SUCCESS') . ' ' . Text::_('DELETING') . ' ' . Text::_('USER') . ' ' . $data->conflict->username, $data->conflict->jname);
$userPlugin->deleteLookup($conflictuserinfo);
}
break;
}
} else {
throw new RuntimeException('Incorrect User Object type');
}
}
} catch (Exception $e) {
Framework::raise(LogLevel::ERROR, $e);
}
}
}
|
php
|
public static function resolveError($syncid, $syncError, $limitstart, $limit)
{
$synclog = static::getLogData($syncid, 'error', $limitstart, $limit);
foreach ($syncError as $id => $error) {
try {
if (isset($error['action']) && isset($synclog[$id]) && $error['action']) {
$data = json_decode($synclog[$id]->data);
$conflictuserinfo = $data->conflict->userinfo;
$useruserinfo = $data->user->userinfo;
$conflictjname = $data->conflict->jname;
$userjname = $data->user->jname;
if ($conflictuserinfo instanceof Userinfo && $useruserinfo instanceof Userinfo) {
switch ($error['action']) {
case '1':
$userinfo = Factory::getUser($conflictjname)->getUser($conflictuserinfo);
if ($userinfo instanceof Userinfo) {
$userPlugin = Factory::getUser($userjname);
$userPlugin->resetDebugger();
if ($userPlugin->validateUser($userinfo)) {
$userPlugin->updateUser($userinfo, 1);
$status = $userPlugin->debugger->get();
if (!empty($status[LogLevel::ERROR])) {
Framework::raise(LogLevel::ERROR, $status[LogLevel::ERROR], $userjname . ' ' . Text::_('USER') . ' ' . Text::_('UPDATE'));
} else {
Framework::raise(LogLevel::INFO, Text::_('USER') . ' ' . $userinfo->username . ' ' . Text::_('UPDATE'), $userjname);
static::markResolved($id);
$userPlugin->updateLookup($useruserinfo, $userinfo);
}
}
}
break;
case '2':
$userinfo = Factory::getUser($userjname)->getUser($useruserinfo);
if ($userinfo instanceof Userinfo) {
$userPlugin = Factory::getUser($conflictjname);
$userPlugin->resetDebugger();
if ($userPlugin->validateUser($userinfo)) {
$userPlugin->updateUser($userinfo, 1);
$status = $userPlugin->debugger->get();
if (!empty($status[LogLevel::ERROR])) {
Framework::raise(LogLevel::ERROR, $status[LogLevel::ERROR], $conflictjname . ' ' . Text::_('USER') . ' ' . Text::_('UPDATE'));
} else {
Framework::raise(LogLevel::INFO, Text::_('USER') . ' ' . $userinfo->username . ' ' . Text::_('UPDATE'), $conflictjname);
static::markResolved($id);
$userPlugin->updateLookup($userinfo, $useruserinfo);
}
}
}
break;
case '3':
//delete the first entity
//prevent Joomla from deleting all the slaves via the user plugin if it is set as master
Factory::getStatus()->set('active.jfusion', true);
$userPlugin = Factory::getUser($data->user->jname);
$userPlugin->deleteUser($useruserinfo);
$status = $userPlugin->debugger->get();
if (!empty($status[LogLevel::ERROR])) {
Framework::raise(LogLevel::ERROR, $status[LogLevel::ERROR], $data->user->jname . ' ' . Text::_('USER_DELETION_ERROR') . ': ' . $data->user->username);
} else {
static::markResolved($id);
Framework::raise(LogLevel::INFO, Text::_('SUCCESS') . ' ' . Text::_('DELETING') . ' ' . Text::_('USER') . ' ' . $data->user->username, $data->user->jname);
$userPlugin->deleteLookup($useruserinfo);
}
break;
case '4':
//delete the second entity (conflicting plugin)
//prevent Joomla from deleting all the slaves via the user plugin if it is set as master
Factory::getStatus()->set('active.jfusion', true);
$userPlugin = Factory::getUser($data->conflict->jname);
$userPlugin->deleteUser($conflictuserinfo);
$status = $userPlugin->debugger->get();
if (!empty($status[LogLevel::ERROR])) {
Framework::raise(LogLevel::ERROR, $status[LogLevel::ERROR], $data->conflict->jname . ' ' . Text::_('USER_DELETION_ERROR') . ': ' . $data->conflict->username);
} else {
static::markResolved($id);
Framework::raise(LogLevel::INFO, Text::_('SUCCESS') . ' ' . Text::_('DELETING') . ' ' . Text::_('USER') . ' ' . $data->conflict->username, $data->conflict->jname);
$userPlugin->deleteLookup($conflictuserinfo);
}
break;
}
} else {
throw new RuntimeException('Incorrect User Object type');
}
}
} catch (Exception $e) {
Framework::raise(LogLevel::ERROR, $e);
}
}
}
|
[
"public",
"static",
"function",
"resolveError",
"(",
"$",
"syncid",
",",
"$",
"syncError",
",",
"$",
"limitstart",
",",
"$",
"limit",
")",
"{",
"$",
"synclog",
"=",
"static",
"::",
"getLogData",
"(",
"$",
"syncid",
",",
"'error'",
",",
"$",
"limitstart",
",",
"$",
"limit",
")",
";",
"foreach",
"(",
"$",
"syncError",
"as",
"$",
"id",
"=>",
"$",
"error",
")",
"{",
"try",
"{",
"if",
"(",
"isset",
"(",
"$",
"error",
"[",
"'action'",
"]",
")",
"&&",
"isset",
"(",
"$",
"synclog",
"[",
"$",
"id",
"]",
")",
"&&",
"$",
"error",
"[",
"'action'",
"]",
")",
"{",
"$",
"data",
"=",
"json_decode",
"(",
"$",
"synclog",
"[",
"$",
"id",
"]",
"->",
"data",
")",
";",
"$",
"conflictuserinfo",
"=",
"$",
"data",
"->",
"conflict",
"->",
"userinfo",
";",
"$",
"useruserinfo",
"=",
"$",
"data",
"->",
"user",
"->",
"userinfo",
";",
"$",
"conflictjname",
"=",
"$",
"data",
"->",
"conflict",
"->",
"jname",
";",
"$",
"userjname",
"=",
"$",
"data",
"->",
"user",
"->",
"jname",
";",
"if",
"(",
"$",
"conflictuserinfo",
"instanceof",
"Userinfo",
"&&",
"$",
"useruserinfo",
"instanceof",
"Userinfo",
")",
"{",
"switch",
"(",
"$",
"error",
"[",
"'action'",
"]",
")",
"{",
"case",
"'1'",
":",
"$",
"userinfo",
"=",
"Factory",
"::",
"getUser",
"(",
"$",
"conflictjname",
")",
"->",
"getUser",
"(",
"$",
"conflictuserinfo",
")",
";",
"if",
"(",
"$",
"userinfo",
"instanceof",
"Userinfo",
")",
"{",
"$",
"userPlugin",
"=",
"Factory",
"::",
"getUser",
"(",
"$",
"userjname",
")",
";",
"$",
"userPlugin",
"->",
"resetDebugger",
"(",
")",
";",
"if",
"(",
"$",
"userPlugin",
"->",
"validateUser",
"(",
"$",
"userinfo",
")",
")",
"{",
"$",
"userPlugin",
"->",
"updateUser",
"(",
"$",
"userinfo",
",",
"1",
")",
";",
"$",
"status",
"=",
"$",
"userPlugin",
"->",
"debugger",
"->",
"get",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"status",
"[",
"LogLevel",
"::",
"ERROR",
"]",
")",
")",
"{",
"Framework",
"::",
"raise",
"(",
"LogLevel",
"::",
"ERROR",
",",
"$",
"status",
"[",
"LogLevel",
"::",
"ERROR",
"]",
",",
"$",
"userjname",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'USER'",
")",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'UPDATE'",
")",
")",
";",
"}",
"else",
"{",
"Framework",
"::",
"raise",
"(",
"LogLevel",
"::",
"INFO",
",",
"Text",
"::",
"_",
"(",
"'USER'",
")",
".",
"' '",
".",
"$",
"userinfo",
"->",
"username",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'UPDATE'",
")",
",",
"$",
"userjname",
")",
";",
"static",
"::",
"markResolved",
"(",
"$",
"id",
")",
";",
"$",
"userPlugin",
"->",
"updateLookup",
"(",
"$",
"useruserinfo",
",",
"$",
"userinfo",
")",
";",
"}",
"}",
"}",
"break",
";",
"case",
"'2'",
":",
"$",
"userinfo",
"=",
"Factory",
"::",
"getUser",
"(",
"$",
"userjname",
")",
"->",
"getUser",
"(",
"$",
"useruserinfo",
")",
";",
"if",
"(",
"$",
"userinfo",
"instanceof",
"Userinfo",
")",
"{",
"$",
"userPlugin",
"=",
"Factory",
"::",
"getUser",
"(",
"$",
"conflictjname",
")",
";",
"$",
"userPlugin",
"->",
"resetDebugger",
"(",
")",
";",
"if",
"(",
"$",
"userPlugin",
"->",
"validateUser",
"(",
"$",
"userinfo",
")",
")",
"{",
"$",
"userPlugin",
"->",
"updateUser",
"(",
"$",
"userinfo",
",",
"1",
")",
";",
"$",
"status",
"=",
"$",
"userPlugin",
"->",
"debugger",
"->",
"get",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"status",
"[",
"LogLevel",
"::",
"ERROR",
"]",
")",
")",
"{",
"Framework",
"::",
"raise",
"(",
"LogLevel",
"::",
"ERROR",
",",
"$",
"status",
"[",
"LogLevel",
"::",
"ERROR",
"]",
",",
"$",
"conflictjname",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'USER'",
")",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'UPDATE'",
")",
")",
";",
"}",
"else",
"{",
"Framework",
"::",
"raise",
"(",
"LogLevel",
"::",
"INFO",
",",
"Text",
"::",
"_",
"(",
"'USER'",
")",
".",
"' '",
".",
"$",
"userinfo",
"->",
"username",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'UPDATE'",
")",
",",
"$",
"conflictjname",
")",
";",
"static",
"::",
"markResolved",
"(",
"$",
"id",
")",
";",
"$",
"userPlugin",
"->",
"updateLookup",
"(",
"$",
"userinfo",
",",
"$",
"useruserinfo",
")",
";",
"}",
"}",
"}",
"break",
";",
"case",
"'3'",
":",
"//delete the first entity",
"//prevent Joomla from deleting all the slaves via the user plugin if it is set as master",
"Factory",
"::",
"getStatus",
"(",
")",
"->",
"set",
"(",
"'active.jfusion'",
",",
"true",
")",
";",
"$",
"userPlugin",
"=",
"Factory",
"::",
"getUser",
"(",
"$",
"data",
"->",
"user",
"->",
"jname",
")",
";",
"$",
"userPlugin",
"->",
"deleteUser",
"(",
"$",
"useruserinfo",
")",
";",
"$",
"status",
"=",
"$",
"userPlugin",
"->",
"debugger",
"->",
"get",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"status",
"[",
"LogLevel",
"::",
"ERROR",
"]",
")",
")",
"{",
"Framework",
"::",
"raise",
"(",
"LogLevel",
"::",
"ERROR",
",",
"$",
"status",
"[",
"LogLevel",
"::",
"ERROR",
"]",
",",
"$",
"data",
"->",
"user",
"->",
"jname",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'USER_DELETION_ERROR'",
")",
".",
"': '",
".",
"$",
"data",
"->",
"user",
"->",
"username",
")",
";",
"}",
"else",
"{",
"static",
"::",
"markResolved",
"(",
"$",
"id",
")",
";",
"Framework",
"::",
"raise",
"(",
"LogLevel",
"::",
"INFO",
",",
"Text",
"::",
"_",
"(",
"'SUCCESS'",
")",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'DELETING'",
")",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'USER'",
")",
".",
"' '",
".",
"$",
"data",
"->",
"user",
"->",
"username",
",",
"$",
"data",
"->",
"user",
"->",
"jname",
")",
";",
"$",
"userPlugin",
"->",
"deleteLookup",
"(",
"$",
"useruserinfo",
")",
";",
"}",
"break",
";",
"case",
"'4'",
":",
"//delete the second entity (conflicting plugin)",
"//prevent Joomla from deleting all the slaves via the user plugin if it is set as master",
"Factory",
"::",
"getStatus",
"(",
")",
"->",
"set",
"(",
"'active.jfusion'",
",",
"true",
")",
";",
"$",
"userPlugin",
"=",
"Factory",
"::",
"getUser",
"(",
"$",
"data",
"->",
"conflict",
"->",
"jname",
")",
";",
"$",
"userPlugin",
"->",
"deleteUser",
"(",
"$",
"conflictuserinfo",
")",
";",
"$",
"status",
"=",
"$",
"userPlugin",
"->",
"debugger",
"->",
"get",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"status",
"[",
"LogLevel",
"::",
"ERROR",
"]",
")",
")",
"{",
"Framework",
"::",
"raise",
"(",
"LogLevel",
"::",
"ERROR",
",",
"$",
"status",
"[",
"LogLevel",
"::",
"ERROR",
"]",
",",
"$",
"data",
"->",
"conflict",
"->",
"jname",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'USER_DELETION_ERROR'",
")",
".",
"': '",
".",
"$",
"data",
"->",
"conflict",
"->",
"username",
")",
";",
"}",
"else",
"{",
"static",
"::",
"markResolved",
"(",
"$",
"id",
")",
";",
"Framework",
"::",
"raise",
"(",
"LogLevel",
"::",
"INFO",
",",
"Text",
"::",
"_",
"(",
"'SUCCESS'",
")",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'DELETING'",
")",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'USER'",
")",
".",
"' '",
".",
"$",
"data",
"->",
"conflict",
"->",
"username",
",",
"$",
"data",
"->",
"conflict",
"->",
"jname",
")",
";",
"$",
"userPlugin",
"->",
"deleteLookup",
"(",
"$",
"conflictuserinfo",
")",
";",
"}",
"break",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'Incorrect User Object type'",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"Framework",
"::",
"raise",
"(",
"LogLevel",
"::",
"ERROR",
",",
"$",
"e",
")",
";",
"}",
"}",
"}"
] |
Fix sync errors
@param string $syncid the usersync id
@param array $syncError the actual syncError data
@param $limitstart
@param $limit
@return string nothing
|
[
"Fix",
"sync",
"errors"
] |
train
|
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/User/Sync.php#L284-L380
|
jfusion/org.jfusion.framework
|
src/User/Sync.php
|
Sync.markResolved
|
public static function markResolved($id) {
$db = Factory::getDBO();
$query = $db->getQuery(true)
->update('#__jfusion_sync_details')
->set('action = ' . $db->quote('resolved'))
->where('id = ' . $db->quote($id));
$db->setQuery($query);
$db->execute();
}
|
php
|
public static function markResolved($id) {
$db = Factory::getDBO();
$query = $db->getQuery(true)
->update('#__jfusion_sync_details')
->set('action = ' . $db->quote('resolved'))
->where('id = ' . $db->quote($id));
$db->setQuery($query);
$db->execute();
}
|
[
"public",
"static",
"function",
"markResolved",
"(",
"$",
"id",
")",
"{",
"$",
"db",
"=",
"Factory",
"::",
"getDBO",
"(",
")",
";",
"$",
"query",
"=",
"$",
"db",
"->",
"getQuery",
"(",
"true",
")",
"->",
"update",
"(",
"'#__jfusion_sync_details'",
")",
"->",
"set",
"(",
"'action = '",
".",
"$",
"db",
"->",
"quote",
"(",
"'resolved'",
")",
")",
"->",
"where",
"(",
"'id = '",
".",
"$",
"db",
"->",
"quote",
"(",
"$",
"id",
")",
")",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"$",
"db",
"->",
"execute",
"(",
")",
";",
"}"
] |
Marks an error in sync details as resolved to prevent it from constantly showing up in the resolve error view
@param $id
|
[
"Marks",
"an",
"error",
"in",
"sync",
"details",
"as",
"resolved",
"to",
"prevent",
"it",
"from",
"constantly",
"showing",
"up",
"in",
"the",
"resolve",
"error",
"view"
] |
train
|
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/User/Sync.php#L386-L396
|
jfusion/org.jfusion.framework
|
src/User/Sync.php
|
Sync.execute
|
public static function execute(&$syncdata)
{
self::init();
try {
$action = $syncdata->get('action');
$completed = $syncdata->get('completed');
if (empty($completed)) {
$master = $syncdata->get('master');
$syncid = $syncdata->get('syncid');
$userbatch = $syncdata->get('userbatch', 500);
//setup some variables
$MasterPlugin = Factory::getAdmin($master);
$MasterUser = Factory::getUser($master);
$db = Factory::getDBO();
if (!static::getStatus($syncid)) {
//tell JFusion a sync is in progress
static::changeStatus($syncid, 1);
$user_count = 1;
//going to die every x users so that apache doesn't time out
//we should start with the import of slave users into the master
/**
* should be reset at end.
*/
$slave_data = $syncdata->get('slave_data', array());
$plugin_offset = $syncdata->get('plugin_offset', 0);
if (!empty($slave_data)) {
for ($i = $plugin_offset; $i < count($slave_data); $i++) {
$syncdata->set('plugin_offset', $i);
$user_offset = $syncdata->get('user_offset', 0);
//get a list of users
$jname = $slave_data[$i]->jname;
if ($jname) {
$SlavePlugin = Factory::getAdmin($jname);
$SlaveUser = Factory::getUser($jname);
if ($action == 'master') {
$userlist = $SlavePlugin->getUserList($user_offset, $userbatch);
$action_name = $jname;
$action_reverse_name = $master;
} else {
$userlist = $MasterPlugin->getUserList($user_offset, $userbatch);
$action_name = $master;
$action_reverse_name = $jname;
}
//catch to determine if the plugin supports limiting users for sync performance
if (count($userlist) != $slave_data[$i]->total_to_sync) {
//the userlist has already been limited so just start with the first one from the retrieved results
$user_offset = 0;
}
//perform the actual sync
for ($j = $user_offset; $j < count($userlist); $j++) {
$syncdata->set('user_offset', $syncdata->get('user_offset', 0) + 1);
$status = array();
$userinfo = new Userinfo(null);
$userinfo->bind($userlist[$j]);
$UpdateUserInfo = null;
try {
if ($action == 'master') {
$userinfo = $SlaveUser->getUser($userinfo);
if ($userinfo instanceof Userinfo) {
$MasterUser->resetDebugger();
if ($MasterUser->validateUser($userinfo)) {
$UpdateUserInfo = $MasterUser->updateUser($userinfo);
$status = $MasterUser->debugger->get();
if (!$UpdateUserInfo instanceof Userinfo) {
//make sure the userinfo is available
$UpdateUserInfo = $MasterUser->getUser($userinfo);
}
}
}
} else {
$userinfo = $MasterUser->getUser($userinfo);
if ($userinfo instanceof Userinfo) {
$SlaveUser->resetDebugger();
if ($MasterUser->validateUser($userinfo)) {
$UpdateUserInfo = $SlaveUser->updateUser($userinfo);
$status = $SlaveUser->debugger->get();
if (!$UpdateUserInfo instanceof Userinfo) {
//make sure the userinfo is available
$UpdateUserInfo = $SlaveUser->getUser($userinfo);
}
}
}
}
} catch (Exception $e) {
$status[LogLevel::ERROR] = $e->getMessage();
$UpdateUserInfo = null;
}
$sync_log = new stdClass;
$sync_log->syncid = $syncid;
$sync_log->jname = $jname;
$sync_log->message = '';
$sync_log->data = '';
$sync_log->username = $userlist[$j]->username;
$sync_log->email = $userlist[$j]->email;
if (!isset($status['action'])) {
$status['action'] = 'error';
}
if (!$userinfo instanceof Userinfo || !$UpdateUserInfo instanceof Userinfo || !empty($status[LogLevel::ERROR])) {
$status['action'] = 'error';
$sync_log->message = (is_array($status[LogLevel::ERROR])) ? implode('; ', $status[LogLevel::ERROR]) : $status[LogLevel::ERROR];
$error = new stdClass();
$error->conflict = new stdClass();
$error->conflict->userinfo = $UpdateUserInfo;
$error->conflict->error = $status[LogLevel::ERROR];
$error->conflict->debug = (!empty($status[LogLevel::DEBUG])) ? $status[LogLevel::DEBUG] : '';
$error->conflict->jname = $action_reverse_name;
$error->user = new stdClass();
$error->user->jname = $action_name;
$error->user->userinfo = $userinfo;
$error->user->userlist = $userlist[$j];
$sync_log->type = 'ERROR';
if (!empty($error->conflict->userinfo->username) && ($error->user->userinfo->username != $error->conflict->userinfo->username)) {
$sync_log->type = 'USERNAME';
} else if (!empty($error->conflict->userinfo->email) && $error->user->userinfo->email != $error->conflict->userinfo->email) {
$sync_log->type = 'EMAIL';
}
$sync_log->data = json_encode($error);
$syncdata->set('sync_errors', $syncdata->get('sync_errors', 0) + 1);
} else {
//usersync loggin enabled
$sync_log->username = isset($UpdateUserInfo->username) ? $UpdateUserInfo->username : $userinfo->username;
$sync_log->email = isset($UpdateUserInfo->email) ? $UpdateUserInfo->email : $userinfo->email;
if ($UpdateUserInfo instanceof Userinfo) {
//update the lookup table
if ($action == 'master') {
$MasterUser->updateLookup($UpdateUserInfo, $userinfo);
} else {
$SlaveUser->updateLookup($userinfo, $UpdateUserInfo);
}
}
}
$sync_log->action = $status['action'];
//append the error to the log
$db->insertObject('#__jfusion_sync_details', $sync_log);
//update the counters
$slave_data[$i]->{$status['action']} += 1;
$slave_data[$i]->total -= 1;
$syncdata->set('slave_data', $slave_data);
$syncdata->set('synced_users', $syncdata->get('synced_users', 0) + 1);
//update the database, only store syncdata every 20 users for better performance
if ($user_count >= 20) {
if ($slave_data[$i]->total == 0) {
//will force the next plugin and first user of that plugin on resume
$syncdata->set('plugin_offset', $syncdata->get('plugin_offset', 0) + 1);
$syncdata->set('user_offset', 0);
}
static::updateData($syncdata);
//update counters
$user_count = 1;
} else {
//update counters
$user_count++;
}
$userbatch--;
if ($syncdata->get('synced_users', 0) == $syncdata->get('total_to_sync', 0)) {
break;
} elseif ($userbatch == 0 || $slave_data[$i]->total == 0) {
//exit the process to prevent an apache timeout; it will resume on the next ajax call
//save the syncdata before exiting
if ($slave_data[$i]->total == 0) {
//will force the next plugin and first user of that plugin on resume
$syncdata->set('plugin_offset', $syncdata->get('plugin_offset', 0) + 1);
$syncdata->set('user_offset', 0);
}
static::updateData($syncdata);
//tell Joomla the batch has completed
static::changeStatus($syncid, 0);
return;
}
}
}
}
}
$syncdata->set('slave_data', $slave_data);
if ($syncdata->get('synced_users', 0) == $syncdata->get('total_to_sync', 0)) {
//end of sync, save the final data
$syncdata->set('completed', true);
static::updateData($syncdata);
//update the finish time
$db = Factory::getDBO();
$query = $db->getQuery(true)
->update('#__jfusion_sync')
->set('time_end = ' . $db->quote(time()))
->where('syncid = ' . $db->quote($syncid));
$db->setQuery($query);
$db->execute();
}
static::updateData($syncdata);
static::changeStatus($syncid, 0);
}
}
} catch (Exception $e) {
Framework::raise(LogLevel::ERROR, $e);
}
}
|
php
|
public static function execute(&$syncdata)
{
self::init();
try {
$action = $syncdata->get('action');
$completed = $syncdata->get('completed');
if (empty($completed)) {
$master = $syncdata->get('master');
$syncid = $syncdata->get('syncid');
$userbatch = $syncdata->get('userbatch', 500);
//setup some variables
$MasterPlugin = Factory::getAdmin($master);
$MasterUser = Factory::getUser($master);
$db = Factory::getDBO();
if (!static::getStatus($syncid)) {
//tell JFusion a sync is in progress
static::changeStatus($syncid, 1);
$user_count = 1;
//going to die every x users so that apache doesn't time out
//we should start with the import of slave users into the master
/**
* should be reset at end.
*/
$slave_data = $syncdata->get('slave_data', array());
$plugin_offset = $syncdata->get('plugin_offset', 0);
if (!empty($slave_data)) {
for ($i = $plugin_offset; $i < count($slave_data); $i++) {
$syncdata->set('plugin_offset', $i);
$user_offset = $syncdata->get('user_offset', 0);
//get a list of users
$jname = $slave_data[$i]->jname;
if ($jname) {
$SlavePlugin = Factory::getAdmin($jname);
$SlaveUser = Factory::getUser($jname);
if ($action == 'master') {
$userlist = $SlavePlugin->getUserList($user_offset, $userbatch);
$action_name = $jname;
$action_reverse_name = $master;
} else {
$userlist = $MasterPlugin->getUserList($user_offset, $userbatch);
$action_name = $master;
$action_reverse_name = $jname;
}
//catch to determine if the plugin supports limiting users for sync performance
if (count($userlist) != $slave_data[$i]->total_to_sync) {
//the userlist has already been limited so just start with the first one from the retrieved results
$user_offset = 0;
}
//perform the actual sync
for ($j = $user_offset; $j < count($userlist); $j++) {
$syncdata->set('user_offset', $syncdata->get('user_offset', 0) + 1);
$status = array();
$userinfo = new Userinfo(null);
$userinfo->bind($userlist[$j]);
$UpdateUserInfo = null;
try {
if ($action == 'master') {
$userinfo = $SlaveUser->getUser($userinfo);
if ($userinfo instanceof Userinfo) {
$MasterUser->resetDebugger();
if ($MasterUser->validateUser($userinfo)) {
$UpdateUserInfo = $MasterUser->updateUser($userinfo);
$status = $MasterUser->debugger->get();
if (!$UpdateUserInfo instanceof Userinfo) {
//make sure the userinfo is available
$UpdateUserInfo = $MasterUser->getUser($userinfo);
}
}
}
} else {
$userinfo = $MasterUser->getUser($userinfo);
if ($userinfo instanceof Userinfo) {
$SlaveUser->resetDebugger();
if ($MasterUser->validateUser($userinfo)) {
$UpdateUserInfo = $SlaveUser->updateUser($userinfo);
$status = $SlaveUser->debugger->get();
if (!$UpdateUserInfo instanceof Userinfo) {
//make sure the userinfo is available
$UpdateUserInfo = $SlaveUser->getUser($userinfo);
}
}
}
}
} catch (Exception $e) {
$status[LogLevel::ERROR] = $e->getMessage();
$UpdateUserInfo = null;
}
$sync_log = new stdClass;
$sync_log->syncid = $syncid;
$sync_log->jname = $jname;
$sync_log->message = '';
$sync_log->data = '';
$sync_log->username = $userlist[$j]->username;
$sync_log->email = $userlist[$j]->email;
if (!isset($status['action'])) {
$status['action'] = 'error';
}
if (!$userinfo instanceof Userinfo || !$UpdateUserInfo instanceof Userinfo || !empty($status[LogLevel::ERROR])) {
$status['action'] = 'error';
$sync_log->message = (is_array($status[LogLevel::ERROR])) ? implode('; ', $status[LogLevel::ERROR]) : $status[LogLevel::ERROR];
$error = new stdClass();
$error->conflict = new stdClass();
$error->conflict->userinfo = $UpdateUserInfo;
$error->conflict->error = $status[LogLevel::ERROR];
$error->conflict->debug = (!empty($status[LogLevel::DEBUG])) ? $status[LogLevel::DEBUG] : '';
$error->conflict->jname = $action_reverse_name;
$error->user = new stdClass();
$error->user->jname = $action_name;
$error->user->userinfo = $userinfo;
$error->user->userlist = $userlist[$j];
$sync_log->type = 'ERROR';
if (!empty($error->conflict->userinfo->username) && ($error->user->userinfo->username != $error->conflict->userinfo->username)) {
$sync_log->type = 'USERNAME';
} else if (!empty($error->conflict->userinfo->email) && $error->user->userinfo->email != $error->conflict->userinfo->email) {
$sync_log->type = 'EMAIL';
}
$sync_log->data = json_encode($error);
$syncdata->set('sync_errors', $syncdata->get('sync_errors', 0) + 1);
} else {
//usersync loggin enabled
$sync_log->username = isset($UpdateUserInfo->username) ? $UpdateUserInfo->username : $userinfo->username;
$sync_log->email = isset($UpdateUserInfo->email) ? $UpdateUserInfo->email : $userinfo->email;
if ($UpdateUserInfo instanceof Userinfo) {
//update the lookup table
if ($action == 'master') {
$MasterUser->updateLookup($UpdateUserInfo, $userinfo);
} else {
$SlaveUser->updateLookup($userinfo, $UpdateUserInfo);
}
}
}
$sync_log->action = $status['action'];
//append the error to the log
$db->insertObject('#__jfusion_sync_details', $sync_log);
//update the counters
$slave_data[$i]->{$status['action']} += 1;
$slave_data[$i]->total -= 1;
$syncdata->set('slave_data', $slave_data);
$syncdata->set('synced_users', $syncdata->get('synced_users', 0) + 1);
//update the database, only store syncdata every 20 users for better performance
if ($user_count >= 20) {
if ($slave_data[$i]->total == 0) {
//will force the next plugin and first user of that plugin on resume
$syncdata->set('plugin_offset', $syncdata->get('plugin_offset', 0) + 1);
$syncdata->set('user_offset', 0);
}
static::updateData($syncdata);
//update counters
$user_count = 1;
} else {
//update counters
$user_count++;
}
$userbatch--;
if ($syncdata->get('synced_users', 0) == $syncdata->get('total_to_sync', 0)) {
break;
} elseif ($userbatch == 0 || $slave_data[$i]->total == 0) {
//exit the process to prevent an apache timeout; it will resume on the next ajax call
//save the syncdata before exiting
if ($slave_data[$i]->total == 0) {
//will force the next plugin and first user of that plugin on resume
$syncdata->set('plugin_offset', $syncdata->get('plugin_offset', 0) + 1);
$syncdata->set('user_offset', 0);
}
static::updateData($syncdata);
//tell Joomla the batch has completed
static::changeStatus($syncid, 0);
return;
}
}
}
}
}
$syncdata->set('slave_data', $slave_data);
if ($syncdata->get('synced_users', 0) == $syncdata->get('total_to_sync', 0)) {
//end of sync, save the final data
$syncdata->set('completed', true);
static::updateData($syncdata);
//update the finish time
$db = Factory::getDBO();
$query = $db->getQuery(true)
->update('#__jfusion_sync')
->set('time_end = ' . $db->quote(time()))
->where('syncid = ' . $db->quote($syncid));
$db->setQuery($query);
$db->execute();
}
static::updateData($syncdata);
static::changeStatus($syncid, 0);
}
}
} catch (Exception $e) {
Framework::raise(LogLevel::ERROR, $e);
}
}
|
[
"public",
"static",
"function",
"execute",
"(",
"&",
"$",
"syncdata",
")",
"{",
"self",
"::",
"init",
"(",
")",
";",
"try",
"{",
"$",
"action",
"=",
"$",
"syncdata",
"->",
"get",
"(",
"'action'",
")",
";",
"$",
"completed",
"=",
"$",
"syncdata",
"->",
"get",
"(",
"'completed'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"completed",
")",
")",
"{",
"$",
"master",
"=",
"$",
"syncdata",
"->",
"get",
"(",
"'master'",
")",
";",
"$",
"syncid",
"=",
"$",
"syncdata",
"->",
"get",
"(",
"'syncid'",
")",
";",
"$",
"userbatch",
"=",
"$",
"syncdata",
"->",
"get",
"(",
"'userbatch'",
",",
"500",
")",
";",
"//setup some variables",
"$",
"MasterPlugin",
"=",
"Factory",
"::",
"getAdmin",
"(",
"$",
"master",
")",
";",
"$",
"MasterUser",
"=",
"Factory",
"::",
"getUser",
"(",
"$",
"master",
")",
";",
"$",
"db",
"=",
"Factory",
"::",
"getDBO",
"(",
")",
";",
"if",
"(",
"!",
"static",
"::",
"getStatus",
"(",
"$",
"syncid",
")",
")",
"{",
"//tell JFusion a sync is in progress",
"static",
"::",
"changeStatus",
"(",
"$",
"syncid",
",",
"1",
")",
";",
"$",
"user_count",
"=",
"1",
";",
"//going to die every x users so that apache doesn't time out",
"//we should start with the import of slave users into the master",
"/**\n\t\t\t\t\t * should be reset at end.\n\t\t\t\t\t */",
"$",
"slave_data",
"=",
"$",
"syncdata",
"->",
"get",
"(",
"'slave_data'",
",",
"array",
"(",
")",
")",
";",
"$",
"plugin_offset",
"=",
"$",
"syncdata",
"->",
"get",
"(",
"'plugin_offset'",
",",
"0",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"slave_data",
")",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"$",
"plugin_offset",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"slave_data",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"syncdata",
"->",
"set",
"(",
"'plugin_offset'",
",",
"$",
"i",
")",
";",
"$",
"user_offset",
"=",
"$",
"syncdata",
"->",
"get",
"(",
"'user_offset'",
",",
"0",
")",
";",
"//get a list of users",
"$",
"jname",
"=",
"$",
"slave_data",
"[",
"$",
"i",
"]",
"->",
"jname",
";",
"if",
"(",
"$",
"jname",
")",
"{",
"$",
"SlavePlugin",
"=",
"Factory",
"::",
"getAdmin",
"(",
"$",
"jname",
")",
";",
"$",
"SlaveUser",
"=",
"Factory",
"::",
"getUser",
"(",
"$",
"jname",
")",
";",
"if",
"(",
"$",
"action",
"==",
"'master'",
")",
"{",
"$",
"userlist",
"=",
"$",
"SlavePlugin",
"->",
"getUserList",
"(",
"$",
"user_offset",
",",
"$",
"userbatch",
")",
";",
"$",
"action_name",
"=",
"$",
"jname",
";",
"$",
"action_reverse_name",
"=",
"$",
"master",
";",
"}",
"else",
"{",
"$",
"userlist",
"=",
"$",
"MasterPlugin",
"->",
"getUserList",
"(",
"$",
"user_offset",
",",
"$",
"userbatch",
")",
";",
"$",
"action_name",
"=",
"$",
"master",
";",
"$",
"action_reverse_name",
"=",
"$",
"jname",
";",
"}",
"//catch to determine if the plugin supports limiting users for sync performance",
"if",
"(",
"count",
"(",
"$",
"userlist",
")",
"!=",
"$",
"slave_data",
"[",
"$",
"i",
"]",
"->",
"total_to_sync",
")",
"{",
"//the userlist has already been limited so just start with the first one from the retrieved results",
"$",
"user_offset",
"=",
"0",
";",
"}",
"//perform the actual sync",
"for",
"(",
"$",
"j",
"=",
"$",
"user_offset",
";",
"$",
"j",
"<",
"count",
"(",
"$",
"userlist",
")",
";",
"$",
"j",
"++",
")",
"{",
"$",
"syncdata",
"->",
"set",
"(",
"'user_offset'",
",",
"$",
"syncdata",
"->",
"get",
"(",
"'user_offset'",
",",
"0",
")",
"+",
"1",
")",
";",
"$",
"status",
"=",
"array",
"(",
")",
";",
"$",
"userinfo",
"=",
"new",
"Userinfo",
"(",
"null",
")",
";",
"$",
"userinfo",
"->",
"bind",
"(",
"$",
"userlist",
"[",
"$",
"j",
"]",
")",
";",
"$",
"UpdateUserInfo",
"=",
"null",
";",
"try",
"{",
"if",
"(",
"$",
"action",
"==",
"'master'",
")",
"{",
"$",
"userinfo",
"=",
"$",
"SlaveUser",
"->",
"getUser",
"(",
"$",
"userinfo",
")",
";",
"if",
"(",
"$",
"userinfo",
"instanceof",
"Userinfo",
")",
"{",
"$",
"MasterUser",
"->",
"resetDebugger",
"(",
")",
";",
"if",
"(",
"$",
"MasterUser",
"->",
"validateUser",
"(",
"$",
"userinfo",
")",
")",
"{",
"$",
"UpdateUserInfo",
"=",
"$",
"MasterUser",
"->",
"updateUser",
"(",
"$",
"userinfo",
")",
";",
"$",
"status",
"=",
"$",
"MasterUser",
"->",
"debugger",
"->",
"get",
"(",
")",
";",
"if",
"(",
"!",
"$",
"UpdateUserInfo",
"instanceof",
"Userinfo",
")",
"{",
"//make sure the userinfo is available",
"$",
"UpdateUserInfo",
"=",
"$",
"MasterUser",
"->",
"getUser",
"(",
"$",
"userinfo",
")",
";",
"}",
"}",
"}",
"}",
"else",
"{",
"$",
"userinfo",
"=",
"$",
"MasterUser",
"->",
"getUser",
"(",
"$",
"userinfo",
")",
";",
"if",
"(",
"$",
"userinfo",
"instanceof",
"Userinfo",
")",
"{",
"$",
"SlaveUser",
"->",
"resetDebugger",
"(",
")",
";",
"if",
"(",
"$",
"MasterUser",
"->",
"validateUser",
"(",
"$",
"userinfo",
")",
")",
"{",
"$",
"UpdateUserInfo",
"=",
"$",
"SlaveUser",
"->",
"updateUser",
"(",
"$",
"userinfo",
")",
";",
"$",
"status",
"=",
"$",
"SlaveUser",
"->",
"debugger",
"->",
"get",
"(",
")",
";",
"if",
"(",
"!",
"$",
"UpdateUserInfo",
"instanceof",
"Userinfo",
")",
"{",
"//make sure the userinfo is available",
"$",
"UpdateUserInfo",
"=",
"$",
"SlaveUser",
"->",
"getUser",
"(",
"$",
"userinfo",
")",
";",
"}",
"}",
"}",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"status",
"[",
"LogLevel",
"::",
"ERROR",
"]",
"=",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"$",
"UpdateUserInfo",
"=",
"null",
";",
"}",
"$",
"sync_log",
"=",
"new",
"stdClass",
";",
"$",
"sync_log",
"->",
"syncid",
"=",
"$",
"syncid",
";",
"$",
"sync_log",
"->",
"jname",
"=",
"$",
"jname",
";",
"$",
"sync_log",
"->",
"message",
"=",
"''",
";",
"$",
"sync_log",
"->",
"data",
"=",
"''",
";",
"$",
"sync_log",
"->",
"username",
"=",
"$",
"userlist",
"[",
"$",
"j",
"]",
"->",
"username",
";",
"$",
"sync_log",
"->",
"email",
"=",
"$",
"userlist",
"[",
"$",
"j",
"]",
"->",
"email",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"status",
"[",
"'action'",
"]",
")",
")",
"{",
"$",
"status",
"[",
"'action'",
"]",
"=",
"'error'",
";",
"}",
"if",
"(",
"!",
"$",
"userinfo",
"instanceof",
"Userinfo",
"||",
"!",
"$",
"UpdateUserInfo",
"instanceof",
"Userinfo",
"||",
"!",
"empty",
"(",
"$",
"status",
"[",
"LogLevel",
"::",
"ERROR",
"]",
")",
")",
"{",
"$",
"status",
"[",
"'action'",
"]",
"=",
"'error'",
";",
"$",
"sync_log",
"->",
"message",
"=",
"(",
"is_array",
"(",
"$",
"status",
"[",
"LogLevel",
"::",
"ERROR",
"]",
")",
")",
"?",
"implode",
"(",
"'; '",
",",
"$",
"status",
"[",
"LogLevel",
"::",
"ERROR",
"]",
")",
":",
"$",
"status",
"[",
"LogLevel",
"::",
"ERROR",
"]",
";",
"$",
"error",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"error",
"->",
"conflict",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"error",
"->",
"conflict",
"->",
"userinfo",
"=",
"$",
"UpdateUserInfo",
";",
"$",
"error",
"->",
"conflict",
"->",
"error",
"=",
"$",
"status",
"[",
"LogLevel",
"::",
"ERROR",
"]",
";",
"$",
"error",
"->",
"conflict",
"->",
"debug",
"=",
"(",
"!",
"empty",
"(",
"$",
"status",
"[",
"LogLevel",
"::",
"DEBUG",
"]",
")",
")",
"?",
"$",
"status",
"[",
"LogLevel",
"::",
"DEBUG",
"]",
":",
"''",
";",
"$",
"error",
"->",
"conflict",
"->",
"jname",
"=",
"$",
"action_reverse_name",
";",
"$",
"error",
"->",
"user",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"error",
"->",
"user",
"->",
"jname",
"=",
"$",
"action_name",
";",
"$",
"error",
"->",
"user",
"->",
"userinfo",
"=",
"$",
"userinfo",
";",
"$",
"error",
"->",
"user",
"->",
"userlist",
"=",
"$",
"userlist",
"[",
"$",
"j",
"]",
";",
"$",
"sync_log",
"->",
"type",
"=",
"'ERROR'",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"error",
"->",
"conflict",
"->",
"userinfo",
"->",
"username",
")",
"&&",
"(",
"$",
"error",
"->",
"user",
"->",
"userinfo",
"->",
"username",
"!=",
"$",
"error",
"->",
"conflict",
"->",
"userinfo",
"->",
"username",
")",
")",
"{",
"$",
"sync_log",
"->",
"type",
"=",
"'USERNAME'",
";",
"}",
"else",
"if",
"(",
"!",
"empty",
"(",
"$",
"error",
"->",
"conflict",
"->",
"userinfo",
"->",
"email",
")",
"&&",
"$",
"error",
"->",
"user",
"->",
"userinfo",
"->",
"email",
"!=",
"$",
"error",
"->",
"conflict",
"->",
"userinfo",
"->",
"email",
")",
"{",
"$",
"sync_log",
"->",
"type",
"=",
"'EMAIL'",
";",
"}",
"$",
"sync_log",
"->",
"data",
"=",
"json_encode",
"(",
"$",
"error",
")",
";",
"$",
"syncdata",
"->",
"set",
"(",
"'sync_errors'",
",",
"$",
"syncdata",
"->",
"get",
"(",
"'sync_errors'",
",",
"0",
")",
"+",
"1",
")",
";",
"}",
"else",
"{",
"//usersync loggin enabled",
"$",
"sync_log",
"->",
"username",
"=",
"isset",
"(",
"$",
"UpdateUserInfo",
"->",
"username",
")",
"?",
"$",
"UpdateUserInfo",
"->",
"username",
":",
"$",
"userinfo",
"->",
"username",
";",
"$",
"sync_log",
"->",
"email",
"=",
"isset",
"(",
"$",
"UpdateUserInfo",
"->",
"email",
")",
"?",
"$",
"UpdateUserInfo",
"->",
"email",
":",
"$",
"userinfo",
"->",
"email",
";",
"if",
"(",
"$",
"UpdateUserInfo",
"instanceof",
"Userinfo",
")",
"{",
"//update the lookup table",
"if",
"(",
"$",
"action",
"==",
"'master'",
")",
"{",
"$",
"MasterUser",
"->",
"updateLookup",
"(",
"$",
"UpdateUserInfo",
",",
"$",
"userinfo",
")",
";",
"}",
"else",
"{",
"$",
"SlaveUser",
"->",
"updateLookup",
"(",
"$",
"userinfo",
",",
"$",
"UpdateUserInfo",
")",
";",
"}",
"}",
"}",
"$",
"sync_log",
"->",
"action",
"=",
"$",
"status",
"[",
"'action'",
"]",
";",
"//append the error to the log",
"$",
"db",
"->",
"insertObject",
"(",
"'#__jfusion_sync_details'",
",",
"$",
"sync_log",
")",
";",
"//update the counters",
"$",
"slave_data",
"[",
"$",
"i",
"]",
"->",
"{",
"$",
"status",
"[",
"'action'",
"]",
"}",
"+=",
"1",
";",
"$",
"slave_data",
"[",
"$",
"i",
"]",
"->",
"total",
"-=",
"1",
";",
"$",
"syncdata",
"->",
"set",
"(",
"'slave_data'",
",",
"$",
"slave_data",
")",
";",
"$",
"syncdata",
"->",
"set",
"(",
"'synced_users'",
",",
"$",
"syncdata",
"->",
"get",
"(",
"'synced_users'",
",",
"0",
")",
"+",
"1",
")",
";",
"//update the database, only store syncdata every 20 users for better performance",
"if",
"(",
"$",
"user_count",
">=",
"20",
")",
"{",
"if",
"(",
"$",
"slave_data",
"[",
"$",
"i",
"]",
"->",
"total",
"==",
"0",
")",
"{",
"//will force the next plugin and first user of that plugin on resume",
"$",
"syncdata",
"->",
"set",
"(",
"'plugin_offset'",
",",
"$",
"syncdata",
"->",
"get",
"(",
"'plugin_offset'",
",",
"0",
")",
"+",
"1",
")",
";",
"$",
"syncdata",
"->",
"set",
"(",
"'user_offset'",
",",
"0",
")",
";",
"}",
"static",
"::",
"updateData",
"(",
"$",
"syncdata",
")",
";",
"//update counters",
"$",
"user_count",
"=",
"1",
";",
"}",
"else",
"{",
"//update counters",
"$",
"user_count",
"++",
";",
"}",
"$",
"userbatch",
"--",
";",
"if",
"(",
"$",
"syncdata",
"->",
"get",
"(",
"'synced_users'",
",",
"0",
")",
"==",
"$",
"syncdata",
"->",
"get",
"(",
"'total_to_sync'",
",",
"0",
")",
")",
"{",
"break",
";",
"}",
"elseif",
"(",
"$",
"userbatch",
"==",
"0",
"||",
"$",
"slave_data",
"[",
"$",
"i",
"]",
"->",
"total",
"==",
"0",
")",
"{",
"//exit the process to prevent an apache timeout; it will resume on the next ajax call",
"//save the syncdata before exiting",
"if",
"(",
"$",
"slave_data",
"[",
"$",
"i",
"]",
"->",
"total",
"==",
"0",
")",
"{",
"//will force the next plugin and first user of that plugin on resume",
"$",
"syncdata",
"->",
"set",
"(",
"'plugin_offset'",
",",
"$",
"syncdata",
"->",
"get",
"(",
"'plugin_offset'",
",",
"0",
")",
"+",
"1",
")",
";",
"$",
"syncdata",
"->",
"set",
"(",
"'user_offset'",
",",
"0",
")",
";",
"}",
"static",
"::",
"updateData",
"(",
"$",
"syncdata",
")",
";",
"//tell Joomla the batch has completed",
"static",
"::",
"changeStatus",
"(",
"$",
"syncid",
",",
"0",
")",
";",
"return",
";",
"}",
"}",
"}",
"}",
"}",
"$",
"syncdata",
"->",
"set",
"(",
"'slave_data'",
",",
"$",
"slave_data",
")",
";",
"if",
"(",
"$",
"syncdata",
"->",
"get",
"(",
"'synced_users'",
",",
"0",
")",
"==",
"$",
"syncdata",
"->",
"get",
"(",
"'total_to_sync'",
",",
"0",
")",
")",
"{",
"//end of sync, save the final data",
"$",
"syncdata",
"->",
"set",
"(",
"'completed'",
",",
"true",
")",
";",
"static",
"::",
"updateData",
"(",
"$",
"syncdata",
")",
";",
"//update the finish time",
"$",
"db",
"=",
"Factory",
"::",
"getDBO",
"(",
")",
";",
"$",
"query",
"=",
"$",
"db",
"->",
"getQuery",
"(",
"true",
")",
"->",
"update",
"(",
"'#__jfusion_sync'",
")",
"->",
"set",
"(",
"'time_end = '",
".",
"$",
"db",
"->",
"quote",
"(",
"time",
"(",
")",
")",
")",
"->",
"where",
"(",
"'syncid = '",
".",
"$",
"db",
"->",
"quote",
"(",
"$",
"syncid",
")",
")",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"$",
"db",
"->",
"execute",
"(",
")",
";",
"}",
"static",
"::",
"updateData",
"(",
"$",
"syncdata",
")",
";",
"static",
"::",
"changeStatus",
"(",
"$",
"syncid",
",",
"0",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"Framework",
"::",
"raise",
"(",
"LogLevel",
"::",
"ERROR",
",",
"$",
"e",
")",
";",
"}",
"}"
] |
Save log data
@param Registry &$syncdata the actual syncdata
@return string nothing
|
[
"Save",
"log",
"data"
] |
train
|
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/User/Sync.php#L405-L625
|
jfusion/org.jfusion.framework
|
src/User/Sync.php
|
Sync.getStatus
|
public static function getStatus($syncid) {
if (!empty($syncid)) {
$db = Factory::getDBO();
$query = $db->getQuery(true)
->select('active')
->from('#__jfusion_sync')
->where('syncid = ' . $db->quote($syncid));
$db->setQuery($query);
return (int)$db->loadResult();
}
return 0;
}
|
php
|
public static function getStatus($syncid) {
if (!empty($syncid)) {
$db = Factory::getDBO();
$query = $db->getQuery(true)
->select('active')
->from('#__jfusion_sync')
->where('syncid = ' . $db->quote($syncid));
$db->setQuery($query);
return (int)$db->loadResult();
}
return 0;
}
|
[
"public",
"static",
"function",
"getStatus",
"(",
"$",
"syncid",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"syncid",
")",
")",
"{",
"$",
"db",
"=",
"Factory",
"::",
"getDBO",
"(",
")",
";",
"$",
"query",
"=",
"$",
"db",
"->",
"getQuery",
"(",
"true",
")",
"->",
"select",
"(",
"'active'",
")",
"->",
"from",
"(",
"'#__jfusion_sync'",
")",
"->",
"where",
"(",
"'syncid = '",
".",
"$",
"db",
"->",
"quote",
"(",
"$",
"syncid",
")",
")",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"return",
"(",
"int",
")",
"$",
"db",
"->",
"loadResult",
"(",
")",
";",
"}",
"return",
"0",
";",
"}"
] |
@static
@param string $syncid
@return int|mixed
|
[
"@static",
"@param",
"string",
"$syncid"
] |
train
|
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/User/Sync.php#L650-L663
|
jfusion/org.jfusion.framework
|
src/User/Sync.php
|
Sync.exsists
|
public static function exsists($syncid) {
if (!empty($syncid)) {
$db = Factory::getDBO();
$query = $db->getQuery(true)
->select('syncid')
->from('#__jfusion_sync')
->where('syncid = ' . $db->quote($syncid));
$db->setQuery($query);
if ($db->loadResult()) {
return true;
}
}
return false;
}
|
php
|
public static function exsists($syncid) {
if (!empty($syncid)) {
$db = Factory::getDBO();
$query = $db->getQuery(true)
->select('syncid')
->from('#__jfusion_sync')
->where('syncid = ' . $db->quote($syncid));
$db->setQuery($query);
if ($db->loadResult()) {
return true;
}
}
return false;
}
|
[
"public",
"static",
"function",
"exsists",
"(",
"$",
"syncid",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"syncid",
")",
")",
"{",
"$",
"db",
"=",
"Factory",
"::",
"getDBO",
"(",
")",
";",
"$",
"query",
"=",
"$",
"db",
"->",
"getQuery",
"(",
"true",
")",
"->",
"select",
"(",
"'syncid'",
")",
"->",
"from",
"(",
"'#__jfusion_sync'",
")",
"->",
"where",
"(",
"'syncid = '",
".",
"$",
"db",
"->",
"quote",
"(",
"$",
"syncid",
")",
")",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"if",
"(",
"$",
"db",
"->",
"loadResult",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
@static
@param string $syncid
@return boolean
|
[
"@static",
"@param",
"string",
"$syncid"
] |
train
|
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/User/Sync.php#L671-L687
|
fubhy/graphql-php
|
src/Utility/TypeInfo.php
|
TypeInfo.typeFromAST
|
public static function typeFromAST(Schema $schema, $inputType)
{
if ($inputType instanceof ListType) {
$innerType = self::typeFromAST($schema, $inputType->get('type'));
return $innerType ? new ListModifier($innerType) : NULL;
}
if ($inputType instanceof NonNullType) {
$innerType = self::typeFromAST($schema, $inputType->get('type'));
return $innerType ? new NonNullModifier($innerType) : NULL;
}
if (!($inputType instanceof NamedType)) {
throw new \LogicException('Must be a type name.');
}
return $schema->getType($inputType->get('name')->get('value'));
}
|
php
|
public static function typeFromAST(Schema $schema, $inputType)
{
if ($inputType instanceof ListType) {
$innerType = self::typeFromAST($schema, $inputType->get('type'));
return $innerType ? new ListModifier($innerType) : NULL;
}
if ($inputType instanceof NonNullType) {
$innerType = self::typeFromAST($schema, $inputType->get('type'));
return $innerType ? new NonNullModifier($innerType) : NULL;
}
if (!($inputType instanceof NamedType)) {
throw new \LogicException('Must be a type name.');
}
return $schema->getType($inputType->get('name')->get('value'));
}
|
[
"public",
"static",
"function",
"typeFromAST",
"(",
"Schema",
"$",
"schema",
",",
"$",
"inputType",
")",
"{",
"if",
"(",
"$",
"inputType",
"instanceof",
"ListType",
")",
"{",
"$",
"innerType",
"=",
"self",
"::",
"typeFromAST",
"(",
"$",
"schema",
",",
"$",
"inputType",
"->",
"get",
"(",
"'type'",
")",
")",
";",
"return",
"$",
"innerType",
"?",
"new",
"ListModifier",
"(",
"$",
"innerType",
")",
":",
"NULL",
";",
"}",
"if",
"(",
"$",
"inputType",
"instanceof",
"NonNullType",
")",
"{",
"$",
"innerType",
"=",
"self",
"::",
"typeFromAST",
"(",
"$",
"schema",
",",
"$",
"inputType",
"->",
"get",
"(",
"'type'",
")",
")",
";",
"return",
"$",
"innerType",
"?",
"new",
"NonNullModifier",
"(",
"$",
"innerType",
")",
":",
"NULL",
";",
"}",
"if",
"(",
"!",
"(",
"$",
"inputType",
"instanceof",
"NamedType",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'Must be a type name.'",
")",
";",
"}",
"return",
"$",
"schema",
"->",
"getType",
"(",
"$",
"inputType",
"->",
"get",
"(",
"'name'",
")",
"->",
"get",
"(",
"'value'",
")",
")",
";",
"}"
] |
@param Schema $schema
@param $inputType
@return ListModifier|NonNullModifier|\Fubhy\GraphQL\Type\Definition\Types\TypeInterface|null
|
[
"@param",
"Schema",
"$schema",
"@param",
"$inputType"
] |
train
|
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Utility/TypeInfo.php#L59-L76
|
fubhy/graphql-php
|
src/Utility/TypeInfo.php
|
TypeInfo.getFieldDefinition
|
protected static function getFieldDefinition(Schema $schema, Type $parentType, Field $fieldAST)
{
$name = $fieldAST->get('name')->get('value');
$schemaMeta = Introspection::schemaMetaFieldDefinition();
if ($name === $schemaMeta->getName() && $schema->getQueryType() === $parentType) {
return $schemaMeta;
}
$typeMeta = Introspection::typeMetaFieldDefinition();
if ($name === $typeMeta->getName() && $schema->getQueryType() === $parentType) {
return $typeMeta;
}
$typeNameMeta = Introspection::typeNameMetaFieldDefinition();
if ($name === $typeNameMeta->getName() && ($parentType instanceof ObjectType || $parentType instanceof InterfaceType || $parentType instanceof UnionType)) {
return $typeNameMeta;
}
if ($parentType instanceof ObjectType || $parentType instanceof InterfaceType) {
$fields = $parentType->getFields();
return isset($fields[$name]) ? $fields[$name] : NULL;
}
return NULL;
}
|
php
|
protected static function getFieldDefinition(Schema $schema, Type $parentType, Field $fieldAST)
{
$name = $fieldAST->get('name')->get('value');
$schemaMeta = Introspection::schemaMetaFieldDefinition();
if ($name === $schemaMeta->getName() && $schema->getQueryType() === $parentType) {
return $schemaMeta;
}
$typeMeta = Introspection::typeMetaFieldDefinition();
if ($name === $typeMeta->getName() && $schema->getQueryType() === $parentType) {
return $typeMeta;
}
$typeNameMeta = Introspection::typeNameMetaFieldDefinition();
if ($name === $typeNameMeta->getName() && ($parentType instanceof ObjectType || $parentType instanceof InterfaceType || $parentType instanceof UnionType)) {
return $typeNameMeta;
}
if ($parentType instanceof ObjectType || $parentType instanceof InterfaceType) {
$fields = $parentType->getFields();
return isset($fields[$name]) ? $fields[$name] : NULL;
}
return NULL;
}
|
[
"protected",
"static",
"function",
"getFieldDefinition",
"(",
"Schema",
"$",
"schema",
",",
"Type",
"$",
"parentType",
",",
"Field",
"$",
"fieldAST",
")",
"{",
"$",
"name",
"=",
"$",
"fieldAST",
"->",
"get",
"(",
"'name'",
")",
"->",
"get",
"(",
"'value'",
")",
";",
"$",
"schemaMeta",
"=",
"Introspection",
"::",
"schemaMetaFieldDefinition",
"(",
")",
";",
"if",
"(",
"$",
"name",
"===",
"$",
"schemaMeta",
"->",
"getName",
"(",
")",
"&&",
"$",
"schema",
"->",
"getQueryType",
"(",
")",
"===",
"$",
"parentType",
")",
"{",
"return",
"$",
"schemaMeta",
";",
"}",
"$",
"typeMeta",
"=",
"Introspection",
"::",
"typeMetaFieldDefinition",
"(",
")",
";",
"if",
"(",
"$",
"name",
"===",
"$",
"typeMeta",
"->",
"getName",
"(",
")",
"&&",
"$",
"schema",
"->",
"getQueryType",
"(",
")",
"===",
"$",
"parentType",
")",
"{",
"return",
"$",
"typeMeta",
";",
"}",
"$",
"typeNameMeta",
"=",
"Introspection",
"::",
"typeNameMetaFieldDefinition",
"(",
")",
";",
"if",
"(",
"$",
"name",
"===",
"$",
"typeNameMeta",
"->",
"getName",
"(",
")",
"&&",
"(",
"$",
"parentType",
"instanceof",
"ObjectType",
"||",
"$",
"parentType",
"instanceof",
"InterfaceType",
"||",
"$",
"parentType",
"instanceof",
"UnionType",
")",
")",
"{",
"return",
"$",
"typeNameMeta",
";",
"}",
"if",
"(",
"$",
"parentType",
"instanceof",
"ObjectType",
"||",
"$",
"parentType",
"instanceof",
"InterfaceType",
")",
"{",
"$",
"fields",
"=",
"$",
"parentType",
"->",
"getFields",
"(",
")",
";",
"return",
"isset",
"(",
"$",
"fields",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"fields",
"[",
"$",
"name",
"]",
":",
"NULL",
";",
"}",
"return",
"NULL",
";",
"}"
] |
Not exactly the same as the executor's definition of getFieldDef, in this
statically evaluated environment we do not always have an Object type,
and need to handle Interface and Union types.
@param Schema $schema
@param Type $parentType
@param Field $fieldAST
@return FieldDefinition
|
[
"Not",
"exactly",
"the",
"same",
"as",
"the",
"executor",
"s",
"definition",
"of",
"getFieldDef",
"in",
"this",
"statically",
"evaluated",
"environment",
"we",
"do",
"not",
"always",
"have",
"an",
"Object",
"type",
"and",
"need",
"to",
"handle",
"Interface",
"and",
"Union",
"types",
"."
] |
train
|
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Utility/TypeInfo.php#L89-L113
|
nooku/nooku-installer
|
src/Nooku/Composer/Installer/NookuFramework.php
|
NookuFramework.install
|
public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
{
if (!$this->_isValidName($package->getPrettyName()))
{
throw new \InvalidArgumentException(
'Invalid package name `'.$package->getPrettyName().'`. '.
'The `nooku-framework` composer type can only install the `nooku/nooku-framework` package.'
);
}
parent::install($repo, $package);
$query = 'UPDATE #__extensions SET enabled = 1 WHERE type = \'plugin\' AND element = \'koowa\' AND folder = \'system\'';
\JFactory::getDBO()->setQuery($query)->query();
$this->_loadFramework();
}
|
php
|
public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
{
if (!$this->_isValidName($package->getPrettyName()))
{
throw new \InvalidArgumentException(
'Invalid package name `'.$package->getPrettyName().'`. '.
'The `nooku-framework` composer type can only install the `nooku/nooku-framework` package.'
);
}
parent::install($repo, $package);
$query = 'UPDATE #__extensions SET enabled = 1 WHERE type = \'plugin\' AND element = \'koowa\' AND folder = \'system\'';
\JFactory::getDBO()->setQuery($query)->query();
$this->_loadFramework();
}
|
[
"public",
"function",
"install",
"(",
"InstalledRepositoryInterface",
"$",
"repo",
",",
"PackageInterface",
"$",
"package",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_isValidName",
"(",
"$",
"package",
"->",
"getPrettyName",
"(",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Invalid package name `'",
".",
"$",
"package",
"->",
"getPrettyName",
"(",
")",
".",
"'`. '",
".",
"'The `nooku-framework` composer type can only install the `nooku/nooku-framework` package.'",
")",
";",
"}",
"parent",
"::",
"install",
"(",
"$",
"repo",
",",
"$",
"package",
")",
";",
"$",
"query",
"=",
"'UPDATE #__extensions SET enabled = 1 WHERE type = \\'plugin\\' AND element = \\'koowa\\' AND folder = \\'system\\''",
";",
"\\",
"JFactory",
"::",
"getDBO",
"(",
")",
"->",
"setQuery",
"(",
"$",
"query",
")",
"->",
"query",
"(",
")",
";",
"$",
"this",
"->",
"_loadFramework",
"(",
")",
";",
"}"
] |
{@inheritDoc}
|
[
"{"
] |
train
|
https://github.com/nooku/nooku-installer/blob/2aa82ed08983bccd51905426cfff4980ba960d89/src/Nooku/Composer/Installer/NookuFramework.php#L26-L42
|
ufocoder/yii2-SyncSocial
|
src/components/Synchronizer.php
|
Synchronizer.factorySyncService
|
protected function factorySyncService( $serviceName ) {
$syncClass = '\\ufocoder\\SyncSocial\\components\\services\\' . ucfirst( $serviceName );
if ( ! class_exists( $syncClass ) ) {
throw new Exception( Yii::t( 'SyncSocial', 'SyncSocial Extension not support "{serviceName}" service', [
'serviceName' => $serviceName
] ) );
}
return new $syncClass( [
'serviceSettings' => isset( $this->settings[ $serviceName ] ) ? $this->settings[ $serviceName ] : [ ],
'connectUrl' => $this->getConnectUrl( $serviceName )
] );
}
|
php
|
protected function factorySyncService( $serviceName ) {
$syncClass = '\\ufocoder\\SyncSocial\\components\\services\\' . ucfirst( $serviceName );
if ( ! class_exists( $syncClass ) ) {
throw new Exception( Yii::t( 'SyncSocial', 'SyncSocial Extension not support "{serviceName}" service', [
'serviceName' => $serviceName
] ) );
}
return new $syncClass( [
'serviceSettings' => isset( $this->settings[ $serviceName ] ) ? $this->settings[ $serviceName ] : [ ],
'connectUrl' => $this->getConnectUrl( $serviceName )
] );
}
|
[
"protected",
"function",
"factorySyncService",
"(",
"$",
"serviceName",
")",
"{",
"$",
"syncClass",
"=",
"'\\\\ufocoder\\\\SyncSocial\\\\components\\\\services\\\\'",
".",
"ucfirst",
"(",
"$",
"serviceName",
")",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"syncClass",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"Yii",
"::",
"t",
"(",
"'SyncSocial'",
",",
"'SyncSocial Extension not support \"{serviceName}\" service'",
",",
"[",
"'serviceName'",
"=>",
"$",
"serviceName",
"]",
")",
")",
";",
"}",
"return",
"new",
"$",
"syncClass",
"(",
"[",
"'serviceSettings'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"settings",
"[",
"$",
"serviceName",
"]",
")",
"?",
"$",
"this",
"->",
"settings",
"[",
"$",
"serviceName",
"]",
":",
"[",
"]",
",",
"'connectUrl'",
"=>",
"$",
"this",
"->",
"getConnectUrl",
"(",
"$",
"serviceName",
")",
"]",
")",
";",
"}"
] |
Create service synchronizer wrapper class
@param $serviceName
@return \yii\authclient\BaseOAuth
@throws Exception
|
[
"Create",
"service",
"synchronizer",
"wrapper",
"class"
] |
train
|
https://github.com/ufocoder/yii2-SyncSocial/blob/2dbaaec2dad782c52fdd5b648a31ba7fe2a75e1b/src/components/Synchronizer.php#L143-L157
|
ufocoder/yii2-SyncSocial
|
src/components/Synchronizer.php
|
Synchronizer.getService
|
public function getService( $serviceName ) {
if ( empty( $this->services[ $serviceName ] ) ) {
$this->services[ $serviceName ] = $this->factorySyncService( $serviceName );
}
if ( ! $this->services[ $serviceName ] instanceof SyncService ) {
throw new Exception( Yii::t( 'SyncSocial', 'Component service must be instance of SyncService class' ) );
}
return $this->services[ $serviceName ];
}
|
php
|
public function getService( $serviceName ) {
if ( empty( $this->services[ $serviceName ] ) ) {
$this->services[ $serviceName ] = $this->factorySyncService( $serviceName );
}
if ( ! $this->services[ $serviceName ] instanceof SyncService ) {
throw new Exception( Yii::t( 'SyncSocial', 'Component service must be instance of SyncService class' ) );
}
return $this->services[ $serviceName ];
}
|
[
"public",
"function",
"getService",
"(",
"$",
"serviceName",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"services",
"[",
"$",
"serviceName",
"]",
")",
")",
"{",
"$",
"this",
"->",
"services",
"[",
"$",
"serviceName",
"]",
"=",
"$",
"this",
"->",
"factorySyncService",
"(",
"$",
"serviceName",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"services",
"[",
"$",
"serviceName",
"]",
"instanceof",
"SyncService",
")",
"{",
"throw",
"new",
"Exception",
"(",
"Yii",
"::",
"t",
"(",
"'SyncSocial'",
",",
"'Component service must be instance of SyncService class'",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"services",
"[",
"$",
"serviceName",
"]",
";",
"}"
] |
@param $serviceName
@return SyncService
@throws Exception
|
[
"@param",
"$serviceName"
] |
train
|
https://github.com/ufocoder/yii2-SyncSocial/blob/2dbaaec2dad782c52fdd5b648a31ba7fe2a75e1b/src/components/Synchronizer.php#L165-L176
|
ufocoder/yii2-SyncSocial
|
src/components/Synchronizer.php
|
Synchronizer.disconnect
|
public function disconnect( $serviceName = null ) {
$service = $this->getService( $serviceName );
$service->disconnect();
return ! $service->isConnected();
}
|
php
|
public function disconnect( $serviceName = null ) {
$service = $this->getService( $serviceName );
$service->disconnect();
return ! $service->isConnected();
}
|
[
"public",
"function",
"disconnect",
"(",
"$",
"serviceName",
"=",
"null",
")",
"{",
"$",
"service",
"=",
"$",
"this",
"->",
"getService",
"(",
"$",
"serviceName",
")",
";",
"$",
"service",
"->",
"disconnect",
"(",
")",
";",
"return",
"!",
"$",
"service",
"->",
"isConnected",
"(",
")",
";",
"}"
] |
@param null $serviceName
@return bool
|
[
"@param",
"null",
"$serviceName"
] |
train
|
https://github.com/ufocoder/yii2-SyncSocial/blob/2dbaaec2dad782c52fdd5b648a31ba7fe2a75e1b/src/components/Synchronizer.php#L222-L227
|
ufocoder/yii2-SyncSocial
|
src/components/Synchronizer.php
|
Synchronizer.createModel
|
protected function createModel( array $data ) {
/**
* @var $model \yii\db\ActiveRecord
*/
$model = new $this->modelClass;
$model->scenario = $this->modelScenario;
$model->{$this->modelAttribute} = $data['content'];
$model->save();
if ( $model->hasErrors() ) {
throw new InvalidConfigException( Yii::t( 'SyncSocial', 'Wrong model configuration for SyncSocial extension' ) );
}
return $model;
}
|
php
|
protected function createModel( array $data ) {
/**
* @var $model \yii\db\ActiveRecord
*/
$model = new $this->modelClass;
$model->scenario = $this->modelScenario;
$model->{$this->modelAttribute} = $data['content'];
$model->save();
if ( $model->hasErrors() ) {
throw new InvalidConfigException( Yii::t( 'SyncSocial', 'Wrong model configuration for SyncSocial extension' ) );
}
return $model;
}
|
[
"protected",
"function",
"createModel",
"(",
"array",
"$",
"data",
")",
"{",
"/**\n * @var $model \\yii\\db\\ActiveRecord\n */",
"$",
"model",
"=",
"new",
"$",
"this",
"->",
"modelClass",
";",
"$",
"model",
"->",
"scenario",
"=",
"$",
"this",
"->",
"modelScenario",
";",
"$",
"model",
"->",
"{",
"$",
"this",
"->",
"modelAttribute",
"}",
"=",
"$",
"data",
"[",
"'content'",
"]",
";",
"$",
"model",
"->",
"save",
"(",
")",
";",
"if",
"(",
"$",
"model",
"->",
"hasErrors",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidConfigException",
"(",
"Yii",
"::",
"t",
"(",
"'SyncSocial'",
",",
"'Wrong model configuration for SyncSocial extension'",
")",
")",
";",
"}",
"return",
"$",
"model",
";",
"}"
] |
@param array $data
@return ActiveRecord
@throws Exception
|
[
"@param",
"array",
"$data"
] |
train
|
https://github.com/ufocoder/yii2-SyncSocial/blob/2dbaaec2dad782c52fdd5b648a31ba7fe2a75e1b/src/components/Synchronizer.php#L235-L250
|
ufocoder/yii2-SyncSocial
|
src/components/Synchronizer.php
|
Synchronizer.isExistsSyncModelByData
|
protected function isExistsSyncModelByData( SyncService $service, array $data ) {
return SyncModel::find()->where( [
'service_name' => $service->getName(),
'service_id_author' => $data['service_id_author'],
'service_id_post' => $data['service_id_post']
] )->exists();
}
|
php
|
protected function isExistsSyncModelByData( SyncService $service, array $data ) {
return SyncModel::find()->where( [
'service_name' => $service->getName(),
'service_id_author' => $data['service_id_author'],
'service_id_post' => $data['service_id_post']
] )->exists();
}
|
[
"protected",
"function",
"isExistsSyncModelByData",
"(",
"SyncService",
"$",
"service",
",",
"array",
"$",
"data",
")",
"{",
"return",
"SyncModel",
"::",
"find",
"(",
")",
"->",
"where",
"(",
"[",
"'service_name'",
"=>",
"$",
"service",
"->",
"getName",
"(",
")",
",",
"'service_id_author'",
"=>",
"$",
"data",
"[",
"'service_id_author'",
"]",
",",
"'service_id_post'",
"=>",
"$",
"data",
"[",
"'service_id_post'",
"]",
"]",
")",
"->",
"exists",
"(",
")",
";",
"}"
] |
@param SyncService $service
@param array $data
@return bool
|
[
"@param",
"SyncService",
"$service",
"@param",
"array",
"$data"
] |
train
|
https://github.com/ufocoder/yii2-SyncSocial/blob/2dbaaec2dad782c52fdd5b648a31ba7fe2a75e1b/src/components/Synchronizer.php#L268-L275
|
ufocoder/yii2-SyncSocial
|
src/components/Synchronizer.php
|
Synchronizer.isExistsSyncModelByActiveRecord
|
protected function isExistsSyncModelByActiveRecord( SyncService $service, ActiveRecord $model ) {
return SyncModel::find()->where( [
'model_id' => $model->getPrimaryKey(),
'service_name' => $service->getName()
] )->exists();
}
|
php
|
protected function isExistsSyncModelByActiveRecord( SyncService $service, ActiveRecord $model ) {
return SyncModel::find()->where( [
'model_id' => $model->getPrimaryKey(),
'service_name' => $service->getName()
] )->exists();
}
|
[
"protected",
"function",
"isExistsSyncModelByActiveRecord",
"(",
"SyncService",
"$",
"service",
",",
"ActiveRecord",
"$",
"model",
")",
"{",
"return",
"SyncModel",
"::",
"find",
"(",
")",
"->",
"where",
"(",
"[",
"'model_id'",
"=>",
"$",
"model",
"->",
"getPrimaryKey",
"(",
")",
",",
"'service_name'",
"=>",
"$",
"service",
"->",
"getName",
"(",
")",
"]",
")",
"->",
"exists",
"(",
")",
";",
"}"
] |
@param SyncService $service
@param ActiveRecord $model
@return bool
|
[
"@param",
"SyncService",
"$service",
"@param",
"ActiveRecord",
"$model"
] |
train
|
https://github.com/ufocoder/yii2-SyncSocial/blob/2dbaaec2dad782c52fdd5b648a31ba7fe2a75e1b/src/components/Synchronizer.php#L283-L289
|
ufocoder/yii2-SyncSocial
|
src/components/Synchronizer.php
|
Synchronizer.getSyncModel
|
protected function getSyncModel( SyncService $service, ActiveRecord $syncActiveRecord ) {
return $this->finSyncModel( [
'service_name' => $service->getName(),
'service_id_post' => $syncActiveRecord->getPrimaryKey()
] );
}
|
php
|
protected function getSyncModel( SyncService $service, ActiveRecord $syncActiveRecord ) {
return $this->finSyncModel( [
'service_name' => $service->getName(),
'service_id_post' => $syncActiveRecord->getPrimaryKey()
] );
}
|
[
"protected",
"function",
"getSyncModel",
"(",
"SyncService",
"$",
"service",
",",
"ActiveRecord",
"$",
"syncActiveRecord",
")",
"{",
"return",
"$",
"this",
"->",
"finSyncModel",
"(",
"[",
"'service_name'",
"=>",
"$",
"service",
"->",
"getName",
"(",
")",
",",
"'service_id_post'",
"=>",
"$",
"syncActiveRecord",
"->",
"getPrimaryKey",
"(",
")",
"]",
")",
";",
"}"
] |
@param SyncService $service
@param ActiveRecord $syncActiveRecord
@return array|null|SyncModel
|
[
"@param",
"SyncService",
"$service",
"@param",
"ActiveRecord",
"$syncActiveRecord"
] |
train
|
https://github.com/ufocoder/yii2-SyncSocial/blob/2dbaaec2dad782c52fdd5b648a31ba7fe2a75e1b/src/components/Synchronizer.php#L306-L312
|
ufocoder/yii2-SyncSocial
|
src/components/Synchronizer.php
|
Synchronizer.getSyncActiveRecord
|
protected function getSyncActiveRecord( SyncService $service, ActiveRecord $model ) {
return $this->finSyncModel( [
'model_id' => $model->getPrimaryKey(),
'service_name' => $service->getName()
] );
}
|
php
|
protected function getSyncActiveRecord( SyncService $service, ActiveRecord $model ) {
return $this->finSyncModel( [
'model_id' => $model->getPrimaryKey(),
'service_name' => $service->getName()
] );
}
|
[
"protected",
"function",
"getSyncActiveRecord",
"(",
"SyncService",
"$",
"service",
",",
"ActiveRecord",
"$",
"model",
")",
"{",
"return",
"$",
"this",
"->",
"finSyncModel",
"(",
"[",
"'model_id'",
"=>",
"$",
"model",
"->",
"getPrimaryKey",
"(",
")",
",",
"'service_name'",
"=>",
"$",
"service",
"->",
"getName",
"(",
")",
"]",
")",
";",
"}"
] |
@param SyncService $service
@param ActiveRecord $model
@return array|null|SyncModel
|
[
"@param",
"SyncService",
"$service",
"@param",
"ActiveRecord",
"$model"
] |
train
|
https://github.com/ufocoder/yii2-SyncSocial/blob/2dbaaec2dad782c52fdd5b648a31ba7fe2a75e1b/src/components/Synchronizer.php#L320-L326
|
ufocoder/yii2-SyncSocial
|
src/components/Synchronizer.php
|
Synchronizer.createSyncModel
|
protected function createSyncModel( SyncService $service, ActiveRecord $model, array $data = array() ) {
$syncModel = new SyncModel();
$syncModel->attributes = [
'model_id' => $model->getPrimaryKey(),
'service_name' => $service->getName(),
'service_id_author' => $data['service_id_author'],
'service_id_post' => $data['service_id_post'],
'time_created' => ! empty( $data['time_created'] ) ? $data['time_created'] : time(),
];
$flag = $syncModel->save();
if ( $syncModel->hasErrors() ) {
throw new InvalidConfigException( Yii::t( 'SyncSocial', 'Wrong sync model configuration for SyncSocial extension' ) );
}
return $flag;
}
|
php
|
protected function createSyncModel( SyncService $service, ActiveRecord $model, array $data = array() ) {
$syncModel = new SyncModel();
$syncModel->attributes = [
'model_id' => $model->getPrimaryKey(),
'service_name' => $service->getName(),
'service_id_author' => $data['service_id_author'],
'service_id_post' => $data['service_id_post'],
'time_created' => ! empty( $data['time_created'] ) ? $data['time_created'] : time(),
];
$flag = $syncModel->save();
if ( $syncModel->hasErrors() ) {
throw new InvalidConfigException( Yii::t( 'SyncSocial', 'Wrong sync model configuration for SyncSocial extension' ) );
}
return $flag;
}
|
[
"protected",
"function",
"createSyncModel",
"(",
"SyncService",
"$",
"service",
",",
"ActiveRecord",
"$",
"model",
",",
"array",
"$",
"data",
"=",
"array",
"(",
")",
")",
"{",
"$",
"syncModel",
"=",
"new",
"SyncModel",
"(",
")",
";",
"$",
"syncModel",
"->",
"attributes",
"=",
"[",
"'model_id'",
"=>",
"$",
"model",
"->",
"getPrimaryKey",
"(",
")",
",",
"'service_name'",
"=>",
"$",
"service",
"->",
"getName",
"(",
")",
",",
"'service_id_author'",
"=>",
"$",
"data",
"[",
"'service_id_author'",
"]",
",",
"'service_id_post'",
"=>",
"$",
"data",
"[",
"'service_id_post'",
"]",
",",
"'time_created'",
"=>",
"!",
"empty",
"(",
"$",
"data",
"[",
"'time_created'",
"]",
")",
"?",
"$",
"data",
"[",
"'time_created'",
"]",
":",
"time",
"(",
")",
",",
"]",
";",
"$",
"flag",
"=",
"$",
"syncModel",
"->",
"save",
"(",
")",
";",
"if",
"(",
"$",
"syncModel",
"->",
"hasErrors",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidConfigException",
"(",
"Yii",
"::",
"t",
"(",
"'SyncSocial'",
",",
"'Wrong sync model configuration for SyncSocial extension'",
")",
")",
";",
"}",
"return",
"$",
"flag",
";",
"}"
] |
@param SyncService $service
@param ActiveRecord $model
@param array $data
@return bool
@throws Exception
|
[
"@param",
"SyncService",
"$service",
"@param",
"ActiveRecord",
"$model",
"@param",
"array",
"$data"
] |
train
|
https://github.com/ufocoder/yii2-SyncSocial/blob/2dbaaec2dad782c52fdd5b648a31ba7fe2a75e1b/src/components/Synchronizer.php#L336-L354
|
ufocoder/yii2-SyncSocial
|
src/components/Synchronizer.php
|
Synchronizer.deleteSyncModel
|
public function deleteSyncModel( $serviceName, ActiveRecord $model, $flagSync = false ) {
$service = $this->getService( $serviceName );
$syncActiveRecord = $this->getSyncActiveRecord( $service, $model );
if ( ! $syncActiveRecord instanceof SyncModel ) {
return false;
}
$syncModel = $this->getSyncModel( $service, $syncActiveRecord );
$flagActiveRecord = (bool) $syncActiveRecord->delete();
if ( $syncModel !== null && $flagActiveRecord ) {
$flagModel = (bool) $syncModel->delete();
if ( $flagModel && $flagSync ) {
return $service->deletePost( $syncModel->service_id_post );
} else {
return $flagModel;
}
} else {
return $flagActiveRecord;
}
}
|
php
|
public function deleteSyncModel( $serviceName, ActiveRecord $model, $flagSync = false ) {
$service = $this->getService( $serviceName );
$syncActiveRecord = $this->getSyncActiveRecord( $service, $model );
if ( ! $syncActiveRecord instanceof SyncModel ) {
return false;
}
$syncModel = $this->getSyncModel( $service, $syncActiveRecord );
$flagActiveRecord = (bool) $syncActiveRecord->delete();
if ( $syncModel !== null && $flagActiveRecord ) {
$flagModel = (bool) $syncModel->delete();
if ( $flagModel && $flagSync ) {
return $service->deletePost( $syncModel->service_id_post );
} else {
return $flagModel;
}
} else {
return $flagActiveRecord;
}
}
|
[
"public",
"function",
"deleteSyncModel",
"(",
"$",
"serviceName",
",",
"ActiveRecord",
"$",
"model",
",",
"$",
"flagSync",
"=",
"false",
")",
"{",
"$",
"service",
"=",
"$",
"this",
"->",
"getService",
"(",
"$",
"serviceName",
")",
";",
"$",
"syncActiveRecord",
"=",
"$",
"this",
"->",
"getSyncActiveRecord",
"(",
"$",
"service",
",",
"$",
"model",
")",
";",
"if",
"(",
"!",
"$",
"syncActiveRecord",
"instanceof",
"SyncModel",
")",
"{",
"return",
"false",
";",
"}",
"$",
"syncModel",
"=",
"$",
"this",
"->",
"getSyncModel",
"(",
"$",
"service",
",",
"$",
"syncActiveRecord",
")",
";",
"$",
"flagActiveRecord",
"=",
"(",
"bool",
")",
"$",
"syncActiveRecord",
"->",
"delete",
"(",
")",
";",
"if",
"(",
"$",
"syncModel",
"!==",
"null",
"&&",
"$",
"flagActiveRecord",
")",
"{",
"$",
"flagModel",
"=",
"(",
"bool",
")",
"$",
"syncModel",
"->",
"delete",
"(",
")",
";",
"if",
"(",
"$",
"flagModel",
"&&",
"$",
"flagSync",
")",
"{",
"return",
"$",
"service",
"->",
"deletePost",
"(",
"$",
"syncModel",
"->",
"service_id_post",
")",
";",
"}",
"else",
"{",
"return",
"$",
"flagModel",
";",
"}",
"}",
"else",
"{",
"return",
"$",
"flagActiveRecord",
";",
"}",
"}"
] |
@param $serviceName
@param ActiveRecord $model
@param bool $flagSync
@return bool
|
[
"@param",
"$serviceName",
"@param",
"ActiveRecord",
"$model",
"@param",
"bool",
"$flagSync"
] |
train
|
https://github.com/ufocoder/yii2-SyncSocial/blob/2dbaaec2dad782c52fdd5b648a31ba7fe2a75e1b/src/components/Synchronizer.php#L363-L388
|
ufocoder/yii2-SyncSocial
|
src/components/Synchronizer.php
|
Synchronizer.syncService
|
public function syncService( $serviceName = null ) {
$flag = false;
$count = 0;
$service = $this->getService( $serviceName );
$postData = $service->getPosts();
if ( $postData !== null ) {
$flag = true;
foreach ( $postData as $data ) {
if ( $this->checkPostData( $data ) && ! $this->isExistsSyncModelByData( $service, $data ) ) {
$model = $this->createModel( $data );
if ( $this->createSyncModel( $service, $model, $data ) ) {
$count ++;
}
}
}
}
return [
'flag' => $flag,
'count' => $count
];
}
|
php
|
public function syncService( $serviceName = null ) {
$flag = false;
$count = 0;
$service = $this->getService( $serviceName );
$postData = $service->getPosts();
if ( $postData !== null ) {
$flag = true;
foreach ( $postData as $data ) {
if ( $this->checkPostData( $data ) && ! $this->isExistsSyncModelByData( $service, $data ) ) {
$model = $this->createModel( $data );
if ( $this->createSyncModel( $service, $model, $data ) ) {
$count ++;
}
}
}
}
return [
'flag' => $flag,
'count' => $count
];
}
|
[
"public",
"function",
"syncService",
"(",
"$",
"serviceName",
"=",
"null",
")",
"{",
"$",
"flag",
"=",
"false",
";",
"$",
"count",
"=",
"0",
";",
"$",
"service",
"=",
"$",
"this",
"->",
"getService",
"(",
"$",
"serviceName",
")",
";",
"$",
"postData",
"=",
"$",
"service",
"->",
"getPosts",
"(",
")",
";",
"if",
"(",
"$",
"postData",
"!==",
"null",
")",
"{",
"$",
"flag",
"=",
"true",
";",
"foreach",
"(",
"$",
"postData",
"as",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"checkPostData",
"(",
"$",
"data",
")",
"&&",
"!",
"$",
"this",
"->",
"isExistsSyncModelByData",
"(",
"$",
"service",
",",
"$",
"data",
")",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"createModel",
"(",
"$",
"data",
")",
";",
"if",
"(",
"$",
"this",
"->",
"createSyncModel",
"(",
"$",
"service",
",",
"$",
"model",
",",
"$",
"data",
")",
")",
"{",
"$",
"count",
"++",
";",
"}",
"}",
"}",
"}",
"return",
"[",
"'flag'",
"=>",
"$",
"flag",
",",
"'count'",
"=>",
"$",
"count",
"]",
";",
"}"
] |
@param null $serviceName
@return bool
@throws Exception
@throws InvalidConfigException
|
[
"@param",
"null",
"$serviceName"
] |
train
|
https://github.com/ufocoder/yii2-SyncSocial/blob/2dbaaec2dad782c52fdd5b648a31ba7fe2a75e1b/src/components/Synchronizer.php#L397-L422
|
ufocoder/yii2-SyncSocial
|
src/components/Synchronizer.php
|
Synchronizer.syncActiveRecord
|
public function syncActiveRecord( $serviceName = null, ActiveRecord $model ) {
$service = $this->getService( $serviceName );
if ( $service->isConnected() && ! $this->isExistsSyncModelByActiveRecord( $service, $model ) ) {
$message = $model->{$this->modelAttribute};
$function = $this->absolutePostUrl;
$url = null;
if ( is_callable( $function ) && ( $function instanceof Closure ) ) {
$url = $function( $serviceName, $model->getPrimaryKey() );
}
$publishData = $service->publishPost( $message, $url );
return $this->checkPostData( $publishData ) && $this->createSyncModel( $service, $model, $publishData );
} else {
return false;
}
}
|
php
|
public function syncActiveRecord( $serviceName = null, ActiveRecord $model ) {
$service = $this->getService( $serviceName );
if ( $service->isConnected() && ! $this->isExistsSyncModelByActiveRecord( $service, $model ) ) {
$message = $model->{$this->modelAttribute};
$function = $this->absolutePostUrl;
$url = null;
if ( is_callable( $function ) && ( $function instanceof Closure ) ) {
$url = $function( $serviceName, $model->getPrimaryKey() );
}
$publishData = $service->publishPost( $message, $url );
return $this->checkPostData( $publishData ) && $this->createSyncModel( $service, $model, $publishData );
} else {
return false;
}
}
|
[
"public",
"function",
"syncActiveRecord",
"(",
"$",
"serviceName",
"=",
"null",
",",
"ActiveRecord",
"$",
"model",
")",
"{",
"$",
"service",
"=",
"$",
"this",
"->",
"getService",
"(",
"$",
"serviceName",
")",
";",
"if",
"(",
"$",
"service",
"->",
"isConnected",
"(",
")",
"&&",
"!",
"$",
"this",
"->",
"isExistsSyncModelByActiveRecord",
"(",
"$",
"service",
",",
"$",
"model",
")",
")",
"{",
"$",
"message",
"=",
"$",
"model",
"->",
"{",
"$",
"this",
"->",
"modelAttribute",
"}",
";",
"$",
"function",
"=",
"$",
"this",
"->",
"absolutePostUrl",
";",
"$",
"url",
"=",
"null",
";",
"if",
"(",
"is_callable",
"(",
"$",
"function",
")",
"&&",
"(",
"$",
"function",
"instanceof",
"Closure",
")",
")",
"{",
"$",
"url",
"=",
"$",
"function",
"(",
"$",
"serviceName",
",",
"$",
"model",
"->",
"getPrimaryKey",
"(",
")",
")",
";",
"}",
"$",
"publishData",
"=",
"$",
"service",
"->",
"publishPost",
"(",
"$",
"message",
",",
"$",
"url",
")",
";",
"return",
"$",
"this",
"->",
"checkPostData",
"(",
"$",
"publishData",
")",
"&&",
"$",
"this",
"->",
"createSyncModel",
"(",
"$",
"service",
",",
"$",
"model",
",",
"$",
"publishData",
")",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Post message with URL to Social Network
@param null $serviceName
@param \yii\db\ActiveRecord $model
@return bool
|
[
"Post",
"message",
"with",
"URL",
"to",
"Social",
"Network"
] |
train
|
https://github.com/ufocoder/yii2-SyncSocial/blob/2dbaaec2dad782c52fdd5b648a31ba7fe2a75e1b/src/components/Synchronizer.php#L432-L453
|
webforge-labs/psc-cms
|
lib/Psc/Code/Event/Manager.php
|
Manager.dispatch
|
public function dispatch(Event $event) {
foreach ($this->getSubscribers($event) as $subscriber) {
$subscriber->trigger($event);
}
return $this;
}
|
php
|
public function dispatch(Event $event) {
foreach ($this->getSubscribers($event) as $subscriber) {
$subscriber->trigger($event);
}
return $this;
}
|
[
"public",
"function",
"dispatch",
"(",
"Event",
"$",
"event",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getSubscribers",
"(",
"$",
"event",
")",
"as",
"$",
"subscriber",
")",
"{",
"$",
"subscriber",
"->",
"trigger",
"(",
"$",
"event",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Dispatched ein Event
@chainable
|
[
"Dispatched",
"ein",
"Event"
] |
train
|
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Code/Event/Manager.php#L13-L20
|
webforge-labs/psc-cms
|
lib/Psc/Code/Event/Manager.php
|
Manager.dispatchEvent
|
public function dispatchEvent($eventName, $eventData = NULL, $target = NULL) {
$event = new Event($eventName,$target);
$event->setData($eventData);
$this->dispatch($event);
return $event;
}
|
php
|
public function dispatchEvent($eventName, $eventData = NULL, $target = NULL) {
$event = new Event($eventName,$target);
$event->setData($eventData);
$this->dispatch($event);
return $event;
}
|
[
"public",
"function",
"dispatchEvent",
"(",
"$",
"eventName",
",",
"$",
"eventData",
"=",
"NULL",
",",
"$",
"target",
"=",
"NULL",
")",
"{",
"$",
"event",
"=",
"new",
"Event",
"(",
"$",
"eventName",
",",
"$",
"target",
")",
";",
"$",
"event",
"->",
"setData",
"(",
"$",
"eventData",
")",
";",
"$",
"this",
"->",
"dispatch",
"(",
"$",
"event",
")",
";",
"return",
"$",
"event",
";",
"}"
] |
Dispatched ein (nicht erstelltes) Event
$manager->dispatchEvent('Psc.SourceFileChanged', array('file'=>'D:\www\psc-cms\Umsetzung\base\src\PSC.php'), $this);
ist dasselbe wie
$event = new Event('Psc.SourceFileChanged',$this);
$manager->dispatch($event);
anders als dispatch() gibt dies das erstellte Event zurück (dieses ist dann aber schon dispatched)
@return Psc\Code\Event\Event
|
[
"Dispatched",
"ein",
"(",
"nicht",
"erstelltes",
")",
"Event"
] |
train
|
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Code/Event/Manager.php#L34-L40
|
webforge-labs/psc-cms
|
lib/Psc/Code/Event/Manager.php
|
Manager.bind
|
public function bind(Subscriber $subscriber, $eventIdentifier) {
if ($eventIdentifier instanceof Event) {
$eventIdentifier = $eventIdentifier->getIdentifier();
}
if (!isset($this->subscribers[$eventIdentifier]))
$this->subscribers[$eventIdentifier] = array();
$this->subscribers[$eventIdentifier][] = $subscriber;
return $this;
}
|
php
|
public function bind(Subscriber $subscriber, $eventIdentifier) {
if ($eventIdentifier instanceof Event) {
$eventIdentifier = $eventIdentifier->getIdentifier();
}
if (!isset($this->subscribers[$eventIdentifier]))
$this->subscribers[$eventIdentifier] = array();
$this->subscribers[$eventIdentifier][] = $subscriber;
return $this;
}
|
[
"public",
"function",
"bind",
"(",
"Subscriber",
"$",
"subscriber",
",",
"$",
"eventIdentifier",
")",
"{",
"if",
"(",
"$",
"eventIdentifier",
"instanceof",
"Event",
")",
"{",
"$",
"eventIdentifier",
"=",
"$",
"eventIdentifier",
"->",
"getIdentifier",
"(",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"subscribers",
"[",
"$",
"eventIdentifier",
"]",
")",
")",
"$",
"this",
"->",
"subscribers",
"[",
"$",
"eventIdentifier",
"]",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"subscribers",
"[",
"$",
"eventIdentifier",
"]",
"[",
"]",
"=",
"$",
"subscriber",
";",
"return",
"$",
"this",
";",
"}"
] |
Bindet den Subscriber an einen Event(Typ)
Wenn das Event dann dispatched wird, wird der subscriber mit trigger() benachrichtigt
@param $eventIdentifier kann NULL sein für alle Event-Typen
|
[
"Bindet",
"den",
"Subscriber",
"an",
"einen",
"Event",
"(",
"Typ",
")"
] |
train
|
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Code/Event/Manager.php#L48-L59
|
ClanCats/Core
|
src/bundles/Auth/Handler.php
|
Handler.create
|
public static function create( $name = null, $conf = null )
{
if ( is_null( $name ) )
{
$name = static::$_default;
}
if ( !is_null( $conf ) && is_array( $conf ) )
{
return static::$_instances[$name] = new static( $name, $conf );
}
if ( !isset( static::$_instances[$name] ) )
{
static::$_instances[$name] = new static( $name );
}
return static::$_instances[$name];
}
|
php
|
public static function create( $name = null, $conf = null )
{
if ( is_null( $name ) )
{
$name = static::$_default;
}
if ( !is_null( $conf ) && is_array( $conf ) )
{
return static::$_instances[$name] = new static( $name, $conf );
}
if ( !isset( static::$_instances[$name] ) )
{
static::$_instances[$name] = new static( $name );
}
return static::$_instances[$name];
}
|
[
"public",
"static",
"function",
"create",
"(",
"$",
"name",
"=",
"null",
",",
"$",
"conf",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"name",
")",
")",
"{",
"$",
"name",
"=",
"static",
"::",
"$",
"_default",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"conf",
")",
"&&",
"is_array",
"(",
"$",
"conf",
")",
")",
"{",
"return",
"static",
"::",
"$",
"_instances",
"[",
"$",
"name",
"]",
"=",
"new",
"static",
"(",
"$",
"name",
",",
"$",
"conf",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"static",
"::",
"$",
"_instances",
"[",
"$",
"name",
"]",
")",
")",
"{",
"static",
"::",
"$",
"_instances",
"[",
"$",
"name",
"]",
"=",
"new",
"static",
"(",
"$",
"name",
")",
";",
"}",
"return",
"static",
"::",
"$",
"_instances",
"[",
"$",
"name",
"]",
";",
"}"
] |
Get an auth instance or create one
@param string $name
@param array $conf You can pass optionally a configuration directly. This will overwrite.
@return Auth_Handler
|
[
"Get",
"an",
"auth",
"instance",
"or",
"create",
"one"
] |
train
|
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Auth/Handler.php#L38-L56
|
ClanCats/Core
|
src/bundles/Auth/Handler.php
|
Handler.kill_restore
|
public function kill_restore()
{
CCCookie::delete( $this->config->get( 'restore.id_cookie' ) );
CCCookie::delete( $this->config->get( 'restore.token_cookie' ) );
}
|
php
|
public function kill_restore()
{
CCCookie::delete( $this->config->get( 'restore.id_cookie' ) );
CCCookie::delete( $this->config->get( 'restore.token_cookie' ) );
}
|
[
"public",
"function",
"kill_restore",
"(",
")",
"{",
"CCCookie",
"::",
"delete",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'restore.id_cookie'",
")",
")",
";",
"CCCookie",
"::",
"delete",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'restore.token_cookie'",
")",
")",
";",
"}"
] |
Kill the restore keys
@return void
|
[
"Kill",
"the",
"restore",
"keys"
] |
train
|
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Auth/Handler.php#L266-L270
|
ClanCats/Core
|
src/bundles/Auth/Handler.php
|
Handler.restore_key
|
public function restore_key( $user )
{
return \CCStr::hash( $user->password.'@'.$user->{$this->config->user_key}.'%'.\CCIn::client()->agent );
}
|
php
|
public function restore_key( $user )
{
return \CCStr::hash( $user->password.'@'.$user->{$this->config->user_key}.'%'.\CCIn::client()->agent );
}
|
[
"public",
"function",
"restore_key",
"(",
"$",
"user",
")",
"{",
"return",
"\\",
"CCStr",
"::",
"hash",
"(",
"$",
"user",
"->",
"password",
".",
"'@'",
".",
"$",
"user",
"->",
"{",
"$",
"this",
"->",
"config",
"->",
"user_key",
"}",
".",
"'%'",
".",
"\\",
"CCIn",
"::",
"client",
"(",
")",
"->",
"agent",
")",
";",
"}"
] |
generate the current restore key
@param User $user
@return string
|
[
"generate",
"the",
"current",
"restore",
"key"
] |
train
|
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Auth/Handler.php#L298-L301
|
ClanCats/Core
|
src/bundles/Auth/Handler.php
|
Handler.login
|
public function login()
{
return $this->select_logins()
->where( 'restore_id', $this->user->{$this->config->user_key} )
->where( 'restore_token', $this->restore_key( $this->user ) )
->limit( 1 )
->run();
}
|
php
|
public function login()
{
return $this->select_logins()
->where( 'restore_id', $this->user->{$this->config->user_key} )
->where( 'restore_token', $this->restore_key( $this->user ) )
->limit( 1 )
->run();
}
|
[
"public",
"function",
"login",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"select_logins",
"(",
")",
"->",
"where",
"(",
"'restore_id'",
",",
"$",
"this",
"->",
"user",
"->",
"{",
"$",
"this",
"->",
"config",
"->",
"user_key",
"}",
")",
"->",
"where",
"(",
"'restore_token'",
",",
"$",
"this",
"->",
"restore_key",
"(",
"$",
"this",
"->",
"user",
")",
")",
"->",
"limit",
"(",
"1",
")",
"->",
"run",
"(",
")",
";",
"}"
] |
Get the current login of the user
@return stdObject|null
|
[
"Get",
"the",
"current",
"login",
"of",
"the",
"user"
] |
train
|
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Auth/Handler.php#L322-L329
|
ClanCats/Core
|
src/bundles/Auth/Handler.php
|
Handler.validate
|
public function validate( $identifier, $password )
{
$user = null;
$user_model = $this->config->user_model;
foreach( $this->config->identifiers as $property )
{
if ( $user = $user_model::find( $property, $identifier ) )
{
break;
}
}
// when could not find a user matching the identifiers return false
if ( !$user )
{
return false;
}
// in case the user has no password set always return false
// you might implement a oauth login so you dont need to set a
// password but this makes sure that validating fails the password fails
if ( empty( $user->password ) )
{
return false;
}
// when the passwords match return the user object
if ( \CCStr::verify_hash( $password, $user->password ))
{
return $user;
}
// otherwise return false
return false;
}
|
php
|
public function validate( $identifier, $password )
{
$user = null;
$user_model = $this->config->user_model;
foreach( $this->config->identifiers as $property )
{
if ( $user = $user_model::find( $property, $identifier ) )
{
break;
}
}
// when could not find a user matching the identifiers return false
if ( !$user )
{
return false;
}
// in case the user has no password set always return false
// you might implement a oauth login so you dont need to set a
// password but this makes sure that validating fails the password fails
if ( empty( $user->password ) )
{
return false;
}
// when the passwords match return the user object
if ( \CCStr::verify_hash( $password, $user->password ))
{
return $user;
}
// otherwise return false
return false;
}
|
[
"public",
"function",
"validate",
"(",
"$",
"identifier",
",",
"$",
"password",
")",
"{",
"$",
"user",
"=",
"null",
";",
"$",
"user_model",
"=",
"$",
"this",
"->",
"config",
"->",
"user_model",
";",
"foreach",
"(",
"$",
"this",
"->",
"config",
"->",
"identifiers",
"as",
"$",
"property",
")",
"{",
"if",
"(",
"$",
"user",
"=",
"$",
"user_model",
"::",
"find",
"(",
"$",
"property",
",",
"$",
"identifier",
")",
")",
"{",
"break",
";",
"}",
"}",
"// when could not find a user matching the identifiers return false",
"if",
"(",
"!",
"$",
"user",
")",
"{",
"return",
"false",
";",
"}",
"// in case the user has no password set always return false",
"// you might implement a oauth login so you dont need to set a ",
"// password but this makes sure that validating fails the password fails",
"if",
"(",
"empty",
"(",
"$",
"user",
"->",
"password",
")",
")",
"{",
"return",
"false",
";",
"}",
"// when the passwords match return the user object",
"if",
"(",
"\\",
"CCStr",
"::",
"verify_hash",
"(",
"$",
"password",
",",
"$",
"user",
"->",
"password",
")",
")",
"{",
"return",
"$",
"user",
";",
"}",
"// otherwise return false",
"return",
"false",
";",
"}"
] |
Validate an identifier with the password
In other words is the login correct?
@param string $identifier
@param string $password
@return mixed false on failure, user object on success
|
[
"Validate",
"an",
"identifier",
"with",
"the",
"password",
"In",
"other",
"words",
"is",
"the",
"login",
"correct?"
] |
train
|
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Auth/Handler.php#L339-L374
|
ClanCats/Core
|
src/bundles/Auth/Handler.php
|
Handler.sign_in
|
public function sign_in( \Auth\User $user, $keep_login = true )
{
// set the session key so the session knows we are logged in
$this->session->set( $this->config->session_key, $user->{$this->config->user_key} );
// update the current user object
$this->user = $user;
// update the last login timestamp
$this->user->last_login = time();
// pass the user trough the events to allow modifications
// of the user object at sign in
$this->user = \CCEvent::pass( 'auth.sign_in', $this->user );
// save the user object to the database
$this->user->save();
// set the restore keys to keep the login
// after the session ends
if ( $keep_login )
{
$restore_id_cookie = $this->config->get( 'restore.id_cookie' );
$restore_token_cookie = $this->config->get( 'restore.token_cookie' );
$restore_lifetime = $this->config->get( 'restore.lifetime' );
$restore_id = $this->session->get( $this->config->session_key );
$restore_token = $this->restore_key( $this->user );
CCCookie::set( $restore_id_cookie, $restore_id, $restore_lifetime );
CCCookie::set( $restore_token_cookie, $restore_token, $restore_lifetime );
// try to get the current login
$login = $this->select_logins()
->where( 'restore_id', $restore_id )
->where( 'restore_token', $restore_token );
// prepare the login data
$login_data = array(
'restore_id' => $restore_id,
'restore_token' => $restore_token,
'last_login' => time(),
'client_agent' => \CCIn::client()->agent,
);
// pass the login data trough the events
$login_data = \CCEvent::pass( 'auth.store_login', $login_data );
// if there is no such login create a new one
if ( !$login->run() )
{
\DB::insert( $this->config->get( 'logins.table' ), $login_data )
->run( $this->config->get( 'logins.handler' ) );
}
else
{
\DB::update( $this->config->get( 'logins.table' ), $login_data )
->where( 'restore_id', $restore_id )
->where( 'restore_token', $restore_token )
->run( $this->config->get( 'logins.handler' ) );
}
}
// and finally we are authenticated
return $this->authenticated = true;
}
|
php
|
public function sign_in( \Auth\User $user, $keep_login = true )
{
// set the session key so the session knows we are logged in
$this->session->set( $this->config->session_key, $user->{$this->config->user_key} );
// update the current user object
$this->user = $user;
// update the last login timestamp
$this->user->last_login = time();
// pass the user trough the events to allow modifications
// of the user object at sign in
$this->user = \CCEvent::pass( 'auth.sign_in', $this->user );
// save the user object to the database
$this->user->save();
// set the restore keys to keep the login
// after the session ends
if ( $keep_login )
{
$restore_id_cookie = $this->config->get( 'restore.id_cookie' );
$restore_token_cookie = $this->config->get( 'restore.token_cookie' );
$restore_lifetime = $this->config->get( 'restore.lifetime' );
$restore_id = $this->session->get( $this->config->session_key );
$restore_token = $this->restore_key( $this->user );
CCCookie::set( $restore_id_cookie, $restore_id, $restore_lifetime );
CCCookie::set( $restore_token_cookie, $restore_token, $restore_lifetime );
// try to get the current login
$login = $this->select_logins()
->where( 'restore_id', $restore_id )
->where( 'restore_token', $restore_token );
// prepare the login data
$login_data = array(
'restore_id' => $restore_id,
'restore_token' => $restore_token,
'last_login' => time(),
'client_agent' => \CCIn::client()->agent,
);
// pass the login data trough the events
$login_data = \CCEvent::pass( 'auth.store_login', $login_data );
// if there is no such login create a new one
if ( !$login->run() )
{
\DB::insert( $this->config->get( 'logins.table' ), $login_data )
->run( $this->config->get( 'logins.handler' ) );
}
else
{
\DB::update( $this->config->get( 'logins.table' ), $login_data )
->where( 'restore_id', $restore_id )
->where( 'restore_token', $restore_token )
->run( $this->config->get( 'logins.handler' ) );
}
}
// and finally we are authenticated
return $this->authenticated = true;
}
|
[
"public",
"function",
"sign_in",
"(",
"\\",
"Auth",
"\\",
"User",
"$",
"user",
",",
"$",
"keep_login",
"=",
"true",
")",
"{",
"// set the session key so the session knows we are logged in",
"$",
"this",
"->",
"session",
"->",
"set",
"(",
"$",
"this",
"->",
"config",
"->",
"session_key",
",",
"$",
"user",
"->",
"{",
"$",
"this",
"->",
"config",
"->",
"user_key",
"}",
")",
";",
"// update the current user object",
"$",
"this",
"->",
"user",
"=",
"$",
"user",
";",
"// update the last login timestamp",
"$",
"this",
"->",
"user",
"->",
"last_login",
"=",
"time",
"(",
")",
";",
"// pass the user trough the events to allow modifications",
"// of the user object at sign in",
"$",
"this",
"->",
"user",
"=",
"\\",
"CCEvent",
"::",
"pass",
"(",
"'auth.sign_in'",
",",
"$",
"this",
"->",
"user",
")",
";",
"// save the user object to the database ",
"$",
"this",
"->",
"user",
"->",
"save",
"(",
")",
";",
"// set the restore keys to keep the login",
"// after the session ends",
"if",
"(",
"$",
"keep_login",
")",
"{",
"$",
"restore_id_cookie",
"=",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'restore.id_cookie'",
")",
";",
"$",
"restore_token_cookie",
"=",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'restore.token_cookie'",
")",
";",
"$",
"restore_lifetime",
"=",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'restore.lifetime'",
")",
";",
"$",
"restore_id",
"=",
"$",
"this",
"->",
"session",
"->",
"get",
"(",
"$",
"this",
"->",
"config",
"->",
"session_key",
")",
";",
"$",
"restore_token",
"=",
"$",
"this",
"->",
"restore_key",
"(",
"$",
"this",
"->",
"user",
")",
";",
"CCCookie",
"::",
"set",
"(",
"$",
"restore_id_cookie",
",",
"$",
"restore_id",
",",
"$",
"restore_lifetime",
")",
";",
"CCCookie",
"::",
"set",
"(",
"$",
"restore_token_cookie",
",",
"$",
"restore_token",
",",
"$",
"restore_lifetime",
")",
";",
"// try to get the current login",
"$",
"login",
"=",
"$",
"this",
"->",
"select_logins",
"(",
")",
"->",
"where",
"(",
"'restore_id'",
",",
"$",
"restore_id",
")",
"->",
"where",
"(",
"'restore_token'",
",",
"$",
"restore_token",
")",
";",
"// prepare the login data",
"$",
"login_data",
"=",
"array",
"(",
"'restore_id'",
"=>",
"$",
"restore_id",
",",
"'restore_token'",
"=>",
"$",
"restore_token",
",",
"'last_login'",
"=>",
"time",
"(",
")",
",",
"'client_agent'",
"=>",
"\\",
"CCIn",
"::",
"client",
"(",
")",
"->",
"agent",
",",
")",
";",
"// pass the login data trough the events",
"$",
"login_data",
"=",
"\\",
"CCEvent",
"::",
"pass",
"(",
"'auth.store_login'",
",",
"$",
"login_data",
")",
";",
"// if there is no such login create a new one",
"if",
"(",
"!",
"$",
"login",
"->",
"run",
"(",
")",
")",
"{",
"\\",
"DB",
"::",
"insert",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'logins.table'",
")",
",",
"$",
"login_data",
")",
"->",
"run",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'logins.handler'",
")",
")",
";",
"}",
"else",
"{",
"\\",
"DB",
"::",
"update",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'logins.table'",
")",
",",
"$",
"login_data",
")",
"->",
"where",
"(",
"'restore_id'",
",",
"$",
"restore_id",
")",
"->",
"where",
"(",
"'restore_token'",
",",
"$",
"restore_token",
")",
"->",
"run",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'logins.handler'",
")",
")",
";",
"}",
"}",
"// and finally we are authenticated",
"return",
"$",
"this",
"->",
"authenticated",
"=",
"true",
";",
"}"
] |
Sign the user and optinal also set the resore keys
@param Auth\User $user
@param bool $keep_login
@return bool
|
[
"Sign",
"the",
"user",
"and",
"optinal",
"also",
"set",
"the",
"resore",
"keys"
] |
train
|
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Auth/Handler.php#L383-L449
|
ClanCats/Core
|
src/bundles/Auth/Handler.php
|
Handler.sign_out
|
public function sign_out() {
if ( !$this->authenticated )
{
return false;
}
// remove the restore login
\DB::delete( $this->config->get( 'logins.table' ) )
->where( 'restore_token', $this->restore_key( $this->user ) )
->run();
// logout the user
$this->session->delete( $this->config->session_key );
// pass the user object through all user hooks
$this->user = \CCEvent::pass( 'auth.sign_out', $this->user );
$this->user->save();
$user_model = $this->config->user_model;
// create new empty user
$this->user = new $user_model;
return $this->authenticated = false;
}
|
php
|
public function sign_out() {
if ( !$this->authenticated )
{
return false;
}
// remove the restore login
\DB::delete( $this->config->get( 'logins.table' ) )
->where( 'restore_token', $this->restore_key( $this->user ) )
->run();
// logout the user
$this->session->delete( $this->config->session_key );
// pass the user object through all user hooks
$this->user = \CCEvent::pass( 'auth.sign_out', $this->user );
$this->user->save();
$user_model = $this->config->user_model;
// create new empty user
$this->user = new $user_model;
return $this->authenticated = false;
}
|
[
"public",
"function",
"sign_out",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"authenticated",
")",
"{",
"return",
"false",
";",
"}",
"// remove the restore login",
"\\",
"DB",
"::",
"delete",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'logins.table'",
")",
")",
"->",
"where",
"(",
"'restore_token'",
",",
"$",
"this",
"->",
"restore_key",
"(",
"$",
"this",
"->",
"user",
")",
")",
"->",
"run",
"(",
")",
";",
"// logout the user",
"$",
"this",
"->",
"session",
"->",
"delete",
"(",
"$",
"this",
"->",
"config",
"->",
"session_key",
")",
";",
"// pass the user object through all user hooks",
"$",
"this",
"->",
"user",
"=",
"\\",
"CCEvent",
"::",
"pass",
"(",
"'auth.sign_out'",
",",
"$",
"this",
"->",
"user",
")",
";",
"$",
"this",
"->",
"user",
"->",
"save",
"(",
")",
";",
"$",
"user_model",
"=",
"$",
"this",
"->",
"config",
"->",
"user_model",
";",
"// create new empty user",
"$",
"this",
"->",
"user",
"=",
"new",
"$",
"user_model",
";",
"return",
"$",
"this",
"->",
"authenticated",
"=",
"false",
";",
"}"
] |
Sign a user out
@param id $user_id
@param string $name
@return false
|
[
"Sign",
"a",
"user",
"out"
] |
train
|
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Auth/Handler.php#L458-L483
|
ripaclub/zf2-sphinxsearch-tool
|
src/Source/Writer/XML2.php
|
XML2.beginOutput
|
public function beginOutput()
{
$this->startDocument('1.0', 'UTF-8');
$this->startElement('sphinx:docset');
$this->startElement('sphinx:schema');
// Add fields to the schema
foreach ($this->fields as $fields) {
$this->startElement('sphinx:field');
foreach ($fields as $key => $value) {
$this->writeAttribute($key, $value);
}
$this->endElement();
}
// Add attributes to the schema
foreach ($this->attributes as $attributes) {
$this->startElement('sphinx:attr');
foreach ($attributes as $key => $value) {
$this->writeAttribute($key, $value);
}
$this->endElement();
}
// End sphinx:schema
$this->endElement();
$return = $this->outputMemory();
$this->flush();
return $return;
}
|
php
|
public function beginOutput()
{
$this->startDocument('1.0', 'UTF-8');
$this->startElement('sphinx:docset');
$this->startElement('sphinx:schema');
// Add fields to the schema
foreach ($this->fields as $fields) {
$this->startElement('sphinx:field');
foreach ($fields as $key => $value) {
$this->writeAttribute($key, $value);
}
$this->endElement();
}
// Add attributes to the schema
foreach ($this->attributes as $attributes) {
$this->startElement('sphinx:attr');
foreach ($attributes as $key => $value) {
$this->writeAttribute($key, $value);
}
$this->endElement();
}
// End sphinx:schema
$this->endElement();
$return = $this->outputMemory();
$this->flush();
return $return;
}
|
[
"public",
"function",
"beginOutput",
"(",
")",
"{",
"$",
"this",
"->",
"startDocument",
"(",
"'1.0'",
",",
"'UTF-8'",
")",
";",
"$",
"this",
"->",
"startElement",
"(",
"'sphinx:docset'",
")",
";",
"$",
"this",
"->",
"startElement",
"(",
"'sphinx:schema'",
")",
";",
"// Add fields to the schema",
"foreach",
"(",
"$",
"this",
"->",
"fields",
"as",
"$",
"fields",
")",
"{",
"$",
"this",
"->",
"startElement",
"(",
"'sphinx:field'",
")",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"writeAttribute",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"$",
"this",
"->",
"endElement",
"(",
")",
";",
"}",
"// Add attributes to the schema",
"foreach",
"(",
"$",
"this",
"->",
"attributes",
"as",
"$",
"attributes",
")",
"{",
"$",
"this",
"->",
"startElement",
"(",
"'sphinx:attr'",
")",
";",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"writeAttribute",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"$",
"this",
"->",
"endElement",
"(",
")",
";",
"}",
"// End sphinx:schema",
"$",
"this",
"->",
"endElement",
"(",
")",
";",
"$",
"return",
"=",
"$",
"this",
"->",
"outputMemory",
"(",
")",
";",
"$",
"this",
"->",
"flush",
"(",
")",
";",
"return",
"$",
"return",
";",
"}"
] |
{@inheritdoc}
|
[
"{"
] |
train
|
https://github.com/ripaclub/zf2-sphinxsearch-tool/blob/4cb51341ccf1db9942e3e578855a579afd608d69/src/Source/Writer/XML2.php#L65-L91
|
ripaclub/zf2-sphinxsearch-tool
|
src/Source/Writer/XML2.php
|
XML2.addDocument
|
public function addDocument(array $doc)
{
$this->startElement('sphinx:document');
if (!isset($doc['id'])) {
throw new NotValidDocumentException('Document array must have an element with "id" key');
}
$this->writeAttribute('id', $doc['id']);
foreach ($doc as $key => $value) {
// Skip the id key since that is an element attribute
if ($key == 'id') {
continue;
}
$this->startElement($key);
$this->text($value);
$this->endElement();
}
$this->endElement();
$return = $this->outputMemory();
$this->flush();
return $return;
}
|
php
|
public function addDocument(array $doc)
{
$this->startElement('sphinx:document');
if (!isset($doc['id'])) {
throw new NotValidDocumentException('Document array must have an element with "id" key');
}
$this->writeAttribute('id', $doc['id']);
foreach ($doc as $key => $value) {
// Skip the id key since that is an element attribute
if ($key == 'id') {
continue;
}
$this->startElement($key);
$this->text($value);
$this->endElement();
}
$this->endElement();
$return = $this->outputMemory();
$this->flush();
return $return;
}
|
[
"public",
"function",
"addDocument",
"(",
"array",
"$",
"doc",
")",
"{",
"$",
"this",
"->",
"startElement",
"(",
"'sphinx:document'",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"doc",
"[",
"'id'",
"]",
")",
")",
"{",
"throw",
"new",
"NotValidDocumentException",
"(",
"'Document array must have an element with \"id\" key'",
")",
";",
"}",
"$",
"this",
"->",
"writeAttribute",
"(",
"'id'",
",",
"$",
"doc",
"[",
"'id'",
"]",
")",
";",
"foreach",
"(",
"$",
"doc",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"// Skip the id key since that is an element attribute",
"if",
"(",
"$",
"key",
"==",
"'id'",
")",
"{",
"continue",
";",
"}",
"$",
"this",
"->",
"startElement",
"(",
"$",
"key",
")",
";",
"$",
"this",
"->",
"text",
"(",
"$",
"value",
")",
";",
"$",
"this",
"->",
"endElement",
"(",
")",
";",
"}",
"$",
"this",
"->",
"endElement",
"(",
")",
";",
"$",
"return",
"=",
"$",
"this",
"->",
"outputMemory",
"(",
")",
";",
"$",
"this",
"->",
"flush",
"(",
")",
";",
"return",
"$",
"return",
";",
"}"
] |
{@inheritdoc}
|
[
"{"
] |
train
|
https://github.com/ripaclub/zf2-sphinxsearch-tool/blob/4cb51341ccf1db9942e3e578855a579afd608d69/src/Source/Writer/XML2.php#L96-L116
|
2amigos/yiifoundation
|
widgets/Reveal.php
|
Reveal.init
|
public function init()
{
$this->assets = array(
'js' => YII_DEBUG ? 'foundation/foundation.reveal.js' : 'foundation.min.js'
);
Html::addCssClass($this->htmlOptions, Enum::DIALOG);
$this->setId(ArrayHelper::removeValue($this->htmlOptions, 'id', $this->getId()));
$this->registerClientScript();
parent::init();
$this->htmlOptions['id'] = $this->getId();
echo $this->renderToggleButton() . "\n";
echo \CHtml::openTag('div', $this->htmlOptions) . "\n";
echo $this->renderHeader() . "\n";
}
|
php
|
public function init()
{
$this->assets = array(
'js' => YII_DEBUG ? 'foundation/foundation.reveal.js' : 'foundation.min.js'
);
Html::addCssClass($this->htmlOptions, Enum::DIALOG);
$this->setId(ArrayHelper::removeValue($this->htmlOptions, 'id', $this->getId()));
$this->registerClientScript();
parent::init();
$this->htmlOptions['id'] = $this->getId();
echo $this->renderToggleButton() . "\n";
echo \CHtml::openTag('div', $this->htmlOptions) . "\n";
echo $this->renderHeader() . "\n";
}
|
[
"public",
"function",
"init",
"(",
")",
"{",
"$",
"this",
"->",
"assets",
"=",
"array",
"(",
"'js'",
"=>",
"YII_DEBUG",
"?",
"'foundation/foundation.reveal.js'",
":",
"'foundation.min.js'",
")",
";",
"Html",
"::",
"addCssClass",
"(",
"$",
"this",
"->",
"htmlOptions",
",",
"Enum",
"::",
"DIALOG",
")",
";",
"$",
"this",
"->",
"setId",
"(",
"ArrayHelper",
"::",
"removeValue",
"(",
"$",
"this",
"->",
"htmlOptions",
",",
"'id'",
",",
"$",
"this",
"->",
"getId",
"(",
")",
")",
")",
";",
"$",
"this",
"->",
"registerClientScript",
"(",
")",
";",
"parent",
"::",
"init",
"(",
")",
";",
"$",
"this",
"->",
"htmlOptions",
"[",
"'id'",
"]",
"=",
"$",
"this",
"->",
"getId",
"(",
")",
";",
"echo",
"$",
"this",
"->",
"renderToggleButton",
"(",
")",
".",
"\"\\n\"",
";",
"echo",
"\\",
"CHtml",
"::",
"openTag",
"(",
"'div'",
",",
"$",
"this",
"->",
"htmlOptions",
")",
".",
"\"\\n\"",
";",
"echo",
"$",
"this",
"->",
"renderHeader",
"(",
")",
".",
"\"\\n\"",
";",
"}"
] |
Initializes the widget
|
[
"Initializes",
"the",
"widget"
] |
train
|
https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/widgets/Reveal.php#L110-L126
|
2amigos/yiifoundation
|
widgets/Reveal.php
|
Reveal.renderToggleButton
|
public function renderToggleButton()
{
if ($this->toggleButton !== null) {
$tag = ArrayHelper::removeValue($this->toggleButton, 'tag', 'button');
$label = ArrayHelper::removeValue($this->toggleButton, 'label', 'Show');
if ($tag === 'button' && !isset($this->toggleButton['type'])) {
$this->toggleButton['type'] = 'button';
}
$this->toggleButton['data-reveal-id'] = $this->getId();
return \CHtml::tag($tag, $this->toggleButton, $label);
} else {
return null;
}
}
|
php
|
public function renderToggleButton()
{
if ($this->toggleButton !== null) {
$tag = ArrayHelper::removeValue($this->toggleButton, 'tag', 'button');
$label = ArrayHelper::removeValue($this->toggleButton, 'label', 'Show');
if ($tag === 'button' && !isset($this->toggleButton['type'])) {
$this->toggleButton['type'] = 'button';
}
$this->toggleButton['data-reveal-id'] = $this->getId();
return \CHtml::tag($tag, $this->toggleButton, $label);
} else {
return null;
}
}
|
[
"public",
"function",
"renderToggleButton",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"toggleButton",
"!==",
"null",
")",
"{",
"$",
"tag",
"=",
"ArrayHelper",
"::",
"removeValue",
"(",
"$",
"this",
"->",
"toggleButton",
",",
"'tag'",
",",
"'button'",
")",
";",
"$",
"label",
"=",
"ArrayHelper",
"::",
"removeValue",
"(",
"$",
"this",
"->",
"toggleButton",
",",
"'label'",
",",
"'Show'",
")",
";",
"if",
"(",
"$",
"tag",
"===",
"'button'",
"&&",
"!",
"isset",
"(",
"$",
"this",
"->",
"toggleButton",
"[",
"'type'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"toggleButton",
"[",
"'type'",
"]",
"=",
"'button'",
";",
"}",
"$",
"this",
"->",
"toggleButton",
"[",
"'data-reveal-id'",
"]",
"=",
"$",
"this",
"->",
"getId",
"(",
")",
";",
"return",
"\\",
"CHtml",
"::",
"tag",
"(",
"$",
"tag",
",",
"$",
"this",
"->",
"toggleButton",
",",
"$",
"label",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
Renders the toggle button
@return null|string the rendering result
|
[
"Renders",
"the",
"toggle",
"button"
] |
train
|
https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/widgets/Reveal.php#L150-L163
|
2amigos/yiifoundation
|
widgets/Reveal.php
|
Reveal.renderCloseButton
|
protected function renderCloseButton()
{
if ($this->closeButton !== null) {
$tag = ArrayHelper::removeValue($this->closeButton, 'tag', 'a');
$label = ArrayHelper::removeValue($this->closeButton, 'label', '×');
if ($tag === 'button' && !isset($this->closeButton['type'])) {
$this->closeButton['type'] = 'button';
}
Html::addCssClass($this->closeButton, Enum::DIALOG_CLOSE);
return \CHtml::tag($tag, $this->closeButton, $label);
} else {
return null;
}
}
|
php
|
protected function renderCloseButton()
{
if ($this->closeButton !== null) {
$tag = ArrayHelper::removeValue($this->closeButton, 'tag', 'a');
$label = ArrayHelper::removeValue($this->closeButton, 'label', '×');
if ($tag === 'button' && !isset($this->closeButton['type'])) {
$this->closeButton['type'] = 'button';
}
Html::addCssClass($this->closeButton, Enum::DIALOG_CLOSE);
return \CHtml::tag($tag, $this->closeButton, $label);
} else {
return null;
}
}
|
[
"protected",
"function",
"renderCloseButton",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"closeButton",
"!==",
"null",
")",
"{",
"$",
"tag",
"=",
"ArrayHelper",
"::",
"removeValue",
"(",
"$",
"this",
"->",
"closeButton",
",",
"'tag'",
",",
"'a'",
")",
";",
"$",
"label",
"=",
"ArrayHelper",
"::",
"removeValue",
"(",
"$",
"this",
"->",
"closeButton",
",",
"'label'",
",",
"'×'",
")",
";",
"if",
"(",
"$",
"tag",
"===",
"'button'",
"&&",
"!",
"isset",
"(",
"$",
"this",
"->",
"closeButton",
"[",
"'type'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"closeButton",
"[",
"'type'",
"]",
"=",
"'button'",
";",
"}",
"Html",
"::",
"addCssClass",
"(",
"$",
"this",
"->",
"closeButton",
",",
"Enum",
"::",
"DIALOG_CLOSE",
")",
";",
"return",
"\\",
"CHtml",
"::",
"tag",
"(",
"$",
"tag",
",",
"$",
"this",
"->",
"closeButton",
",",
"$",
"label",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
Renders the close button.
@return string the rendering result
|
[
"Renders",
"the",
"close",
"button",
"."
] |
train
|
https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/widgets/Reveal.php#L169-L182
|
phpmob/changmin
|
src/PhpMob/WidgetBundle/Twig/AbstractWidgetExtension.php
|
AbstractWidgetExtension.resolveOptions
|
private function resolveOptions(array $options = [])
{
$resolver = new OptionsResolver();
$this->configure($resolver);
return $resolver->resolve($options);
}
|
php
|
private function resolveOptions(array $options = [])
{
$resolver = new OptionsResolver();
$this->configure($resolver);
return $resolver->resolve($options);
}
|
[
"private",
"function",
"resolveOptions",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"resolver",
"=",
"new",
"OptionsResolver",
"(",
")",
";",
"$",
"this",
"->",
"configure",
"(",
"$",
"resolver",
")",
";",
"return",
"$",
"resolver",
"->",
"resolve",
"(",
"$",
"options",
")",
";",
"}"
] |
@param array $options
@return array
|
[
"@param",
"array",
"$options"
] |
train
|
https://github.com/phpmob/changmin/blob/bfebb1561229094d1c138574abab75f2f1d17d66/src/PhpMob/WidgetBundle/Twig/AbstractWidgetExtension.php#L86-L92
|
phpmob/changmin
|
src/PhpMob/WidgetBundle/Twig/AbstractWidgetExtension.php
|
AbstractWidgetExtension.render
|
final public function render(\Twig_Environment $env, array $userOptions = [])
{
$data = [];
$options = $this->getOptions($userOptions);
if ('away' === $options['visibility']) {
$data = $this->getData($options);
}
if (empty($options['render_url'])) {
$options['render_url'] = $this->router->generate('phpmob_widget_render', []);
}
// todo: session check DoS refresh
if (false === $options['auto_refresh']) {
unset($options['auto_refresh']);
unset($options['auto_refresh_timer']);
}
if (!empty($options['script_path'])) {
$this->widgetAssets->addScript($options['script_path']);
}
if (!empty($options['style_path'])) {
$this->widgetAssets->addScript($options['style_path']);
}
$this->widgetAssets->increaseCounter();
return $env->render($options['template'], [
'data' => $data,
'options' => $options,
'userOptions' => $userOptions,
]);
}
|
php
|
final public function render(\Twig_Environment $env, array $userOptions = [])
{
$data = [];
$options = $this->getOptions($userOptions);
if ('away' === $options['visibility']) {
$data = $this->getData($options);
}
if (empty($options['render_url'])) {
$options['render_url'] = $this->router->generate('phpmob_widget_render', []);
}
// todo: session check DoS refresh
if (false === $options['auto_refresh']) {
unset($options['auto_refresh']);
unset($options['auto_refresh_timer']);
}
if (!empty($options['script_path'])) {
$this->widgetAssets->addScript($options['script_path']);
}
if (!empty($options['style_path'])) {
$this->widgetAssets->addScript($options['style_path']);
}
$this->widgetAssets->increaseCounter();
return $env->render($options['template'], [
'data' => $data,
'options' => $options,
'userOptions' => $userOptions,
]);
}
|
[
"final",
"public",
"function",
"render",
"(",
"\\",
"Twig_Environment",
"$",
"env",
",",
"array",
"$",
"userOptions",
"=",
"[",
"]",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"$",
"options",
"=",
"$",
"this",
"->",
"getOptions",
"(",
"$",
"userOptions",
")",
";",
"if",
"(",
"'away'",
"===",
"$",
"options",
"[",
"'visibility'",
"]",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
"$",
"options",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"options",
"[",
"'render_url'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'render_url'",
"]",
"=",
"$",
"this",
"->",
"router",
"->",
"generate",
"(",
"'phpmob_widget_render'",
",",
"[",
"]",
")",
";",
"}",
"// todo: session check DoS refresh",
"if",
"(",
"false",
"===",
"$",
"options",
"[",
"'auto_refresh'",
"]",
")",
"{",
"unset",
"(",
"$",
"options",
"[",
"'auto_refresh'",
"]",
")",
";",
"unset",
"(",
"$",
"options",
"[",
"'auto_refresh_timer'",
"]",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'script_path'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"widgetAssets",
"->",
"addScript",
"(",
"$",
"options",
"[",
"'script_path'",
"]",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'style_path'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"widgetAssets",
"->",
"addScript",
"(",
"$",
"options",
"[",
"'style_path'",
"]",
")",
";",
"}",
"$",
"this",
"->",
"widgetAssets",
"->",
"increaseCounter",
"(",
")",
";",
"return",
"$",
"env",
"->",
"render",
"(",
"$",
"options",
"[",
"'template'",
"]",
",",
"[",
"'data'",
"=>",
"$",
"data",
",",
"'options'",
"=>",
"$",
"options",
",",
"'userOptions'",
"=>",
"$",
"userOptions",
",",
"]",
")",
";",
"}"
] |
{@inheritdoc}
|
[
"{"
] |
train
|
https://github.com/phpmob/changmin/blob/bfebb1561229094d1c138574abab75f2f1d17d66/src/PhpMob/WidgetBundle/Twig/AbstractWidgetExtension.php#L140-L174
|
phpmob/changmin
|
src/PhpMob/Sylius/Grid/FieldType/BadgeFieldType.php
|
BadgeFieldType.render
|
public function render(Field $field, $data, array $options)
{
if ('.' !== $field->getPath()) {
$data = $this->dataExtractor->get($field, $data);
}
$field->setOptions($options);
return $this->twig->render($options['template'], ['data' => $data, 'options' => $options]);
}
|
php
|
public function render(Field $field, $data, array $options)
{
if ('.' !== $field->getPath()) {
$data = $this->dataExtractor->get($field, $data);
}
$field->setOptions($options);
return $this->twig->render($options['template'], ['data' => $data, 'options' => $options]);
}
|
[
"public",
"function",
"render",
"(",
"Field",
"$",
"field",
",",
"$",
"data",
",",
"array",
"$",
"options",
")",
"{",
"if",
"(",
"'.'",
"!==",
"$",
"field",
"->",
"getPath",
"(",
")",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"dataExtractor",
"->",
"get",
"(",
"$",
"field",
",",
"$",
"data",
")",
";",
"}",
"$",
"field",
"->",
"setOptions",
"(",
"$",
"options",
")",
";",
"return",
"$",
"this",
"->",
"twig",
"->",
"render",
"(",
"$",
"options",
"[",
"'template'",
"]",
",",
"[",
"'data'",
"=>",
"$",
"data",
",",
"'options'",
"=>",
"$",
"options",
"]",
")",
";",
"}"
] |
{@inheritdoc}
|
[
"{"
] |
train
|
https://github.com/phpmob/changmin/blob/bfebb1561229094d1c138574abab75f2f1d17d66/src/PhpMob/Sylius/Grid/FieldType/BadgeFieldType.php#L56-L65
|
phpmob/changmin
|
src/PhpMob/Sylius/Grid/FieldType/BadgeFieldType.php
|
BadgeFieldType.configureOptions
|
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefault('template', $this->defaultTemplate);
$resolver->setAllowedTypes('template', 'string');
$resolver->setDefined('vars');
$resolver->setAllowedTypes('vars', 'array');
$resolver->setDefaults([
'width' => 'auto',
'align' => 'left',
'type' => 'info',
]);
$resolver->setAllowedTypes('align', 'string');
$resolver->setAllowedTypes('width', 'string');
$resolver->setAllowedTypes('type', 'string');
}
|
php
|
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefault('template', $this->defaultTemplate);
$resolver->setAllowedTypes('template', 'string');
$resolver->setDefined('vars');
$resolver->setAllowedTypes('vars', 'array');
$resolver->setDefaults([
'width' => 'auto',
'align' => 'left',
'type' => 'info',
]);
$resolver->setAllowedTypes('align', 'string');
$resolver->setAllowedTypes('width', 'string');
$resolver->setAllowedTypes('type', 'string');
}
|
[
"public",
"function",
"configureOptions",
"(",
"OptionsResolver",
"$",
"resolver",
")",
":",
"void",
"{",
"$",
"resolver",
"->",
"setDefault",
"(",
"'template'",
",",
"$",
"this",
"->",
"defaultTemplate",
")",
";",
"$",
"resolver",
"->",
"setAllowedTypes",
"(",
"'template'",
",",
"'string'",
")",
";",
"$",
"resolver",
"->",
"setDefined",
"(",
"'vars'",
")",
";",
"$",
"resolver",
"->",
"setAllowedTypes",
"(",
"'vars'",
",",
"'array'",
")",
";",
"$",
"resolver",
"->",
"setDefaults",
"(",
"[",
"'width'",
"=>",
"'auto'",
",",
"'align'",
"=>",
"'left'",
",",
"'type'",
"=>",
"'info'",
",",
"]",
")",
";",
"$",
"resolver",
"->",
"setAllowedTypes",
"(",
"'align'",
",",
"'string'",
")",
";",
"$",
"resolver",
"->",
"setAllowedTypes",
"(",
"'width'",
",",
"'string'",
")",
";",
"$",
"resolver",
"->",
"setAllowedTypes",
"(",
"'type'",
",",
"'string'",
")",
";",
"}"
] |
{@inheritdoc}
|
[
"{"
] |
train
|
https://github.com/phpmob/changmin/blob/bfebb1561229094d1c138574abab75f2f1d17d66/src/PhpMob/Sylius/Grid/FieldType/BadgeFieldType.php#L70-L87
|
fubhy/graphql-php
|
src/Language/Token.php
|
Token.typeToString
|
public static function typeToString($type)
{
switch ($type) {
case self::EOF_TYPE:
return 'EOF';
case self::BANG_TYPE:
return '!';
case self::DOLLAR_TYPE:
return '$';
case self::PAREN_L_TYPE:
return '(';
case self::PAREN_R_TYPE:
return ')';
case self::SPREAD_TYPE:
return '...';
case self::COLON_TYPE:
return ':';
case self::EQUALS_TYPE:
return '=';
case self::AT_TYPE:
return '@';
case self::BRACKET_L_TYPE:
return '[';
case self::BRACKET_R_TYPE:
return ']';
case self::BRACE_L_TYPE:
return '{';
case self::PIPE_TYPE:
return '|';
case self::BRACE_R_TYPE:
return '}';
case self::NAME_TYPE:
return 'Name';
case self::VARIABLE_TYPE:
return 'Variable';
case self::INT_TYPE:
return 'Int';
case self::FLOAT_TYPE:
return 'Float';
case self::STRING_TYPE:
return 'String';
default:
throw new \LogicException(sprintf('Token of type "%s" does not exist.', $type));
}
}
|
php
|
public static function typeToString($type)
{
switch ($type) {
case self::EOF_TYPE:
return 'EOF';
case self::BANG_TYPE:
return '!';
case self::DOLLAR_TYPE:
return '$';
case self::PAREN_L_TYPE:
return '(';
case self::PAREN_R_TYPE:
return ')';
case self::SPREAD_TYPE:
return '...';
case self::COLON_TYPE:
return ':';
case self::EQUALS_TYPE:
return '=';
case self::AT_TYPE:
return '@';
case self::BRACKET_L_TYPE:
return '[';
case self::BRACKET_R_TYPE:
return ']';
case self::BRACE_L_TYPE:
return '{';
case self::PIPE_TYPE:
return '|';
case self::BRACE_R_TYPE:
return '}';
case self::NAME_TYPE:
return 'Name';
case self::VARIABLE_TYPE:
return 'Variable';
case self::INT_TYPE:
return 'Int';
case self::FLOAT_TYPE:
return 'Float';
case self::STRING_TYPE:
return 'String';
default:
throw new \LogicException(sprintf('Token of type "%s" does not exist.', $type));
}
}
|
[
"public",
"static",
"function",
"typeToString",
"(",
"$",
"type",
")",
"{",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"self",
"::",
"EOF_TYPE",
":",
"return",
"'EOF'",
";",
"case",
"self",
"::",
"BANG_TYPE",
":",
"return",
"'!'",
";",
"case",
"self",
"::",
"DOLLAR_TYPE",
":",
"return",
"'$'",
";",
"case",
"self",
"::",
"PAREN_L_TYPE",
":",
"return",
"'('",
";",
"case",
"self",
"::",
"PAREN_R_TYPE",
":",
"return",
"')'",
";",
"case",
"self",
"::",
"SPREAD_TYPE",
":",
"return",
"'...'",
";",
"case",
"self",
"::",
"COLON_TYPE",
":",
"return",
"':'",
";",
"case",
"self",
"::",
"EQUALS_TYPE",
":",
"return",
"'='",
";",
"case",
"self",
"::",
"AT_TYPE",
":",
"return",
"'@'",
";",
"case",
"self",
"::",
"BRACKET_L_TYPE",
":",
"return",
"'['",
";",
"case",
"self",
"::",
"BRACKET_R_TYPE",
":",
"return",
"']'",
";",
"case",
"self",
"::",
"BRACE_L_TYPE",
":",
"return",
"'{'",
";",
"case",
"self",
"::",
"PIPE_TYPE",
":",
"return",
"'|'",
";",
"case",
"self",
"::",
"BRACE_R_TYPE",
":",
"return",
"'}'",
";",
"case",
"self",
"::",
"NAME_TYPE",
":",
"return",
"'Name'",
";",
"case",
"self",
"::",
"VARIABLE_TYPE",
":",
"return",
"'Variable'",
";",
"case",
"self",
"::",
"INT_TYPE",
":",
"return",
"'Int'",
";",
"case",
"self",
"::",
"FLOAT_TYPE",
":",
"return",
"'Float'",
";",
"case",
"self",
"::",
"STRING_TYPE",
":",
"return",
"'String'",
";",
"default",
":",
"throw",
"new",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'Token of type \"%s\" does not exist.'",
",",
"$",
"type",
")",
")",
";",
"}",
"}"
] |
Returns the constant representation (internal) of a given type.
@param int $type
The type as an integer
@return string
The string representation
|
[
"Returns",
"the",
"constant",
"representation",
"(",
"internal",
")",
"of",
"a",
"given",
"type",
"."
] |
train
|
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Language/Token.php#L154-L198
|
webforge-labs/psc-cms
|
lib/Psc/JS/JooseSnippet.php
|
JooseSnippet.expr
|
public static function expr($jsCode) {
$dsl = new \Psc\Code\AST\DSL();
return $dsl->expression($jsCode);
}
|
php
|
public static function expr($jsCode) {
$dsl = new \Psc\Code\AST\DSL();
return $dsl->expression($jsCode);
}
|
[
"public",
"static",
"function",
"expr",
"(",
"$",
"jsCode",
")",
"{",
"$",
"dsl",
"=",
"new",
"\\",
"Psc",
"\\",
"Code",
"\\",
"AST",
"\\",
"DSL",
"(",
")",
";",
"return",
"$",
"dsl",
"->",
"expression",
"(",
"$",
"jsCode",
")",
";",
"}"
] |
Kleiner Helfer für das Erzeugen einer Expression
JooseSnippet::expr("$('#psc-ui-tabs')")
|
[
"Kleiner",
"Helfer",
"für",
"das",
"Erzeugen",
"einer",
"Expression"
] |
train
|
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/JS/JooseSnippet.php#L52-L55
|
npbtrac/yii2-enpii-cms
|
libs/override/db/NpActiveRecord.php
|
NpActiveRecord.init
|
public function init()
{
parent::init();
$this->datetimeFormat = (empty(Yii::$app->params['site']->datetimeFormat)) ? $this->datetimeFormat : Yii::$app->params['site']->datetimeFormat;
$this->timezone = (empty(Yii::$app->params['site']->timezone)) ? $this->timezone : Yii::$app->params['site']->timezone;
}
|
php
|
public function init()
{
parent::init();
$this->datetimeFormat = (empty(Yii::$app->params['site']->datetimeFormat)) ? $this->datetimeFormat : Yii::$app->params['site']->datetimeFormat;
$this->timezone = (empty(Yii::$app->params['site']->timezone)) ? $this->timezone : Yii::$app->params['site']->timezone;
}
|
[
"public",
"function",
"init",
"(",
")",
"{",
"parent",
"::",
"init",
"(",
")",
";",
"$",
"this",
"->",
"datetimeFormat",
"=",
"(",
"empty",
"(",
"Yii",
"::",
"$",
"app",
"->",
"params",
"[",
"'site'",
"]",
"->",
"datetimeFormat",
")",
")",
"?",
"$",
"this",
"->",
"datetimeFormat",
":",
"Yii",
"::",
"$",
"app",
"->",
"params",
"[",
"'site'",
"]",
"->",
"datetimeFormat",
";",
"$",
"this",
"->",
"timezone",
"=",
"(",
"empty",
"(",
"Yii",
"::",
"$",
"app",
"->",
"params",
"[",
"'site'",
"]",
"->",
"timezone",
")",
")",
"?",
"$",
"this",
"->",
"timezone",
":",
"Yii",
"::",
"$",
"app",
"->",
"params",
"[",
"'site'",
"]",
"->",
"timezone",
";",
"}"
] |
Set default timezone and datetime format for model
|
[
"Set",
"default",
"timezone",
"and",
"datetime",
"format",
"for",
"model"
] |
train
|
https://github.com/npbtrac/yii2-enpii-cms/blob/3495e697509a57a573983f552629ff9f707a63b9/libs/override/db/NpActiveRecord.php#L24-L30
|
npbtrac/yii2-enpii-cms
|
libs/override/db/NpActiveRecord.php
|
NpActiveRecord.getDisplayDateTime
|
public function getDisplayDateTime($input, $format = null, $timezone = null)
{
return \enpii\enpiiCms\helpers\DateTimeHelper::fromDbFormat($input,
($format === null ? $this->datetimeFormat : $format),
($timezone === null ? $this->timezone : $timezone));
}
|
php
|
public function getDisplayDateTime($input, $format = null, $timezone = null)
{
return \enpii\enpiiCms\helpers\DateTimeHelper::fromDbFormat($input,
($format === null ? $this->datetimeFormat : $format),
($timezone === null ? $this->timezone : $timezone));
}
|
[
"public",
"function",
"getDisplayDateTime",
"(",
"$",
"input",
",",
"$",
"format",
"=",
"null",
",",
"$",
"timezone",
"=",
"null",
")",
"{",
"return",
"\\",
"enpii",
"\\",
"enpiiCms",
"\\",
"helpers",
"\\",
"DateTimeHelper",
"::",
"fromDbFormat",
"(",
"$",
"input",
",",
"(",
"$",
"format",
"===",
"null",
"?",
"$",
"this",
"->",
"datetimeFormat",
":",
"$",
"format",
")",
",",
"(",
"$",
"timezone",
"===",
"null",
"?",
"$",
"this",
"->",
"timezone",
":",
"$",
"timezone",
")",
")",
";",
"}"
] |
Display datetime from the result retrieve from database (stored by GMT datetime
@param $input
@param null $format
@param null $timezone
@return bool|string
|
[
"Display",
"datetime",
"from",
"the",
"result",
"retrieve",
"from",
"database",
"(",
"stored",
"by",
"GMT",
"datetime"
] |
train
|
https://github.com/npbtrac/yii2-enpii-cms/blob/3495e697509a57a573983f552629ff9f707a63b9/libs/override/db/NpActiveRecord.php#L54-L59
|
npbtrac/yii2-enpii-cms
|
libs/override/db/NpActiveRecord.php
|
NpActiveRecord.getCreatedAt
|
public function getCreatedAt($format = null, $timezone = null)
{
return $this->getDisplayDateTime($this->created_at, $format, $timezone);
}
|
php
|
public function getCreatedAt($format = null, $timezone = null)
{
return $this->getDisplayDateTime($this->created_at, $format, $timezone);
}
|
[
"public",
"function",
"getCreatedAt",
"(",
"$",
"format",
"=",
"null",
",",
"$",
"timezone",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"getDisplayDateTime",
"(",
"$",
"this",
"->",
"created_at",
",",
"$",
"format",
",",
"$",
"timezone",
")",
";",
"}"
] |
Display create_at datetime
@param null $format
@param null $timezone
@return bool|string
|
[
"Display",
"create_at",
"datetime"
] |
train
|
https://github.com/npbtrac/yii2-enpii-cms/blob/3495e697509a57a573983f552629ff9f707a63b9/libs/override/db/NpActiveRecord.php#L67-L70
|
npbtrac/yii2-enpii-cms
|
libs/override/db/NpActiveRecord.php
|
NpActiveRecord.getUpdatedAt
|
public function getUpdatedAt($format = null, $timezone = null)
{
return $this->getDisplayDateTime($this->updated_at, $format, $timezone);
}
|
php
|
public function getUpdatedAt($format = null, $timezone = null)
{
return $this->getDisplayDateTime($this->updated_at, $format, $timezone);
}
|
[
"public",
"function",
"getUpdatedAt",
"(",
"$",
"format",
"=",
"null",
",",
"$",
"timezone",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"getDisplayDateTime",
"(",
"$",
"this",
"->",
"updated_at",
",",
"$",
"format",
",",
"$",
"timezone",
")",
";",
"}"
] |
Display updated_at datetime
@param null $format
@param null $timezone
@return bool|string
|
[
"Display",
"updated_at",
"datetime"
] |
train
|
https://github.com/npbtrac/yii2-enpii-cms/blob/3495e697509a57a573983f552629ff9f707a63b9/libs/override/db/NpActiveRecord.php#L78-L81
|
npbtrac/yii2-enpii-cms
|
libs/override/db/NpActiveRecord.php
|
NpActiveRecord.getPublishedAt
|
public function getPublishedAt($format = null, $timezone = null)
{
return $this->getDisplayDateTime($this->published_at, $format, $timezone);
}
|
php
|
public function getPublishedAt($format = null, $timezone = null)
{
return $this->getDisplayDateTime($this->published_at, $format, $timezone);
}
|
[
"public",
"function",
"getPublishedAt",
"(",
"$",
"format",
"=",
"null",
",",
"$",
"timezone",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"getDisplayDateTime",
"(",
"$",
"this",
"->",
"published_at",
",",
"$",
"format",
",",
"$",
"timezone",
")",
";",
"}"
] |
Display published_at datetime
@param null $format
@param null $timezone
@return bool|string
|
[
"Display",
"published_at",
"datetime"
] |
train
|
https://github.com/npbtrac/yii2-enpii-cms/blob/3495e697509a57a573983f552629ff9f707a63b9/libs/override/db/NpActiveRecord.php#L89-L92
|
npbtrac/yii2-enpii-cms
|
libs/override/db/NpActiveRecord.php
|
NpActiveRecord.getUploadTmpPath
|
public function getUploadTmpPath()
{
$path = Yii::getAlias('@root' . '/' . Yii::$app->params['uploads']['folderName'] . '/' . 'tmp');
if (!file_exists($path)) {
FileHelper::createDirectory($path, 0777);
}
return $path;
}
|
php
|
public function getUploadTmpPath()
{
$path = Yii::getAlias('@root' . '/' . Yii::$app->params['uploads']['folderName'] . '/' . 'tmp');
if (!file_exists($path)) {
FileHelper::createDirectory($path, 0777);
}
return $path;
}
|
[
"public",
"function",
"getUploadTmpPath",
"(",
")",
"{",
"$",
"path",
"=",
"Yii",
"::",
"getAlias",
"(",
"'@root'",
".",
"'/'",
".",
"Yii",
"::",
"$",
"app",
"->",
"params",
"[",
"'uploads'",
"]",
"[",
"'folderName'",
"]",
".",
"'/'",
".",
"'tmp'",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"FileHelper",
"::",
"createDirectory",
"(",
"$",
"path",
",",
"0777",
")",
";",
"}",
"return",
"$",
"path",
";",
"}"
] |
Temporary upload path
@return bool|string
|
[
"Temporary",
"upload",
"path"
] |
train
|
https://github.com/npbtrac/yii2-enpii-cms/blob/3495e697509a57a573983f552629ff9f707a63b9/libs/override/db/NpActiveRecord.php#L98-L105
|
atkrad/data-tables
|
src/Column/ActionBuilder.php
|
ActionBuilder.addAction
|
public function addAction($slug, $name, $url, $options = [])
{
$this->actions[$slug] = ['name' => $name, 'url' => $url, 'options' => $options];
return $this;
}
|
php
|
public function addAction($slug, $name, $url, $options = [])
{
$this->actions[$slug] = ['name' => $name, 'url' => $url, 'options' => $options];
return $this;
}
|
[
"public",
"function",
"addAction",
"(",
"$",
"slug",
",",
"$",
"name",
",",
"$",
"url",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"actions",
"[",
"$",
"slug",
"]",
"=",
"[",
"'name'",
"=>",
"$",
"name",
",",
"'url'",
"=>",
"$",
"url",
",",
"'options'",
"=>",
"$",
"options",
"]",
";",
"return",
"$",
"this",
";",
"}"
] |
Add Action
@param string $slug Action slug
@param string $name Action name
@param string $url Action url
@param array $options Action options
@return ActionBuilder
|
[
"Add",
"Action"
] |
train
|
https://github.com/atkrad/data-tables/blob/5afcc337ab624ca626e29d9674459c5105982b16/src/Column/ActionBuilder.php#L40-L45
|
atkrad/data-tables
|
src/Column/ActionBuilder.php
|
ActionBuilder.removeAction
|
public function removeAction($slug)
{
if (array_key_exists($slug, $this->actions)) {
unset($this->actions[$slug]);
return true;
} else {
return false;
}
}
|
php
|
public function removeAction($slug)
{
if (array_key_exists($slug, $this->actions)) {
unset($this->actions[$slug]);
return true;
} else {
return false;
}
}
|
[
"public",
"function",
"removeAction",
"(",
"$",
"slug",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"slug",
",",
"$",
"this",
"->",
"actions",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"actions",
"[",
"$",
"slug",
"]",
")",
";",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Remove action
@param string $slug Action slug
@return bool
|
[
"Remove",
"action"
] |
train
|
https://github.com/atkrad/data-tables/blob/5afcc337ab624ca626e29d9674459c5105982b16/src/Column/ActionBuilder.php#L54-L63
|
atkrad/data-tables
|
src/Column/ActionBuilder.php
|
ActionBuilder.render
|
public function render($template)
{
$actions = $this->getActions();
$this->flushActions();
return $this->table->getRender()->getTwig()->render($template, ['actions' => $actions]);
}
|
php
|
public function render($template)
{
$actions = $this->getActions();
$this->flushActions();
return $this->table->getRender()->getTwig()->render($template, ['actions' => $actions]);
}
|
[
"public",
"function",
"render",
"(",
"$",
"template",
")",
"{",
"$",
"actions",
"=",
"$",
"this",
"->",
"getActions",
"(",
")",
";",
"$",
"this",
"->",
"flushActions",
"(",
")",
";",
"return",
"$",
"this",
"->",
"table",
"->",
"getRender",
"(",
")",
"->",
"getTwig",
"(",
")",
"->",
"render",
"(",
"$",
"template",
",",
"[",
"'actions'",
"=>",
"$",
"actions",
"]",
")",
";",
"}"
] |
Actions render
@param string $template Action template name
@return string
|
[
"Actions",
"render"
] |
train
|
https://github.com/atkrad/data-tables/blob/5afcc337ab624ca626e29d9674459c5105982b16/src/Column/ActionBuilder.php#L90-L96
|
ruvents/ruwork-upload-bundle
|
Form/TypeGuesser/DoctrineUploadTypeGuesser.php
|
DoctrineUploadTypeGuesser.guessType
|
public function guessType($class, $property)
{
if (!$result = $this->getMetadata($class)) {
return null;
}
/** @var ClassMetadata $metadata */
$metadata = $result[0];
if (!$metadata->hasAssociation($property) || $metadata->isCollectionValuedAssociation($property)) {
return null;
}
$uploadClass = $metadata->getAssociationTargetClass($property);
try {
$this->metadataFactory->getMetadata($uploadClass);
} catch (NotMappedException $exception) {
return null;
}
return new TypeGuess(
DoctrineUploadType::class,
['class' => $uploadClass],
Guess::HIGH_CONFIDENCE
);
}
|
php
|
public function guessType($class, $property)
{
if (!$result = $this->getMetadata($class)) {
return null;
}
/** @var ClassMetadata $metadata */
$metadata = $result[0];
if (!$metadata->hasAssociation($property) || $metadata->isCollectionValuedAssociation($property)) {
return null;
}
$uploadClass = $metadata->getAssociationTargetClass($property);
try {
$this->metadataFactory->getMetadata($uploadClass);
} catch (NotMappedException $exception) {
return null;
}
return new TypeGuess(
DoctrineUploadType::class,
['class' => $uploadClass],
Guess::HIGH_CONFIDENCE
);
}
|
[
"public",
"function",
"guessType",
"(",
"$",
"class",
",",
"$",
"property",
")",
"{",
"if",
"(",
"!",
"$",
"result",
"=",
"$",
"this",
"->",
"getMetadata",
"(",
"$",
"class",
")",
")",
"{",
"return",
"null",
";",
"}",
"/** @var ClassMetadata $metadata */",
"$",
"metadata",
"=",
"$",
"result",
"[",
"0",
"]",
";",
"if",
"(",
"!",
"$",
"metadata",
"->",
"hasAssociation",
"(",
"$",
"property",
")",
"||",
"$",
"metadata",
"->",
"isCollectionValuedAssociation",
"(",
"$",
"property",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"uploadClass",
"=",
"$",
"metadata",
"->",
"getAssociationTargetClass",
"(",
"$",
"property",
")",
";",
"try",
"{",
"$",
"this",
"->",
"metadataFactory",
"->",
"getMetadata",
"(",
"$",
"uploadClass",
")",
";",
"}",
"catch",
"(",
"NotMappedException",
"$",
"exception",
")",
"{",
"return",
"null",
";",
"}",
"return",
"new",
"TypeGuess",
"(",
"DoctrineUploadType",
"::",
"class",
",",
"[",
"'class'",
"=>",
"$",
"uploadClass",
"]",
",",
"Guess",
"::",
"HIGH_CONFIDENCE",
")",
";",
"}"
] |
{@inheritdoc}
|
[
"{"
] |
train
|
https://github.com/ruvents/ruwork-upload-bundle/blob/8ad09cc2dce6ab389105c440d791346696da43af/Form/TypeGuesser/DoctrineUploadTypeGuesser.php#L29-L55
|
steeffeen/FancyManiaLinks
|
FML/Script/Features/Toggle.php
|
Toggle.setTogglingControl
|
public function setTogglingControl(Control $control)
{
$control->checkId();
if ($control instanceof Scriptable) {
$control->setScriptEvents(true);
}
$this->togglingControl = $control;
return $this;
}
|
php
|
public function setTogglingControl(Control $control)
{
$control->checkId();
if ($control instanceof Scriptable) {
$control->setScriptEvents(true);
}
$this->togglingControl = $control;
return $this;
}
|
[
"public",
"function",
"setTogglingControl",
"(",
"Control",
"$",
"control",
")",
"{",
"$",
"control",
"->",
"checkId",
"(",
")",
";",
"if",
"(",
"$",
"control",
"instanceof",
"Scriptable",
")",
"{",
"$",
"control",
"->",
"setScriptEvents",
"(",
"true",
")",
";",
"}",
"$",
"this",
"->",
"togglingControl",
"=",
"$",
"control",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the toggling Control
@api
@param Control $control Toggling Control
@return static
|
[
"Set",
"the",
"toggling",
"Control"
] |
train
|
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/Toggle.php#L98-L106
|
steeffeen/FancyManiaLinks
|
FML/Script/Features/Toggle.php
|
Toggle.setOnlyShow
|
public function setOnlyShow($onlyShow)
{
$this->onlyShow = (bool)$onlyShow;
if ($this->onlyShow) {
$this->onlyHide = null;
}
return $this;
}
|
php
|
public function setOnlyShow($onlyShow)
{
$this->onlyShow = (bool)$onlyShow;
if ($this->onlyShow) {
$this->onlyHide = null;
}
return $this;
}
|
[
"public",
"function",
"setOnlyShow",
"(",
"$",
"onlyShow",
")",
"{",
"$",
"this",
"->",
"onlyShow",
"=",
"(",
"bool",
")",
"$",
"onlyShow",
";",
"if",
"(",
"$",
"this",
"->",
"onlyShow",
")",
"{",
"$",
"this",
"->",
"onlyHide",
"=",
"null",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set Show Only
@api
@param bool $onlyShow If it should only show the Control but not toggle
@return static
|
[
"Set",
"Show",
"Only"
] |
train
|
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/Toggle.php#L175-L182
|
steeffeen/FancyManiaLinks
|
FML/Script/Features/Toggle.php
|
Toggle.setOnlyHide
|
public function setOnlyHide($onlyHide)
{
$this->onlyHide = (bool)$onlyHide;
if ($this->onlyHide) {
$this->onlyShow = null;
}
return $this;
}
|
php
|
public function setOnlyHide($onlyHide)
{
$this->onlyHide = (bool)$onlyHide;
if ($this->onlyHide) {
$this->onlyShow = null;
}
return $this;
}
|
[
"public",
"function",
"setOnlyHide",
"(",
"$",
"onlyHide",
")",
"{",
"$",
"this",
"->",
"onlyHide",
"=",
"(",
"bool",
")",
"$",
"onlyHide",
";",
"if",
"(",
"$",
"this",
"->",
"onlyHide",
")",
"{",
"$",
"this",
"->",
"onlyShow",
"=",
"null",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set Hide Only
@api
@param bool $onlyHide If it should only hide the Control but not toggle
@return static
|
[
"Set",
"Hide",
"Only"
] |
train
|
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/Toggle.php#L202-L209
|
steeffeen/FancyManiaLinks
|
FML/Script/Features/Toggle.php
|
Toggle.getScriptText
|
protected function getScriptText()
{
$togglingControlId = Builder::escapeText($this->togglingControl->getId());
$toggledControlId = Builder::escapeText($this->toggledControl->getId());
$visibility = "!ToggleControl.Visible";
if ($this->onlyShow) {
$visibility = "True";
} else if ($this->onlyHide) {
$visibility = "False";
}
return "
if (Event.Control.ControlId == {$togglingControlId}) {
declare ToggleControl = Page.GetFirstChild({$toggledControlId});
ToggleControl.Visible = {$visibility};
}";
}
|
php
|
protected function getScriptText()
{
$togglingControlId = Builder::escapeText($this->togglingControl->getId());
$toggledControlId = Builder::escapeText($this->toggledControl->getId());
$visibility = "!ToggleControl.Visible";
if ($this->onlyShow) {
$visibility = "True";
} else if ($this->onlyHide) {
$visibility = "False";
}
return "
if (Event.Control.ControlId == {$togglingControlId}) {
declare ToggleControl = Page.GetFirstChild({$toggledControlId});
ToggleControl.Visible = {$visibility};
}";
}
|
[
"protected",
"function",
"getScriptText",
"(",
")",
"{",
"$",
"togglingControlId",
"=",
"Builder",
"::",
"escapeText",
"(",
"$",
"this",
"->",
"togglingControl",
"->",
"getId",
"(",
")",
")",
";",
"$",
"toggledControlId",
"=",
"Builder",
"::",
"escapeText",
"(",
"$",
"this",
"->",
"toggledControl",
"->",
"getId",
"(",
")",
")",
";",
"$",
"visibility",
"=",
"\"!ToggleControl.Visible\"",
";",
"if",
"(",
"$",
"this",
"->",
"onlyShow",
")",
"{",
"$",
"visibility",
"=",
"\"True\"",
";",
"}",
"else",
"if",
"(",
"$",
"this",
"->",
"onlyHide",
")",
"{",
"$",
"visibility",
"=",
"\"False\"",
";",
"}",
"return",
"\"\nif (Event.Control.ControlId == {$togglingControlId}) {\n\tdeclare ToggleControl = Page.GetFirstChild({$toggledControlId});\n\tToggleControl.Visible = {$visibility};\n}\"",
";",
"}"
] |
Get the script text
@return string
|
[
"Get",
"the",
"script",
"text"
] |
train
|
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/Toggle.php#L225-L240
|
liugene/framework
|
src/Collection.php
|
Collection.each
|
public function each(callable $callback)
{
foreach ($this->items as $key => $item) {
$result = $callback($item, $key);
if (false === $result) {
break;
}
if (!is_object($item)) {
$this->items[$key] = $result;
}
}
return $this;
}
|
php
|
public function each(callable $callback)
{
foreach ($this->items as $key => $item) {
$result = $callback($item, $key);
if (false === $result) {
break;
}
if (!is_object($item)) {
$this->items[$key] = $result;
}
}
return $this;
}
|
[
"public",
"function",
"each",
"(",
"callable",
"$",
"callback",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"key",
"=>",
"$",
"item",
")",
"{",
"$",
"result",
"=",
"$",
"callback",
"(",
"$",
"item",
",",
"$",
"key",
")",
";",
"if",
"(",
"false",
"===",
"$",
"result",
")",
"{",
"break",
";",
"}",
"if",
"(",
"!",
"is_object",
"(",
"$",
"item",
")",
")",
"{",
"$",
"this",
"->",
"items",
"[",
"$",
"key",
"]",
"=",
"$",
"result",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
给数据中的每个元素执行回调
@access public
@param callable $callback 回调函数
@return $this
|
[
"给数据中的每个元素执行回调"
] |
train
|
https://github.com/liugene/framework/blob/450642242442c5884d47552a588a2639923e7289/src/Collection.php#L224-L239
|
liugene/framework
|
src/Collection.php
|
Collection.column
|
public function column($columnKey, $indexKey = null)
{
if (function_exists('array_column')) {
return array_column($this->items, $columnKey, $indexKey);
}
$result = [];
foreach ($this->items as $row) {
$key = $value = null;
$keySet = $valueSet = false;
if (null !== $indexKey && array_key_exists($indexKey, $row)) {
$key = (string) $row[$indexKey];
$keySet = true;
}
if (null === $columnKey) {
$valueSet = true;
$value = $row;
} elseif (is_array($row) && array_key_exists($columnKey, $row)) {
$valueSet = true;
$value = $row[$columnKey];
}
if ($valueSet) {
if ($keySet) {
$result[$key] = $value;
} else {
$result[] = $value;
}
}
}
return $result;
}
|
php
|
public function column($columnKey, $indexKey = null)
{
if (function_exists('array_column')) {
return array_column($this->items, $columnKey, $indexKey);
}
$result = [];
foreach ($this->items as $row) {
$key = $value = null;
$keySet = $valueSet = false;
if (null !== $indexKey && array_key_exists($indexKey, $row)) {
$key = (string) $row[$indexKey];
$keySet = true;
}
if (null === $columnKey) {
$valueSet = true;
$value = $row;
} elseif (is_array($row) && array_key_exists($columnKey, $row)) {
$valueSet = true;
$value = $row[$columnKey];
}
if ($valueSet) {
if ($keySet) {
$result[$key] = $value;
} else {
$result[] = $value;
}
}
}
return $result;
}
|
[
"public",
"function",
"column",
"(",
"$",
"columnKey",
",",
"$",
"indexKey",
"=",
"null",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'array_column'",
")",
")",
"{",
"return",
"array_column",
"(",
"$",
"this",
"->",
"items",
",",
"$",
"columnKey",
",",
"$",
"indexKey",
")",
";",
"}",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"row",
")",
"{",
"$",
"key",
"=",
"$",
"value",
"=",
"null",
";",
"$",
"keySet",
"=",
"$",
"valueSet",
"=",
"false",
";",
"if",
"(",
"null",
"!==",
"$",
"indexKey",
"&&",
"array_key_exists",
"(",
"$",
"indexKey",
",",
"$",
"row",
")",
")",
"{",
"$",
"key",
"=",
"(",
"string",
")",
"$",
"row",
"[",
"$",
"indexKey",
"]",
";",
"$",
"keySet",
"=",
"true",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"columnKey",
")",
"{",
"$",
"valueSet",
"=",
"true",
";",
"$",
"value",
"=",
"$",
"row",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"row",
")",
"&&",
"array_key_exists",
"(",
"$",
"columnKey",
",",
"$",
"row",
")",
")",
"{",
"$",
"valueSet",
"=",
"true",
";",
"$",
"value",
"=",
"$",
"row",
"[",
"$",
"columnKey",
"]",
";",
"}",
"if",
"(",
"$",
"valueSet",
")",
"{",
"if",
"(",
"$",
"keySet",
")",
"{",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
返回数据中指定的一列
@access public
@param mixed $columnKey 键名
@param null $indexKey 作为索引值的列
@return array
|
[
"返回数据中指定的一列"
] |
train
|
https://github.com/liugene/framework/blob/450642242442c5884d47552a588a2639923e7289/src/Collection.php#L259-L293
|
webforge-labs/psc-cms
|
lib/Psc/Net/HTTP/RequestHandler.php
|
RequestHandler.findService
|
public function findService(ServiceRequest $serviceRequest) {
$this->log('Find Services..');
foreach ($this->services as $service) {
$this->log('Service: '.Code::getClass($service).'::isResponsibleFor');
if ($service->isResponsibleFor($serviceRequest)) {
$this->log('ok: Service übernimmt den Request');
return $service;
}
}
throw NoServiceFoundException::build(
'Es konnte kein passender Service ermittelt werden. Es wurden %d Services (%s) befragt.',
count($this->services),
\Webforge\Common\ArrayUtil::implode($this->services, ', ', function ($svc) { return Code::getClass($svc); })
)->set('serviceRequest',$serviceRequest)
->end();
}
|
php
|
public function findService(ServiceRequest $serviceRequest) {
$this->log('Find Services..');
foreach ($this->services as $service) {
$this->log('Service: '.Code::getClass($service).'::isResponsibleFor');
if ($service->isResponsibleFor($serviceRequest)) {
$this->log('ok: Service übernimmt den Request');
return $service;
}
}
throw NoServiceFoundException::build(
'Es konnte kein passender Service ermittelt werden. Es wurden %d Services (%s) befragt.',
count($this->services),
\Webforge\Common\ArrayUtil::implode($this->services, ', ', function ($svc) { return Code::getClass($svc); })
)->set('serviceRequest',$serviceRequest)
->end();
}
|
[
"public",
"function",
"findService",
"(",
"ServiceRequest",
"$",
"serviceRequest",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"'Find Services..'",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"services",
"as",
"$",
"service",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"'Service: '",
".",
"Code",
"::",
"getClass",
"(",
"$",
"service",
")",
".",
"'::isResponsibleFor'",
")",
";",
"if",
"(",
"$",
"service",
"->",
"isResponsibleFor",
"(",
"$",
"serviceRequest",
")",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"'ok: Service übernimmt den Request')",
";",
"",
"return",
"$",
"service",
";",
"}",
"}",
"throw",
"NoServiceFoundException",
"::",
"build",
"(",
"'Es konnte kein passender Service ermittelt werden. Es wurden %d Services (%s) befragt.'",
",",
"count",
"(",
"$",
"this",
"->",
"services",
")",
",",
"\\",
"Webforge",
"\\",
"Common",
"\\",
"ArrayUtil",
"::",
"implode",
"(",
"$",
"this",
"->",
"services",
",",
"', '",
",",
"function",
"(",
"$",
"svc",
")",
"{",
"return",
"Code",
"::",
"getClass",
"(",
"$",
"svc",
")",
";",
"}",
")",
")",
"->",
"set",
"(",
"'serviceRequest'",
",",
"$",
"serviceRequest",
")",
"->",
"end",
"(",
")",
";",
"}"
] |
Sucht den ersten der Services, der den Request bearbeiten will
@throws NoServiceFoundException
|
[
"Sucht",
"den",
"ersten",
"der",
"Services",
"der",
"den",
"Request",
"bearbeiten",
"will"
] |
train
|
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Net/HTTP/RequestHandler.php#L216-L232
|
webforge-labs/psc-cms
|
lib/Psc/Net/HTTP/RequestHandler.php
|
RequestHandler.addService
|
public function addService(Service $service) {
if (!in_array($service, $this->services, TRUE)) {
$this->services[] = $service;
if ($service instanceof \Psc\System\LoggerObject && $service->getLogger() instanceof \Psc\System\DispatchingLogger) {
$this->getLogger()->listenTo($service->getLogger());
}
}
return $this;
}
|
php
|
public function addService(Service $service) {
if (!in_array($service, $this->services, TRUE)) {
$this->services[] = $service;
if ($service instanceof \Psc\System\LoggerObject && $service->getLogger() instanceof \Psc\System\DispatchingLogger) {
$this->getLogger()->listenTo($service->getLogger());
}
}
return $this;
}
|
[
"public",
"function",
"addService",
"(",
"Service",
"$",
"service",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"service",
",",
"$",
"this",
"->",
"services",
",",
"TRUE",
")",
")",
"{",
"$",
"this",
"->",
"services",
"[",
"]",
"=",
"$",
"service",
";",
"if",
"(",
"$",
"service",
"instanceof",
"\\",
"Psc",
"\\",
"System",
"\\",
"LoggerObject",
"&&",
"$",
"service",
"->",
"getLogger",
"(",
")",
"instanceof",
"\\",
"Psc",
"\\",
"System",
"\\",
"DispatchingLogger",
")",
"{",
"$",
"this",
"->",
"getLogger",
"(",
")",
"->",
"listenTo",
"(",
"$",
"service",
"->",
"getLogger",
"(",
")",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Fügt einen Service hinzu
spätere Services werden immer auch später nach isResponsibleFor()- gefragt (bis jetzt)
|
[
"Fügt",
"einen",
"Service",
"hinzu"
] |
train
|
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Net/HTTP/RequestHandler.php#L262-L271
|
webforge-labs/psc-cms
|
lib/Psc/Net/HTTP/RequestHandler.php
|
RequestHandler.dumpRequest
|
protected function dumpRequest(Request $request) {
$body = $request->getBody();
$dump = "Body of request is:\n";
if (is_object($body) || is_array($body)) {
$dump .= json_encode($body);
} elseif(is_string($body)) {
$dump .= sprintf('"%s"',$body);
}
return $dump;
}
|
php
|
protected function dumpRequest(Request $request) {
$body = $request->getBody();
$dump = "Body of request is:\n";
if (is_object($body) || is_array($body)) {
$dump .= json_encode($body);
} elseif(is_string($body)) {
$dump .= sprintf('"%s"',$body);
}
return $dump;
}
|
[
"protected",
"function",
"dumpRequest",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"body",
"=",
"$",
"request",
"->",
"getBody",
"(",
")",
";",
"$",
"dump",
"=",
"\"Body of request is:\\n\"",
";",
"if",
"(",
"is_object",
"(",
"$",
"body",
")",
"||",
"is_array",
"(",
"$",
"body",
")",
")",
"{",
"$",
"dump",
".=",
"json_encode",
"(",
"$",
"body",
")",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"body",
")",
")",
"{",
"$",
"dump",
".=",
"sprintf",
"(",
"'\"%s\"'",
",",
"$",
"body",
")",
";",
"}",
"return",
"$",
"dump",
";",
"}"
] |
returns a importable string representation of the request
@return string
|
[
"returns",
"a",
"importable",
"string",
"representation",
"of",
"the",
"request"
] |
train
|
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Net/HTTP/RequestHandler.php#L317-L329
|
webforge-labs/psc-cms
|
lib/Psc/Net/HTTP/RequestHandler.php
|
RequestHandler.setServices
|
public function setServices(Array $services) {
$this->services = array();
foreach ($services as $service) {
$this->addService($service);
}
return $this;
}
|
php
|
public function setServices(Array $services) {
$this->services = array();
foreach ($services as $service) {
$this->addService($service);
}
return $this;
}
|
[
"public",
"function",
"setServices",
"(",
"Array",
"$",
"services",
")",
"{",
"$",
"this",
"->",
"services",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"services",
"as",
"$",
"service",
")",
"{",
"$",
"this",
"->",
"addService",
"(",
"$",
"service",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Überschreibt alle Services
|
[
"Überschreibt",
"alle",
"Services"
] |
train
|
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Net/HTTP/RequestHandler.php#L369-L375
|
CakeCMS/Core
|
src/View/Widget/MaterializeCss/FileWidget.php
|
FileWidget.render
|
public function render(array $data, ContextInterface $context)
{
$data += [
'name' => '',
'templateVars' => [],
'escape' => true
];
unset($data['val']);
$title = (Arr::key('title', $data)) ? $data['title'] : $data['name'];
return $this->_templates->format('file', [
'title' => $title,
'name' => $data['name'],
'templateVars' => $data['templateVars'],
'attrs' => $this->_templates->formatAttributes($data, ['name'])
]);
}
|
php
|
public function render(array $data, ContextInterface $context)
{
$data += [
'name' => '',
'templateVars' => [],
'escape' => true
];
unset($data['val']);
$title = (Arr::key('title', $data)) ? $data['title'] : $data['name'];
return $this->_templates->format('file', [
'title' => $title,
'name' => $data['name'],
'templateVars' => $data['templateVars'],
'attrs' => $this->_templates->formatAttributes($data, ['name'])
]);
}
|
[
"public",
"function",
"render",
"(",
"array",
"$",
"data",
",",
"ContextInterface",
"$",
"context",
")",
"{",
"$",
"data",
"+=",
"[",
"'name'",
"=>",
"''",
",",
"'templateVars'",
"=>",
"[",
"]",
",",
"'escape'",
"=>",
"true",
"]",
";",
"unset",
"(",
"$",
"data",
"[",
"'val'",
"]",
")",
";",
"$",
"title",
"=",
"(",
"Arr",
"::",
"key",
"(",
"'title'",
",",
"$",
"data",
")",
")",
"?",
"$",
"data",
"[",
"'title'",
"]",
":",
"$",
"data",
"[",
"'name'",
"]",
";",
"return",
"$",
"this",
"->",
"_templates",
"->",
"format",
"(",
"'file'",
",",
"[",
"'title'",
"=>",
"$",
"title",
",",
"'name'",
"=>",
"$",
"data",
"[",
"'name'",
"]",
",",
"'templateVars'",
"=>",
"$",
"data",
"[",
"'templateVars'",
"]",
",",
"'attrs'",
"=>",
"$",
"this",
"->",
"_templates",
"->",
"formatAttributes",
"(",
"$",
"data",
",",
"[",
"'name'",
"]",
")",
"]",
")",
";",
"}"
] |
Render a file upload form widget.
Data supports the following keys:
- `name` - Set the input name.
- `escape` - Set to false to disable HTML escaping.
All other keys will be converted into HTML attributes.
Unlike other input objects the `val` property will be specifically
ignored.
@param array $data The data to build a file input with.
@param \Cake\View\Form\ContextInterface $context The current form context.
@return string HTML elements.
|
[
"Render",
"a",
"file",
"upload",
"form",
"widget",
"."
] |
train
|
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Widget/MaterializeCss/FileWidget.php#L47-L65
|
VincentChalnot/SidusEAVFilterBundle
|
Pager/Adapter/EAVAdapter.php
|
EAVAdapter.create
|
public static function create(DataLoaderInterface $dataLoader, QueryBuilder $qb, $depth = 2)
{
return new self(
$dataLoader,
new DoctrineORMAdapter($qb, false, $depth)
);
}
|
php
|
public static function create(DataLoaderInterface $dataLoader, QueryBuilder $qb, $depth = 2)
{
return new self(
$dataLoader,
new DoctrineORMAdapter($qb, false, $depth)
);
}
|
[
"public",
"static",
"function",
"create",
"(",
"DataLoaderInterface",
"$",
"dataLoader",
",",
"QueryBuilder",
"$",
"qb",
",",
"$",
"depth",
"=",
"2",
")",
"{",
"return",
"new",
"self",
"(",
"$",
"dataLoader",
",",
"new",
"DoctrineORMAdapter",
"(",
"$",
"qb",
",",
"false",
",",
"$",
"depth",
")",
")",
";",
"}"
] |
Automatically creates an adapter with the Sidus/FilterBundle's DoctrineORMAdapter
@param DataLoaderInterface $dataLoader
@param QueryBuilder $qb
@param int $depth
@return EAVAdapter
|
[
"Automatically",
"creates",
"an",
"adapter",
"with",
"the",
"Sidus",
"/",
"FilterBundle",
"s",
"DoctrineORMAdapter"
] |
train
|
https://github.com/VincentChalnot/SidusEAVFilterBundle/blob/25a9e0495fae30cb96ecded56c50cf7fe70c9032/Pager/Adapter/EAVAdapter.php#L35-L41
|
VincentChalnot/SidusEAVFilterBundle
|
Pager/Adapter/EAVAdapter.php
|
EAVAdapter.getSlice
|
public function getSlice($offset, $length)
{
$iterator = $this->baseAdapter->getSlice($offset, $length);
$this->dataLoader->load($iterator, $this->depth);
return $iterator;
}
|
php
|
public function getSlice($offset, $length)
{
$iterator = $this->baseAdapter->getSlice($offset, $length);
$this->dataLoader->load($iterator, $this->depth);
return $iterator;
}
|
[
"public",
"function",
"getSlice",
"(",
"$",
"offset",
",",
"$",
"length",
")",
"{",
"$",
"iterator",
"=",
"$",
"this",
"->",
"baseAdapter",
"->",
"getSlice",
"(",
"$",
"offset",
",",
"$",
"length",
")",
";",
"$",
"this",
"->",
"dataLoader",
"->",
"load",
"(",
"$",
"iterator",
",",
"$",
"this",
"->",
"depth",
")",
";",
"return",
"$",
"iterator",
";",
"}"
] |
{@inheritdoc}
|
[
"{"
] |
train
|
https://github.com/VincentChalnot/SidusEAVFilterBundle/blob/25a9e0495fae30cb96ecded56c50cf7fe70c9032/Pager/Adapter/EAVAdapter.php#L61-L67
|
slashworks/control-bundle
|
src/Slashworks/BackendBundle/Form/Type/InstallType.php
|
InstallType.buildForm
|
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add("controlUrl", "text", array(
'required' => true,
'data' => $this->_getSiteURL(),
'constraints' => array(
new NotBlank(),
new Length(array('min' => 3)),
)
)
)
->add("adminUser", "text", array(
'required' => true,
'data' => 'admin',
'constraints' => array(
new NotBlank(),
new Length(array('min' => 3)),
)
)
)
->add("adminEmail", "text", array(
'required' => true,
'data' => '',
'constraints' => array(
new NotBlank(),
new Length(array('min' => 3)),
)
)
)
->add('adminPassword', 'password', array(
'required' => true,
'constraints' => array(
new NotBlank(),
new Length(array('min' => 3)),
)
)
)
->add('dbDriver', 'choice', array(
'choices' => array(
'pdo_mysql' => 'MySQL (PDO)',
// 'pdo_sqlite' => 'SQLite (PDO)',
'pdo_pgsql' => 'PosgreSQL (PDO)',
// 'oci8' => 'Oracle (native)',
// 'ibm_db2' => 'IBM DB2 (native)',
// 'pdo_oci' => 'Oracle (PDO)',
// 'pdo_ibm' => 'IBM DB2 (PDO)',
// 'pdo_sqlsrv' => 'SQLServer (PDO)',
),
'required' => true, 'data' => 'MySQLi',
'constraints' => array(
new NotBlank(),
)
)
)
->add('dbHost', 'text', array(
'required' => true,
'data' => 'localhost',
'constraints' => array(
new NotBlank(),
new Length(array('min' => 3)),
)
)
)
->add('dbName', 'text', array(
'required' => true,
'data' => '',
'constraints' => array(
new NotBlank(),
new Length(array('min' => 3)),
)
)
)
->add('dbUser', 'text', array(
'required' => true,
'data' => '',
'constraints' => array(
new NotBlank(),
new Length(array('min' => 3)),
)
)
)
->add('dbPassword', 'password', array(
'required' => true,
'data' => '',
'constraints' => array(
new NotBlank(),
new Length(array('min' => 3)),
)
)
)
->add('dbPort', 'text', array(
'required' => true,
'data' => 3306,
'constraints' => array(
new NotBlank(),
new Length(array('min' => 4)),
)
)
)
->add('mailerTransport', 'choice', array(
'choices' => array('smtp'=>'smtp', 'mail'=> 'mail', 'sendmail'=>'sendmail'),
'required' => true,
'data' => 'smtp',
'constraints' => array(
new NotBlank(),
)
)
)
->add('mailerHost', 'text', array('required' => false, 'data' => 'localhost'))
->add('mailerUser', 'text', array('required' => false))
->add('mailerPassword', 'password', array('required' => false));
}
|
php
|
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add("controlUrl", "text", array(
'required' => true,
'data' => $this->_getSiteURL(),
'constraints' => array(
new NotBlank(),
new Length(array('min' => 3)),
)
)
)
->add("adminUser", "text", array(
'required' => true,
'data' => 'admin',
'constraints' => array(
new NotBlank(),
new Length(array('min' => 3)),
)
)
)
->add("adminEmail", "text", array(
'required' => true,
'data' => '',
'constraints' => array(
new NotBlank(),
new Length(array('min' => 3)),
)
)
)
->add('adminPassword', 'password', array(
'required' => true,
'constraints' => array(
new NotBlank(),
new Length(array('min' => 3)),
)
)
)
->add('dbDriver', 'choice', array(
'choices' => array(
'pdo_mysql' => 'MySQL (PDO)',
// 'pdo_sqlite' => 'SQLite (PDO)',
'pdo_pgsql' => 'PosgreSQL (PDO)',
// 'oci8' => 'Oracle (native)',
// 'ibm_db2' => 'IBM DB2 (native)',
// 'pdo_oci' => 'Oracle (PDO)',
// 'pdo_ibm' => 'IBM DB2 (PDO)',
// 'pdo_sqlsrv' => 'SQLServer (PDO)',
),
'required' => true, 'data' => 'MySQLi',
'constraints' => array(
new NotBlank(),
)
)
)
->add('dbHost', 'text', array(
'required' => true,
'data' => 'localhost',
'constraints' => array(
new NotBlank(),
new Length(array('min' => 3)),
)
)
)
->add('dbName', 'text', array(
'required' => true,
'data' => '',
'constraints' => array(
new NotBlank(),
new Length(array('min' => 3)),
)
)
)
->add('dbUser', 'text', array(
'required' => true,
'data' => '',
'constraints' => array(
new NotBlank(),
new Length(array('min' => 3)),
)
)
)
->add('dbPassword', 'password', array(
'required' => true,
'data' => '',
'constraints' => array(
new NotBlank(),
new Length(array('min' => 3)),
)
)
)
->add('dbPort', 'text', array(
'required' => true,
'data' => 3306,
'constraints' => array(
new NotBlank(),
new Length(array('min' => 4)),
)
)
)
->add('mailerTransport', 'choice', array(
'choices' => array('smtp'=>'smtp', 'mail'=> 'mail', 'sendmail'=>'sendmail'),
'required' => true,
'data' => 'smtp',
'constraints' => array(
new NotBlank(),
)
)
)
->add('mailerHost', 'text', array('required' => false, 'data' => 'localhost'))
->add('mailerUser', 'text', array('required' => false))
->add('mailerPassword', 'password', array('required' => false));
}
|
[
"public",
"function",
"buildForm",
"(",
"FormBuilderInterface",
"$",
"builder",
",",
"array",
"$",
"options",
")",
"{",
"$",
"builder",
"->",
"add",
"(",
"\"controlUrl\"",
",",
"\"text\"",
",",
"array",
"(",
"'required'",
"=>",
"true",
",",
"'data'",
"=>",
"$",
"this",
"->",
"_getSiteURL",
"(",
")",
",",
"'constraints'",
"=>",
"array",
"(",
"new",
"NotBlank",
"(",
")",
",",
"new",
"Length",
"(",
"array",
"(",
"'min'",
"=>",
"3",
")",
")",
",",
")",
")",
")",
"->",
"add",
"(",
"\"adminUser\"",
",",
"\"text\"",
",",
"array",
"(",
"'required'",
"=>",
"true",
",",
"'data'",
"=>",
"'admin'",
",",
"'constraints'",
"=>",
"array",
"(",
"new",
"NotBlank",
"(",
")",
",",
"new",
"Length",
"(",
"array",
"(",
"'min'",
"=>",
"3",
")",
")",
",",
")",
")",
")",
"->",
"add",
"(",
"\"adminEmail\"",
",",
"\"text\"",
",",
"array",
"(",
"'required'",
"=>",
"true",
",",
"'data'",
"=>",
"''",
",",
"'constraints'",
"=>",
"array",
"(",
"new",
"NotBlank",
"(",
")",
",",
"new",
"Length",
"(",
"array",
"(",
"'min'",
"=>",
"3",
")",
")",
",",
")",
")",
")",
"->",
"add",
"(",
"'adminPassword'",
",",
"'password'",
",",
"array",
"(",
"'required'",
"=>",
"true",
",",
"'constraints'",
"=>",
"array",
"(",
"new",
"NotBlank",
"(",
")",
",",
"new",
"Length",
"(",
"array",
"(",
"'min'",
"=>",
"3",
")",
")",
",",
")",
")",
")",
"->",
"add",
"(",
"'dbDriver'",
",",
"'choice'",
",",
"array",
"(",
"'choices'",
"=>",
"array",
"(",
"'pdo_mysql'",
"=>",
"'MySQL (PDO)'",
",",
"// 'pdo_sqlite' => 'SQLite (PDO)',",
"'pdo_pgsql'",
"=>",
"'PosgreSQL (PDO)'",
",",
"// 'oci8' => 'Oracle (native)',",
"// 'ibm_db2' => 'IBM DB2 (native)',",
"// 'pdo_oci' => 'Oracle (PDO)',",
"// 'pdo_ibm' => 'IBM DB2 (PDO)',",
"// 'pdo_sqlsrv' => 'SQLServer (PDO)',",
")",
",",
"'required'",
"=>",
"true",
",",
"'data'",
"=>",
"'MySQLi'",
",",
"'constraints'",
"=>",
"array",
"(",
"new",
"NotBlank",
"(",
")",
",",
")",
")",
")",
"->",
"add",
"(",
"'dbHost'",
",",
"'text'",
",",
"array",
"(",
"'required'",
"=>",
"true",
",",
"'data'",
"=>",
"'localhost'",
",",
"'constraints'",
"=>",
"array",
"(",
"new",
"NotBlank",
"(",
")",
",",
"new",
"Length",
"(",
"array",
"(",
"'min'",
"=>",
"3",
")",
")",
",",
")",
")",
")",
"->",
"add",
"(",
"'dbName'",
",",
"'text'",
",",
"array",
"(",
"'required'",
"=>",
"true",
",",
"'data'",
"=>",
"''",
",",
"'constraints'",
"=>",
"array",
"(",
"new",
"NotBlank",
"(",
")",
",",
"new",
"Length",
"(",
"array",
"(",
"'min'",
"=>",
"3",
")",
")",
",",
")",
")",
")",
"->",
"add",
"(",
"'dbUser'",
",",
"'text'",
",",
"array",
"(",
"'required'",
"=>",
"true",
",",
"'data'",
"=>",
"''",
",",
"'constraints'",
"=>",
"array",
"(",
"new",
"NotBlank",
"(",
")",
",",
"new",
"Length",
"(",
"array",
"(",
"'min'",
"=>",
"3",
")",
")",
",",
")",
")",
")",
"->",
"add",
"(",
"'dbPassword'",
",",
"'password'",
",",
"array",
"(",
"'required'",
"=>",
"true",
",",
"'data'",
"=>",
"''",
",",
"'constraints'",
"=>",
"array",
"(",
"new",
"NotBlank",
"(",
")",
",",
"new",
"Length",
"(",
"array",
"(",
"'min'",
"=>",
"3",
")",
")",
",",
")",
")",
")",
"->",
"add",
"(",
"'dbPort'",
",",
"'text'",
",",
"array",
"(",
"'required'",
"=>",
"true",
",",
"'data'",
"=>",
"3306",
",",
"'constraints'",
"=>",
"array",
"(",
"new",
"NotBlank",
"(",
")",
",",
"new",
"Length",
"(",
"array",
"(",
"'min'",
"=>",
"4",
")",
")",
",",
")",
")",
")",
"->",
"add",
"(",
"'mailerTransport'",
",",
"'choice'",
",",
"array",
"(",
"'choices'",
"=>",
"array",
"(",
"'smtp'",
"=>",
"'smtp'",
",",
"'mail'",
"=>",
"'mail'",
",",
"'sendmail'",
"=>",
"'sendmail'",
")",
",",
"'required'",
"=>",
"true",
",",
"'data'",
"=>",
"'smtp'",
",",
"'constraints'",
"=>",
"array",
"(",
"new",
"NotBlank",
"(",
")",
",",
")",
")",
")",
"->",
"add",
"(",
"'mailerHost'",
",",
"'text'",
",",
"array",
"(",
"'required'",
"=>",
"false",
",",
"'data'",
"=>",
"'localhost'",
")",
")",
"->",
"add",
"(",
"'mailerUser'",
",",
"'text'",
",",
"array",
"(",
"'required'",
"=>",
"false",
")",
")",
"->",
"add",
"(",
"'mailerPassword'",
",",
"'password'",
",",
"array",
"(",
"'required'",
"=>",
"false",
")",
")",
";",
"}"
] |
{@inheritdoc}
|
[
"{"
] |
train
|
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Form/Type/InstallType.php#L43-L157
|
drsdre/yii2-xmlsoccer
|
models/Team.php
|
Team.getMatches
|
public function getMatches()
{
$matches = ArrayHelper::merge($this->homeMatches, $this->awayMatches);
ArrayHelper::multisort($matches, 'date', SORT_ASC);
return $matches;
}
|
php
|
public function getMatches()
{
$matches = ArrayHelper::merge($this->homeMatches, $this->awayMatches);
ArrayHelper::multisort($matches, 'date', SORT_ASC);
return $matches;
}
|
[
"public",
"function",
"getMatches",
"(",
")",
"{",
"$",
"matches",
"=",
"ArrayHelper",
"::",
"merge",
"(",
"$",
"this",
"->",
"homeMatches",
",",
"$",
"this",
"->",
"awayMatches",
")",
";",
"ArrayHelper",
"::",
"multisort",
"(",
"$",
"matches",
",",
"'date'",
",",
"SORT_ASC",
")",
";",
"return",
"$",
"matches",
";",
"}"
] |
Get all matches
@return array
|
[
"Get",
"all",
"matches"
] |
train
|
https://github.com/drsdre/yii2-xmlsoccer/blob/a746edee6269ed0791bac6c6165a946adc30d994/models/Team.php#L96-L101
|
anime-db/app-bundle
|
src/Controller/NoticeController.php
|
NoticeController.showAction
|
public function showAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
/* @var $rep NoticeRepository */
$rep = $em->getRepository('AnimeDbAppBundle:Notice');
$notice = $rep->getFirstShow();
// caching
/* @var $response JsonResponse */
$response = $this->getCacheTimeKeeper()->getResponse([], -1, new JsonResponse());
$response->setEtag(md5($notice ? $notice->getId() : 0));
// response was not modified for this request
if ($response->isNotModified($request)) {
return $response;
}
// shown notice
if (!is_null($notice)) {
$notice->shown();
$em->persist($notice);
$em->flush();
$response->setData([
'notice' => $notice->getId(),
'close' => $this->generateUrl('notice_close', ['id' => $notice->getId()]),
'see_later' => $this->generateUrl('notice_see_later'),
'content' => $this->renderView('AnimeDbAppBundle:Notice:show.html.twig', [
'notice' => $notice,
'link_all' => $request->query->getBoolean('all'),
]),
]);
}
return $response;
}
|
php
|
public function showAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
/* @var $rep NoticeRepository */
$rep = $em->getRepository('AnimeDbAppBundle:Notice');
$notice = $rep->getFirstShow();
// caching
/* @var $response JsonResponse */
$response = $this->getCacheTimeKeeper()->getResponse([], -1, new JsonResponse());
$response->setEtag(md5($notice ? $notice->getId() : 0));
// response was not modified for this request
if ($response->isNotModified($request)) {
return $response;
}
// shown notice
if (!is_null($notice)) {
$notice->shown();
$em->persist($notice);
$em->flush();
$response->setData([
'notice' => $notice->getId(),
'close' => $this->generateUrl('notice_close', ['id' => $notice->getId()]),
'see_later' => $this->generateUrl('notice_see_later'),
'content' => $this->renderView('AnimeDbAppBundle:Notice:show.html.twig', [
'notice' => $notice,
'link_all' => $request->query->getBoolean('all'),
]),
]);
}
return $response;
}
|
[
"public",
"function",
"showAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"/* @var $rep NoticeRepository */",
"$",
"rep",
"=",
"$",
"em",
"->",
"getRepository",
"(",
"'AnimeDbAppBundle:Notice'",
")",
";",
"$",
"notice",
"=",
"$",
"rep",
"->",
"getFirstShow",
"(",
")",
";",
"// caching",
"/* @var $response JsonResponse */",
"$",
"response",
"=",
"$",
"this",
"->",
"getCacheTimeKeeper",
"(",
")",
"->",
"getResponse",
"(",
"[",
"]",
",",
"-",
"1",
",",
"new",
"JsonResponse",
"(",
")",
")",
";",
"$",
"response",
"->",
"setEtag",
"(",
"md5",
"(",
"$",
"notice",
"?",
"$",
"notice",
"->",
"getId",
"(",
")",
":",
"0",
")",
")",
";",
"// response was not modified for this request",
"if",
"(",
"$",
"response",
"->",
"isNotModified",
"(",
"$",
"request",
")",
")",
"{",
"return",
"$",
"response",
";",
"}",
"// shown notice",
"if",
"(",
"!",
"is_null",
"(",
"$",
"notice",
")",
")",
"{",
"$",
"notice",
"->",
"shown",
"(",
")",
";",
"$",
"em",
"->",
"persist",
"(",
"$",
"notice",
")",
";",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"$",
"response",
"->",
"setData",
"(",
"[",
"'notice'",
"=>",
"$",
"notice",
"->",
"getId",
"(",
")",
",",
"'close'",
"=>",
"$",
"this",
"->",
"generateUrl",
"(",
"'notice_close'",
",",
"[",
"'id'",
"=>",
"$",
"notice",
"->",
"getId",
"(",
")",
"]",
")",
",",
"'see_later'",
"=>",
"$",
"this",
"->",
"generateUrl",
"(",
"'notice_see_later'",
")",
",",
"'content'",
"=>",
"$",
"this",
"->",
"renderView",
"(",
"'AnimeDbAppBundle:Notice:show.html.twig'",
",",
"[",
"'notice'",
"=>",
"$",
"notice",
",",
"'link_all'",
"=>",
"$",
"request",
"->",
"query",
"->",
"getBoolean",
"(",
"'all'",
")",
",",
"]",
")",
",",
"]",
")",
";",
"}",
"return",
"$",
"response",
";",
"}"
] |
Show last notice.
@param Request $request
@return JsonResponse
|
[
"Show",
"last",
"notice",
"."
] |
train
|
https://github.com/anime-db/app-bundle/blob/ca3b342081719d41ba018792a75970cbb1f1fe22/src/Controller/NoticeController.php#L25-L59
|
anime-db/app-bundle
|
src/Controller/NoticeController.php
|
NoticeController.closeAction
|
public function closeAction(Notice $notice)
{
// mark as closed
$notice->setStatus(Notice::STATUS_CLOSED);
$em = $this->getDoctrine()->getManager();
$em->persist($notice);
$em->flush();
return new JsonResponse([]);
}
|
php
|
public function closeAction(Notice $notice)
{
// mark as closed
$notice->setStatus(Notice::STATUS_CLOSED);
$em = $this->getDoctrine()->getManager();
$em->persist($notice);
$em->flush();
return new JsonResponse([]);
}
|
[
"public",
"function",
"closeAction",
"(",
"Notice",
"$",
"notice",
")",
"{",
"// mark as closed",
"$",
"notice",
"->",
"setStatus",
"(",
"Notice",
"::",
"STATUS_CLOSED",
")",
";",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"em",
"->",
"persist",
"(",
"$",
"notice",
")",
";",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"return",
"new",
"JsonResponse",
"(",
"[",
"]",
")",
";",
"}"
] |
@param Notice $notice
@return JsonResponse
|
[
"@param",
"Notice",
"$notice"
] |
train
|
https://github.com/anime-db/app-bundle/blob/ca3b342081719d41ba018792a75970cbb1f1fe22/src/Controller/NoticeController.php#L66-L75
|
flipboxstudio/orm-manager
|
src/Flipbox/OrmManager/BothRelations/ManyToMany.php
|
ManyToMany.setDefaultOptions
|
protected function setDefaultOptions(array $options=[])
{
$tables = [
'model' => $this->model->getTable(),
'toModel' => $this->toModel->getTable()
];
asort($tables, SORT_REGULAR);
$pivotTable = implode('_', array_map([Str::class, 'singular'], $tables));
$this->defaultOptions = [
'pivot_table' => $pivotTable,
'foreign_key' => $this->model->getForeignKey(),
'related_key' => $this->toModel->getForeignKey(),
'relation' => $this->toModel->getTable()
];
}
|
php
|
protected function setDefaultOptions(array $options=[])
{
$tables = [
'model' => $this->model->getTable(),
'toModel' => $this->toModel->getTable()
];
asort($tables, SORT_REGULAR);
$pivotTable = implode('_', array_map([Str::class, 'singular'], $tables));
$this->defaultOptions = [
'pivot_table' => $pivotTable,
'foreign_key' => $this->model->getForeignKey(),
'related_key' => $this->toModel->getForeignKey(),
'relation' => $this->toModel->getTable()
];
}
|
[
"protected",
"function",
"setDefaultOptions",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"tables",
"=",
"[",
"'model'",
"=>",
"$",
"this",
"->",
"model",
"->",
"getTable",
"(",
")",
",",
"'toModel'",
"=>",
"$",
"this",
"->",
"toModel",
"->",
"getTable",
"(",
")",
"]",
";",
"asort",
"(",
"$",
"tables",
",",
"SORT_REGULAR",
")",
";",
"$",
"pivotTable",
"=",
"implode",
"(",
"'_'",
",",
"array_map",
"(",
"[",
"Str",
"::",
"class",
",",
"'singular'",
"]",
",",
"$",
"tables",
")",
")",
";",
"$",
"this",
"->",
"defaultOptions",
"=",
"[",
"'pivot_table'",
"=>",
"$",
"pivotTable",
",",
"'foreign_key'",
"=>",
"$",
"this",
"->",
"model",
"->",
"getForeignKey",
"(",
")",
",",
"'related_key'",
"=>",
"$",
"this",
"->",
"toModel",
"->",
"getForeignKey",
"(",
")",
",",
"'relation'",
"=>",
"$",
"this",
"->",
"toModel",
"->",
"getTable",
"(",
")",
"]",
";",
"}"
] |
set default options
@param array $options
@return void
|
[
"set",
"default",
"options"
] |
train
|
https://github.com/flipboxstudio/orm-manager/blob/4288426517f53d05177b8729c4ba94c5beca9a98/src/Flipbox/OrmManager/BothRelations/ManyToMany.php#L15-L31
|
flipboxstudio/orm-manager
|
src/Flipbox/OrmManager/BothRelations/ManyToMany.php
|
ManyToMany.stylingText
|
protected function stylingText()
{
$modelTable = $this->model->getTable();
$toModelTable = $this->toModel->getTable();
$pivotTable = $this->defaultOptions['pivot_table'];
$foreignKey = $this->defaultOptions['foreign_key'];
$relatedKey = $this->defaultOptions['related_key'];
$this->text = [
'table' => "[".$this->command->paintString($modelTable ,'green')."]",
'to_table' => "[".$this->command->paintString($toModelTable ,'green')."]",
'pivot_table' => "[".$this->command->paintString($pivotTable ,'green')."]",
'foreign_key' => "[".$this->command->paintString($foreignKey ,'green')."]",
'related_key' => "[".$this->command->paintString($relatedKey ,'green')."]",
'pivot_text' => $this->command->paintString('pivot table', 'brown'),
'foreign_text' => $this->command->paintString('foreign key', 'brown'),
'related_text' => $this->command->paintString('related key', 'brown'),
];
}
|
php
|
protected function stylingText()
{
$modelTable = $this->model->getTable();
$toModelTable = $this->toModel->getTable();
$pivotTable = $this->defaultOptions['pivot_table'];
$foreignKey = $this->defaultOptions['foreign_key'];
$relatedKey = $this->defaultOptions['related_key'];
$this->text = [
'table' => "[".$this->command->paintString($modelTable ,'green')."]",
'to_table' => "[".$this->command->paintString($toModelTable ,'green')."]",
'pivot_table' => "[".$this->command->paintString($pivotTable ,'green')."]",
'foreign_key' => "[".$this->command->paintString($foreignKey ,'green')."]",
'related_key' => "[".$this->command->paintString($relatedKey ,'green')."]",
'pivot_text' => $this->command->paintString('pivot table', 'brown'),
'foreign_text' => $this->command->paintString('foreign key', 'brown'),
'related_text' => $this->command->paintString('related key', 'brown'),
];
}
|
[
"protected",
"function",
"stylingText",
"(",
")",
"{",
"$",
"modelTable",
"=",
"$",
"this",
"->",
"model",
"->",
"getTable",
"(",
")",
";",
"$",
"toModelTable",
"=",
"$",
"this",
"->",
"toModel",
"->",
"getTable",
"(",
")",
";",
"$",
"pivotTable",
"=",
"$",
"this",
"->",
"defaultOptions",
"[",
"'pivot_table'",
"]",
";",
"$",
"foreignKey",
"=",
"$",
"this",
"->",
"defaultOptions",
"[",
"'foreign_key'",
"]",
";",
"$",
"relatedKey",
"=",
"$",
"this",
"->",
"defaultOptions",
"[",
"'related_key'",
"]",
";",
"$",
"this",
"->",
"text",
"=",
"[",
"'table'",
"=>",
"\"[\"",
".",
"$",
"this",
"->",
"command",
"->",
"paintString",
"(",
"$",
"modelTable",
",",
"'green'",
")",
".",
"\"]\"",
",",
"'to_table'",
"=>",
"\"[\"",
".",
"$",
"this",
"->",
"command",
"->",
"paintString",
"(",
"$",
"toModelTable",
",",
"'green'",
")",
".",
"\"]\"",
",",
"'pivot_table'",
"=>",
"\"[\"",
".",
"$",
"this",
"->",
"command",
"->",
"paintString",
"(",
"$",
"pivotTable",
",",
"'green'",
")",
".",
"\"]\"",
",",
"'foreign_key'",
"=>",
"\"[\"",
".",
"$",
"this",
"->",
"command",
"->",
"paintString",
"(",
"$",
"foreignKey",
",",
"'green'",
")",
".",
"\"]\"",
",",
"'related_key'",
"=>",
"\"[\"",
".",
"$",
"this",
"->",
"command",
"->",
"paintString",
"(",
"$",
"relatedKey",
",",
"'green'",
")",
".",
"\"]\"",
",",
"'pivot_text'",
"=>",
"$",
"this",
"->",
"command",
"->",
"paintString",
"(",
"'pivot table'",
",",
"'brown'",
")",
",",
"'foreign_text'",
"=>",
"$",
"this",
"->",
"command",
"->",
"paintString",
"(",
"'foreign key'",
",",
"'brown'",
")",
",",
"'related_text'",
"=>",
"$",
"this",
"->",
"command",
"->",
"paintString",
"(",
"'related key'",
",",
"'brown'",
")",
",",
"]",
";",
"}"
] |
styling text
@return void
|
[
"styling",
"text"
] |
train
|
https://github.com/flipboxstudio/orm-manager/blob/4288426517f53d05177b8729c4ba94c5beca9a98/src/Flipbox/OrmManager/BothRelations/ManyToMany.php#L38-L56
|
flipboxstudio/orm-manager
|
src/Flipbox/OrmManager/BothRelations/ManyToMany.php
|
ManyToMany.setConnectedRelationOptions
|
protected function setConnectedRelationOptions()
{
$pivotTable = $this->defaultOptions['pivot_table'];
$foreignKey = $this->defaultOptions['foreign_key'];
$relatedKey = $this->defaultOptions['related_key'];
if (! $this->db->isTableExists($pivotTable)) {
$question = "Can't find table {$this->text['pivot_table']} in the database as {$this->text['pivot_text']}, choice one!";
$pivotTable = $this->options['pivot_table'] = $this->command->choice(
$question, $this->getTables());
$this->text['pivot_table'] = "[".$this->command->paintString($pivotTable, 'green')."]";
}
if (! $this->db->isFieldExists($pivotTable, $foreignKey)) {
$question = "Can't find field {$this->text['foreign_key']} in the table {$this->text['pivot_table']} as {$this->text['foreign_text']} of table {$this->text['table']}, choice one!";
$this->options['foreign_key'] = $this->command->choice($question, $this->getFields($pivotTable));
}
if (! $this->db->isFieldExists($pivotTable, $relatedKey)) {
$question = "Can't find field {$this->text['related_key']} in the table {$this->text['pivot_table']} as {$this->text['related_text']} of table {$this->text['to_table']}, choice one!";
$this->options['related_key'] = $this->command->choice($question, $this->getFields($pivotTable));
}
}
|
php
|
protected function setConnectedRelationOptions()
{
$pivotTable = $this->defaultOptions['pivot_table'];
$foreignKey = $this->defaultOptions['foreign_key'];
$relatedKey = $this->defaultOptions['related_key'];
if (! $this->db->isTableExists($pivotTable)) {
$question = "Can't find table {$this->text['pivot_table']} in the database as {$this->text['pivot_text']}, choice one!";
$pivotTable = $this->options['pivot_table'] = $this->command->choice(
$question, $this->getTables());
$this->text['pivot_table'] = "[".$this->command->paintString($pivotTable, 'green')."]";
}
if (! $this->db->isFieldExists($pivotTable, $foreignKey)) {
$question = "Can't find field {$this->text['foreign_key']} in the table {$this->text['pivot_table']} as {$this->text['foreign_text']} of table {$this->text['table']}, choice one!";
$this->options['foreign_key'] = $this->command->choice($question, $this->getFields($pivotTable));
}
if (! $this->db->isFieldExists($pivotTable, $relatedKey)) {
$question = "Can't find field {$this->text['related_key']} in the table {$this->text['pivot_table']} as {$this->text['related_text']} of table {$this->text['to_table']}, choice one!";
$this->options['related_key'] = $this->command->choice($question, $this->getFields($pivotTable));
}
}
|
[
"protected",
"function",
"setConnectedRelationOptions",
"(",
")",
"{",
"$",
"pivotTable",
"=",
"$",
"this",
"->",
"defaultOptions",
"[",
"'pivot_table'",
"]",
";",
"$",
"foreignKey",
"=",
"$",
"this",
"->",
"defaultOptions",
"[",
"'foreign_key'",
"]",
";",
"$",
"relatedKey",
"=",
"$",
"this",
"->",
"defaultOptions",
"[",
"'related_key'",
"]",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"db",
"->",
"isTableExists",
"(",
"$",
"pivotTable",
")",
")",
"{",
"$",
"question",
"=",
"\"Can't find table {$this->text['pivot_table']} in the database as {$this->text['pivot_text']}, choice one!\"",
";",
"$",
"pivotTable",
"=",
"$",
"this",
"->",
"options",
"[",
"'pivot_table'",
"]",
"=",
"$",
"this",
"->",
"command",
"->",
"choice",
"(",
"$",
"question",
",",
"$",
"this",
"->",
"getTables",
"(",
")",
")",
";",
"$",
"this",
"->",
"text",
"[",
"'pivot_table'",
"]",
"=",
"\"[\"",
".",
"$",
"this",
"->",
"command",
"->",
"paintString",
"(",
"$",
"pivotTable",
",",
"'green'",
")",
".",
"\"]\"",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"db",
"->",
"isFieldExists",
"(",
"$",
"pivotTable",
",",
"$",
"foreignKey",
")",
")",
"{",
"$",
"question",
"=",
"\"Can't find field {$this->text['foreign_key']} in the table {$this->text['pivot_table']} as {$this->text['foreign_text']} of table {$this->text['table']}, choice one!\"",
";",
"$",
"this",
"->",
"options",
"[",
"'foreign_key'",
"]",
"=",
"$",
"this",
"->",
"command",
"->",
"choice",
"(",
"$",
"question",
",",
"$",
"this",
"->",
"getFields",
"(",
"$",
"pivotTable",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"db",
"->",
"isFieldExists",
"(",
"$",
"pivotTable",
",",
"$",
"relatedKey",
")",
")",
"{",
"$",
"question",
"=",
"\"Can't find field {$this->text['related_key']} in the table {$this->text['pivot_table']} as {$this->text['related_text']} of table {$this->text['to_table']}, choice one!\"",
";",
"$",
"this",
"->",
"options",
"[",
"'related_key'",
"]",
"=",
"$",
"this",
"->",
"command",
"->",
"choice",
"(",
"$",
"question",
",",
"$",
"this",
"->",
"getFields",
"(",
"$",
"pivotTable",
")",
")",
";",
"}",
"}"
] |
get connected db relation options
@return void
|
[
"get",
"connected",
"db",
"relation",
"options"
] |
train
|
https://github.com/flipboxstudio/orm-manager/blob/4288426517f53d05177b8729c4ba94c5beca9a98/src/Flipbox/OrmManager/BothRelations/ManyToMany.php#L63-L86
|
flipboxstudio/orm-manager
|
src/Flipbox/OrmManager/BothRelations/ManyToMany.php
|
ManyToMany.askToUseCustomeOptions
|
protected function askToUseCustomeOptions()
{
$question = "The {$this->text['pivot_text']} in the database will be?";
$this->options['pivot_table'] = $this->command->ask($question, $this->defaultOptions['pivot_table']);
$this->text['pivot_table'] = "[".$this->command->paintString($this->options['pivot_table'], 'green')."]";
$question = "The {$this->text['foreign_text']} of table {$this->text['table']} in the table {$this->text['pivot_table']}, will be?";
$this->options['foreign_key'] = $this->command->ask($question, $this->defaultOptions['foreign_key']);
$question = "The {$this->text['related_text']} of table {$this->text['to_table']} in the table {$this->text['pivot_table']}, will be?";
$this->options['related_key'] = $this->command->ask($question, $this->defaultOptions['related_key']);
}
|
php
|
protected function askToUseCustomeOptions()
{
$question = "The {$this->text['pivot_text']} in the database will be?";
$this->options['pivot_table'] = $this->command->ask($question, $this->defaultOptions['pivot_table']);
$this->text['pivot_table'] = "[".$this->command->paintString($this->options['pivot_table'], 'green')."]";
$question = "The {$this->text['foreign_text']} of table {$this->text['table']} in the table {$this->text['pivot_table']}, will be?";
$this->options['foreign_key'] = $this->command->ask($question, $this->defaultOptions['foreign_key']);
$question = "The {$this->text['related_text']} of table {$this->text['to_table']} in the table {$this->text['pivot_table']}, will be?";
$this->options['related_key'] = $this->command->ask($question, $this->defaultOptions['related_key']);
}
|
[
"protected",
"function",
"askToUseCustomeOptions",
"(",
")",
"{",
"$",
"question",
"=",
"\"The {$this->text['pivot_text']} in the database will be?\"",
";",
"$",
"this",
"->",
"options",
"[",
"'pivot_table'",
"]",
"=",
"$",
"this",
"->",
"command",
"->",
"ask",
"(",
"$",
"question",
",",
"$",
"this",
"->",
"defaultOptions",
"[",
"'pivot_table'",
"]",
")",
";",
"$",
"this",
"->",
"text",
"[",
"'pivot_table'",
"]",
"=",
"\"[\"",
".",
"$",
"this",
"->",
"command",
"->",
"paintString",
"(",
"$",
"this",
"->",
"options",
"[",
"'pivot_table'",
"]",
",",
"'green'",
")",
".",
"\"]\"",
";",
"$",
"question",
"=",
"\"The {$this->text['foreign_text']} of table {$this->text['table']} in the table {$this->text['pivot_table']}, will be?\"",
";",
"$",
"this",
"->",
"options",
"[",
"'foreign_key'",
"]",
"=",
"$",
"this",
"->",
"command",
"->",
"ask",
"(",
"$",
"question",
",",
"$",
"this",
"->",
"defaultOptions",
"[",
"'foreign_key'",
"]",
")",
";",
"$",
"question",
"=",
"\"The {$this->text['related_text']} of table {$this->text['to_table']} in the table {$this->text['pivot_table']}, will be?\"",
";",
"$",
"this",
"->",
"options",
"[",
"'related_key'",
"]",
"=",
"$",
"this",
"->",
"command",
"->",
"ask",
"(",
"$",
"question",
",",
"$",
"this",
"->",
"defaultOptions",
"[",
"'related_key'",
"]",
")",
";",
"}"
] |
ask to use custome options
@return void
|
[
"ask",
"to",
"use",
"custome",
"options"
] |
train
|
https://github.com/flipboxstudio/orm-manager/blob/4288426517f53d05177b8729c4ba94c5beca9a98/src/Flipbox/OrmManager/BothRelations/ManyToMany.php#L107-L118
|
flipboxstudio/orm-manager
|
src/Flipbox/OrmManager/BothRelations/ManyToMany.php
|
ManyToMany.buildRelations
|
public function buildRelations()
{
$this->command->buildMethod($this->model, 'belongsToMany', $this->toModel, $this->options);
$foreignKey = $this->options['foreign_key'];
$relatedKey = $this->options['related_key'];
$this->options['foreign_key'] = $relatedKey;
$this->options['related_key'] = $foreignKey;
$this->options['relation'] = $this->model->getTable();
$this->command->buildMethod($this->toModel, 'belongsToMany', $this->model, $this->options);
}
|
php
|
public function buildRelations()
{
$this->command->buildMethod($this->model, 'belongsToMany', $this->toModel, $this->options);
$foreignKey = $this->options['foreign_key'];
$relatedKey = $this->options['related_key'];
$this->options['foreign_key'] = $relatedKey;
$this->options['related_key'] = $foreignKey;
$this->options['relation'] = $this->model->getTable();
$this->command->buildMethod($this->toModel, 'belongsToMany', $this->model, $this->options);
}
|
[
"public",
"function",
"buildRelations",
"(",
")",
"{",
"$",
"this",
"->",
"command",
"->",
"buildMethod",
"(",
"$",
"this",
"->",
"model",
",",
"'belongsToMany'",
",",
"$",
"this",
"->",
"toModel",
",",
"$",
"this",
"->",
"options",
")",
";",
"$",
"foreignKey",
"=",
"$",
"this",
"->",
"options",
"[",
"'foreign_key'",
"]",
";",
"$",
"relatedKey",
"=",
"$",
"this",
"->",
"options",
"[",
"'related_key'",
"]",
";",
"$",
"this",
"->",
"options",
"[",
"'foreign_key'",
"]",
"=",
"$",
"relatedKey",
";",
"$",
"this",
"->",
"options",
"[",
"'related_key'",
"]",
"=",
"$",
"foreignKey",
";",
"$",
"this",
"->",
"options",
"[",
"'relation'",
"]",
"=",
"$",
"this",
"->",
"model",
"->",
"getTable",
"(",
")",
";",
"$",
"this",
"->",
"command",
"->",
"buildMethod",
"(",
"$",
"this",
"->",
"toModel",
",",
"'belongsToMany'",
",",
"$",
"this",
"->",
"model",
",",
"$",
"this",
"->",
"options",
")",
";",
"}"
] |
build relations between models
@return void
|
[
"build",
"relations",
"between",
"models"
] |
train
|
https://github.com/flipboxstudio/orm-manager/blob/4288426517f53d05177b8729c4ba94c5beca9a98/src/Flipbox/OrmManager/BothRelations/ManyToMany.php#L125-L136
|
anime-db/app-bundle
|
src/Repository/Notice.php
|
Notice.getList
|
public function getList($limit, $offset = 0)
{
return $this->getEntityManager()->createQuery('
SELECT
n
FROM
AnimeDbAppBundle:Notice n
ORDER BY
n.date_created DESC
')
->setFirstResult($offset)
->setMaxResults($limit)
->getResult();
}
|
php
|
public function getList($limit, $offset = 0)
{
return $this->getEntityManager()->createQuery('
SELECT
n
FROM
AnimeDbAppBundle:Notice n
ORDER BY
n.date_created DESC
')
->setFirstResult($offset)
->setMaxResults($limit)
->getResult();
}
|
[
"public",
"function",
"getList",
"(",
"$",
"limit",
",",
"$",
"offset",
"=",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
"->",
"createQuery",
"(",
"'\n SELECT\n n\n FROM\n AnimeDbAppBundle:Notice n\n ORDER BY\n n.date_created DESC\n '",
")",
"->",
"setFirstResult",
"(",
"$",
"offset",
")",
"->",
"setMaxResults",
"(",
"$",
"limit",
")",
"->",
"getResult",
"(",
")",
";",
"}"
] |
@param int $limit
@param int $offset
@return NoticeEntity[]
|
[
"@param",
"int",
"$limit",
"@param",
"int",
"$offset"
] |
train
|
https://github.com/anime-db/app-bundle/blob/ca3b342081719d41ba018792a75970cbb1f1fe22/src/Repository/Notice.php#L51-L64
|
anime-db/app-bundle
|
src/Repository/Notice.php
|
Notice.getFilteredQuery
|
public function getFilteredQuery($status, $type)
{
$query = $this->createQueryBuilder('n');
if (is_int($status) && in_array($status, NoticeEntity::getStatuses())) {
$query
->where('n.status = :status')
->setParameter('status', $status);
}
if ($type) {
$query
->andWhere('n.type = :type')
->setParameter('type', $type);
}
return $query;
}
|
php
|
public function getFilteredQuery($status, $type)
{
$query = $this->createQueryBuilder('n');
if (is_int($status) && in_array($status, NoticeEntity::getStatuses())) {
$query
->where('n.status = :status')
->setParameter('status', $status);
}
if ($type) {
$query
->andWhere('n.type = :type')
->setParameter('type', $type);
}
return $query;
}
|
[
"public",
"function",
"getFilteredQuery",
"(",
"$",
"status",
",",
"$",
"type",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'n'",
")",
";",
"if",
"(",
"is_int",
"(",
"$",
"status",
")",
"&&",
"in_array",
"(",
"$",
"status",
",",
"NoticeEntity",
"::",
"getStatuses",
"(",
")",
")",
")",
"{",
"$",
"query",
"->",
"where",
"(",
"'n.status = :status'",
")",
"->",
"setParameter",
"(",
"'status'",
",",
"$",
"status",
")",
";",
"}",
"if",
"(",
"$",
"type",
")",
"{",
"$",
"query",
"->",
"andWhere",
"(",
"'n.type = :type'",
")",
"->",
"setParameter",
"(",
"'type'",
",",
"$",
"type",
")",
";",
"}",
"return",
"$",
"query",
";",
"}"
] |
@param int $status
@param string $type
@return QueryBuilder
|
[
"@param",
"int",
"$status",
"@param",
"string",
"$type"
] |
train
|
https://github.com/anime-db/app-bundle/blob/ca3b342081719d41ba018792a75970cbb1f1fe22/src/Repository/Notice.php#L174-L191
|
krzysztofmazur/php-object-mapper
|
src/KrzysztofMazur/ObjectMapper/Mapping/Field/FieldsMatchmaker.php
|
FieldsMatchmaker.match
|
public function match($sourceClass, $targetClass)
{
$fields = [];
$targetClassProperties = Reflection::getPropertyNames($targetClass);
$sourceClassProperties = Reflection::getPropertyNames($sourceClass);
$this->matchProperties($fields, $targetClassProperties, $sourceClassProperties);
$this->matchAccessors($fields, $targetClassProperties, $sourceClass);
return $fields;
}
|
php
|
public function match($sourceClass, $targetClass)
{
$fields = [];
$targetClassProperties = Reflection::getPropertyNames($targetClass);
$sourceClassProperties = Reflection::getPropertyNames($sourceClass);
$this->matchProperties($fields, $targetClassProperties, $sourceClassProperties);
$this->matchAccessors($fields, $targetClassProperties, $sourceClass);
return $fields;
}
|
[
"public",
"function",
"match",
"(",
"$",
"sourceClass",
",",
"$",
"targetClass",
")",
"{",
"$",
"fields",
"=",
"[",
"]",
";",
"$",
"targetClassProperties",
"=",
"Reflection",
"::",
"getPropertyNames",
"(",
"$",
"targetClass",
")",
";",
"$",
"sourceClassProperties",
"=",
"Reflection",
"::",
"getPropertyNames",
"(",
"$",
"sourceClass",
")",
";",
"$",
"this",
"->",
"matchProperties",
"(",
"$",
"fields",
",",
"$",
"targetClassProperties",
",",
"$",
"sourceClassProperties",
")",
";",
"$",
"this",
"->",
"matchAccessors",
"(",
"$",
"fields",
",",
"$",
"targetClassProperties",
",",
"$",
"sourceClass",
")",
";",
"return",
"$",
"fields",
";",
"}"
] |
{@inheritdoc}
|
[
"{"
] |
train
|
https://github.com/krzysztofmazur/php-object-mapper/blob/2c22acad9634cfe8e9a75d72e665d450ada8d4e3/src/KrzysztofMazur/ObjectMapper/Mapping/Field/FieldsMatchmaker.php#L37-L46
|
dreamfactorysoftware/df-file
|
src/Components/SFTPFileSystem.php
|
SFTPFileSystem.getFolder
|
public function getFolder($container, $path, $include_files = true, $include_folders = true, $full_tree = false)
{
if ($this->folderExists($container, $path)) {
$path = rtrim($path, '/');
$contents = $this->adapter->listContents($path, $full_tree);
foreach ($contents as $key => $content) {
if (strtolower(array_get($content, 'type')) === 'dir') {
$this->normalizeFolderInfo($content, $path);
} else {
$this->normalizeFileInfo($content, $path);
}
$contents[$key] = $content;
}
return $contents;
} else {
throw new NotFoundException("Folder '$path' does not exist in storage.");
}
}
|
php
|
public function getFolder($container, $path, $include_files = true, $include_folders = true, $full_tree = false)
{
if ($this->folderExists($container, $path)) {
$path = rtrim($path, '/');
$contents = $this->adapter->listContents($path, $full_tree);
foreach ($contents as $key => $content) {
if (strtolower(array_get($content, 'type')) === 'dir') {
$this->normalizeFolderInfo($content, $path);
} else {
$this->normalizeFileInfo($content, $path);
}
$contents[$key] = $content;
}
return $contents;
} else {
throw new NotFoundException("Folder '$path' does not exist in storage.");
}
}
|
[
"public",
"function",
"getFolder",
"(",
"$",
"container",
",",
"$",
"path",
",",
"$",
"include_files",
"=",
"true",
",",
"$",
"include_folders",
"=",
"true",
",",
"$",
"full_tree",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"folderExists",
"(",
"$",
"container",
",",
"$",
"path",
")",
")",
"{",
"$",
"path",
"=",
"rtrim",
"(",
"$",
"path",
",",
"'/'",
")",
";",
"$",
"contents",
"=",
"$",
"this",
"->",
"adapter",
"->",
"listContents",
"(",
"$",
"path",
",",
"$",
"full_tree",
")",
";",
"foreach",
"(",
"$",
"contents",
"as",
"$",
"key",
"=>",
"$",
"content",
")",
"{",
"if",
"(",
"strtolower",
"(",
"array_get",
"(",
"$",
"content",
",",
"'type'",
")",
")",
"===",
"'dir'",
")",
"{",
"$",
"this",
"->",
"normalizeFolderInfo",
"(",
"$",
"content",
",",
"$",
"path",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"normalizeFileInfo",
"(",
"$",
"content",
",",
"$",
"path",
")",
";",
"}",
"$",
"contents",
"[",
"$",
"key",
"]",
"=",
"$",
"content",
";",
"}",
"return",
"$",
"contents",
";",
"}",
"else",
"{",
"throw",
"new",
"NotFoundException",
"(",
"\"Folder '$path' does not exist in storage.\"",
")",
";",
"}",
"}"
] |
{@inheritdoc}
|
[
"{"
] |
train
|
https://github.com/dreamfactorysoftware/df-file/blob/e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66/src/Components/SFTPFileSystem.php#L20-L38
|
dreamfactorysoftware/df-file
|
src/Components/SFTPFileSystem.php
|
SFTPFileSystem.normalizeFolderInfo
|
protected function normalizeFolderInfo(array & $folder, $localizer)
{
if(empty(array_get($folder, 'type')) && !empty(array_get($folder, 'path'))){
$folder['type'] = 'dir';
}
parent::normalizeFolderInfo($folder, $localizer);
$folder['last_modified'] = gmdate('D, d M Y H:i:s \G\M\T', array_get($folder, 'timestamp', 0));
unset($folder['timestamp']);
}
|
php
|
protected function normalizeFolderInfo(array & $folder, $localizer)
{
if(empty(array_get($folder, 'type')) && !empty(array_get($folder, 'path'))){
$folder['type'] = 'dir';
}
parent::normalizeFolderInfo($folder, $localizer);
$folder['last_modified'] = gmdate('D, d M Y H:i:s \G\M\T', array_get($folder, 'timestamp', 0));
unset($folder['timestamp']);
}
|
[
"protected",
"function",
"normalizeFolderInfo",
"(",
"array",
"&",
"$",
"folder",
",",
"$",
"localizer",
")",
"{",
"if",
"(",
"empty",
"(",
"array_get",
"(",
"$",
"folder",
",",
"'type'",
")",
")",
"&&",
"!",
"empty",
"(",
"array_get",
"(",
"$",
"folder",
",",
"'path'",
")",
")",
")",
"{",
"$",
"folder",
"[",
"'type'",
"]",
"=",
"'dir'",
";",
"}",
"parent",
"::",
"normalizeFolderInfo",
"(",
"$",
"folder",
",",
"$",
"localizer",
")",
";",
"$",
"folder",
"[",
"'last_modified'",
"]",
"=",
"gmdate",
"(",
"'D, d M Y H:i:s \\G\\M\\T'",
",",
"array_get",
"(",
"$",
"folder",
",",
"'timestamp'",
",",
"0",
")",
")",
";",
"unset",
"(",
"$",
"folder",
"[",
"'timestamp'",
"]",
")",
";",
"}"
] |
@param array $folder
@param string $localizer
@throws \DreamFactory\Core\Exceptions\InternalServerErrorException
|
[
"@param",
"array",
"$folder",
"@param",
"string",
"$localizer"
] |
train
|
https://github.com/dreamfactorysoftware/df-file/blob/e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66/src/Components/SFTPFileSystem.php#L46-L54
|
webforge-labs/psc-cms
|
lib/Psc/Graph/BFSVertice.php
|
BFSVertice.getParents
|
public function getParents($withSelf = TRUE) {
$node = $this;
$parents = array();
while ($node->getParent() != NULL) {
$parents[] = $node->getParent();
$node = $node->getParent();
}
if ($withSelf) array_unshift($parents,$this);
return $parents;
}
|
php
|
public function getParents($withSelf = TRUE) {
$node = $this;
$parents = array();
while ($node->getParent() != NULL) {
$parents[] = $node->getParent();
$node = $node->getParent();
}
if ($withSelf) array_unshift($parents,$this);
return $parents;
}
|
[
"public",
"function",
"getParents",
"(",
"$",
"withSelf",
"=",
"TRUE",
")",
"{",
"$",
"node",
"=",
"$",
"this",
";",
"$",
"parents",
"=",
"array",
"(",
")",
";",
"while",
"(",
"$",
"node",
"->",
"getParent",
"(",
")",
"!=",
"NULL",
")",
"{",
"$",
"parents",
"[",
"]",
"=",
"$",
"node",
"->",
"getParent",
"(",
")",
";",
"$",
"node",
"=",
"$",
"node",
"->",
"getParent",
"(",
")",
";",
"}",
"if",
"(",
"$",
"withSelf",
")",
"array_unshift",
"(",
"$",
"parents",
",",
"$",
"this",
")",
";",
"return",
"$",
"parents",
";",
"}"
] |
Gibt die Eltern des Knoten zurücks
Dabei werden auch die Eltern der Eltern des Knotens zurückgegeben (diese stehe im Array weiter hinten)
Die Node selbst ist nicht im Array enthalten wenn $withSelf FALSE ist
|
[
"Gibt",
"die",
"Eltern",
"des",
"Knoten",
"zurücks"
] |
train
|
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Graph/BFSVertice.php#L43-L52
|
php-rise/rise
|
src/Request/Upload/File.php
|
File.moveTo
|
public function moveTo($destination) {
if (!$this->isValid()) {
return null;
}
$path = $this->generateFinalPath($destination);
$moved = move_uploaded_file($this->tmpName, $path);
if (!$moved) {
return null;
}
return $path;
}
|
php
|
public function moveTo($destination) {
if (!$this->isValid()) {
return null;
}
$path = $this->generateFinalPath($destination);
$moved = move_uploaded_file($this->tmpName, $path);
if (!$moved) {
return null;
}
return $path;
}
|
[
"public",
"function",
"moveTo",
"(",
"$",
"destination",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isValid",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"path",
"=",
"$",
"this",
"->",
"generateFinalPath",
"(",
"$",
"destination",
")",
";",
"$",
"moved",
"=",
"move_uploaded_file",
"(",
"$",
"this",
"->",
"tmpName",
",",
"$",
"path",
")",
";",
"if",
"(",
"!",
"$",
"moved",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"path",
";",
"}"
] |
Move file.
@param string $destination
@return string|null Path of the moved file.
|
[
"Move",
"file",
"."
] |
train
|
https://github.com/php-rise/rise/blob/cd14ef9956f1b6875b7bcd642545dcef6a9152b7/src/Request/Upload/File.php#L132-L145
|
limen/php-jobs
|
src/Contracts/BaseJobset.php
|
BaseJobset.make
|
public static function make($attributes = [])
{
$jobset = new static();
// make jobset model
$model = $jobset->makeModel($attributes);
// update local model
$jobset->setModel($model);
// make job models and init job instances
$jobset->makeJobs();
// set jobset try at
$jobsetTryAt = $jobset->getJobsEarliestTryAt();
$jobset->model->setTryAt($jobsetTryAt);
$jobset->model->persist();
return $jobset;
}
|
php
|
public static function make($attributes = [])
{
$jobset = new static();
// make jobset model
$model = $jobset->makeModel($attributes);
// update local model
$jobset->setModel($model);
// make job models and init job instances
$jobset->makeJobs();
// set jobset try at
$jobsetTryAt = $jobset->getJobsEarliestTryAt();
$jobset->model->setTryAt($jobsetTryAt);
$jobset->model->persist();
return $jobset;
}
|
[
"public",
"static",
"function",
"make",
"(",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"$",
"jobset",
"=",
"new",
"static",
"(",
")",
";",
"// make jobset model",
"$",
"model",
"=",
"$",
"jobset",
"->",
"makeModel",
"(",
"$",
"attributes",
")",
";",
"// update local model",
"$",
"jobset",
"->",
"setModel",
"(",
"$",
"model",
")",
";",
"// make job models and init job instances",
"$",
"jobset",
"->",
"makeJobs",
"(",
")",
";",
"// set jobset try at",
"$",
"jobsetTryAt",
"=",
"$",
"jobset",
"->",
"getJobsEarliestTryAt",
"(",
")",
";",
"$",
"jobset",
"->",
"model",
"->",
"setTryAt",
"(",
"$",
"jobsetTryAt",
")",
";",
"$",
"jobset",
"->",
"model",
"->",
"persist",
"(",
")",
";",
"return",
"$",
"jobset",
";",
"}"
] |
Make new jobset
@param array $attributes
@return BaseJobset
|
[
"Make",
"new",
"jobset"
] |
train
|
https://github.com/limen/php-jobs/blob/525f4082b49a7a3e69acb4cea3a622244f1616b9/src/Contracts/BaseJobset.php#L37-L53
|
limen/php-jobs
|
src/Contracts/BaseJobset.php
|
BaseJobset.get
|
public static function get($id)
{
$jobset = new static();
// find jobset model
$model = $jobset->findModel($id);
// update local model
$jobset->setModel($model);
// Init job instances
$jobset->initJobs();
return $jobset;
}
|
php
|
public static function get($id)
{
$jobset = new static();
// find jobset model
$model = $jobset->findModel($id);
// update local model
$jobset->setModel($model);
// Init job instances
$jobset->initJobs();
return $jobset;
}
|
[
"public",
"static",
"function",
"get",
"(",
"$",
"id",
")",
"{",
"$",
"jobset",
"=",
"new",
"static",
"(",
")",
";",
"// find jobset model",
"$",
"model",
"=",
"$",
"jobset",
"->",
"findModel",
"(",
"$",
"id",
")",
";",
"// update local model",
"$",
"jobset",
"->",
"setModel",
"(",
"$",
"model",
")",
";",
"// Init job instances",
"$",
"jobset",
"->",
"initJobs",
"(",
")",
";",
"return",
"$",
"jobset",
";",
"}"
] |
Get an existed jobset
@param $id
@return static
|
[
"Get",
"an",
"existed",
"jobset"
] |
train
|
https://github.com/limen/php-jobs/blob/525f4082b49a7a3e69acb4cea3a622244f1616b9/src/Contracts/BaseJobset.php#L61-L73
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.