repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_code_tokens
listlengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
listlengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
limen/php-jobs | src/Contracts/BaseJobset.php | BaseJobset.execute | public function execute()
{
// If the jobset is finished or failed
// the jobset may need to be dispatched
// so we return true
if ($this->isFinished() || $this->isFailed()) {
return true;
}
// Just return false to tell to terminate the process
if (!$this->isInTime()) {
return false;
}
// return false means the jobset is done
// and the process should be terminated
if ($this->isDispatched() || $this->isCanceled()) {
return false;
}
try {
if (!$this->jobs) {
$this->initJobs();
}
$this->doUnorderedJobs();
$this->doOrderedJobs();
$status = $this->getJobsetExecutionStatus();
if ($status === JobsConst::JOB_SET_STATUS_FAILED) {
$this->failed();
} else {
$this->updateStatus($status);
}
} catch (\Exception $e) {
// just throw it
throw $e;
}
return true;
} | php | public function execute()
{
// If the jobset is finished or failed
// the jobset may need to be dispatched
// so we return true
if ($this->isFinished() || $this->isFailed()) {
return true;
}
// Just return false to tell to terminate the process
if (!$this->isInTime()) {
return false;
}
// return false means the jobset is done
// and the process should be terminated
if ($this->isDispatched() || $this->isCanceled()) {
return false;
}
try {
if (!$this->jobs) {
$this->initJobs();
}
$this->doUnorderedJobs();
$this->doOrderedJobs();
$status = $this->getJobsetExecutionStatus();
if ($status === JobsConst::JOB_SET_STATUS_FAILED) {
$this->failed();
} else {
$this->updateStatus($status);
}
} catch (\Exception $e) {
// just throw it
throw $e;
}
return true;
} | [
"public",
"function",
"execute",
"(",
")",
"{",
"// If the jobset is finished or failed",
"// the jobset may need to be dispatched",
"// so we return true",
"if",
"(",
"$",
"this",
"->",
"isFinished",
"(",
")",
"||",
"$",
"this",
"->",
"isFailed",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"// Just return false to tell to terminate the process",
"if",
"(",
"!",
"$",
"this",
"->",
"isInTime",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"// return false means the jobset is done",
"// and the process should be terminated",
"if",
"(",
"$",
"this",
"->",
"isDispatched",
"(",
")",
"||",
"$",
"this",
"->",
"isCanceled",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"try",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"jobs",
")",
"{",
"$",
"this",
"->",
"initJobs",
"(",
")",
";",
"}",
"$",
"this",
"->",
"doUnorderedJobs",
"(",
")",
";",
"$",
"this",
"->",
"doOrderedJobs",
"(",
")",
";",
"$",
"status",
"=",
"$",
"this",
"->",
"getJobsetExecutionStatus",
"(",
")",
";",
"if",
"(",
"$",
"status",
"===",
"JobsConst",
"::",
"JOB_SET_STATUS_FAILED",
")",
"{",
"$",
"this",
"->",
"failed",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"updateStatus",
"(",
"$",
"status",
")",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"// just throw it",
"throw",
"$",
"e",
";",
"}",
"return",
"true",
";",
"}"
]
| If return true, the jobset should be dispatched with considering its status
Or the jobset process should be terminated
@return bool
@throws \Exception | [
"If",
"return",
"true",
"the",
"jobset",
"should",
"be",
"dispatched",
"with",
"considering",
"its",
"status",
"Or",
"the",
"jobset",
"process",
"should",
"be",
"terminated"
]
| train | https://github.com/limen/php-jobs/blob/525f4082b49a7a3e69acb4cea3a622244f1616b9/src/Contracts/BaseJobset.php#L206-L244 |
limen/php-jobs | src/Contracts/BaseJobset.php | BaseJobset.dispatched | public function dispatched()
{
// Only finished or failed jobset should be dispatched
if ($this->isFinished() || $this->isFailed()) {
$status = $this->isFinished() ?
JobsConst::JOB_SET_STATUS_FINISHED_AND_DISPATCHED : JobsConst::JOB_SET_STATUS_FAILED_AND_DISPATCHED;
return $this->model->updateStatus($status);
}
return false;
} | php | public function dispatched()
{
// Only finished or failed jobset should be dispatched
if ($this->isFinished() || $this->isFailed()) {
$status = $this->isFinished() ?
JobsConst::JOB_SET_STATUS_FINISHED_AND_DISPATCHED : JobsConst::JOB_SET_STATUS_FAILED_AND_DISPATCHED;
return $this->model->updateStatus($status);
}
return false;
} | [
"public",
"function",
"dispatched",
"(",
")",
"{",
"// Only finished or failed jobset should be dispatched",
"if",
"(",
"$",
"this",
"->",
"isFinished",
"(",
")",
"||",
"$",
"this",
"->",
"isFailed",
"(",
")",
")",
"{",
"$",
"status",
"=",
"$",
"this",
"->",
"isFinished",
"(",
")",
"?",
"JobsConst",
"::",
"JOB_SET_STATUS_FINISHED_AND_DISPATCHED",
":",
"JobsConst",
"::",
"JOB_SET_STATUS_FAILED_AND_DISPATCHED",
";",
"return",
"$",
"this",
"->",
"model",
"->",
"updateStatus",
"(",
"$",
"status",
")",
";",
"}",
"return",
"false",
";",
"}"
]
| After successfully notice to commander, we mark the jobset as dispatched here. | [
"After",
"successfully",
"notice",
"to",
"commander",
"we",
"mark",
"the",
"jobset",
"as",
"dispatched",
"here",
"."
]
| train | https://github.com/limen/php-jobs/blob/525f4082b49a7a3e69acb4cea3a622244f1616b9/src/Contracts/BaseJobset.php#L309-L320 |
limen/php-jobs | src/Contracts/BaseJobset.php | BaseJobset.getJobsetExecutionStatus | public function getJobsetExecutionStatus()
{
$finished = count($this->jobs) > 0 ? true : false;
$failed = false;
$middle = false;
foreach ($this->jobs as $job) {
if ($job->isFailed()) {
$finished = false;
$middle = false;
$failed = true;
break;
}
$finished = $finished && $job->isFinished();
if (!$job->isFinished() && !$job->isFailed()) {
$middle = true;
}
}
if ($failed) {
return JobsConst::JOB_SET_STATUS_FAILED;
} elseif ($finished) {
return JobsConst::JOB_SET_STATUS_FINISHED;
} elseif ($middle) {
return JobsConst::JOB_SET_STATUS_ONGOING;
} else {
return JobsConst::JOB_SET_STATUS_DEFAULT;
}
} | php | public function getJobsetExecutionStatus()
{
$finished = count($this->jobs) > 0 ? true : false;
$failed = false;
$middle = false;
foreach ($this->jobs as $job) {
if ($job->isFailed()) {
$finished = false;
$middle = false;
$failed = true;
break;
}
$finished = $finished && $job->isFinished();
if (!$job->isFinished() && !$job->isFailed()) {
$middle = true;
}
}
if ($failed) {
return JobsConst::JOB_SET_STATUS_FAILED;
} elseif ($finished) {
return JobsConst::JOB_SET_STATUS_FINISHED;
} elseif ($middle) {
return JobsConst::JOB_SET_STATUS_ONGOING;
} else {
return JobsConst::JOB_SET_STATUS_DEFAULT;
}
} | [
"public",
"function",
"getJobsetExecutionStatus",
"(",
")",
"{",
"$",
"finished",
"=",
"count",
"(",
"$",
"this",
"->",
"jobs",
")",
">",
"0",
"?",
"true",
":",
"false",
";",
"$",
"failed",
"=",
"false",
";",
"$",
"middle",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"jobs",
"as",
"$",
"job",
")",
"{",
"if",
"(",
"$",
"job",
"->",
"isFailed",
"(",
")",
")",
"{",
"$",
"finished",
"=",
"false",
";",
"$",
"middle",
"=",
"false",
";",
"$",
"failed",
"=",
"true",
";",
"break",
";",
"}",
"$",
"finished",
"=",
"$",
"finished",
"&&",
"$",
"job",
"->",
"isFinished",
"(",
")",
";",
"if",
"(",
"!",
"$",
"job",
"->",
"isFinished",
"(",
")",
"&&",
"!",
"$",
"job",
"->",
"isFailed",
"(",
")",
")",
"{",
"$",
"middle",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"$",
"failed",
")",
"{",
"return",
"JobsConst",
"::",
"JOB_SET_STATUS_FAILED",
";",
"}",
"elseif",
"(",
"$",
"finished",
")",
"{",
"return",
"JobsConst",
"::",
"JOB_SET_STATUS_FINISHED",
";",
"}",
"elseif",
"(",
"$",
"middle",
")",
"{",
"return",
"JobsConst",
"::",
"JOB_SET_STATUS_ONGOING",
";",
"}",
"else",
"{",
"return",
"JobsConst",
"::",
"JOB_SET_STATUS_DEFAULT",
";",
"}",
"}"
]
| Get jobset execution status from sub jobs statuses.
At least one job failed, the jobset is failed.
All jobs finished, the jobset is finished.
At least one job has been executed, the jobset is ongoing.
All jobs have not been executed, the jobset is in default status.
@return int | [
"Get",
"jobset",
"execution",
"status",
"from",
"sub",
"jobs",
"statuses",
".",
"At",
"least",
"one",
"job",
"failed",
"the",
"jobset",
"is",
"failed",
".",
"All",
"jobs",
"finished",
"the",
"jobset",
"is",
"finished",
".",
"At",
"least",
"one",
"job",
"has",
"been",
"executed",
"the",
"jobset",
"is",
"ongoing",
".",
"All",
"jobs",
"have",
"not",
"been",
"executed",
"the",
"jobset",
"is",
"in",
"default",
"status",
"."
]
| train | https://github.com/limen/php-jobs/blob/525f4082b49a7a3e69acb4cea3a622244f1616b9/src/Contracts/BaseJobset.php#L341-L369 |
limen/php-jobs | src/Contracts/BaseJobset.php | BaseJobset.doOrderedJobs | protected function doOrderedJobs()
{
$jobNames = $this->getOrderedJobNames();
foreach ($jobNames as $jobName) {
$job = $this->getLocalJob($jobName);
if (!$job) {
throw new \Exception("job [$jobName] not exists");
}
$job->execute();
$this->updateLocalJob($job);
if (!$job->isFinished()) {
break;
}
}
} | php | protected function doOrderedJobs()
{
$jobNames = $this->getOrderedJobNames();
foreach ($jobNames as $jobName) {
$job = $this->getLocalJob($jobName);
if (!$job) {
throw new \Exception("job [$jobName] not exists");
}
$job->execute();
$this->updateLocalJob($job);
if (!$job->isFinished()) {
break;
}
}
} | [
"protected",
"function",
"doOrderedJobs",
"(",
")",
"{",
"$",
"jobNames",
"=",
"$",
"this",
"->",
"getOrderedJobNames",
"(",
")",
";",
"foreach",
"(",
"$",
"jobNames",
"as",
"$",
"jobName",
")",
"{",
"$",
"job",
"=",
"$",
"this",
"->",
"getLocalJob",
"(",
"$",
"jobName",
")",
";",
"if",
"(",
"!",
"$",
"job",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"job [$jobName] not exists\"",
")",
";",
"}",
"$",
"job",
"->",
"execute",
"(",
")",
";",
"$",
"this",
"->",
"updateLocalJob",
"(",
"$",
"job",
")",
";",
"if",
"(",
"!",
"$",
"job",
"->",
"isFinished",
"(",
")",
")",
"{",
"break",
";",
"}",
"}",
"}"
]
| Do ordered jobs | [
"Do",
"ordered",
"jobs"
]
| train | https://github.com/limen/php-jobs/blob/525f4082b49a7a3e69acb4cea3a622244f1616b9/src/Contracts/BaseJobset.php#L374-L388 |
limen/php-jobs | src/Contracts/BaseJobset.php | BaseJobset.doUnorderedJobs | protected function doUnorderedJobs()
{
$jobNames = $this->getUnorderedJobNames();
foreach ($jobNames as $jobName) {
$job = $this->getLocalJob($jobName);
if (!$job) {
throw new \Exception("job [$jobName] not exists");
}
$job->execute();
$this->updateLocalJob($job);
}
} | php | protected function doUnorderedJobs()
{
$jobNames = $this->getUnorderedJobNames();
foreach ($jobNames as $jobName) {
$job = $this->getLocalJob($jobName);
if (!$job) {
throw new \Exception("job [$jobName] not exists");
}
$job->execute();
$this->updateLocalJob($job);
}
} | [
"protected",
"function",
"doUnorderedJobs",
"(",
")",
"{",
"$",
"jobNames",
"=",
"$",
"this",
"->",
"getUnorderedJobNames",
"(",
")",
";",
"foreach",
"(",
"$",
"jobNames",
"as",
"$",
"jobName",
")",
"{",
"$",
"job",
"=",
"$",
"this",
"->",
"getLocalJob",
"(",
"$",
"jobName",
")",
";",
"if",
"(",
"!",
"$",
"job",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"job [$jobName] not exists\"",
")",
";",
"}",
"$",
"job",
"->",
"execute",
"(",
")",
";",
"$",
"this",
"->",
"updateLocalJob",
"(",
"$",
"job",
")",
";",
"}",
"}"
]
| Do unordered jobs | [
"Do",
"unordered",
"jobs"
]
| train | https://github.com/limen/php-jobs/blob/525f4082b49a7a3e69acb4cea3a622244f1616b9/src/Contracts/BaseJobset.php#L393-L405 |
limen/php-jobs | src/Contracts/BaseJobset.php | BaseJobset.getJobsEarliestTryAt | protected function getJobsEarliestTryAt()
{
$tryAt = date('Y-m-d H:i:s');
foreach ($this->jobs as $job) {
if (!$job->isFinished() && Helper::datetimeLT($job->getTryAt(), $tryAt)) {
$tryAt = $job->getTryAt();
}
}
return $tryAt;
} | php | protected function getJobsEarliestTryAt()
{
$tryAt = date('Y-m-d H:i:s');
foreach ($this->jobs as $job) {
if (!$job->isFinished() && Helper::datetimeLT($job->getTryAt(), $tryAt)) {
$tryAt = $job->getTryAt();
}
}
return $tryAt;
} | [
"protected",
"function",
"getJobsEarliestTryAt",
"(",
")",
"{",
"$",
"tryAt",
"=",
"date",
"(",
"'Y-m-d H:i:s'",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"jobs",
"as",
"$",
"job",
")",
"{",
"if",
"(",
"!",
"$",
"job",
"->",
"isFinished",
"(",
")",
"&&",
"Helper",
"::",
"datetimeLT",
"(",
"$",
"job",
"->",
"getTryAt",
"(",
")",
",",
"$",
"tryAt",
")",
")",
"{",
"$",
"tryAt",
"=",
"$",
"job",
"->",
"getTryAt",
"(",
")",
";",
"}",
"}",
"return",
"$",
"tryAt",
";",
"}"
]
| get the earliest job try at time, except the finished jobs
@return false|mixed|string | [
"get",
"the",
"earliest",
"job",
"try",
"at",
"time",
"except",
"the",
"finished",
"jobs"
]
| train | https://github.com/limen/php-jobs/blob/525f4082b49a7a3e69acb4cea3a622244f1616b9/src/Contracts/BaseJobset.php#L412-L423 |
seeruo/framework | src/Command/BuildCommand.php | BuildCommand.execute | protected function execute(InputInterface $input, OutputInterface $output)
{
try {
$output->writeln([
'Start Building...',
'<bg=yellow;>=================================</>',
]);
$build = new BuildService();
$active = $input->getOption('active');
if ($active === false) {
$build->run();
}else{
$build->listen();
}
$output->writeln('<bg=yellow;>Build Success!!!</>');
$output->writeln('');
} catch (Exception $e) {
$output->writeln('<bg=red;>'.$e->getMessage().'</> <options=bold></>');
$output->writeln('');
}
} | php | protected function execute(InputInterface $input, OutputInterface $output)
{
try {
$output->writeln([
'Start Building...',
'<bg=yellow;>=================================</>',
]);
$build = new BuildService();
$active = $input->getOption('active');
if ($active === false) {
$build->run();
}else{
$build->listen();
}
$output->writeln('<bg=yellow;>Build Success!!!</>');
$output->writeln('');
} catch (Exception $e) {
$output->writeln('<bg=red;>'.$e->getMessage().'</> <options=bold></>');
$output->writeln('');
}
} | [
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"try",
"{",
"$",
"output",
"->",
"writeln",
"(",
"[",
"'Start Building...'",
",",
"'<bg=yellow;>=================================</>'",
",",
"]",
")",
";",
"$",
"build",
"=",
"new",
"BuildService",
"(",
")",
";",
"$",
"active",
"=",
"$",
"input",
"->",
"getOption",
"(",
"'active'",
")",
";",
"if",
"(",
"$",
"active",
"===",
"false",
")",
"{",
"$",
"build",
"->",
"run",
"(",
")",
";",
"}",
"else",
"{",
"$",
"build",
"->",
"listen",
"(",
")",
";",
"}",
"$",
"output",
"->",
"writeln",
"(",
"'<bg=yellow;>Build Success!!!</>'",
")",
";",
"$",
"output",
"->",
"writeln",
"(",
"''",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"output",
"->",
"writeln",
"(",
"'<bg=red;>'",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
".",
"'</> <options=bold></>'",
")",
";",
"$",
"output",
"->",
"writeln",
"(",
"''",
")",
";",
"}",
"}"
]
| [执行命令]
@DateTime 2018-12-13
@param InputInterface $input 输入对象
@param OutputInterface $output 输出对象 | [
"[",
"执行命令",
"]"
]
| train | https://github.com/seeruo/framework/blob/689c6e95bc95fe2ae037e056d8228820dd08d7e9/src/Command/BuildCommand.php#L43-L66 |
traderinteractive/util-string-php | src/Strings.php | Strings.format | public static function format(string $format, string ...$arguments) : string
{
foreach ($arguments as $key => $value) {
$format = str_replace("{{$key}}", (string)$value, $format);
}
return $format;
} | php | public static function format(string $format, string ...$arguments) : string
{
foreach ($arguments as $key => $value) {
$format = str_replace("{{$key}}", (string)$value, $format);
}
return $format;
} | [
"public",
"static",
"function",
"format",
"(",
"string",
"$",
"format",
",",
"string",
"...",
"$",
"arguments",
")",
":",
"string",
"{",
"foreach",
"(",
"$",
"arguments",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"format",
"=",
"str_replace",
"(",
"\"{{$key}}\"",
",",
"(",
"string",
")",
"$",
"value",
",",
"$",
"format",
")",
";",
"}",
"return",
"$",
"format",
";",
"}"
]
| Replaces the format items in a specified string with the string representation of n specified objects.
@param string $format A composit format string
@param mixed $arguments Variable number of items to format.
@return string Returns a copy of format in which the format items have been
replaced by the string representations of arg0, arg1,... argN. | [
"Replaces",
"the",
"format",
"items",
"in",
"a",
"specified",
"string",
"with",
"the",
"string",
"representation",
"of",
"n",
"specified",
"objects",
"."
]
| train | https://github.com/traderinteractive/util-string-php/blob/5c05605fd836f3a2822065d474e814c8644857b8/src/Strings.php#L22-L29 |
traderinteractive/util-string-php | src/Strings.php | Strings.endsWith | public static function endsWith(string $string, string $suffix, &$nonSuffix = null) : bool
{
$suffixLength = strlen($suffix);
if ($suffixLength === 0) {
$nonSuffix = $string;
return true;
}
if (empty($string)) {
$nonSuffix = '';
return false;
}
if (substr_compare($string, $suffix, -$suffixLength, $suffixLength) !== 0) {
$nonSuffix = $string;
return false;
}
$nonSuffix = substr($string, 0, -$suffixLength);
return true;
} | php | public static function endsWith(string $string, string $suffix, &$nonSuffix = null) : bool
{
$suffixLength = strlen($suffix);
if ($suffixLength === 0) {
$nonSuffix = $string;
return true;
}
if (empty($string)) {
$nonSuffix = '';
return false;
}
if (substr_compare($string, $suffix, -$suffixLength, $suffixLength) !== 0) {
$nonSuffix = $string;
return false;
}
$nonSuffix = substr($string, 0, -$suffixLength);
return true;
} | [
"public",
"static",
"function",
"endsWith",
"(",
"string",
"$",
"string",
",",
"string",
"$",
"suffix",
",",
"&",
"$",
"nonSuffix",
"=",
"null",
")",
":",
"bool",
"{",
"$",
"suffixLength",
"=",
"strlen",
"(",
"$",
"suffix",
")",
";",
"if",
"(",
"$",
"suffixLength",
"===",
"0",
")",
"{",
"$",
"nonSuffix",
"=",
"$",
"string",
";",
"return",
"true",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"string",
")",
")",
"{",
"$",
"nonSuffix",
"=",
"''",
";",
"return",
"false",
";",
"}",
"if",
"(",
"substr_compare",
"(",
"$",
"string",
",",
"$",
"suffix",
",",
"-",
"$",
"suffixLength",
",",
"$",
"suffixLength",
")",
"!==",
"0",
")",
"{",
"$",
"nonSuffix",
"=",
"$",
"string",
";",
"return",
"false",
";",
"}",
"$",
"nonSuffix",
"=",
"substr",
"(",
"$",
"string",
",",
"0",
",",
"-",
"$",
"suffixLength",
")",
";",
"return",
"true",
";",
"}"
]
| Checks if $string ends with $suffix and puts the rest of the $string in $nonSuffix.
@param string $string The string to check
@param string $suffix The suffix to check for
@param mixed &$nonSuffix This is the part of the string that is not the suffix.
@return bool whether the $string ended with $suffix or not. | [
"Checks",
"if",
"$string",
"ends",
"with",
"$suffix",
"and",
"puts",
"the",
"rest",
"of",
"the",
"$string",
"in",
"$nonSuffix",
"."
]
| train | https://github.com/traderinteractive/util-string-php/blob/5c05605fd836f3a2822065d474e814c8644857b8/src/Strings.php#L40-L61 |
traderinteractive/util-string-php | src/Strings.php | Strings.ellipsize | public static function ellipsize(string $string, int $maxLength, string $suffix = '...') : string
{
if ($maxLength < 0) {
throw new \InvalidArgumentException('$maxLength is negative');
}
if (strlen($string) <= $maxLength) {
return $string;
}
$trimmedLength = $maxLength - strlen($suffix);
$string = substr($string, 0, max(0, $trimmedLength));
if ($string === '') {
return substr($suffix, 0, $maxLength);
}
return $string . $suffix;
} | php | public static function ellipsize(string $string, int $maxLength, string $suffix = '...') : string
{
if ($maxLength < 0) {
throw new \InvalidArgumentException('$maxLength is negative');
}
if (strlen($string) <= $maxLength) {
return $string;
}
$trimmedLength = $maxLength - strlen($suffix);
$string = substr($string, 0, max(0, $trimmedLength));
if ($string === '') {
return substr($suffix, 0, $maxLength);
}
return $string . $suffix;
} | [
"public",
"static",
"function",
"ellipsize",
"(",
"string",
"$",
"string",
",",
"int",
"$",
"maxLength",
",",
"string",
"$",
"suffix",
"=",
"'...'",
")",
":",
"string",
"{",
"if",
"(",
"$",
"maxLength",
"<",
"0",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'$maxLength is negative'",
")",
";",
"}",
"if",
"(",
"strlen",
"(",
"$",
"string",
")",
"<=",
"$",
"maxLength",
")",
"{",
"return",
"$",
"string",
";",
"}",
"$",
"trimmedLength",
"=",
"$",
"maxLength",
"-",
"strlen",
"(",
"$",
"suffix",
")",
";",
"$",
"string",
"=",
"substr",
"(",
"$",
"string",
",",
"0",
",",
"max",
"(",
"0",
",",
"$",
"trimmedLength",
")",
")",
";",
"if",
"(",
"$",
"string",
"===",
"''",
")",
"{",
"return",
"substr",
"(",
"$",
"suffix",
",",
"0",
",",
"$",
"maxLength",
")",
";",
"}",
"return",
"$",
"string",
".",
"$",
"suffix",
";",
"}"
]
| Truncates the string to the given length, with an ellipsis at the end.
@param string $string The string to shorten.
@param int $maxLength The length to truncate the string to. The result will not be longer than this, but may be
shorter.
@param string $suffix The string to append when truncating. Typically this will be an ellipsis.
@return string The truncated string with the ellipsis included if truncation occured.
@throws \InvalidArgumentException if $maxLength is negative | [
"Truncates",
"the",
"string",
"to",
"the",
"given",
"length",
"with",
"an",
"ellipsis",
"at",
"the",
"end",
"."
]
| train | https://github.com/traderinteractive/util-string-php/blob/5c05605fd836f3a2822065d474e814c8644857b8/src/Strings.php#L75-L93 |
trafficgate/shell-command | src/ShellOption.php | ShellOption.enable | public function enable($enable = true)
{
if (! is_bool($enable)) {
throw new InvalidArgumentException("enable must be a boolean. [$enable] given.");
}
$this->enabled = $enable;
return $this;
} | php | public function enable($enable = true)
{
if (! is_bool($enable)) {
throw new InvalidArgumentException("enable must be a boolean. [$enable] given.");
}
$this->enabled = $enable;
return $this;
} | [
"public",
"function",
"enable",
"(",
"$",
"enable",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"is_bool",
"(",
"$",
"enable",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"enable must be a boolean. [$enable] given.\"",
")",
";",
"}",
"$",
"this",
"->",
"enabled",
"=",
"$",
"enable",
";",
"return",
"$",
"this",
";",
"}"
]
| Enable the option.
@param bool|true $enable
@throws InvalidArgumentException
@return $this | [
"Enable",
"the",
"option",
"."
]
| train | https://github.com/trafficgate/shell-command/blob/1a5f3fcf689f33098b192c34839effe309202c0e/src/ShellOption.php#L100-L109 |
trafficgate/shell-command | src/ShellOption.php | ShellOption.hasValue | public function hasValue($value)
{
$index = array_search($value, $this->values);
if ($index === false) {
return false;
}
return true;
} | php | public function hasValue($value)
{
$index = array_search($value, $this->values);
if ($index === false) {
return false;
}
return true;
} | [
"public",
"function",
"hasValue",
"(",
"$",
"value",
")",
"{",
"$",
"index",
"=",
"array_search",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"values",
")",
";",
"if",
"(",
"$",
"index",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
]
| Return whether this option has the given value or not.
@param mixed $value
@return bool | [
"Return",
"whether",
"this",
"option",
"has",
"the",
"given",
"value",
"or",
"not",
"."
]
| train | https://github.com/trafficgate/shell-command/blob/1a5f3fcf689f33098b192c34839effe309202c0e/src/ShellOption.php#L150-L159 |
trafficgate/shell-command | src/ShellOption.php | ShellOption.addValue | public function addValue($value)
{
$this->assertCanHaveValue();
$this->assertValueIsValid($value);
if ($this->canHaveMultipleValues() && ! $this->hasValue($value)) {
$value = array_merge($this->values, (array) $value);
}
$this->values = (array) $value;
return $this;
} | php | public function addValue($value)
{
$this->assertCanHaveValue();
$this->assertValueIsValid($value);
if ($this->canHaveMultipleValues() && ! $this->hasValue($value)) {
$value = array_merge($this->values, (array) $value);
}
$this->values = (array) $value;
return $this;
} | [
"public",
"function",
"addValue",
"(",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"assertCanHaveValue",
"(",
")",
";",
"$",
"this",
"->",
"assertValueIsValid",
"(",
"$",
"value",
")",
";",
"if",
"(",
"$",
"this",
"->",
"canHaveMultipleValues",
"(",
")",
"&&",
"!",
"$",
"this",
"->",
"hasValue",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"values",
",",
"(",
"array",
")",
"$",
"value",
")",
";",
"}",
"$",
"this",
"->",
"values",
"=",
"(",
"array",
")",
"$",
"value",
";",
"return",
"$",
"this",
";",
"}"
]
| Add a new value to this option.
@param int|string $value
@return $this | [
"Add",
"a",
"new",
"value",
"to",
"this",
"option",
"."
]
| train | https://github.com/trafficgate/shell-command/blob/1a5f3fcf689f33098b192c34839effe309202c0e/src/ShellOption.php#L178-L190 |
trafficgate/shell-command | src/ShellOption.php | ShellOption.addValues | public function addValues(array $values = [])
{
$this->assertCanHaveMultipleValues();
foreach ($values as $value) {
$this->addValue($value);
}
return $this;
} | php | public function addValues(array $values = [])
{
$this->assertCanHaveMultipleValues();
foreach ($values as $value) {
$this->addValue($value);
}
return $this;
} | [
"public",
"function",
"addValues",
"(",
"array",
"$",
"values",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"assertCanHaveMultipleValues",
"(",
")",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"addValue",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Add multiple values to this option.
@param array $values
@return $this | [
"Add",
"multiple",
"values",
"to",
"this",
"option",
"."
]
| train | https://github.com/trafficgate/shell-command/blob/1a5f3fcf689f33098b192c34839effe309202c0e/src/ShellOption.php#L199-L208 |
trafficgate/shell-command | src/ShellOption.php | ShellOption.removeValue | public function removeValue($value)
{
if (! $this->canHaveMultipleValues() && ! isset($value)) {
$this->values = [];
$this->enable($enable = false);
return $this;
}
$this->assertValueIsValid($value);
$this->assertCanHaveValue();
if ($this->hasValue($value)) {
$index = array_search($value, $this->values);
unset($this->values[$index]);
$this->values = array_values($this->values);
}
return $this;
} | php | public function removeValue($value)
{
if (! $this->canHaveMultipleValues() && ! isset($value)) {
$this->values = [];
$this->enable($enable = false);
return $this;
}
$this->assertValueIsValid($value);
$this->assertCanHaveValue();
if ($this->hasValue($value)) {
$index = array_search($value, $this->values);
unset($this->values[$index]);
$this->values = array_values($this->values);
}
return $this;
} | [
"public",
"function",
"removeValue",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"canHaveMultipleValues",
"(",
")",
"&&",
"!",
"isset",
"(",
"$",
"value",
")",
")",
"{",
"$",
"this",
"->",
"values",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"enable",
"(",
"$",
"enable",
"=",
"false",
")",
";",
"return",
"$",
"this",
";",
"}",
"$",
"this",
"->",
"assertValueIsValid",
"(",
"$",
"value",
")",
";",
"$",
"this",
"->",
"assertCanHaveValue",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"hasValue",
"(",
"$",
"value",
")",
")",
"{",
"$",
"index",
"=",
"array_search",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"values",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"values",
"[",
"$",
"index",
"]",
")",
";",
"$",
"this",
"->",
"values",
"=",
"array_values",
"(",
"$",
"this",
"->",
"values",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Remove the given value from the option.
@param int|string $value
@return $this | [
"Remove",
"the",
"given",
"value",
"from",
"the",
"option",
"."
]
| train | https://github.com/trafficgate/shell-command/blob/1a5f3fcf689f33098b192c34839effe309202c0e/src/ShellOption.php#L217-L236 |
trafficgate/shell-command | src/ShellOption.php | ShellOption.removeValues | public function removeValues(array $values = [])
{
$this->assertCanHaveMultipleValues();
foreach ($values as $value) {
$this->removeValue($value);
}
return $this;
} | php | public function removeValues(array $values = [])
{
$this->assertCanHaveMultipleValues();
foreach ($values as $value) {
$this->removeValue($value);
}
return $this;
} | [
"public",
"function",
"removeValues",
"(",
"array",
"$",
"values",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"assertCanHaveMultipleValues",
"(",
")",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"removeValue",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Remove the given values from the option.
@param array $values
@return $this | [
"Remove",
"the",
"given",
"values",
"from",
"the",
"option",
"."
]
| train | https://github.com/trafficgate/shell-command/blob/1a5f3fcf689f33098b192c34839effe309202c0e/src/ShellOption.php#L245-L254 |
trafficgate/shell-command | src/ShellOption.php | ShellOption.getArray | public function getArray()
{
$options = [];
if ($this->isDisabled() || $this->canHaveValue() && empty($this->values)) {
return $options;
}
foreach ($this->values as $value) {
$options[] = $this->flag();
$options[] = $value;
}
if (empty($options)) {
$options[] = $this->flag();
}
return $options;
} | php | public function getArray()
{
$options = [];
if ($this->isDisabled() || $this->canHaveValue() && empty($this->values)) {
return $options;
}
foreach ($this->values as $value) {
$options[] = $this->flag();
$options[] = $value;
}
if (empty($options)) {
$options[] = $this->flag();
}
return $options;
} | [
"public",
"function",
"getArray",
"(",
")",
"{",
"$",
"options",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"isDisabled",
"(",
")",
"||",
"$",
"this",
"->",
"canHaveValue",
"(",
")",
"&&",
"empty",
"(",
"$",
"this",
"->",
"values",
")",
")",
"{",
"return",
"$",
"options",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"values",
"as",
"$",
"value",
")",
"{",
"$",
"options",
"[",
"]",
"=",
"$",
"this",
"->",
"flag",
"(",
")",
";",
"$",
"options",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"options",
")",
")",
"{",
"$",
"options",
"[",
"]",
"=",
"$",
"this",
"->",
"flag",
"(",
")",
";",
"}",
"return",
"$",
"options",
";",
"}"
]
| Get the option and its values as an array.
@return array | [
"Get",
"the",
"option",
"and",
"its",
"values",
"as",
"an",
"array",
"."
]
| train | https://github.com/trafficgate/shell-command/blob/1a5f3fcf689f33098b192c34839effe309202c0e/src/ShellOption.php#L261-L279 |
trafficgate/shell-command | src/ShellOption.php | ShellOption.parseFlag | private function parseFlag($flag)
{
$flag = trim($flag);
$pattern = '/^'.// Match start of string
'('.// Start Group
'(?<flag>(?:-\w|--\w[\w-]+))'.// Match Group <flag>
'(?<enable>\+)?'.//Enable option by default (useful for creating special commands)
')'.// End Group
'('.// Start Group
'(?<can_have_value>=)?'.// Match Group <can_have_value>
'(?<can_have_multiple_values>\*)?'.// Match Group <can_have_multiple_values>
'(?<values>'.// Match Group <values>
'(?(<can_have_multiple_values>)'.// If <can_have_multiple_values>
'(\w+,)*\w+|'.// Match multiple comma-separated values
'(?(<can_have_value>)'.// Else if <can_have_value>
'\w+'.// Match only a single value
')'.// End if <can_have_value>
')'.// End if <can_have_multiple_values>
')?'.// End Group <values>
')?'.// End Group
'('.// Start Group
'\s+:\s+'.// [space] followed by ':' followed by [space]
'(?<description>.+)'.// Match Group <description>
')?'.// End Group
'$/'; // Match end of string
$matches = [];
$result = preg_match($pattern, $flag, $matches);
if ($result === 0 || $result === false) {
throw new LogicException("[$flag] is improperly formatted for a shell option.");
}
// Set flag
$parsedFlag['flag'] = null;
if (isset($matches['flag'])) {
$parsedFlag['flag'] = $matches['flag'];
}
// Set enable
$parsedFlag['enable'] = false;
if (! empty($matches['enable'])) {
$parsedFlag['enable'] = true;
}
// Set can have value
$parsedFlag['can_have_value'] = false;
if (! empty($matches['can_have_value'])) {
$parsedFlag['can_have_value'] = true;
}
// Set can have multiple values
$parsedFlag['can_have_multiple_values'] = false;
if (! empty($matches['can_have_multiple_values'])) {
$parsedFlag['can_have_multiple_values'] = true;
}
// Set the values
$parsedFlag['values'] = [];
if (! empty($matches['values']) && $parsedFlag['can_have_value']) {
$parsedFlag['values'] = $matches['values'];
if ($parsedFlag['can_have_multiple_values']) {
$parsedFlag['values'] = explode(',', $matches['values']);
}
}
// Set the description
$parsedFlag['description'] = null;
if (isset($matches['description'])) {
$parsedFlag['description'] = $matches['description'];
}
return $parsedFlag;
} | php | private function parseFlag($flag)
{
$flag = trim($flag);
$pattern = '/^'.// Match start of string
'('.// Start Group
'(?<flag>(?:-\w|--\w[\w-]+))'.// Match Group <flag>
'(?<enable>\+)?'.//Enable option by default (useful for creating special commands)
')'.// End Group
'('.// Start Group
'(?<can_have_value>=)?'.// Match Group <can_have_value>
'(?<can_have_multiple_values>\*)?'.// Match Group <can_have_multiple_values>
'(?<values>'.// Match Group <values>
'(?(<can_have_multiple_values>)'.// If <can_have_multiple_values>
'(\w+,)*\w+|'.// Match multiple comma-separated values
'(?(<can_have_value>)'.// Else if <can_have_value>
'\w+'.// Match only a single value
')'.// End if <can_have_value>
')'.// End if <can_have_multiple_values>
')?'.// End Group <values>
')?'.// End Group
'('.// Start Group
'\s+:\s+'.// [space] followed by ':' followed by [space]
'(?<description>.+)'.// Match Group <description>
')?'.// End Group
'$/'; // Match end of string
$matches = [];
$result = preg_match($pattern, $flag, $matches);
if ($result === 0 || $result === false) {
throw new LogicException("[$flag] is improperly formatted for a shell option.");
}
// Set flag
$parsedFlag['flag'] = null;
if (isset($matches['flag'])) {
$parsedFlag['flag'] = $matches['flag'];
}
// Set enable
$parsedFlag['enable'] = false;
if (! empty($matches['enable'])) {
$parsedFlag['enable'] = true;
}
// Set can have value
$parsedFlag['can_have_value'] = false;
if (! empty($matches['can_have_value'])) {
$parsedFlag['can_have_value'] = true;
}
// Set can have multiple values
$parsedFlag['can_have_multiple_values'] = false;
if (! empty($matches['can_have_multiple_values'])) {
$parsedFlag['can_have_multiple_values'] = true;
}
// Set the values
$parsedFlag['values'] = [];
if (! empty($matches['values']) && $parsedFlag['can_have_value']) {
$parsedFlag['values'] = $matches['values'];
if ($parsedFlag['can_have_multiple_values']) {
$parsedFlag['values'] = explode(',', $matches['values']);
}
}
// Set the description
$parsedFlag['description'] = null;
if (isset($matches['description'])) {
$parsedFlag['description'] = $matches['description'];
}
return $parsedFlag;
} | [
"private",
"function",
"parseFlag",
"(",
"$",
"flag",
")",
"{",
"$",
"flag",
"=",
"trim",
"(",
"$",
"flag",
")",
";",
"$",
"pattern",
"=",
"'/^'",
".",
"// Match start of string",
"'('",
".",
"// Start Group",
"'(?<flag>(?:-\\w|--\\w[\\w-]+))'",
".",
"// Match Group <flag>",
"'(?<enable>\\+)?'",
".",
"//Enable option by default (useful for creating special commands)",
"')'",
".",
"// End Group",
"'('",
".",
"// Start Group",
"'(?<can_have_value>=)?'",
".",
"// Match Group <can_have_value>",
"'(?<can_have_multiple_values>\\*)?'",
".",
"// Match Group <can_have_multiple_values>",
"'(?<values>'",
".",
"// Match Group <values>",
"'(?(<can_have_multiple_values>)'",
".",
"// If <can_have_multiple_values>",
"'(\\w+,)*\\w+|'",
".",
"// Match multiple comma-separated values",
"'(?(<can_have_value>)'",
".",
"// Else if <can_have_value>",
"'\\w+'",
".",
"// Match only a single value",
"')'",
".",
"// End if <can_have_value>",
"')'",
".",
"// End if <can_have_multiple_values>",
"')?'",
".",
"// End Group <values>",
"')?'",
".",
"// End Group",
"'('",
".",
"// Start Group",
"'\\s+:\\s+'",
".",
"// [space] followed by ':' followed by [space]",
"'(?<description>.+)'",
".",
"// Match Group <description>",
"')?'",
".",
"// End Group",
"'$/'",
";",
"// Match end of string",
"$",
"matches",
"=",
"[",
"]",
";",
"$",
"result",
"=",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"flag",
",",
"$",
"matches",
")",
";",
"if",
"(",
"$",
"result",
"===",
"0",
"||",
"$",
"result",
"===",
"false",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"\"[$flag] is improperly formatted for a shell option.\"",
")",
";",
"}",
"// Set flag",
"$",
"parsedFlag",
"[",
"'flag'",
"]",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"matches",
"[",
"'flag'",
"]",
")",
")",
"{",
"$",
"parsedFlag",
"[",
"'flag'",
"]",
"=",
"$",
"matches",
"[",
"'flag'",
"]",
";",
"}",
"// Set enable",
"$",
"parsedFlag",
"[",
"'enable'",
"]",
"=",
"false",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"matches",
"[",
"'enable'",
"]",
")",
")",
"{",
"$",
"parsedFlag",
"[",
"'enable'",
"]",
"=",
"true",
";",
"}",
"// Set can have value",
"$",
"parsedFlag",
"[",
"'can_have_value'",
"]",
"=",
"false",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"matches",
"[",
"'can_have_value'",
"]",
")",
")",
"{",
"$",
"parsedFlag",
"[",
"'can_have_value'",
"]",
"=",
"true",
";",
"}",
"// Set can have multiple values",
"$",
"parsedFlag",
"[",
"'can_have_multiple_values'",
"]",
"=",
"false",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"matches",
"[",
"'can_have_multiple_values'",
"]",
")",
")",
"{",
"$",
"parsedFlag",
"[",
"'can_have_multiple_values'",
"]",
"=",
"true",
";",
"}",
"// Set the values",
"$",
"parsedFlag",
"[",
"'values'",
"]",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"matches",
"[",
"'values'",
"]",
")",
"&&",
"$",
"parsedFlag",
"[",
"'can_have_value'",
"]",
")",
"{",
"$",
"parsedFlag",
"[",
"'values'",
"]",
"=",
"$",
"matches",
"[",
"'values'",
"]",
";",
"if",
"(",
"$",
"parsedFlag",
"[",
"'can_have_multiple_values'",
"]",
")",
"{",
"$",
"parsedFlag",
"[",
"'values'",
"]",
"=",
"explode",
"(",
"','",
",",
"$",
"matches",
"[",
"'values'",
"]",
")",
";",
"}",
"}",
"// Set the description",
"$",
"parsedFlag",
"[",
"'description'",
"]",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"matches",
"[",
"'description'",
"]",
")",
")",
"{",
"$",
"parsedFlag",
"[",
"'description'",
"]",
"=",
"$",
"matches",
"[",
"'description'",
"]",
";",
"}",
"return",
"$",
"parsedFlag",
";",
"}"
]
| Parse a given flag.
The flag should be in one of the following formats:
- "-v"
- "--verbose"
- "-a="
- "--address="
- "-a=*"
- "--address=*"
@param string $flag
@return array | [
"Parse",
"a",
"given",
"flag",
"."
]
| train | https://github.com/trafficgate/shell-command/blob/1a5f3fcf689f33098b192c34839effe309202c0e/src/ShellOption.php#L296-L370 |
trafficgate/shell-command | src/ShellOption.php | ShellOption.setDescription | private function setDescription($description = null)
{
if (isset($description) && ! is_string($description)) {
throw new InvalidArgumentException("Description must be a string. [$description] given.");
}
$this->description = $description;
} | php | private function setDescription($description = null)
{
if (isset($description) && ! is_string($description)) {
throw new InvalidArgumentException("Description must be a string. [$description] given.");
}
$this->description = $description;
} | [
"private",
"function",
"setDescription",
"(",
"$",
"description",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"description",
")",
"&&",
"!",
"is_string",
"(",
"$",
"description",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Description must be a string. [$description] given.\"",
")",
";",
"}",
"$",
"this",
"->",
"description",
"=",
"$",
"description",
";",
"}"
]
| Set the description.
@param string|null $description
@throws InvalidArgumentException | [
"Set",
"the",
"description",
"."
]
| train | https://github.com/trafficgate/shell-command/blob/1a5f3fcf689f33098b192c34839effe309202c0e/src/ShellOption.php#L439-L446 |
trafficgate/shell-command | src/ShellOption.php | ShellOption.setValues | private function setValues($values)
{
if (! empty($values)) {
if ($this->canHaveMultipleValues()) {
$this->addValues($values);
} elseif ($this->canHaveValue()) {
$this->addValue($values);
}
}
return $this;
} | php | private function setValues($values)
{
if (! empty($values)) {
if ($this->canHaveMultipleValues()) {
$this->addValues($values);
} elseif ($this->canHaveValue()) {
$this->addValue($values);
}
}
return $this;
} | [
"private",
"function",
"setValues",
"(",
"$",
"values",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"values",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"canHaveMultipleValues",
"(",
")",
")",
"{",
"$",
"this",
"->",
"addValues",
"(",
"$",
"values",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"canHaveValue",
"(",
")",
")",
"{",
"$",
"this",
"->",
"addValue",
"(",
"$",
"values",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
]
| Set the values for this option.
@param array $values
@return $this | [
"Set",
"the",
"values",
"for",
"this",
"option",
"."
]
| train | https://github.com/trafficgate/shell-command/blob/1a5f3fcf689f33098b192c34839effe309202c0e/src/ShellOption.php#L455-L466 |
webtorque7/link-field | code/WTTreeDropdownField.php | WTTreeDropdownField.Link | public function Link($action = null) {
$name = $this->name;
if (($pos = stripos($name, '[')) !== false) {
$name = substr($name, 0, $pos);
$action = substr($this->name, $pos + 1, strlen($this->name) - 1 - ($pos + 1)) . 'Tree';
}
return Controller::join_links($this->form->FormAction(), 'field/' . $name, $action);
} | php | public function Link($action = null) {
$name = $this->name;
if (($pos = stripos($name, '[')) !== false) {
$name = substr($name, 0, $pos);
$action = substr($this->name, $pos + 1, strlen($this->name) - 1 - ($pos + 1)) . 'Tree';
}
return Controller::join_links($this->form->FormAction(), 'field/' . $name, $action);
} | [
"public",
"function",
"Link",
"(",
"$",
"action",
"=",
"null",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"name",
";",
"if",
"(",
"(",
"$",
"pos",
"=",
"stripos",
"(",
"$",
"name",
",",
"'['",
")",
")",
"!==",
"false",
")",
"{",
"$",
"name",
"=",
"substr",
"(",
"$",
"name",
",",
"0",
",",
"$",
"pos",
")",
";",
"$",
"action",
"=",
"substr",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"pos",
"+",
"1",
",",
"strlen",
"(",
"$",
"this",
"->",
"name",
")",
"-",
"1",
"-",
"(",
"$",
"pos",
"+",
"1",
")",
")",
".",
"'Tree'",
";",
"}",
"return",
"Controller",
"::",
"join_links",
"(",
"$",
"this",
"->",
"form",
"->",
"FormAction",
"(",
")",
",",
"'field/'",
".",
"$",
"name",
",",
"$",
"action",
")",
";",
"}"
]
| Return a Link to this field | [
"Return",
"a",
"Link",
"to",
"this",
"field"
]
| train | https://github.com/webtorque7/link-field/blob/b846644e1d35676419e71f3127cfc8f150aff081/code/WTTreeDropdownField.php#L8-L18 |
Sedona-Solutions/sedona-sbo | src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php | DatatableQuery.setupColumnArrays | private function setupColumnArrays()
{
/* Example:
SELECT
partial fos_user.{id},
partial posts_comments.{title,id},
partial posts.{id,title}
FROM
AppBundle\Entity\User fos_user
LEFT JOIN
fos_user.posts posts
LEFT JOIN
posts.comments posts_comments
ORDER BY
posts_comments.title asc
*/
$this->selectColumns[$this->tableName][] = $this->rootEntityIdentifier;
foreach ($this->columns as $key => $column) {
$data = $column->getDql();
if (true === $this->isSelectColumn($data)) {
if (false === $this->isAssociation($data)) {
if (!$this->metadata->hasField($data)) {
$reflection = $this->metadata->getReflectionClass();
if (
ClassUtils::hasTrait($reflection, 'Knp\DoctrineBehaviors\Model\Translatable\Translatable', true) &&
$this->em->getClassMetadata(call_user_func([$reflection->getName(), 'getTranslationEntityClass']))->hasField($data)
) {
$this->setIdentifierFromAssociation('translations');
$this->selectColumns['translations'][] = $data;
$this->joins[$this->tableName.'.'.'translations'] = 'translations';
$this->addSearchOrderColumn($key, 'translations', $data);
continue;
} else {
if (false === array_key_exists($data, $this->selectColumns)) {
$this->setIdentifierFromAssociation($data);
}
$this->selectColumns[$data][] = 'id';
$this->joins[$this->tableName.'.'.$data] = $data;
$this->addSearchOrderColumn($key, $data, 'id');
continue;
}
}
$this->addSearchOrderColumn($key, $this->tableName, $data);
if ($data !== $this->rootEntityIdentifier) {
$this->selectColumns[$this->tableName][] = $data;
}
} else {
$array = explode('.', $data);
$count = count($array);
if ($count > 2) {
$replaced = str_replace('.', '_', $data);
$parts = explode('_', $replaced);
$last = array_pop($parts);
$select = implode('_', $parts);
$join = str_replace('_', '.', $select);
// id root-table
if (false === array_key_exists($array[0], $this->selectColumns)) {
$this->setIdentifierFromAssociation($array[0]);
}
$this->joins[$this->tableName.'.'.$array[0]] = $array[0];
// id association
if (false === array_key_exists($select, $this->selectColumns)) {
$this->setIdentifierFromAssociation($parts, $select);
}
$this->joins[$join] = $select;
$this->selectColumns[$select][] = $last;
$this->addSearchOrderColumn($key, $select, $last);
} else {
if (false === array_key_exists($array[0], $this->selectColumns)) {
$this->setIdentifierFromAssociation($array[0]);
}
$this->selectColumns[$array[0]][] = $array[1];
$this->joins[$this->tableName.'.'.$array[0]] = $array[0];
$this->addSearchOrderColumn($key, $array[0], $array[1]);
}
}
} else {
$this->orderColumns[] = null;
$this->searchColumns[] = null;
}
}
return $this;
} | php | private function setupColumnArrays()
{
/* Example:
SELECT
partial fos_user.{id},
partial posts_comments.{title,id},
partial posts.{id,title}
FROM
AppBundle\Entity\User fos_user
LEFT JOIN
fos_user.posts posts
LEFT JOIN
posts.comments posts_comments
ORDER BY
posts_comments.title asc
*/
$this->selectColumns[$this->tableName][] = $this->rootEntityIdentifier;
foreach ($this->columns as $key => $column) {
$data = $column->getDql();
if (true === $this->isSelectColumn($data)) {
if (false === $this->isAssociation($data)) {
if (!$this->metadata->hasField($data)) {
$reflection = $this->metadata->getReflectionClass();
if (
ClassUtils::hasTrait($reflection, 'Knp\DoctrineBehaviors\Model\Translatable\Translatable', true) &&
$this->em->getClassMetadata(call_user_func([$reflection->getName(), 'getTranslationEntityClass']))->hasField($data)
) {
$this->setIdentifierFromAssociation('translations');
$this->selectColumns['translations'][] = $data;
$this->joins[$this->tableName.'.'.'translations'] = 'translations';
$this->addSearchOrderColumn($key, 'translations', $data);
continue;
} else {
if (false === array_key_exists($data, $this->selectColumns)) {
$this->setIdentifierFromAssociation($data);
}
$this->selectColumns[$data][] = 'id';
$this->joins[$this->tableName.'.'.$data] = $data;
$this->addSearchOrderColumn($key, $data, 'id');
continue;
}
}
$this->addSearchOrderColumn($key, $this->tableName, $data);
if ($data !== $this->rootEntityIdentifier) {
$this->selectColumns[$this->tableName][] = $data;
}
} else {
$array = explode('.', $data);
$count = count($array);
if ($count > 2) {
$replaced = str_replace('.', '_', $data);
$parts = explode('_', $replaced);
$last = array_pop($parts);
$select = implode('_', $parts);
$join = str_replace('_', '.', $select);
// id root-table
if (false === array_key_exists($array[0], $this->selectColumns)) {
$this->setIdentifierFromAssociation($array[0]);
}
$this->joins[$this->tableName.'.'.$array[0]] = $array[0];
// id association
if (false === array_key_exists($select, $this->selectColumns)) {
$this->setIdentifierFromAssociation($parts, $select);
}
$this->joins[$join] = $select;
$this->selectColumns[$select][] = $last;
$this->addSearchOrderColumn($key, $select, $last);
} else {
if (false === array_key_exists($array[0], $this->selectColumns)) {
$this->setIdentifierFromAssociation($array[0]);
}
$this->selectColumns[$array[0]][] = $array[1];
$this->joins[$this->tableName.'.'.$array[0]] = $array[0];
$this->addSearchOrderColumn($key, $array[0], $array[1]);
}
}
} else {
$this->orderColumns[] = null;
$this->searchColumns[] = null;
}
}
return $this;
} | [
"private",
"function",
"setupColumnArrays",
"(",
")",
"{",
"/* Example:\n SELECT\n partial fos_user.{id},\n partial posts_comments.{title,id},\n partial posts.{id,title}\n FROM\n AppBundle\\Entity\\User fos_user\n LEFT JOIN\n fos_user.posts posts\n LEFT JOIN\n posts.comments posts_comments\n ORDER BY\n posts_comments.title asc\n */",
"$",
"this",
"->",
"selectColumns",
"[",
"$",
"this",
"->",
"tableName",
"]",
"[",
"]",
"=",
"$",
"this",
"->",
"rootEntityIdentifier",
";",
"foreach",
"(",
"$",
"this",
"->",
"columns",
"as",
"$",
"key",
"=>",
"$",
"column",
")",
"{",
"$",
"data",
"=",
"$",
"column",
"->",
"getDql",
"(",
")",
";",
"if",
"(",
"true",
"===",
"$",
"this",
"->",
"isSelectColumn",
"(",
"$",
"data",
")",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"isAssociation",
"(",
"$",
"data",
")",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"metadata",
"->",
"hasField",
"(",
"$",
"data",
")",
")",
"{",
"$",
"reflection",
"=",
"$",
"this",
"->",
"metadata",
"->",
"getReflectionClass",
"(",
")",
";",
"if",
"(",
"ClassUtils",
"::",
"hasTrait",
"(",
"$",
"reflection",
",",
"'Knp\\DoctrineBehaviors\\Model\\Translatable\\Translatable'",
",",
"true",
")",
"&&",
"$",
"this",
"->",
"em",
"->",
"getClassMetadata",
"(",
"call_user_func",
"(",
"[",
"$",
"reflection",
"->",
"getName",
"(",
")",
",",
"'getTranslationEntityClass'",
"]",
")",
")",
"->",
"hasField",
"(",
"$",
"data",
")",
")",
"{",
"$",
"this",
"->",
"setIdentifierFromAssociation",
"(",
"'translations'",
")",
";",
"$",
"this",
"->",
"selectColumns",
"[",
"'translations'",
"]",
"[",
"]",
"=",
"$",
"data",
";",
"$",
"this",
"->",
"joins",
"[",
"$",
"this",
"->",
"tableName",
".",
"'.'",
".",
"'translations'",
"]",
"=",
"'translations'",
";",
"$",
"this",
"->",
"addSearchOrderColumn",
"(",
"$",
"key",
",",
"'translations'",
",",
"$",
"data",
")",
";",
"continue",
";",
"}",
"else",
"{",
"if",
"(",
"false",
"===",
"array_key_exists",
"(",
"$",
"data",
",",
"$",
"this",
"->",
"selectColumns",
")",
")",
"{",
"$",
"this",
"->",
"setIdentifierFromAssociation",
"(",
"$",
"data",
")",
";",
"}",
"$",
"this",
"->",
"selectColumns",
"[",
"$",
"data",
"]",
"[",
"]",
"=",
"'id'",
";",
"$",
"this",
"->",
"joins",
"[",
"$",
"this",
"->",
"tableName",
".",
"'.'",
".",
"$",
"data",
"]",
"=",
"$",
"data",
";",
"$",
"this",
"->",
"addSearchOrderColumn",
"(",
"$",
"key",
",",
"$",
"data",
",",
"'id'",
")",
";",
"continue",
";",
"}",
"}",
"$",
"this",
"->",
"addSearchOrderColumn",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"tableName",
",",
"$",
"data",
")",
";",
"if",
"(",
"$",
"data",
"!==",
"$",
"this",
"->",
"rootEntityIdentifier",
")",
"{",
"$",
"this",
"->",
"selectColumns",
"[",
"$",
"this",
"->",
"tableName",
"]",
"[",
"]",
"=",
"$",
"data",
";",
"}",
"}",
"else",
"{",
"$",
"array",
"=",
"explode",
"(",
"'.'",
",",
"$",
"data",
")",
";",
"$",
"count",
"=",
"count",
"(",
"$",
"array",
")",
";",
"if",
"(",
"$",
"count",
">",
"2",
")",
"{",
"$",
"replaced",
"=",
"str_replace",
"(",
"'.'",
",",
"'_'",
",",
"$",
"data",
")",
";",
"$",
"parts",
"=",
"explode",
"(",
"'_'",
",",
"$",
"replaced",
")",
";",
"$",
"last",
"=",
"array_pop",
"(",
"$",
"parts",
")",
";",
"$",
"select",
"=",
"implode",
"(",
"'_'",
",",
"$",
"parts",
")",
";",
"$",
"join",
"=",
"str_replace",
"(",
"'_'",
",",
"'.'",
",",
"$",
"select",
")",
";",
"// id root-table",
"if",
"(",
"false",
"===",
"array_key_exists",
"(",
"$",
"array",
"[",
"0",
"]",
",",
"$",
"this",
"->",
"selectColumns",
")",
")",
"{",
"$",
"this",
"->",
"setIdentifierFromAssociation",
"(",
"$",
"array",
"[",
"0",
"]",
")",
";",
"}",
"$",
"this",
"->",
"joins",
"[",
"$",
"this",
"->",
"tableName",
".",
"'.'",
".",
"$",
"array",
"[",
"0",
"]",
"]",
"=",
"$",
"array",
"[",
"0",
"]",
";",
"// id association",
"if",
"(",
"false",
"===",
"array_key_exists",
"(",
"$",
"select",
",",
"$",
"this",
"->",
"selectColumns",
")",
")",
"{",
"$",
"this",
"->",
"setIdentifierFromAssociation",
"(",
"$",
"parts",
",",
"$",
"select",
")",
";",
"}",
"$",
"this",
"->",
"joins",
"[",
"$",
"join",
"]",
"=",
"$",
"select",
";",
"$",
"this",
"->",
"selectColumns",
"[",
"$",
"select",
"]",
"[",
"]",
"=",
"$",
"last",
";",
"$",
"this",
"->",
"addSearchOrderColumn",
"(",
"$",
"key",
",",
"$",
"select",
",",
"$",
"last",
")",
";",
"}",
"else",
"{",
"if",
"(",
"false",
"===",
"array_key_exists",
"(",
"$",
"array",
"[",
"0",
"]",
",",
"$",
"this",
"->",
"selectColumns",
")",
")",
"{",
"$",
"this",
"->",
"setIdentifierFromAssociation",
"(",
"$",
"array",
"[",
"0",
"]",
")",
";",
"}",
"$",
"this",
"->",
"selectColumns",
"[",
"$",
"array",
"[",
"0",
"]",
"]",
"[",
"]",
"=",
"$",
"array",
"[",
"1",
"]",
";",
"$",
"this",
"->",
"joins",
"[",
"$",
"this",
"->",
"tableName",
".",
"'.'",
".",
"$",
"array",
"[",
"0",
"]",
"]",
"=",
"$",
"array",
"[",
"0",
"]",
";",
"$",
"this",
"->",
"addSearchOrderColumn",
"(",
"$",
"key",
",",
"$",
"array",
"[",
"0",
"]",
",",
"$",
"array",
"[",
"1",
"]",
")",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"orderColumns",
"[",
"]",
"=",
"null",
";",
"$",
"this",
"->",
"searchColumns",
"[",
"]",
"=",
"null",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
]
| Setup column arrays.
@return $this | [
"Setup",
"column",
"arrays",
"."
]
| train | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php#L228-L324 |
Sedona-Solutions/sedona-sbo | src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php | DatatableQuery.buildQuery | public function buildQuery()
{
$this->setSelectFrom();
$this->setLeftJoins($this->qb);
$this->setWhere($this->qb);
$this->setWhereResultCallback($this->qb);
$this->setWhereAllCallback($this->qb);
$this->setOrderBy();
$this->setLimit();
return $this;
} | php | public function buildQuery()
{
$this->setSelectFrom();
$this->setLeftJoins($this->qb);
$this->setWhere($this->qb);
$this->setWhereResultCallback($this->qb);
$this->setWhereAllCallback($this->qb);
$this->setOrderBy();
$this->setLimit();
return $this;
} | [
"public",
"function",
"buildQuery",
"(",
")",
"{",
"$",
"this",
"->",
"setSelectFrom",
"(",
")",
";",
"$",
"this",
"->",
"setLeftJoins",
"(",
"$",
"this",
"->",
"qb",
")",
";",
"$",
"this",
"->",
"setWhere",
"(",
"$",
"this",
"->",
"qb",
")",
";",
"$",
"this",
"->",
"setWhereResultCallback",
"(",
"$",
"this",
"->",
"qb",
")",
";",
"$",
"this",
"->",
"setWhereAllCallback",
"(",
"$",
"this",
"->",
"qb",
")",
";",
"$",
"this",
"->",
"setOrderBy",
"(",
")",
";",
"$",
"this",
"->",
"setLimit",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Build query.
@return $this | [
"Build",
"query",
"."
]
| train | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php#L331-L342 |
Sedona-Solutions/sedona-sbo | src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php | DatatableQuery.setWhereResultCallback | private function setWhereResultCallback(QueryBuilder $qb)
{
if (!empty($this->callbacks['WhereResult'])) {
foreach ($this->callbacks['WhereResult'] as $callback) {
$callback($qb);
}
}
return $this;
} | php | private function setWhereResultCallback(QueryBuilder $qb)
{
if (!empty($this->callbacks['WhereResult'])) {
foreach ($this->callbacks['WhereResult'] as $callback) {
$callback($qb);
}
}
return $this;
} | [
"private",
"function",
"setWhereResultCallback",
"(",
"QueryBuilder",
"$",
"qb",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"callbacks",
"[",
"'WhereResult'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"callbacks",
"[",
"'WhereResult'",
"]",
"as",
"$",
"callback",
")",
"{",
"$",
"callback",
"(",
"$",
"qb",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
]
| Set where result callback.
@param QueryBuilder $qb
@return $this | [
"Set",
"where",
"result",
"callback",
"."
]
| train | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php#L419-L428 |
Sedona-Solutions/sedona-sbo | src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php | DatatableQuery.setWhereAllCallback | private function setWhereAllCallback(QueryBuilder $qb)
{
if (!empty($this->callbacks['WhereAll'])) {
foreach ($this->callbacks['WhereAll'] as $callback) {
$callback($qb);
}
}
return $this;
} | php | private function setWhereAllCallback(QueryBuilder $qb)
{
if (!empty($this->callbacks['WhereAll'])) {
foreach ($this->callbacks['WhereAll'] as $callback) {
$callback($qb);
}
}
return $this;
} | [
"private",
"function",
"setWhereAllCallback",
"(",
"QueryBuilder",
"$",
"qb",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"callbacks",
"[",
"'WhereAll'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"callbacks",
"[",
"'WhereAll'",
"]",
"as",
"$",
"callback",
")",
"{",
"$",
"callback",
"(",
"$",
"qb",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
]
| Set where all callback.
@param QueryBuilder $qb
@return $this | [
"Set",
"where",
"all",
"callback",
"."
]
| train | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php#L437-L446 |
Sedona-Solutions/sedona-sbo | src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php | DatatableQuery.setSelectFrom | private function setSelectFrom()
{
foreach ($this->selectColumns as $key => $value) {
$this->qb->addSelect($key);
}
$this->qb->from($this->entity, $this->tableName);
return $this;
} | php | private function setSelectFrom()
{
foreach ($this->selectColumns as $key => $value) {
$this->qb->addSelect($key);
}
$this->qb->from($this->entity, $this->tableName);
return $this;
} | [
"private",
"function",
"setSelectFrom",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"selectColumns",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"qb",
"->",
"addSelect",
"(",
"$",
"key",
")",
";",
"}",
"$",
"this",
"->",
"qb",
"->",
"from",
"(",
"$",
"this",
"->",
"entity",
",",
"$",
"this",
"->",
"tableName",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Set select from.
@return $this | [
"Set",
"select",
"from",
"."
]
| train | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php#L457-L466 |
Sedona-Solutions/sedona-sbo | src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php | DatatableQuery.setLeftJoins | private function setLeftJoins(QueryBuilder $qb)
{
foreach ($this->joins as $key => $value) {
$qb->leftJoin($key, $value);
}
return $this;
} | php | private function setLeftJoins(QueryBuilder $qb)
{
foreach ($this->joins as $key => $value) {
$qb->leftJoin($key, $value);
}
return $this;
} | [
"private",
"function",
"setLeftJoins",
"(",
"QueryBuilder",
"$",
"qb",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"joins",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"qb",
"->",
"leftJoin",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Set leftJoins.
@param QueryBuilder $qb
@return $this | [
"Set",
"leftJoins",
"."
]
| train | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php#L475-L482 |
Sedona-Solutions/sedona-sbo | src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php | DatatableQuery.setWhere | private function setWhere(QueryBuilder $qb)
{
$globalSearch = $this->requestParams['search']['value'];
// global filtering
if ('' != $globalSearch) {
$orExpr = $qb->expr()->orX();
foreach ($this->columns as $key => $column) {
if (true === $this->isSearchColumn($column)) {
$searchField = $this->searchColumns[$key];
$orExpr->add($qb->expr()->like($searchField, '?'.$key));
$qb->setParameter($key, '%'.$globalSearch.'%');
}
}
$qb->where($orExpr);
}
// individual filtering
if (true === $this->individualFiltering) {
$andExpr = $qb->expr()->andX();
$i = 100;
foreach ($this->columns as $key => $column) {
if (true === $this->isSearchColumn($column)) {
$searchType = $column->getSearchType();
$searchField = $this->searchColumns[$key];
$searchValue = $this->requestParams['columns'][$key]['search']['value'];
$searchRange = $this->requestParams['columns'][$key]['name'] === 'daterange';
if ('' != $searchValue && 'null' != $searchValue) {
if ($searchRange) {
list($_dateStart, $_dateEnd) = explode(' - ', $searchValue);
$dateStart = new \DateTime($_dateStart);
$dateEnd = new \DateTime($_dateEnd);
$dateEnd->setTime(23, 59, 59);
$k = $i + 1;
$andExpr->add($qb->expr()->between($searchField, '?'.$i, '?'.$k));
$qb->setParameter($i, $dateStart->format('Y-m-d H:i:s'));
$qb->setParameter($k, $dateEnd->format('Y-m-d H:i:s'));
$i += 2;
} else {
$andExpr = $this->addCondition($andExpr, $qb, $searchType, $searchField, $searchValue, $i);
++$i;
}
}
}
}
if ($andExpr->count() > 0) {
$qb->andWhere($andExpr);
}
}
return $this;
} | php | private function setWhere(QueryBuilder $qb)
{
$globalSearch = $this->requestParams['search']['value'];
// global filtering
if ('' != $globalSearch) {
$orExpr = $qb->expr()->orX();
foreach ($this->columns as $key => $column) {
if (true === $this->isSearchColumn($column)) {
$searchField = $this->searchColumns[$key];
$orExpr->add($qb->expr()->like($searchField, '?'.$key));
$qb->setParameter($key, '%'.$globalSearch.'%');
}
}
$qb->where($orExpr);
}
// individual filtering
if (true === $this->individualFiltering) {
$andExpr = $qb->expr()->andX();
$i = 100;
foreach ($this->columns as $key => $column) {
if (true === $this->isSearchColumn($column)) {
$searchType = $column->getSearchType();
$searchField = $this->searchColumns[$key];
$searchValue = $this->requestParams['columns'][$key]['search']['value'];
$searchRange = $this->requestParams['columns'][$key]['name'] === 'daterange';
if ('' != $searchValue && 'null' != $searchValue) {
if ($searchRange) {
list($_dateStart, $_dateEnd) = explode(' - ', $searchValue);
$dateStart = new \DateTime($_dateStart);
$dateEnd = new \DateTime($_dateEnd);
$dateEnd->setTime(23, 59, 59);
$k = $i + 1;
$andExpr->add($qb->expr()->between($searchField, '?'.$i, '?'.$k));
$qb->setParameter($i, $dateStart->format('Y-m-d H:i:s'));
$qb->setParameter($k, $dateEnd->format('Y-m-d H:i:s'));
$i += 2;
} else {
$andExpr = $this->addCondition($andExpr, $qb, $searchType, $searchField, $searchValue, $i);
++$i;
}
}
}
}
if ($andExpr->count() > 0) {
$qb->andWhere($andExpr);
}
}
return $this;
} | [
"private",
"function",
"setWhere",
"(",
"QueryBuilder",
"$",
"qb",
")",
"{",
"$",
"globalSearch",
"=",
"$",
"this",
"->",
"requestParams",
"[",
"'search'",
"]",
"[",
"'value'",
"]",
";",
"// global filtering",
"if",
"(",
"''",
"!=",
"$",
"globalSearch",
")",
"{",
"$",
"orExpr",
"=",
"$",
"qb",
"->",
"expr",
"(",
")",
"->",
"orX",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"columns",
"as",
"$",
"key",
"=>",
"$",
"column",
")",
"{",
"if",
"(",
"true",
"===",
"$",
"this",
"->",
"isSearchColumn",
"(",
"$",
"column",
")",
")",
"{",
"$",
"searchField",
"=",
"$",
"this",
"->",
"searchColumns",
"[",
"$",
"key",
"]",
";",
"$",
"orExpr",
"->",
"add",
"(",
"$",
"qb",
"->",
"expr",
"(",
")",
"->",
"like",
"(",
"$",
"searchField",
",",
"'?'",
".",
"$",
"key",
")",
")",
";",
"$",
"qb",
"->",
"setParameter",
"(",
"$",
"key",
",",
"'%'",
".",
"$",
"globalSearch",
".",
"'%'",
")",
";",
"}",
"}",
"$",
"qb",
"->",
"where",
"(",
"$",
"orExpr",
")",
";",
"}",
"// individual filtering",
"if",
"(",
"true",
"===",
"$",
"this",
"->",
"individualFiltering",
")",
"{",
"$",
"andExpr",
"=",
"$",
"qb",
"->",
"expr",
"(",
")",
"->",
"andX",
"(",
")",
";",
"$",
"i",
"=",
"100",
";",
"foreach",
"(",
"$",
"this",
"->",
"columns",
"as",
"$",
"key",
"=>",
"$",
"column",
")",
"{",
"if",
"(",
"true",
"===",
"$",
"this",
"->",
"isSearchColumn",
"(",
"$",
"column",
")",
")",
"{",
"$",
"searchType",
"=",
"$",
"column",
"->",
"getSearchType",
"(",
")",
";",
"$",
"searchField",
"=",
"$",
"this",
"->",
"searchColumns",
"[",
"$",
"key",
"]",
";",
"$",
"searchValue",
"=",
"$",
"this",
"->",
"requestParams",
"[",
"'columns'",
"]",
"[",
"$",
"key",
"]",
"[",
"'search'",
"]",
"[",
"'value'",
"]",
";",
"$",
"searchRange",
"=",
"$",
"this",
"->",
"requestParams",
"[",
"'columns'",
"]",
"[",
"$",
"key",
"]",
"[",
"'name'",
"]",
"===",
"'daterange'",
";",
"if",
"(",
"''",
"!=",
"$",
"searchValue",
"&&",
"'null'",
"!=",
"$",
"searchValue",
")",
"{",
"if",
"(",
"$",
"searchRange",
")",
"{",
"list",
"(",
"$",
"_dateStart",
",",
"$",
"_dateEnd",
")",
"=",
"explode",
"(",
"' - '",
",",
"$",
"searchValue",
")",
";",
"$",
"dateStart",
"=",
"new",
"\\",
"DateTime",
"(",
"$",
"_dateStart",
")",
";",
"$",
"dateEnd",
"=",
"new",
"\\",
"DateTime",
"(",
"$",
"_dateEnd",
")",
";",
"$",
"dateEnd",
"->",
"setTime",
"(",
"23",
",",
"59",
",",
"59",
")",
";",
"$",
"k",
"=",
"$",
"i",
"+",
"1",
";",
"$",
"andExpr",
"->",
"add",
"(",
"$",
"qb",
"->",
"expr",
"(",
")",
"->",
"between",
"(",
"$",
"searchField",
",",
"'?'",
".",
"$",
"i",
",",
"'?'",
".",
"$",
"k",
")",
")",
";",
"$",
"qb",
"->",
"setParameter",
"(",
"$",
"i",
",",
"$",
"dateStart",
"->",
"format",
"(",
"'Y-m-d H:i:s'",
")",
")",
";",
"$",
"qb",
"->",
"setParameter",
"(",
"$",
"k",
",",
"$",
"dateEnd",
"->",
"format",
"(",
"'Y-m-d H:i:s'",
")",
")",
";",
"$",
"i",
"+=",
"2",
";",
"}",
"else",
"{",
"$",
"andExpr",
"=",
"$",
"this",
"->",
"addCondition",
"(",
"$",
"andExpr",
",",
"$",
"qb",
",",
"$",
"searchType",
",",
"$",
"searchField",
",",
"$",
"searchValue",
",",
"$",
"i",
")",
";",
"++",
"$",
"i",
";",
"}",
"}",
"}",
"}",
"if",
"(",
"$",
"andExpr",
"->",
"count",
"(",
")",
">",
"0",
")",
"{",
"$",
"qb",
"->",
"andWhere",
"(",
"$",
"andExpr",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
]
| Searching / Filtering.
Construct the WHERE clause for server-side processing SQL query.
@param QueryBuilder $qb
@return $this | [
"Searching",
"/",
"Filtering",
".",
"Construct",
"the",
"WHERE",
"clause",
"for",
"server",
"-",
"side",
"processing",
"SQL",
"query",
"."
]
| train | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php#L492-L549 |
Sedona-Solutions/sedona-sbo | src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php | DatatableQuery.addCondition | private function addCondition(Andx $andExpr, QueryBuilder $pivot, $searchType, $searchField, $searchValue, $i)
{
switch ($searchType) {
case 'like':
$andExpr->add($pivot->expr()->like($searchField, '?'.$i));
$pivot->setParameter($i, '%'.$searchValue.'%');
break;
case 'notLike':
$andExpr->add($pivot->expr()->notLike($searchField, '?'.$i));
$pivot->setParameter($i, '%'.$searchValue.'%');
break;
case 'eq':
$andExpr->add($pivot->expr()->eq($searchField, '?'.$i));
$pivot->setParameter($i, $searchValue);
break;
case 'neq':
$andExpr->add($pivot->expr()->neq($searchField, '?'.$i));
$pivot->setParameter($i, $searchValue);
break;
case 'lt':
$andExpr->add($pivot->expr()->lt($searchField, '?'.$i));
$pivot->setParameter($i, $searchValue);
break;
case 'lte':
$andExpr->add($pivot->expr()->lte($searchField, '?'.$i));
$pivot->setParameter($i, $searchValue);
break;
case 'gt':
$andExpr->add($pivot->expr()->gt($searchField, '?'.$i));
$pivot->setParameter($i, $searchValue);
break;
case 'gte':
$andExpr->add($pivot->expr()->gte($searchField, '?'.$i));
$pivot->setParameter($i, $searchValue);
break;
case 'in':
$andExpr->add($pivot->expr()->in($searchField, '?'.$i));
$pivot->setParameter($i, explode(',', $searchValue));
break;
case 'notIn':
$andExpr->add($pivot->expr()->notIn($searchField, '?'.$i));
$pivot->setParameter($i, explode(',', $searchValue));
break;
case 'isNull':
$andExpr->add($pivot->expr()->isNull($searchField));
break;
case 'isNotNull':
$andExpr->add($pivot->expr()->isNotNull($searchField));
break;
}
return $andExpr;
} | php | private function addCondition(Andx $andExpr, QueryBuilder $pivot, $searchType, $searchField, $searchValue, $i)
{
switch ($searchType) {
case 'like':
$andExpr->add($pivot->expr()->like($searchField, '?'.$i));
$pivot->setParameter($i, '%'.$searchValue.'%');
break;
case 'notLike':
$andExpr->add($pivot->expr()->notLike($searchField, '?'.$i));
$pivot->setParameter($i, '%'.$searchValue.'%');
break;
case 'eq':
$andExpr->add($pivot->expr()->eq($searchField, '?'.$i));
$pivot->setParameter($i, $searchValue);
break;
case 'neq':
$andExpr->add($pivot->expr()->neq($searchField, '?'.$i));
$pivot->setParameter($i, $searchValue);
break;
case 'lt':
$andExpr->add($pivot->expr()->lt($searchField, '?'.$i));
$pivot->setParameter($i, $searchValue);
break;
case 'lte':
$andExpr->add($pivot->expr()->lte($searchField, '?'.$i));
$pivot->setParameter($i, $searchValue);
break;
case 'gt':
$andExpr->add($pivot->expr()->gt($searchField, '?'.$i));
$pivot->setParameter($i, $searchValue);
break;
case 'gte':
$andExpr->add($pivot->expr()->gte($searchField, '?'.$i));
$pivot->setParameter($i, $searchValue);
break;
case 'in':
$andExpr->add($pivot->expr()->in($searchField, '?'.$i));
$pivot->setParameter($i, explode(',', $searchValue));
break;
case 'notIn':
$andExpr->add($pivot->expr()->notIn($searchField, '?'.$i));
$pivot->setParameter($i, explode(',', $searchValue));
break;
case 'isNull':
$andExpr->add($pivot->expr()->isNull($searchField));
break;
case 'isNotNull':
$andExpr->add($pivot->expr()->isNotNull($searchField));
break;
}
return $andExpr;
} | [
"private",
"function",
"addCondition",
"(",
"Andx",
"$",
"andExpr",
",",
"QueryBuilder",
"$",
"pivot",
",",
"$",
"searchType",
",",
"$",
"searchField",
",",
"$",
"searchValue",
",",
"$",
"i",
")",
"{",
"switch",
"(",
"$",
"searchType",
")",
"{",
"case",
"'like'",
":",
"$",
"andExpr",
"->",
"add",
"(",
"$",
"pivot",
"->",
"expr",
"(",
")",
"->",
"like",
"(",
"$",
"searchField",
",",
"'?'",
".",
"$",
"i",
")",
")",
";",
"$",
"pivot",
"->",
"setParameter",
"(",
"$",
"i",
",",
"'%'",
".",
"$",
"searchValue",
".",
"'%'",
")",
";",
"break",
";",
"case",
"'notLike'",
":",
"$",
"andExpr",
"->",
"add",
"(",
"$",
"pivot",
"->",
"expr",
"(",
")",
"->",
"notLike",
"(",
"$",
"searchField",
",",
"'?'",
".",
"$",
"i",
")",
")",
";",
"$",
"pivot",
"->",
"setParameter",
"(",
"$",
"i",
",",
"'%'",
".",
"$",
"searchValue",
".",
"'%'",
")",
";",
"break",
";",
"case",
"'eq'",
":",
"$",
"andExpr",
"->",
"add",
"(",
"$",
"pivot",
"->",
"expr",
"(",
")",
"->",
"eq",
"(",
"$",
"searchField",
",",
"'?'",
".",
"$",
"i",
")",
")",
";",
"$",
"pivot",
"->",
"setParameter",
"(",
"$",
"i",
",",
"$",
"searchValue",
")",
";",
"break",
";",
"case",
"'neq'",
":",
"$",
"andExpr",
"->",
"add",
"(",
"$",
"pivot",
"->",
"expr",
"(",
")",
"->",
"neq",
"(",
"$",
"searchField",
",",
"'?'",
".",
"$",
"i",
")",
")",
";",
"$",
"pivot",
"->",
"setParameter",
"(",
"$",
"i",
",",
"$",
"searchValue",
")",
";",
"break",
";",
"case",
"'lt'",
":",
"$",
"andExpr",
"->",
"add",
"(",
"$",
"pivot",
"->",
"expr",
"(",
")",
"->",
"lt",
"(",
"$",
"searchField",
",",
"'?'",
".",
"$",
"i",
")",
")",
";",
"$",
"pivot",
"->",
"setParameter",
"(",
"$",
"i",
",",
"$",
"searchValue",
")",
";",
"break",
";",
"case",
"'lte'",
":",
"$",
"andExpr",
"->",
"add",
"(",
"$",
"pivot",
"->",
"expr",
"(",
")",
"->",
"lte",
"(",
"$",
"searchField",
",",
"'?'",
".",
"$",
"i",
")",
")",
";",
"$",
"pivot",
"->",
"setParameter",
"(",
"$",
"i",
",",
"$",
"searchValue",
")",
";",
"break",
";",
"case",
"'gt'",
":",
"$",
"andExpr",
"->",
"add",
"(",
"$",
"pivot",
"->",
"expr",
"(",
")",
"->",
"gt",
"(",
"$",
"searchField",
",",
"'?'",
".",
"$",
"i",
")",
")",
";",
"$",
"pivot",
"->",
"setParameter",
"(",
"$",
"i",
",",
"$",
"searchValue",
")",
";",
"break",
";",
"case",
"'gte'",
":",
"$",
"andExpr",
"->",
"add",
"(",
"$",
"pivot",
"->",
"expr",
"(",
")",
"->",
"gte",
"(",
"$",
"searchField",
",",
"'?'",
".",
"$",
"i",
")",
")",
";",
"$",
"pivot",
"->",
"setParameter",
"(",
"$",
"i",
",",
"$",
"searchValue",
")",
";",
"break",
";",
"case",
"'in'",
":",
"$",
"andExpr",
"->",
"add",
"(",
"$",
"pivot",
"->",
"expr",
"(",
")",
"->",
"in",
"(",
"$",
"searchField",
",",
"'?'",
".",
"$",
"i",
")",
")",
";",
"$",
"pivot",
"->",
"setParameter",
"(",
"$",
"i",
",",
"explode",
"(",
"','",
",",
"$",
"searchValue",
")",
")",
";",
"break",
";",
"case",
"'notIn'",
":",
"$",
"andExpr",
"->",
"add",
"(",
"$",
"pivot",
"->",
"expr",
"(",
")",
"->",
"notIn",
"(",
"$",
"searchField",
",",
"'?'",
".",
"$",
"i",
")",
")",
";",
"$",
"pivot",
"->",
"setParameter",
"(",
"$",
"i",
",",
"explode",
"(",
"','",
",",
"$",
"searchValue",
")",
")",
";",
"break",
";",
"case",
"'isNull'",
":",
"$",
"andExpr",
"->",
"add",
"(",
"$",
"pivot",
"->",
"expr",
"(",
")",
"->",
"isNull",
"(",
"$",
"searchField",
")",
")",
";",
"break",
";",
"case",
"'isNotNull'",
":",
"$",
"andExpr",
"->",
"add",
"(",
"$",
"pivot",
"->",
"expr",
"(",
")",
"->",
"isNotNull",
"(",
"$",
"searchField",
")",
")",
";",
"break",
";",
"}",
"return",
"$",
"andExpr",
";",
"}"
]
| Add a condition.
@param Andx $andExpr
@param QueryBuilder $pivot
@param string $searchType
@param string $searchField
@param string $searchValue
@param int $i
@return Andx | [
"Add",
"a",
"condition",
"."
]
| train | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php#L563-L615 |
Sedona-Solutions/sedona-sbo | src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php | DatatableQuery.setOrderBy | private function setOrderBy()
{
if (isset($this->requestParams['order']) && count($this->requestParams['order'])) {
$counter = count($this->requestParams['order']);
for ($i = 0; $i < $counter; ++$i) {
$columnIdx = (integer) $this->requestParams['order'][$i]['column'];
$requestColumn = $this->requestParams['columns'][$columnIdx];
if ('true' == $requestColumn['orderable']) {
$this->qb->addOrderBy(
$this->orderColumns[$columnIdx],
$this->requestParams['order'][$i]['dir']
);
}
}
}
return $this;
} | php | private function setOrderBy()
{
if (isset($this->requestParams['order']) && count($this->requestParams['order'])) {
$counter = count($this->requestParams['order']);
for ($i = 0; $i < $counter; ++$i) {
$columnIdx = (integer) $this->requestParams['order'][$i]['column'];
$requestColumn = $this->requestParams['columns'][$columnIdx];
if ('true' == $requestColumn['orderable']) {
$this->qb->addOrderBy(
$this->orderColumns[$columnIdx],
$this->requestParams['order'][$i]['dir']
);
}
}
}
return $this;
} | [
"private",
"function",
"setOrderBy",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"requestParams",
"[",
"'order'",
"]",
")",
"&&",
"count",
"(",
"$",
"this",
"->",
"requestParams",
"[",
"'order'",
"]",
")",
")",
"{",
"$",
"counter",
"=",
"count",
"(",
"$",
"this",
"->",
"requestParams",
"[",
"'order'",
"]",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"counter",
";",
"++",
"$",
"i",
")",
"{",
"$",
"columnIdx",
"=",
"(",
"integer",
")",
"$",
"this",
"->",
"requestParams",
"[",
"'order'",
"]",
"[",
"$",
"i",
"]",
"[",
"'column'",
"]",
";",
"$",
"requestColumn",
"=",
"$",
"this",
"->",
"requestParams",
"[",
"'columns'",
"]",
"[",
"$",
"columnIdx",
"]",
";",
"if",
"(",
"'true'",
"==",
"$",
"requestColumn",
"[",
"'orderable'",
"]",
")",
"{",
"$",
"this",
"->",
"qb",
"->",
"addOrderBy",
"(",
"$",
"this",
"->",
"orderColumns",
"[",
"$",
"columnIdx",
"]",
",",
"$",
"this",
"->",
"requestParams",
"[",
"'order'",
"]",
"[",
"$",
"i",
"]",
"[",
"'dir'",
"]",
")",
";",
"}",
"}",
"}",
"return",
"$",
"this",
";",
"}"
]
| Ordering.
Construct the ORDER BY clause for server-side processing SQL query.
@return $this | [
"Ordering",
".",
"Construct",
"the",
"ORDER",
"BY",
"clause",
"for",
"server",
"-",
"side",
"processing",
"SQL",
"query",
"."
]
| train | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php#L623-L642 |
Sedona-Solutions/sedona-sbo | src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php | DatatableQuery.setLimit | private function setLimit()
{
if (isset($this->requestParams['start']) && -1 != $this->requestParams['length']) {
$this->qb->setFirstResult($this->requestParams['start'])->setMaxResults($this->requestParams['length']);
}
return $this;
} | php | private function setLimit()
{
if (isset($this->requestParams['start']) && -1 != $this->requestParams['length']) {
$this->qb->setFirstResult($this->requestParams['start'])->setMaxResults($this->requestParams['length']);
}
return $this;
} | [
"private",
"function",
"setLimit",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"requestParams",
"[",
"'start'",
"]",
")",
"&&",
"-",
"1",
"!=",
"$",
"this",
"->",
"requestParams",
"[",
"'length'",
"]",
")",
"{",
"$",
"this",
"->",
"qb",
"->",
"setFirstResult",
"(",
"$",
"this",
"->",
"requestParams",
"[",
"'start'",
"]",
")",
"->",
"setMaxResults",
"(",
"$",
"this",
"->",
"requestParams",
"[",
"'length'",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Paging.
Construct the LIMIT clause for server-side processing SQL query.
@return $this | [
"Paging",
".",
"Construct",
"the",
"LIMIT",
"clause",
"for",
"server",
"-",
"side",
"processing",
"SQL",
"query",
"."
]
| train | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php#L650-L657 |
Sedona-Solutions/sedona-sbo | src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php | DatatableQuery.getCountAllResults | private function getCountAllResults($rootEntityIdentifier)
{
$qb = $this->em->createQueryBuilder();
$qb->select('count(distinct '.$this->tableName.'.'.$rootEntityIdentifier.')');
$qb->from($this->entity, $this->tableName);
$this->setLeftJoins($qb);
$this->setWhereAllCallback($qb);
return (int) $qb->getQuery()->getSingleScalarResult();
} | php | private function getCountAllResults($rootEntityIdentifier)
{
$qb = $this->em->createQueryBuilder();
$qb->select('count(distinct '.$this->tableName.'.'.$rootEntityIdentifier.')');
$qb->from($this->entity, $this->tableName);
$this->setLeftJoins($qb);
$this->setWhereAllCallback($qb);
return (int) $qb->getQuery()->getSingleScalarResult();
} | [
"private",
"function",
"getCountAllResults",
"(",
"$",
"rootEntityIdentifier",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"em",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"qb",
"->",
"select",
"(",
"'count(distinct '",
".",
"$",
"this",
"->",
"tableName",
".",
"'.'",
".",
"$",
"rootEntityIdentifier",
".",
"')'",
")",
";",
"$",
"qb",
"->",
"from",
"(",
"$",
"this",
"->",
"entity",
",",
"$",
"this",
"->",
"tableName",
")",
";",
"$",
"this",
"->",
"setLeftJoins",
"(",
"$",
"qb",
")",
";",
"$",
"this",
"->",
"setWhereAllCallback",
"(",
"$",
"qb",
")",
";",
"return",
"(",
"int",
")",
"$",
"qb",
"->",
"getQuery",
"(",
")",
"->",
"getSingleScalarResult",
"(",
")",
";",
"}"
]
| Query results before filtering.
@param int $rootEntityIdentifier
@return int | [
"Query",
"results",
"before",
"filtering",
"."
]
| train | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php#L670-L680 |
Sedona-Solutions/sedona-sbo | src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php | DatatableQuery.execute | private function execute()
{
$query = $this->qb->getQuery();
if (true === $this->configs['translation_query_hints']) {
if (true === $this->doctrineExtensions) {
$query->setHint(
\Doctrine\ORM\Query::HINT_CUSTOM_OUTPUT_WALKER,
'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker'
);
$query->setHint(
\Gedmo\Translatable\TranslatableListener::HINT_TRANSLATABLE_LOCALE,
$this->locale
);
$query->setHint(
\Gedmo\Translatable\TranslatableListener::HINT_FALLBACK,
1
);
} else {
throw new \Exception('execute(): "DoctrineExtensions" does not exist.');
}
}
$query->setHydrationMode(Query::HYDRATE_OBJECT);
return $query;
} | php | private function execute()
{
$query = $this->qb->getQuery();
if (true === $this->configs['translation_query_hints']) {
if (true === $this->doctrineExtensions) {
$query->setHint(
\Doctrine\ORM\Query::HINT_CUSTOM_OUTPUT_WALKER,
'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker'
);
$query->setHint(
\Gedmo\Translatable\TranslatableListener::HINT_TRANSLATABLE_LOCALE,
$this->locale
);
$query->setHint(
\Gedmo\Translatable\TranslatableListener::HINT_FALLBACK,
1
);
} else {
throw new \Exception('execute(): "DoctrineExtensions" does not exist.');
}
}
$query->setHydrationMode(Query::HYDRATE_OBJECT);
return $query;
} | [
"private",
"function",
"execute",
"(",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"qb",
"->",
"getQuery",
"(",
")",
";",
"if",
"(",
"true",
"===",
"$",
"this",
"->",
"configs",
"[",
"'translation_query_hints'",
"]",
")",
"{",
"if",
"(",
"true",
"===",
"$",
"this",
"->",
"doctrineExtensions",
")",
"{",
"$",
"query",
"->",
"setHint",
"(",
"\\",
"Doctrine",
"\\",
"ORM",
"\\",
"Query",
"::",
"HINT_CUSTOM_OUTPUT_WALKER",
",",
"'Gedmo\\\\Translatable\\\\Query\\\\TreeWalker\\\\TranslationWalker'",
")",
";",
"$",
"query",
"->",
"setHint",
"(",
"\\",
"Gedmo",
"\\",
"Translatable",
"\\",
"TranslatableListener",
"::",
"HINT_TRANSLATABLE_LOCALE",
",",
"$",
"this",
"->",
"locale",
")",
";",
"$",
"query",
"->",
"setHint",
"(",
"\\",
"Gedmo",
"\\",
"Translatable",
"\\",
"TranslatableListener",
"::",
"HINT_FALLBACK",
",",
"1",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'execute(): \"DoctrineExtensions\" does not exist.'",
")",
";",
"}",
"}",
"$",
"query",
"->",
"setHydrationMode",
"(",
"Query",
"::",
"HYDRATE_OBJECT",
")",
";",
"return",
"$",
"query",
";",
"}"
]
| Constructs a Query instance.
@return Query
@throws \Exception | [
"Constructs",
"a",
"Query",
"instance",
"."
]
| train | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php#L709-L737 |
Sedona-Solutions/sedona-sbo | src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php | DatatableQuery.entityFieldToArray | private function entityFieldToArray(array $data, $entity, $path)
{
$parts = explode('.', $path, 2);
if (count($parts) === 1) {
if ($entity instanceof \Traversable) {
$data = [];
foreach ($entity as $item) {
$id = $this->em->getClassMetadata(get_class($item))->getSingleIdentifierColumnName();
$data[] = [
$id => $this->propertyAccessor->getValue($item, $id),
$parts[0] => $this->propertyAccessor->getValue($item, $parts[0]),
];
}
} else {
if (count($data) === 0) {
$data = [];
$id = $this->em->getClassMetadata(get_class($entity))->getSingleIdentifierColumnName();
$data[$id] = $this->propertyAccessor->getValue($entity, $id);
}
$data[$parts[0]] = $this->propertyAccessor->getValue($entity, $parts[0]);
}
return $data;
} else {
$data[$parts[0]] = $this->entityFieldToArray(
isset($data[$parts[0]]) ? $data[$parts[0]] : [],
$this->propertyAccessor->getValue($entity, $parts[0]),
$parts[1]
);
return $data;
}
} | php | private function entityFieldToArray(array $data, $entity, $path)
{
$parts = explode('.', $path, 2);
if (count($parts) === 1) {
if ($entity instanceof \Traversable) {
$data = [];
foreach ($entity as $item) {
$id = $this->em->getClassMetadata(get_class($item))->getSingleIdentifierColumnName();
$data[] = [
$id => $this->propertyAccessor->getValue($item, $id),
$parts[0] => $this->propertyAccessor->getValue($item, $parts[0]),
];
}
} else {
if (count($data) === 0) {
$data = [];
$id = $this->em->getClassMetadata(get_class($entity))->getSingleIdentifierColumnName();
$data[$id] = $this->propertyAccessor->getValue($entity, $id);
}
$data[$parts[0]] = $this->propertyAccessor->getValue($entity, $parts[0]);
}
return $data;
} else {
$data[$parts[0]] = $this->entityFieldToArray(
isset($data[$parts[0]]) ? $data[$parts[0]] : [],
$this->propertyAccessor->getValue($entity, $parts[0]),
$parts[1]
);
return $data;
}
} | [
"private",
"function",
"entityFieldToArray",
"(",
"array",
"$",
"data",
",",
"$",
"entity",
",",
"$",
"path",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'.'",
",",
"$",
"path",
",",
"2",
")",
";",
"if",
"(",
"count",
"(",
"$",
"parts",
")",
"===",
"1",
")",
"{",
"if",
"(",
"$",
"entity",
"instanceof",
"\\",
"Traversable",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"entity",
"as",
"$",
"item",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"em",
"->",
"getClassMetadata",
"(",
"get_class",
"(",
"$",
"item",
")",
")",
"->",
"getSingleIdentifierColumnName",
"(",
")",
";",
"$",
"data",
"[",
"]",
"=",
"[",
"$",
"id",
"=>",
"$",
"this",
"->",
"propertyAccessor",
"->",
"getValue",
"(",
"$",
"item",
",",
"$",
"id",
")",
",",
"$",
"parts",
"[",
"0",
"]",
"=>",
"$",
"this",
"->",
"propertyAccessor",
"->",
"getValue",
"(",
"$",
"item",
",",
"$",
"parts",
"[",
"0",
"]",
")",
",",
"]",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"count",
"(",
"$",
"data",
")",
"===",
"0",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"$",
"id",
"=",
"$",
"this",
"->",
"em",
"->",
"getClassMetadata",
"(",
"get_class",
"(",
"$",
"entity",
")",
")",
"->",
"getSingleIdentifierColumnName",
"(",
")",
";",
"$",
"data",
"[",
"$",
"id",
"]",
"=",
"$",
"this",
"->",
"propertyAccessor",
"->",
"getValue",
"(",
"$",
"entity",
",",
"$",
"id",
")",
";",
"}",
"$",
"data",
"[",
"$",
"parts",
"[",
"0",
"]",
"]",
"=",
"$",
"this",
"->",
"propertyAccessor",
"->",
"getValue",
"(",
"$",
"entity",
",",
"$",
"parts",
"[",
"0",
"]",
")",
";",
"}",
"return",
"$",
"data",
";",
"}",
"else",
"{",
"$",
"data",
"[",
"$",
"parts",
"[",
"0",
"]",
"]",
"=",
"$",
"this",
"->",
"entityFieldToArray",
"(",
"isset",
"(",
"$",
"data",
"[",
"$",
"parts",
"[",
"0",
"]",
"]",
")",
"?",
"$",
"data",
"[",
"$",
"parts",
"[",
"0",
"]",
"]",
":",
"[",
"]",
",",
"$",
"this",
"->",
"propertyAccessor",
"->",
"getValue",
"(",
"$",
"entity",
",",
"$",
"parts",
"[",
"0",
"]",
")",
",",
"$",
"parts",
"[",
"1",
"]",
")",
";",
"return",
"$",
"data",
";",
"}",
"}"
]
| Normalizes an entity path into an array.
Each entity of each level will have its id set.
All values are retrieved using a property accessor with magic call activated.
@param array $data
@param object $entity Entity to normalize
@param string $path Path to set in the array
@return array Normalized data | [
"Normalizes",
"an",
"entity",
"path",
"into",
"an",
"array",
".",
"Each",
"entity",
"of",
"each",
"level",
"will",
"have",
"its",
"id",
"set",
".",
"All",
"values",
"are",
"retrieved",
"using",
"a",
"property",
"accessor",
"with",
"magic",
"call",
"activated",
"."
]
| train | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php#L754-L790 |
Sedona-Solutions/sedona-sbo | src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php | DatatableQuery.addSearchOrderColumn | private function addSearchOrderColumn($key, $columnTableName, $data)
{
$column = $this->columns[$key];
true === $column->getOrderable() ? $this->orderColumns[] = $columnTableName.'.'.$data : $this->orderColumns[] = null;
true === $column->getSearchable() ? $this->searchColumns[] = $columnTableName.'.'.$data : $this->searchColumns[] = null;
} | php | private function addSearchOrderColumn($key, $columnTableName, $data)
{
$column = $this->columns[$key];
true === $column->getOrderable() ? $this->orderColumns[] = $columnTableName.'.'.$data : $this->orderColumns[] = null;
true === $column->getSearchable() ? $this->searchColumns[] = $columnTableName.'.'.$data : $this->searchColumns[] = null;
} | [
"private",
"function",
"addSearchOrderColumn",
"(",
"$",
"key",
",",
"$",
"columnTableName",
",",
"$",
"data",
")",
"{",
"$",
"column",
"=",
"$",
"this",
"->",
"columns",
"[",
"$",
"key",
"]",
";",
"true",
"===",
"$",
"column",
"->",
"getOrderable",
"(",
")",
"?",
"$",
"this",
"->",
"orderColumns",
"[",
"]",
"=",
"$",
"columnTableName",
".",
"'.'",
".",
"$",
"data",
":",
"$",
"this",
"->",
"orderColumns",
"[",
"]",
"=",
"null",
";",
"true",
"===",
"$",
"column",
"->",
"getSearchable",
"(",
")",
"?",
"$",
"this",
"->",
"searchColumns",
"[",
"]",
"=",
"$",
"columnTableName",
".",
"'.'",
".",
"$",
"data",
":",
"$",
"this",
"->",
"searchColumns",
"[",
"]",
"=",
"null",
";",
"}"
]
| Add search/order columns.
@param int $key
@param string $columnTableName
@param string $data | [
"Add",
"search",
"/",
"order",
"columns",
"."
]
| train | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php#L889-L895 |
Sedona-Solutions/sedona-sbo | src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php | DatatableQuery.getMetadata | private function getMetadata($entity)
{
try {
$metadata = $this->em->getMetadataFactory()->getMetadataFor($entity);
} catch (MappingException $e) {
throw new \Exception('getMetadata(): Given object '.$entity.' is not a Doctrine Entity.');
}
return $metadata;
} | php | private function getMetadata($entity)
{
try {
$metadata = $this->em->getMetadataFactory()->getMetadataFor($entity);
} catch (MappingException $e) {
throw new \Exception('getMetadata(): Given object '.$entity.' is not a Doctrine Entity.');
}
return $metadata;
} | [
"private",
"function",
"getMetadata",
"(",
"$",
"entity",
")",
"{",
"try",
"{",
"$",
"metadata",
"=",
"$",
"this",
"->",
"em",
"->",
"getMetadataFactory",
"(",
")",
"->",
"getMetadataFor",
"(",
"$",
"entity",
")",
";",
"}",
"catch",
"(",
"MappingException",
"$",
"e",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'getMetadata(): Given object '",
".",
"$",
"entity",
".",
"' is not a Doctrine Entity.'",
")",
";",
"}",
"return",
"$",
"metadata",
";",
"}"
]
| Get metadata.
@param string $entity
@return ClassMetadata
@throws \Exception | [
"Get",
"metadata",
"."
]
| train | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php#L906-L915 |
Sedona-Solutions/sedona-sbo | src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php | DatatableQuery.setIdentifierFromAssociation | private function setIdentifierFromAssociation($association, $key = '', $i = 0, $metadata = null)
{
if (null === $metadata) {
$metadata = $this->metadata;
}
if (is_string($association)) {
$targetEntityClass = $metadata->getAssociationTargetClass($association);
$targetMetadata = $this->getMetadata($targetEntityClass);
$this->selectColumns[$association][] = $this->getIdentifier($targetMetadata);
}
if (is_array($association) && array_key_exists($i, $association)) {
$column = $association[$i];
$count = count($association) - 1;
if (true === $metadata->hasAssociation($column)) {
$targetEntityClass = $metadata->getAssociationTargetClass($column);
$targetMetadata = $this->getMetadata($targetEntityClass);
if ($count == $i) {
$this->selectColumns[$key][] = $this->getIdentifier($targetMetadata);
} else {
++$i;
$this->setIdentifierFromAssociation($association, $key, $i, $targetMetadata);
}
}
}
return $this;
} | php | private function setIdentifierFromAssociation($association, $key = '', $i = 0, $metadata = null)
{
if (null === $metadata) {
$metadata = $this->metadata;
}
if (is_string($association)) {
$targetEntityClass = $metadata->getAssociationTargetClass($association);
$targetMetadata = $this->getMetadata($targetEntityClass);
$this->selectColumns[$association][] = $this->getIdentifier($targetMetadata);
}
if (is_array($association) && array_key_exists($i, $association)) {
$column = $association[$i];
$count = count($association) - 1;
if (true === $metadata->hasAssociation($column)) {
$targetEntityClass = $metadata->getAssociationTargetClass($column);
$targetMetadata = $this->getMetadata($targetEntityClass);
if ($count == $i) {
$this->selectColumns[$key][] = $this->getIdentifier($targetMetadata);
} else {
++$i;
$this->setIdentifierFromAssociation($association, $key, $i, $targetMetadata);
}
}
}
return $this;
} | [
"private",
"function",
"setIdentifierFromAssociation",
"(",
"$",
"association",
",",
"$",
"key",
"=",
"''",
",",
"$",
"i",
"=",
"0",
",",
"$",
"metadata",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"metadata",
")",
"{",
"$",
"metadata",
"=",
"$",
"this",
"->",
"metadata",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"association",
")",
")",
"{",
"$",
"targetEntityClass",
"=",
"$",
"metadata",
"->",
"getAssociationTargetClass",
"(",
"$",
"association",
")",
";",
"$",
"targetMetadata",
"=",
"$",
"this",
"->",
"getMetadata",
"(",
"$",
"targetEntityClass",
")",
";",
"$",
"this",
"->",
"selectColumns",
"[",
"$",
"association",
"]",
"[",
"]",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
"$",
"targetMetadata",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"association",
")",
"&&",
"array_key_exists",
"(",
"$",
"i",
",",
"$",
"association",
")",
")",
"{",
"$",
"column",
"=",
"$",
"association",
"[",
"$",
"i",
"]",
";",
"$",
"count",
"=",
"count",
"(",
"$",
"association",
")",
"-",
"1",
";",
"if",
"(",
"true",
"===",
"$",
"metadata",
"->",
"hasAssociation",
"(",
"$",
"column",
")",
")",
"{",
"$",
"targetEntityClass",
"=",
"$",
"metadata",
"->",
"getAssociationTargetClass",
"(",
"$",
"column",
")",
";",
"$",
"targetMetadata",
"=",
"$",
"this",
"->",
"getMetadata",
"(",
"$",
"targetEntityClass",
")",
";",
"if",
"(",
"$",
"count",
"==",
"$",
"i",
")",
"{",
"$",
"this",
"->",
"selectColumns",
"[",
"$",
"key",
"]",
"[",
"]",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
"$",
"targetMetadata",
")",
";",
"}",
"else",
"{",
"++",
"$",
"i",
";",
"$",
"this",
"->",
"setIdentifierFromAssociation",
"(",
"$",
"association",
",",
"$",
"key",
",",
"$",
"i",
",",
"$",
"targetMetadata",
")",
";",
"}",
"}",
"}",
"return",
"$",
"this",
";",
"}"
]
| Set identifier from association.
@param string|array $association
@param string $key
@param int $i
@param ClassMetadata|null $metadata
@return $this
@throws \Exception | [
"Set",
"identifier",
"from",
"association",
"."
]
| train | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php#L955-L983 |
Sedona-Solutions/sedona-sbo | src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php | DatatableQuery.isSelectColumn | private function isSelectColumn($data)
{
if (null !== $data && !in_array($data, $this->virtualColumns)) {
return true;
}
return false;
} | php | private function isSelectColumn($data)
{
if (null !== $data && !in_array($data, $this->virtualColumns)) {
return true;
}
return false;
} | [
"private",
"function",
"isSelectColumn",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"data",
"&&",
"!",
"in_array",
"(",
"$",
"data",
",",
"$",
"this",
"->",
"virtualColumns",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
]
| Is select column.
@param string $data
@return bool | [
"Is",
"select",
"column",
"."
]
| train | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php#L1004-L1011 |
Sedona-Solutions/sedona-sbo | src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php | DatatableQuery.isSearchColumn | private function isSearchColumn(AbstractColumn $column)
{
if (false === $this->configs['search_on_non_visible_columns']) {
if (null !== $column->getDql() && true === $column->getSearchable() && true === $column->getVisible()) {
return true;
}
} else {
if (null !== $column->getDql() && true === $column->getSearchable()) {
return true;
}
}
return false;
} | php | private function isSearchColumn(AbstractColumn $column)
{
if (false === $this->configs['search_on_non_visible_columns']) {
if (null !== $column->getDql() && true === $column->getSearchable() && true === $column->getVisible()) {
return true;
}
} else {
if (null !== $column->getDql() && true === $column->getSearchable()) {
return true;
}
}
return false;
} | [
"private",
"function",
"isSearchColumn",
"(",
"AbstractColumn",
"$",
"column",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"configs",
"[",
"'search_on_non_visible_columns'",
"]",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"column",
"->",
"getDql",
"(",
")",
"&&",
"true",
"===",
"$",
"column",
"->",
"getSearchable",
"(",
")",
"&&",
"true",
"===",
"$",
"column",
"->",
"getVisible",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"null",
"!==",
"$",
"column",
"->",
"getDql",
"(",
")",
"&&",
"true",
"===",
"$",
"column",
"->",
"getSearchable",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
]
| Is search column.
@param AbstractColumn $column
@return bool | [
"Is",
"search",
"column",
"."
]
| train | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php#L1020-L1033 |
Sedona-Solutions/sedona-sbo | src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php | DatatableQuery.renderImage | private function renderImage($imageName, ImageColumn $column)
{
return $this->twig->render(
'SgDatatablesBundle:Helper:ii_render_image.html.twig',
array(
'image_id' => 'sg_image_'.uniqid(rand(10000, 99999)),
'image_name' => $imageName,
'filter' => $column->getImagineFilter(),
'path' => $column->getRelativePath(),
'holder_url' => $column->getHolderUrl(),
'width' => $column->getHolderWidth(),
'height' => $column->getHolderHeight(),
'enlarge' => $column->getEnlarge(),
)
);
} | php | private function renderImage($imageName, ImageColumn $column)
{
return $this->twig->render(
'SgDatatablesBundle:Helper:ii_render_image.html.twig',
array(
'image_id' => 'sg_image_'.uniqid(rand(10000, 99999)),
'image_name' => $imageName,
'filter' => $column->getImagineFilter(),
'path' => $column->getRelativePath(),
'holder_url' => $column->getHolderUrl(),
'width' => $column->getHolderWidth(),
'height' => $column->getHolderHeight(),
'enlarge' => $column->getEnlarge(),
)
);
} | [
"private",
"function",
"renderImage",
"(",
"$",
"imageName",
",",
"ImageColumn",
"$",
"column",
")",
"{",
"return",
"$",
"this",
"->",
"twig",
"->",
"render",
"(",
"'SgDatatablesBundle:Helper:ii_render_image.html.twig'",
",",
"array",
"(",
"'image_id'",
"=>",
"'sg_image_'",
".",
"uniqid",
"(",
"rand",
"(",
"10000",
",",
"99999",
")",
")",
",",
"'image_name'",
"=>",
"$",
"imageName",
",",
"'filter'",
"=>",
"$",
"column",
"->",
"getImagineFilter",
"(",
")",
",",
"'path'",
"=>",
"$",
"column",
"->",
"getRelativePath",
"(",
")",
",",
"'holder_url'",
"=>",
"$",
"column",
"->",
"getHolderUrl",
"(",
")",
",",
"'width'",
"=>",
"$",
"column",
"->",
"getHolderWidth",
"(",
")",
",",
"'height'",
"=>",
"$",
"column",
"->",
"getHolderHeight",
"(",
")",
",",
"'enlarge'",
"=>",
"$",
"column",
"->",
"getEnlarge",
"(",
")",
",",
")",
")",
";",
"}"
]
| Render image.
@param string $imageName
@param ImageColumn $column
@return string | [
"Render",
"image",
"."
]
| train | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php#L1043-L1058 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseRole.php | BaseRole.setName | public function setName($v)
{
if ($v !== null) {
$v = (string) $v;
}
if ($this->name !== $v) {
$this->name = $v;
$this->modifiedColumns[] = RolePeer::NAME;
}
return $this;
} | php | public function setName($v)
{
if ($v !== null) {
$v = (string) $v;
}
if ($this->name !== $v) {
$this->name = $v;
$this->modifiedColumns[] = RolePeer::NAME;
}
return $this;
} | [
"public",
"function",
"setName",
"(",
"$",
"v",
")",
"{",
"if",
"(",
"$",
"v",
"!==",
"null",
")",
"{",
"$",
"v",
"=",
"(",
"string",
")",
"$",
"v",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"name",
"!==",
"$",
"v",
")",
"{",
"$",
"this",
"->",
"name",
"=",
"$",
"v",
";",
"$",
"this",
"->",
"modifiedColumns",
"[",
"]",
"=",
"RolePeer",
"::",
"NAME",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Set the value of [name] column.
@param string $v new value
@return Role The current object (for fluent API support) | [
"Set",
"the",
"value",
"of",
"[",
"name",
"]",
"column",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseRole.php#L153-L166 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseRole.php | BaseRole.setRole | public function setRole($v)
{
if ($v !== null) {
$v = (string) $v;
}
if ($this->role !== $v) {
$this->role = $v;
$this->modifiedColumns[] = RolePeer::ROLE;
}
return $this;
} | php | public function setRole($v)
{
if ($v !== null) {
$v = (string) $v;
}
if ($this->role !== $v) {
$this->role = $v;
$this->modifiedColumns[] = RolePeer::ROLE;
}
return $this;
} | [
"public",
"function",
"setRole",
"(",
"$",
"v",
")",
"{",
"if",
"(",
"$",
"v",
"!==",
"null",
")",
"{",
"$",
"v",
"=",
"(",
"string",
")",
"$",
"v",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"role",
"!==",
"$",
"v",
")",
"{",
"$",
"this",
"->",
"role",
"=",
"$",
"v",
";",
"$",
"this",
"->",
"modifiedColumns",
"[",
"]",
"=",
"RolePeer",
"::",
"ROLE",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Set the value of [role] column.
@param string $v new value
@return Role The current object (for fluent API support) | [
"Set",
"the",
"value",
"of",
"[",
"role",
"]",
"column",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseRole.php#L174-L187 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseRole.php | BaseRole.hydrate | public function hydrate($row, $startcol = 0, $rehydrate = false)
{
try {
$this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
$this->name = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
$this->role = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
$this->resetModified();
$this->setNew(false);
if ($rehydrate) {
$this->ensureConsistency();
}
$this->postHydrate($row, $startcol, $rehydrate);
return $startcol + 3; // 3 = RolePeer::NUM_HYDRATE_COLUMNS.
} catch (Exception $e) {
throw new PropelException("Error populating Role object", $e);
}
} | php | public function hydrate($row, $startcol = 0, $rehydrate = false)
{
try {
$this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
$this->name = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
$this->role = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
$this->resetModified();
$this->setNew(false);
if ($rehydrate) {
$this->ensureConsistency();
}
$this->postHydrate($row, $startcol, $rehydrate);
return $startcol + 3; // 3 = RolePeer::NUM_HYDRATE_COLUMNS.
} catch (Exception $e) {
throw new PropelException("Error populating Role object", $e);
}
} | [
"public",
"function",
"hydrate",
"(",
"$",
"row",
",",
"$",
"startcol",
"=",
"0",
",",
"$",
"rehydrate",
"=",
"false",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"id",
"=",
"(",
"$",
"row",
"[",
"$",
"startcol",
"+",
"0",
"]",
"!==",
"null",
")",
"?",
"(",
"int",
")",
"$",
"row",
"[",
"$",
"startcol",
"+",
"0",
"]",
":",
"null",
";",
"$",
"this",
"->",
"name",
"=",
"(",
"$",
"row",
"[",
"$",
"startcol",
"+",
"1",
"]",
"!==",
"null",
")",
"?",
"(",
"string",
")",
"$",
"row",
"[",
"$",
"startcol",
"+",
"1",
"]",
":",
"null",
";",
"$",
"this",
"->",
"role",
"=",
"(",
"$",
"row",
"[",
"$",
"startcol",
"+",
"2",
"]",
"!==",
"null",
")",
"?",
"(",
"string",
")",
"$",
"row",
"[",
"$",
"startcol",
"+",
"2",
"]",
":",
"null",
";",
"$",
"this",
"->",
"resetModified",
"(",
")",
";",
"$",
"this",
"->",
"setNew",
"(",
"false",
")",
";",
"if",
"(",
"$",
"rehydrate",
")",
"{",
"$",
"this",
"->",
"ensureConsistency",
"(",
")",
";",
"}",
"$",
"this",
"->",
"postHydrate",
"(",
"$",
"row",
",",
"$",
"startcol",
",",
"$",
"rehydrate",
")",
";",
"return",
"$",
"startcol",
"+",
"3",
";",
"// 3 = RolePeer::NUM_HYDRATE_COLUMNS.",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"\"Error populating Role object\"",
",",
"$",
"e",
")",
";",
"}",
"}"
]
| Hydrates (populates) the object variables with values from the database resultset.
An offset (0-based "start column") is specified so that objects can be hydrated
with a subset of the columns in the resultset rows. This is needed, for example,
for results of JOIN queries where the resultset row includes columns from two or
more tables.
@param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
@param int $startcol 0-based offset column which indicates which resultset column to start with.
@param boolean $rehydrate Whether this object is being re-hydrated from the database.
@return int next starting column
@throws PropelException - Any caught Exception will be rewrapped as a PropelException. | [
"Hydrates",
"(",
"populates",
")",
"the",
"object",
"variables",
"with",
"values",
"from",
"the",
"database",
"resultset",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseRole.php#L217-L238 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseRole.php | BaseRole.doSave | protected function doSave(PropelPDO $con)
{
$affectedRows = 0; // initialize var to track total num of affected rows
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
$this->doInsert($con);
} else {
$this->doUpdate($con);
}
$affectedRows += 1;
$this->resetModified();
}
if ($this->userRolesScheduledForDeletion !== null) {
if (!$this->userRolesScheduledForDeletion->isEmpty()) {
UserRoleQuery::create()
->filterByPrimaryKeys($this->userRolesScheduledForDeletion->getPrimaryKeys(false))
->delete($con);
$this->userRolesScheduledForDeletion = null;
}
}
if ($this->collUserRoles !== null) {
foreach ($this->collUserRoles as $referrerFK) {
if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
$affectedRows += $referrerFK->save($con);
}
}
}
$this->alreadyInSave = false;
}
return $affectedRows;
} | php | protected function doSave(PropelPDO $con)
{
$affectedRows = 0; // initialize var to track total num of affected rows
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
$this->doInsert($con);
} else {
$this->doUpdate($con);
}
$affectedRows += 1;
$this->resetModified();
}
if ($this->userRolesScheduledForDeletion !== null) {
if (!$this->userRolesScheduledForDeletion->isEmpty()) {
UserRoleQuery::create()
->filterByPrimaryKeys($this->userRolesScheduledForDeletion->getPrimaryKeys(false))
->delete($con);
$this->userRolesScheduledForDeletion = null;
}
}
if ($this->collUserRoles !== null) {
foreach ($this->collUserRoles as $referrerFK) {
if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
$affectedRows += $referrerFK->save($con);
}
}
}
$this->alreadyInSave = false;
}
return $affectedRows;
} | [
"protected",
"function",
"doSave",
"(",
"PropelPDO",
"$",
"con",
")",
"{",
"$",
"affectedRows",
"=",
"0",
";",
"// initialize var to track total num of affected rows",
"if",
"(",
"!",
"$",
"this",
"->",
"alreadyInSave",
")",
"{",
"$",
"this",
"->",
"alreadyInSave",
"=",
"true",
";",
"if",
"(",
"$",
"this",
"->",
"isNew",
"(",
")",
"||",
"$",
"this",
"->",
"isModified",
"(",
")",
")",
"{",
"// persist changes",
"if",
"(",
"$",
"this",
"->",
"isNew",
"(",
")",
")",
"{",
"$",
"this",
"->",
"doInsert",
"(",
"$",
"con",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"doUpdate",
"(",
"$",
"con",
")",
";",
"}",
"$",
"affectedRows",
"+=",
"1",
";",
"$",
"this",
"->",
"resetModified",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"userRolesScheduledForDeletion",
"!==",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"userRolesScheduledForDeletion",
"->",
"isEmpty",
"(",
")",
")",
"{",
"UserRoleQuery",
"::",
"create",
"(",
")",
"->",
"filterByPrimaryKeys",
"(",
"$",
"this",
"->",
"userRolesScheduledForDeletion",
"->",
"getPrimaryKeys",
"(",
"false",
")",
")",
"->",
"delete",
"(",
"$",
"con",
")",
";",
"$",
"this",
"->",
"userRolesScheduledForDeletion",
"=",
"null",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"collUserRoles",
"!==",
"null",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"collUserRoles",
"as",
"$",
"referrerFK",
")",
"{",
"if",
"(",
"!",
"$",
"referrerFK",
"->",
"isDeleted",
"(",
")",
"&&",
"(",
"$",
"referrerFK",
"->",
"isNew",
"(",
")",
"||",
"$",
"referrerFK",
"->",
"isModified",
"(",
")",
")",
")",
"{",
"$",
"affectedRows",
"+=",
"$",
"referrerFK",
"->",
"save",
"(",
"$",
"con",
")",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"alreadyInSave",
"=",
"false",
";",
"}",
"return",
"$",
"affectedRows",
";",
"}"
]
| Performs the work of inserting or updating the row in the database.
If the object is new, it inserts it; otherwise an update is performed.
All related objects are also updated in this method.
@param PropelPDO $con
@return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
@throws PropelException
@see save() | [
"Performs",
"the",
"work",
"of",
"inserting",
"or",
"updating",
"the",
"row",
"in",
"the",
"database",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseRole.php#L404-L443 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseRole.php | BaseRole.doInsert | protected function doInsert(PropelPDO $con)
{
$modifiedColumns = array();
$index = 0;
$this->modifiedColumns[] = RolePeer::ID;
if (null !== $this->id) {
throw new PropelException('Cannot insert a value for auto-increment primary key (' . RolePeer::ID . ')');
}
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(RolePeer::ID)) {
$modifiedColumns[':p' . $index++] = '`id`';
}
if ($this->isColumnModified(RolePeer::NAME)) {
$modifiedColumns[':p' . $index++] = '`name`';
}
if ($this->isColumnModified(RolePeer::ROLE)) {
$modifiedColumns[':p' . $index++] = '`role`';
}
$sql = sprintf(
'INSERT INTO `role` (%s) VALUES (%s)',
implode(', ', $modifiedColumns),
implode(', ', array_keys($modifiedColumns))
);
try {
$stmt = $con->prepare($sql);
foreach ($modifiedColumns as $identifier => $columnName) {
switch ($columnName) {
case '`id`':
$stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
break;
case '`name`':
$stmt->bindValue($identifier, $this->name, PDO::PARAM_STR);
break;
case '`role`':
$stmt->bindValue($identifier, $this->role, PDO::PARAM_STR);
break;
}
}
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
}
try {
$pk = $con->lastInsertId();
} catch (Exception $e) {
throw new PropelException('Unable to get autoincrement id.', $e);
}
$this->setId($pk);
$this->setNew(false);
} | php | protected function doInsert(PropelPDO $con)
{
$modifiedColumns = array();
$index = 0;
$this->modifiedColumns[] = RolePeer::ID;
if (null !== $this->id) {
throw new PropelException('Cannot insert a value for auto-increment primary key (' . RolePeer::ID . ')');
}
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(RolePeer::ID)) {
$modifiedColumns[':p' . $index++] = '`id`';
}
if ($this->isColumnModified(RolePeer::NAME)) {
$modifiedColumns[':p' . $index++] = '`name`';
}
if ($this->isColumnModified(RolePeer::ROLE)) {
$modifiedColumns[':p' . $index++] = '`role`';
}
$sql = sprintf(
'INSERT INTO `role` (%s) VALUES (%s)',
implode(', ', $modifiedColumns),
implode(', ', array_keys($modifiedColumns))
);
try {
$stmt = $con->prepare($sql);
foreach ($modifiedColumns as $identifier => $columnName) {
switch ($columnName) {
case '`id`':
$stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
break;
case '`name`':
$stmt->bindValue($identifier, $this->name, PDO::PARAM_STR);
break;
case '`role`':
$stmt->bindValue($identifier, $this->role, PDO::PARAM_STR);
break;
}
}
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
}
try {
$pk = $con->lastInsertId();
} catch (Exception $e) {
throw new PropelException('Unable to get autoincrement id.', $e);
}
$this->setId($pk);
$this->setNew(false);
} | [
"protected",
"function",
"doInsert",
"(",
"PropelPDO",
"$",
"con",
")",
"{",
"$",
"modifiedColumns",
"=",
"array",
"(",
")",
";",
"$",
"index",
"=",
"0",
";",
"$",
"this",
"->",
"modifiedColumns",
"[",
"]",
"=",
"RolePeer",
"::",
"ID",
";",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"id",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"'Cannot insert a value for auto-increment primary key ('",
".",
"RolePeer",
"::",
"ID",
".",
"')'",
")",
";",
"}",
"// check the columns in natural order for more readable SQL queries",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"RolePeer",
"::",
"ID",
")",
")",
"{",
"$",
"modifiedColumns",
"[",
"':p'",
".",
"$",
"index",
"++",
"]",
"=",
"'`id`'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"RolePeer",
"::",
"NAME",
")",
")",
"{",
"$",
"modifiedColumns",
"[",
"':p'",
".",
"$",
"index",
"++",
"]",
"=",
"'`name`'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"RolePeer",
"::",
"ROLE",
")",
")",
"{",
"$",
"modifiedColumns",
"[",
"':p'",
".",
"$",
"index",
"++",
"]",
"=",
"'`role`'",
";",
"}",
"$",
"sql",
"=",
"sprintf",
"(",
"'INSERT INTO `role` (%s) VALUES (%s)'",
",",
"implode",
"(",
"', '",
",",
"$",
"modifiedColumns",
")",
",",
"implode",
"(",
"', '",
",",
"array_keys",
"(",
"$",
"modifiedColumns",
")",
")",
")",
";",
"try",
"{",
"$",
"stmt",
"=",
"$",
"con",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"foreach",
"(",
"$",
"modifiedColumns",
"as",
"$",
"identifier",
"=>",
"$",
"columnName",
")",
"{",
"switch",
"(",
"$",
"columnName",
")",
"{",
"case",
"'`id`'",
":",
"$",
"stmt",
"->",
"bindValue",
"(",
"$",
"identifier",
",",
"$",
"this",
"->",
"id",
",",
"PDO",
"::",
"PARAM_INT",
")",
";",
"break",
";",
"case",
"'`name`'",
":",
"$",
"stmt",
"->",
"bindValue",
"(",
"$",
"identifier",
",",
"$",
"this",
"->",
"name",
",",
"PDO",
"::",
"PARAM_STR",
")",
";",
"break",
";",
"case",
"'`role`'",
":",
"$",
"stmt",
"->",
"bindValue",
"(",
"$",
"identifier",
",",
"$",
"this",
"->",
"role",
",",
"PDO",
"::",
"PARAM_STR",
")",
";",
"break",
";",
"}",
"}",
"$",
"stmt",
"->",
"execute",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"Propel",
"::",
"log",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"Propel",
"::",
"LOG_ERR",
")",
";",
"throw",
"new",
"PropelException",
"(",
"sprintf",
"(",
"'Unable to execute INSERT statement [%s]'",
",",
"$",
"sql",
")",
",",
"$",
"e",
")",
";",
"}",
"try",
"{",
"$",
"pk",
"=",
"$",
"con",
"->",
"lastInsertId",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"'Unable to get autoincrement id.'",
",",
"$",
"e",
")",
";",
"}",
"$",
"this",
"->",
"setId",
"(",
"$",
"pk",
")",
";",
"$",
"this",
"->",
"setNew",
"(",
"false",
")",
";",
"}"
]
| Insert the row in the database.
@param PropelPDO $con
@throws PropelException
@see doSave() | [
"Insert",
"the",
"row",
"in",
"the",
"database",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseRole.php#L453-L509 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseRole.php | BaseRole.doValidate | protected function doValidate($columns = null)
{
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
if (($retval = RolePeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
if ($this->collUserRoles !== null) {
foreach ($this->collUserRoles as $referrerFK) {
if (!$referrerFK->validate($columns)) {
$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
}
}
}
$this->alreadyInValidation = false;
}
return (!empty($failureMap) ? $failureMap : true);
} | php | protected function doValidate($columns = null)
{
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
if (($retval = RolePeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
if ($this->collUserRoles !== null) {
foreach ($this->collUserRoles as $referrerFK) {
if (!$referrerFK->validate($columns)) {
$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
}
}
}
$this->alreadyInValidation = false;
}
return (!empty($failureMap) ? $failureMap : true);
} | [
"protected",
"function",
"doValidate",
"(",
"$",
"columns",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"alreadyInValidation",
")",
"{",
"$",
"this",
"->",
"alreadyInValidation",
"=",
"true",
";",
"$",
"retval",
"=",
"null",
";",
"$",
"failureMap",
"=",
"array",
"(",
")",
";",
"if",
"(",
"(",
"$",
"retval",
"=",
"RolePeer",
"::",
"doValidate",
"(",
"$",
"this",
",",
"$",
"columns",
")",
")",
"!==",
"true",
")",
"{",
"$",
"failureMap",
"=",
"array_merge",
"(",
"$",
"failureMap",
",",
"$",
"retval",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"collUserRoles",
"!==",
"null",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"collUserRoles",
"as",
"$",
"referrerFK",
")",
"{",
"if",
"(",
"!",
"$",
"referrerFK",
"->",
"validate",
"(",
"$",
"columns",
")",
")",
"{",
"$",
"failureMap",
"=",
"array_merge",
"(",
"$",
"failureMap",
",",
"$",
"referrerFK",
"->",
"getValidationFailures",
"(",
")",
")",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"alreadyInValidation",
"=",
"false",
";",
"}",
"return",
"(",
"!",
"empty",
"(",
"$",
"failureMap",
")",
"?",
"$",
"failureMap",
":",
"true",
")",
";",
"}"
]
| This function performs the validation work for complex object models.
In addition to checking the current object, all related objects will
also be validated. If all pass then <code>true</code> is returned; otherwise
an aggregated array of ValidationFailed objects will be returned.
@param array $columns Array of column names to validate.
@return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objects otherwise. | [
"This",
"function",
"performs",
"the",
"validation",
"work",
"for",
"complex",
"object",
"models",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseRole.php#L578-L605 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseRole.php | BaseRole.getByPosition | public function getByPosition($pos)
{
switch ($pos) {
case 0:
return $this->getId();
break;
case 1:
return $this->getName();
break;
case 2:
return $this->getRole();
break;
default:
return null;
break;
} // switch()
} | php | public function getByPosition($pos)
{
switch ($pos) {
case 0:
return $this->getId();
break;
case 1:
return $this->getName();
break;
case 2:
return $this->getRole();
break;
default:
return null;
break;
} // switch()
} | [
"public",
"function",
"getByPosition",
"(",
"$",
"pos",
")",
"{",
"switch",
"(",
"$",
"pos",
")",
"{",
"case",
"0",
":",
"return",
"$",
"this",
"->",
"getId",
"(",
")",
";",
"break",
";",
"case",
"1",
":",
"return",
"$",
"this",
"->",
"getName",
"(",
")",
";",
"break",
";",
"case",
"2",
":",
"return",
"$",
"this",
"->",
"getRole",
"(",
")",
";",
"break",
";",
"default",
":",
"return",
"null",
";",
"break",
";",
"}",
"// switch()",
"}"
]
| Retrieves a field from the object by Position as specified in the xml schema.
Zero-based.
@param int $pos position in xml schema
@return mixed Value of field at $pos | [
"Retrieves",
"a",
"field",
"from",
"the",
"object",
"by",
"Position",
"as",
"specified",
"in",
"the",
"xml",
"schema",
".",
"Zero",
"-",
"based",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseRole.php#L632-L648 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseRole.php | BaseRole.toArray | public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
{
if (isset($alreadyDumpedObjects['Role'][$this->getPrimaryKey()])) {
return '*RECURSION*';
}
$alreadyDumpedObjects['Role'][$this->getPrimaryKey()] = true;
$keys = RolePeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getId(),
$keys[1] => $this->getName(),
$keys[2] => $this->getRole(),
);
$virtualColumns = $this->virtualColumns;
foreach ($virtualColumns as $key => $virtualColumn) {
$result[$key] = $virtualColumn;
}
if ($includeForeignObjects) {
if (null !== $this->collUserRoles) {
$result['UserRoles'] = $this->collUserRoles->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
}
return $result;
} | php | public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
{
if (isset($alreadyDumpedObjects['Role'][$this->getPrimaryKey()])) {
return '*RECURSION*';
}
$alreadyDumpedObjects['Role'][$this->getPrimaryKey()] = true;
$keys = RolePeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getId(),
$keys[1] => $this->getName(),
$keys[2] => $this->getRole(),
);
$virtualColumns = $this->virtualColumns;
foreach ($virtualColumns as $key => $virtualColumn) {
$result[$key] = $virtualColumn;
}
if ($includeForeignObjects) {
if (null !== $this->collUserRoles) {
$result['UserRoles'] = $this->collUserRoles->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
}
return $result;
} | [
"public",
"function",
"toArray",
"(",
"$",
"keyType",
"=",
"BasePeer",
"::",
"TYPE_PHPNAME",
",",
"$",
"includeLazyLoadColumns",
"=",
"true",
",",
"$",
"alreadyDumpedObjects",
"=",
"array",
"(",
")",
",",
"$",
"includeForeignObjects",
"=",
"false",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"alreadyDumpedObjects",
"[",
"'Role'",
"]",
"[",
"$",
"this",
"->",
"getPrimaryKey",
"(",
")",
"]",
")",
")",
"{",
"return",
"'*RECURSION*'",
";",
"}",
"$",
"alreadyDumpedObjects",
"[",
"'Role'",
"]",
"[",
"$",
"this",
"->",
"getPrimaryKey",
"(",
")",
"]",
"=",
"true",
";",
"$",
"keys",
"=",
"RolePeer",
"::",
"getFieldNames",
"(",
"$",
"keyType",
")",
";",
"$",
"result",
"=",
"array",
"(",
"$",
"keys",
"[",
"0",
"]",
"=>",
"$",
"this",
"->",
"getId",
"(",
")",
",",
"$",
"keys",
"[",
"1",
"]",
"=>",
"$",
"this",
"->",
"getName",
"(",
")",
",",
"$",
"keys",
"[",
"2",
"]",
"=>",
"$",
"this",
"->",
"getRole",
"(",
")",
",",
")",
";",
"$",
"virtualColumns",
"=",
"$",
"this",
"->",
"virtualColumns",
";",
"foreach",
"(",
"$",
"virtualColumns",
"as",
"$",
"key",
"=>",
"$",
"virtualColumn",
")",
"{",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"$",
"virtualColumn",
";",
"}",
"if",
"(",
"$",
"includeForeignObjects",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"collUserRoles",
")",
"{",
"$",
"result",
"[",
"'UserRoles'",
"]",
"=",
"$",
"this",
"->",
"collUserRoles",
"->",
"toArray",
"(",
"null",
",",
"true",
",",
"$",
"keyType",
",",
"$",
"includeLazyLoadColumns",
",",
"$",
"alreadyDumpedObjects",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
]
| Exports the object as an array.
You can specify the key type of the array by passing one of the class
type constants.
@param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
Defaults to BasePeer::TYPE_PHPNAME.
@param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
@param array $alreadyDumpedObjects List of objects to skip to avoid recursion
@param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
@return array an associative array containing the field names (as keys) and field values | [
"Exports",
"the",
"object",
"as",
"an",
"array",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseRole.php#L665-L689 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseRole.php | BaseRole.setByPosition | public function setByPosition($pos, $value)
{
switch ($pos) {
case 0:
$this->setId($value);
break;
case 1:
$this->setName($value);
break;
case 2:
$this->setRole($value);
break;
} // switch()
} | php | public function setByPosition($pos, $value)
{
switch ($pos) {
case 0:
$this->setId($value);
break;
case 1:
$this->setName($value);
break;
case 2:
$this->setRole($value);
break;
} // switch()
} | [
"public",
"function",
"setByPosition",
"(",
"$",
"pos",
",",
"$",
"value",
")",
"{",
"switch",
"(",
"$",
"pos",
")",
"{",
"case",
"0",
":",
"$",
"this",
"->",
"setId",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"1",
":",
"$",
"this",
"->",
"setName",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"2",
":",
"$",
"this",
"->",
"setRole",
"(",
"$",
"value",
")",
";",
"break",
";",
"}",
"// switch()",
"}"
]
| Sets a field from the object by Position as specified in the xml schema.
Zero-based.
@param int $pos position in xml schema
@param mixed $value field value
@return void | [
"Sets",
"a",
"field",
"from",
"the",
"object",
"by",
"Position",
"as",
"specified",
"in",
"the",
"xml",
"schema",
".",
"Zero",
"-",
"based",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseRole.php#L717-L730 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseRole.php | BaseRole.fromArray | public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
{
$keys = RolePeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setName($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setRole($arr[$keys[2]]);
} | php | public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
{
$keys = RolePeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setName($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setRole($arr[$keys[2]]);
} | [
"public",
"function",
"fromArray",
"(",
"$",
"arr",
",",
"$",
"keyType",
"=",
"BasePeer",
"::",
"TYPE_PHPNAME",
")",
"{",
"$",
"keys",
"=",
"RolePeer",
"::",
"getFieldNames",
"(",
"$",
"keyType",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"keys",
"[",
"0",
"]",
",",
"$",
"arr",
")",
")",
"$",
"this",
"->",
"setId",
"(",
"$",
"arr",
"[",
"$",
"keys",
"[",
"0",
"]",
"]",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"keys",
"[",
"1",
"]",
",",
"$",
"arr",
")",
")",
"$",
"this",
"->",
"setName",
"(",
"$",
"arr",
"[",
"$",
"keys",
"[",
"1",
"]",
"]",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"keys",
"[",
"2",
"]",
",",
"$",
"arr",
")",
")",
"$",
"this",
"->",
"setRole",
"(",
"$",
"arr",
"[",
"$",
"keys",
"[",
"2",
"]",
"]",
")",
";",
"}"
]
| Populates the object using an array.
This is particularly useful when populating an object from one of the
request arrays (e.g. $_POST). This method goes through the column
names, checking to see whether a matching key exists in populated
array. If so the setByName() method is called for that column.
You can specify the key type of the array by additionally passing one
of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
The default key type is the column's BasePeer::TYPE_PHPNAME
@param array $arr An array to populate the object from.
@param string $keyType The type of keys the array uses.
@return void | [
"Populates",
"the",
"object",
"using",
"an",
"array",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseRole.php#L749-L756 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseRole.php | BaseRole.buildCriteria | public function buildCriteria()
{
$criteria = new Criteria(RolePeer::DATABASE_NAME);
if ($this->isColumnModified(RolePeer::ID)) $criteria->add(RolePeer::ID, $this->id);
if ($this->isColumnModified(RolePeer::NAME)) $criteria->add(RolePeer::NAME, $this->name);
if ($this->isColumnModified(RolePeer::ROLE)) $criteria->add(RolePeer::ROLE, $this->role);
return $criteria;
} | php | public function buildCriteria()
{
$criteria = new Criteria(RolePeer::DATABASE_NAME);
if ($this->isColumnModified(RolePeer::ID)) $criteria->add(RolePeer::ID, $this->id);
if ($this->isColumnModified(RolePeer::NAME)) $criteria->add(RolePeer::NAME, $this->name);
if ($this->isColumnModified(RolePeer::ROLE)) $criteria->add(RolePeer::ROLE, $this->role);
return $criteria;
} | [
"public",
"function",
"buildCriteria",
"(",
")",
"{",
"$",
"criteria",
"=",
"new",
"Criteria",
"(",
"RolePeer",
"::",
"DATABASE_NAME",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"RolePeer",
"::",
"ID",
")",
")",
"$",
"criteria",
"->",
"add",
"(",
"RolePeer",
"::",
"ID",
",",
"$",
"this",
"->",
"id",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"RolePeer",
"::",
"NAME",
")",
")",
"$",
"criteria",
"->",
"add",
"(",
"RolePeer",
"::",
"NAME",
",",
"$",
"this",
"->",
"name",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"RolePeer",
"::",
"ROLE",
")",
")",
"$",
"criteria",
"->",
"add",
"(",
"RolePeer",
"::",
"ROLE",
",",
"$",
"this",
"->",
"role",
")",
";",
"return",
"$",
"criteria",
";",
"}"
]
| Build a Criteria object containing the values of all modified columns in this object.
@return Criteria The Criteria object containing all modified values. | [
"Build",
"a",
"Criteria",
"object",
"containing",
"the",
"values",
"of",
"all",
"modified",
"columns",
"in",
"this",
"object",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseRole.php#L763-L772 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseRole.php | BaseRole.copyInto | public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
{
$copyObj->setName($this->getName());
$copyObj->setRole($this->getRole());
if ($deepCopy && !$this->startCopy) {
// important: temporarily setNew(false) because this affects the behavior of
// the getter/setter methods for fkey referrer objects.
$copyObj->setNew(false);
// store object hash to prevent cycle
$this->startCopy = true;
foreach ($this->getUserRoles() as $relObj) {
if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
$copyObj->addUserRole($relObj->copy($deepCopy));
}
}
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
if ($makeNew) {
$copyObj->setNew(true);
$copyObj->setId(NULL); // this is a auto-increment column, so set to default value
}
} | php | public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
{
$copyObj->setName($this->getName());
$copyObj->setRole($this->getRole());
if ($deepCopy && !$this->startCopy) {
// important: temporarily setNew(false) because this affects the behavior of
// the getter/setter methods for fkey referrer objects.
$copyObj->setNew(false);
// store object hash to prevent cycle
$this->startCopy = true;
foreach ($this->getUserRoles() as $relObj) {
if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
$copyObj->addUserRole($relObj->copy($deepCopy));
}
}
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
if ($makeNew) {
$copyObj->setNew(true);
$copyObj->setId(NULL); // this is a auto-increment column, so set to default value
}
} | [
"public",
"function",
"copyInto",
"(",
"$",
"copyObj",
",",
"$",
"deepCopy",
"=",
"false",
",",
"$",
"makeNew",
"=",
"true",
")",
"{",
"$",
"copyObj",
"->",
"setName",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
")",
";",
"$",
"copyObj",
"->",
"setRole",
"(",
"$",
"this",
"->",
"getRole",
"(",
")",
")",
";",
"if",
"(",
"$",
"deepCopy",
"&&",
"!",
"$",
"this",
"->",
"startCopy",
")",
"{",
"// important: temporarily setNew(false) because this affects the behavior of",
"// the getter/setter methods for fkey referrer objects.",
"$",
"copyObj",
"->",
"setNew",
"(",
"false",
")",
";",
"// store object hash to prevent cycle",
"$",
"this",
"->",
"startCopy",
"=",
"true",
";",
"foreach",
"(",
"$",
"this",
"->",
"getUserRoles",
"(",
")",
"as",
"$",
"relObj",
")",
"{",
"if",
"(",
"$",
"relObj",
"!==",
"$",
"this",
")",
"{",
"// ensure that we don't try to copy a reference to ourselves",
"$",
"copyObj",
"->",
"addUserRole",
"(",
"$",
"relObj",
"->",
"copy",
"(",
"$",
"deepCopy",
")",
")",
";",
"}",
"}",
"//unflag object copy",
"$",
"this",
"->",
"startCopy",
"=",
"false",
";",
"}",
"// if ($deepCopy)",
"if",
"(",
"$",
"makeNew",
")",
"{",
"$",
"copyObj",
"->",
"setNew",
"(",
"true",
")",
";",
"$",
"copyObj",
"->",
"setId",
"(",
"NULL",
")",
";",
"// this is a auto-increment column, so set to default value",
"}",
"}"
]
| Sets contents of passed object to values from current object.
If desired, this method can also make copies of all associated (fkey referrers)
objects.
@param object $copyObj An object of Role (or compatible) type.
@param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
@param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
@throws PropelException | [
"Sets",
"contents",
"of",
"passed",
"object",
"to",
"values",
"from",
"current",
"object",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseRole.php#L831-L857 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseRole.php | BaseRole.initUserRoles | public function initUserRoles($overrideExisting = true)
{
if (null !== $this->collUserRoles && !$overrideExisting) {
return;
}
$this->collUserRoles = new PropelObjectCollection();
$this->collUserRoles->setModel('UserRole');
} | php | public function initUserRoles($overrideExisting = true)
{
if (null !== $this->collUserRoles && !$overrideExisting) {
return;
}
$this->collUserRoles = new PropelObjectCollection();
$this->collUserRoles->setModel('UserRole');
} | [
"public",
"function",
"initUserRoles",
"(",
"$",
"overrideExisting",
"=",
"true",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"collUserRoles",
"&&",
"!",
"$",
"overrideExisting",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"collUserRoles",
"=",
"new",
"PropelObjectCollection",
"(",
")",
";",
"$",
"this",
"->",
"collUserRoles",
"->",
"setModel",
"(",
"'UserRole'",
")",
";",
"}"
]
| Initializes the collUserRoles collection.
By default this just sets the collUserRoles collection to an empty array (like clearcollUserRoles());
however, you may wish to override this method in your stub class to provide setting appropriate
to your application -- for example, setting the initial array to the values stored in database.
@param boolean $overrideExisting If set to true, the method call initializes
the collection even if it is not empty
@return void | [
"Initializes",
"the",
"collUserRoles",
"collection",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseRole.php#L954-L961 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseRole.php | BaseRole.setUserRoles | public function setUserRoles(PropelCollection $userRoles, PropelPDO $con = null)
{
$userRolesToDelete = $this->getUserRoles(new Criteria(), $con)->diff($userRoles);
//since at least one column in the foreign key is at the same time a PK
//we can not just set a PK to NULL in the lines below. We have to store
//a backup of all values, so we are able to manipulate these items based on the onDelete value later.
$this->userRolesScheduledForDeletion = clone $userRolesToDelete;
foreach ($userRolesToDelete as $userRoleRemoved) {
$userRoleRemoved->setRole(null);
}
$this->collUserRoles = null;
foreach ($userRoles as $userRole) {
$this->addUserRole($userRole);
}
$this->collUserRoles = $userRoles;
$this->collUserRolesPartial = false;
return $this;
} | php | public function setUserRoles(PropelCollection $userRoles, PropelPDO $con = null)
{
$userRolesToDelete = $this->getUserRoles(new Criteria(), $con)->diff($userRoles);
//since at least one column in the foreign key is at the same time a PK
//we can not just set a PK to NULL in the lines below. We have to store
//a backup of all values, so we are able to manipulate these items based on the onDelete value later.
$this->userRolesScheduledForDeletion = clone $userRolesToDelete;
foreach ($userRolesToDelete as $userRoleRemoved) {
$userRoleRemoved->setRole(null);
}
$this->collUserRoles = null;
foreach ($userRoles as $userRole) {
$this->addUserRole($userRole);
}
$this->collUserRoles = $userRoles;
$this->collUserRolesPartial = false;
return $this;
} | [
"public",
"function",
"setUserRoles",
"(",
"PropelCollection",
"$",
"userRoles",
",",
"PropelPDO",
"$",
"con",
"=",
"null",
")",
"{",
"$",
"userRolesToDelete",
"=",
"$",
"this",
"->",
"getUserRoles",
"(",
"new",
"Criteria",
"(",
")",
",",
"$",
"con",
")",
"->",
"diff",
"(",
"$",
"userRoles",
")",
";",
"//since at least one column in the foreign key is at the same time a PK",
"//we can not just set a PK to NULL in the lines below. We have to store",
"//a backup of all values, so we are able to manipulate these items based on the onDelete value later.",
"$",
"this",
"->",
"userRolesScheduledForDeletion",
"=",
"clone",
"$",
"userRolesToDelete",
";",
"foreach",
"(",
"$",
"userRolesToDelete",
"as",
"$",
"userRoleRemoved",
")",
"{",
"$",
"userRoleRemoved",
"->",
"setRole",
"(",
"null",
")",
";",
"}",
"$",
"this",
"->",
"collUserRoles",
"=",
"null",
";",
"foreach",
"(",
"$",
"userRoles",
"as",
"$",
"userRole",
")",
"{",
"$",
"this",
"->",
"addUserRole",
"(",
"$",
"userRole",
")",
";",
"}",
"$",
"this",
"->",
"collUserRoles",
"=",
"$",
"userRoles",
";",
"$",
"this",
"->",
"collUserRolesPartial",
"=",
"false",
";",
"return",
"$",
"this",
";",
"}"
]
| Sets a collection of UserRole objects related by a one-to-many relationship
to the current object.
It will also schedule objects for deletion based on a diff between old objects (aka persisted)
and new objects from the given Propel collection.
@param PropelCollection $userRoles A Propel collection.
@param PropelPDO $con Optional connection object
@return Role The current object (for fluent API support) | [
"Sets",
"a",
"collection",
"of",
"UserRole",
"objects",
"related",
"by",
"a",
"one",
"-",
"to",
"-",
"many",
"relationship",
"to",
"the",
"current",
"object",
".",
"It",
"will",
"also",
"schedule",
"objects",
"for",
"deletion",
"based",
"on",
"a",
"diff",
"between",
"old",
"objects",
"(",
"aka",
"persisted",
")",
"and",
"new",
"objects",
"from",
"the",
"given",
"Propel",
"collection",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseRole.php#L1032-L1055 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseRole.php | BaseRole.countUserRoles | public function countUserRoles(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
{
$partial = $this->collUserRolesPartial && !$this->isNew();
if (null === $this->collUserRoles || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collUserRoles) {
return 0;
}
if ($partial && !$criteria) {
return count($this->getUserRoles());
}
$query = UserRoleQuery::create(null, $criteria);
if ($distinct) {
$query->distinct();
}
return $query
->filterByRole($this)
->count($con);
}
return count($this->collUserRoles);
} | php | public function countUserRoles(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
{
$partial = $this->collUserRolesPartial && !$this->isNew();
if (null === $this->collUserRoles || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collUserRoles) {
return 0;
}
if ($partial && !$criteria) {
return count($this->getUserRoles());
}
$query = UserRoleQuery::create(null, $criteria);
if ($distinct) {
$query->distinct();
}
return $query
->filterByRole($this)
->count($con);
}
return count($this->collUserRoles);
} | [
"public",
"function",
"countUserRoles",
"(",
"Criteria",
"$",
"criteria",
"=",
"null",
",",
"$",
"distinct",
"=",
"false",
",",
"PropelPDO",
"$",
"con",
"=",
"null",
")",
"{",
"$",
"partial",
"=",
"$",
"this",
"->",
"collUserRolesPartial",
"&&",
"!",
"$",
"this",
"->",
"isNew",
"(",
")",
";",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"collUserRoles",
"||",
"null",
"!==",
"$",
"criteria",
"||",
"$",
"partial",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isNew",
"(",
")",
"&&",
"null",
"===",
"$",
"this",
"->",
"collUserRoles",
")",
"{",
"return",
"0",
";",
"}",
"if",
"(",
"$",
"partial",
"&&",
"!",
"$",
"criteria",
")",
"{",
"return",
"count",
"(",
"$",
"this",
"->",
"getUserRoles",
"(",
")",
")",
";",
"}",
"$",
"query",
"=",
"UserRoleQuery",
"::",
"create",
"(",
"null",
",",
"$",
"criteria",
")",
";",
"if",
"(",
"$",
"distinct",
")",
"{",
"$",
"query",
"->",
"distinct",
"(",
")",
";",
"}",
"return",
"$",
"query",
"->",
"filterByRole",
"(",
"$",
"this",
")",
"->",
"count",
"(",
"$",
"con",
")",
";",
"}",
"return",
"count",
"(",
"$",
"this",
"->",
"collUserRoles",
")",
";",
"}"
]
| Returns the number of related UserRole objects.
@param Criteria $criteria
@param boolean $distinct
@param PropelPDO $con
@return int Count of related UserRole objects.
@throws PropelException | [
"Returns",
"the",
"number",
"of",
"related",
"UserRole",
"objects",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseRole.php#L1066-L1088 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseRole.php | BaseRole.addUserRole | public function addUserRole(UserRole $l)
{
if ($this->collUserRoles === null) {
$this->initUserRoles();
$this->collUserRolesPartial = true;
}
if (!in_array($l, $this->collUserRoles->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
$this->doAddUserRole($l);
if ($this->userRolesScheduledForDeletion and $this->userRolesScheduledForDeletion->contains($l)) {
$this->userRolesScheduledForDeletion->remove($this->userRolesScheduledForDeletion->search($l));
}
}
return $this;
} | php | public function addUserRole(UserRole $l)
{
if ($this->collUserRoles === null) {
$this->initUserRoles();
$this->collUserRolesPartial = true;
}
if (!in_array($l, $this->collUserRoles->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
$this->doAddUserRole($l);
if ($this->userRolesScheduledForDeletion and $this->userRolesScheduledForDeletion->contains($l)) {
$this->userRolesScheduledForDeletion->remove($this->userRolesScheduledForDeletion->search($l));
}
}
return $this;
} | [
"public",
"function",
"addUserRole",
"(",
"UserRole",
"$",
"l",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"collUserRoles",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"initUserRoles",
"(",
")",
";",
"$",
"this",
"->",
"collUserRolesPartial",
"=",
"true",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"$",
"l",
",",
"$",
"this",
"->",
"collUserRoles",
"->",
"getArrayCopy",
"(",
")",
",",
"true",
")",
")",
"{",
"// only add it if the **same** object is not already associated",
"$",
"this",
"->",
"doAddUserRole",
"(",
"$",
"l",
")",
";",
"if",
"(",
"$",
"this",
"->",
"userRolesScheduledForDeletion",
"and",
"$",
"this",
"->",
"userRolesScheduledForDeletion",
"->",
"contains",
"(",
"$",
"l",
")",
")",
"{",
"$",
"this",
"->",
"userRolesScheduledForDeletion",
"->",
"remove",
"(",
"$",
"this",
"->",
"userRolesScheduledForDeletion",
"->",
"search",
"(",
"$",
"l",
")",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
]
| Method called to associate a UserRole object to this object
through the UserRole foreign key attribute.
@param UserRole $l UserRole
@return Role The current object (for fluent API support) | [
"Method",
"called",
"to",
"associate",
"a",
"UserRole",
"object",
"to",
"this",
"object",
"through",
"the",
"UserRole",
"foreign",
"key",
"attribute",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseRole.php#L1097-L1113 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseRole.php | BaseRole.getUserRolesJoinUser | public function getUserRolesJoinUser($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
{
$query = UserRoleQuery::create(null, $criteria);
$query->joinWith('User', $join_behavior);
return $this->getUserRoles($query, $con);
} | php | public function getUserRolesJoinUser($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
{
$query = UserRoleQuery::create(null, $criteria);
$query->joinWith('User', $join_behavior);
return $this->getUserRoles($query, $con);
} | [
"public",
"function",
"getUserRolesJoinUser",
"(",
"$",
"criteria",
"=",
"null",
",",
"$",
"con",
"=",
"null",
",",
"$",
"join_behavior",
"=",
"Criteria",
"::",
"LEFT_JOIN",
")",
"{",
"$",
"query",
"=",
"UserRoleQuery",
"::",
"create",
"(",
"null",
",",
"$",
"criteria",
")",
";",
"$",
"query",
"->",
"joinWith",
"(",
"'User'",
",",
"$",
"join_behavior",
")",
";",
"return",
"$",
"this",
"->",
"getUserRoles",
"(",
"$",
"query",
",",
"$",
"con",
")",
";",
"}"
]
| If this collection has already been initialized with
an identical criteria, it returns the collection.
Otherwise if this Role is new, it will return
an empty collection; or if this Role has previously
been saved, it will retrieve related UserRoles from storage.
This method is protected by default in order to keep the public
api reasonable. You can provide public methods for those you
actually need in Role.
@param Criteria $criteria optional Criteria object to narrow the query
@param PropelPDO $con optional connection object
@param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
@return PropelObjectCollection|UserRole[] List of UserRole objects | [
"If",
"this",
"collection",
"has",
"already",
"been",
"initialized",
"with",
"an",
"identical",
"criteria",
"it",
"returns",
"the",
"collection",
".",
"Otherwise",
"if",
"this",
"Role",
"is",
"new",
"it",
"will",
"return",
"an",
"empty",
"collection",
";",
"or",
"if",
"this",
"Role",
"has",
"previously",
"been",
"saved",
"it",
"will",
"retrieve",
"related",
"UserRoles",
"from",
"storage",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseRole.php#L1160-L1166 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseRole.php | BaseRole.clear | public function clear()
{
$this->id = null;
$this->name = null;
$this->role = null;
$this->alreadyInSave = false;
$this->alreadyInValidation = false;
$this->alreadyInClearAllReferencesDeep = false;
$this->clearAllReferences();
$this->resetModified();
$this->setNew(true);
$this->setDeleted(false);
} | php | public function clear()
{
$this->id = null;
$this->name = null;
$this->role = null;
$this->alreadyInSave = false;
$this->alreadyInValidation = false;
$this->alreadyInClearAllReferencesDeep = false;
$this->clearAllReferences();
$this->resetModified();
$this->setNew(true);
$this->setDeleted(false);
} | [
"public",
"function",
"clear",
"(",
")",
"{",
"$",
"this",
"->",
"id",
"=",
"null",
";",
"$",
"this",
"->",
"name",
"=",
"null",
";",
"$",
"this",
"->",
"role",
"=",
"null",
";",
"$",
"this",
"->",
"alreadyInSave",
"=",
"false",
";",
"$",
"this",
"->",
"alreadyInValidation",
"=",
"false",
";",
"$",
"this",
"->",
"alreadyInClearAllReferencesDeep",
"=",
"false",
";",
"$",
"this",
"->",
"clearAllReferences",
"(",
")",
";",
"$",
"this",
"->",
"resetModified",
"(",
")",
";",
"$",
"this",
"->",
"setNew",
"(",
"true",
")",
";",
"$",
"this",
"->",
"setDeleted",
"(",
"false",
")",
";",
"}"
]
| Clears the current object and sets all attributes to their default values | [
"Clears",
"the",
"current",
"object",
"and",
"sets",
"all",
"attributes",
"to",
"their",
"default",
"values"
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseRole.php#L1171-L1183 |
PortaText/php-sdk | src/PortaText/Command/Api/Inspect.php | Inspect.getEndpoint | protected function getEndpoint($method)
{
$endpoint = 'inspect';
$number = $this->getArgument("number");
if (!is_null($number)) {
$endpoint .= "/$number";
$this->delArgument("number");
}
return $endpoint;
} | php | protected function getEndpoint($method)
{
$endpoint = 'inspect';
$number = $this->getArgument("number");
if (!is_null($number)) {
$endpoint .= "/$number";
$this->delArgument("number");
}
return $endpoint;
} | [
"protected",
"function",
"getEndpoint",
"(",
"$",
"method",
")",
"{",
"$",
"endpoint",
"=",
"'inspect'",
";",
"$",
"number",
"=",
"$",
"this",
"->",
"getArgument",
"(",
"\"number\"",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"number",
")",
")",
"{",
"$",
"endpoint",
".=",
"\"/$number\"",
";",
"$",
"this",
"->",
"delArgument",
"(",
"\"number\"",
")",
";",
"}",
"return",
"$",
"endpoint",
";",
"}"
]
| Returns a string with the endpoint for the given command.
@param string $method Method for this command.
@return string | [
"Returns",
"a",
"string",
"with",
"the",
"endpoint",
"for",
"the",
"given",
"command",
"."
]
| train | https://github.com/PortaText/php-sdk/blob/dbe04ef043db5b251953f9de57aa4d0f1785dfcc/src/PortaText/Command/Api/Inspect.php#L50-L59 |
redaigbaria/oauth2 | src/TokenType/Bearer.php | Bearer.generateResponse | public function generateResponse()
{
$return = [
'access_token' => $this->getParam('access_token'),
'token_type' => 'Bearer',
'expires_in' => $this->getParam('expires_in'),
];
if (!is_null($this->getParam('refresh_token'))) {
$return['refresh_token'] = $this->getParam('refresh_token');
}
return $return;
} | php | public function generateResponse()
{
$return = [
'access_token' => $this->getParam('access_token'),
'token_type' => 'Bearer',
'expires_in' => $this->getParam('expires_in'),
];
if (!is_null($this->getParam('refresh_token'))) {
$return['refresh_token'] = $this->getParam('refresh_token');
}
return $return;
} | [
"public",
"function",
"generateResponse",
"(",
")",
"{",
"$",
"return",
"=",
"[",
"'access_token'",
"=>",
"$",
"this",
"->",
"getParam",
"(",
"'access_token'",
")",
",",
"'token_type'",
"=>",
"'Bearer'",
",",
"'expires_in'",
"=>",
"$",
"this",
"->",
"getParam",
"(",
"'expires_in'",
")",
",",
"]",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"getParam",
"(",
"'refresh_token'",
")",
")",
")",
"{",
"$",
"return",
"[",
"'refresh_token'",
"]",
"=",
"$",
"this",
"->",
"getParam",
"(",
"'refresh_token'",
")",
";",
"}",
"return",
"$",
"return",
";",
"}"
]
| {@inheritdoc} | [
"{"
]
| train | https://github.com/redaigbaria/oauth2/blob/54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a/src/TokenType/Bearer.php#L21-L34 |
redaigbaria/oauth2 | src/TokenType/Bearer.php | Bearer.determineAccessTokenInHeader | public function determineAccessTokenInHeader(Request $request)
{
if ($request->headers->has('Authorization') === false) {
return;
}
$header = $request->headers->get('Authorization');
$header = explode(',', $header)[0];
if (substr($header, 0, 7) !== 'Bearer ') {
return;
}
return trim(substr($header, 7));
} | php | public function determineAccessTokenInHeader(Request $request)
{
if ($request->headers->has('Authorization') === false) {
return;
}
$header = $request->headers->get('Authorization');
$header = explode(',', $header)[0];
if (substr($header, 0, 7) !== 'Bearer ') {
return;
}
return trim(substr($header, 7));
} | [
"public",
"function",
"determineAccessTokenInHeader",
"(",
"Request",
"$",
"request",
")",
"{",
"if",
"(",
"$",
"request",
"->",
"headers",
"->",
"has",
"(",
"'Authorization'",
")",
"===",
"false",
")",
"{",
"return",
";",
"}",
"$",
"header",
"=",
"$",
"request",
"->",
"headers",
"->",
"get",
"(",
"'Authorization'",
")",
";",
"$",
"header",
"=",
"explode",
"(",
"','",
",",
"$",
"header",
")",
"[",
"0",
"]",
";",
"if",
"(",
"substr",
"(",
"$",
"header",
",",
"0",
",",
"7",
")",
"!==",
"'Bearer '",
")",
"{",
"return",
";",
"}",
"return",
"trim",
"(",
"substr",
"(",
"$",
"header",
",",
"7",
")",
")",
";",
"}"
]
| {@inheritdoc} | [
"{"
]
| train | https://github.com/redaigbaria/oauth2/blob/54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a/src/TokenType/Bearer.php#L39-L53 |
JBZoo/Less | src/Driver/Iless.php | Iless._compile | protected function _compile($fullPath, $relPath)
{
$this->_initCompiler();
$this->_compiler->parseFile($fullPath);
$resultCss = $this->_compiler->getCSS();
return $resultCss;
} | php | protected function _compile($fullPath, $relPath)
{
$this->_initCompiler();
$this->_compiler->parseFile($fullPath);
$resultCss = $this->_compiler->getCSS();
return $resultCss;
} | [
"protected",
"function",
"_compile",
"(",
"$",
"fullPath",
",",
"$",
"relPath",
")",
"{",
"$",
"this",
"->",
"_initCompiler",
"(",
")",
";",
"$",
"this",
"->",
"_compiler",
"->",
"parseFile",
"(",
"$",
"fullPath",
")",
";",
"$",
"resultCss",
"=",
"$",
"this",
"->",
"_compiler",
"->",
"getCSS",
"(",
")",
";",
"return",
"$",
"resultCss",
";",
"}"
]
| {@inheritdoc} | [
"{"
]
| train | https://github.com/JBZoo/Less/blob/9e9c41e3c7b76222c0d81379dead222413f2f042/src/Driver/Iless.php#L37-L46 |
SAREhub/PHP_Commons | src/SAREhub/Commons/Zmq/RequestReply/RequestSender.php | RequestSender.sendRequest | public function sendRequest($request, $wait = self::WAIT)
{
$this->getSocket()->send($request, ($wait) ? 0 : \ZMQ::MODE_DONTWAIT);
return $this;
} | php | public function sendRequest($request, $wait = self::WAIT)
{
$this->getSocket()->send($request, ($wait) ? 0 : \ZMQ::MODE_DONTWAIT);
return $this;
} | [
"public",
"function",
"sendRequest",
"(",
"$",
"request",
",",
"$",
"wait",
"=",
"self",
"::",
"WAIT",
")",
"{",
"$",
"this",
"->",
"getSocket",
"(",
")",
"->",
"send",
"(",
"$",
"request",
",",
"(",
"$",
"wait",
")",
"?",
"0",
":",
"\\",
"ZMQ",
"::",
"MODE_DONTWAIT",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Send request via ZMQ socket.
@param string $request Request payload.
@param bool $wait If true that operation would be block.
@return $this
@throws \ZMQSocketException | [
"Send",
"request",
"via",
"ZMQ",
"socket",
"."
]
| train | https://github.com/SAREhub/PHP_Commons/blob/4e1769ab6411a584112df1151dcc90e6b82fe2bb/src/SAREhub/Commons/Zmq/RequestReply/RequestSender.php#L75-L79 |
redaigbaria/oauth2 | examples/relational/Storage/AccessTokenStorage.php | AccessTokenStorage.get | public function get($token)
{
$result = Capsule::table('oauth_access_tokens')
->where('access_token', $token)
->get();
if (count($result) === 1) {
$token = (new AccessTokenEntity($this->server))
->setId($result[0]['access_token'])
->setExpireTime($result[0]['expire_time']);
return $token;
}
return;
} | php | public function get($token)
{
$result = Capsule::table('oauth_access_tokens')
->where('access_token', $token)
->get();
if (count($result) === 1) {
$token = (new AccessTokenEntity($this->server))
->setId($result[0]['access_token'])
->setExpireTime($result[0]['expire_time']);
return $token;
}
return;
} | [
"public",
"function",
"get",
"(",
"$",
"token",
")",
"{",
"$",
"result",
"=",
"Capsule",
"::",
"table",
"(",
"'oauth_access_tokens'",
")",
"->",
"where",
"(",
"'access_token'",
",",
"$",
"token",
")",
"->",
"get",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"result",
")",
"===",
"1",
")",
"{",
"$",
"token",
"=",
"(",
"new",
"AccessTokenEntity",
"(",
"$",
"this",
"->",
"server",
")",
")",
"->",
"setId",
"(",
"$",
"result",
"[",
"0",
"]",
"[",
"'access_token'",
"]",
")",
"->",
"setExpireTime",
"(",
"$",
"result",
"[",
"0",
"]",
"[",
"'expire_time'",
"]",
")",
";",
"return",
"$",
"token",
";",
"}",
"return",
";",
"}"
]
| {@inheritdoc} | [
"{"
]
| train | https://github.com/redaigbaria/oauth2/blob/54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a/examples/relational/Storage/AccessTokenStorage.php#L16-L31 |
redaigbaria/oauth2 | examples/relational/Storage/AccessTokenStorage.php | AccessTokenStorage.create | public function create($token, $expireTime, $sessionId)
{
Capsule::table('oauth_access_tokens')
->insert([
'access_token' => $token,
'session_id' => $sessionId,
'expire_time' => $expireTime,
]);
} | php | public function create($token, $expireTime, $sessionId)
{
Capsule::table('oauth_access_tokens')
->insert([
'access_token' => $token,
'session_id' => $sessionId,
'expire_time' => $expireTime,
]);
} | [
"public",
"function",
"create",
"(",
"$",
"token",
",",
"$",
"expireTime",
",",
"$",
"sessionId",
")",
"{",
"Capsule",
"::",
"table",
"(",
"'oauth_access_tokens'",
")",
"->",
"insert",
"(",
"[",
"'access_token'",
"=>",
"$",
"token",
",",
"'session_id'",
"=>",
"$",
"sessionId",
",",
"'expire_time'",
"=>",
"$",
"expireTime",
",",
"]",
")",
";",
"}"
]
| {@inheritdoc} | [
"{"
]
| train | https://github.com/redaigbaria/oauth2/blob/54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a/examples/relational/Storage/AccessTokenStorage.php#L62-L70 |
redaigbaria/oauth2 | examples/relational/Storage/AccessTokenStorage.php | AccessTokenStorage.associateScope | public function associateScope(AccessTokenEntity $token, ScopeEntity $scope)
{
Capsule::table('oauth_access_token_scopes')
->insert([
'access_token' => $token->getId(),
'scope' => $scope->getId(),
]);
} | php | public function associateScope(AccessTokenEntity $token, ScopeEntity $scope)
{
Capsule::table('oauth_access_token_scopes')
->insert([
'access_token' => $token->getId(),
'scope' => $scope->getId(),
]);
} | [
"public",
"function",
"associateScope",
"(",
"AccessTokenEntity",
"$",
"token",
",",
"ScopeEntity",
"$",
"scope",
")",
"{",
"Capsule",
"::",
"table",
"(",
"'oauth_access_token_scopes'",
")",
"->",
"insert",
"(",
"[",
"'access_token'",
"=>",
"$",
"token",
"->",
"getId",
"(",
")",
",",
"'scope'",
"=>",
"$",
"scope",
"->",
"getId",
"(",
")",
",",
"]",
")",
";",
"}"
]
| {@inheritdoc} | [
"{"
]
| train | https://github.com/redaigbaria/oauth2/blob/54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a/examples/relational/Storage/AccessTokenStorage.php#L75-L82 |
adammbalogh/key-value-store-memory | src/Adapter/MemoryAdapter/ValueTrait.php | ValueTrait.getValue | protected function getValue($key)
{
if (!array_key_exists($key, $this->store)) {
throw new KeyNotFoundException();
}
$getResult = $this->store[$key];
$unserialized = @unserialize($getResult);
if (Util::hasInternalExpireTime($unserialized)) {
$this->handleTtl($key, $unserialized['ts'], $unserialized['s']);
$getResult = $unserialized['v'];
}
return $getResult;
} | php | protected function getValue($key)
{
if (!array_key_exists($key, $this->store)) {
throw new KeyNotFoundException();
}
$getResult = $this->store[$key];
$unserialized = @unserialize($getResult);
if (Util::hasInternalExpireTime($unserialized)) {
$this->handleTtl($key, $unserialized['ts'], $unserialized['s']);
$getResult = $unserialized['v'];
}
return $getResult;
} | [
"protected",
"function",
"getValue",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"store",
")",
")",
"{",
"throw",
"new",
"KeyNotFoundException",
"(",
")",
";",
"}",
"$",
"getResult",
"=",
"$",
"this",
"->",
"store",
"[",
"$",
"key",
"]",
";",
"$",
"unserialized",
"=",
"@",
"unserialize",
"(",
"$",
"getResult",
")",
";",
"if",
"(",
"Util",
"::",
"hasInternalExpireTime",
"(",
"$",
"unserialized",
")",
")",
"{",
"$",
"this",
"->",
"handleTtl",
"(",
"$",
"key",
",",
"$",
"unserialized",
"[",
"'ts'",
"]",
",",
"$",
"unserialized",
"[",
"'s'",
"]",
")",
";",
"$",
"getResult",
"=",
"$",
"unserialized",
"[",
"'v'",
"]",
";",
"}",
"return",
"$",
"getResult",
";",
"}"
]
| Gets value, watches expiring.
@param string $key
@return mixed
@throws KeyNotFoundException | [
"Gets",
"value",
"watches",
"expiring",
"."
]
| train | https://github.com/adammbalogh/key-value-store-memory/blob/6bafb9037d61911f76343a7aa7270866b1a11995/src/Adapter/MemoryAdapter/ValueTrait.php#L49-L65 |
adammbalogh/key-value-store-memory | src/Adapter/MemoryAdapter/ValueTrait.php | ValueTrait.handleTtl | protected function handleTtl($key, $expireSetTs, $expireSec)
{
$ttl = $expireSetTs + $expireSec - time();
if ($ttl <= 0) {
unset($this->store[$key]);
throw new KeyNotFoundException();
}
return $ttl;
} | php | protected function handleTtl($key, $expireSetTs, $expireSec)
{
$ttl = $expireSetTs + $expireSec - time();
if ($ttl <= 0) {
unset($this->store[$key]);
throw new KeyNotFoundException();
}
return $ttl;
} | [
"protected",
"function",
"handleTtl",
"(",
"$",
"key",
",",
"$",
"expireSetTs",
",",
"$",
"expireSec",
")",
"{",
"$",
"ttl",
"=",
"$",
"expireSetTs",
"+",
"$",
"expireSec",
"-",
"time",
"(",
")",
";",
"if",
"(",
"$",
"ttl",
"<=",
"0",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"store",
"[",
"$",
"key",
"]",
")",
";",
"throw",
"new",
"KeyNotFoundException",
"(",
")",
";",
"}",
"return",
"$",
"ttl",
";",
"}"
]
| If ttl is lesser or equals 0 delete key.
@param string $key
@param int $expireSetTs
@param int $expireSec
@return int ttl
@throws KeyNotFoundException | [
"If",
"ttl",
"is",
"lesser",
"or",
"equals",
"0",
"delete",
"key",
"."
]
| train | https://github.com/adammbalogh/key-value-store-memory/blob/6bafb9037d61911f76343a7aa7270866b1a11995/src/Adapter/MemoryAdapter/ValueTrait.php#L78-L88 |
phpmob/changmin | src/PhpMob/MediaBundle/Imagine/Cache/CacheManager.php | CacheManager.generateUrl | public function generateUrl($path, $filter, array $runtimeConfig = array(), $resolver = null)
{
$params = array(
'path' => ltrim($path, '/'),
'filter' => $filter,
);
if ($resolver) {
$params['resolver'] = $resolver;
}
if (empty($runtimeConfig)) {
$filterUrl = $this->router->generate('liip_imagine_filter', $params, UrlGeneratorInterface::ABSOLUTE_URL);
} else {
$params['filters'] = $runtimeConfig;
$hash = $this->signer->sign($path, $runtimeConfig);
try {
$filterUrl = $this->getImagineController()
->filterRuntimeAction(new Request($params), $hash, $path, $filter)
->getTargetUrl()
;
} catch (NotFoundHttpException $e) {
return null;
}
}
return $filterUrl;
} | php | public function generateUrl($path, $filter, array $runtimeConfig = array(), $resolver = null)
{
$params = array(
'path' => ltrim($path, '/'),
'filter' => $filter,
);
if ($resolver) {
$params['resolver'] = $resolver;
}
if (empty($runtimeConfig)) {
$filterUrl = $this->router->generate('liip_imagine_filter', $params, UrlGeneratorInterface::ABSOLUTE_URL);
} else {
$params['filters'] = $runtimeConfig;
$hash = $this->signer->sign($path, $runtimeConfig);
try {
$filterUrl = $this->getImagineController()
->filterRuntimeAction(new Request($params), $hash, $path, $filter)
->getTargetUrl()
;
} catch (NotFoundHttpException $e) {
return null;
}
}
return $filterUrl;
} | [
"public",
"function",
"generateUrl",
"(",
"$",
"path",
",",
"$",
"filter",
",",
"array",
"$",
"runtimeConfig",
"=",
"array",
"(",
")",
",",
"$",
"resolver",
"=",
"null",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"'path'",
"=>",
"ltrim",
"(",
"$",
"path",
",",
"'/'",
")",
",",
"'filter'",
"=>",
"$",
"filter",
",",
")",
";",
"if",
"(",
"$",
"resolver",
")",
"{",
"$",
"params",
"[",
"'resolver'",
"]",
"=",
"$",
"resolver",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"runtimeConfig",
")",
")",
"{",
"$",
"filterUrl",
"=",
"$",
"this",
"->",
"router",
"->",
"generate",
"(",
"'liip_imagine_filter'",
",",
"$",
"params",
",",
"UrlGeneratorInterface",
"::",
"ABSOLUTE_URL",
")",
";",
"}",
"else",
"{",
"$",
"params",
"[",
"'filters'",
"]",
"=",
"$",
"runtimeConfig",
";",
"$",
"hash",
"=",
"$",
"this",
"->",
"signer",
"->",
"sign",
"(",
"$",
"path",
",",
"$",
"runtimeConfig",
")",
";",
"try",
"{",
"$",
"filterUrl",
"=",
"$",
"this",
"->",
"getImagineController",
"(",
")",
"->",
"filterRuntimeAction",
"(",
"new",
"Request",
"(",
"$",
"params",
")",
",",
"$",
"hash",
",",
"$",
"path",
",",
"$",
"filter",
")",
"->",
"getTargetUrl",
"(",
")",
";",
"}",
"catch",
"(",
"NotFoundHttpException",
"$",
"e",
")",
"{",
"return",
"null",
";",
"}",
"}",
"return",
"$",
"filterUrl",
";",
"}"
]
| Returns a web accessible URL.
@param string $path The path where the resolved file is expected
@param string $filter The name of the imagine filter in effect
@param array $runtimeConfig
@param string $resolver
@return string | [
"Returns",
"a",
"web",
"accessible",
"URL",
"."
]
| train | https://github.com/phpmob/changmin/blob/bfebb1561229094d1c138574abab75f2f1d17d66/src/PhpMob/MediaBundle/Imagine/Cache/CacheManager.php#L45-L73 |
nyeholt/silverstripe-external-content | thirdparty/Zend/Http/Client/Adapter/Proxy.php | Zend_Http_Client_Adapter_Proxy.connect | public function connect($host, $port = 80, $secure = false)
{
// If no proxy is set, fall back to Socket adapter
if (! $this->config['proxy_host']) return parent::connect($host, $port, $secure);
// Go through a proxy - the connection is actually to the proxy server
$host = $this->config['proxy_host'];
$port = $this->config['proxy_port'];
// If we are connected to the wrong proxy, disconnect first
if (($this->connected_to[0] != $host || $this->connected_to[1] != $port)) {
if (is_resource($this->socket)) $this->close();
}
// Now, if we are not connected, connect
if (! is_resource($this->socket) || ! $this->config['keepalive']) {
$this->socket = @fsockopen($host, $port, $errno, $errstr, (int) $this->config['timeout']);
if (! $this->socket) {
$this->close();
require_once 'Zend/Http/Client/Adapter/Exception.php';
throw new Zend_Http_Client_Adapter_Exception(
'Unable to Connect to proxy server ' . $host . ':' . $port . '. Error #' . $errno . ': ' . $errstr);
}
// Set the stream timeout
if (!stream_set_timeout($this->socket, (int) $this->config['timeout'])) {
require_once 'Zend/Http/Client/Adapter/Exception.php';
throw new Zend_Http_Client_Adapter_Exception('Unable to set the connection timeout');
}
// Update connected_to
$this->connected_to = array($host, $port);
}
} | php | public function connect($host, $port = 80, $secure = false)
{
// If no proxy is set, fall back to Socket adapter
if (! $this->config['proxy_host']) return parent::connect($host, $port, $secure);
// Go through a proxy - the connection is actually to the proxy server
$host = $this->config['proxy_host'];
$port = $this->config['proxy_port'];
// If we are connected to the wrong proxy, disconnect first
if (($this->connected_to[0] != $host || $this->connected_to[1] != $port)) {
if (is_resource($this->socket)) $this->close();
}
// Now, if we are not connected, connect
if (! is_resource($this->socket) || ! $this->config['keepalive']) {
$this->socket = @fsockopen($host, $port, $errno, $errstr, (int) $this->config['timeout']);
if (! $this->socket) {
$this->close();
require_once 'Zend/Http/Client/Adapter/Exception.php';
throw new Zend_Http_Client_Adapter_Exception(
'Unable to Connect to proxy server ' . $host . ':' . $port . '. Error #' . $errno . ': ' . $errstr);
}
// Set the stream timeout
if (!stream_set_timeout($this->socket, (int) $this->config['timeout'])) {
require_once 'Zend/Http/Client/Adapter/Exception.php';
throw new Zend_Http_Client_Adapter_Exception('Unable to set the connection timeout');
}
// Update connected_to
$this->connected_to = array($host, $port);
}
} | [
"public",
"function",
"connect",
"(",
"$",
"host",
",",
"$",
"port",
"=",
"80",
",",
"$",
"secure",
"=",
"false",
")",
"{",
"// If no proxy is set, fall back to Socket adapter",
"if",
"(",
"!",
"$",
"this",
"->",
"config",
"[",
"'proxy_host'",
"]",
")",
"return",
"parent",
"::",
"connect",
"(",
"$",
"host",
",",
"$",
"port",
",",
"$",
"secure",
")",
";",
"// Go through a proxy - the connection is actually to the proxy server",
"$",
"host",
"=",
"$",
"this",
"->",
"config",
"[",
"'proxy_host'",
"]",
";",
"$",
"port",
"=",
"$",
"this",
"->",
"config",
"[",
"'proxy_port'",
"]",
";",
"// If we are connected to the wrong proxy, disconnect first",
"if",
"(",
"(",
"$",
"this",
"->",
"connected_to",
"[",
"0",
"]",
"!=",
"$",
"host",
"||",
"$",
"this",
"->",
"connected_to",
"[",
"1",
"]",
"!=",
"$",
"port",
")",
")",
"{",
"if",
"(",
"is_resource",
"(",
"$",
"this",
"->",
"socket",
")",
")",
"$",
"this",
"->",
"close",
"(",
")",
";",
"}",
"// Now, if we are not connected, connect",
"if",
"(",
"!",
"is_resource",
"(",
"$",
"this",
"->",
"socket",
")",
"||",
"!",
"$",
"this",
"->",
"config",
"[",
"'keepalive'",
"]",
")",
"{",
"$",
"this",
"->",
"socket",
"=",
"@",
"fsockopen",
"(",
"$",
"host",
",",
"$",
"port",
",",
"$",
"errno",
",",
"$",
"errstr",
",",
"(",
"int",
")",
"$",
"this",
"->",
"config",
"[",
"'timeout'",
"]",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"socket",
")",
"{",
"$",
"this",
"->",
"close",
"(",
")",
";",
"require_once",
"'Zend/Http/Client/Adapter/Exception.php'",
";",
"throw",
"new",
"Zend_Http_Client_Adapter_Exception",
"(",
"'Unable to Connect to proxy server '",
".",
"$",
"host",
".",
"':'",
".",
"$",
"port",
".",
"'. Error #'",
".",
"$",
"errno",
".",
"': '",
".",
"$",
"errstr",
")",
";",
"}",
"// Set the stream timeout",
"if",
"(",
"!",
"stream_set_timeout",
"(",
"$",
"this",
"->",
"socket",
",",
"(",
"int",
")",
"$",
"this",
"->",
"config",
"[",
"'timeout'",
"]",
")",
")",
"{",
"require_once",
"'Zend/Http/Client/Adapter/Exception.php'",
";",
"throw",
"new",
"Zend_Http_Client_Adapter_Exception",
"(",
"'Unable to set the connection timeout'",
")",
";",
"}",
"// Update connected_to",
"$",
"this",
"->",
"connected_to",
"=",
"array",
"(",
"$",
"host",
",",
"$",
"port",
")",
";",
"}",
"}"
]
| Connect to the remote server
Will try to connect to the proxy server. If no proxy was set, will
fall back to the target server (behave like regular Socket adapter)
@param string $host
@param int $port
@param boolean $secure
@param int $timeout | [
"Connect",
"to",
"the",
"remote",
"server"
]
| train | https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Http/Client/Adapter/Proxy.php#L78-L111 |
nyeholt/silverstripe-external-content | thirdparty/Zend/Http/Client/Adapter/Proxy.php | Zend_Http_Client_Adapter_Proxy.write | public function write($method, $uri, $http_ver = '1.1', $headers = array(), $body = '')
{
// If no proxy is set, fall back to default Socket adapter
if (! $this->config['proxy_host']) return parent::write($method, $uri, $http_ver, $headers, $body);
// Make sure we're properly connected
if (! $this->socket) {
require_once 'Zend/Http/Client/Adapter/Exception.php';
throw new Zend_Http_Client_Adapter_Exception("Trying to write but we are not connected");
}
$host = $this->config['proxy_host'];
$port = $this->config['proxy_port'];
if ($this->connected_to[0] != $host || $this->connected_to[1] != $port) {
require_once 'Zend/Http/Client/Adapter/Exception.php';
throw new Zend_Http_Client_Adapter_Exception("Trying to write but we are connected to the wrong proxy server");
}
// Add Proxy-Authorization header
if ($this->config['proxy_user'] && ! isset($headers['proxy-authorization'])) {
$headers['proxy-authorization'] = Zend_Http_Client::encodeAuthHeader(
$this->config['proxy_user'], $this->config['proxy_pass'], $this->config['proxy_auth']
);
}
// if we are proxying HTTPS, preform CONNECT handshake with the proxy
if ($uri->getScheme() == 'https' && (! $this->negotiated)) {
$this->connectHandshake($uri->getHost(), $uri->getPort(), $http_ver, $headers);
$this->negotiated = true;
}
// Save request method for later
$this->method = $method;
// Build request headers
$request = "{$method} {$uri->__toString()} HTTP/{$http_ver}\r\n";
// Add all headers to the request string
foreach ($headers as $k => $v) {
if (is_string($k)) $v = "$k: $v";
$request .= "$v\r\n";
}
// Add the request body
$request .= "\r\n" . $body;
// Send the request
if (! @fwrite($this->socket, $request)) {
require_once 'Zend/Http/Client/Adapter/Exception.php';
throw new Zend_Http_Client_Adapter_Exception("Error writing request to proxy server");
}
return $request;
} | php | public function write($method, $uri, $http_ver = '1.1', $headers = array(), $body = '')
{
// If no proxy is set, fall back to default Socket adapter
if (! $this->config['proxy_host']) return parent::write($method, $uri, $http_ver, $headers, $body);
// Make sure we're properly connected
if (! $this->socket) {
require_once 'Zend/Http/Client/Adapter/Exception.php';
throw new Zend_Http_Client_Adapter_Exception("Trying to write but we are not connected");
}
$host = $this->config['proxy_host'];
$port = $this->config['proxy_port'];
if ($this->connected_to[0] != $host || $this->connected_to[1] != $port) {
require_once 'Zend/Http/Client/Adapter/Exception.php';
throw new Zend_Http_Client_Adapter_Exception("Trying to write but we are connected to the wrong proxy server");
}
// Add Proxy-Authorization header
if ($this->config['proxy_user'] && ! isset($headers['proxy-authorization'])) {
$headers['proxy-authorization'] = Zend_Http_Client::encodeAuthHeader(
$this->config['proxy_user'], $this->config['proxy_pass'], $this->config['proxy_auth']
);
}
// if we are proxying HTTPS, preform CONNECT handshake with the proxy
if ($uri->getScheme() == 'https' && (! $this->negotiated)) {
$this->connectHandshake($uri->getHost(), $uri->getPort(), $http_ver, $headers);
$this->negotiated = true;
}
// Save request method for later
$this->method = $method;
// Build request headers
$request = "{$method} {$uri->__toString()} HTTP/{$http_ver}\r\n";
// Add all headers to the request string
foreach ($headers as $k => $v) {
if (is_string($k)) $v = "$k: $v";
$request .= "$v\r\n";
}
// Add the request body
$request .= "\r\n" . $body;
// Send the request
if (! @fwrite($this->socket, $request)) {
require_once 'Zend/Http/Client/Adapter/Exception.php';
throw new Zend_Http_Client_Adapter_Exception("Error writing request to proxy server");
}
return $request;
} | [
"public",
"function",
"write",
"(",
"$",
"method",
",",
"$",
"uri",
",",
"$",
"http_ver",
"=",
"'1.1'",
",",
"$",
"headers",
"=",
"array",
"(",
")",
",",
"$",
"body",
"=",
"''",
")",
"{",
"// If no proxy is set, fall back to default Socket adapter",
"if",
"(",
"!",
"$",
"this",
"->",
"config",
"[",
"'proxy_host'",
"]",
")",
"return",
"parent",
"::",
"write",
"(",
"$",
"method",
",",
"$",
"uri",
",",
"$",
"http_ver",
",",
"$",
"headers",
",",
"$",
"body",
")",
";",
"// Make sure we're properly connected",
"if",
"(",
"!",
"$",
"this",
"->",
"socket",
")",
"{",
"require_once",
"'Zend/Http/Client/Adapter/Exception.php'",
";",
"throw",
"new",
"Zend_Http_Client_Adapter_Exception",
"(",
"\"Trying to write but we are not connected\"",
")",
";",
"}",
"$",
"host",
"=",
"$",
"this",
"->",
"config",
"[",
"'proxy_host'",
"]",
";",
"$",
"port",
"=",
"$",
"this",
"->",
"config",
"[",
"'proxy_port'",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"connected_to",
"[",
"0",
"]",
"!=",
"$",
"host",
"||",
"$",
"this",
"->",
"connected_to",
"[",
"1",
"]",
"!=",
"$",
"port",
")",
"{",
"require_once",
"'Zend/Http/Client/Adapter/Exception.php'",
";",
"throw",
"new",
"Zend_Http_Client_Adapter_Exception",
"(",
"\"Trying to write but we are connected to the wrong proxy server\"",
")",
";",
"}",
"// Add Proxy-Authorization header",
"if",
"(",
"$",
"this",
"->",
"config",
"[",
"'proxy_user'",
"]",
"&&",
"!",
"isset",
"(",
"$",
"headers",
"[",
"'proxy-authorization'",
"]",
")",
")",
"{",
"$",
"headers",
"[",
"'proxy-authorization'",
"]",
"=",
"Zend_Http_Client",
"::",
"encodeAuthHeader",
"(",
"$",
"this",
"->",
"config",
"[",
"'proxy_user'",
"]",
",",
"$",
"this",
"->",
"config",
"[",
"'proxy_pass'",
"]",
",",
"$",
"this",
"->",
"config",
"[",
"'proxy_auth'",
"]",
")",
";",
"}",
"// if we are proxying HTTPS, preform CONNECT handshake with the proxy",
"if",
"(",
"$",
"uri",
"->",
"getScheme",
"(",
")",
"==",
"'https'",
"&&",
"(",
"!",
"$",
"this",
"->",
"negotiated",
")",
")",
"{",
"$",
"this",
"->",
"connectHandshake",
"(",
"$",
"uri",
"->",
"getHost",
"(",
")",
",",
"$",
"uri",
"->",
"getPort",
"(",
")",
",",
"$",
"http_ver",
",",
"$",
"headers",
")",
";",
"$",
"this",
"->",
"negotiated",
"=",
"true",
";",
"}",
"// Save request method for later",
"$",
"this",
"->",
"method",
"=",
"$",
"method",
";",
"// Build request headers",
"$",
"request",
"=",
"\"{$method} {$uri->__toString()} HTTP/{$http_ver}\\r\\n\"",
";",
"// Add all headers to the request string",
"foreach",
"(",
"$",
"headers",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"k",
")",
")",
"$",
"v",
"=",
"\"$k: $v\"",
";",
"$",
"request",
".=",
"\"$v\\r\\n\"",
";",
"}",
"// Add the request body",
"$",
"request",
".=",
"\"\\r\\n\"",
".",
"$",
"body",
";",
"// Send the request",
"if",
"(",
"!",
"@",
"fwrite",
"(",
"$",
"this",
"->",
"socket",
",",
"$",
"request",
")",
")",
"{",
"require_once",
"'Zend/Http/Client/Adapter/Exception.php'",
";",
"throw",
"new",
"Zend_Http_Client_Adapter_Exception",
"(",
"\"Error writing request to proxy server\"",
")",
";",
"}",
"return",
"$",
"request",
";",
"}"
]
| Send request to the proxy server
@param string $method
@param Zend_Uri_Http $uri
@param string $http_ver
@param array $headers
@param string $body
@return string Request as string | [
"Send",
"request",
"to",
"the",
"proxy",
"server"
]
| train | https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Http/Client/Adapter/Proxy.php#L123-L177 |
nyeholt/silverstripe-external-content | thirdparty/Zend/Http/Client/Adapter/Proxy.php | Zend_Http_Client_Adapter_Proxy.connectHandshake | protected function connectHandshake($host, $port = 443, $http_ver = '1.1', array &$headers = array())
{
$request = "CONNECT $host:$port HTTP/$http_ver\r\n" .
"Host: " . $this->config['proxy_host'] . "\r\n";
// Add the user-agent header
if (isset($this->config['useragent'])) {
$request .= "User-agent: " . $this->config['useragent'] . "\r\n";
}
// If the proxy-authorization header is set, send it to proxy but remove
// it from headers sent to target host
if (isset($headers['proxy-authorization'])) {
$request .= "Proxy-authorization: " . $headers['proxy-authorization'] . "\r\n";
unset($headers['proxy-authorization']);
}
$request .= "\r\n";
// Send the request
if (! @fwrite($this->socket, $request)) {
require_once 'Zend/Http/Client/Adapter/Exception.php';
throw new Zend_Http_Client_Adapter_Exception("Error writing request to proxy server");
}
// Read response headers only
$response = '';
$gotStatus = false;
while ($line = @fgets($this->socket)) {
$gotStatus = $gotStatus || (strpos($line, 'HTTP') !== false);
if ($gotStatus) {
$response .= $line;
if (!chop($line)) break;
}
}
// Check that the response from the proxy is 200
if (Zend_Http_Response::extractCode($response) != 200) {
require_once 'Zend/Http/Client/Adapter/Exception.php';
throw new Zend_Http_Client_Adapter_Exception("Unable to connect to HTTPS proxy. Server response: " . $response);
}
// If all is good, switch socket to secure mode. We have to fall back
// through the different modes
$modes = array(
STREAM_CRYPTO_METHOD_TLS_CLIENT,
STREAM_CRYPTO_METHOD_SSLv3_CLIENT,
STREAM_CRYPTO_METHOD_SSLv23_CLIENT,
STREAM_CRYPTO_METHOD_SSLv2_CLIENT
);
$success = false;
foreach($modes as $mode) {
$success = stream_socket_enable_crypto($this->socket, true, $mode);
if ($success) break;
}
if (! $success) {
require_once 'Zend/Http/Client/Adapter/Exception.php';
throw new Zend_Http_Client_Adapter_Exception("Unable to connect to" .
" HTTPS server through proxy: could not negotiate secure connection.");
}
} | php | protected function connectHandshake($host, $port = 443, $http_ver = '1.1', array &$headers = array())
{
$request = "CONNECT $host:$port HTTP/$http_ver\r\n" .
"Host: " . $this->config['proxy_host'] . "\r\n";
// Add the user-agent header
if (isset($this->config['useragent'])) {
$request .= "User-agent: " . $this->config['useragent'] . "\r\n";
}
// If the proxy-authorization header is set, send it to proxy but remove
// it from headers sent to target host
if (isset($headers['proxy-authorization'])) {
$request .= "Proxy-authorization: " . $headers['proxy-authorization'] . "\r\n";
unset($headers['proxy-authorization']);
}
$request .= "\r\n";
// Send the request
if (! @fwrite($this->socket, $request)) {
require_once 'Zend/Http/Client/Adapter/Exception.php';
throw new Zend_Http_Client_Adapter_Exception("Error writing request to proxy server");
}
// Read response headers only
$response = '';
$gotStatus = false;
while ($line = @fgets($this->socket)) {
$gotStatus = $gotStatus || (strpos($line, 'HTTP') !== false);
if ($gotStatus) {
$response .= $line;
if (!chop($line)) break;
}
}
// Check that the response from the proxy is 200
if (Zend_Http_Response::extractCode($response) != 200) {
require_once 'Zend/Http/Client/Adapter/Exception.php';
throw new Zend_Http_Client_Adapter_Exception("Unable to connect to HTTPS proxy. Server response: " . $response);
}
// If all is good, switch socket to secure mode. We have to fall back
// through the different modes
$modes = array(
STREAM_CRYPTO_METHOD_TLS_CLIENT,
STREAM_CRYPTO_METHOD_SSLv3_CLIENT,
STREAM_CRYPTO_METHOD_SSLv23_CLIENT,
STREAM_CRYPTO_METHOD_SSLv2_CLIENT
);
$success = false;
foreach($modes as $mode) {
$success = stream_socket_enable_crypto($this->socket, true, $mode);
if ($success) break;
}
if (! $success) {
require_once 'Zend/Http/Client/Adapter/Exception.php';
throw new Zend_Http_Client_Adapter_Exception("Unable to connect to" .
" HTTPS server through proxy: could not negotiate secure connection.");
}
} | [
"protected",
"function",
"connectHandshake",
"(",
"$",
"host",
",",
"$",
"port",
"=",
"443",
",",
"$",
"http_ver",
"=",
"'1.1'",
",",
"array",
"&",
"$",
"headers",
"=",
"array",
"(",
")",
")",
"{",
"$",
"request",
"=",
"\"CONNECT $host:$port HTTP/$http_ver\\r\\n\"",
".",
"\"Host: \"",
".",
"$",
"this",
"->",
"config",
"[",
"'proxy_host'",
"]",
".",
"\"\\r\\n\"",
";",
"// Add the user-agent header",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"config",
"[",
"'useragent'",
"]",
")",
")",
"{",
"$",
"request",
".=",
"\"User-agent: \"",
".",
"$",
"this",
"->",
"config",
"[",
"'useragent'",
"]",
".",
"\"\\r\\n\"",
";",
"}",
"// If the proxy-authorization header is set, send it to proxy but remove",
"// it from headers sent to target host",
"if",
"(",
"isset",
"(",
"$",
"headers",
"[",
"'proxy-authorization'",
"]",
")",
")",
"{",
"$",
"request",
".=",
"\"Proxy-authorization: \"",
".",
"$",
"headers",
"[",
"'proxy-authorization'",
"]",
".",
"\"\\r\\n\"",
";",
"unset",
"(",
"$",
"headers",
"[",
"'proxy-authorization'",
"]",
")",
";",
"}",
"$",
"request",
".=",
"\"\\r\\n\"",
";",
"// Send the request",
"if",
"(",
"!",
"@",
"fwrite",
"(",
"$",
"this",
"->",
"socket",
",",
"$",
"request",
")",
")",
"{",
"require_once",
"'Zend/Http/Client/Adapter/Exception.php'",
";",
"throw",
"new",
"Zend_Http_Client_Adapter_Exception",
"(",
"\"Error writing request to proxy server\"",
")",
";",
"}",
"// Read response headers only",
"$",
"response",
"=",
"''",
";",
"$",
"gotStatus",
"=",
"false",
";",
"while",
"(",
"$",
"line",
"=",
"@",
"fgets",
"(",
"$",
"this",
"->",
"socket",
")",
")",
"{",
"$",
"gotStatus",
"=",
"$",
"gotStatus",
"||",
"(",
"strpos",
"(",
"$",
"line",
",",
"'HTTP'",
")",
"!==",
"false",
")",
";",
"if",
"(",
"$",
"gotStatus",
")",
"{",
"$",
"response",
".=",
"$",
"line",
";",
"if",
"(",
"!",
"chop",
"(",
"$",
"line",
")",
")",
"break",
";",
"}",
"}",
"// Check that the response from the proxy is 200",
"if",
"(",
"Zend_Http_Response",
"::",
"extractCode",
"(",
"$",
"response",
")",
"!=",
"200",
")",
"{",
"require_once",
"'Zend/Http/Client/Adapter/Exception.php'",
";",
"throw",
"new",
"Zend_Http_Client_Adapter_Exception",
"(",
"\"Unable to connect to HTTPS proxy. Server response: \"",
".",
"$",
"response",
")",
";",
"}",
"// If all is good, switch socket to secure mode. We have to fall back",
"// through the different modes ",
"$",
"modes",
"=",
"array",
"(",
"STREAM_CRYPTO_METHOD_TLS_CLIENT",
",",
"STREAM_CRYPTO_METHOD_SSLv3_CLIENT",
",",
"STREAM_CRYPTO_METHOD_SSLv23_CLIENT",
",",
"STREAM_CRYPTO_METHOD_SSLv2_CLIENT",
")",
";",
"$",
"success",
"=",
"false",
";",
"foreach",
"(",
"$",
"modes",
"as",
"$",
"mode",
")",
"{",
"$",
"success",
"=",
"stream_socket_enable_crypto",
"(",
"$",
"this",
"->",
"socket",
",",
"true",
",",
"$",
"mode",
")",
";",
"if",
"(",
"$",
"success",
")",
"break",
";",
"}",
"if",
"(",
"!",
"$",
"success",
")",
"{",
"require_once",
"'Zend/Http/Client/Adapter/Exception.php'",
";",
"throw",
"new",
"Zend_Http_Client_Adapter_Exception",
"(",
"\"Unable to connect to\"",
".",
"\" HTTPS server through proxy: could not negotiate secure connection.\"",
")",
";",
"}",
"}"
]
| Preform handshaking with HTTPS proxy using CONNECT method
@param string $host
@param integer $port
@param string $http_ver
@param array $headers | [
"Preform",
"handshaking",
"with",
"HTTPS",
"proxy",
"using",
"CONNECT",
"method"
]
| train | https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Http/Client/Adapter/Proxy.php#L187-L249 |
inpsyde/inpsyde-filter | src/WordPress/AutoP.php | AutoP.filter | public function filter( $value ) {
if ( ! is_string( $value ) || empty( $value ) ) {
do_action( 'inpsyde.filter.error', 'The given value is not a string or empty.', [ 'method' => __METHOD__, 'value' => $value ] );
return $value;
}
$br = (bool) $this->options[ 'br' ];
return wpautop( $value, $br );
} | php | public function filter( $value ) {
if ( ! is_string( $value ) || empty( $value ) ) {
do_action( 'inpsyde.filter.error', 'The given value is not a string or empty.', [ 'method' => __METHOD__, 'value' => $value ] );
return $value;
}
$br = (bool) $this->options[ 'br' ];
return wpautop( $value, $br );
} | [
"public",
"function",
"filter",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"value",
")",
"||",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"do_action",
"(",
"'inpsyde.filter.error'",
",",
"'The given value is not a string or empty.'",
",",
"[",
"'method'",
"=>",
"__METHOD__",
",",
"'value'",
"=>",
"$",
"value",
"]",
")",
";",
"return",
"$",
"value",
";",
"}",
"$",
"br",
"=",
"(",
"bool",
")",
"$",
"this",
"->",
"options",
"[",
"'br'",
"]",
";",
"return",
"wpautop",
"(",
"$",
"value",
",",
"$",
"br",
")",
";",
"}"
]
| {@inheritdoc} | [
"{"
]
| train | https://github.com/inpsyde/inpsyde-filter/blob/777a6208ea4dfbeed89e6d0712a35dc25eab498b/src/WordPress/AutoP.php#L24-L35 |
webforge-labs/psc-cms | lib/Psc/HTML/Tag.php | Tag.after | public function after(Tag $after) {
$id = $after->guid();
$this->templateAppend('%'.$id.'%');
$this->templateContent->$id =& $after;
} | php | public function after(Tag $after) {
$id = $after->guid();
$this->templateAppend('%'.$id.'%');
$this->templateContent->$id =& $after;
} | [
"public",
"function",
"after",
"(",
"Tag",
"$",
"after",
")",
"{",
"$",
"id",
"=",
"$",
"after",
"->",
"guid",
"(",
")",
";",
"$",
"this",
"->",
"templateAppend",
"(",
"'%'",
".",
"$",
"id",
".",
"'%'",
")",
";",
"$",
"this",
"->",
"templateContent",
"->",
"$",
"id",
"=",
"&",
"$",
"after",
";",
"}"
]
| Fügt hinter diesem Element ein anderes Element an | [
"Fügt",
"hinter",
"diesem",
"Element",
"ein",
"anderes",
"Element",
"an"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/HTML/Tag.php#L476-L480 |
christianblos/markdown2html | src/Theme/NavItem.php | NavItem.getChildById | public function getChildById($id)
{
foreach ($this->children as $child) {
if ($child->id === $id) {
return $child;
}
$subChild = $child->getChildById($id);
if ($subChild !== null) {
return $subChild;
}
}
return null;
} | php | public function getChildById($id)
{
foreach ($this->children as $child) {
if ($child->id === $id) {
return $child;
}
$subChild = $child->getChildById($id);
if ($subChild !== null) {
return $subChild;
}
}
return null;
} | [
"public",
"function",
"getChildById",
"(",
"$",
"id",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"children",
"as",
"$",
"child",
")",
"{",
"if",
"(",
"$",
"child",
"->",
"id",
"===",
"$",
"id",
")",
"{",
"return",
"$",
"child",
";",
"}",
"$",
"subChild",
"=",
"$",
"child",
"->",
"getChildById",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"subChild",
"!==",
"null",
")",
"{",
"return",
"$",
"subChild",
";",
"}",
"}",
"return",
"null",
";",
"}"
]
| @param string $id
@return NavItem|null | [
"@param",
"string",
"$id"
]
| train | https://github.com/christianblos/markdown2html/blob/2ae1177d71fe313c802962dbb9226b5a90bbc65a/src/Theme/NavItem.php#L72-L86 |
anexia-it/anexia-laravel-encryption | src/PostgresPgpEncryption.php | PostgresPgpEncryption.getEncryptExpression | public function getEncryptExpression($text, $encryptionKey, $quote = true)
{
$quotedText = $quote ? DB::connection()->getPdo()->quote($text) : $text;
$quotedEncryptKey = DB::connection()->getPdo()->quote($encryptionKey);
return "pgp_sym_encrypt($quotedText, $quotedEncryptKey)";
} | php | public function getEncryptExpression($text, $encryptionKey, $quote = true)
{
$quotedText = $quote ? DB::connection()->getPdo()->quote($text) : $text;
$quotedEncryptKey = DB::connection()->getPdo()->quote($encryptionKey);
return "pgp_sym_encrypt($quotedText, $quotedEncryptKey)";
} | [
"public",
"function",
"getEncryptExpression",
"(",
"$",
"text",
",",
"$",
"encryptionKey",
",",
"$",
"quote",
"=",
"true",
")",
"{",
"$",
"quotedText",
"=",
"$",
"quote",
"?",
"DB",
"::",
"connection",
"(",
")",
"->",
"getPdo",
"(",
")",
"->",
"quote",
"(",
"$",
"text",
")",
":",
"$",
"text",
";",
"$",
"quotedEncryptKey",
"=",
"DB",
"::",
"connection",
"(",
")",
"->",
"getPdo",
"(",
")",
"->",
"quote",
"(",
"$",
"encryptionKey",
")",
";",
"return",
"\"pgp_sym_encrypt($quotedText, $quotedEncryptKey)\"",
";",
"}"
]
| Returns a encrypt expression
@param string $text text to encrypt or field name
@param string $encryptionKey
@param bool $quote use false if $text is a field name
@return string | [
"Returns",
"a",
"encrypt",
"expression"
]
| train | https://github.com/anexia-it/anexia-laravel-encryption/blob/b7c72d99916ebca2d2cf2dbab1d4c0f84e383081/src/PostgresPgpEncryption.php#L18-L23 |
anexia-it/anexia-laravel-encryption | src/PostgresPgpEncryption.php | PostgresPgpEncryption.getDecryptExpression | public function getDecryptExpression($text, $decryptionKey, $quote = false)
{
$quotedText = $quote ? DB::connection()->getPdo()->quote($text) : $text;
$quotedDecryptKey = DB::connection()->getPdo()->quote($decryptionKey);
return "pgp_sym_decrypt({$quotedText}::bytea, $quotedDecryptKey)";
} | php | public function getDecryptExpression($text, $decryptionKey, $quote = false)
{
$quotedText = $quote ? DB::connection()->getPdo()->quote($text) : $text;
$quotedDecryptKey = DB::connection()->getPdo()->quote($decryptionKey);
return "pgp_sym_decrypt({$quotedText}::bytea, $quotedDecryptKey)";
} | [
"public",
"function",
"getDecryptExpression",
"(",
"$",
"text",
",",
"$",
"decryptionKey",
",",
"$",
"quote",
"=",
"false",
")",
"{",
"$",
"quotedText",
"=",
"$",
"quote",
"?",
"DB",
"::",
"connection",
"(",
")",
"->",
"getPdo",
"(",
")",
"->",
"quote",
"(",
"$",
"text",
")",
":",
"$",
"text",
";",
"$",
"quotedDecryptKey",
"=",
"DB",
"::",
"connection",
"(",
")",
"->",
"getPdo",
"(",
")",
"->",
"quote",
"(",
"$",
"decryptionKey",
")",
";",
"return",
"\"pgp_sym_decrypt({$quotedText}::bytea, $quotedDecryptKey)\"",
";",
"}"
]
| Returns a encrypt expression
@param string $text text to encrypt or field name
@param string $decryptionKey
@param bool $quote use false if $text is a field name
@return string | [
"Returns",
"a",
"encrypt",
"expression"
]
| train | https://github.com/anexia-it/anexia-laravel-encryption/blob/b7c72d99916ebca2d2cf2dbab1d4c0f84e383081/src/PostgresPgpEncryption.php#L32-L37 |
meccado/acl-admin-control-panel | src/Http/Controllers/Admin/ProfileController.php | ProfileController.update | public function update(ProfileImageFormRequest $request, $id)
{
if($request->hasFile('avatar'))
{
$user = User::with('profile')->findOrFail($id);
// REMOVE OLD AVATAR:
if ($user->profile->avatar != NULL) {
// DELETE FROM THE DIRECTORY:
File::delete($user->profile->avatar);
// DELETE FROM THE DATABASE:
$user->profile->avatar= null;
}
if (!File::exists('assets/images/avatars'))
{
File::makeDirectory('assets/images/avatars', $mode = 0777, true, true);
}
$avatar = $request->file('avatar');
$filename = time() . '.' . $avatar->getClientOriginalExtension();
Image::make($avatar)->resize(300, 300)->save('assets/images/avatars/' . $filename);
$profile = $user->profile;
$profile->avatar = 'assets/images/avatars/' . $filename;
$profile->bio = Input::get('bio');
$profile->update();
}
return \View::make('acl::admin.profiles.profile');
} | php | public function update(ProfileImageFormRequest $request, $id)
{
if($request->hasFile('avatar'))
{
$user = User::with('profile')->findOrFail($id);
// REMOVE OLD AVATAR:
if ($user->profile->avatar != NULL) {
// DELETE FROM THE DIRECTORY:
File::delete($user->profile->avatar);
// DELETE FROM THE DATABASE:
$user->profile->avatar= null;
}
if (!File::exists('assets/images/avatars'))
{
File::makeDirectory('assets/images/avatars', $mode = 0777, true, true);
}
$avatar = $request->file('avatar');
$filename = time() . '.' . $avatar->getClientOriginalExtension();
Image::make($avatar)->resize(300, 300)->save('assets/images/avatars/' . $filename);
$profile = $user->profile;
$profile->avatar = 'assets/images/avatars/' . $filename;
$profile->bio = Input::get('bio');
$profile->update();
}
return \View::make('acl::admin.profiles.profile');
} | [
"public",
"function",
"update",
"(",
"ProfileImageFormRequest",
"$",
"request",
",",
"$",
"id",
")",
"{",
"if",
"(",
"$",
"request",
"->",
"hasFile",
"(",
"'avatar'",
")",
")",
"{",
"$",
"user",
"=",
"User",
"::",
"with",
"(",
"'profile'",
")",
"->",
"findOrFail",
"(",
"$",
"id",
")",
";",
"// REMOVE OLD AVATAR:",
"if",
"(",
"$",
"user",
"->",
"profile",
"->",
"avatar",
"!=",
"NULL",
")",
"{",
"// DELETE FROM THE DIRECTORY:",
"File",
"::",
"delete",
"(",
"$",
"user",
"->",
"profile",
"->",
"avatar",
")",
";",
"// DELETE FROM THE DATABASE:",
"$",
"user",
"->",
"profile",
"->",
"avatar",
"=",
"null",
";",
"}",
"if",
"(",
"!",
"File",
"::",
"exists",
"(",
"'assets/images/avatars'",
")",
")",
"{",
"File",
"::",
"makeDirectory",
"(",
"'assets/images/avatars'",
",",
"$",
"mode",
"=",
"0777",
",",
"true",
",",
"true",
")",
";",
"}",
"$",
"avatar",
"=",
"$",
"request",
"->",
"file",
"(",
"'avatar'",
")",
";",
"$",
"filename",
"=",
"time",
"(",
")",
".",
"'.'",
".",
"$",
"avatar",
"->",
"getClientOriginalExtension",
"(",
")",
";",
"Image",
"::",
"make",
"(",
"$",
"avatar",
")",
"->",
"resize",
"(",
"300",
",",
"300",
")",
"->",
"save",
"(",
"'assets/images/avatars/'",
".",
"$",
"filename",
")",
";",
"$",
"profile",
"=",
"$",
"user",
"->",
"profile",
";",
"$",
"profile",
"->",
"avatar",
"=",
"'assets/images/avatars/'",
".",
"$",
"filename",
";",
"$",
"profile",
"->",
"bio",
"=",
"Input",
"::",
"get",
"(",
"'bio'",
")",
";",
"$",
"profile",
"->",
"update",
"(",
")",
";",
"}",
"return",
"\\",
"View",
"::",
"make",
"(",
"'acl::admin.profiles.profile'",
")",
";",
"}"
]
| Update the specified resource in storage.
@param \Illuminate\Http\Request $request
@param int $id
@return \Illuminate\Http\Response | [
"Update",
"the",
"specified",
"resource",
"in",
"storage",
"."
]
| train | https://github.com/meccado/acl-admin-control-panel/blob/50ac4c0dbf8bd49944ecad6a70708a70411b7378/src/Http/Controllers/Admin/ProfileController.php#L91-L116 |
meccado/acl-admin-control-panel | src/Http/Controllers/Admin/ProfileController.php | ProfileController.updateImage | public function updateImage(Request $request, $id)
{
if($request->hasFile('avatar'))
{
$avatar = $request->file('avatar');
$user = User::with('profile')->findOrFail($id);
// REMOVE OLD AVATAR:
if ($user->profile->avatar != NULL) {
// DELETE FROM THE DIRECTORY:
File::delete($user->profile->avatar);
// DELETE FROM THE DATABASE:
$user->profile->avatar= null;
}
$filename = uniqid() . '.' . $avatar->getClientOriginalExtension();
if (!File::exists('assets/images/avatars'))
{
File::makeDirectory('assets/images/avatars', $mode = 0777, true, true);
}
\Image::make($avatar)->resize(320, 240)->save('assets/images/avatars/' . $filename );
$user->profile->avatar = 'assets/images/avatars/' . $filename;
$user->profile->file_name = $filename;
$user->profile->update();
}
return \View::make('acl::admin.profiles.profile');
} | php | public function updateImage(Request $request, $id)
{
if($request->hasFile('avatar'))
{
$avatar = $request->file('avatar');
$user = User::with('profile')->findOrFail($id);
// REMOVE OLD AVATAR:
if ($user->profile->avatar != NULL) {
// DELETE FROM THE DIRECTORY:
File::delete($user->profile->avatar);
// DELETE FROM THE DATABASE:
$user->profile->avatar= null;
}
$filename = uniqid() . '.' . $avatar->getClientOriginalExtension();
if (!File::exists('assets/images/avatars'))
{
File::makeDirectory('assets/images/avatars', $mode = 0777, true, true);
}
\Image::make($avatar)->resize(320, 240)->save('assets/images/avatars/' . $filename );
$user->profile->avatar = 'assets/images/avatars/' . $filename;
$user->profile->file_name = $filename;
$user->profile->update();
}
return \View::make('acl::admin.profiles.profile');
} | [
"public",
"function",
"updateImage",
"(",
"Request",
"$",
"request",
",",
"$",
"id",
")",
"{",
"if",
"(",
"$",
"request",
"->",
"hasFile",
"(",
"'avatar'",
")",
")",
"{",
"$",
"avatar",
"=",
"$",
"request",
"->",
"file",
"(",
"'avatar'",
")",
";",
"$",
"user",
"=",
"User",
"::",
"with",
"(",
"'profile'",
")",
"->",
"findOrFail",
"(",
"$",
"id",
")",
";",
"// REMOVE OLD AVATAR:",
"if",
"(",
"$",
"user",
"->",
"profile",
"->",
"avatar",
"!=",
"NULL",
")",
"{",
"// DELETE FROM THE DIRECTORY:",
"File",
"::",
"delete",
"(",
"$",
"user",
"->",
"profile",
"->",
"avatar",
")",
";",
"// DELETE FROM THE DATABASE:",
"$",
"user",
"->",
"profile",
"->",
"avatar",
"=",
"null",
";",
"}",
"$",
"filename",
"=",
"uniqid",
"(",
")",
".",
"'.'",
".",
"$",
"avatar",
"->",
"getClientOriginalExtension",
"(",
")",
";",
"if",
"(",
"!",
"File",
"::",
"exists",
"(",
"'assets/images/avatars'",
")",
")",
"{",
"File",
"::",
"makeDirectory",
"(",
"'assets/images/avatars'",
",",
"$",
"mode",
"=",
"0777",
",",
"true",
",",
"true",
")",
";",
"}",
"\\",
"Image",
"::",
"make",
"(",
"$",
"avatar",
")",
"->",
"resize",
"(",
"320",
",",
"240",
")",
"->",
"save",
"(",
"'assets/images/avatars/'",
".",
"$",
"filename",
")",
";",
"$",
"user",
"->",
"profile",
"->",
"avatar",
"=",
"'assets/images/avatars/'",
".",
"$",
"filename",
";",
"$",
"user",
"->",
"profile",
"->",
"file_name",
"=",
"$",
"filename",
";",
"$",
"user",
"->",
"profile",
"->",
"update",
"(",
")",
";",
"}",
"return",
"\\",
"View",
"::",
"make",
"(",
"'acl::admin.profiles.profile'",
")",
";",
"}"
]
| Update the specified resource in storage.
@param \Illuminate\Http\Request $request
@param int $id
@return \Illuminate\Http\Response | [
"Update",
"the",
"specified",
"resource",
"in",
"storage",
"."
]
| train | https://github.com/meccado/acl-admin-control-panel/blob/50ac4c0dbf8bd49944ecad6a70708a70411b7378/src/Http/Controllers/Admin/ProfileController.php#L140-L165 |
JeanWolf/yii2-jrbac | controllers/MenuController.php | MenuController.actionDelete | public function actionDelete($id)
{
$subCount = Menu::find()->where('`pid`=:id',[':id'=>$id])->count();
if($subCount == 0) { //不包含子菜单时 方可删除
$this->findModel($id)->delete();
}
return $this->redirect(['index']);
} | php | public function actionDelete($id)
{
$subCount = Menu::find()->where('`pid`=:id',[':id'=>$id])->count();
if($subCount == 0) { //不包含子菜单时 方可删除
$this->findModel($id)->delete();
}
return $this->redirect(['index']);
} | [
"public",
"function",
"actionDelete",
"(",
"$",
"id",
")",
"{",
"$",
"subCount",
"=",
"Menu",
"::",
"find",
"(",
")",
"->",
"where",
"(",
"'`pid`=:id'",
",",
"[",
"':id'",
"=>",
"$",
"id",
"]",
")",
"->",
"count",
"(",
")",
";",
"if",
"(",
"$",
"subCount",
"==",
"0",
")",
"{",
"//不包含子菜单时 方可删除",
"$",
"this",
"->",
"findModel",
"(",
"$",
"id",
")",
"->",
"delete",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"redirect",
"(",
"[",
"'index'",
"]",
")",
";",
"}"
]
| 删除菜单
Deletes an existing Menu model.
If deletion is successful, the browser will be redirected to the 'index' page.
@param integer $id
@return mixed | [
"删除菜单",
"Deletes",
"an",
"existing",
"Menu",
"model",
".",
"If",
"deletion",
"is",
"successful",
"the",
"browser",
"will",
"be",
"redirected",
"to",
"the",
"index",
"page",
"."
]
| train | https://github.com/JeanWolf/yii2-jrbac/blob/1e5c80038451bd5b385f83cb9344c3bd5edd85e0/controllers/MenuController.php#L84-L91 |
factorio-item-browser/export-data | src/Entity/LocalisedString.php | LocalisedString.setTranslation | public function setTranslation(string $locale, string $value)
{
if (strlen($value) === 0) {
unset($this->translations[$locale]);
} else {
$this->translations[$locale] = mb_convert_encoding($value, 'UTF-8', 'UTF-8');
}
return $this;
} | php | public function setTranslation(string $locale, string $value)
{
if (strlen($value) === 0) {
unset($this->translations[$locale]);
} else {
$this->translations[$locale] = mb_convert_encoding($value, 'UTF-8', 'UTF-8');
}
return $this;
} | [
"public",
"function",
"setTranslation",
"(",
"string",
"$",
"locale",
",",
"string",
"$",
"value",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"value",
")",
"===",
"0",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"translations",
"[",
"$",
"locale",
"]",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"translations",
"[",
"$",
"locale",
"]",
"=",
"mb_convert_encoding",
"(",
"$",
"value",
",",
"'UTF-8'",
",",
"'UTF-8'",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Sets a translation of the localised string.
@param string $locale
@param string $value
@return $this | [
"Sets",
"a",
"translation",
"of",
"the",
"localised",
"string",
"."
]
| train | https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Entity/LocalisedString.php#L30-L38 |
phpmob/changmin | src/PhpMob/CmsBundle/Form/Type/TemplateChoiceType.php | TemplateChoiceType.configureOptions | public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'choices' => function (Options $options) {
return $this->repository->findNoneAbstractTemplates();
},
'choice_value' => 'id',
'choice_label' => 'name',
'choice_translation_domain' => false,
]);
} | php | public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'choices' => function (Options $options) {
return $this->repository->findNoneAbstractTemplates();
},
'choice_value' => 'id',
'choice_label' => 'name',
'choice_translation_domain' => false,
]);
} | [
"public",
"function",
"configureOptions",
"(",
"OptionsResolver",
"$",
"resolver",
")",
":",
"void",
"{",
"$",
"resolver",
"->",
"setDefaults",
"(",
"[",
"'choices'",
"=>",
"function",
"(",
"Options",
"$",
"options",
")",
"{",
"return",
"$",
"this",
"->",
"repository",
"->",
"findNoneAbstractTemplates",
"(",
")",
";",
"}",
",",
"'choice_value'",
"=>",
"'id'",
",",
"'choice_label'",
"=>",
"'name'",
",",
"'choice_translation_domain'",
"=>",
"false",
",",
"]",
")",
";",
"}"
]
| {@inheritdoc} | [
"{"
]
| train | https://github.com/phpmob/changmin/blob/bfebb1561229094d1c138574abab75f2f1d17d66/src/PhpMob/CmsBundle/Form/Type/TemplateChoiceType.php#L41-L51 |
webforge-labs/psc-cms | lib/Psc/JS/AST/CodeWriter.php | CodeWriter.writeHashMap | public function writeHashMap(stdClass $walkedHashMap, Type $type) {
$hashMap = '{';
if (count((array) $walkedHashMap) > 0) {
foreach ($walkedHashMap as $field => $walkedValue) {
$hashMap .= sprintf("'%s': %s, ", $field, $walkedValue);
}
$hashMap = mb_substr($hashMap, 0, -2);
}
$hashMap .= '}';
return $hashMap;
} | php | public function writeHashMap(stdClass $walkedHashMap, Type $type) {
$hashMap = '{';
if (count((array) $walkedHashMap) > 0) {
foreach ($walkedHashMap as $field => $walkedValue) {
$hashMap .= sprintf("'%s': %s, ", $field, $walkedValue);
}
$hashMap = mb_substr($hashMap, 0, -2);
}
$hashMap .= '}';
return $hashMap;
} | [
"public",
"function",
"writeHashMap",
"(",
"stdClass",
"$",
"walkedHashMap",
",",
"Type",
"$",
"type",
")",
"{",
"$",
"hashMap",
"=",
"'{'",
";",
"if",
"(",
"count",
"(",
"(",
"array",
")",
"$",
"walkedHashMap",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"walkedHashMap",
"as",
"$",
"field",
"=>",
"$",
"walkedValue",
")",
"{",
"$",
"hashMap",
".=",
"sprintf",
"(",
"\"'%s': %s, \"",
",",
"$",
"field",
",",
"$",
"walkedValue",
")",
";",
"}",
"$",
"hashMap",
"=",
"mb_substr",
"(",
"$",
"hashMap",
",",
"0",
",",
"-",
"2",
")",
";",
"}",
"$",
"hashMap",
".=",
"'}'",
";",
"return",
"$",
"hashMap",
";",
"}"
]
| Eine HashMap hat signifikante Schlüssel (integer oder string)
z.B. in Javascript {} (ein Object-Literal)
nach der schließen klammer } ist kein umbruch, für maximale flexibilität | [
"Eine",
"HashMap",
"hat",
"signifikante",
"Schlüssel",
"(",
"integer",
"oder",
"string",
")"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/JS/AST/CodeWriter.php#L90-L100 |
webforge-labs/psc-cms | lib/Psc/CMS/ProjectMain.php | ProjectMain.initDoctrinePackage | public function initDoctrinePackage() {
$module = $GLOBALS['env']['container']->getModule('Doctrine');
$this->dc = new DCPackage($module, $module->getEntityManager($this->getConnectionName()));
$this->attachEntityMetaListener(); // ganz wichtig das hier zu machen, weil das sonst das doctrinepackage initialisiert
} | php | public function initDoctrinePackage() {
$module = $GLOBALS['env']['container']->getModule('Doctrine');
$this->dc = new DCPackage($module, $module->getEntityManager($this->getConnectionName()));
$this->attachEntityMetaListener(); // ganz wichtig das hier zu machen, weil das sonst das doctrinepackage initialisiert
} | [
"public",
"function",
"initDoctrinePackage",
"(",
")",
"{",
"$",
"module",
"=",
"$",
"GLOBALS",
"[",
"'env'",
"]",
"[",
"'container'",
"]",
"->",
"getModule",
"(",
"'Doctrine'",
")",
";",
"$",
"this",
"->",
"dc",
"=",
"new",
"DCPackage",
"(",
"$",
"module",
",",
"$",
"module",
"->",
"getEntityManager",
"(",
"$",
"this",
"->",
"getConnectionName",
"(",
")",
")",
")",
";",
"$",
"this",
"->",
"attachEntityMetaListener",
"(",
")",
";",
"// ganz wichtig das hier zu machen, weil das sonst das doctrinepackage initialisiert",
"}"
]
| Erstellt das DCPackage
wird vom getter aufgerufen, damit es immer da ist | [
"Erstellt",
"das",
"DCPackage"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/ProjectMain.php#L195-L199 |
webforge-labs/psc-cms | lib/Psc/CMS/ProjectMain.php | ProjectMain.initServices | public function initServices() {
$this->getFrontController()->getRequestHandler()->addService($entityService = $this->getEntityService());
// wir mappen den users controller auf den in Psc
$entityService->setControllerClass('User', 'Psc\CMS\Controller\UserEntityController');
} | php | public function initServices() {
$this->getFrontController()->getRequestHandler()->addService($entityService = $this->getEntityService());
// wir mappen den users controller auf den in Psc
$entityService->setControllerClass('User', 'Psc\CMS\Controller\UserEntityController');
} | [
"public",
"function",
"initServices",
"(",
")",
"{",
"$",
"this",
"->",
"getFrontController",
"(",
")",
"->",
"getRequestHandler",
"(",
")",
"->",
"addService",
"(",
"$",
"entityService",
"=",
"$",
"this",
"->",
"getEntityService",
"(",
")",
")",
";",
"// wir mappen den users controller auf den in Psc",
"$",
"entityService",
"->",
"setControllerClass",
"(",
"'User'",
",",
"'Psc\\CMS\\Controller\\UserEntityController'",
")",
";",
"}"
]
| Intialisiert zusätzliche Services für den RequestHandler
standardmäßig wird der EntityService hinzugefügt | [
"Intialisiert",
"zusätzliche",
"Services",
"für",
"den",
"RequestHandler"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/ProjectMain.php#L218-L223 |
webforge-labs/psc-cms | lib/Psc/CMS/ProjectMain.php | ProjectMain.hydrateEntity | public function hydrateEntity($entityName, $identifier) {
return $this->getDoctrinePackage()->getRepository(
$this->getDoctrinePackage()->getModule()->getEntityName($entityName)
)->hydrate($identifier);
} | php | public function hydrateEntity($entityName, $identifier) {
return $this->getDoctrinePackage()->getRepository(
$this->getDoctrinePackage()->getModule()->getEntityName($entityName)
)->hydrate($identifier);
} | [
"public",
"function",
"hydrateEntity",
"(",
"$",
"entityName",
",",
"$",
"identifier",
")",
"{",
"return",
"$",
"this",
"->",
"getDoctrinePackage",
"(",
")",
"->",
"getRepository",
"(",
"$",
"this",
"->",
"getDoctrinePackage",
"(",
")",
"->",
"getModule",
"(",
")",
"->",
"getEntityName",
"(",
"$",
"entityName",
")",
")",
"->",
"hydrate",
"(",
"$",
"identifier",
")",
";",
"}"
]
| Hydriert ein einzelnes Entity
@param string $entityName kann der FQN oder Shortname sein
@return Psc\CMS\Entity | [
"Hydriert",
"ein",
"einzelnes",
"Entity"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/ProjectMain.php#L262-L266 |
webforge-labs/psc-cms | lib/Psc/CMS/ProjectMain.php | ProjectMain.getAuthController | public function getAuthController() {
if (!isset($this->authController)) {
$this->authController = new \Psc\CMS\Controller\AuthController(
new Auth(
$this->session,
$this->cookieManager,
$this->getUserManager()
)
);
$this->authController->setUserClass($this->getUserClass($this->getProject()));
$this->authController->setHTMLPage($this->createHTMLPage());
}
return $this->authController;
} | php | public function getAuthController() {
if (!isset($this->authController)) {
$this->authController = new \Psc\CMS\Controller\AuthController(
new Auth(
$this->session,
$this->cookieManager,
$this->getUserManager()
)
);
$this->authController->setUserClass($this->getUserClass($this->getProject()));
$this->authController->setHTMLPage($this->createHTMLPage());
}
return $this->authController;
} | [
"public",
"function",
"getAuthController",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"authController",
")",
")",
"{",
"$",
"this",
"->",
"authController",
"=",
"new",
"\\",
"Psc",
"\\",
"CMS",
"\\",
"Controller",
"\\",
"AuthController",
"(",
"new",
"Auth",
"(",
"$",
"this",
"->",
"session",
",",
"$",
"this",
"->",
"cookieManager",
",",
"$",
"this",
"->",
"getUserManager",
"(",
")",
")",
")",
";",
"$",
"this",
"->",
"authController",
"->",
"setUserClass",
"(",
"$",
"this",
"->",
"getUserClass",
"(",
"$",
"this",
"->",
"getProject",
"(",
")",
")",
")",
";",
"$",
"this",
"->",
"authController",
"->",
"setHTMLPage",
"(",
"$",
"this",
"->",
"createHTMLPage",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"authController",
";",
"}"
]
| ganz wichtig, das hier zu überschreiben, damit der authcontroller auf jeden fall den richtigen EntityManager bekommt | [
"ganz",
"wichtig",
"das",
"hier",
"zu",
"überschreiben",
"damit",
"der",
"authcontroller",
"auf",
"jeden",
"fall",
"den",
"richtigen",
"EntityManager",
"bekommt"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/ProjectMain.php#L518-L532 |
php-rise/rise | src/Dispatcher.php | Dispatcher.dispatch | public function dispatch() {
$handler = current($this->handlers);
if (!$handler) {
return;
}
$this->resolveHandler($handler);
return $this;
} | php | public function dispatch() {
$handler = current($this->handlers);
if (!$handler) {
return;
}
$this->resolveHandler($handler);
return $this;
} | [
"public",
"function",
"dispatch",
"(",
")",
"{",
"$",
"handler",
"=",
"current",
"(",
"$",
"this",
"->",
"handlers",
")",
";",
"if",
"(",
"!",
"$",
"handler",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"resolveHandler",
"(",
"$",
"handler",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Dispatch handlers.
@return self | [
"Dispatch",
"handlers",
"."
]
| train | https://github.com/php-rise/rise/blob/cd14ef9956f1b6875b7bcd642545dcef6a9152b7/src/Dispatcher.php#L26-L35 |
maniaplanet/maniaplanet-ws-sdk | libraries/Maniaplanet/WebServices/TrustCircles.php | TrustCircles.getKarma | function getKarma($circle, $player)
{
if(!$circle)
{
throw new Exception('Invalid circle');
}
if(!$player)
{
throw new Exception('Invalid player');
}
return $this->execute('GET', '/trust/%s/karma/%s/', array($circle, $player));
} | php | function getKarma($circle, $player)
{
if(!$circle)
{
throw new Exception('Invalid circle');
}
if(!$player)
{
throw new Exception('Invalid player');
}
return $this->execute('GET', '/trust/%s/karma/%s/', array($circle, $player));
} | [
"function",
"getKarma",
"(",
"$",
"circle",
",",
"$",
"player",
")",
"{",
"if",
"(",
"!",
"$",
"circle",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Invalid circle'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"player",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Invalid player'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"execute",
"(",
"'GET'",
",",
"'/trust/%s/karma/%s/'",
",",
"array",
"(",
"$",
"circle",
",",
"$",
"player",
")",
")",
";",
"}"
]
| Get how many times a player has been blacklisted and whitelisted within a circle
@param string $circle
@param string $player
@return object Numbers of blacklistings and whitelistings
@throws Exception | [
"Get",
"how",
"many",
"times",
"a",
"player",
"has",
"been",
"blacklisted",
"and",
"whitelisted",
"within",
"a",
"circle"
]
| train | https://github.com/maniaplanet/maniaplanet-ws-sdk/blob/027a458388035fe66f2f56ff3ea1f85eff2a5a4e/libraries/Maniaplanet/WebServices/TrustCircles.php#L21-L33 |
redaigbaria/oauth2 | examples/relational/Storage/ScopeStorage.php | ScopeStorage.get | public function get($scope, $grantType = null, $clientId = null)
{
$result = Capsule::table('oauth_scopes')
->where('id', $scope)
->get();
if (count($result) === 0) {
return;
}
return (new ScopeEntity($this->server))->hydrate([
'id' => $result[0]['id'],
'description' => $result[0]['description'],
]);
} | php | public function get($scope, $grantType = null, $clientId = null)
{
$result = Capsule::table('oauth_scopes')
->where('id', $scope)
->get();
if (count($result) === 0) {
return;
}
return (new ScopeEntity($this->server))->hydrate([
'id' => $result[0]['id'],
'description' => $result[0]['description'],
]);
} | [
"public",
"function",
"get",
"(",
"$",
"scope",
",",
"$",
"grantType",
"=",
"null",
",",
"$",
"clientId",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"Capsule",
"::",
"table",
"(",
"'oauth_scopes'",
")",
"->",
"where",
"(",
"'id'",
",",
"$",
"scope",
")",
"->",
"get",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"result",
")",
"===",
"0",
")",
"{",
"return",
";",
"}",
"return",
"(",
"new",
"ScopeEntity",
"(",
"$",
"this",
"->",
"server",
")",
")",
"->",
"hydrate",
"(",
"[",
"'id'",
"=>",
"$",
"result",
"[",
"0",
"]",
"[",
"'id'",
"]",
",",
"'description'",
"=>",
"$",
"result",
"[",
"0",
"]",
"[",
"'description'",
"]",
",",
"]",
")",
";",
"}"
]
| {@inheritdoc} | [
"{"
]
| train | https://github.com/redaigbaria/oauth2/blob/54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a/examples/relational/Storage/ScopeStorage.php#L15-L29 |
yuncms/framework | src/widgets/MultipleUpload.php | MultipleUpload.formatAttachment | protected function formatAttachment($attachment)
{
if (!empty($attachment) && is_string($attachment)) {
return ['url' => $attachment, 'path' => $attachment,];
} else if (is_array($attachment)) {
return $attachment;
} else if ($attachment instanceof Arrayable)
return $attachment->toArray();
return [];
} | php | protected function formatAttachment($attachment)
{
if (!empty($attachment) && is_string($attachment)) {
return ['url' => $attachment, 'path' => $attachment,];
} else if (is_array($attachment)) {
return $attachment;
} else if ($attachment instanceof Arrayable)
return $attachment->toArray();
return [];
} | [
"protected",
"function",
"formatAttachment",
"(",
"$",
"attachment",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"attachment",
")",
"&&",
"is_string",
"(",
"$",
"attachment",
")",
")",
"{",
"return",
"[",
"'url'",
"=>",
"$",
"attachment",
",",
"'path'",
"=>",
"$",
"attachment",
",",
"]",
";",
"}",
"else",
"if",
"(",
"is_array",
"(",
"$",
"attachment",
")",
")",
"{",
"return",
"$",
"attachment",
";",
"}",
"else",
"if",
"(",
"$",
"attachment",
"instanceof",
"Arrayable",
")",
"return",
"$",
"attachment",
"->",
"toArray",
"(",
")",
";",
"return",
"[",
"]",
";",
"}"
]
| 格式化附件
@param $attachment
@return array | [
"格式化附件"
]
| train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/widgets/MultipleUpload.php#L160-L169 |
yuncms/framework | src/widgets/MultipleUpload.php | MultipleUpload.registerClientScript | public function registerClientScript()
{
Html::addCssClass($this->wrapperOptions, "upload-kit");
UploadAsset::register($this->getView());
if ($this->sortable) {
JuiAsset::register($this->getView());
}
$options = Json::encode($this->clientOptions);
$this->getView()->registerJs("jQuery('#{$this->fileInputName}').attachmentUpload({$options});");
} | php | public function registerClientScript()
{
Html::addCssClass($this->wrapperOptions, "upload-kit");
UploadAsset::register($this->getView());
if ($this->sortable) {
JuiAsset::register($this->getView());
}
$options = Json::encode($this->clientOptions);
$this->getView()->registerJs("jQuery('#{$this->fileInputName}').attachmentUpload({$options});");
} | [
"public",
"function",
"registerClientScript",
"(",
")",
"{",
"Html",
"::",
"addCssClass",
"(",
"$",
"this",
"->",
"wrapperOptions",
",",
"\"upload-kit\"",
")",
";",
"UploadAsset",
"::",
"register",
"(",
"$",
"this",
"->",
"getView",
"(",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"sortable",
")",
"{",
"JuiAsset",
"::",
"register",
"(",
"$",
"this",
"->",
"getView",
"(",
")",
")",
";",
"}",
"$",
"options",
"=",
"Json",
"::",
"encode",
"(",
"$",
"this",
"->",
"clientOptions",
")",
";",
"$",
"this",
"->",
"getView",
"(",
")",
"->",
"registerJs",
"(",
"\"jQuery('#{$this->fileInputName}').attachmentUpload({$options});\"",
")",
";",
"}"
]
| Registers required script for the plugin to work as jQuery File Uploader | [
"Registers",
"required",
"script",
"for",
"the",
"plugin",
"to",
"work",
"as",
"jQuery",
"File",
"Uploader"
]
| train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/widgets/MultipleUpload.php#L192-L201 |
yuncms/framework | src/oauth2/grant/types/WeChatMiniCredentials.php | WeChatMiniCredentials.init | public function init()
{
parent::init();
if (!Yii::$app->has('wechat')) {
throw new InvalidConfigException("Unknown component ID: wechat.");
}
$this->wechat = Yii::$app->wechat;
} | php | public function init()
{
parent::init();
if (!Yii::$app->has('wechat')) {
throw new InvalidConfigException("Unknown component ID: wechat.");
}
$this->wechat = Yii::$app->wechat;
} | [
"public",
"function",
"init",
"(",
")",
"{",
"parent",
"::",
"init",
"(",
")",
";",
"if",
"(",
"!",
"Yii",
"::",
"$",
"app",
"->",
"has",
"(",
"'wechat'",
")",
")",
"{",
"throw",
"new",
"InvalidConfigException",
"(",
"\"Unknown component ID: wechat.\"",
")",
";",
"}",
"$",
"this",
"->",
"wechat",
"=",
"Yii",
"::",
"$",
"app",
"->",
"wechat",
";",
"}"
]
| 初始化模型
@throws InvalidConfigException | [
"初始化模型"
]
| train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/oauth2/grant/types/WeChatMiniCredentials.php#L85-L92 |
yuncms/framework | src/admin/controllers/UserRuleController.php | UserRuleController.actionCreate | public function actionCreate()
{
$model = new UserBizRule(null);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
UserRBACHelper::invalidate();
Yii::$app->getSession()->setFlash('success', Yii::t('yuncms','Create success.'));
return $this->redirect(['view', 'id' => $model->name]);
} else {
return $this->render('create', ['model' => $model,]);
}
} | php | public function actionCreate()
{
$model = new UserBizRule(null);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
UserRBACHelper::invalidate();
Yii::$app->getSession()->setFlash('success', Yii::t('yuncms','Create success.'));
return $this->redirect(['view', 'id' => $model->name]);
} else {
return $this->render('create', ['model' => $model,]);
}
} | [
"public",
"function",
"actionCreate",
"(",
")",
"{",
"$",
"model",
"=",
"new",
"UserBizRule",
"(",
"null",
")",
";",
"if",
"(",
"$",
"model",
"->",
"load",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
")",
"&&",
"$",
"model",
"->",
"save",
"(",
")",
")",
"{",
"UserRBACHelper",
"::",
"invalidate",
"(",
")",
";",
"Yii",
"::",
"$",
"app",
"->",
"getSession",
"(",
")",
"->",
"setFlash",
"(",
"'success'",
",",
"Yii",
"::",
"t",
"(",
"'yuncms'",
",",
"'Create success.'",
")",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"[",
"'view'",
",",
"'id'",
"=>",
"$",
"model",
"->",
"name",
"]",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"render",
"(",
"'create'",
",",
"[",
"'model'",
"=>",
"$",
"model",
",",
"]",
")",
";",
"}",
"}"
]
| Creates a new AuthItem model.
If creation is successful, the browser will be redirected to the 'view' page.
@return mixed
@throws \Exception | [
"Creates",
"a",
"new",
"AuthItem",
"model",
".",
"If",
"creation",
"is",
"successful",
"the",
"browser",
"will",
"be",
"redirected",
"to",
"the",
"view",
"page",
"."
]
| train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/admin/controllers/UserRuleController.php#L71-L81 |
yuncms/framework | src/admin/controllers/UserRuleController.php | UserRuleController.findModel | protected function findModel($id)
{
$item = UserRBACHelper::getAuthManager()->getRule($id);
if ($item) {
return new UserBizRule($item);
} else {
throw new NotFoundHttpException(Yii::t('yuncms', 'The requested page does not exist.'));
}
} | php | protected function findModel($id)
{
$item = UserRBACHelper::getAuthManager()->getRule($id);
if ($item) {
return new UserBizRule($item);
} else {
throw new NotFoundHttpException(Yii::t('yuncms', 'The requested page does not exist.'));
}
} | [
"protected",
"function",
"findModel",
"(",
"$",
"id",
")",
"{",
"$",
"item",
"=",
"UserRBACHelper",
"::",
"getAuthManager",
"(",
")",
"->",
"getRule",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"item",
")",
"{",
"return",
"new",
"UserBizRule",
"(",
"$",
"item",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"NotFoundHttpException",
"(",
"Yii",
"::",
"t",
"(",
"'yuncms'",
",",
"'The requested page does not exist.'",
")",
")",
";",
"}",
"}"
]
| Finds the AuthItem model based on its primary key value.
If the model is not found, a 404 HTTP exception will be thrown.
@param string $id
@return UserBizRule the loaded model
@throws NotFoundHttpException if the model cannot be found
@throws \yii\base\InvalidConfigException | [
"Finds",
"the",
"AuthItem",
"model",
"based",
"on",
"its",
"primary",
"key",
"value",
".",
"If",
"the",
"model",
"is",
"not",
"found",
"a",
"404",
"HTTP",
"exception",
"will",
"be",
"thrown",
"."
]
| train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/admin/controllers/UserRuleController.php#L128-L136 |
ufocoder/yii2-SyncSocial | src/components/services/Facebook.php | Facebook.publishPost | public function publishPost( $message, $url = null ) {
$response = $this->service->api( 'me/feed', 'POST', [
'message' => $message,
] );
if ( ! isset( $response['id'] ) ) {
return [ ];
}
return $this->parsePublishPost(
$this->service->api( $response['id'], 'GET' ),
'id',
[
'service_id_author' => 'from.id',
'service_id_post' => 'id',
'time_created' => 'created_time'
]
);
} | php | public function publishPost( $message, $url = null ) {
$response = $this->service->api( 'me/feed', 'POST', [
'message' => $message,
] );
if ( ! isset( $response['id'] ) ) {
return [ ];
}
return $this->parsePublishPost(
$this->service->api( $response['id'], 'GET' ),
'id',
[
'service_id_author' => 'from.id',
'service_id_post' => 'id',
'time_created' => 'created_time'
]
);
} | [
"public",
"function",
"publishPost",
"(",
"$",
"message",
",",
"$",
"url",
"=",
"null",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"service",
"->",
"api",
"(",
"'me/feed'",
",",
"'POST'",
",",
"[",
"'message'",
"=>",
"$",
"message",
",",
"]",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"response",
"[",
"'id'",
"]",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"parsePublishPost",
"(",
"$",
"this",
"->",
"service",
"->",
"api",
"(",
"$",
"response",
"[",
"'id'",
"]",
",",
"'GET'",
")",
",",
"'id'",
",",
"[",
"'service_id_author'",
"=>",
"'from.id'",
",",
"'service_id_post'",
"=>",
"'id'",
",",
"'time_created'",
"=>",
"'created_time'",
"]",
")",
";",
"}"
]
| @param $message
@param null $url
@return array
@throws \yii\base\Exception | [
"@param",
"$message",
"@param",
"null",
"$url"
]
| train | https://github.com/ufocoder/yii2-SyncSocial/blob/2dbaaec2dad782c52fdd5b648a31ba7fe2a75e1b/src/components/services/Facebook.php#L32-L51 |
webforge-labs/psc-cms | lib/Psc/Doctrine/PersistentCollectionSynchronizer.php | PersistentCollectionSynchronizer.createFor | public static function createFor($entityClass, $collectionPropertyName, DCPackage $dc) {
$entityMeta = $dc->getEntityMeta($entityClass);
$property = $entityMeta->getPropertyMeta($collectionPropertyName);
$collectionClass = $property->getRelationEntityClass();
$synchronizer = new static(
$entityMeta,
$property->getName(),
new UniqueEntityHydrator($dc->getEntityManager()->getRepository($collectionClass->getFQN())),
new EntityFactory($dc->getEntityMeta($collectionClass->getFQN()))
);
return $synchronizer;
} | php | public static function createFor($entityClass, $collectionPropertyName, DCPackage $dc) {
$entityMeta = $dc->getEntityMeta($entityClass);
$property = $entityMeta->getPropertyMeta($collectionPropertyName);
$collectionClass = $property->getRelationEntityClass();
$synchronizer = new static(
$entityMeta,
$property->getName(),
new UniqueEntityHydrator($dc->getEntityManager()->getRepository($collectionClass->getFQN())),
new EntityFactory($dc->getEntityMeta($collectionClass->getFQN()))
);
return $synchronizer;
} | [
"public",
"static",
"function",
"createFor",
"(",
"$",
"entityClass",
",",
"$",
"collectionPropertyName",
",",
"DCPackage",
"$",
"dc",
")",
"{",
"$",
"entityMeta",
"=",
"$",
"dc",
"->",
"getEntityMeta",
"(",
"$",
"entityClass",
")",
";",
"$",
"property",
"=",
"$",
"entityMeta",
"->",
"getPropertyMeta",
"(",
"$",
"collectionPropertyName",
")",
";",
"$",
"collectionClass",
"=",
"$",
"property",
"->",
"getRelationEntityClass",
"(",
")",
";",
"$",
"synchronizer",
"=",
"new",
"static",
"(",
"$",
"entityMeta",
",",
"$",
"property",
"->",
"getName",
"(",
")",
",",
"new",
"UniqueEntityHydrator",
"(",
"$",
"dc",
"->",
"getEntityManager",
"(",
")",
"->",
"getRepository",
"(",
"$",
"collectionClass",
"->",
"getFQN",
"(",
")",
")",
")",
",",
"new",
"EntityFactory",
"(",
"$",
"dc",
"->",
"getEntityMeta",
"(",
"$",
"collectionClass",
"->",
"getFQN",
"(",
")",
")",
")",
")",
";",
"return",
"$",
"synchronizer",
";",
"}"
]
| Erstellt einen Synchronizer für das $collectionPropertyName in $entityClass
@return PersistentCollectionSynchronizer | [
"Erstellt",
"einen",
"Synchronizer",
"für",
"das",
"$collectionPropertyName",
"in",
"$entityClass"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Doctrine/PersistentCollectionSynchronizer.php#L49-L62 |
webforge-labs/psc-cms | lib/Psc/Doctrine/PersistentCollectionSynchronizer.php | PersistentCollectionSynchronizer.init | public function init(Entity $entity) {
parent::init($entity);
$hydrator = $this->hydrator;
$factory = $this->factory;
$repository = $hydrator->getRepository();
$identifier = $factory->getEntityMeta()->getIdentifier();
$skipFields = array();
if ($identifier->isAutogeneratedValue()) {
$skipFields[$identifier->getName()] = TRUE;
}
list($add, $remove) = $this->getRelationInterface();
// hydrate
$this->onHydrate(function ($toObject) use ($hydrator) {
return $hydrator->getEntity((array) $toObject); // convention: $field=>value für alle unique constraint-felder
});
// hash
$this->onHash(function (Entity $entity) {
return $entity->getIdentifier();
});
// insert
$this->onInsert(function ($toObject) use ($factory, $repository, $entity, $add, $skipFields) {
$factory->reset();
foreach ($toObject as $field => $value) {
if (!array_key_exists($field,$skipFields))
$factory->set($field, $value);
}
$collectionEntity = $factory->getEntity();
$entity->$add($collectionEntity);
$repository->persist($collectionEntity);
});
// update (merge)
$this->onUpdate(function (Entity $collectionEntity, $toObject) use ($repository, $entity, $add, $skipFields) {
foreach ($toObject as $field => $value) {
if (!array_key_exists($field,$skipFields)) {
$collectionEntity->callSetter($field, $value);
}
}
$entity->$add($collectionEntity);
$repository->persist($collectionEntity);
});
// delete
$this->onDelete(function (Entity $collectionEntity) use ($entity, $remove) {
$entity->$remove($collectionEntity);
// wenn tag 0 verknüpfungen hat, könnte man es hier auch löschen
});
return $this;
} | php | public function init(Entity $entity) {
parent::init($entity);
$hydrator = $this->hydrator;
$factory = $this->factory;
$repository = $hydrator->getRepository();
$identifier = $factory->getEntityMeta()->getIdentifier();
$skipFields = array();
if ($identifier->isAutogeneratedValue()) {
$skipFields[$identifier->getName()] = TRUE;
}
list($add, $remove) = $this->getRelationInterface();
// hydrate
$this->onHydrate(function ($toObject) use ($hydrator) {
return $hydrator->getEntity((array) $toObject); // convention: $field=>value für alle unique constraint-felder
});
// hash
$this->onHash(function (Entity $entity) {
return $entity->getIdentifier();
});
// insert
$this->onInsert(function ($toObject) use ($factory, $repository, $entity, $add, $skipFields) {
$factory->reset();
foreach ($toObject as $field => $value) {
if (!array_key_exists($field,$skipFields))
$factory->set($field, $value);
}
$collectionEntity = $factory->getEntity();
$entity->$add($collectionEntity);
$repository->persist($collectionEntity);
});
// update (merge)
$this->onUpdate(function (Entity $collectionEntity, $toObject) use ($repository, $entity, $add, $skipFields) {
foreach ($toObject as $field => $value) {
if (!array_key_exists($field,$skipFields)) {
$collectionEntity->callSetter($field, $value);
}
}
$entity->$add($collectionEntity);
$repository->persist($collectionEntity);
});
// delete
$this->onDelete(function (Entity $collectionEntity) use ($entity, $remove) {
$entity->$remove($collectionEntity);
// wenn tag 0 verknüpfungen hat, könnte man es hier auch löschen
});
return $this;
} | [
"public",
"function",
"init",
"(",
"Entity",
"$",
"entity",
")",
"{",
"parent",
"::",
"init",
"(",
"$",
"entity",
")",
";",
"$",
"hydrator",
"=",
"$",
"this",
"->",
"hydrator",
";",
"$",
"factory",
"=",
"$",
"this",
"->",
"factory",
";",
"$",
"repository",
"=",
"$",
"hydrator",
"->",
"getRepository",
"(",
")",
";",
"$",
"identifier",
"=",
"$",
"factory",
"->",
"getEntityMeta",
"(",
")",
"->",
"getIdentifier",
"(",
")",
";",
"$",
"skipFields",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"identifier",
"->",
"isAutogeneratedValue",
"(",
")",
")",
"{",
"$",
"skipFields",
"[",
"$",
"identifier",
"->",
"getName",
"(",
")",
"]",
"=",
"TRUE",
";",
"}",
"list",
"(",
"$",
"add",
",",
"$",
"remove",
")",
"=",
"$",
"this",
"->",
"getRelationInterface",
"(",
")",
";",
"// hydrate\r",
"$",
"this",
"->",
"onHydrate",
"(",
"function",
"(",
"$",
"toObject",
")",
"use",
"(",
"$",
"hydrator",
")",
"{",
"return",
"$",
"hydrator",
"->",
"getEntity",
"(",
"(",
"array",
")",
"$",
"toObject",
")",
";",
"// convention: $field=>value für alle unique constraint-felder\r",
"}",
")",
";",
"// hash\r",
"$",
"this",
"->",
"onHash",
"(",
"function",
"(",
"Entity",
"$",
"entity",
")",
"{",
"return",
"$",
"entity",
"->",
"getIdentifier",
"(",
")",
";",
"}",
")",
";",
"// insert\r",
"$",
"this",
"->",
"onInsert",
"(",
"function",
"(",
"$",
"toObject",
")",
"use",
"(",
"$",
"factory",
",",
"$",
"repository",
",",
"$",
"entity",
",",
"$",
"add",
",",
"$",
"skipFields",
")",
"{",
"$",
"factory",
"->",
"reset",
"(",
")",
";",
"foreach",
"(",
"$",
"toObject",
"as",
"$",
"field",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"field",
",",
"$",
"skipFields",
")",
")",
"$",
"factory",
"->",
"set",
"(",
"$",
"field",
",",
"$",
"value",
")",
";",
"}",
"$",
"collectionEntity",
"=",
"$",
"factory",
"->",
"getEntity",
"(",
")",
";",
"$",
"entity",
"->",
"$",
"add",
"(",
"$",
"collectionEntity",
")",
";",
"$",
"repository",
"->",
"persist",
"(",
"$",
"collectionEntity",
")",
";",
"}",
")",
";",
"// update (merge)\r",
"$",
"this",
"->",
"onUpdate",
"(",
"function",
"(",
"Entity",
"$",
"collectionEntity",
",",
"$",
"toObject",
")",
"use",
"(",
"$",
"repository",
",",
"$",
"entity",
",",
"$",
"add",
",",
"$",
"skipFields",
")",
"{",
"foreach",
"(",
"$",
"toObject",
"as",
"$",
"field",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"field",
",",
"$",
"skipFields",
")",
")",
"{",
"$",
"collectionEntity",
"->",
"callSetter",
"(",
"$",
"field",
",",
"$",
"value",
")",
";",
"}",
"}",
"$",
"entity",
"->",
"$",
"add",
"(",
"$",
"collectionEntity",
")",
";",
"$",
"repository",
"->",
"persist",
"(",
"$",
"collectionEntity",
")",
";",
"}",
")",
";",
"// delete\r",
"$",
"this",
"->",
"onDelete",
"(",
"function",
"(",
"Entity",
"$",
"collectionEntity",
")",
"use",
"(",
"$",
"entity",
",",
"$",
"remove",
")",
"{",
"$",
"entity",
"->",
"$",
"remove",
"(",
"$",
"collectionEntity",
")",
";",
"// wenn tag 0 verknüpfungen hat, könnte man es hier auch löschen\r",
"}",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Initialisiert die Defaults für alle on* Methoden für das Entity mit der Collection
ein CollectionSynchronizer kann mehrere Collections eines Types von mehreren Entities synchronisieren wenn jeweils init() für das aktuelle Entity aufgerufen wird
new Synchronizer();
foreach ($articles as $article) {
$synchronizer->init($article);
$synchronizer->process($article->getTags(), $formData[$article->getId()]);
} | [
"Initialisiert",
"die",
"Defaults",
"für",
"alle",
"on",
"*",
"Methoden",
"für",
"das",
"Entity",
"mit",
"der",
"Collection"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Doctrine/PersistentCollectionSynchronizer.php#L76-L135 |
NasExt/VisualPaginator | src/NasExt/Controls/VisualPaginator.php | VisualPaginator.render | public function render()
{
$paginator = $this->getPaginator();
$page = $paginator->page;
if ($paginator->pageCount < 2) {
$steps = array($page);
} else {
$arr = range(max($paginator->firstPage, $page - 3), min($paginator->lastPage, $page + 3));
if ($this->countBlocks) {
$quotient = ($paginator->pageCount - 1) / $this->countBlocks;
for ($i = 0; $i <= $this->countBlocks; $i++) {
$arr[] = round($quotient * $i) + $paginator->firstPage;
}
}
sort($arr);
$steps = array_values(array_unique($arr));
}
$this->template->steps = $steps;
$this->template->paginator = $paginator;
$this->template->isAjax = $this->isAjax;
$this->template->handle = 'showPage!';
$this->template->setFile($this->getTemplateFile());
$this->template->render();
} | php | public function render()
{
$paginator = $this->getPaginator();
$page = $paginator->page;
if ($paginator->pageCount < 2) {
$steps = array($page);
} else {
$arr = range(max($paginator->firstPage, $page - 3), min($paginator->lastPage, $page + 3));
if ($this->countBlocks) {
$quotient = ($paginator->pageCount - 1) / $this->countBlocks;
for ($i = 0; $i <= $this->countBlocks; $i++) {
$arr[] = round($quotient * $i) + $paginator->firstPage;
}
}
sort($arr);
$steps = array_values(array_unique($arr));
}
$this->template->steps = $steps;
$this->template->paginator = $paginator;
$this->template->isAjax = $this->isAjax;
$this->template->handle = 'showPage!';
$this->template->setFile($this->getTemplateFile());
$this->template->render();
} | [
"public",
"function",
"render",
"(",
")",
"{",
"$",
"paginator",
"=",
"$",
"this",
"->",
"getPaginator",
"(",
")",
";",
"$",
"page",
"=",
"$",
"paginator",
"->",
"page",
";",
"if",
"(",
"$",
"paginator",
"->",
"pageCount",
"<",
"2",
")",
"{",
"$",
"steps",
"=",
"array",
"(",
"$",
"page",
")",
";",
"}",
"else",
"{",
"$",
"arr",
"=",
"range",
"(",
"max",
"(",
"$",
"paginator",
"->",
"firstPage",
",",
"$",
"page",
"-",
"3",
")",
",",
"min",
"(",
"$",
"paginator",
"->",
"lastPage",
",",
"$",
"page",
"+",
"3",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"countBlocks",
")",
"{",
"$",
"quotient",
"=",
"(",
"$",
"paginator",
"->",
"pageCount",
"-",
"1",
")",
"/",
"$",
"this",
"->",
"countBlocks",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<=",
"$",
"this",
"->",
"countBlocks",
";",
"$",
"i",
"++",
")",
"{",
"$",
"arr",
"[",
"]",
"=",
"round",
"(",
"$",
"quotient",
"*",
"$",
"i",
")",
"+",
"$",
"paginator",
"->",
"firstPage",
";",
"}",
"}",
"sort",
"(",
"$",
"arr",
")",
";",
"$",
"steps",
"=",
"array_values",
"(",
"array_unique",
"(",
"$",
"arr",
")",
")",
";",
"}",
"$",
"this",
"->",
"template",
"->",
"steps",
"=",
"$",
"steps",
";",
"$",
"this",
"->",
"template",
"->",
"paginator",
"=",
"$",
"paginator",
";",
"$",
"this",
"->",
"template",
"->",
"isAjax",
"=",
"$",
"this",
"->",
"isAjax",
";",
"$",
"this",
"->",
"template",
"->",
"handle",
"=",
"'showPage!'",
";",
"$",
"this",
"->",
"template",
"->",
"setFile",
"(",
"$",
"this",
"->",
"getTemplateFile",
"(",
")",
")",
";",
"$",
"this",
"->",
"template",
"->",
"render",
"(",
")",
";",
"}"
]
| Renders paginator.
@return void | [
"Renders",
"paginator",
"."
]
| train | https://github.com/NasExt/VisualPaginator/blob/cd03481be6a9074883716f5354293c5cd0f7da84/src/NasExt/Controls/VisualPaginator.php#L125-L150 |
webforge-labs/psc-cms | lib/PHPWord/PHPWord.php | PHPWord.createSection | public function createSection($settings = null) {
$sectionCount = $this->_countSections() + 1;
$section = new PHPWord_Section($sectionCount, $settings);
$this->_sectionCollection[] = $section;
return $section;
} | php | public function createSection($settings = null) {
$sectionCount = $this->_countSections() + 1;
$section = new PHPWord_Section($sectionCount, $settings);
$this->_sectionCollection[] = $section;
return $section;
} | [
"public",
"function",
"createSection",
"(",
"$",
"settings",
"=",
"null",
")",
"{",
"$",
"sectionCount",
"=",
"$",
"this",
"->",
"_countSections",
"(",
")",
"+",
"1",
";",
"$",
"section",
"=",
"new",
"PHPWord_Section",
"(",
"$",
"sectionCount",
",",
"$",
"settings",
")",
";",
"$",
"this",
"->",
"_sectionCollection",
"[",
"]",
"=",
"$",
"section",
";",
"return",
"$",
"section",
";",
"}"
]
| Create a new Section
@param PHPWord_Section_Settings $settings
@return PHPWord_Section | [
"Create",
"a",
"new",
"Section"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord.php#L100-L106 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.