repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_code_tokens
sequencelengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
sequencelengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Base/src/metadata/tarball.php | ezcBaseMetaDataTarballReader.getComponentVersion | public function getComponentVersion( $componentName )
{
$root = $this->xml->deps->packages->package;
foreach ( $root as $package )
{
if ( (string) $package['name'] == $componentName )
{
return (string) $package['version'];
}
}
return false;
} | php | public function getComponentVersion( $componentName )
{
$root = $this->xml->deps->packages->package;
foreach ( $root as $package )
{
if ( (string) $package['name'] == $componentName )
{
return (string) $package['version'];
}
}
return false;
} | [
"public",
"function",
"getComponentVersion",
"(",
"$",
"componentName",
")",
"{",
"$",
"root",
"=",
"$",
"this",
"->",
"xml",
"->",
"deps",
"->",
"packages",
"->",
"package",
";",
"foreach",
"(",
"$",
"root",
"as",
"$",
"package",
")",
"{",
"if",
"(",
"(",
"string",
")",
"$",
"package",
"[",
"'name'",
"]",
"==",
"$",
"componentName",
")",
"{",
"return",
"(",
"string",
")",
"$",
"package",
"[",
"'version'",
"]",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Returns the version string of the available $componentName or false when
the component is not installed.
@return string | [
"Returns",
"the",
"version",
"string",
"of",
"the",
"available",
"$componentName",
"or",
"false",
"when",
"the",
"component",
"is",
"not",
"installed",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Base/src/metadata/tarball.php#L86-L98 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Base/src/metadata/tarball.php | ezcBaseMetaDataTarballReader.getComponentDependencies | public function getComponentDependencies( $componentName = null )
{
$baseVersion = false;
$root = $this->xml->deps->packages;
$found = $componentName === null ? true : false;
// in case $componentName != null, we loop through all the components
// in the file, and figure out the new root that we can list dependency
// packages from.
foreach ( $root->package as $package )
{
if ( (string) $package['name'] == 'Base' )
{
$baseVersion = $package['version'];
}
if ( !$found && (string) $package['name'] == $componentName )
{
$root = $package->deps;
$found = true;
}
}
if ( !$found )
{
return null;
}
// We always add the Base dependency even though it's not in the dependency file.
$deps = array();
$deps['Base'] = (string) $baseVersion;
if ( !isset( $root->package ) )
{
return $deps;
}
foreach ( $root->package as $package )
{
$deps[(string) $package['name']] = (string) $package['version'];
}
return $deps;
} | php | public function getComponentDependencies( $componentName = null )
{
$baseVersion = false;
$root = $this->xml->deps->packages;
$found = $componentName === null ? true : false;
// in case $componentName != null, we loop through all the components
// in the file, and figure out the new root that we can list dependency
// packages from.
foreach ( $root->package as $package )
{
if ( (string) $package['name'] == 'Base' )
{
$baseVersion = $package['version'];
}
if ( !$found && (string) $package['name'] == $componentName )
{
$root = $package->deps;
$found = true;
}
}
if ( !$found )
{
return null;
}
// We always add the Base dependency even though it's not in the dependency file.
$deps = array();
$deps['Base'] = (string) $baseVersion;
if ( !isset( $root->package ) )
{
return $deps;
}
foreach ( $root->package as $package )
{
$deps[(string) $package['name']] = (string) $package['version'];
}
return $deps;
} | [
"public",
"function",
"getComponentDependencies",
"(",
"$",
"componentName",
"=",
"null",
")",
"{",
"$",
"baseVersion",
"=",
"false",
";",
"$",
"root",
"=",
"$",
"this",
"->",
"xml",
"->",
"deps",
"->",
"packages",
";",
"$",
"found",
"=",
"$",
"componentName",
"===",
"null",
"?",
"true",
":",
"false",
";",
"// in case $componentName != null, we loop through all the components",
"// in the file, and figure out the new root that we can list dependency",
"// packages from.",
"foreach",
"(",
"$",
"root",
"->",
"package",
"as",
"$",
"package",
")",
"{",
"if",
"(",
"(",
"string",
")",
"$",
"package",
"[",
"'name'",
"]",
"==",
"'Base'",
")",
"{",
"$",
"baseVersion",
"=",
"$",
"package",
"[",
"'version'",
"]",
";",
"}",
"if",
"(",
"!",
"$",
"found",
"&&",
"(",
"string",
")",
"$",
"package",
"[",
"'name'",
"]",
"==",
"$",
"componentName",
")",
"{",
"$",
"root",
"=",
"$",
"package",
"->",
"deps",
";",
"$",
"found",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"found",
")",
"{",
"return",
"null",
";",
"}",
"// We always add the Base dependency even though it's not in the dependency file.",
"$",
"deps",
"=",
"array",
"(",
")",
";",
"$",
"deps",
"[",
"'Base'",
"]",
"=",
"(",
"string",
")",
"$",
"baseVersion",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"root",
"->",
"package",
")",
")",
"{",
"return",
"$",
"deps",
";",
"}",
"foreach",
"(",
"$",
"root",
"->",
"package",
"as",
"$",
"package",
")",
"{",
"$",
"deps",
"[",
"(",
"string",
")",
"$",
"package",
"[",
"'name'",
"]",
"]",
"=",
"(",
"string",
")",
"$",
"package",
"[",
"'version'",
"]",
";",
"}",
"return",
"$",
"deps",
";",
"}"
] | Returns a list of components that $componentName depends on.
If $componentName is left empty, all installed components are returned.
The returned array has as keys the component names, and as values the
version of the components. It returns null of the $componentName
is not found.
@return array(string=>string). | [
"Returns",
"a",
"list",
"of",
"components",
"that",
"$componentName",
"depends",
"on",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Base/src/metadata/tarball.php#L111-L151 |
xiewulong/yii2-fileupload | oss/libs/symfony/yaml/Symfony/Component/Yaml/Unescaper.php | Unescaper.unescapeCharacter | public function unescapeCharacter($value)
{
switch ($value{1}) {
case '0':
return "\x0";
case 'a':
return "\x7";
case 'b':
return "\x8";
case 't':
return "\t";
case "\t":
return "\t";
case 'n':
return "\n";
case 'v':
return "\xb";
case 'f':
return "\xc";
case 'r':
return "\xd";
case 'e':
return "\x1b";
case ' ':
return ' ';
case '"':
return '"';
case '/':
return '/';
case '\\':
return '\\';
case 'N':
// U+0085 NEXT LINE
return $this->convertEncoding("\x00\x85", self::ENCODING, 'UCS-2BE');
case '_':
// U+00A0 NO-BREAK SPACE
return $this->convertEncoding("\x00\xA0", self::ENCODING, 'UCS-2BE');
case 'L':
// U+2028 LINE SEPARATOR
return $this->convertEncoding("\x20\x28", self::ENCODING, 'UCS-2BE');
case 'P':
// U+2029 PARAGRAPH SEPARATOR
return $this->convertEncoding("\x20\x29", self::ENCODING, 'UCS-2BE');
case 'x':
$char = pack('n', hexdec(substr($value, 2, 2)));
return $this->convertEncoding($char, self::ENCODING, 'UCS-2BE');
case 'u':
$char = pack('n', hexdec(substr($value, 2, 4)));
return $this->convertEncoding($char, self::ENCODING, 'UCS-2BE');
case 'U':
$char = pack('N', hexdec(substr($value, 2, 8)));
return $this->convertEncoding($char, self::ENCODING, 'UCS-4BE');
}
} | php | public function unescapeCharacter($value)
{
switch ($value{1}) {
case '0':
return "\x0";
case 'a':
return "\x7";
case 'b':
return "\x8";
case 't':
return "\t";
case "\t":
return "\t";
case 'n':
return "\n";
case 'v':
return "\xb";
case 'f':
return "\xc";
case 'r':
return "\xd";
case 'e':
return "\x1b";
case ' ':
return ' ';
case '"':
return '"';
case '/':
return '/';
case '\\':
return '\\';
case 'N':
// U+0085 NEXT LINE
return $this->convertEncoding("\x00\x85", self::ENCODING, 'UCS-2BE');
case '_':
// U+00A0 NO-BREAK SPACE
return $this->convertEncoding("\x00\xA0", self::ENCODING, 'UCS-2BE');
case 'L':
// U+2028 LINE SEPARATOR
return $this->convertEncoding("\x20\x28", self::ENCODING, 'UCS-2BE');
case 'P':
// U+2029 PARAGRAPH SEPARATOR
return $this->convertEncoding("\x20\x29", self::ENCODING, 'UCS-2BE');
case 'x':
$char = pack('n', hexdec(substr($value, 2, 2)));
return $this->convertEncoding($char, self::ENCODING, 'UCS-2BE');
case 'u':
$char = pack('n', hexdec(substr($value, 2, 4)));
return $this->convertEncoding($char, self::ENCODING, 'UCS-2BE');
case 'U':
$char = pack('N', hexdec(substr($value, 2, 8)));
return $this->convertEncoding($char, self::ENCODING, 'UCS-4BE');
}
} | [
"public",
"function",
"unescapeCharacter",
"(",
"$",
"value",
")",
"{",
"switch",
"(",
"$",
"value",
"{",
"1",
"}",
")",
"{",
"case",
"'0'",
":",
"return",
"\"\\x0\"",
";",
"case",
"'a'",
":",
"return",
"\"\\x7\"",
";",
"case",
"'b'",
":",
"return",
"\"\\x8\"",
";",
"case",
"'t'",
":",
"return",
"\"\\t\"",
";",
"case",
"\"\\t\"",
":",
"return",
"\"\\t\"",
";",
"case",
"'n'",
":",
"return",
"\"\\n\"",
";",
"case",
"'v'",
":",
"return",
"\"\\xb\"",
";",
"case",
"'f'",
":",
"return",
"\"\\xc\"",
";",
"case",
"'r'",
":",
"return",
"\"\\xd\"",
";",
"case",
"'e'",
":",
"return",
"\"\\x1b\"",
";",
"case",
"' '",
":",
"return",
"' '",
";",
"case",
"'\"'",
":",
"return",
"'\"'",
";",
"case",
"'/'",
":",
"return",
"'/'",
";",
"case",
"'\\\\'",
":",
"return",
"'\\\\'",
";",
"case",
"'N'",
":",
"// U+0085 NEXT LINE",
"return",
"$",
"this",
"->",
"convertEncoding",
"(",
"\"\\x00\\x85\"",
",",
"self",
"::",
"ENCODING",
",",
"'UCS-2BE'",
")",
";",
"case",
"'_'",
":",
"// U+00A0 NO-BREAK SPACE",
"return",
"$",
"this",
"->",
"convertEncoding",
"(",
"\"\\x00\\xA0\"",
",",
"self",
"::",
"ENCODING",
",",
"'UCS-2BE'",
")",
";",
"case",
"'L'",
":",
"// U+2028 LINE SEPARATOR",
"return",
"$",
"this",
"->",
"convertEncoding",
"(",
"\"\\x20\\x28\"",
",",
"self",
"::",
"ENCODING",
",",
"'UCS-2BE'",
")",
";",
"case",
"'P'",
":",
"// U+2029 PARAGRAPH SEPARATOR",
"return",
"$",
"this",
"->",
"convertEncoding",
"(",
"\"\\x20\\x29\"",
",",
"self",
"::",
"ENCODING",
",",
"'UCS-2BE'",
")",
";",
"case",
"'x'",
":",
"$",
"char",
"=",
"pack",
"(",
"'n'",
",",
"hexdec",
"(",
"substr",
"(",
"$",
"value",
",",
"2",
",",
"2",
")",
")",
")",
";",
"return",
"$",
"this",
"->",
"convertEncoding",
"(",
"$",
"char",
",",
"self",
"::",
"ENCODING",
",",
"'UCS-2BE'",
")",
";",
"case",
"'u'",
":",
"$",
"char",
"=",
"pack",
"(",
"'n'",
",",
"hexdec",
"(",
"substr",
"(",
"$",
"value",
",",
"2",
",",
"4",
")",
")",
")",
";",
"return",
"$",
"this",
"->",
"convertEncoding",
"(",
"$",
"char",
",",
"self",
"::",
"ENCODING",
",",
"'UCS-2BE'",
")",
";",
"case",
"'U'",
":",
"$",
"char",
"=",
"pack",
"(",
"'N'",
",",
"hexdec",
"(",
"substr",
"(",
"$",
"value",
",",
"2",
",",
"8",
")",
")",
")",
";",
"return",
"$",
"this",
"->",
"convertEncoding",
"(",
"$",
"char",
",",
"self",
"::",
"ENCODING",
",",
"'UCS-4BE'",
")",
";",
"}",
"}"
] | Unescapes a character that was found in a double-quoted string
@param string $value An escaped character
@return string The unescaped character | [
"Unescapes",
"a",
"character",
"that",
"was",
"found",
"in",
"a",
"double",
"-",
"quoted",
"string"
] | train | https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/symfony/yaml/Symfony/Component/Yaml/Unescaper.php#L66-L122 |
xiewulong/yii2-fileupload | oss/libs/symfony/yaml/Symfony/Component/Yaml/Unescaper.php | Unescaper.convertEncoding | private function convertEncoding($value, $to, $from)
{
if (function_exists('mb_convert_encoding')) {
return mb_convert_encoding($value, $to, $from);
} elseif (function_exists('iconv')) {
return iconv($from, $to, $value);
}
throw new RuntimeException('No suitable convert encoding function (install the iconv or mbstring extension).');
} | php | private function convertEncoding($value, $to, $from)
{
if (function_exists('mb_convert_encoding')) {
return mb_convert_encoding($value, $to, $from);
} elseif (function_exists('iconv')) {
return iconv($from, $to, $value);
}
throw new RuntimeException('No suitable convert encoding function (install the iconv or mbstring extension).');
} | [
"private",
"function",
"convertEncoding",
"(",
"$",
"value",
",",
"$",
"to",
",",
"$",
"from",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'mb_convert_encoding'",
")",
")",
"{",
"return",
"mb_convert_encoding",
"(",
"$",
"value",
",",
"$",
"to",
",",
"$",
"from",
")",
";",
"}",
"elseif",
"(",
"function_exists",
"(",
"'iconv'",
")",
")",
"{",
"return",
"iconv",
"(",
"$",
"from",
",",
"$",
"to",
",",
"$",
"value",
")",
";",
"}",
"throw",
"new",
"RuntimeException",
"(",
"'No suitable convert encoding function (install the iconv or mbstring extension).'",
")",
";",
"}"
] | Convert a string from one encoding to another.
@param string $value The string to convert
@param string $to The input encoding
@param string $from The output encoding
@return string The string with the new encoding
@throws RuntimeException if no suitable encoding function is found (iconv or mbstring) | [
"Convert",
"a",
"string",
"from",
"one",
"encoding",
"to",
"another",
"."
] | train | https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/symfony/yaml/Symfony/Component/Yaml/Unescaper.php#L135-L144 |
gregoryv/php-logger | src/State.php | State.toggle | public function toggle($flag, $name)
{
switch ($flag) {
case 'on':
$onoff = true;
break;
case 'off':
$onoff = false;
break;
default:
throw new \InvalidArgumentException("Flag must be 'on' or 'off'");
}
switch ($name) {
case 'debug':
$this->debug = $onoff;
break;
case 'info':
$this->info = $onoff;
break;
case 'notice':
$this->notice = $onoff;
break;
case 'warn':
$this->warn = $onoff;
break;
case 'error':
$this->error = $onoff;
break;
case 'critical':
$this->critical = $onoff;
break;
case 'alert':
$this->alert = $onoff;
break;
case 'emergency':
$this->emergency = $onoff;
break;
default:
throw new \InvalidArgumentException("Name must be on (debug|info|notice|warn|error|critical|alert|emergency)");
}
} | php | public function toggle($flag, $name)
{
switch ($flag) {
case 'on':
$onoff = true;
break;
case 'off':
$onoff = false;
break;
default:
throw new \InvalidArgumentException("Flag must be 'on' or 'off'");
}
switch ($name) {
case 'debug':
$this->debug = $onoff;
break;
case 'info':
$this->info = $onoff;
break;
case 'notice':
$this->notice = $onoff;
break;
case 'warn':
$this->warn = $onoff;
break;
case 'error':
$this->error = $onoff;
break;
case 'critical':
$this->critical = $onoff;
break;
case 'alert':
$this->alert = $onoff;
break;
case 'emergency':
$this->emergency = $onoff;
break;
default:
throw new \InvalidArgumentException("Name must be on (debug|info|notice|warn|error|critical|alert|emergency)");
}
} | [
"public",
"function",
"toggle",
"(",
"$",
"flag",
",",
"$",
"name",
")",
"{",
"switch",
"(",
"$",
"flag",
")",
"{",
"case",
"'on'",
":",
"$",
"onoff",
"=",
"true",
";",
"break",
";",
"case",
"'off'",
":",
"$",
"onoff",
"=",
"false",
";",
"break",
";",
"default",
":",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Flag must be 'on' or 'off'\"",
")",
";",
"}",
"switch",
"(",
"$",
"name",
")",
"{",
"case",
"'debug'",
":",
"$",
"this",
"->",
"debug",
"=",
"$",
"onoff",
";",
"break",
";",
"case",
"'info'",
":",
"$",
"this",
"->",
"info",
"=",
"$",
"onoff",
";",
"break",
";",
"case",
"'notice'",
":",
"$",
"this",
"->",
"notice",
"=",
"$",
"onoff",
";",
"break",
";",
"case",
"'warn'",
":",
"$",
"this",
"->",
"warn",
"=",
"$",
"onoff",
";",
"break",
";",
"case",
"'error'",
":",
"$",
"this",
"->",
"error",
"=",
"$",
"onoff",
";",
"break",
";",
"case",
"'critical'",
":",
"$",
"this",
"->",
"critical",
"=",
"$",
"onoff",
";",
"break",
";",
"case",
"'alert'",
":",
"$",
"this",
"->",
"alert",
"=",
"$",
"onoff",
";",
"break",
";",
"case",
"'emergency'",
":",
"$",
"this",
"->",
"emergency",
"=",
"$",
"onoff",
";",
"break",
";",
"default",
":",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Name must be on (debug|info|notice|warn|error|critical|alert|emergency)\"",
")",
";",
"}",
"}"
] | Sets the named attribute to true or false
@param string $flag (on|off)
@param string $name (debug|info|notice|warn|error|critical|alert|emergency)
@throws InvalidArgumentException on badly formated $flag or $name | [
"Sets",
"the",
"named",
"attribute",
"to",
"true",
"or",
"false"
] | train | https://github.com/gregoryv/php-logger/blob/0f8ffc360a0233531a9775359929af8876997862/src/State.php#L26-L67 |
OKTOTV/OktolabMediaBundle | Model/FFprobeService.php | FFprobeService.detectEncodingOptionForResolution | public function detectEncodingOptionForResolution($resolution, $episode)
{
$metainfo = $this->getMetainfoForEpisode($episode);
switch ($this->getMediaType($metainfo)) {
case $this::MEDIA_TYPE_AUDIO:
$can_copy_audio = $this->audioCanBeCopied(
$resolution,
$metainfo['audio']
);
$can_encode_audio = $this->audioCanBeEncoded(
$resolution,
$metainfo['audio']
);
if ($can_copy_audio) {
return $this::ENCODING_OPTION_AUDIO_COPY;
}
if ($can_encode_audio) {
return $this::ENCODING_OPTION_AUDIO_CONVERT;
}
return $this::ENCODING_OPTION_NONE;
case $this::MEDIA_TYPE_VIDEO:
$can_copy_audio = $this->audioCanBeCopied(
$resolution,
$metainfo['audio']
);
$can_encode_audio = $this->audioCanBeEncoded(
$resolution,
$metainfo['audio']
);
$can_copy_video = $this->videoCanBeCopied(
$resolution,
$metainfo['video']
);
$can_encode_video = $this->videoCanBeEncoded(
$resolution,
$metainfo['video']
);
if ($can_copy_audio && $can_copy_video) {
return $this::ENCODING_OPTION_VIDEO_COPY_ALL;
}
if($can_copy_audio && $can_encode_video) {
return $this::ENCODING_OPTION_VIDEO_COPY_AUDIO;
}
if($can_encode_audio && $can_copy_video) {
return $this::ENCODING_OPTION_VIDEO_COPY_VIDEO;
}
if($can_encode_audio && $can_encode_video) {
return $this::ENCODING_OPTION_VIDEO_ENCODE_BOTH;
}
return $this::ENCODING_OPTION_NONE;
case $this::MEDIA_TYPE_VIDEO_ONLY:
$can_copy_video = $this->videoCanBeCopied(
$resolution,
$metainfo['video']
);
$can_encode_video = $this->videoCanBeEncoded(
$resolution,
$metainfo['video']
);
if ($can_copy_video) {
return $this::ENCODING_OPTION_VIDEO_ONLY_COPY;
} elseif ($can_encode_video) {
return $this::ENCODING_OPTION_VIDEO_ONLY_ENCODE;
}
return $this::ENCODING_OPTION_NONE;
}
return $this::ENCODING_OPTION_NONE;
} | php | public function detectEncodingOptionForResolution($resolution, $episode)
{
$metainfo = $this->getMetainfoForEpisode($episode);
switch ($this->getMediaType($metainfo)) {
case $this::MEDIA_TYPE_AUDIO:
$can_copy_audio = $this->audioCanBeCopied(
$resolution,
$metainfo['audio']
);
$can_encode_audio = $this->audioCanBeEncoded(
$resolution,
$metainfo['audio']
);
if ($can_copy_audio) {
return $this::ENCODING_OPTION_AUDIO_COPY;
}
if ($can_encode_audio) {
return $this::ENCODING_OPTION_AUDIO_CONVERT;
}
return $this::ENCODING_OPTION_NONE;
case $this::MEDIA_TYPE_VIDEO:
$can_copy_audio = $this->audioCanBeCopied(
$resolution,
$metainfo['audio']
);
$can_encode_audio = $this->audioCanBeEncoded(
$resolution,
$metainfo['audio']
);
$can_copy_video = $this->videoCanBeCopied(
$resolution,
$metainfo['video']
);
$can_encode_video = $this->videoCanBeEncoded(
$resolution,
$metainfo['video']
);
if ($can_copy_audio && $can_copy_video) {
return $this::ENCODING_OPTION_VIDEO_COPY_ALL;
}
if($can_copy_audio && $can_encode_video) {
return $this::ENCODING_OPTION_VIDEO_COPY_AUDIO;
}
if($can_encode_audio && $can_copy_video) {
return $this::ENCODING_OPTION_VIDEO_COPY_VIDEO;
}
if($can_encode_audio && $can_encode_video) {
return $this::ENCODING_OPTION_VIDEO_ENCODE_BOTH;
}
return $this::ENCODING_OPTION_NONE;
case $this::MEDIA_TYPE_VIDEO_ONLY:
$can_copy_video = $this->videoCanBeCopied(
$resolution,
$metainfo['video']
);
$can_encode_video = $this->videoCanBeEncoded(
$resolution,
$metainfo['video']
);
if ($can_copy_video) {
return $this::ENCODING_OPTION_VIDEO_ONLY_COPY;
} elseif ($can_encode_video) {
return $this::ENCODING_OPTION_VIDEO_ONLY_ENCODE;
}
return $this::ENCODING_OPTION_NONE;
}
return $this::ENCODING_OPTION_NONE;
} | [
"public",
"function",
"detectEncodingOptionForResolution",
"(",
"$",
"resolution",
",",
"$",
"episode",
")",
"{",
"$",
"metainfo",
"=",
"$",
"this",
"->",
"getMetainfoForEpisode",
"(",
"$",
"episode",
")",
";",
"switch",
"(",
"$",
"this",
"->",
"getMediaType",
"(",
"$",
"metainfo",
")",
")",
"{",
"case",
"$",
"this",
"::",
"MEDIA_TYPE_AUDIO",
":",
"$",
"can_copy_audio",
"=",
"$",
"this",
"->",
"audioCanBeCopied",
"(",
"$",
"resolution",
",",
"$",
"metainfo",
"[",
"'audio'",
"]",
")",
";",
"$",
"can_encode_audio",
"=",
"$",
"this",
"->",
"audioCanBeEncoded",
"(",
"$",
"resolution",
",",
"$",
"metainfo",
"[",
"'audio'",
"]",
")",
";",
"if",
"(",
"$",
"can_copy_audio",
")",
"{",
"return",
"$",
"this",
"::",
"ENCODING_OPTION_AUDIO_COPY",
";",
"}",
"if",
"(",
"$",
"can_encode_audio",
")",
"{",
"return",
"$",
"this",
"::",
"ENCODING_OPTION_AUDIO_CONVERT",
";",
"}",
"return",
"$",
"this",
"::",
"ENCODING_OPTION_NONE",
";",
"case",
"$",
"this",
"::",
"MEDIA_TYPE_VIDEO",
":",
"$",
"can_copy_audio",
"=",
"$",
"this",
"->",
"audioCanBeCopied",
"(",
"$",
"resolution",
",",
"$",
"metainfo",
"[",
"'audio'",
"]",
")",
";",
"$",
"can_encode_audio",
"=",
"$",
"this",
"->",
"audioCanBeEncoded",
"(",
"$",
"resolution",
",",
"$",
"metainfo",
"[",
"'audio'",
"]",
")",
";",
"$",
"can_copy_video",
"=",
"$",
"this",
"->",
"videoCanBeCopied",
"(",
"$",
"resolution",
",",
"$",
"metainfo",
"[",
"'video'",
"]",
")",
";",
"$",
"can_encode_video",
"=",
"$",
"this",
"->",
"videoCanBeEncoded",
"(",
"$",
"resolution",
",",
"$",
"metainfo",
"[",
"'video'",
"]",
")",
";",
"if",
"(",
"$",
"can_copy_audio",
"&&",
"$",
"can_copy_video",
")",
"{",
"return",
"$",
"this",
"::",
"ENCODING_OPTION_VIDEO_COPY_ALL",
";",
"}",
"if",
"(",
"$",
"can_copy_audio",
"&&",
"$",
"can_encode_video",
")",
"{",
"return",
"$",
"this",
"::",
"ENCODING_OPTION_VIDEO_COPY_AUDIO",
";",
"}",
"if",
"(",
"$",
"can_encode_audio",
"&&",
"$",
"can_copy_video",
")",
"{",
"return",
"$",
"this",
"::",
"ENCODING_OPTION_VIDEO_COPY_VIDEO",
";",
"}",
"if",
"(",
"$",
"can_encode_audio",
"&&",
"$",
"can_encode_video",
")",
"{",
"return",
"$",
"this",
"::",
"ENCODING_OPTION_VIDEO_ENCODE_BOTH",
";",
"}",
"return",
"$",
"this",
"::",
"ENCODING_OPTION_NONE",
";",
"case",
"$",
"this",
"::",
"MEDIA_TYPE_VIDEO_ONLY",
":",
"$",
"can_copy_video",
"=",
"$",
"this",
"->",
"videoCanBeCopied",
"(",
"$",
"resolution",
",",
"$",
"metainfo",
"[",
"'video'",
"]",
")",
";",
"$",
"can_encode_video",
"=",
"$",
"this",
"->",
"videoCanBeEncoded",
"(",
"$",
"resolution",
",",
"$",
"metainfo",
"[",
"'video'",
"]",
")",
";",
"if",
"(",
"$",
"can_copy_video",
")",
"{",
"return",
"$",
"this",
"::",
"ENCODING_OPTION_VIDEO_ONLY_COPY",
";",
"}",
"elseif",
"(",
"$",
"can_encode_video",
")",
"{",
"return",
"$",
"this",
"::",
"ENCODING_OPTION_VIDEO_ONLY_ENCODE",
";",
"}",
"return",
"$",
"this",
"::",
"ENCODING_OPTION_NONE",
";",
"}",
"return",
"$",
"this",
"::",
"ENCODING_OPTION_NONE",
";",
"}"
] | returns | [
"returns"
] | train | https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/FFprobeService.php#L38-L110 |
OKTOTV/OktolabMediaBundle | Model/FFprobeService.php | FFprobeService.videoCanBeCopied | private function videoCanBeCopied($resolution, $metainfo) {
return
// codec is the same (for example h264)
$resolution['video_codec'] == $metainfo['codec_name'] &&
// framerate is the same (for example 50)
$resolution['video_framerate'] == $metainfo['avg_frame_rate'] &&
// resolution is the same
$resolution['video_width'] == $metainfo['width'] &&
$resolution['video_height'] == $metainfo['height'] &&
// average bitrate is lower or same as in resolution
$resolution['video_bitrate'] >= $metainfo['bit_rate'] &&
// the color coding is the same (prores 422 -> 420)
$resolution['pix_fmt'] == $metainfo['pix_fmt']
;
} | php | private function videoCanBeCopied($resolution, $metainfo) {
return
// codec is the same (for example h264)
$resolution['video_codec'] == $metainfo['codec_name'] &&
// framerate is the same (for example 50)
$resolution['video_framerate'] == $metainfo['avg_frame_rate'] &&
// resolution is the same
$resolution['video_width'] == $metainfo['width'] &&
$resolution['video_height'] == $metainfo['height'] &&
// average bitrate is lower or same as in resolution
$resolution['video_bitrate'] >= $metainfo['bit_rate'] &&
// the color coding is the same (prores 422 -> 420)
$resolution['pix_fmt'] == $metainfo['pix_fmt']
;
} | [
"private",
"function",
"videoCanBeCopied",
"(",
"$",
"resolution",
",",
"$",
"metainfo",
")",
"{",
"return",
"// codec is the same (for example h264)",
"$",
"resolution",
"[",
"'video_codec'",
"]",
"==",
"$",
"metainfo",
"[",
"'codec_name'",
"]",
"&&",
"// framerate is the same (for example 50)",
"$",
"resolution",
"[",
"'video_framerate'",
"]",
"==",
"$",
"metainfo",
"[",
"'avg_frame_rate'",
"]",
"&&",
"// resolution is the same",
"$",
"resolution",
"[",
"'video_width'",
"]",
"==",
"$",
"metainfo",
"[",
"'width'",
"]",
"&&",
"$",
"resolution",
"[",
"'video_height'",
"]",
"==",
"$",
"metainfo",
"[",
"'height'",
"]",
"&&",
"// average bitrate is lower or same as in resolution",
"$",
"resolution",
"[",
"'video_bitrate'",
"]",
">=",
"$",
"metainfo",
"[",
"'bit_rate'",
"]",
"&&",
"// the color coding is the same (prores 422 -> 420)",
"$",
"resolution",
"[",
"'pix_fmt'",
"]",
"==",
"$",
"metainfo",
"[",
"'pix_fmt'",
"]",
";",
"}"
] | determines if the stream can simply be copied. (videostreams)
important factors are codec, framerate and a maximum bitrate. | [
"determines",
"if",
"the",
"stream",
"can",
"simply",
"be",
"copied",
".",
"(",
"videostreams",
")",
"important",
"factors",
"are",
"codec",
"framerate",
"and",
"a",
"maximum",
"bitrate",
"."
] | train | https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/FFprobeService.php#L116-L131 |
OKTOTV/OktolabMediaBundle | Model/FFprobeService.php | FFprobeService.audioCanBeEncoded | private function audioCanBeEncoded($resolution, $metainfo) {
return
// sample rate of file is better or as good as defined in resolution
$resolution['audio_sample_rate'] >= $metainfo['sample_rate'] &&
// bitrate of file is better or as good as defined in resolution
$resolution['audio_bitrate'] <= $metainfo['max_bit_rate'] ||
// or we allow worse quality to be used for encoding
filter_var(
$resolution['allow_lower_audio_bitrate'],
FILTER_VALIDATE_BOOLEAN
)
;
} | php | private function audioCanBeEncoded($resolution, $metainfo) {
return
// sample rate of file is better or as good as defined in resolution
$resolution['audio_sample_rate'] >= $metainfo['sample_rate'] &&
// bitrate of file is better or as good as defined in resolution
$resolution['audio_bitrate'] <= $metainfo['max_bit_rate'] ||
// or we allow worse quality to be used for encoding
filter_var(
$resolution['allow_lower_audio_bitrate'],
FILTER_VALIDATE_BOOLEAN
)
;
} | [
"private",
"function",
"audioCanBeEncoded",
"(",
"$",
"resolution",
",",
"$",
"metainfo",
")",
"{",
"return",
"// sample rate of file is better or as good as defined in resolution",
"$",
"resolution",
"[",
"'audio_sample_rate'",
"]",
">=",
"$",
"metainfo",
"[",
"'sample_rate'",
"]",
"&&",
"// bitrate of file is better or as good as defined in resolution",
"$",
"resolution",
"[",
"'audio_bitrate'",
"]",
"<=",
"$",
"metainfo",
"[",
"'max_bit_rate'",
"]",
"||",
"// or we allow worse quality to be used for encoding",
"filter_var",
"(",
"$",
"resolution",
"[",
"'allow_lower_audio_bitrate'",
"]",
",",
"FILTER_VALIDATE_BOOLEAN",
")",
";",
"}"
] | determines if the the audiotrack meets minimum standards to be encoded | [
"determines",
"if",
"the",
"the",
"audiotrack",
"meets",
"minimum",
"standards",
"to",
"be",
"encoded"
] | train | https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/FFprobeService.php#L158-L170 |
OKTOTV/OktolabMediaBundle | Model/FFprobeService.php | FFprobeService.getMediaType | private function getMediaType($metainfo) {
if (
$metainfo['audio'] != false &&
(
$metainfo['video'] == false ||
$metainfo['video']['codec_name'] == 'png' ||
$metainfo['video']['codec_name'] == 'jpg'
)
) {
return $this::MEDIA_TYPE_AUDIO;
}
if ($metainfo['video'] != false && $metainfo['audio'] == false) {
return $this::MEDIA_TYPE_VIDEO_ONLY;
}
if ($metainfo['video'] != false && $metainfo['audio'] != false) {
return $this::MEDIA_TYPE_VIDEO;
}
return $this::MEDIA_TYPE_UNKNOWN;
} | php | private function getMediaType($metainfo) {
if (
$metainfo['audio'] != false &&
(
$metainfo['video'] == false ||
$metainfo['video']['codec_name'] == 'png' ||
$metainfo['video']['codec_name'] == 'jpg'
)
) {
return $this::MEDIA_TYPE_AUDIO;
}
if ($metainfo['video'] != false && $metainfo['audio'] == false) {
return $this::MEDIA_TYPE_VIDEO_ONLY;
}
if ($metainfo['video'] != false && $metainfo['audio'] != false) {
return $this::MEDIA_TYPE_VIDEO;
}
return $this::MEDIA_TYPE_UNKNOWN;
} | [
"private",
"function",
"getMediaType",
"(",
"$",
"metainfo",
")",
"{",
"if",
"(",
"$",
"metainfo",
"[",
"'audio'",
"]",
"!=",
"false",
"&&",
"(",
"$",
"metainfo",
"[",
"'video'",
"]",
"==",
"false",
"||",
"$",
"metainfo",
"[",
"'video'",
"]",
"[",
"'codec_name'",
"]",
"==",
"'png'",
"||",
"$",
"metainfo",
"[",
"'video'",
"]",
"[",
"'codec_name'",
"]",
"==",
"'jpg'",
")",
")",
"{",
"return",
"$",
"this",
"::",
"MEDIA_TYPE_AUDIO",
";",
"}",
"if",
"(",
"$",
"metainfo",
"[",
"'video'",
"]",
"!=",
"false",
"&&",
"$",
"metainfo",
"[",
"'audio'",
"]",
"==",
"false",
")",
"{",
"return",
"$",
"this",
"::",
"MEDIA_TYPE_VIDEO_ONLY",
";",
"}",
"if",
"(",
"$",
"metainfo",
"[",
"'video'",
"]",
"!=",
"false",
"&&",
"$",
"metainfo",
"[",
"'audio'",
"]",
"!=",
"false",
")",
"{",
"return",
"$",
"this",
"::",
"MEDIA_TYPE_VIDEO",
";",
"}",
"return",
"$",
"this",
"::",
"MEDIA_TYPE_UNKNOWN",
";",
"}"
] | returns the mediatype depending on given metainfos
MEDIA_TYPE_AUDIO if soundfile,
MEDIA_TYPE_VIDEO if videofile,
MEDIA_TYPE_VIDEO_ONLY if videofile without soundstream. | [
"returns",
"the",
"mediatype",
"depending",
"on",
"given",
"metainfos",
"MEDIA_TYPE_AUDIO",
"if",
"soundfile",
"MEDIA_TYPE_VIDEO",
"if",
"videofile",
"MEDIA_TYPE_VIDEO_ONLY",
"if",
"videofile",
"without",
"soundstream",
"."
] | train | https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/FFprobeService.php#L178-L198 |
OKTOTV/OktolabMediaBundle | Model/FFprobeService.php | FFprobeService.getMetainfoForEpisode | private function getMetainfoForEpisode($episode) {
$uri = $this->bprs_asset_helper->getAbsoluteUrl(
$episode->getVideo()
);
if (!$uri) { // can't create uri of episode video
$this->logbook->error(
'oktolab_media.episode_encode_no_streams',
[],
$episode->getUniqID()
);
return false;
}
$metainfo = json_decode(
shell_exec(
sprintf(
'ffprobe -v error -show_streams -print_format json %s',
$uri)
),
true
);
$metadata = ['video' => false, 'audio' => false];
// run through all streams to find the primary video and audio stream
foreach ($metainfo['streams'] as $stream) {
// found both streams, skip the rest
if ($metadata['video'] && $metadata['audio']) {
break;
}
// found an audio stream
if ($stream['codec_type'] == "audio" && $metadata['audio'] == false) {
$metadata['audio'] = $stream;
if (
!array_key_exists('max_bit_rate', $metadata['audio']) &&
array_key_exists('tags', $metadata['audio'])
) {
$metadata['audio']['max_bit_rate'] = $metadata['tags']['BPS'];
}
}
if ($stream['codec_type'] == "video") {
$metadata['video'] = $stream;
if (!array_key_exists('duration', $metadata['video'])) {
$metadata['video']['duration'] = 0;
} else {
$episode->setDuration($metadata['video']['duration']);
}
}
}
return $metadata;
} | php | private function getMetainfoForEpisode($episode) {
$uri = $this->bprs_asset_helper->getAbsoluteUrl(
$episode->getVideo()
);
if (!$uri) { // can't create uri of episode video
$this->logbook->error(
'oktolab_media.episode_encode_no_streams',
[],
$episode->getUniqID()
);
return false;
}
$metainfo = json_decode(
shell_exec(
sprintf(
'ffprobe -v error -show_streams -print_format json %s',
$uri)
),
true
);
$metadata = ['video' => false, 'audio' => false];
// run through all streams to find the primary video and audio stream
foreach ($metainfo['streams'] as $stream) {
// found both streams, skip the rest
if ($metadata['video'] && $metadata['audio']) {
break;
}
// found an audio stream
if ($stream['codec_type'] == "audio" && $metadata['audio'] == false) {
$metadata['audio'] = $stream;
if (
!array_key_exists('max_bit_rate', $metadata['audio']) &&
array_key_exists('tags', $metadata['audio'])
) {
$metadata['audio']['max_bit_rate'] = $metadata['tags']['BPS'];
}
}
if ($stream['codec_type'] == "video") {
$metadata['video'] = $stream;
if (!array_key_exists('duration', $metadata['video'])) {
$metadata['video']['duration'] = 0;
} else {
$episode->setDuration($metadata['video']['duration']);
}
}
}
return $metadata;
} | [
"private",
"function",
"getMetainfoForEpisode",
"(",
"$",
"episode",
")",
"{",
"$",
"uri",
"=",
"$",
"this",
"->",
"bprs_asset_helper",
"->",
"getAbsoluteUrl",
"(",
"$",
"episode",
"->",
"getVideo",
"(",
")",
")",
";",
"if",
"(",
"!",
"$",
"uri",
")",
"{",
"// can't create uri of episode video",
"$",
"this",
"->",
"logbook",
"->",
"error",
"(",
"'oktolab_media.episode_encode_no_streams'",
",",
"[",
"]",
",",
"$",
"episode",
"->",
"getUniqID",
"(",
")",
")",
";",
"return",
"false",
";",
"}",
"$",
"metainfo",
"=",
"json_decode",
"(",
"shell_exec",
"(",
"sprintf",
"(",
"'ffprobe -v error -show_streams -print_format json %s'",
",",
"$",
"uri",
")",
")",
",",
"true",
")",
";",
"$",
"metadata",
"=",
"[",
"'video'",
"=>",
"false",
",",
"'audio'",
"=>",
"false",
"]",
";",
"// run through all streams to find the primary video and audio stream",
"foreach",
"(",
"$",
"metainfo",
"[",
"'streams'",
"]",
"as",
"$",
"stream",
")",
"{",
"// found both streams, skip the rest",
"if",
"(",
"$",
"metadata",
"[",
"'video'",
"]",
"&&",
"$",
"metadata",
"[",
"'audio'",
"]",
")",
"{",
"break",
";",
"}",
"// found an audio stream",
"if",
"(",
"$",
"stream",
"[",
"'codec_type'",
"]",
"==",
"\"audio\"",
"&&",
"$",
"metadata",
"[",
"'audio'",
"]",
"==",
"false",
")",
"{",
"$",
"metadata",
"[",
"'audio'",
"]",
"=",
"$",
"stream",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"'max_bit_rate'",
",",
"$",
"metadata",
"[",
"'audio'",
"]",
")",
"&&",
"array_key_exists",
"(",
"'tags'",
",",
"$",
"metadata",
"[",
"'audio'",
"]",
")",
")",
"{",
"$",
"metadata",
"[",
"'audio'",
"]",
"[",
"'max_bit_rate'",
"]",
"=",
"$",
"metadata",
"[",
"'tags'",
"]",
"[",
"'BPS'",
"]",
";",
"}",
"}",
"if",
"(",
"$",
"stream",
"[",
"'codec_type'",
"]",
"==",
"\"video\"",
")",
"{",
"$",
"metadata",
"[",
"'video'",
"]",
"=",
"$",
"stream",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"'duration'",
",",
"$",
"metadata",
"[",
"'video'",
"]",
")",
")",
"{",
"$",
"metadata",
"[",
"'video'",
"]",
"[",
"'duration'",
"]",
"=",
"0",
";",
"}",
"else",
"{",
"$",
"episode",
"->",
"setDuration",
"(",
"$",
"metadata",
"[",
"'video'",
"]",
"[",
"'duration'",
"]",
")",
";",
"}",
"}",
"}",
"return",
"$",
"metadata",
";",
"}"
] | extracts streaminformations of an episode from its video.
@param object $episode Entity you want the stream infos from
@return false|array if informations can't be extracted,
array of video and audio info | [
"extracts",
"streaminformations",
"of",
"an",
"episode",
"from",
"its",
"video",
"."
] | train | https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/FFprobeService.php#L206-L258 |
wearenolte/wp-cpt | src/Cpt.php | Cpt.init | public function init() {
if ( ! post_type_exists( $this->post_type ) ) {
$post_type = register_post_type( $this->post_type, $this->args );
if ( is_wp_error( $post_type ) ) {
return $post_type;
}
}
if ( '' !== $this->title_placeholder ) {
add_filter( 'enter_title_here', array( $this, 'update_placeholder' ) );
}
} | php | public function init() {
if ( ! post_type_exists( $this->post_type ) ) {
$post_type = register_post_type( $this->post_type, $this->args );
if ( is_wp_error( $post_type ) ) {
return $post_type;
}
}
if ( '' !== $this->title_placeholder ) {
add_filter( 'enter_title_here', array( $this, 'update_placeholder' ) );
}
} | [
"public",
"function",
"init",
"(",
")",
"{",
"if",
"(",
"!",
"post_type_exists",
"(",
"$",
"this",
"->",
"post_type",
")",
")",
"{",
"$",
"post_type",
"=",
"register_post_type",
"(",
"$",
"this",
"->",
"post_type",
",",
"$",
"this",
"->",
"args",
")",
";",
"if",
"(",
"is_wp_error",
"(",
"$",
"post_type",
")",
")",
"{",
"return",
"$",
"post_type",
";",
"}",
"}",
"if",
"(",
"''",
"!==",
"$",
"this",
"->",
"title_placeholder",
")",
"{",
"add_filter",
"(",
"'enter_title_here'",
",",
"array",
"(",
"$",
"this",
",",
"'update_placeholder'",
")",
")",
";",
"}",
"}"
] | Function that register the CPT first tests if there is no such CPT on
the site.
@since 0.1.0 | [
"Function",
"that",
"register",
"the",
"CPT",
"first",
"tests",
"if",
"there",
"is",
"no",
"such",
"CPT",
"on",
"the",
"site",
"."
] | train | https://github.com/wearenolte/wp-cpt/blob/b6c11946e8f53a7c5ad5b347f66848c6df355812/src/Cpt.php#L177-L187 |
wearenolte/wp-cpt | src/Cpt.php | Cpt.set_default_args | private function set_default_args() {
$this->set_args(array(
// The array of labels to use in the UI for this post type.
'labels' => $this->labels,
// Array of supported fields ( title, editor, thumbnail, etc ).
'supports' => $this->supports,
// We use the query var 'store' as opposed to the post type 'acf-store'.
'query_var' => strtolower( $this->singular ),
// Triggers the handling of re-writes for this post-type.
'rewrite' => $this->rewrite,
));
} | php | private function set_default_args() {
$this->set_args(array(
// The array of labels to use in the UI for this post type.
'labels' => $this->labels,
// Array of supported fields ( title, editor, thumbnail, etc ).
'supports' => $this->supports,
// We use the query var 'store' as opposed to the post type 'acf-store'.
'query_var' => strtolower( $this->singular ),
// Triggers the handling of re-writes for this post-type.
'rewrite' => $this->rewrite,
));
} | [
"private",
"function",
"set_default_args",
"(",
")",
"{",
"$",
"this",
"->",
"set_args",
"(",
"array",
"(",
"// The array of labels to use in the UI for this post type.",
"'labels'",
"=>",
"$",
"this",
"->",
"labels",
",",
"// Array of supported fields ( title, editor, thumbnail, etc ).",
"'supports'",
"=>",
"$",
"this",
"->",
"supports",
",",
"// We use the query var 'store' as opposed to the post type 'acf-store'.",
"'query_var'",
"=>",
"strtolower",
"(",
"$",
"this",
"->",
"singular",
")",
",",
"// Triggers the handling of re-writes for this post-type.",
"'rewrite'",
"=>",
"$",
"this",
"->",
"rewrite",
",",
")",
")",
";",
"}"
] | Creates the default group of arguments, all of the arguments can be
overwritten by calling set_args, function with an instance of this object,
the value is stored in the $args variable.
@since 0.1.0 | [
"Creates",
"the",
"default",
"group",
"of",
"arguments",
"all",
"of",
"the",
"arguments",
"can",
"be",
"overwritten",
"by",
"calling",
"set_args",
"function",
"with",
"an",
"instance",
"of",
"this",
"object",
"the",
"value",
"is",
"stored",
"in",
"the",
"$args",
"variable",
"."
] | train | https://github.com/wearenolte/wp-cpt/blob/b6c11946e8f53a7c5ad5b347f66848c6df355812/src/Cpt.php#L196-L207 |
wearenolte/wp-cpt | src/Cpt.php | Cpt.set_labels | public function set_labels( $labels ) {
$this->merge( $this->labels, $labels );
$this->update_arg( 'labels', $this->labels );
} | php | public function set_labels( $labels ) {
$this->merge( $this->labels, $labels );
$this->update_arg( 'labels', $this->labels );
} | [
"public",
"function",
"set_labels",
"(",
"$",
"labels",
")",
"{",
"$",
"this",
"->",
"merge",
"(",
"$",
"this",
"->",
"labels",
",",
"$",
"labels",
")",
";",
"$",
"this",
"->",
"update_arg",
"(",
"'labels'",
",",
"$",
"this",
"->",
"labels",
")",
";",
"}"
] | Allows to overwrite any of the default labels for this CPT, just
send an associate array with the value you want to update.
@since 0.1.0
@param array $labels The group of labels to update. | [
"Allows",
"to",
"overwrite",
"any",
"of",
"the",
"default",
"labels",
"for",
"this",
"CPT",
"just",
"send",
"an",
"associate",
"array",
"with",
"the",
"value",
"you",
"want",
"to",
"update",
"."
] | train | https://github.com/wearenolte/wp-cpt/blob/b6c11946e8f53a7c5ad5b347f66848c6df355812/src/Cpt.php#L229-L232 |
wearenolte/wp-cpt | src/Cpt.php | Cpt.set_default_labels | private function set_default_labels() {
$this->labels = array(
'name' => $this->interpolate( '%s', $this->plural ),
'singular_name' => $this->interpolate( '%s', $this->singular ),
'add_new' => $this->interpolate( 'Add New' ),
'all_items' => $this->interpolate( 'All %s', $this-> plural ),
'new_item' => $this->interpolate( 'New %s', $this->singular ),
'edit_item' => $this->interpolate( 'Edit %s', $this->singular ),
'add_new_item' => $this->interpolate( 'Add New %s', $this->singular ),
'view_item' => $this->interpolate( 'View %S', $this->singular ),
'menu_name' => $this->interpolate( '%s', $this->plural ),
'search_items' => $this->interpolate( 'Search %s', $this->plural ),
'not_found' => $this->interpolate( 'No %s found.', $this->plural ),
'not_found_in_trash' => $this->interpolate( 'No %s found in trash.', $this->plural ),
);
} | php | private function set_default_labels() {
$this->labels = array(
'name' => $this->interpolate( '%s', $this->plural ),
'singular_name' => $this->interpolate( '%s', $this->singular ),
'add_new' => $this->interpolate( 'Add New' ),
'all_items' => $this->interpolate( 'All %s', $this-> plural ),
'new_item' => $this->interpolate( 'New %s', $this->singular ),
'edit_item' => $this->interpolate( 'Edit %s', $this->singular ),
'add_new_item' => $this->interpolate( 'Add New %s', $this->singular ),
'view_item' => $this->interpolate( 'View %S', $this->singular ),
'menu_name' => $this->interpolate( '%s', $this->plural ),
'search_items' => $this->interpolate( 'Search %s', $this->plural ),
'not_found' => $this->interpolate( 'No %s found.', $this->plural ),
'not_found_in_trash' => $this->interpolate( 'No %s found in trash.', $this->plural ),
);
} | [
"private",
"function",
"set_default_labels",
"(",
")",
"{",
"$",
"this",
"->",
"labels",
"=",
"array",
"(",
"'name'",
"=>",
"$",
"this",
"->",
"interpolate",
"(",
"'%s'",
",",
"$",
"this",
"->",
"plural",
")",
",",
"'singular_name'",
"=>",
"$",
"this",
"->",
"interpolate",
"(",
"'%s'",
",",
"$",
"this",
"->",
"singular",
")",
",",
"'add_new'",
"=>",
"$",
"this",
"->",
"interpolate",
"(",
"'Add New'",
")",
",",
"'all_items'",
"=>",
"$",
"this",
"->",
"interpolate",
"(",
"'All %s'",
",",
"$",
"this",
"->",
"plural",
")",
",",
"'new_item'",
"=>",
"$",
"this",
"->",
"interpolate",
"(",
"'New %s'",
",",
"$",
"this",
"->",
"singular",
")",
",",
"'edit_item'",
"=>",
"$",
"this",
"->",
"interpolate",
"(",
"'Edit %s'",
",",
"$",
"this",
"->",
"singular",
")",
",",
"'add_new_item'",
"=>",
"$",
"this",
"->",
"interpolate",
"(",
"'Add New %s'",
",",
"$",
"this",
"->",
"singular",
")",
",",
"'view_item'",
"=>",
"$",
"this",
"->",
"interpolate",
"(",
"'View %S'",
",",
"$",
"this",
"->",
"singular",
")",
",",
"'menu_name'",
"=>",
"$",
"this",
"->",
"interpolate",
"(",
"'%s'",
",",
"$",
"this",
"->",
"plural",
")",
",",
"'search_items'",
"=>",
"$",
"this",
"->",
"interpolate",
"(",
"'Search %s'",
",",
"$",
"this",
"->",
"plural",
")",
",",
"'not_found'",
"=>",
"$",
"this",
"->",
"interpolate",
"(",
"'No %s found.'",
",",
"$",
"this",
"->",
"plural",
")",
",",
"'not_found_in_trash'",
"=>",
"$",
"this",
"->",
"interpolate",
"(",
"'No %s found in trash.'",
",",
"$",
"this",
"->",
"plural",
")",
",",
")",
";",
"}"
] | Creates the default labels to be used with this CPT.
@since 0.10 | [
"Creates",
"the",
"default",
"labels",
"to",
"be",
"used",
"with",
"this",
"CPT",
"."
] | train | https://github.com/wearenolte/wp-cpt/blob/b6c11946e8f53a7c5ad5b347f66848c6df355812/src/Cpt.php#L256-L271 |
wearenolte/wp-cpt | src/Cpt.php | Cpt.set_rewrite | public function set_rewrite( $rules ) {
$this->merge( $this->rewrite, $rules );
$this->update_arg( 'rewrite', $this->rewrite );
} | php | public function set_rewrite( $rules ) {
$this->merge( $this->rewrite, $rules );
$this->update_arg( 'rewrite', $this->rewrite );
} | [
"public",
"function",
"set_rewrite",
"(",
"$",
"rules",
")",
"{",
"$",
"this",
"->",
"merge",
"(",
"$",
"this",
"->",
"rewrite",
",",
"$",
"rules",
")",
";",
"$",
"this",
"->",
"update_arg",
"(",
"'rewrite'",
",",
"$",
"this",
"->",
"rewrite",
")",
";",
"}"
] | Updates the default options in the $rewrite variable.
@since 0.1.0
@param array $rules The associate array with the new rules. | [
"Updates",
"the",
"default",
"options",
"in",
"the",
"$rewrite",
"variable",
"."
] | train | https://github.com/wearenolte/wp-cpt/blob/b6c11946e8f53a7c5ad5b347f66848c6df355812/src/Cpt.php#L330-L333 |
wearenolte/wp-cpt | src/Cpt.php | Cpt.set_supports | public function set_supports( $support ) {
if ( is_array( $support ) ) {
$this->supports = $support;
$this->update_arg( 'supports', $this->supports );
}
} | php | public function set_supports( $support ) {
if ( is_array( $support ) ) {
$this->supports = $support;
$this->update_arg( 'supports', $this->supports );
}
} | [
"public",
"function",
"set_supports",
"(",
"$",
"support",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"support",
")",
")",
"{",
"$",
"this",
"->",
"supports",
"=",
"$",
"support",
";",
"$",
"this",
"->",
"update_arg",
"(",
"'supports'",
",",
"$",
"this",
"->",
"supports",
")",
";",
"}",
"}"
] | Allow to update the default supports values for the CPT.
@since 0.1.0
@param array $support The new array with the supported featurs. | [
"Allow",
"to",
"update",
"the",
"default",
"supports",
"values",
"for",
"the",
"CPT",
"."
] | train | https://github.com/wearenolte/wp-cpt/blob/b6c11946e8f53a7c5ad5b347f66848c6df355812/src/Cpt.php#L342-L347 |
wearenolte/wp-cpt | src/Cpt.php | Cpt.update_placeholder | public function update_placeholder( $title ) {
$screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null;
$current_cpt = is_object( $screen ) && property_exists( $screen, 'post_type' )
? $screen->post_type
: '';
if ( $this->post_type === $current_cpt ) {
$title = $this->label( $this->title_placeholder );
}
return $title;
} | php | public function update_placeholder( $title ) {
$screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null;
$current_cpt = is_object( $screen ) && property_exists( $screen, 'post_type' )
? $screen->post_type
: '';
if ( $this->post_type === $current_cpt ) {
$title = $this->label( $this->title_placeholder );
}
return $title;
} | [
"public",
"function",
"update_placeholder",
"(",
"$",
"title",
")",
"{",
"$",
"screen",
"=",
"function_exists",
"(",
"'get_current_screen'",
")",
"?",
"get_current_screen",
"(",
")",
":",
"null",
";",
"$",
"current_cpt",
"=",
"is_object",
"(",
"$",
"screen",
")",
"&&",
"property_exists",
"(",
"$",
"screen",
",",
"'post_type'",
")",
"?",
"$",
"screen",
"->",
"post_type",
":",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"post_type",
"===",
"$",
"current_cpt",
")",
"{",
"$",
"title",
"=",
"$",
"this",
"->",
"label",
"(",
"$",
"this",
"->",
"title_placeholder",
")",
";",
"}",
"return",
"$",
"title",
";",
"}"
] | Function that is being colled by the filter: 'enter_title_here' to update
the default 'enter title here' in the admin.
@since 0.1.0
@param string $title The current title on the input.
@return string $title The new title | [
"Function",
"that",
"is",
"being",
"colled",
"by",
"the",
"filter",
":",
"enter_title_here",
"to",
"update",
"the",
"default",
"enter",
"title",
"here",
"in",
"the",
"admin",
"."
] | train | https://github.com/wearenolte/wp-cpt/blob/b6c11946e8f53a7c5ad5b347f66848c6df355812/src/Cpt.php#L374-L384 |
oroinc/OroLayoutComponent | DataAccessor.php | DataAccessor.offsetGet | public function offsetGet($name)
{
$dataProvider = $this->getDataProvider($name);
if (is_object($dataProvider)) {
return new DataProviderDecorator($dataProvider, ['get', 'has', 'is']);
} elseif ($dataProvider !== false) {
return $this->context->data()->get($name);
}
throw new Exception\InvalidArgumentException(
sprintf('Could not load the data provider "%s".', $name)
);
} | php | public function offsetGet($name)
{
$dataProvider = $this->getDataProvider($name);
if (is_object($dataProvider)) {
return new DataProviderDecorator($dataProvider, ['get', 'has', 'is']);
} elseif ($dataProvider !== false) {
return $this->context->data()->get($name);
}
throw new Exception\InvalidArgumentException(
sprintf('Could not load the data provider "%s".', $name)
);
} | [
"public",
"function",
"offsetGet",
"(",
"$",
"name",
")",
"{",
"$",
"dataProvider",
"=",
"$",
"this",
"->",
"getDataProvider",
"(",
"$",
"name",
")",
";",
"if",
"(",
"is_object",
"(",
"$",
"dataProvider",
")",
")",
"{",
"return",
"new",
"DataProviderDecorator",
"(",
"$",
"dataProvider",
",",
"[",
"'get'",
",",
"'has'",
",",
"'is'",
"]",
")",
";",
"}",
"elseif",
"(",
"$",
"dataProvider",
"!==",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"context",
"->",
"data",
"(",
")",
"->",
"get",
"(",
"$",
"name",
")",
";",
"}",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Could not load the data provider \"%s\".'",
",",
"$",
"name",
")",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/DataAccessor.php#L43-L56 |
oroinc/OroLayoutComponent | DataAccessor.php | DataAccessor.getDataProvider | protected function getDataProvider($name)
{
if (!isset($this->dataProviders[$name])) {
$dataProvider = $this->registry->findDataProvider($name);
if ($dataProvider === null) {
$dataProvider = $this->context->data()->has($name) ? true : false;
}
$this->dataProviders[$name] = $dataProvider;
}
return $this->dataProviders[$name];
} | php | protected function getDataProvider($name)
{
if (!isset($this->dataProviders[$name])) {
$dataProvider = $this->registry->findDataProvider($name);
if ($dataProvider === null) {
$dataProvider = $this->context->data()->has($name) ? true : false;
}
$this->dataProviders[$name] = $dataProvider;
}
return $this->dataProviders[$name];
} | [
"protected",
"function",
"getDataProvider",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"dataProviders",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"dataProvider",
"=",
"$",
"this",
"->",
"registry",
"->",
"findDataProvider",
"(",
"$",
"name",
")",
";",
"if",
"(",
"$",
"dataProvider",
"===",
"null",
")",
"{",
"$",
"dataProvider",
"=",
"$",
"this",
"->",
"context",
"->",
"data",
"(",
")",
"->",
"has",
"(",
"$",
"name",
")",
"?",
"true",
":",
"false",
";",
"}",
"$",
"this",
"->",
"dataProviders",
"[",
"$",
"name",
"]",
"=",
"$",
"dataProvider",
";",
"}",
"return",
"$",
"this",
"->",
"dataProviders",
"[",
"$",
"name",
"]",
";",
"}"
] | @param string $name The name of the data provider
@return mixed The returned values:
data provider object if the data provider is loaded
mixed if data should be loaded from the layout context
false if the requested data cannot be loaded | [
"@param",
"string",
"$name",
"The",
"name",
"of",
"the",
"data",
"provider"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/DataAccessor.php#L95-L108 |
Eresus/EresusCMS | src/core/Application.php | Eresus_Application.detectFsRoot | protected function detectFsRoot()
{
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, 'start');
switch (true)
{
case Eresus_Kernel::isCLI():
$path = reset($GLOBALS['argv']);
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, 'Using global $argv variable: %s', $path);
$path = dirname($path);
break;
default:
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, 'Using $_SERVER["SCRIPT_FILENAME"]: %s',
$_SERVER['SCRIPT_FILENAME']);
$path = dirname($_SERVER['SCRIPT_FILENAME']);
}
$path = Eresus_FS_Tool::normalize($path);
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, '"%s"', $path);
return $path;
} | php | protected function detectFsRoot()
{
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, 'start');
switch (true)
{
case Eresus_Kernel::isCLI():
$path = reset($GLOBALS['argv']);
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, 'Using global $argv variable: %s', $path);
$path = dirname($path);
break;
default:
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, 'Using $_SERVER["SCRIPT_FILENAME"]: %s',
$_SERVER['SCRIPT_FILENAME']);
$path = dirname($_SERVER['SCRIPT_FILENAME']);
}
$path = Eresus_FS_Tool::normalize($path);
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, '"%s"', $path);
return $path;
} | [
"protected",
"function",
"detectFsRoot",
"(",
")",
"{",
"Eresus_Kernel",
"::",
"log",
"(",
"__METHOD__",
",",
"LOG_DEBUG",
",",
"'start'",
")",
";",
"switch",
"(",
"true",
")",
"{",
"case",
"Eresus_Kernel",
"::",
"isCLI",
"(",
")",
":",
"$",
"path",
"=",
"reset",
"(",
"$",
"GLOBALS",
"[",
"'argv'",
"]",
")",
";",
"Eresus_Kernel",
"::",
"log",
"(",
"__METHOD__",
",",
"LOG_DEBUG",
",",
"'Using global $argv variable: %s'",
",",
"$",
"path",
")",
";",
"$",
"path",
"=",
"dirname",
"(",
"$",
"path",
")",
";",
"break",
";",
"default",
":",
"Eresus_Kernel",
"::",
"log",
"(",
"__METHOD__",
",",
"LOG_DEBUG",
",",
"'Using $_SERVER[\"SCRIPT_FILENAME\"]: %s'",
",",
"$",
"_SERVER",
"[",
"'SCRIPT_FILENAME'",
"]",
")",
";",
"$",
"path",
"=",
"dirname",
"(",
"$",
"_SERVER",
"[",
"'SCRIPT_FILENAME'",
"]",
")",
";",
"}",
"$",
"path",
"=",
"Eresus_FS_Tool",
"::",
"normalize",
"(",
"$",
"path",
")",
";",
"Eresus_Kernel",
"::",
"log",
"(",
"__METHOD__",
",",
"LOG_DEBUG",
",",
"'\"%s\"'",
",",
"$",
"path",
")",
";",
"return",
"$",
"path",
";",
"}"
] | Trying to determine application root directory
In CLI mode $GLOBALS['argv'][0] used.
In other modes $_SERVER['SCRIPT_FILENAME'] used.
@return string
@see fsRoot, getFsRoot() | [
"Trying",
"to",
"determine",
"application",
"root",
"directory"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/Application.php#L115-L135 |
xinix-technology/bono-blade | src/Xinix/Blade/BladeView.php | BladeView.resolvePath | protected function resolvePath(array $originalPaths)
{
$paths = array();
foreach ($originalPaths as $key => $path) {
if (count(explode('templates', $path)) == 1) {
$path = $path . DIRECTORY_SEPARATOR . 'templates';
}
if (realpath($path)) {
$paths[$key] = realpath($path);
}
}
return array_unique($paths);
} | php | protected function resolvePath(array $originalPaths)
{
$paths = array();
foreach ($originalPaths as $key => $path) {
if (count(explode('templates', $path)) == 1) {
$path = $path . DIRECTORY_SEPARATOR . 'templates';
}
if (realpath($path)) {
$paths[$key] = realpath($path);
}
}
return array_unique($paths);
} | [
"protected",
"function",
"resolvePath",
"(",
"array",
"$",
"originalPaths",
")",
"{",
"$",
"paths",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"originalPaths",
"as",
"$",
"key",
"=>",
"$",
"path",
")",
"{",
"if",
"(",
"count",
"(",
"explode",
"(",
"'templates'",
",",
"$",
"path",
")",
")",
"==",
"1",
")",
"{",
"$",
"path",
"=",
"$",
"path",
".",
"DIRECTORY_SEPARATOR",
".",
"'templates'",
";",
"}",
"if",
"(",
"realpath",
"(",
"$",
"path",
")",
")",
"{",
"$",
"paths",
"[",
"$",
"key",
"]",
"=",
"realpath",
"(",
"$",
"path",
")",
";",
"}",
"}",
"return",
"array_unique",
"(",
"$",
"paths",
")",
";",
"}"
] | Build an array for templates path directory
@return void | [
"Build",
"an",
"array",
"for",
"templates",
"path",
"directory"
] | train | https://github.com/xinix-technology/bono-blade/blob/5b7b03bd3e87cc20d7262192d2b7b9cf334ba92f/src/Xinix/Blade/BladeView.php#L97-L113 |
xinix-technology/bono-blade | src/Xinix/Blade/BladeView.php | BladeView.registerEngineResolver | protected function registerEngineResolver()
{
$mySelf = $this;
$this->container->bindShared('view.engine.resolver', function ($app) use ($mySelf) {
$resolver = new EngineResolver();
$mySelf->registerPhpEngine($resolver);
$mySelf->registerBladeEngine($resolver);
return $resolver;
});
} | php | protected function registerEngineResolver()
{
$mySelf = $this;
$this->container->bindShared('view.engine.resolver', function ($app) use ($mySelf) {
$resolver = new EngineResolver();
$mySelf->registerPhpEngine($resolver);
$mySelf->registerBladeEngine($resolver);
return $resolver;
});
} | [
"protected",
"function",
"registerEngineResolver",
"(",
")",
"{",
"$",
"mySelf",
"=",
"$",
"this",
";",
"$",
"this",
"->",
"container",
"->",
"bindShared",
"(",
"'view.engine.resolver'",
",",
"function",
"(",
"$",
"app",
")",
"use",
"(",
"$",
"mySelf",
")",
"{",
"$",
"resolver",
"=",
"new",
"EngineResolver",
"(",
")",
";",
"$",
"mySelf",
"->",
"registerPhpEngine",
"(",
"$",
"resolver",
")",
";",
"$",
"mySelf",
"->",
"registerBladeEngine",
"(",
"$",
"resolver",
")",
";",
"return",
"$",
"resolver",
";",
"}",
")",
";",
"}"
] | Register the engine resolver instance.
@return void | [
"Register",
"the",
"engine",
"resolver",
"instance",
"."
] | train | https://github.com/xinix-technology/bono-blade/blob/5b7b03bd3e87cc20d7262192d2b7b9cf334ba92f/src/Xinix/Blade/BladeView.php#L144-L156 |
xinix-technology/bono-blade | src/Xinix/Blade/BladeView.php | BladeView.registerBladeEngine | protected function registerBladeEngine(EngineResolver $resolver)
{
$mySelf = $this;
$container = $this->container;
// The Compiler engine requires an instance of the CompilerInterface, which in
// this case will be the Blade compiler, so we'll first create the compiler
// instance to pass into the engine so it can compile the views properly.
$this->container->bindShared('blade.compiler', function ($container) use ($mySelf) {
return new BladeCompiler($container['files'], $container['cache.path']);
});
// Register the blade view file finder to resolve to template
$resolver->register('blade', function () use ($container) {
return new CompilerEngine($container['blade.compiler'], $container['files']);
});
} | php | protected function registerBladeEngine(EngineResolver $resolver)
{
$mySelf = $this;
$container = $this->container;
// The Compiler engine requires an instance of the CompilerInterface, which in
// this case will be the Blade compiler, so we'll first create the compiler
// instance to pass into the engine so it can compile the views properly.
$this->container->bindShared('blade.compiler', function ($container) use ($mySelf) {
return new BladeCompiler($container['files'], $container['cache.path']);
});
// Register the blade view file finder to resolve to template
$resolver->register('blade', function () use ($container) {
return new CompilerEngine($container['blade.compiler'], $container['files']);
});
} | [
"protected",
"function",
"registerBladeEngine",
"(",
"EngineResolver",
"$",
"resolver",
")",
"{",
"$",
"mySelf",
"=",
"$",
"this",
";",
"$",
"container",
"=",
"$",
"this",
"->",
"container",
";",
"// The Compiler engine requires an instance of the CompilerInterface, which in",
"// this case will be the Blade compiler, so we'll first create the compiler",
"// instance to pass into the engine so it can compile the views properly.",
"$",
"this",
"->",
"container",
"->",
"bindShared",
"(",
"'blade.compiler'",
",",
"function",
"(",
"$",
"container",
")",
"use",
"(",
"$",
"mySelf",
")",
"{",
"return",
"new",
"BladeCompiler",
"(",
"$",
"container",
"[",
"'files'",
"]",
",",
"$",
"container",
"[",
"'cache.path'",
"]",
")",
";",
"}",
")",
";",
"// Register the blade view file finder to resolve to template",
"$",
"resolver",
"->",
"register",
"(",
"'blade'",
",",
"function",
"(",
")",
"use",
"(",
"$",
"container",
")",
"{",
"return",
"new",
"CompilerEngine",
"(",
"$",
"container",
"[",
"'blade.compiler'",
"]",
",",
"$",
"container",
"[",
"'files'",
"]",
")",
";",
"}",
")",
";",
"}"
] | Register the Blade engine implementation.
@param \Illuminate\View\Engines\EngineResolver $resolver Engine Resolver
@return void | [
"Register",
"the",
"Blade",
"engine",
"implementation",
"."
] | train | https://github.com/xinix-technology/bono-blade/blob/5b7b03bd3e87cc20d7262192d2b7b9cf334ba92f/src/Xinix/Blade/BladeView.php#L179-L195 |
xinix-technology/bono-blade | src/Xinix/Blade/BladeView.php | BladeView.registerViewFinder | protected function registerViewFinder()
{
$container = $this->container;
$this->container->bindShared('view.finder', function ($app) use ($container) {
return new FileViewFinder($app['files'], $container['view.paths']);
});
} | php | protected function registerViewFinder()
{
$container = $this->container;
$this->container->bindShared('view.finder', function ($app) use ($container) {
return new FileViewFinder($app['files'], $container['view.paths']);
});
} | [
"protected",
"function",
"registerViewFinder",
"(",
")",
"{",
"$",
"container",
"=",
"$",
"this",
"->",
"container",
";",
"$",
"this",
"->",
"container",
"->",
"bindShared",
"(",
"'view.finder'",
",",
"function",
"(",
"$",
"app",
")",
"use",
"(",
"$",
"container",
")",
"{",
"return",
"new",
"FileViewFinder",
"(",
"$",
"app",
"[",
"'files'",
"]",
",",
"$",
"container",
"[",
"'view.paths'",
"]",
")",
";",
"}",
")",
";",
"}"
] | Register the view finder implementation.
@return void | [
"Register",
"the",
"view",
"finder",
"implementation",
"."
] | train | https://github.com/xinix-technology/bono-blade/blob/5b7b03bd3e87cc20d7262192d2b7b9cf334ba92f/src/Xinix/Blade/BladeView.php#L202-L209 |
xinix-technology/bono-blade | src/Xinix/Blade/BladeView.php | BladeView.registerEnvironment | protected function registerEnvironment()
{
// Next we need to grab the engine resolver instance that will be used by the
// environment. The resolver will be used by an environment to get each of
// the various engine implementations such as plain PHP or Blade engine.
$resolver = $this->container['view.engine.resolver'];
$finder = $this->container['view.finder'];
$events = $this->container['events'];
$env = new Environment($resolver, $finder, $events);
// We will also set the container instance on this view environment since the
// view composers may be classes registered in the container, which allows
// for great testable, flexible composers for the application developer.
$env->setContainer($this->container);
return $env;
} | php | protected function registerEnvironment()
{
// Next we need to grab the engine resolver instance that will be used by the
// environment. The resolver will be used by an environment to get each of
// the various engine implementations such as plain PHP or Blade engine.
$resolver = $this->container['view.engine.resolver'];
$finder = $this->container['view.finder'];
$events = $this->container['events'];
$env = new Environment($resolver, $finder, $events);
// We will also set the container instance on this view environment since the
// view composers may be classes registered in the container, which allows
// for great testable, flexible composers for the application developer.
$env->setContainer($this->container);
return $env;
} | [
"protected",
"function",
"registerEnvironment",
"(",
")",
"{",
"// Next we need to grab the engine resolver instance that will be used by the",
"// environment. The resolver will be used by an environment to get each of",
"// the various engine implementations such as plain PHP or Blade engine.",
"$",
"resolver",
"=",
"$",
"this",
"->",
"container",
"[",
"'view.engine.resolver'",
"]",
";",
"$",
"finder",
"=",
"$",
"this",
"->",
"container",
"[",
"'view.finder'",
"]",
";",
"$",
"events",
"=",
"$",
"this",
"->",
"container",
"[",
"'events'",
"]",
";",
"$",
"env",
"=",
"new",
"Environment",
"(",
"$",
"resolver",
",",
"$",
"finder",
",",
"$",
"events",
")",
";",
"// We will also set the container instance on this view environment since the",
"// view composers may be classes registered in the container, which allows",
"// for great testable, flexible composers for the application developer.",
"$",
"env",
"->",
"setContainer",
"(",
"$",
"this",
"->",
"container",
")",
";",
"return",
"$",
"env",
";",
"}"
] | Register the view environment.
@return Illuminate\View\Environment | [
"Register",
"the",
"view",
"environment",
"."
] | train | https://github.com/xinix-technology/bono-blade/blob/5b7b03bd3e87cc20d7262192d2b7b9cf334ba92f/src/Xinix/Blade/BladeView.php#L216-L232 |
xinix-technology/bono-blade | src/Xinix/Blade/BladeView.php | BladeView.setContentTags | public function setContentTags($openTag, $closeTag, $escaped = false)
{
return $this->container['blade.compiler']->setContentTags($openTag, $closeTag, $escaped);
} | php | public function setContentTags($openTag, $closeTag, $escaped = false)
{
return $this->container['blade.compiler']->setContentTags($openTag, $closeTag, $escaped);
} | [
"public",
"function",
"setContentTags",
"(",
"$",
"openTag",
",",
"$",
"closeTag",
",",
"$",
"escaped",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"container",
"[",
"'blade.compiler'",
"]",
"->",
"setContentTags",
"(",
"$",
"openTag",
",",
"$",
"closeTag",
",",
"$",
"escaped",
")",
";",
"}"
] | Sets the content tags used for the compiler.
@param string $openTag
@param string $closeTag
@param bool $escaped
@return void | [
"Sets",
"the",
"content",
"tags",
"used",
"for",
"the",
"compiler",
"."
] | train | https://github.com/xinix-technology/bono-blade/blob/5b7b03bd3e87cc20d7262192d2b7b9cf334ba92f/src/Xinix/Blade/BladeView.php#L254-L257 |
xinix-technology/bono-blade | src/Xinix/Blade/BladeView.php | BladeView.setLayout | public function setLayout($layout, array $data = array())
{
if (is_null($layout)) {
$this->layout = null;
return;
}
$this->layout = $this->make($this->resolve($layout), $data);
} | php | public function setLayout($layout, array $data = array())
{
if (is_null($layout)) {
$this->layout = null;
return;
}
$this->layout = $this->make($this->resolve($layout), $data);
} | [
"public",
"function",
"setLayout",
"(",
"$",
"layout",
",",
"array",
"$",
"data",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"layout",
")",
")",
"{",
"$",
"this",
"->",
"layout",
"=",
"null",
";",
"return",
";",
"}",
"$",
"this",
"->",
"layout",
"=",
"$",
"this",
"->",
"make",
"(",
"$",
"this",
"->",
"resolve",
"(",
"$",
"layout",
")",
",",
"$",
"data",
")",
";",
"}"
] | Manually set the layout
This method will output the rendered template content, so you can set the layout on the air
@param string $layout name
@return void | [
"Manually",
"set",
"the",
"layout"
] | train | https://github.com/xinix-technology/bono-blade/blob/5b7b03bd3e87cc20d7262192d2b7b9cf334ba92f/src/Xinix/Blade/BladeView.php#L278-L287 |
xinix-technology/bono-blade | src/Xinix/Blade/BladeView.php | BladeView.fetch | public function fetch($template, $data = array())
{
$view = $this->render($template, $data);
return ($view) ? $view->render() : '';
} | php | public function fetch($template, $data = array())
{
$view = $this->render($template, $data);
return ($view) ? $view->render() : '';
} | [
"public",
"function",
"fetch",
"(",
"$",
"template",
",",
"$",
"data",
"=",
"array",
"(",
")",
")",
"{",
"$",
"view",
"=",
"$",
"this",
"->",
"render",
"(",
"$",
"template",
",",
"$",
"data",
")",
";",
"return",
"(",
"$",
"view",
")",
"?",
"$",
"view",
"->",
"render",
"(",
")",
":",
"''",
";",
"}"
] | Return the contents of a rendered template file
@var string $template The template pathname, relative to the template base directory
@return Illuminate\View\View | [
"Return",
"the",
"contents",
"of",
"a",
"rendered",
"template",
"file"
] | train | https://github.com/xinix-technology/bono-blade/blob/5b7b03bd3e87cc20d7262192d2b7b9cf334ba92f/src/Xinix/Blade/BladeView.php#L308-L313 |
xinix-technology/bono-blade | src/Xinix/Blade/BladeView.php | BladeView.render | protected function render($template, $data = array())
{
$view = null;
$data = array_merge_recursive($this->all(), $data);
$data['app'] = $this->app;
$template = $this->resolve($template);
if (! $template) {
return;
}
if (! $this->layout) {
$view = $this->make($template, $data);
} else {
$view = $this->layout->nest('content', $template, $data);
}
return $view;
} | php | protected function render($template, $data = array())
{
$view = null;
$data = array_merge_recursive($this->all(), $data);
$data['app'] = $this->app;
$template = $this->resolve($template);
if (! $template) {
return;
}
if (! $this->layout) {
$view = $this->make($template, $data);
} else {
$view = $this->layout->nest('content', $template, $data);
}
return $view;
} | [
"protected",
"function",
"render",
"(",
"$",
"template",
",",
"$",
"data",
"=",
"array",
"(",
")",
")",
"{",
"$",
"view",
"=",
"null",
";",
"$",
"data",
"=",
"array_merge_recursive",
"(",
"$",
"this",
"->",
"all",
"(",
")",
",",
"$",
"data",
")",
";",
"$",
"data",
"[",
"'app'",
"]",
"=",
"$",
"this",
"->",
"app",
";",
"$",
"template",
"=",
"$",
"this",
"->",
"resolve",
"(",
"$",
"template",
")",
";",
"if",
"(",
"!",
"$",
"template",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"layout",
")",
"{",
"$",
"view",
"=",
"$",
"this",
"->",
"make",
"(",
"$",
"template",
",",
"$",
"data",
")",
";",
"}",
"else",
"{",
"$",
"view",
"=",
"$",
"this",
"->",
"layout",
"->",
"nest",
"(",
"'content'",
",",
"$",
"template",
",",
"$",
"data",
")",
";",
"}",
"return",
"$",
"view",
";",
"}"
] | This method will output the rendered template content
@param string $template The path to the Blade template, relative to the Blade templates directory.
@return Illuminate\View\View | [
"This",
"method",
"will",
"output",
"the",
"rendered",
"template",
"content"
] | train | https://github.com/xinix-technology/bono-blade/blob/5b7b03bd3e87cc20d7262192d2b7b9cf334ba92f/src/Xinix/Blade/BladeView.php#L322-L341 |
xinix-technology/bono-blade | src/Xinix/Blade/BladeView.php | BladeView.resolve | public function resolve($path)
{
$path = str_replace('/', '.', preg_replace('/\/:\w+/', '', $path));
$finder = $this->container['view.finder'];
try {
$finder->find($path);
} catch (InvalidArgumentException $e) {
$explodedPath = explode('.', $path);
if ($explodedPath[0] === 'static') {
return null;
}
if (count($explodedPath) > 1) {
$explodedPath[0] = 'shared';
$explodedPath = array('shared', end($explodedPath));
try {
$finder->find(implode('.', $explodedPath));
$path = implode('.', $explodedPath);
} catch (InvalidArgumentException $e) {
$this->app->error($e);
}
}
}
return $path;
} | php | public function resolve($path)
{
$path = str_replace('/', '.', preg_replace('/\/:\w+/', '', $path));
$finder = $this->container['view.finder'];
try {
$finder->find($path);
} catch (InvalidArgumentException $e) {
$explodedPath = explode('.', $path);
if ($explodedPath[0] === 'static') {
return null;
}
if (count($explodedPath) > 1) {
$explodedPath[0] = 'shared';
$explodedPath = array('shared', end($explodedPath));
try {
$finder->find(implode('.', $explodedPath));
$path = implode('.', $explodedPath);
} catch (InvalidArgumentException $e) {
$this->app->error($e);
}
}
}
return $path;
} | [
"public",
"function",
"resolve",
"(",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"str_replace",
"(",
"'/'",
",",
"'.'",
",",
"preg_replace",
"(",
"'/\\/:\\w+/'",
",",
"''",
",",
"$",
"path",
")",
")",
";",
"$",
"finder",
"=",
"$",
"this",
"->",
"container",
"[",
"'view.finder'",
"]",
";",
"try",
"{",
"$",
"finder",
"->",
"find",
"(",
"$",
"path",
")",
";",
"}",
"catch",
"(",
"InvalidArgumentException",
"$",
"e",
")",
"{",
"$",
"explodedPath",
"=",
"explode",
"(",
"'.'",
",",
"$",
"path",
")",
";",
"if",
"(",
"$",
"explodedPath",
"[",
"0",
"]",
"===",
"'static'",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"explodedPath",
")",
">",
"1",
")",
"{",
"$",
"explodedPath",
"[",
"0",
"]",
"=",
"'shared'",
";",
"$",
"explodedPath",
"=",
"array",
"(",
"'shared'",
",",
"end",
"(",
"$",
"explodedPath",
")",
")",
";",
"try",
"{",
"$",
"finder",
"->",
"find",
"(",
"implode",
"(",
"'.'",
",",
"$",
"explodedPath",
")",
")",
";",
"$",
"path",
"=",
"implode",
"(",
"'.'",
",",
"$",
"explodedPath",
")",
";",
"}",
"catch",
"(",
"InvalidArgumentException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"error",
"(",
"$",
"e",
")",
";",
"}",
"}",
"}",
"return",
"$",
"path",
";",
"}"
] | This method will try to find the existing of template file
@param string $path The relative template path
@return string
@throws InvalidArgumentException If we cannot find view | [
"This",
"method",
"will",
"try",
"to",
"find",
"the",
"existing",
"of",
"template",
"file"
] | train | https://github.com/xinix-technology/bono-blade/blob/5b7b03bd3e87cc20d7262192d2b7b9cf334ba92f/src/Xinix/Blade/BladeView.php#L351-L380 |
expectation-php/expect | src/MatcherLookupTable.php | MatcherLookupTable.get | public function get($name)
{
if ($this->hasNot($name)) {
throw new MatcherNotRegisteredException("$name is not registered");
}
$matcherClass = $this->matchers->get($name);
return $matcherClass;
} | php | public function get($name)
{
if ($this->hasNot($name)) {
throw new MatcherNotRegisteredException("$name is not registered");
}
$matcherClass = $this->matchers->get($name);
return $matcherClass;
} | [
"public",
"function",
"get",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasNot",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"MatcherNotRegisteredException",
"(",
"\"$name is not registered\"",
")",
";",
"}",
"$",
"matcherClass",
"=",
"$",
"this",
"->",
"matchers",
"->",
"get",
"(",
"$",
"name",
")",
";",
"return",
"$",
"matcherClass",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/expectation-php/expect/blob/1a32c5af37f3dc8dabe4e8eedeeb21aea16ce139/src/MatcherLookupTable.php#L56-L65 |
inhere/php-librarys | src/Helpers/DsnHelper.php | DsnHelper.getDsn | public static function getDsn(array $options = [], $driver = null)
{
if (!empty($options['dsn'])) {
return $options['dsn'];
}
self::$options = $options;
if (!$driver) {
$driver = $options['driver'] ?? null;
}
if (!$driver) {
throw new \LogicException('The driver name is required.');
}
if (!\is_callable([static::class, $driver])) {
throw new \RuntimeException('The ' . $driver . ' driver is not supported.');
}
list($dsn, $replace) = static::$driver();
$dsn = strtr($dsn, $replace);
self::$options = [];
return $dsn;
} | php | public static function getDsn(array $options = [], $driver = null)
{
if (!empty($options['dsn'])) {
return $options['dsn'];
}
self::$options = $options;
if (!$driver) {
$driver = $options['driver'] ?? null;
}
if (!$driver) {
throw new \LogicException('The driver name is required.');
}
if (!\is_callable([static::class, $driver])) {
throw new \RuntimeException('The ' . $driver . ' driver is not supported.');
}
list($dsn, $replace) = static::$driver();
$dsn = strtr($dsn, $replace);
self::$options = [];
return $dsn;
} | [
"public",
"static",
"function",
"getDsn",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
",",
"$",
"driver",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'dsn'",
"]",
")",
")",
"{",
"return",
"$",
"options",
"[",
"'dsn'",
"]",
";",
"}",
"self",
"::",
"$",
"options",
"=",
"$",
"options",
";",
"if",
"(",
"!",
"$",
"driver",
")",
"{",
"$",
"driver",
"=",
"$",
"options",
"[",
"'driver'",
"]",
"??",
"null",
";",
"}",
"if",
"(",
"!",
"$",
"driver",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'The driver name is required.'",
")",
";",
"}",
"if",
"(",
"!",
"\\",
"is_callable",
"(",
"[",
"static",
"::",
"class",
",",
"$",
"driver",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'The '",
".",
"$",
"driver",
".",
"' driver is not supported.'",
")",
";",
"}",
"list",
"(",
"$",
"dsn",
",",
"$",
"replace",
")",
"=",
"static",
"::",
"$",
"driver",
"(",
")",
";",
"$",
"dsn",
"=",
"strtr",
"(",
"$",
"dsn",
",",
"$",
"replace",
")",
";",
"self",
"::",
"$",
"options",
"=",
"[",
"]",
";",
"return",
"$",
"dsn",
";",
"}"
] | getDsn
@param string $driver
@param array $options
@throws \LogicException
@throws \RuntimeException
@return string | [
"getDsn"
] | train | https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/DsnHelper.php#L45-L72 |
DevGroup-ru/yii2-users-module | src/models/User.php | User.rules | public function rules()
{
$module = UsersModule::module();
$rules = [
[
['phone'],
'safe',
],
[
[
'password',
],
'safe',
'on' => self::SCENARIO_DEFAULT,
],
[
[
'password',
],
'required',
'on' => self::SCENARIO_PASSWORD_RESET,
],
[
'username',
'unique',
],
[
'email',
'unique',
],
'standardEmailRules' => [
[
'email',
],
'email',
'checkDNS' => $module->authorizationScenario()->emailCheckDNS,
'enableIDN' => $module->authorizationScenario()->emailEnableIDN,
'skipOnEmpty' => true,
'on' => self::SCENARIO_PROFILE_UPDATE,
],
'trimEmail' => [
[
'email',
],
'filter',
'filter' => 'trim',
'on' => self::SCENARIO_PROFILE_UPDATE,
],
[
[
'username_is_temporary',
'password_is_temporary',
'is_active',
],
'filter',
'filter' => 'boolval',
]
];
$property_rules = $this->propertiesRules();
if (!empty($property_rules)) {
$rules = array_merge($rules, $property_rules);
}
if (count(UsersModule::module()->requiredUserAttributes) > 0) {
$rules['requiredAttributes'] = [
UsersModule::module()->requiredUserAttributes,
'required',
'on' => self::SCENARIO_PROFILE_UPDATE,
];
}
return $rules;
} | php | public function rules()
{
$module = UsersModule::module();
$rules = [
[
['phone'],
'safe',
],
[
[
'password',
],
'safe',
'on' => self::SCENARIO_DEFAULT,
],
[
[
'password',
],
'required',
'on' => self::SCENARIO_PASSWORD_RESET,
],
[
'username',
'unique',
],
[
'email',
'unique',
],
'standardEmailRules' => [
[
'email',
],
'email',
'checkDNS' => $module->authorizationScenario()->emailCheckDNS,
'enableIDN' => $module->authorizationScenario()->emailEnableIDN,
'skipOnEmpty' => true,
'on' => self::SCENARIO_PROFILE_UPDATE,
],
'trimEmail' => [
[
'email',
],
'filter',
'filter' => 'trim',
'on' => self::SCENARIO_PROFILE_UPDATE,
],
[
[
'username_is_temporary',
'password_is_temporary',
'is_active',
],
'filter',
'filter' => 'boolval',
]
];
$property_rules = $this->propertiesRules();
if (!empty($property_rules)) {
$rules = array_merge($rules, $property_rules);
}
if (count(UsersModule::module()->requiredUserAttributes) > 0) {
$rules['requiredAttributes'] = [
UsersModule::module()->requiredUserAttributes,
'required',
'on' => self::SCENARIO_PROFILE_UPDATE,
];
}
return $rules;
} | [
"public",
"function",
"rules",
"(",
")",
"{",
"$",
"module",
"=",
"UsersModule",
"::",
"module",
"(",
")",
";",
"$",
"rules",
"=",
"[",
"[",
"[",
"'phone'",
"]",
",",
"'safe'",
",",
"]",
",",
"[",
"[",
"'password'",
",",
"]",
",",
"'safe'",
",",
"'on'",
"=>",
"self",
"::",
"SCENARIO_DEFAULT",
",",
"]",
",",
"[",
"[",
"'password'",
",",
"]",
",",
"'required'",
",",
"'on'",
"=>",
"self",
"::",
"SCENARIO_PASSWORD_RESET",
",",
"]",
",",
"[",
"'username'",
",",
"'unique'",
",",
"]",
",",
"[",
"'email'",
",",
"'unique'",
",",
"]",
",",
"'standardEmailRules'",
"=>",
"[",
"[",
"'email'",
",",
"]",
",",
"'email'",
",",
"'checkDNS'",
"=>",
"$",
"module",
"->",
"authorizationScenario",
"(",
")",
"->",
"emailCheckDNS",
",",
"'enableIDN'",
"=>",
"$",
"module",
"->",
"authorizationScenario",
"(",
")",
"->",
"emailEnableIDN",
",",
"'skipOnEmpty'",
"=>",
"true",
",",
"'on'",
"=>",
"self",
"::",
"SCENARIO_PROFILE_UPDATE",
",",
"]",
",",
"'trimEmail'",
"=>",
"[",
"[",
"'email'",
",",
"]",
",",
"'filter'",
",",
"'filter'",
"=>",
"'trim'",
",",
"'on'",
"=>",
"self",
"::",
"SCENARIO_PROFILE_UPDATE",
",",
"]",
",",
"[",
"[",
"'username_is_temporary'",
",",
"'password_is_temporary'",
",",
"'is_active'",
",",
"]",
",",
"'filter'",
",",
"'filter'",
"=>",
"'boolval'",
",",
"]",
"]",
";",
"$",
"property_rules",
"=",
"$",
"this",
"->",
"propertiesRules",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"property_rules",
")",
")",
"{",
"$",
"rules",
"=",
"array_merge",
"(",
"$",
"rules",
",",
"$",
"property_rules",
")",
";",
"}",
"if",
"(",
"count",
"(",
"UsersModule",
"::",
"module",
"(",
")",
"->",
"requiredUserAttributes",
")",
">",
"0",
")",
"{",
"$",
"rules",
"[",
"'requiredAttributes'",
"]",
"=",
"[",
"UsersModule",
"::",
"module",
"(",
")",
"->",
"requiredUserAttributes",
",",
"'required'",
",",
"'on'",
"=>",
"self",
"::",
"SCENARIO_PROFILE_UPDATE",
",",
"]",
";",
"}",
"return",
"$",
"rules",
";",
"}"
] | Validation rules for this model. | [
"Validation",
"rules",
"for",
"this",
"model",
"."
] | train | https://github.com/DevGroup-ru/yii2-users-module/blob/ff0103dc55c3462627ccc704c33e70c96053f750/src/models/User.php#L118-L190 |
DevGroup-ru/yii2-users-module | src/models/User.php | User.afterFind | public function afterFind()
{
parent::afterFind();
$this->username_is_temporary = boolval($this->username_is_temporary);
$this->is_active = boolval($this->is_active);
} | php | public function afterFind()
{
parent::afterFind();
$this->username_is_temporary = boolval($this->username_is_temporary);
$this->is_active = boolval($this->is_active);
} | [
"public",
"function",
"afterFind",
"(",
")",
"{",
"parent",
"::",
"afterFind",
"(",
")",
";",
"$",
"this",
"->",
"username_is_temporary",
"=",
"boolval",
"(",
"$",
"this",
"->",
"username_is_temporary",
")",
";",
"$",
"this",
"->",
"is_active",
"=",
"boolval",
"(",
"$",
"this",
"->",
"is_active",
")",
";",
"}"
] | Performs after find action and casts attributes to proper type | [
"Performs",
"after",
"find",
"action",
"and",
"casts",
"attributes",
"to",
"proper",
"type"
] | train | https://github.com/DevGroup-ru/yii2-users-module/blob/ff0103dc55c3462627ccc704c33e70c96053f750/src/models/User.php#L213-L218 |
DevGroup-ru/yii2-users-module | src/models/User.php | User.register | public function register()
{
if ($this->getIsNewRecord() == false) {
throw new \RuntimeException('Calling "' . __CLASS__ . '::' . __METHOD__ . '" on existing user');
}
$module = UsersModule::module();
if (empty($this->password) === true) {
$this->password = PasswordHelper::generate($module->generatedPasswordLength);
}
if ($module->emailConfirmationNeeded === false) {
$this->is_active = true;
}
$event = new RegistrationEvent();
$this->trigger(self::EVENT_BEFORE_REGISTER, $event);
if ($event->isValid === false) {
return false;
}
if (!$this->save()) {
return false;
}
$this->trigger(self::EVENT_AFTER_REGISTER, $event);
return $this;
} | php | public function register()
{
if ($this->getIsNewRecord() == false) {
throw new \RuntimeException('Calling "' . __CLASS__ . '::' . __METHOD__ . '" on existing user');
}
$module = UsersModule::module();
if (empty($this->password) === true) {
$this->password = PasswordHelper::generate($module->generatedPasswordLength);
}
if ($module->emailConfirmationNeeded === false) {
$this->is_active = true;
}
$event = new RegistrationEvent();
$this->trigger(self::EVENT_BEFORE_REGISTER, $event);
if ($event->isValid === false) {
return false;
}
if (!$this->save()) {
return false;
}
$this->trigger(self::EVENT_AFTER_REGISTER, $event);
return $this;
} | [
"public",
"function",
"register",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getIsNewRecord",
"(",
")",
"==",
"false",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Calling \"'",
".",
"__CLASS__",
".",
"'::'",
".",
"__METHOD__",
".",
"'\" on existing user'",
")",
";",
"}",
"$",
"module",
"=",
"UsersModule",
"::",
"module",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"password",
")",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"password",
"=",
"PasswordHelper",
"::",
"generate",
"(",
"$",
"module",
"->",
"generatedPasswordLength",
")",
";",
"}",
"if",
"(",
"$",
"module",
"->",
"emailConfirmationNeeded",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"is_active",
"=",
"true",
";",
"}",
"$",
"event",
"=",
"new",
"RegistrationEvent",
"(",
")",
";",
"$",
"this",
"->",
"trigger",
"(",
"self",
"::",
"EVENT_BEFORE_REGISTER",
",",
"$",
"event",
")",
";",
"if",
"(",
"$",
"event",
"->",
"isValid",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"save",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"trigger",
"(",
"self",
"::",
"EVENT_AFTER_REGISTER",
",",
"$",
"event",
")",
";",
"return",
"$",
"this",
";",
"}"
] | This method is used to register new user account.
@return bool|User | [
"This",
"method",
"is",
"used",
"to",
"register",
"new",
"user",
"account",
"."
] | train | https://github.com/DevGroup-ru/yii2-users-module/blob/ff0103dc55c3462627ccc704c33e70c96053f750/src/models/User.php#L285-L314 |
DevGroup-ru/yii2-users-module | src/models/User.php | User.login | public function login($loginDuration = 0)
{
$loginStatus = Yii::$app->getUser()->login($this, $loginDuration);
if ($loginStatus) {
$this->trigger(User::EVENT_LOGIN);
}
return $loginStatus;
} | php | public function login($loginDuration = 0)
{
$loginStatus = Yii::$app->getUser()->login($this, $loginDuration);
if ($loginStatus) {
$this->trigger(User::EVENT_LOGIN);
}
return $loginStatus;
} | [
"public",
"function",
"login",
"(",
"$",
"loginDuration",
"=",
"0",
")",
"{",
"$",
"loginStatus",
"=",
"Yii",
"::",
"$",
"app",
"->",
"getUser",
"(",
")",
"->",
"login",
"(",
"$",
"this",
",",
"$",
"loginDuration",
")",
";",
"if",
"(",
"$",
"loginStatus",
")",
"{",
"$",
"this",
"->",
"trigger",
"(",
"User",
"::",
"EVENT_LOGIN",
")",
";",
"}",
"return",
"$",
"loginStatus",
";",
"}"
] | Login user.
@param integer $loginDuration
@return bool true if success | [
"Login",
"user",
"."
] | train | https://github.com/DevGroup-ru/yii2-users-module/blob/ff0103dc55c3462627ccc704c33e70c96053f750/src/models/User.php#L321-L328 |
DevGroup-ru/yii2-users-module | src/models/User.php | User.isPasswordResetTokenValid | public static function isPasswordResetTokenValid($token)
{
if (empty($token)) {
return false;
}
$timestamp = (int)substr($token, strrpos($token, '_') + 1);
$expire = UsersModule::module()->passwordResetTokenExpire;
return $timestamp + $expire >= time();
} | php | public static function isPasswordResetTokenValid($token)
{
if (empty($token)) {
return false;
}
$timestamp = (int)substr($token, strrpos($token, '_') + 1);
$expire = UsersModule::module()->passwordResetTokenExpire;
return $timestamp + $expire >= time();
} | [
"public",
"static",
"function",
"isPasswordResetTokenValid",
"(",
"$",
"token",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"token",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"timestamp",
"=",
"(",
"int",
")",
"substr",
"(",
"$",
"token",
",",
"strrpos",
"(",
"$",
"token",
",",
"'_'",
")",
"+",
"1",
")",
";",
"$",
"expire",
"=",
"UsersModule",
"::",
"module",
"(",
")",
"->",
"passwordResetTokenExpire",
";",
"return",
"$",
"timestamp",
"+",
"$",
"expire",
">=",
"time",
"(",
")",
";",
"}"
] | Finds out if password reset token is valid
@param string $token password reset token
@return boolean | [
"Finds",
"out",
"if",
"password",
"reset",
"token",
"is",
"valid"
] | train | https://github.com/DevGroup-ru/yii2-users-module/blob/ff0103dc55c3462627ccc704c33e70c96053f750/src/models/User.php#L379-L387 |
SporkCode/Spork | src/CSS/UpdateListener.php | UpdateListener.configure | protected function configure($options)
{
foreach ($options as $key => $value) {
switch ($key) {
case 'compiler':
$this->setCompiler($value);
break;
case 'builds':
$this->setBuilds($value);
break;
// case 'include':
// $this->setInclude($include);
// break;
}
}
} | php | protected function configure($options)
{
foreach ($options as $key => $value) {
switch ($key) {
case 'compiler':
$this->setCompiler($value);
break;
case 'builds':
$this->setBuilds($value);
break;
// case 'include':
// $this->setInclude($include);
// break;
}
}
} | [
"protected",
"function",
"configure",
"(",
"$",
"options",
")",
"{",
"foreach",
"(",
"$",
"options",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"switch",
"(",
"$",
"key",
")",
"{",
"case",
"'compiler'",
":",
"$",
"this",
"->",
"setCompiler",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"'builds'",
":",
"$",
"this",
"->",
"setBuilds",
"(",
"$",
"value",
")",
";",
"break",
";",
"// case 'include':",
"// $this->setInclude($include);",
"// break;",
"}",
"}",
"}"
] | } | [
"}"
] | train | https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/CSS/UpdateListener.php#L177-L192 |
SporkCode/Spork | src/CSS/UpdateListener.php | UpdateListener.getFileKey | protected function getFileKey($basePath, \SplFileInfo $file)
{
$baseLength = strlen(rtrim($basePath, DIRECTORY_SEPARATOR));
return substr($file->getPath(), $baseLength) . DIRECTORY_SEPARATOR
. $file->getBasename('.' . $file->getExtension());
} | php | protected function getFileKey($basePath, \SplFileInfo $file)
{
$baseLength = strlen(rtrim($basePath, DIRECTORY_SEPARATOR));
return substr($file->getPath(), $baseLength) . DIRECTORY_SEPARATOR
. $file->getBasename('.' . $file->getExtension());
} | [
"protected",
"function",
"getFileKey",
"(",
"$",
"basePath",
",",
"\\",
"SplFileInfo",
"$",
"file",
")",
"{",
"$",
"baseLength",
"=",
"strlen",
"(",
"rtrim",
"(",
"$",
"basePath",
",",
"DIRECTORY_SEPARATOR",
")",
")",
";",
"return",
"substr",
"(",
"$",
"file",
"->",
"getPath",
"(",
")",
",",
"$",
"baseLength",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"file",
"->",
"getBasename",
"(",
"'.'",
".",
"$",
"file",
"->",
"getExtension",
"(",
")",
")",
";",
"}"
] | Get relative key for a file
@param string $basepath
@param \SplFileInfo $file | [
"Get",
"relative",
"key",
"for",
"a",
"file"
] | train | https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/CSS/UpdateListener.php#L200-L206 |
SporkCode/Spork | src/CSS/UpdateListener.php | UpdateListener.isOutOfDate | protected function isOutOfDate($source, $destination, array $includes = null)
{
$includes = (array) $includes;
$extensions = $this->compiler->getExtensions();
if (!file_exists($destination)) {
return true;
}
if (is_file($source) && is_file($destination)) {
$sourceFiles = array(new \SplFileInfo($source));
$destinationFiles = array(new \SplFileInfo($destination));
} else {
$sourceFiles = $this->scanDirectory($source, $extensions);
$destinationFiles = $this->scanDirectory($destination, array('css'));
}
$youngest = time();
foreach ($sourceFiles as $key => $file) {
if (array_key_exists($key, $destinationFiles)) {
if ($file->getMTime() > $destinationFiles[$key]->getMTime()) {
return true;
}
if ($file->getMTime() < $youngest) {
$youngest = $file->getMTime();
}
} else {
return true;
}
}
// $oldest = time();
// foreach ($destinationFiles as $file) {
// $modified = $file->getMTime();
// if ($modified < $oldest) {
// $oldest = $modified;
// }
// }
foreach ($includes as $include) {
$includeFiles = $this->scanDirectory($include, $extensions);
foreach ($includeFiles as $file) {
if ($file->getMTime() > $youngest) {
return true;
}
}
}
return false;
} | php | protected function isOutOfDate($source, $destination, array $includes = null)
{
$includes = (array) $includes;
$extensions = $this->compiler->getExtensions();
if (!file_exists($destination)) {
return true;
}
if (is_file($source) && is_file($destination)) {
$sourceFiles = array(new \SplFileInfo($source));
$destinationFiles = array(new \SplFileInfo($destination));
} else {
$sourceFiles = $this->scanDirectory($source, $extensions);
$destinationFiles = $this->scanDirectory($destination, array('css'));
}
$youngest = time();
foreach ($sourceFiles as $key => $file) {
if (array_key_exists($key, $destinationFiles)) {
if ($file->getMTime() > $destinationFiles[$key]->getMTime()) {
return true;
}
if ($file->getMTime() < $youngest) {
$youngest = $file->getMTime();
}
} else {
return true;
}
}
// $oldest = time();
// foreach ($destinationFiles as $file) {
// $modified = $file->getMTime();
// if ($modified < $oldest) {
// $oldest = $modified;
// }
// }
foreach ($includes as $include) {
$includeFiles = $this->scanDirectory($include, $extensions);
foreach ($includeFiles as $file) {
if ($file->getMTime() > $youngest) {
return true;
}
}
}
return false;
} | [
"protected",
"function",
"isOutOfDate",
"(",
"$",
"source",
",",
"$",
"destination",
",",
"array",
"$",
"includes",
"=",
"null",
")",
"{",
"$",
"includes",
"=",
"(",
"array",
")",
"$",
"includes",
";",
"$",
"extensions",
"=",
"$",
"this",
"->",
"compiler",
"->",
"getExtensions",
"(",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"destination",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"is_file",
"(",
"$",
"source",
")",
"&&",
"is_file",
"(",
"$",
"destination",
")",
")",
"{",
"$",
"sourceFiles",
"=",
"array",
"(",
"new",
"\\",
"SplFileInfo",
"(",
"$",
"source",
")",
")",
";",
"$",
"destinationFiles",
"=",
"array",
"(",
"new",
"\\",
"SplFileInfo",
"(",
"$",
"destination",
")",
")",
";",
"}",
"else",
"{",
"$",
"sourceFiles",
"=",
"$",
"this",
"->",
"scanDirectory",
"(",
"$",
"source",
",",
"$",
"extensions",
")",
";",
"$",
"destinationFiles",
"=",
"$",
"this",
"->",
"scanDirectory",
"(",
"$",
"destination",
",",
"array",
"(",
"'css'",
")",
")",
";",
"}",
"$",
"youngest",
"=",
"time",
"(",
")",
";",
"foreach",
"(",
"$",
"sourceFiles",
"as",
"$",
"key",
"=>",
"$",
"file",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"destinationFiles",
")",
")",
"{",
"if",
"(",
"$",
"file",
"->",
"getMTime",
"(",
")",
">",
"$",
"destinationFiles",
"[",
"$",
"key",
"]",
"->",
"getMTime",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"file",
"->",
"getMTime",
"(",
")",
"<",
"$",
"youngest",
")",
"{",
"$",
"youngest",
"=",
"$",
"file",
"->",
"getMTime",
"(",
")",
";",
"}",
"}",
"else",
"{",
"return",
"true",
";",
"}",
"}",
"// $oldest = time();",
"// foreach ($destinationFiles as $file) {",
"// $modified = $file->getMTime(); ",
"// if ($modified < $oldest) {",
"// $oldest = $modified;",
"// }",
"// }",
"foreach",
"(",
"$",
"includes",
"as",
"$",
"include",
")",
"{",
"$",
"includeFiles",
"=",
"$",
"this",
"->",
"scanDirectory",
"(",
"$",
"include",
",",
"$",
"extensions",
")",
";",
"foreach",
"(",
"$",
"includeFiles",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"$",
"file",
"->",
"getMTime",
"(",
")",
">",
"$",
"youngest",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] | Test is destination file or folder is out of date from the source.
@param string $source
@param string $destination
@return boolean | [
"Test",
"is",
"destination",
"file",
"or",
"folder",
"is",
"out",
"of",
"date",
"from",
"the",
"source",
"."
] | train | https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/CSS/UpdateListener.php#L215-L264 |
SporkCode/Spork | src/CSS/UpdateListener.php | UpdateListener.scanDirectory | protected function scanDirectory($path, $extensions)
{
if (is_file($path)) {
$file = new \SplFileInfo($path);
return array($this->getFileKey($file->getPath(), $file) => $file);
}
$files = array();
$extensions = (array) $extensions;
$iterator = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator(
$path,
\FileSystemIterator::SKIP_DOTS
| \FileSystemIterator::CURRENT_AS_FILEINFO)
);
foreach ($iterator as $file) {
if (in_array($file->getExtension(), $extensions)) {
$files[$this->getFileKey($path, $file)] = $file;
}
}
return $files;
} | php | protected function scanDirectory($path, $extensions)
{
if (is_file($path)) {
$file = new \SplFileInfo($path);
return array($this->getFileKey($file->getPath(), $file) => $file);
}
$files = array();
$extensions = (array) $extensions;
$iterator = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator(
$path,
\FileSystemIterator::SKIP_DOTS
| \FileSystemIterator::CURRENT_AS_FILEINFO)
);
foreach ($iterator as $file) {
if (in_array($file->getExtension(), $extensions)) {
$files[$this->getFileKey($path, $file)] = $file;
}
}
return $files;
} | [
"protected",
"function",
"scanDirectory",
"(",
"$",
"path",
",",
"$",
"extensions",
")",
"{",
"if",
"(",
"is_file",
"(",
"$",
"path",
")",
")",
"{",
"$",
"file",
"=",
"new",
"\\",
"SplFileInfo",
"(",
"$",
"path",
")",
";",
"return",
"array",
"(",
"$",
"this",
"->",
"getFileKey",
"(",
"$",
"file",
"->",
"getPath",
"(",
")",
",",
"$",
"file",
")",
"=>",
"$",
"file",
")",
";",
"}",
"$",
"files",
"=",
"array",
"(",
")",
";",
"$",
"extensions",
"=",
"(",
"array",
")",
"$",
"extensions",
";",
"$",
"iterator",
"=",
"new",
"\\",
"RecursiveIteratorIterator",
"(",
"new",
"\\",
"RecursiveDirectoryIterator",
"(",
"$",
"path",
",",
"\\",
"FileSystemIterator",
"::",
"SKIP_DOTS",
"|",
"\\",
"FileSystemIterator",
"::",
"CURRENT_AS_FILEINFO",
")",
")",
";",
"foreach",
"(",
"$",
"iterator",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"file",
"->",
"getExtension",
"(",
")",
",",
"$",
"extensions",
")",
")",
"{",
"$",
"files",
"[",
"$",
"this",
"->",
"getFileKey",
"(",
"$",
"path",
",",
"$",
"file",
")",
"]",
"=",
"$",
"file",
";",
"}",
"}",
"return",
"$",
"files",
";",
"}"
] | Scan a directory and return a list of files with matching extenstions
@param string $path Directory path to scan
@param string|array $extensions Match files with these extensions | [
"Scan",
"a",
"directory",
"and",
"return",
"a",
"list",
"of",
"files",
"with",
"matching",
"extenstions"
] | train | https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/CSS/UpdateListener.php#L272-L293 |
FrenzelGmbH/cm-address | controllers/DefaultController.php | DefaultController.actionCreate | public function actionCreate()
{
$model = new Address(['scenario' => 'create']);
Yii::$app->response->format = Response::FORMAT_JSON;
if ($model->load(Yii::$app->request->post())) {
if ($model->validate()) {
if ($model->save(false)) {
return $this->tree($model);
} else {
Yii::$app->response->setStatusCode(500);
return \Yii::t('net_frenzel_address', 'FRONTEND_FLASH_FAIL_CREATE');
}
} elseif (Yii::$app->request->isAjax) {
Yii::$app->response->setStatusCode(400);
return ActiveForm::validate($model);
}
}
} | php | public function actionCreate()
{
$model = new Address(['scenario' => 'create']);
Yii::$app->response->format = Response::FORMAT_JSON;
if ($model->load(Yii::$app->request->post())) {
if ($model->validate()) {
if ($model->save(false)) {
return $this->tree($model);
} else {
Yii::$app->response->setStatusCode(500);
return \Yii::t('net_frenzel_address', 'FRONTEND_FLASH_FAIL_CREATE');
}
} elseif (Yii::$app->request->isAjax) {
Yii::$app->response->setStatusCode(400);
return ActiveForm::validate($model);
}
}
} | [
"public",
"function",
"actionCreate",
"(",
")",
"{",
"$",
"model",
"=",
"new",
"Address",
"(",
"[",
"'scenario'",
"=>",
"'create'",
"]",
")",
";",
"Yii",
"::",
"$",
"app",
"->",
"response",
"->",
"format",
"=",
"Response",
"::",
"FORMAT_JSON",
";",
"if",
"(",
"$",
"model",
"->",
"load",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
")",
")",
"{",
"if",
"(",
"$",
"model",
"->",
"validate",
"(",
")",
")",
"{",
"if",
"(",
"$",
"model",
"->",
"save",
"(",
"false",
")",
")",
"{",
"return",
"$",
"this",
"->",
"tree",
"(",
"$",
"model",
")",
";",
"}",
"else",
"{",
"Yii",
"::",
"$",
"app",
"->",
"response",
"->",
"setStatusCode",
"(",
"500",
")",
";",
"return",
"\\",
"Yii",
"::",
"t",
"(",
"'net_frenzel_address'",
",",
"'FRONTEND_FLASH_FAIL_CREATE'",
")",
";",
"}",
"}",
"elseif",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"isAjax",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"response",
"->",
"setStatusCode",
"(",
"400",
")",
";",
"return",
"ActiveForm",
"::",
"validate",
"(",
"$",
"model",
")",
";",
"}",
"}",
"}"
] | Create Address. | [
"Create",
"Address",
"."
] | train | https://github.com/FrenzelGmbH/cm-address/blob/4295671dc603beed4bea6c5a7f77dac9846127f3/controllers/DefaultController.php#L46-L63 |
FrenzelGmbH/cm-address | controllers/DefaultController.php | DefaultController.actionUpdate | public function actionUpdate($id)
{
$model = $this->findModel($id);
$model->setScenario('update');
Yii::$app->response->format = Response::FORMAT_JSON;
if ($model->load(Yii::$app->request->post())) {
if ($model->validate()) {
if ($model->save(false)) {
return $this->renderAjax('@vendor/frenzelgmbh/cm-address/views/widgets/views/_index_single_item', ['model' => $model]);
} else {
Yii::$app->response->setStatusCode(500);
return \Yii::t('net_frenzel_address', 'FRONTEND_FLASH_FAIL_UPDATE');
}
} elseif (Yii::$app->request->isAjax) {
Yii::$app->response->setStatusCode(400);
return ActiveForm::validate($model);
}
}
} | php | public function actionUpdate($id)
{
$model = $this->findModel($id);
$model->setScenario('update');
Yii::$app->response->format = Response::FORMAT_JSON;
if ($model->load(Yii::$app->request->post())) {
if ($model->validate()) {
if ($model->save(false)) {
return $this->renderAjax('@vendor/frenzelgmbh/cm-address/views/widgets/views/_index_single_item', ['model' => $model]);
} else {
Yii::$app->response->setStatusCode(500);
return \Yii::t('net_frenzel_address', 'FRONTEND_FLASH_FAIL_UPDATE');
}
} elseif (Yii::$app->request->isAjax) {
Yii::$app->response->setStatusCode(400);
return ActiveForm::validate($model);
}
}
} | [
"public",
"function",
"actionUpdate",
"(",
"$",
"id",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"findModel",
"(",
"$",
"id",
")",
";",
"$",
"model",
"->",
"setScenario",
"(",
"'update'",
")",
";",
"Yii",
"::",
"$",
"app",
"->",
"response",
"->",
"format",
"=",
"Response",
"::",
"FORMAT_JSON",
";",
"if",
"(",
"$",
"model",
"->",
"load",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
")",
")",
"{",
"if",
"(",
"$",
"model",
"->",
"validate",
"(",
")",
")",
"{",
"if",
"(",
"$",
"model",
"->",
"save",
"(",
"false",
")",
")",
"{",
"return",
"$",
"this",
"->",
"renderAjax",
"(",
"'@vendor/frenzelgmbh/cm-address/views/widgets/views/_index_single_item'",
",",
"[",
"'model'",
"=>",
"$",
"model",
"]",
")",
";",
"}",
"else",
"{",
"Yii",
"::",
"$",
"app",
"->",
"response",
"->",
"setStatusCode",
"(",
"500",
")",
";",
"return",
"\\",
"Yii",
"::",
"t",
"(",
"'net_frenzel_address'",
",",
"'FRONTEND_FLASH_FAIL_UPDATE'",
")",
";",
"}",
"}",
"elseif",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"isAjax",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"response",
"->",
"setStatusCode",
"(",
"400",
")",
";",
"return",
"ActiveForm",
"::",
"validate",
"(",
"$",
"model",
")",
";",
"}",
"}",
"}"
] | Update Communication.
@param integer $id Communication ID
@return mixed | [
"Update",
"Communication",
"."
] | train | https://github.com/FrenzelGmbH/cm-address/blob/4295671dc603beed4bea6c5a7f77dac9846127f3/controllers/DefaultController.php#L71-L89 |
FrenzelGmbH/cm-address | controllers/DefaultController.php | DefaultController.actionFetch | public function actionFetch($id)
{
$model = $this->findModel($id);
$model->setScenario('update');
Yii::$app->response->format = Response::FORMAT_HTML;
return $this->renderAjax('@vendor/frenzelgmbh/cm-address/views/widgets/views/_form_update', ['model' => $model]);
} | php | public function actionFetch($id)
{
$model = $this->findModel($id);
$model->setScenario('update');
Yii::$app->response->format = Response::FORMAT_HTML;
return $this->renderAjax('@vendor/frenzelgmbh/cm-address/views/widgets/views/_form_update', ['model' => $model]);
} | [
"public",
"function",
"actionFetch",
"(",
"$",
"id",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"findModel",
"(",
"$",
"id",
")",
";",
"$",
"model",
"->",
"setScenario",
"(",
"'update'",
")",
";",
"Yii",
"::",
"$",
"app",
"->",
"response",
"->",
"format",
"=",
"Response",
"::",
"FORMAT_HTML",
";",
"return",
"$",
"this",
"->",
"renderAjax",
"(",
"'@vendor/frenzelgmbh/cm-address/views/widgets/views/_form_update'",
",",
"[",
"'model'",
"=>",
"$",
"model",
"]",
")",
";",
"}"
] | fetch Communication.
@param integer $id Communication ID
@return mixed | [
"fetch",
"Communication",
"."
] | train | https://github.com/FrenzelGmbH/cm-address/blob/4295671dc603beed4bea6c5a7f77dac9846127f3/controllers/DefaultController.php#L97-L103 |
FrenzelGmbH/cm-address | controllers/DefaultController.php | DefaultController.actionDelete | public function actionDelete($id)
{
Yii::$app->response->format = Response::FORMAT_JSON;
if ($this->findModel($id)->deleteCommunication()) {
return \Yii::t('net_frenzel_address', 'FRONTEND_WIDGET_COMMENTS_DELETED_COMMENT_TEXT');
} else {
Yii::$app->response->setStatusCode(500);
return \Yii::t('net_frenzel_address', 'FRONTEND_FLASH_FAIL_DELETE');
}
} | php | public function actionDelete($id)
{
Yii::$app->response->format = Response::FORMAT_JSON;
if ($this->findModel($id)->deleteCommunication()) {
return \Yii::t('net_frenzel_address', 'FRONTEND_WIDGET_COMMENTS_DELETED_COMMENT_TEXT');
} else {
Yii::$app->response->setStatusCode(500);
return \Yii::t('net_frenzel_address', 'FRONTEND_FLASH_FAIL_DELETE');
}
} | [
"public",
"function",
"actionDelete",
"(",
"$",
"id",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"response",
"->",
"format",
"=",
"Response",
"::",
"FORMAT_JSON",
";",
"if",
"(",
"$",
"this",
"->",
"findModel",
"(",
"$",
"id",
")",
"->",
"deleteCommunication",
"(",
")",
")",
"{",
"return",
"\\",
"Yii",
"::",
"t",
"(",
"'net_frenzel_address'",
",",
"'FRONTEND_WIDGET_COMMENTS_DELETED_COMMENT_TEXT'",
")",
";",
"}",
"else",
"{",
"Yii",
"::",
"$",
"app",
"->",
"response",
"->",
"setStatusCode",
"(",
"500",
")",
";",
"return",
"\\",
"Yii",
"::",
"t",
"(",
"'net_frenzel_address'",
",",
"'FRONTEND_FLASH_FAIL_DELETE'",
")",
";",
"}",
"}"
] | Delete comment page.
@param integer $id Comment ID
@return string Comment text | [
"Delete",
"comment",
"page",
"."
] | train | https://github.com/FrenzelGmbH/cm-address/blob/4295671dc603beed4bea6c5a7f77dac9846127f3/controllers/DefaultController.php#L111-L120 |
FrenzelGmbH/cm-address | controllers/DefaultController.php | DefaultController.findModel | protected function findModel($id)
{
/** @var Comment $model */
$model = Address::findOne($id);
if ($model !== null) {
return $model;
} else {
throw new HttpException(404, \Yii::t('net_frenzel_address', 'FRONTEND_FLASH_RECORD_NOT_FOUND'));
}
} | php | protected function findModel($id)
{
/** @var Comment $model */
$model = Address::findOne($id);
if ($model !== null) {
return $model;
} else {
throw new HttpException(404, \Yii::t('net_frenzel_address', 'FRONTEND_FLASH_RECORD_NOT_FOUND'));
}
} | [
"protected",
"function",
"findModel",
"(",
"$",
"id",
")",
"{",
"/** @var Comment $model */",
"$",
"model",
"=",
"Address",
"::",
"findOne",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"model",
"!==",
"null",
")",
"{",
"return",
"$",
"model",
";",
"}",
"else",
"{",
"throw",
"new",
"HttpException",
"(",
"404",
",",
"\\",
"Yii",
"::",
"t",
"(",
"'net_frenzel_address'",
",",
"'FRONTEND_FLASH_RECORD_NOT_FOUND'",
")",
")",
";",
"}",
"}"
] | Find model by ID.
@param integer|array $id Comment ID
@return Comment Model
@throws HttpException 404 error if comment not found | [
"Find",
"model",
"by",
"ID",
"."
] | train | https://github.com/FrenzelGmbH/cm-address/blob/4295671dc603beed4bea6c5a7f77dac9846127f3/controllers/DefaultController.php#L129-L138 |
FrenzelGmbH/cm-address | controllers/DefaultController.php | DefaultController.tree | protected function tree($model)
{
$models = Address::getAddresses($model->entity_id, $model->entity);
return $this->renderPartial('@net/frenzel/address/views/widgets/views/_index_item', ['models' => $models]);
} | php | protected function tree($model)
{
$models = Address::getAddresses($model->entity_id, $model->entity);
return $this->renderPartial('@net/frenzel/address/views/widgets/views/_index_item', ['models' => $models]);
} | [
"protected",
"function",
"tree",
"(",
"$",
"model",
")",
"{",
"$",
"models",
"=",
"Address",
"::",
"getAddresses",
"(",
"$",
"model",
"->",
"entity_id",
",",
"$",
"model",
"->",
"entity",
")",
";",
"return",
"$",
"this",
"->",
"renderPartial",
"(",
"'@net/frenzel/address/views/widgets/views/_index_item'",
",",
"[",
"'models'",
"=>",
"$",
"models",
"]",
")",
";",
"}"
] | @param Comment $model Comment
@return string Comments list | [
"@param",
"Comment",
"$model",
"Comment"
] | train | https://github.com/FrenzelGmbH/cm-address/blob/4295671dc603beed4bea6c5a7f77dac9846127f3/controllers/DefaultController.php#L145-L149 |
FrenzelGmbH/cm-address | controllers/DefaultController.php | DefaultController.actionJscountry | public function actionJscountry($search = NULL,$id = NULL)
{
Yii::$app->response->format = Response::FORMAT_JSON;
$clean['more'] = false;
$query = new Query;
if(!is_Null($search))
{
$mainQuery = $query->select('id, iso3 AS text')
->from('{{%net_frenzel_country}}')
->where('UPPER(iso3) LIKE "%'.strtoupper($search).'%"');
$command = $mainQuery->createCommand();
$rows = $command->queryAll();
$clean['results'] = array_values($rows);
}
else
{
if(!is_null($id))
{
$clean['results'] = ['id'=> $id,'text' => Country::findOne($id)->iso3];
}else
{
$clean['results'] = ['id'=> 0,'text' => 'None found'];
}
}
return $clean;
} | php | public function actionJscountry($search = NULL,$id = NULL)
{
Yii::$app->response->format = Response::FORMAT_JSON;
$clean['more'] = false;
$query = new Query;
if(!is_Null($search))
{
$mainQuery = $query->select('id, iso3 AS text')
->from('{{%net_frenzel_country}}')
->where('UPPER(iso3) LIKE "%'.strtoupper($search).'%"');
$command = $mainQuery->createCommand();
$rows = $command->queryAll();
$clean['results'] = array_values($rows);
}
else
{
if(!is_null($id))
{
$clean['results'] = ['id'=> $id,'text' => Country::findOne($id)->iso3];
}else
{
$clean['results'] = ['id'=> 0,'text' => 'None found'];
}
}
return $clean;
} | [
"public",
"function",
"actionJscountry",
"(",
"$",
"search",
"=",
"NULL",
",",
"$",
"id",
"=",
"NULL",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"response",
"->",
"format",
"=",
"Response",
"::",
"FORMAT_JSON",
";",
"$",
"clean",
"[",
"'more'",
"]",
"=",
"false",
";",
"$",
"query",
"=",
"new",
"Query",
";",
"if",
"(",
"!",
"is_Null",
"(",
"$",
"search",
")",
")",
"{",
"$",
"mainQuery",
"=",
"$",
"query",
"->",
"select",
"(",
"'id, iso3 AS text'",
")",
"->",
"from",
"(",
"'{{%net_frenzel_country}}'",
")",
"->",
"where",
"(",
"'UPPER(iso3) LIKE \"%'",
".",
"strtoupper",
"(",
"$",
"search",
")",
".",
"'%\"'",
")",
";",
"$",
"command",
"=",
"$",
"mainQuery",
"->",
"createCommand",
"(",
")",
";",
"$",
"rows",
"=",
"$",
"command",
"->",
"queryAll",
"(",
")",
";",
"$",
"clean",
"[",
"'results'",
"]",
"=",
"array_values",
"(",
"$",
"rows",
")",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"id",
")",
")",
"{",
"$",
"clean",
"[",
"'results'",
"]",
"=",
"[",
"'id'",
"=>",
"$",
"id",
",",
"'text'",
"=>",
"Country",
"::",
"findOne",
"(",
"$",
"id",
")",
"->",
"iso3",
"]",
";",
"}",
"else",
"{",
"$",
"clean",
"[",
"'results'",
"]",
"=",
"[",
"'id'",
"=>",
"0",
",",
"'text'",
"=>",
"'None found'",
"]",
";",
"}",
"}",
"return",
"$",
"clean",
";",
"}"
] | js(on)country returns an json object for the select2 widget
@param string $search Text for the lookup
@param integer of the set value
@return json [description] | [
"js",
"(",
"on",
")",
"country",
"returns",
"an",
"json",
"object",
"for",
"the",
"select2",
"widget"
] | train | https://github.com/FrenzelGmbH/cm-address/blob/4295671dc603beed4bea6c5a7f77dac9846127f3/controllers/DefaultController.php#L157-L184 |
ajgarlag/AjglCsv | src/Writer/WriterFactory.php | WriterFactory.createWriter | public function createWriter(
$type,
$filePath,
$delimiter = WriterInterface::DELIMITER_DEFAULT,
$fileCharset = WriterInterface::CHARSET_DEFAULT,
$mode = 'w'
) {
switch ($type) {
case 'php':
return new NativePhpWriter($filePath, $delimiter, $fileCharset, $mode);
break;
case 'rfc':
return new RfcWriter($filePath, $delimiter, $fileCharset, $mode);
break;
default:
throw new \InvalidArgumentException(
sprintf("Unsupported writer type '%s'", $type)
);
break;
}
} | php | public function createWriter(
$type,
$filePath,
$delimiter = WriterInterface::DELIMITER_DEFAULT,
$fileCharset = WriterInterface::CHARSET_DEFAULT,
$mode = 'w'
) {
switch ($type) {
case 'php':
return new NativePhpWriter($filePath, $delimiter, $fileCharset, $mode);
break;
case 'rfc':
return new RfcWriter($filePath, $delimiter, $fileCharset, $mode);
break;
default:
throw new \InvalidArgumentException(
sprintf("Unsupported writer type '%s'", $type)
);
break;
}
} | [
"public",
"function",
"createWriter",
"(",
"$",
"type",
",",
"$",
"filePath",
",",
"$",
"delimiter",
"=",
"WriterInterface",
"::",
"DELIMITER_DEFAULT",
",",
"$",
"fileCharset",
"=",
"WriterInterface",
"::",
"CHARSET_DEFAULT",
",",
"$",
"mode",
"=",
"'w'",
")",
"{",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'php'",
":",
"return",
"new",
"NativePhpWriter",
"(",
"$",
"filePath",
",",
"$",
"delimiter",
",",
"$",
"fileCharset",
",",
"$",
"mode",
")",
";",
"break",
";",
"case",
"'rfc'",
":",
"return",
"new",
"RfcWriter",
"(",
"$",
"filePath",
",",
"$",
"delimiter",
",",
"$",
"fileCharset",
",",
"$",
"mode",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"\"Unsupported writer type '%s'\"",
",",
"$",
"type",
")",
")",
";",
"break",
";",
"}",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/ajgarlag/AjglCsv/blob/28872f58b9ef864893cac6faddfcb1229c2c2047/src/Writer/WriterFactory.php#L22-L42 |
InfiniteSoftware/ISEcommpayPayum | Action/CaptureAction.php | CaptureAction.execute | public function execute($request)
{
RequestNotSupportedException::assertSupports($this, $request);
$model = ArrayObject::ensureArrayObject($request->getModel());
$model['signature'] = Signer::sign(
$model->toUnsafeArray(),
$this->api['secretKey']
);
throw new HttpPostRedirect($this->api['endpoint'], $model->toUnsafeArray());
} | php | public function execute($request)
{
RequestNotSupportedException::assertSupports($this, $request);
$model = ArrayObject::ensureArrayObject($request->getModel());
$model['signature'] = Signer::sign(
$model->toUnsafeArray(),
$this->api['secretKey']
);
throw new HttpPostRedirect($this->api['endpoint'], $model->toUnsafeArray());
} | [
"public",
"function",
"execute",
"(",
"$",
"request",
")",
"{",
"RequestNotSupportedException",
"::",
"assertSupports",
"(",
"$",
"this",
",",
"$",
"request",
")",
";",
"$",
"model",
"=",
"ArrayObject",
"::",
"ensureArrayObject",
"(",
"$",
"request",
"->",
"getModel",
"(",
")",
")",
";",
"$",
"model",
"[",
"'signature'",
"]",
"=",
"Signer",
"::",
"sign",
"(",
"$",
"model",
"->",
"toUnsafeArray",
"(",
")",
",",
"$",
"this",
"->",
"api",
"[",
"'secretKey'",
"]",
")",
";",
"throw",
"new",
"HttpPostRedirect",
"(",
"$",
"this",
"->",
"api",
"[",
"'endpoint'",
"]",
",",
"$",
"model",
"->",
"toUnsafeArray",
"(",
")",
")",
";",
"}"
] | {@inheritDoc}
@param Capture $request | [
"{",
"@inheritDoc",
"}"
] | train | https://github.com/InfiniteSoftware/ISEcommpayPayum/blob/44a073e3d885d9007aa54d6ff13aea93a9e52e7c/Action/CaptureAction.php#L36-L48 |
ajgarlag/AjglSessionConcurrency | src/Http/Session/RegisterSessionAuthenticationStrategy.php | RegisterSessionAuthenticationStrategy.onAuthentication | public function onAuthentication(Request $request, TokenInterface $token)
{
if (null !== $session = $request->getSession()) {
$this->registry->registerNewSession($session->getId(), $token->getUsername(), $session->getMetadataBag()->getLastUsed());
}
} | php | public function onAuthentication(Request $request, TokenInterface $token)
{
if (null !== $session = $request->getSession()) {
$this->registry->registerNewSession($session->getId(), $token->getUsername(), $session->getMetadataBag()->getLastUsed());
}
} | [
"public",
"function",
"onAuthentication",
"(",
"Request",
"$",
"request",
",",
"TokenInterface",
"$",
"token",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"session",
"=",
"$",
"request",
"->",
"getSession",
"(",
")",
")",
"{",
"$",
"this",
"->",
"registry",
"->",
"registerNewSession",
"(",
"$",
"session",
"->",
"getId",
"(",
")",
",",
"$",
"token",
"->",
"getUsername",
"(",
")",
",",
"$",
"session",
"->",
"getMetadataBag",
"(",
")",
"->",
"getLastUsed",
"(",
")",
")",
";",
"}",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/ajgarlag/AjglSessionConcurrency/blob/daa3b1ff3ad4951947f7192e12b2496555e135fb/src/Http/Session/RegisterSessionAuthenticationStrategy.php#L40-L45 |
globalis-ms/wp-cubi-robo | src/GitTrait.php | GitTrait.hotfixStart | public function hotfixStart($options = ['semversion' => null, 'type' => 'patch'])
{
if (empty($options['semversion'])) {
$version = $this->getVersion()
->increment($options['type']);
} else {
$version = $options['semversion'];
}
return $this->taskHotfixStart((string)$version)->run();
} | php | public function hotfixStart($options = ['semversion' => null, 'type' => 'patch'])
{
if (empty($options['semversion'])) {
$version = $this->getVersion()
->increment($options['type']);
} else {
$version = $options['semversion'];
}
return $this->taskHotfixStart((string)$version)->run();
} | [
"public",
"function",
"hotfixStart",
"(",
"$",
"options",
"=",
"[",
"'semversion'",
"=>",
"null",
",",
"'type'",
"=>",
"'patch'",
"]",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"options",
"[",
"'semversion'",
"]",
")",
")",
"{",
"$",
"version",
"=",
"$",
"this",
"->",
"getVersion",
"(",
")",
"->",
"increment",
"(",
"$",
"options",
"[",
"'type'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"version",
"=",
"$",
"options",
"[",
"'semversion'",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"taskHotfixStart",
"(",
"(",
"string",
")",
"$",
"version",
")",
"->",
"run",
"(",
")",
";",
"}"
] | Start a new hotfix
@option string $semversion Version number
@option string $type Hotfix type (path, minor) | [
"Start",
"a",
"new",
"hotfix"
] | train | https://github.com/globalis-ms/wp-cubi-robo/blob/4acc9d37c77e24a968a950d59b5ba53818c53bc1/src/GitTrait.php#L36-L45 |
globalis-ms/wp-cubi-robo | src/GitTrait.php | GitTrait.hotfixFinish | public function hotfixFinish($options = ['semversion' => null, 'type' => 'patch'])
{
if (empty($options['semversion'])) {
$version = $this->getVersion()
->increment($options['type']);
} else {
$version = $options['semversion'];
}
return $this->taskHotfixFinish((string)$version)->run();
} | php | public function hotfixFinish($options = ['semversion' => null, 'type' => 'patch'])
{
if (empty($options['semversion'])) {
$version = $this->getVersion()
->increment($options['type']);
} else {
$version = $options['semversion'];
}
return $this->taskHotfixFinish((string)$version)->run();
} | [
"public",
"function",
"hotfixFinish",
"(",
"$",
"options",
"=",
"[",
"'semversion'",
"=>",
"null",
",",
"'type'",
"=>",
"'patch'",
"]",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"options",
"[",
"'semversion'",
"]",
")",
")",
"{",
"$",
"version",
"=",
"$",
"this",
"->",
"getVersion",
"(",
")",
"->",
"increment",
"(",
"$",
"options",
"[",
"'type'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"version",
"=",
"$",
"options",
"[",
"'semversion'",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"taskHotfixFinish",
"(",
"(",
"string",
")",
"$",
"version",
")",
"->",
"run",
"(",
")",
";",
"}"
] | Finish a hotfix
@option string $semversion Version number
@option string $type Hotfix type (path, minor) | [
"Finish",
"a",
"hotfix"
] | train | https://github.com/globalis-ms/wp-cubi-robo/blob/4acc9d37c77e24a968a950d59b5ba53818c53bc1/src/GitTrait.php#L53-L62 |
globalis-ms/wp-cubi-robo | src/GitTrait.php | GitTrait.releaseStart | public function releaseStart($options = ['semversion' => null, 'type' => 'minor'])
{
if (empty($options['semversion'])) {
$version = $this->getVersion()
->increment($options['type']);
} else {
$version = $options['semversion'];
}
return $this->taskReleaseStart((string)$version)->run();
} | php | public function releaseStart($options = ['semversion' => null, 'type' => 'minor'])
{
if (empty($options['semversion'])) {
$version = $this->getVersion()
->increment($options['type']);
} else {
$version = $options['semversion'];
}
return $this->taskReleaseStart((string)$version)->run();
} | [
"public",
"function",
"releaseStart",
"(",
"$",
"options",
"=",
"[",
"'semversion'",
"=>",
"null",
",",
"'type'",
"=>",
"'minor'",
"]",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"options",
"[",
"'semversion'",
"]",
")",
")",
"{",
"$",
"version",
"=",
"$",
"this",
"->",
"getVersion",
"(",
")",
"->",
"increment",
"(",
"$",
"options",
"[",
"'type'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"version",
"=",
"$",
"options",
"[",
"'semversion'",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"taskReleaseStart",
"(",
"(",
"string",
")",
"$",
"version",
")",
"->",
"run",
"(",
")",
";",
"}"
] | Start a new release
@option string $semversion Version number
@option string $type Relase type (minor, major) | [
"Start",
"a",
"new",
"release"
] | train | https://github.com/globalis-ms/wp-cubi-robo/blob/4acc9d37c77e24a968a950d59b5ba53818c53bc1/src/GitTrait.php#L70-L79 |
globalis-ms/wp-cubi-robo | src/GitTrait.php | GitTrait.releaseFinish | public function releaseFinish($options = ['semversion' => null, 'type' => 'minor'])
{
if (empty($options['semversion'])) {
$version = $this->getVersion()
->increment($options['type']);
} else {
$version = $options['semversion'];
}
return $this->taskReleaseFinish((string)$version)->run();
} | php | public function releaseFinish($options = ['semversion' => null, 'type' => 'minor'])
{
if (empty($options['semversion'])) {
$version = $this->getVersion()
->increment($options['type']);
} else {
$version = $options['semversion'];
}
return $this->taskReleaseFinish((string)$version)->run();
} | [
"public",
"function",
"releaseFinish",
"(",
"$",
"options",
"=",
"[",
"'semversion'",
"=>",
"null",
",",
"'type'",
"=>",
"'minor'",
"]",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"options",
"[",
"'semversion'",
"]",
")",
")",
"{",
"$",
"version",
"=",
"$",
"this",
"->",
"getVersion",
"(",
")",
"->",
"increment",
"(",
"$",
"options",
"[",
"'type'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"version",
"=",
"$",
"options",
"[",
"'semversion'",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"taskReleaseFinish",
"(",
"(",
"string",
")",
"$",
"version",
")",
"->",
"run",
"(",
")",
";",
"}"
] | Finish a release
@option string $semversion Version number
@option string $type Relase type (minor, major) | [
"Finish",
"a",
"release"
] | train | https://github.com/globalis-ms/wp-cubi-robo/blob/4acc9d37c77e24a968a950d59b5ba53818c53bc1/src/GitTrait.php#L87-L96 |
globalis-ms/wp-cubi-robo | src/GitTrait.php | GitTrait.getVersion | protected function getVersion()
{
// Get version from tag
$cmd = new Command('git');
$cmd = $cmd->arg('tag')
->execute();
$output = explode(PHP_EOL, trim($cmd->getOutput()));
$currentVersion = '0.0.0';
foreach ($output as $tag) {
if (preg_match(SemanticVersion::REGEX, $tag)) {
if (version_compare($currentVersion, $tag, '<')) {
$currentVersion = $tag;
}
}
}
return new SemanticVersion($currentVersion);
} | php | protected function getVersion()
{
// Get version from tag
$cmd = new Command('git');
$cmd = $cmd->arg('tag')
->execute();
$output = explode(PHP_EOL, trim($cmd->getOutput()));
$currentVersion = '0.0.0';
foreach ($output as $tag) {
if (preg_match(SemanticVersion::REGEX, $tag)) {
if (version_compare($currentVersion, $tag, '<')) {
$currentVersion = $tag;
}
}
}
return new SemanticVersion($currentVersion);
} | [
"protected",
"function",
"getVersion",
"(",
")",
"{",
"// Get version from tag",
"$",
"cmd",
"=",
"new",
"Command",
"(",
"'git'",
")",
";",
"$",
"cmd",
"=",
"$",
"cmd",
"->",
"arg",
"(",
"'tag'",
")",
"->",
"execute",
"(",
")",
";",
"$",
"output",
"=",
"explode",
"(",
"PHP_EOL",
",",
"trim",
"(",
"$",
"cmd",
"->",
"getOutput",
"(",
")",
")",
")",
";",
"$",
"currentVersion",
"=",
"'0.0.0'",
";",
"foreach",
"(",
"$",
"output",
"as",
"$",
"tag",
")",
"{",
"if",
"(",
"preg_match",
"(",
"SemanticVersion",
"::",
"REGEX",
",",
"$",
"tag",
")",
")",
"{",
"if",
"(",
"version_compare",
"(",
"$",
"currentVersion",
",",
"$",
"tag",
",",
"'<'",
")",
")",
"{",
"$",
"currentVersion",
"=",
"$",
"tag",
";",
"}",
"}",
"}",
"return",
"new",
"SemanticVersion",
"(",
"$",
"currentVersion",
")",
";",
"}"
] | Return current version
@return SemanticVersion | [
"Return",
"current",
"version"
] | train | https://github.com/globalis-ms/wp-cubi-robo/blob/4acc9d37c77e24a968a950d59b5ba53818c53bc1/src/GitTrait.php#L183-L199 |
xiewulong/yii2-fileupload | oss/libs/guzzle/http/Guzzle/Http/Curl/CurlMultiProxy.php | CurlMultiProxy.getAvailableHandle | protected function getAvailableHandle()
{
// Grab a handle that is not claimed
foreach ($this->handles as $h) {
if (!in_array($h, $this->groups, true)) {
return $h;
}
}
// All are claimed, so create one
$handle = new CurlMulti();
$handle->setEventDispatcher($this->getEventDispatcher());
$this->handles[] = $handle;
return $handle;
} | php | protected function getAvailableHandle()
{
// Grab a handle that is not claimed
foreach ($this->handles as $h) {
if (!in_array($h, $this->groups, true)) {
return $h;
}
}
// All are claimed, so create one
$handle = new CurlMulti();
$handle->setEventDispatcher($this->getEventDispatcher());
$this->handles[] = $handle;
return $handle;
} | [
"protected",
"function",
"getAvailableHandle",
"(",
")",
"{",
"// Grab a handle that is not claimed",
"foreach",
"(",
"$",
"this",
"->",
"handles",
"as",
"$",
"h",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"h",
",",
"$",
"this",
"->",
"groups",
",",
"true",
")",
")",
"{",
"return",
"$",
"h",
";",
"}",
"}",
"// All are claimed, so create one",
"$",
"handle",
"=",
"new",
"CurlMulti",
"(",
")",
";",
"$",
"handle",
"->",
"setEventDispatcher",
"(",
"$",
"this",
"->",
"getEventDispatcher",
"(",
")",
")",
";",
"$",
"this",
"->",
"handles",
"[",
"]",
"=",
"$",
"handle",
";",
"return",
"$",
"handle",
";",
"}"
] | Get an existing available CurlMulti handle or create a new one
@return CurlMulti | [
"Get",
"an",
"existing",
"available",
"CurlMulti",
"handle",
"or",
"create",
"a",
"new",
"one"
] | train | https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/guzzle/http/Guzzle/Http/Curl/CurlMultiProxy.php#L115-L130 |
mainio/c5pkg_symfony_forms | src/Mainio/C5/Symfony/Form/Extension/Concrete5/Type/UserSelectorType.php | UserSelectorType.buildView | public function buildView(FormView $view, FormInterface $form, array $options)
{
// TODO: Through configurations variables we should allow the user to
// use also $uh->quickSelect(...) and $uh->selectMultipleUsers(...).
$uh = \Core::make('helper/form/user_selector');
$view->vars = array_replace($view->vars, array(
'selector' => $uh->selectUser($view->vars["full_name"], $view->vars["value"]),
));
} | php | public function buildView(FormView $view, FormInterface $form, array $options)
{
// TODO: Through configurations variables we should allow the user to
// use also $uh->quickSelect(...) and $uh->selectMultipleUsers(...).
$uh = \Core::make('helper/form/user_selector');
$view->vars = array_replace($view->vars, array(
'selector' => $uh->selectUser($view->vars["full_name"], $view->vars["value"]),
));
} | [
"public",
"function",
"buildView",
"(",
"FormView",
"$",
"view",
",",
"FormInterface",
"$",
"form",
",",
"array",
"$",
"options",
")",
"{",
"// TODO: Through configurations variables we should allow the user to",
"// use also $uh->quickSelect(...) and $uh->selectMultipleUsers(...).",
"$",
"uh",
"=",
"\\",
"Core",
"::",
"make",
"(",
"'helper/form/user_selector'",
")",
";",
"$",
"view",
"->",
"vars",
"=",
"array_replace",
"(",
"$",
"view",
"->",
"vars",
",",
"array",
"(",
"'selector'",
"=>",
"$",
"uh",
"->",
"selectUser",
"(",
"$",
"view",
"->",
"vars",
"[",
"\"full_name\"",
"]",
",",
"$",
"view",
"->",
"vars",
"[",
"\"value\"",
"]",
")",
",",
")",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/mainio/c5pkg_symfony_forms/blob/41a93c293d986574ec5cade8a7c8700e083dbaaa/src/Mainio/C5/Symfony/Form/Extension/Concrete5/Type/UserSelectorType.php#L33-L41 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/TranslationCacheTiein/src/backends/cache_backend.php | ezcTranslationCacheBackend.getContext | public function getContext( $locale, $context )
{
$cachedContext = $this->cache->restore( "$locale/$context" );
if ( $cachedContext === false )
{
throw new ezcTranslationContextNotAvailableException( $context );
}
foreach ( $cachedContext as $key => $cachedElement )
{
if ( $cachedElement->status == ezcTranslationData::OBSOLETE )
{
unset( $cachedContext[$key] );
}
}
return $cachedContext;
} | php | public function getContext( $locale, $context )
{
$cachedContext = $this->cache->restore( "$locale/$context" );
if ( $cachedContext === false )
{
throw new ezcTranslationContextNotAvailableException( $context );
}
foreach ( $cachedContext as $key => $cachedElement )
{
if ( $cachedElement->status == ezcTranslationData::OBSOLETE )
{
unset( $cachedContext[$key] );
}
}
return $cachedContext;
} | [
"public",
"function",
"getContext",
"(",
"$",
"locale",
",",
"$",
"context",
")",
"{",
"$",
"cachedContext",
"=",
"$",
"this",
"->",
"cache",
"->",
"restore",
"(",
"\"$locale/$context\"",
")",
";",
"if",
"(",
"$",
"cachedContext",
"===",
"false",
")",
"{",
"throw",
"new",
"ezcTranslationContextNotAvailableException",
"(",
"$",
"context",
")",
";",
"}",
"foreach",
"(",
"$",
"cachedContext",
"as",
"$",
"key",
"=>",
"$",
"cachedElement",
")",
"{",
"if",
"(",
"$",
"cachedElement",
"->",
"status",
"==",
"ezcTranslationData",
"::",
"OBSOLETE",
")",
"{",
"unset",
"(",
"$",
"cachedContext",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"return",
"$",
"cachedContext",
";",
"}"
] | Returns a array containing the translation map for the specified
$locale and $context.
It uses the $tsLocationPath and
$tsFilenameFormat properties to locate the file, unless caching is
enabled. If a cache object is available it will be used to retrieve the
information from the cache.
@throws ezcTranslationContextNotAvailableException if the context is not available.
@param string $locale
@param string $context
@return array(ezcTranslationData) | [
"Returns",
"a",
"array",
"containing",
"the",
"translation",
"map",
"for",
"the",
"specified",
"$locale",
"and",
"$context",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/TranslationCacheTiein/src/backends/cache_backend.php#L138-L153 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/TranslationCacheTiein/src/backends/cache_backend.php | ezcTranslationCacheBackend.storeContext | public function storeContext( $context, array $data )
{
if ( is_null( $this->writeLocale ) )
{
throw new ezcTranslationWriterNotInitializedException();
}
foreach ( $data as $key => $cachedElement )
{
if ( $cachedElement->status == ezcTranslationData::OBSOLETE )
{
unset( $data[$key] );
}
}
$cachedContext = $this->cache->store( "{$this->writeLocale}/$context" , $data );
} | php | public function storeContext( $context, array $data )
{
if ( is_null( $this->writeLocale ) )
{
throw new ezcTranslationWriterNotInitializedException();
}
foreach ( $data as $key => $cachedElement )
{
if ( $cachedElement->status == ezcTranslationData::OBSOLETE )
{
unset( $data[$key] );
}
}
$cachedContext = $this->cache->store( "{$this->writeLocale}/$context" , $data );
} | [
"public",
"function",
"storeContext",
"(",
"$",
"context",
",",
"array",
"$",
"data",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"writeLocale",
")",
")",
"{",
"throw",
"new",
"ezcTranslationWriterNotInitializedException",
"(",
")",
";",
"}",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"cachedElement",
")",
"{",
"if",
"(",
"$",
"cachedElement",
"->",
"status",
"==",
"ezcTranslationData",
"::",
"OBSOLETE",
")",
"{",
"unset",
"(",
"$",
"data",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"$",
"cachedContext",
"=",
"$",
"this",
"->",
"cache",
"->",
"store",
"(",
"\"{$this->writeLocale}/$context\"",
",",
"$",
"data",
")",
";",
"}"
] | Stores a context.
This method stores the context that it received to the backend specified
storage place.
@throws ezcTranslationWriterNotInitializedException when the writer is
not initialized with initWriter().
@param string $context The context's name
@param array $data The context's translation map
@return void | [
"Stores",
"a",
"context",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/TranslationCacheTiein/src/backends/cache_backend.php#L200-L214 |
willhoffmann/domuserp-php | src/Resources/AbstractResource.php | AbstractResource.setBranch | public function setBranch($branch)
{
$this->branch = $branch;
$this->domusClient->setBranch($branch);
return $this;
} | php | public function setBranch($branch)
{
$this->branch = $branch;
$this->domusClient->setBranch($branch);
return $this;
} | [
"public",
"function",
"setBranch",
"(",
"$",
"branch",
")",
"{",
"$",
"this",
"->",
"branch",
"=",
"$",
"branch",
";",
"$",
"this",
"->",
"domusClient",
"->",
"setBranch",
"(",
"$",
"branch",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set branch
@param $branch
@return $this
@throws \GuzzleHttp\Exception\GuzzleException | [
"Set",
"branch"
] | train | https://github.com/willhoffmann/domuserp-php/blob/44e77a4f02b0252bc26cae4c0e6b2b7d578f10a6/src/Resources/AbstractResource.php#L42-L48 |
willhoffmann/domuserp-php | src/Resources/AbstractResource.php | AbstractResource.execute | protected function execute($method, $resource, array $data = [])
{
if (! $this->branch) {
$this->setBranch(1);
}
$request = new Request($this->domusClient->getHandler());
$dataResource = $request->execute($method, $this->domusClient->makeUrl($resource), array_merge($data, [
'headers' => [
'X-Session-ID' => $this->domusClient->getToken()
]
]));
return $dataResource;
} | php | protected function execute($method, $resource, array $data = [])
{
if (! $this->branch) {
$this->setBranch(1);
}
$request = new Request($this->domusClient->getHandler());
$dataResource = $request->execute($method, $this->domusClient->makeUrl($resource), array_merge($data, [
'headers' => [
'X-Session-ID' => $this->domusClient->getToken()
]
]));
return $dataResource;
} | [
"protected",
"function",
"execute",
"(",
"$",
"method",
",",
"$",
"resource",
",",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"branch",
")",
"{",
"$",
"this",
"->",
"setBranch",
"(",
"1",
")",
";",
"}",
"$",
"request",
"=",
"new",
"Request",
"(",
"$",
"this",
"->",
"domusClient",
"->",
"getHandler",
"(",
")",
")",
";",
"$",
"dataResource",
"=",
"$",
"request",
"->",
"execute",
"(",
"$",
"method",
",",
"$",
"this",
"->",
"domusClient",
"->",
"makeUrl",
"(",
"$",
"resource",
")",
",",
"array_merge",
"(",
"$",
"data",
",",
"[",
"'headers'",
"=>",
"[",
"'X-Session-ID'",
"=>",
"$",
"this",
"->",
"domusClient",
"->",
"getToken",
"(",
")",
"]",
"]",
")",
")",
";",
"return",
"$",
"dataResource",
";",
"}"
] | Execute the resource
@param $method
@param $resource
@param array $data
@return string
@throws \GuzzleHttp\Exception\GuzzleException | [
"Execute",
"the",
"resource"
] | train | https://github.com/willhoffmann/domuserp-php/blob/44e77a4f02b0252bc26cae4c0e6b2b7d578f10a6/src/Resources/AbstractResource.php#L73-L87 |
maestroprog/saw-php | src/Thread/Pool/ControllerThreadPoolIndex.php | ControllerThreadPoolIndex.add | public function add(Worker $worker, AbstractThread $thread)
{
$this->threads[$thread->getId()] = $worker->getId();
$this->workers[$worker->getId()][$thread->getId()] = $thread;
} | php | public function add(Worker $worker, AbstractThread $thread)
{
$this->threads[$thread->getId()] = $worker->getId();
$this->workers[$worker->getId()][$thread->getId()] = $thread;
} | [
"public",
"function",
"add",
"(",
"Worker",
"$",
"worker",
",",
"AbstractThread",
"$",
"thread",
")",
"{",
"$",
"this",
"->",
"threads",
"[",
"$",
"thread",
"->",
"getId",
"(",
")",
"]",
"=",
"$",
"worker",
"->",
"getId",
"(",
")",
";",
"$",
"this",
"->",
"workers",
"[",
"$",
"worker",
"->",
"getId",
"(",
")",
"]",
"[",
"$",
"thread",
"->",
"getId",
"(",
")",
"]",
"=",
"$",
"thread",
";",
"}"
] | Добавляет информацию о потоке и воркере в индекс.
@param Worker $worker
@param AbstractThread $thread | [
"Добавляет",
"информацию",
"о",
"потоке",
"и",
"воркере",
"в",
"индекс",
"."
] | train | https://github.com/maestroprog/saw-php/blob/159215a4d7a951cca2a9c2eed3e1aa4f5b624cfb/src/Thread/Pool/ControllerThreadPoolIndex.php#L25-L29 |
HedronDev/hedron | src/Bootstrap.php | Bootstrap.getConfiguration | public static function getConfiguration(string $input) {
list($oldrev, $newrev, $refname) = explode(' ', $input);
list(,, $branch) = explode('/', $refname);
return new ParserVariableConfiguration($oldrev, $newrev, $refname, $branch);
} | php | public static function getConfiguration(string $input) {
list($oldrev, $newrev, $refname) = explode(' ', $input);
list(,, $branch) = explode('/', $refname);
return new ParserVariableConfiguration($oldrev, $newrev, $refname, $branch);
} | [
"public",
"static",
"function",
"getConfiguration",
"(",
"string",
"$",
"input",
")",
"{",
"list",
"(",
"$",
"oldrev",
",",
"$",
"newrev",
",",
"$",
"refname",
")",
"=",
"explode",
"(",
"' '",
",",
"$",
"input",
")",
";",
"list",
"(",
",",
",",
"$",
"branch",
")",
"=",
"explode",
"(",
"'/'",
",",
"$",
"refname",
")",
";",
"return",
"new",
"ParserVariableConfiguration",
"(",
"$",
"oldrev",
",",
"$",
"newrev",
",",
"$",
"refname",
",",
"$",
"branch",
")",
";",
"}"
] | Extracts data from the post-receive hook as configuration for easy use.
@param string $input
Input to the post-receive git hook
@return \Hedron\Configuration\ParserVariableConfiguration
A simple configuration object. | [
"Extracts",
"data",
"from",
"the",
"post",
"-",
"receive",
"hook",
"as",
"configuration",
"for",
"easy",
"use",
"."
] | train | https://github.com/HedronDev/hedron/blob/3b4adec4912f2d7c0b7e7262dc36515fbc2e8e00/src/Bootstrap.php#L48-L52 |
HedronDev/hedron | src/Bootstrap.php | Bootstrap.getEnvironmentVariables | public static function getEnvironmentVariables() {
$dir = shell_exec('pwd');
$dir_parts = explode(DIRECTORY_SEPARATOR, $dir);
$project = trim(array_pop($dir_parts));
$client = trim(array_pop($dir_parts));
$dir = $dir . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'project' . DIRECTORY_SEPARATOR . $client . DIRECTORY_SEPARATOR . $project;
$environment_file = file_get_contents($dir . DIRECTORY_SEPARATOR . 'environment.yml');
if (!$environment_file) {
throw new MissingEnvironmentConfigurationException("The environment configuration is missing, please contact your administrator.");
}
return new EnvironmentVariables(Yaml::parse($environment_file));
} | php | public static function getEnvironmentVariables() {
$dir = shell_exec('pwd');
$dir_parts = explode(DIRECTORY_SEPARATOR, $dir);
$project = trim(array_pop($dir_parts));
$client = trim(array_pop($dir_parts));
$dir = $dir . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'project' . DIRECTORY_SEPARATOR . $client . DIRECTORY_SEPARATOR . $project;
$environment_file = file_get_contents($dir . DIRECTORY_SEPARATOR . 'environment.yml');
if (!$environment_file) {
throw new MissingEnvironmentConfigurationException("The environment configuration is missing, please contact your administrator.");
}
return new EnvironmentVariables(Yaml::parse($environment_file));
} | [
"public",
"static",
"function",
"getEnvironmentVariables",
"(",
")",
"{",
"$",
"dir",
"=",
"shell_exec",
"(",
"'pwd'",
")",
";",
"$",
"dir_parts",
"=",
"explode",
"(",
"DIRECTORY_SEPARATOR",
",",
"$",
"dir",
")",
";",
"$",
"project",
"=",
"trim",
"(",
"array_pop",
"(",
"$",
"dir_parts",
")",
")",
";",
"$",
"client",
"=",
"trim",
"(",
"array_pop",
"(",
"$",
"dir_parts",
")",
")",
";",
"$",
"dir",
"=",
"$",
"dir",
".",
"DIRECTORY_SEPARATOR",
".",
"'..'",
".",
"DIRECTORY_SEPARATOR",
".",
"'..'",
".",
"DIRECTORY_SEPARATOR",
".",
"'..'",
".",
"DIRECTORY_SEPARATOR",
".",
"'project'",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"client",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"project",
";",
"$",
"environment_file",
"=",
"file_get_contents",
"(",
"$",
"dir",
".",
"DIRECTORY_SEPARATOR",
".",
"'environment.yml'",
")",
";",
"if",
"(",
"!",
"$",
"environment_file",
")",
"{",
"throw",
"new",
"MissingEnvironmentConfigurationException",
"(",
"\"The environment configuration is missing, please contact your administrator.\"",
")",
";",
"}",
"return",
"new",
"EnvironmentVariables",
"(",
"Yaml",
"::",
"parse",
"(",
"$",
"environment_file",
")",
")",
";",
"}"
] | Bootstraps the environment variables.
@return \Hedron\Configuration\EnvironmentVariables
The environment variables from yaml.
@throws \Hedron\Exception\MissingEnvironmentConfigurationException
If the yaml file is missing, throws this exception. | [
"Bootstraps",
"the",
"environment",
"variables",
"."
] | train | https://github.com/HedronDev/hedron/blob/3b4adec4912f2d7c0b7e7262dc36515fbc2e8e00/src/Bootstrap.php#L63-L74 |
HedronDev/hedron | src/Bootstrap.php | Bootstrap.collectServices | public static function collectServices(ContainerBuilder $container, \Traversable $namespaces) {
$service_directories = [];
foreach ($namespaces as $directory) {
// $directory will correspond to the src dir, so up one level.
$service_directories[] = $directory . DIRECTORY_SEPARATOR . '..';
}
$loader = new PhpFileLoader($container, new FileLocator($service_directories));
$loader->load('services.php');
} | php | public static function collectServices(ContainerBuilder $container, \Traversable $namespaces) {
$service_directories = [];
foreach ($namespaces as $directory) {
// $directory will correspond to the src dir, so up one level.
$service_directories[] = $directory . DIRECTORY_SEPARATOR . '..';
}
$loader = new PhpFileLoader($container, new FileLocator($service_directories));
$loader->load('services.php');
} | [
"public",
"static",
"function",
"collectServices",
"(",
"ContainerBuilder",
"$",
"container",
",",
"\\",
"Traversable",
"$",
"namespaces",
")",
"{",
"$",
"service_directories",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"namespaces",
"as",
"$",
"directory",
")",
"{",
"// $directory will correspond to the src dir, so up one level.",
"$",
"service_directories",
"[",
"]",
"=",
"$",
"directory",
".",
"DIRECTORY_SEPARATOR",
".",
"'..'",
";",
"}",
"$",
"loader",
"=",
"new",
"PhpFileLoader",
"(",
"$",
"container",
",",
"new",
"FileLocator",
"(",
"$",
"service_directories",
")",
")",
";",
"$",
"loader",
"->",
"load",
"(",
"'services.php'",
")",
";",
"}"
] | Iterate through all namespace dirs and add services to the container.
@param \Symfony\Component\DependencyInjection\ContainerBuilder $container
The container builder.
@param \Traversable $namespaces
The namespaces. | [
"Iterate",
"through",
"all",
"namespace",
"dirs",
"and",
"add",
"services",
"to",
"the",
"container",
"."
] | train | https://github.com/HedronDev/hedron/blob/3b4adec4912f2d7c0b7e7262dc36515fbc2e8e00/src/Bootstrap.php#L84-L92 |
HedronDev/hedron | src/Bootstrap.php | Bootstrap.getValidParsers | public static function getValidParsers(ProjectTypeInterface $project, ParserDictionary $parserDictionary, EventDispatcherInterface $dispatcher) {
$parserSet = $project::getFileParsers($parserDictionary);
$event = new ParserSetEvent($project, $parserSet);
$dispatcher->dispatch(ProjectTypeInterface::COLLECT_PARSER_SET, $event);
$plugins = [];
foreach ($event->getParserDefinitionSet() as $parserDefinition) {
$plugins[] = $parserDictionary->createInstance($parserDefinition->getPluginId(), $parserDefinition, $project);
}
return $plugins;
} | php | public static function getValidParsers(ProjectTypeInterface $project, ParserDictionary $parserDictionary, EventDispatcherInterface $dispatcher) {
$parserSet = $project::getFileParsers($parserDictionary);
$event = new ParserSetEvent($project, $parserSet);
$dispatcher->dispatch(ProjectTypeInterface::COLLECT_PARSER_SET, $event);
$plugins = [];
foreach ($event->getParserDefinitionSet() as $parserDefinition) {
$plugins[] = $parserDictionary->createInstance($parserDefinition->getPluginId(), $parserDefinition, $project);
}
return $plugins;
} | [
"public",
"static",
"function",
"getValidParsers",
"(",
"ProjectTypeInterface",
"$",
"project",
",",
"ParserDictionary",
"$",
"parserDictionary",
",",
"EventDispatcherInterface",
"$",
"dispatcher",
")",
"{",
"$",
"parserSet",
"=",
"$",
"project",
"::",
"getFileParsers",
"(",
"$",
"parserDictionary",
")",
";",
"$",
"event",
"=",
"new",
"ParserSetEvent",
"(",
"$",
"project",
",",
"$",
"parserSet",
")",
";",
"$",
"dispatcher",
"->",
"dispatch",
"(",
"ProjectTypeInterface",
"::",
"COLLECT_PARSER_SET",
",",
"$",
"event",
")",
";",
"$",
"plugins",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"event",
"->",
"getParserDefinitionSet",
"(",
")",
"as",
"$",
"parserDefinition",
")",
"{",
"$",
"plugins",
"[",
"]",
"=",
"$",
"parserDictionary",
"->",
"createInstance",
"(",
"$",
"parserDefinition",
"->",
"getPluginId",
"(",
")",
",",
"$",
"parserDefinition",
",",
"$",
"project",
")",
";",
"}",
"return",
"$",
"plugins",
";",
"}"
] | Gets an array of valid parser plugins for the project type.
@param \Hedron\ProjectTypeInterface $project
The project plugin for the current environment settings.
@param \Hedron\ParserDictionary $parserDictionary
The parser dictionary.
@param \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher
The event dispatcher.
@return \Hedron\FileParserInterface[]
The valid parser plugins. | [
"Gets",
"an",
"array",
"of",
"valid",
"parser",
"plugins",
"for",
"the",
"project",
"type",
"."
] | train | https://github.com/HedronDev/hedron/blob/3b4adec4912f2d7c0b7e7262dc36515fbc2e8e00/src/Bootstrap.php#L120-L129 |
dstuecken/notify | src/Handler/MemoryHandler.php | MemoryHandler.handle | public function handle(NotificationInterface $notification, $level)
{
$this->memory[$level][] = $notification->message();
return true;
} | php | public function handle(NotificationInterface $notification, $level)
{
$this->memory[$level][] = $notification->message();
return true;
} | [
"public",
"function",
"handle",
"(",
"NotificationInterface",
"$",
"notification",
",",
"$",
"level",
")",
"{",
"$",
"this",
"->",
"memory",
"[",
"$",
"level",
"]",
"[",
"]",
"=",
"$",
"notification",
"->",
"message",
"(",
")",
";",
"return",
"true",
";",
"}"
] | Handle a notification
@return bool | [
"Handle",
"a",
"notification"
] | train | https://github.com/dstuecken/notify/blob/abccf0a6a272caf66baea74323f18e2212c6e11e/src/Handler/MemoryHandler.php#L35-L40 |
namics/twig-nitro-library | src/Twig/Loader/TerrificLoader.php | TerrificLoader.findTemplate | protected function findTemplate($name)
{
$name = $this->normalizeName($name);
if (isset($this->cache[$name])) {
return $this->cache[$name];
}
if (isset($this->errorCache[$name])) {
throw new Twig_Error_Loader($this->errorCache[$name]);
}
$this->validateName($name);
$namespace = parent::MAIN_NAMESPACE;
$terrificPath = $name . '/' . strtolower($name) . '.' . $this->fileExtension;
foreach ($this->paths[$namespace] as $path) {
$fullPath = $path . '/' . $terrificPath;
$realPath = realpath($fullPath);
if (is_readable($fullPath) && $realPath !== false) {
return $this->cache[$name] = $realPath;
}
}
$this->errorCache[$name] = sprintf('Unable to find component "%s" (looked into: %s).', $name, implode(', ', $this->paths[$namespace]));
throw new Twig_Error_Loader($this->errorCache[$name]);
} | php | protected function findTemplate($name)
{
$name = $this->normalizeName($name);
if (isset($this->cache[$name])) {
return $this->cache[$name];
}
if (isset($this->errorCache[$name])) {
throw new Twig_Error_Loader($this->errorCache[$name]);
}
$this->validateName($name);
$namespace = parent::MAIN_NAMESPACE;
$terrificPath = $name . '/' . strtolower($name) . '.' . $this->fileExtension;
foreach ($this->paths[$namespace] as $path) {
$fullPath = $path . '/' . $terrificPath;
$realPath = realpath($fullPath);
if (is_readable($fullPath) && $realPath !== false) {
return $this->cache[$name] = $realPath;
}
}
$this->errorCache[$name] = sprintf('Unable to find component "%s" (looked into: %s).', $name, implode(', ', $this->paths[$namespace]));
throw new Twig_Error_Loader($this->errorCache[$name]);
} | [
"protected",
"function",
"findTemplate",
"(",
"$",
"name",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"normalizeName",
"(",
"$",
"name",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"cache",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"cache",
"[",
"$",
"name",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"errorCache",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"Twig_Error_Loader",
"(",
"$",
"this",
"->",
"errorCache",
"[",
"$",
"name",
"]",
")",
";",
"}",
"$",
"this",
"->",
"validateName",
"(",
"$",
"name",
")",
";",
"$",
"namespace",
"=",
"parent",
"::",
"MAIN_NAMESPACE",
";",
"$",
"terrificPath",
"=",
"$",
"name",
".",
"'/'",
".",
"strtolower",
"(",
"$",
"name",
")",
".",
"'.'",
".",
"$",
"this",
"->",
"fileExtension",
";",
"foreach",
"(",
"$",
"this",
"->",
"paths",
"[",
"$",
"namespace",
"]",
"as",
"$",
"path",
")",
"{",
"$",
"fullPath",
"=",
"$",
"path",
".",
"'/'",
".",
"$",
"terrificPath",
";",
"$",
"realPath",
"=",
"realpath",
"(",
"$",
"fullPath",
")",
";",
"if",
"(",
"is_readable",
"(",
"$",
"fullPath",
")",
"&&",
"$",
"realPath",
"!==",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"cache",
"[",
"$",
"name",
"]",
"=",
"$",
"realPath",
";",
"}",
"}",
"$",
"this",
"->",
"errorCache",
"[",
"$",
"name",
"]",
"=",
"sprintf",
"(",
"'Unable to find component \"%s\" (looked into: %s).'",
",",
"$",
"name",
",",
"implode",
"(",
"', '",
",",
"$",
"this",
"->",
"paths",
"[",
"$",
"namespace",
"]",
")",
")",
";",
"throw",
"new",
"Twig_Error_Loader",
"(",
"$",
"this",
"->",
"errorCache",
"[",
"$",
"name",
"]",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/namics/twig-nitro-library/blob/f4631b50876b7cdc79f3cca4d3465c8c9a2e87de/src/Twig/Loader/TerrificLoader.php#L45-L73 |
InactiveProjects/limoncello-illuminate | app/Api/BoardsApi.php | BoardsApi.indexPosts | public function indexPosts($boardId, EncodingParametersInterface $parameters)
{
$this->getLogger()->debug('Index board posts started.', [Board::FIELD_ID => $boardId]);
$result = $this->indexRelationship($boardId, Board::REL_POSTS, $parameters);
$this->getLogger()->debug('Index board posts completed.');
return $result;
} | php | public function indexPosts($boardId, EncodingParametersInterface $parameters)
{
$this->getLogger()->debug('Index board posts started.', [Board::FIELD_ID => $boardId]);
$result = $this->indexRelationship($boardId, Board::REL_POSTS, $parameters);
$this->getLogger()->debug('Index board posts completed.');
return $result;
} | [
"public",
"function",
"indexPosts",
"(",
"$",
"boardId",
",",
"EncodingParametersInterface",
"$",
"parameters",
")",
"{",
"$",
"this",
"->",
"getLogger",
"(",
")",
"->",
"debug",
"(",
"'Index board posts started.'",
",",
"[",
"Board",
"::",
"FIELD_ID",
"=>",
"$",
"boardId",
"]",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"indexRelationship",
"(",
"$",
"boardId",
",",
"Board",
"::",
"REL_POSTS",
",",
"$",
"parameters",
")",
";",
"$",
"this",
"->",
"getLogger",
"(",
")",
"->",
"debug",
"(",
"'Index board posts completed.'",
")",
";",
"return",
"$",
"result",
";",
"}"
] | @param int|string $boardId
@param EncodingParametersInterface $parameters
@return PagedDataInterface | [
"@param",
"int|string",
"$boardId",
"@param",
"EncodingParametersInterface",
"$parameters"
] | train | https://github.com/InactiveProjects/limoncello-illuminate/blob/cae6fc26190efcf090495a5c3582c10fa2430897/app/Api/BoardsApi.php#L71-L80 |
chubbyphp/chubbyphp-lazy-command | src/LazyCommand.php | LazyCommand.execute | protected function execute(Input $input, Output $output)
{
$command = $this->container->get($this->serviceId);
return $command($input, $output);
} | php | protected function execute(Input $input, Output $output)
{
$command = $this->container->get($this->serviceId);
return $command($input, $output);
} | [
"protected",
"function",
"execute",
"(",
"Input",
"$",
"input",
",",
"Output",
"$",
"output",
")",
"{",
"$",
"command",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"$",
"this",
"->",
"serviceId",
")",
";",
"return",
"$",
"command",
"(",
"$",
"input",
",",
"$",
"output",
")",
";",
"}"
] | @param Input $input
@param Output $output
@return int|null | [
"@param",
"Input",
"$input",
"@param",
"Output",
"$output"
] | train | https://github.com/chubbyphp/chubbyphp-lazy-command/blob/80a41c84b2a57f565b24e5bac4d9d030f5c053b4/src/LazyCommand.php#L56-L61 |
nathan-fiscaletti/extended-arrays | src/ExtendedArrays/Traits/Restricted.php | Restricted.offsetSet | public function offsetSet($offset, $value)
{
if (is_null($offset)) {
throw new \Exception('Must supply key to modify an associative array.');
} else {
if ($this->_isFillable($offset)) {
$this->_args[$offset] = $value;
} else {
throw new \Exception('Cannot modify element \''.$offset.'\'. Not fillable.');
}
}
} | php | public function offsetSet($offset, $value)
{
if (is_null($offset)) {
throw new \Exception('Must supply key to modify an associative array.');
} else {
if ($this->_isFillable($offset)) {
$this->_args[$offset] = $value;
} else {
throw new \Exception('Cannot modify element \''.$offset.'\'. Not fillable.');
}
}
} | [
"public",
"function",
"offsetSet",
"(",
"$",
"offset",
",",
"$",
"value",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"offset",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Must supply key to modify an associative array.'",
")",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"this",
"->",
"_isFillable",
"(",
"$",
"offset",
")",
")",
"{",
"$",
"this",
"->",
"_args",
"[",
"$",
"offset",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Cannot modify element \\''",
".",
"$",
"offset",
".",
"'\\'. Not fillable.'",
")",
";",
"}",
"}",
"}"
] | Override the offsetSet function to enforce
the list of restricted keys.
@param mixed $offset
@param mixed $value
@throws \Exception | [
"Override",
"the",
"offsetSet",
"function",
"to",
"enforce",
"the",
"list",
"of",
"restricted",
"keys",
"."
] | train | https://github.com/nathan-fiscaletti/extended-arrays/blob/a641856115131f76417521d3e4aa2d951158050a/src/ExtendedArrays/Traits/Restricted.php#L51-L62 |
LordDashMe/wordpress-db-schema-extender | src/SchemaExtender.php | SchemaExtender.setSeedQuery | public function setSeedQuery($key, $value)
{
$index = $this->getSeedQueryIndex();
$this->seedQueries[$index][$key] = $value;
} | php | public function setSeedQuery($key, $value)
{
$index = $this->getSeedQueryIndex();
$this->seedQueries[$index][$key] = $value;
} | [
"public",
"function",
"setSeedQuery",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"index",
"=",
"$",
"this",
"->",
"getSeedQueryIndex",
"(",
")",
";",
"$",
"this",
"->",
"seedQueries",
"[",
"$",
"index",
"]",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}"
] | The stter for the seed queries class property.
@param string $key
@param mixed $value
@return void | [
"The",
"stter",
"for",
"the",
"seed",
"queries",
"class",
"property",
"."
] | train | https://github.com/LordDashMe/wordpress-db-schema-extender/blob/1798435ec064256174b034a16d9683081c0c299f/src/SchemaExtender.php#L219-L224 |
LordDashMe/wordpress-db-schema-extender | src/SchemaExtender.php | SchemaExtender.getWordpressDatabaseInstance | protected function getWordpressDatabaseInstance()
{
global $wpdb;
if ((! \class_exists('wpdb')) || (! $wpdb) || (! $wpdb instanceof \wpdb)) {
throw InvalidDatabaseInstanceException::wordpressDatabaseIsNotSet();
}
$this->db = $wpdb;
} | php | protected function getWordpressDatabaseInstance()
{
global $wpdb;
if ((! \class_exists('wpdb')) || (! $wpdb) || (! $wpdb instanceof \wpdb)) {
throw InvalidDatabaseInstanceException::wordpressDatabaseIsNotSet();
}
$this->db = $wpdb;
} | [
"protected",
"function",
"getWordpressDatabaseInstance",
"(",
")",
"{",
"global",
"$",
"wpdb",
";",
"if",
"(",
"(",
"!",
"\\",
"class_exists",
"(",
"'wpdb'",
")",
")",
"||",
"(",
"!",
"$",
"wpdb",
")",
"||",
"(",
"!",
"$",
"wpdb",
"instanceof",
"\\",
"wpdb",
")",
")",
"{",
"throw",
"InvalidDatabaseInstanceException",
"::",
"wordpressDatabaseIsNotSet",
"(",
")",
";",
"}",
"$",
"this",
"->",
"db",
"=",
"$",
"wpdb",
";",
"}"
] | Tightly coupled to the wordpress database instance.
@throws LordDashMe\Wordpress\DB\Exception\InvalidDatabaseInstance
@return void | [
"Tightly",
"coupled",
"to",
"the",
"wordpress",
"database",
"instance",
"."
] | train | https://github.com/LordDashMe/wordpress-db-schema-extender/blob/1798435ec064256174b034a16d9683081c0c299f/src/SchemaExtender.php#L302-L311 |
LordDashMe/wordpress-db-schema-extender | src/SchemaExtender.php | SchemaExtender.table | public function table($name, $callback = null)
{
if (! $callback instanceof \Closure) {
throw InvalidArgumentPassedException::isNotClosure();
}
$this->setTableName($name);
$callback($this);
$tableNamePrefixed = $this->getTableNamePrefix($this->getTableName());
$tableStructure = \substr($this->getColumnsQuery() . $this->getPrimaryKeyQuery(), 0, -2);
$tableCharsetCollate = $this->getCharacterSetCollate();
$this->buildCreateTableQuery($tableNamePrefixed, $tableStructure, $tableCharsetCollate);
$this->flushColumns();
$this->flushPrimaryKey();
} | php | public function table($name, $callback = null)
{
if (! $callback instanceof \Closure) {
throw InvalidArgumentPassedException::isNotClosure();
}
$this->setTableName($name);
$callback($this);
$tableNamePrefixed = $this->getTableNamePrefix($this->getTableName());
$tableStructure = \substr($this->getColumnsQuery() . $this->getPrimaryKeyQuery(), 0, -2);
$tableCharsetCollate = $this->getCharacterSetCollate();
$this->buildCreateTableQuery($tableNamePrefixed, $tableStructure, $tableCharsetCollate);
$this->flushColumns();
$this->flushPrimaryKey();
} | [
"public",
"function",
"table",
"(",
"$",
"name",
",",
"$",
"callback",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"callback",
"instanceof",
"\\",
"Closure",
")",
"{",
"throw",
"InvalidArgumentPassedException",
"::",
"isNotClosure",
"(",
")",
";",
"}",
"$",
"this",
"->",
"setTableName",
"(",
"$",
"name",
")",
";",
"$",
"callback",
"(",
"$",
"this",
")",
";",
"$",
"tableNamePrefixed",
"=",
"$",
"this",
"->",
"getTableNamePrefix",
"(",
"$",
"this",
"->",
"getTableName",
"(",
")",
")",
";",
"$",
"tableStructure",
"=",
"\\",
"substr",
"(",
"$",
"this",
"->",
"getColumnsQuery",
"(",
")",
".",
"$",
"this",
"->",
"getPrimaryKeyQuery",
"(",
")",
",",
"0",
",",
"-",
"2",
")",
";",
"$",
"tableCharsetCollate",
"=",
"$",
"this",
"->",
"getCharacterSetCollate",
"(",
")",
";",
"$",
"this",
"->",
"buildCreateTableQuery",
"(",
"$",
"tableNamePrefixed",
",",
"$",
"tableStructure",
",",
"$",
"tableCharsetCollate",
")",
";",
"$",
"this",
"->",
"flushColumns",
"(",
")",
";",
"$",
"this",
"->",
"flushPrimaryKey",
"(",
")",
";",
"}"
] | The composer of the database table schema.
@param string $name
@param \Closure $callback
@throws LordDashMe\Wordpress\DB\Exception\InvalidArgumentPassed
@return void | [
"The",
"composer",
"of",
"the",
"database",
"table",
"schema",
"."
] | train | https://github.com/LordDashMe/wordpress-db-schema-extender/blob/1798435ec064256174b034a16d9683081c0c299f/src/SchemaExtender.php#L323-L341 |
LordDashMe/wordpress-db-schema-extender | src/SchemaExtender.php | SchemaExtender.buildCreateTableQuery | protected function buildCreateTableQuery($name, $struture, $charsetCollate)
{
$total = $this->totalQueries();
$this->queries[$total] = "CREATE TABLE `{$name}` ({$struture}) {$charsetCollate};";
} | php | protected function buildCreateTableQuery($name, $struture, $charsetCollate)
{
$total = $this->totalQueries();
$this->queries[$total] = "CREATE TABLE `{$name}` ({$struture}) {$charsetCollate};";
} | [
"protected",
"function",
"buildCreateTableQuery",
"(",
"$",
"name",
",",
"$",
"struture",
",",
"$",
"charsetCollate",
")",
"{",
"$",
"total",
"=",
"$",
"this",
"->",
"totalQueries",
"(",
")",
";",
"$",
"this",
"->",
"queries",
"[",
"$",
"total",
"]",
"=",
"\"CREATE TABLE `{$name}` ({$struture}) {$charsetCollate};\"",
";",
"}"
] | Build a create table query base on the complete details given.
@param string $name The table name with prefix.
@param string $structure The structure of the tables containing columns, etc.
@param string $charsetCollate The character set for the table structure.
@return void | [
"Build",
"a",
"create",
"table",
"query",
"base",
"on",
"the",
"complete",
"details",
"given",
"."
] | train | https://github.com/LordDashMe/wordpress-db-schema-extender/blob/1798435ec064256174b034a16d9683081c0c299f/src/SchemaExtender.php#L382-L387 |
LordDashMe/wordpress-db-schema-extender | src/SchemaExtender.php | SchemaExtender.tableSeed | public function tableSeed($tableName, $callback)
{
if (! is_array($callback) && ! ($callback instanceof \Closure)) {
throw InvalidArgumentPassedException::isNotArrayOrClosure();
}
$this->setTableName($tableName);
// Make sure to flush the old seed query index
// to avoid collision with the new incoming value.
$this->flushSeedQueryIndex();
if ($callback instanceof \Closure) {
$obj = (object) array();
$callback = (array) $callback($obj);
}
$seeds = array();
foreach ($callback as $column => $value) {
$seeds[$column] = $value;
}
$this->setSeedQueryIndex($this->totalSeedQueries());
$this->setSeedQuery('table', $this->getTableNamePrefix($this->getTableName()));
$this->setSeedQuery('record', $seeds);
return $this;
} | php | public function tableSeed($tableName, $callback)
{
if (! is_array($callback) && ! ($callback instanceof \Closure)) {
throw InvalidArgumentPassedException::isNotArrayOrClosure();
}
$this->setTableName($tableName);
// Make sure to flush the old seed query index
// to avoid collision with the new incoming value.
$this->flushSeedQueryIndex();
if ($callback instanceof \Closure) {
$obj = (object) array();
$callback = (array) $callback($obj);
}
$seeds = array();
foreach ($callback as $column => $value) {
$seeds[$column] = $value;
}
$this->setSeedQueryIndex($this->totalSeedQueries());
$this->setSeedQuery('table', $this->getTableNamePrefix($this->getTableName()));
$this->setSeedQuery('record', $seeds);
return $this;
} | [
"public",
"function",
"tableSeed",
"(",
"$",
"tableName",
",",
"$",
"callback",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"callback",
")",
"&&",
"!",
"(",
"$",
"callback",
"instanceof",
"\\",
"Closure",
")",
")",
"{",
"throw",
"InvalidArgumentPassedException",
"::",
"isNotArrayOrClosure",
"(",
")",
";",
"}",
"$",
"this",
"->",
"setTableName",
"(",
"$",
"tableName",
")",
";",
"// Make sure to flush the old seed query index",
"// to avoid collision with the new incoming value.",
"$",
"this",
"->",
"flushSeedQueryIndex",
"(",
")",
";",
"if",
"(",
"$",
"callback",
"instanceof",
"\\",
"Closure",
")",
"{",
"$",
"obj",
"=",
"(",
"object",
")",
"array",
"(",
")",
";",
"$",
"callback",
"=",
"(",
"array",
")",
"$",
"callback",
"(",
"$",
"obj",
")",
";",
"}",
"$",
"seeds",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"callback",
"as",
"$",
"column",
"=>",
"$",
"value",
")",
"{",
"$",
"seeds",
"[",
"$",
"column",
"]",
"=",
"$",
"value",
";",
"}",
"$",
"this",
"->",
"setSeedQueryIndex",
"(",
"$",
"this",
"->",
"totalSeedQueries",
"(",
")",
")",
";",
"$",
"this",
"->",
"setSeedQuery",
"(",
"'table'",
",",
"$",
"this",
"->",
"getTableNamePrefix",
"(",
"$",
"this",
"->",
"getTableName",
"(",
")",
")",
")",
";",
"$",
"this",
"->",
"setSeedQuery",
"(",
"'record'",
",",
"$",
"seeds",
")",
";",
"return",
"$",
"this",
";",
"}"
] | The composer for seeding the given table name.
@param string $tableName
@param array|\Closure $callback
@throws LordDashMe\Wordpress\DB\Exception\InvalidArgumentPassed
@return $this | [
"The",
"composer",
"for",
"seeding",
"the",
"given",
"table",
"name",
"."
] | train | https://github.com/LordDashMe/wordpress-db-schema-extender/blob/1798435ec064256174b034a16d9683081c0c299f/src/SchemaExtender.php#L399-L426 |
LordDashMe/wordpress-db-schema-extender | src/SchemaExtender.php | SchemaExtender.iterate | public function iterate($counter)
{
if (! \is_numeric($counter)) {
throw InvalidArgumentPassedException::isNotNumeric();
}
$this->setSeedQuery('iterate', \round($counter));
} | php | public function iterate($counter)
{
if (! \is_numeric($counter)) {
throw InvalidArgumentPassedException::isNotNumeric();
}
$this->setSeedQuery('iterate', \round($counter));
} | [
"public",
"function",
"iterate",
"(",
"$",
"counter",
")",
"{",
"if",
"(",
"!",
"\\",
"is_numeric",
"(",
"$",
"counter",
")",
")",
"{",
"throw",
"InvalidArgumentPassedException",
"::",
"isNotNumeric",
"(",
")",
";",
"}",
"$",
"this",
"->",
"setSeedQuery",
"(",
"'iterate'",
",",
"\\",
"round",
"(",
"$",
"counter",
")",
")",
";",
"}"
] | The repetition that will apply for the given record.
@param int $counter Total number of repetition for the given record.
@throws LordDashMe\Wordpress\DB\Exception\InvalidArgumentPassed
@return void | [
"The",
"repetition",
"that",
"will",
"apply",
"for",
"the",
"given",
"record",
"."
] | train | https://github.com/LordDashMe/wordpress-db-schema-extender/blob/1798435ec064256174b034a16d9683081c0c299f/src/SchemaExtender.php#L437-L444 |
LordDashMe/wordpress-db-schema-extender | src/SchemaExtender.php | SchemaExtender.rawQuery | public function rawQuery($query = '')
{
if (! \is_string($query)) {
throw InvalidArgumentPassedException::isNotString();
}
$total = $this->totalQueries();
$this->queries[$total] = \trim($query);
} | php | public function rawQuery($query = '')
{
if (! \is_string($query)) {
throw InvalidArgumentPassedException::isNotString();
}
$total = $this->totalQueries();
$this->queries[$total] = \trim($query);
} | [
"public",
"function",
"rawQuery",
"(",
"$",
"query",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"\\",
"is_string",
"(",
"$",
"query",
")",
")",
"{",
"throw",
"InvalidArgumentPassedException",
"::",
"isNotString",
"(",
")",
";",
"}",
"$",
"total",
"=",
"$",
"this",
"->",
"totalQueries",
"(",
")",
";",
"$",
"this",
"->",
"queries",
"[",
"$",
"total",
"]",
"=",
"\\",
"trim",
"(",
"$",
"query",
")",
";",
"}"
] | Allow to compose raw database query.
@param string $query
@throws LordDashMe\Wordpress\DB\Exception\InvalidArgumentPassed
@return void | [
"Allow",
"to",
"compose",
"raw",
"database",
"query",
"."
] | train | https://github.com/LordDashMe/wordpress-db-schema-extender/blob/1798435ec064256174b034a16d9683081c0c299f/src/SchemaExtender.php#L455-L464 |
LordDashMe/wordpress-db-schema-extender | src/SchemaExtender.php | SchemaExtender.processQueries | protected function processQueries()
{
if (! \function_exists('dbDelta')) {
throw WPDatabaseUpdateFunctionsNotFoundException::dbDeltaIsNotExist();
}
$queries = '';
foreach ($this->getQueries() as $index => $query) {
$queries .= \trim($query);
}
\dbDelta($queries);
} | php | protected function processQueries()
{
if (! \function_exists('dbDelta')) {
throw WPDatabaseUpdateFunctionsNotFoundException::dbDeltaIsNotExist();
}
$queries = '';
foreach ($this->getQueries() as $index => $query) {
$queries .= \trim($query);
}
\dbDelta($queries);
} | [
"protected",
"function",
"processQueries",
"(",
")",
"{",
"if",
"(",
"!",
"\\",
"function_exists",
"(",
"'dbDelta'",
")",
")",
"{",
"throw",
"WPDatabaseUpdateFunctionsNotFoundException",
"::",
"dbDeltaIsNotExist",
"(",
")",
";",
"}",
"$",
"queries",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"getQueries",
"(",
")",
"as",
"$",
"index",
"=>",
"$",
"query",
")",
"{",
"$",
"queries",
".=",
"\\",
"trim",
"(",
"$",
"query",
")",
";",
"}",
"\\",
"dbDelta",
"(",
"$",
"queries",
")",
";",
"}"
] | Process the queries using the wordpress "dbDelta".
This function is tightly coupled to the wordpress "dbDelta".
@return void | [
"Process",
"the",
"queries",
"using",
"the",
"wordpress",
"dbDelta",
".",
"This",
"function",
"is",
"tightly",
"coupled",
"to",
"the",
"wordpress",
"dbDelta",
"."
] | train | https://github.com/LordDashMe/wordpress-db-schema-extender/blob/1798435ec064256174b034a16d9683081c0c299f/src/SchemaExtender.php#L485-L498 |
LordDashMe/wordpress-db-schema-extender | src/SchemaExtender.php | SchemaExtender.processTableSeeds | protected function processTableSeeds()
{
foreach ($this->getSeedQueries() as $index => $query) {
if (isset($query['iterate'])) {
for ($x = 1; $x <= $query['iterate']; $x++) {
$this->db->insert($query['table'], $query['record']);
}
continue;
}
$this->db->insert($query['table'], $query['record']);
}
} | php | protected function processTableSeeds()
{
foreach ($this->getSeedQueries() as $index => $query) {
if (isset($query['iterate'])) {
for ($x = 1; $x <= $query['iterate']; $x++) {
$this->db->insert($query['table'], $query['record']);
}
continue;
}
$this->db->insert($query['table'], $query['record']);
}
} | [
"protected",
"function",
"processTableSeeds",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getSeedQueries",
"(",
")",
"as",
"$",
"index",
"=>",
"$",
"query",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"query",
"[",
"'iterate'",
"]",
")",
")",
"{",
"for",
"(",
"$",
"x",
"=",
"1",
";",
"$",
"x",
"<=",
"$",
"query",
"[",
"'iterate'",
"]",
";",
"$",
"x",
"++",
")",
"{",
"$",
"this",
"->",
"db",
"->",
"insert",
"(",
"$",
"query",
"[",
"'table'",
"]",
",",
"$",
"query",
"[",
"'record'",
"]",
")",
";",
"}",
"continue",
";",
"}",
"$",
"this",
"->",
"db",
"->",
"insert",
"(",
"$",
"query",
"[",
"'table'",
"]",
",",
"$",
"query",
"[",
"'record'",
"]",
")",
";",
"}",
"}"
] | Process the seed queries using the wordpress database "insert".
@return void | [
"Process",
"the",
"seed",
"queries",
"using",
"the",
"wordpress",
"database",
"insert",
"."
] | train | https://github.com/LordDashMe/wordpress-db-schema-extender/blob/1798435ec064256174b034a16d9683081c0c299f/src/SchemaExtender.php#L505-L518 |
LordDashMe/wordpress-db-schema-extender | src/SchemaExtender.php | SchemaExtender.dropTable | public function dropTable($tableName)
{
$this->db->query('SET FOREIGN_KEY_CHECKS = 0;');
$this->db->query("DROP TABLE IF EXISTS `{$this->getTableNamePrefix($tableName)}`;");
$this->db->query('SET FOREIGN_KEY_CHECKS = 1;');
} | php | public function dropTable($tableName)
{
$this->db->query('SET FOREIGN_KEY_CHECKS = 0;');
$this->db->query("DROP TABLE IF EXISTS `{$this->getTableNamePrefix($tableName)}`;");
$this->db->query('SET FOREIGN_KEY_CHECKS = 1;');
} | [
"public",
"function",
"dropTable",
"(",
"$",
"tableName",
")",
"{",
"$",
"this",
"->",
"db",
"->",
"query",
"(",
"'SET FOREIGN_KEY_CHECKS = 0;'",
")",
";",
"$",
"this",
"->",
"db",
"->",
"query",
"(",
"\"DROP TABLE IF EXISTS `{$this->getTableNamePrefix($tableName)}`;\"",
")",
";",
"$",
"this",
"->",
"db",
"->",
"query",
"(",
"'SET FOREIGN_KEY_CHECKS = 1;'",
")",
";",
"}"
] | Process the drop table base on the given table name.
Foreign key checks disable before processing the drop action and
enable it back again after the process.
@param string $tableName
@return void | [
"Process",
"the",
"drop",
"table",
"base",
"on",
"the",
"given",
"table",
"name",
".",
"Foreign",
"key",
"checks",
"disable",
"before",
"processing",
"the",
"drop",
"action",
"and",
"enable",
"it",
"back",
"again",
"after",
"the",
"process",
"."
] | train | https://github.com/LordDashMe/wordpress-db-schema-extender/blob/1798435ec064256174b034a16d9683081c0c299f/src/SchemaExtender.php#L529-L534 |
inhere/php-librarys | src/Helpers/JsonHelper.php | JsonHelper.encode | public static function encode($data): string
{
if (PHP_VERSION_ID >= 50400) {
return json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
}
return json_encode($data);
} | php | public static function encode($data): string
{
if (PHP_VERSION_ID >= 50400) {
return json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
}
return json_encode($data);
} | [
"public",
"static",
"function",
"encode",
"(",
"$",
"data",
")",
":",
"string",
"{",
"if",
"(",
"PHP_VERSION_ID",
">=",
"50400",
")",
"{",
"return",
"json_encode",
"(",
"$",
"data",
",",
"JSON_UNESCAPED_SLASHES",
"|",
"JSON_UNESCAPED_UNICODE",
")",
";",
"}",
"return",
"json_encode",
"(",
"$",
"data",
")",
";",
"}"
] | encode data to json
@param $data
@return string | [
"encode",
"data",
"to",
"json"
] | train | https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/JsonHelper.php#L24-L31 |
dragonmantank/fillet | src/Fillet/Fillet.php | Fillet.parse | public function parse()
{
foreach($this->parser->parse($this->inputFile) as $item) {
$writer = WriterFactory::create($item['type'], $this->config);
if($writer) {
$writer->write($item);
}
}
} | php | public function parse()
{
foreach($this->parser->parse($this->inputFile) as $item) {
$writer = WriterFactory::create($item['type'], $this->config);
if($writer) {
$writer->write($item);
}
}
} | [
"public",
"function",
"parse",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"parser",
"->",
"parse",
"(",
"$",
"this",
"->",
"inputFile",
")",
"as",
"$",
"item",
")",
"{",
"$",
"writer",
"=",
"WriterFactory",
"::",
"create",
"(",
"$",
"item",
"[",
"'type'",
"]",
",",
"$",
"this",
"->",
"config",
")",
";",
"if",
"(",
"$",
"writer",
")",
"{",
"$",
"writer",
"->",
"write",
"(",
"$",
"item",
")",
";",
"}",
"}",
"}"
] | Calls the parser and generates the files
@throws \Exception | [
"Calls",
"the",
"parser",
"and",
"generates",
"the",
"files"
] | train | https://github.com/dragonmantank/fillet/blob/b197947608c05ac2318e8f6b296345494004d9c6/src/Fillet/Fillet.php#L53-L62 |
dave-redfern/laravel-doctrine-entity-audit | src/ServiceProvider.php | ServiceProvider.register | public function register()
{
$this->mergeConfig();
/** @var Repository $config */
$config = $this->app->make('config');
$this->registerCoreServices($config);
$this->registerEntityAuditConfigurations($config);
} | php | public function register()
{
$this->mergeConfig();
/** @var Repository $config */
$config = $this->app->make('config');
$this->registerCoreServices($config);
$this->registerEntityAuditConfigurations($config);
} | [
"public",
"function",
"register",
"(",
")",
"{",
"$",
"this",
"->",
"mergeConfig",
"(",
")",
";",
"/** @var Repository $config */",
"$",
"config",
"=",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"'config'",
")",
";",
"$",
"this",
"->",
"registerCoreServices",
"(",
"$",
"config",
")",
";",
"$",
"this",
"->",
"registerEntityAuditConfigurations",
"(",
"$",
"config",
")",
";",
"}"
] | Register the service provider.
@return void | [
"Register",
"the",
"service",
"provider",
"."
] | train | https://github.com/dave-redfern/laravel-doctrine-entity-audit/blob/ab79e305fe512ceefbc14d585fefe0a40cf911ab/src/ServiceProvider.php#L56-L65 |
dave-redfern/laravel-doctrine-entity-audit | src/ServiceProvider.php | ServiceProvider.registerCoreServices | protected function registerCoreServices(Repository $config)
{
$this->app->singleton(AuditRegistry::class, function () {
return new AuditRegistry();
});
$this->app->alias(AuditRegistry::class, 'entity_audit.registry');
} | php | protected function registerCoreServices(Repository $config)
{
$this->app->singleton(AuditRegistry::class, function () {
return new AuditRegistry();
});
$this->app->alias(AuditRegistry::class, 'entity_audit.registry');
} | [
"protected",
"function",
"registerCoreServices",
"(",
"Repository",
"$",
"config",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"AuditRegistry",
"::",
"class",
",",
"function",
"(",
")",
"{",
"return",
"new",
"AuditRegistry",
"(",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"app",
"->",
"alias",
"(",
"AuditRegistry",
"::",
"class",
",",
"'entity_audit.registry'",
")",
";",
"}"
] | Registers the core Tenant services
@param Repository $config
@return void | [
"Registers",
"the",
"core",
"Tenant",
"services"
] | train | https://github.com/dave-redfern/laravel-doctrine-entity-audit/blob/ab79e305fe512ceefbc14d585fefe0a40cf911ab/src/ServiceProvider.php#L84-L90 |
dave-redfern/laravel-doctrine-entity-audit | src/ServiceProvider.php | ServiceProvider.registerEntityAuditConfigurations | protected function registerEntityAuditConfigurations(Repository $config)
{
$this->app->afterResolving(IlluminateRegistry::class, function ($registry) use ($config) {
$table = $config->get('entity_audit.global.table');
$users = $config->get('entity_audit.global.username_for');
$columns = $config->get('entity_audit.global.ignore_columns');
$auditRegistry = $this->app->make(AuditRegistry::class);
foreach ($config->get('entity_audit.entity_managers', []) as $emName => $emConfig) {
$users = array_merge($users, data_get($emConfig, 'username_for', []));
$metadata = new MetadataFactory(data_get($emConfig, 'entities', []));
$auditConfig = new AuditConfiguration(
new UserResolver(
$this->app->make(Guard::class),
$users['unknown_authenticated_user'],
$users['unknown_unauthenticated_user']
),
new TableConfiguration(array_merge($table, data_get($emConfig, 'table', []))),
data_get($emConfig, 'ignore_columns', $columns)
);
/** @var IlluminateRegistry $registry */
/** @var EntityManager $em */
$em = $registry->getManager($emName);
$reader = new AuditReader($em, $auditConfig, $metadata);
$manager = new AuditManager($auditConfig, $metadata, $reader);
$em->getEventManager()->addEventSubscriber(new CreateSchemaListener($manager));
$em->getEventManager()->addEventSubscriber(new LogRevisionsListener($manager));
$auditRegistry->add($emName, $manager);
$this->app->instance(sprintf('entity_audit.%s.manager', $emName), $manager);
$this->app->instance(sprintf('entity_audit.%s.reader', $emName), $reader);
}
});
} | php | protected function registerEntityAuditConfigurations(Repository $config)
{
$this->app->afterResolving(IlluminateRegistry::class, function ($registry) use ($config) {
$table = $config->get('entity_audit.global.table');
$users = $config->get('entity_audit.global.username_for');
$columns = $config->get('entity_audit.global.ignore_columns');
$auditRegistry = $this->app->make(AuditRegistry::class);
foreach ($config->get('entity_audit.entity_managers', []) as $emName => $emConfig) {
$users = array_merge($users, data_get($emConfig, 'username_for', []));
$metadata = new MetadataFactory(data_get($emConfig, 'entities', []));
$auditConfig = new AuditConfiguration(
new UserResolver(
$this->app->make(Guard::class),
$users['unknown_authenticated_user'],
$users['unknown_unauthenticated_user']
),
new TableConfiguration(array_merge($table, data_get($emConfig, 'table', []))),
data_get($emConfig, 'ignore_columns', $columns)
);
/** @var IlluminateRegistry $registry */
/** @var EntityManager $em */
$em = $registry->getManager($emName);
$reader = new AuditReader($em, $auditConfig, $metadata);
$manager = new AuditManager($auditConfig, $metadata, $reader);
$em->getEventManager()->addEventSubscriber(new CreateSchemaListener($manager));
$em->getEventManager()->addEventSubscriber(new LogRevisionsListener($manager));
$auditRegistry->add($emName, $manager);
$this->app->instance(sprintf('entity_audit.%s.manager', $emName), $manager);
$this->app->instance(sprintf('entity_audit.%s.reader', $emName), $reader);
}
});
} | [
"protected",
"function",
"registerEntityAuditConfigurations",
"(",
"Repository",
"$",
"config",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"afterResolving",
"(",
"IlluminateRegistry",
"::",
"class",
",",
"function",
"(",
"$",
"registry",
")",
"use",
"(",
"$",
"config",
")",
"{",
"$",
"table",
"=",
"$",
"config",
"->",
"get",
"(",
"'entity_audit.global.table'",
")",
";",
"$",
"users",
"=",
"$",
"config",
"->",
"get",
"(",
"'entity_audit.global.username_for'",
")",
";",
"$",
"columns",
"=",
"$",
"config",
"->",
"get",
"(",
"'entity_audit.global.ignore_columns'",
")",
";",
"$",
"auditRegistry",
"=",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"AuditRegistry",
"::",
"class",
")",
";",
"foreach",
"(",
"$",
"config",
"->",
"get",
"(",
"'entity_audit.entity_managers'",
",",
"[",
"]",
")",
"as",
"$",
"emName",
"=>",
"$",
"emConfig",
")",
"{",
"$",
"users",
"=",
"array_merge",
"(",
"$",
"users",
",",
"data_get",
"(",
"$",
"emConfig",
",",
"'username_for'",
",",
"[",
"]",
")",
")",
";",
"$",
"metadata",
"=",
"new",
"MetadataFactory",
"(",
"data_get",
"(",
"$",
"emConfig",
",",
"'entities'",
",",
"[",
"]",
")",
")",
";",
"$",
"auditConfig",
"=",
"new",
"AuditConfiguration",
"(",
"new",
"UserResolver",
"(",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"Guard",
"::",
"class",
")",
",",
"$",
"users",
"[",
"'unknown_authenticated_user'",
"]",
",",
"$",
"users",
"[",
"'unknown_unauthenticated_user'",
"]",
")",
",",
"new",
"TableConfiguration",
"(",
"array_merge",
"(",
"$",
"table",
",",
"data_get",
"(",
"$",
"emConfig",
",",
"'table'",
",",
"[",
"]",
")",
")",
")",
",",
"data_get",
"(",
"$",
"emConfig",
",",
"'ignore_columns'",
",",
"$",
"columns",
")",
")",
";",
"/** @var IlluminateRegistry $registry */",
"/** @var EntityManager $em */",
"$",
"em",
"=",
"$",
"registry",
"->",
"getManager",
"(",
"$",
"emName",
")",
";",
"$",
"reader",
"=",
"new",
"AuditReader",
"(",
"$",
"em",
",",
"$",
"auditConfig",
",",
"$",
"metadata",
")",
";",
"$",
"manager",
"=",
"new",
"AuditManager",
"(",
"$",
"auditConfig",
",",
"$",
"metadata",
",",
"$",
"reader",
")",
";",
"$",
"em",
"->",
"getEventManager",
"(",
")",
"->",
"addEventSubscriber",
"(",
"new",
"CreateSchemaListener",
"(",
"$",
"manager",
")",
")",
";",
"$",
"em",
"->",
"getEventManager",
"(",
")",
"->",
"addEventSubscriber",
"(",
"new",
"LogRevisionsListener",
"(",
"$",
"manager",
")",
")",
";",
"$",
"auditRegistry",
"->",
"add",
"(",
"$",
"emName",
",",
"$",
"manager",
")",
";",
"$",
"this",
"->",
"app",
"->",
"instance",
"(",
"sprintf",
"(",
"'entity_audit.%s.manager'",
",",
"$",
"emName",
")",
",",
"$",
"manager",
")",
";",
"$",
"this",
"->",
"app",
"->",
"instance",
"(",
"sprintf",
"(",
"'entity_audit.%s.reader'",
",",
"$",
"emName",
")",
",",
"$",
"reader",
")",
";",
"}",
"}",
")",
";",
"}"
] | Registers auditing to the specified entity managers
@param Repository $config
@return void | [
"Registers",
"auditing",
"to",
"the",
"specified",
"entity",
"managers"
] | train | https://github.com/dave-redfern/laravel-doctrine-entity-audit/blob/ab79e305fe512ceefbc14d585fefe0a40cf911ab/src/ServiceProvider.php#L99-L134 |
digipolisgent/robo-digipolis-general | src/ReadProperties.php | ReadProperties.run | public function run()
{
try {
$this->finder->in($this->dirs)->files();
$defaults = clone $this->finder;
$packageOverrides = clone $this->finder;
$projectConfig = [];
// Get the property overrides for this project.
$root = $this->getConfig()->get('digipolis.root.project', false);
if ($root && file_exists($root . '/properties.yml')) {
$this->printTaskInfo(
sprintf(
'Parsing config from %s.',
$root . '/properties.yml'
)
);
$contents = file_get_contents($root . '/properties.yml');
$this->printTaskDebug(sprintf('Parsing %s', $contents));
$projectConfig = Yaml::parse($contents);
}
$parsedConfig = Expander::expandArrayProperties(
\Ckr\Util\ArrayMerger::doMerge(
\Ckr\Util\ArrayMerger::doMerge(
// Get the default properties.
$this->parseConfigFiles($defaults->name('default.properties.yml')),
// Get the property overrides for robo packages.
$this->parseConfigFiles($packageOverrides->name('properties.yml'))
),
// Add the project overrides last.
$projectConfig
)
);
$this->printTaskDebug(sprintf('Resulted config: %s', print_r($parsedConfig, true)));
// Save the settings to config.
$config = $this->getConfig();
foreach ($parsedConfig as $key => $value) {
$config->set($key, $value);
}
} catch (\Exception $exception) {
return Result::fromException($this, $exception);
}
return Result::success($this, 'Parsed all config.');
} | php | public function run()
{
try {
$this->finder->in($this->dirs)->files();
$defaults = clone $this->finder;
$packageOverrides = clone $this->finder;
$projectConfig = [];
// Get the property overrides for this project.
$root = $this->getConfig()->get('digipolis.root.project', false);
if ($root && file_exists($root . '/properties.yml')) {
$this->printTaskInfo(
sprintf(
'Parsing config from %s.',
$root . '/properties.yml'
)
);
$contents = file_get_contents($root . '/properties.yml');
$this->printTaskDebug(sprintf('Parsing %s', $contents));
$projectConfig = Yaml::parse($contents);
}
$parsedConfig = Expander::expandArrayProperties(
\Ckr\Util\ArrayMerger::doMerge(
\Ckr\Util\ArrayMerger::doMerge(
// Get the default properties.
$this->parseConfigFiles($defaults->name('default.properties.yml')),
// Get the property overrides for robo packages.
$this->parseConfigFiles($packageOverrides->name('properties.yml'))
),
// Add the project overrides last.
$projectConfig
)
);
$this->printTaskDebug(sprintf('Resulted config: %s', print_r($parsedConfig, true)));
// Save the settings to config.
$config = $this->getConfig();
foreach ($parsedConfig as $key => $value) {
$config->set($key, $value);
}
} catch (\Exception $exception) {
return Result::fromException($this, $exception);
}
return Result::success($this, 'Parsed all config.');
} | [
"public",
"function",
"run",
"(",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"finder",
"->",
"in",
"(",
"$",
"this",
"->",
"dirs",
")",
"->",
"files",
"(",
")",
";",
"$",
"defaults",
"=",
"clone",
"$",
"this",
"->",
"finder",
";",
"$",
"packageOverrides",
"=",
"clone",
"$",
"this",
"->",
"finder",
";",
"$",
"projectConfig",
"=",
"[",
"]",
";",
"// Get the property overrides for this project.",
"$",
"root",
"=",
"$",
"this",
"->",
"getConfig",
"(",
")",
"->",
"get",
"(",
"'digipolis.root.project'",
",",
"false",
")",
";",
"if",
"(",
"$",
"root",
"&&",
"file_exists",
"(",
"$",
"root",
".",
"'/properties.yml'",
")",
")",
"{",
"$",
"this",
"->",
"printTaskInfo",
"(",
"sprintf",
"(",
"'Parsing config from %s.'",
",",
"$",
"root",
".",
"'/properties.yml'",
")",
")",
";",
"$",
"contents",
"=",
"file_get_contents",
"(",
"$",
"root",
".",
"'/properties.yml'",
")",
";",
"$",
"this",
"->",
"printTaskDebug",
"(",
"sprintf",
"(",
"'Parsing %s'",
",",
"$",
"contents",
")",
")",
";",
"$",
"projectConfig",
"=",
"Yaml",
"::",
"parse",
"(",
"$",
"contents",
")",
";",
"}",
"$",
"parsedConfig",
"=",
"Expander",
"::",
"expandArrayProperties",
"(",
"\\",
"Ckr",
"\\",
"Util",
"\\",
"ArrayMerger",
"::",
"doMerge",
"(",
"\\",
"Ckr",
"\\",
"Util",
"\\",
"ArrayMerger",
"::",
"doMerge",
"(",
"// Get the default properties.",
"$",
"this",
"->",
"parseConfigFiles",
"(",
"$",
"defaults",
"->",
"name",
"(",
"'default.properties.yml'",
")",
")",
",",
"// Get the property overrides for robo packages.",
"$",
"this",
"->",
"parseConfigFiles",
"(",
"$",
"packageOverrides",
"->",
"name",
"(",
"'properties.yml'",
")",
")",
")",
",",
"// Add the project overrides last.",
"$",
"projectConfig",
")",
")",
";",
"$",
"this",
"->",
"printTaskDebug",
"(",
"sprintf",
"(",
"'Resulted config: %s'",
",",
"print_r",
"(",
"$",
"parsedConfig",
",",
"true",
")",
")",
")",
";",
"// Save the settings to config.",
"$",
"config",
"=",
"$",
"this",
"->",
"getConfig",
"(",
")",
";",
"foreach",
"(",
"$",
"parsedConfig",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"config",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"exception",
")",
"{",
"return",
"Result",
"::",
"fromException",
"(",
"$",
"this",
",",
"$",
"exception",
")",
";",
"}",
"return",
"Result",
"::",
"success",
"(",
"$",
"this",
",",
"'Parsed all config.'",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/digipolisgent/robo-digipolis-general/blob/66f0806c9ed7bd4e5aaf3f57ae1363f6aaae7cd9/src/ReadProperties.php#L98-L144 |
digipolisgent/robo-digipolis-general | src/ReadProperties.php | ReadProperties.parseConfigFiles | protected function parseConfigFiles(Finder $files)
{
$config = [];
foreach ($files as $file) {
// Check if this is part of a Robo package.
$path = $file->getRealPath();
if (!file_exists(dirname($path) . '/RoboFile.php')) {
continue;
}
$this->printTaskInfo(sprintf('Parsing config from %s.', $path));
$contents = file_get_contents($path);
$this->printTaskDebug(sprintf('Parsing %s', $contents));
$config += Yaml::parse($contents);
}
return $config;
} | php | protected function parseConfigFiles(Finder $files)
{
$config = [];
foreach ($files as $file) {
// Check if this is part of a Robo package.
$path = $file->getRealPath();
if (!file_exists(dirname($path) . '/RoboFile.php')) {
continue;
}
$this->printTaskInfo(sprintf('Parsing config from %s.', $path));
$contents = file_get_contents($path);
$this->printTaskDebug(sprintf('Parsing %s', $contents));
$config += Yaml::parse($contents);
}
return $config;
} | [
"protected",
"function",
"parseConfigFiles",
"(",
"Finder",
"$",
"files",
")",
"{",
"$",
"config",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"// Check if this is part of a Robo package.",
"$",
"path",
"=",
"$",
"file",
"->",
"getRealPath",
"(",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"dirname",
"(",
"$",
"path",
")",
".",
"'/RoboFile.php'",
")",
")",
"{",
"continue",
";",
"}",
"$",
"this",
"->",
"printTaskInfo",
"(",
"sprintf",
"(",
"'Parsing config from %s.'",
",",
"$",
"path",
")",
")",
";",
"$",
"contents",
"=",
"file_get_contents",
"(",
"$",
"path",
")",
";",
"$",
"this",
"->",
"printTaskDebug",
"(",
"sprintf",
"(",
"'Parsing %s'",
",",
"$",
"contents",
")",
")",
";",
"$",
"config",
"+=",
"Yaml",
"::",
"parse",
"(",
"$",
"contents",
")",
";",
"}",
"return",
"$",
"config",
";",
"}"
] | Helper function to parse config files.
@param \Symfony\Component\Finder\Finder $files
The files to parse.
@return array
The parsed config. | [
"Helper",
"function",
"to",
"parse",
"config",
"files",
"."
] | train | https://github.com/digipolisgent/robo-digipolis-general/blob/66f0806c9ed7bd4e5aaf3f57ae1363f6aaae7cd9/src/ReadProperties.php#L155-L170 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/validators/types.php | ezcDbSchemaTypesValidator.validate | static public function validate( ezcDbSchema $schema )
{
$errors = array();
/* For each table we check all field's types. */
foreach ( $schema->getSchema() as $tableName => $table )
{
foreach ( $table->fields as $fieldName => $field )
{
if ( !in_array( $field->type, ezcDbSchema::$supportedTypes ) )
{
$errors[] = "Field '$tableName:$fieldName' uses the unsupported type '{$field->type}'.";
}
}
}
return $errors;
} | php | static public function validate( ezcDbSchema $schema )
{
$errors = array();
/* For each table we check all field's types. */
foreach ( $schema->getSchema() as $tableName => $table )
{
foreach ( $table->fields as $fieldName => $field )
{
if ( !in_array( $field->type, ezcDbSchema::$supportedTypes ) )
{
$errors[] = "Field '$tableName:$fieldName' uses the unsupported type '{$field->type}'.";
}
}
}
return $errors;
} | [
"static",
"public",
"function",
"validate",
"(",
"ezcDbSchema",
"$",
"schema",
")",
"{",
"$",
"errors",
"=",
"array",
"(",
")",
";",
"/* For each table we check all field's types. */",
"foreach",
"(",
"$",
"schema",
"->",
"getSchema",
"(",
")",
"as",
"$",
"tableName",
"=>",
"$",
"table",
")",
"{",
"foreach",
"(",
"$",
"table",
"->",
"fields",
"as",
"$",
"fieldName",
"=>",
"$",
"field",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"field",
"->",
"type",
",",
"ezcDbSchema",
"::",
"$",
"supportedTypes",
")",
")",
"{",
"$",
"errors",
"[",
"]",
"=",
"\"Field '$tableName:$fieldName' uses the unsupported type '{$field->type}'.\"",
";",
"}",
"}",
"}",
"return",
"$",
"errors",
";",
"}"
] | Validates if all the types used in the $schema are supported.
This method loops over all the fields in a table and checks whether the
type that is used for each field is supported. It will return an array
containing error strings for each non-supported type that it finds.
@param ezcDbSchema $schema
@return array(string) | [
"Validates",
"if",
"all",
"the",
"types",
"used",
"in",
"the",
"$schema",
"are",
"supported",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/validators/types.php#L30-L47 |
xiewulong/yii2-fileupload | oss/libs/guzzle/http/Guzzle/Http/QueryString.php | QueryString.fromString | public static function fromString($query)
{
$q = new static();
if ($query || $query === '0') {
if ($query[0] == '?') {
$query = substr($query, 1);
}
foreach (explode('&', $query) as $kvp) {
$parts = explode('=', $kvp, 2);
$key = rawurldecode($parts[0]);
if ($paramIsPhpStyleArray = substr($key, -2) == '[]') {
$key = substr($key, 0, -2);
}
if (isset($parts[1])) {
$value = rawurldecode(str_replace('+', '%20', $parts[1]));
if ($paramIsPhpStyleArray && !$q->hasKey($key)) {
$value = array($value);
}
$q->add($key, $value);
} else {
$q->add($key, null);
}
}
}
return $q;
} | php | public static function fromString($query)
{
$q = new static();
if ($query || $query === '0') {
if ($query[0] == '?') {
$query = substr($query, 1);
}
foreach (explode('&', $query) as $kvp) {
$parts = explode('=', $kvp, 2);
$key = rawurldecode($parts[0]);
if ($paramIsPhpStyleArray = substr($key, -2) == '[]') {
$key = substr($key, 0, -2);
}
if (isset($parts[1])) {
$value = rawurldecode(str_replace('+', '%20', $parts[1]));
if ($paramIsPhpStyleArray && !$q->hasKey($key)) {
$value = array($value);
}
$q->add($key, $value);
} else {
$q->add($key, null);
}
}
}
return $q;
} | [
"public",
"static",
"function",
"fromString",
"(",
"$",
"query",
")",
"{",
"$",
"q",
"=",
"new",
"static",
"(",
")",
";",
"if",
"(",
"$",
"query",
"||",
"$",
"query",
"===",
"'0'",
")",
"{",
"if",
"(",
"$",
"query",
"[",
"0",
"]",
"==",
"'?'",
")",
"{",
"$",
"query",
"=",
"substr",
"(",
"$",
"query",
",",
"1",
")",
";",
"}",
"foreach",
"(",
"explode",
"(",
"'&'",
",",
"$",
"query",
")",
"as",
"$",
"kvp",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'='",
",",
"$",
"kvp",
",",
"2",
")",
";",
"$",
"key",
"=",
"rawurldecode",
"(",
"$",
"parts",
"[",
"0",
"]",
")",
";",
"if",
"(",
"$",
"paramIsPhpStyleArray",
"=",
"substr",
"(",
"$",
"key",
",",
"-",
"2",
")",
"==",
"'[]'",
")",
"{",
"$",
"key",
"=",
"substr",
"(",
"$",
"key",
",",
"0",
",",
"-",
"2",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"parts",
"[",
"1",
"]",
")",
")",
"{",
"$",
"value",
"=",
"rawurldecode",
"(",
"str_replace",
"(",
"'+'",
",",
"'%20'",
",",
"$",
"parts",
"[",
"1",
"]",
")",
")",
";",
"if",
"(",
"$",
"paramIsPhpStyleArray",
"&&",
"!",
"$",
"q",
"->",
"hasKey",
"(",
"$",
"key",
")",
")",
"{",
"$",
"value",
"=",
"array",
"(",
"$",
"value",
")",
";",
"}",
"$",
"q",
"->",
"add",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"else",
"{",
"$",
"q",
"->",
"add",
"(",
"$",
"key",
",",
"null",
")",
";",
"}",
"}",
"}",
"return",
"$",
"q",
";",
"}"
] | Parse a query string into a QueryString object
@param string $query Query string to parse
@return self | [
"Parse",
"a",
"query",
"string",
"into",
"a",
"QueryString",
"object"
] | train | https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/guzzle/http/Guzzle/Http/QueryString.php#L45-L74 |
SergioMadness/query-builder | src/abstraction/DeleteBuilder.php | DeleteBuilder.generate | public function generate()
{
$result = '';
$table = $this->buildTable();
$where = $this->buildWhere();
$result .= 'DELETE FROM '.$table;
if ($where != '') {
$result .= ' '.$where;
}
return $result;
} | php | public function generate()
{
$result = '';
$table = $this->buildTable();
$where = $this->buildWhere();
$result .= 'DELETE FROM '.$table;
if ($where != '') {
$result .= ' '.$where;
}
return $result;
} | [
"public",
"function",
"generate",
"(",
")",
"{",
"$",
"result",
"=",
"''",
";",
"$",
"table",
"=",
"$",
"this",
"->",
"buildTable",
"(",
")",
";",
"$",
"where",
"=",
"$",
"this",
"->",
"buildWhere",
"(",
")",
";",
"$",
"result",
".=",
"'DELETE FROM '",
".",
"$",
"table",
";",
"if",
"(",
"$",
"where",
"!=",
"''",
")",
"{",
"$",
"result",
".=",
"' '",
".",
"$",
"where",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Generate query
@return string | [
"Generate",
"query"
] | train | https://github.com/SergioMadness/query-builder/blob/95b7a46bba4c4d369101c6f0d37f133fecb3956d/src/abstraction/DeleteBuilder.php#L27-L41 |
odiaseo/pagebuilder | src/PageBuilder/Model/ThemeModel.php | ThemeModel.getActiveTheme | public function getActiveTheme($siteId)
{
$manager = $this->getEntityManager();
$query = $manager
->createQueryBuilder()
->select('t,s')
->from($this->_entity, 't')
->innerJoin('t.siteThemes', 's')
->where('s.siteId = :id')
->andWhere('s.isActive = 1')
->setParameter(':id', $siteId)
->setMaxResults(1)
->getQuery();
try {
return $query->getSingleResult(AbstractQuery::HYDRATE_OBJECT);
} catch (NoResultException $e) {
return false;
} catch (NonUniqueResultException $e) {
return false;
}
} | php | public function getActiveTheme($siteId)
{
$manager = $this->getEntityManager();
$query = $manager
->createQueryBuilder()
->select('t,s')
->from($this->_entity, 't')
->innerJoin('t.siteThemes', 's')
->where('s.siteId = :id')
->andWhere('s.isActive = 1')
->setParameter(':id', $siteId)
->setMaxResults(1)
->getQuery();
try {
return $query->getSingleResult(AbstractQuery::HYDRATE_OBJECT);
} catch (NoResultException $e) {
return false;
} catch (NonUniqueResultException $e) {
return false;
}
} | [
"public",
"function",
"getActiveTheme",
"(",
"$",
"siteId",
")",
"{",
"$",
"manager",
"=",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
";",
"$",
"query",
"=",
"$",
"manager",
"->",
"createQueryBuilder",
"(",
")",
"->",
"select",
"(",
"'t,s'",
")",
"->",
"from",
"(",
"$",
"this",
"->",
"_entity",
",",
"'t'",
")",
"->",
"innerJoin",
"(",
"'t.siteThemes'",
",",
"'s'",
")",
"->",
"where",
"(",
"'s.siteId = :id'",
")",
"->",
"andWhere",
"(",
"'s.isActive = 1'",
")",
"->",
"setParameter",
"(",
"':id'",
",",
"$",
"siteId",
")",
"->",
"setMaxResults",
"(",
"1",
")",
"->",
"getQuery",
"(",
")",
";",
"try",
"{",
"return",
"$",
"query",
"->",
"getSingleResult",
"(",
"AbstractQuery",
"::",
"HYDRATE_OBJECT",
")",
";",
"}",
"catch",
"(",
"NoResultException",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"catch",
"(",
"NonUniqueResultException",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}"
] | @param $siteId
@return bool|mixed
@throws \Doctrine\ORM\NonUniqueResultException | [
"@param",
"$siteId"
] | train | https://github.com/odiaseo/pagebuilder/blob/88ef7cccf305368561307efe4ca07fac8e5774f3/src/PageBuilder/Model/ThemeModel.php#L21-L42 |
wenbinye/PhalconX | src/Serializer/Serializer.php | Serializer.denormalize | public function denormalize(array $arr, $class)
{
$properties = $this->getClassProperties($class);
$obj = new $class;
foreach ($properties as $name => $prop) {
if (isset($prop['serializeName'])) {
$name = $prop['serializeName'];
}
if (!isset($arr[$name])) {
continue;
}
$value = $arr[$name];
if (isset($prop['type'])) {
if ($prop['type'] === 'array') {
$value = array_map(function ($elem) use ($prop) {
return $this->denormalize($elem, $prop['element']);
}, $value);
} else {
$value = $this->denormalize($value, $prop['type']);
}
}
if (isset($prop['setter'])) {
$setter = $prop['setter'];
$obj->$setter($value);
} else {
$key = $prop['name'];
$obj->$key = $value;
}
}
return $obj;
} | php | public function denormalize(array $arr, $class)
{
$properties = $this->getClassProperties($class);
$obj = new $class;
foreach ($properties as $name => $prop) {
if (isset($prop['serializeName'])) {
$name = $prop['serializeName'];
}
if (!isset($arr[$name])) {
continue;
}
$value = $arr[$name];
if (isset($prop['type'])) {
if ($prop['type'] === 'array') {
$value = array_map(function ($elem) use ($prop) {
return $this->denormalize($elem, $prop['element']);
}, $value);
} else {
$value = $this->denormalize($value, $prop['type']);
}
}
if (isset($prop['setter'])) {
$setter = $prop['setter'];
$obj->$setter($value);
} else {
$key = $prop['name'];
$obj->$key = $value;
}
}
return $obj;
} | [
"public",
"function",
"denormalize",
"(",
"array",
"$",
"arr",
",",
"$",
"class",
")",
"{",
"$",
"properties",
"=",
"$",
"this",
"->",
"getClassProperties",
"(",
"$",
"class",
")",
";",
"$",
"obj",
"=",
"new",
"$",
"class",
";",
"foreach",
"(",
"$",
"properties",
"as",
"$",
"name",
"=>",
"$",
"prop",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"prop",
"[",
"'serializeName'",
"]",
")",
")",
"{",
"$",
"name",
"=",
"$",
"prop",
"[",
"'serializeName'",
"]",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"arr",
"[",
"$",
"name",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"value",
"=",
"$",
"arr",
"[",
"$",
"name",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"prop",
"[",
"'type'",
"]",
")",
")",
"{",
"if",
"(",
"$",
"prop",
"[",
"'type'",
"]",
"===",
"'array'",
")",
"{",
"$",
"value",
"=",
"array_map",
"(",
"function",
"(",
"$",
"elem",
")",
"use",
"(",
"$",
"prop",
")",
"{",
"return",
"$",
"this",
"->",
"denormalize",
"(",
"$",
"elem",
",",
"$",
"prop",
"[",
"'element'",
"]",
")",
";",
"}",
",",
"$",
"value",
")",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"denormalize",
"(",
"$",
"value",
",",
"$",
"prop",
"[",
"'type'",
"]",
")",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"prop",
"[",
"'setter'",
"]",
")",
")",
"{",
"$",
"setter",
"=",
"$",
"prop",
"[",
"'setter'",
"]",
";",
"$",
"obj",
"->",
"$",
"setter",
"(",
"$",
"value",
")",
";",
"}",
"else",
"{",
"$",
"key",
"=",
"$",
"prop",
"[",
"'name'",
"]",
";",
"$",
"obj",
"->",
"$",
"key",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"obj",
";",
"}"
] | Denormalizes data back into an object of the given class. | [
"Denormalizes",
"data",
"back",
"into",
"an",
"object",
"of",
"the",
"given",
"class",
"."
] | train | https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Serializer/Serializer.php#L53-L83 |
wenbinye/PhalconX | src/Serializer/Serializer.php | Serializer.normalize | public function normalize($obj)
{
$properties = $this->getClassProperties(get_class($obj));
$data = [];
foreach ($properties as $name => $prop) {
if (isset($prop['getter'])) {
$getter = $prop['getter'];
$value = $obj->$getter();
} else {
$key = $prop['name'];
$value = $obj->$key;
}
if (isset($prop['type'])) {
if ($prop['type'] === 'array') {
$value = array_map(function ($elem) use ($prop) {
return $this->normalize($elem);
}, $value);
} else {
$value = $this->normalize($value);
}
}
if (isset($prop['serializeName'])) {
$name = $prop['serializeName'];
}
$data[$name] = $value;
}
return $data;
} | php | public function normalize($obj)
{
$properties = $this->getClassProperties(get_class($obj));
$data = [];
foreach ($properties as $name => $prop) {
if (isset($prop['getter'])) {
$getter = $prop['getter'];
$value = $obj->$getter();
} else {
$key = $prop['name'];
$value = $obj->$key;
}
if (isset($prop['type'])) {
if ($prop['type'] === 'array') {
$value = array_map(function ($elem) use ($prop) {
return $this->normalize($elem);
}, $value);
} else {
$value = $this->normalize($value);
}
}
if (isset($prop['serializeName'])) {
$name = $prop['serializeName'];
}
$data[$name] = $value;
}
return $data;
} | [
"public",
"function",
"normalize",
"(",
"$",
"obj",
")",
"{",
"$",
"properties",
"=",
"$",
"this",
"->",
"getClassProperties",
"(",
"get_class",
"(",
"$",
"obj",
")",
")",
";",
"$",
"data",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"properties",
"as",
"$",
"name",
"=>",
"$",
"prop",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"prop",
"[",
"'getter'",
"]",
")",
")",
"{",
"$",
"getter",
"=",
"$",
"prop",
"[",
"'getter'",
"]",
";",
"$",
"value",
"=",
"$",
"obj",
"->",
"$",
"getter",
"(",
")",
";",
"}",
"else",
"{",
"$",
"key",
"=",
"$",
"prop",
"[",
"'name'",
"]",
";",
"$",
"value",
"=",
"$",
"obj",
"->",
"$",
"key",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"prop",
"[",
"'type'",
"]",
")",
")",
"{",
"if",
"(",
"$",
"prop",
"[",
"'type'",
"]",
"===",
"'array'",
")",
"{",
"$",
"value",
"=",
"array_map",
"(",
"function",
"(",
"$",
"elem",
")",
"use",
"(",
"$",
"prop",
")",
"{",
"return",
"$",
"this",
"->",
"normalize",
"(",
"$",
"elem",
")",
";",
"}",
",",
"$",
"value",
")",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"normalize",
"(",
"$",
"value",
")",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"prop",
"[",
"'serializeName'",
"]",
")",
")",
"{",
"$",
"name",
"=",
"$",
"prop",
"[",
"'serializeName'",
"]",
";",
"}",
"$",
"data",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"data",
";",
"}"
] | Normalizes the object into an array of scalars|arrays. | [
"Normalizes",
"the",
"object",
"into",
"an",
"array",
"of",
"scalars|arrays",
"."
] | train | https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Serializer/Serializer.php#L88-L115 |
wenbinye/PhalconX | src/Serializer/Serializer.php | Serializer.getClassProperties | private function getClassProperties($class)
{
$properties = $this->getCache()->get('_PHX.serialze_properties.'. $class);
if (!isset($properties)) {
$classResolver = $this->getClassResolver();
$properties = $this->getReflectionProperties($class);
foreach ($this->getAnnotations()->get($class) as $annotation) {
if ($annotation instanceof IsA) {
$properties[$this->getAnnotationProperty($annotation)]['type']
= $classResolver->resolve($annotation->class, $annotation->getDeclaringClass());
} elseif ($annotation instanceof IsArray && is_scalar($annotation->element)) {
$name = $this->getAnnotationProperty($annotation);
$properties[$name]['type'] = 'array';
$properties[$name]['element']
= $classResolver->resolve($annotation->element, $annotation->getDeclaringClass());
} elseif ($annotation instanceof SerializeName) {
$properties[$this->getAnnotationProperty($annotation)]['serializeName']
= $annotation->value;
}
}
$this->getCache()->save('_PHX.serialze_properties.'.$class, $properties);
}
return $properties;
} | php | private function getClassProperties($class)
{
$properties = $this->getCache()->get('_PHX.serialze_properties.'. $class);
if (!isset($properties)) {
$classResolver = $this->getClassResolver();
$properties = $this->getReflectionProperties($class);
foreach ($this->getAnnotations()->get($class) as $annotation) {
if ($annotation instanceof IsA) {
$properties[$this->getAnnotationProperty($annotation)]['type']
= $classResolver->resolve($annotation->class, $annotation->getDeclaringClass());
} elseif ($annotation instanceof IsArray && is_scalar($annotation->element)) {
$name = $this->getAnnotationProperty($annotation);
$properties[$name]['type'] = 'array';
$properties[$name]['element']
= $classResolver->resolve($annotation->element, $annotation->getDeclaringClass());
} elseif ($annotation instanceof SerializeName) {
$properties[$this->getAnnotationProperty($annotation)]['serializeName']
= $annotation->value;
}
}
$this->getCache()->save('_PHX.serialze_properties.'.$class, $properties);
}
return $properties;
} | [
"private",
"function",
"getClassProperties",
"(",
"$",
"class",
")",
"{",
"$",
"properties",
"=",
"$",
"this",
"->",
"getCache",
"(",
")",
"->",
"get",
"(",
"'_PHX.serialze_properties.'",
".",
"$",
"class",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"properties",
")",
")",
"{",
"$",
"classResolver",
"=",
"$",
"this",
"->",
"getClassResolver",
"(",
")",
";",
"$",
"properties",
"=",
"$",
"this",
"->",
"getReflectionProperties",
"(",
"$",
"class",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getAnnotations",
"(",
")",
"->",
"get",
"(",
"$",
"class",
")",
"as",
"$",
"annotation",
")",
"{",
"if",
"(",
"$",
"annotation",
"instanceof",
"IsA",
")",
"{",
"$",
"properties",
"[",
"$",
"this",
"->",
"getAnnotationProperty",
"(",
"$",
"annotation",
")",
"]",
"[",
"'type'",
"]",
"=",
"$",
"classResolver",
"->",
"resolve",
"(",
"$",
"annotation",
"->",
"class",
",",
"$",
"annotation",
"->",
"getDeclaringClass",
"(",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"annotation",
"instanceof",
"IsArray",
"&&",
"is_scalar",
"(",
"$",
"annotation",
"->",
"element",
")",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"getAnnotationProperty",
"(",
"$",
"annotation",
")",
";",
"$",
"properties",
"[",
"$",
"name",
"]",
"[",
"'type'",
"]",
"=",
"'array'",
";",
"$",
"properties",
"[",
"$",
"name",
"]",
"[",
"'element'",
"]",
"=",
"$",
"classResolver",
"->",
"resolve",
"(",
"$",
"annotation",
"->",
"element",
",",
"$",
"annotation",
"->",
"getDeclaringClass",
"(",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"annotation",
"instanceof",
"SerializeName",
")",
"{",
"$",
"properties",
"[",
"$",
"this",
"->",
"getAnnotationProperty",
"(",
"$",
"annotation",
")",
"]",
"[",
"'serializeName'",
"]",
"=",
"$",
"annotation",
"->",
"value",
";",
"}",
"}",
"$",
"this",
"->",
"getCache",
"(",
")",
"->",
"save",
"(",
"'_PHX.serialze_properties.'",
".",
"$",
"class",
",",
"$",
"properties",
")",
";",
"}",
"return",
"$",
"properties",
";",
"}"
] | gets class properties metadata | [
"gets",
"class",
"properties",
"metadata"
] | train | https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Serializer/Serializer.php#L120-L143 |
odiaseo/pagebuilder | src/PageBuilder/Entity/Site.php | Site.getSiteFilterQuery | public function getSiteFilterQuery($targetTableAlias)
{
$parent = $this->getParent();
if ($parent and $parentId = $parent->getId()) {
return $targetTableAlias . '.site_id = ' . $parentId;
} elseif ($id = $this->getId()) {
return $targetTableAlias . '.site_id = ' . $id;
}
return '';
} | php | public function getSiteFilterQuery($targetTableAlias)
{
$parent = $this->getParent();
if ($parent and $parentId = $parent->getId()) {
return $targetTableAlias . '.site_id = ' . $parentId;
} elseif ($id = $this->getId()) {
return $targetTableAlias . '.site_id = ' . $id;
}
return '';
} | [
"public",
"function",
"getSiteFilterQuery",
"(",
"$",
"targetTableAlias",
")",
"{",
"$",
"parent",
"=",
"$",
"this",
"->",
"getParent",
"(",
")",
";",
"if",
"(",
"$",
"parent",
"and",
"$",
"parentId",
"=",
"$",
"parent",
"->",
"getId",
"(",
")",
")",
"{",
"return",
"$",
"targetTableAlias",
".",
"'.site_id = '",
".",
"$",
"parentId",
";",
"}",
"elseif",
"(",
"$",
"id",
"=",
"$",
"this",
"->",
"getId",
"(",
")",
")",
"{",
"return",
"$",
"targetTableAlias",
".",
"'.site_id = '",
".",
"$",
"id",
";",
"}",
"return",
"''",
";",
"}"
] | Get filter query
@param $targetTableAlias
@return string | [
"Get",
"filter",
"query"
] | train | https://github.com/odiaseo/pagebuilder/blob/88ef7cccf305368561307efe4ca07fac8e5774f3/src/PageBuilder/Entity/Site.php#L384-L394 |
odiaseo/pagebuilder | src/PageBuilder/Entity/Site.php | Site.sumOfferCount | public function sumOfferCount()
{
$count = $this->getOfferCount();
if ($this->getParent()) {
$count += $this->getParent()->getOfferCount();
}
if ($this->getLinkedSites()->count()) {
/** @var Site $linked */
foreach ($this->getLinkedSites() as $linked) {
$count += $linked->getOfferCount();
}
}
if ($this->getSubDomains()->count()) {
foreach ($this->getSubDomains() as $linked) {
$count += $linked->getOfferCount();
}
}
return $count;
} | php | public function sumOfferCount()
{
$count = $this->getOfferCount();
if ($this->getParent()) {
$count += $this->getParent()->getOfferCount();
}
if ($this->getLinkedSites()->count()) {
/** @var Site $linked */
foreach ($this->getLinkedSites() as $linked) {
$count += $linked->getOfferCount();
}
}
if ($this->getSubDomains()->count()) {
foreach ($this->getSubDomains() as $linked) {
$count += $linked->getOfferCount();
}
}
return $count;
} | [
"public",
"function",
"sumOfferCount",
"(",
")",
"{",
"$",
"count",
"=",
"$",
"this",
"->",
"getOfferCount",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getParent",
"(",
")",
")",
"{",
"$",
"count",
"+=",
"$",
"this",
"->",
"getParent",
"(",
")",
"->",
"getOfferCount",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"getLinkedSites",
"(",
")",
"->",
"count",
"(",
")",
")",
"{",
"/** @var Site $linked */",
"foreach",
"(",
"$",
"this",
"->",
"getLinkedSites",
"(",
")",
"as",
"$",
"linked",
")",
"{",
"$",
"count",
"+=",
"$",
"linked",
"->",
"getOfferCount",
"(",
")",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"getSubDomains",
"(",
")",
"->",
"count",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getSubDomains",
"(",
")",
"as",
"$",
"linked",
")",
"{",
"$",
"count",
"+=",
"$",
"linked",
"->",
"getOfferCount",
"(",
")",
";",
"}",
"}",
"return",
"$",
"count",
";",
"}"
] | Get sum of all offers
@return mixed | [
"Get",
"sum",
"of",
"all",
"offers"
] | train | https://github.com/odiaseo/pagebuilder/blob/88ef7cccf305368561307efe4ca07fac8e5774f3/src/PageBuilder/Entity/Site.php#L451-L472 |
ProjetPP/WikidataQueryApi | src/WikidataQueryApi.php | WikidataQueryApi.doQuery | public function doQuery( $params ) {
$result = json_decode( $this->client->get(
$this->apiUrl,
[ 'query' => $params ]
)->getBody(), true );
if ( $result['status']['error'] !== 'OK' ) {
throw new WikibaseQueryApiException( $result['status']['error'] );
}
return $result;
} | php | public function doQuery( $params ) {
$result = json_decode( $this->client->get(
$this->apiUrl,
[ 'query' => $params ]
)->getBody(), true );
if ( $result['status']['error'] !== 'OK' ) {
throw new WikibaseQueryApiException( $result['status']['error'] );
}
return $result;
} | [
"public",
"function",
"doQuery",
"(",
"$",
"params",
")",
"{",
"$",
"result",
"=",
"json_decode",
"(",
"$",
"this",
"->",
"client",
"->",
"get",
"(",
"$",
"this",
"->",
"apiUrl",
",",
"[",
"'query'",
"=>",
"$",
"params",
"]",
")",
"->",
"getBody",
"(",
")",
",",
"true",
")",
";",
"if",
"(",
"$",
"result",
"[",
"'status'",
"]",
"[",
"'error'",
"]",
"!==",
"'OK'",
")",
"{",
"throw",
"new",
"WikibaseQueryApiException",
"(",
"$",
"result",
"[",
"'status'",
"]",
"[",
"'error'",
"]",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | @param array $params
@return array
@throws WikibaseQueryApiException | [
"@param",
"array",
"$params",
"@return",
"array"
] | train | https://github.com/ProjetPP/WikidataQueryApi/blob/d6c448a4ca8e9472b0a223f88cc7c28baffac861/src/WikidataQueryApi.php#L43-L54 |
o2system/email | src/Protocols/SmtpProtocol.php | SmtpProtocol.sending | protected function sending(Message $message)
{
$phpMailer = new PHPMailer();
$phpMailer->isSMTP();
$phpMailer->SMTPDebug = $this->config[ 'debug' ];
$host = $this->config[ 'host' ];
if (is_array($this->config[ 'host' ])) {
$host = implode(';', $this->config[ 'host' ]);
}
$phpMailer->Host = $host;
$phpMailer->SMTPAuth = $this->config[ 'auth' ];
$phpMailer->Username = $this->config[ 'username' ];
$phpMailer->Password = $this->config[ 'password' ];
$phpMailer->SMTPSecure = $this->config[ 'encryption' ];
$phpMailer->Port = $this->config[ 'port' ];
// Set from
if (false !== ($from = $message->getFrom())) {
$phpMailer->setFrom($from->getEmail(), $from->getName());
}
// Set recipient
if (false !== ($to = $message->getTo())) {
foreach ($to as $address) {
if ($address instanceof Address) {
$phpMailer->addAddress($address->getEmail(), $address->getName());
}
}
}
// Set reply-to
if (false !== ($replyTo = $message->getReplyTo())) {
$phpMailer->addReplyTo($replyTo->getEmail(), $replyTo->getName());
}
// Set content-type
if ($message->getContentType() === 'html') {
$phpMailer->isHTML(true);
}
// Set subject, body & alt-body
$phpMailer->Subject = $message->getSubject();
$phpMailer->Body = $message->getBody();
$phpMailer->AltBody = $message->getAltBody();
if (false !== ($attachments = $message->getAttachments())) {
foreach ($attachments as $filename => $attachment) {
$phpMailer->addAttachment($attachment, $filename);
}
}
if ( ! $phpMailer->send()) {
$this->addError(100, $phpMailer->ErrorInfo);
return false;
}
return true;
} | php | protected function sending(Message $message)
{
$phpMailer = new PHPMailer();
$phpMailer->isSMTP();
$phpMailer->SMTPDebug = $this->config[ 'debug' ];
$host = $this->config[ 'host' ];
if (is_array($this->config[ 'host' ])) {
$host = implode(';', $this->config[ 'host' ]);
}
$phpMailer->Host = $host;
$phpMailer->SMTPAuth = $this->config[ 'auth' ];
$phpMailer->Username = $this->config[ 'username' ];
$phpMailer->Password = $this->config[ 'password' ];
$phpMailer->SMTPSecure = $this->config[ 'encryption' ];
$phpMailer->Port = $this->config[ 'port' ];
// Set from
if (false !== ($from = $message->getFrom())) {
$phpMailer->setFrom($from->getEmail(), $from->getName());
}
// Set recipient
if (false !== ($to = $message->getTo())) {
foreach ($to as $address) {
if ($address instanceof Address) {
$phpMailer->addAddress($address->getEmail(), $address->getName());
}
}
}
// Set reply-to
if (false !== ($replyTo = $message->getReplyTo())) {
$phpMailer->addReplyTo($replyTo->getEmail(), $replyTo->getName());
}
// Set content-type
if ($message->getContentType() === 'html') {
$phpMailer->isHTML(true);
}
// Set subject, body & alt-body
$phpMailer->Subject = $message->getSubject();
$phpMailer->Body = $message->getBody();
$phpMailer->AltBody = $message->getAltBody();
if (false !== ($attachments = $message->getAttachments())) {
foreach ($attachments as $filename => $attachment) {
$phpMailer->addAttachment($attachment, $filename);
}
}
if ( ! $phpMailer->send()) {
$this->addError(100, $phpMailer->ErrorInfo);
return false;
}
return true;
} | [
"protected",
"function",
"sending",
"(",
"Message",
"$",
"message",
")",
"{",
"$",
"phpMailer",
"=",
"new",
"PHPMailer",
"(",
")",
";",
"$",
"phpMailer",
"->",
"isSMTP",
"(",
")",
";",
"$",
"phpMailer",
"->",
"SMTPDebug",
"=",
"$",
"this",
"->",
"config",
"[",
"'debug'",
"]",
";",
"$",
"host",
"=",
"$",
"this",
"->",
"config",
"[",
"'host'",
"]",
";",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"config",
"[",
"'host'",
"]",
")",
")",
"{",
"$",
"host",
"=",
"implode",
"(",
"';'",
",",
"$",
"this",
"->",
"config",
"[",
"'host'",
"]",
")",
";",
"}",
"$",
"phpMailer",
"->",
"Host",
"=",
"$",
"host",
";",
"$",
"phpMailer",
"->",
"SMTPAuth",
"=",
"$",
"this",
"->",
"config",
"[",
"'auth'",
"]",
";",
"$",
"phpMailer",
"->",
"Username",
"=",
"$",
"this",
"->",
"config",
"[",
"'username'",
"]",
";",
"$",
"phpMailer",
"->",
"Password",
"=",
"$",
"this",
"->",
"config",
"[",
"'password'",
"]",
";",
"$",
"phpMailer",
"->",
"SMTPSecure",
"=",
"$",
"this",
"->",
"config",
"[",
"'encryption'",
"]",
";",
"$",
"phpMailer",
"->",
"Port",
"=",
"$",
"this",
"->",
"config",
"[",
"'port'",
"]",
";",
"// Set from\r",
"if",
"(",
"false",
"!==",
"(",
"$",
"from",
"=",
"$",
"message",
"->",
"getFrom",
"(",
")",
")",
")",
"{",
"$",
"phpMailer",
"->",
"setFrom",
"(",
"$",
"from",
"->",
"getEmail",
"(",
")",
",",
"$",
"from",
"->",
"getName",
"(",
")",
")",
";",
"}",
"// Set recipient\r",
"if",
"(",
"false",
"!==",
"(",
"$",
"to",
"=",
"$",
"message",
"->",
"getTo",
"(",
")",
")",
")",
"{",
"foreach",
"(",
"$",
"to",
"as",
"$",
"address",
")",
"{",
"if",
"(",
"$",
"address",
"instanceof",
"Address",
")",
"{",
"$",
"phpMailer",
"->",
"addAddress",
"(",
"$",
"address",
"->",
"getEmail",
"(",
")",
",",
"$",
"address",
"->",
"getName",
"(",
")",
")",
";",
"}",
"}",
"}",
"// Set reply-to\r",
"if",
"(",
"false",
"!==",
"(",
"$",
"replyTo",
"=",
"$",
"message",
"->",
"getReplyTo",
"(",
")",
")",
")",
"{",
"$",
"phpMailer",
"->",
"addReplyTo",
"(",
"$",
"replyTo",
"->",
"getEmail",
"(",
")",
",",
"$",
"replyTo",
"->",
"getName",
"(",
")",
")",
";",
"}",
"// Set content-type\r",
"if",
"(",
"$",
"message",
"->",
"getContentType",
"(",
")",
"===",
"'html'",
")",
"{",
"$",
"phpMailer",
"->",
"isHTML",
"(",
"true",
")",
";",
"}",
"// Set subject, body & alt-body\r",
"$",
"phpMailer",
"->",
"Subject",
"=",
"$",
"message",
"->",
"getSubject",
"(",
")",
";",
"$",
"phpMailer",
"->",
"Body",
"=",
"$",
"message",
"->",
"getBody",
"(",
")",
";",
"$",
"phpMailer",
"->",
"AltBody",
"=",
"$",
"message",
"->",
"getAltBody",
"(",
")",
";",
"if",
"(",
"false",
"!==",
"(",
"$",
"attachments",
"=",
"$",
"message",
"->",
"getAttachments",
"(",
")",
")",
")",
"{",
"foreach",
"(",
"$",
"attachments",
"as",
"$",
"filename",
"=>",
"$",
"attachment",
")",
"{",
"$",
"phpMailer",
"->",
"addAttachment",
"(",
"$",
"attachment",
",",
"$",
"filename",
")",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"phpMailer",
"->",
"send",
"(",
")",
")",
"{",
"$",
"this",
"->",
"addError",
"(",
"100",
",",
"$",
"phpMailer",
"->",
"ErrorInfo",
")",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | MailProtocol::sending
Protocol message sending process.
@param Message $message
@return bool
@throws \PHPMailer\PHPMailer\Exception | [
"MailProtocol",
"::",
"sending"
] | train | https://github.com/o2system/email/blob/7c64b73f539cac8df4b2aaef474b29b949067898/src/Protocols/SmtpProtocol.php#L81-L142 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.