id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
224,600
|
rafasamp/sonus
|
src/Rafasamp/Sonus/Sonus.php
|
Sonus.getSupportedVideoDecoders
|
public static function getSupportedVideoDecoders()
{
// Run terminal command
$command = self::getConverterPath().' -decoders';
$output = shell_exec($command);
// PREG pattern to retrive version information
$output = preg_match_all("/[V]([.]|\w)([.]|\w)([.]|\w)([.]|\w)([.]|\w)\s(?P<format>\w{3,20})\s/", $output, $parsed);
// Verify output
if ($output === false || $output == 0)
{
return false;
}
return $parsed['format'];
}
|
php
|
public static function getSupportedVideoDecoders()
{
// Run terminal command
$command = self::getConverterPath().' -decoders';
$output = shell_exec($command);
// PREG pattern to retrive version information
$output = preg_match_all("/[V]([.]|\w)([.]|\w)([.]|\w)([.]|\w)([.]|\w)\s(?P<format>\w{3,20})\s/", $output, $parsed);
// Verify output
if ($output === false || $output == 0)
{
return false;
}
return $parsed['format'];
}
|
[
"public",
"static",
"function",
"getSupportedVideoDecoders",
"(",
")",
"{",
"// Run terminal command",
"$",
"command",
"=",
"self",
"::",
"getConverterPath",
"(",
")",
".",
"' -decoders'",
";",
"$",
"output",
"=",
"shell_exec",
"(",
"$",
"command",
")",
";",
"// PREG pattern to retrive version information",
"$",
"output",
"=",
"preg_match_all",
"(",
"\"/[V]([.]|\\w)([.]|\\w)([.]|\\w)([.]|\\w)([.]|\\w)\\s(?P<format>\\w{3,20})\\s/\"",
",",
"$",
"output",
",",
"$",
"parsed",
")",
";",
"// Verify output",
"if",
"(",
"$",
"output",
"===",
"false",
"||",
"$",
"output",
"==",
"0",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"parsed",
"[",
"'format'",
"]",
";",
"}"
] |
Returns all video formats ffmpeg can decode
@return array
|
[
"Returns",
"all",
"video",
"formats",
"ffmpeg",
"can",
"decode"
] |
bdf49840c5de4e72a7b767eec399d3338f1f9779
|
https://github.com/rafasamp/sonus/blob/bdf49840c5de4e72a7b767eec399d3338f1f9779/src/Rafasamp/Sonus/Sonus.php#L167-L183
|
224,601
|
rafasamp/sonus
|
src/Rafasamp/Sonus/Sonus.php
|
Sonus.canEncode
|
public static function canEncode($format)
{
$formats = array_merge(self::getSupportedAudioEncoders(), self::getSupportedVideoEncoders());
// Return boolean if they can be encoded or not
if(!in_array($format, $formats))
{
return false;
} else {
return true;
}
}
|
php
|
public static function canEncode($format)
{
$formats = array_merge(self::getSupportedAudioEncoders(), self::getSupportedVideoEncoders());
// Return boolean if they can be encoded or not
if(!in_array($format, $formats))
{
return false;
} else {
return true;
}
}
|
[
"public",
"static",
"function",
"canEncode",
"(",
"$",
"format",
")",
"{",
"$",
"formats",
"=",
"array_merge",
"(",
"self",
"::",
"getSupportedAudioEncoders",
"(",
")",
",",
"self",
"::",
"getSupportedVideoEncoders",
"(",
")",
")",
";",
"// Return boolean if they can be encoded or not",
"if",
"(",
"!",
"in_array",
"(",
"$",
"format",
",",
"$",
"formats",
")",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"return",
"true",
";",
"}",
"}"
] |
Returns boolean if ffmpeg is able to encode to this format
@param string $format ffmpeg format name
@return boolean
|
[
"Returns",
"boolean",
"if",
"ffmpeg",
"is",
"able",
"to",
"encode",
"to",
"this",
"format"
] |
bdf49840c5de4e72a7b767eec399d3338f1f9779
|
https://github.com/rafasamp/sonus/blob/bdf49840c5de4e72a7b767eec399d3338f1f9779/src/Rafasamp/Sonus/Sonus.php#L190-L201
|
224,602
|
rafasamp/sonus
|
src/Rafasamp/Sonus/Sonus.php
|
Sonus.canDecode
|
public static function canDecode($format)
{
// Get an array with all supported encoding formats
$formats = array_merge(self::getSupportedAudioDecoders(), self::getSupportedVideoDecoders());
// Return boolean if they can be encoded or not
if(!in_array($format, $formats))
{
return false;
} else {
return true;
}
}
|
php
|
public static function canDecode($format)
{
// Get an array with all supported encoding formats
$formats = array_merge(self::getSupportedAudioDecoders(), self::getSupportedVideoDecoders());
// Return boolean if they can be encoded or not
if(!in_array($format, $formats))
{
return false;
} else {
return true;
}
}
|
[
"public",
"static",
"function",
"canDecode",
"(",
"$",
"format",
")",
"{",
"// Get an array with all supported encoding formats",
"$",
"formats",
"=",
"array_merge",
"(",
"self",
"::",
"getSupportedAudioDecoders",
"(",
")",
",",
"self",
"::",
"getSupportedVideoDecoders",
"(",
")",
")",
";",
"// Return boolean if they can be encoded or not",
"if",
"(",
"!",
"in_array",
"(",
"$",
"format",
",",
"$",
"formats",
")",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"return",
"true",
";",
"}",
"}"
] |
Returns boolean if ffmpeg is able to decode to this format
@param string $format ffmpeg format name
@return boolean
|
[
"Returns",
"boolean",
"if",
"ffmpeg",
"is",
"able",
"to",
"decode",
"to",
"this",
"format"
] |
bdf49840c5de4e72a7b767eec399d3338f1f9779
|
https://github.com/rafasamp/sonus/blob/bdf49840c5de4e72a7b767eec399d3338f1f9779/src/Rafasamp/Sonus/Sonus.php#L208-L220
|
224,603
|
rafasamp/sonus
|
src/Rafasamp/Sonus/Sonus.php
|
Sonus.getMediaInfo
|
public static function getMediaInfo($input, $type = null)
{
// Just making sure everything goes smooth
if (substr($input, 0, 2) == '-i')
{
$input = substr($input, 3);
}
switch ($type)
{
case 'json':
$command = self::getProbePath().' -v quiet -print_format json -show_format -show_streams -pretty -i '.$input.' 2>&1';
$output = shell_exec($command);
$output = json_decode($output, true);
break;
case 'xml':
$command = self::getProbePath().' -v quiet -print_format xml -show_format -show_streams -pretty -i '.$input.' 2>&1';
$output = shell_exec($command);
break;
case 'csv':
$command = self::getProbePath().' -v quiet -print_format csv -show_format -show_streams -pretty -i '.$input.' 2>&1';
$output = shell_exec($command);
break;
default:
$command = self::getProbePath().' -v quiet -print_format json -show_format -show_streams -pretty -i '.$input.' 2>&1';
$output = shell_exec($command);
$output = json_decode($output, true);
break;
}
return $output;
}
|
php
|
public static function getMediaInfo($input, $type = null)
{
// Just making sure everything goes smooth
if (substr($input, 0, 2) == '-i')
{
$input = substr($input, 3);
}
switch ($type)
{
case 'json':
$command = self::getProbePath().' -v quiet -print_format json -show_format -show_streams -pretty -i '.$input.' 2>&1';
$output = shell_exec($command);
$output = json_decode($output, true);
break;
case 'xml':
$command = self::getProbePath().' -v quiet -print_format xml -show_format -show_streams -pretty -i '.$input.' 2>&1';
$output = shell_exec($command);
break;
case 'csv':
$command = self::getProbePath().' -v quiet -print_format csv -show_format -show_streams -pretty -i '.$input.' 2>&1';
$output = shell_exec($command);
break;
default:
$command = self::getProbePath().' -v quiet -print_format json -show_format -show_streams -pretty -i '.$input.' 2>&1';
$output = shell_exec($command);
$output = json_decode($output, true);
break;
}
return $output;
}
|
[
"public",
"static",
"function",
"getMediaInfo",
"(",
"$",
"input",
",",
"$",
"type",
"=",
"null",
")",
"{",
"// Just making sure everything goes smooth",
"if",
"(",
"substr",
"(",
"$",
"input",
",",
"0",
",",
"2",
")",
"==",
"'-i'",
")",
"{",
"$",
"input",
"=",
"substr",
"(",
"$",
"input",
",",
"3",
")",
";",
"}",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'json'",
":",
"$",
"command",
"=",
"self",
"::",
"getProbePath",
"(",
")",
".",
"' -v quiet -print_format json -show_format -show_streams -pretty -i '",
".",
"$",
"input",
".",
"' 2>&1'",
";",
"$",
"output",
"=",
"shell_exec",
"(",
"$",
"command",
")",
";",
"$",
"output",
"=",
"json_decode",
"(",
"$",
"output",
",",
"true",
")",
";",
"break",
";",
"case",
"'xml'",
":",
"$",
"command",
"=",
"self",
"::",
"getProbePath",
"(",
")",
".",
"' -v quiet -print_format xml -show_format -show_streams -pretty -i '",
".",
"$",
"input",
".",
"' 2>&1'",
";",
"$",
"output",
"=",
"shell_exec",
"(",
"$",
"command",
")",
";",
"break",
";",
"case",
"'csv'",
":",
"$",
"command",
"=",
"self",
"::",
"getProbePath",
"(",
")",
".",
"' -v quiet -print_format csv -show_format -show_streams -pretty -i '",
".",
"$",
"input",
".",
"' 2>&1'",
";",
"$",
"output",
"=",
"shell_exec",
"(",
"$",
"command",
")",
";",
"break",
";",
"default",
":",
"$",
"command",
"=",
"self",
"::",
"getProbePath",
"(",
")",
".",
"' -v quiet -print_format json -show_format -show_streams -pretty -i '",
".",
"$",
"input",
".",
"' 2>&1'",
";",
"$",
"output",
"=",
"shell_exec",
"(",
"$",
"command",
")",
";",
"$",
"output",
"=",
"json_decode",
"(",
"$",
"output",
",",
"true",
")",
";",
"break",
";",
"}",
"return",
"$",
"output",
";",
"}"
] |
Returns array with file information
@param string $input file input
@param string $type output format
@return array, json, xml, csv
|
[
"Returns",
"array",
"with",
"file",
"information"
] |
bdf49840c5de4e72a7b767eec399d3338f1f9779
|
https://github.com/rafasamp/sonus/blob/bdf49840c5de4e72a7b767eec399d3338f1f9779/src/Rafasamp/Sonus/Sonus.php#L228-L262
|
224,604
|
rafasamp/sonus
|
src/Rafasamp/Sonus/Sonus.php
|
Sonus.overwrite
|
public function overwrite($var = true)
{
switch ($var)
{
case true:
array_push($this->parameters, '-y');
return $this;
break;
case false:
array_push($this->parameters, '-n');
return $this;
break;
default:
return false;
break;
}
}
|
php
|
public function overwrite($var = true)
{
switch ($var)
{
case true:
array_push($this->parameters, '-y');
return $this;
break;
case false:
array_push($this->parameters, '-n');
return $this;
break;
default:
return false;
break;
}
}
|
[
"public",
"function",
"overwrite",
"(",
"$",
"var",
"=",
"true",
")",
"{",
"switch",
"(",
"$",
"var",
")",
"{",
"case",
"true",
":",
"array_push",
"(",
"$",
"this",
"->",
"parameters",
",",
"'-y'",
")",
";",
"return",
"$",
"this",
";",
"break",
";",
"case",
"false",
":",
"array_push",
"(",
"$",
"this",
"->",
"parameters",
",",
"'-n'",
")",
";",
"return",
"$",
"this",
";",
"break",
";",
"default",
":",
"return",
"false",
";",
"break",
";",
"}",
"}"
] |
Overwrite output file if it exists
@param boolean $var
@return boolean
|
[
"Overwrite",
"output",
"file",
"if",
"it",
"exists"
] |
bdf49840c5de4e72a7b767eec399d3338f1f9779
|
https://github.com/rafasamp/sonus/blob/bdf49840c5de4e72a7b767eec399d3338f1f9779/src/Rafasamp/Sonus/Sonus.php#L380-L398
|
224,605
|
rafasamp/sonus
|
src/Rafasamp/Sonus/Sonus.php
|
Sonus.bitrate
|
public function bitrate($var, $type = 'audio')
{
// Value must be numeric
if (!is_numeric($var))
{
return false;
}
switch ($type)
{
case 'audio':
array_push($this->parameters, '-b:a '.$var.'k');
return $this;
break;
case 'video':
array_push($this->parameters, '-b:v '.$var.'k');
return $this;
break;
default:
return false;
break;
}
}
|
php
|
public function bitrate($var, $type = 'audio')
{
// Value must be numeric
if (!is_numeric($var))
{
return false;
}
switch ($type)
{
case 'audio':
array_push($this->parameters, '-b:a '.$var.'k');
return $this;
break;
case 'video':
array_push($this->parameters, '-b:v '.$var.'k');
return $this;
break;
default:
return false;
break;
}
}
|
[
"public",
"function",
"bitrate",
"(",
"$",
"var",
",",
"$",
"type",
"=",
"'audio'",
")",
"{",
"// Value must be numeric",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"var",
")",
")",
"{",
"return",
"false",
";",
"}",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'audio'",
":",
"array_push",
"(",
"$",
"this",
"->",
"parameters",
",",
"'-b:a '",
".",
"$",
"var",
".",
"'k'",
")",
";",
"return",
"$",
"this",
";",
"break",
";",
"case",
"'video'",
":",
"array_push",
"(",
"$",
"this",
"->",
"parameters",
",",
"'-b:v '",
".",
"$",
"var",
".",
"'k'",
")",
";",
"return",
"$",
"this",
";",
"break",
";",
"default",
":",
"return",
"false",
";",
"break",
";",
"}",
"}"
] |
Sets the constant bitrate
@param int $var bitrate
@return boolean
|
[
"Sets",
"the",
"constant",
"bitrate"
] |
bdf49840c5de4e72a7b767eec399d3338f1f9779
|
https://github.com/rafasamp/sonus/blob/bdf49840c5de4e72a7b767eec399d3338f1f9779/src/Rafasamp/Sonus/Sonus.php#L455-L479
|
224,606
|
rafasamp/sonus
|
src/Rafasamp/Sonus/Sonus.php
|
Sonus.getProgress
|
public static function getProgress($job, $format = null)
{
// Get the temporary directory
$tmpdir = self::getTempPath();
// The code below has been adapted from Jimbo
// http://stackoverflow.com/questions/11441517/ffmpeg-progress-bar-encoding-percentage-in-php
$content = @file_get_contents($tmpdir.$job.'.sonustmp');
if($content)
{
// Get duration of source
preg_match("/Duration: (.*?), start:/", $content, $matches);
$rawDuration = $matches[1];
// rawDuration is in 00:00:00.00 format. This converts it to seconds.
$ar = array_reverse(explode(":", $rawDuration));
$duration = floatval($ar[0]);
if (!empty($ar[1])) $duration += intval($ar[1]) * 60;
if (!empty($ar[2])) $duration += intval($ar[2]) * 60 * 60;
// Get the time in the file that is already encoded
preg_match_all("/time=(.*?) bitrate/", $content, $matches);
$rawTime = array_pop($matches);
// This is needed if there is more than one match
if (is_array($rawTime))
{
$rawTime = array_pop($rawTime);
}
// rawTime is in 00:00:00.00 format. This converts it to seconds.
$ar = array_reverse(explode(":", $rawTime));
$time = floatval($ar[0]);
if (!empty($ar[1])) $time += intval($ar[1]) * 60;
if (!empty($ar[2])) $time += intval($ar[2]) * 60 * 60;
// Calculate the progress
$progress = round(($time/$duration) * 100);
// Output to array
$output = array(
'Duration' => $rawDuration,
'Current' => $rawTime,
'Progress' => $progress
);
// Return data
switch ($format)
{
case 'array':
return $output;
break;
default:
return json_encode($output);
break;
}
} else {
return null;
}
}
|
php
|
public static function getProgress($job, $format = null)
{
// Get the temporary directory
$tmpdir = self::getTempPath();
// The code below has been adapted from Jimbo
// http://stackoverflow.com/questions/11441517/ffmpeg-progress-bar-encoding-percentage-in-php
$content = @file_get_contents($tmpdir.$job.'.sonustmp');
if($content)
{
// Get duration of source
preg_match("/Duration: (.*?), start:/", $content, $matches);
$rawDuration = $matches[1];
// rawDuration is in 00:00:00.00 format. This converts it to seconds.
$ar = array_reverse(explode(":", $rawDuration));
$duration = floatval($ar[0]);
if (!empty($ar[1])) $duration += intval($ar[1]) * 60;
if (!empty($ar[2])) $duration += intval($ar[2]) * 60 * 60;
// Get the time in the file that is already encoded
preg_match_all("/time=(.*?) bitrate/", $content, $matches);
$rawTime = array_pop($matches);
// This is needed if there is more than one match
if (is_array($rawTime))
{
$rawTime = array_pop($rawTime);
}
// rawTime is in 00:00:00.00 format. This converts it to seconds.
$ar = array_reverse(explode(":", $rawTime));
$time = floatval($ar[0]);
if (!empty($ar[1])) $time += intval($ar[1]) * 60;
if (!empty($ar[2])) $time += intval($ar[2]) * 60 * 60;
// Calculate the progress
$progress = round(($time/$duration) * 100);
// Output to array
$output = array(
'Duration' => $rawDuration,
'Current' => $rawTime,
'Progress' => $progress
);
// Return data
switch ($format)
{
case 'array':
return $output;
break;
default:
return json_encode($output);
break;
}
} else {
return null;
}
}
|
[
"public",
"static",
"function",
"getProgress",
"(",
"$",
"job",
",",
"$",
"format",
"=",
"null",
")",
"{",
"// Get the temporary directory",
"$",
"tmpdir",
"=",
"self",
"::",
"getTempPath",
"(",
")",
";",
"// The code below has been adapted from Jimbo",
"// http://stackoverflow.com/questions/11441517/ffmpeg-progress-bar-encoding-percentage-in-php",
"$",
"content",
"=",
"@",
"file_get_contents",
"(",
"$",
"tmpdir",
".",
"$",
"job",
".",
"'.sonustmp'",
")",
";",
"if",
"(",
"$",
"content",
")",
"{",
"// Get duration of source",
"preg_match",
"(",
"\"/Duration: (.*?), start:/\"",
",",
"$",
"content",
",",
"$",
"matches",
")",
";",
"$",
"rawDuration",
"=",
"$",
"matches",
"[",
"1",
"]",
";",
"// rawDuration is in 00:00:00.00 format. This converts it to seconds.",
"$",
"ar",
"=",
"array_reverse",
"(",
"explode",
"(",
"\":\"",
",",
"$",
"rawDuration",
")",
")",
";",
"$",
"duration",
"=",
"floatval",
"(",
"$",
"ar",
"[",
"0",
"]",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"ar",
"[",
"1",
"]",
")",
")",
"$",
"duration",
"+=",
"intval",
"(",
"$",
"ar",
"[",
"1",
"]",
")",
"*",
"60",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"ar",
"[",
"2",
"]",
")",
")",
"$",
"duration",
"+=",
"intval",
"(",
"$",
"ar",
"[",
"2",
"]",
")",
"*",
"60",
"*",
"60",
";",
"// Get the time in the file that is already encoded",
"preg_match_all",
"(",
"\"/time=(.*?) bitrate/\"",
",",
"$",
"content",
",",
"$",
"matches",
")",
";",
"$",
"rawTime",
"=",
"array_pop",
"(",
"$",
"matches",
")",
";",
"// This is needed if there is more than one match",
"if",
"(",
"is_array",
"(",
"$",
"rawTime",
")",
")",
"{",
"$",
"rawTime",
"=",
"array_pop",
"(",
"$",
"rawTime",
")",
";",
"}",
"// rawTime is in 00:00:00.00 format. This converts it to seconds.",
"$",
"ar",
"=",
"array_reverse",
"(",
"explode",
"(",
"\":\"",
",",
"$",
"rawTime",
")",
")",
";",
"$",
"time",
"=",
"floatval",
"(",
"$",
"ar",
"[",
"0",
"]",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"ar",
"[",
"1",
"]",
")",
")",
"$",
"time",
"+=",
"intval",
"(",
"$",
"ar",
"[",
"1",
"]",
")",
"*",
"60",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"ar",
"[",
"2",
"]",
")",
")",
"$",
"time",
"+=",
"intval",
"(",
"$",
"ar",
"[",
"2",
"]",
")",
"*",
"60",
"*",
"60",
";",
"// Calculate the progress",
"$",
"progress",
"=",
"round",
"(",
"(",
"$",
"time",
"/",
"$",
"duration",
")",
"*",
"100",
")",
";",
"// Output to array",
"$",
"output",
"=",
"array",
"(",
"'Duration'",
"=>",
"$",
"rawDuration",
",",
"'Current'",
"=>",
"$",
"rawTime",
",",
"'Progress'",
"=>",
"$",
"progress",
")",
";",
"// Return data",
"switch",
"(",
"$",
"format",
")",
"{",
"case",
"'array'",
":",
"return",
"$",
"output",
";",
"break",
";",
"default",
":",
"return",
"json_encode",
"(",
"$",
"output",
")",
";",
"break",
";",
"}",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
Returns given job progress
@param string $job id
@param string $format format to output data
@return array
|
[
"Returns",
"given",
"job",
"progress"
] |
bdf49840c5de4e72a7b767eec399d3338f1f9779
|
https://github.com/rafasamp/sonus/blob/bdf49840c5de4e72a7b767eec399d3338f1f9779/src/Rafasamp/Sonus/Sonus.php#L575-L638
|
224,607
|
rafasamp/sonus
|
src/Rafasamp/Sonus/Sonus.php
|
Sonus.destroyProgress
|
public static function destroyProgress($job)
{
// Get temporary file path
$file = $tmpdir.$job.'.sonustmp';
// Check if file exists
if (is_file($file))
{
// Delete file
$output = unlink($tmpdir.$job.'.sonustmp');
return $output;
} else {
return false;
}
}
|
php
|
public static function destroyProgress($job)
{
// Get temporary file path
$file = $tmpdir.$job.'.sonustmp';
// Check if file exists
if (is_file($file))
{
// Delete file
$output = unlink($tmpdir.$job.'.sonustmp');
return $output;
} else {
return false;
}
}
|
[
"public",
"static",
"function",
"destroyProgress",
"(",
"$",
"job",
")",
"{",
"// Get temporary file path",
"$",
"file",
"=",
"$",
"tmpdir",
".",
"$",
"job",
".",
"'.sonustmp'",
";",
"// Check if file exists",
"if",
"(",
"is_file",
"(",
"$",
"file",
")",
")",
"{",
"// Delete file",
"$",
"output",
"=",
"unlink",
"(",
"$",
"tmpdir",
".",
"$",
"job",
".",
"'.sonustmp'",
")",
";",
"return",
"$",
"output",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Deletes job temporary file
@param string $job id
@return boolean
|
[
"Deletes",
"job",
"temporary",
"file"
] |
bdf49840c5de4e72a7b767eec399d3338f1f9779
|
https://github.com/rafasamp/sonus/blob/bdf49840c5de4e72a7b767eec399d3338f1f9779/src/Rafasamp/Sonus/Sonus.php#L645-L659
|
224,608
|
rafasamp/sonus
|
src/Rafasamp/Sonus/Sonus.php
|
Sonus.destroyAllProgress
|
public static function destroyAllProgress()
{
// Get all filenames within the temporary folder
$files = glob($tmpdir.'*');
// Iterate through files
$output = array();
foreach ($files as $file)
{
if (is_file($file))
{
// Return result to array
$result = unlink($file);
array_push($output, var_export($result, true));
}
}
// If a file could not be deleted, return false
if (array_search('false', $output))
{
return false;
}
return true;
}
|
php
|
public static function destroyAllProgress()
{
// Get all filenames within the temporary folder
$files = glob($tmpdir.'*');
// Iterate through files
$output = array();
foreach ($files as $file)
{
if (is_file($file))
{
// Return result to array
$result = unlink($file);
array_push($output, var_export($result, true));
}
}
// If a file could not be deleted, return false
if (array_search('false', $output))
{
return false;
}
return true;
}
|
[
"public",
"static",
"function",
"destroyAllProgress",
"(",
")",
"{",
"// Get all filenames within the temporary folder",
"$",
"files",
"=",
"glob",
"(",
"$",
"tmpdir",
".",
"'*'",
")",
";",
"// Iterate through files",
"$",
"output",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"is_file",
"(",
"$",
"file",
")",
")",
"{",
"// Return result to array",
"$",
"result",
"=",
"unlink",
"(",
"$",
"file",
")",
";",
"array_push",
"(",
"$",
"output",
",",
"var_export",
"(",
"$",
"result",
",",
"true",
")",
")",
";",
"}",
"}",
"// If a file could not be deleted, return false",
"if",
"(",
"array_search",
"(",
"'false'",
",",
"$",
"output",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Deletes all temporary files
@return boolean
|
[
"Deletes",
"all",
"temporary",
"files"
] |
bdf49840c5de4e72a7b767eec399d3338f1f9779
|
https://github.com/rafasamp/sonus/blob/bdf49840c5de4e72a7b767eec399d3338f1f9779/src/Rafasamp/Sonus/Sonus.php#L665-L689
|
224,609
|
Troopers/AlertifyBundle
|
Handler/AlertifySessionHandler.php
|
AlertifySessionHandler.getDefaultParametersFromContext
|
protected function getDefaultParametersFromContext($context = null)
{
if (count($this->defaultParameters['contexts'])) {
//If context is not given, just take the default one
if ($context === null) {
$context = $this->defaultParameters['default']['context'];
}
//If context is in declared contexts, we use it
if (array_key_exists($context, $this->defaultParameters['contexts'])) {
return $this->defaultParameters['contexts'][$context];
}
}
//else we return the default configuration
return $this->defaultParameters['default'];
}
|
php
|
protected function getDefaultParametersFromContext($context = null)
{
if (count($this->defaultParameters['contexts'])) {
//If context is not given, just take the default one
if ($context === null) {
$context = $this->defaultParameters['default']['context'];
}
//If context is in declared contexts, we use it
if (array_key_exists($context, $this->defaultParameters['contexts'])) {
return $this->defaultParameters['contexts'][$context];
}
}
//else we return the default configuration
return $this->defaultParameters['default'];
}
|
[
"protected",
"function",
"getDefaultParametersFromContext",
"(",
"$",
"context",
"=",
"null",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"defaultParameters",
"[",
"'contexts'",
"]",
")",
")",
"{",
"//If context is not given, just take the default one",
"if",
"(",
"$",
"context",
"===",
"null",
")",
"{",
"$",
"context",
"=",
"$",
"this",
"->",
"defaultParameters",
"[",
"'default'",
"]",
"[",
"'context'",
"]",
";",
"}",
"//If context is in declared contexts, we use it",
"if",
"(",
"array_key_exists",
"(",
"$",
"context",
",",
"$",
"this",
"->",
"defaultParameters",
"[",
"'contexts'",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"defaultParameters",
"[",
"'contexts'",
"]",
"[",
"$",
"context",
"]",
";",
"}",
"}",
"//else we return the default configuration",
"return",
"$",
"this",
"->",
"defaultParameters",
"[",
"'default'",
"]",
";",
"}"
] |
Get the configuration for the given context.
@param string $context The actual context
@return array
|
[
"Get",
"the",
"configuration",
"for",
"the",
"given",
"context",
"."
] |
eded39af141d056627718d2ba7dee4e458fb7187
|
https://github.com/Troopers/AlertifyBundle/blob/eded39af141d056627718d2ba7dee4e458fb7187/Handler/AlertifySessionHandler.php#L72-L88
|
224,610
|
burnbright/silverstripe-importexport
|
code/gridfield/GridFieldImporter.php
|
GridFieldImporter.getLoader
|
public function getLoader(GridField $gridField)
{
if (!$this->loader) {
$this->loader = $this->scaffoldLoader($gridField);
}
return $this->loader;
}
|
php
|
public function getLoader(GridField $gridField)
{
if (!$this->loader) {
$this->loader = $this->scaffoldLoader($gridField);
}
return $this->loader;
}
|
[
"public",
"function",
"getLoader",
"(",
"GridField",
"$",
"gridField",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"loader",
")",
"{",
"$",
"this",
"->",
"loader",
"=",
"$",
"this",
"->",
"scaffoldLoader",
"(",
"$",
"gridField",
")",
";",
"}",
"return",
"$",
"this",
"->",
"loader",
";",
"}"
] |
Get the BulkLoader
@return BetterBulkLoader
|
[
"Get",
"the",
"BulkLoader"
] |
673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3
|
https://github.com/burnbright/silverstripe-importexport/blob/673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3/code/gridfield/GridFieldImporter.php#L48-L55
|
224,611
|
burnbright/silverstripe-importexport
|
code/gridfield/GridFieldImporter.php
|
GridFieldImporter.scaffoldLoader
|
public function scaffoldLoader(GridField $gridField)
{
$gridlist = $gridField->getList();
$class = ($gridlist instanceof HasManyList) ?
"ListBulkLoader" : "BetterBulkLoader";
//set the correct constructor argument
$arg = ($class === "ListBulkLoader" ||
is_subclass_of($class, "ListBulkLoader")) ?
$gridlist : $gridField->getModelClass();
$loader = new $class($arg);
$loader->setSource(new CsvBulkLoaderSource());
return $loader;
}
|
php
|
public function scaffoldLoader(GridField $gridField)
{
$gridlist = $gridField->getList();
$class = ($gridlist instanceof HasManyList) ?
"ListBulkLoader" : "BetterBulkLoader";
//set the correct constructor argument
$arg = ($class === "ListBulkLoader" ||
is_subclass_of($class, "ListBulkLoader")) ?
$gridlist : $gridField->getModelClass();
$loader = new $class($arg);
$loader->setSource(new CsvBulkLoaderSource());
return $loader;
}
|
[
"public",
"function",
"scaffoldLoader",
"(",
"GridField",
"$",
"gridField",
")",
"{",
"$",
"gridlist",
"=",
"$",
"gridField",
"->",
"getList",
"(",
")",
";",
"$",
"class",
"=",
"(",
"$",
"gridlist",
"instanceof",
"HasManyList",
")",
"?",
"\"ListBulkLoader\"",
":",
"\"BetterBulkLoader\"",
";",
"//set the correct constructor argument",
"$",
"arg",
"=",
"(",
"$",
"class",
"===",
"\"ListBulkLoader\"",
"||",
"is_subclass_of",
"(",
"$",
"class",
",",
"\"ListBulkLoader\"",
")",
")",
"?",
"$",
"gridlist",
":",
"$",
"gridField",
"->",
"getModelClass",
"(",
")",
";",
"$",
"loader",
"=",
"new",
"$",
"class",
"(",
"$",
"arg",
")",
";",
"$",
"loader",
"->",
"setSource",
"(",
"new",
"CsvBulkLoaderSource",
"(",
")",
")",
";",
"return",
"$",
"loader",
";",
"}"
] |
Scaffold a bulk loader, if none is provided
|
[
"Scaffold",
"a",
"bulk",
"loader",
"if",
"none",
"is",
"provided"
] |
673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3
|
https://github.com/burnbright/silverstripe-importexport/blob/673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3/code/gridfield/GridFieldImporter.php#L60-L73
|
224,612
|
burnbright/silverstripe-importexport
|
code/gridfield/GridFieldImporter.php
|
GridFieldImporter.getUploadField
|
public function getUploadField(GridField $gridField)
{
$uploadField = UploadField::create(
$gridField->Name."_ImportUploadField", 'Upload CSV'
)
->setForm($gridField->getForm())
->setConfig('url', $gridField->Link('importer/upload'))
->setConfig('edit_url', $gridField->Link('importer/import'))
->setConfig('allowedMaxFileNumber', 1)
->setConfig('changeDetection', false)
->setConfig('canPreviewFolder', false)
->setConfig('canAttachExisting', false)
->setConfig('overwriteWarning', false)
->setAllowedExtensions(array('csv'))
->setFolderName('csvImports') //TODO: don't store temp CSV in assets
->addExtraClass("import-upload-csv-field");
return $uploadField;
}
|
php
|
public function getUploadField(GridField $gridField)
{
$uploadField = UploadField::create(
$gridField->Name."_ImportUploadField", 'Upload CSV'
)
->setForm($gridField->getForm())
->setConfig('url', $gridField->Link('importer/upload'))
->setConfig('edit_url', $gridField->Link('importer/import'))
->setConfig('allowedMaxFileNumber', 1)
->setConfig('changeDetection', false)
->setConfig('canPreviewFolder', false)
->setConfig('canAttachExisting', false)
->setConfig('overwriteWarning', false)
->setAllowedExtensions(array('csv'))
->setFolderName('csvImports') //TODO: don't store temp CSV in assets
->addExtraClass("import-upload-csv-field");
return $uploadField;
}
|
[
"public",
"function",
"getUploadField",
"(",
"GridField",
"$",
"gridField",
")",
"{",
"$",
"uploadField",
"=",
"UploadField",
"::",
"create",
"(",
"$",
"gridField",
"->",
"Name",
".",
"\"_ImportUploadField\"",
",",
"'Upload CSV'",
")",
"->",
"setForm",
"(",
"$",
"gridField",
"->",
"getForm",
"(",
")",
")",
"->",
"setConfig",
"(",
"'url'",
",",
"$",
"gridField",
"->",
"Link",
"(",
"'importer/upload'",
")",
")",
"->",
"setConfig",
"(",
"'edit_url'",
",",
"$",
"gridField",
"->",
"Link",
"(",
"'importer/import'",
")",
")",
"->",
"setConfig",
"(",
"'allowedMaxFileNumber'",
",",
"1",
")",
"->",
"setConfig",
"(",
"'changeDetection'",
",",
"false",
")",
"->",
"setConfig",
"(",
"'canPreviewFolder'",
",",
"false",
")",
"->",
"setConfig",
"(",
"'canAttachExisting'",
",",
"false",
")",
"->",
"setConfig",
"(",
"'overwriteWarning'",
",",
"false",
")",
"->",
"setAllowedExtensions",
"(",
"array",
"(",
"'csv'",
")",
")",
"->",
"setFolderName",
"(",
"'csvImports'",
")",
"//TODO: don't store temp CSV in assets",
"->",
"addExtraClass",
"(",
"\"import-upload-csv-field\"",
")",
";",
"return",
"$",
"uploadField",
";",
"}"
] |
Return a configured UploadField instance
@param GridField $gridField Current GridField
@return UploadField Configured UploadField instance
|
[
"Return",
"a",
"configured",
"UploadField",
"instance"
] |
673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3
|
https://github.com/burnbright/silverstripe-importexport/blob/673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3/code/gridfield/GridFieldImporter.php#L125-L143
|
224,613
|
burnbright/silverstripe-importexport
|
code/gridfield/GridFieldImporter.php
|
GridFieldImporter.handleImporter
|
public function handleImporter($gridField, $request = null)
{
$controller = $gridField->getForm()->getController();
$handler = new GridFieldImporter_Request($gridField, $this, $controller);
return $handler->handleRequest($request, DataModel::inst());
}
|
php
|
public function handleImporter($gridField, $request = null)
{
$controller = $gridField->getForm()->getController();
$handler = new GridFieldImporter_Request($gridField, $this, $controller);
return $handler->handleRequest($request, DataModel::inst());
}
|
[
"public",
"function",
"handleImporter",
"(",
"$",
"gridField",
",",
"$",
"request",
"=",
"null",
")",
"{",
"$",
"controller",
"=",
"$",
"gridField",
"->",
"getForm",
"(",
")",
"->",
"getController",
"(",
")",
";",
"$",
"handler",
"=",
"new",
"GridFieldImporter_Request",
"(",
"$",
"gridField",
",",
"$",
"this",
",",
"$",
"controller",
")",
";",
"return",
"$",
"handler",
"->",
"handleRequest",
"(",
"$",
"request",
",",
"DataModel",
"::",
"inst",
"(",
")",
")",
";",
"}"
] |
Pass importer requests to a new GridFieldImporter_Request
|
[
"Pass",
"importer",
"requests",
"to",
"a",
"new",
"GridFieldImporter_Request"
] |
673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3
|
https://github.com/burnbright/silverstripe-importexport/blob/673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3/code/gridfield/GridFieldImporter.php#L160-L166
|
224,614
|
neos/setup
|
Classes/Step/DatabaseStep.php
|
DatabaseStep.getAvailableDrivers
|
protected function getAvailableDrivers()
{
$supportedDrivers = [
'pdo_mysql' => 'MySQL/MariaDB via PDO',
'mysqli' => 'MySQL/MariaDB via mysqli',
'pdo_pgsql' => 'PostgreSQL via PDO'
];
$availableDrivers = [];
foreach ($supportedDrivers as $driver => $label) {
if (extension_loaded($driver)) {
$availableDrivers[$driver] = $label;
}
}
return $availableDrivers;
}
|
php
|
protected function getAvailableDrivers()
{
$supportedDrivers = [
'pdo_mysql' => 'MySQL/MariaDB via PDO',
'mysqli' => 'MySQL/MariaDB via mysqli',
'pdo_pgsql' => 'PostgreSQL via PDO'
];
$availableDrivers = [];
foreach ($supportedDrivers as $driver => $label) {
if (extension_loaded($driver)) {
$availableDrivers[$driver] = $label;
}
}
return $availableDrivers;
}
|
[
"protected",
"function",
"getAvailableDrivers",
"(",
")",
"{",
"$",
"supportedDrivers",
"=",
"[",
"'pdo_mysql'",
"=>",
"'MySQL/MariaDB via PDO'",
",",
"'mysqli'",
"=>",
"'MySQL/MariaDB via mysqli'",
",",
"'pdo_pgsql'",
"=>",
"'PostgreSQL via PDO'",
"]",
";",
"$",
"availableDrivers",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"supportedDrivers",
"as",
"$",
"driver",
"=>",
"$",
"label",
")",
"{",
"if",
"(",
"extension_loaded",
"(",
"$",
"driver",
")",
")",
"{",
"$",
"availableDrivers",
"[",
"$",
"driver",
"]",
"=",
"$",
"label",
";",
"}",
"}",
"return",
"$",
"availableDrivers",
";",
"}"
] |
Return an array with driver.
This is built on supported drivers (those we actually provide migration for in Flow and Neos), filtered to show
only available options (needed extension loaded, actually usable in current setup).
@return array
|
[
"Return",
"an",
"array",
"with",
"driver",
"."
] |
7b5437efe8113e997007be6896628aa9f5c39d2f
|
https://github.com/neos/setup/blob/7b5437efe8113e997007be6896628aa9f5c39d2f/Classes/Step/DatabaseStep.php#L208-L224
|
224,615
|
joomla-framework/github-api
|
src/Package/Issues/Assignees.php
|
Assignees.check
|
public function check($owner, $repo, $assignee)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo . '/assignees/' . $assignee;
try
{
$response = $this->client->get($this->fetchUrl($path));
if ($response->code == 204)
{
return true;
}
throw new UnexpectedResponseException($response, 'Invalid response: ' . $response->code);
}
catch (\DomainException $e)
{
if (isset($response->code) && $response->code == 404)
{
return false;
}
throw $e;
}
}
|
php
|
public function check($owner, $repo, $assignee)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo . '/assignees/' . $assignee;
try
{
$response = $this->client->get($this->fetchUrl($path));
if ($response->code == 204)
{
return true;
}
throw new UnexpectedResponseException($response, 'Invalid response: ' . $response->code);
}
catch (\DomainException $e)
{
if (isset($response->code) && $response->code == 404)
{
return false;
}
throw $e;
}
}
|
[
"public",
"function",
"check",
"(",
"$",
"owner",
",",
"$",
"repo",
",",
"$",
"assignee",
")",
"{",
"// Build the request path.",
"$",
"path",
"=",
"'/repos/'",
".",
"$",
"owner",
".",
"'/'",
".",
"$",
"repo",
".",
"'/assignees/'",
".",
"$",
"assignee",
";",
"try",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"get",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"path",
")",
")",
";",
"if",
"(",
"$",
"response",
"->",
"code",
"==",
"204",
")",
"{",
"return",
"true",
";",
"}",
"throw",
"new",
"UnexpectedResponseException",
"(",
"$",
"response",
",",
"'Invalid response: '",
".",
"$",
"response",
"->",
"code",
")",
";",
"}",
"catch",
"(",
"\\",
"DomainException",
"$",
"e",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"response",
"->",
"code",
")",
"&&",
"$",
"response",
"->",
"code",
"==",
"404",
")",
"{",
"return",
"false",
";",
"}",
"throw",
"$",
"e",
";",
"}",
"}"
] |
Check assignee.
You may check to see if a particular user is an assignee for a repository.
If the given assignee login belongs to an assignee for the repository, a 204 header
with no content is returned.
Otherwise a 404 status code is returned.
@param string $owner The name of the owner of the GitHub repository.
@param string $repo The name of the GitHub repository.
@param string $assignee The assignees login name.
@return boolean
@since 1.0
@throws \DomainException
|
[
"Check",
"assignee",
"."
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Issues/Assignees.php#L62-L87
|
224,616
|
joomla-framework/github-api
|
src/Package/Issues/Assignees.php
|
Assignees.add
|
public function add($owner, $repo, $number, array $assignees)
{
// Build the request path.
$path = "/repos/$owner/$repo/issues/$number/assignees";
$data = json_encode(
array(
'assignees' => $assignees,
)
);
return $this->processResponse($this->client->post($this->fetchUrl($path), $data), 201);
}
|
php
|
public function add($owner, $repo, $number, array $assignees)
{
// Build the request path.
$path = "/repos/$owner/$repo/issues/$number/assignees";
$data = json_encode(
array(
'assignees' => $assignees,
)
);
return $this->processResponse($this->client->post($this->fetchUrl($path), $data), 201);
}
|
[
"public",
"function",
"add",
"(",
"$",
"owner",
",",
"$",
"repo",
",",
"$",
"number",
",",
"array",
"$",
"assignees",
")",
"{",
"// Build the request path.",
"$",
"path",
"=",
"\"/repos/$owner/$repo/issues/$number/assignees\"",
";",
"$",
"data",
"=",
"json_encode",
"(",
"array",
"(",
"'assignees'",
"=>",
"$",
"assignees",
",",
")",
")",
";",
"return",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"this",
"->",
"client",
"->",
"post",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"path",
")",
",",
"$",
"data",
")",
",",
"201",
")",
";",
"}"
] |
Add assignees to an Issue
This call adds the users passed in the assignees key (as their logins) to the issue.
@param string $owner The name of the owner of the GitHub repository.
@param string $repo The name of the GitHub repository.
@param integer $number The issue number to add assignees to.
@param string[] $assignees The logins for GitHub users to assign to this issue.
@return object
@since 1.4.0
@throws \DomainException
|
[
"Add",
"assignees",
"to",
"an",
"Issue"
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Issues/Assignees.php#L104-L116
|
224,617
|
joomla-framework/github-api
|
src/Package/Issues/Assignees.php
|
Assignees.remove
|
public function remove($owner, $repo, $number, array $assignees)
{
// Build the request path.
$path = "/repos/$owner/$repo/issues/$number/assignees";
$data = json_encode(
array(
'assignees' => $assignees,
)
);
return $this->processResponse($this->client->delete($this->fetchUrl($path), array(), null, $data));
}
|
php
|
public function remove($owner, $repo, $number, array $assignees)
{
// Build the request path.
$path = "/repos/$owner/$repo/issues/$number/assignees";
$data = json_encode(
array(
'assignees' => $assignees,
)
);
return $this->processResponse($this->client->delete($this->fetchUrl($path), array(), null, $data));
}
|
[
"public",
"function",
"remove",
"(",
"$",
"owner",
",",
"$",
"repo",
",",
"$",
"number",
",",
"array",
"$",
"assignees",
")",
"{",
"// Build the request path.",
"$",
"path",
"=",
"\"/repos/$owner/$repo/issues/$number/assignees\"",
";",
"$",
"data",
"=",
"json_encode",
"(",
"array",
"(",
"'assignees'",
"=>",
"$",
"assignees",
",",
")",
")",
";",
"return",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"this",
"->",
"client",
"->",
"delete",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"path",
")",
",",
"array",
"(",
")",
",",
"null",
",",
"$",
"data",
")",
")",
";",
"}"
] |
Remove assignees from an Issue
This call removes the users passed in the assignees key (as their logins) from the issue.
@param string $owner The name of the owner of the GitHub repository.
@param string $repo The name of the GitHub repository.
@param integer $number The issue number to add assignees to.
@param string[] $assignees The logins for GitHub users to assign to this issue.
@return object
@since 1.4.0
@throws \DomainException
|
[
"Remove",
"assignees",
"from",
"an",
"Issue"
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Issues/Assignees.php#L133-L145
|
224,618
|
acacha/users
|
src/Models/UserInvitation.php
|
UserInvitation.setInitialState
|
public function setInitialState()
{
$this->setAttribute($this->getStateColumn(), $this->getInitialState());
$this->token = hash_hmac('sha256', str_random(40), env('APP_KEY'));
}
|
php
|
public function setInitialState()
{
$this->setAttribute($this->getStateColumn(), $this->getInitialState());
$this->token = hash_hmac('sha256', str_random(40), env('APP_KEY'));
}
|
[
"public",
"function",
"setInitialState",
"(",
")",
"{",
"$",
"this",
"->",
"setAttribute",
"(",
"$",
"this",
"->",
"getStateColumn",
"(",
")",
",",
"$",
"this",
"->",
"getInitialState",
"(",
")",
")",
";",
"$",
"this",
"->",
"token",
"=",
"hash_hmac",
"(",
"'sha256'",
",",
"str_random",
"(",
"40",
")",
",",
"env",
"(",
"'APP_KEY'",
")",
")",
";",
"}"
] |
Set the initial state.
@return void
|
[
"Set",
"the",
"initial",
"state",
"."
] |
af74be23d225bc9a23ee049579abb1596ae683c0
|
https://github.com/acacha/users/blob/af74be23d225bc9a23ee049579abb1596ae683c0/src/Models/UserInvitation.php#L67-L71
|
224,619
|
joomla-framework/github-api
|
src/Package/Issues.php
|
Issues.create
|
public function create($user, $repo, $title, $body = null, $assignee = null, $milestone = null, array $labels = array(),
array $assignees = array()
)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo . '/issues';
// Ensure that we have a non-associative array.
if (!empty($labels))
{
$labels = array_values($labels);
}
// Build the request data.
$data = array(
'title' => $title,
'milestone' => $milestone,
'labels' => $labels,
'body' => $body,
);
if (\is_string($assignee) && !empty($assignees))
{
throw new \UnexpectedValueException('You cannot pass both assignee and assignees. Only one may be provided.');
}
if (!empty($assignees))
{
$data['assignees'] = array_values($assignees);
}
elseif (\is_string($assignee))
{
$data['assignee'] = $assignee;
}
// Encode the request data.
$data = json_encode($data);
// Send the request.
return $this->processResponse($this->client->post($this->fetchUrl($path), $data), 201);
}
|
php
|
public function create($user, $repo, $title, $body = null, $assignee = null, $milestone = null, array $labels = array(),
array $assignees = array()
)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo . '/issues';
// Ensure that we have a non-associative array.
if (!empty($labels))
{
$labels = array_values($labels);
}
// Build the request data.
$data = array(
'title' => $title,
'milestone' => $milestone,
'labels' => $labels,
'body' => $body,
);
if (\is_string($assignee) && !empty($assignees))
{
throw new \UnexpectedValueException('You cannot pass both assignee and assignees. Only one may be provided.');
}
if (!empty($assignees))
{
$data['assignees'] = array_values($assignees);
}
elseif (\is_string($assignee))
{
$data['assignee'] = $assignee;
}
// Encode the request data.
$data = json_encode($data);
// Send the request.
return $this->processResponse($this->client->post($this->fetchUrl($path), $data), 201);
}
|
[
"public",
"function",
"create",
"(",
"$",
"user",
",",
"$",
"repo",
",",
"$",
"title",
",",
"$",
"body",
"=",
"null",
",",
"$",
"assignee",
"=",
"null",
",",
"$",
"milestone",
"=",
"null",
",",
"array",
"$",
"labels",
"=",
"array",
"(",
")",
",",
"array",
"$",
"assignees",
"=",
"array",
"(",
")",
")",
"{",
"// Build the request path.",
"$",
"path",
"=",
"'/repos/'",
".",
"$",
"user",
".",
"'/'",
".",
"$",
"repo",
".",
"'/issues'",
";",
"// Ensure that we have a non-associative array.",
"if",
"(",
"!",
"empty",
"(",
"$",
"labels",
")",
")",
"{",
"$",
"labels",
"=",
"array_values",
"(",
"$",
"labels",
")",
";",
"}",
"// Build the request data.",
"$",
"data",
"=",
"array",
"(",
"'title'",
"=>",
"$",
"title",
",",
"'milestone'",
"=>",
"$",
"milestone",
",",
"'labels'",
"=>",
"$",
"labels",
",",
"'body'",
"=>",
"$",
"body",
",",
")",
";",
"if",
"(",
"\\",
"is_string",
"(",
"$",
"assignee",
")",
"&&",
"!",
"empty",
"(",
"$",
"assignees",
")",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"'You cannot pass both assignee and assignees. Only one may be provided.'",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"assignees",
")",
")",
"{",
"$",
"data",
"[",
"'assignees'",
"]",
"=",
"array_values",
"(",
"$",
"assignees",
")",
";",
"}",
"elseif",
"(",
"\\",
"is_string",
"(",
"$",
"assignee",
")",
")",
"{",
"$",
"data",
"[",
"'assignee'",
"]",
"=",
"$",
"assignee",
";",
"}",
"// Encode the request data.",
"$",
"data",
"=",
"json_encode",
"(",
"$",
"data",
")",
";",
"// Send the request.",
"return",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"this",
"->",
"client",
"->",
"post",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"path",
")",
",",
"$",
"data",
")",
",",
"201",
")",
";",
"}"
] |
Create an issue.
@param string $user The name of the owner of the GitHub repository.
@param string $repo The name of the GitHub repository.
@param string $title The title of the new issue.
@param string $body The body text for the new issue.
@param string $assignee The login for the GitHub user that this issue should be assigned to.
@param integer $milestone The milestone to associate this issue with.
@param string[] $labels The labels to associate with this issue.
@param string[] $assignees The logins for GitHub users to assign to this issue.
@return object
@since 1.0
@throws \DomainException
|
[
"Create",
"an",
"issue",
"."
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Issues.php#L46-L86
|
224,620
|
joomla-framework/github-api
|
src/Package/Issues.php
|
Issues.edit
|
public function edit($user, $repo, $issueId, $state = null, $title = null, $body = null, $assignee = null, $milestone = null,
array $labels = null
)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo . '/issues/' . (int) $issueId;
// Create the data object.
$data = new \stdClass;
// If a title is set add it to the data object.
if (isset($title))
{
$data->title = $title;
}
// If a body is set add it to the data object.
if (isset($body))
{
$data->body = $body;
}
// If a state is set add it to the data object.
if (isset($state))
{
$data->state = $state;
}
// If an assignee is set add it to the data object.
if (isset($assignee))
{
$data->assignee = $assignee;
}
// If a milestone is set add it to the data object.
if (isset($milestone))
{
$data->milestone = $milestone;
}
// If labels are set add them to the data object.
if (isset($labels))
{
// Ensure that we have a non-associative array.
if (isset($labels))
{
$labels = array_values($labels);
}
$data->labels = $labels;
}
// Encode the request data.
$data = json_encode($data);
// Send the request.
return $this->processResponse($this->client->patch($this->fetchUrl($path), $data));
}
|
php
|
public function edit($user, $repo, $issueId, $state = null, $title = null, $body = null, $assignee = null, $milestone = null,
array $labels = null
)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo . '/issues/' . (int) $issueId;
// Create the data object.
$data = new \stdClass;
// If a title is set add it to the data object.
if (isset($title))
{
$data->title = $title;
}
// If a body is set add it to the data object.
if (isset($body))
{
$data->body = $body;
}
// If a state is set add it to the data object.
if (isset($state))
{
$data->state = $state;
}
// If an assignee is set add it to the data object.
if (isset($assignee))
{
$data->assignee = $assignee;
}
// If a milestone is set add it to the data object.
if (isset($milestone))
{
$data->milestone = $milestone;
}
// If labels are set add them to the data object.
if (isset($labels))
{
// Ensure that we have a non-associative array.
if (isset($labels))
{
$labels = array_values($labels);
}
$data->labels = $labels;
}
// Encode the request data.
$data = json_encode($data);
// Send the request.
return $this->processResponse($this->client->patch($this->fetchUrl($path), $data));
}
|
[
"public",
"function",
"edit",
"(",
"$",
"user",
",",
"$",
"repo",
",",
"$",
"issueId",
",",
"$",
"state",
"=",
"null",
",",
"$",
"title",
"=",
"null",
",",
"$",
"body",
"=",
"null",
",",
"$",
"assignee",
"=",
"null",
",",
"$",
"milestone",
"=",
"null",
",",
"array",
"$",
"labels",
"=",
"null",
")",
"{",
"// Build the request path.",
"$",
"path",
"=",
"'/repos/'",
".",
"$",
"user",
".",
"'/'",
".",
"$",
"repo",
".",
"'/issues/'",
".",
"(",
"int",
")",
"$",
"issueId",
";",
"// Create the data object.",
"$",
"data",
"=",
"new",
"\\",
"stdClass",
";",
"// If a title is set add it to the data object.",
"if",
"(",
"isset",
"(",
"$",
"title",
")",
")",
"{",
"$",
"data",
"->",
"title",
"=",
"$",
"title",
";",
"}",
"// If a body is set add it to the data object.",
"if",
"(",
"isset",
"(",
"$",
"body",
")",
")",
"{",
"$",
"data",
"->",
"body",
"=",
"$",
"body",
";",
"}",
"// If a state is set add it to the data object.",
"if",
"(",
"isset",
"(",
"$",
"state",
")",
")",
"{",
"$",
"data",
"->",
"state",
"=",
"$",
"state",
";",
"}",
"// If an assignee is set add it to the data object.",
"if",
"(",
"isset",
"(",
"$",
"assignee",
")",
")",
"{",
"$",
"data",
"->",
"assignee",
"=",
"$",
"assignee",
";",
"}",
"// If a milestone is set add it to the data object.",
"if",
"(",
"isset",
"(",
"$",
"milestone",
")",
")",
"{",
"$",
"data",
"->",
"milestone",
"=",
"$",
"milestone",
";",
"}",
"// If labels are set add them to the data object.",
"if",
"(",
"isset",
"(",
"$",
"labels",
")",
")",
"{",
"// Ensure that we have a non-associative array.",
"if",
"(",
"isset",
"(",
"$",
"labels",
")",
")",
"{",
"$",
"labels",
"=",
"array_values",
"(",
"$",
"labels",
")",
";",
"}",
"$",
"data",
"->",
"labels",
"=",
"$",
"labels",
";",
"}",
"// Encode the request data.",
"$",
"data",
"=",
"json_encode",
"(",
"$",
"data",
")",
";",
"// Send the request.",
"return",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"this",
"->",
"client",
"->",
"patch",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"path",
")",
",",
"$",
"data",
")",
")",
";",
"}"
] |
Edit an issue.
@param string $user The name of the owner of the GitHub repository.
@param string $repo The name of the GitHub repository.
@param integer $issueId The issue number.
@param string $state The optional new state for the issue. [open, closed]
@param string $title The title of the new issue.
@param string $body The body text for the new issue.
@param string $assignee The login for the GitHub user that this issue should be assigned to.
@param integer $milestone The milestone to associate this issue with.
@param array $labels The labels to associate with this issue.
@return object
@since 1.0
@throws \DomainException
|
[
"Edit",
"an",
"issue",
"."
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Issues.php#L106-L163
|
224,621
|
joomla-framework/github-api
|
src/Package/Issues.php
|
Issues.getList
|
public function getList($filter = null, $state = null, $labels = null, $sort = null, $direction = null, \DateTime $since = null, $page = 0,
$limit = 0
)
{
// Build the request path.
$uri = new Uri($this->fetchUrl('/issues', $page, $limit));
if ($filter)
{
$uri->setVar('filter', $filter);
}
if ($state)
{
$uri->setVar('state', $state);
}
if ($labels)
{
$uri->setVar('labels', $labels);
}
if ($sort)
{
$uri->setVar('sort', $sort);
}
if ($direction)
{
$uri->setVar('direction', $direction);
}
if ($since)
{
$uri->setVar('since', $since->format(\DateTime::ISO8601));
}
// Send the request.
return $this->processResponse($this->client->get($uri));
}
|
php
|
public function getList($filter = null, $state = null, $labels = null, $sort = null, $direction = null, \DateTime $since = null, $page = 0,
$limit = 0
)
{
// Build the request path.
$uri = new Uri($this->fetchUrl('/issues', $page, $limit));
if ($filter)
{
$uri->setVar('filter', $filter);
}
if ($state)
{
$uri->setVar('state', $state);
}
if ($labels)
{
$uri->setVar('labels', $labels);
}
if ($sort)
{
$uri->setVar('sort', $sort);
}
if ($direction)
{
$uri->setVar('direction', $direction);
}
if ($since)
{
$uri->setVar('since', $since->format(\DateTime::ISO8601));
}
// Send the request.
return $this->processResponse($this->client->get($uri));
}
|
[
"public",
"function",
"getList",
"(",
"$",
"filter",
"=",
"null",
",",
"$",
"state",
"=",
"null",
",",
"$",
"labels",
"=",
"null",
",",
"$",
"sort",
"=",
"null",
",",
"$",
"direction",
"=",
"null",
",",
"\\",
"DateTime",
"$",
"since",
"=",
"null",
",",
"$",
"page",
"=",
"0",
",",
"$",
"limit",
"=",
"0",
")",
"{",
"// Build the request path.",
"$",
"uri",
"=",
"new",
"Uri",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"'/issues'",
",",
"$",
"page",
",",
"$",
"limit",
")",
")",
";",
"if",
"(",
"$",
"filter",
")",
"{",
"$",
"uri",
"->",
"setVar",
"(",
"'filter'",
",",
"$",
"filter",
")",
";",
"}",
"if",
"(",
"$",
"state",
")",
"{",
"$",
"uri",
"->",
"setVar",
"(",
"'state'",
",",
"$",
"state",
")",
";",
"}",
"if",
"(",
"$",
"labels",
")",
"{",
"$",
"uri",
"->",
"setVar",
"(",
"'labels'",
",",
"$",
"labels",
")",
";",
"}",
"if",
"(",
"$",
"sort",
")",
"{",
"$",
"uri",
"->",
"setVar",
"(",
"'sort'",
",",
"$",
"sort",
")",
";",
"}",
"if",
"(",
"$",
"direction",
")",
"{",
"$",
"uri",
"->",
"setVar",
"(",
"'direction'",
",",
"$",
"direction",
")",
";",
"}",
"if",
"(",
"$",
"since",
")",
"{",
"$",
"uri",
"->",
"setVar",
"(",
"'since'",
",",
"$",
"since",
"->",
"format",
"(",
"\\",
"DateTime",
"::",
"ISO8601",
")",
")",
";",
"}",
"// Send the request.",
"return",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"this",
"->",
"client",
"->",
"get",
"(",
"$",
"uri",
")",
")",
";",
"}"
] |
List issues.
@param string $filter The filter type: assigned, created, mentioned, subscribed.
@param string $state The optional state to filter requests by. [open, closed]
@param string $labels The list of comma separated Label names. Example: bug,ui,@high.
@param string $sort The sort order: created, updated, comments, default: created.
@param string $direction The list direction: asc or desc, default: desc.
@param \DateTime $since Only issues updated at or after this time are returned.
@param integer $page The page number from which to get items.
@param integer $limit The number of items on a page.
@return object
@since 1.0
@throws \DomainException
|
[
"List",
"issues",
"."
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Issues.php#L203-L242
|
224,622
|
joomla-framework/github-api
|
src/Package/Issues.php
|
Issues.getListByRepository
|
public function getListByRepository($user, $repo, $milestone = null, $state = null, $assignee = null, $mentioned = null, $labels = null,
$sort = null, $direction = null, \DateTime $since = null, $page = 0, $limit = 0
)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo . '/issues';
$uri = new Uri($this->fetchUrl($path, $page, $limit));
if ($milestone)
{
$uri->setVar('milestone', $milestone);
}
if ($state)
{
$uri->setVar('state', $state);
}
if ($assignee)
{
$uri->setVar('assignee', $assignee);
}
if ($mentioned)
{
$uri->setVar('mentioned', $mentioned);
}
if ($labels)
{
$uri->setVar('labels', $labels);
}
if ($sort)
{
$uri->setVar('sort', $sort);
}
if ($direction)
{
$uri->setVar('direction', $direction);
}
if ($since)
{
$uri->setVar('since', $since->format(\DateTime::RFC3339));
}
// Send the request.
return $this->processResponse($this->client->get($uri));
}
|
php
|
public function getListByRepository($user, $repo, $milestone = null, $state = null, $assignee = null, $mentioned = null, $labels = null,
$sort = null, $direction = null, \DateTime $since = null, $page = 0, $limit = 0
)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo . '/issues';
$uri = new Uri($this->fetchUrl($path, $page, $limit));
if ($milestone)
{
$uri->setVar('milestone', $milestone);
}
if ($state)
{
$uri->setVar('state', $state);
}
if ($assignee)
{
$uri->setVar('assignee', $assignee);
}
if ($mentioned)
{
$uri->setVar('mentioned', $mentioned);
}
if ($labels)
{
$uri->setVar('labels', $labels);
}
if ($sort)
{
$uri->setVar('sort', $sort);
}
if ($direction)
{
$uri->setVar('direction', $direction);
}
if ($since)
{
$uri->setVar('since', $since->format(\DateTime::RFC3339));
}
// Send the request.
return $this->processResponse($this->client->get($uri));
}
|
[
"public",
"function",
"getListByRepository",
"(",
"$",
"user",
",",
"$",
"repo",
",",
"$",
"milestone",
"=",
"null",
",",
"$",
"state",
"=",
"null",
",",
"$",
"assignee",
"=",
"null",
",",
"$",
"mentioned",
"=",
"null",
",",
"$",
"labels",
"=",
"null",
",",
"$",
"sort",
"=",
"null",
",",
"$",
"direction",
"=",
"null",
",",
"\\",
"DateTime",
"$",
"since",
"=",
"null",
",",
"$",
"page",
"=",
"0",
",",
"$",
"limit",
"=",
"0",
")",
"{",
"// Build the request path.",
"$",
"path",
"=",
"'/repos/'",
".",
"$",
"user",
".",
"'/'",
".",
"$",
"repo",
".",
"'/issues'",
";",
"$",
"uri",
"=",
"new",
"Uri",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"path",
",",
"$",
"page",
",",
"$",
"limit",
")",
")",
";",
"if",
"(",
"$",
"milestone",
")",
"{",
"$",
"uri",
"->",
"setVar",
"(",
"'milestone'",
",",
"$",
"milestone",
")",
";",
"}",
"if",
"(",
"$",
"state",
")",
"{",
"$",
"uri",
"->",
"setVar",
"(",
"'state'",
",",
"$",
"state",
")",
";",
"}",
"if",
"(",
"$",
"assignee",
")",
"{",
"$",
"uri",
"->",
"setVar",
"(",
"'assignee'",
",",
"$",
"assignee",
")",
";",
"}",
"if",
"(",
"$",
"mentioned",
")",
"{",
"$",
"uri",
"->",
"setVar",
"(",
"'mentioned'",
",",
"$",
"mentioned",
")",
";",
"}",
"if",
"(",
"$",
"labels",
")",
"{",
"$",
"uri",
"->",
"setVar",
"(",
"'labels'",
",",
"$",
"labels",
")",
";",
"}",
"if",
"(",
"$",
"sort",
")",
"{",
"$",
"uri",
"->",
"setVar",
"(",
"'sort'",
",",
"$",
"sort",
")",
";",
"}",
"if",
"(",
"$",
"direction",
")",
"{",
"$",
"uri",
"->",
"setVar",
"(",
"'direction'",
",",
"$",
"direction",
")",
";",
"}",
"if",
"(",
"$",
"since",
")",
"{",
"$",
"uri",
"->",
"setVar",
"(",
"'since'",
",",
"$",
"since",
"->",
"format",
"(",
"\\",
"DateTime",
"::",
"RFC3339",
")",
")",
";",
"}",
"// Send the request.",
"return",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"this",
"->",
"client",
"->",
"get",
"(",
"$",
"uri",
")",
")",
";",
"}"
] |
List issues for a repository.
@param string $user The name of the owner of the GitHub repository.
@param string $repo The name of the GitHub repository.
@param string $milestone The milestone number, 'none', or *.
@param string $state The optional state to filter requests by. [open, closed]
@param string $assignee The assignee name, 'none', or *.
@param string $mentioned The GitHub user name.
@param string $labels The list of comma separated Label names. Example: bug,ui,@high.
@param string $sort The sort order: created, updated, comments, default: created.
@param string $direction The list direction: asc or desc, default: desc.
@param \DateTime $since Only issues updated at or after this time are returned.
@param integer $page The page number from which to get items.
@param integer $limit The number of items on a page.
@return object
@since 1.0
@throws \DomainException
|
[
"List",
"issues",
"for",
"a",
"repository",
"."
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Issues.php#L265-L316
|
224,623
|
joomla-framework/github-api
|
src/Package/Issues.php
|
Issues.lock
|
public function lock($user, $repo, $issueId)
{
// Build the request path.
$path = "/repos/$user/$repo/issues/" . (int) $issueId . '/lock';
return $this->processResponse($this->client->put($this->fetchUrl($path), array()), 204);
}
|
php
|
public function lock($user, $repo, $issueId)
{
// Build the request path.
$path = "/repos/$user/$repo/issues/" . (int) $issueId . '/lock';
return $this->processResponse($this->client->put($this->fetchUrl($path), array()), 204);
}
|
[
"public",
"function",
"lock",
"(",
"$",
"user",
",",
"$",
"repo",
",",
"$",
"issueId",
")",
"{",
"// Build the request path.",
"$",
"path",
"=",
"\"/repos/$user/$repo/issues/\"",
".",
"(",
"int",
")",
"$",
"issueId",
".",
"'/lock'",
";",
"return",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"this",
"->",
"client",
"->",
"put",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"path",
")",
",",
"array",
"(",
")",
")",
",",
"204",
")",
";",
"}"
] |
Lock an issue.
@param string $user The name of the owner of the GitHub repository.
@param string $repo The name of the GitHub repository.
@param integer $issueId The issue number.
@return object
@since 1.4.0
@throws \DomainException
|
[
"Lock",
"an",
"issue",
"."
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Issues.php#L330-L336
|
224,624
|
joomla-framework/github-api
|
src/Package/Issues.php
|
Issues.unlock
|
public function unlock($user, $repo, $issueId)
{
// Build the request path.
$path = "/repos/$user/$repo/issues/" . (int) $issueId . '/lock';
return $this->processResponse($this->client->delete($this->fetchUrl($path)), 204);
}
|
php
|
public function unlock($user, $repo, $issueId)
{
// Build the request path.
$path = "/repos/$user/$repo/issues/" . (int) $issueId . '/lock';
return $this->processResponse($this->client->delete($this->fetchUrl($path)), 204);
}
|
[
"public",
"function",
"unlock",
"(",
"$",
"user",
",",
"$",
"repo",
",",
"$",
"issueId",
")",
"{",
"// Build the request path.",
"$",
"path",
"=",
"\"/repos/$user/$repo/issues/\"",
".",
"(",
"int",
")",
"$",
"issueId",
".",
"'/lock'",
";",
"return",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"this",
"->",
"client",
"->",
"delete",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"path",
")",
")",
",",
"204",
")",
";",
"}"
] |
Unlock an issue.
@param string $user The name of the owner of the GitHub repository.
@param string $repo The name of the GitHub repository.
@param integer $issueId The issue number.
@return object
@since 1.4.0
@throws \DomainException
|
[
"Unlock",
"an",
"issue",
"."
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Issues.php#L350-L356
|
224,625
|
codebach/PianoSoloWeatherBundle
|
Http/WeatherCsvResponse.php
|
WeatherCsvResponse.createCsvResponse
|
public function createCsvResponse()
{
$handle = fopen('php://memory', 'r+');
fputcsv($handle, array('Date', 'City', 'Temperature', 'Description'));
foreach ($this->weathers as $weather) {
fputcsv($handle, array(
$weather->getWdate(),
$weather->getCity(),
$weather->getTemperature(),
$weather->getDescription()
));
}
rewind($handle);
$content = stream_get_contents($handle);
fclose($handle);
$this->setCharset('ISO-8859-2');
$this->headers->set('Content-Type', 'text/csv; charset=UTF-8');
$this->headers->set('Content-Description', 'File Transfer');
$this->headers->set('Content-Disposition', sprintf('attachment; filename="%s.csv"', $this->fileName));
return $this->setContent($content);
}
|
php
|
public function createCsvResponse()
{
$handle = fopen('php://memory', 'r+');
fputcsv($handle, array('Date', 'City', 'Temperature', 'Description'));
foreach ($this->weathers as $weather) {
fputcsv($handle, array(
$weather->getWdate(),
$weather->getCity(),
$weather->getTemperature(),
$weather->getDescription()
));
}
rewind($handle);
$content = stream_get_contents($handle);
fclose($handle);
$this->setCharset('ISO-8859-2');
$this->headers->set('Content-Type', 'text/csv; charset=UTF-8');
$this->headers->set('Content-Description', 'File Transfer');
$this->headers->set('Content-Disposition', sprintf('attachment; filename="%s.csv"', $this->fileName));
return $this->setContent($content);
}
|
[
"public",
"function",
"createCsvResponse",
"(",
")",
"{",
"$",
"handle",
"=",
"fopen",
"(",
"'php://memory'",
",",
"'r+'",
")",
";",
"fputcsv",
"(",
"$",
"handle",
",",
"array",
"(",
"'Date'",
",",
"'City'",
",",
"'Temperature'",
",",
"'Description'",
")",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"weathers",
"as",
"$",
"weather",
")",
"{",
"fputcsv",
"(",
"$",
"handle",
",",
"array",
"(",
"$",
"weather",
"->",
"getWdate",
"(",
")",
",",
"$",
"weather",
"->",
"getCity",
"(",
")",
",",
"$",
"weather",
"->",
"getTemperature",
"(",
")",
",",
"$",
"weather",
"->",
"getDescription",
"(",
")",
")",
")",
";",
"}",
"rewind",
"(",
"$",
"handle",
")",
";",
"$",
"content",
"=",
"stream_get_contents",
"(",
"$",
"handle",
")",
";",
"fclose",
"(",
"$",
"handle",
")",
";",
"$",
"this",
"->",
"setCharset",
"(",
"'ISO-8859-2'",
")",
";",
"$",
"this",
"->",
"headers",
"->",
"set",
"(",
"'Content-Type'",
",",
"'text/csv; charset=UTF-8'",
")",
";",
"$",
"this",
"->",
"headers",
"->",
"set",
"(",
"'Content-Description'",
",",
"'File Transfer'",
")",
";",
"$",
"this",
"->",
"headers",
"->",
"set",
"(",
"'Content-Disposition'",
",",
"sprintf",
"(",
"'attachment; filename=\"%s.csv\"'",
",",
"$",
"this",
"->",
"fileName",
")",
")",
";",
"return",
"$",
"this",
"->",
"setContent",
"(",
"$",
"content",
")",
";",
"}"
] |
Creates CSV Response of Weathers
@return Response
|
[
"Creates",
"CSV",
"Response",
"of",
"Weathers"
] |
f6b3ce0a86dbd8ab4e23d4e2d3031e6d4af0e269
|
https://github.com/codebach/PianoSoloWeatherBundle/blob/f6b3ce0a86dbd8ab4e23d4e2d3031e6d4af0e269/Http/WeatherCsvResponse.php#L43-L67
|
224,626
|
netz98/n98-deployer
|
src/Deployer/RoleManager.php
|
RoleManager.addServerToRoles
|
public static function addServerToRoles($server, array $roles)
{
foreach ($roles as $role) {
self::$roles[$role][] = $server;
}
}
|
php
|
public static function addServerToRoles($server, array $roles)
{
foreach ($roles as $role) {
self::$roles[$role][] = $server;
}
}
|
[
"public",
"static",
"function",
"addServerToRoles",
"(",
"$",
"server",
",",
"array",
"$",
"roles",
")",
"{",
"foreach",
"(",
"$",
"roles",
"as",
"$",
"role",
")",
"{",
"self",
"::",
"$",
"roles",
"[",
"$",
"role",
"]",
"[",
"]",
"=",
"$",
"server",
";",
"}",
"}"
] |
Asign a Server to a Role
@param string $server
@param array $roles
|
[
"Asign",
"a",
"Server",
"to",
"a",
"Role"
] |
cf7b7c790f45c41ed338b8a33b498eeaaaa765e9
|
https://github.com/netz98/n98-deployer/blob/cf7b7c790f45c41ed338b8a33b498eeaaaa765e9/src/Deployer/RoleManager.php#L64-L70
|
224,627
|
joomla-framework/github-api
|
src/Package/Pulls.php
|
Pulls.create
|
public function create($user, $repo, $title, $base, $head, $body = '')
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo . '/pulls';
// Build the request data.
$data = json_encode(
array(
'title' => $title,
'base' => $base,
'head' => $head,
'body' => $body,
)
);
// Send the request.
return $this->processResponse($this->client->post($this->fetchUrl($path), $data), 201);
}
|
php
|
public function create($user, $repo, $title, $base, $head, $body = '')
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo . '/pulls';
// Build the request data.
$data = json_encode(
array(
'title' => $title,
'base' => $base,
'head' => $head,
'body' => $body,
)
);
// Send the request.
return $this->processResponse($this->client->post($this->fetchUrl($path), $data), 201);
}
|
[
"public",
"function",
"create",
"(",
"$",
"user",
",",
"$",
"repo",
",",
"$",
"title",
",",
"$",
"base",
",",
"$",
"head",
",",
"$",
"body",
"=",
"''",
")",
"{",
"// Build the request path.",
"$",
"path",
"=",
"'/repos/'",
".",
"$",
"user",
".",
"'/'",
".",
"$",
"repo",
".",
"'/pulls'",
";",
"// Build the request data.",
"$",
"data",
"=",
"json_encode",
"(",
"array",
"(",
"'title'",
"=>",
"$",
"title",
",",
"'base'",
"=>",
"$",
"base",
",",
"'head'",
"=>",
"$",
"head",
",",
"'body'",
"=>",
"$",
"body",
",",
")",
")",
";",
"// Send the request.",
"return",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"this",
"->",
"client",
"->",
"post",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"path",
")",
",",
"$",
"data",
")",
",",
"201",
")",
";",
"}"
] |
Create a pull request.
@param string $user The name of the owner of the GitHub repository.
@param string $repo The name of the GitHub repository.
@param string $title The title of the new pull request.
@param string $base The branch (or git ref) you want your changes pulled into. This
should be an existing branch on the current repository. You cannot
submit a pull request to one repo that requests a merge to a base
of another repo.
@param string $head The branch (or git ref) where your changes are implemented.
@param string $body The body text for the new pull request.
@return object
@since 1.0
@throws \DomainException
|
[
"Create",
"a",
"pull",
"request",
"."
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Pulls.php#L43-L60
|
224,628
|
joomla-framework/github-api
|
src/Package/Pulls.php
|
Pulls.edit
|
public function edit($user, $repo, $pullId, $title = null, $body = null, $state = null, $base = null)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo . '/pulls/' . (int) $pullId;
// Create the data object.
$data = new \stdClass;
// If a title is set add it to the data object.
if (isset($title))
{
$data->title = $title;
}
// If a body is set add it to the data object.
if (isset($body))
{
$data->body = $body;
}
// If a state is set add it to the data object.
if (isset($state))
{
$data->state = $state;
}
// If a base branch is set add it to the data object.
if (isset($base))
{
$data->base = $base;
}
// Encode the request data.
$data = json_encode($data);
// Send the request.
return $this->processResponse($this->client->patch($this->fetchUrl($path), $data));
}
|
php
|
public function edit($user, $repo, $pullId, $title = null, $body = null, $state = null, $base = null)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo . '/pulls/' . (int) $pullId;
// Create the data object.
$data = new \stdClass;
// If a title is set add it to the data object.
if (isset($title))
{
$data->title = $title;
}
// If a body is set add it to the data object.
if (isset($body))
{
$data->body = $body;
}
// If a state is set add it to the data object.
if (isset($state))
{
$data->state = $state;
}
// If a base branch is set add it to the data object.
if (isset($base))
{
$data->base = $base;
}
// Encode the request data.
$data = json_encode($data);
// Send the request.
return $this->processResponse($this->client->patch($this->fetchUrl($path), $data));
}
|
[
"public",
"function",
"edit",
"(",
"$",
"user",
",",
"$",
"repo",
",",
"$",
"pullId",
",",
"$",
"title",
"=",
"null",
",",
"$",
"body",
"=",
"null",
",",
"$",
"state",
"=",
"null",
",",
"$",
"base",
"=",
"null",
")",
"{",
"// Build the request path.",
"$",
"path",
"=",
"'/repos/'",
".",
"$",
"user",
".",
"'/'",
".",
"$",
"repo",
".",
"'/pulls/'",
".",
"(",
"int",
")",
"$",
"pullId",
";",
"// Create the data object.",
"$",
"data",
"=",
"new",
"\\",
"stdClass",
";",
"// If a title is set add it to the data object.",
"if",
"(",
"isset",
"(",
"$",
"title",
")",
")",
"{",
"$",
"data",
"->",
"title",
"=",
"$",
"title",
";",
"}",
"// If a body is set add it to the data object.",
"if",
"(",
"isset",
"(",
"$",
"body",
")",
")",
"{",
"$",
"data",
"->",
"body",
"=",
"$",
"body",
";",
"}",
"// If a state is set add it to the data object.",
"if",
"(",
"isset",
"(",
"$",
"state",
")",
")",
"{",
"$",
"data",
"->",
"state",
"=",
"$",
"state",
";",
"}",
"// If a base branch is set add it to the data object.",
"if",
"(",
"isset",
"(",
"$",
"base",
")",
")",
"{",
"$",
"data",
"->",
"base",
"=",
"$",
"base",
";",
"}",
"// Encode the request data.",
"$",
"data",
"=",
"json_encode",
"(",
"$",
"data",
")",
";",
"// Send the request.",
"return",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"this",
"->",
"client",
"->",
"patch",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"path",
")",
",",
"$",
"data",
")",
")",
";",
"}"
] |
Update a pull request.
@param string $user The name of the owner of the GitHub repository.
@param string $repo The name of the GitHub repository.
@param integer $pullId The pull request number.
@param string $title The optional new title for the pull request.
@param string $body The optional new body text for the pull request.
@param string $state The optional new state for the pull request. [open, closed]
@param string $base The optional new base branch for the pull request.
@return object
@since 1.0
@throws \DomainException
|
[
"Update",
"a",
"pull",
"request",
"."
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Pulls.php#L113-L150
|
224,629
|
joomla-framework/github-api
|
src/Package/Pulls.php
|
Pulls.getCommits
|
public function getCommits($user, $repo, $pullId, $page = 0, $limit = 0)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo . '/pulls/' . (int) $pullId . '/commits';
// Send the request.
return $this->processResponse($this->client->get($this->fetchUrl($path, $page, $limit)));
}
|
php
|
public function getCommits($user, $repo, $pullId, $page = 0, $limit = 0)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo . '/pulls/' . (int) $pullId . '/commits';
// Send the request.
return $this->processResponse($this->client->get($this->fetchUrl($path, $page, $limit)));
}
|
[
"public",
"function",
"getCommits",
"(",
"$",
"user",
",",
"$",
"repo",
",",
"$",
"pullId",
",",
"$",
"page",
"=",
"0",
",",
"$",
"limit",
"=",
"0",
")",
"{",
"// Build the request path.",
"$",
"path",
"=",
"'/repos/'",
".",
"$",
"user",
".",
"'/'",
".",
"$",
"repo",
".",
"'/pulls/'",
".",
"(",
"int",
")",
"$",
"pullId",
".",
"'/commits'",
";",
"// Send the request.",
"return",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"this",
"->",
"client",
"->",
"get",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"path",
",",
"$",
"page",
",",
"$",
"limit",
")",
")",
")",
";",
"}"
] |
List commits on a pull request.
@param string $user The name of the owner of the GitHub repository.
@param string $repo The name of the GitHub repository.
@param integer $pullId The pull request number.
@param integer $page The page number from which to get items.
@param integer $limit The number of items on a page.
@return object
@since 1.0
@throws \DomainException
|
[
"List",
"commits",
"on",
"a",
"pull",
"request",
"."
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Pulls.php#L187-L194
|
224,630
|
joomla-framework/github-api
|
src/Package/Search.php
|
Search.issues
|
public function issues($owner, $repo, $state, $keyword)
{
if (\in_array($state, array('open', 'close')) == false)
{
throw new \UnexpectedValueException('State must be either "open" or "closed"');
}
// Build the request path.
$path = '/legacy/issues/search/' . $owner . '/' . $repo . '/' . $state . '/' . $keyword;
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
|
php
|
public function issues($owner, $repo, $state, $keyword)
{
if (\in_array($state, array('open', 'close')) == false)
{
throw new \UnexpectedValueException('State must be either "open" or "closed"');
}
// Build the request path.
$path = '/legacy/issues/search/' . $owner . '/' . $repo . '/' . $state . '/' . $keyword;
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
|
[
"public",
"function",
"issues",
"(",
"$",
"owner",
",",
"$",
"repo",
",",
"$",
"state",
",",
"$",
"keyword",
")",
"{",
"if",
"(",
"\\",
"in_array",
"(",
"$",
"state",
",",
"array",
"(",
"'open'",
",",
"'close'",
")",
")",
"==",
"false",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"'State must be either \"open\" or \"closed\"'",
")",
";",
"}",
"// Build the request path.",
"$",
"path",
"=",
"'/legacy/issues/search/'",
".",
"$",
"owner",
".",
"'/'",
".",
"$",
"repo",
".",
"'/'",
".",
"$",
"state",
".",
"'/'",
".",
"$",
"keyword",
";",
"// Send the request.",
"return",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"this",
"->",
"client",
"->",
"get",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"path",
")",
")",
")",
";",
"}"
] |
Search issues.
@param string $owner The name of the owner of the repository.
@param string $repo The name of the repository.
@param string $state The state - open or closed.
@param string $keyword The search term.
@return object
@since 1.0
@throws \UnexpectedValueException
@deprecated The legacy API is deprecated
|
[
"Search",
"issues",
"."
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Search.php#L37-L51
|
224,631
|
codebach/PianoSoloWeatherBundle
|
Controller/WeatherController.php
|
WeatherController.generateCsvAction
|
public function generateCsvAction($city, $days)
{
if ($this->getParameter('pianosolo.weather.options.download_csv') === TRUE) {
$weatherHandler = $this->get('pianosolo.weather');
$weathers = $weatherHandler->getForecastObject($city, $days);
if (!empty($weathers)) {
// Creating CSV Response
$csvResponse = new WeatherCsvResponse($weathers, $city);
return $csvResponse->createCsvResponse();
}
throw $this->createNotFoundException('City Not Found!');
}
throw $this->createNotFoundException('Page Not Found!');
}
|
php
|
public function generateCsvAction($city, $days)
{
if ($this->getParameter('pianosolo.weather.options.download_csv') === TRUE) {
$weatherHandler = $this->get('pianosolo.weather');
$weathers = $weatherHandler->getForecastObject($city, $days);
if (!empty($weathers)) {
// Creating CSV Response
$csvResponse = new WeatherCsvResponse($weathers, $city);
return $csvResponse->createCsvResponse();
}
throw $this->createNotFoundException('City Not Found!');
}
throw $this->createNotFoundException('Page Not Found!');
}
|
[
"public",
"function",
"generateCsvAction",
"(",
"$",
"city",
",",
"$",
"days",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getParameter",
"(",
"'pianosolo.weather.options.download_csv'",
")",
"===",
"TRUE",
")",
"{",
"$",
"weatherHandler",
"=",
"$",
"this",
"->",
"get",
"(",
"'pianosolo.weather'",
")",
";",
"$",
"weathers",
"=",
"$",
"weatherHandler",
"->",
"getForecastObject",
"(",
"$",
"city",
",",
"$",
"days",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"weathers",
")",
")",
"{",
"// Creating CSV Response",
"$",
"csvResponse",
"=",
"new",
"WeatherCsvResponse",
"(",
"$",
"weathers",
",",
"$",
"city",
")",
";",
"return",
"$",
"csvResponse",
"->",
"createCsvResponse",
"(",
")",
";",
"}",
"throw",
"$",
"this",
"->",
"createNotFoundException",
"(",
"'City Not Found!'",
")",
";",
"}",
"throw",
"$",
"this",
"->",
"createNotFoundException",
"(",
"'Page Not Found!'",
")",
";",
"}"
] |
Downloads Weather List of City as CSV
@param mixed (int|string) $city
@param integer $days
@return Response
@throws NotFoundHttpException
|
[
"Downloads",
"Weather",
"List",
"of",
"City",
"as",
"CSV"
] |
f6b3ce0a86dbd8ab4e23d4e2d3031e6d4af0e269
|
https://github.com/codebach/PianoSoloWeatherBundle/blob/f6b3ce0a86dbd8ab4e23d4e2d3031e6d4af0e269/Controller/WeatherController.php#L22-L40
|
224,632
|
acacha/users
|
src/Http/Controllers/APILoggedUserController.php
|
APILoggedUserController.update
|
public function update(LoggedUserUpdate $request)
{
$user = Auth::user();
$user->update($request->only(['name','email','password']));
return $user;
}
|
php
|
public function update(LoggedUserUpdate $request)
{
$user = Auth::user();
$user->update($request->only(['name','email','password']));
return $user;
}
|
[
"public",
"function",
"update",
"(",
"LoggedUserUpdate",
"$",
"request",
")",
"{",
"$",
"user",
"=",
"Auth",
"::",
"user",
"(",
")",
";",
"$",
"user",
"->",
"update",
"(",
"$",
"request",
"->",
"only",
"(",
"[",
"'name'",
",",
"'email'",
",",
"'password'",
"]",
")",
")",
";",
"return",
"$",
"user",
";",
"}"
] |
Update logged user.
@return Response
|
[
"Update",
"logged",
"user",
"."
] |
af74be23d225bc9a23ee049579abb1596ae683c0
|
https://github.com/acacha/users/blob/af74be23d225bc9a23ee049579abb1596ae683c0/src/Http/Controllers/APILoggedUserController.php#L30-L36
|
224,633
|
netz98/n98-deployer
|
src/Deployer/Service/GetReleasesNameService.php
|
GetReleasesNameService.execute
|
public static function execute()
{
$release = null;
// Get release-name from branch
$input = \Deployer\input();
if ($input->hasOption('branch')) {
$branch = $input->getOption('branch');
if (!empty($branch)) {
$release = $branch;
}
}
if ($release !== null) {
return $release;
}
// Get release-name from tag
$input = \Deployer\input();
if ($input->hasOption('tag')) {
$tag = $input->getOption('tag');
if (!empty($tag)) {
$release = $tag;
}
}
if ($release !== null) {
return $release;
}
$release = date('Ymdhis');
return $release;
}
|
php
|
public static function execute()
{
$release = null;
// Get release-name from branch
$input = \Deployer\input();
if ($input->hasOption('branch')) {
$branch = $input->getOption('branch');
if (!empty($branch)) {
$release = $branch;
}
}
if ($release !== null) {
return $release;
}
// Get release-name from tag
$input = \Deployer\input();
if ($input->hasOption('tag')) {
$tag = $input->getOption('tag');
if (!empty($tag)) {
$release = $tag;
}
}
if ($release !== null) {
return $release;
}
$release = date('Ymdhis');
return $release;
}
|
[
"public",
"static",
"function",
"execute",
"(",
")",
"{",
"$",
"release",
"=",
"null",
";",
"// Get release-name from branch",
"$",
"input",
"=",
"\\",
"Deployer",
"\\",
"input",
"(",
")",
";",
"if",
"(",
"$",
"input",
"->",
"hasOption",
"(",
"'branch'",
")",
")",
"{",
"$",
"branch",
"=",
"$",
"input",
"->",
"getOption",
"(",
"'branch'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"branch",
")",
")",
"{",
"$",
"release",
"=",
"$",
"branch",
";",
"}",
"}",
"if",
"(",
"$",
"release",
"!==",
"null",
")",
"{",
"return",
"$",
"release",
";",
"}",
"// Get release-name from tag",
"$",
"input",
"=",
"\\",
"Deployer",
"\\",
"input",
"(",
")",
";",
"if",
"(",
"$",
"input",
"->",
"hasOption",
"(",
"'tag'",
")",
")",
"{",
"$",
"tag",
"=",
"$",
"input",
"->",
"getOption",
"(",
"'tag'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"tag",
")",
")",
"{",
"$",
"release",
"=",
"$",
"tag",
";",
"}",
"}",
"if",
"(",
"$",
"release",
"!==",
"null",
")",
"{",
"return",
"$",
"release",
";",
"}",
"$",
"release",
"=",
"date",
"(",
"'Ymdhis'",
")",
";",
"return",
"$",
"release",
";",
"}"
] |
Determine the release name by branch or tag, otherwise uses datetime string
this method is an overwrite of the Deployer release-name logic
@return string
|
[
"Determine",
"the",
"release",
"name",
"by",
"branch",
"or",
"tag",
"otherwise",
"uses",
"datetime",
"string"
] |
cf7b7c790f45c41ed338b8a33b498eeaaaa765e9
|
https://github.com/netz98/n98-deployer/blob/cf7b7c790f45c41ed338b8a33b498eeaaaa765e9/src/Deployer/Service/GetReleasesNameService.php#L22-L55
|
224,634
|
phootwork/collection
|
src/Map.php
|
Map.set
|
public function set($key, $element) {
$key = $this->extractKey($key);
$this->collection[$key] = $element;
return $this;
}
|
php
|
public function set($key, $element) {
$key = $this->extractKey($key);
$this->collection[$key] = $element;
return $this;
}
|
[
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"element",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"extractKey",
"(",
"$",
"key",
")",
";",
"$",
"this",
"->",
"collection",
"[",
"$",
"key",
"]",
"=",
"$",
"element",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets an element with the given key on that map
@param string key
@param mixed $element
@return Map $this
|
[
"Sets",
"an",
"element",
"with",
"the",
"given",
"key",
"on",
"that",
"map"
] |
e745fe3735a6f2099015d11ea7b917634ebf76f3
|
https://github.com/phootwork/collection/blob/e745fe3735a6f2099015d11ea7b917634ebf76f3/src/Map.php#L43-L48
|
224,635
|
phootwork/collection
|
src/Map.php
|
Map.get
|
public function get($key, $default = null) {
$key = $this->extractKey($key);
if (isset($this->collection[$key])) {
return $this->collection[$key];
} else {
return $default;
}
}
|
php
|
public function get($key, $default = null) {
$key = $this->extractKey($key);
if (isset($this->collection[$key])) {
return $this->collection[$key];
} else {
return $default;
}
}
|
[
"public",
"function",
"get",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"extractKey",
"(",
"$",
"key",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"collection",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"collection",
"[",
"$",
"key",
"]",
";",
"}",
"else",
"{",
"return",
"$",
"default",
";",
"}",
"}"
] |
Returns the element for the given key or your value, if the key doesn't exist.
@param string $key
@param mixed $default the return value, if the key doesn't exist
@return mixed
|
[
"Returns",
"the",
"element",
"for",
"the",
"given",
"key",
"or",
"your",
"value",
"if",
"the",
"key",
"doesn",
"t",
"exist",
"."
] |
e745fe3735a6f2099015d11ea7b917634ebf76f3
|
https://github.com/phootwork/collection/blob/e745fe3735a6f2099015d11ea7b917634ebf76f3/src/Map.php#L57-L64
|
224,636
|
phootwork/collection
|
src/Map.php
|
Map.getKey
|
public function getKey($value) {
foreach ($this->collection as $k => $v) {
if ($v === $value) {
return $k;
}
}
return null;
}
|
php
|
public function getKey($value) {
foreach ($this->collection as $k => $v) {
if ($v === $value) {
return $k;
}
}
return null;
}
|
[
"public",
"function",
"getKey",
"(",
"$",
"value",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"collection",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"$",
"v",
"===",
"$",
"value",
")",
"{",
"return",
"$",
"k",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Returns the key for the given value
@param mixed $value the value
@return mixed
|
[
"Returns",
"the",
"key",
"for",
"the",
"given",
"value"
] |
e745fe3735a6f2099015d11ea7b917634ebf76f3
|
https://github.com/phootwork/collection/blob/e745fe3735a6f2099015d11ea7b917634ebf76f3/src/Map.php#L72-L80
|
224,637
|
phootwork/collection
|
src/Map.php
|
Map.setAll
|
public function setAll($collection) {
foreach ($collection as $key => $element) {
$this->set($key, $element);
}
return $this;
}
|
php
|
public function setAll($collection) {
foreach ($collection as $key => $element) {
$this->set($key, $element);
}
return $this;
}
|
[
"public",
"function",
"setAll",
"(",
"$",
"collection",
")",
"{",
"foreach",
"(",
"$",
"collection",
"as",
"$",
"key",
"=>",
"$",
"element",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"element",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Sets many elements on that map
@param array|Iterator $collection
@return Map $this
|
[
"Sets",
"many",
"elements",
"on",
"that",
"map"
] |
e745fe3735a6f2099015d11ea7b917634ebf76f3
|
https://github.com/phootwork/collection/blob/e745fe3735a6f2099015d11ea7b917634ebf76f3/src/Map.php#L88-L94
|
224,638
|
phootwork/collection
|
src/Map.php
|
Map.remove
|
public function remove($key) {
$key = $this->extractKey($key);
if (isset($this->collection[$key])) {
$element = $this->collection[$key];
unset($this->collection[$key]);
return $element;
}
}
|
php
|
public function remove($key) {
$key = $this->extractKey($key);
if (isset($this->collection[$key])) {
$element = $this->collection[$key];
unset($this->collection[$key]);
return $element;
}
}
|
[
"public",
"function",
"remove",
"(",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"extractKey",
"(",
"$",
"key",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"collection",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"element",
"=",
"$",
"this",
"->",
"collection",
"[",
"$",
"key",
"]",
";",
"unset",
"(",
"$",
"this",
"->",
"collection",
"[",
"$",
"key",
"]",
")",
";",
"return",
"$",
"element",
";",
"}",
"}"
] |
Removes and returns an element from the map by the given key. Returns null if the key
does not exist.
@param string $key
@return mixed the element at the given key
|
[
"Removes",
"and",
"returns",
"an",
"element",
"from",
"the",
"map",
"by",
"the",
"given",
"key",
".",
"Returns",
"null",
"if",
"the",
"key",
"does",
"not",
"exist",
"."
] |
e745fe3735a6f2099015d11ea7b917634ebf76f3
|
https://github.com/phootwork/collection/blob/e745fe3735a6f2099015d11ea7b917634ebf76f3/src/Map.php#L103-L111
|
224,639
|
phootwork/collection
|
src/Map.php
|
Map.has
|
public function has($key) {
$key = $this->extractKey($key);
return isset($this->collection[$key]);
}
|
php
|
public function has($key) {
$key = $this->extractKey($key);
return isset($this->collection[$key]);
}
|
[
"public",
"function",
"has",
"(",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"extractKey",
"(",
"$",
"key",
")",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"collection",
"[",
"$",
"key",
"]",
")",
";",
"}"
] |
Returns whether the key exist.
@param string $key
@return boolean
|
[
"Returns",
"whether",
"the",
"key",
"exist",
"."
] |
e745fe3735a6f2099015d11ea7b917634ebf76f3
|
https://github.com/phootwork/collection/blob/e745fe3735a6f2099015d11ea7b917634ebf76f3/src/Map.php#L137-L140
|
224,640
|
phootwork/collection
|
src/Map.php
|
Map.findKey
|
public function findKey() {
if (func_num_args() == 1) {
$callback = func_get_arg(0);
} else {
$query = func_get_arg(0);
$callback = func_get_arg(1);
}
$index = func_num_args() == 1 ? $this->find($callback) : $this->find($query, $callback);
if ($index !== null) {
$index = $this->getKey($index);
}
return $index;
}
|
php
|
public function findKey() {
if (func_num_args() == 1) {
$callback = func_get_arg(0);
} else {
$query = func_get_arg(0);
$callback = func_get_arg(1);
}
$index = func_num_args() == 1 ? $this->find($callback) : $this->find($query, $callback);
if ($index !== null) {
$index = $this->getKey($index);
}
return $index;
}
|
[
"public",
"function",
"findKey",
"(",
")",
"{",
"if",
"(",
"func_num_args",
"(",
")",
"==",
"1",
")",
"{",
"$",
"callback",
"=",
"func_get_arg",
"(",
"0",
")",
";",
"}",
"else",
"{",
"$",
"query",
"=",
"func_get_arg",
"(",
"0",
")",
";",
"$",
"callback",
"=",
"func_get_arg",
"(",
"1",
")",
";",
"}",
"$",
"index",
"=",
"func_num_args",
"(",
")",
"==",
"1",
"?",
"$",
"this",
"->",
"find",
"(",
"$",
"callback",
")",
":",
"$",
"this",
"->",
"find",
"(",
"$",
"query",
",",
"$",
"callback",
")",
";",
"if",
"(",
"$",
"index",
"!==",
"null",
")",
"{",
"$",
"index",
"=",
"$",
"this",
"->",
"getKey",
"(",
"$",
"index",
")",
";",
"}",
"return",
"$",
"index",
";",
"}"
] |
Searches the collection with a given callback and returns the key for the first element if found.
The callback function takes one or two parameters:
function ($element [, $query]) {}
The callback must return a boolean
@param mixed $query OPTIONAL the provided query
@param callable $callback the callback function
@return mixed|null the key or null if it hasn't been found
|
[
"Searches",
"the",
"collection",
"with",
"a",
"given",
"callback",
"and",
"returns",
"the",
"key",
"for",
"the",
"first",
"element",
"if",
"found",
"."
] |
e745fe3735a6f2099015d11ea7b917634ebf76f3
|
https://github.com/phootwork/collection/blob/e745fe3735a6f2099015d11ea7b917634ebf76f3/src/Map.php#L190-L204
|
224,641
|
phootwork/collection
|
src/Map.php
|
Map.findLastKey
|
public function findLastKey() {
if (func_num_args() == 1) {
$callback = func_get_arg(0);
} else {
$query = func_get_arg(0);
$callback = func_get_arg(1);
}
$index = func_num_args() == 1 ? $this->findLast($callback) : $this->findLast($query, $callback);
if ($index !== null) {
$index = $this->getKey($index);
}
return $index;
}
|
php
|
public function findLastKey() {
if (func_num_args() == 1) {
$callback = func_get_arg(0);
} else {
$query = func_get_arg(0);
$callback = func_get_arg(1);
}
$index = func_num_args() == 1 ? $this->findLast($callback) : $this->findLast($query, $callback);
if ($index !== null) {
$index = $this->getKey($index);
}
return $index;
}
|
[
"public",
"function",
"findLastKey",
"(",
")",
"{",
"if",
"(",
"func_num_args",
"(",
")",
"==",
"1",
")",
"{",
"$",
"callback",
"=",
"func_get_arg",
"(",
"0",
")",
";",
"}",
"else",
"{",
"$",
"query",
"=",
"func_get_arg",
"(",
"0",
")",
";",
"$",
"callback",
"=",
"func_get_arg",
"(",
"1",
")",
";",
"}",
"$",
"index",
"=",
"func_num_args",
"(",
")",
"==",
"1",
"?",
"$",
"this",
"->",
"findLast",
"(",
"$",
"callback",
")",
":",
"$",
"this",
"->",
"findLast",
"(",
"$",
"query",
",",
"$",
"callback",
")",
";",
"if",
"(",
"$",
"index",
"!==",
"null",
")",
"{",
"$",
"index",
"=",
"$",
"this",
"->",
"getKey",
"(",
"$",
"index",
")",
";",
"}",
"return",
"$",
"index",
";",
"}"
] |
Searches the collection with a given callback and returns the key for the last element if found.
The callback function takes one or two parameters:
function ($element [, $query]) {}
The callback must return a boolean
@param mixed $query OPTIONAL the provided query
@param callable $callback the callback function
@return mixed|null the key or null if it hasn't been found
|
[
"Searches",
"the",
"collection",
"with",
"a",
"given",
"callback",
"and",
"returns",
"the",
"key",
"for",
"the",
"last",
"element",
"if",
"found",
"."
] |
e745fe3735a6f2099015d11ea7b917634ebf76f3
|
https://github.com/phootwork/collection/blob/e745fe3735a6f2099015d11ea7b917634ebf76f3/src/Map.php#L219-L233
|
224,642
|
hnhdigital-os/laravel-model-json
|
src/JsonColumnTrait.php
|
JsonColumnTrait.checkValuesUponSave
|
public function checkValuesUponSave()
{
foreach ($this->getJsonColumns() as $column_name) {
if (isset($this->attributes[$column_name]) && !is_string($this->attributes[$column_name])) {
if (is_array($this->attributes[$column_name])) {
$this->attributes[$column_name] = json_encode($this->attributes[$column_name]);
} elseif (is_object($this->attributes[$column_name])) {
$this->attributes[$column_name] = (string) $this->attributes[$column_name];
}
}
}
}
|
php
|
public function checkValuesUponSave()
{
foreach ($this->getJsonColumns() as $column_name) {
if (isset($this->attributes[$column_name]) && !is_string($this->attributes[$column_name])) {
if (is_array($this->attributes[$column_name])) {
$this->attributes[$column_name] = json_encode($this->attributes[$column_name]);
} elseif (is_object($this->attributes[$column_name])) {
$this->attributes[$column_name] = (string) $this->attributes[$column_name];
}
}
}
}
|
[
"public",
"function",
"checkValuesUponSave",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getJsonColumns",
"(",
")",
"as",
"$",
"column_name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"attributes",
"[",
"$",
"column_name",
"]",
")",
"&&",
"!",
"is_string",
"(",
"$",
"this",
"->",
"attributes",
"[",
"$",
"column_name",
"]",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"attributes",
"[",
"$",
"column_name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"attributes",
"[",
"$",
"column_name",
"]",
"=",
"json_encode",
"(",
"$",
"this",
"->",
"attributes",
"[",
"$",
"column_name",
"]",
")",
";",
"}",
"elseif",
"(",
"is_object",
"(",
"$",
"this",
"->",
"attributes",
"[",
"$",
"column_name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"attributes",
"[",
"$",
"column_name",
"]",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"attributes",
"[",
"$",
"column_name",
"]",
";",
"}",
"}",
"}",
"}"
] |
Checks values and ensures the json values are in the correct format.
@return void
|
[
"Checks",
"values",
"and",
"ensures",
"the",
"json",
"values",
"are",
"in",
"the",
"correct",
"format",
"."
] |
092511d2ce76ffbd1e3a94c9bed48df9ce0be643
|
https://github.com/hnhdigital-os/laravel-model-json/blob/092511d2ce76ffbd1e3a94c9bed48df9ce0be643/src/JsonColumnTrait.php#L66-L77
|
224,643
|
hnhdigital-os/laravel-model-json
|
src/JsonColumnTrait.php
|
JsonColumnTrait.inspectJson
|
public function inspectJson()
{
if (!empty($this->json_columns)) {
foreach ($this->json_columns as $column_name) {
if (!in_array($column_name, static::$protected_columns)) {
$this->processJson($column_name, $this->attributes[$column_name]);
}
}
}
}
|
php
|
public function inspectJson()
{
if (!empty($this->json_columns)) {
foreach ($this->json_columns as $column_name) {
if (!in_array($column_name, static::$protected_columns)) {
$this->processJson($column_name, $this->attributes[$column_name]);
}
}
}
}
|
[
"public",
"function",
"inspectJson",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"json_columns",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"json_columns",
"as",
"$",
"column_name",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"column_name",
",",
"static",
"::",
"$",
"protected_columns",
")",
")",
"{",
"$",
"this",
"->",
"processJson",
"(",
"$",
"column_name",
",",
"$",
"this",
"->",
"attributes",
"[",
"$",
"column_name",
"]",
")",
";",
"}",
"}",
"}",
"}"
] |
Decodes each of the declared JSON attributes and allocates them to
the json value object. Binds closures based on the column name to
access and update the values.
@return void
|
[
"Decodes",
"each",
"of",
"the",
"declared",
"JSON",
"attributes",
"and",
"allocates",
"them",
"to",
"the",
"json",
"value",
"object",
".",
"Binds",
"closures",
"based",
"on",
"the",
"column",
"name",
"to",
"access",
"and",
"update",
"the",
"values",
"."
] |
092511d2ce76ffbd1e3a94c9bed48df9ce0be643
|
https://github.com/hnhdigital-os/laravel-model-json/blob/092511d2ce76ffbd1e3a94c9bed48df9ce0be643/src/JsonColumnTrait.php#L117-L126
|
224,644
|
hnhdigital-os/laravel-model-json
|
src/JsonColumnTrait.php
|
JsonColumnTrait.processJson
|
public function processJson($column_name, &$value)
{
if (empty($value) || $value === 'null') {
$value = [];
}
$defaults = (!empty($this->json_defaults[$column_name])) ? $this->json_defaults[$column_name] : [];
$options = (!empty($this->json_options[$column_name])) ? $this->json_options[$column_name] : [];
// Only create the json value object if it hasn't been done already.
if (!isset($this->json_values[$column_name]) || !is_object($this->json_values[$column_name])) {
$this->json_values[$column_name] = new JsonColumnValue($value, $defaults, $options);
$json_column_access = function &($column_name) {
return $this->json_values[$column_name];
};
$this->json_methods[$column_name] = Closure::bind($json_column_access, $this, static::class);
}
}
|
php
|
public function processJson($column_name, &$value)
{
if (empty($value) || $value === 'null') {
$value = [];
}
$defaults = (!empty($this->json_defaults[$column_name])) ? $this->json_defaults[$column_name] : [];
$options = (!empty($this->json_options[$column_name])) ? $this->json_options[$column_name] : [];
// Only create the json value object if it hasn't been done already.
if (!isset($this->json_values[$column_name]) || !is_object($this->json_values[$column_name])) {
$this->json_values[$column_name] = new JsonColumnValue($value, $defaults, $options);
$json_column_access = function &($column_name) {
return $this->json_values[$column_name];
};
$this->json_methods[$column_name] = Closure::bind($json_column_access, $this, static::class);
}
}
|
[
"public",
"function",
"processJson",
"(",
"$",
"column_name",
",",
"&",
"$",
"value",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"value",
")",
"||",
"$",
"value",
"===",
"'null'",
")",
"{",
"$",
"value",
"=",
"[",
"]",
";",
"}",
"$",
"defaults",
"=",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"json_defaults",
"[",
"$",
"column_name",
"]",
")",
")",
"?",
"$",
"this",
"->",
"json_defaults",
"[",
"$",
"column_name",
"]",
":",
"[",
"]",
";",
"$",
"options",
"=",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"json_options",
"[",
"$",
"column_name",
"]",
")",
")",
"?",
"$",
"this",
"->",
"json_options",
"[",
"$",
"column_name",
"]",
":",
"[",
"]",
";",
"// Only create the json value object if it hasn't been done already.",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"json_values",
"[",
"$",
"column_name",
"]",
")",
"||",
"!",
"is_object",
"(",
"$",
"this",
"->",
"json_values",
"[",
"$",
"column_name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"json_values",
"[",
"$",
"column_name",
"]",
"=",
"new",
"JsonColumnValue",
"(",
"$",
"value",
",",
"$",
"defaults",
",",
"$",
"options",
")",
";",
"$",
"json_column_access",
"=",
"function",
"&",
"(",
"$",
"column_name",
")",
"{",
"return",
"$",
"this",
"->",
"json_values",
"[",
"$",
"column_name",
"]",
";",
"}",
";",
"$",
"this",
"->",
"json_methods",
"[",
"$",
"column_name",
"]",
"=",
"Closure",
"::",
"bind",
"(",
"$",
"json_column_access",
",",
"$",
"this",
",",
"static",
"::",
"class",
")",
";",
"}",
"}"
] |
Process the json column.
@param string $column_name
@param mixed &$value
@return void
@SuppressWarnings(PHPMD.StaticAccess)
|
[
"Process",
"the",
"json",
"column",
"."
] |
092511d2ce76ffbd1e3a94c9bed48df9ce0be643
|
https://github.com/hnhdigital-os/laravel-model-json/blob/092511d2ce76ffbd1e3a94c9bed48df9ce0be643/src/JsonColumnTrait.php#L138-L154
|
224,645
|
hnhdigital-os/laravel-model-json
|
src/JsonColumnTrait.php
|
JsonColumnTrait.getOriginal
|
public function getOriginal($key = null, $default = null)
{
$original = parent::getOriginal($key, $default);
if (!empty($this->json_values)) {
if ($key === null) {
foreach ($this->json_values as $column_name => &$json_data) {
$original[$column_name] = $json_data->getOriginal();
}
return $original;
}
$key_array = explode('.', $key, 2);
if (count($key_array) > 1) {
list($column_name, $json_key) = $key_array;
if (array_key_exists($column_name, $this->json_values)) {
return $this->json_values[$column_name]->getOriginal($json_key, $default);
}
return $default;
}
}
return $original;
}
|
php
|
public function getOriginal($key = null, $default = null)
{
$original = parent::getOriginal($key, $default);
if (!empty($this->json_values)) {
if ($key === null) {
foreach ($this->json_values as $column_name => &$json_data) {
$original[$column_name] = $json_data->getOriginal();
}
return $original;
}
$key_array = explode('.', $key, 2);
if (count($key_array) > 1) {
list($column_name, $json_key) = $key_array;
if (array_key_exists($column_name, $this->json_values)) {
return $this->json_values[$column_name]->getOriginal($json_key, $default);
}
return $default;
}
}
return $original;
}
|
[
"public",
"function",
"getOriginal",
"(",
"$",
"key",
"=",
"null",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"original",
"=",
"parent",
"::",
"getOriginal",
"(",
"$",
"key",
",",
"$",
"default",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"json_values",
")",
")",
"{",
"if",
"(",
"$",
"key",
"===",
"null",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"json_values",
"as",
"$",
"column_name",
"=>",
"&",
"$",
"json_data",
")",
"{",
"$",
"original",
"[",
"$",
"column_name",
"]",
"=",
"$",
"json_data",
"->",
"getOriginal",
"(",
")",
";",
"}",
"return",
"$",
"original",
";",
"}",
"$",
"key_array",
"=",
"explode",
"(",
"'.'",
",",
"$",
"key",
",",
"2",
")",
";",
"if",
"(",
"count",
"(",
"$",
"key_array",
")",
">",
"1",
")",
"{",
"list",
"(",
"$",
"column_name",
",",
"$",
"json_key",
")",
"=",
"$",
"key_array",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"column_name",
",",
"$",
"this",
"->",
"json_values",
")",
")",
"{",
"return",
"$",
"this",
"->",
"json_values",
"[",
"$",
"column_name",
"]",
"->",
"getOriginal",
"(",
"$",
"json_key",
",",
"$",
"default",
")",
";",
"}",
"return",
"$",
"default",
";",
"}",
"}",
"return",
"$",
"original",
";",
"}"
] |
Get the model's original attribute values.
@param string|null $key
@param mixed $default
@return array
|
[
"Get",
"the",
"model",
"s",
"original",
"attribute",
"values",
"."
] |
092511d2ce76ffbd1e3a94c9bed48df9ce0be643
|
https://github.com/hnhdigital-os/laravel-model-json/blob/092511d2ce76ffbd1e3a94c9bed48df9ce0be643/src/JsonColumnTrait.php#L185-L208
|
224,646
|
hnhdigital-os/laravel-model-json
|
src/JsonColumnTrait.php
|
JsonColumnTrait.fromJson
|
public function fromJson($value, $asObject = false)
{
if (is_array($value)) {
return $value;
}
return json_decode($value, !$asObject);
}
|
php
|
public function fromJson($value, $asObject = false)
{
if (is_array($value)) {
return $value;
}
return json_decode($value, !$asObject);
}
|
[
"public",
"function",
"fromJson",
"(",
"$",
"value",
",",
"$",
"asObject",
"=",
"false",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"return",
"json_decode",
"(",
"$",
"value",
",",
"!",
"$",
"asObject",
")",
";",
"}"
] |
Decode the given JSON back into an array or object.
@param string $value
@param bool $asObject
@return mixed
|
[
"Decode",
"the",
"given",
"JSON",
"back",
"into",
"an",
"array",
"or",
"object",
"."
] |
092511d2ce76ffbd1e3a94c9bed48df9ce0be643
|
https://github.com/hnhdigital-os/laravel-model-json/blob/092511d2ce76ffbd1e3a94c9bed48df9ce0be643/src/JsonColumnTrait.php#L218-L225
|
224,647
|
atorscho/membership
|
src/Membership.php
|
Membership.user
|
public function user(?string $attribute = null)
{
if ($this->isGuest()) {
return null;
}
$user = auth()->user();
if ($attribute) {
return $user->{$attribute};
}
return $user;
}
|
php
|
public function user(?string $attribute = null)
{
if ($this->isGuest()) {
return null;
}
$user = auth()->user();
if ($attribute) {
return $user->{$attribute};
}
return $user;
}
|
[
"public",
"function",
"user",
"(",
"?",
"string",
"$",
"attribute",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isGuest",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"user",
"=",
"auth",
"(",
")",
"->",
"user",
"(",
")",
";",
"if",
"(",
"$",
"attribute",
")",
"{",
"return",
"$",
"user",
"->",
"{",
"$",
"attribute",
"}",
";",
"}",
"return",
"$",
"user",
";",
"}"
] |
Retrieve currently authenticated user or its attribute value.
@param string|null $attribute Optional.
@return \Illuminate\Contracts\Auth\Authenticatable|string|null
|
[
"Retrieve",
"currently",
"authenticated",
"user",
"or",
"its",
"attribute",
"value",
"."
] |
c39ee69b5bc33702912fb16ef4f4736eaf1e6d71
|
https://github.com/atorscho/membership/blob/c39ee69b5bc33702912fb16ef4f4736eaf1e6d71/src/Membership.php#L42-L55
|
224,648
|
atorscho/membership
|
src/Membership.php
|
Membership.registerGatePolicies
|
public function registerGatePolicies(): void
{
if (!\Schema::hasTable('permissions')) {
return;
}
$permissions = Permission::all(['handle', 'type']);
foreach ($permissions as $permission) {
Gate::define($permission->code, function (Authenticatable $user, ?Model $model = null, string $userForeignKey = 'user_id') use ($permission) {
return $user->hasPermission($permission->code, $model, $userForeignKey);
});
}
}
|
php
|
public function registerGatePolicies(): void
{
if (!\Schema::hasTable('permissions')) {
return;
}
$permissions = Permission::all(['handle', 'type']);
foreach ($permissions as $permission) {
Gate::define($permission->code, function (Authenticatable $user, ?Model $model = null, string $userForeignKey = 'user_id') use ($permission) {
return $user->hasPermission($permission->code, $model, $userForeignKey);
});
}
}
|
[
"public",
"function",
"registerGatePolicies",
"(",
")",
":",
"void",
"{",
"if",
"(",
"!",
"\\",
"Schema",
"::",
"hasTable",
"(",
"'permissions'",
")",
")",
"{",
"return",
";",
"}",
"$",
"permissions",
"=",
"Permission",
"::",
"all",
"(",
"[",
"'handle'",
",",
"'type'",
"]",
")",
";",
"foreach",
"(",
"$",
"permissions",
"as",
"$",
"permission",
")",
"{",
"Gate",
"::",
"define",
"(",
"$",
"permission",
"->",
"code",
",",
"function",
"(",
"Authenticatable",
"$",
"user",
",",
"?",
"Model",
"$",
"model",
"=",
"null",
",",
"string",
"$",
"userForeignKey",
"=",
"'user_id'",
")",
"use",
"(",
"$",
"permission",
")",
"{",
"return",
"$",
"user",
"->",
"hasPermission",
"(",
"$",
"permission",
"->",
"code",
",",
"$",
"model",
",",
"$",
"userForeignKey",
")",
";",
"}",
")",
";",
"}",
"}"
] |
Register Gate policies in order to integrate
Membership into Laravel Authorization system.
|
[
"Register",
"Gate",
"policies",
"in",
"order",
"to",
"integrate",
"Membership",
"into",
"Laravel",
"Authorization",
"system",
"."
] |
c39ee69b5bc33702912fb16ef4f4736eaf1e6d71
|
https://github.com/atorscho/membership/blob/c39ee69b5bc33702912fb16ef4f4736eaf1e6d71/src/Membership.php#L61-L74
|
224,649
|
joomla-framework/github-api
|
src/Package/Graphql.php
|
Graphql.execute
|
public function execute($query, array $variables = array())
{
// Build the request path.
$path = '/graphql';
$headers = array(
'Accept' => 'application/vnd.github.v4+json',
'Content-Type' => 'application/json',
);
$data = array(
'query' => $query,
);
if (!empty($variables))
{
$data['variables'] = $variables;
}
// Send the request.
return $this->processResponse(
$this->client->post($this->fetchUrl($path), json_encode($data), $headers)
);
}
|
php
|
public function execute($query, array $variables = array())
{
// Build the request path.
$path = '/graphql';
$headers = array(
'Accept' => 'application/vnd.github.v4+json',
'Content-Type' => 'application/json',
);
$data = array(
'query' => $query,
);
if (!empty($variables))
{
$data['variables'] = $variables;
}
// Send the request.
return $this->processResponse(
$this->client->post($this->fetchUrl($path), json_encode($data), $headers)
);
}
|
[
"public",
"function",
"execute",
"(",
"$",
"query",
",",
"array",
"$",
"variables",
"=",
"array",
"(",
")",
")",
"{",
"// Build the request path.",
"$",
"path",
"=",
"'/graphql'",
";",
"$",
"headers",
"=",
"array",
"(",
"'Accept'",
"=>",
"'application/vnd.github.v4+json'",
",",
"'Content-Type'",
"=>",
"'application/json'",
",",
")",
";",
"$",
"data",
"=",
"array",
"(",
"'query'",
"=>",
"$",
"query",
",",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"variables",
")",
")",
"{",
"$",
"data",
"[",
"'variables'",
"]",
"=",
"$",
"variables",
";",
"}",
"// Send the request.",
"return",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"this",
"->",
"client",
"->",
"post",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"path",
")",
",",
"json_encode",
"(",
"$",
"data",
")",
",",
"$",
"headers",
")",
")",
";",
"}"
] |
Execute a query against the GraphQL API.
@param string $query The query to perform.
@param array $variables An optional array of variables to include in the request.
@return string
@since 1.6.0
|
[
"Execute",
"a",
"query",
"against",
"the",
"GraphQL",
"API",
"."
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Graphql.php#L32-L55
|
224,650
|
joomla-framework/github-api
|
src/Package/Orgs.php
|
Orgs.edit
|
public function edit($org, $billingEmail = '', $company = '', $email = '', $location = '', $name = '')
{
// Build the request path.
$path = '/orgs/' . $org;
$args = array('billing_email', 'company', 'email', 'location', 'name');
$data = array();
$fArgs = \func_get_args();
foreach ($args as $i => $arg)
{
if (array_key_exists($i + 1, $fArgs) && $fArgs[$i + 1])
{
$data[$arg] = $fArgs[$i + 1];
}
}
// Send the request.
return $this->processResponse(
$this->client->patch($this->fetchUrl($path), $data)
);
}
|
php
|
public function edit($org, $billingEmail = '', $company = '', $email = '', $location = '', $name = '')
{
// Build the request path.
$path = '/orgs/' . $org;
$args = array('billing_email', 'company', 'email', 'location', 'name');
$data = array();
$fArgs = \func_get_args();
foreach ($args as $i => $arg)
{
if (array_key_exists($i + 1, $fArgs) && $fArgs[$i + 1])
{
$data[$arg] = $fArgs[$i + 1];
}
}
// Send the request.
return $this->processResponse(
$this->client->patch($this->fetchUrl($path), $data)
);
}
|
[
"public",
"function",
"edit",
"(",
"$",
"org",
",",
"$",
"billingEmail",
"=",
"''",
",",
"$",
"company",
"=",
"''",
",",
"$",
"email",
"=",
"''",
",",
"$",
"location",
"=",
"''",
",",
"$",
"name",
"=",
"''",
")",
"{",
"// Build the request path.",
"$",
"path",
"=",
"'/orgs/'",
".",
"$",
"org",
";",
"$",
"args",
"=",
"array",
"(",
"'billing_email'",
",",
"'company'",
",",
"'email'",
",",
"'location'",
",",
"'name'",
")",
";",
"$",
"data",
"=",
"array",
"(",
")",
";",
"$",
"fArgs",
"=",
"\\",
"func_get_args",
"(",
")",
";",
"foreach",
"(",
"$",
"args",
"as",
"$",
"i",
"=>",
"$",
"arg",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"i",
"+",
"1",
",",
"$",
"fArgs",
")",
"&&",
"$",
"fArgs",
"[",
"$",
"i",
"+",
"1",
"]",
")",
"{",
"$",
"data",
"[",
"$",
"arg",
"]",
"=",
"$",
"fArgs",
"[",
"$",
"i",
"+",
"1",
"]",
";",
"}",
"}",
"// Send the request.",
"return",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"this",
"->",
"client",
"->",
"patch",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"path",
")",
",",
"$",
"data",
")",
")",
";",
"}"
] |
Edit an organization.
@param string $org The organization name.
@param string $billingEmail Billing email address. This address is not publicized.
@param string $company The company name.
@param string $email The email address.
@param string $location The location name.
@param string $name The name.
@return object
@since 1.0
|
[
"Edit",
"an",
"organization",
"."
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Orgs.php#L84-L107
|
224,651
|
joomla-framework/github-api
|
src/Package/Repositories/Commits.php
|
Commits.getList
|
public function getList($user, $repo, $sha = '', $path = '', $author = '', \DateTime $since = null, \DateTime $until = null)
{
// Build the request path.
$rPath = '/repos/' . $user . '/' . $repo . '/commits';
$uri = new Uri($this->fetchUrl($rPath));
if ($sha)
{
$uri->setVar('sha', $sha);
}
if ($path)
{
$uri->setVar('path', $path);
}
if ($author)
{
$uri->setVar('author', $author);
}
if ($since)
{
$uri->setVar('since', $since->format(\DateTime::RFC3339));
}
if ($until)
{
$uri->setVar('until', $until->format(\DateTime::RFC3339));
}
// Send the request.
return $this->processResponse($this->client->get($uri));
}
|
php
|
public function getList($user, $repo, $sha = '', $path = '', $author = '', \DateTime $since = null, \DateTime $until = null)
{
// Build the request path.
$rPath = '/repos/' . $user . '/' . $repo . '/commits';
$uri = new Uri($this->fetchUrl($rPath));
if ($sha)
{
$uri->setVar('sha', $sha);
}
if ($path)
{
$uri->setVar('path', $path);
}
if ($author)
{
$uri->setVar('author', $author);
}
if ($since)
{
$uri->setVar('since', $since->format(\DateTime::RFC3339));
}
if ($until)
{
$uri->setVar('until', $until->format(\DateTime::RFC3339));
}
// Send the request.
return $this->processResponse($this->client->get($uri));
}
|
[
"public",
"function",
"getList",
"(",
"$",
"user",
",",
"$",
"repo",
",",
"$",
"sha",
"=",
"''",
",",
"$",
"path",
"=",
"''",
",",
"$",
"author",
"=",
"''",
",",
"\\",
"DateTime",
"$",
"since",
"=",
"null",
",",
"\\",
"DateTime",
"$",
"until",
"=",
"null",
")",
"{",
"// Build the request path.",
"$",
"rPath",
"=",
"'/repos/'",
".",
"$",
"user",
".",
"'/'",
".",
"$",
"repo",
".",
"'/commits'",
";",
"$",
"uri",
"=",
"new",
"Uri",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"rPath",
")",
")",
";",
"if",
"(",
"$",
"sha",
")",
"{",
"$",
"uri",
"->",
"setVar",
"(",
"'sha'",
",",
"$",
"sha",
")",
";",
"}",
"if",
"(",
"$",
"path",
")",
"{",
"$",
"uri",
"->",
"setVar",
"(",
"'path'",
",",
"$",
"path",
")",
";",
"}",
"if",
"(",
"$",
"author",
")",
"{",
"$",
"uri",
"->",
"setVar",
"(",
"'author'",
",",
"$",
"author",
")",
";",
"}",
"if",
"(",
"$",
"since",
")",
"{",
"$",
"uri",
"->",
"setVar",
"(",
"'since'",
",",
"$",
"since",
"->",
"format",
"(",
"\\",
"DateTime",
"::",
"RFC3339",
")",
")",
";",
"}",
"if",
"(",
"$",
"until",
")",
"{",
"$",
"uri",
"->",
"setVar",
"(",
"'until'",
",",
"$",
"until",
"->",
"format",
"(",
"\\",
"DateTime",
"::",
"RFC3339",
")",
")",
";",
"}",
"// Send the request.",
"return",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"this",
"->",
"client",
"->",
"get",
"(",
"$",
"uri",
")",
")",
";",
"}"
] |
List commits on a repository.
A special note on pagination: Due to the way Git works, commits are paginated based on SHA
instead of page number.
Please follow the link headers as outlined in the pagination overview instead of constructing
page links yourself.
@param string $user The name of the owner of the GitHub repository.
@param string $repo The name of the GitHub repository.
@param string $sha Sha or branch to start listing commits from.
@param string $path Only commits containing this file path will be returned.
@param string $author GitHub login, name, or email by which to filter by commit author.
@param \DateTime $since ISO 8601 Date - Only commits after this date will be returned.
@param \DateTime $until ISO 8601 Date - Only commits before this date will be returned.
@return object
@since 1.0
@throws \DomainException
|
[
"List",
"commits",
"on",
"a",
"repository",
"."
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Repositories/Commits.php#L45-L79
|
224,652
|
joomla-framework/github-api
|
src/Package/Repositories/Commits.php
|
Commits.getSha
|
public function getSha($user, $repo, $ref)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo . '/commits/' . $ref;
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
$message = isset($error->message) ? $error->message : 'Invalid response received from GitHub.';
throw new UnexpectedResponseException($response, $message, $response->code);
}
return $response->body;
}
|
php
|
public function getSha($user, $repo, $ref)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo . '/commits/' . $ref;
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
$message = isset($error->message) ? $error->message : 'Invalid response received from GitHub.';
throw new UnexpectedResponseException($response, $message, $response->code);
}
return $response->body;
}
|
[
"public",
"function",
"getSha",
"(",
"$",
"user",
",",
"$",
"repo",
",",
"$",
"ref",
")",
"{",
"// Build the request path.",
"$",
"path",
"=",
"'/repos/'",
".",
"$",
"user",
".",
"'/'",
".",
"$",
"repo",
".",
"'/commits/'",
".",
"$",
"ref",
";",
"// Send the request.",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"get",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"path",
")",
")",
";",
"// Validate the response code.",
"if",
"(",
"$",
"response",
"->",
"code",
"!=",
"200",
")",
"{",
"// Decode the error response and throw an exception.",
"$",
"error",
"=",
"json_decode",
"(",
"$",
"response",
"->",
"body",
")",
";",
"$",
"message",
"=",
"isset",
"(",
"$",
"error",
"->",
"message",
")",
"?",
"$",
"error",
"->",
"message",
":",
"'Invalid response received from GitHub.'",
";",
"throw",
"new",
"UnexpectedResponseException",
"(",
"$",
"response",
",",
"$",
"message",
",",
"$",
"response",
"->",
"code",
")",
";",
"}",
"return",
"$",
"response",
"->",
"body",
";",
"}"
] |
Get the SHA-1 of a commit reference.
@param string $user The name of the owner of the GitHub repository.
@param string $repo The name of the GitHub repository.
@param string $ref The commit reference
@return string
@since 1.4.0
@throws UnexpectedResponseException
|
[
"Get",
"the",
"SHA",
"-",
"1",
"of",
"a",
"commit",
"reference",
"."
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Repositories/Commits.php#L114-L133
|
224,653
|
php-poppler/php-poppler
|
Driver/Pdftohtml.php
|
Pdftohtml.create
|
public static function create(LoggerInterface $logger = null, $configuration = array())
{
if (!$configuration instanceof ConfigurationInterface) {
$configuration = new Configuration($configuration);
}
$binaries = $configuration->get('pdftohtml.binaries', 'pdftohtml');
if (!$configuration->has('timeout')) {
$configuration->set('timeout', 60);
}
try {
return static::load($binaries, $logger, $configuration);
} catch (BinaryDriverExecutableNotFound $e) {
throw new ExecutableNotFoundException('Unable to load pdftohtml', $e->getCode(), $e);
}
}
|
php
|
public static function create(LoggerInterface $logger = null, $configuration = array())
{
if (!$configuration instanceof ConfigurationInterface) {
$configuration = new Configuration($configuration);
}
$binaries = $configuration->get('pdftohtml.binaries', 'pdftohtml');
if (!$configuration->has('timeout')) {
$configuration->set('timeout', 60);
}
try {
return static::load($binaries, $logger, $configuration);
} catch (BinaryDriverExecutableNotFound $e) {
throw new ExecutableNotFoundException('Unable to load pdftohtml', $e->getCode(), $e);
}
}
|
[
"public",
"static",
"function",
"create",
"(",
"LoggerInterface",
"$",
"logger",
"=",
"null",
",",
"$",
"configuration",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"$",
"configuration",
"instanceof",
"ConfigurationInterface",
")",
"{",
"$",
"configuration",
"=",
"new",
"Configuration",
"(",
"$",
"configuration",
")",
";",
"}",
"$",
"binaries",
"=",
"$",
"configuration",
"->",
"get",
"(",
"'pdftohtml.binaries'",
",",
"'pdftohtml'",
")",
";",
"if",
"(",
"!",
"$",
"configuration",
"->",
"has",
"(",
"'timeout'",
")",
")",
"{",
"$",
"configuration",
"->",
"set",
"(",
"'timeout'",
",",
"60",
")",
";",
"}",
"try",
"{",
"return",
"static",
"::",
"load",
"(",
"$",
"binaries",
",",
"$",
"logger",
",",
"$",
"configuration",
")",
";",
"}",
"catch",
"(",
"BinaryDriverExecutableNotFound",
"$",
"e",
")",
"{",
"throw",
"new",
"ExecutableNotFoundException",
"(",
"'Unable to load pdftohtml'",
",",
"$",
"e",
"->",
"getCode",
"(",
")",
",",
"$",
"e",
")",
";",
"}",
"}"
] |
Creates an Pdftohtml driver.
@param LoggerInterface $logger
@param array|Configuration $configuration
@return Pdftohtml
|
[
"Creates",
"an",
"Pdftohtml",
"driver",
"."
] |
033427289ec4f1ff00656a0e02410a84c529ace4
|
https://github.com/php-poppler/php-poppler/blob/033427289ec4f1ff00656a0e02410a84c529ace4/Driver/Pdftohtml.php#L57-L74
|
224,654
|
acacha/users
|
src/Services/UserInvitations.php
|
UserInvitations.send
|
public function send(UserInvitationModel $invitation)
{
Mail::to($invitation->email)->send(new UserInvitation($invitation));
}
|
php
|
public function send(UserInvitationModel $invitation)
{
Mail::to($invitation->email)->send(new UserInvitation($invitation));
}
|
[
"public",
"function",
"send",
"(",
"UserInvitationModel",
"$",
"invitation",
")",
"{",
"Mail",
"::",
"to",
"(",
"$",
"invitation",
"->",
"email",
")",
"->",
"send",
"(",
"new",
"UserInvitation",
"(",
"$",
"invitation",
")",
")",
";",
"}"
] |
Send user invitation.
@param UserInvitationModel $invitation
|
[
"Send",
"user",
"invitation",
"."
] |
af74be23d225bc9a23ee049579abb1596ae683c0
|
https://github.com/acacha/users/blob/af74be23d225bc9a23ee049579abb1596ae683c0/src/Services/UserInvitations.php#L21-L24
|
224,655
|
Troopers/AlertifyBundle
|
Controller/AlertifyController.php
|
AlertifyController.confirmAction
|
public function confirmAction(Request $request)
{
$confirmCallback = $request->get('confirm_callback');
if ($confirmCallback === '') {
$confirmCallback = null;
}
return [
'title' => $request->get('title'),
'body' => $request->get('body'),
'id' => $request->get('id').rand(1, 100).'-modal',
'cancel_button_class' => $request->get('cancel_button_class', 'btn-cancel'),
'confirm_button_class' => $request->get('confirm_button_class', 'btn-primary'),
'cancel_button_value' => $request->get('cancel_button_value'),
'confirm_button_value' => $request->get('confirm_button_value'),
'modal_class' => $request->get('modal_class'),
'type' => $request->get('type'),
'confirmCallback' => $confirmCallback,
];
}
|
php
|
public function confirmAction(Request $request)
{
$confirmCallback = $request->get('confirm_callback');
if ($confirmCallback === '') {
$confirmCallback = null;
}
return [
'title' => $request->get('title'),
'body' => $request->get('body'),
'id' => $request->get('id').rand(1, 100).'-modal',
'cancel_button_class' => $request->get('cancel_button_class', 'btn-cancel'),
'confirm_button_class' => $request->get('confirm_button_class', 'btn-primary'),
'cancel_button_value' => $request->get('cancel_button_value'),
'confirm_button_value' => $request->get('confirm_button_value'),
'modal_class' => $request->get('modal_class'),
'type' => $request->get('type'),
'confirmCallback' => $confirmCallback,
];
}
|
[
"public",
"function",
"confirmAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"confirmCallback",
"=",
"$",
"request",
"->",
"get",
"(",
"'confirm_callback'",
")",
";",
"if",
"(",
"$",
"confirmCallback",
"===",
"''",
")",
"{",
"$",
"confirmCallback",
"=",
"null",
";",
"}",
"return",
"[",
"'title'",
"=>",
"$",
"request",
"->",
"get",
"(",
"'title'",
")",
",",
"'body'",
"=>",
"$",
"request",
"->",
"get",
"(",
"'body'",
")",
",",
"'id'",
"=>",
"$",
"request",
"->",
"get",
"(",
"'id'",
")",
".",
"rand",
"(",
"1",
",",
"100",
")",
".",
"'-modal'",
",",
"'cancel_button_class'",
"=>",
"$",
"request",
"->",
"get",
"(",
"'cancel_button_class'",
",",
"'btn-cancel'",
")",
",",
"'confirm_button_class'",
"=>",
"$",
"request",
"->",
"get",
"(",
"'confirm_button_class'",
",",
"'btn-primary'",
")",
",",
"'cancel_button_value'",
"=>",
"$",
"request",
"->",
"get",
"(",
"'cancel_button_value'",
")",
",",
"'confirm_button_value'",
"=>",
"$",
"request",
"->",
"get",
"(",
"'confirm_button_value'",
")",
",",
"'modal_class'",
"=>",
"$",
"request",
"->",
"get",
"(",
"'modal_class'",
")",
",",
"'type'",
"=>",
"$",
"request",
"->",
"get",
"(",
"'type'",
")",
",",
"'confirmCallback'",
"=>",
"$",
"confirmCallback",
",",
"]",
";",
"}"
] |
Confirm modal.
@param Request $request An HTTP request.
@Route("/confirm", name="alertify_confirm", options={"expose"=true})
@Template("TroopersAlertifyBundle::confirm.html.twig")
@return array
|
[
"Confirm",
"modal",
"."
] |
eded39af141d056627718d2ba7dee4e458fb7187
|
https://github.com/Troopers/AlertifyBundle/blob/eded39af141d056627718d2ba7dee4e458fb7187/Controller/AlertifyController.php#L24-L43
|
224,656
|
netz98/n98-deployer
|
src/Deployer/Service/GetReleasesListService.php
|
GetReleasesListService.execute
|
public static function execute()
{
\Deployer\cd('{{deploy_path}}');
// If there is no releases return empty list.
$cmdReleaseDirs = '[ -d releases ] && [ "$(ls -A releases)" ]';
$hasReleaseDirs = \Deployer\test($cmdReleaseDirs);
if (!$hasReleaseDirs) {
return [];
}
// Will list only dirs in releases.
$releasesRaw = \Deployer\run('cd releases && ls -t -d */');
$list = explode("\n", $releasesRaw);
// Prepare list.
$list = array_map(function ($release) { return basename(rtrim($release, '/')); }, $list);
$releases = []; // Releases list.
// Collect releases based on .dep/releases info.
// Other will be ignored.
$hasReleasesList = \Deployer\test('[ -f .dep/releases ]');
if (!$hasReleasesList) {
return $releases;
}
// we do not filter the keep_releases here, as we want a full list
$csv = \Deployer\run('cat .dep/releases');
$metainfo = CsvType::parse($csv);
for ($i = count($metainfo) - 1; $i >= 0; --$i) {
if (is_array($metainfo[$i]) && count($metainfo[$i]) >= 2) {
list($date, $release) = $metainfo[$i];
$index = array_search($release, $list, true);
if ($index !== false) {
$releases[] = $release;
unset($list[$index]);
}
}
}
return $releases;
}
|
php
|
public static function execute()
{
\Deployer\cd('{{deploy_path}}');
// If there is no releases return empty list.
$cmdReleaseDirs = '[ -d releases ] && [ "$(ls -A releases)" ]';
$hasReleaseDirs = \Deployer\test($cmdReleaseDirs);
if (!$hasReleaseDirs) {
return [];
}
// Will list only dirs in releases.
$releasesRaw = \Deployer\run('cd releases && ls -t -d */');
$list = explode("\n", $releasesRaw);
// Prepare list.
$list = array_map(function ($release) { return basename(rtrim($release, '/')); }, $list);
$releases = []; // Releases list.
// Collect releases based on .dep/releases info.
// Other will be ignored.
$hasReleasesList = \Deployer\test('[ -f .dep/releases ]');
if (!$hasReleasesList) {
return $releases;
}
// we do not filter the keep_releases here, as we want a full list
$csv = \Deployer\run('cat .dep/releases');
$metainfo = CsvType::parse($csv);
for ($i = count($metainfo) - 1; $i >= 0; --$i) {
if (is_array($metainfo[$i]) && count($metainfo[$i]) >= 2) {
list($date, $release) = $metainfo[$i];
$index = array_search($release, $list, true);
if ($index !== false) {
$releases[] = $release;
unset($list[$index]);
}
}
}
return $releases;
}
|
[
"public",
"static",
"function",
"execute",
"(",
")",
"{",
"\\",
"Deployer",
"\\",
"cd",
"(",
"'{{deploy_path}}'",
")",
";",
"// If there is no releases return empty list.",
"$",
"cmdReleaseDirs",
"=",
"'[ -d releases ] && [ \"$(ls -A releases)\" ]'",
";",
"$",
"hasReleaseDirs",
"=",
"\\",
"Deployer",
"\\",
"test",
"(",
"$",
"cmdReleaseDirs",
")",
";",
"if",
"(",
"!",
"$",
"hasReleaseDirs",
")",
"{",
"return",
"[",
"]",
";",
"}",
"// Will list only dirs in releases.",
"$",
"releasesRaw",
"=",
"\\",
"Deployer",
"\\",
"run",
"(",
"'cd releases && ls -t -d */'",
")",
";",
"$",
"list",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"releasesRaw",
")",
";",
"// Prepare list.",
"$",
"list",
"=",
"array_map",
"(",
"function",
"(",
"$",
"release",
")",
"{",
"return",
"basename",
"(",
"rtrim",
"(",
"$",
"release",
",",
"'/'",
")",
")",
";",
"}",
",",
"$",
"list",
")",
";",
"$",
"releases",
"=",
"[",
"]",
";",
"// Releases list.",
"// Collect releases based on .dep/releases info.",
"// Other will be ignored.",
"$",
"hasReleasesList",
"=",
"\\",
"Deployer",
"\\",
"test",
"(",
"'[ -f .dep/releases ]'",
")",
";",
"if",
"(",
"!",
"$",
"hasReleasesList",
")",
"{",
"return",
"$",
"releases",
";",
"}",
"// we do not filter the keep_releases here, as we want a full list",
"$",
"csv",
"=",
"\\",
"Deployer",
"\\",
"run",
"(",
"'cat .dep/releases'",
")",
";",
"$",
"metainfo",
"=",
"CsvType",
"::",
"parse",
"(",
"$",
"csv",
")",
";",
"for",
"(",
"$",
"i",
"=",
"count",
"(",
"$",
"metainfo",
")",
"-",
"1",
";",
"$",
"i",
">=",
"0",
";",
"--",
"$",
"i",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"metainfo",
"[",
"$",
"i",
"]",
")",
"&&",
"count",
"(",
"$",
"metainfo",
"[",
"$",
"i",
"]",
")",
">=",
"2",
")",
"{",
"list",
"(",
"$",
"date",
",",
"$",
"release",
")",
"=",
"$",
"metainfo",
"[",
"$",
"i",
"]",
";",
"$",
"index",
"=",
"array_search",
"(",
"$",
"release",
",",
"$",
"list",
",",
"true",
")",
";",
"if",
"(",
"$",
"index",
"!==",
"false",
")",
"{",
"$",
"releases",
"[",
"]",
"=",
"$",
"release",
";",
"unset",
"(",
"$",
"list",
"[",
"$",
"index",
"]",
")",
";",
"}",
"}",
"}",
"return",
"$",
"releases",
";",
"}"
] |
Returns a list of releases on server.
@return array
|
[
"Returns",
"a",
"list",
"of",
"releases",
"on",
"server",
"."
] |
cf7b7c790f45c41ed338b8a33b498eeaaaa765e9
|
https://github.com/netz98/n98-deployer/blob/cf7b7c790f45c41ed338b8a33b498eeaaaa765e9/src/Deployer/Service/GetReleasesListService.php#L22-L68
|
224,657
|
neos/setup
|
Classes/Core/MessageRenderer.php
|
MessageRenderer.showMessages
|
public function showMessages(array $messages, $extraHeaderHtml = '')
{
if ($messages === []) {
throw new \InvalidArgumentException('No messages given for rendering', 1416914970);
}
/** @var \Neos\Flow\Package\PackageManagerInterface $packageManager */
$packageManager = $this->bootstrap->getEarlyInstance(\Neos\Flow\Package\PackageManagerInterface::class);
$css = '';
if ($packageManager->isPackageAvailable('Neos.Twitter.Bootstrap')) {
$css .= file_get_contents($packageManager->getPackage('Neos.Twitter.Bootstrap')->getResourcesPath() . 'Public/3/css/bootstrap.min.css');
$css = str_replace('url(../', 'url(/_Resources/Static/Packages/Neos.Twitter.Bootstrap/3.0/', $css);
}
if ($packageManager->isPackageAvailable('Neos.Setup')) {
$css .= file_get_contents($packageManager->getPackage('Neos.Setup')->getResourcesPath() . 'Public/Styles/Setup.css');
$css = str_replace('url(\'../', 'url(\'/_Resources/Static/Packages/Neos.Setup/', $css);
}
echo '<html>';
echo '<head>';
echo '<title>Setup message</title>';
echo '<style type="text/css">';
echo $css;
echo '</style>';
echo $extraHeaderHtml;
echo '</head>';
echo '<body>';
$renderedMessages = $this->renderMessages($messages);
$lastMessage = end($messages);
echo sprintf('
<div class="logo"></div>
<div class="well">
<div class="container">
<ul class="breadcrumb">
<li><a class="active">Setup</a></li>
</ul>
<h3>%s</h3>
%s
</div>
</div>
', $lastMessage->getTitle(), $renderedMessages);
echo '</body></html>';
exit(0);
}
|
php
|
public function showMessages(array $messages, $extraHeaderHtml = '')
{
if ($messages === []) {
throw new \InvalidArgumentException('No messages given for rendering', 1416914970);
}
/** @var \Neos\Flow\Package\PackageManagerInterface $packageManager */
$packageManager = $this->bootstrap->getEarlyInstance(\Neos\Flow\Package\PackageManagerInterface::class);
$css = '';
if ($packageManager->isPackageAvailable('Neos.Twitter.Bootstrap')) {
$css .= file_get_contents($packageManager->getPackage('Neos.Twitter.Bootstrap')->getResourcesPath() . 'Public/3/css/bootstrap.min.css');
$css = str_replace('url(../', 'url(/_Resources/Static/Packages/Neos.Twitter.Bootstrap/3.0/', $css);
}
if ($packageManager->isPackageAvailable('Neos.Setup')) {
$css .= file_get_contents($packageManager->getPackage('Neos.Setup')->getResourcesPath() . 'Public/Styles/Setup.css');
$css = str_replace('url(\'../', 'url(\'/_Resources/Static/Packages/Neos.Setup/', $css);
}
echo '<html>';
echo '<head>';
echo '<title>Setup message</title>';
echo '<style type="text/css">';
echo $css;
echo '</style>';
echo $extraHeaderHtml;
echo '</head>';
echo '<body>';
$renderedMessages = $this->renderMessages($messages);
$lastMessage = end($messages);
echo sprintf('
<div class="logo"></div>
<div class="well">
<div class="container">
<ul class="breadcrumb">
<li><a class="active">Setup</a></li>
</ul>
<h3>%s</h3>
%s
</div>
</div>
', $lastMessage->getTitle(), $renderedMessages);
echo '</body></html>';
exit(0);
}
|
[
"public",
"function",
"showMessages",
"(",
"array",
"$",
"messages",
",",
"$",
"extraHeaderHtml",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"messages",
"===",
"[",
"]",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'No messages given for rendering'",
",",
"1416914970",
")",
";",
"}",
"/** @var \\Neos\\Flow\\Package\\PackageManagerInterface $packageManager */",
"$",
"packageManager",
"=",
"$",
"this",
"->",
"bootstrap",
"->",
"getEarlyInstance",
"(",
"\\",
"Neos",
"\\",
"Flow",
"\\",
"Package",
"\\",
"PackageManagerInterface",
"::",
"class",
")",
";",
"$",
"css",
"=",
"''",
";",
"if",
"(",
"$",
"packageManager",
"->",
"isPackageAvailable",
"(",
"'Neos.Twitter.Bootstrap'",
")",
")",
"{",
"$",
"css",
".=",
"file_get_contents",
"(",
"$",
"packageManager",
"->",
"getPackage",
"(",
"'Neos.Twitter.Bootstrap'",
")",
"->",
"getResourcesPath",
"(",
")",
".",
"'Public/3/css/bootstrap.min.css'",
")",
";",
"$",
"css",
"=",
"str_replace",
"(",
"'url(../'",
",",
"'url(/_Resources/Static/Packages/Neos.Twitter.Bootstrap/3.0/'",
",",
"$",
"css",
")",
";",
"}",
"if",
"(",
"$",
"packageManager",
"->",
"isPackageAvailable",
"(",
"'Neos.Setup'",
")",
")",
"{",
"$",
"css",
".=",
"file_get_contents",
"(",
"$",
"packageManager",
"->",
"getPackage",
"(",
"'Neos.Setup'",
")",
"->",
"getResourcesPath",
"(",
")",
".",
"'Public/Styles/Setup.css'",
")",
";",
"$",
"css",
"=",
"str_replace",
"(",
"'url(\\'../'",
",",
"'url(\\'/_Resources/Static/Packages/Neos.Setup/'",
",",
"$",
"css",
")",
";",
"}",
"echo",
"'<html>'",
";",
"echo",
"'<head>'",
";",
"echo",
"'<title>Setup message</title>'",
";",
"echo",
"'<style type=\"text/css\">'",
";",
"echo",
"$",
"css",
";",
"echo",
"'</style>'",
";",
"echo",
"$",
"extraHeaderHtml",
";",
"echo",
"'</head>'",
";",
"echo",
"'<body>'",
";",
"$",
"renderedMessages",
"=",
"$",
"this",
"->",
"renderMessages",
"(",
"$",
"messages",
")",
";",
"$",
"lastMessage",
"=",
"end",
"(",
"$",
"messages",
")",
";",
"echo",
"sprintf",
"(",
"'\n\t\t\t<div class=\"logo\"></div>\n\t\t\t<div class=\"well\">\n\t\t\t\t<div class=\"container\">\n\t\t\t\t\t<ul class=\"breadcrumb\">\n\t\t\t\t\t\t<li><a class=\"active\">Setup</a></li>\n\t\t\t\t\t</ul>\n\t\t\t\t\t<h3>%s</h3>\n %s\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t'",
",",
"$",
"lastMessage",
"->",
"getTitle",
"(",
")",
",",
"$",
"renderedMessages",
")",
";",
"echo",
"'</body></html>'",
";",
"exit",
"(",
"0",
")",
";",
"}"
] |
Display a message. As we cannot rely on any Flow requirements being fulfilled here,
we have to statically include the CSS styles at this point, and have to in-line the Neos logo.
@param array <\Neos\Error\Messages\Message> $messages Array of messages (at least one message must be passed)
@param string $extraHeaderHtml extra HTML code to include at the end of the head tag
@return void This method never returns.
|
[
"Display",
"a",
"message",
".",
"As",
"we",
"cannot",
"rely",
"on",
"any",
"Flow",
"requirements",
"being",
"fulfilled",
"here",
"we",
"have",
"to",
"statically",
"include",
"the",
"CSS",
"styles",
"at",
"this",
"point",
"and",
"have",
"to",
"in",
"-",
"line",
"the",
"Neos",
"logo",
"."
] |
7b5437efe8113e997007be6896628aa9f5c39d2f
|
https://github.com/neos/setup/blob/7b5437efe8113e997007be6896628aa9f5c39d2f/Classes/Core/MessageRenderer.php#L52-L98
|
224,658
|
joomla-framework/github-api
|
src/Package/Repositories/Hooks.php
|
Hooks.edit
|
public function edit($user, $repo, $id, $name, $config, array $events = array('push'), array $addEvents = array(),
array $removeEvents = array(), $active = true
)
{
// Check to ensure all events are in the allowed list
foreach ($events as $event)
{
if (!\in_array($event, $this->hookEvents))
{
throw new \RuntimeException('Your events array contains an unauthorized event.');
}
}
foreach ($addEvents as $event)
{
if (!\in_array($event, $this->hookEvents))
{
throw new \RuntimeException('Your active_events array contains an unauthorized event.');
}
}
foreach ($removeEvents as $event)
{
if (!\in_array($event, $this->hookEvents))
{
throw new \RuntimeException('Your remove_events array contains an unauthorized event.');
}
}
// Build the request path.
$path = '/repos/' . $user . '/' . $repo . '/hooks/' . $id;
$data = json_encode(
array(
'name' => $name,
'config' => $config,
'events' => $events,
'add_events' => $addEvents,
'remove_events' => $removeEvents,
'active' => $active,
)
);
return $this->processResponse(
$this->client->patch($this->fetchUrl($path), $data)
);
}
|
php
|
public function edit($user, $repo, $id, $name, $config, array $events = array('push'), array $addEvents = array(),
array $removeEvents = array(), $active = true
)
{
// Check to ensure all events are in the allowed list
foreach ($events as $event)
{
if (!\in_array($event, $this->hookEvents))
{
throw new \RuntimeException('Your events array contains an unauthorized event.');
}
}
foreach ($addEvents as $event)
{
if (!\in_array($event, $this->hookEvents))
{
throw new \RuntimeException('Your active_events array contains an unauthorized event.');
}
}
foreach ($removeEvents as $event)
{
if (!\in_array($event, $this->hookEvents))
{
throw new \RuntimeException('Your remove_events array contains an unauthorized event.');
}
}
// Build the request path.
$path = '/repos/' . $user . '/' . $repo . '/hooks/' . $id;
$data = json_encode(
array(
'name' => $name,
'config' => $config,
'events' => $events,
'add_events' => $addEvents,
'remove_events' => $removeEvents,
'active' => $active,
)
);
return $this->processResponse(
$this->client->patch($this->fetchUrl($path), $data)
);
}
|
[
"public",
"function",
"edit",
"(",
"$",
"user",
",",
"$",
"repo",
",",
"$",
"id",
",",
"$",
"name",
",",
"$",
"config",
",",
"array",
"$",
"events",
"=",
"array",
"(",
"'push'",
")",
",",
"array",
"$",
"addEvents",
"=",
"array",
"(",
")",
",",
"array",
"$",
"removeEvents",
"=",
"array",
"(",
")",
",",
"$",
"active",
"=",
"true",
")",
"{",
"// Check to ensure all events are in the allowed list",
"foreach",
"(",
"$",
"events",
"as",
"$",
"event",
")",
"{",
"if",
"(",
"!",
"\\",
"in_array",
"(",
"$",
"event",
",",
"$",
"this",
"->",
"hookEvents",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Your events array contains an unauthorized event.'",
")",
";",
"}",
"}",
"foreach",
"(",
"$",
"addEvents",
"as",
"$",
"event",
")",
"{",
"if",
"(",
"!",
"\\",
"in_array",
"(",
"$",
"event",
",",
"$",
"this",
"->",
"hookEvents",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Your active_events array contains an unauthorized event.'",
")",
";",
"}",
"}",
"foreach",
"(",
"$",
"removeEvents",
"as",
"$",
"event",
")",
"{",
"if",
"(",
"!",
"\\",
"in_array",
"(",
"$",
"event",
",",
"$",
"this",
"->",
"hookEvents",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Your remove_events array contains an unauthorized event.'",
")",
";",
"}",
"}",
"// Build the request path.",
"$",
"path",
"=",
"'/repos/'",
".",
"$",
"user",
".",
"'/'",
".",
"$",
"repo",
".",
"'/hooks/'",
".",
"$",
"id",
";",
"$",
"data",
"=",
"json_encode",
"(",
"array",
"(",
"'name'",
"=>",
"$",
"name",
",",
"'config'",
"=>",
"$",
"config",
",",
"'events'",
"=>",
"$",
"events",
",",
"'add_events'",
"=>",
"$",
"addEvents",
",",
"'remove_events'",
"=>",
"$",
"removeEvents",
",",
"'active'",
"=>",
"$",
"active",
",",
")",
")",
";",
"return",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"this",
"->",
"client",
"->",
"patch",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"path",
")",
",",
"$",
"data",
")",
")",
";",
"}"
] |
Edit a hook.
@param string $user The name of the owner of the GitHub repository.
@param string $repo The name of the GitHub repository.
@param integer $id ID of the hook to edit.
@param string $name The name of the service being called.
@param array $config Array containing the config for the service.
@param array $events The events the hook will be triggered for. This resets the currently set list
@param array $addEvents Events to add to the hook.
@param array $removeEvents Events to remove from the hook.
@param boolean $active Flag to determine if the hook is active
@return object
@since 1.0
@throws \DomainException
@throws \RuntimeException
|
[
"Edit",
"a",
"hook",
"."
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Repositories/Hooks.php#L104-L150
|
224,659
|
neos/setup
|
Classes/Core/RequestHandler.php
|
RequestHandler.checkBasicRequirementsAndDisplayLoadingScreen
|
protected function checkBasicRequirementsAndDisplayLoadingScreen()
{
$messageRenderer = new MessageRenderer($this->bootstrap);
$basicRequirements = new BasicRequirements();
$result = $basicRequirements->findError();
if ($result instanceof Error) {
$messageRenderer->showMessages([$result]);
return;
}
$phpBinaryDetectionMessage = $this->checkAndSetPhpBinaryIfNeeded();
if ($phpBinaryDetectionMessage instanceof Error) {
$messageRenderer->showMessages([$phpBinaryDetectionMessage]);
return;
}
$currentUri = substr($this->request->getUri(), strlen($this->request->getBaseUri()));
if ($currentUri === 'setup' || $currentUri === 'setup/') {
$redirectUri = ($currentUri === 'setup/' ? 'index' : 'setup/index');
$messages = [new Message('We are now redirecting you to the setup. <b>This might take 10-60 seconds on the first run,</b> because the application needs to build up various caches.', null, [], 'Initialising Setup ...')];
if ($phpBinaryDetectionMessage !== null) {
array_unshift($messages, $phpBinaryDetectionMessage);
}
$messageRenderer->showMessages($messages, '<meta http-equiv="refresh" content="2;URL=\'' . $redirectUri . '\'">');
}
}
|
php
|
protected function checkBasicRequirementsAndDisplayLoadingScreen()
{
$messageRenderer = new MessageRenderer($this->bootstrap);
$basicRequirements = new BasicRequirements();
$result = $basicRequirements->findError();
if ($result instanceof Error) {
$messageRenderer->showMessages([$result]);
return;
}
$phpBinaryDetectionMessage = $this->checkAndSetPhpBinaryIfNeeded();
if ($phpBinaryDetectionMessage instanceof Error) {
$messageRenderer->showMessages([$phpBinaryDetectionMessage]);
return;
}
$currentUri = substr($this->request->getUri(), strlen($this->request->getBaseUri()));
if ($currentUri === 'setup' || $currentUri === 'setup/') {
$redirectUri = ($currentUri === 'setup/' ? 'index' : 'setup/index');
$messages = [new Message('We are now redirecting you to the setup. <b>This might take 10-60 seconds on the first run,</b> because the application needs to build up various caches.', null, [], 'Initialising Setup ...')];
if ($phpBinaryDetectionMessage !== null) {
array_unshift($messages, $phpBinaryDetectionMessage);
}
$messageRenderer->showMessages($messages, '<meta http-equiv="refresh" content="2;URL=\'' . $redirectUri . '\'">');
}
}
|
[
"protected",
"function",
"checkBasicRequirementsAndDisplayLoadingScreen",
"(",
")",
"{",
"$",
"messageRenderer",
"=",
"new",
"MessageRenderer",
"(",
"$",
"this",
"->",
"bootstrap",
")",
";",
"$",
"basicRequirements",
"=",
"new",
"BasicRequirements",
"(",
")",
";",
"$",
"result",
"=",
"$",
"basicRequirements",
"->",
"findError",
"(",
")",
";",
"if",
"(",
"$",
"result",
"instanceof",
"Error",
")",
"{",
"$",
"messageRenderer",
"->",
"showMessages",
"(",
"[",
"$",
"result",
"]",
")",
";",
"return",
";",
"}",
"$",
"phpBinaryDetectionMessage",
"=",
"$",
"this",
"->",
"checkAndSetPhpBinaryIfNeeded",
"(",
")",
";",
"if",
"(",
"$",
"phpBinaryDetectionMessage",
"instanceof",
"Error",
")",
"{",
"$",
"messageRenderer",
"->",
"showMessages",
"(",
"[",
"$",
"phpBinaryDetectionMessage",
"]",
")",
";",
"return",
";",
"}",
"$",
"currentUri",
"=",
"substr",
"(",
"$",
"this",
"->",
"request",
"->",
"getUri",
"(",
")",
",",
"strlen",
"(",
"$",
"this",
"->",
"request",
"->",
"getBaseUri",
"(",
")",
")",
")",
";",
"if",
"(",
"$",
"currentUri",
"===",
"'setup'",
"||",
"$",
"currentUri",
"===",
"'setup/'",
")",
"{",
"$",
"redirectUri",
"=",
"(",
"$",
"currentUri",
"===",
"'setup/'",
"?",
"'index'",
":",
"'setup/index'",
")",
";",
"$",
"messages",
"=",
"[",
"new",
"Message",
"(",
"'We are now redirecting you to the setup. <b>This might take 10-60 seconds on the first run,</b> because the application needs to build up various caches.'",
",",
"null",
",",
"[",
"]",
",",
"'Initialising Setup ...'",
")",
"]",
";",
"if",
"(",
"$",
"phpBinaryDetectionMessage",
"!==",
"null",
")",
"{",
"array_unshift",
"(",
"$",
"messages",
",",
"$",
"phpBinaryDetectionMessage",
")",
";",
"}",
"$",
"messageRenderer",
"->",
"showMessages",
"(",
"$",
"messages",
",",
"'<meta http-equiv=\"refresh\" content=\"2;URL=\\''",
".",
"$",
"redirectUri",
".",
"'\\'\">'",
")",
";",
"}",
"}"
] |
Check the basic requirements, and display a loading screen on initial request.
@return void
|
[
"Check",
"the",
"basic",
"requirements",
"and",
"display",
"a",
"loading",
"screen",
"on",
"initial",
"request",
"."
] |
7b5437efe8113e997007be6896628aa9f5c39d2f
|
https://github.com/neos/setup/blob/7b5437efe8113e997007be6896628aa9f5c39d2f/Classes/Core/RequestHandler.php#L89-L116
|
224,660
|
neos/setup
|
Classes/Core/RequestHandler.php
|
RequestHandler.resolveDependencies
|
protected function resolveDependencies()
{
$objectManager = $this->bootstrap->getObjectManager();
$componentChainFactory = $objectManager->get(ComponentChainFactory::class);
$configurationManager = $objectManager->get(ConfigurationManager::class);
$this->settings = $configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Neos.Flow');
$setupSettings = $configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Neos.Setup');
$httpChainSettings = Arrays::arrayMergeRecursiveOverrule($this->settings['http']['chain'], $setupSettings['http']['chain']);
$this->baseComponentChain = $componentChainFactory->create($httpChainSettings);
}
|
php
|
protected function resolveDependencies()
{
$objectManager = $this->bootstrap->getObjectManager();
$componentChainFactory = $objectManager->get(ComponentChainFactory::class);
$configurationManager = $objectManager->get(ConfigurationManager::class);
$this->settings = $configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Neos.Flow');
$setupSettings = $configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Neos.Setup');
$httpChainSettings = Arrays::arrayMergeRecursiveOverrule($this->settings['http']['chain'], $setupSettings['http']['chain']);
$this->baseComponentChain = $componentChainFactory->create($httpChainSettings);
}
|
[
"protected",
"function",
"resolveDependencies",
"(",
")",
"{",
"$",
"objectManager",
"=",
"$",
"this",
"->",
"bootstrap",
"->",
"getObjectManager",
"(",
")",
";",
"$",
"componentChainFactory",
"=",
"$",
"objectManager",
"->",
"get",
"(",
"ComponentChainFactory",
"::",
"class",
")",
";",
"$",
"configurationManager",
"=",
"$",
"objectManager",
"->",
"get",
"(",
"ConfigurationManager",
"::",
"class",
")",
";",
"$",
"this",
"->",
"settings",
"=",
"$",
"configurationManager",
"->",
"getConfiguration",
"(",
"ConfigurationManager",
"::",
"CONFIGURATION_TYPE_SETTINGS",
",",
"'Neos.Flow'",
")",
";",
"$",
"setupSettings",
"=",
"$",
"configurationManager",
"->",
"getConfiguration",
"(",
"ConfigurationManager",
"::",
"CONFIGURATION_TYPE_SETTINGS",
",",
"'Neos.Setup'",
")",
";",
"$",
"httpChainSettings",
"=",
"Arrays",
"::",
"arrayMergeRecursiveOverrule",
"(",
"$",
"this",
"->",
"settings",
"[",
"'http'",
"]",
"[",
"'chain'",
"]",
",",
"$",
"setupSettings",
"[",
"'http'",
"]",
"[",
"'chain'",
"]",
")",
";",
"$",
"this",
"->",
"baseComponentChain",
"=",
"$",
"componentChainFactory",
"->",
"create",
"(",
"$",
"httpChainSettings",
")",
";",
"}"
] |
Create a HTTP component chain that adds our own routing configuration component
only for this request handler.
@return void
|
[
"Create",
"a",
"HTTP",
"component",
"chain",
"that",
"adds",
"our",
"own",
"routing",
"configuration",
"component",
"only",
"for",
"this",
"request",
"handler",
"."
] |
7b5437efe8113e997007be6896628aa9f5c39d2f
|
https://github.com/neos/setup/blob/7b5437efe8113e997007be6896628aa9f5c39d2f/Classes/Core/RequestHandler.php#L124-L133
|
224,661
|
neos/setup
|
Classes/Core/RequestHandler.php
|
RequestHandler.checkPhpBinary
|
protected function checkPhpBinary($phpBinaryPathAndFilename)
{
$phpVersion = null;
if ($this->phpBinaryExistsAndIsExecutableFile($phpBinaryPathAndFilename)) {
if (DIRECTORY_SEPARATOR === '/') {
$phpCommand = '"' . escapeshellcmd(Files::getUnixStylePath($phpBinaryPathAndFilename)) . '"';
} else {
$phpCommand = escapeshellarg(Files::getUnixStylePath($phpBinaryPathAndFilename));
}
// If the tested binary is a CGI binary that also runs the current request the SCRIPT_FILENAME would take precedence and create an endless recursion.
$possibleScriptFilenameValue = getenv('SCRIPT_FILENAME');
putenv('SCRIPT_FILENAME');
exec($phpCommand . ' -r "echo \'(\' . php_sapi_name() . \') \' . PHP_VERSION;"', $phpVersionString);
if ($possibleScriptFilenameValue !== false) {
putenv('SCRIPT_FILENAME=' . (string)$possibleScriptFilenameValue);
}
if (!isset($phpVersionString[0]) || strpos($phpVersionString[0], '(cli)') === false) {
return new Error('The specified path to your PHP binary (see Configuration/Settings.yaml) is incorrect or not a PHP command line (cli) version.', 1341839376, [], 'Environment requirements not fulfilled');
}
$versionStringParts = explode(' ', $phpVersionString[0]);
$phpVersion = isset($versionStringParts[1]) ? trim($versionStringParts[1]) : null;
if ($phpVersion === PHP_VERSION) {
return null;
}
}
if ($phpVersion === null) {
return new Error('The specified path to your PHP binary (see Configuration/Settings.yaml) is incorrect: not found at "%s"', 1341839376, [$phpBinaryPathAndFilename], 'Environment requirements not fulfilled');
} else {
$phpMinorVersionMatch = array_slice(explode('.', $phpVersion), 0, 2) === array_slice(explode('.', PHP_VERSION), 0, 2);
if ($phpMinorVersionMatch) {
return new \Neos\Error\Messages\Warning('The specified path to your PHP binary (see Configuration/Settings.yaml) points to a PHP binary with the version "%s". This is not the exact same version as is currently running ("%s").', 1416913501, [$phpVersion, PHP_VERSION], 'Possible PHP version mismatch');
} else {
return new Error('The specified path to your PHP binary (see Configuration/Settings.yaml) points to a PHP binary with the version "%s". This is not compatible to the version that is currently running ("%s").', 1341839377, [$phpVersion, PHP_VERSION], 'Environment requirements not fulfilled');
}
}
}
|
php
|
protected function checkPhpBinary($phpBinaryPathAndFilename)
{
$phpVersion = null;
if ($this->phpBinaryExistsAndIsExecutableFile($phpBinaryPathAndFilename)) {
if (DIRECTORY_SEPARATOR === '/') {
$phpCommand = '"' . escapeshellcmd(Files::getUnixStylePath($phpBinaryPathAndFilename)) . '"';
} else {
$phpCommand = escapeshellarg(Files::getUnixStylePath($phpBinaryPathAndFilename));
}
// If the tested binary is a CGI binary that also runs the current request the SCRIPT_FILENAME would take precedence and create an endless recursion.
$possibleScriptFilenameValue = getenv('SCRIPT_FILENAME');
putenv('SCRIPT_FILENAME');
exec($phpCommand . ' -r "echo \'(\' . php_sapi_name() . \') \' . PHP_VERSION;"', $phpVersionString);
if ($possibleScriptFilenameValue !== false) {
putenv('SCRIPT_FILENAME=' . (string)$possibleScriptFilenameValue);
}
if (!isset($phpVersionString[0]) || strpos($phpVersionString[0], '(cli)') === false) {
return new Error('The specified path to your PHP binary (see Configuration/Settings.yaml) is incorrect or not a PHP command line (cli) version.', 1341839376, [], 'Environment requirements not fulfilled');
}
$versionStringParts = explode(' ', $phpVersionString[0]);
$phpVersion = isset($versionStringParts[1]) ? trim($versionStringParts[1]) : null;
if ($phpVersion === PHP_VERSION) {
return null;
}
}
if ($phpVersion === null) {
return new Error('The specified path to your PHP binary (see Configuration/Settings.yaml) is incorrect: not found at "%s"', 1341839376, [$phpBinaryPathAndFilename], 'Environment requirements not fulfilled');
} else {
$phpMinorVersionMatch = array_slice(explode('.', $phpVersion), 0, 2) === array_slice(explode('.', PHP_VERSION), 0, 2);
if ($phpMinorVersionMatch) {
return new \Neos\Error\Messages\Warning('The specified path to your PHP binary (see Configuration/Settings.yaml) points to a PHP binary with the version "%s". This is not the exact same version as is currently running ("%s").', 1416913501, [$phpVersion, PHP_VERSION], 'Possible PHP version mismatch');
} else {
return new Error('The specified path to your PHP binary (see Configuration/Settings.yaml) points to a PHP binary with the version "%s". This is not compatible to the version that is currently running ("%s").', 1341839377, [$phpVersion, PHP_VERSION], 'Environment requirements not fulfilled');
}
}
}
|
[
"protected",
"function",
"checkPhpBinary",
"(",
"$",
"phpBinaryPathAndFilename",
")",
"{",
"$",
"phpVersion",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"phpBinaryExistsAndIsExecutableFile",
"(",
"$",
"phpBinaryPathAndFilename",
")",
")",
"{",
"if",
"(",
"DIRECTORY_SEPARATOR",
"===",
"'/'",
")",
"{",
"$",
"phpCommand",
"=",
"'\"'",
".",
"escapeshellcmd",
"(",
"Files",
"::",
"getUnixStylePath",
"(",
"$",
"phpBinaryPathAndFilename",
")",
")",
".",
"'\"'",
";",
"}",
"else",
"{",
"$",
"phpCommand",
"=",
"escapeshellarg",
"(",
"Files",
"::",
"getUnixStylePath",
"(",
"$",
"phpBinaryPathAndFilename",
")",
")",
";",
"}",
"// If the tested binary is a CGI binary that also runs the current request the SCRIPT_FILENAME would take precedence and create an endless recursion.",
"$",
"possibleScriptFilenameValue",
"=",
"getenv",
"(",
"'SCRIPT_FILENAME'",
")",
";",
"putenv",
"(",
"'SCRIPT_FILENAME'",
")",
";",
"exec",
"(",
"$",
"phpCommand",
".",
"' -r \"echo \\'(\\' . php_sapi_name() . \\') \\' . PHP_VERSION;\"'",
",",
"$",
"phpVersionString",
")",
";",
"if",
"(",
"$",
"possibleScriptFilenameValue",
"!==",
"false",
")",
"{",
"putenv",
"(",
"'SCRIPT_FILENAME='",
".",
"(",
"string",
")",
"$",
"possibleScriptFilenameValue",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"phpVersionString",
"[",
"0",
"]",
")",
"||",
"strpos",
"(",
"$",
"phpVersionString",
"[",
"0",
"]",
",",
"'(cli)'",
")",
"===",
"false",
")",
"{",
"return",
"new",
"Error",
"(",
"'The specified path to your PHP binary (see Configuration/Settings.yaml) is incorrect or not a PHP command line (cli) version.'",
",",
"1341839376",
",",
"[",
"]",
",",
"'Environment requirements not fulfilled'",
")",
";",
"}",
"$",
"versionStringParts",
"=",
"explode",
"(",
"' '",
",",
"$",
"phpVersionString",
"[",
"0",
"]",
")",
";",
"$",
"phpVersion",
"=",
"isset",
"(",
"$",
"versionStringParts",
"[",
"1",
"]",
")",
"?",
"trim",
"(",
"$",
"versionStringParts",
"[",
"1",
"]",
")",
":",
"null",
";",
"if",
"(",
"$",
"phpVersion",
"===",
"PHP_VERSION",
")",
"{",
"return",
"null",
";",
"}",
"}",
"if",
"(",
"$",
"phpVersion",
"===",
"null",
")",
"{",
"return",
"new",
"Error",
"(",
"'The specified path to your PHP binary (see Configuration/Settings.yaml) is incorrect: not found at \"%s\"'",
",",
"1341839376",
",",
"[",
"$",
"phpBinaryPathAndFilename",
"]",
",",
"'Environment requirements not fulfilled'",
")",
";",
"}",
"else",
"{",
"$",
"phpMinorVersionMatch",
"=",
"array_slice",
"(",
"explode",
"(",
"'.'",
",",
"$",
"phpVersion",
")",
",",
"0",
",",
"2",
")",
"===",
"array_slice",
"(",
"explode",
"(",
"'.'",
",",
"PHP_VERSION",
")",
",",
"0",
",",
"2",
")",
";",
"if",
"(",
"$",
"phpMinorVersionMatch",
")",
"{",
"return",
"new",
"\\",
"Neos",
"\\",
"Error",
"\\",
"Messages",
"\\",
"Warning",
"(",
"'The specified path to your PHP binary (see Configuration/Settings.yaml) points to a PHP binary with the version \"%s\". This is not the exact same version as is currently running (\"%s\").'",
",",
"1416913501",
",",
"[",
"$",
"phpVersion",
",",
"PHP_VERSION",
"]",
",",
"'Possible PHP version mismatch'",
")",
";",
"}",
"else",
"{",
"return",
"new",
"Error",
"(",
"'The specified path to your PHP binary (see Configuration/Settings.yaml) points to a PHP binary with the version \"%s\". This is not compatible to the version that is currently running (\"%s\").'",
",",
"1341839377",
",",
"[",
"$",
"phpVersion",
",",
"PHP_VERSION",
"]",
",",
"'Environment requirements not fulfilled'",
")",
";",
"}",
"}",
"}"
] |
Checks if the given PHP binary is executable and of the same version as the currently running one.
@param string $phpBinaryPathAndFilename
@return Message An error or warning message or NULL if the PHP binary was detected successfully
|
[
"Checks",
"if",
"the",
"given",
"PHP",
"binary",
"is",
"executable",
"and",
"of",
"the",
"same",
"version",
"as",
"the",
"currently",
"running",
"one",
"."
] |
7b5437efe8113e997007be6896628aa9f5c39d2f
|
https://github.com/neos/setup/blob/7b5437efe8113e997007be6896628aa9f5c39d2f/Classes/Core/RequestHandler.php#L173-L208
|
224,662
|
neos/setup
|
Classes/Core/RequestHandler.php
|
RequestHandler.detectPhpBinaryPathAndFilename
|
protected function detectPhpBinaryPathAndFilename()
{
if (defined('PHP_BINARY') && PHP_BINARY !== '' && dirname(PHP_BINARY) === PHP_BINDIR) {
if ($this->checkPhpBinary(PHP_BINARY) === null) {
return [PHP_BINARY, null];
}
}
$environmentPaths = explode(PATH_SEPARATOR, getenv('PATH'));
$environmentPaths[] = PHP_BINDIR;
$lastCheckMessage = null;
foreach ($environmentPaths as $path) {
$path = rtrim(str_replace('\\', '/', $path), '/');
if (strlen($path) === 0) {
continue;
}
$phpBinaryPathAndFilename = $path . '/php' . (DIRECTORY_SEPARATOR !== '/' ? '.exe' : '');
$lastCheckMessage = $this->checkPhpBinary($phpBinaryPathAndFilename);
if (!$lastCheckMessage instanceof Error) {
return [$phpBinaryPathAndFilename, $lastCheckMessage];
}
}
return [null, $lastCheckMessage];
}
|
php
|
protected function detectPhpBinaryPathAndFilename()
{
if (defined('PHP_BINARY') && PHP_BINARY !== '' && dirname(PHP_BINARY) === PHP_BINDIR) {
if ($this->checkPhpBinary(PHP_BINARY) === null) {
return [PHP_BINARY, null];
}
}
$environmentPaths = explode(PATH_SEPARATOR, getenv('PATH'));
$environmentPaths[] = PHP_BINDIR;
$lastCheckMessage = null;
foreach ($environmentPaths as $path) {
$path = rtrim(str_replace('\\', '/', $path), '/');
if (strlen($path) === 0) {
continue;
}
$phpBinaryPathAndFilename = $path . '/php' . (DIRECTORY_SEPARATOR !== '/' ? '.exe' : '');
$lastCheckMessage = $this->checkPhpBinary($phpBinaryPathAndFilename);
if (!$lastCheckMessage instanceof Error) {
return [$phpBinaryPathAndFilename, $lastCheckMessage];
}
}
return [null, $lastCheckMessage];
}
|
[
"protected",
"function",
"detectPhpBinaryPathAndFilename",
"(",
")",
"{",
"if",
"(",
"defined",
"(",
"'PHP_BINARY'",
")",
"&&",
"PHP_BINARY",
"!==",
"''",
"&&",
"dirname",
"(",
"PHP_BINARY",
")",
"===",
"PHP_BINDIR",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"checkPhpBinary",
"(",
"PHP_BINARY",
")",
"===",
"null",
")",
"{",
"return",
"[",
"PHP_BINARY",
",",
"null",
"]",
";",
"}",
"}",
"$",
"environmentPaths",
"=",
"explode",
"(",
"PATH_SEPARATOR",
",",
"getenv",
"(",
"'PATH'",
")",
")",
";",
"$",
"environmentPaths",
"[",
"]",
"=",
"PHP_BINDIR",
";",
"$",
"lastCheckMessage",
"=",
"null",
";",
"foreach",
"(",
"$",
"environmentPaths",
"as",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"rtrim",
"(",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"$",
"path",
")",
",",
"'/'",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"path",
")",
"===",
"0",
")",
"{",
"continue",
";",
"}",
"$",
"phpBinaryPathAndFilename",
"=",
"$",
"path",
".",
"'/php'",
".",
"(",
"DIRECTORY_SEPARATOR",
"!==",
"'/'",
"?",
"'.exe'",
":",
"''",
")",
";",
"$",
"lastCheckMessage",
"=",
"$",
"this",
"->",
"checkPhpBinary",
"(",
"$",
"phpBinaryPathAndFilename",
")",
";",
"if",
"(",
"!",
"$",
"lastCheckMessage",
"instanceof",
"Error",
")",
"{",
"return",
"[",
"$",
"phpBinaryPathAndFilename",
",",
"$",
"lastCheckMessage",
"]",
";",
"}",
"}",
"return",
"[",
"null",
",",
"$",
"lastCheckMessage",
"]",
";",
"}"
] |
Traverse the PATH locations and check for the existence of a valid PHP binary.
If found, the path and filename are returned, if not NULL is returned.
We only use PHP_BINARY if it's set to a file in the path PHP_BINDIR.
This is because PHP_BINARY might, for example, be "/opt/local/sbin/php54-fpm"
while PHP_BINDIR contains "/opt/local/bin" and the actual CLI binary is "/opt/local/bin/php".
@return array PHP binary path as string or NULL if not found and a possible Message
|
[
"Traverse",
"the",
"PATH",
"locations",
"and",
"check",
"for",
"the",
"existence",
"of",
"a",
"valid",
"PHP",
"binary",
".",
"If",
"found",
"the",
"path",
"and",
"filename",
"are",
"returned",
"if",
"not",
"NULL",
"is",
"returned",
"."
] |
7b5437efe8113e997007be6896628aa9f5c39d2f
|
https://github.com/neos/setup/blob/7b5437efe8113e997007be6896628aa9f5c39d2f/Classes/Core/RequestHandler.php#L220-L244
|
224,663
|
neos/setup
|
Classes/Core/RequestHandler.php
|
RequestHandler.phpBinaryExistsAndIsExecutableFile
|
protected function phpBinaryExistsAndIsExecutableFile($phpBinaryPathAndFilename)
{
$phpBinaryPathAndFilename = escapeshellarg(Files::getUnixStylePath($phpBinaryPathAndFilename));
if (DIRECTORY_SEPARATOR === '/') {
$command = sprintf('test -f %s && test -x %s', $phpBinaryPathAndFilename, $phpBinaryPathAndFilename);
} else {
$command = sprintf('IF EXIST %s (IF NOT EXIST %s\* (EXIT 0) ELSE (EXIT 1)) ELSE (EXIT 1)', $phpBinaryPathAndFilename, $phpBinaryPathAndFilename);
}
exec($command, $outputLines, $exitCode);
if ($exitCode === 0) {
return true;
}
return false;
}
|
php
|
protected function phpBinaryExistsAndIsExecutableFile($phpBinaryPathAndFilename)
{
$phpBinaryPathAndFilename = escapeshellarg(Files::getUnixStylePath($phpBinaryPathAndFilename));
if (DIRECTORY_SEPARATOR === '/') {
$command = sprintf('test -f %s && test -x %s', $phpBinaryPathAndFilename, $phpBinaryPathAndFilename);
} else {
$command = sprintf('IF EXIST %s (IF NOT EXIST %s\* (EXIT 0) ELSE (EXIT 1)) ELSE (EXIT 1)', $phpBinaryPathAndFilename, $phpBinaryPathAndFilename);
}
exec($command, $outputLines, $exitCode);
if ($exitCode === 0) {
return true;
}
return false;
}
|
[
"protected",
"function",
"phpBinaryExistsAndIsExecutableFile",
"(",
"$",
"phpBinaryPathAndFilename",
")",
"{",
"$",
"phpBinaryPathAndFilename",
"=",
"escapeshellarg",
"(",
"Files",
"::",
"getUnixStylePath",
"(",
"$",
"phpBinaryPathAndFilename",
")",
")",
";",
"if",
"(",
"DIRECTORY_SEPARATOR",
"===",
"'/'",
")",
"{",
"$",
"command",
"=",
"sprintf",
"(",
"'test -f %s && test -x %s'",
",",
"$",
"phpBinaryPathAndFilename",
",",
"$",
"phpBinaryPathAndFilename",
")",
";",
"}",
"else",
"{",
"$",
"command",
"=",
"sprintf",
"(",
"'IF EXIST %s (IF NOT EXIST %s\\* (EXIT 0) ELSE (EXIT 1)) ELSE (EXIT 1)'",
",",
"$",
"phpBinaryPathAndFilename",
",",
"$",
"phpBinaryPathAndFilename",
")",
";",
"}",
"exec",
"(",
"$",
"command",
",",
"$",
"outputLines",
",",
"$",
"exitCode",
")",
";",
"if",
"(",
"$",
"exitCode",
"===",
"0",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Checks if PHP binary file exists bypassing open_basedir violation.
If PHP binary is not within open_basedir path,
it is impossible to access this binary in any other way than exec() or system().
So we must check existence of this file with system tools.
@param string $phpBinaryPathAndFilename
@return boolean
|
[
"Checks",
"if",
"PHP",
"binary",
"file",
"exists",
"bypassing",
"open_basedir",
"violation",
"."
] |
7b5437efe8113e997007be6896628aa9f5c39d2f
|
https://github.com/neos/setup/blob/7b5437efe8113e997007be6896628aa9f5c39d2f/Classes/Core/RequestHandler.php#L256-L271
|
224,664
|
atorscho/membership
|
src/Permission.php
|
Permission.search
|
public static function search(string $handle, array $attributes = ['*'])
{
$handle = explode('.', $handle);
$type = array_shift($handle);
if (!$handle) {
throw new InvalidArgumentException('The search argument is not properly formatted.');
}
$handle = $handle[0];
return static::where(compact('type', 'handle'))->firstOrFail($attributes);
}
|
php
|
public static function search(string $handle, array $attributes = ['*'])
{
$handle = explode('.', $handle);
$type = array_shift($handle);
if (!$handle) {
throw new InvalidArgumentException('The search argument is not properly formatted.');
}
$handle = $handle[0];
return static::where(compact('type', 'handle'))->firstOrFail($attributes);
}
|
[
"public",
"static",
"function",
"search",
"(",
"string",
"$",
"handle",
",",
"array",
"$",
"attributes",
"=",
"[",
"'*'",
"]",
")",
"{",
"$",
"handle",
"=",
"explode",
"(",
"'.'",
",",
"$",
"handle",
")",
";",
"$",
"type",
"=",
"array_shift",
"(",
"$",
"handle",
")",
";",
"if",
"(",
"!",
"$",
"handle",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'The search argument is not properly formatted.'",
")",
";",
"}",
"$",
"handle",
"=",
"$",
"handle",
"[",
"0",
"]",
";",
"return",
"static",
"::",
"where",
"(",
"compact",
"(",
"'type'",
",",
"'handle'",
")",
")",
"->",
"firstOrFail",
"(",
"$",
"attributes",
")",
";",
"}"
] |
Find a permission using its type and handle.
|
[
"Find",
"a",
"permission",
"using",
"its",
"type",
"and",
"handle",
"."
] |
c39ee69b5bc33702912fb16ef4f4736eaf1e6d71
|
https://github.com/atorscho/membership/blob/c39ee69b5bc33702912fb16ef4f4736eaf1e6d71/src/Permission.php#L65-L77
|
224,665
|
atorscho/membership
|
src/Permission.php
|
Permission.isGrantedTo
|
public function isGrantedTo($user): bool
{
$userModel = config('auth.providers.users.model');
if (is_int($user) && !$userModel::find($user)) {
return false;
}
return $this->users()->where('user_id', is_int($user) ? $user : $user->id)->exists();
}
|
php
|
public function isGrantedTo($user): bool
{
$userModel = config('auth.providers.users.model');
if (is_int($user) && !$userModel::find($user)) {
return false;
}
return $this->users()->where('user_id', is_int($user) ? $user : $user->id)->exists();
}
|
[
"public",
"function",
"isGrantedTo",
"(",
"$",
"user",
")",
":",
"bool",
"{",
"$",
"userModel",
"=",
"config",
"(",
"'auth.providers.users.model'",
")",
";",
"if",
"(",
"is_int",
"(",
"$",
"user",
")",
"&&",
"!",
"$",
"userModel",
"::",
"find",
"(",
"$",
"user",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"this",
"->",
"users",
"(",
")",
"->",
"where",
"(",
"'user_id'",
",",
"is_int",
"(",
"$",
"user",
")",
"?",
"$",
"user",
":",
"$",
"user",
"->",
"id",
")",
"->",
"exists",
"(",
")",
";",
"}"
] |
Check whether the permission is granted to a user.
@param int|Authenticatable $group
@return bool
|
[
"Check",
"whether",
"the",
"permission",
"is",
"granted",
"to",
"a",
"user",
"."
] |
c39ee69b5bc33702912fb16ef4f4736eaf1e6d71
|
https://github.com/atorscho/membership/blob/c39ee69b5bc33702912fb16ef4f4736eaf1e6d71/src/Permission.php#L134-L143
|
224,666
|
joomla-framework/github-api
|
src/Package/Repositories.php
|
Repositories.getListContributors
|
public function getListContributors($owner, $repo, $anon = false)
{
// Build the request path.
$uri = new Uri($this->fetchUrl('/repos/' . $owner . '/' . $repo . '/contributors'));
if ($anon)
{
$uri->setVar('anon', 'true');
}
// Send the request.
return $this->processResponse($this->client->get($uri));
}
|
php
|
public function getListContributors($owner, $repo, $anon = false)
{
// Build the request path.
$uri = new Uri($this->fetchUrl('/repos/' . $owner . '/' . $repo . '/contributors'));
if ($anon)
{
$uri->setVar('anon', 'true');
}
// Send the request.
return $this->processResponse($this->client->get($uri));
}
|
[
"public",
"function",
"getListContributors",
"(",
"$",
"owner",
",",
"$",
"repo",
",",
"$",
"anon",
"=",
"false",
")",
"{",
"// Build the request path.",
"$",
"uri",
"=",
"new",
"Uri",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"'/repos/'",
".",
"$",
"owner",
".",
"'/'",
".",
"$",
"repo",
".",
"'/contributors'",
")",
")",
";",
"if",
"(",
"$",
"anon",
")",
"{",
"$",
"uri",
"->",
"setVar",
"(",
"'anon'",
",",
"'true'",
")",
";",
"}",
"// Send the request.",
"return",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"this",
"->",
"client",
"->",
"get",
"(",
"$",
"uri",
")",
")",
";",
"}"
] |
List contributors.
@param string $owner Repository owner.
@param string $repo Repository name.
@param boolean $anon Set to 1 or true to include anonymous contributors in results.
@return object
@since 1.0
|
[
"List",
"contributors",
"."
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Repositories.php#L310-L322
|
224,667
|
joomla-framework/github-api
|
src/Package/Repositories.php
|
Repositories.getBranch
|
public function getBranch($owner, $repo, $branch)
{
return $this->branches->get($owner, $repo, $branch);
}
|
php
|
public function getBranch($owner, $repo, $branch)
{
return $this->branches->get($owner, $repo, $branch);
}
|
[
"public",
"function",
"getBranch",
"(",
"$",
"owner",
",",
"$",
"repo",
",",
"$",
"branch",
")",
"{",
"return",
"$",
"this",
"->",
"branches",
"->",
"get",
"(",
"$",
"owner",
",",
"$",
"repo",
",",
"$",
"branch",
")",
";",
"}"
] |
Get a Branch.
@param string $owner Repository owner.
@param string $repo Repository name.
@param string $branch Branch name.
@return object
@since 1.0
@deprecated 2.0 Use Joomla\Github\Package\Repositories\Branches::get() instead
|
[
"Get",
"a",
"Branch",
"."
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Repositories.php#L418-L421
|
224,668
|
fojuth/plupload
|
src/Fojuth/Plupload/UploadHandler.php
|
UploadHandler.upload
|
public function upload(\Symfony\Component\HttpFoundation\File\UploadedFile $file) {
// We simply move the uploaded file to the target directory
$result = $file->move(\Config::get('plupload::plupload.upload_dir'), $file->getClientOriginalName());
// Return the result of the upload
return $this->respond(array('OK' => ($result) ? 1 : 0));
}
|
php
|
public function upload(\Symfony\Component\HttpFoundation\File\UploadedFile $file) {
// We simply move the uploaded file to the target directory
$result = $file->move(\Config::get('plupload::plupload.upload_dir'), $file->getClientOriginalName());
// Return the result of the upload
return $this->respond(array('OK' => ($result) ? 1 : 0));
}
|
[
"public",
"function",
"upload",
"(",
"\\",
"Symfony",
"\\",
"Component",
"\\",
"HttpFoundation",
"\\",
"File",
"\\",
"UploadedFile",
"$",
"file",
")",
"{",
"// We simply move the uploaded file to the target directory",
"$",
"result",
"=",
"$",
"file",
"->",
"move",
"(",
"\\",
"Config",
"::",
"get",
"(",
"'plupload::plupload.upload_dir'",
")",
",",
"$",
"file",
"->",
"getClientOriginalName",
"(",
")",
")",
";",
"// Return the result of the upload",
"return",
"$",
"this",
"->",
"respond",
"(",
"array",
"(",
"'OK'",
"=>",
"(",
"$",
"result",
")",
"?",
"1",
":",
"0",
")",
")",
";",
"}"
] |
The main upload method.
@param \Symfony\Component\HttpFoundation\File\UploadedFile $file Uploaded file instance.
@return string
|
[
"The",
"main",
"upload",
"method",
"."
] |
9d27e62516761352863cd08b7a2342326d69dd5c
|
https://github.com/fojuth/plupload/blob/9d27e62516761352863cd08b7a2342326d69dd5c/src/Fojuth/Plupload/UploadHandler.php#L21-L28
|
224,669
|
mlambley/swagception
|
src/SwaggerSchema.php
|
SwaggerSchema.checkFilter
|
public function checkFilter($path)
{
//No filters? Include all paths.
if (empty($this->filters)) {
return true;
}
//Match either with or without braces.
$cleanPath = str_replace(array('{', '}'), array('', ''), $path);
foreach ($this->filters as $filter) {
if (stripos($path, $filter) !== false || stripos($cleanPath, $filter) !== false) {
return true;
}
}
return false;
}
|
php
|
public function checkFilter($path)
{
//No filters? Include all paths.
if (empty($this->filters)) {
return true;
}
//Match either with or without braces.
$cleanPath = str_replace(array('{', '}'), array('', ''), $path);
foreach ($this->filters as $filter) {
if (stripos($path, $filter) !== false || stripos($cleanPath, $filter) !== false) {
return true;
}
}
return false;
}
|
[
"public",
"function",
"checkFilter",
"(",
"$",
"path",
")",
"{",
"//No filters? Include all paths.",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"filters",
")",
")",
"{",
"return",
"true",
";",
"}",
"//Match either with or without braces.",
"$",
"cleanPath",
"=",
"str_replace",
"(",
"array",
"(",
"'{'",
",",
"'}'",
")",
",",
"array",
"(",
"''",
",",
"''",
")",
",",
"$",
"path",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"filters",
"as",
"$",
"filter",
")",
"{",
"if",
"(",
"stripos",
"(",
"$",
"path",
",",
"$",
"filter",
")",
"!==",
"false",
"||",
"stripos",
"(",
"$",
"cleanPath",
",",
"$",
"filter",
")",
"!==",
"false",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Checks whether the path should be included, based on the previously specified filters.
@param string $path
@return bool
|
[
"Checks",
"whether",
"the",
"path",
"should",
"be",
"included",
"based",
"on",
"the",
"previously",
"specified",
"filters",
"."
] |
2ca006c158a0465be537ba05903d7d940ac92085
|
https://github.com/mlambley/swagception/blob/2ca006c158a0465be537ba05903d7d940ac92085/src/SwaggerSchema.php#L177-L192
|
224,670
|
joomla-framework/github-api
|
src/Package/Authorization.php
|
Authorization.deleteGrant
|
public function deleteGrant($id)
{
// Build the request path.
$path = '/authorizations/grants/' . $id;
// Send the request.
return $this->processResponse($this->client->delete($this->fetchUrl($path)), 204);
}
|
php
|
public function deleteGrant($id)
{
// Build the request path.
$path = '/authorizations/grants/' . $id;
// Send the request.
return $this->processResponse($this->client->delete($this->fetchUrl($path)), 204);
}
|
[
"public",
"function",
"deleteGrant",
"(",
"$",
"id",
")",
"{",
"// Build the request path.",
"$",
"path",
"=",
"'/authorizations/grants/'",
".",
"$",
"id",
";",
"// Send the request.",
"return",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"this",
"->",
"client",
"->",
"delete",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"path",
")",
")",
",",
"204",
")",
";",
"}"
] |
Delete a grant
Deleting an OAuth application's grant will also delete all OAuth tokens associated with the application for your user.
@param integer $id ID of the authorization to delete
@return object
@since 1.5.0
@throws \DomainException
|
[
"Delete",
"a",
"grant"
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Authorization.php#L82-L89
|
224,671
|
joomla-framework/github-api
|
src/Package/Authorization.php
|
Authorization.getListGrants
|
public function getListGrants()
{
// Build the request path.
$path = '/authorizations/grants';
// Send the request.
return $this->processResponse($this->client->get($this->fetchUrl($path)));
}
|
php
|
public function getListGrants()
{
// Build the request path.
$path = '/authorizations/grants';
// Send the request.
return $this->processResponse($this->client->get($this->fetchUrl($path)));
}
|
[
"public",
"function",
"getListGrants",
"(",
")",
"{",
"// Build the request path.",
"$",
"path",
"=",
"'/authorizations/grants'",
";",
"// Send the request.",
"return",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"this",
"->",
"client",
"->",
"get",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"path",
")",
")",
")",
";",
"}"
] |
List your grants.
You can use this API to list the set of OAuth applications that have been granted access to your account.
@return object
@since 1.5.0
@throws \DomainException
|
[
"List",
"your",
"grants",
"."
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Authorization.php#L221-L228
|
224,672
|
joomla-framework/github-api
|
src/Package/Authorization.php
|
Authorization.revokeGrantForApplication
|
public function revokeGrantForApplication($clientId, $accessToken)
{
// Build the request path.
$path = "/applications/$clientId/grants/$accessToken";
// Send the request.
return $this->processResponse($this->client->delete($this->fetchUrl($path)), 204);
}
|
php
|
public function revokeGrantForApplication($clientId, $accessToken)
{
// Build the request path.
$path = "/applications/$clientId/grants/$accessToken";
// Send the request.
return $this->processResponse($this->client->delete($this->fetchUrl($path)), 204);
}
|
[
"public",
"function",
"revokeGrantForApplication",
"(",
"$",
"clientId",
",",
"$",
"accessToken",
")",
"{",
"// Build the request path.",
"$",
"path",
"=",
"\"/applications/$clientId/grants/$accessToken\"",
";",
"// Send the request.",
"return",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"this",
"->",
"client",
"->",
"delete",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"path",
")",
")",
",",
"204",
")",
";",
"}"
] |
Revoke a grant for an application
OAuth application owners can revoke a grant for their OAuth application and a specific user.
@param integer $clientId The application client ID
@param integer $accessToken The access token to revoke
@return object
@since 1.5.0
@throws \DomainException
|
[
"Revoke",
"a",
"grant",
"for",
"an",
"application"
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Authorization.php#L373-L380
|
224,673
|
laravel-notification-channels/bearychat
|
src/Exceptions/CouldNotSendNotification.php
|
CouldNotSendNotification.invalidMessage
|
public static function invalidMessage($message)
{
$type = is_object($message) ? get_class($message) : gettype($message);
return new static('The message should be an instance of '.Message::class.". Given `{$type}` is invalid.", 1);
}
|
php
|
public static function invalidMessage($message)
{
$type = is_object($message) ? get_class($message) : gettype($message);
return new static('The message should be an instance of '.Message::class.". Given `{$type}` is invalid.", 1);
}
|
[
"public",
"static",
"function",
"invalidMessage",
"(",
"$",
"message",
")",
"{",
"$",
"type",
"=",
"is_object",
"(",
"$",
"message",
")",
"?",
"get_class",
"(",
"$",
"message",
")",
":",
"gettype",
"(",
"$",
"message",
")",
";",
"return",
"new",
"static",
"(",
"'The message should be an instance of '",
".",
"Message",
"::",
"class",
".",
"\". Given `{$type}` is invalid.\"",
",",
"1",
")",
";",
"}"
] |
Thrown when an invalid message was passed.
@param mixed $message
@return static
|
[
"Thrown",
"when",
"an",
"invalid",
"message",
"was",
"passed",
"."
] |
c0fdc1918c14b72bdc40157e72cc125962347b06
|
https://github.com/laravel-notification-channels/bearychat/blob/c0fdc1918c14b72bdc40157e72cc125962347b06/src/Exceptions/CouldNotSendNotification.php#L16-L21
|
224,674
|
laravel-notification-channels/bearychat
|
src/Exceptions/CouldNotSendNotification.php
|
CouldNotSendNotification.sendingFailed
|
public static function sendingFailed($webhook, $payload)
{
if (! is_string($payload)) {
$payload = json_encode($payload, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);
}
return new static("Failed sending to BearyChat with webhook {$webhook} .\n{$payload}", 4);
}
|
php
|
public static function sendingFailed($webhook, $payload)
{
if (! is_string($payload)) {
$payload = json_encode($payload, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);
}
return new static("Failed sending to BearyChat with webhook {$webhook} .\n{$payload}", 4);
}
|
[
"public",
"static",
"function",
"sendingFailed",
"(",
"$",
"webhook",
",",
"$",
"payload",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"payload",
")",
")",
"{",
"$",
"payload",
"=",
"json_encode",
"(",
"$",
"payload",
",",
"JSON_UNESCAPED_UNICODE",
"|",
"JSON_UNESCAPED_SLASHES",
"|",
"JSON_PRETTY_PRINT",
")",
";",
"}",
"return",
"new",
"static",
"(",
"\"Failed sending to BearyChat with webhook {$webhook} .\\n{$payload}\"",
",",
"4",
")",
";",
"}"
] |
Thrown when sending failed.
@param string $webhook
@param mixed $payload
@return static
|
[
"Thrown",
"when",
"sending",
"failed",
"."
] |
c0fdc1918c14b72bdc40157e72cc125962347b06
|
https://github.com/laravel-notification-channels/bearychat/blob/c0fdc1918c14b72bdc40157e72cc125962347b06/src/Exceptions/CouldNotSendNotification.php#L30-L37
|
224,675
|
joomla-framework/github-api
|
src/Package/Activity/Notifications.php
|
Notifications.markReadThread
|
public function markReadThread($id, $unread = true, $read = true)
{
// Build the request path.
$path = '/notifications/threads/' . $id;
$data = array(
'unread' => $unread,
'read' => $read,
);
return $this->processResponse(
$this->client->patch($this->fetchUrl($path), json_encode($data)),
205
);
}
|
php
|
public function markReadThread($id, $unread = true, $read = true)
{
// Build the request path.
$path = '/notifications/threads/' . $id;
$data = array(
'unread' => $unread,
'read' => $read,
);
return $this->processResponse(
$this->client->patch($this->fetchUrl($path), json_encode($data)),
205
);
}
|
[
"public",
"function",
"markReadThread",
"(",
"$",
"id",
",",
"$",
"unread",
"=",
"true",
",",
"$",
"read",
"=",
"true",
")",
"{",
"// Build the request path.",
"$",
"path",
"=",
"'/notifications/threads/'",
".",
"$",
"id",
";",
"$",
"data",
"=",
"array",
"(",
"'unread'",
"=>",
"$",
"unread",
",",
"'read'",
"=>",
"$",
"read",
",",
")",
";",
"return",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"this",
"->",
"client",
"->",
"patch",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"path",
")",
",",
"json_encode",
"(",
"$",
"data",
")",
")",
",",
"205",
")",
";",
"}"
] |
Mark a thread as read.
@param integer $id The thread id.
@param boolean $unread Changes the unread status of the threads.
@param boolean $read Inverse of “unread”.
@return object
@since 1.0
|
[
"Mark",
"a",
"thread",
"as",
"read",
"."
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Activity/Notifications.php#L215-L229
|
224,676
|
joomla-framework/github-api
|
src/Package/Activity/Notifications.php
|
Notifications.setThreadSubscription
|
public function setThreadSubscription($id, $subscribed, $ignored)
{
// Build the request path.
$path = '/notifications/threads/' . $id . '/subscription';
$data = array(
'subscribed' => $subscribed,
'ignored' => $ignored,
);
return $this->processResponse(
$this->client->put($this->fetchUrl($path), json_encode($data))
);
}
|
php
|
public function setThreadSubscription($id, $subscribed, $ignored)
{
// Build the request path.
$path = '/notifications/threads/' . $id . '/subscription';
$data = array(
'subscribed' => $subscribed,
'ignored' => $ignored,
);
return $this->processResponse(
$this->client->put($this->fetchUrl($path), json_encode($data))
);
}
|
[
"public",
"function",
"setThreadSubscription",
"(",
"$",
"id",
",",
"$",
"subscribed",
",",
"$",
"ignored",
")",
"{",
"// Build the request path.",
"$",
"path",
"=",
"'/notifications/threads/'",
".",
"$",
"id",
".",
"'/subscription'",
";",
"$",
"data",
"=",
"array",
"(",
"'subscribed'",
"=>",
"$",
"subscribed",
",",
"'ignored'",
"=>",
"$",
"ignored",
",",
")",
";",
"return",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"this",
"->",
"client",
"->",
"put",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"path",
")",
",",
"json_encode",
"(",
"$",
"data",
")",
")",
")",
";",
"}"
] |
Set a Thread Subscription.
This lets you subscribe to a thread, or ignore it. Subscribing to a thread is unnecessary
if the user is already subscribed to the repository. Ignoring a thread will mute all
future notifications (until you comment or get @mentioned).
@param integer $id The thread id.
@param boolean $subscribed Determines if notifications should be received from this thread.
@param boolean $ignored Determines if all notifications should be blocked from this thread.
@return object
@since 1.0
|
[
"Set",
"a",
"Thread",
"Subscription",
"."
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Activity/Notifications.php#L268-L281
|
224,677
|
neos/setup
|
Classes/Condition/DatabaseConnectionCondition.php
|
DatabaseConnectionCondition.isMet
|
public function isMet()
{
$settings = $this->configurationManager->getConfiguration(\Neos\Flow\Configuration\ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Neos.Flow');
try {
\Doctrine\DBAL\DriverManager::getConnection($settings['persistence']['backendOptions'])->connect();
} catch (\PDOException $exception) {
return false;
}
return true;
}
|
php
|
public function isMet()
{
$settings = $this->configurationManager->getConfiguration(\Neos\Flow\Configuration\ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Neos.Flow');
try {
\Doctrine\DBAL\DriverManager::getConnection($settings['persistence']['backendOptions'])->connect();
} catch (\PDOException $exception) {
return false;
}
return true;
}
|
[
"public",
"function",
"isMet",
"(",
")",
"{",
"$",
"settings",
"=",
"$",
"this",
"->",
"configurationManager",
"->",
"getConfiguration",
"(",
"\\",
"Neos",
"\\",
"Flow",
"\\",
"Configuration",
"\\",
"ConfigurationManager",
"::",
"CONFIGURATION_TYPE_SETTINGS",
",",
"'Neos.Flow'",
")",
";",
"try",
"{",
"\\",
"Doctrine",
"\\",
"DBAL",
"\\",
"DriverManager",
"::",
"getConnection",
"(",
"$",
"settings",
"[",
"'persistence'",
"]",
"[",
"'backendOptions'",
"]",
")",
"->",
"connect",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"PDOException",
"$",
"exception",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Returns TRUE if the condition is satisfied, otherwise FALSE
@return boolean
|
[
"Returns",
"TRUE",
"if",
"the",
"condition",
"is",
"satisfied",
"otherwise",
"FALSE"
] |
7b5437efe8113e997007be6896628aa9f5c39d2f
|
https://github.com/neos/setup/blob/7b5437efe8113e997007be6896628aa9f5c39d2f/Classes/Condition/DatabaseConnectionCondition.php#L26-L36
|
224,678
|
acacha/users
|
src/Http/Controllers/APIForgotPasswordController.php
|
APIForgotPasswordController.massiveSendResetLinkEmail
|
public function massiveSendResetLinkEmail(Request $request)
{
$this->validate($request, ['ids' => 'required']);
$errors = [];
foreach ($request->input('ids') as $id) {
$user = User::find($id);
$response = Password::broker()->sendResetLink([ 'email' => $user->email ]);
if (! Password::RESET_LINK_SENT) {
dd('ERROR!');
$errors[] = $response;
}
}
if ( count($errors) > 0 ) return new JsonResponse(['status' => 'Error', 'errors' => $errors ], 422);
return new JsonResponse(['status' => 'Done' ], 200);
}
|
php
|
public function massiveSendResetLinkEmail(Request $request)
{
$this->validate($request, ['ids' => 'required']);
$errors = [];
foreach ($request->input('ids') as $id) {
$user = User::find($id);
$response = Password::broker()->sendResetLink([ 'email' => $user->email ]);
if (! Password::RESET_LINK_SENT) {
dd('ERROR!');
$errors[] = $response;
}
}
if ( count($errors) > 0 ) return new JsonResponse(['status' => 'Error', 'errors' => $errors ], 422);
return new JsonResponse(['status' => 'Done' ], 200);
}
|
[
"public",
"function",
"massiveSendResetLinkEmail",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"validate",
"(",
"$",
"request",
",",
"[",
"'ids'",
"=>",
"'required'",
"]",
")",
";",
"$",
"errors",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"request",
"->",
"input",
"(",
"'ids'",
")",
"as",
"$",
"id",
")",
"{",
"$",
"user",
"=",
"User",
"::",
"find",
"(",
"$",
"id",
")",
";",
"$",
"response",
"=",
"Password",
"::",
"broker",
"(",
")",
"->",
"sendResetLink",
"(",
"[",
"'email'",
"=>",
"$",
"user",
"->",
"email",
"]",
")",
";",
"if",
"(",
"!",
"Password",
"::",
"RESET_LINK_SENT",
")",
"{",
"dd",
"(",
"'ERROR!'",
")",
";",
"$",
"errors",
"[",
"]",
"=",
"$",
"response",
";",
"}",
"}",
"if",
"(",
"count",
"(",
"$",
"errors",
")",
">",
"0",
")",
"return",
"new",
"JsonResponse",
"(",
"[",
"'status'",
"=>",
"'Error'",
",",
"'errors'",
"=>",
"$",
"errors",
"]",
",",
"422",
")",
";",
"return",
"new",
"JsonResponse",
"(",
"[",
"'status'",
"=>",
"'Done'",
"]",
",",
"200",
")",
";",
"}"
] |
Send a reset link to the given users.
@param Request $request
@return JsonResponse
|
[
"Send",
"a",
"reset",
"link",
"to",
"the",
"given",
"users",
"."
] |
af74be23d225bc9a23ee049579abb1596ae683c0
|
https://github.com/acacha/users/blob/af74be23d225bc9a23ee049579abb1596ae683c0/src/Http/Controllers/APIForgotPasswordController.php#L46-L63
|
224,679
|
phootwork/collection
|
src/AbstractList.php
|
AbstractList.findIndex
|
public function findIndex() {
if (func_num_args() == 1) {
$callback = func_get_arg(0);
} else {
$query = func_get_arg(0);
$callback = func_get_arg(1);
}
$index = func_num_args() == 1 ? $this->find($callback) : $this->find($query, $callback);
if ($index !== null) {
$index = $this->indexOf($index);
}
return $index;
}
|
php
|
public function findIndex() {
if (func_num_args() == 1) {
$callback = func_get_arg(0);
} else {
$query = func_get_arg(0);
$callback = func_get_arg(1);
}
$index = func_num_args() == 1 ? $this->find($callback) : $this->find($query, $callback);
if ($index !== null) {
$index = $this->indexOf($index);
}
return $index;
}
|
[
"public",
"function",
"findIndex",
"(",
")",
"{",
"if",
"(",
"func_num_args",
"(",
")",
"==",
"1",
")",
"{",
"$",
"callback",
"=",
"func_get_arg",
"(",
"0",
")",
";",
"}",
"else",
"{",
"$",
"query",
"=",
"func_get_arg",
"(",
"0",
")",
";",
"$",
"callback",
"=",
"func_get_arg",
"(",
"1",
")",
";",
"}",
"$",
"index",
"=",
"func_num_args",
"(",
")",
"==",
"1",
"?",
"$",
"this",
"->",
"find",
"(",
"$",
"callback",
")",
":",
"$",
"this",
"->",
"find",
"(",
"$",
"query",
",",
"$",
"callback",
")",
";",
"if",
"(",
"$",
"index",
"!==",
"null",
")",
"{",
"$",
"index",
"=",
"$",
"this",
"->",
"indexOf",
"(",
"$",
"index",
")",
";",
"}",
"return",
"$",
"index",
";",
"}"
] |
Searches the collection with a given callback and returns the index for the first element if found.
The callback function takes one or two parameters:
function ($element [, $query]) {}
The callback must return a boolean
@param mixed $query OPTIONAL the provided query
@param callable $callback the callback function
@return int|null the index or null if it hasn't been found
|
[
"Searches",
"the",
"collection",
"with",
"a",
"given",
"callback",
"and",
"returns",
"the",
"index",
"for",
"the",
"first",
"element",
"if",
"found",
"."
] |
e745fe3735a6f2099015d11ea7b917634ebf76f3
|
https://github.com/phootwork/collection/blob/e745fe3735a6f2099015d11ea7b917634ebf76f3/src/AbstractList.php#L83-L97
|
224,680
|
phootwork/collection
|
src/AbstractList.php
|
AbstractList.findLastIndex
|
public function findLastIndex() {
if (func_num_args() == 1) {
$callback = func_get_arg(0);
} else {
$query = func_get_arg(0);
$callback = func_get_arg(1);
}
$index = func_num_args() == 1 ? $this->findLast($callback) : $this->findLast($query, $callback);
if ($index !== null) {
$index = $this->indexOf($index);
}
return $index;
}
|
php
|
public function findLastIndex() {
if (func_num_args() == 1) {
$callback = func_get_arg(0);
} else {
$query = func_get_arg(0);
$callback = func_get_arg(1);
}
$index = func_num_args() == 1 ? $this->findLast($callback) : $this->findLast($query, $callback);
if ($index !== null) {
$index = $this->indexOf($index);
}
return $index;
}
|
[
"public",
"function",
"findLastIndex",
"(",
")",
"{",
"if",
"(",
"func_num_args",
"(",
")",
"==",
"1",
")",
"{",
"$",
"callback",
"=",
"func_get_arg",
"(",
"0",
")",
";",
"}",
"else",
"{",
"$",
"query",
"=",
"func_get_arg",
"(",
"0",
")",
";",
"$",
"callback",
"=",
"func_get_arg",
"(",
"1",
")",
";",
"}",
"$",
"index",
"=",
"func_num_args",
"(",
")",
"==",
"1",
"?",
"$",
"this",
"->",
"findLast",
"(",
"$",
"callback",
")",
":",
"$",
"this",
"->",
"findLast",
"(",
"$",
"query",
",",
"$",
"callback",
")",
";",
"if",
"(",
"$",
"index",
"!==",
"null",
")",
"{",
"$",
"index",
"=",
"$",
"this",
"->",
"indexOf",
"(",
"$",
"index",
")",
";",
"}",
"return",
"$",
"index",
";",
"}"
] |
Searches the collection with a given callback and returns the index for the last element if found.
The callback function takes one or two parameters:
function ($element [, $query]) {}
The callback must return a boolean
@param mixed $query OPTIONAL the provided query
@param callable $callback the callback function
@return int|null the index or null if it hasn't been found
|
[
"Searches",
"the",
"collection",
"with",
"a",
"given",
"callback",
"and",
"returns",
"the",
"index",
"for",
"the",
"last",
"element",
"if",
"found",
"."
] |
e745fe3735a6f2099015d11ea7b917634ebf76f3
|
https://github.com/phootwork/collection/blob/e745fe3735a6f2099015d11ea7b917634ebf76f3/src/AbstractList.php#L112-L126
|
224,681
|
phootwork/collection
|
src/AbstractCollection.php
|
AbstractCollection.every
|
public function every(callable $callback) {
$match = true;
foreach ($this->collection as $element) {
$match = $match && $callback($element);
}
return $match;
}
|
php
|
public function every(callable $callback) {
$match = true;
foreach ($this->collection as $element) {
$match = $match && $callback($element);
}
return $match;
}
|
[
"public",
"function",
"every",
"(",
"callable",
"$",
"callback",
")",
"{",
"$",
"match",
"=",
"true",
";",
"foreach",
"(",
"$",
"this",
"->",
"collection",
"as",
"$",
"element",
")",
"{",
"$",
"match",
"=",
"$",
"match",
"&&",
"$",
"callback",
"(",
"$",
"element",
")",
";",
"}",
"return",
"$",
"match",
";",
"}"
] |
Tests whether all elements in the collection pass the test implemented by the provided function.
Returns <code>true</code> for an empty collection.
@param callable $callback
@return boolean
|
[
"Tests",
"whether",
"all",
"elements",
"in",
"the",
"collection",
"pass",
"the",
"test",
"implemented",
"by",
"the",
"provided",
"function",
"."
] |
e745fe3735a6f2099015d11ea7b917634ebf76f3
|
https://github.com/phootwork/collection/blob/e745fe3735a6f2099015d11ea7b917634ebf76f3/src/AbstractCollection.php#L63-L70
|
224,682
|
phootwork/collection
|
src/AbstractCollection.php
|
AbstractCollection.some
|
public function some(callable $callback) {
$match = false;
foreach ($this->collection as $element) {
$match = $match || $callback($element);
}
return $match;
}
|
php
|
public function some(callable $callback) {
$match = false;
foreach ($this->collection as $element) {
$match = $match || $callback($element);
}
return $match;
}
|
[
"public",
"function",
"some",
"(",
"callable",
"$",
"callback",
")",
"{",
"$",
"match",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"collection",
"as",
"$",
"element",
")",
"{",
"$",
"match",
"=",
"$",
"match",
"||",
"$",
"callback",
"(",
"$",
"element",
")",
";",
"}",
"return",
"$",
"match",
";",
"}"
] |
Tests whether at least one element in the collection passes the test implemented by the provided function.
Returns <code>false</code> for an empty collection.
@param callable $callback
@return boolean
|
[
"Tests",
"whether",
"at",
"least",
"one",
"element",
"in",
"the",
"collection",
"passes",
"the",
"test",
"implemented",
"by",
"the",
"provided",
"function",
"."
] |
e745fe3735a6f2099015d11ea7b917634ebf76f3
|
https://github.com/phootwork/collection/blob/e745fe3735a6f2099015d11ea7b917634ebf76f3/src/AbstractCollection.php#L80-L87
|
224,683
|
phootwork/collection
|
src/AbstractCollection.php
|
AbstractCollection.search
|
public function search() {
if (func_num_args() == 1) {
$callback = func_get_arg(0);
} else {
$query = func_get_arg(0);
$callback = func_get_arg(1);
}
foreach ($this->collection as $element) {
$return = func_num_args() == 1 ? $callback($element) : $callback($element, $query);
if ($return) {
return true;
}
}
return false;
}
|
php
|
public function search() {
if (func_num_args() == 1) {
$callback = func_get_arg(0);
} else {
$query = func_get_arg(0);
$callback = func_get_arg(1);
}
foreach ($this->collection as $element) {
$return = func_num_args() == 1 ? $callback($element) : $callback($element, $query);
if ($return) {
return true;
}
}
return false;
}
|
[
"public",
"function",
"search",
"(",
")",
"{",
"if",
"(",
"func_num_args",
"(",
")",
"==",
"1",
")",
"{",
"$",
"callback",
"=",
"func_get_arg",
"(",
"0",
")",
";",
"}",
"else",
"{",
"$",
"query",
"=",
"func_get_arg",
"(",
"0",
")",
";",
"$",
"callback",
"=",
"func_get_arg",
"(",
"1",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"collection",
"as",
"$",
"element",
")",
"{",
"$",
"return",
"=",
"func_num_args",
"(",
")",
"==",
"1",
"?",
"$",
"callback",
"(",
"$",
"element",
")",
":",
"$",
"callback",
"(",
"$",
"element",
",",
"$",
"query",
")",
";",
"if",
"(",
"$",
"return",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Searches the collection for query using the callback function on each element
The callback function takes one or two parameters:
function ($element [, $query]) {}
The callback must return a boolean
@param mixed $query (optional)
@param callable $callback
@return boolean
|
[
"Searches",
"the",
"collection",
"for",
"query",
"using",
"the",
"callback",
"function",
"on",
"each",
"element"
] |
e745fe3735a6f2099015d11ea7b917634ebf76f3
|
https://github.com/phootwork/collection/blob/e745fe3735a6f2099015d11ea7b917634ebf76f3/src/AbstractCollection.php#L102-L118
|
224,684
|
fojuth/plupload
|
src/Fojuth/Plupload/Controllers/PluploadController.php
|
PluploadController.gate
|
public function gate() {
// The upload handler class name can be set as a GET parameter, but it must exist in the config file
if (true === isset($_GET['upload_handler'])) {
$handler = (string) str_replace('::', '\\', $_GET['upload_handler']);
$class_name = \Config::get('plupload::plupload.upload_handler_'.$handler);
}
else {
$class_name = \Config::get('plupload::plupload.upload_handler');
}
$this->upload_handler = new $class_name;
// The upload handler must implement a specific interface
if (false === $this->upload_handler instanceof \Fojuth\Plupload\UploadHandlerInterface) {
throw new \LogicException('The upload handler must implement the \Fojuth\Plupload\UploadHandlerInterface interface.');
}
// All looks fine, we start the upload
return $this->upload_handler->upload(\Input::file('file'));
}
|
php
|
public function gate() {
// The upload handler class name can be set as a GET parameter, but it must exist in the config file
if (true === isset($_GET['upload_handler'])) {
$handler = (string) str_replace('::', '\\', $_GET['upload_handler']);
$class_name = \Config::get('plupload::plupload.upload_handler_'.$handler);
}
else {
$class_name = \Config::get('plupload::plupload.upload_handler');
}
$this->upload_handler = new $class_name;
// The upload handler must implement a specific interface
if (false === $this->upload_handler instanceof \Fojuth\Plupload\UploadHandlerInterface) {
throw new \LogicException('The upload handler must implement the \Fojuth\Plupload\UploadHandlerInterface interface.');
}
// All looks fine, we start the upload
return $this->upload_handler->upload(\Input::file('file'));
}
|
[
"public",
"function",
"gate",
"(",
")",
"{",
"// The upload handler class name can be set as a GET parameter, but it must exist in the config file",
"if",
"(",
"true",
"===",
"isset",
"(",
"$",
"_GET",
"[",
"'upload_handler'",
"]",
")",
")",
"{",
"$",
"handler",
"=",
"(",
"string",
")",
"str_replace",
"(",
"'::'",
",",
"'\\\\'",
",",
"$",
"_GET",
"[",
"'upload_handler'",
"]",
")",
";",
"$",
"class_name",
"=",
"\\",
"Config",
"::",
"get",
"(",
"'plupload::plupload.upload_handler_'",
".",
"$",
"handler",
")",
";",
"}",
"else",
"{",
"$",
"class_name",
"=",
"\\",
"Config",
"::",
"get",
"(",
"'plupload::plupload.upload_handler'",
")",
";",
"}",
"$",
"this",
"->",
"upload_handler",
"=",
"new",
"$",
"class_name",
";",
"// The upload handler must implement a specific interface",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"upload_handler",
"instanceof",
"\\",
"Fojuth",
"\\",
"Plupload",
"\\",
"UploadHandlerInterface",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'The upload handler must implement the \\Fojuth\\Plupload\\UploadHandlerInterface interface.'",
")",
";",
"}",
"// All looks fine, we start the upload",
"return",
"$",
"this",
"->",
"upload_handler",
"->",
"upload",
"(",
"\\",
"Input",
"::",
"file",
"(",
"'file'",
")",
")",
";",
"}"
] |
Instantiate the upload handler and start the upload process.
@throws \LogicException
|
[
"Instantiate",
"the",
"upload",
"handler",
"and",
"start",
"the",
"upload",
"process",
"."
] |
9d27e62516761352863cd08b7a2342326d69dd5c
|
https://github.com/fojuth/plupload/blob/9d27e62516761352863cd08b7a2342326d69dd5c/src/Fojuth/Plupload/Controllers/PluploadController.php#L19-L40
|
224,685
|
netz98/n98-deployer
|
src/Deployer/Config/ReleaseConfig.php
|
ReleaseConfig.register
|
public static function register()
{
\Deployer\set('release_path_app', function () { return ReleaseConfig::getReleasePathAppDir(); });
\Deployer\set('shared_path_app', function () { return ReleaseConfig::getSharedPathAppDir(); });
\Deployer\set('release_name', function () { return GetReleasesNameService::execute(); });
\Deployer\set('releases_list', function () { return GetReleasesListService::execute(); });
}
|
php
|
public static function register()
{
\Deployer\set('release_path_app', function () { return ReleaseConfig::getReleasePathAppDir(); });
\Deployer\set('shared_path_app', function () { return ReleaseConfig::getSharedPathAppDir(); });
\Deployer\set('release_name', function () { return GetReleasesNameService::execute(); });
\Deployer\set('releases_list', function () { return GetReleasesListService::execute(); });
}
|
[
"public",
"static",
"function",
"register",
"(",
")",
"{",
"\\",
"Deployer",
"\\",
"set",
"(",
"'release_path_app'",
",",
"function",
"(",
")",
"{",
"return",
"ReleaseConfig",
"::",
"getReleasePathAppDir",
"(",
")",
";",
"}",
")",
";",
"\\",
"Deployer",
"\\",
"set",
"(",
"'shared_path_app'",
",",
"function",
"(",
")",
"{",
"return",
"ReleaseConfig",
"::",
"getSharedPathAppDir",
"(",
")",
";",
"}",
")",
";",
"\\",
"Deployer",
"\\",
"set",
"(",
"'release_name'",
",",
"function",
"(",
")",
"{",
"return",
"GetReleasesNameService",
"::",
"execute",
"(",
")",
";",
"}",
")",
";",
"\\",
"Deployer",
"\\",
"set",
"(",
"'releases_list'",
",",
"function",
"(",
")",
"{",
"return",
"GetReleasesListService",
"::",
"execute",
"(",
")",
";",
"}",
")",
";",
"}"
] |
Register Config Proxies that are executed when config is fetched the first time
|
[
"Register",
"Config",
"Proxies",
"that",
"are",
"executed",
"when",
"config",
"is",
"fetched",
"the",
"first",
"time"
] |
cf7b7c790f45c41ed338b8a33b498eeaaaa765e9
|
https://github.com/netz98/n98-deployer/blob/cf7b7c790f45c41ed338b8a33b498eeaaaa765e9/src/Deployer/Config/ReleaseConfig.php#L22-L29
|
224,686
|
burnbright/silverstripe-importexport
|
code/bulkloader/ListBulkLoader.php
|
ListBulkLoader.processAll
|
protected function processAll($filepath, $preview = false)
{
$iterator = $this->getSource()->getIterator();
$results = new BetterBulkLoader_Result();
foreach ($iterator as $record) {
if ($id = $this->processRecord($record, $this->columnMap, $results, $preview)) {
$this->list->add($id);
}
}
return $results;
}
|
php
|
protected function processAll($filepath, $preview = false)
{
$iterator = $this->getSource()->getIterator();
$results = new BetterBulkLoader_Result();
foreach ($iterator as $record) {
if ($id = $this->processRecord($record, $this->columnMap, $results, $preview)) {
$this->list->add($id);
}
}
return $results;
}
|
[
"protected",
"function",
"processAll",
"(",
"$",
"filepath",
",",
"$",
"preview",
"=",
"false",
")",
"{",
"$",
"iterator",
"=",
"$",
"this",
"->",
"getSource",
"(",
")",
"->",
"getIterator",
"(",
")",
";",
"$",
"results",
"=",
"new",
"BetterBulkLoader_Result",
"(",
")",
";",
"foreach",
"(",
"$",
"iterator",
"as",
"$",
"record",
")",
"{",
"if",
"(",
"$",
"id",
"=",
"$",
"this",
"->",
"processRecord",
"(",
"$",
"record",
",",
"$",
"this",
"->",
"columnMap",
",",
"$",
"results",
",",
"$",
"preview",
")",
")",
"{",
"$",
"this",
"->",
"list",
"->",
"add",
"(",
"$",
"id",
")",
";",
"}",
"}",
"return",
"$",
"results",
";",
"}"
] |
Add records to the list.
|
[
"Add",
"records",
"to",
"the",
"list",
"."
] |
673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3
|
https://github.com/burnbright/silverstripe-importexport/blob/673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3/code/bulkloader/ListBulkLoader.php#L41-L52
|
224,687
|
netz98/n98-deployer
|
src/Deployer/Task/BuildTasks.php
|
BuildTasks.generateSharedDirs
|
public static function generateSharedDirs()
{
/** @var array $dirs */
$dirs = \Deployer\get('shared_dirs');
foreach ($dirs as $dir) {
$cmd = "mkdir -p {{deploy_path}}/shared/$dir";
\Deployer\run($cmd);
}
}
|
php
|
public static function generateSharedDirs()
{
/** @var array $dirs */
$dirs = \Deployer\get('shared_dirs');
foreach ($dirs as $dir) {
$cmd = "mkdir -p {{deploy_path}}/shared/$dir";
\Deployer\run($cmd);
}
}
|
[
"public",
"static",
"function",
"generateSharedDirs",
"(",
")",
"{",
"/** @var array $dirs */",
"$",
"dirs",
"=",
"\\",
"Deployer",
"\\",
"get",
"(",
"'shared_dirs'",
")",
";",
"foreach",
"(",
"$",
"dirs",
"as",
"$",
"dir",
")",
"{",
"$",
"cmd",
"=",
"\"mkdir -p {{deploy_path}}/shared/$dir\"",
";",
"\\",
"Deployer",
"\\",
"run",
"(",
"$",
"cmd",
")",
";",
"}",
"}"
] |
Generate Shared Dirs
@todo validate if this method is still needed? recipe/deploy/shared.php should suffice
|
[
"Generate",
"Shared",
"Dirs"
] |
cf7b7c790f45c41ed338b8a33b498eeaaaa765e9
|
https://github.com/netz98/n98-deployer/blob/cf7b7c790f45c41ed338b8a33b498eeaaaa765e9/src/Deployer/Task/BuildTasks.php#L58-L67
|
224,688
|
netz98/n98-deployer
|
src/Deployer/Task/BuildTasks.php
|
BuildTasks.changeOwnerAndMode
|
public static function changeOwnerAndMode()
{
$dirs = \Deployer\get('change_owner_mode_dirs');
if (empty($dirs)) {
return;
}
foreach ($dirs as $key => $dirData) {
$dir = $dirData['dir'];
$owner = $dirData['owner'];
$mode = $dirData['mode'];
\Deployer\run("sudo chown -RH $owner $dir");
\Deployer\run("sudo chmod -R $mode $dir");
}
}
|
php
|
public static function changeOwnerAndMode()
{
$dirs = \Deployer\get('change_owner_mode_dirs');
if (empty($dirs)) {
return;
}
foreach ($dirs as $key => $dirData) {
$dir = $dirData['dir'];
$owner = $dirData['owner'];
$mode = $dirData['mode'];
\Deployer\run("sudo chown -RH $owner $dir");
\Deployer\run("sudo chmod -R $mode $dir");
}
}
|
[
"public",
"static",
"function",
"changeOwnerAndMode",
"(",
")",
"{",
"$",
"dirs",
"=",
"\\",
"Deployer",
"\\",
"get",
"(",
"'change_owner_mode_dirs'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"dirs",
")",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"dirs",
"as",
"$",
"key",
"=>",
"$",
"dirData",
")",
"{",
"$",
"dir",
"=",
"$",
"dirData",
"[",
"'dir'",
"]",
";",
"$",
"owner",
"=",
"$",
"dirData",
"[",
"'owner'",
"]",
";",
"$",
"mode",
"=",
"$",
"dirData",
"[",
"'mode'",
"]",
";",
"\\",
"Deployer",
"\\",
"run",
"(",
"\"sudo chown -RH $owner $dir\"",
")",
";",
"\\",
"Deployer",
"\\",
"run",
"(",
"\"sudo chmod -R $mode $dir\"",
")",
";",
"}",
"}"
] |
Fix File Ownership and access rights for both deploy user and webserver_user
|
[
"Fix",
"File",
"Ownership",
"and",
"access",
"rights",
"for",
"both",
"deploy",
"user",
"and",
"webserver_user"
] |
cf7b7c790f45c41ed338b8a33b498eeaaaa765e9
|
https://github.com/netz98/n98-deployer/blob/cf7b7c790f45c41ed338b8a33b498eeaaaa765e9/src/Deployer/Task/BuildTasks.php#L72-L88
|
224,689
|
acacha/users
|
src/Traits/ExposePermissions.php
|
ExposePermissions.getCanAttribute
|
public function getCanAttribute()
{
$permissions = [];
foreach (Permission::all() as $permission) {
if (Auth::check() && Auth::user()->can($permission->name)) {
$permissions[$permission->name] = true;
} else {
$permissions[$permission->name] = false;
}
}
return $permissions;
}
|
php
|
public function getCanAttribute()
{
$permissions = [];
foreach (Permission::all() as $permission) {
if (Auth::check() && Auth::user()->can($permission->name)) {
$permissions[$permission->name] = true;
} else {
$permissions[$permission->name] = false;
}
}
return $permissions;
}
|
[
"public",
"function",
"getCanAttribute",
"(",
")",
"{",
"$",
"permissions",
"=",
"[",
"]",
";",
"foreach",
"(",
"Permission",
"::",
"all",
"(",
")",
"as",
"$",
"permission",
")",
"{",
"if",
"(",
"Auth",
"::",
"check",
"(",
")",
"&&",
"Auth",
"::",
"user",
"(",
")",
"->",
"can",
"(",
"$",
"permission",
"->",
"name",
")",
")",
"{",
"$",
"permissions",
"[",
"$",
"permission",
"->",
"name",
"]",
"=",
"true",
";",
"}",
"else",
"{",
"$",
"permissions",
"[",
"$",
"permission",
"->",
"name",
"]",
"=",
"false",
";",
"}",
"}",
"return",
"$",
"permissions",
";",
"}"
] |
Get all user permissions in a flat array.
@return array
|
[
"Get",
"all",
"user",
"permissions",
"in",
"a",
"flat",
"array",
"."
] |
af74be23d225bc9a23ee049579abb1596ae683c0
|
https://github.com/acacha/users/blob/af74be23d225bc9a23ee049579abb1596ae683c0/src/Traits/ExposePermissions.php#L20-L31
|
224,690
|
neos/setup
|
Classes/Core/BasicRequirements.php
|
BasicRequirements.findError
|
public function findError()
{
$requiredEnvironmentError = $this->ensureRequiredEnvironment();
if ($requiredEnvironmentError !== null) {
return $this->setErrorTitle($requiredEnvironmentError, 'Environment requirements not fulfilled');
}
$filePermissionsError = $this->checkFilePermissions();
if ($filePermissionsError !== null) {
return $this->setErrorTitle($filePermissionsError, 'Error with file system permissions');
}
return null;
}
|
php
|
public function findError()
{
$requiredEnvironmentError = $this->ensureRequiredEnvironment();
if ($requiredEnvironmentError !== null) {
return $this->setErrorTitle($requiredEnvironmentError, 'Environment requirements not fulfilled');
}
$filePermissionsError = $this->checkFilePermissions();
if ($filePermissionsError !== null) {
return $this->setErrorTitle($filePermissionsError, 'Error with file system permissions');
}
return null;
}
|
[
"public",
"function",
"findError",
"(",
")",
"{",
"$",
"requiredEnvironmentError",
"=",
"$",
"this",
"->",
"ensureRequiredEnvironment",
"(",
")",
";",
"if",
"(",
"$",
"requiredEnvironmentError",
"!==",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"setErrorTitle",
"(",
"$",
"requiredEnvironmentError",
",",
"'Environment requirements not fulfilled'",
")",
";",
"}",
"$",
"filePermissionsError",
"=",
"$",
"this",
"->",
"checkFilePermissions",
"(",
")",
";",
"if",
"(",
"$",
"filePermissionsError",
"!==",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"setErrorTitle",
"(",
"$",
"filePermissionsError",
",",
"'Error with file system permissions'",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Ensure that the environment and file permission requirements are fulfilled.
@return \Neos\Error\Messages\Error if requirements are fulfilled, NULL is returned. else, an Error object is returned.
|
[
"Ensure",
"that",
"the",
"environment",
"and",
"file",
"permission",
"requirements",
"are",
"fulfilled",
"."
] |
7b5437efe8113e997007be6896628aa9f5c39d2f
|
https://github.com/neos/setup/blob/7b5437efe8113e997007be6896628aa9f5c39d2f/Classes/Core/BasicRequirements.php#L77-L90
|
224,691
|
neos/setup
|
Classes/Core/BasicRequirements.php
|
BasicRequirements.checkFilePermissions
|
protected function checkFilePermissions()
{
foreach ($this->requiredWritableFolders as $folder) {
$folderPath = FLOW_PATH_ROOT . $folder;
if (!is_dir($folderPath) && !\Neos\Utility\Files::is_link($folderPath)) {
try {
\Neos\Utility\Files::createDirectoryRecursively($folderPath);
} catch (\Neos\Flow\Utility\Exception $exception) {
return new Error('Unable to create folder "%s". Check your file permissions (did you use flow:core:setfilepermissions?).', 1330363887, [$folderPath]);
}
}
if (!is_writable($folderPath)) {
return new Error('The folder "%s" is not writable. Check your file permissions (did you use flow:core:setfilepermissions?)', 1330372964, [$folderPath]);
}
}
return null;
}
|
php
|
protected function checkFilePermissions()
{
foreach ($this->requiredWritableFolders as $folder) {
$folderPath = FLOW_PATH_ROOT . $folder;
if (!is_dir($folderPath) && !\Neos\Utility\Files::is_link($folderPath)) {
try {
\Neos\Utility\Files::createDirectoryRecursively($folderPath);
} catch (\Neos\Flow\Utility\Exception $exception) {
return new Error('Unable to create folder "%s". Check your file permissions (did you use flow:core:setfilepermissions?).', 1330363887, [$folderPath]);
}
}
if (!is_writable($folderPath)) {
return new Error('The folder "%s" is not writable. Check your file permissions (did you use flow:core:setfilepermissions?)', 1330372964, [$folderPath]);
}
}
return null;
}
|
[
"protected",
"function",
"checkFilePermissions",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"requiredWritableFolders",
"as",
"$",
"folder",
")",
"{",
"$",
"folderPath",
"=",
"FLOW_PATH_ROOT",
".",
"$",
"folder",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"folderPath",
")",
"&&",
"!",
"\\",
"Neos",
"\\",
"Utility",
"\\",
"Files",
"::",
"is_link",
"(",
"$",
"folderPath",
")",
")",
"{",
"try",
"{",
"\\",
"Neos",
"\\",
"Utility",
"\\",
"Files",
"::",
"createDirectoryRecursively",
"(",
"$",
"folderPath",
")",
";",
"}",
"catch",
"(",
"\\",
"Neos",
"\\",
"Flow",
"\\",
"Utility",
"\\",
"Exception",
"$",
"exception",
")",
"{",
"return",
"new",
"Error",
"(",
"'Unable to create folder \"%s\". Check your file permissions (did you use flow:core:setfilepermissions?).'",
",",
"1330363887",
",",
"[",
"$",
"folderPath",
"]",
")",
";",
"}",
"}",
"if",
"(",
"!",
"is_writable",
"(",
"$",
"folderPath",
")",
")",
"{",
"return",
"new",
"Error",
"(",
"'The folder \"%s\" is not writable. Check your file permissions (did you use flow:core:setfilepermissions?)'",
",",
"1330372964",
",",
"[",
"$",
"folderPath",
"]",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Check write permissions for folders used for writing files
@return mixed
|
[
"Check",
"write",
"permissions",
"for",
"folders",
"used",
"for",
"writing",
"files"
] |
7b5437efe8113e997007be6896628aa9f5c39d2f
|
https://github.com/neos/setup/blob/7b5437efe8113e997007be6896628aa9f5c39d2f/Classes/Core/BasicRequirements.php#L153-L170
|
224,692
|
joomla-framework/github-api
|
src/Package/Repositories/Comments.php
|
Comments.edit
|
public function edit($user, $repo, $id, $comment)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo . '/comments/' . $id;
$data = json_encode(
array(
'body' => $comment,
)
);
// Send the request.
return $this->processResponse(
$this->client->patch($this->fetchUrl($path), $data)
);
}
|
php
|
public function edit($user, $repo, $id, $comment)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo . '/comments/' . $id;
$data = json_encode(
array(
'body' => $comment,
)
);
// Send the request.
return $this->processResponse(
$this->client->patch($this->fetchUrl($path), $data)
);
}
|
[
"public",
"function",
"edit",
"(",
"$",
"user",
",",
"$",
"repo",
",",
"$",
"id",
",",
"$",
"comment",
")",
"{",
"// Build the request path.",
"$",
"path",
"=",
"'/repos/'",
".",
"$",
"user",
".",
"'/'",
".",
"$",
"repo",
".",
"'/comments/'",
".",
"$",
"id",
";",
"$",
"data",
"=",
"json_encode",
"(",
"array",
"(",
"'body'",
"=>",
"$",
"comment",
",",
")",
")",
";",
"// Send the request.",
"return",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"this",
"->",
"client",
"->",
"patch",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"path",
")",
",",
"$",
"data",
")",
")",
";",
"}"
] |
Update a commit comment.
@param string $user The name of the owner of the GitHub repository.
@param string $repo The name of the GitHub repository.
@param string $id The ID of the comment to edit.
@param string $comment The text of the comment.
@return object
@since 1.0
|
[
"Update",
"a",
"commit",
"comment",
"."
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Repositories/Comments.php#L103-L118
|
224,693
|
joomla-framework/github-api
|
src/Package/Repositories/Comments.php
|
Comments.create
|
public function create($user, $repo, $sha, $comment, $line, $filepath, $position)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo . '/commits/' . $sha . '/comments';
$data = json_encode(
array(
'body' => $comment,
'path' => $filepath,
'position' => (int) $position,
'line' => (int) $line,
)
);
// Send the request.
return $this->processResponse(
$this->client->post($this->fetchUrl($path), $data),
201
);
}
|
php
|
public function create($user, $repo, $sha, $comment, $line, $filepath, $position)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo . '/commits/' . $sha . '/comments';
$data = json_encode(
array(
'body' => $comment,
'path' => $filepath,
'position' => (int) $position,
'line' => (int) $line,
)
);
// Send the request.
return $this->processResponse(
$this->client->post($this->fetchUrl($path), $data),
201
);
}
|
[
"public",
"function",
"create",
"(",
"$",
"user",
",",
"$",
"repo",
",",
"$",
"sha",
",",
"$",
"comment",
",",
"$",
"line",
",",
"$",
"filepath",
",",
"$",
"position",
")",
"{",
"// Build the request path.",
"$",
"path",
"=",
"'/repos/'",
".",
"$",
"user",
".",
"'/'",
".",
"$",
"repo",
".",
"'/commits/'",
".",
"$",
"sha",
".",
"'/comments'",
";",
"$",
"data",
"=",
"json_encode",
"(",
"array",
"(",
"'body'",
"=>",
"$",
"comment",
",",
"'path'",
"=>",
"$",
"filepath",
",",
"'position'",
"=>",
"(",
"int",
")",
"$",
"position",
",",
"'line'",
"=>",
"(",
"int",
")",
"$",
"line",
",",
")",
")",
";",
"// Send the request.",
"return",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"this",
"->",
"client",
"->",
"post",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"path",
")",
",",
"$",
"data",
")",
",",
"201",
")",
";",
"}"
] |
Create a commit comment.
@param string $user The name of the owner of the GitHub repository.
@param string $repo The name of the GitHub repository.
@param string $sha The SHA of the commit to comment on.
@param string $comment The text of the comment.
@param integer $line The line number of the commit to comment on.
@param string $filepath A relative path to the file to comment on within the commit.
@param integer $position Line index in the diff to comment on.
@return object
@since 1.0
|
[
"Create",
"a",
"commit",
"comment",
"."
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Repositories/Comments.php#L158-L177
|
224,694
|
alxmsl/AppStoreClient
|
source/Client.php
|
Client.verifyReceipt
|
public function verifyReceipt($receipt) {
$Request = $this->getRequest($this->getEndpointUrl());
$Request->addPostField('receipt-data', $receipt)
->addPostField('password', $this->getPassword());
$data = $Request->send();
try {
return ResponsePayload::initializeByString($data);
} catch (InvalidArgumentException $Ex) {
try {
return RenewableStatus::initializeByString($data);
} catch (InvalidArgumentException $ex) {
return Status::initializeByString($data);
}
}
}
|
php
|
public function verifyReceipt($receipt) {
$Request = $this->getRequest($this->getEndpointUrl());
$Request->addPostField('receipt-data', $receipt)
->addPostField('password', $this->getPassword());
$data = $Request->send();
try {
return ResponsePayload::initializeByString($data);
} catch (InvalidArgumentException $Ex) {
try {
return RenewableStatus::initializeByString($data);
} catch (InvalidArgumentException $ex) {
return Status::initializeByString($data);
}
}
}
|
[
"public",
"function",
"verifyReceipt",
"(",
"$",
"receipt",
")",
"{",
"$",
"Request",
"=",
"$",
"this",
"->",
"getRequest",
"(",
"$",
"this",
"->",
"getEndpointUrl",
"(",
")",
")",
";",
"$",
"Request",
"->",
"addPostField",
"(",
"'receipt-data'",
",",
"$",
"receipt",
")",
"->",
"addPostField",
"(",
"'password'",
",",
"$",
"this",
"->",
"getPassword",
"(",
")",
")",
";",
"$",
"data",
"=",
"$",
"Request",
"->",
"send",
"(",
")",
";",
"try",
"{",
"return",
"ResponsePayload",
"::",
"initializeByString",
"(",
"$",
"data",
")",
";",
"}",
"catch",
"(",
"InvalidArgumentException",
"$",
"Ex",
")",
"{",
"try",
"{",
"return",
"RenewableStatus",
"::",
"initializeByString",
"(",
"$",
"data",
")",
";",
"}",
"catch",
"(",
"InvalidArgumentException",
"$",
"ex",
")",
"{",
"return",
"Status",
"::",
"initializeByString",
"(",
"$",
"data",
")",
";",
"}",
"}",
"}"
] |
Method for receipts data verification
@param string $receipt base64 encoded receipt
@return Status|RenewableStatus|ResponsePayload iTunes status for receipt
|
[
"Method",
"for",
"receipts",
"data",
"verification"
] |
95b6e9ea9f8b717760cf648f4a2e83d6fe3103b4
|
https://github.com/alxmsl/AppStoreClient/blob/95b6e9ea9f8b717760cf648f4a2e83d6fe3103b4/source/Client.php#L43-L57
|
224,695
|
burnbright/silverstripe-importexport
|
code/bulkloader/BetterBulkLoader_Result.php
|
BetterBulkLoader_Result.getMessageList
|
public function getMessageList()
{
$output = array();
if ($this->CreatedCount()) {
$output['created'] = _t(
'BulkLoader.IMPORTEDRECORDS', "Imported {count} new records.",
array('count' => $this->CreatedCount())
);
}
if ($this->UpdatedCount()) {
$output['updated'] = _t(
'BulkLoader.UPDATEDRECORDS', "Updated {count} records.",
array('count' => $this->UpdatedCount())
);
}
if ($this->DeletedCount()) {
$output['deleted'] = _t(
'BulkLoader.DELETEDRECORDS', "Deleted {count} records.",
array('count' => $this->DeletedCount())
);
}
if ($this->SkippedCount()) {
$output['skipped'] = _t(
'BulkLoader.SKIPPEDRECORDS', "Skipped {count} bad records.",
array('count' => $this->SkippedCount())
);
}
if (!$this->CreatedCount() && !$this->UpdatedCount()) {
$output['empty'] = _t('BulkLoader.NOIMPORT', "Nothing to import");
}
return $output;
}
|
php
|
public function getMessageList()
{
$output = array();
if ($this->CreatedCount()) {
$output['created'] = _t(
'BulkLoader.IMPORTEDRECORDS', "Imported {count} new records.",
array('count' => $this->CreatedCount())
);
}
if ($this->UpdatedCount()) {
$output['updated'] = _t(
'BulkLoader.UPDATEDRECORDS', "Updated {count} records.",
array('count' => $this->UpdatedCount())
);
}
if ($this->DeletedCount()) {
$output['deleted'] = _t(
'BulkLoader.DELETEDRECORDS', "Deleted {count} records.",
array('count' => $this->DeletedCount())
);
}
if ($this->SkippedCount()) {
$output['skipped'] = _t(
'BulkLoader.SKIPPEDRECORDS', "Skipped {count} bad records.",
array('count' => $this->SkippedCount())
);
}
if (!$this->CreatedCount() && !$this->UpdatedCount()) {
$output['empty'] = _t('BulkLoader.NOIMPORT', "Nothing to import");
}
return $output;
}
|
[
"public",
"function",
"getMessageList",
"(",
")",
"{",
"$",
"output",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"CreatedCount",
"(",
")",
")",
"{",
"$",
"output",
"[",
"'created'",
"]",
"=",
"_t",
"(",
"'BulkLoader.IMPORTEDRECORDS'",
",",
"\"Imported {count} new records.\"",
",",
"array",
"(",
"'count'",
"=>",
"$",
"this",
"->",
"CreatedCount",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"UpdatedCount",
"(",
")",
")",
"{",
"$",
"output",
"[",
"'updated'",
"]",
"=",
"_t",
"(",
"'BulkLoader.UPDATEDRECORDS'",
",",
"\"Updated {count} records.\"",
",",
"array",
"(",
"'count'",
"=>",
"$",
"this",
"->",
"UpdatedCount",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"DeletedCount",
"(",
")",
")",
"{",
"$",
"output",
"[",
"'deleted'",
"]",
"=",
"_t",
"(",
"'BulkLoader.DELETEDRECORDS'",
",",
"\"Deleted {count} records.\"",
",",
"array",
"(",
"'count'",
"=>",
"$",
"this",
"->",
"DeletedCount",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"SkippedCount",
"(",
")",
")",
"{",
"$",
"output",
"[",
"'skipped'",
"]",
"=",
"_t",
"(",
"'BulkLoader.SKIPPEDRECORDS'",
",",
"\"Skipped {count} bad records.\"",
",",
"array",
"(",
"'count'",
"=>",
"$",
"this",
"->",
"SkippedCount",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"CreatedCount",
"(",
")",
"&&",
"!",
"$",
"this",
"->",
"UpdatedCount",
"(",
")",
")",
"{",
"$",
"output",
"[",
"'empty'",
"]",
"=",
"_t",
"(",
"'BulkLoader.NOIMPORT'",
",",
"\"Nothing to import\"",
")",
";",
"}",
"return",
"$",
"output",
";",
"}"
] |
Get an array of messages describing the result.
@return array messages
|
[
"Get",
"an",
"array",
"of",
"messages",
"describing",
"the",
"result",
"."
] |
673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3
|
https://github.com/burnbright/silverstripe-importexport/blob/673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3/code/bulkloader/BetterBulkLoader_Result.php#L37-L70
|
224,696
|
hnhdigital-os/laravel-model-json
|
src/JsonColumnValue.php
|
JsonColumnValue.getOriginal
|
public function getOriginal($key = null, $default = null)
{
if ($key === null) {
return $this->internal_original_data;
} elseif (array_key_exists($key, $this->internal_original_data)) {
return $this->internal_original_data[$key];
}
return $default;
}
|
php
|
public function getOriginal($key = null, $default = null)
{
if ($key === null) {
return $this->internal_original_data;
} elseif (array_key_exists($key, $this->internal_original_data)) {
return $this->internal_original_data[$key];
}
return $default;
}
|
[
"public",
"function",
"getOriginal",
"(",
"$",
"key",
"=",
"null",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"key",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"internal_original_data",
";",
"}",
"elseif",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"internal_original_data",
")",
")",
"{",
"return",
"$",
"this",
"->",
"internal_original_data",
"[",
"$",
"key",
"]",
";",
"}",
"return",
"$",
"default",
";",
"}"
] |
Get the json data original values.
@param string|null $key
@param mixed $default
@return array
|
[
"Get",
"the",
"json",
"data",
"original",
"values",
"."
] |
092511d2ce76ffbd1e3a94c9bed48df9ce0be643
|
https://github.com/hnhdigital-os/laravel-model-json/blob/092511d2ce76ffbd1e3a94c9bed48df9ce0be643/src/JsonColumnValue.php#L71-L80
|
224,697
|
hnhdigital-os/laravel-model-json
|
src/JsonColumnValue.php
|
JsonColumnValue.getCurrent
|
public function getCurrent()
{
$data = [];
foreach (get_object_vars($this) as $key => $value) {
if (substr($key, 0, 8) !== 'internal') {
$data[$key] = $value;
}
}
return $data;
}
|
php
|
public function getCurrent()
{
$data = [];
foreach (get_object_vars($this) as $key => $value) {
if (substr($key, 0, 8) !== 'internal') {
$data[$key] = $value;
}
}
return $data;
}
|
[
"public",
"function",
"getCurrent",
"(",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"foreach",
"(",
"get_object_vars",
"(",
"$",
"this",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"key",
",",
"0",
",",
"8",
")",
"!==",
"'internal'",
")",
"{",
"$",
"data",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"data",
";",
"}"
] |
Get the current data as an array.
@return array
|
[
"Get",
"the",
"current",
"data",
"as",
"an",
"array",
"."
] |
092511d2ce76ffbd1e3a94c9bed48df9ce0be643
|
https://github.com/hnhdigital-os/laravel-model-json/blob/092511d2ce76ffbd1e3a94c9bed48df9ce0be643/src/JsonColumnValue.php#L87-L97
|
224,698
|
hnhdigital-os/laravel-model-json
|
src/JsonColumnValue.php
|
JsonColumnValue.getJson
|
public function getJson()
{
$dirty = $this->getDirty();
if (count($dirty)) {
$this->internal_original_value = $this->__toString();
}
return $this->internal_original_value;
}
|
php
|
public function getJson()
{
$dirty = $this->getDirty();
if (count($dirty)) {
$this->internal_original_value = $this->__toString();
}
return $this->internal_original_value;
}
|
[
"public",
"function",
"getJson",
"(",
")",
"{",
"$",
"dirty",
"=",
"$",
"this",
"->",
"getDirty",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"dirty",
")",
")",
"{",
"$",
"this",
"->",
"internal_original_value",
"=",
"$",
"this",
"->",
"__toString",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"internal_original_value",
";",
"}"
] |
Get the current data json encoded.
@return string
|
[
"Get",
"the",
"current",
"data",
"json",
"encoded",
"."
] |
092511d2ce76ffbd1e3a94c9bed48df9ce0be643
|
https://github.com/hnhdigital-os/laravel-model-json/blob/092511d2ce76ffbd1e3a94c9bed48df9ce0be643/src/JsonColumnValue.php#L104-L112
|
224,699
|
hnhdigital-os/laravel-model-json
|
src/JsonColumnValue.php
|
JsonColumnValue.getDirty
|
public function getDirty()
{
$dirty = [];
foreach ($this->getCurrent() as $key => $value) {
// Value is a default value and `no_saving_default_values` option has been enabled
if (array_key_exists('no_saving_default_values', $this->internal_options)
&& $this->internal_options['no_saving_default_values']
&& array_key_exists($key, $this->internal_defaults)
&& $this->internal_defaults[$key] === $value) {
// Do nothing
}
// Existing value has changed
elseif (array_key_exists($key, $this->internal_original_data)
&& $this->internal_original_data[$key] !== $value) {
$dirty[$key] = $value;
}
// New value that has been assigned
elseif (!array_key_exists($key, $this->internal_original_data)) {
$dirty[$key] = $value;
}
}
return $dirty;
}
|
php
|
public function getDirty()
{
$dirty = [];
foreach ($this->getCurrent() as $key => $value) {
// Value is a default value and `no_saving_default_values` option has been enabled
if (array_key_exists('no_saving_default_values', $this->internal_options)
&& $this->internal_options['no_saving_default_values']
&& array_key_exists($key, $this->internal_defaults)
&& $this->internal_defaults[$key] === $value) {
// Do nothing
}
// Existing value has changed
elseif (array_key_exists($key, $this->internal_original_data)
&& $this->internal_original_data[$key] !== $value) {
$dirty[$key] = $value;
}
// New value that has been assigned
elseif (!array_key_exists($key, $this->internal_original_data)) {
$dirty[$key] = $value;
}
}
return $dirty;
}
|
[
"public",
"function",
"getDirty",
"(",
")",
"{",
"$",
"dirty",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getCurrent",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"// Value is a default value and `no_saving_default_values` option has been enabled",
"if",
"(",
"array_key_exists",
"(",
"'no_saving_default_values'",
",",
"$",
"this",
"->",
"internal_options",
")",
"&&",
"$",
"this",
"->",
"internal_options",
"[",
"'no_saving_default_values'",
"]",
"&&",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"internal_defaults",
")",
"&&",
"$",
"this",
"->",
"internal_defaults",
"[",
"$",
"key",
"]",
"===",
"$",
"value",
")",
"{",
"// Do nothing",
"}",
"// Existing value has changed",
"elseif",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"internal_original_data",
")",
"&&",
"$",
"this",
"->",
"internal_original_data",
"[",
"$",
"key",
"]",
"!==",
"$",
"value",
")",
"{",
"$",
"dirty",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"// New value that has been assigned",
"elseif",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"internal_original_data",
")",
")",
"{",
"$",
"dirty",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"dirty",
";",
"}"
] |
Add json data values that have changed.
@return array
|
[
"Add",
"json",
"data",
"values",
"that",
"have",
"changed",
"."
] |
092511d2ce76ffbd1e3a94c9bed48df9ce0be643
|
https://github.com/hnhdigital-os/laravel-model-json/blob/092511d2ce76ffbd1e3a94c9bed48df9ce0be643/src/JsonColumnValue.php#L119-L145
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.