repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_code_tokens
sequencelengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
sequencelengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
GreenCape/joomla-cli | src/GreenCape/JoomlaCLI/Command.php | Command.setupEnvironment | protected function setupEnvironment($application, InputInterface $input, OutputInterface $output)
{
$basePath = $this->handleBasePath($input, $output);
$driverFactory = new DriverFactory;
$this->joomla = $driverFactory->create($basePath);
$this->joomla->setupEnvironment($basePath, $application);
} | php | protected function setupEnvironment($application, InputInterface $input, OutputInterface $output)
{
$basePath = $this->handleBasePath($input, $output);
$driverFactory = new DriverFactory;
$this->joomla = $driverFactory->create($basePath);
$this->joomla->setupEnvironment($basePath, $application);
} | [
"protected",
"function",
"setupEnvironment",
"(",
"$",
"application",
",",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"basePath",
"=",
"$",
"this",
"->",
"handleBasePath",
"(",
"$",
"input",
",",
"$",
"output",
")",
";",
"$",
"driverFactory",
"=",
"new",
"DriverFactory",
";",
"$",
"this",
"->",
"joomla",
"=",
"$",
"driverFactory",
"->",
"create",
"(",
"$",
"basePath",
")",
";",
"$",
"this",
"->",
"joomla",
"->",
"setupEnvironment",
"(",
"$",
"basePath",
",",
"$",
"application",
")",
";",
"}"
] | Setup the environment
@param string $application The application, eg., 'site' or 'administration'
@param InputInterface $input An InputInterface instance
@param OutputInterface $output An OutputInterface instance
@return void | [
"Setup",
"the",
"environment"
] | train | https://github.com/GreenCape/joomla-cli/blob/74a6940f27b1f66c99330d4f9e2c5ac314cdd369/src/GreenCape/JoomlaCLI/Command.php#L89-L96 |
GreenCape/joomla-cli | src/GreenCape/JoomlaCLI/Command.php | Command.handleBasePath | protected function handleBasePath(InputInterface $input, OutputInterface $output)
{
$path = realpath($input->getOption('basepath'));
$this->writeln($output, 'Joomla! installation expected in ' . $path, OutputInterface::VERBOSITY_DEBUG);
return $path;
} | php | protected function handleBasePath(InputInterface $input, OutputInterface $output)
{
$path = realpath($input->getOption('basepath'));
$this->writeln($output, 'Joomla! installation expected in ' . $path, OutputInterface::VERBOSITY_DEBUG);
return $path;
} | [
"protected",
"function",
"handleBasePath",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"path",
"=",
"realpath",
"(",
"$",
"input",
"->",
"getOption",
"(",
"'basepath'",
")",
")",
";",
"$",
"this",
"->",
"writeln",
"(",
"$",
"output",
",",
"'Joomla! installation expected in '",
".",
"$",
"path",
",",
"OutputInterface",
"::",
"VERBOSITY_DEBUG",
")",
";",
"return",
"$",
"path",
";",
"}"
] | Read the base path from the options
@param InputInterface $input An InputInterface instance
@param OutputInterface $output An OutputInterface instance
@return string The base path | [
"Read",
"the",
"base",
"path",
"from",
"the",
"options"
] | train | https://github.com/GreenCape/joomla-cli/blob/74a6940f27b1f66c99330d4f9e2c5ac314cdd369/src/GreenCape/JoomlaCLI/Command.php#L106-L112 |
GreenCape/joomla-cli | src/GreenCape/JoomlaCLI/Command.php | Command.writeln | protected function writeln(OutputInterface $output, $message, $level = OutputInterface::VERBOSITY_NORMAL, $mode = OutputInterface::OUTPUT_NORMAL)
{
if ($output->getVerbosity() >= $level)
{
$output->writeln($message, $mode);
}
} | php | protected function writeln(OutputInterface $output, $message, $level = OutputInterface::VERBOSITY_NORMAL, $mode = OutputInterface::OUTPUT_NORMAL)
{
if ($output->getVerbosity() >= $level)
{
$output->writeln($message, $mode);
}
} | [
"protected",
"function",
"writeln",
"(",
"OutputInterface",
"$",
"output",
",",
"$",
"message",
",",
"$",
"level",
"=",
"OutputInterface",
"::",
"VERBOSITY_NORMAL",
",",
"$",
"mode",
"=",
"OutputInterface",
"::",
"OUTPUT_NORMAL",
")",
"{",
"if",
"(",
"$",
"output",
"->",
"getVerbosity",
"(",
")",
">=",
"$",
"level",
")",
"{",
"$",
"output",
"->",
"writeln",
"(",
"$",
"message",
",",
"$",
"mode",
")",
";",
"}",
"}"
] | Proxy for OutputInterface::writeln()
@param OutputInterface $output An OutputInterface instance
@param string|array $message
@param int $level One of OutputInterface::VERBOSITY_*
@param int $mode One of OutputInterface::OUTPUT_*
@return void | [
"Proxy",
"for",
"OutputInterface",
"::",
"writeln",
"()"
] | train | https://github.com/GreenCape/joomla-cli/blob/74a6940f27b1f66c99330d4f9e2c5ac314cdd369/src/GreenCape/JoomlaCLI/Command.php#L124-L130 |
DevGroup-ru/yii2-users-module | src/models/LoginForm.php | LoginForm.login | public function login()
{
$module = UsersModule::module();
if ($this->validate()) {
return $this->user->login($this->rememberMe ? $module->loginDuration : 0);
} else {
return false;
}
} | php | public function login()
{
$module = UsersModule::module();
if ($this->validate()) {
return $this->user->login($this->rememberMe ? $module->loginDuration : 0);
} else {
return false;
}
} | [
"public",
"function",
"login",
"(",
")",
"{",
"$",
"module",
"=",
"UsersModule",
"::",
"module",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"validate",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"user",
"->",
"login",
"(",
"$",
"this",
"->",
"rememberMe",
"?",
"$",
"module",
"->",
"loginDuration",
":",
"0",
")",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] | Validates form and logs the user in.
@return bool whether the user is logged in successfully | [
"Validates",
"form",
"and",
"logs",
"the",
"user",
"in",
"."
] | train | https://github.com/DevGroup-ru/yii2-users-module/blob/ff0103dc55c3462627ccc704c33e70c96053f750/src/models/LoginForm.php#L76-L84 |
infinity-next/sleuth | src/Detectives/ffmpegDetective.php | ffmpegDetective.ffprobe | private function ffprobe($binary = null)
{
if (is_null($binary))
{
$binary = static::$ffprobe;
}
if (!isset($this->metadata))
{
$cmd = "{$binary} -v quiet -print_format json -show_format -show_streams {$this->file}";
exec($cmd, $output, $returnvalue);
$json = json_decode( implode("\n", $output), true );
if (!is_array($json))
{
$json = false;
}
$this->metadata = $json;
if ($this->ffprobeHasFormat())
{
$this->formats = array_filter(explode(",", $json['format']['format_name']));
}
}
} | php | private function ffprobe($binary = null)
{
if (is_null($binary))
{
$binary = static::$ffprobe;
}
if (!isset($this->metadata))
{
$cmd = "{$binary} -v quiet -print_format json -show_format -show_streams {$this->file}";
exec($cmd, $output, $returnvalue);
$json = json_decode( implode("\n", $output), true );
if (!is_array($json))
{
$json = false;
}
$this->metadata = $json;
if ($this->ffprobeHasFormat())
{
$this->formats = array_filter(explode(",", $json['format']['format_name']));
}
}
} | [
"private",
"function",
"ffprobe",
"(",
"$",
"binary",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"binary",
")",
")",
"{",
"$",
"binary",
"=",
"static",
"::",
"$",
"ffprobe",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"metadata",
")",
")",
"{",
"$",
"cmd",
"=",
"\"{$binary} -v quiet -print_format json -show_format -show_streams {$this->file}\"",
";",
"exec",
"(",
"$",
"cmd",
",",
"$",
"output",
",",
"$",
"returnvalue",
")",
";",
"$",
"json",
"=",
"json_decode",
"(",
"implode",
"(",
"\"\\n\"",
",",
"$",
"output",
")",
",",
"true",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"json",
")",
")",
"{",
"$",
"json",
"=",
"false",
";",
"}",
"$",
"this",
"->",
"metadata",
"=",
"$",
"json",
";",
"if",
"(",
"$",
"this",
"->",
"ffprobeHasFormat",
"(",
")",
")",
"{",
"$",
"this",
"->",
"formats",
"=",
"array_filter",
"(",
"explode",
"(",
"\",\"",
",",
"$",
"json",
"[",
"'format'",
"]",
"[",
"'format_name'",
"]",
")",
")",
";",
"}",
"}",
"}"
] | Runs an ffprobe on the file or returns cached information.
@return array|false | [
"Runs",
"an",
"ffprobe",
"on",
"the",
"file",
"or",
"returns",
"cached",
"information",
"."
] | train | https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Detectives/ffmpegDetective.php#L36-L63 |
infinity-next/sleuth | src/Detectives/ffmpegDetective.php | ffmpegDetective.ffprobeFormat | private function ffprobeFormat($format)
{
$this->ffprobe();
if (count($this->formats) > 0)
{
$args = func_get_args();
foreach ($args as $arg)
{
if (in_array($arg, $this->formats))
{
return true;
}
}
return null;
}
return false;
} | php | private function ffprobeFormat($format)
{
$this->ffprobe();
if (count($this->formats) > 0)
{
$args = func_get_args();
foreach ($args as $arg)
{
if (in_array($arg, $this->formats))
{
return true;
}
}
return null;
}
return false;
} | [
"private",
"function",
"ffprobeFormat",
"(",
"$",
"format",
")",
"{",
"$",
"this",
"->",
"ffprobe",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"formats",
")",
">",
"0",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"foreach",
"(",
"$",
"args",
"as",
"$",
"arg",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"arg",
",",
"$",
"this",
"->",
"formats",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"null",
";",
"}",
"return",
"false",
";",
"}"
] | Checks requested format against what formats ffprobe returned.
@param string $format The format extenson to check for.
@param string|null $format Option number of additional formats.
@return boolean|null | [
"Checks",
"requested",
"format",
"against",
"what",
"formats",
"ffprobe",
"returned",
"."
] | train | https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Detectives/ffmpegDetective.php#L72-L92 |
infinity-next/sleuth | src/Detectives/ffmpegDetective.php | ffmpegDetective.ffprobeHasVideo | private function ffprobeHasVideo()
{
if (isset($this->metadata['streams']))
{
foreach ($this->metadata['streams'] as $streamIndex => $stream)
{
if (isset($stream['codec_type']) && $stream['codec_type'] === "video" && $stream['disposition']['attached_pic'] !== 1)
{
return $streamIndex;
}
}
}
return false;
} | php | private function ffprobeHasVideo()
{
if (isset($this->metadata['streams']))
{
foreach ($this->metadata['streams'] as $streamIndex => $stream)
{
if (isset($stream['codec_type']) && $stream['codec_type'] === "video" && $stream['disposition']['attached_pic'] !== 1)
{
return $streamIndex;
}
}
}
return false;
} | [
"private",
"function",
"ffprobeHasVideo",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"metadata",
"[",
"'streams'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"metadata",
"[",
"'streams'",
"]",
"as",
"$",
"streamIndex",
"=>",
"$",
"stream",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"stream",
"[",
"'codec_type'",
"]",
")",
"&&",
"$",
"stream",
"[",
"'codec_type'",
"]",
"===",
"\"video\"",
"&&",
"$",
"stream",
"[",
"'disposition'",
"]",
"[",
"'attached_pic'",
"]",
"!==",
"1",
")",
"{",
"return",
"$",
"streamIndex",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] | Check our metadata for a video stream.
@return boolean|int Int if video stream index found (CAN BE 0), false if none | [
"Check",
"our",
"metadata",
"for",
"a",
"video",
"stream",
"."
] | train | https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Detectives/ffmpegDetective.php#L114-L128 |
infinity-next/sleuth | src/Detectives/ffmpegDetective.php | ffmpegDetective.ffprobeHasAudio | private function ffprobeHasAudio()
{
if (isset($this->metadata['streams']))
{
foreach ($this->metadata['streams'] as $streamIndex => $stream)
{
if (isset($stream['codec_type']) && $stream['codec_type'] === "audio")
{
return $streamIndex;
}
}
}
return false;
} | php | private function ffprobeHasAudio()
{
if (isset($this->metadata['streams']))
{
foreach ($this->metadata['streams'] as $streamIndex => $stream)
{
if (isset($stream['codec_type']) && $stream['codec_type'] === "audio")
{
return $streamIndex;
}
}
}
return false;
} | [
"private",
"function",
"ffprobeHasAudio",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"metadata",
"[",
"'streams'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"metadata",
"[",
"'streams'",
"]",
"as",
"$",
"streamIndex",
"=>",
"$",
"stream",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"stream",
"[",
"'codec_type'",
"]",
")",
"&&",
"$",
"stream",
"[",
"'codec_type'",
"]",
"===",
"\"audio\"",
")",
"{",
"return",
"$",
"streamIndex",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] | Check our metadata for an audio stream.
@return boolean|int Int if video stream index found (CAN BE 0), false if none | [
"Check",
"our",
"metadata",
"for",
"an",
"audio",
"stream",
"."
] | train | https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Detectives/ffmpegDetective.php#L135-L149 |
infinity-next/sleuth | src/Detectives/ffmpegDetective.php | ffmpegDetective.lead3GP | protected function lead3GP()
{
$lead = $this->ffprobeFormat("3gp");
if ($lead === true)
{
return $this->closeCase("3gp", "video/3gp", $this->metadata);
}
return null;
} | php | protected function lead3GP()
{
$lead = $this->ffprobeFormat("3gp");
if ($lead === true)
{
return $this->closeCase("3gp", "video/3gp", $this->metadata);
}
return null;
} | [
"protected",
"function",
"lead3GP",
"(",
")",
"{",
"$",
"lead",
"=",
"$",
"this",
"->",
"ffprobeFormat",
"(",
"\"3gp\"",
")",
";",
"if",
"(",
"$",
"lead",
"===",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"closeCase",
"(",
"\"3gp\"",
",",
"\"video/3gp\"",
",",
"$",
"this",
"->",
"metadata",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Checks if the file is a 3GP.
@return boolean|null | [
"Checks",
"if",
"the",
"file",
"is",
"a",
"3GP",
"."
] | train | https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Detectives/ffmpegDetective.php#L156-L166 |
infinity-next/sleuth | src/Detectives/ffmpegDetective.php | ffmpegDetective.leadAAC | protected function leadAAC()
{
$lead = $this->ffprobeFormat("aac");
if ($lead === true)
{
return $this->closeCase("aac", "audio/aac", $this->metadata);
}
return null;
} | php | protected function leadAAC()
{
$lead = $this->ffprobeFormat("aac");
if ($lead === true)
{
return $this->closeCase("aac", "audio/aac", $this->metadata);
}
return null;
} | [
"protected",
"function",
"leadAAC",
"(",
")",
"{",
"$",
"lead",
"=",
"$",
"this",
"->",
"ffprobeFormat",
"(",
"\"aac\"",
")",
";",
"if",
"(",
"$",
"lead",
"===",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"closeCase",
"(",
"\"aac\"",
",",
"\"audio/aac\"",
",",
"$",
"this",
"->",
"metadata",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Checks if the file is a AAC
@return boolean|null | [
"Checks",
"if",
"the",
"file",
"is",
"a",
"AAC"
] | train | https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Detectives/ffmpegDetective.php#L173-L183 |
infinity-next/sleuth | src/Detectives/ffmpegDetective.php | ffmpegDetective.leadFLV | protected function leadFLV()
{
$lead = $this->ffprobeFormat("flv");
if ($lead === true)
{
return $this->closeCase("flv", "video/x-flv", $this->metadata);
}
return null;
} | php | protected function leadFLV()
{
$lead = $this->ffprobeFormat("flv");
if ($lead === true)
{
return $this->closeCase("flv", "video/x-flv", $this->metadata);
}
return null;
} | [
"protected",
"function",
"leadFLV",
"(",
")",
"{",
"$",
"lead",
"=",
"$",
"this",
"->",
"ffprobeFormat",
"(",
"\"flv\"",
")",
";",
"if",
"(",
"$",
"lead",
"===",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"closeCase",
"(",
"\"flv\"",
",",
"\"video/x-flv\"",
",",
"$",
"this",
"->",
"metadata",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Checks if the file is a FLV.
@return boolean|null | [
"Checks",
"if",
"the",
"file",
"is",
"a",
"FLV",
"."
] | train | https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Detectives/ffmpegDetective.php#L190-L200 |
infinity-next/sleuth | src/Detectives/ffmpegDetective.php | ffmpegDetective.leadMP3 | protected function leadMP3()
{
$lead = $this->ffprobeFormat("mp1", "mp2", "mp3", "mpg", "mpeg");
if ($lead === true)
{
return $this->closeCase("mp3", "audio/mpeg", $this->metadata);
}
return null;
} | php | protected function leadMP3()
{
$lead = $this->ffprobeFormat("mp1", "mp2", "mp3", "mpg", "mpeg");
if ($lead === true)
{
return $this->closeCase("mp3", "audio/mpeg", $this->metadata);
}
return null;
} | [
"protected",
"function",
"leadMP3",
"(",
")",
"{",
"$",
"lead",
"=",
"$",
"this",
"->",
"ffprobeFormat",
"(",
"\"mp1\"",
",",
"\"mp2\"",
",",
"\"mp3\"",
",",
"\"mpg\"",
",",
"\"mpeg\"",
")",
";",
"if",
"(",
"$",
"lead",
"===",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"closeCase",
"(",
"\"mp3\"",
",",
"\"audio/mpeg\"",
",",
"$",
"this",
"->",
"metadata",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Checks if the file is a MP3
@return boolean|null | [
"Checks",
"if",
"the",
"file",
"is",
"a",
"MP3"
] | train | https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Detectives/ffmpegDetective.php#L207-L217 |
infinity-next/sleuth | src/Detectives/ffmpegDetective.php | ffmpegDetective.leadMP4 | protected function leadMP4()
{
$lead = $this->ffprobeFormat("mp4", "m4a");
if ($lead === true)
{
if ($this->ffprobeHasVideo() !== false)
{
return $this->closeCase("mp4", "video/mp4", $this->metadata);
}
else if ($this->ffprobeHasAudio() !== false)
{
return $this->closeCase("mp4", "audio/mp4", $this->metadata);
}
else
{
return false;
}
}
return null;
} | php | protected function leadMP4()
{
$lead = $this->ffprobeFormat("mp4", "m4a");
if ($lead === true)
{
if ($this->ffprobeHasVideo() !== false)
{
return $this->closeCase("mp4", "video/mp4", $this->metadata);
}
else if ($this->ffprobeHasAudio() !== false)
{
return $this->closeCase("mp4", "audio/mp4", $this->metadata);
}
else
{
return false;
}
}
return null;
} | [
"protected",
"function",
"leadMP4",
"(",
")",
"{",
"$",
"lead",
"=",
"$",
"this",
"->",
"ffprobeFormat",
"(",
"\"mp4\"",
",",
"\"m4a\"",
")",
";",
"if",
"(",
"$",
"lead",
"===",
"true",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"ffprobeHasVideo",
"(",
")",
"!==",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"closeCase",
"(",
"\"mp4\"",
",",
"\"video/mp4\"",
",",
"$",
"this",
"->",
"metadata",
")",
";",
"}",
"else",
"if",
"(",
"$",
"this",
"->",
"ffprobeHasAudio",
"(",
")",
"!==",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"closeCase",
"(",
"\"mp4\"",
",",
"\"audio/mp4\"",
",",
"$",
"this",
"->",
"metadata",
")",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Checks if the file is a MP4.
@return boolean|null | [
"Checks",
"if",
"the",
"file",
"is",
"a",
"MP4",
"."
] | train | https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Detectives/ffmpegDetective.php#L224-L245 |
infinity-next/sleuth | src/Detectives/ffmpegDetective.php | ffmpegDetective.leadMKA | protected function leadMKA()
{
$lead = $this->ffprobeFormat("matroska", "webm");
if ($lead === true)
{
if ($this->ffprobeHasAudio() !== false)
{
return $this->closeCase("mka", "audio/x-matroska", $this->metadata);
}
else
{
return false;
}
}
return null;
} | php | protected function leadMKA()
{
$lead = $this->ffprobeFormat("matroska", "webm");
if ($lead === true)
{
if ($this->ffprobeHasAudio() !== false)
{
return $this->closeCase("mka", "audio/x-matroska", $this->metadata);
}
else
{
return false;
}
}
return null;
} | [
"protected",
"function",
"leadMKA",
"(",
")",
"{",
"$",
"lead",
"=",
"$",
"this",
"->",
"ffprobeFormat",
"(",
"\"matroska\"",
",",
"\"webm\"",
")",
";",
"if",
"(",
"$",
"lead",
"===",
"true",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"ffprobeHasAudio",
"(",
")",
"!==",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"closeCase",
"(",
"\"mka\"",
",",
"\"audio/x-matroska\"",
",",
"$",
"this",
"->",
"metadata",
")",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Checks if the file is a MKA.
@return boolean|null | [
"Checks",
"if",
"the",
"file",
"is",
"a",
"MKA",
"."
] | train | https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Detectives/ffmpegDetective.php#L252-L269 |
infinity-next/sleuth | src/Detectives/ffmpegDetective.php | ffmpegDetective.leadMKV | protected function leadMKV()
{
$lead = $this->ffprobeFormat("matroska", "webm");
if ($lead === true)
{
if ($this->ffprobeHasVideo() !== false)
{
return $this->closeCase("mkv", "video/x-matroska", $this->metadata);
}
else
{
return false;
}
}
return null;
} | php | protected function leadMKV()
{
$lead = $this->ffprobeFormat("matroska", "webm");
if ($lead === true)
{
if ($this->ffprobeHasVideo() !== false)
{
return $this->closeCase("mkv", "video/x-matroska", $this->metadata);
}
else
{
return false;
}
}
return null;
} | [
"protected",
"function",
"leadMKV",
"(",
")",
"{",
"$",
"lead",
"=",
"$",
"this",
"->",
"ffprobeFormat",
"(",
"\"matroska\"",
",",
"\"webm\"",
")",
";",
"if",
"(",
"$",
"lead",
"===",
"true",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"ffprobeHasVideo",
"(",
")",
"!==",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"closeCase",
"(",
"\"mkv\"",
",",
"\"video/x-matroska\"",
",",
"$",
"this",
"->",
"metadata",
")",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Checks if the file is a MKV.
@return boolean|null | [
"Checks",
"if",
"the",
"file",
"is",
"a",
"MKV",
"."
] | train | https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Detectives/ffmpegDetective.php#L276-L293 |
infinity-next/sleuth | src/Detectives/ffmpegDetective.php | ffmpegDetective.leadWAV | protected function leadWAV()
{
$lead = $this->ffprobeFormat("wav");
if ($lead === true)
{
return $this->closeCase("wav", "audio/wave", $this->metadata);
}
return null;
} | php | protected function leadWAV()
{
$lead = $this->ffprobeFormat("wav");
if ($lead === true)
{
return $this->closeCase("wav", "audio/wave", $this->metadata);
}
return null;
} | [
"protected",
"function",
"leadWAV",
"(",
")",
"{",
"$",
"lead",
"=",
"$",
"this",
"->",
"ffprobeFormat",
"(",
"\"wav\"",
")",
";",
"if",
"(",
"$",
"lead",
"===",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"closeCase",
"(",
"\"wav\"",
",",
"\"audio/wave\"",
",",
"$",
"this",
"->",
"metadata",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Checks if the file is a WAV
@return boolean|null | [
"Checks",
"if",
"the",
"file",
"is",
"a",
"WAV"
] | train | https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Detectives/ffmpegDetective.php#L328-L338 |
infinity-next/sleuth | src/Detectives/ffmpegDetective.php | ffmpegDetective.on | public static function on()
{
static::fetchBinaries();
return (empty(static::$ffmpeg) ? false : true) && (empty(static::$ffprobe) ? false : true);
} | php | public static function on()
{
static::fetchBinaries();
return (empty(static::$ffmpeg) ? false : true) && (empty(static::$ffprobe) ? false : true);
} | [
"public",
"static",
"function",
"on",
"(",
")",
"{",
"static",
"::",
"fetchBinaries",
"(",
")",
";",
"return",
"(",
"empty",
"(",
"static",
"::",
"$",
"ffmpeg",
")",
"?",
"false",
":",
"true",
")",
"&&",
"(",
"empty",
"(",
"static",
"::",
"$",
"ffprobe",
")",
"?",
"false",
":",
"true",
")",
";",
"}"
] | Can the system run this Detective?
@return boolean True if we can run, False if not. | [
"Can",
"the",
"system",
"run",
"this",
"Detective?"
] | train | https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Detectives/ffmpegDetective.php#L406-L410 |
Danack/GithubArtaxService | lib/GithubService/Operation/listSelfStarredGistsPaginate.php | listSelfStarredGistsPaginate.createRequest | public function createRequest() {
$request = new \Amp\Artax\Request();
$url = null;
$request->setMethod('GET');
$queryParameters = [];
if (array_key_exists('Accept', $this->parameters) == true) {
$value = $this->getFilteredParameter('Accept');
$request->setHeader('Accept', $value);
}
$value = $this->getFilteredParameter('Authorization');
if ($value != null) {
$request->setHeader('Authorization', $value);
}
$value = $this->getFilteredParameter('userAgent');
$request->setHeader('User-Agent', $value);
if (array_key_exists('perPage', $this->parameters) == true) {
$value = $this->getFilteredParameter('perPage');
$queryParameters['per_page'] = $value;
}
if (array_key_exists('otp', $this->parameters) == true) {
$value = $this->getFilteredParameter('otp');
$request->setHeader('X-GitHub-OTP', $value);
}
$value = $this->getFilteredParameter('pageURL');
$url = $value;
//Parameters are parsed and set, lets prepare the request
if ($url == null) {
$url = "https://api.github.com";
}
if (count($queryParameters)) {
$url = $url.'?'.http_build_query($queryParameters, '', '&', PHP_QUERY_RFC3986);
}
$request->setUri($url);
return $request;
} | php | public function createRequest() {
$request = new \Amp\Artax\Request();
$url = null;
$request->setMethod('GET');
$queryParameters = [];
if (array_key_exists('Accept', $this->parameters) == true) {
$value = $this->getFilteredParameter('Accept');
$request->setHeader('Accept', $value);
}
$value = $this->getFilteredParameter('Authorization');
if ($value != null) {
$request->setHeader('Authorization', $value);
}
$value = $this->getFilteredParameter('userAgent');
$request->setHeader('User-Agent', $value);
if (array_key_exists('perPage', $this->parameters) == true) {
$value = $this->getFilteredParameter('perPage');
$queryParameters['per_page'] = $value;
}
if (array_key_exists('otp', $this->parameters) == true) {
$value = $this->getFilteredParameter('otp');
$request->setHeader('X-GitHub-OTP', $value);
}
$value = $this->getFilteredParameter('pageURL');
$url = $value;
//Parameters are parsed and set, lets prepare the request
if ($url == null) {
$url = "https://api.github.com";
}
if (count($queryParameters)) {
$url = $url.'?'.http_build_query($queryParameters, '', '&', PHP_QUERY_RFC3986);
}
$request->setUri($url);
return $request;
} | [
"public",
"function",
"createRequest",
"(",
")",
"{",
"$",
"request",
"=",
"new",
"\\",
"Amp",
"\\",
"Artax",
"\\",
"Request",
"(",
")",
";",
"$",
"url",
"=",
"null",
";",
"$",
"request",
"->",
"setMethod",
"(",
"'GET'",
")",
";",
"$",
"queryParameters",
"=",
"[",
"]",
";",
"if",
"(",
"array_key_exists",
"(",
"'Accept'",
",",
"$",
"this",
"->",
"parameters",
")",
"==",
"true",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getFilteredParameter",
"(",
"'Accept'",
")",
";",
"$",
"request",
"->",
"setHeader",
"(",
"'Accept'",
",",
"$",
"value",
")",
";",
"}",
"$",
"value",
"=",
"$",
"this",
"->",
"getFilteredParameter",
"(",
"'Authorization'",
")",
";",
"if",
"(",
"$",
"value",
"!=",
"null",
")",
"{",
"$",
"request",
"->",
"setHeader",
"(",
"'Authorization'",
",",
"$",
"value",
")",
";",
"}",
"$",
"value",
"=",
"$",
"this",
"->",
"getFilteredParameter",
"(",
"'userAgent'",
")",
";",
"$",
"request",
"->",
"setHeader",
"(",
"'User-Agent'",
",",
"$",
"value",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"'perPage'",
",",
"$",
"this",
"->",
"parameters",
")",
"==",
"true",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getFilteredParameter",
"(",
"'perPage'",
")",
";",
"$",
"queryParameters",
"[",
"'per_page'",
"]",
"=",
"$",
"value",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"'otp'",
",",
"$",
"this",
"->",
"parameters",
")",
"==",
"true",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getFilteredParameter",
"(",
"'otp'",
")",
";",
"$",
"request",
"->",
"setHeader",
"(",
"'X-GitHub-OTP'",
",",
"$",
"value",
")",
";",
"}",
"$",
"value",
"=",
"$",
"this",
"->",
"getFilteredParameter",
"(",
"'pageURL'",
")",
";",
"$",
"url",
"=",
"$",
"value",
";",
"//Parameters are parsed and set, lets prepare the request",
"if",
"(",
"$",
"url",
"==",
"null",
")",
"{",
"$",
"url",
"=",
"\"https://api.github.com\"",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"queryParameters",
")",
")",
"{",
"$",
"url",
"=",
"$",
"url",
".",
"'?'",
".",
"http_build_query",
"(",
"$",
"queryParameters",
",",
"''",
",",
"'&'",
",",
"PHP_QUERY_RFC3986",
")",
";",
"}",
"$",
"request",
"->",
"setUri",
"(",
"$",
"url",
")",
";",
"return",
"$",
"request",
";",
"}"
] | Create an Amp\Artax\Request object from the operation.
@return \Amp\Artax\Request | [
"Create",
"an",
"Amp",
"\\",
"Artax",
"\\",
"Request",
"object",
"from",
"the",
"operation",
"."
] | train | https://github.com/Danack/GithubArtaxService/blob/9f62b5be4f413207d4012e7fa084d0ae505680eb/lib/GithubService/Operation/listSelfStarredGistsPaginate.php#L202-L240 |
tkotosz/behat-browser-initialiser | src/Bex/Behat/BrowserInitialiserExtension/ServiceContainer/BrowserInitialiserExtension.php | BrowserInitialiserExtension.configure | public function configure(ArrayNodeDefinition $builder)
{
$validator = new ConfigValidator();
$builder
->children()
->booleanNode('close_browser_after_scenario')
->defaultFalse()
->end()
->scalarNode('browser_window_size')
->defaultValue('max')
->validate()
->always($validator->getBrowserSizeValueValidator())
->end()
->end()
->end();
} | php | public function configure(ArrayNodeDefinition $builder)
{
$validator = new ConfigValidator();
$builder
->children()
->booleanNode('close_browser_after_scenario')
->defaultFalse()
->end()
->scalarNode('browser_window_size')
->defaultValue('max')
->validate()
->always($validator->getBrowserSizeValueValidator())
->end()
->end()
->end();
} | [
"public",
"function",
"configure",
"(",
"ArrayNodeDefinition",
"$",
"builder",
")",
"{",
"$",
"validator",
"=",
"new",
"ConfigValidator",
"(",
")",
";",
"$",
"builder",
"->",
"children",
"(",
")",
"->",
"booleanNode",
"(",
"'close_browser_after_scenario'",
")",
"->",
"defaultFalse",
"(",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'browser_window_size'",
")",
"->",
"defaultValue",
"(",
"'max'",
")",
"->",
"validate",
"(",
")",
"->",
"always",
"(",
"$",
"validator",
"->",
"getBrowserSizeValueValidator",
"(",
")",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/tkotosz/behat-browser-initialiser/blob/b20636f3ec2c83b027a21deb48c4388c940af6d3/src/Bex/Behat/BrowserInitialiserExtension/ServiceContainer/BrowserInitialiserExtension.php#L45-L60 |
tkotosz/behat-browser-initialiser | src/Bex/Behat/BrowserInitialiserExtension/ServiceContainer/BrowserInitialiserExtension.php | BrowserInitialiserExtension.load | public function load(ContainerBuilder $container, array $config)
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/config'));
$loader->load('services.xml');
$extensionConfig = new Config($config);
$container->set('bex.browser_initialiser_extension.config', $extensionConfig);
} | php | public function load(ContainerBuilder $container, array $config)
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/config'));
$loader->load('services.xml');
$extensionConfig = new Config($config);
$container->set('bex.browser_initialiser_extension.config', $extensionConfig);
} | [
"public",
"function",
"load",
"(",
"ContainerBuilder",
"$",
"container",
",",
"array",
"$",
"config",
")",
"{",
"$",
"loader",
"=",
"new",
"XmlFileLoader",
"(",
"$",
"container",
",",
"new",
"FileLocator",
"(",
"__DIR__",
".",
"'/config'",
")",
")",
";",
"$",
"loader",
"->",
"load",
"(",
"'services.xml'",
")",
";",
"$",
"extensionConfig",
"=",
"new",
"Config",
"(",
"$",
"config",
")",
";",
"$",
"container",
"->",
"set",
"(",
"'bex.browser_initialiser_extension.config'",
",",
"$",
"extensionConfig",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/tkotosz/behat-browser-initialiser/blob/b20636f3ec2c83b027a21deb48c4388c940af6d3/src/Bex/Behat/BrowserInitialiserExtension/ServiceContainer/BrowserInitialiserExtension.php#L65-L72 |
eXistenZNL/PermCheck | src/Message/Bag.php | Bag.addMessage | public function addMessage($message, $type)
{
if (!is_string($message)) {
throw new \InvalidArgumentException('Message must be a string');
}
if (!$message) {
throw new \InvalidArgumentException('Message can\'t be empty');
}
if (!is_string($type)) {
throw new \InvalidArgumentException('Type must be a string');
}
if (!$type) {
throw new \InvalidArgumentException('Type can\'t be empty');
}
$this->messages[$type][] = $message;
return $this;
} | php | public function addMessage($message, $type)
{
if (!is_string($message)) {
throw new \InvalidArgumentException('Message must be a string');
}
if (!$message) {
throw new \InvalidArgumentException('Message can\'t be empty');
}
if (!is_string($type)) {
throw new \InvalidArgumentException('Type must be a string');
}
if (!$type) {
throw new \InvalidArgumentException('Type can\'t be empty');
}
$this->messages[$type][] = $message;
return $this;
} | [
"public",
"function",
"addMessage",
"(",
"$",
"message",
",",
"$",
"type",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"message",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Message must be a string'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"message",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Message can\\'t be empty'",
")",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"type",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Type must be a string'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"type",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Type can\\'t be empty'",
")",
";",
"}",
"$",
"this",
"->",
"messages",
"[",
"$",
"type",
"]",
"[",
"]",
"=",
"$",
"message",
";",
"return",
"$",
"this",
";",
"}"
] | Add a message to this message bag.
@param string $message The message to add.
@param string $type The type of message to add.
@throws \InvalidArgumentException When the provided data is incorrect.
@return Bag | [
"Add",
"a",
"message",
"to",
"this",
"message",
"bag",
"."
] | train | https://github.com/eXistenZNL/PermCheck/blob/f22f2936350f6b440222fb6ea37dfc382fc4550e/src/Message/Bag.php#L21-L38 |
php-lug/lug | src/Bundle/ResourceBundle/Form/Extension/BooleanExtension.php | BooleanExtension.buildForm | public function buildForm(FormBuilderInterface $builder, array $options)
{
if ($options['api']) {
$builder
->resetViewTransformers()
->addViewTransformer($this->booleanTransformer);
}
} | php | public function buildForm(FormBuilderInterface $builder, array $options)
{
if ($options['api']) {
$builder
->resetViewTransformers()
->addViewTransformer($this->booleanTransformer);
}
} | [
"public",
"function",
"buildForm",
"(",
"FormBuilderInterface",
"$",
"builder",
",",
"array",
"$",
"options",
")",
"{",
"if",
"(",
"$",
"options",
"[",
"'api'",
"]",
")",
"{",
"$",
"builder",
"->",
"resetViewTransformers",
"(",
")",
"->",
"addViewTransformer",
"(",
"$",
"this",
"->",
"booleanTransformer",
")",
";",
"}",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Form/Extension/BooleanExtension.php#L49-L56 |
php-lug/lug | src/Bundle/ResourceBundle/Form/EventSubscriber/CollectionSubscriber.php | CollectionSubscriber.resolveResource | private function resolveResource($class)
{
if (array_key_exists($class, $this->cache)) {
return $this->cache[$class];
}
$found = null;
foreach ($this->resourceRegistry as $resource) {
if ($resource->getModel() === $class) {
$found = $resource;
break;
}
}
return $this->cache[$class] = $found;
} | php | private function resolveResource($class)
{
if (array_key_exists($class, $this->cache)) {
return $this->cache[$class];
}
$found = null;
foreach ($this->resourceRegistry as $resource) {
if ($resource->getModel() === $class) {
$found = $resource;
break;
}
}
return $this->cache[$class] = $found;
} | [
"private",
"function",
"resolveResource",
"(",
"$",
"class",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"class",
",",
"$",
"this",
"->",
"cache",
")",
")",
"{",
"return",
"$",
"this",
"->",
"cache",
"[",
"$",
"class",
"]",
";",
"}",
"$",
"found",
"=",
"null",
";",
"foreach",
"(",
"$",
"this",
"->",
"resourceRegistry",
"as",
"$",
"resource",
")",
"{",
"if",
"(",
"$",
"resource",
"->",
"getModel",
"(",
")",
"===",
"$",
"class",
")",
"{",
"$",
"found",
"=",
"$",
"resource",
";",
"break",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"cache",
"[",
"$",
"class",
"]",
"=",
"$",
"found",
";",
"}"
] | @param string $class
@return ResourceInterface|null | [
"@param",
"string",
"$class"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Form/EventSubscriber/CollectionSubscriber.php#L113-L130 |
inhere/php-librarys | src/Helpers/Cli.php | Cli.write | public static function write($message, $nl = true, $quit = false)
{
if (\is_array($message)) {
$message = implode($nl ? PHP_EOL : '', $message);
}
self::stdout(self::renderColor($message), $nl, $quit);
} | php | public static function write($message, $nl = true, $quit = false)
{
if (\is_array($message)) {
$message = implode($nl ? PHP_EOL : '', $message);
}
self::stdout(self::renderColor($message), $nl, $quit);
} | [
"public",
"static",
"function",
"write",
"(",
"$",
"message",
",",
"$",
"nl",
"=",
"true",
",",
"$",
"quit",
"=",
"false",
")",
"{",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"message",
")",
")",
"{",
"$",
"message",
"=",
"implode",
"(",
"$",
"nl",
"?",
"PHP_EOL",
":",
"''",
",",
"$",
"message",
")",
";",
"}",
"self",
"::",
"stdout",
"(",
"self",
"::",
"renderColor",
"(",
"$",
"message",
")",
",",
"$",
"nl",
",",
"$",
"quit",
")",
";",
"}"
] | write message to console
@param $message
@param bool $nl
@param bool $quit | [
"write",
"message",
"to",
"console"
] | train | https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/Cli.php#L206-L213 |
inhere/php-librarys | src/Helpers/Cli.php | Cli.stdout | public static function stdout($message, $nl = true, $quit = false)
{
fwrite(\STDOUT, $message . ($nl ? PHP_EOL : ''));
fflush(\STDOUT);
if (($isTrue = true === $quit) || \is_int($quit)) {
$code = $isTrue ? 0 : $quit;
exit($code);
}
} | php | public static function stdout($message, $nl = true, $quit = false)
{
fwrite(\STDOUT, $message . ($nl ? PHP_EOL : ''));
fflush(\STDOUT);
if (($isTrue = true === $quit) || \is_int($quit)) {
$code = $isTrue ? 0 : $quit;
exit($code);
}
} | [
"public",
"static",
"function",
"stdout",
"(",
"$",
"message",
",",
"$",
"nl",
"=",
"true",
",",
"$",
"quit",
"=",
"false",
")",
"{",
"fwrite",
"(",
"\\",
"STDOUT",
",",
"$",
"message",
".",
"(",
"$",
"nl",
"?",
"PHP_EOL",
":",
"''",
")",
")",
";",
"fflush",
"(",
"\\",
"STDOUT",
")",
";",
"if",
"(",
"(",
"$",
"isTrue",
"=",
"true",
"===",
"$",
"quit",
")",
"||",
"\\",
"is_int",
"(",
"$",
"quit",
")",
")",
"{",
"$",
"code",
"=",
"$",
"isTrue",
"?",
"0",
":",
"$",
"quit",
";",
"exit",
"(",
"$",
"code",
")",
";",
"}",
"}"
] | Logs data to stdout
@param string $message
@param bool $nl
@param bool|int $quit | [
"Logs",
"data",
"to",
"stdout"
] | train | https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/Cli.php#L221-L230 |
inhere/php-librarys | src/Helpers/Cli.php | Cli.stderr | public static function stderr($message, $nl = true, $quit = -200)
{
fwrite(\STDERR, self::color('[ERROR] ', 'red') . $message . ($nl ? PHP_EOL : ''));
fflush(\STDOUT);
if (($isTrue = true === $quit) || \is_int($quit)) {
$code = $isTrue ? 0 : $quit;
exit($code);
}
} | php | public static function stderr($message, $nl = true, $quit = -200)
{
fwrite(\STDERR, self::color('[ERROR] ', 'red') . $message . ($nl ? PHP_EOL : ''));
fflush(\STDOUT);
if (($isTrue = true === $quit) || \is_int($quit)) {
$code = $isTrue ? 0 : $quit;
exit($code);
}
} | [
"public",
"static",
"function",
"stderr",
"(",
"$",
"message",
",",
"$",
"nl",
"=",
"true",
",",
"$",
"quit",
"=",
"-",
"200",
")",
"{",
"fwrite",
"(",
"\\",
"STDERR",
",",
"self",
"::",
"color",
"(",
"'[ERROR] '",
",",
"'red'",
")",
".",
"$",
"message",
".",
"(",
"$",
"nl",
"?",
"PHP_EOL",
":",
"''",
")",
")",
";",
"fflush",
"(",
"\\",
"STDOUT",
")",
";",
"if",
"(",
"(",
"$",
"isTrue",
"=",
"true",
"===",
"$",
"quit",
")",
"||",
"\\",
"is_int",
"(",
"$",
"quit",
")",
")",
"{",
"$",
"code",
"=",
"$",
"isTrue",
"?",
"0",
":",
"$",
"quit",
";",
"exit",
"(",
"$",
"code",
")",
";",
"}",
"}"
] | Logs data to stderr
@param string $message
@param bool $nl
@param bool|int $quit | [
"Logs",
"data",
"to",
"stderr"
] | train | https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/Cli.php#L238-L247 |
inhere/php-librarys | src/Helpers/Cli.php | Cli.argOptParse | public static function argOptParse(array $noValues = [], $mergeOpts = false)
{
$params = $GLOBALS['argv'];
reset($params);
$args = $sOpts = $lOpts = [];
$fullScript = implode(' ', $params);
$script = array_shift($params);
// each() will deprecated at 7.2 so,there use current and next instead it.
// while (list(,$p) = each($params)) {
while (false !== ($p = current($params))) {
next($params);
// is options
if ($p{0} === '-') {
$isLong = false;
$opt = substr($p, 1);
$value = true;
// long-opt: (--<opt>)
if ($opt{0} === '-') {
$isLong = true;
$opt = substr($opt, 1);
// long-opt: value specified inline (--<opt>=<value>)
if (strpos($opt, '=') !== false) {
list($opt, $value) = explode('=', $opt, 2);
}
// short-opt: value specified inline (-<opt>=<value>)
} elseif (\strlen($opt) > 2 && $opt{1} === '=') {
list($opt, $value) = explode('=', $opt, 2);
}
// check if next parameter is a descriptor or a value
$nxp = current($params);
if ($value === true && $nxp !== false && $nxp{0} !== '-' && !\in_array($opt, $noValues, true)) {
// list(,$value) = each($params);
$value = current($params);
next($params);
// short-opt: bool opts. like -e -abc
} elseif (!$isLong && $value === true) {
foreach (str_split($opt) as $char) {
$sOpts[$char] = true;
}
continue;
}
if ($isLong) {
$lOpts[$opt] = $value;
} else {
$sOpts[$opt] = $value;
}
// arguments: param doesn't belong to any option, define it is args
} else {
// value specified inline (<arg>=<value>)
if (strpos($p, '=') !== false) {
list($name, $value) = explode('=', $p, 2);
$args[$name] = $value;
} else {
$args[] = $p;
}
}
}
unset($params);
if ($mergeOpts) {
return [$fullScript, $script, $args, array_merge($sOpts, $lOpts)];
}
return [$fullScript, $script, $args, $sOpts, $lOpts];
} | php | public static function argOptParse(array $noValues = [], $mergeOpts = false)
{
$params = $GLOBALS['argv'];
reset($params);
$args = $sOpts = $lOpts = [];
$fullScript = implode(' ', $params);
$script = array_shift($params);
// each() will deprecated at 7.2 so,there use current and next instead it.
// while (list(,$p) = each($params)) {
while (false !== ($p = current($params))) {
next($params);
// is options
if ($p{0} === '-') {
$isLong = false;
$opt = substr($p, 1);
$value = true;
// long-opt: (--<opt>)
if ($opt{0} === '-') {
$isLong = true;
$opt = substr($opt, 1);
// long-opt: value specified inline (--<opt>=<value>)
if (strpos($opt, '=') !== false) {
list($opt, $value) = explode('=', $opt, 2);
}
// short-opt: value specified inline (-<opt>=<value>)
} elseif (\strlen($opt) > 2 && $opt{1} === '=') {
list($opt, $value) = explode('=', $opt, 2);
}
// check if next parameter is a descriptor or a value
$nxp = current($params);
if ($value === true && $nxp !== false && $nxp{0} !== '-' && !\in_array($opt, $noValues, true)) {
// list(,$value) = each($params);
$value = current($params);
next($params);
// short-opt: bool opts. like -e -abc
} elseif (!$isLong && $value === true) {
foreach (str_split($opt) as $char) {
$sOpts[$char] = true;
}
continue;
}
if ($isLong) {
$lOpts[$opt] = $value;
} else {
$sOpts[$opt] = $value;
}
// arguments: param doesn't belong to any option, define it is args
} else {
// value specified inline (<arg>=<value>)
if (strpos($p, '=') !== false) {
list($name, $value) = explode('=', $p, 2);
$args[$name] = $value;
} else {
$args[] = $p;
}
}
}
unset($params);
if ($mergeOpts) {
return [$fullScript, $script, $args, array_merge($sOpts, $lOpts)];
}
return [$fullScript, $script, $args, $sOpts, $lOpts];
} | [
"public",
"static",
"function",
"argOptParse",
"(",
"array",
"$",
"noValues",
"=",
"[",
"]",
",",
"$",
"mergeOpts",
"=",
"false",
")",
"{",
"$",
"params",
"=",
"$",
"GLOBALS",
"[",
"'argv'",
"]",
";",
"reset",
"(",
"$",
"params",
")",
";",
"$",
"args",
"=",
"$",
"sOpts",
"=",
"$",
"lOpts",
"=",
"[",
"]",
";",
"$",
"fullScript",
"=",
"implode",
"(",
"' '",
",",
"$",
"params",
")",
";",
"$",
"script",
"=",
"array_shift",
"(",
"$",
"params",
")",
";",
"// each() will deprecated at 7.2 so,there use current and next instead it.",
"// while (list(,$p) = each($params)) {",
"while",
"(",
"false",
"!==",
"(",
"$",
"p",
"=",
"current",
"(",
"$",
"params",
")",
")",
")",
"{",
"next",
"(",
"$",
"params",
")",
";",
"// is options",
"if",
"(",
"$",
"p",
"{",
"0",
"}",
"===",
"'-'",
")",
"{",
"$",
"isLong",
"=",
"false",
";",
"$",
"opt",
"=",
"substr",
"(",
"$",
"p",
",",
"1",
")",
";",
"$",
"value",
"=",
"true",
";",
"// long-opt: (--<opt>)",
"if",
"(",
"$",
"opt",
"{",
"0",
"}",
"===",
"'-'",
")",
"{",
"$",
"isLong",
"=",
"true",
";",
"$",
"opt",
"=",
"substr",
"(",
"$",
"opt",
",",
"1",
")",
";",
"// long-opt: value specified inline (--<opt>=<value>)",
"if",
"(",
"strpos",
"(",
"$",
"opt",
",",
"'='",
")",
"!==",
"false",
")",
"{",
"list",
"(",
"$",
"opt",
",",
"$",
"value",
")",
"=",
"explode",
"(",
"'='",
",",
"$",
"opt",
",",
"2",
")",
";",
"}",
"// short-opt: value specified inline (-<opt>=<value>)",
"}",
"elseif",
"(",
"\\",
"strlen",
"(",
"$",
"opt",
")",
">",
"2",
"&&",
"$",
"opt",
"{",
"1",
"}",
"===",
"'='",
")",
"{",
"list",
"(",
"$",
"opt",
",",
"$",
"value",
")",
"=",
"explode",
"(",
"'='",
",",
"$",
"opt",
",",
"2",
")",
";",
"}",
"// check if next parameter is a descriptor or a value",
"$",
"nxp",
"=",
"current",
"(",
"$",
"params",
")",
";",
"if",
"(",
"$",
"value",
"===",
"true",
"&&",
"$",
"nxp",
"!==",
"false",
"&&",
"$",
"nxp",
"{",
"0",
"}",
"!==",
"'-'",
"&&",
"!",
"\\",
"in_array",
"(",
"$",
"opt",
",",
"$",
"noValues",
",",
"true",
")",
")",
"{",
"// list(,$value) = each($params);",
"$",
"value",
"=",
"current",
"(",
"$",
"params",
")",
";",
"next",
"(",
"$",
"params",
")",
";",
"// short-opt: bool opts. like -e -abc",
"}",
"elseif",
"(",
"!",
"$",
"isLong",
"&&",
"$",
"value",
"===",
"true",
")",
"{",
"foreach",
"(",
"str_split",
"(",
"$",
"opt",
")",
"as",
"$",
"char",
")",
"{",
"$",
"sOpts",
"[",
"$",
"char",
"]",
"=",
"true",
";",
"}",
"continue",
";",
"}",
"if",
"(",
"$",
"isLong",
")",
"{",
"$",
"lOpts",
"[",
"$",
"opt",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"sOpts",
"[",
"$",
"opt",
"]",
"=",
"$",
"value",
";",
"}",
"// arguments: param doesn't belong to any option, define it is args",
"}",
"else",
"{",
"// value specified inline (<arg>=<value>)",
"if",
"(",
"strpos",
"(",
"$",
"p",
",",
"'='",
")",
"!==",
"false",
")",
"{",
"list",
"(",
"$",
"name",
",",
"$",
"value",
")",
"=",
"explode",
"(",
"'='",
",",
"$",
"p",
",",
"2",
")",
";",
"$",
"args",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"args",
"[",
"]",
"=",
"$",
"p",
";",
"}",
"}",
"}",
"unset",
"(",
"$",
"params",
")",
";",
"if",
"(",
"$",
"mergeOpts",
")",
"{",
"return",
"[",
"$",
"fullScript",
",",
"$",
"script",
",",
"$",
"args",
",",
"array_merge",
"(",
"$",
"sOpts",
",",
"$",
"lOpts",
")",
"]",
";",
"}",
"return",
"[",
"$",
"fullScript",
",",
"$",
"script",
",",
"$",
"args",
",",
"$",
"sOpts",
",",
"$",
"lOpts",
"]",
";",
"}"
] | Parses $GLOBALS['argv'] for parameters and assigns them to an array.
Supports:
-e
-e <value>
--long-param
--long-param=<value>
--long-param <value>
<value>
@link https://github.com/inhere/php-console/blob/master/src/io/Input.php
@param array $noValues List of parameters without values
@param bool $mergeOpts
@return array | [
"Parses",
"$GLOBALS",
"[",
"argv",
"]",
"for",
"parameters",
"and",
"assigns",
"them",
"to",
"an",
"array",
".",
"Supports",
":",
"-",
"e",
"-",
"e",
"<value",
">",
"--",
"long",
"-",
"param",
"--",
"long",
"-",
"param",
"=",
"<value",
">",
"--",
"long",
"-",
"param",
"<value",
">",
"<value",
">"
] | train | https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/Cli.php#L274-L351 |
arndtteunissen/column-layout | Classes/ViewHelpers/RowWrapViewHelper.php | RowWrapViewHelper.renderStatic | public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
$enabled = self::isEnabled($arguments['colPos']);
if ($enabled) {
return self::wrapContent($renderChildrenClosure);
} else {
return $renderChildrenClosure();
}
} | php | public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
$enabled = self::isEnabled($arguments['colPos']);
if ($enabled) {
return self::wrapContent($renderChildrenClosure);
} else {
return $renderChildrenClosure();
}
} | [
"public",
"static",
"function",
"renderStatic",
"(",
"array",
"$",
"arguments",
",",
"\\",
"Closure",
"$",
"renderChildrenClosure",
",",
"RenderingContextInterface",
"$",
"renderingContext",
")",
"{",
"$",
"enabled",
"=",
"self",
"::",
"isEnabled",
"(",
"$",
"arguments",
"[",
"'colPos'",
"]",
")",
";",
"if",
"(",
"$",
"enabled",
")",
"{",
"return",
"self",
"::",
"wrapContent",
"(",
"$",
"renderChildrenClosure",
")",
";",
"}",
"else",
"{",
"return",
"$",
"renderChildrenClosure",
"(",
")",
";",
"}",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/arndtteunissen/column-layout/blob/ad737068eef3b084d4d0e3a48e6a3d8277af9560/Classes/ViewHelpers/RowWrapViewHelper.php#L48-L57 |
oroinc/OroLayoutComponent | Loader/Generator/Extension/ImportLayoutUpdateVisitor.php | ImportLayoutUpdateVisitor.startVisit | public function startVisit(VisitContext $visitContext)
{
$writer = $visitContext->createWriter();
$class = $visitContext->getClass();
$class->addUseStatement('Oro\Component\Layout\ImportLayoutManipulator');
$class->addInterfaceName('Oro\Component\Layout\LayoutUpdateImportInterface');
$class->addInterfaceName('Oro\Component\Layout\IsApplicableLayoutUpdateInterface');
$setFactoryMethod = PhpMethod::create('isApplicable');
$setFactoryMethod->addParameter(
PhpParameter::create('context')
->setType('\Oro\Component\Layout\ContextInterface')
);
$setFactoryMethod->setBody($writer->reset()->write('return true;')->getContent());
$class->setMethod($setFactoryMethod);
$setFactoryMethod = PhpMethod::create('getImport');
$setFactoryMethod->setBody($writer->reset()->write('return $this->import;')->getContent());
$class->setMethod($setFactoryMethod);
$setFactoryMethod = PhpMethod::create('setImport');
$setFactoryMethod->addParameter(
PhpParameter::create('import')
->setType('Oro\Component\Layout\Model\LayoutUpdateImport')
);
$setFactoryMethod->setBody($writer->reset()->write('$this->import = $import;')->getContent());
$class->setMethod($setFactoryMethod);
$factoryProperty = PhpProperty::create('import');
$factoryProperty->setVisibility(PhpProperty::VISIBILITY_PRIVATE);
$class->setProperty($factoryProperty);
$setFactoryMethod = PhpMethod::create('setParentUpdate');
$setFactoryMethod->addParameter(
PhpParameter::create('parentLayoutUpdate')
->setType('\Oro\Component\Layout\ImportsAwareLayoutUpdateInterface')
);
$setFactoryMethod->setBody(
$writer->reset()->write('$this->parentLayoutUpdate = $parentLayoutUpdate;')
->getContent()
);
$class->setMethod($setFactoryMethod);
$factoryProperty = PhpProperty::create('parentLayoutUpdate');
$factoryProperty->setVisibility(PhpProperty::VISIBILITY_PRIVATE);
$class->setProperty($factoryProperty);
$visitContext->getUpdateMethodWriter()
->writeln('if (null === $this->import) {')
->indent()
->writeln(
'throw new \\RuntimeException(\'Missing import configuration for layout update\');'
)
->outdent()
->writeln('}')
->writeln('')
->writeln('if ($this->parentLayoutUpdate instanceof Oro\Component\Layout\IsApplicableLayoutUpdateInterface')
->indent()
->writeln('&& !$this->parentLayoutUpdate->isApplicable($item->getContext())) {')
->writeln('return;')
->outdent()
->writeln('}')
->writeln('')
->writeln('$layoutManipulator = new ImportLayoutManipulator($layoutManipulator, $this->import);');
} | php | public function startVisit(VisitContext $visitContext)
{
$writer = $visitContext->createWriter();
$class = $visitContext->getClass();
$class->addUseStatement('Oro\Component\Layout\ImportLayoutManipulator');
$class->addInterfaceName('Oro\Component\Layout\LayoutUpdateImportInterface');
$class->addInterfaceName('Oro\Component\Layout\IsApplicableLayoutUpdateInterface');
$setFactoryMethod = PhpMethod::create('isApplicable');
$setFactoryMethod->addParameter(
PhpParameter::create('context')
->setType('\Oro\Component\Layout\ContextInterface')
);
$setFactoryMethod->setBody($writer->reset()->write('return true;')->getContent());
$class->setMethod($setFactoryMethod);
$setFactoryMethod = PhpMethod::create('getImport');
$setFactoryMethod->setBody($writer->reset()->write('return $this->import;')->getContent());
$class->setMethod($setFactoryMethod);
$setFactoryMethod = PhpMethod::create('setImport');
$setFactoryMethod->addParameter(
PhpParameter::create('import')
->setType('Oro\Component\Layout\Model\LayoutUpdateImport')
);
$setFactoryMethod->setBody($writer->reset()->write('$this->import = $import;')->getContent());
$class->setMethod($setFactoryMethod);
$factoryProperty = PhpProperty::create('import');
$factoryProperty->setVisibility(PhpProperty::VISIBILITY_PRIVATE);
$class->setProperty($factoryProperty);
$setFactoryMethod = PhpMethod::create('setParentUpdate');
$setFactoryMethod->addParameter(
PhpParameter::create('parentLayoutUpdate')
->setType('\Oro\Component\Layout\ImportsAwareLayoutUpdateInterface')
);
$setFactoryMethod->setBody(
$writer->reset()->write('$this->parentLayoutUpdate = $parentLayoutUpdate;')
->getContent()
);
$class->setMethod($setFactoryMethod);
$factoryProperty = PhpProperty::create('parentLayoutUpdate');
$factoryProperty->setVisibility(PhpProperty::VISIBILITY_PRIVATE);
$class->setProperty($factoryProperty);
$visitContext->getUpdateMethodWriter()
->writeln('if (null === $this->import) {')
->indent()
->writeln(
'throw new \\RuntimeException(\'Missing import configuration for layout update\');'
)
->outdent()
->writeln('}')
->writeln('')
->writeln('if ($this->parentLayoutUpdate instanceof Oro\Component\Layout\IsApplicableLayoutUpdateInterface')
->indent()
->writeln('&& !$this->parentLayoutUpdate->isApplicable($item->getContext())) {')
->writeln('return;')
->outdent()
->writeln('}')
->writeln('')
->writeln('$layoutManipulator = new ImportLayoutManipulator($layoutManipulator, $this->import);');
} | [
"public",
"function",
"startVisit",
"(",
"VisitContext",
"$",
"visitContext",
")",
"{",
"$",
"writer",
"=",
"$",
"visitContext",
"->",
"createWriter",
"(",
")",
";",
"$",
"class",
"=",
"$",
"visitContext",
"->",
"getClass",
"(",
")",
";",
"$",
"class",
"->",
"addUseStatement",
"(",
"'Oro\\Component\\Layout\\ImportLayoutManipulator'",
")",
";",
"$",
"class",
"->",
"addInterfaceName",
"(",
"'Oro\\Component\\Layout\\LayoutUpdateImportInterface'",
")",
";",
"$",
"class",
"->",
"addInterfaceName",
"(",
"'Oro\\Component\\Layout\\IsApplicableLayoutUpdateInterface'",
")",
";",
"$",
"setFactoryMethod",
"=",
"PhpMethod",
"::",
"create",
"(",
"'isApplicable'",
")",
";",
"$",
"setFactoryMethod",
"->",
"addParameter",
"(",
"PhpParameter",
"::",
"create",
"(",
"'context'",
")",
"->",
"setType",
"(",
"'\\Oro\\Component\\Layout\\ContextInterface'",
")",
")",
";",
"$",
"setFactoryMethod",
"->",
"setBody",
"(",
"$",
"writer",
"->",
"reset",
"(",
")",
"->",
"write",
"(",
"'return true;'",
")",
"->",
"getContent",
"(",
")",
")",
";",
"$",
"class",
"->",
"setMethod",
"(",
"$",
"setFactoryMethod",
")",
";",
"$",
"setFactoryMethod",
"=",
"PhpMethod",
"::",
"create",
"(",
"'getImport'",
")",
";",
"$",
"setFactoryMethod",
"->",
"setBody",
"(",
"$",
"writer",
"->",
"reset",
"(",
")",
"->",
"write",
"(",
"'return $this->import;'",
")",
"->",
"getContent",
"(",
")",
")",
";",
"$",
"class",
"->",
"setMethod",
"(",
"$",
"setFactoryMethod",
")",
";",
"$",
"setFactoryMethod",
"=",
"PhpMethod",
"::",
"create",
"(",
"'setImport'",
")",
";",
"$",
"setFactoryMethod",
"->",
"addParameter",
"(",
"PhpParameter",
"::",
"create",
"(",
"'import'",
")",
"->",
"setType",
"(",
"'Oro\\Component\\Layout\\Model\\LayoutUpdateImport'",
")",
")",
";",
"$",
"setFactoryMethod",
"->",
"setBody",
"(",
"$",
"writer",
"->",
"reset",
"(",
")",
"->",
"write",
"(",
"'$this->import = $import;'",
")",
"->",
"getContent",
"(",
")",
")",
";",
"$",
"class",
"->",
"setMethod",
"(",
"$",
"setFactoryMethod",
")",
";",
"$",
"factoryProperty",
"=",
"PhpProperty",
"::",
"create",
"(",
"'import'",
")",
";",
"$",
"factoryProperty",
"->",
"setVisibility",
"(",
"PhpProperty",
"::",
"VISIBILITY_PRIVATE",
")",
";",
"$",
"class",
"->",
"setProperty",
"(",
"$",
"factoryProperty",
")",
";",
"$",
"setFactoryMethod",
"=",
"PhpMethod",
"::",
"create",
"(",
"'setParentUpdate'",
")",
";",
"$",
"setFactoryMethod",
"->",
"addParameter",
"(",
"PhpParameter",
"::",
"create",
"(",
"'parentLayoutUpdate'",
")",
"->",
"setType",
"(",
"'\\Oro\\Component\\Layout\\ImportsAwareLayoutUpdateInterface'",
")",
")",
";",
"$",
"setFactoryMethod",
"->",
"setBody",
"(",
"$",
"writer",
"->",
"reset",
"(",
")",
"->",
"write",
"(",
"'$this->parentLayoutUpdate = $parentLayoutUpdate;'",
")",
"->",
"getContent",
"(",
")",
")",
";",
"$",
"class",
"->",
"setMethod",
"(",
"$",
"setFactoryMethod",
")",
";",
"$",
"factoryProperty",
"=",
"PhpProperty",
"::",
"create",
"(",
"'parentLayoutUpdate'",
")",
";",
"$",
"factoryProperty",
"->",
"setVisibility",
"(",
"PhpProperty",
"::",
"VISIBILITY_PRIVATE",
")",
";",
"$",
"class",
"->",
"setProperty",
"(",
"$",
"factoryProperty",
")",
";",
"$",
"visitContext",
"->",
"getUpdateMethodWriter",
"(",
")",
"->",
"writeln",
"(",
"'if (null === $this->import) {'",
")",
"->",
"indent",
"(",
")",
"->",
"writeln",
"(",
"'throw new \\\\RuntimeException(\\'Missing import configuration for layout update\\');'",
")",
"->",
"outdent",
"(",
")",
"->",
"writeln",
"(",
"'}'",
")",
"->",
"writeln",
"(",
"''",
")",
"->",
"writeln",
"(",
"'if ($this->parentLayoutUpdate instanceof Oro\\Component\\Layout\\IsApplicableLayoutUpdateInterface'",
")",
"->",
"indent",
"(",
")",
"->",
"writeln",
"(",
"'&& !$this->parentLayoutUpdate->isApplicable($item->getContext())) {'",
")",
"->",
"writeln",
"(",
"'return;'",
")",
"->",
"outdent",
"(",
")",
"->",
"writeln",
"(",
"'}'",
")",
"->",
"writeln",
"(",
"''",
")",
"->",
"writeln",
"(",
"'$layoutManipulator = new ImportLayoutManipulator($layoutManipulator, $this->import);'",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Loader/Generator/Extension/ImportLayoutUpdateVisitor.php#L16-L80 |
Eresus/EresusCMS | src/core/Client/Controller/Content/Url.php | Eresus_Client_Controller_Content_Url.getHtml | public function getHtml(Eresus_CMS_Request $request, TClientUI $page)
{
$tmpl = new Eresus_Template();
$tmpl->setSource($page->content);
$html = $tmpl->compile();
$response = new Eresus_HTTP_Redirect($html);
return $response;
} | php | public function getHtml(Eresus_CMS_Request $request, TClientUI $page)
{
$tmpl = new Eresus_Template();
$tmpl->setSource($page->content);
$html = $tmpl->compile();
$response = new Eresus_HTTP_Redirect($html);
return $response;
} | [
"public",
"function",
"getHtml",
"(",
"Eresus_CMS_Request",
"$",
"request",
",",
"TClientUI",
"$",
"page",
")",
"{",
"$",
"tmpl",
"=",
"new",
"Eresus_Template",
"(",
")",
";",
"$",
"tmpl",
"->",
"setSource",
"(",
"$",
"page",
"->",
"content",
")",
";",
"$",
"html",
"=",
"$",
"tmpl",
"->",
"compile",
"(",
")",
";",
"$",
"response",
"=",
"new",
"Eresus_HTTP_Redirect",
"(",
"$",
"html",
")",
";",
"return",
"$",
"response",
";",
"}"
] | Возвращает разметку области контента
@param Eresus_CMS_Request $request
@param TClientUI $page
@return Eresus_HTTP_Response
@since 3.01 | [
"Возвращает",
"разметку",
"области",
"контента"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/Client/Controller/Content/Url.php#L45-L52 |
OpenClassrooms/Cache | src/OpenClassrooms/Cache/Cache/CacheImpl.php | CacheImpl.fetchWithNamespace | public function fetchWithNamespace($id, $namespaceId = null)
{
if (null !== $namespaceId) {
$namespace = $this->fetch($namespaceId);
$id = $namespace . $id;
}
return $this->fetch($id);
} | php | public function fetchWithNamespace($id, $namespaceId = null)
{
if (null !== $namespaceId) {
$namespace = $this->fetch($namespaceId);
$id = $namespace . $id;
}
return $this->fetch($id);
} | [
"public",
"function",
"fetchWithNamespace",
"(",
"$",
"id",
",",
"$",
"namespaceId",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"namespaceId",
")",
"{",
"$",
"namespace",
"=",
"$",
"this",
"->",
"fetch",
"(",
"$",
"namespaceId",
")",
";",
"$",
"id",
"=",
"$",
"namespace",
".",
"$",
"id",
";",
"}",
"return",
"$",
"this",
"->",
"fetch",
"(",
"$",
"id",
")",
";",
"}"
] | Fetches an entry from the cache.
@param string $id The id of the cache entry to fetch.
@param string $namespaceId The id of the namespace entry to fetch.
@return mixed The cached data or FALSE, if no cache entry exists for the given namespace and id. | [
"Fetches",
"an",
"entry",
"from",
"the",
"cache",
"."
] | train | https://github.com/OpenClassrooms/Cache/blob/7e7bdfd1b1503384f59ff6d5d29ba741a0e18ad6/src/OpenClassrooms/Cache/Cache/CacheImpl.php#L40-L48 |
OpenClassrooms/Cache | src/OpenClassrooms/Cache/Cache/CacheImpl.php | CacheImpl.invalidate | public function invalidate($namespaceId)
{
$namespace = $this->fetch($namespaceId);
if (false === $namespace) {
return false;
}
$newNamespace = rand(0, 10000);
// @codeCoverageIgnoreStart
while ($namespace === $newNamespace) {
$newNamespace = rand(0, 10000);
}
// @codeCoverageIgnoreEnd
return $this->save($namespaceId, $namespaceId . '_' . $newNamespace .'_', 0);
} | php | public function invalidate($namespaceId)
{
$namespace = $this->fetch($namespaceId);
if (false === $namespace) {
return false;
}
$newNamespace = rand(0, 10000);
// @codeCoverageIgnoreStart
while ($namespace === $newNamespace) {
$newNamespace = rand(0, 10000);
}
// @codeCoverageIgnoreEnd
return $this->save($namespaceId, $namespaceId . '_' . $newNamespace .'_', 0);
} | [
"public",
"function",
"invalidate",
"(",
"$",
"namespaceId",
")",
"{",
"$",
"namespace",
"=",
"$",
"this",
"->",
"fetch",
"(",
"$",
"namespaceId",
")",
";",
"if",
"(",
"false",
"===",
"$",
"namespace",
")",
"{",
"return",
"false",
";",
"}",
"$",
"newNamespace",
"=",
"rand",
"(",
"0",
",",
"10000",
")",
";",
"// @codeCoverageIgnoreStart",
"while",
"(",
"$",
"namespace",
"===",
"$",
"newNamespace",
")",
"{",
"$",
"newNamespace",
"=",
"rand",
"(",
"0",
",",
"10000",
")",
";",
"}",
"// @codeCoverageIgnoreEnd",
"return",
"$",
"this",
"->",
"save",
"(",
"$",
"namespaceId",
",",
"$",
"namespaceId",
".",
"'_'",
".",
"$",
"newNamespace",
".",
"'_'",
",",
"0",
")",
";",
"}"
] | Invalidate a namespace.
@param string $namespaceId The id of the namespace to invalidate.
@return boolean TRUE if the namespace entry was successfully regenerated, FALSE otherwise. | [
"Invalidate",
"a",
"namespace",
"."
] | train | https://github.com/OpenClassrooms/Cache/blob/7e7bdfd1b1503384f59ff6d5d29ba741a0e18ad6/src/OpenClassrooms/Cache/Cache/CacheImpl.php#L122-L138 |
OpenClassrooms/Cache | src/OpenClassrooms/Cache/Cache/CacheImpl.php | CacheImpl.save | public function save($id, $data, $lifeTime = null)
{
if (null === $lifeTime) {
$lifeTime = $this->defaultLifetime;
}
return $this->cache->save($id, $data, $lifeTime);
} | php | public function save($id, $data, $lifeTime = null)
{
if (null === $lifeTime) {
$lifeTime = $this->defaultLifetime;
}
return $this->cache->save($id, $data, $lifeTime);
} | [
"public",
"function",
"save",
"(",
"$",
"id",
",",
"$",
"data",
",",
"$",
"lifeTime",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"lifeTime",
")",
"{",
"$",
"lifeTime",
"=",
"$",
"this",
"->",
"defaultLifetime",
";",
"}",
"return",
"$",
"this",
"->",
"cache",
"->",
"save",
"(",
"$",
"id",
",",
"$",
"data",
",",
"$",
"lifeTime",
")",
";",
"}"
] | Puts data into the cache.
@param string $id The cache id.
@param mixed $data The cache entry/data.
@param int $lifeTime The cache lifetime.
If != 0, sets a specific lifetime for this cache entry (0 => infinite lifeTime).
@return boolean TRUE if the entry was successfully stored in the cache, FALSE otherwise. | [
"Puts",
"data",
"into",
"the",
"cache",
"."
] | train | https://github.com/OpenClassrooms/Cache/blob/7e7bdfd1b1503384f59ff6d5d29ba741a0e18ad6/src/OpenClassrooms/Cache/Cache/CacheImpl.php#L150-L157 |
OpenClassrooms/Cache | src/OpenClassrooms/Cache/Cache/CacheImpl.php | CacheImpl.saveWithNamespace | public function saveWithNamespace($id, $data, $namespaceId = null, $lifeTime = null)
{
if (null !== $namespaceId) {
$namespace = $this->fetch($namespaceId);
if (!$namespace) {
$namespace = $namespaceId . '_' . rand(0, 10000);
$this->save($namespaceId, $namespace, 0);
}
$id = $namespace . $id;
}
return $this->save($id, $data, $lifeTime);
} | php | public function saveWithNamespace($id, $data, $namespaceId = null, $lifeTime = null)
{
if (null !== $namespaceId) {
$namespace = $this->fetch($namespaceId);
if (!$namespace) {
$namespace = $namespaceId . '_' . rand(0, 10000);
$this->save($namespaceId, $namespace, 0);
}
$id = $namespace . $id;
}
return $this->save($id, $data, $lifeTime);
} | [
"public",
"function",
"saveWithNamespace",
"(",
"$",
"id",
",",
"$",
"data",
",",
"$",
"namespaceId",
"=",
"null",
",",
"$",
"lifeTime",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"namespaceId",
")",
"{",
"$",
"namespace",
"=",
"$",
"this",
"->",
"fetch",
"(",
"$",
"namespaceId",
")",
";",
"if",
"(",
"!",
"$",
"namespace",
")",
"{",
"$",
"namespace",
"=",
"$",
"namespaceId",
".",
"'_'",
".",
"rand",
"(",
"0",
",",
"10000",
")",
";",
"$",
"this",
"->",
"save",
"(",
"$",
"namespaceId",
",",
"$",
"namespace",
",",
"0",
")",
";",
"}",
"$",
"id",
"=",
"$",
"namespace",
".",
"$",
"id",
";",
"}",
"return",
"$",
"this",
"->",
"save",
"(",
"$",
"id",
",",
"$",
"data",
",",
"$",
"lifeTime",
")",
";",
"}"
] | Puts data into the cache.
@param string $id The cache id.
@param mixed $data The cache entry/data.
@param string $namespaceId The namespace id.
@param int $lifeTime The cache lifetime.
If != 0, sets a specific lifetime for this cache entry (0 => infinite lifeTime).
@return boolean TRUE if the entry was successfully stored in the cache, FALSE otherwise. | [
"Puts",
"data",
"into",
"the",
"cache",
"."
] | train | https://github.com/OpenClassrooms/Cache/blob/7e7bdfd1b1503384f59ff6d5d29ba741a0e18ad6/src/OpenClassrooms/Cache/Cache/CacheImpl.php#L170-L182 |
antarctica/laravel-base-repositories | src/Repository/BaseRepositoryEloquent.php | BaseRepositoryEloquent.find | public function find($id)
{
$result = $this->model->findOrFail($id)->toArray();
return $this->export($result);
} | php | public function find($id)
{
$result = $this->model->findOrFail($id)->toArray();
return $this->export($result);
} | [
"public",
"function",
"find",
"(",
"$",
"id",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"model",
"->",
"findOrFail",
"(",
"$",
"id",
")",
"->",
"toArray",
"(",
")",
";",
"return",
"$",
"this",
"->",
"export",
"(",
"$",
"result",
")",
";",
"}"
] | Return a single record/entity specified by an $id
TODO Handle export within export() method
@param string $id
@return array | [
"Return",
"a",
"single",
"record",
"/",
"entity",
"specified",
"by",
"an",
"$id"
] | train | https://github.com/antarctica/laravel-base-repositories/blob/ca3d36bc841807d5b9108e52f433433a2663e7dc/src/Repository/BaseRepositoryEloquent.php#L41-L46 |
antarctica/laravel-base-repositories | src/Repository/BaseRepositoryEloquent.php | BaseRepositoryEloquent.create | public function create(Array $input)
{
$result = $this->model->create($input);
return $this->export($result);
} | php | public function create(Array $input)
{
$result = $this->model->create($input);
return $this->export($result);
} | [
"public",
"function",
"create",
"(",
"Array",
"$",
"input",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"model",
"->",
"create",
"(",
"$",
"input",
")",
";",
"return",
"$",
"this",
"->",
"export",
"(",
"$",
"result",
")",
";",
"}"
] | Create new record/entity from $input
TODO Handle export within export() method
@param array $input
@return array | [
"Create",
"new",
"record",
"/",
"entity",
"from",
"$input"
] | train | https://github.com/antarctica/laravel-base-repositories/blob/ca3d36bc841807d5b9108e52f433433a2663e7dc/src/Repository/BaseRepositoryEloquent.php#L56-L61 |
technote-space/wordpress-plugin-base | src/traits/loader.php | Loader.namespace_to_dir | private function namespace_to_dir( $namespace ) {
$namespace = ltrim( $namespace, '\\' );
$dir = null;
if ( preg_match( "#\A{$this->app->define->plugin_namespace}#", $namespace ) ) {
$namespace = preg_replace( "#\A{$this->app->define->plugin_namespace}#", '', $namespace );
$dir = $this->app->define->plugin_src_dir;
} elseif ( preg_match( "#\A{$this->app->define->lib_namespace}#", $namespace ) ) {
$namespace = preg_replace( "#\A{$this->app->define->lib_namespace}#", '', $namespace );
$dir = $this->app->define->lib_src_dir;
}
if ( isset( $dir ) ) {
$namespace = ltrim( $namespace, '\\' );
$namespace = strtolower( $namespace );
$path = $dir . DS . str_replace( '\\', DS, $namespace );
$path = rtrim( $path, DS );
if ( is_dir( $path ) ) {
return $path;
}
}
return false;
} | php | private function namespace_to_dir( $namespace ) {
$namespace = ltrim( $namespace, '\\' );
$dir = null;
if ( preg_match( "#\A{$this->app->define->plugin_namespace}#", $namespace ) ) {
$namespace = preg_replace( "#\A{$this->app->define->plugin_namespace}#", '', $namespace );
$dir = $this->app->define->plugin_src_dir;
} elseif ( preg_match( "#\A{$this->app->define->lib_namespace}#", $namespace ) ) {
$namespace = preg_replace( "#\A{$this->app->define->lib_namespace}#", '', $namespace );
$dir = $this->app->define->lib_src_dir;
}
if ( isset( $dir ) ) {
$namespace = ltrim( $namespace, '\\' );
$namespace = strtolower( $namespace );
$path = $dir . DS . str_replace( '\\', DS, $namespace );
$path = rtrim( $path, DS );
if ( is_dir( $path ) ) {
return $path;
}
}
return false;
} | [
"private",
"function",
"namespace_to_dir",
"(",
"$",
"namespace",
")",
"{",
"$",
"namespace",
"=",
"ltrim",
"(",
"$",
"namespace",
",",
"'\\\\'",
")",
";",
"$",
"dir",
"=",
"null",
";",
"if",
"(",
"preg_match",
"(",
"\"#\\A{$this->app->define->plugin_namespace}#\"",
",",
"$",
"namespace",
")",
")",
"{",
"$",
"namespace",
"=",
"preg_replace",
"(",
"\"#\\A{$this->app->define->plugin_namespace}#\"",
",",
"''",
",",
"$",
"namespace",
")",
";",
"$",
"dir",
"=",
"$",
"this",
"->",
"app",
"->",
"define",
"->",
"plugin_src_dir",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"\"#\\A{$this->app->define->lib_namespace}#\"",
",",
"$",
"namespace",
")",
")",
"{",
"$",
"namespace",
"=",
"preg_replace",
"(",
"\"#\\A{$this->app->define->lib_namespace}#\"",
",",
"''",
",",
"$",
"namespace",
")",
";",
"$",
"dir",
"=",
"$",
"this",
"->",
"app",
"->",
"define",
"->",
"lib_src_dir",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"dir",
")",
")",
"{",
"$",
"namespace",
"=",
"ltrim",
"(",
"$",
"namespace",
",",
"'\\\\'",
")",
";",
"$",
"namespace",
"=",
"strtolower",
"(",
"$",
"namespace",
")",
";",
"$",
"path",
"=",
"$",
"dir",
".",
"DS",
".",
"str_replace",
"(",
"'\\\\'",
",",
"DS",
",",
"$",
"namespace",
")",
";",
"$",
"path",
"=",
"rtrim",
"(",
"$",
"path",
",",
"DS",
")",
";",
"if",
"(",
"is_dir",
"(",
"$",
"path",
")",
")",
"{",
"return",
"$",
"path",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | @param string $namespace
@return string|false | [
"@param",
"string",
"$namespace"
] | train | https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/traits/loader.php#L61-L83 |
technote-space/wordpress-plugin-base | src/traits/loader.php | Loader.get_loaded_count | public function get_loaded_count( $exact = true ) {
if ( ! $exact && ! isset( $this->_list ) ) {
if ( ! isset( $this->_count ) ) {
$this->_count = 0;
foreach ( $this->get_namespaces() as $namespace ) {
$this->_count += count( $this->app->utility->scan_dir_namespace_class( $this->namespace_to_dir( $namespace ) ) );
}
}
return $this->_count;
}
return count( $this->get_class_list() );
} | php | public function get_loaded_count( $exact = true ) {
if ( ! $exact && ! isset( $this->_list ) ) {
if ( ! isset( $this->_count ) ) {
$this->_count = 0;
foreach ( $this->get_namespaces() as $namespace ) {
$this->_count += count( $this->app->utility->scan_dir_namespace_class( $this->namespace_to_dir( $namespace ) ) );
}
}
return $this->_count;
}
return count( $this->get_class_list() );
} | [
"public",
"function",
"get_loaded_count",
"(",
"$",
"exact",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"$",
"exact",
"&&",
"!",
"isset",
"(",
"$",
"this",
"->",
"_list",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_count",
")",
")",
"{",
"$",
"this",
"->",
"_count",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"get_namespaces",
"(",
")",
"as",
"$",
"namespace",
")",
"{",
"$",
"this",
"->",
"_count",
"+=",
"count",
"(",
"$",
"this",
"->",
"app",
"->",
"utility",
"->",
"scan_dir_namespace_class",
"(",
"$",
"this",
"->",
"namespace_to_dir",
"(",
"$",
"namespace",
")",
")",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"_count",
";",
"}",
"return",
"count",
"(",
"$",
"this",
"->",
"get_class_list",
"(",
")",
")",
";",
"}"
] | @since 2.6.1 Updated: count without load class feature
@param bool $exact
@return int | [
"@since",
"2",
".",
"6",
".",
"1",
"Updated",
":",
"count",
"without",
"load",
"class",
"feature"
] | train | https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/traits/loader.php#L130-L143 |
technote-space/wordpress-plugin-base | src/traits/loader.php | Loader.get_class_settings | protected function get_class_settings( $dir ) {
foreach ( $this->app->utility->scan_dir_namespace_class( $dir, true ) as list( $namespace, $class ) ) {
yield $this->get_class_setting( $class, $namespace );
}
} | php | protected function get_class_settings( $dir ) {
foreach ( $this->app->utility->scan_dir_namespace_class( $dir, true ) as list( $namespace, $class ) ) {
yield $this->get_class_setting( $class, $namespace );
}
} | [
"protected",
"function",
"get_class_settings",
"(",
"$",
"dir",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"app",
"->",
"utility",
"->",
"scan_dir_namespace_class",
"(",
"$",
"dir",
",",
"true",
")",
"as",
"list",
"(",
"$",
"namespace",
",",
"$",
"class",
")",
")",
"{",
"yield",
"$",
"this",
"->",
"get_class_setting",
"(",
"$",
"class",
",",
"$",
"namespace",
")",
";",
"}",
"}"
] | @param string $dir
@return \Generator | [
"@param",
"string",
"$dir"
] | train | https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/traits/loader.php#L150-L154 |
technote-space/wordpress-plugin-base | src/traits/loader.php | Loader.get_classes | protected function get_classes( $dir, $instanceof, $return_instance = true ) {
foreach ( $this->get_class_settings( $dir ) as $class_setting ) {
$instance = $this->get_class_instance( $class_setting, $instanceof );
if ( false !== $instance ) {
if ( $return_instance ) {
yield $instance;
} else {
yield $class_setting;
}
}
}
} | php | protected function get_classes( $dir, $instanceof, $return_instance = true ) {
foreach ( $this->get_class_settings( $dir ) as $class_setting ) {
$instance = $this->get_class_instance( $class_setting, $instanceof );
if ( false !== $instance ) {
if ( $return_instance ) {
yield $instance;
} else {
yield $class_setting;
}
}
}
} | [
"protected",
"function",
"get_classes",
"(",
"$",
"dir",
",",
"$",
"instanceof",
",",
"$",
"return_instance",
"=",
"true",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"get_class_settings",
"(",
"$",
"dir",
")",
"as",
"$",
"class_setting",
")",
"{",
"$",
"instance",
"=",
"$",
"this",
"->",
"get_class_instance",
"(",
"$",
"class_setting",
",",
"$",
"instanceof",
")",
";",
"if",
"(",
"false",
"!==",
"$",
"instance",
")",
"{",
"if",
"(",
"$",
"return_instance",
")",
"{",
"yield",
"$",
"instance",
";",
"}",
"else",
"{",
"yield",
"$",
"class_setting",
";",
"}",
"}",
"}",
"}"
] | @param string $dir
@param string $instanceof
@param bool $return_instance
@return \Generator | [
"@param",
"string",
"$dir",
"@param",
"string",
"$instanceof",
"@param",
"bool",
"$return_instance"
] | train | https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/traits/loader.php#L163-L174 |
technote-space/wordpress-plugin-base | src/traits/loader.php | Loader.get_class_setting | protected function get_class_setting( $class_name, $add_namespace = '' ) {
if ( isset( $this->_cache[ $add_namespace . $class_name ] ) ) {
return $this->_cache[ $add_namespace . $class_name ];
}
$namespaces = $this->get_namespaces();
if ( ! empty( $namespaces ) ) {
foreach ( $namespaces as $namespace ) {
$class = rtrim( $namespace, '\\' ) . '\\' . $add_namespace . $class_name;
if ( class_exists( $class ) ) {
$this->_cache[ $add_namespace . $class_name ] = [ $class, $add_namespace ];
return $this->_cache[ $add_namespace . $class_name ];
}
}
}
return false;
} | php | protected function get_class_setting( $class_name, $add_namespace = '' ) {
if ( isset( $this->_cache[ $add_namespace . $class_name ] ) ) {
return $this->_cache[ $add_namespace . $class_name ];
}
$namespaces = $this->get_namespaces();
if ( ! empty( $namespaces ) ) {
foreach ( $namespaces as $namespace ) {
$class = rtrim( $namespace, '\\' ) . '\\' . $add_namespace . $class_name;
if ( class_exists( $class ) ) {
$this->_cache[ $add_namespace . $class_name ] = [ $class, $add_namespace ];
return $this->_cache[ $add_namespace . $class_name ];
}
}
}
return false;
} | [
"protected",
"function",
"get_class_setting",
"(",
"$",
"class_name",
",",
"$",
"add_namespace",
"=",
"''",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_cache",
"[",
"$",
"add_namespace",
".",
"$",
"class_name",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_cache",
"[",
"$",
"add_namespace",
".",
"$",
"class_name",
"]",
";",
"}",
"$",
"namespaces",
"=",
"$",
"this",
"->",
"get_namespaces",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"namespaces",
")",
")",
"{",
"foreach",
"(",
"$",
"namespaces",
"as",
"$",
"namespace",
")",
"{",
"$",
"class",
"=",
"rtrim",
"(",
"$",
"namespace",
",",
"'\\\\'",
")",
".",
"'\\\\'",
".",
"$",
"add_namespace",
".",
"$",
"class_name",
";",
"if",
"(",
"class_exists",
"(",
"$",
"class",
")",
")",
"{",
"$",
"this",
"->",
"_cache",
"[",
"$",
"add_namespace",
".",
"$",
"class_name",
"]",
"=",
"[",
"$",
"class",
",",
"$",
"add_namespace",
"]",
";",
"return",
"$",
"this",
"->",
"_cache",
"[",
"$",
"add_namespace",
".",
"$",
"class_name",
"]",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] | @param string $class_name
@param string $add_namespace
@return false|array | [
"@param",
"string",
"$class_name",
"@param",
"string",
"$add_namespace"
] | train | https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/traits/loader.php#L182-L199 |
technote-space/wordpress-plugin-base | src/traits/loader.php | Loader.get_class_instance | protected function get_class_instance( $class_setting, $instanceof ) {
if ( false !== $class_setting && class_exists( $class_setting[0] ) && is_subclass_of( $class_setting[0], '\Technote\Interfaces\Singleton' ) ) {
try {
/** @var Singleton[] $class_setting */
$instance = $class_setting[0]::get_instance( $this->app );
if ( $instance instanceof $instanceof ) {
if ( $instance instanceof \Technote\Interfaces\Controller\Admin ) {
$instance->set_relative_namespace( $class_setting[1] );
}
return $instance;
}
} catch ( \Exception $e ) {
}
}
return false;
} | php | protected function get_class_instance( $class_setting, $instanceof ) {
if ( false !== $class_setting && class_exists( $class_setting[0] ) && is_subclass_of( $class_setting[0], '\Technote\Interfaces\Singleton' ) ) {
try {
/** @var Singleton[] $class_setting */
$instance = $class_setting[0]::get_instance( $this->app );
if ( $instance instanceof $instanceof ) {
if ( $instance instanceof \Technote\Interfaces\Controller\Admin ) {
$instance->set_relative_namespace( $class_setting[1] );
}
return $instance;
}
} catch ( \Exception $e ) {
}
}
return false;
} | [
"protected",
"function",
"get_class_instance",
"(",
"$",
"class_setting",
",",
"$",
"instanceof",
")",
"{",
"if",
"(",
"false",
"!==",
"$",
"class_setting",
"&&",
"class_exists",
"(",
"$",
"class_setting",
"[",
"0",
"]",
")",
"&&",
"is_subclass_of",
"(",
"$",
"class_setting",
"[",
"0",
"]",
",",
"'\\Technote\\Interfaces\\Singleton'",
")",
")",
"{",
"try",
"{",
"/** @var Singleton[] $class_setting */",
"$",
"instance",
"=",
"$",
"class_setting",
"[",
"0",
"]",
"::",
"get_instance",
"(",
"$",
"this",
"->",
"app",
")",
";",
"if",
"(",
"$",
"instance",
"instanceof",
"$",
"instanceof",
")",
"{",
"if",
"(",
"$",
"instance",
"instanceof",
"\\",
"Technote",
"\\",
"Interfaces",
"\\",
"Controller",
"\\",
"Admin",
")",
"{",
"$",
"instance",
"->",
"set_relative_namespace",
"(",
"$",
"class_setting",
"[",
"1",
"]",
")",
";",
"}",
"return",
"$",
"instance",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"}",
"}",
"return",
"false",
";",
"}"
] | @param array $class_setting
@param string $instanceof
@return bool|Singleton | [
"@param",
"array",
"$class_setting",
"@param",
"string",
"$instanceof"
] | train | https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/traits/loader.php#L207-L224 |
titledk/silverstripe-uploaddirrules | code/AssetsFolderExtension.php | AssetsFolderExtension.onAfterWrite | public function onAfterWrite()
{
parent::onAfterWrite();
//creation will only be considered if the object has no folder relation
if ($this->owner->AssetsFolderID == 0) {
$url = $this->owner->assetsFolderUrlToBeWritten();
if ($url) {
//this creates the directory, and attaches it to the page,
//as well as saving the object one more time - with the attached folder
$this->findOrMakeAssetsFolder($url, true);
}
}
} | php | public function onAfterWrite()
{
parent::onAfterWrite();
//creation will only be considered if the object has no folder relation
if ($this->owner->AssetsFolderID == 0) {
$url = $this->owner->assetsFolderUrlToBeWritten();
if ($url) {
//this creates the directory, and attaches it to the page,
//as well as saving the object one more time - with the attached folder
$this->findOrMakeAssetsFolder($url, true);
}
}
} | [
"public",
"function",
"onAfterWrite",
"(",
")",
"{",
"parent",
"::",
"onAfterWrite",
"(",
")",
";",
"//creation will only be considered if the object has no folder relation",
"if",
"(",
"$",
"this",
"->",
"owner",
"->",
"AssetsFolderID",
"==",
"0",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"owner",
"->",
"assetsFolderUrlToBeWritten",
"(",
")",
";",
"if",
"(",
"$",
"url",
")",
"{",
"//this creates the directory, and attaches it to the page,",
"//as well as saving the object one more time - with the attached folder",
"$",
"this",
"->",
"findOrMakeAssetsFolder",
"(",
"$",
"url",
",",
"true",
")",
";",
"}",
"}",
"}"
] | Creation and association of assets folder,
once a data object has been created (and is ready for it). | [
"Creation",
"and",
"association",
"of",
"assets",
"folder",
"once",
"a",
"data",
"object",
"has",
"been",
"created",
"(",
"and",
"is",
"ready",
"for",
"it",
")",
"."
] | train | https://github.com/titledk/silverstripe-uploaddirrules/blob/ed8ece7b6a4ca86dcb5dc16ee10ff339f629de3c/code/AssetsFolderExtension.php#L37-L51 |
titledk/silverstripe-uploaddirrules | code/AssetsFolderExtension.php | AssetsFolderExtension.assetsFolderUrlToBeWritten | public function assetsFolderUrlToBeWritten() {
$url = null;
//the default rules only require the object to have an ID
//but more sophisticated rules might require more - e.g. a title to be set
//thus we check if the object is ready for folder creation - if custom rules
//(UploadDirRulesInterface) have been set
if (method_exists($this->owner, 'getReadyForFolderCreation')) {
if (!$this->owner->getReadyForFolderCreation()) {
return false;
}
}
//check if the page we're having is implementing the UploadDirRulesInterface
//for rule customization
if ($this->owner instanceof UploadDirRulesInterface) {
$url = $this->owner->getCalcAssetsFolderDirectory();
} else {
//else use the default settings
$class = UploadDirRules::get_rules_class();
$url = $class::calc_full_directory_for_object($this->owner);
}
return $url;
} | php | public function assetsFolderUrlToBeWritten() {
$url = null;
//the default rules only require the object to have an ID
//but more sophisticated rules might require more - e.g. a title to be set
//thus we check if the object is ready for folder creation - if custom rules
//(UploadDirRulesInterface) have been set
if (method_exists($this->owner, 'getReadyForFolderCreation')) {
if (!$this->owner->getReadyForFolderCreation()) {
return false;
}
}
//check if the page we're having is implementing the UploadDirRulesInterface
//for rule customization
if ($this->owner instanceof UploadDirRulesInterface) {
$url = $this->owner->getCalcAssetsFolderDirectory();
} else {
//else use the default settings
$class = UploadDirRules::get_rules_class();
$url = $class::calc_full_directory_for_object($this->owner);
}
return $url;
} | [
"public",
"function",
"assetsFolderUrlToBeWritten",
"(",
")",
"{",
"$",
"url",
"=",
"null",
";",
"//the default rules only require the object to have an ID",
"//but more sophisticated rules might require more - e.g. a title to be set",
"//thus we check if the object is ready for folder creation - if custom rules",
"//(UploadDirRulesInterface) have been set",
"if",
"(",
"method_exists",
"(",
"$",
"this",
"->",
"owner",
",",
"'getReadyForFolderCreation'",
")",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"owner",
"->",
"getReadyForFolderCreation",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"//check if the page we're having is implementing the UploadDirRulesInterface",
"//for rule customization",
"if",
"(",
"$",
"this",
"->",
"owner",
"instanceof",
"UploadDirRulesInterface",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"owner",
"->",
"getCalcAssetsFolderDirectory",
"(",
")",
";",
"}",
"else",
"{",
"//else use the default settings",
"$",
"class",
"=",
"UploadDirRules",
"::",
"get_rules_class",
"(",
")",
";",
"$",
"url",
"=",
"$",
"class",
"::",
"calc_full_directory_for_object",
"(",
"$",
"this",
"->",
"owner",
")",
";",
"}",
"return",
"$",
"url",
";",
"}"
] | TODO this should NOT be public, but I'm not sure whether there's a way around it | [
"TODO",
"this",
"should",
"NOT",
"be",
"public",
"but",
"I",
"m",
"not",
"sure",
"whether",
"there",
"s",
"a",
"way",
"around",
"it"
] | train | https://github.com/titledk/silverstripe-uploaddirrules/blob/ed8ece7b6a4ca86dcb5dc16ee10ff339f629de3c/code/AssetsFolderExtension.php#L54-L78 |
titledk/silverstripe-uploaddirrules | code/AssetsFolderExtension.php | AssetsFolderExtension.findOrMakeAssetsFolder | public function findOrMakeAssetsFolder($url, $doWrite = true)
{
$owner = $this->owner;
$dir = Folder::find_or_make($url);
$owner->AssetsFolderID = $dir->ID;
if ($doWrite) {
$owner->write();
}
//Special case for when creating a new subsite
//the directory will need to be associated with the subsite
if ($owner->ClassName == 'Subsite') {
$dir->SubsiteID = $owner->ID;
$dir->write();
}
return $dir;
} | php | public function findOrMakeAssetsFolder($url, $doWrite = true)
{
$owner = $this->owner;
$dir = Folder::find_or_make($url);
$owner->AssetsFolderID = $dir->ID;
if ($doWrite) {
$owner->write();
}
//Special case for when creating a new subsite
//the directory will need to be associated with the subsite
if ($owner->ClassName == 'Subsite') {
$dir->SubsiteID = $owner->ID;
$dir->write();
}
return $dir;
} | [
"public",
"function",
"findOrMakeAssetsFolder",
"(",
"$",
"url",
",",
"$",
"doWrite",
"=",
"true",
")",
"{",
"$",
"owner",
"=",
"$",
"this",
"->",
"owner",
";",
"$",
"dir",
"=",
"Folder",
"::",
"find_or_make",
"(",
"$",
"url",
")",
";",
"$",
"owner",
"->",
"AssetsFolderID",
"=",
"$",
"dir",
"->",
"ID",
";",
"if",
"(",
"$",
"doWrite",
")",
"{",
"$",
"owner",
"->",
"write",
"(",
")",
";",
"}",
"//Special case for when creating a new subsite",
"//the directory will need to be associated with the subsite",
"if",
"(",
"$",
"owner",
"->",
"ClassName",
"==",
"'Subsite'",
")",
"{",
"$",
"dir",
"->",
"SubsiteID",
"=",
"$",
"owner",
"->",
"ID",
";",
"$",
"dir",
"->",
"write",
"(",
")",
";",
"}",
"return",
"$",
"dir",
";",
"}"
] | Find or make assets folder
called from onBeforeWrite.
@param string $url
@param bool $doWrite
@return Folder|null | [
"Find",
"or",
"make",
"assets",
"folder",
"called",
"from",
"onBeforeWrite",
"."
] | train | https://github.com/titledk/silverstripe-uploaddirrules/blob/ed8ece7b6a4ca86dcb5dc16ee10ff339f629de3c/code/AssetsFolderExtension.php#L89-L106 |
titledk/silverstripe-uploaddirrules | code/AssetsFolderExtension.php | AssetsFolderExtension.getAssetsFolderDirName | public function getAssetsFolderDirName()
{
if ($this->owner->getField('AssetsFolderID') != 0) {
$dirObj = $this->owner->AssetsFolder();
$dirName = str_replace('assets/', '', $dirObj->Filename);
return $dirName;
}
} | php | public function getAssetsFolderDirName()
{
if ($this->owner->getField('AssetsFolderID') != 0) {
$dirObj = $this->owner->AssetsFolder();
$dirName = str_replace('assets/', '', $dirObj->Filename);
return $dirName;
}
} | [
"public",
"function",
"getAssetsFolderDirName",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"owner",
"->",
"getField",
"(",
"'AssetsFolderID'",
")",
"!=",
"0",
")",
"{",
"$",
"dirObj",
"=",
"$",
"this",
"->",
"owner",
"->",
"AssetsFolder",
"(",
")",
";",
"$",
"dirName",
"=",
"str_replace",
"(",
"'assets/'",
",",
"''",
",",
"$",
"dirObj",
"->",
"Filename",
")",
";",
"return",
"$",
"dirName",
";",
"}",
"}"
] | Name of the associated assets folder.
@return string|null | [
"Name",
"of",
"the",
"associated",
"assets",
"folder",
"."
] | train | https://github.com/titledk/silverstripe-uploaddirrules/blob/ed8ece7b6a4ca86dcb5dc16ee10ff339f629de3c/code/AssetsFolderExtension.php#L113-L121 |
simbiosis-group/yii2-helper | actions/CreateAction.php | CreateAction.run | public function run()
{
$model = $this->model;
if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post()) && isset($_POST['ajax'])) {
Yii::$app->response->format = Response::FORMAT_JSON;
return ActiveForm::validate($model);
}
if ($model->load(Yii::$app->request->post())) {
$textField = $this->textField;
if ($model->save()) {
if (!empty($this->gridviewCheckboxOptions)) {
$this->gridviewCheckbox();
}
if ($this->isSaveAndNew) {
Yii::$app->response->format = Response::FORMAT_JSON;
return [
'message' => 'saveAndNew',
'success' => true,
'saveAndNewUrl' => $this->saveAndNewUrl,
'id' => $model->id,
'text' => $model->$textField,
];
}
if (isset($this->redirectToViewUrl)) {
return $this->controller->redirect([$this->redirectToViewUrl, 'id' => $model->id]);
}
Yii::$app->getSession()->setFlash('success', $this->successMsg);
Yii::$app->response->format = Response::FORMAT_JSON;
return [
'message' => 'success',
'success' => true,
'id' => $model->id,
'text' => $model->$textField,
];
}
Yii::$app->getSession()->setFlash('error', $this->errorMsg);
Yii::$app->response->format = Response::FORMAT_JSON;
return [
'message' => 'error',
'success' => false,
'error' => print_r($model->getErrors()),
];
}
return $this->controller->renderAjax($this->view, array_merge([
'model' => $model,
], $this->params));
} | php | public function run()
{
$model = $this->model;
if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post()) && isset($_POST['ajax'])) {
Yii::$app->response->format = Response::FORMAT_JSON;
return ActiveForm::validate($model);
}
if ($model->load(Yii::$app->request->post())) {
$textField = $this->textField;
if ($model->save()) {
if (!empty($this->gridviewCheckboxOptions)) {
$this->gridviewCheckbox();
}
if ($this->isSaveAndNew) {
Yii::$app->response->format = Response::FORMAT_JSON;
return [
'message' => 'saveAndNew',
'success' => true,
'saveAndNewUrl' => $this->saveAndNewUrl,
'id' => $model->id,
'text' => $model->$textField,
];
}
if (isset($this->redirectToViewUrl)) {
return $this->controller->redirect([$this->redirectToViewUrl, 'id' => $model->id]);
}
Yii::$app->getSession()->setFlash('success', $this->successMsg);
Yii::$app->response->format = Response::FORMAT_JSON;
return [
'message' => 'success',
'success' => true,
'id' => $model->id,
'text' => $model->$textField,
];
}
Yii::$app->getSession()->setFlash('error', $this->errorMsg);
Yii::$app->response->format = Response::FORMAT_JSON;
return [
'message' => 'error',
'success' => false,
'error' => print_r($model->getErrors()),
];
}
return $this->controller->renderAjax($this->view, array_merge([
'model' => $model,
], $this->params));
} | [
"public",
"function",
"run",
"(",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"model",
";",
"if",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"isAjax",
"&&",
"$",
"model",
"->",
"load",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
")",
"&&",
"isset",
"(",
"$",
"_POST",
"[",
"'ajax'",
"]",
")",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"response",
"->",
"format",
"=",
"Response",
"::",
"FORMAT_JSON",
";",
"return",
"ActiveForm",
"::",
"validate",
"(",
"$",
"model",
")",
";",
"}",
"if",
"(",
"$",
"model",
"->",
"load",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
")",
")",
"{",
"$",
"textField",
"=",
"$",
"this",
"->",
"textField",
";",
"if",
"(",
"$",
"model",
"->",
"save",
"(",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"gridviewCheckboxOptions",
")",
")",
"{",
"$",
"this",
"->",
"gridviewCheckbox",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isSaveAndNew",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"response",
"->",
"format",
"=",
"Response",
"::",
"FORMAT_JSON",
";",
"return",
"[",
"'message'",
"=>",
"'saveAndNew'",
",",
"'success'",
"=>",
"true",
",",
"'saveAndNewUrl'",
"=>",
"$",
"this",
"->",
"saveAndNewUrl",
",",
"'id'",
"=>",
"$",
"model",
"->",
"id",
",",
"'text'",
"=>",
"$",
"model",
"->",
"$",
"textField",
",",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"redirectToViewUrl",
")",
")",
"{",
"return",
"$",
"this",
"->",
"controller",
"->",
"redirect",
"(",
"[",
"$",
"this",
"->",
"redirectToViewUrl",
",",
"'id'",
"=>",
"$",
"model",
"->",
"id",
"]",
")",
";",
"}",
"Yii",
"::",
"$",
"app",
"->",
"getSession",
"(",
")",
"->",
"setFlash",
"(",
"'success'",
",",
"$",
"this",
"->",
"successMsg",
")",
";",
"Yii",
"::",
"$",
"app",
"->",
"response",
"->",
"format",
"=",
"Response",
"::",
"FORMAT_JSON",
";",
"return",
"[",
"'message'",
"=>",
"'success'",
",",
"'success'",
"=>",
"true",
",",
"'id'",
"=>",
"$",
"model",
"->",
"id",
",",
"'text'",
"=>",
"$",
"model",
"->",
"$",
"textField",
",",
"]",
";",
"}",
"Yii",
"::",
"$",
"app",
"->",
"getSession",
"(",
")",
"->",
"setFlash",
"(",
"'error'",
",",
"$",
"this",
"->",
"errorMsg",
")",
";",
"Yii",
"::",
"$",
"app",
"->",
"response",
"->",
"format",
"=",
"Response",
"::",
"FORMAT_JSON",
";",
"return",
"[",
"'message'",
"=>",
"'error'",
",",
"'success'",
"=>",
"false",
",",
"'error'",
"=>",
"print_r",
"(",
"$",
"model",
"->",
"getErrors",
"(",
")",
")",
",",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"controller",
"->",
"renderAjax",
"(",
"$",
"this",
"->",
"view",
",",
"array_merge",
"(",
"[",
"'model'",
"=>",
"$",
"model",
",",
"]",
",",
"$",
"this",
"->",
"params",
")",
")",
";",
"}"
] | Runs the action
@return string result content | [
"Runs",
"the",
"action"
] | train | https://github.com/simbiosis-group/yii2-helper/blob/c85c4204dd06b16e54210e75fe6deb51869d1dd9/actions/CreateAction.php#L97-L152 |
simbiosis-group/yii2-helper | actions/CreateAction.php | CreateAction.assignDefaultValues | protected function assignDefaultValues()
{
foreach ($this->defaultValues as $key => $value) {
$this->model[$key] = $value;
}
return true;
} | php | protected function assignDefaultValues()
{
foreach ($this->defaultValues as $key => $value) {
$this->model[$key] = $value;
}
return true;
} | [
"protected",
"function",
"assignDefaultValues",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"defaultValues",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"model",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"true",
";",
"}"
] | Assign default values to model.
@return boolean | [
"Assign",
"default",
"values",
"to",
"model",
"."
] | train | https://github.com/simbiosis-group/yii2-helper/blob/c85c4204dd06b16e54210e75fe6deb51869d1dd9/actions/CreateAction.php#L158-L165 |
WellCommerce/AppBundle | Form/Admin/PackageFormBuilder.php | PackageFormBuilder.getPackageVersions | protected function getPackageVersions($id)
{
$localPackage = $this->get('package.repository')->findOneById($id);
$remotePackage = $this->get('package.helper')->getPackage($localPackage->getFullName());
$versions = $remotePackage->getVersions();
$result = [];
foreach ($versions as $version) {
$this->getPackageInfo($version, $result);
}
return $result;
} | php | protected function getPackageVersions($id)
{
$localPackage = $this->get('package.repository')->findOneById($id);
$remotePackage = $this->get('package.helper')->getPackage($localPackage->getFullName());
$versions = $remotePackage->getVersions();
$result = [];
foreach ($versions as $version) {
$this->getPackageInfo($version, $result);
}
return $result;
} | [
"protected",
"function",
"getPackageVersions",
"(",
"$",
"id",
")",
"{",
"$",
"localPackage",
"=",
"$",
"this",
"->",
"get",
"(",
"'package.repository'",
")",
"->",
"findOneById",
"(",
"$",
"id",
")",
";",
"$",
"remotePackage",
"=",
"$",
"this",
"->",
"get",
"(",
"'package.helper'",
")",
"->",
"getPackage",
"(",
"$",
"localPackage",
"->",
"getFullName",
"(",
")",
")",
";",
"$",
"versions",
"=",
"$",
"remotePackage",
"->",
"getVersions",
"(",
")",
";",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"versions",
"as",
"$",
"version",
")",
"{",
"$",
"this",
"->",
"getPackageInfo",
"(",
"$",
"version",
",",
"$",
"result",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Returns version information for package
@param $id
@return array | [
"Returns",
"version",
"information",
"for",
"package"
] | train | https://github.com/WellCommerce/AppBundle/blob/2add687d1c898dd0b24afd611d896e3811a0eac3/Form/Admin/PackageFormBuilder.php#L83-L95 |
WellCommerce/AppBundle | Form/Admin/PackageFormBuilder.php | PackageFormBuilder.getPackageInfo | protected function getPackageInfo(Version $version, &$result)
{
$date = new \DateTime($version->getTime());
$packageVersion = $version->getVersion();
if ($packageVersion === PackageHelperInterface::DEFAULT_BRANCH_VERSION) {
$result[$packageVersion] = [
'version' => $packageVersion,
'date' => $date->format('Y-m-d H:i:s'),
'authors' => $version->getAuthors(),
'description' => $version->getDescription(),
'homepage' => $version->getHomepage(),
'license' => $version->getLicense(),
];
}
} | php | protected function getPackageInfo(Version $version, &$result)
{
$date = new \DateTime($version->getTime());
$packageVersion = $version->getVersion();
if ($packageVersion === PackageHelperInterface::DEFAULT_BRANCH_VERSION) {
$result[$packageVersion] = [
'version' => $packageVersion,
'date' => $date->format('Y-m-d H:i:s'),
'authors' => $version->getAuthors(),
'description' => $version->getDescription(),
'homepage' => $version->getHomepage(),
'license' => $version->getLicense(),
];
}
} | [
"protected",
"function",
"getPackageInfo",
"(",
"Version",
"$",
"version",
",",
"&",
"$",
"result",
")",
"{",
"$",
"date",
"=",
"new",
"\\",
"DateTime",
"(",
"$",
"version",
"->",
"getTime",
"(",
")",
")",
";",
"$",
"packageVersion",
"=",
"$",
"version",
"->",
"getVersion",
"(",
")",
";",
"if",
"(",
"$",
"packageVersion",
"===",
"PackageHelperInterface",
"::",
"DEFAULT_BRANCH_VERSION",
")",
"{",
"$",
"result",
"[",
"$",
"packageVersion",
"]",
"=",
"[",
"'version'",
"=>",
"$",
"packageVersion",
",",
"'date'",
"=>",
"$",
"date",
"->",
"format",
"(",
"'Y-m-d H:i:s'",
")",
",",
"'authors'",
"=>",
"$",
"version",
"->",
"getAuthors",
"(",
")",
",",
"'description'",
"=>",
"$",
"version",
"->",
"getDescription",
"(",
")",
",",
"'homepage'",
"=>",
"$",
"version",
"->",
"getHomepage",
"(",
")",
",",
"'license'",
"=>",
"$",
"version",
"->",
"getLicense",
"(",
")",
",",
"]",
";",
"}",
"}"
] | Adds information about single version to result array
@param Version $version
@param array $result | [
"Adds",
"information",
"about",
"single",
"version",
"to",
"result",
"array"
] | train | https://github.com/WellCommerce/AppBundle/blob/2add687d1c898dd0b24afd611d896e3811a0eac3/Form/Admin/PackageFormBuilder.php#L103-L117 |
surebert/surebert-framework | src/sb/Password/Hash.php | Hash.create | public static function create($password) {
// format: algorithm:iterations:salt:hash
if(function_exists('random_bytes')){
$salt = random_bytes(self::$salt_byte_size);
} else if(function_exists('openssl_random_pseudo_bytes')){
$salt = openssl_random_pseudo_bytes(self::$salt_byte_size);
} else if(function_exists('mcrypt_create_iv')){
$salt = mcrypt_create_iv(self::$salt_byte_size, MCRYPT_DEV_URANDOM);
} else {
throw(new Exception("You must have random_bytes, openssl_random_pseudo_bytes or mcrypt_create_iv function available to create salt"));
}
$salt = base64_encode($salt);
return self::$hash_algorithm . ":" . self::$iterations . ":" . $salt . ":" .
base64_encode(self::calculate(
self::$hash_algorithm, $password, $salt, self::$iterations, self::$hash_byte_size, true
));
} | php | public static function create($password) {
// format: algorithm:iterations:salt:hash
if(function_exists('random_bytes')){
$salt = random_bytes(self::$salt_byte_size);
} else if(function_exists('openssl_random_pseudo_bytes')){
$salt = openssl_random_pseudo_bytes(self::$salt_byte_size);
} else if(function_exists('mcrypt_create_iv')){
$salt = mcrypt_create_iv(self::$salt_byte_size, MCRYPT_DEV_URANDOM);
} else {
throw(new Exception("You must have random_bytes, openssl_random_pseudo_bytes or mcrypt_create_iv function available to create salt"));
}
$salt = base64_encode($salt);
return self::$hash_algorithm . ":" . self::$iterations . ":" . $salt . ":" .
base64_encode(self::calculate(
self::$hash_algorithm, $password, $salt, self::$iterations, self::$hash_byte_size, true
));
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"password",
")",
"{",
"// format: algorithm:iterations:salt:hash",
"if",
"(",
"function_exists",
"(",
"'random_bytes'",
")",
")",
"{",
"$",
"salt",
"=",
"random_bytes",
"(",
"self",
"::",
"$",
"salt_byte_size",
")",
";",
"}",
"else",
"if",
"(",
"function_exists",
"(",
"'openssl_random_pseudo_bytes'",
")",
")",
"{",
"$",
"salt",
"=",
"openssl_random_pseudo_bytes",
"(",
"self",
"::",
"$",
"salt_byte_size",
")",
";",
"}",
"else",
"if",
"(",
"function_exists",
"(",
"'mcrypt_create_iv'",
")",
")",
"{",
"$",
"salt",
"=",
"mcrypt_create_iv",
"(",
"self",
"::",
"$",
"salt_byte_size",
",",
"MCRYPT_DEV_URANDOM",
")",
";",
"}",
"else",
"{",
"throw",
"(",
"new",
"Exception",
"(",
"\"You must have random_bytes, openssl_random_pseudo_bytes or mcrypt_create_iv function available to create salt\"",
")",
")",
";",
"}",
"$",
"salt",
"=",
"base64_encode",
"(",
"$",
"salt",
")",
";",
"return",
"self",
"::",
"$",
"hash_algorithm",
".",
"\":\"",
".",
"self",
"::",
"$",
"iterations",
".",
"\":\"",
".",
"$",
"salt",
".",
"\":\"",
".",
"base64_encode",
"(",
"self",
"::",
"calculate",
"(",
"self",
"::",
"$",
"hash_algorithm",
",",
"$",
"password",
",",
"$",
"salt",
",",
"self",
"::",
"$",
"iterations",
",",
"self",
"::",
"$",
"hash_byte_size",
",",
"true",
")",
")",
";",
"}"
] | Creates the password hash that you would store for comparison.
Make sure to check the size of the output when creating database tables
to store this hash. The defaults produce a 94 char string. Changing the
public static properties may affect the size of the hash returned.
@param string $password
@return string The hash
<code>
$hash = \sb\Password\Hash::create('password');
</code> | [
"Creates",
"the",
"password",
"hash",
"that",
"you",
"would",
"store",
"for",
"comparison",
".",
"Make",
"sure",
"to",
"check",
"the",
"size",
"of",
"the",
"output",
"when",
"creating",
"database",
"tables",
"to",
"store",
"this",
"hash",
".",
"The",
"defaults",
"produce",
"a",
"94",
"char",
"string",
".",
"Changing",
"the",
"public",
"static",
"properties",
"may",
"affect",
"the",
"size",
"of",
"the",
"hash",
"returned",
"."
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Password/Hash.php#L112-L129 |
surebert/surebert-framework | src/sb/Password/Hash.php | Hash.validate | public static function validate($password, $hash) {
$params = explode(":", $hash);
if (count($params) < 4)
return false;
$pbkdf2 = base64_decode($params[self::$hash_pbkdf2_index]);
return self::slowEquals(
$pbkdf2, self::calculate(
$params[self::$hash_alogrithm_index], $password, $params[self::$hash_salt_index], (int) $params[self::$hash_iteration_index], strlen($pbkdf2), true
)
);
} | php | public static function validate($password, $hash) {
$params = explode(":", $hash);
if (count($params) < 4)
return false;
$pbkdf2 = base64_decode($params[self::$hash_pbkdf2_index]);
return self::slowEquals(
$pbkdf2, self::calculate(
$params[self::$hash_alogrithm_index], $password, $params[self::$hash_salt_index], (int) $params[self::$hash_iteration_index], strlen($pbkdf2), true
)
);
} | [
"public",
"static",
"function",
"validate",
"(",
"$",
"password",
",",
"$",
"hash",
")",
"{",
"$",
"params",
"=",
"explode",
"(",
"\":\"",
",",
"$",
"hash",
")",
";",
"if",
"(",
"count",
"(",
"$",
"params",
")",
"<",
"4",
")",
"return",
"false",
";",
"$",
"pbkdf2",
"=",
"base64_decode",
"(",
"$",
"params",
"[",
"self",
"::",
"$",
"hash_pbkdf2_index",
"]",
")",
";",
"return",
"self",
"::",
"slowEquals",
"(",
"$",
"pbkdf2",
",",
"self",
"::",
"calculate",
"(",
"$",
"params",
"[",
"self",
"::",
"$",
"hash_alogrithm_index",
"]",
",",
"$",
"password",
",",
"$",
"params",
"[",
"self",
"::",
"$",
"hash_salt_index",
"]",
",",
"(",
"int",
")",
"$",
"params",
"[",
"self",
"::",
"$",
"hash_iteration_index",
"]",
",",
"strlen",
"(",
"$",
"pbkdf2",
")",
",",
"true",
")",
")",
";",
"}"
] | Validates a password against its precalculated hash
@param string $password
@param string $hash
@return boolean
<code>
$bool = \sb\Password\Hash::validate('password', $hash_from_create);
</code> | [
"Validates",
"a",
"password",
"against",
"its",
"precalculated",
"hash"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Password/Hash.php#L140-L150 |
kenphp/ken | src/Helpers/Input.php | Input.get | public static function get($name = null, $default = null)
{
$queryParams = app()->request->getQueryParams();
if (is_null($name)) {
return $queryParams;
} elseif (isset($queryParams[$name])) {
return $queryParams[$name];
}
return $default;
} | php | public static function get($name = null, $default = null)
{
$queryParams = app()->request->getQueryParams();
if (is_null($name)) {
return $queryParams;
} elseif (isset($queryParams[$name])) {
return $queryParams[$name];
}
return $default;
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"name",
"=",
"null",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"queryParams",
"=",
"app",
"(",
")",
"->",
"request",
"->",
"getQueryParams",
"(",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"name",
")",
")",
"{",
"return",
"$",
"queryParams",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"queryParams",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"queryParams",
"[",
"$",
"name",
"]",
";",
"}",
"return",
"$",
"default",
";",
"}"
] | Retrieves GET parameter.
@param string $name Name of GET parameter, if null then all parameter will be returned
@param mixed $default Default value returned if *$name* is not null but does not exist in GET query parameters
@return mixed | [
"Retrieves",
"GET",
"parameter",
"."
] | train | https://github.com/kenphp/ken/blob/c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb/src/Helpers/Input.php#L17-L28 |
kenphp/ken | src/Helpers/Input.php | Input.delete | public static function delete($name = null, $default = null)
{
$parsedBody = app()->request->getParsedBody();
if (is_null($name)) {
return $parsedBody;
}
if (isset($parsedBody[$name])) {
return $parsedBody[$name];
}
return $default;
} | php | public static function delete($name = null, $default = null)
{
$parsedBody = app()->request->getParsedBody();
if (is_null($name)) {
return $parsedBody;
}
if (isset($parsedBody[$name])) {
return $parsedBody[$name];
}
return $default;
} | [
"public",
"static",
"function",
"delete",
"(",
"$",
"name",
"=",
"null",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"parsedBody",
"=",
"app",
"(",
")",
"->",
"request",
"->",
"getParsedBody",
"(",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"name",
")",
")",
"{",
"return",
"$",
"parsedBody",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"parsedBody",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"parsedBody",
"[",
"$",
"name",
"]",
";",
"}",
"return",
"$",
"default",
";",
"}"
] | Retrieves DELETE parameter.
@param string $name Name of DELETE parameter, if null then all parameter will be returned
@param mixed $default Default value returned if *$name* is not null but does not exist in DELETE request
@return mixed | [
"Retrieves",
"DELETE",
"parameter",
"."
] | train | https://github.com/kenphp/ken/blob/c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb/src/Helpers/Input.php#L61-L74 |
kenphp/ken | src/Helpers/Input.php | Input.files | public static function files($name = null)
{
$files = app()->request->getUploadedFiles();
if (is_null($name)) {
return $files;
}
if (isset($files[$name])) {
return $files[$name];
}
return null;
} | php | public static function files($name = null)
{
$files = app()->request->getUploadedFiles();
if (is_null($name)) {
return $files;
}
if (isset($files[$name])) {
return $files[$name];
}
return null;
} | [
"public",
"static",
"function",
"files",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"files",
"=",
"app",
"(",
")",
"->",
"request",
"->",
"getUploadedFiles",
"(",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"name",
")",
")",
"{",
"return",
"$",
"files",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"files",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"files",
"[",
"$",
"name",
"]",
";",
"}",
"return",
"null",
";",
"}"
] | Retrieves Uploaded Files.
@param string $name Name of Uploaded Files parameter, if null then all value will be returned
@return \Psr\Http\Message\UploadedFileInterface|array|null | [
"Retrieves",
"Uploaded",
"Files",
"."
] | train | https://github.com/kenphp/ken/blob/c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb/src/Helpers/Input.php#L106-L119 |
petrica/php-statsd-system | Command/NotifyCommand.php | NotifyCommand.getStatsd | protected function getStatsd(InputInterface $input)
{
if (null === $this->statsd) {
$this->statsdConnection = new UdpSocket(
$input->getOption('statsd-host'),
$input->getOption('statsd-port')
);
$this->statsd = new Client(
$this->statsdConnection,
$input->getOption('statsd-namespace')
);
}
return $this->statsd;
} | php | protected function getStatsd(InputInterface $input)
{
if (null === $this->statsd) {
$this->statsdConnection = new UdpSocket(
$input->getOption('statsd-host'),
$input->getOption('statsd-port')
);
$this->statsd = new Client(
$this->statsdConnection,
$input->getOption('statsd-namespace')
);
}
return $this->statsd;
} | [
"protected",
"function",
"getStatsd",
"(",
"InputInterface",
"$",
"input",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"statsd",
")",
"{",
"$",
"this",
"->",
"statsdConnection",
"=",
"new",
"UdpSocket",
"(",
"$",
"input",
"->",
"getOption",
"(",
"'statsd-host'",
")",
",",
"$",
"input",
"->",
"getOption",
"(",
"'statsd-port'",
")",
")",
";",
"$",
"this",
"->",
"statsd",
"=",
"new",
"Client",
"(",
"$",
"this",
"->",
"statsdConnection",
",",
"$",
"input",
"->",
"getOption",
"(",
"'statsd-namespace'",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"statsd",
";",
"}"
] | Statically cache statsd client and return a statsd client
@param InputInterface $input
@return Client | [
"Statically",
"cache",
"statsd",
"client",
"and",
"return",
"a",
"statsd",
"client"
] | train | https://github.com/petrica/php-statsd-system/blob/c476be3514a631a605737888bb8f6eb096789c9d/Command/NotifyCommand.php#L134-L148 |
petrica/php-statsd-system | Command/NotifyCommand.php | NotifyCommand.getGauges | protected function getGauges($config)
{
if (null === $this->gauges) {
$this->gauges = array();
foreach ($config as $path => $details) {
$className = $details['class'];
if (class_exists($className)) {
$reflection = new \ReflectionClass($className);
if ($reflection->getConstructor()) {
$this->gauges[$path] = $reflection->newInstanceArgs(
$details['arguments'] ? $details['arguments'] : array());
}
else {
$this->gauges[$path] = $reflection->newInstance();
}
}
else {
throw new \RuntimeException(sprintf(
'Class does not exists %s'
), $className);
}
}
if (empty($this->gauges)) {
throw new \RuntimeException(
sprintf('No gauges found for provided string %s', $input->getArgument('gauges-class'))
);
}
}
return $this->gauges;
} | php | protected function getGauges($config)
{
if (null === $this->gauges) {
$this->gauges = array();
foreach ($config as $path => $details) {
$className = $details['class'];
if (class_exists($className)) {
$reflection = new \ReflectionClass($className);
if ($reflection->getConstructor()) {
$this->gauges[$path] = $reflection->newInstanceArgs(
$details['arguments'] ? $details['arguments'] : array());
}
else {
$this->gauges[$path] = $reflection->newInstance();
}
}
else {
throw new \RuntimeException(sprintf(
'Class does not exists %s'
), $className);
}
}
if (empty($this->gauges)) {
throw new \RuntimeException(
sprintf('No gauges found for provided string %s', $input->getArgument('gauges-class'))
);
}
}
return $this->gauges;
} | [
"protected",
"function",
"getGauges",
"(",
"$",
"config",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"gauges",
")",
"{",
"$",
"this",
"->",
"gauges",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"config",
"as",
"$",
"path",
"=>",
"$",
"details",
")",
"{",
"$",
"className",
"=",
"$",
"details",
"[",
"'class'",
"]",
";",
"if",
"(",
"class_exists",
"(",
"$",
"className",
")",
")",
"{",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"className",
")",
";",
"if",
"(",
"$",
"reflection",
"->",
"getConstructor",
"(",
")",
")",
"{",
"$",
"this",
"->",
"gauges",
"[",
"$",
"path",
"]",
"=",
"$",
"reflection",
"->",
"newInstanceArgs",
"(",
"$",
"details",
"[",
"'arguments'",
"]",
"?",
"$",
"details",
"[",
"'arguments'",
"]",
":",
"array",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"gauges",
"[",
"$",
"path",
"]",
"=",
"$",
"reflection",
"->",
"newInstance",
"(",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Class does not exists %s'",
")",
",",
"$",
"className",
")",
";",
"}",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"gauges",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'No gauges found for provided string %s'",
",",
"$",
"input",
"->",
"getArgument",
"(",
"'gauges-class'",
")",
")",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"gauges",
";",
"}"
] | Instantiate selected gauges
@param array $config
@return GaugeInterface[] array | [
"Instantiate",
"selected",
"gauges"
] | train | https://github.com/petrica/php-statsd-system/blob/c476be3514a631a605737888bb8f6eb096789c9d/Command/NotifyCommand.php#L166-L199 |
ClementIV/yii-rest-rbac2.0 | controllers/RuleController.php | RuleController.actionIndex | public function actionIndex()
{
$request = \Yii::$app->request;
if ($request->getIsOptions()) {
return $this->ResponseOptions($this->verbs()['index']);
}
try{
$searchModel = new BizRuleSearch();
$dataProvider = $searchModel->search(Yii::$app->request->getQueryParams());
//var_dump($dataProvider);die();
return $dataProvider;
}catch(Exception $e){
throw new Exception($e);
}
} | php | public function actionIndex()
{
$request = \Yii::$app->request;
if ($request->getIsOptions()) {
return $this->ResponseOptions($this->verbs()['index']);
}
try{
$searchModel = new BizRuleSearch();
$dataProvider = $searchModel->search(Yii::$app->request->getQueryParams());
//var_dump($dataProvider);die();
return $dataProvider;
}catch(Exception $e){
throw new Exception($e);
}
} | [
"public",
"function",
"actionIndex",
"(",
")",
"{",
"$",
"request",
"=",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"request",
";",
"if",
"(",
"$",
"request",
"->",
"getIsOptions",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"ResponseOptions",
"(",
"$",
"this",
"->",
"verbs",
"(",
")",
"[",
"'index'",
"]",
")",
";",
"}",
"try",
"{",
"$",
"searchModel",
"=",
"new",
"BizRuleSearch",
"(",
")",
";",
"$",
"dataProvider",
"=",
"$",
"searchModel",
"->",
"search",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"getQueryParams",
"(",
")",
")",
";",
"//var_dump($dataProvider);die();",
"return",
"$",
"dataProvider",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"e",
")",
";",
"}",
"}"
] | Lists all AuthItem models.
@return mixed | [
"Lists",
"all",
"AuthItem",
"models",
"."
] | train | https://github.com/ClementIV/yii-rest-rbac2.0/blob/435ffceca8d51b4d369182db3a06c20f336e9ac4/controllers/RuleController.php#L52-L67 |
ClementIV/yii-rest-rbac2.0 | controllers/RuleController.php | RuleController.actionView | public function actionView($id)
{
try{
$request = \Yii::$app->request;
if ($request->getIsOptions()) {
return $this->ResponseOptions($this->verbs()['view']);
}
$model = $this->findModel($id);
if($model!=null){
$result= ['success'=>true,'rules'=>$model];
} else {
$result= ['success'=>false,'message'=>'没有对应规则'];
}
return $result;
}catch(Exception $e){
throw new Exception($e);
}
//return $this->render('view', ['model' => $model]);
} | php | public function actionView($id)
{
try{
$request = \Yii::$app->request;
if ($request->getIsOptions()) {
return $this->ResponseOptions($this->verbs()['view']);
}
$model = $this->findModel($id);
if($model!=null){
$result= ['success'=>true,'rules'=>$model];
} else {
$result= ['success'=>false,'message'=>'没有对应规则'];
}
return $result;
}catch(Exception $e){
throw new Exception($e);
}
//return $this->render('view', ['model' => $model]);
} | [
"public",
"function",
"actionView",
"(",
"$",
"id",
")",
"{",
"try",
"{",
"$",
"request",
"=",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"request",
";",
"if",
"(",
"$",
"request",
"->",
"getIsOptions",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"ResponseOptions",
"(",
"$",
"this",
"->",
"verbs",
"(",
")",
"[",
"'view'",
"]",
")",
";",
"}",
"$",
"model",
"=",
"$",
"this",
"->",
"findModel",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"model",
"!=",
"null",
")",
"{",
"$",
"result",
"=",
"[",
"'success'",
"=>",
"true",
",",
"'rules'",
"=>",
"$",
"model",
"]",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"[",
"'success'",
"=>",
"false",
",",
"'message'",
"=>",
"'没有对应规则'];",
"",
"",
"}",
"return",
"$",
"result",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"e",
")",
";",
"}",
"//return $this->render('view', ['model' => $model]);",
"}"
] | Displays a single AuthItem model.
@param string $id
@return mixed | [
"Displays",
"a",
"single",
"AuthItem",
"model",
"."
] | train | https://github.com/ClementIV/yii-rest-rbac2.0/blob/435ffceca8d51b4d369182db3a06c20f336e9ac4/controllers/RuleController.php#L74-L94 |
ClementIV/yii-rest-rbac2.0 | controllers/RuleController.php | RuleController.actionCheckname | public function actionCheckname(){
$request = \Yii::$app->request;
if ($request->getIsOptions()) {
return $this->ResponseOptions($this->verbs()['checkname']);
}
$model = new BizRule(null);
$mo =$model->find(Yii::$app->request->post()['BizRule']['name']);
if($mo==null){
return ['message'=>true];
}else{
return ['message'=>false];
}
} | php | public function actionCheckname(){
$request = \Yii::$app->request;
if ($request->getIsOptions()) {
return $this->ResponseOptions($this->verbs()['checkname']);
}
$model = new BizRule(null);
$mo =$model->find(Yii::$app->request->post()['BizRule']['name']);
if($mo==null){
return ['message'=>true];
}else{
return ['message'=>false];
}
} | [
"public",
"function",
"actionCheckname",
"(",
")",
"{",
"$",
"request",
"=",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"request",
";",
"if",
"(",
"$",
"request",
"->",
"getIsOptions",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"ResponseOptions",
"(",
"$",
"this",
"->",
"verbs",
"(",
")",
"[",
"'checkname'",
"]",
")",
";",
"}",
"$",
"model",
"=",
"new",
"BizRule",
"(",
"null",
")",
";",
"$",
"mo",
"=",
"$",
"model",
"->",
"find",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
"[",
"'BizRule'",
"]",
"[",
"'name'",
"]",
")",
";",
"if",
"(",
"$",
"mo",
"==",
"null",
")",
"{",
"return",
"[",
"'message'",
"=>",
"true",
"]",
";",
"}",
"else",
"{",
"return",
"[",
"'message'",
"=>",
"false",
"]",
";",
"}",
"}"
] | check is a new item
@return boolan | [
"check",
"is",
"a",
"new",
"item"
] | train | https://github.com/ClementIV/yii-rest-rbac2.0/blob/435ffceca8d51b4d369182db3a06c20f336e9ac4/controllers/RuleController.php#L99-L112 |
ClementIV/yii-rest-rbac2.0 | controllers/RuleController.php | RuleController.actionCreate | public function actionCreate()
{
$request = \Yii::$app->request;
if ($request->getIsOptions()) {
return $this->ResponseOptions($this->verbs()['create']);
}
try
{
$model = new BizRule(null);
if(!array_key_exists('BizRule', Yii::$app->request->post())){
return ['success'=>false,'message'=>'参数错误!'];
}
$mo =$model->find(Yii::$app->request->post()['BizRule']['name']);
if($mo==null){
if ($model->load(Yii::$app->request->post()) ) {
$classExists = $model->classExists();
if($classExists==$model::RIGHTCLASS){
$model->save();
$result=['success'=>true,'message'=>'规则已成功添加!'];
return $result;
}else{
return ['success'=>false,'message'=>'规则类不存在!'];
}
} else {
return ['success'=>false,'message'=>'参数错误!'];
}
}else{
return ['success'=>false,'message'=>'规则已存在!'];
}
}catch(Exception $e){
throw new \yii\web\ServerErrorHttpException();
}
} | php | public function actionCreate()
{
$request = \Yii::$app->request;
if ($request->getIsOptions()) {
return $this->ResponseOptions($this->verbs()['create']);
}
try
{
$model = new BizRule(null);
if(!array_key_exists('BizRule', Yii::$app->request->post())){
return ['success'=>false,'message'=>'参数错误!'];
}
$mo =$model->find(Yii::$app->request->post()['BizRule']['name']);
if($mo==null){
if ($model->load(Yii::$app->request->post()) ) {
$classExists = $model->classExists();
if($classExists==$model::RIGHTCLASS){
$model->save();
$result=['success'=>true,'message'=>'规则已成功添加!'];
return $result;
}else{
return ['success'=>false,'message'=>'规则类不存在!'];
}
} else {
return ['success'=>false,'message'=>'参数错误!'];
}
}else{
return ['success'=>false,'message'=>'规则已存在!'];
}
}catch(Exception $e){
throw new \yii\web\ServerErrorHttpException();
}
} | [
"public",
"function",
"actionCreate",
"(",
")",
"{",
"$",
"request",
"=",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"request",
";",
"if",
"(",
"$",
"request",
"->",
"getIsOptions",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"ResponseOptions",
"(",
"$",
"this",
"->",
"verbs",
"(",
")",
"[",
"'create'",
"]",
")",
";",
"}",
"try",
"{",
"$",
"model",
"=",
"new",
"BizRule",
"(",
"null",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"'BizRule'",
",",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
")",
")",
"{",
"return",
"[",
"'success'",
"=>",
"false",
",",
"'message'",
"=>",
"'参数错误!'];",
"",
"",
"}",
"$",
"mo",
"=",
"$",
"model",
"->",
"find",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
"[",
"'BizRule'",
"]",
"[",
"'name'",
"]",
")",
";",
"if",
"(",
"$",
"mo",
"==",
"null",
")",
"{",
"if",
"(",
"$",
"model",
"->",
"load",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
")",
")",
"{",
"$",
"classExists",
"=",
"$",
"model",
"->",
"classExists",
"(",
")",
";",
"if",
"(",
"$",
"classExists",
"==",
"$",
"model",
"::",
"RIGHTCLASS",
")",
"{",
"$",
"model",
"->",
"save",
"(",
")",
";",
"$",
"result",
"=",
"[",
"'success'",
"=>",
"true",
",",
"'message'",
"=>",
"'规则已成功添加!'];",
"",
"",
"return",
"$",
"result",
";",
"}",
"else",
"{",
"return",
"[",
"'success'",
"=>",
"false",
",",
"'message'",
"=>",
"'规则类不存在!'];",
"",
"",
"}",
"}",
"else",
"{",
"return",
"[",
"'success'",
"=>",
"false",
",",
"'message'",
"=>",
"'参数错误!'];",
"",
"",
"}",
"}",
"else",
"{",
"return",
"[",
"'success'",
"=>",
"false",
",",
"'message'",
"=>",
"'规则已存在!'];",
"",
"",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"\\",
"yii",
"\\",
"web",
"\\",
"ServerErrorHttpException",
"(",
")",
";",
"}",
"}"
] | Creates a new AuthItem model.
If creation is successful, the browser will be redirected to the 'view' page.
@return mixed | [
"Creates",
"a",
"new",
"AuthItem",
"model",
".",
"If",
"creation",
"is",
"successful",
"the",
"browser",
"will",
"be",
"redirected",
"to",
"the",
"view",
"page",
"."
] | train | https://github.com/ClementIV/yii-rest-rbac2.0/blob/435ffceca8d51b4d369182db3a06c20f336e9ac4/controllers/RuleController.php#L135-L171 |
ClementIV/yii-rest-rbac2.0 | controllers/RuleController.php | RuleController.actionUpdate | public function actionUpdate($id)
{
$request = \Yii::$app->request;
if ($request->getIsOptions()) {
return $this->ResponseOptions($this->verbs()['update']);
}
if($model = $this->findModel($id)){
//($model->save());die();
if ($model->load(Yii::$app->request->post())&& $model->save()) {
//Helper::invalidate();
return ['success'=>true];
}else {
throw new \yii\web\ServerErrorHttpException();
}
}
throw new \yii\web\ServerErrorHttpException();
} | php | public function actionUpdate($id)
{
$request = \Yii::$app->request;
if ($request->getIsOptions()) {
return $this->ResponseOptions($this->verbs()['update']);
}
if($model = $this->findModel($id)){
//($model->save());die();
if ($model->load(Yii::$app->request->post())&& $model->save()) {
//Helper::invalidate();
return ['success'=>true];
}else {
throw new \yii\web\ServerErrorHttpException();
}
}
throw new \yii\web\ServerErrorHttpException();
} | [
"public",
"function",
"actionUpdate",
"(",
"$",
"id",
")",
"{",
"$",
"request",
"=",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"request",
";",
"if",
"(",
"$",
"request",
"->",
"getIsOptions",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"ResponseOptions",
"(",
"$",
"this",
"->",
"verbs",
"(",
")",
"[",
"'update'",
"]",
")",
";",
"}",
"if",
"(",
"$",
"model",
"=",
"$",
"this",
"->",
"findModel",
"(",
"$",
"id",
")",
")",
"{",
"//($model->save());die();",
"if",
"(",
"$",
"model",
"->",
"load",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
")",
"&&",
"$",
"model",
"->",
"save",
"(",
")",
")",
"{",
"//Helper::invalidate();",
"return",
"[",
"'success'",
"=>",
"true",
"]",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"yii",
"\\",
"web",
"\\",
"ServerErrorHttpException",
"(",
")",
";",
"}",
"}",
"throw",
"new",
"\\",
"yii",
"\\",
"web",
"\\",
"ServerErrorHttpException",
"(",
")",
";",
"}"
] | Updates an existing AuthItem model.
If update is successful, the browser will be redirected to the 'view' page.
@param string $id
@return mixed | [
"Updates",
"an",
"existing",
"AuthItem",
"model",
".",
"If",
"update",
"is",
"successful",
"the",
"browser",
"will",
"be",
"redirected",
"to",
"the",
"view",
"page",
"."
] | train | https://github.com/ClementIV/yii-rest-rbac2.0/blob/435ffceca8d51b4d369182db3a06c20f336e9ac4/controllers/RuleController.php#L179-L196 |
ClementIV/yii-rest-rbac2.0 | controllers/RuleController.php | RuleController.actionDelete | public function actionDelete($id)
{
$request = \Yii::$app->request;
if ($request->getIsOptions()) {
return $this->ResponseOptions($this->verbs()['delete']);
}
try{
$model = $this->findModel($id);
Configs::authManager()->remove($model->item);
Helper::invalidate();
}catch (Exception $e){
throw new Exception($e);
}
return ['success'=>true];
} | php | public function actionDelete($id)
{
$request = \Yii::$app->request;
if ($request->getIsOptions()) {
return $this->ResponseOptions($this->verbs()['delete']);
}
try{
$model = $this->findModel($id);
Configs::authManager()->remove($model->item);
Helper::invalidate();
}catch (Exception $e){
throw new Exception($e);
}
return ['success'=>true];
} | [
"public",
"function",
"actionDelete",
"(",
"$",
"id",
")",
"{",
"$",
"request",
"=",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"request",
";",
"if",
"(",
"$",
"request",
"->",
"getIsOptions",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"ResponseOptions",
"(",
"$",
"this",
"->",
"verbs",
"(",
")",
"[",
"'delete'",
"]",
")",
";",
"}",
"try",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"findModel",
"(",
"$",
"id",
")",
";",
"Configs",
"::",
"authManager",
"(",
")",
"->",
"remove",
"(",
"$",
"model",
"->",
"item",
")",
";",
"Helper",
"::",
"invalidate",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"e",
")",
";",
"}",
"return",
"[",
"'success'",
"=>",
"true",
"]",
";",
"}"
] | Deletes an existing AuthItem model.
If deletion is successful, the browser will be redirected to the 'index' page.
@param string $id
@return mixed | [
"Deletes",
"an",
"existing",
"AuthItem",
"model",
".",
"If",
"deletion",
"is",
"successful",
"the",
"browser",
"will",
"be",
"redirected",
"to",
"the",
"index",
"page",
"."
] | train | https://github.com/ClementIV/yii-rest-rbac2.0/blob/435ffceca8d51b4d369182db3a06c20f336e9ac4/controllers/RuleController.php#L204-L221 |
NuclearCMS/Hierarchy | src/Support/TokenManager.php | TokenManager.setToken | public function setToken($key, $value, $duration = 60)
{
$this->cache->put('reactor.tokens.' . $key, $value, $duration);
} | php | public function setToken($key, $value, $duration = 60)
{
$this->cache->put('reactor.tokens.' . $key, $value, $duration);
} | [
"public",
"function",
"setToken",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"duration",
"=",
"60",
")",
"{",
"$",
"this",
"->",
"cache",
"->",
"put",
"(",
"'reactor.tokens.'",
".",
"$",
"key",
",",
"$",
"value",
",",
"$",
"duration",
")",
";",
"}"
] | Setter for token
@param string $key
@param string $value
@param int $duration | [
"Setter",
"for",
"token"
] | train | https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Support/TokenManager.php#L47-L50 |
NuclearCMS/Hierarchy | src/Support/TokenManager.php | TokenManager.makeNewToken | public function makeNewToken($key, $duration = 60)
{
$token = str_random(32);
$this->setToken($key, $token, $duration);
return $token;
} | php | public function makeNewToken($key, $duration = 60)
{
$token = str_random(32);
$this->setToken($key, $token, $duration);
return $token;
} | [
"public",
"function",
"makeNewToken",
"(",
"$",
"key",
",",
"$",
"duration",
"=",
"60",
")",
"{",
"$",
"token",
"=",
"str_random",
"(",
"32",
")",
";",
"$",
"this",
"->",
"setToken",
"(",
"$",
"key",
",",
"$",
"token",
",",
"$",
"duration",
")",
";",
"return",
"$",
"token",
";",
"}"
] | Creates a new token and returns it
@param string $key
@param int $duration
@return string | [
"Creates",
"a",
"new",
"token",
"and",
"returns",
"it"
] | train | https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Support/TokenManager.php#L59-L66 |
NuclearCMS/Hierarchy | src/Support/TokenManager.php | TokenManager.requestHasToken | public function requestHasToken($key)
{
$token = $this->request->input($key, null);
if($token && $token === $this->getToken($key))
{
return true;
}
return false;
} | php | public function requestHasToken($key)
{
$token = $this->request->input($key, null);
if($token && $token === $this->getToken($key))
{
return true;
}
return false;
} | [
"public",
"function",
"requestHasToken",
"(",
"$",
"key",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"request",
"->",
"input",
"(",
"$",
"key",
",",
"null",
")",
";",
"if",
"(",
"$",
"token",
"&&",
"$",
"token",
"===",
"$",
"this",
"->",
"getToken",
"(",
"$",
"key",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Checks if the request has the token
@param string $key
@return bool | [
"Checks",
"if",
"the",
"request",
"has",
"the",
"token"
] | train | https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Support/TokenManager.php#L74-L84 |
mvccore/ext-router-module | src/MvcCore/Ext/Routers/Module/RouteMethods.php | RouteMethods.& | public function & SetDomainRoutes ($routes = [], $autoInitialize = TRUE) {
/** @var $this \MvcCore\Ext\Routers\Module */
if ($autoInitialize) {
$this->domainRoutes = [];
$this->AddDomainRoutes($routes);
} else {
$newRoutes = [];
foreach ($routes as $route)
$newRoutes[$route->GetModule()] = $route;
$this->domainRoutes = $newRoutes;
}
return $this;
} | php | public function & SetDomainRoutes ($routes = [], $autoInitialize = TRUE) {
/** @var $this \MvcCore\Ext\Routers\Module */
if ($autoInitialize) {
$this->domainRoutes = [];
$this->AddDomainRoutes($routes);
} else {
$newRoutes = [];
foreach ($routes as $route)
$newRoutes[$route->GetModule()] = $route;
$this->domainRoutes = $newRoutes;
}
return $this;
} | [
"public",
"function",
"&",
"SetDomainRoutes",
"(",
"$",
"routes",
"=",
"[",
"]",
",",
"$",
"autoInitialize",
"=",
"TRUE",
")",
"{",
"/** @var $this \\MvcCore\\Ext\\Routers\\Module */",
"if",
"(",
"$",
"autoInitialize",
")",
"{",
"$",
"this",
"->",
"domainRoutes",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"AddDomainRoutes",
"(",
"$",
"routes",
")",
";",
"}",
"else",
"{",
"$",
"newRoutes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"routes",
"as",
"$",
"route",
")",
"$",
"newRoutes",
"[",
"$",
"route",
"->",
"GetModule",
"(",
")",
"]",
"=",
"$",
"route",
";",
"$",
"this",
"->",
"domainRoutes",
"=",
"$",
"newRoutes",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Clear all possible previously configured module domain routes and set new
given routes again collection again. If there is no module property
configured in given route item in array configuration, route module is set
by given `$routes` array key, if key is not numeric.
Routes could be defined in various forms:
Example:
`\MvcCore\Router::GetInstance()->SetDomainRoutes([
"blog" => [
"pattern" => "//blog.%sld%.%tld%",
"namespace" => "Blog",
"defaults" => ["page" => 1],
"constraints" => ["page" => "\d+"],
"allowedLocalizations" => ["en-US"],
"allowedMediaVersions" => ["full" => ""]
],
"main" => [
"pattern" => "//%domain%",
"allowedLocalizations" => ["en-US", "de-DE"],
"allowedMediaVersions" => ["mobile" => "m", "full" => ""]
]
]);`
or:
`\MvcCore\Router::GetInstance()->SetDomainRoutes([
new \MvcCore\Ext\Routers\Modules\Route(
"//blog.%sld%.%tld%", // pattern
"blog", // module
"Blog", // namespace
["page" => 1], // defaults
["page" => "\d+"], // constraints
[ // advanced configuration
"allowedLocalizations" => ["en-US"],
"allowedMediaVersions" => ["full" => ""]
]
),
new \MvcCore\Ext\Routers\Modules\Route([
"pattern" => "//%domain%",
"module" => "main",
"allowedLocalizations" => ["en-US", "de-DE"],
"allowedMediaVersions" => ["mobile" => "m", "full" => ""]
])
]);`
@param \MvcCore\Ext\Routers\Modules\Route[]|\MvcCore\Ext\Routers\Modules\IRoute[]|array|array[] $routes
@param bool $autoInitialize
@throws \InvalidArgumentException
@return \MvcCore\Ext\Routers\Module|\MvcCore\Ext\Routers\IModule | [
"Clear",
"all",
"possible",
"previously",
"configured",
"module",
"domain",
"routes",
"and",
"set",
"new",
"given",
"routes",
"again",
"collection",
"again",
".",
"If",
"there",
"is",
"no",
"module",
"property",
"configured",
"in",
"given",
"route",
"item",
"in",
"array",
"configuration",
"route",
"module",
"is",
"set",
"by",
"given",
"$routes",
"array",
"key",
"if",
"key",
"is",
"not",
"numeric",
"."
] | train | https://github.com/mvccore/ext-router-module/blob/7695784a451db86cca6a43c98d076803cd0a50a7/src/MvcCore/Ext/Routers/Module/RouteMethods.php#L66-L78 |
mvccore/ext-router-module | src/MvcCore/Ext/Routers/Module/RouteMethods.php | RouteMethods.& | public function & AddDomainRoutes ($routes, $prepend = FALSE, $throwExceptionForDuplication = TRUE) {
/** @var $this \MvcCore\Ext\Routers\Module */
if ($prepend) $routes = array_reverse($routes);
$routeClass = static::$routeClass;
foreach ($routes as $key => $route) {
$numericKey = is_numeric($key);
if ($route instanceof \MvcCore\Ext\Routers\Modules\IRoute) {
if ($numericKey) {
$routeModule = $route->GetModule();
if ($routeModule === NULL) {
$selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__;
throw new \InvalidArgumentException(
"[".$selfClass."] Domain route cannot be configured without module "
."record or without alphanumeric key in given routes collection."
);
}
}
$this->AddDomainRoute(
$route, $prepend, $throwExceptionForDuplication
);
} else {
if ($numericKey) {
$selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__;
throw new \InvalidArgumentException(
"[".$selfClass."] Domain route cannot be configured without "
."alphanumeric key (representing module) in given routes collection."
);
}
if (is_array($route)) {
if (!isset($route['module'])) $route['module'] = $key;
$this->AddDomainRoute(
$this->getRouteDomainInstance($route),
$prepend, $throwExceptionForDuplication
);
} else if (is_string($route)) {
$routeCfgData = [
'pattern' => $route,
'module' => $key,
];
$this->AddDomainRoute(
$routeClass::CreateInstance($routeCfgData),
$prepend, $throwExceptionForDuplication
);
} else {
$selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__;
throw new \InvalidArgumentException (
"[".$selfClass."] Route is not possible to assign "
."(key: \"$key\", value: " . serialize($route) . ")."
);
}
}
}
return $this;
} | php | public function & AddDomainRoutes ($routes, $prepend = FALSE, $throwExceptionForDuplication = TRUE) {
/** @var $this \MvcCore\Ext\Routers\Module */
if ($prepend) $routes = array_reverse($routes);
$routeClass = static::$routeClass;
foreach ($routes as $key => $route) {
$numericKey = is_numeric($key);
if ($route instanceof \MvcCore\Ext\Routers\Modules\IRoute) {
if ($numericKey) {
$routeModule = $route->GetModule();
if ($routeModule === NULL) {
$selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__;
throw new \InvalidArgumentException(
"[".$selfClass."] Domain route cannot be configured without module "
."record or without alphanumeric key in given routes collection."
);
}
}
$this->AddDomainRoute(
$route, $prepend, $throwExceptionForDuplication
);
} else {
if ($numericKey) {
$selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__;
throw new \InvalidArgumentException(
"[".$selfClass."] Domain route cannot be configured without "
."alphanumeric key (representing module) in given routes collection."
);
}
if (is_array($route)) {
if (!isset($route['module'])) $route['module'] = $key;
$this->AddDomainRoute(
$this->getRouteDomainInstance($route),
$prepend, $throwExceptionForDuplication
);
} else if (is_string($route)) {
$routeCfgData = [
'pattern' => $route,
'module' => $key,
];
$this->AddDomainRoute(
$routeClass::CreateInstance($routeCfgData),
$prepend, $throwExceptionForDuplication
);
} else {
$selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__;
throw new \InvalidArgumentException (
"[".$selfClass."] Route is not possible to assign "
."(key: \"$key\", value: " . serialize($route) . ")."
);
}
}
}
return $this;
} | [
"public",
"function",
"&",
"AddDomainRoutes",
"(",
"$",
"routes",
",",
"$",
"prepend",
"=",
"FALSE",
",",
"$",
"throwExceptionForDuplication",
"=",
"TRUE",
")",
"{",
"/** @var $this \\MvcCore\\Ext\\Routers\\Module */",
"if",
"(",
"$",
"prepend",
")",
"$",
"routes",
"=",
"array_reverse",
"(",
"$",
"routes",
")",
";",
"$",
"routeClass",
"=",
"static",
"::",
"$",
"routeClass",
";",
"foreach",
"(",
"$",
"routes",
"as",
"$",
"key",
"=>",
"$",
"route",
")",
"{",
"$",
"numericKey",
"=",
"is_numeric",
"(",
"$",
"key",
")",
";",
"if",
"(",
"$",
"route",
"instanceof",
"\\",
"MvcCore",
"\\",
"Ext",
"\\",
"Routers",
"\\",
"Modules",
"\\",
"IRoute",
")",
"{",
"if",
"(",
"$",
"numericKey",
")",
"{",
"$",
"routeModule",
"=",
"$",
"route",
"->",
"GetModule",
"(",
")",
";",
"if",
"(",
"$",
"routeModule",
"===",
"NULL",
")",
"{",
"$",
"selfClass",
"=",
"version_compare",
"(",
"PHP_VERSION",
",",
"'5.5'",
",",
"'>'",
")",
"?",
"self",
"::",
"class",
":",
"__CLASS__",
";",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"[\"",
".",
"$",
"selfClass",
".",
"\"] Domain route cannot be configured without module \"",
".",
"\"record or without alphanumeric key in given routes collection.\"",
")",
";",
"}",
"}",
"$",
"this",
"->",
"AddDomainRoute",
"(",
"$",
"route",
",",
"$",
"prepend",
",",
"$",
"throwExceptionForDuplication",
")",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"numericKey",
")",
"{",
"$",
"selfClass",
"=",
"version_compare",
"(",
"PHP_VERSION",
",",
"'5.5'",
",",
"'>'",
")",
"?",
"self",
"::",
"class",
":",
"__CLASS__",
";",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"[\"",
".",
"$",
"selfClass",
".",
"\"] Domain route cannot be configured without \"",
".",
"\"alphanumeric key (representing module) in given routes collection.\"",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"route",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"route",
"[",
"'module'",
"]",
")",
")",
"$",
"route",
"[",
"'module'",
"]",
"=",
"$",
"key",
";",
"$",
"this",
"->",
"AddDomainRoute",
"(",
"$",
"this",
"->",
"getRouteDomainInstance",
"(",
"$",
"route",
")",
",",
"$",
"prepend",
",",
"$",
"throwExceptionForDuplication",
")",
";",
"}",
"else",
"if",
"(",
"is_string",
"(",
"$",
"route",
")",
")",
"{",
"$",
"routeCfgData",
"=",
"[",
"'pattern'",
"=>",
"$",
"route",
",",
"'module'",
"=>",
"$",
"key",
",",
"]",
";",
"$",
"this",
"->",
"AddDomainRoute",
"(",
"$",
"routeClass",
"::",
"CreateInstance",
"(",
"$",
"routeCfgData",
")",
",",
"$",
"prepend",
",",
"$",
"throwExceptionForDuplication",
")",
";",
"}",
"else",
"{",
"$",
"selfClass",
"=",
"version_compare",
"(",
"PHP_VERSION",
",",
"'5.5'",
",",
"'>'",
")",
"?",
"self",
"::",
"class",
":",
"__CLASS__",
";",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"[\"",
".",
"$",
"selfClass",
".",
"\"] Route is not possible to assign \"",
".",
"\"(key: \\\"$key\\\", value: \"",
".",
"serialize",
"(",
"$",
"route",
")",
".",
"\").\"",
")",
";",
"}",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Append or prepend new module domain routes. If there is no module property
configured in given route item in array configuration, route module is set
by given `$routes` array key, if key is not numeric.
Routes could be defined in various forms:
Example:
`\MvcCore\Router::GetInstance()->AddDomainRoutes([
"blog" => [
"pattern" => "//blog.%sld%.%tld%",
"namespace" => "Blog",
"defaults" => ["page" => 1],
"constraints" => ["page" => "\d+"],
"allowedLocalizations" => ["en-US"],
"allowedMediaVersions" => ["full" => ""]
],
"main" => [
"pattern" => "//%domain%",
"allowedLocalizations" => ["en-US", "de-DE"],
"allowedMediaVersions" => ["mobile" => "m", "full" => ""]
]
]);`
or:
`\MvcCore\Router::GetInstance()->AddDomainRoutes([
new \MvcCore\Ext\Routers\Modules\Route(
"//blog.%sld%.%tld%", // pattern
"blog", // module
"Blog", // namespace
["page" => 1], // defaults
["page" => "\d+"], // constraints
[ // advanced configuration
"allowedLocalizations" => ["en-US"],
"allowedMediaVersions" => ["full" => ""]
]
),
new \MvcCore\Ext\Routers\Modules\Route([
"pattern" => "//%domain%",
"module" => "main",
"allowedLocalizations" => ["en-US", "de-DE"],
"allowedMediaVersions" => ["mobile" => "m", "full" => ""]
])
]);`
@param \MvcCore\Ext\Routers\Modules\Route[]|\MvcCore\Ext\Routers\Modules\IRoute[]|array|array[] $routes
@param bool $prepend
@param bool $throwExceptionForDuplication
@throws \InvalidArgumentException
@return \MvcCore\Ext\Routers\Module|\MvcCore\Ext\Routers\IModule | [
"Append",
"or",
"prepend",
"new",
"module",
"domain",
"routes",
".",
"If",
"there",
"is",
"no",
"module",
"property",
"configured",
"in",
"given",
"route",
"item",
"in",
"array",
"configuration",
"route",
"module",
"is",
"set",
"by",
"given",
"$routes",
"array",
"key",
"if",
"key",
"is",
"not",
"numeric",
"."
] | train | https://github.com/mvccore/ext-router-module/blob/7695784a451db86cca6a43c98d076803cd0a50a7/src/MvcCore/Ext/Routers/Module/RouteMethods.php#L128-L181 |
mvccore/ext-router-module | src/MvcCore/Ext/Routers/Module/RouteMethods.php | RouteMethods.& | public function & AddDomainRoute ($routeCfgOrRoute, $prepend = FALSE, $throwExceptionForDuplication = TRUE) {
/** @var $this \MvcCore\Ext\Routers\Module */
$instance = & $this->getRouteDomainInstance($routeCfgOrRoute);
$routeModule = $instance->GetModule();
if (isset($this->domainRoutes[$routeModule]) && $throwExceptionForDuplication) {
$selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__;
throw new \InvalidArgumentException(
"[".$selfClass."] Route with module name `.$routeModule.` "
."has already been defined between router domain routes."
);
}
if ($prepend) {
$newItem = [$routeModule => $instance];
$this->domainRoutes = $newItem + $this->routes;
} else {
$this->domainRoutes[$routeModule] = $instance;
}
return $this;
} | php | public function & AddDomainRoute ($routeCfgOrRoute, $prepend = FALSE, $throwExceptionForDuplication = TRUE) {
/** @var $this \MvcCore\Ext\Routers\Module */
$instance = & $this->getRouteDomainInstance($routeCfgOrRoute);
$routeModule = $instance->GetModule();
if (isset($this->domainRoutes[$routeModule]) && $throwExceptionForDuplication) {
$selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__;
throw new \InvalidArgumentException(
"[".$selfClass."] Route with module name `.$routeModule.` "
."has already been defined between router domain routes."
);
}
if ($prepend) {
$newItem = [$routeModule => $instance];
$this->domainRoutes = $newItem + $this->routes;
} else {
$this->domainRoutes[$routeModule] = $instance;
}
return $this;
} | [
"public",
"function",
"&",
"AddDomainRoute",
"(",
"$",
"routeCfgOrRoute",
",",
"$",
"prepend",
"=",
"FALSE",
",",
"$",
"throwExceptionForDuplication",
"=",
"TRUE",
")",
"{",
"/** @var $this \\MvcCore\\Ext\\Routers\\Module */",
"$",
"instance",
"=",
"&",
"$",
"this",
"->",
"getRouteDomainInstance",
"(",
"$",
"routeCfgOrRoute",
")",
";",
"$",
"routeModule",
"=",
"$",
"instance",
"->",
"GetModule",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"domainRoutes",
"[",
"$",
"routeModule",
"]",
")",
"&&",
"$",
"throwExceptionForDuplication",
")",
"{",
"$",
"selfClass",
"=",
"version_compare",
"(",
"PHP_VERSION",
",",
"'5.5'",
",",
"'>'",
")",
"?",
"self",
"::",
"class",
":",
"__CLASS__",
";",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"[\"",
".",
"$",
"selfClass",
".",
"\"] Route with module name `.$routeModule.` \"",
".",
"\"has already been defined between router domain routes.\"",
")",
";",
"}",
"if",
"(",
"$",
"prepend",
")",
"{",
"$",
"newItem",
"=",
"[",
"$",
"routeModule",
"=>",
"$",
"instance",
"]",
";",
"$",
"this",
"->",
"domainRoutes",
"=",
"$",
"newItem",
"+",
"$",
"this",
"->",
"routes",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"domainRoutes",
"[",
"$",
"routeModule",
"]",
"=",
"$",
"instance",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Append or prepend new module domain route.
Example:
`\MvcCore\Router::GetInstance()->AddDomainRoute([
"blog" => [
"pattern" => "//blog.%sld%.%tld%",
"namespace" => "Blog",
"defaults" => ["page" => 1],
"constraints" => ["page" => "\d+"],
"allowedLocalizations" => ["en-US"],
"allowedMediaVersions" => ["full" => ""]
],
"main" => [
"pattern" => "//%domain%",
"allowedLocalizations" => ["en-US", "de-DE"],
"allowedMediaVersions" => ["mobile" => "m", "full" => ""]
]
]);`
or:
`\MvcCore\Router::GetInstance()->AddDomainRoute([
new \MvcCore\Ext\Routers\Modules\Route(
"//blog.%sld%.%tld%", // pattern
"blog", // module
"Blog", // namespace
["page" => 1], // defaults
["page" => "\d+"], // constraints
[ // advanced configuration
"allowedLocalizations" => ["en-US"],
"allowedMediaVersions" => ["full" => ""]
]
),
new \MvcCore\Ext\Routers\Modules\Route([
"pattern" => "//%domain%",
"module" => "main",
"allowedLocalizations" => ["en-US", "de-DE"],
"allowedMediaVersions" => ["mobile" => "m", "full" => ""]
])
]);`
@param \MvcCore\Ext\Routers\Modules\Route|\MvcCore\Ext\Routers\Modules\IRoute|array $routeCfgOrRoute
@param bool $prepend
@param bool $throwExceptionForDuplication
@throws \InvalidArgumentException
@return \MvcCore\Ext\Routers\Module|\MvcCore\Ext\Routers\IModule | [
"Append",
"or",
"prepend",
"new",
"module",
"domain",
"route",
".",
"Example",
":",
"\\",
"MvcCore",
"\\",
"Router",
"::",
"GetInstance",
"()",
"-",
">",
"AddDomainRoute",
"(",
"[",
"blog",
"=",
">",
"[",
"pattern",
"=",
">",
"//",
"blog",
".",
"%sld%",
".",
"%tld%",
"namespace",
"=",
">",
"Blog",
"defaults",
"=",
">",
"[",
"page",
"=",
">",
"1",
"]",
"constraints",
"=",
">",
"[",
"page",
"=",
">",
"\\",
"d",
"+",
"]",
"allowedLocalizations",
"=",
">",
"[",
"en",
"-",
"US",
"]",
"allowedMediaVersions",
"=",
">",
"[",
"full",
"=",
">",
"]",
"]",
"main",
"=",
">",
"[",
"pattern",
"=",
">",
"//",
"%domain%",
"allowedLocalizations",
"=",
">",
"[",
"en",
"-",
"US",
"de",
"-",
"DE",
"]",
"allowedMediaVersions",
"=",
">",
"[",
"mobile",
"=",
">",
"m",
"full",
"=",
">",
"]",
"]",
"]",
")",
";",
"or",
":",
"\\",
"MvcCore",
"\\",
"Router",
"::",
"GetInstance",
"()",
"-",
">",
"AddDomainRoute",
"(",
"[",
"new",
"\\",
"MvcCore",
"\\",
"Ext",
"\\",
"Routers",
"\\",
"Modules",
"\\",
"Route",
"(",
"//",
"blog",
".",
"%sld%",
".",
"%tld%",
"//",
"pattern",
"blog",
"//",
"module",
"Blog",
"//",
"namespace",
"[",
"page",
"=",
">",
"1",
"]",
"//",
"defaults",
"[",
"page",
"=",
">",
"\\",
"d",
"+",
"]",
"//",
"constraints",
"[",
"//",
"advanced",
"configuration",
"allowedLocalizations",
"=",
">",
"[",
"en",
"-",
"US",
"]",
"allowedMediaVersions",
"=",
">",
"[",
"full",
"=",
">",
"]",
"]",
")",
"new",
"\\",
"MvcCore",
"\\",
"Ext",
"\\",
"Routers",
"\\",
"Modules",
"\\",
"Route",
"(",
"[",
"pattern",
"=",
">",
"//",
"%domain%",
"module",
"=",
">",
"main",
"allowedLocalizations",
"=",
">",
"[",
"en",
"-",
"US",
"de",
"-",
"DE",
"]",
"allowedMediaVersions",
"=",
">",
"[",
"mobile",
"=",
">",
"m",
"full",
"=",
">",
"]",
"]",
")",
"]",
")",
";"
] | train | https://github.com/mvccore/ext-router-module/blob/7695784a451db86cca6a43c98d076803cd0a50a7/src/MvcCore/Ext/Routers/Module/RouteMethods.php#L227-L245 |
mvccore/ext-router-module | src/MvcCore/Ext/Routers/Module/RouteMethods.php | RouteMethods.& | protected function & getRouteDomainInstance (& $routeCfgOrRoute) {
if ($routeCfgOrRoute instanceof \MvcCore\Ext\Routers\Modules\IRoute)
return $routeCfgOrRoute->SetRouter($this);
$routeClass = self::$routeDomainClass;
return $routeClass::CreateInstance($routeCfgOrRoute)->SetRouter($this);
} | php | protected function & getRouteDomainInstance (& $routeCfgOrRoute) {
if ($routeCfgOrRoute instanceof \MvcCore\Ext\Routers\Modules\IRoute)
return $routeCfgOrRoute->SetRouter($this);
$routeClass = self::$routeDomainClass;
return $routeClass::CreateInstance($routeCfgOrRoute)->SetRouter($this);
} | [
"protected",
"function",
"&",
"getRouteDomainInstance",
"(",
"&",
"$",
"routeCfgOrRoute",
")",
"{",
"if",
"(",
"$",
"routeCfgOrRoute",
"instanceof",
"\\",
"MvcCore",
"\\",
"Ext",
"\\",
"Routers",
"\\",
"Modules",
"\\",
"IRoute",
")",
"return",
"$",
"routeCfgOrRoute",
"->",
"SetRouter",
"(",
"$",
"this",
")",
";",
"$",
"routeClass",
"=",
"self",
"::",
"$",
"routeDomainClass",
";",
"return",
"$",
"routeClass",
"::",
"CreateInstance",
"(",
"$",
"routeCfgOrRoute",
")",
"->",
"SetRouter",
"(",
"$",
"this",
")",
";",
"}"
] | Get always route instance from given route configuration data or return
already created given instance.
@param \MvcCore\Ext\Routers\Modules\Route|\MvcCore\Ext\Routers\Modules\IRoute|array $routeCfgOrRoute
Route instance or route config array.
@return \MvcCore\Ext\Routers\Modules\Route|\MvcCore\Ext\Routers\Modules\IRoute | [
"Get",
"always",
"route",
"instance",
"from",
"given",
"route",
"configuration",
"data",
"or",
"return",
"already",
"created",
"given",
"instance",
"."
] | train | https://github.com/mvccore/ext-router-module/blob/7695784a451db86cca6a43c98d076803cd0a50a7/src/MvcCore/Ext/Routers/Module/RouteMethods.php#L254-L259 |
gpupo/common-schema | src/ORM/Entity/Trading/Order/Order.php | Order.setOrderStatusDetail | public function setOrderStatusDetail(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\OrderStatusDetail $orderStatusDetail = null)
{
$this->order_status_detail = $orderStatusDetail;
return $this;
} | php | public function setOrderStatusDetail(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\OrderStatusDetail $orderStatusDetail = null)
{
$this->order_status_detail = $orderStatusDetail;
return $this;
} | [
"public",
"function",
"setOrderStatusDetail",
"(",
"\\",
"Gpupo",
"\\",
"CommonSchema",
"\\",
"ORM",
"\\",
"Entity",
"\\",
"Trading",
"\\",
"Order",
"\\",
"OrderStatusDetail",
"$",
"orderStatusDetail",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"order_status_detail",
"=",
"$",
"orderStatusDetail",
";",
"return",
"$",
"this",
";",
"}"
] | Set orderStatusDetail.
@param null|\Gpupo\CommonSchema\ORM\Entity\Trading\Order\OrderStatusDetail $orderStatusDetail
@return Order | [
"Set",
"orderStatusDetail",
"."
] | train | https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Trading/Order/Order.php#L714-L719 |
gpupo/common-schema | src/ORM/Entity/Trading/Order/Order.php | Order.setCustomer | public function setCustomer(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Customer\Customer $customer = null)
{
$this->customer = $customer;
return $this;
} | php | public function setCustomer(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Customer\Customer $customer = null)
{
$this->customer = $customer;
return $this;
} | [
"public",
"function",
"setCustomer",
"(",
"\\",
"Gpupo",
"\\",
"CommonSchema",
"\\",
"ORM",
"\\",
"Entity",
"\\",
"Trading",
"\\",
"Order",
"\\",
"Customer",
"\\",
"Customer",
"$",
"customer",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"customer",
"=",
"$",
"customer",
";",
"return",
"$",
"this",
";",
"}"
] | Set customer.
@param null|\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Customer\Customer $customer
@return Order | [
"Set",
"customer",
"."
] | train | https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Trading/Order/Order.php#L738-L743 |
gpupo/common-schema | src/ORM/Entity/Trading/Order/Order.php | Order.setTrading | public function setTrading(\Gpupo\CommonSchema\ORM\Entity\Trading\Trading $trading = null)
{
$this->trading = $trading;
return $this;
} | php | public function setTrading(\Gpupo\CommonSchema\ORM\Entity\Trading\Trading $trading = null)
{
$this->trading = $trading;
return $this;
} | [
"public",
"function",
"setTrading",
"(",
"\\",
"Gpupo",
"\\",
"CommonSchema",
"\\",
"ORM",
"\\",
"Entity",
"\\",
"Trading",
"\\",
"Trading",
"$",
"trading",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"trading",
"=",
"$",
"trading",
";",
"return",
"$",
"this",
";",
"}"
] | Set trading.
@param null|\Gpupo\CommonSchema\ORM\Entity\Trading\Trading $trading
@return Order | [
"Set",
"trading",
"."
] | train | https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Trading/Order/Order.php#L762-L767 |
gpupo/common-schema | src/ORM/Entity/Trading/Order/Order.php | Order.addShipping | public function addShipping(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Shipping $shipping)
{
$this->shippings[] = $shipping;
return $this;
} | php | public function addShipping(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Shipping $shipping)
{
$this->shippings[] = $shipping;
return $this;
} | [
"public",
"function",
"addShipping",
"(",
"\\",
"Gpupo",
"\\",
"CommonSchema",
"\\",
"ORM",
"\\",
"Entity",
"\\",
"Trading",
"\\",
"Order",
"\\",
"Shipping",
"\\",
"Shipping",
"$",
"shipping",
")",
"{",
"$",
"this",
"->",
"shippings",
"[",
"]",
"=",
"$",
"shipping",
";",
"return",
"$",
"this",
";",
"}"
] | Add shipping.
@param \Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Shipping $shipping
@return Order | [
"Add",
"shipping",
"."
] | train | https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Trading/Order/Order.php#L786-L791 |
gpupo/common-schema | src/ORM/Entity/Trading/Order/Order.php | Order.removeShipping | public function removeShipping(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Shipping $shipping)
{
return $this->shippings->removeElement($shipping);
} | php | public function removeShipping(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Shipping $shipping)
{
return $this->shippings->removeElement($shipping);
} | [
"public",
"function",
"removeShipping",
"(",
"\\",
"Gpupo",
"\\",
"CommonSchema",
"\\",
"ORM",
"\\",
"Entity",
"\\",
"Trading",
"\\",
"Order",
"\\",
"Shipping",
"\\",
"Shipping",
"$",
"shipping",
")",
"{",
"return",
"$",
"this",
"->",
"shippings",
"->",
"removeElement",
"(",
"$",
"shipping",
")",
";",
"}"
] | Remove shipping.
@param \Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Shipping $shipping
@return bool TRUE if this collection contained the specified element, FALSE otherwise | [
"Remove",
"shipping",
"."
] | train | https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Trading/Order/Order.php#L800-L803 |
gpupo/common-schema | src/ORM/Entity/Trading/Order/Order.php | Order.removeFeedback | public function removeFeedback(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Feedback\Feedback $feedback)
{
return $this->feedbacks->removeElement($feedback);
} | php | public function removeFeedback(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Feedback\Feedback $feedback)
{
return $this->feedbacks->removeElement($feedback);
} | [
"public",
"function",
"removeFeedback",
"(",
"\\",
"Gpupo",
"\\",
"CommonSchema",
"\\",
"ORM",
"\\",
"Entity",
"\\",
"Trading",
"\\",
"Order",
"\\",
"Feedback",
"\\",
"Feedback",
"$",
"feedback",
")",
"{",
"return",
"$",
"this",
"->",
"feedbacks",
"->",
"removeElement",
"(",
"$",
"feedback",
")",
";",
"}"
] | Remove feedback.
@param \Gpupo\CommonSchema\ORM\Entity\Trading\Order\Feedback\Feedback $feedback
@return bool TRUE if this collection contained the specified element, FALSE otherwise | [
"Remove",
"feedback",
"."
] | train | https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Trading/Order/Order.php#L836-L839 |
WellCommerce/StandardEditionBundle | DataFixtures/ORM/LoadPageData.php | LoadPageData.load | public function load(ObjectManager $manager)
{
if (!$this->isEnabled()) {
return;
}
$this->manager = $manager;
$this->shop = $this->getReference('shop');
$this->defaultText = $this->getFakerGenerator()->text(600);
$aboutUs = $this->createPage('About us', 0, null);
$this->setReference('page_about_us', $aboutUs);
$newsFeed = $this->createPage('News feed', 10, $aboutUs);
$newsFeed->setRedirectRoute('front.news.index');
$newsFeed->setRedirectType(1);
$this->createPage('Stores', 20, $aboutUs);
$this->createPage('Brands', 30, $aboutUs);
$this->createPage('Our brand', 40, $aboutUs);
$this->createPage('About company', 50, $aboutUs);
$this->createPage('Wholesale', 60, $aboutUs);
$help = $this->createPage('Help', 10, null);
$this->setReference('page_help', $aboutUs);
$this->createPage('Conditions', 10, $help);
$this->createPage('Returns, warranty', 20, $help);
$contactUs = $this->createPage('Contact us', 30, $help);
$contactUs->setRedirectRoute('front.contact.index');
$contactUs->setRedirectType(1);
$this->createPage('Availability & delivery times', 40, $help);
$this->createPage('Payment & Shipping', 50, $help);
$sitemap = $this->createPage('Site map', 60, $help);
$sitemap->setRedirectRoute('front.sitemap.index');
$sitemap->setRedirectType(1);
$this->createLayoutBoxes($manager, [
'page' => [
'type' => 'Page',
'name' => 'Page',
],
]);
$manager->flush();
} | php | public function load(ObjectManager $manager)
{
if (!$this->isEnabled()) {
return;
}
$this->manager = $manager;
$this->shop = $this->getReference('shop');
$this->defaultText = $this->getFakerGenerator()->text(600);
$aboutUs = $this->createPage('About us', 0, null);
$this->setReference('page_about_us', $aboutUs);
$newsFeed = $this->createPage('News feed', 10, $aboutUs);
$newsFeed->setRedirectRoute('front.news.index');
$newsFeed->setRedirectType(1);
$this->createPage('Stores', 20, $aboutUs);
$this->createPage('Brands', 30, $aboutUs);
$this->createPage('Our brand', 40, $aboutUs);
$this->createPage('About company', 50, $aboutUs);
$this->createPage('Wholesale', 60, $aboutUs);
$help = $this->createPage('Help', 10, null);
$this->setReference('page_help', $aboutUs);
$this->createPage('Conditions', 10, $help);
$this->createPage('Returns, warranty', 20, $help);
$contactUs = $this->createPage('Contact us', 30, $help);
$contactUs->setRedirectRoute('front.contact.index');
$contactUs->setRedirectType(1);
$this->createPage('Availability & delivery times', 40, $help);
$this->createPage('Payment & Shipping', 50, $help);
$sitemap = $this->createPage('Site map', 60, $help);
$sitemap->setRedirectRoute('front.sitemap.index');
$sitemap->setRedirectType(1);
$this->createLayoutBoxes($manager, [
'page' => [
'type' => 'Page',
'name' => 'Page',
],
]);
$manager->flush();
} | [
"public",
"function",
"load",
"(",
"ObjectManager",
"$",
"manager",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isEnabled",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"manager",
"=",
"$",
"manager",
";",
"$",
"this",
"->",
"shop",
"=",
"$",
"this",
"->",
"getReference",
"(",
"'shop'",
")",
";",
"$",
"this",
"->",
"defaultText",
"=",
"$",
"this",
"->",
"getFakerGenerator",
"(",
")",
"->",
"text",
"(",
"600",
")",
";",
"$",
"aboutUs",
"=",
"$",
"this",
"->",
"createPage",
"(",
"'About us'",
",",
"0",
",",
"null",
")",
";",
"$",
"this",
"->",
"setReference",
"(",
"'page_about_us'",
",",
"$",
"aboutUs",
")",
";",
"$",
"newsFeed",
"=",
"$",
"this",
"->",
"createPage",
"(",
"'News feed'",
",",
"10",
",",
"$",
"aboutUs",
")",
";",
"$",
"newsFeed",
"->",
"setRedirectRoute",
"(",
"'front.news.index'",
")",
";",
"$",
"newsFeed",
"->",
"setRedirectType",
"(",
"1",
")",
";",
"$",
"this",
"->",
"createPage",
"(",
"'Stores'",
",",
"20",
",",
"$",
"aboutUs",
")",
";",
"$",
"this",
"->",
"createPage",
"(",
"'Brands'",
",",
"30",
",",
"$",
"aboutUs",
")",
";",
"$",
"this",
"->",
"createPage",
"(",
"'Our brand'",
",",
"40",
",",
"$",
"aboutUs",
")",
";",
"$",
"this",
"->",
"createPage",
"(",
"'About company'",
",",
"50",
",",
"$",
"aboutUs",
")",
";",
"$",
"this",
"->",
"createPage",
"(",
"'Wholesale'",
",",
"60",
",",
"$",
"aboutUs",
")",
";",
"$",
"help",
"=",
"$",
"this",
"->",
"createPage",
"(",
"'Help'",
",",
"10",
",",
"null",
")",
";",
"$",
"this",
"->",
"setReference",
"(",
"'page_help'",
",",
"$",
"aboutUs",
")",
";",
"$",
"this",
"->",
"createPage",
"(",
"'Conditions'",
",",
"10",
",",
"$",
"help",
")",
";",
"$",
"this",
"->",
"createPage",
"(",
"'Returns, warranty'",
",",
"20",
",",
"$",
"help",
")",
";",
"$",
"contactUs",
"=",
"$",
"this",
"->",
"createPage",
"(",
"'Contact us'",
",",
"30",
",",
"$",
"help",
")",
";",
"$",
"contactUs",
"->",
"setRedirectRoute",
"(",
"'front.contact.index'",
")",
";",
"$",
"contactUs",
"->",
"setRedirectType",
"(",
"1",
")",
";",
"$",
"this",
"->",
"createPage",
"(",
"'Availability & delivery times'",
",",
"40",
",",
"$",
"help",
")",
";",
"$",
"this",
"->",
"createPage",
"(",
"'Payment & Shipping'",
",",
"50",
",",
"$",
"help",
")",
";",
"$",
"sitemap",
"=",
"$",
"this",
"->",
"createPage",
"(",
"'Site map'",
",",
"60",
",",
"$",
"help",
")",
";",
"$",
"sitemap",
"->",
"setRedirectRoute",
"(",
"'front.sitemap.index'",
")",
";",
"$",
"sitemap",
"->",
"setRedirectType",
"(",
"1",
")",
";",
"$",
"this",
"->",
"createLayoutBoxes",
"(",
"$",
"manager",
",",
"[",
"'page'",
"=>",
"[",
"'type'",
"=>",
"'Page'",
",",
"'name'",
"=>",
"'Page'",
",",
"]",
",",
"]",
")",
";",
"$",
"manager",
"->",
"flush",
"(",
")",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/WellCommerce/StandardEditionBundle/blob/6367bd20bbb6bde37c710a6ba87ae72b5f05f61e/DataFixtures/ORM/LoadPageData.php#L40-L87 |
WellCommerce/StandardEditionBundle | DataFixtures/ORM/LoadPageData.php | LoadPageData.createPage | protected function createPage($name, $hierarchy, Page $parent = null): Page
{
$page = new Page();
$page->setParent($parent);
$page->setHierarchy($hierarchy);
$page->setPublish(1);
$page->setRedirectType(0);
$page->setSection('');
$page->addShop($this->shop);
foreach ($this->getLocales() as $locale) {
/** @var PageTranslation $translation */
$translation = $page->translate($locale->getCode());
$translation->setName($name);
$translation->setSlug(Helper::urlize($name));
$translation->setContent($this->defaultText);
}
$page->mergeNewTranslations();
$this->manager->persist($page);
return $page;
} | php | protected function createPage($name, $hierarchy, Page $parent = null): Page
{
$page = new Page();
$page->setParent($parent);
$page->setHierarchy($hierarchy);
$page->setPublish(1);
$page->setRedirectType(0);
$page->setSection('');
$page->addShop($this->shop);
foreach ($this->getLocales() as $locale) {
/** @var PageTranslation $translation */
$translation = $page->translate($locale->getCode());
$translation->setName($name);
$translation->setSlug(Helper::urlize($name));
$translation->setContent($this->defaultText);
}
$page->mergeNewTranslations();
$this->manager->persist($page);
return $page;
} | [
"protected",
"function",
"createPage",
"(",
"$",
"name",
",",
"$",
"hierarchy",
",",
"Page",
"$",
"parent",
"=",
"null",
")",
":",
"Page",
"{",
"$",
"page",
"=",
"new",
"Page",
"(",
")",
";",
"$",
"page",
"->",
"setParent",
"(",
"$",
"parent",
")",
";",
"$",
"page",
"->",
"setHierarchy",
"(",
"$",
"hierarchy",
")",
";",
"$",
"page",
"->",
"setPublish",
"(",
"1",
")",
";",
"$",
"page",
"->",
"setRedirectType",
"(",
"0",
")",
";",
"$",
"page",
"->",
"setSection",
"(",
"''",
")",
";",
"$",
"page",
"->",
"addShop",
"(",
"$",
"this",
"->",
"shop",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getLocales",
"(",
")",
"as",
"$",
"locale",
")",
"{",
"/** @var PageTranslation $translation */",
"$",
"translation",
"=",
"$",
"page",
"->",
"translate",
"(",
"$",
"locale",
"->",
"getCode",
"(",
")",
")",
";",
"$",
"translation",
"->",
"setName",
"(",
"$",
"name",
")",
";",
"$",
"translation",
"->",
"setSlug",
"(",
"Helper",
"::",
"urlize",
"(",
"$",
"name",
")",
")",
";",
"$",
"translation",
"->",
"setContent",
"(",
"$",
"this",
"->",
"defaultText",
")",
";",
"}",
"$",
"page",
"->",
"mergeNewTranslations",
"(",
")",
";",
"$",
"this",
"->",
"manager",
"->",
"persist",
"(",
"$",
"page",
")",
";",
"return",
"$",
"page",
";",
"}"
] | Creates a cms page
@param string $name
@param int $hierarchy
@param Page $parent
@return Page | [
"Creates",
"a",
"cms",
"page"
] | train | https://github.com/WellCommerce/StandardEditionBundle/blob/6367bd20bbb6bde37c710a6ba87ae72b5f05f61e/DataFixtures/ORM/LoadPageData.php#L98-L120 |
verdet23/SphinxSearchBundle | DependencyInjection/Configuration.php | Configuration.getConfigTreeBuilder | public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('sphinx_search');
$this->addIndexerSection($rootNode);
$this->addIndexesSection($rootNode);
$this->addSearchdSection($rootNode);
return $treeBuilder;
} | php | public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('sphinx_search');
$this->addIndexerSection($rootNode);
$this->addIndexesSection($rootNode);
$this->addSearchdSection($rootNode);
return $treeBuilder;
} | [
"public",
"function",
"getConfigTreeBuilder",
"(",
")",
"{",
"$",
"treeBuilder",
"=",
"new",
"TreeBuilder",
"(",
")",
";",
"$",
"rootNode",
"=",
"$",
"treeBuilder",
"->",
"root",
"(",
"'sphinx_search'",
")",
";",
"$",
"this",
"->",
"addIndexerSection",
"(",
"$",
"rootNode",
")",
";",
"$",
"this",
"->",
"addIndexesSection",
"(",
"$",
"rootNode",
")",
";",
"$",
"this",
"->",
"addSearchdSection",
"(",
"$",
"rootNode",
")",
";",
"return",
"$",
"treeBuilder",
";",
"}"
] | Generates the configuration tree.
@return TreeBuilder | [
"Generates",
"the",
"configuration",
"tree",
"."
] | train | https://github.com/verdet23/SphinxSearchBundle/blob/6452cc3a5fab83647b6c08574164249fb8f03b05/DependencyInjection/Configuration.php#L19-L29 |
verdet23/SphinxSearchBundle | DependencyInjection/Configuration.php | Configuration.addIndexerSection | private function addIndexerSection(ArrayNodeDefinition $node)
{
$node
->children()
->arrayNode('indexer')
->addDefaultsIfNotSet()
->children()
->booleanNode('sudo')->defaultValue(false)->end()
->scalarNode('bin')->defaultValue('/usr/bin/indexer')->end()
->scalarNode('config')->defaultNull()->end()
->end()
->end()
->end();
} | php | private function addIndexerSection(ArrayNodeDefinition $node)
{
$node
->children()
->arrayNode('indexer')
->addDefaultsIfNotSet()
->children()
->booleanNode('sudo')->defaultValue(false)->end()
->scalarNode('bin')->defaultValue('/usr/bin/indexer')->end()
->scalarNode('config')->defaultNull()->end()
->end()
->end()
->end();
} | [
"private",
"function",
"addIndexerSection",
"(",
"ArrayNodeDefinition",
"$",
"node",
")",
"{",
"$",
"node",
"->",
"children",
"(",
")",
"->",
"arrayNode",
"(",
"'indexer'",
")",
"->",
"addDefaultsIfNotSet",
"(",
")",
"->",
"children",
"(",
")",
"->",
"booleanNode",
"(",
"'sudo'",
")",
"->",
"defaultValue",
"(",
"false",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'bin'",
")",
"->",
"defaultValue",
"(",
"'/usr/bin/indexer'",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'config'",
")",
"->",
"defaultNull",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
";",
"}"
] | Set indexer parameters
@param ArrayNodeDefinition $node | [
"Set",
"indexer",
"parameters"
] | train | https://github.com/verdet23/SphinxSearchBundle/blob/6452cc3a5fab83647b6c08574164249fb8f03b05/DependencyInjection/Configuration.php#L36-L49 |
verdet23/SphinxSearchBundle | DependencyInjection/Configuration.php | Configuration.addIndexesSection | private function addIndexesSection(ArrayNodeDefinition $node)
{
$node
->children()
->arrayNode('indexes')
->isRequired()
->requiresAtLeastOneElement()
->useAttributeAsKey('key')
->prototype('scalar')->end()
->end()
->end();
} | php | private function addIndexesSection(ArrayNodeDefinition $node)
{
$node
->children()
->arrayNode('indexes')
->isRequired()
->requiresAtLeastOneElement()
->useAttributeAsKey('key')
->prototype('scalar')->end()
->end()
->end();
} | [
"private",
"function",
"addIndexesSection",
"(",
"ArrayNodeDefinition",
"$",
"node",
")",
"{",
"$",
"node",
"->",
"children",
"(",
")",
"->",
"arrayNode",
"(",
"'indexes'",
")",
"->",
"isRequired",
"(",
")",
"->",
"requiresAtLeastOneElement",
"(",
")",
"->",
"useAttributeAsKey",
"(",
"'key'",
")",
"->",
"prototype",
"(",
"'scalar'",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
";",
"}"
] | Set indexes parameters
@param ArrayNodeDefinition $node | [
"Set",
"indexes",
"parameters"
] | train | https://github.com/verdet23/SphinxSearchBundle/blob/6452cc3a5fab83647b6c08574164249fb8f03b05/DependencyInjection/Configuration.php#L56-L67 |
verdet23/SphinxSearchBundle | DependencyInjection/Configuration.php | Configuration.addSearchdSection | private function addSearchdSection(ArrayNodeDefinition $node)
{
$node
->children()
->arrayNode('searchd')
->addDefaultsIfNotSet()
->children()
->scalarNode('host')->defaultValue('localhost')->end()
->scalarNode('port')->defaultValue('9312')->end()
->scalarNode('socket')->defaultNull()->end()
->end()
->end()
->end();
} | php | private function addSearchdSection(ArrayNodeDefinition $node)
{
$node
->children()
->arrayNode('searchd')
->addDefaultsIfNotSet()
->children()
->scalarNode('host')->defaultValue('localhost')->end()
->scalarNode('port')->defaultValue('9312')->end()
->scalarNode('socket')->defaultNull()->end()
->end()
->end()
->end();
} | [
"private",
"function",
"addSearchdSection",
"(",
"ArrayNodeDefinition",
"$",
"node",
")",
"{",
"$",
"node",
"->",
"children",
"(",
")",
"->",
"arrayNode",
"(",
"'searchd'",
")",
"->",
"addDefaultsIfNotSet",
"(",
")",
"->",
"children",
"(",
")",
"->",
"scalarNode",
"(",
"'host'",
")",
"->",
"defaultValue",
"(",
"'localhost'",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'port'",
")",
"->",
"defaultValue",
"(",
"'9312'",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'socket'",
")",
"->",
"defaultNull",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
";",
"}"
] | Set search daemon parameters
@param ArrayNodeDefinition $node | [
"Set",
"search",
"daemon",
"parameters"
] | train | https://github.com/verdet23/SphinxSearchBundle/blob/6452cc3a5fab83647b6c08574164249fb8f03b05/DependencyInjection/Configuration.php#L74-L87 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/memcache.php | ezcCacheStorageMemcache.setOptions | public function setOptions( $options )
{
switch ( true )
{
case ( $options instanceof ezcCacheStorageMemcacheOptions ):
$this->properties['options'] = $options;
break;
case ( $options instanceof ezcCacheStorageOptions ):
$this->properties['options']->mergeStorageOptions( $options );
break;
case ( is_array( $options ) ):
$this->properties['options']->merge( $options );
break;
default:
throw new ezcBaseValueException(
'options',
$options,
'instance of ezcCacheStorageMemcacheOptions'
);
}
} | php | public function setOptions( $options )
{
switch ( true )
{
case ( $options instanceof ezcCacheStorageMemcacheOptions ):
$this->properties['options'] = $options;
break;
case ( $options instanceof ezcCacheStorageOptions ):
$this->properties['options']->mergeStorageOptions( $options );
break;
case ( is_array( $options ) ):
$this->properties['options']->merge( $options );
break;
default:
throw new ezcBaseValueException(
'options',
$options,
'instance of ezcCacheStorageMemcacheOptions'
);
}
} | [
"public",
"function",
"setOptions",
"(",
"$",
"options",
")",
"{",
"switch",
"(",
"true",
")",
"{",
"case",
"(",
"$",
"options",
"instanceof",
"ezcCacheStorageMemcacheOptions",
")",
":",
"$",
"this",
"->",
"properties",
"[",
"'options'",
"]",
"=",
"$",
"options",
";",
"break",
";",
"case",
"(",
"$",
"options",
"instanceof",
"ezcCacheStorageOptions",
")",
":",
"$",
"this",
"->",
"properties",
"[",
"'options'",
"]",
"->",
"mergeStorageOptions",
"(",
"$",
"options",
")",
";",
"break",
";",
"case",
"(",
"is_array",
"(",
"$",
"options",
")",
")",
":",
"$",
"this",
"->",
"properties",
"[",
"'options'",
"]",
"->",
"merge",
"(",
"$",
"options",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"ezcBaseValueException",
"(",
"'options'",
",",
"$",
"options",
",",
"'instance of ezcCacheStorageMemcacheOptions'",
")",
";",
"}",
"}"
] | Set new options.
Overwrites the options with the given ones.
@param ezcCacheStorageMemcacheOptions $options The options to set.
@throws ezcBasePropertyNotFoundException
If you tried to set a non-existent option value. The accepted
options depend on the ezcCacheStorage implementation and may
vary.
@throws ezcBaseValueException
If the value is not valid for the desired option.
@throws ezcBaseValueException
If you submit neither an array nor an instance of
ezcCacheStorageOptions.
@apichange Use $storage->options instead. | [
"Set",
"new",
"options",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/memcache.php#L135-L155 |
alevilar/ristorantino-vendor | Fidelization/Model/Cliente.php | Cliente.getResponsabilidadIva | function getResponsabilidadIva($id = 0){
if($id == 0){
$id = $this->id;
}
$ret = $this->find('first',array('conditions'=>array('Cliente.id'=>$id),'contain'=>array('IvaResponsabilidad')));
return $ret;
} | php | function getResponsabilidadIva($id = 0){
if($id == 0){
$id = $this->id;
}
$ret = $this->find('first',array('conditions'=>array('Cliente.id'=>$id),'contain'=>array('IvaResponsabilidad')));
return $ret;
} | [
"function",
"getResponsabilidadIva",
"(",
"$",
"id",
"=",
"0",
")",
"{",
"if",
"(",
"$",
"id",
"==",
"0",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"id",
";",
"}",
"$",
"ret",
"=",
"$",
"this",
"->",
"find",
"(",
"'first'",
",",
"array",
"(",
"'conditions'",
"=>",
"array",
"(",
"'Cliente.id'",
"=>",
"$",
"id",
")",
",",
"'contain'",
"=>",
"array",
"(",
"'IvaResponsabilidad'",
")",
")",
")",
";",
"return",
"$",
"ret",
";",
"}"
] | Me devuelve la responsabilidad del cliente frente el IVA
@return array find(first) con Cliente e IvaResponsabilidad | [
"Me",
"devuelve",
"la",
"responsabilidad",
"del",
"cliente",
"frente",
"el",
"IVA"
] | train | https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Fidelization/Model/Cliente.php#L344-L350 |
alevilar/ristorantino-vendor | Fidelization/Model/Cliente.php | Cliente.filerBySearch | public function filerBySearch($data) {
$filter = $data['search'];
$condition = array(
'OR' => array(
$this->alias . '.nombre LIKE' => '%' . $filter . '%',
$this->alias . '.nrodocumento LIKE' => '%' . $filter . '%',
$this->alias . '.telefono LIKE' => '%' . $filter . '%',
$this->alias . '.domicilio LIKE' => '%' . $filter . '%',
$this->alias . '.codigo' => $filter,
)
);
return $condition;
} | php | public function filerBySearch($data) {
$filter = $data['search'];
$condition = array(
'OR' => array(
$this->alias . '.nombre LIKE' => '%' . $filter . '%',
$this->alias . '.nrodocumento LIKE' => '%' . $filter . '%',
$this->alias . '.telefono LIKE' => '%' . $filter . '%',
$this->alias . '.domicilio LIKE' => '%' . $filter . '%',
$this->alias . '.codigo' => $filter,
)
);
return $condition;
} | [
"public",
"function",
"filerBySearch",
"(",
"$",
"data",
")",
"{",
"$",
"filter",
"=",
"$",
"data",
"[",
"'search'",
"]",
";",
"$",
"condition",
"=",
"array",
"(",
"'OR'",
"=>",
"array",
"(",
"$",
"this",
"->",
"alias",
".",
"'.nombre LIKE'",
"=>",
"'%'",
".",
"$",
"filter",
".",
"'%'",
",",
"$",
"this",
"->",
"alias",
".",
"'.nrodocumento LIKE'",
"=>",
"'%'",
".",
"$",
"filter",
".",
"'%'",
",",
"$",
"this",
"->",
"alias",
".",
"'.telefono LIKE'",
"=>",
"'%'",
".",
"$",
"filter",
".",
"'%'",
",",
"$",
"this",
"->",
"alias",
".",
"'.domicilio LIKE'",
"=>",
"'%'",
".",
"$",
"filter",
".",
"'%'",
",",
"$",
"this",
"->",
"alias",
".",
"'.codigo'",
"=>",
"$",
"filter",
",",
")",
")",
";",
"return",
"$",
"condition",
";",
"}"
] | Or conditions with like | [
"Or",
"conditions",
"with",
"like"
] | train | https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Fidelization/Model/Cliente.php#L354-L366 |
surebert/surebert-framework | src/sb/Email/Attachment.php | Attachment.zip | public function zip()
{
if (empty($this->filepath)) {
throw(new \Exception("Must set \sb\Email\Attachment::file_path before zipping attachment"));
}
if (empty($this->name)) {
$this->name = basename($this->filepath);
}
$zip = new \ZipArchive();
$zipfile_path = \ROOT . "/private/cache/compression/" . md5(microtime(true)) . '_' . $this->name . ".zip";
$zip_dir = dirname($zipfile_path);
if (!is_dir($zip_dir) && !@mkdir($zip_dir, 0755, true)) {
throw(new \Exception("Cannot create /private/cache/compression directory\n"));
}
if ($zip->open($zipfile_path, \ZIPARCHIVE::CREATE) !== true) {
throw(new \Exception("Cannot open <$zipfile_path>\n"));
}
$zip->addFromString($this->name, \file_get_contents($this->filepath));
$zip->close();
$this->name .= '.zip';
//this is the content, in this case I am ready the blob data from a saved image file but you could easily replace this with blob data from a database. The mime type will be added based on the extension using \sb\Files::extensionToMime. For bizarre mime-types that are not in \sb\Files::extensionToMime you can override this by setting the mime-type manually $myAttachment->mime_type ='bizarre/weird';
$this->contents = \file_get_contents($zipfile_path);
//remove the tmp zip file
\unlink($zipfile_path);
//add mime type for zip files, \sb\Files should handle this after 1.41
$this->mime_type = 'application/x-zip-compressed';
} | php | public function zip()
{
if (empty($this->filepath)) {
throw(new \Exception("Must set \sb\Email\Attachment::file_path before zipping attachment"));
}
if (empty($this->name)) {
$this->name = basename($this->filepath);
}
$zip = new \ZipArchive();
$zipfile_path = \ROOT . "/private/cache/compression/" . md5(microtime(true)) . '_' . $this->name . ".zip";
$zip_dir = dirname($zipfile_path);
if (!is_dir($zip_dir) && !@mkdir($zip_dir, 0755, true)) {
throw(new \Exception("Cannot create /private/cache/compression directory\n"));
}
if ($zip->open($zipfile_path, \ZIPARCHIVE::CREATE) !== true) {
throw(new \Exception("Cannot open <$zipfile_path>\n"));
}
$zip->addFromString($this->name, \file_get_contents($this->filepath));
$zip->close();
$this->name .= '.zip';
//this is the content, in this case I am ready the blob data from a saved image file but you could easily replace this with blob data from a database. The mime type will be added based on the extension using \sb\Files::extensionToMime. For bizarre mime-types that are not in \sb\Files::extensionToMime you can override this by setting the mime-type manually $myAttachment->mime_type ='bizarre/weird';
$this->contents = \file_get_contents($zipfile_path);
//remove the tmp zip file
\unlink($zipfile_path);
//add mime type for zip files, \sb\Files should handle this after 1.41
$this->mime_type = 'application/x-zip-compressed';
} | [
"public",
"function",
"zip",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"filepath",
")",
")",
"{",
"throw",
"(",
"new",
"\\",
"Exception",
"(",
"\"Must set \\sb\\Email\\Attachment::file_path before zipping attachment\"",
")",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"name",
")",
")",
"{",
"$",
"this",
"->",
"name",
"=",
"basename",
"(",
"$",
"this",
"->",
"filepath",
")",
";",
"}",
"$",
"zip",
"=",
"new",
"\\",
"ZipArchive",
"(",
")",
";",
"$",
"zipfile_path",
"=",
"\\",
"ROOT",
".",
"\"/private/cache/compression/\"",
".",
"md5",
"(",
"microtime",
"(",
"true",
")",
")",
".",
"'_'",
".",
"$",
"this",
"->",
"name",
".",
"\".zip\"",
";",
"$",
"zip_dir",
"=",
"dirname",
"(",
"$",
"zipfile_path",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"zip_dir",
")",
"&&",
"!",
"@",
"mkdir",
"(",
"$",
"zip_dir",
",",
"0755",
",",
"true",
")",
")",
"{",
"throw",
"(",
"new",
"\\",
"Exception",
"(",
"\"Cannot create /private/cache/compression directory\\n\"",
")",
")",
";",
"}",
"if",
"(",
"$",
"zip",
"->",
"open",
"(",
"$",
"zipfile_path",
",",
"\\",
"ZIPARCHIVE",
"::",
"CREATE",
")",
"!==",
"true",
")",
"{",
"throw",
"(",
"new",
"\\",
"Exception",
"(",
"\"Cannot open <$zipfile_path>\\n\"",
")",
")",
";",
"}",
"$",
"zip",
"->",
"addFromString",
"(",
"$",
"this",
"->",
"name",
",",
"\\",
"file_get_contents",
"(",
"$",
"this",
"->",
"filepath",
")",
")",
";",
"$",
"zip",
"->",
"close",
"(",
")",
";",
"$",
"this",
"->",
"name",
".=",
"'.zip'",
";",
"//this is the content, in this case I am ready the blob data from a saved image file but you could easily replace this with blob data from a database. The mime type will be added based on the extension using \\sb\\Files::extensionToMime. For bizarre mime-types that are not in \\sb\\Files::extensionToMime you can override this by setting the mime-type manually $myAttachment->mime_type ='bizarre/weird';",
"$",
"this",
"->",
"contents",
"=",
"\\",
"file_get_contents",
"(",
"$",
"zipfile_path",
")",
";",
"//remove the tmp zip file",
"\\",
"unlink",
"(",
"$",
"zipfile_path",
")",
";",
"//add mime type for zip files, \\sb\\Files should handle this after 1.41",
"$",
"this",
"->",
"mime_type",
"=",
"'application/x-zip-compressed'",
";",
"}"
] | Zips the attachment before sending and sets the proper mime type | [
"Zips",
"the",
"attachment",
"before",
"sending",
"and",
"sets",
"the",
"proper",
"mime",
"type"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Email/Attachment.php#L125-L161 |
surebert/surebert-framework | src/sb/Email/Attachment.php | Attachment.pgpEncrypt | public function pgpEncrypt($pgpEncrypt_key, $gnupg_path = '')
{
if (empty($gnupg_path)) {
$gnupg_path = \ROOT . '/private/resources/.gnupg';
}
if (!is_dir($gnupg_path)) {
throw(new \Exception('In order to use pgp engryption you must either '
.'pass a valid .gnupg path as the second argument of '
. __METHOD__ . ' or have the .gnupg directory reside in the /private/resources'));
}
putenv("GNUPGHOME=" . $gnupg_path);
$gpg = new \gnupg();
// throw exception if error occurs
$gpg->seterrormode(\gnupg::ERROR_EXCEPTION);
$gpg->addencryptkey($pgpEncrypt_key);
$this->contents = $gpg->encrypt($this->contents);
$this->mime_type = 'application/pgp';
$this->name .= '.pgp';
} | php | public function pgpEncrypt($pgpEncrypt_key, $gnupg_path = '')
{
if (empty($gnupg_path)) {
$gnupg_path = \ROOT . '/private/resources/.gnupg';
}
if (!is_dir($gnupg_path)) {
throw(new \Exception('In order to use pgp engryption you must either '
.'pass a valid .gnupg path as the second argument of '
. __METHOD__ . ' or have the .gnupg directory reside in the /private/resources'));
}
putenv("GNUPGHOME=" . $gnupg_path);
$gpg = new \gnupg();
// throw exception if error occurs
$gpg->seterrormode(\gnupg::ERROR_EXCEPTION);
$gpg->addencryptkey($pgpEncrypt_key);
$this->contents = $gpg->encrypt($this->contents);
$this->mime_type = 'application/pgp';
$this->name .= '.pgp';
} | [
"public",
"function",
"pgpEncrypt",
"(",
"$",
"pgpEncrypt_key",
",",
"$",
"gnupg_path",
"=",
"''",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"gnupg_path",
")",
")",
"{",
"$",
"gnupg_path",
"=",
"\\",
"ROOT",
".",
"'/private/resources/.gnupg'",
";",
"}",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"gnupg_path",
")",
")",
"{",
"throw",
"(",
"new",
"\\",
"Exception",
"(",
"'In order to use pgp engryption you must either '",
".",
"'pass a valid .gnupg path as the second argument of '",
".",
"__METHOD__",
".",
"' or have the .gnupg directory reside in the /private/resources'",
")",
")",
";",
"}",
"putenv",
"(",
"\"GNUPGHOME=\"",
".",
"$",
"gnupg_path",
")",
";",
"$",
"gpg",
"=",
"new",
"\\",
"gnupg",
"(",
")",
";",
"// throw exception if error occurs",
"$",
"gpg",
"->",
"seterrormode",
"(",
"\\",
"gnupg",
"::",
"ERROR_EXCEPTION",
")",
";",
"$",
"gpg",
"->",
"addencryptkey",
"(",
"$",
"pgpEncrypt_key",
")",
";",
"$",
"this",
"->",
"contents",
"=",
"$",
"gpg",
"->",
"encrypt",
"(",
"$",
"this",
"->",
"contents",
")",
";",
"$",
"this",
"->",
"mime_type",
"=",
"'application/pgp'",
";",
"$",
"this",
"->",
"name",
".=",
"'.pgp'",
";",
"}"
] | Encrypts the extension with PGP using gpg extension for php http://pecl.php.net/package/gnupg
@author James Buczkowski, Paul Visco
@param string $pgpEncrypt_key The key to use to encrypt
@param string $gnupg_path Optional The path to your .gnupg directory, must be
readible by apache, by default served out of /private/resources e.g. ROOT.'/private/resources/.gnupg | [
"Encrypts",
"the",
"extension",
"with",
"PGP",
"using",
"gpg",
"extension",
"for",
"php",
"http",
":",
"//",
"pecl",
".",
"php",
".",
"net",
"/",
"package",
"/",
"gnupg"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Email/Attachment.php#L170-L194 |
grozzzny/catalog | controllers/TraitController.php | TraitController.saveFiles | public function saveFiles(&$current_model)
{
foreach ($current_model->getAttributes() as $attribute => $value){
if($current_model->hasValidator('image', $attribute)) {
$current_model->$attribute = UploadedFile::getInstance($current_model, $attribute);
if($current_model->$attribute && $current_model->validate([$attribute])){
$current_model->$attribute = Image::upload($current_model->$attribute, $current_model::SLUG);
}
else{
$current_model->$attribute = $current_model->isNewRecord ? '' : $current_model->oldAttributes[$attribute];
}
}elseif ($current_model->hasValidator('file', $attribute)){
if($fileInstanse = UploadedFile::getInstance($current_model, $attribute)) {
$current_model->$attribute = Upload::file($fileInstanse, $current_model::SLUG);
}else{
$current_model->$attribute = $current_model->isNewRecord ? '' : $current_model->oldAttributes[$attribute];
}
}
}
} | php | public function saveFiles(&$current_model)
{
foreach ($current_model->getAttributes() as $attribute => $value){
if($current_model->hasValidator('image', $attribute)) {
$current_model->$attribute = UploadedFile::getInstance($current_model, $attribute);
if($current_model->$attribute && $current_model->validate([$attribute])){
$current_model->$attribute = Image::upload($current_model->$attribute, $current_model::SLUG);
}
else{
$current_model->$attribute = $current_model->isNewRecord ? '' : $current_model->oldAttributes[$attribute];
}
}elseif ($current_model->hasValidator('file', $attribute)){
if($fileInstanse = UploadedFile::getInstance($current_model, $attribute)) {
$current_model->$attribute = Upload::file($fileInstanse, $current_model::SLUG);
}else{
$current_model->$attribute = $current_model->isNewRecord ? '' : $current_model->oldAttributes[$attribute];
}
}
}
} | [
"public",
"function",
"saveFiles",
"(",
"&",
"$",
"current_model",
")",
"{",
"foreach",
"(",
"$",
"current_model",
"->",
"getAttributes",
"(",
")",
"as",
"$",
"attribute",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"current_model",
"->",
"hasValidator",
"(",
"'image'",
",",
"$",
"attribute",
")",
")",
"{",
"$",
"current_model",
"->",
"$",
"attribute",
"=",
"UploadedFile",
"::",
"getInstance",
"(",
"$",
"current_model",
",",
"$",
"attribute",
")",
";",
"if",
"(",
"$",
"current_model",
"->",
"$",
"attribute",
"&&",
"$",
"current_model",
"->",
"validate",
"(",
"[",
"$",
"attribute",
"]",
")",
")",
"{",
"$",
"current_model",
"->",
"$",
"attribute",
"=",
"Image",
"::",
"upload",
"(",
"$",
"current_model",
"->",
"$",
"attribute",
",",
"$",
"current_model",
"::",
"SLUG",
")",
";",
"}",
"else",
"{",
"$",
"current_model",
"->",
"$",
"attribute",
"=",
"$",
"current_model",
"->",
"isNewRecord",
"?",
"''",
":",
"$",
"current_model",
"->",
"oldAttributes",
"[",
"$",
"attribute",
"]",
";",
"}",
"}",
"elseif",
"(",
"$",
"current_model",
"->",
"hasValidator",
"(",
"'file'",
",",
"$",
"attribute",
")",
")",
"{",
"if",
"(",
"$",
"fileInstanse",
"=",
"UploadedFile",
"::",
"getInstance",
"(",
"$",
"current_model",
",",
"$",
"attribute",
")",
")",
"{",
"$",
"current_model",
"->",
"$",
"attribute",
"=",
"Upload",
"::",
"file",
"(",
"$",
"fileInstanse",
",",
"$",
"current_model",
"::",
"SLUG",
")",
";",
"}",
"else",
"{",
"$",
"current_model",
"->",
"$",
"attribute",
"=",
"$",
"current_model",
"->",
"isNewRecord",
"?",
"''",
":",
"$",
"current_model",
"->",
"oldAttributes",
"[",
"$",
"attribute",
"]",
";",
"}",
"}",
"}",
"}"
] | Сохранение изображений и файлов. Отличе в методе сохранения
@param $current_model | [
"Сохранение",
"изображений",
"и",
"файлов",
".",
"Отличе",
"в",
"методе",
"сохранения"
] | train | https://github.com/grozzzny/catalog/blob/ff1cac10a5f3a89f3ef2767f9ede6b2d74e1849a/controllers/TraitController.php#L18-L37 |
OKTOTV/OktolabMediaBundle | Model/MediaService.php | MediaService.addEpisodeJob | public function addEpisodeJob(Keychain $keychain, $uniqID, $overwrite = false, $worker_queue = false ,$first = false)
{
$this->jobService->addJob(
"Oktolab\MediaBundle\Model\ImportEpisodeMetadataJob",
[
'keychain' => $keychain->getUniqID(),
'uniqID' => $uniqID,
'overwrite' => $overwrite
],
$worker_queue,
$first
);
} | php | public function addEpisodeJob(Keychain $keychain, $uniqID, $overwrite = false, $worker_queue = false ,$first = false)
{
$this->jobService->addJob(
"Oktolab\MediaBundle\Model\ImportEpisodeMetadataJob",
[
'keychain' => $keychain->getUniqID(),
'uniqID' => $uniqID,
'overwrite' => $overwrite
],
$worker_queue,
$first
);
} | [
"public",
"function",
"addEpisodeJob",
"(",
"Keychain",
"$",
"keychain",
",",
"$",
"uniqID",
",",
"$",
"overwrite",
"=",
"false",
",",
"$",
"worker_queue",
"=",
"false",
",",
"$",
"first",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"jobService",
"->",
"addJob",
"(",
"\"Oktolab\\MediaBundle\\Model\\ImportEpisodeMetadataJob\"",
",",
"[",
"'keychain'",
"=>",
"$",
"keychain",
"->",
"getUniqID",
"(",
")",
",",
"'uniqID'",
"=>",
"$",
"uniqID",
",",
"'overwrite'",
"=>",
"$",
"overwrite",
"]",
",",
"$",
"worker_queue",
",",
"$",
"first",
")",
";",
"}"
] | starts an import worker for an episode by uniqID from the given Keychain | [
"starts",
"an",
"import",
"worker",
"for",
"an",
"episode",
"by",
"uniqID",
"from",
"the",
"given",
"Keychain"
] | train | https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/MediaService.php#L92-L104 |
OKTOTV/OktolabMediaBundle | Model/MediaService.php | MediaService.addImportSeriesPosterframeJob | public function addImportSeriesPosterframeJob($uniqID, $keychain, $filekey)
{
$this->jobService->addJob(
"Oktolab\MediaBundle\Model\ImportSeriesPosterframeJob",
['uniqID' => $uniqID, 'keychain' => $keychain->getUniqID(), 'key' => $filekey]
);
} | php | public function addImportSeriesPosterframeJob($uniqID, $keychain, $filekey)
{
$this->jobService->addJob(
"Oktolab\MediaBundle\Model\ImportSeriesPosterframeJob",
['uniqID' => $uniqID, 'keychain' => $keychain->getUniqID(), 'key' => $filekey]
);
} | [
"public",
"function",
"addImportSeriesPosterframeJob",
"(",
"$",
"uniqID",
",",
"$",
"keychain",
",",
"$",
"filekey",
")",
"{",
"$",
"this",
"->",
"jobService",
"->",
"addJob",
"(",
"\"Oktolab\\MediaBundle\\Model\\ImportSeriesPosterframeJob\"",
",",
"[",
"'uniqID'",
"=>",
"$",
"uniqID",
",",
"'keychain'",
"=>",
"$",
"keychain",
"->",
"getUniqID",
"(",
")",
",",
"'key'",
"=>",
"$",
"filekey",
"]",
")",
";",
"}"
] | please use addSeriesPosterframeJob in the future.
@deprecated | [
"please",
"use",
"addSeriesPosterframeJob",
"in",
"the",
"future",
"."
] | train | https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/MediaService.php#L313-L319 |
wenbinye/PhalconX | src/Db/DbHelper.php | DbHelper.describeColumns | public function describeColumns($conn, $table, $schema = null)
{
$dialect = $this->getDialect($conn);
if (method_exists($dialect, 'showFullColumns')) {
$sql = $this->getDialect($conn)->showFullColumns($table, $schema);
$comments = [];
foreach ($conn->fetchAll($sql, Db::FETCH_ASSOC) as $row) {
$comments[$row['Field']] = $row['Comment'];
}
$columns = [];
foreach ($conn->describeColumns($table, $schema) as $col) {
$column = Column::copy($col);
if (!empty($comments[$col->getName()])) {
$column->setComment($comments[$col->getName()]);
}
$columns[] = $column;
}
return $columns;
} else {
return $conn->describeColumns($table, $schema);
}
} | php | public function describeColumns($conn, $table, $schema = null)
{
$dialect = $this->getDialect($conn);
if (method_exists($dialect, 'showFullColumns')) {
$sql = $this->getDialect($conn)->showFullColumns($table, $schema);
$comments = [];
foreach ($conn->fetchAll($sql, Db::FETCH_ASSOC) as $row) {
$comments[$row['Field']] = $row['Comment'];
}
$columns = [];
foreach ($conn->describeColumns($table, $schema) as $col) {
$column = Column::copy($col);
if (!empty($comments[$col->getName()])) {
$column->setComment($comments[$col->getName()]);
}
$columns[] = $column;
}
return $columns;
} else {
return $conn->describeColumns($table, $schema);
}
} | [
"public",
"function",
"describeColumns",
"(",
"$",
"conn",
",",
"$",
"table",
",",
"$",
"schema",
"=",
"null",
")",
"{",
"$",
"dialect",
"=",
"$",
"this",
"->",
"getDialect",
"(",
"$",
"conn",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"dialect",
",",
"'showFullColumns'",
")",
")",
"{",
"$",
"sql",
"=",
"$",
"this",
"->",
"getDialect",
"(",
"$",
"conn",
")",
"->",
"showFullColumns",
"(",
"$",
"table",
",",
"$",
"schema",
")",
";",
"$",
"comments",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"conn",
"->",
"fetchAll",
"(",
"$",
"sql",
",",
"Db",
"::",
"FETCH_ASSOC",
")",
"as",
"$",
"row",
")",
"{",
"$",
"comments",
"[",
"$",
"row",
"[",
"'Field'",
"]",
"]",
"=",
"$",
"row",
"[",
"'Comment'",
"]",
";",
"}",
"$",
"columns",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"conn",
"->",
"describeColumns",
"(",
"$",
"table",
",",
"$",
"schema",
")",
"as",
"$",
"col",
")",
"{",
"$",
"column",
"=",
"Column",
"::",
"copy",
"(",
"$",
"col",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"comments",
"[",
"$",
"col",
"->",
"getName",
"(",
")",
"]",
")",
")",
"{",
"$",
"column",
"->",
"setComment",
"(",
"$",
"comments",
"[",
"$",
"col",
"->",
"getName",
"(",
")",
"]",
")",
";",
"}",
"$",
"columns",
"[",
"]",
"=",
"$",
"column",
";",
"}",
"return",
"$",
"columns",
";",
"}",
"else",
"{",
"return",
"$",
"conn",
"->",
"describeColumns",
"(",
"$",
"table",
",",
"$",
"schema",
")",
";",
"}",
"}"
] | Adds comment to column
@param DbAdapter $conn
@param string $table
@param string $schema
@return Column[] | [
"Adds",
"comment",
"to",
"column"
] | train | https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Db/DbHelper.php#L32-L53 |
wenbinye/PhalconX | src/Db/DbHelper.php | DbHelper.describeIndexes | public function describeIndexes($conn, $table, $schema = null)
{
$dialect = $conn->getDialectType();
$method = 'describeIndexes' . $dialect;
if (!method_exists($this, $method)) {
throw new Exception("Describe index for $dialect is not implemented yet");
}
return $this->$method($conn, $table, $schema);
} | php | public function describeIndexes($conn, $table, $schema = null)
{
$dialect = $conn->getDialectType();
$method = 'describeIndexes' . $dialect;
if (!method_exists($this, $method)) {
throw new Exception("Describe index for $dialect is not implemented yet");
}
return $this->$method($conn, $table, $schema);
} | [
"public",
"function",
"describeIndexes",
"(",
"$",
"conn",
",",
"$",
"table",
",",
"$",
"schema",
"=",
"null",
")",
"{",
"$",
"dialect",
"=",
"$",
"conn",
"->",
"getDialectType",
"(",
")",
";",
"$",
"method",
"=",
"'describeIndexes'",
".",
"$",
"dialect",
";",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"this",
",",
"$",
"method",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Describe index for $dialect is not implemented yet\"",
")",
";",
"}",
"return",
"$",
"this",
"->",
"$",
"method",
"(",
"$",
"conn",
",",
"$",
"table",
",",
"$",
"schema",
")",
";",
"}"
] | Describes table indexes
@param DbAdapter $conn
@param string $table
@param string $schema
@return Index[] | [
"Describes",
"table",
"indexes"
] | train | https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Db/DbHelper.php#L63-L71 |
wenbinye/PhalconX | src/Db/DbHelper.php | DbHelper.createTable | public function createTable($conn, $table, $schema, array $definition)
{
if (empty($definition['columns'])) {
throw new Exception("The table must contain at least one column");
}
$conn->execute($this->getDialect($conn)->createTable($table, $schema, $definition));
} | php | public function createTable($conn, $table, $schema, array $definition)
{
if (empty($definition['columns'])) {
throw new Exception("The table must contain at least one column");
}
$conn->execute($this->getDialect($conn)->createTable($table, $schema, $definition));
} | [
"public",
"function",
"createTable",
"(",
"$",
"conn",
",",
"$",
"table",
",",
"$",
"schema",
",",
"array",
"$",
"definition",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"definition",
"[",
"'columns'",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"The table must contain at least one column\"",
")",
";",
"}",
"$",
"conn",
"->",
"execute",
"(",
"$",
"this",
"->",
"getDialect",
"(",
"$",
"conn",
")",
"->",
"createTable",
"(",
"$",
"table",
",",
"$",
"schema",
",",
"$",
"definition",
")",
")",
";",
"}"
] | creates database table | [
"creates",
"database",
"table"
] | train | https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Db/DbHelper.php#L100-L106 |
wenbinye/PhalconX | src/Db/DbHelper.php | DbHelper.getConnection | public static function getConnection($dsn)
{
if (!is_array($dsn)) {
$dsn = self::parseDsn($dsn);
}
if (!isset($dsn['adapter'])) {
throw new Exception("database adapter is missing for " . json_encode($dsn));
}
$class = 'Phalcon\Db\Adapter\Pdo\\' . ucfirst($dsn['adapter']);
$conn = new $class($dsn);
return Mixin::create($conn, new self);
} | php | public static function getConnection($dsn)
{
if (!is_array($dsn)) {
$dsn = self::parseDsn($dsn);
}
if (!isset($dsn['adapter'])) {
throw new Exception("database adapter is missing for " . json_encode($dsn));
}
$class = 'Phalcon\Db\Adapter\Pdo\\' . ucfirst($dsn['adapter']);
$conn = new $class($dsn);
return Mixin::create($conn, new self);
} | [
"public",
"static",
"function",
"getConnection",
"(",
"$",
"dsn",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"dsn",
")",
")",
"{",
"$",
"dsn",
"=",
"self",
"::",
"parseDsn",
"(",
"$",
"dsn",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"dsn",
"[",
"'adapter'",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"database adapter is missing for \"",
".",
"json_encode",
"(",
"$",
"dsn",
")",
")",
";",
"}",
"$",
"class",
"=",
"'Phalcon\\Db\\Adapter\\Pdo\\\\'",
".",
"ucfirst",
"(",
"$",
"dsn",
"[",
"'adapter'",
"]",
")",
";",
"$",
"conn",
"=",
"new",
"$",
"class",
"(",
"$",
"dsn",
")",
";",
"return",
"Mixin",
"::",
"create",
"(",
"$",
"conn",
",",
"new",
"self",
")",
";",
"}"
] | creates database connect by dsn
@param string $dsn
@return DbAdapter | [
"creates",
"database",
"connect",
"by",
"dsn"
] | train | https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Db/DbHelper.php#L159-L170 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/ZendFramework/View.php | Dwoo_Adapters_ZendFramework_View.setOptions | public function setOptions(array $opt = array())
{
// BC checks
// TODO remove in 1.1
if (isset($opt['compileDir']) || isset($opt['compile_dir'])) {
trigger_error('Dwoo ZF Adapter: the compile dir should be set in the $options[\'engine\'][\'compileDir\'] value the adapter settings', E_USER_WARNING);
}
if (isset($opt['cacheDir']) || isset($opt['cache_dir'])) {
trigger_error('Dwoo ZF Adapter: the cache dir should be set in the $options[\'engine\'][\'cacheDir\'] value the adapter settings', E_USER_WARNING);
}
// end BC
// Making sure that everything is loaded.
$classes = array('engine', 'dataProvider', 'compiler');
// Setting options to Dwoo objects...
foreach ($opt as $type => $settings) {
if (!method_exists($this, 'set' . $type)) {
throw new Dwoo_Exception("Unknown type $type");
}
if (is_string($settings) || is_object($settings)) {
call_user_func(array($this, 'set' . $type), $settings);
} elseif (is_array($settings)) {
// Set requested class
if (array_key_exists('type', $settings)) {
call_user_func(array($this, 'set' . $type), $settings['type']);
}
if (in_array($type, $classes)) {
// Call get so that the class is initialized
$rel = call_user_func(array($this, 'get' . $type));
// Call set*() methods so that all the settings are set.
foreach ($settings as $method => $value) {
if (method_exists($rel, 'set' . $method)) {
call_user_func(array($rel, 'set' . $method), $value);
}
}
} elseif ('templateFile' == $type) {
// Remember the settings for the templateFile
$this->_templateFileSettings = $settings;
}
}
}
} | php | public function setOptions(array $opt = array())
{
// BC checks
// TODO remove in 1.1
if (isset($opt['compileDir']) || isset($opt['compile_dir'])) {
trigger_error('Dwoo ZF Adapter: the compile dir should be set in the $options[\'engine\'][\'compileDir\'] value the adapter settings', E_USER_WARNING);
}
if (isset($opt['cacheDir']) || isset($opt['cache_dir'])) {
trigger_error('Dwoo ZF Adapter: the cache dir should be set in the $options[\'engine\'][\'cacheDir\'] value the adapter settings', E_USER_WARNING);
}
// end BC
// Making sure that everything is loaded.
$classes = array('engine', 'dataProvider', 'compiler');
// Setting options to Dwoo objects...
foreach ($opt as $type => $settings) {
if (!method_exists($this, 'set' . $type)) {
throw new Dwoo_Exception("Unknown type $type");
}
if (is_string($settings) || is_object($settings)) {
call_user_func(array($this, 'set' . $type), $settings);
} elseif (is_array($settings)) {
// Set requested class
if (array_key_exists('type', $settings)) {
call_user_func(array($this, 'set' . $type), $settings['type']);
}
if (in_array($type, $classes)) {
// Call get so that the class is initialized
$rel = call_user_func(array($this, 'get' . $type));
// Call set*() methods so that all the settings are set.
foreach ($settings as $method => $value) {
if (method_exists($rel, 'set' . $method)) {
call_user_func(array($rel, 'set' . $method), $value);
}
}
} elseif ('templateFile' == $type) {
// Remember the settings for the templateFile
$this->_templateFileSettings = $settings;
}
}
}
} | [
"public",
"function",
"setOptions",
"(",
"array",
"$",
"opt",
"=",
"array",
"(",
")",
")",
"{",
"// BC checks",
"// TODO remove in 1.1",
"if",
"(",
"isset",
"(",
"$",
"opt",
"[",
"'compileDir'",
"]",
")",
"||",
"isset",
"(",
"$",
"opt",
"[",
"'compile_dir'",
"]",
")",
")",
"{",
"trigger_error",
"(",
"'Dwoo ZF Adapter: the compile dir should be set in the $options[\\'engine\\'][\\'compileDir\\'] value the adapter settings'",
",",
"E_USER_WARNING",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"opt",
"[",
"'cacheDir'",
"]",
")",
"||",
"isset",
"(",
"$",
"opt",
"[",
"'cache_dir'",
"]",
")",
")",
"{",
"trigger_error",
"(",
"'Dwoo ZF Adapter: the cache dir should be set in the $options[\\'engine\\'][\\'cacheDir\\'] value the adapter settings'",
",",
"E_USER_WARNING",
")",
";",
"}",
"// end BC",
"// Making sure that everything is loaded.\t\t",
"$",
"classes",
"=",
"array",
"(",
"'engine'",
",",
"'dataProvider'",
",",
"'compiler'",
")",
";",
"// Setting options to Dwoo objects...",
"foreach",
"(",
"$",
"opt",
"as",
"$",
"type",
"=>",
"$",
"settings",
")",
"{",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"this",
",",
"'set'",
".",
"$",
"type",
")",
")",
"{",
"throw",
"new",
"Dwoo_Exception",
"(",
"\"Unknown type $type\"",
")",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"settings",
")",
"||",
"is_object",
"(",
"$",
"settings",
")",
")",
"{",
"call_user_func",
"(",
"array",
"(",
"$",
"this",
",",
"'set'",
".",
"$",
"type",
")",
",",
"$",
"settings",
")",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"settings",
")",
")",
"{",
"// Set requested class",
"if",
"(",
"array_key_exists",
"(",
"'type'",
",",
"$",
"settings",
")",
")",
"{",
"call_user_func",
"(",
"array",
"(",
"$",
"this",
",",
"'set'",
".",
"$",
"type",
")",
",",
"$",
"settings",
"[",
"'type'",
"]",
")",
";",
"}",
"if",
"(",
"in_array",
"(",
"$",
"type",
",",
"$",
"classes",
")",
")",
"{",
"// Call get so that the class is initialized",
"$",
"rel",
"=",
"call_user_func",
"(",
"array",
"(",
"$",
"this",
",",
"'get'",
".",
"$",
"type",
")",
")",
";",
"// Call set*() methods so that all the settings are set.",
"foreach",
"(",
"$",
"settings",
"as",
"$",
"method",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"method_exists",
"(",
"$",
"rel",
",",
"'set'",
".",
"$",
"method",
")",
")",
"{",
"call_user_func",
"(",
"array",
"(",
"$",
"rel",
",",
"'set'",
".",
"$",
"method",
")",
",",
"$",
"value",
")",
";",
"}",
"}",
"}",
"elseif",
"(",
"'templateFile'",
"==",
"$",
"type",
")",
"{",
"// Remember the settings for the templateFile",
"$",
"this",
"->",
"_templateFileSettings",
"=",
"$",
"settings",
";",
"}",
"}",
"}",
"}"
] | Set object state from options array
- engine = engine class name|engine object|array of options for engine
- dataProvider = data provider class name|data provider object|array of options for data provider
- compiler = compiler class name|compiler object|array of options for compiler
- templateFile =
Array of options:
- type class name or object for engine, dataProvider or compiler
- any set* method (compileDir for setCompileDir ...)
@param array $options
@return Dwoo_Adapters_ZendFramework_View | [
"Set",
"object",
"state",
"from",
"options",
"array",
"-",
"engine",
"=",
"engine",
"class",
"name|engine",
"object|array",
"of",
"options",
"for",
"engine",
"-",
"dataProvider",
"=",
"data",
"provider",
"class",
"name|data",
"provider",
"object|array",
"of",
"options",
"for",
"data",
"provider",
"-",
"compiler",
"=",
"compiler",
"class",
"name|compiler",
"object|array",
"of",
"options",
"for",
"compiler",
"-",
"templateFile",
"="
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/ZendFramework/View.php#L93-L139 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/ZendFramework/View.php | Dwoo_Adapters_ZendFramework_View.setEngine | public function setEngine($engine)
{
// if param given as an object
if ($engine instanceof Dwoo) {
$this->_engine = $engine;
}
//
elseif (is_subclass_of($engine, 'Dwoo') || 'Dwoo' === $engine) {
$this->_engine = new $engine();
}
else {
throw new Dwoo_Exception("Custom engine must be a subclass of Dwoo");
}
} | php | public function setEngine($engine)
{
// if param given as an object
if ($engine instanceof Dwoo) {
$this->_engine = $engine;
}
//
elseif (is_subclass_of($engine, 'Dwoo') || 'Dwoo' === $engine) {
$this->_engine = new $engine();
}
else {
throw new Dwoo_Exception("Custom engine must be a subclass of Dwoo");
}
} | [
"public",
"function",
"setEngine",
"(",
"$",
"engine",
")",
"{",
"// if param given as an object",
"if",
"(",
"$",
"engine",
"instanceof",
"Dwoo",
")",
"{",
"$",
"this",
"->",
"_engine",
"=",
"$",
"engine",
";",
"}",
"//",
"elseif",
"(",
"is_subclass_of",
"(",
"$",
"engine",
",",
"'Dwoo'",
")",
"||",
"'Dwoo'",
"===",
"$",
"engine",
")",
"{",
"$",
"this",
"->",
"_engine",
"=",
"new",
"$",
"engine",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Dwoo_Exception",
"(",
"\"Custom engine must be a subclass of Dwoo\"",
")",
";",
"}",
"}"
] | Sets template engine
@param string|Dwoo Object or name of the class | [
"Sets",
"template",
"engine"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/ZendFramework/View.php#L253-L266 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/ZendFramework/View.php | Dwoo_Adapters_ZendFramework_View.setDataProvider | public function setDataProvider($data)
{
if ($data instanceof Dwoo_IDataProvider) {
$this->_dataProvider = $data;
}
elseif (is_subclass_of($data, 'Dwoo_Data') || 'Dwoo_Data' == $data) {
$this->_dataProvider = new $data();
}
else {
throw new Dwoo_Exception("Custom data provider must be a subclass of Dwoo_Data or instance of Dwoo_IDataProvider");
}
} | php | public function setDataProvider($data)
{
if ($data instanceof Dwoo_IDataProvider) {
$this->_dataProvider = $data;
}
elseif (is_subclass_of($data, 'Dwoo_Data') || 'Dwoo_Data' == $data) {
$this->_dataProvider = new $data();
}
else {
throw new Dwoo_Exception("Custom data provider must be a subclass of Dwoo_Data or instance of Dwoo_IDataProvider");
}
} | [
"public",
"function",
"setDataProvider",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"data",
"instanceof",
"Dwoo_IDataProvider",
")",
"{",
"$",
"this",
"->",
"_dataProvider",
"=",
"$",
"data",
";",
"}",
"elseif",
"(",
"is_subclass_of",
"(",
"$",
"data",
",",
"'Dwoo_Data'",
")",
"||",
"'Dwoo_Data'",
"==",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"_dataProvider",
"=",
"new",
"$",
"data",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Dwoo_Exception",
"(",
"\"Custom data provider must be a subclass of Dwoo_Data or instance of Dwoo_IDataProvider\"",
")",
";",
"}",
"}"
] | Sets Dwoo data object
@param string|Dwoo_Data Object or name of the class | [
"Sets",
"Dwoo",
"data",
"object"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/ZendFramework/View.php#L287-L298 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/ZendFramework/View.php | Dwoo_Adapters_ZendFramework_View.setCompiler | public function setCompiler($compiler)
{
// if param given as an object
if ($compiler instanceof Dwoo_ICompiler) {
$this->_compiler = $compiler;
}
// if param given as a string
elseif (is_subclass_of($compiler, 'Dwoo_Compiler') || 'Dwoo_Compiler' == $compiler) {
$this->_compiler = new $compiler;
}
else {
throw new Dwoo_Exception("Custom compiler must be a subclass of Dwoo_Compiler or instance of Dwoo_ICompiler");
}
} | php | public function setCompiler($compiler)
{
// if param given as an object
if ($compiler instanceof Dwoo_ICompiler) {
$this->_compiler = $compiler;
}
// if param given as a string
elseif (is_subclass_of($compiler, 'Dwoo_Compiler') || 'Dwoo_Compiler' == $compiler) {
$this->_compiler = new $compiler;
}
else {
throw new Dwoo_Exception("Custom compiler must be a subclass of Dwoo_Compiler or instance of Dwoo_ICompiler");
}
} | [
"public",
"function",
"setCompiler",
"(",
"$",
"compiler",
")",
"{",
"// if param given as an object",
"if",
"(",
"$",
"compiler",
"instanceof",
"Dwoo_ICompiler",
")",
"{",
"$",
"this",
"->",
"_compiler",
"=",
"$",
"compiler",
";",
"}",
"// if param given as a string",
"elseif",
"(",
"is_subclass_of",
"(",
"$",
"compiler",
",",
"'Dwoo_Compiler'",
")",
"||",
"'Dwoo_Compiler'",
"==",
"$",
"compiler",
")",
"{",
"$",
"this",
"->",
"_compiler",
"=",
"new",
"$",
"compiler",
";",
"}",
"else",
"{",
"throw",
"new",
"Dwoo_Exception",
"(",
"\"Custom compiler must be a subclass of Dwoo_Compiler or instance of Dwoo_ICompiler\"",
")",
";",
"}",
"}"
] | Sets Dwoo compiler
@param string|Dwoo_Compiler Object or name of the class | [
"Sets",
"Dwoo",
"compiler"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/ZendFramework/View.php#L320-L334 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/ZendFramework/View.php | Dwoo_Adapters_ZendFramework_View.getCompiler | public function getCompiler()
{
if (null === $this->_compiler) {
$this->_compiler = Dwoo_Compiler::compilerFactory();
}
return $this->_compiler;
} | php | public function getCompiler()
{
if (null === $this->_compiler) {
$this->_compiler = Dwoo_Compiler::compilerFactory();
}
return $this->_compiler;
} | [
"public",
"function",
"getCompiler",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"_compiler",
")",
"{",
"$",
"this",
"->",
"_compiler",
"=",
"Dwoo_Compiler",
"::",
"compilerFactory",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_compiler",
";",
"}"
] | Return the Dwoo compiler object
@return Dwoo_Data | [
"Return",
"the",
"Dwoo",
"compiler",
"object"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/ZendFramework/View.php#L341-L348 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/ZendFramework/View.php | Dwoo_Adapters_ZendFramework_View.getTemplateFile | public function getTemplateFile($template) {
$templateFileClass = $this->_templateFileClass;
$dwooTemplateFile = new $templateFileClass($template);
if (!($dwooTemplateFile instanceof Dwoo_ITemplate)) {
throw new Dwoo_Exception("Custom templateFile class must be a subclass of Dwoo_ITemplate");
}
foreach ($this->_templateFileSettings as $method => $value) {
if (method_exists($dwooTemplateFile, 'set' . $method)) {
call_user_func(array($dwooTemplateFile, 'set' . $method), $value);
}
}
return $dwooTemplateFile;
} | php | public function getTemplateFile($template) {
$templateFileClass = $this->_templateFileClass;
$dwooTemplateFile = new $templateFileClass($template);
if (!($dwooTemplateFile instanceof Dwoo_ITemplate)) {
throw new Dwoo_Exception("Custom templateFile class must be a subclass of Dwoo_ITemplate");
}
foreach ($this->_templateFileSettings as $method => $value) {
if (method_exists($dwooTemplateFile, 'set' . $method)) {
call_user_func(array($dwooTemplateFile, 'set' . $method), $value);
}
}
return $dwooTemplateFile;
} | [
"public",
"function",
"getTemplateFile",
"(",
"$",
"template",
")",
"{",
"$",
"templateFileClass",
"=",
"$",
"this",
"->",
"_templateFileClass",
";",
"$",
"dwooTemplateFile",
"=",
"new",
"$",
"templateFileClass",
"(",
"$",
"template",
")",
";",
"if",
"(",
"!",
"(",
"$",
"dwooTemplateFile",
"instanceof",
"Dwoo_ITemplate",
")",
")",
"{",
"throw",
"new",
"Dwoo_Exception",
"(",
"\"Custom templateFile class must be a subclass of Dwoo_ITemplate\"",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"_templateFileSettings",
"as",
"$",
"method",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"method_exists",
"(",
"$",
"dwooTemplateFile",
",",
"'set'",
".",
"$",
"method",
")",
")",
"{",
"call_user_func",
"(",
"array",
"(",
"$",
"dwooTemplateFile",
",",
"'set'",
".",
"$",
"method",
")",
",",
"$",
"value",
")",
";",
"}",
"}",
"return",
"$",
"dwooTemplateFile",
";",
"}"
] | Initializes Dwoo_ITemplate type of class and sets properties from _templateFileSettings
@param string Template location
@return Dwoo_ITemplate | [
"Initializes",
"Dwoo_ITemplate",
"type",
"of",
"class",
"and",
"sets",
"properties",
"from",
"_templateFileSettings"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/ZendFramework/View.php#L356-L372 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.