repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
| partition
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
codeblanche/Depend | src/Depend/Descriptor.php | Descriptor.resolveParamName | public function resolveParamName($identifier)
{
if (!isset($this->paramNames[$identifier])) {
return $identifier;
}
return $this->paramNames[$identifier];
} | php | public function resolveParamName($identifier)
{
if (!isset($this->paramNames[$identifier])) {
return $identifier;
}
return $this->paramNames[$identifier];
} | [
"public",
"function",
"resolveParamName",
"(",
"$",
"identifier",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"paramNames",
"[",
"$",
"identifier",
"]",
")",
")",
"{",
"return",
"$",
"identifier",
";",
"}",
"return",
"$",
"this",
"->",
"paramNames",
"[",
"$",
"identifier",
"]",
";",
"}"
] | Resolve the parameter name
@param int|string $identifier
@return string|int | [
"Resolve",
"the",
"parameter",
"name"
] | 6520d010ec71f5b2ea0d622b8abae2e029ef7f16 | https://github.com/codeblanche/Depend/blob/6520d010ec71f5b2ea0d622b8abae2e029ef7f16/src/Depend/Descriptor.php#L408-L415 | train |
MindyPHP/OrmNestedSet | TreeManager.php | TreeManager.descendants | public function descendants($includeSelf = false, $depth = null)
{
$this
->getQuerySet()
->descendants($includeSelf, $depth);
return $this;
} | php | public function descendants($includeSelf = false, $depth = null)
{
$this
->getQuerySet()
->descendants($includeSelf, $depth);
return $this;
} | [
"public",
"function",
"descendants",
"(",
"$",
"includeSelf",
"=",
"false",
",",
"$",
"depth",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"getQuerySet",
"(",
")",
"->",
"descendants",
"(",
"$",
"includeSelf",
",",
"$",
"depth",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Named scope. Gets descendants for node.
@param bool $includeSelf
@param int $depth the depth
@return $this | [
"Named",
"scope",
".",
"Gets",
"descendants",
"for",
"node",
"."
] | 8231c55f9b95314789983c0b0ec83a9eb70adf79 | https://github.com/MindyPHP/OrmNestedSet/blob/8231c55f9b95314789983c0b0ec83a9eb70adf79/TreeManager.php#L51-L58 | train |
MindyPHP/OrmNestedSet | TreeManager.php | TreeManager.ancestors | public function ancestors($includeSelf = false, $depth = null)
{
$this
->getQuerySet()
->ancestors($includeSelf, $depth);
return $this;
} | php | public function ancestors($includeSelf = false, $depth = null)
{
$this
->getQuerySet()
->ancestors($includeSelf, $depth);
return $this;
} | [
"public",
"function",
"ancestors",
"(",
"$",
"includeSelf",
"=",
"false",
",",
"$",
"depth",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"getQuerySet",
"(",
")",
"->",
"ancestors",
"(",
"$",
"includeSelf",
",",
"$",
"depth",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Named scope. Gets ancestors for node.
@param bool $includeSelf
@param int $depth the depth
@return $this | [
"Named",
"scope",
".",
"Gets",
"ancestors",
"for",
"node",
"."
] | 8231c55f9b95314789983c0b0ec83a9eb70adf79 | https://github.com/MindyPHP/OrmNestedSet/blob/8231c55f9b95314789983c0b0ec83a9eb70adf79/TreeManager.php#L84-L91 | train |
MindyPHP/OrmNestedSet | TreeManager.php | TreeManager.rebuild | public function rebuild()
{
$i = 0;
$skip = [];
while (0 != $this->filter(['lft__isnull' => true])->count()) {
++$i;
$fixed = 0;
echo 'Iteration: '.$i.PHP_EOL;
$clone = clone $this;
/** @var TreeModel[] $models */
$models = $clone
->exclude(['pk__in' => $skip])
->filter(['lft__isnull' => true])
->order(['parent_id'])
->all();
foreach ($models as $model) {
$model->lft = $model->rgt = $model->level = $model->root = null;
if ($model->saveRebuild()) {
$skip[] = $model->pk;
++$fixed;
}
echo '.';
}
echo PHP_EOL;
echo 'Fixed: '.$fixed.PHP_EOL;
}
} | php | public function rebuild()
{
$i = 0;
$skip = [];
while (0 != $this->filter(['lft__isnull' => true])->count()) {
++$i;
$fixed = 0;
echo 'Iteration: '.$i.PHP_EOL;
$clone = clone $this;
/** @var TreeModel[] $models */
$models = $clone
->exclude(['pk__in' => $skip])
->filter(['lft__isnull' => true])
->order(['parent_id'])
->all();
foreach ($models as $model) {
$model->lft = $model->rgt = $model->level = $model->root = null;
if ($model->saveRebuild()) {
$skip[] = $model->pk;
++$fixed;
}
echo '.';
}
echo PHP_EOL;
echo 'Fixed: '.$fixed.PHP_EOL;
}
} | [
"public",
"function",
"rebuild",
"(",
")",
"{",
"$",
"i",
"=",
"0",
";",
"$",
"skip",
"=",
"[",
"]",
";",
"while",
"(",
"0",
"!=",
"$",
"this",
"->",
"filter",
"(",
"[",
"'lft__isnull'",
"=>",
"true",
"]",
")",
"->",
"count",
"(",
")",
")",
"{",
"++",
"$",
"i",
";",
"$",
"fixed",
"=",
"0",
";",
"echo",
"'Iteration: '",
".",
"$",
"i",
".",
"PHP_EOL",
";",
"$",
"clone",
"=",
"clone",
"$",
"this",
";",
"/** @var TreeModel[] $models */",
"$",
"models",
"=",
"$",
"clone",
"->",
"exclude",
"(",
"[",
"'pk__in'",
"=>",
"$",
"skip",
"]",
")",
"->",
"filter",
"(",
"[",
"'lft__isnull'",
"=>",
"true",
"]",
")",
"->",
"order",
"(",
"[",
"'parent_id'",
"]",
")",
"->",
"all",
"(",
")",
";",
"foreach",
"(",
"$",
"models",
"as",
"$",
"model",
")",
"{",
"$",
"model",
"->",
"lft",
"=",
"$",
"model",
"->",
"rgt",
"=",
"$",
"model",
"->",
"level",
"=",
"$",
"model",
"->",
"root",
"=",
"null",
";",
"if",
"(",
"$",
"model",
"->",
"saveRebuild",
"(",
")",
")",
"{",
"$",
"skip",
"[",
"]",
"=",
"$",
"model",
"->",
"pk",
";",
"++",
"$",
"fixed",
";",
"}",
"echo",
"'.'",
";",
"}",
"echo",
"PHP_EOL",
";",
"echo",
"'Fixed: '",
".",
"$",
"fixed",
".",
"PHP_EOL",
";",
"}",
"}"
] | Completely rebuild broken tree | [
"Completely",
"rebuild",
"broken",
"tree"
] | 8231c55f9b95314789983c0b0ec83a9eb70adf79 | https://github.com/MindyPHP/OrmNestedSet/blob/8231c55f9b95314789983c0b0ec83a9eb70adf79/TreeManager.php#L180-L208 | train |
rapisarda/event-manager | src/EventManager.php | EventManager.detach | public function detach(string $event, $callback){
if(isset($this->listeners[$event])){
return $this->listeners[$event]->remove($callback);
}
return false;
} | php | public function detach(string $event, $callback){
if(isset($this->listeners[$event])){
return $this->listeners[$event]->remove($callback);
}
return false;
} | [
"public",
"function",
"detach",
"(",
"string",
"$",
"event",
",",
"$",
"callback",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"listeners",
"[",
"$",
"event",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"listeners",
"[",
"$",
"event",
"]",
"->",
"remove",
"(",
"$",
"callback",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Detaches a listener from an event
@param string $event the event to attach too
@param callable $callback a callable function
@return bool true on success false on failure | [
"Detaches",
"a",
"listener",
"from",
"an",
"event"
] | bfe99f425b884abd4b357ec1e9a3753de2946ef3 | https://github.com/rapisarda/event-manager/blob/bfe99f425b884abd4b357ec1e9a3753de2946ef3/src/EventManager.php#L48-L53 | train |
translationexchange/tml-php-clientsdk | library/Tr8n/TranslationKey.php | TranslationKey.decorationTokens | public function decorationTokens() {
if ($this->decoration_tokens == null) {
$dt = new DecorationTokenizer($this->label);
$dt->parse();
$this->decoration_tokens = $dt->tokens;
}
return $this->decoration_tokens;
} | php | public function decorationTokens() {
if ($this->decoration_tokens == null) {
$dt = new DecorationTokenizer($this->label);
$dt->parse();
$this->decoration_tokens = $dt->tokens;
}
return $this->decoration_tokens;
} | [
"public",
"function",
"decorationTokens",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"decoration_tokens",
"==",
"null",
")",
"{",
"$",
"dt",
"=",
"new",
"DecorationTokenizer",
"(",
"$",
"this",
"->",
"label",
")",
";",
"$",
"dt",
"->",
"parse",
"(",
")",
";",
"$",
"this",
"->",
"decoration_tokens",
"=",
"$",
"dt",
"->",
"tokens",
";",
"}",
"return",
"$",
"this",
"->",
"decoration_tokens",
";",
"}"
] | Returns an array of decoration tokens from the translation key
@return \string[] | [
"Returns",
"an",
"array",
"of",
"decoration",
"tokens",
"from",
"the",
"translation",
"key"
] | fe51473824e62cfd883c6aa0c6a3783a16ce8425 | https://github.com/translationexchange/tml-php-clientsdk/blob/fe51473824e62cfd883c6aa0c6a3783a16ce8425/library/Tr8n/TranslationKey.php#L321-L329 | train |
translationexchange/tml-php-clientsdk | library/Tr8n/TranslationKey.php | TranslationKey.dataTokens | public function dataTokens() {
if ($this->data_tokens == null) {
$dt = new DataTokenizer($this->label);
$this->data_tokens = $dt->tokens;
}
return $this->data_tokens;
} | php | public function dataTokens() {
if ($this->data_tokens == null) {
$dt = new DataTokenizer($this->label);
$this->data_tokens = $dt->tokens;
}
return $this->data_tokens;
} | [
"public",
"function",
"dataTokens",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"data_tokens",
"==",
"null",
")",
"{",
"$",
"dt",
"=",
"new",
"DataTokenizer",
"(",
"$",
"this",
"->",
"label",
")",
";",
"$",
"this",
"->",
"data_tokens",
"=",
"$",
"dt",
"->",
"tokens",
";",
"}",
"return",
"$",
"this",
"->",
"data_tokens",
";",
"}"
] | Returns an array of data tokens from the translation key
@return \mixed[] | [
"Returns",
"an",
"array",
"of",
"data",
"tokens",
"from",
"the",
"translation",
"key"
] | fe51473824e62cfd883c6aa0c6a3783a16ce8425 | https://github.com/translationexchange/tml-php-clientsdk/blob/fe51473824e62cfd883c6aa0c6a3783a16ce8425/library/Tr8n/TranslationKey.php#L336-L343 | train |
WellCommerce/ReportBundle | Provider/AbstractReportProvider.php | AbstractReportProvider.convertAmount | protected function convertAmount(OrderInterface $order)
{
$amount = $order->getSummary()->getGrossAmount();
$baseCurrency = $order->getCurrency();
return $this->getCurrencyHelper()->convert($amount, $baseCurrency);
} | php | protected function convertAmount(OrderInterface $order)
{
$amount = $order->getSummary()->getGrossAmount();
$baseCurrency = $order->getCurrency();
return $this->getCurrencyHelper()->convert($amount, $baseCurrency);
} | [
"protected",
"function",
"convertAmount",
"(",
"OrderInterface",
"$",
"order",
")",
"{",
"$",
"amount",
"=",
"$",
"order",
"->",
"getSummary",
"(",
")",
"->",
"getGrossAmount",
"(",
")",
";",
"$",
"baseCurrency",
"=",
"$",
"order",
"->",
"getCurrency",
"(",
")",
";",
"return",
"$",
"this",
"->",
"getCurrencyHelper",
"(",
")",
"->",
"convert",
"(",
"$",
"amount",
",",
"$",
"baseCurrency",
")",
";",
"}"
] | Converts the order's gross total to target currency
@param OrderInterface $order
@return float | [
"Converts",
"the",
"order",
"s",
"gross",
"total",
"to",
"target",
"currency"
] | 863d1f1fbb3030711bf13da2a07921317bd60f03 | https://github.com/WellCommerce/ReportBundle/blob/863d1f1fbb3030711bf13da2a07921317bd60f03/Provider/AbstractReportProvider.php#L48-L54 | train |
translationexchange/tml-php-clientsdk | library/Tr8n/Cache/Generators/ChdbGenerator.php | ChdbGenerator.cacheTranslations | private function cacheTranslations() {
$this->log("Downloading translations...");
stream_wrapper_register("chdb", '\Tr8n\Cache\Generators\ChdbStream') or die("Failed to register Chdb protocol for streaming Tr8n translation keys");
$fp = fopen("chdb://ChdbInMemory", "r+");
$ch = curl_init();
$url = Config::instance()->application->host . ApiClient::API_PATH . "application/translations?stream=true&client_id=" . Config::instance()->application->key;
$this->log("GET: " . $url);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_BUFFERSIZE, 256);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_exec($ch);
curl_close($ch);
fclose($fp);
} | php | private function cacheTranslations() {
$this->log("Downloading translations...");
stream_wrapper_register("chdb", '\Tr8n\Cache\Generators\ChdbStream') or die("Failed to register Chdb protocol for streaming Tr8n translation keys");
$fp = fopen("chdb://ChdbInMemory", "r+");
$ch = curl_init();
$url = Config::instance()->application->host . ApiClient::API_PATH . "application/translations?stream=true&client_id=" . Config::instance()->application->key;
$this->log("GET: " . $url);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_BUFFERSIZE, 256);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_exec($ch);
curl_close($ch);
fclose($fp);
} | [
"private",
"function",
"cacheTranslations",
"(",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"\"Downloading translations...\"",
")",
";",
"stream_wrapper_register",
"(",
"\"chdb\"",
",",
"'\\Tr8n\\Cache\\Generators\\ChdbStream'",
")",
"or",
"die",
"(",
"\"Failed to register Chdb protocol for streaming Tr8n translation keys\"",
")",
";",
"$",
"fp",
"=",
"fopen",
"(",
"\"chdb://ChdbInMemory\"",
",",
"\"r+\"",
")",
";",
"$",
"ch",
"=",
"curl_init",
"(",
")",
";",
"$",
"url",
"=",
"Config",
"::",
"instance",
"(",
")",
"->",
"application",
"->",
"host",
".",
"ApiClient",
"::",
"API_PATH",
".",
"\"application/translations?stream=true&client_id=\"",
".",
"Config",
"::",
"instance",
"(",
")",
"->",
"application",
"->",
"key",
";",
"$",
"this",
"->",
"log",
"(",
"\"GET: \"",
".",
"$",
"url",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_URL",
",",
"$",
"url",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_HEADER",
",",
"0",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_BUFFERSIZE",
",",
"256",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_RETURNTRANSFER",
",",
"true",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_FILE",
",",
"$",
"fp",
")",
";",
"curl_exec",
"(",
"$",
"ch",
")",
";",
"curl_close",
"(",
"$",
"ch",
")",
";",
"fclose",
"(",
"$",
"fp",
")",
";",
"}"
] | Caches translation keys | [
"Caches",
"translation",
"keys"
] | fe51473824e62cfd883c6aa0c6a3783a16ce8425 | https://github.com/translationexchange/tml-php-clientsdk/blob/fe51473824e62cfd883c6aa0c6a3783a16ce8425/library/Tr8n/Cache/Generators/ChdbGenerator.php#L103-L122 | train |
translationexchange/tml-php-clientsdk | library/Tr8n/Cache/Generators/ChdbGenerator.php | ChdbGenerator.generateChdb | public function generateChdb() {
$this->extracted_at = new \DateTime();
$this->log("Writing chdb file...");
$this->log("File: " . $this->chdb_path);
$success = chdb_create($this->chdb_path, $this->cache);
if (!$success) {
fprintf(STDERR, "Failed to create chdb file $this->chdb_path\n");
return;
}
} | php | public function generateChdb() {
$this->extracted_at = new \DateTime();
$this->log("Writing chdb file...");
$this->log("File: " . $this->chdb_path);
$success = chdb_create($this->chdb_path, $this->cache);
if (!$success) {
fprintf(STDERR, "Failed to create chdb file $this->chdb_path\n");
return;
}
} | [
"public",
"function",
"generateChdb",
"(",
")",
"{",
"$",
"this",
"->",
"extracted_at",
"=",
"new",
"\\",
"DateTime",
"(",
")",
";",
"$",
"this",
"->",
"log",
"(",
"\"Writing chdb file...\"",
")",
";",
"$",
"this",
"->",
"log",
"(",
"\"File: \"",
".",
"$",
"this",
"->",
"chdb_path",
")",
";",
"$",
"success",
"=",
"chdb_create",
"(",
"$",
"this",
"->",
"chdb_path",
",",
"$",
"this",
"->",
"cache",
")",
";",
"if",
"(",
"!",
"$",
"success",
")",
"{",
"fprintf",
"(",
"STDERR",
",",
"\"Failed to create chdb file $this->chdb_path\\n\"",
")",
";",
"return",
";",
"}",
"}"
] | Generates chdb database | [
"Generates",
"chdb",
"database"
] | fe51473824e62cfd883c6aa0c6a3783a16ce8425 | https://github.com/translationexchange/tml-php-clientsdk/blob/fe51473824e62cfd883c6aa0c6a3783a16ce8425/library/Tr8n/Cache/Generators/ChdbGenerator.php#L127-L139 | train |
Linkvalue-Interne/MajoraFrameworkExtraBundle | src/Majora/Framework/Model/EntityCollection.php | EntityCollection.search | public function search(array $filters)
{
return $this->filter(function (CollectionableInterface $entity) use ($filters) {
$res = true;
foreach ($filters as $key => $value) {
$current = $this->getPropertyAccessor()->getValue($entity, $key);
$res = $res && (is_array($value) ?
in_array($current, $value) :
$current == $value
);
}
return $res;
});
} | php | public function search(array $filters)
{
return $this->filter(function (CollectionableInterface $entity) use ($filters) {
$res = true;
foreach ($filters as $key => $value) {
$current = $this->getPropertyAccessor()->getValue($entity, $key);
$res = $res && (is_array($value) ?
in_array($current, $value) :
$current == $value
);
}
return $res;
});
} | [
"public",
"function",
"search",
"(",
"array",
"$",
"filters",
")",
"{",
"return",
"$",
"this",
"->",
"filter",
"(",
"function",
"(",
"CollectionableInterface",
"$",
"entity",
")",
"use",
"(",
"$",
"filters",
")",
"{",
"$",
"res",
"=",
"true",
";",
"foreach",
"(",
"$",
"filters",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"current",
"=",
"$",
"this",
"->",
"getPropertyAccessor",
"(",
")",
"->",
"getValue",
"(",
"$",
"entity",
",",
"$",
"key",
")",
";",
"$",
"res",
"=",
"$",
"res",
"&&",
"(",
"is_array",
"(",
"$",
"value",
")",
"?",
"in_array",
"(",
"$",
"current",
",",
"$",
"value",
")",
":",
"$",
"current",
"==",
"$",
"value",
")",
";",
"}",
"return",
"$",
"res",
";",
"}",
")",
";",
"}"
] | filter given collection on given fields.
@param array $filters
@return EntityCollection | [
"filter",
"given",
"collection",
"on",
"given",
"fields",
"."
] | 6f368380cfc39d27fafb0844e9a53b4d86d7c034 | https://github.com/Linkvalue-Interne/MajoraFrameworkExtraBundle/blob/6f368380cfc39d27fafb0844e9a53b4d86d7c034/src/Majora/Framework/Model/EntityCollection.php#L109-L123 | train |
Linkvalue-Interne/MajoraFrameworkExtraBundle | src/Majora/Framework/Model/EntityCollection.php | EntityCollection.sort | public function sort(\Closure $p)
{
$elements = $this->toArray();
if (!uasort($elements, $p)) {
throw new \InvalidArgumentException('Sort failed.');
}
return new static(array_values($elements));
} | php | public function sort(\Closure $p)
{
$elements = $this->toArray();
if (!uasort($elements, $p)) {
throw new \InvalidArgumentException('Sort failed.');
}
return new static(array_values($elements));
} | [
"public",
"function",
"sort",
"(",
"\\",
"Closure",
"$",
"p",
")",
"{",
"$",
"elements",
"=",
"$",
"this",
"->",
"toArray",
"(",
")",
";",
"if",
"(",
"!",
"uasort",
"(",
"$",
"elements",
",",
"$",
"p",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Sort failed.'",
")",
";",
"}",
"return",
"new",
"static",
"(",
"array_values",
"(",
"$",
"elements",
")",
")",
";",
"}"
] | Sort collection with given closure.
@param \Closure $p
@return EntityCollection | [
"Sort",
"collection",
"with",
"given",
"closure",
"."
] | 6f368380cfc39d27fafb0844e9a53b4d86d7c034 | https://github.com/Linkvalue-Interne/MajoraFrameworkExtraBundle/blob/6f368380cfc39d27fafb0844e9a53b4d86d7c034/src/Majora/Framework/Model/EntityCollection.php#L156-L165 | train |
Linkvalue-Interne/MajoraFrameworkExtraBundle | src/Majora/Framework/Model/EntityCollection.php | EntityCollection.reduce | public function reduce(\Closure $p, $initialValue = null)
{
return array_reduce($this->toArray(), $p, $initialValue);
} | php | public function reduce(\Closure $p, $initialValue = null)
{
return array_reduce($this->toArray(), $p, $initialValue);
} | [
"public",
"function",
"reduce",
"(",
"\\",
"Closure",
"$",
"p",
",",
"$",
"initialValue",
"=",
"null",
")",
"{",
"return",
"array_reduce",
"(",
"$",
"this",
"->",
"toArray",
"(",
")",
",",
"$",
"p",
",",
"$",
"initialValue",
")",
";",
"}"
] | Reduce collection with given closure.
@link http://php.net/manual/en/function.array-reduce.php
@param \Closure $p
@param mixed $initialValue
@return mixed | [
"Reduce",
"collection",
"with",
"given",
"closure",
"."
] | 6f368380cfc39d27fafb0844e9a53b4d86d7c034 | https://github.com/Linkvalue-Interne/MajoraFrameworkExtraBundle/blob/6f368380cfc39d27fafb0844e9a53b4d86d7c034/src/Majora/Framework/Model/EntityCollection.php#L177-L180 | train |
Linkvalue-Interne/MajoraFrameworkExtraBundle | src/Majora/Framework/Model/EntityCollection.php | EntityCollection.indexBy | public function indexBy($field)
{
$elements = $this->toArray();
$this->clear();
foreach ($elements as $element) {
$this->set(
$this->getFieldValue($element, $field),
$element
);
}
return $this;
} | php | public function indexBy($field)
{
$elements = $this->toArray();
$this->clear();
foreach ($elements as $element) {
$this->set(
$this->getFieldValue($element, $field),
$element
);
}
return $this;
} | [
"public",
"function",
"indexBy",
"(",
"$",
"field",
")",
"{",
"$",
"elements",
"=",
"$",
"this",
"->",
"toArray",
"(",
")",
";",
"$",
"this",
"->",
"clear",
"(",
")",
";",
"foreach",
"(",
"$",
"elements",
"as",
"$",
"element",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"$",
"this",
"->",
"getFieldValue",
"(",
"$",
"element",
",",
"$",
"field",
")",
",",
"$",
"element",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | index collection by given object field.
@param string $field
@return EntityCollection | [
"index",
"collection",
"by",
"given",
"object",
"field",
"."
] | 6f368380cfc39d27fafb0844e9a53b4d86d7c034 | https://github.com/Linkvalue-Interne/MajoraFrameworkExtraBundle/blob/6f368380cfc39d27fafb0844e9a53b4d86d7c034/src/Majora/Framework/Model/EntityCollection.php#L202-L215 | train |
Linkvalue-Interne/MajoraFrameworkExtraBundle | src/Majora/Framework/Model/EntityCollection.php | EntityCollection.column | public function column($column)
{
return $this
->map(function (CollectionableInterface $entity) use ($column) {
return $this->getFieldValue($entity, $column);
})
->toArray()
;
} | php | public function column($column)
{
return $this
->map(function (CollectionableInterface $entity) use ($column) {
return $this->getFieldValue($entity, $column);
})
->toArray()
;
} | [
"public",
"function",
"column",
"(",
"$",
"column",
")",
"{",
"return",
"$",
"this",
"->",
"map",
"(",
"function",
"(",
"CollectionableInterface",
"$",
"entity",
")",
"use",
"(",
"$",
"column",
")",
"{",
"return",
"$",
"this",
"->",
"getFieldValue",
"(",
"$",
"entity",
",",
"$",
"column",
")",
";",
"}",
")",
"->",
"toArray",
"(",
")",
";",
"}"
] | Return value of inner objects given property as an array.
This is an object version of array_column() method.
@link http://php.net/manual/fr/function.array-column.php
@param string $column
@return array | [
"Return",
"value",
"of",
"inner",
"objects",
"given",
"property",
"as",
"an",
"array",
"."
] | 6f368380cfc39d27fafb0844e9a53b4d86d7c034 | https://github.com/Linkvalue-Interne/MajoraFrameworkExtraBundle/blob/6f368380cfc39d27fafb0844e9a53b4d86d7c034/src/Majora/Framework/Model/EntityCollection.php#L227-L235 | train |
Linkvalue-Interne/MajoraFrameworkExtraBundle | src/Majora/Framework/Model/EntityCollection.php | EntityCollection.flatten | public function flatten($indexColumn, $valueColumn)
{
return $this->reduce(
function ($carry, CollectionableInterface $entity) use ($indexColumn, $valueColumn) {
$carry[$this->getFieldValue($entity, $indexColumn)] = $this->getFieldValue($entity, $valueColumn);
return $carry;
},
array()
);
} | php | public function flatten($indexColumn, $valueColumn)
{
return $this->reduce(
function ($carry, CollectionableInterface $entity) use ($indexColumn, $valueColumn) {
$carry[$this->getFieldValue($entity, $indexColumn)] = $this->getFieldValue($entity, $valueColumn);
return $carry;
},
array()
);
} | [
"public",
"function",
"flatten",
"(",
"$",
"indexColumn",
",",
"$",
"valueColumn",
")",
"{",
"return",
"$",
"this",
"->",
"reduce",
"(",
"function",
"(",
"$",
"carry",
",",
"CollectionableInterface",
"$",
"entity",
")",
"use",
"(",
"$",
"indexColumn",
",",
"$",
"valueColumn",
")",
"{",
"$",
"carry",
"[",
"$",
"this",
"->",
"getFieldValue",
"(",
"$",
"entity",
",",
"$",
"indexColumn",
")",
"]",
"=",
"$",
"this",
"->",
"getFieldValue",
"(",
"$",
"entity",
",",
"$",
"valueColumn",
")",
";",
"return",
"$",
"carry",
";",
"}",
",",
"array",
"(",
")",
")",
";",
"}"
] | Create a flattened view of collection as a key value array.
@param string $indexColumn
@param string $valueColumn
@return array | [
"Create",
"a",
"flattened",
"view",
"of",
"collection",
"as",
"a",
"key",
"value",
"array",
"."
] | 6f368380cfc39d27fafb0844e9a53b4d86d7c034 | https://github.com/Linkvalue-Interne/MajoraFrameworkExtraBundle/blob/6f368380cfc39d27fafb0844e9a53b4d86d7c034/src/Majora/Framework/Model/EntityCollection.php#L245-L255 | train |
Linkvalue-Interne/MajoraFrameworkExtraBundle | src/Majora/Framework/Model/EntityCollection.php | EntityCollection.display | public function display($column, $slug = '", "', $format = '["%s"]')
{
return sprintf($format, implode($slug, $this
->column($column)
));
} | php | public function display($column, $slug = '", "', $format = '["%s"]')
{
return sprintf($format, implode($slug, $this
->column($column)
));
} | [
"public",
"function",
"display",
"(",
"$",
"column",
",",
"$",
"slug",
"=",
"'\", \"'",
",",
"$",
"format",
"=",
"'[\"%s\"]'",
")",
"{",
"return",
"sprintf",
"(",
"$",
"format",
",",
"implode",
"(",
"$",
"slug",
",",
"$",
"this",
"->",
"column",
"(",
"$",
"column",
")",
")",
")",
";",
"}"
] | Returns a string representation of given column values.
@param string $column
@param string $slug
@return string | [
"Returns",
"a",
"string",
"representation",
"of",
"given",
"column",
"values",
"."
] | 6f368380cfc39d27fafb0844e9a53b4d86d7c034 | https://github.com/Linkvalue-Interne/MajoraFrameworkExtraBundle/blob/6f368380cfc39d27fafb0844e9a53b4d86d7c034/src/Majora/Framework/Model/EntityCollection.php#L265-L270 | train |
wb-crowdfusion/crowdfusion | system/core/classes/mvc/filters/PagingFilterer.php | PagingFilterer.totalPages | public function totalPages()
{
$maxrows = (($m = $this->getParameter('RowsPerPage')) !== null)?$m:$this->getLocal('MaxRows');
$totalrecords = (($m = $this->getParameter('TotalRecords')) !== null)?$m:$this->getLocal('TotalRecords');
if (empty($totalrecords))
return 0;
if(empty($maxrows))
throw new FiltererException('filter \'paging-total-pages\' requires the MaxRows template variable to be set');
$totalpages = intval(($totalrecords-1)/$maxrows)+1;
return $totalpages;
} | php | public function totalPages()
{
$maxrows = (($m = $this->getParameter('RowsPerPage')) !== null)?$m:$this->getLocal('MaxRows');
$totalrecords = (($m = $this->getParameter('TotalRecords')) !== null)?$m:$this->getLocal('TotalRecords');
if (empty($totalrecords))
return 0;
if(empty($maxrows))
throw new FiltererException('filter \'paging-total-pages\' requires the MaxRows template variable to be set');
$totalpages = intval(($totalrecords-1)/$maxrows)+1;
return $totalpages;
} | [
"public",
"function",
"totalPages",
"(",
")",
"{",
"$",
"maxrows",
"=",
"(",
"(",
"$",
"m",
"=",
"$",
"this",
"->",
"getParameter",
"(",
"'RowsPerPage'",
")",
")",
"!==",
"null",
")",
"?",
"$",
"m",
":",
"$",
"this",
"->",
"getLocal",
"(",
"'MaxRows'",
")",
";",
"$",
"totalrecords",
"=",
"(",
"(",
"$",
"m",
"=",
"$",
"this",
"->",
"getParameter",
"(",
"'TotalRecords'",
")",
")",
"!==",
"null",
")",
"?",
"$",
"m",
":",
"$",
"this",
"->",
"getLocal",
"(",
"'TotalRecords'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"totalrecords",
")",
")",
"return",
"0",
";",
"if",
"(",
"empty",
"(",
"$",
"maxrows",
")",
")",
"throw",
"new",
"FiltererException",
"(",
"'filter \\'paging-total-pages\\' requires the MaxRows template variable to be set'",
")",
";",
"$",
"totalpages",
"=",
"intval",
"(",
"(",
"$",
"totalrecords",
"-",
"1",
")",
"/",
"$",
"maxrows",
")",
"+",
"1",
";",
"return",
"$",
"totalpages",
";",
"}"
] | Returns the total number of pages
Expected Params (These will be looked for in Locals if the Param doesn't exist):
RowsPerPage integer
TotalRecords integer
@throws FiltererException
@return int | [
"Returns",
"the",
"total",
"number",
"of",
"pages"
] | 8cad7988f046a6fefbed07d026cb4ae6706c1217 | https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/mvc/filters/PagingFilterer.php#L252-L265 | train |
MayMeow/may-encrypt | src/Factory/CertificateFactory.php | CertificateFactory._setCertConfigure | protected function _setCertConfigure()
{
$this->certConfigure = [
'config' => $this->typeConfigurations[$this->type],
'x509_extensions' => $this->_getConfig('x509_extensions'),
'private_key_bits' => $this->config['default']['private_key_bits']
];
} | php | protected function _setCertConfigure()
{
$this->certConfigure = [
'config' => $this->typeConfigurations[$this->type],
'x509_extensions' => $this->_getConfig('x509_extensions'),
'private_key_bits' => $this->config['default']['private_key_bits']
];
} | [
"protected",
"function",
"_setCertConfigure",
"(",
")",
"{",
"$",
"this",
"->",
"certConfigure",
"=",
"[",
"'config'",
"=>",
"$",
"this",
"->",
"typeConfigurations",
"[",
"$",
"this",
"->",
"type",
"]",
",",
"'x509_extensions'",
"=>",
"$",
"this",
"->",
"_getConfig",
"(",
"'x509_extensions'",
")",
",",
"'private_key_bits'",
"=>",
"$",
"this",
"->",
"config",
"[",
"'default'",
"]",
"[",
"'private_key_bits'",
"]",
"]",
";",
"}"
] | Load Default Configuration | [
"Load",
"Default",
"Configuration"
] | d67122e240037e6cc31e1c0742911e87cda93a86 | https://github.com/MayMeow/may-encrypt/blob/d67122e240037e6cc31e1c0742911e87cda93a86/src/Factory/CertificateFactory.php#L151-L158 | train |
MayMeow/may-encrypt | src/Factory/CertificateFactory.php | CertificateFactory.getKeyPair | public function getKeyPair($file = false)
{
$pk = $this->_generatePK();
openssl_pkey_export($pk, $privKey, null, $this->certConfigure);
$pubKey = openssl_pkey_get_details($pk);
$keys = new KeyPair();
$keys->setPrivateKey($privKey)->setPublicKey($pubKey['key']);
if ($file) {
file_put_contents($this->fileName . static::PRIV_KEY_FILENAME , $keys->getPrivateKey());
file_put_contents($this->fileName . static::PUB_KEY_FILENAME , $keys->getPublicKey());
}
return $keys;
} | php | public function getKeyPair($file = false)
{
$pk = $this->_generatePK();
openssl_pkey_export($pk, $privKey, null, $this->certConfigure);
$pubKey = openssl_pkey_get_details($pk);
$keys = new KeyPair();
$keys->setPrivateKey($privKey)->setPublicKey($pubKey['key']);
if ($file) {
file_put_contents($this->fileName . static::PRIV_KEY_FILENAME , $keys->getPrivateKey());
file_put_contents($this->fileName . static::PUB_KEY_FILENAME , $keys->getPublicKey());
}
return $keys;
} | [
"public",
"function",
"getKeyPair",
"(",
"$",
"file",
"=",
"false",
")",
"{",
"$",
"pk",
"=",
"$",
"this",
"->",
"_generatePK",
"(",
")",
";",
"openssl_pkey_export",
"(",
"$",
"pk",
",",
"$",
"privKey",
",",
"null",
",",
"$",
"this",
"->",
"certConfigure",
")",
";",
"$",
"pubKey",
"=",
"openssl_pkey_get_details",
"(",
"$",
"pk",
")",
";",
"$",
"keys",
"=",
"new",
"KeyPair",
"(",
")",
";",
"$",
"keys",
"->",
"setPrivateKey",
"(",
"$",
"privKey",
")",
"->",
"setPublicKey",
"(",
"$",
"pubKey",
"[",
"'key'",
"]",
")",
";",
"if",
"(",
"$",
"file",
")",
"{",
"file_put_contents",
"(",
"$",
"this",
"->",
"fileName",
".",
"static",
"::",
"PRIV_KEY_FILENAME",
",",
"$",
"keys",
"->",
"getPrivateKey",
"(",
")",
")",
";",
"file_put_contents",
"(",
"$",
"this",
"->",
"fileName",
".",
"static",
"::",
"PUB_KEY_FILENAME",
",",
"$",
"keys",
"->",
"getPublicKey",
"(",
")",
")",
";",
"}",
"return",
"$",
"keys",
";",
"}"
] | Returns key pair | [
"Returns",
"key",
"pair"
] | d67122e240037e6cc31e1c0742911e87cda93a86 | https://github.com/MayMeow/may-encrypt/blob/d67122e240037e6cc31e1c0742911e87cda93a86/src/Factory/CertificateFactory.php#L229-L245 | train |
MayMeow/may-encrypt | src/Factory/CertificateFactory.php | CertificateFactory.setType | public function setType($type, $options = null)
{
$this->type = $type;
$this->_setCertConfigure();
return $this;
} | php | public function setType($type, $options = null)
{
$this->type = $type;
$this->_setCertConfigure();
return $this;
} | [
"public",
"function",
"setType",
"(",
"$",
"type",
",",
"$",
"options",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"type",
"=",
"$",
"type",
";",
"$",
"this",
"->",
"_setCertConfigure",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Sets type of certificate
@param $type
@param null $options
@return $this | [
"Sets",
"type",
"of",
"certificate"
] | d67122e240037e6cc31e1c0742911e87cda93a86 | https://github.com/MayMeow/may-encrypt/blob/d67122e240037e6cc31e1c0742911e87cda93a86/src/Factory/CertificateFactory.php#L276-L282 | train |
MayMeow/may-encrypt | src/Factory/CertificateFactory.php | CertificateFactory.setCa | public function setCa($name = null, $password = null)
{
$this->caName = $name;
$this->caPassword = $password;
return $this;
} | php | public function setCa($name = null, $password = null)
{
$this->caName = $name;
$this->caPassword = $password;
return $this;
} | [
"public",
"function",
"setCa",
"(",
"$",
"name",
"=",
"null",
",",
"$",
"password",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"caName",
"=",
"$",
"name",
";",
"$",
"this",
"->",
"caPassword",
"=",
"$",
"password",
";",
"return",
"$",
"this",
";",
"}"
] | Function SetCa
Functions to set CA name to use for signing certificate
@param null $name
@param null $password
@return $this | [
"Function",
"SetCa",
"Functions",
"to",
"set",
"CA",
"name",
"to",
"use",
"for",
"signing",
"certificate"
] | d67122e240037e6cc31e1c0742911e87cda93a86 | https://github.com/MayMeow/may-encrypt/blob/d67122e240037e6cc31e1c0742911e87cda93a86/src/Factory/CertificateFactory.php#L292-L298 | train |
MayMeow/may-encrypt | src/Factory/CertificateFactory.php | CertificateFactory.setName | public function setName($name = null)
{
$this->fileName = $this->caDataRoot . $name . DS;
// Create folder for future certificate
if(!file_exists($this->fileName))
{
mkdir($this->fileName, 0777, true);
}
return $this;
} | php | public function setName($name = null)
{
$this->fileName = $this->caDataRoot . $name . DS;
// Create folder for future certificate
if(!file_exists($this->fileName))
{
mkdir($this->fileName, 0777, true);
}
return $this;
} | [
"public",
"function",
"setName",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"fileName",
"=",
"$",
"this",
"->",
"caDataRoot",
".",
"$",
"name",
".",
"DS",
";",
"// Create folder for future certificate",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"this",
"->",
"fileName",
")",
")",
"{",
"mkdir",
"(",
"$",
"this",
"->",
"fileName",
",",
"0777",
",",
"true",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Function SetName
Set name of certificate file
@param null $name
@return $this | [
"Function",
"SetName",
"Set",
"name",
"of",
"certificate",
"file"
] | d67122e240037e6cc31e1c0742911e87cda93a86 | https://github.com/MayMeow/may-encrypt/blob/d67122e240037e6cc31e1c0742911e87cda93a86/src/Factory/CertificateFactory.php#L348-L359 | train |
MayMeow/may-encrypt | src/Factory/CertificateFactory.php | CertificateFactory.sign | public function sign()
{
$this->crt = new SignedCertificate();
$this->_altConfiguration();
//print_r($this->altNames);
/*
print_r([
$this->certConfigure, $this->domainName()->get()
]);
*/
$this->crt->setPrivateKey($this->_generatePK());
$privKey = $this->crt->getPrivateKey();
$this->crt->setCsr(openssl_csr_new($this->domainName()->get(), $privKey, $this->certConfigure));
if (!$this->caName == null) {
// If CA name is not null sign certificate with loaded CA certificate
$this->crt->setSignedCert(openssl_csr_sign(
$this->crt->getCsr(), $this->_getCaCert(), $this->_getCaKey(), $this->_getConfig('daysvalid'), $this->certConfigure, time()
));
} else {
/**
* Else self sign certificate
* Its important for ROOT Certification authority certificate
*/
$this->crt->setSignedCert(openssl_csr_sign(
$this->crt->getCsr(), null, $this->crt->getPrivateKey(), $this->_getConfig('daysvalid'), $this->certConfigure, time()
));
}
return $this;
} | php | public function sign()
{
$this->crt = new SignedCertificate();
$this->_altConfiguration();
//print_r($this->altNames);
/*
print_r([
$this->certConfigure, $this->domainName()->get()
]);
*/
$this->crt->setPrivateKey($this->_generatePK());
$privKey = $this->crt->getPrivateKey();
$this->crt->setCsr(openssl_csr_new($this->domainName()->get(), $privKey, $this->certConfigure));
if (!$this->caName == null) {
// If CA name is not null sign certificate with loaded CA certificate
$this->crt->setSignedCert(openssl_csr_sign(
$this->crt->getCsr(), $this->_getCaCert(), $this->_getCaKey(), $this->_getConfig('daysvalid'), $this->certConfigure, time()
));
} else {
/**
* Else self sign certificate
* Its important for ROOT Certification authority certificate
*/
$this->crt->setSignedCert(openssl_csr_sign(
$this->crt->getCsr(), null, $this->crt->getPrivateKey(), $this->_getConfig('daysvalid'), $this->certConfigure, time()
));
}
return $this;
} | [
"public",
"function",
"sign",
"(",
")",
"{",
"$",
"this",
"->",
"crt",
"=",
"new",
"SignedCertificate",
"(",
")",
";",
"$",
"this",
"->",
"_altConfiguration",
"(",
")",
";",
"//print_r($this->altNames);",
"/*\n print_r([\n $this->certConfigure, $this->domainName()->get()\n ]);\n */",
"$",
"this",
"->",
"crt",
"->",
"setPrivateKey",
"(",
"$",
"this",
"->",
"_generatePK",
"(",
")",
")",
";",
"$",
"privKey",
"=",
"$",
"this",
"->",
"crt",
"->",
"getPrivateKey",
"(",
")",
";",
"$",
"this",
"->",
"crt",
"->",
"setCsr",
"(",
"openssl_csr_new",
"(",
"$",
"this",
"->",
"domainName",
"(",
")",
"->",
"get",
"(",
")",
",",
"$",
"privKey",
",",
"$",
"this",
"->",
"certConfigure",
")",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"caName",
"==",
"null",
")",
"{",
"// If CA name is not null sign certificate with loaded CA certificate",
"$",
"this",
"->",
"crt",
"->",
"setSignedCert",
"(",
"openssl_csr_sign",
"(",
"$",
"this",
"->",
"crt",
"->",
"getCsr",
"(",
")",
",",
"$",
"this",
"->",
"_getCaCert",
"(",
")",
",",
"$",
"this",
"->",
"_getCaKey",
"(",
")",
",",
"$",
"this",
"->",
"_getConfig",
"(",
"'daysvalid'",
")",
",",
"$",
"this",
"->",
"certConfigure",
",",
"time",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"/**\n * Else self sign certificate\n * Its important for ROOT Certification authority certificate\n */",
"$",
"this",
"->",
"crt",
"->",
"setSignedCert",
"(",
"openssl_csr_sign",
"(",
"$",
"this",
"->",
"crt",
"->",
"getCsr",
"(",
")",
",",
"null",
",",
"$",
"this",
"->",
"crt",
"->",
"getPrivateKey",
"(",
")",
",",
"$",
"this",
"->",
"_getConfig",
"(",
"'daysvalid'",
")",
",",
"$",
"this",
"->",
"certConfigure",
",",
"time",
"(",
")",
")",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Sign certificate file and export tem to disk | [
"Sign",
"certificate",
"file",
"and",
"export",
"tem",
"to",
"disk"
] | d67122e240037e6cc31e1c0742911e87cda93a86 | https://github.com/MayMeow/may-encrypt/blob/d67122e240037e6cc31e1c0742911e87cda93a86/src/Factory/CertificateFactory.php#L364-L400 | train |
MayMeow/may-encrypt | src/Factory/CertificateFactory.php | CertificateFactory.createRequest | public function createRequest()
{
$this->crt = new SignedCertificate();
$this->crt->setPrivateKey(openssl_pkey_new($this->certConfigure));
$privKey = $this->crt->getPrivateKey();
$this->crt->setCsr(openssl_csr_new($this->domainName()->get(), $privKey, $this->certConfigure));
$request = json_encode([
'csr' => $this->crt->getCsr()
]);
// Send CSR to server and wait for signing
$response = $this->signWithServer($request);
$response = json_decode($response);
$this->crt->setSignedCert(openssl_x509_read($response->certificate));
return $this;
} | php | public function createRequest()
{
$this->crt = new SignedCertificate();
$this->crt->setPrivateKey(openssl_pkey_new($this->certConfigure));
$privKey = $this->crt->getPrivateKey();
$this->crt->setCsr(openssl_csr_new($this->domainName()->get(), $privKey, $this->certConfigure));
$request = json_encode([
'csr' => $this->crt->getCsr()
]);
// Send CSR to server and wait for signing
$response = $this->signWithServer($request);
$response = json_decode($response);
$this->crt->setSignedCert(openssl_x509_read($response->certificate));
return $this;
} | [
"public",
"function",
"createRequest",
"(",
")",
"{",
"$",
"this",
"->",
"crt",
"=",
"new",
"SignedCertificate",
"(",
")",
";",
"$",
"this",
"->",
"crt",
"->",
"setPrivateKey",
"(",
"openssl_pkey_new",
"(",
"$",
"this",
"->",
"certConfigure",
")",
")",
";",
"$",
"privKey",
"=",
"$",
"this",
"->",
"crt",
"->",
"getPrivateKey",
"(",
")",
";",
"$",
"this",
"->",
"crt",
"->",
"setCsr",
"(",
"openssl_csr_new",
"(",
"$",
"this",
"->",
"domainName",
"(",
")",
"->",
"get",
"(",
")",
",",
"$",
"privKey",
",",
"$",
"this",
"->",
"certConfigure",
")",
")",
";",
"$",
"request",
"=",
"json_encode",
"(",
"[",
"'csr'",
"=>",
"$",
"this",
"->",
"crt",
"->",
"getCsr",
"(",
")",
"]",
")",
";",
"// Send CSR to server and wait for signing",
"$",
"response",
"=",
"$",
"this",
"->",
"signWithServer",
"(",
"$",
"request",
")",
";",
"$",
"response",
"=",
"json_decode",
"(",
"$",
"response",
")",
";",
"$",
"this",
"->",
"crt",
"->",
"setSignedCert",
"(",
"openssl_x509_read",
"(",
"$",
"response",
"->",
"certificate",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Create request for server signing
For Client App
@return string | [
"Create",
"request",
"for",
"server",
"signing",
"For",
"Client",
"App"
] | d67122e240037e6cc31e1c0742911e87cda93a86 | https://github.com/MayMeow/may-encrypt/blob/d67122e240037e6cc31e1c0742911e87cda93a86/src/Factory/CertificateFactory.php#L408-L426 | train |
MayMeow/may-encrypt | src/Factory/CertificateFactory.php | CertificateFactory.signWithServer | public function signWithServer($request)
{
//server
$clientRequest = json_decode($request);
$this->crt->setSignedCert(openssl_csr_sign($clientRequest->csr, $this->_getCaCert(), $this->_getCaKey(), $this->_getConfig('daysvalid'), $this->certConfigure, time()));
// return signed file to user
openssl_x509_export($this->crt->getSignedCert(), $clientCertificate);
return json_encode(['certificate' => $clientCertificate]);
} | php | public function signWithServer($request)
{
//server
$clientRequest = json_decode($request);
$this->crt->setSignedCert(openssl_csr_sign($clientRequest->csr, $this->_getCaCert(), $this->_getCaKey(), $this->_getConfig('daysvalid'), $this->certConfigure, time()));
// return signed file to user
openssl_x509_export($this->crt->getSignedCert(), $clientCertificate);
return json_encode(['certificate' => $clientCertificate]);
} | [
"public",
"function",
"signWithServer",
"(",
"$",
"request",
")",
"{",
"//server",
"$",
"clientRequest",
"=",
"json_decode",
"(",
"$",
"request",
")",
";",
"$",
"this",
"->",
"crt",
"->",
"setSignedCert",
"(",
"openssl_csr_sign",
"(",
"$",
"clientRequest",
"->",
"csr",
",",
"$",
"this",
"->",
"_getCaCert",
"(",
")",
",",
"$",
"this",
"->",
"_getCaKey",
"(",
")",
",",
"$",
"this",
"->",
"_getConfig",
"(",
"'daysvalid'",
")",
",",
"$",
"this",
"->",
"certConfigure",
",",
"time",
"(",
")",
")",
")",
";",
"// return signed file to user",
"openssl_x509_export",
"(",
"$",
"this",
"->",
"crt",
"->",
"getSignedCert",
"(",
")",
",",
"$",
"clientCertificate",
")",
";",
"return",
"json_encode",
"(",
"[",
"'certificate'",
"=>",
"$",
"clientCertificate",
"]",
")",
";",
"}"
] | Sign certificate from client request
For Server app
@return $this | [
"Sign",
"certificate",
"from",
"client",
"request",
"For",
"Server",
"app"
] | d67122e240037e6cc31e1c0742911e87cda93a86 | https://github.com/MayMeow/may-encrypt/blob/d67122e240037e6cc31e1c0742911e87cda93a86/src/Factory/CertificateFactory.php#L454-L464 | train |
MayMeow/may-encrypt | src/Factory/CertificateFactory.php | CertificateFactory.getPrivateKey | public function getPrivateKey($caName = null, $caPassword = null)
{
// if password is set
if ($caPassword !== null) {
return [
file_get_contents($this->caDataRoot . $caName . DS . static::PRIV_KEY_FILENAME),
$caPassword
];
}
return file_get_contents($this->caDataRoot . $caName . DS . static::PRIV_KEY_FILENAME);
} | php | public function getPrivateKey($caName = null, $caPassword = null)
{
// if password is set
if ($caPassword !== null) {
return [
file_get_contents($this->caDataRoot . $caName . DS . static::PRIV_KEY_FILENAME),
$caPassword
];
}
return file_get_contents($this->caDataRoot . $caName . DS . static::PRIV_KEY_FILENAME);
} | [
"public",
"function",
"getPrivateKey",
"(",
"$",
"caName",
"=",
"null",
",",
"$",
"caPassword",
"=",
"null",
")",
"{",
"// if password is set",
"if",
"(",
"$",
"caPassword",
"!==",
"null",
")",
"{",
"return",
"[",
"file_get_contents",
"(",
"$",
"this",
"->",
"caDataRoot",
".",
"$",
"caName",
".",
"DS",
".",
"static",
"::",
"PRIV_KEY_FILENAME",
")",
",",
"$",
"caPassword",
"]",
";",
"}",
"return",
"file_get_contents",
"(",
"$",
"this",
"->",
"caDataRoot",
".",
"$",
"caName",
".",
"DS",
".",
"static",
"::",
"PRIV_KEY_FILENAME",
")",
";",
"}"
] | Method getCaKey
Returns array for encrypted keys and string othervise
@param $caName
@param $caPassword
@return array|string | [
"Method",
"getCaKey",
"Returns",
"array",
"for",
"encrypted",
"keys",
"and",
"string",
"othervise"
] | d67122e240037e6cc31e1c0742911e87cda93a86 | https://github.com/MayMeow/may-encrypt/blob/d67122e240037e6cc31e1c0742911e87cda93a86/src/Factory/CertificateFactory.php#L474-L485 | train |
stubbles/stubbles-peer | src/main/php/http/HttpVersion.php | HttpVersion.fromString | public static function fromString($httpVersion): self
{
if (empty($httpVersion)) {
throw new \InvalidArgumentException('Given HTTP version is empty');
}
$major = null;
$minor = null;
if (2 != sscanf($httpVersion, 'HTTP/%d.%d', $major, $minor)) {
throw new \InvalidArgumentException(
'Given HTTP version "' . $httpVersion . '" can not be parsed'
);
}
return new self($major, $minor);
} | php | public static function fromString($httpVersion): self
{
if (empty($httpVersion)) {
throw new \InvalidArgumentException('Given HTTP version is empty');
}
$major = null;
$minor = null;
if (2 != sscanf($httpVersion, 'HTTP/%d.%d', $major, $minor)) {
throw new \InvalidArgumentException(
'Given HTTP version "' . $httpVersion . '" can not be parsed'
);
}
return new self($major, $minor);
} | [
"public",
"static",
"function",
"fromString",
"(",
"$",
"httpVersion",
")",
":",
"self",
"{",
"if",
"(",
"empty",
"(",
"$",
"httpVersion",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Given HTTP version is empty'",
")",
";",
"}",
"$",
"major",
"=",
"null",
";",
"$",
"minor",
"=",
"null",
";",
"if",
"(",
"2",
"!=",
"sscanf",
"(",
"$",
"httpVersion",
",",
"'HTTP/%d.%d'",
",",
"$",
"major",
",",
"$",
"minor",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Given HTTP version \"'",
".",
"$",
"httpVersion",
".",
"'\" can not be parsed'",
")",
";",
"}",
"return",
"new",
"self",
"(",
"$",
"major",
",",
"$",
"minor",
")",
";",
"}"
] | parses http version from given string
@param string $httpVersion a http version string like "HTTP/1.1"
@return HttpVersion
@throws \InvalidArgumentException in case string can not be parsed successfully | [
"parses",
"http",
"version",
"from",
"given",
"string"
] | dc8b0a517dc4c84b615cc3c88f0d64a2b742f9cc | https://github.com/stubbles/stubbles-peer/blob/dc8b0a517dc4c84b615cc3c88f0d64a2b742f9cc/src/main/php/http/HttpVersion.php#L48-L63 | train |
stubbles/stubbles-peer | src/main/php/http/HttpVersion.php | HttpVersion.equals | public function equals($httpVersion): bool
{
if (empty($httpVersion)) {
return false;
}
try {
$other = self::castFrom($httpVersion);
} catch (\InvalidArgumentException $iae) {
return false;
}
return $this->major() === $other->major() && $this->minor() === $other->minor();
} | php | public function equals($httpVersion): bool
{
if (empty($httpVersion)) {
return false;
}
try {
$other = self::castFrom($httpVersion);
} catch (\InvalidArgumentException $iae) {
return false;
}
return $this->major() === $other->major() && $this->minor() === $other->minor();
} | [
"public",
"function",
"equals",
"(",
"$",
"httpVersion",
")",
":",
"bool",
"{",
"if",
"(",
"empty",
"(",
"$",
"httpVersion",
")",
")",
"{",
"return",
"false",
";",
"}",
"try",
"{",
"$",
"other",
"=",
"self",
"::",
"castFrom",
"(",
"$",
"httpVersion",
")",
";",
"}",
"catch",
"(",
"\\",
"InvalidArgumentException",
"$",
"iae",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"this",
"->",
"major",
"(",
")",
"===",
"$",
"other",
"->",
"major",
"(",
")",
"&&",
"$",
"this",
"->",
"minor",
"(",
")",
"===",
"$",
"other",
"->",
"minor",
"(",
")",
";",
"}"
] | checks if given http version is equal to this http version
@param string|\stubbles\peer\http\HttpVersion $httpVersion
@return bool | [
"checks",
"if",
"given",
"http",
"version",
"is",
"equal",
"to",
"this",
"http",
"version"
] | dc8b0a517dc4c84b615cc3c88f0d64a2b742f9cc | https://github.com/stubbles/stubbles-peer/blob/dc8b0a517dc4c84b615cc3c88f0d64a2b742f9cc/src/main/php/http/HttpVersion.php#L151-L164 | train |
yvoyer/collection | lib/Star/Component/Collection/TypedCollection.php | TypedCollection.map | public function map(Closure $func)
{
$this->guardAgainstInvalidGivenType();
$elements = $this->collection->map($func)->toArray();
$newCollection = $this->create();
foreach ($elements as $key => $element) {
try {
$newCollection->set($key, $element);
} catch (InvalidArgumentException $e) {
// do nothing, because the mapped item is not instance of type
}
}
return $newCollection;
} | php | public function map(Closure $func)
{
$this->guardAgainstInvalidGivenType();
$elements = $this->collection->map($func)->toArray();
$newCollection = $this->create();
foreach ($elements as $key => $element) {
try {
$newCollection->set($key, $element);
} catch (InvalidArgumentException $e) {
// do nothing, because the mapped item is not instance of type
}
}
return $newCollection;
} | [
"public",
"function",
"map",
"(",
"Closure",
"$",
"func",
")",
"{",
"$",
"this",
"->",
"guardAgainstInvalidGivenType",
"(",
")",
";",
"$",
"elements",
"=",
"$",
"this",
"->",
"collection",
"->",
"map",
"(",
"$",
"func",
")",
"->",
"toArray",
"(",
")",
";",
"$",
"newCollection",
"=",
"$",
"this",
"->",
"create",
"(",
")",
";",
"foreach",
"(",
"$",
"elements",
"as",
"$",
"key",
"=>",
"$",
"element",
")",
"{",
"try",
"{",
"$",
"newCollection",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"element",
")",
";",
"}",
"catch",
"(",
"InvalidArgumentException",
"$",
"e",
")",
"{",
"// do nothing, because the mapped item is not instance of type",
"}",
"}",
"return",
"$",
"newCollection",
";",
"}"
] | Applies the given public function to each element in the collection and returns
a new collection with the elements returned by the function.
@param Closure $func
@return Collection | [
"Applies",
"the",
"given",
"public",
"function",
"to",
"each",
"element",
"in",
"the",
"collection",
"and",
"returns",
"a",
"new",
"collection",
"with",
"the",
"elements",
"returned",
"by",
"the",
"function",
"."
] | 08babb9996bece44e01aaa4d3b244bf48139c3ea | https://github.com/yvoyer/collection/blob/08babb9996bece44e01aaa4d3b244bf48139c3ea/lib/Star/Component/Collection/TypedCollection.php#L351-L365 | train |
squareproton/Bond | src/Bond/Entity/Types/Hstore.php | Hstore.isSameAs | public function isSameAs( Hstore $compStore )
{
$thisArray = $this->jsonSerialize();
ksort( $thisArray );
$compStore = $compStore->jsonSerialize();
ksort( $compStore );
return json_encode( $thisArray ) == json_encode( $compStore );
} | php | public function isSameAs( Hstore $compStore )
{
$thisArray = $this->jsonSerialize();
ksort( $thisArray );
$compStore = $compStore->jsonSerialize();
ksort( $compStore );
return json_encode( $thisArray ) == json_encode( $compStore );
} | [
"public",
"function",
"isSameAs",
"(",
"Hstore",
"$",
"compStore",
")",
"{",
"$",
"thisArray",
"=",
"$",
"this",
"->",
"jsonSerialize",
"(",
")",
";",
"ksort",
"(",
"$",
"thisArray",
")",
";",
"$",
"compStore",
"=",
"$",
"compStore",
"->",
"jsonSerialize",
"(",
")",
";",
"ksort",
"(",
"$",
"compStore",
")",
";",
"return",
"json_encode",
"(",
"$",
"thisArray",
")",
"==",
"json_encode",
"(",
"$",
"compStore",
")",
";",
"}"
] | Compare two hstores | [
"Compare",
"two",
"hstores"
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Entity/Types/Hstore.php#L67-L78 | train |
squareproton/Bond | src/Bond/Entity/Types/Hstore.php | Hstore.fromStringToArray | private function fromStringToArray( $str )
{
$p = 0;
// Leading spaces.
$c = $this->charAfterSpaces( $str, $p );
if( $c === false ) {
return array();
}
$result = [];
while (true) {
$c = $this->charAfterSpaces($str, $p);
// end of string
if ($c === false) {
break;
}
// next element
if ($c == ',') {
$p++;
continue;
}
// key
$key = $this->readKeyValue($str, $p);
// '=>' sequence.
$this->charAfterSpaces($str, $p);
if (substr($str, $p, 2) != '=>') {
throw new \Exception("Was expecting a `=>` {$str} when passing hstore's value");
}
$p += 2;
$this->charAfterSpaces($str, $p);
// value, null safe
$value = $this->readKeyValue($str, $p);
if (!strcasecmp($value, "null")) {
$result[$key] = null;
} else {
$result[$key] = $value;
}
}
return $result;
} | php | private function fromStringToArray( $str )
{
$p = 0;
// Leading spaces.
$c = $this->charAfterSpaces( $str, $p );
if( $c === false ) {
return array();
}
$result = [];
while (true) {
$c = $this->charAfterSpaces($str, $p);
// end of string
if ($c === false) {
break;
}
// next element
if ($c == ',') {
$p++;
continue;
}
// key
$key = $this->readKeyValue($str, $p);
// '=>' sequence.
$this->charAfterSpaces($str, $p);
if (substr($str, $p, 2) != '=>') {
throw new \Exception("Was expecting a `=>` {$str} when passing hstore's value");
}
$p += 2;
$this->charAfterSpaces($str, $p);
// value, null safe
$value = $this->readKeyValue($str, $p);
if (!strcasecmp($value, "null")) {
$result[$key] = null;
} else {
$result[$key] = $value;
}
}
return $result;
} | [
"private",
"function",
"fromStringToArray",
"(",
"$",
"str",
")",
"{",
"$",
"p",
"=",
"0",
";",
"// Leading spaces.",
"$",
"c",
"=",
"$",
"this",
"->",
"charAfterSpaces",
"(",
"$",
"str",
",",
"$",
"p",
")",
";",
"if",
"(",
"$",
"c",
"===",
"false",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"$",
"result",
"=",
"[",
"]",
";",
"while",
"(",
"true",
")",
"{",
"$",
"c",
"=",
"$",
"this",
"->",
"charAfterSpaces",
"(",
"$",
"str",
",",
"$",
"p",
")",
";",
"// end of string",
"if",
"(",
"$",
"c",
"===",
"false",
")",
"{",
"break",
";",
"}",
"// next element",
"if",
"(",
"$",
"c",
"==",
"','",
")",
"{",
"$",
"p",
"++",
";",
"continue",
";",
"}",
"// key",
"$",
"key",
"=",
"$",
"this",
"->",
"readKeyValue",
"(",
"$",
"str",
",",
"$",
"p",
")",
";",
"// '=>' sequence.",
"$",
"this",
"->",
"charAfterSpaces",
"(",
"$",
"str",
",",
"$",
"p",
")",
";",
"if",
"(",
"substr",
"(",
"$",
"str",
",",
"$",
"p",
",",
"2",
")",
"!=",
"'=>'",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Was expecting a `=>` {$str} when passing hstore's value\"",
")",
";",
"}",
"$",
"p",
"+=",
"2",
";",
"$",
"this",
"->",
"charAfterSpaces",
"(",
"$",
"str",
",",
"$",
"p",
")",
";",
"// value, null safe",
"$",
"value",
"=",
"$",
"this",
"->",
"readKeyValue",
"(",
"$",
"str",
",",
"$",
"p",
")",
";",
"if",
"(",
"!",
"strcasecmp",
"(",
"$",
"value",
",",
"\"null\"",
")",
")",
"{",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"null",
";",
"}",
"else",
"{",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Build a array from a postgres' hstore string representation
@param string
@return array | [
"Build",
"a",
"array",
"from",
"a",
"postgres",
"hstore",
"string",
"representation"
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Entity/Types/Hstore.php#L114-L164 | train |
squareproton/Bond | src/Bond/Entity/Types/Hstore.php | Hstore.readKeyValue | private function readKeyValue($str, &$p)
{
$c = substr($str, $p, 1);
// Unquoted string.
if ($c != '"') {
$len = strcspn($str, " \r\n\t,=>", $p);
$value = substr($str, $p, $len);
$p += $len;
// $value = stripcslashes($value)
$value = str_replace( '\\"', '"', $value );
$value = str_replace( '\\\\', '\\', $value );
return $value;
}
// Quoted string.
$m = null;
if (preg_match('/" ((?' . '>[^"\\\\]+|\\\\.)*) "/Asx', $str, $m, 0, $p)) {
$p += strlen( $m[0] );
// $value = stripcslashes($m[1]);
$value = str_replace( '\\"', '"', $m[1] );
$value = str_replace( '\\\\', '\\', $value );
return $value;
}
// Error.
throw new \Exception( "quoted or unquoted string `{$str}` only" );
} | php | private function readKeyValue($str, &$p)
{
$c = substr($str, $p, 1);
// Unquoted string.
if ($c != '"') {
$len = strcspn($str, " \r\n\t,=>", $p);
$value = substr($str, $p, $len);
$p += $len;
// $value = stripcslashes($value)
$value = str_replace( '\\"', '"', $value );
$value = str_replace( '\\\\', '\\', $value );
return $value;
}
// Quoted string.
$m = null;
if (preg_match('/" ((?' . '>[^"\\\\]+|\\\\.)*) "/Asx', $str, $m, 0, $p)) {
$p += strlen( $m[0] );
// $value = stripcslashes($m[1]);
$value = str_replace( '\\"', '"', $m[1] );
$value = str_replace( '\\\\', '\\', $value );
return $value;
}
// Error.
throw new \Exception( "quoted or unquoted string `{$str}` only" );
} | [
"private",
"function",
"readKeyValue",
"(",
"$",
"str",
",",
"&",
"$",
"p",
")",
"{",
"$",
"c",
"=",
"substr",
"(",
"$",
"str",
",",
"$",
"p",
",",
"1",
")",
";",
"// Unquoted string.",
"if",
"(",
"$",
"c",
"!=",
"'\"'",
")",
"{",
"$",
"len",
"=",
"strcspn",
"(",
"$",
"str",
",",
"\" \\r\\n\\t,=>\"",
",",
"$",
"p",
")",
";",
"$",
"value",
"=",
"substr",
"(",
"$",
"str",
",",
"$",
"p",
",",
"$",
"len",
")",
";",
"$",
"p",
"+=",
"$",
"len",
";",
"// $value = stripcslashes($value)",
"$",
"value",
"=",
"str_replace",
"(",
"'\\\\\"'",
",",
"'\"'",
",",
"$",
"value",
")",
";",
"$",
"value",
"=",
"str_replace",
"(",
"'\\\\\\\\'",
",",
"'\\\\'",
",",
"$",
"value",
")",
";",
"return",
"$",
"value",
";",
"}",
"// Quoted string.",
"$",
"m",
"=",
"null",
";",
"if",
"(",
"preg_match",
"(",
"'/\" ((?'",
".",
"'>[^\"\\\\\\\\]+|\\\\\\\\.)*) \"/Asx'",
",",
"$",
"str",
",",
"$",
"m",
",",
"0",
",",
"$",
"p",
")",
")",
"{",
"$",
"p",
"+=",
"strlen",
"(",
"$",
"m",
"[",
"0",
"]",
")",
";",
"// $value = stripcslashes($m[1]);",
"$",
"value",
"=",
"str_replace",
"(",
"'\\\\\"'",
",",
"'\"'",
",",
"$",
"m",
"[",
"1",
"]",
")",
";",
"$",
"value",
"=",
"str_replace",
"(",
"'\\\\\\\\'",
",",
"'\\\\'",
",",
"$",
"value",
")",
";",
"return",
"$",
"value",
";",
"}",
"// Error.",
"throw",
"new",
"\\",
"Exception",
"(",
"\"quoted or unquoted string `{$str}` only\"",
")",
";",
"}"
] | Read a 'key' or 'value' component from a hstore's string representation
@param string $str
@param int $p
@return string | [
"Read",
"a",
"key",
"or",
"value",
"component",
"from",
"a",
"hstore",
"s",
"string",
"representation"
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Entity/Types/Hstore.php#L188-L217 | train |
Soneritics/Database | Soneritics/Database/Table.php | Table.reloadTableSchema | public function reloadTableSchema()
{
$this->columns = [];
$described = $this->describe()->execute();
while ($column = $described->get()) {
$this->columns[] = $column['COLUMNS']['Field'];
}
return $this;
} | php | public function reloadTableSchema()
{
$this->columns = [];
$described = $this->describe()->execute();
while ($column = $described->get()) {
$this->columns[] = $column['COLUMNS']['Field'];
}
return $this;
} | [
"public",
"function",
"reloadTableSchema",
"(",
")",
"{",
"$",
"this",
"->",
"columns",
"=",
"[",
"]",
";",
"$",
"described",
"=",
"$",
"this",
"->",
"describe",
"(",
")",
"->",
"execute",
"(",
")",
";",
"while",
"(",
"$",
"column",
"=",
"$",
"described",
"->",
"get",
"(",
")",
")",
"{",
"$",
"this",
"->",
"columns",
"[",
"]",
"=",
"$",
"column",
"[",
"'COLUMNS'",
"]",
"[",
"'Field'",
"]",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Reload the table schema.
@return $this | [
"Reload",
"the",
"table",
"schema",
"."
] | 20cb74f2a2ee8d9161d3144b5c061a6da11cd066 | https://github.com/Soneritics/Database/blob/20cb74f2a2ee8d9161d3144b5c061a6da11cd066/Soneritics/Database/Table.php#L182-L192 | train |
Soneritics/Database | Soneritics/Database/Table.php | Table.select | public function select($fields = null)
{
$select = new Select($this);
if ($fields !== null) {
$select->fields($fields);
}
return $select;
} | php | public function select($fields = null)
{
$select = new Select($this);
if ($fields !== null) {
$select->fields($fields);
}
return $select;
} | [
"public",
"function",
"select",
"(",
"$",
"fields",
"=",
"null",
")",
"{",
"$",
"select",
"=",
"new",
"Select",
"(",
"$",
"this",
")",
";",
"if",
"(",
"$",
"fields",
"!==",
"null",
")",
"{",
"$",
"select",
"->",
"fields",
"(",
"$",
"fields",
")",
";",
"}",
"return",
"$",
"select",
";",
"}"
] | Get a select object for the current table.
@param null $fields
@return Select | [
"Get",
"a",
"select",
"object",
"for",
"the",
"current",
"table",
"."
] | 20cb74f2a2ee8d9161d3144b5c061a6da11cd066 | https://github.com/Soneritics/Database/blob/20cb74f2a2ee8d9161d3144b5c061a6da11cd066/Soneritics/Database/Table.php#L222-L231 | train |
Soneritics/Database | Soneritics/Database/Table.php | Table.exists | public function exists()
{
$quotedTable = \Database\DatabaseConnectionFactory::get()->quote($this->getTable());
$record = \Database\DatabaseConnectionFactory::get()->query("show tables like {$quotedTable}");
return !is_a($record, 'Database\DatabaseRecord\EmptyDatabaseRecord') && count($record->all()) > 0;
} | php | public function exists()
{
$quotedTable = \Database\DatabaseConnectionFactory::get()->quote($this->getTable());
$record = \Database\DatabaseConnectionFactory::get()->query("show tables like {$quotedTable}");
return !is_a($record, 'Database\DatabaseRecord\EmptyDatabaseRecord') && count($record->all()) > 0;
} | [
"public",
"function",
"exists",
"(",
")",
"{",
"$",
"quotedTable",
"=",
"\\",
"Database",
"\\",
"DatabaseConnectionFactory",
"::",
"get",
"(",
")",
"->",
"quote",
"(",
"$",
"this",
"->",
"getTable",
"(",
")",
")",
";",
"$",
"record",
"=",
"\\",
"Database",
"\\",
"DatabaseConnectionFactory",
"::",
"get",
"(",
")",
"->",
"query",
"(",
"\"show tables like {$quotedTable}\"",
")",
";",
"return",
"!",
"is_a",
"(",
"$",
"record",
",",
"'Database\\DatabaseRecord\\EmptyDatabaseRecord'",
")",
"&&",
"count",
"(",
"$",
"record",
"->",
"all",
"(",
")",
")",
">",
"0",
";",
"}"
] | Check if the table exists in the database.
@return bool | [
"Check",
"if",
"the",
"table",
"exists",
"in",
"the",
"database",
"."
] | 20cb74f2a2ee8d9161d3144b5c061a6da11cd066 | https://github.com/Soneritics/Database/blob/20cb74f2a2ee8d9161d3144b5c061a6da11cd066/Soneritics/Database/Table.php#L282-L287 | train |
cloudtek/dynamodm | lib/Cloudtek/DynamoDM/Expression/RootExpr.php | RootExpr.put | public function put(array $values = [])
{
$this->qb->setQueryClass(PutItem::class);
foreach ($values as $attributeName => $value) {
$value = $this->value($value);
if ($attributeName !== $this->qb->class->discriminatorAttribute) {
$attribute = $this->attr($attributeName);
$mapping = $attribute->getMapping();
$attributeName = $mapping->attributeName;
$value->setMapping($mapping);
} else {
$value->setMapping(null);
}
$this->put[$attributeName] = $value->getSerialized();
}
return $this->qb;
} | php | public function put(array $values = [])
{
$this->qb->setQueryClass(PutItem::class);
foreach ($values as $attributeName => $value) {
$value = $this->value($value);
if ($attributeName !== $this->qb->class->discriminatorAttribute) {
$attribute = $this->attr($attributeName);
$mapping = $attribute->getMapping();
$attributeName = $mapping->attributeName;
$value->setMapping($mapping);
} else {
$value->setMapping(null);
}
$this->put[$attributeName] = $value->getSerialized();
}
return $this->qb;
} | [
"public",
"function",
"put",
"(",
"array",
"$",
"values",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"qb",
"->",
"setQueryClass",
"(",
"PutItem",
"::",
"class",
")",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"attributeName",
"=>",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"value",
"(",
"$",
"value",
")",
";",
"if",
"(",
"$",
"attributeName",
"!==",
"$",
"this",
"->",
"qb",
"->",
"class",
"->",
"discriminatorAttribute",
")",
"{",
"$",
"attribute",
"=",
"$",
"this",
"->",
"attr",
"(",
"$",
"attributeName",
")",
";",
"$",
"mapping",
"=",
"$",
"attribute",
"->",
"getMapping",
"(",
")",
";",
"$",
"attributeName",
"=",
"$",
"mapping",
"->",
"attributeName",
";",
"$",
"value",
"->",
"setMapping",
"(",
"$",
"mapping",
")",
";",
"}",
"else",
"{",
"$",
"value",
"->",
"setMapping",
"(",
"null",
")",
";",
"}",
"$",
"this",
"->",
"put",
"[",
"$",
"attributeName",
"]",
"=",
"$",
"value",
"->",
"getSerialized",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"qb",
";",
"}"
] | Sets the query operation to 'put' and optionally specifies an array of data
to add to the put command.
@param Value[]|mixed[] $values Indexed by attribute name
@return QueryBuilder | [
"Sets",
"the",
"query",
"operation",
"to",
"put",
"and",
"optionally",
"specifies",
"an",
"array",
"of",
"data",
"to",
"add",
"to",
"the",
"put",
"command",
"."
] | 119d355e2c5cbaef1f867970349b4432f5704fcd | https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Expression/RootExpr.php#L159-L180 | train |
lasallecms/lasallecms-l5-lasallecmsadmin-pkg | src/Http/Controllers/AdminPostController.php | AdminPostController.publishPostEvent | public function publishPostEvent(Request $request) {
// Laravel's Mail::send second "data" param must be an array, not an object.
$post = $this->model->FindOrFail($request->input('postID'))->toArray();
$post['listID'] = $request->input('listID');
$post['eventDescription'] = $request->input('eventDescription');
event(new PublishThePost($post));
$message = "You successfully ".$post['eventDescription']."!";
Session::flash('message', $message);
Session::flash('status_code', 200 );
return Redirect::route('admin.'.$this->model->resource_route_name.'.index');
} | php | public function publishPostEvent(Request $request) {
// Laravel's Mail::send second "data" param must be an array, not an object.
$post = $this->model->FindOrFail($request->input('postID'))->toArray();
$post['listID'] = $request->input('listID');
$post['eventDescription'] = $request->input('eventDescription');
event(new PublishThePost($post));
$message = "You successfully ".$post['eventDescription']."!";
Session::flash('message', $message);
Session::flash('status_code', 200 );
return Redirect::route('admin.'.$this->model->resource_route_name.'.index');
} | [
"public",
"function",
"publishPostEvent",
"(",
"Request",
"$",
"request",
")",
"{",
"// Laravel's Mail::send second \"data\" param must be an array, not an object.",
"$",
"post",
"=",
"$",
"this",
"->",
"model",
"->",
"FindOrFail",
"(",
"$",
"request",
"->",
"input",
"(",
"'postID'",
")",
")",
"->",
"toArray",
"(",
")",
";",
"$",
"post",
"[",
"'listID'",
"]",
"=",
"$",
"request",
"->",
"input",
"(",
"'listID'",
")",
";",
"$",
"post",
"[",
"'eventDescription'",
"]",
"=",
"$",
"request",
"->",
"input",
"(",
"'eventDescription'",
")",
";",
"event",
"(",
"new",
"PublishThePost",
"(",
"$",
"post",
")",
")",
";",
"$",
"message",
"=",
"\"You successfully \"",
".",
"$",
"post",
"[",
"'eventDescription'",
"]",
".",
"\"!\"",
";",
"Session",
"::",
"flash",
"(",
"'message'",
",",
"$",
"message",
")",
";",
"Session",
"::",
"flash",
"(",
"'status_code'",
",",
"200",
")",
";",
"return",
"Redirect",
"::",
"route",
"(",
"'admin.'",
".",
"$",
"this",
"->",
"model",
"->",
"resource_route_name",
".",
"'.index'",
")",
";",
"}"
] | Fire the SendPostToLaSalleCRMemailList event.
This method is called from the confirmation view in the LaSalle List Management package.
@param Request $request
@return mixed | [
"Fire",
"the",
"SendPostToLaSalleCRMemailList",
"event",
"."
] | 5a4b3375e449273a98e84a566bcf60fd2172cb2d | https://github.com/lasallecms/lasallecms-l5-lasallecmsadmin-pkg/blob/5a4b3375e449273a98e84a566bcf60fd2172cb2d/src/Http/Controllers/AdminPostController.php#L90-L104 | train |
PenoaksDev/Milky-Framework | src/Milky/Database/Connection.php | Connection.setFetchMode | public function setFetchMode( $fetchMode, $fetchArgument = null, array $fetchConstructorArgument = [] )
{
$this->fetchMode = $fetchMode;
$this->fetchArgument = $fetchArgument;
$this->fetchConstructorArgument = $fetchConstructorArgument;
} | php | public function setFetchMode( $fetchMode, $fetchArgument = null, array $fetchConstructorArgument = [] )
{
$this->fetchMode = $fetchMode;
$this->fetchArgument = $fetchArgument;
$this->fetchConstructorArgument = $fetchConstructorArgument;
} | [
"public",
"function",
"setFetchMode",
"(",
"$",
"fetchMode",
",",
"$",
"fetchArgument",
"=",
"null",
",",
"array",
"$",
"fetchConstructorArgument",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"fetchMode",
"=",
"$",
"fetchMode",
";",
"$",
"this",
"->",
"fetchArgument",
"=",
"$",
"fetchArgument",
";",
"$",
"this",
"->",
"fetchConstructorArgument",
"=",
"$",
"fetchConstructorArgument",
";",
"}"
] | Set the default fetch mode for the connection, and optional arguments for the given fetch mode.
@param int $fetchMode
@param mixed $fetchArgument
@param array $fetchConstructorArgument
@return int | [
"Set",
"the",
"default",
"fetch",
"mode",
"for",
"the",
"connection",
"and",
"optional",
"arguments",
"for",
"the",
"given",
"fetch",
"mode",
"."
] | 8afd7156610a70371aa5b1df50b8a212bf7b142c | https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Database/Connection.php#L1183-L1188 | train |
libreworks/caridea-validate | src/Validator.php | Validator.access | protected function access($values, string $field)
{
return isset($values[$field]) ? $values[$field] : null;
} | php | protected function access($values, string $field)
{
return isset($values[$field]) ? $values[$field] : null;
} | [
"protected",
"function",
"access",
"(",
"$",
"values",
",",
"string",
"$",
"field",
")",
"{",
"return",
"isset",
"(",
"$",
"values",
"[",
"$",
"field",
"]",
")",
"?",
"$",
"values",
"[",
"$",
"field",
"]",
":",
"null",
";",
"}"
] | Gets a field from the values.
This can be overridden to access by other means (e.g. object properties,
getter methods).
@param mixed $values The values
@param string $field The field to access
@return mixed The accessed value | [
"Gets",
"a",
"field",
"from",
"the",
"values",
"."
] | 625835694d34591bfb1e3b2ce60c2cc28a28d006 | https://github.com/libreworks/caridea-validate/blob/625835694d34591bfb1e3b2ce60c2cc28a28d006/src/Validator.php#L56-L59 | train |
libreworks/caridea-validate | src/Validator.php | Validator.assert | public function assert($values)
{
$errors = $this->iterate($values);
if (!empty($errors)) {
throw new Exception\Invalid($errors);
}
} | php | public function assert($values)
{
$errors = $this->iterate($values);
if (!empty($errors)) {
throw new Exception\Invalid($errors);
}
} | [
"public",
"function",
"assert",
"(",
"$",
"values",
")",
"{",
"$",
"errors",
"=",
"$",
"this",
"->",
"iterate",
"(",
"$",
"values",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"errors",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"Invalid",
"(",
"$",
"errors",
")",
";",
"}",
"}"
] | Validates the provided value, throwing an exception upon failure.
@param object|array $values An object or associative array to validate
@throws \Caridea\Validate\Exception\Invalid if validation fails
@throws \InvalidArgumentException if `$values` is null | [
"Validates",
"the",
"provided",
"value",
"throwing",
"an",
"exception",
"upon",
"failure",
"."
] | 625835694d34591bfb1e3b2ce60c2cc28a28d006 | https://github.com/libreworks/caridea-validate/blob/625835694d34591bfb1e3b2ce60c2cc28a28d006/src/Validator.php#L104-L110 | train |
sil-project/VarietyBundle | src/Entity/Variety.php | Variety.getLatinName | public function getLatinName()
{
if ($this->hasParent() && !$this->latin_name) {
return $this->getParent()->getLatinName();
}
return $this->latin_name;
} | php | public function getLatinName()
{
if ($this->hasParent() && !$this->latin_name) {
return $this->getParent()->getLatinName();
}
return $this->latin_name;
} | [
"public",
"function",
"getLatinName",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasParent",
"(",
")",
"&&",
"!",
"$",
"this",
"->",
"latin_name",
")",
"{",
"return",
"$",
"this",
"->",
"getParent",
"(",
")",
"->",
"getLatinName",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"latin_name",
";",
"}"
] | Get latinName.
@return string | [
"Get",
"latinName",
"."
] | e9508ce13a4bb277d10bdcd925fdb84bc01f453f | https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/Variety.php#L327-L334 | train |
sil-project/VarietyBundle | src/Entity/Variety.php | Variety.getAlias | public function getAlias()
{
if ($this->hasParent() && !$this->alias) {
return $this->getParent()->getAlias();
}
return $this->alias;
} | php | public function getAlias()
{
if ($this->hasParent() && !$this->alias) {
return $this->getParent()->getAlias();
}
return $this->alias;
} | [
"public",
"function",
"getAlias",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasParent",
"(",
")",
"&&",
"!",
"$",
"this",
"->",
"alias",
")",
"{",
"return",
"$",
"this",
"->",
"getParent",
"(",
")",
"->",
"getAlias",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"alias",
";",
"}"
] | Get alias.
@return string | [
"Get",
"alias",
"."
] | e9508ce13a4bb277d10bdcd925fdb84bc01f453f | https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/Variety.php#L379-L386 | train |
sil-project/VarietyBundle | src/Entity/Variety.php | Variety.getLifeCycle | public function getLifeCycle()
{
if ($this->hasParent() && !$this->life_cycle) {
return $this->getParent()->getLifeCycle();
}
if (!$this->life_cycle && $this->getSpecies()) {
return $this->getSpecies()->getLifeCycle();
}
return $this->life_cycle;
} | php | public function getLifeCycle()
{
if ($this->hasParent() && !$this->life_cycle) {
return $this->getParent()->getLifeCycle();
}
if (!$this->life_cycle && $this->getSpecies()) {
return $this->getSpecies()->getLifeCycle();
}
return $this->life_cycle;
} | [
"public",
"function",
"getLifeCycle",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasParent",
"(",
")",
"&&",
"!",
"$",
"this",
"->",
"life_cycle",
")",
"{",
"return",
"$",
"this",
"->",
"getParent",
"(",
")",
"->",
"getLifeCycle",
"(",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"life_cycle",
"&&",
"$",
"this",
"->",
"getSpecies",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getSpecies",
"(",
")",
"->",
"getLifeCycle",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"life_cycle",
";",
"}"
] | Get lifeCycle.
@return string | [
"Get",
"lifeCycle",
"."
] | e9508ce13a4bb277d10bdcd925fdb84bc01f453f | https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/Variety.php#L431-L442 | train |
sil-project/VarietyBundle | src/Entity/Variety.php | Variety.getLegalGerminationRate | public function getLegalGerminationRate()
{
if (!$this->legal_germination_rate && $this->getSpecies()) {
return $this->getSpecies()->getLegalGerminationRate();
}
return $this->legal_germination_rate;
} | php | public function getLegalGerminationRate()
{
if (!$this->legal_germination_rate && $this->getSpecies()) {
return $this->getSpecies()->getLegalGerminationRate();
}
return $this->legal_germination_rate;
} | [
"public",
"function",
"getLegalGerminationRate",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"legal_germination_rate",
"&&",
"$",
"this",
"->",
"getSpecies",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getSpecies",
"(",
")",
"->",
"getLegalGerminationRate",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"legal_germination_rate",
";",
"}"
] | Get legalGerminationRate.
@return int | [
"Get",
"legalGerminationRate",
"."
] | e9508ce13a4bb277d10bdcd925fdb84bc01f453f | https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/Variety.php#L583-L590 | train |
sil-project/VarietyBundle | src/Entity/Variety.php | Variety.setSpecies | public function setSpecies(\Librinfo\VarietiesBundle\Entity\Species $species = null)
{
$this->species = $species;
return $this;
} | php | public function setSpecies(\Librinfo\VarietiesBundle\Entity\Species $species = null)
{
$this->species = $species;
return $this;
} | [
"public",
"function",
"setSpecies",
"(",
"\\",
"Librinfo",
"\\",
"VarietiesBundle",
"\\",
"Entity",
"\\",
"Species",
"$",
"species",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"species",
"=",
"$",
"species",
";",
"return",
"$",
"this",
";",
"}"
] | Set species.
@param \Librinfo\VarietiesBundle\Entity\Species $species
@return Variety | [
"Set",
"species",
"."
] | e9508ce13a4bb277d10bdcd925fdb84bc01f453f | https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/Variety.php#L707-L712 | train |
sil-project/VarietyBundle | src/Entity/Variety.php | Variety.getSpecies | public function getSpecies()
{
if ($this->hasParent() && !$this->species) {
return $this->getParent()->getSpecies();
}
return $this->species;
} | php | public function getSpecies()
{
if ($this->hasParent() && !$this->species) {
return $this->getParent()->getSpecies();
}
return $this->species;
} | [
"public",
"function",
"getSpecies",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasParent",
"(",
")",
"&&",
"!",
"$",
"this",
"->",
"species",
")",
"{",
"return",
"$",
"this",
"->",
"getParent",
"(",
")",
"->",
"getSpecies",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"species",
";",
"}"
] | Get species.
@return \Librinfo\VarietiesBundle\Entity\Species | [
"Get",
"species",
"."
] | e9508ce13a4bb277d10bdcd925fdb84bc01f453f | https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/Variety.php#L719-L726 | train |
sil-project/VarietyBundle | src/Entity/Variety.php | Variety.addPlantCategory | public function addPlantCategory(\Librinfo\VarietiesBundle\Entity\PlantCategory $plantCategory)
{
$this->plant_categories[] = $plantCategory;
return $this;
} | php | public function addPlantCategory(\Librinfo\VarietiesBundle\Entity\PlantCategory $plantCategory)
{
$this->plant_categories[] = $plantCategory;
return $this;
} | [
"public",
"function",
"addPlantCategory",
"(",
"\\",
"Librinfo",
"\\",
"VarietiesBundle",
"\\",
"Entity",
"\\",
"PlantCategory",
"$",
"plantCategory",
")",
"{",
"$",
"this",
"->",
"plant_categories",
"[",
"]",
"=",
"$",
"plantCategory",
";",
"return",
"$",
"this",
";",
"}"
] | Add plantCategory.
@param \Librinfo\VarietiesBundle\Entity\PlantCategory $plantCategory
@return Variety | [
"Add",
"plantCategory",
"."
] | e9508ce13a4bb277d10bdcd925fdb84bc01f453f | https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/Variety.php#L735-L740 | train |
sil-project/VarietyBundle | src/Entity/Variety.php | Variety.removePlantCategory | public function removePlantCategory(\Librinfo\VarietiesBundle\Entity\PlantCategory $plantCategory)
{
return $this->plant_categories->removeElement($plantCategory);
} | php | public function removePlantCategory(\Librinfo\VarietiesBundle\Entity\PlantCategory $plantCategory)
{
return $this->plant_categories->removeElement($plantCategory);
} | [
"public",
"function",
"removePlantCategory",
"(",
"\\",
"Librinfo",
"\\",
"VarietiesBundle",
"\\",
"Entity",
"\\",
"PlantCategory",
"$",
"plantCategory",
")",
"{",
"return",
"$",
"this",
"->",
"plant_categories",
"->",
"removeElement",
"(",
"$",
"plantCategory",
")",
";",
"}"
] | Remove plantCategory.
@param \Librinfo\VarietiesBundle\Entity\PlantCategory $plantCategory
@return bool tRUE if this collection contained the specified element, FALSE otherwise | [
"Remove",
"plantCategory",
"."
] | e9508ce13a4bb277d10bdcd925fdb84bc01f453f | https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/Variety.php#L749-L752 | train |
sil-project/VarietyBundle | src/Entity/Variety.php | Variety.getPlantCategories | public function getPlantCategories()
{
if (!$this->plant_categories && $this->getSpecies()) {
return $this->getSpecies()->getPlantCategories();
}
return $this->plant_categories;
} | php | public function getPlantCategories()
{
if (!$this->plant_categories && $this->getSpecies()) {
return $this->getSpecies()->getPlantCategories();
}
return $this->plant_categories;
} | [
"public",
"function",
"getPlantCategories",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"plant_categories",
"&&",
"$",
"this",
"->",
"getSpecies",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getSpecies",
"(",
")",
"->",
"getPlantCategories",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"plant_categories",
";",
"}"
] | Get plantCategories.
@return \Doctrine\Common\Collections\Collection | [
"Get",
"plantCategories",
"."
] | e9508ce13a4bb277d10bdcd925fdb84bc01f453f | https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/Variety.php#L759-L766 | train |
sil-project/VarietyBundle | src/Entity/Variety.php | Variety.getTkw | public function getTkw()
{
if (!$this->tkw && $this->getSpecies()) {
return $this->getSpecies()->getTkw();
}
return $this->tkw;
} | php | public function getTkw()
{
if (!$this->tkw && $this->getSpecies()) {
return $this->getSpecies()->getTkw();
}
return $this->tkw;
} | [
"public",
"function",
"getTkw",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"tkw",
"&&",
"$",
"this",
"->",
"getSpecies",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getSpecies",
"(",
")",
"->",
"getTkw",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"tkw",
";",
"}"
] | Get tkw.
@return float | [
"Get",
"tkw",
"."
] | e9508ce13a4bb277d10bdcd925fdb84bc01f453f | https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/Variety.php#L867-L874 | train |
sil-project/VarietyBundle | src/Entity/Variety.php | Variety.getSeedLifespan | public function getSeedLifespan()
{
if (!$this->seed_lifespan && $this->getSpecies()) {
return $this->getSpecies()->getSeedLifeSpan();
}
return $this->seed_lifespan;
} | php | public function getSeedLifespan()
{
if (!$this->seed_lifespan && $this->getSpecies()) {
return $this->getSpecies()->getSeedLifeSpan();
}
return $this->seed_lifespan;
} | [
"public",
"function",
"getSeedLifespan",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"seed_lifespan",
"&&",
"$",
"this",
"->",
"getSpecies",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getSpecies",
"(",
")",
"->",
"getSeedLifeSpan",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"seed_lifespan",
";",
"}"
] | Get seedLifespan.
@return int | [
"Get",
"seedLifespan",
"."
] | e9508ce13a4bb277d10bdcd925fdb84bc01f453f | https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/Variety.php#L895-L902 | train |
sil-project/VarietyBundle | src/Entity/Variety.php | Variety.getRaiseDuration | public function getRaiseDuration()
{
if (!$this->raise_duration && $this->getSpecies()) {
return $this->getSpecies()->getRaiseDuration();
}
return $this->raise_duration;
} | php | public function getRaiseDuration()
{
if (!$this->raise_duration && $this->getSpecies()) {
return $this->getSpecies()->getRaiseDuration();
}
return $this->raise_duration;
} | [
"public",
"function",
"getRaiseDuration",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"raise_duration",
"&&",
"$",
"this",
"->",
"getSpecies",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getSpecies",
"(",
")",
"->",
"getRaiseDuration",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"raise_duration",
";",
"}"
] | Get raiseDuration.
@return int | [
"Get",
"raiseDuration",
"."
] | e9508ce13a4bb277d10bdcd925fdb84bc01f453f | https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/Variety.php#L923-L930 | train |
sil-project/VarietyBundle | src/Entity/Variety.php | Variety.setVariety | public function setVariety(\Librinfo\VarietiesBundle\Entity\Variety $variety = null)
{
$this->variety = $variety;
return $this;
} | php | public function setVariety(\Librinfo\VarietiesBundle\Entity\Variety $variety = null)
{
$this->variety = $variety;
return $this;
} | [
"public",
"function",
"setVariety",
"(",
"\\",
"Librinfo",
"\\",
"VarietiesBundle",
"\\",
"Entity",
"\\",
"Variety",
"$",
"variety",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"variety",
"=",
"$",
"variety",
";",
"return",
"$",
"this",
";",
"}"
] | Set variety.
@param \Librinfo\VarietiesBundle\Entity\Variety $variety
@return Strain | [
"Set",
"variety",
"."
] | e9508ce13a4bb277d10bdcd925fdb84bc01f453f | https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/Variety.php#L1155-L1160 | train |
sil-project/VarietyBundle | src/Entity/Variety.php | Variety.addProfessionalDescription | public function addProfessionalDescription(\Librinfo\VarietiesBundle\Entity\VarietyDescriptionProfessional $professionalDescription)
{
$this->professional_descriptions[] = $professionalDescription;
return $this;
} | php | public function addProfessionalDescription(\Librinfo\VarietiesBundle\Entity\VarietyDescriptionProfessional $professionalDescription)
{
$this->professional_descriptions[] = $professionalDescription;
return $this;
} | [
"public",
"function",
"addProfessionalDescription",
"(",
"\\",
"Librinfo",
"\\",
"VarietiesBundle",
"\\",
"Entity",
"\\",
"VarietyDescriptionProfessional",
"$",
"professionalDescription",
")",
"{",
"$",
"this",
"->",
"professional_descriptions",
"[",
"]",
"=",
"$",
"professionalDescription",
";",
"return",
"$",
"this",
";",
"}"
] | Add professionalDescription.
@param \Librinfo\VarietiesBundle\Entity\VarietyDescriptionProfessional $professionalDescription
@return Variety | [
"Add",
"professionalDescription",
"."
] | e9508ce13a4bb277d10bdcd925fdb84bc01f453f | https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/Variety.php#L1179-L1184 | train |
sil-project/VarietyBundle | src/Entity/Variety.php | Variety.removeProfessionalDescription | public function removeProfessionalDescription(\Librinfo\VarietiesBundle\Entity\VarietyDescriptionProfessional $professionalDescription)
{
return $this->professional_descriptions->removeElement($professionalDescription);
} | php | public function removeProfessionalDescription(\Librinfo\VarietiesBundle\Entity\VarietyDescriptionProfessional $professionalDescription)
{
return $this->professional_descriptions->removeElement($professionalDescription);
} | [
"public",
"function",
"removeProfessionalDescription",
"(",
"\\",
"Librinfo",
"\\",
"VarietiesBundle",
"\\",
"Entity",
"\\",
"VarietyDescriptionProfessional",
"$",
"professionalDescription",
")",
"{",
"return",
"$",
"this",
"->",
"professional_descriptions",
"->",
"removeElement",
"(",
"$",
"professionalDescription",
")",
";",
"}"
] | Remove professionalDescription.
@param \Librinfo\VarietiesBundle\Entity\VarietyDescriptionProfessional $professionalDescription
@return bool tRUE if this collection contained the specified element, FALSE otherwise | [
"Remove",
"professionalDescription",
"."
] | e9508ce13a4bb277d10bdcd925fdb84bc01f453f | https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/Variety.php#L1193-L1196 | train |
sil-project/VarietyBundle | src/Entity/Variety.php | Variety.setProfessionalDescriptions | public function setProfessionalDescriptions($descriptions)
{
foreach ($descriptions as $description) {
$description->setVariety($this);
}
$this->professional_descriptions = $descriptions;
return $this;
} | php | public function setProfessionalDescriptions($descriptions)
{
foreach ($descriptions as $description) {
$description->setVariety($this);
}
$this->professional_descriptions = $descriptions;
return $this;
} | [
"public",
"function",
"setProfessionalDescriptions",
"(",
"$",
"descriptions",
")",
"{",
"foreach",
"(",
"$",
"descriptions",
"as",
"$",
"description",
")",
"{",
"$",
"description",
"->",
"setVariety",
"(",
"$",
"this",
")",
";",
"}",
"$",
"this",
"->",
"professional_descriptions",
"=",
"$",
"descriptions",
";",
"return",
"$",
"this",
";",
"}"
] | Set professional descriptions.
@param \Doctrine\Common\Collections\Collection $descriptions
@return Variety | [
"Set",
"professional",
"descriptions",
"."
] | e9508ce13a4bb277d10bdcd925fdb84bc01f453f | https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/Variety.php#L1225-L1233 | train |
sil-project/VarietyBundle | src/Entity/Variety.php | Variety.addAmateurDescription | public function addAmateurDescription(\Librinfo\VarietiesBundle\Entity\VarietyDescriptionAmateur $amateurDescription)
{
$this->amateur_descriptions[] = $amateurDescription;
return $this;
} | php | public function addAmateurDescription(\Librinfo\VarietiesBundle\Entity\VarietyDescriptionAmateur $amateurDescription)
{
$this->amateur_descriptions[] = $amateurDescription;
return $this;
} | [
"public",
"function",
"addAmateurDescription",
"(",
"\\",
"Librinfo",
"\\",
"VarietiesBundle",
"\\",
"Entity",
"\\",
"VarietyDescriptionAmateur",
"$",
"amateurDescription",
")",
"{",
"$",
"this",
"->",
"amateur_descriptions",
"[",
"]",
"=",
"$",
"amateurDescription",
";",
"return",
"$",
"this",
";",
"}"
] | Add amateurDescription.
@param \Librinfo\VarietiesBundle\Entity\VarietyDescriptionAmateur amateurDescription
@return Variety | [
"Add",
"amateurDescription",
"."
] | e9508ce13a4bb277d10bdcd925fdb84bc01f453f | https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/Variety.php#L1242-L1247 | train |
sil-project/VarietyBundle | src/Entity/Variety.php | Variety.removeAmateurDescription | public function removeAmateurDescription(\Librinfo\VarietiesBundle\Entity\VarietyDescriptionAmateur $amateurDescription)
{
return $this->amateur_descriptions->removeElement($amateurDescription);
} | php | public function removeAmateurDescription(\Librinfo\VarietiesBundle\Entity\VarietyDescriptionAmateur $amateurDescription)
{
return $this->amateur_descriptions->removeElement($amateurDescription);
} | [
"public",
"function",
"removeAmateurDescription",
"(",
"\\",
"Librinfo",
"\\",
"VarietiesBundle",
"\\",
"Entity",
"\\",
"VarietyDescriptionAmateur",
"$",
"amateurDescription",
")",
"{",
"return",
"$",
"this",
"->",
"amateur_descriptions",
"->",
"removeElement",
"(",
"$",
"amateurDescription",
")",
";",
"}"
] | Remove amateurDescription.
@param \Librinfo\VarietiesBundle\Entity\VarietyDescriptionAmateur $amateurDescription
@return bool tRUE if this collection contained the specified element, FALSE otherwise | [
"Remove",
"amateurDescription",
"."
] | e9508ce13a4bb277d10bdcd925fdb84bc01f453f | https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/Variety.php#L1256-L1259 | train |
sil-project/VarietyBundle | src/Entity/Variety.php | Variety.setAmateurDescriptions | public function setAmateurDescriptions($descriptions)
{
foreach ($descriptions as $description) {
$description->setVariety($this);
}
$this->amateur_descriptions = $descriptions;
return $this;
} | php | public function setAmateurDescriptions($descriptions)
{
foreach ($descriptions as $description) {
$description->setVariety($this);
}
$this->amateur_descriptions = $descriptions;
return $this;
} | [
"public",
"function",
"setAmateurDescriptions",
"(",
"$",
"descriptions",
")",
"{",
"foreach",
"(",
"$",
"descriptions",
"as",
"$",
"description",
")",
"{",
"$",
"description",
"->",
"setVariety",
"(",
"$",
"this",
")",
";",
"}",
"$",
"this",
"->",
"amateur_descriptions",
"=",
"$",
"descriptions",
";",
"return",
"$",
"this",
";",
"}"
] | Set amateur descriptions.
@param \Doctrine\Common\Collections\Collection $descriptions
@return Variety | [
"Set",
"amateur",
"descriptions",
"."
] | e9508ce13a4bb277d10bdcd925fdb84bc01f453f | https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/Variety.php#L1288-L1296 | train |
sil-project/VarietyBundle | src/Entity/Variety.php | Variety.addProductionDescription | public function addProductionDescription(\Librinfo\VarietiesBundle\Entity\VarietyDescriptionProduction $productionDescription)
{
$this->production_descriptions[] = $productionDescription;
return $this;
} | php | public function addProductionDescription(\Librinfo\VarietiesBundle\Entity\VarietyDescriptionProduction $productionDescription)
{
$this->production_descriptions[] = $productionDescription;
return $this;
} | [
"public",
"function",
"addProductionDescription",
"(",
"\\",
"Librinfo",
"\\",
"VarietiesBundle",
"\\",
"Entity",
"\\",
"VarietyDescriptionProduction",
"$",
"productionDescription",
")",
"{",
"$",
"this",
"->",
"production_descriptions",
"[",
"]",
"=",
"$",
"productionDescription",
";",
"return",
"$",
"this",
";",
"}"
] | Add productionDescription.
@param \Librinfo\VarietiesBundle\Entity\VarietyDescriptionProduction $productionDescription
@return Variety | [
"Add",
"productionDescription",
"."
] | e9508ce13a4bb277d10bdcd925fdb84bc01f453f | https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/Variety.php#L1305-L1310 | train |
sil-project/VarietyBundle | src/Entity/Variety.php | Variety.removeProductionDescription | public function removeProductionDescription(\Librinfo\VarietiesBundle\Entity\VarietyDescriptionProduction $productionDescription)
{
return $this->production_descriptions->removeElement($productionDescription);
} | php | public function removeProductionDescription(\Librinfo\VarietiesBundle\Entity\VarietyDescriptionProduction $productionDescription)
{
return $this->production_descriptions->removeElement($productionDescription);
} | [
"public",
"function",
"removeProductionDescription",
"(",
"\\",
"Librinfo",
"\\",
"VarietiesBundle",
"\\",
"Entity",
"\\",
"VarietyDescriptionProduction",
"$",
"productionDescription",
")",
"{",
"return",
"$",
"this",
"->",
"production_descriptions",
"->",
"removeElement",
"(",
"$",
"productionDescription",
")",
";",
"}"
] | Remove productionDescription.
@param \Librinfo\VarietiesBundle\Entity\VarietyDescriptionProduction $productionDescription
@return bool tRUE if this collection contained the specified element, FALSE otherwise | [
"Remove",
"productionDescription",
"."
] | e9508ce13a4bb277d10bdcd925fdb84bc01f453f | https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/Variety.php#L1319-L1322 | train |
sil-project/VarietyBundle | src/Entity/Variety.php | Variety.setProductionDescriptions | public function setProductionDescriptions($descriptions)
{
foreach ($descriptions as $description) {
$description->setVariety($this);
}
$this->production_descriptions = $descriptions;
return $this;
} | php | public function setProductionDescriptions($descriptions)
{
foreach ($descriptions as $description) {
$description->setVariety($this);
}
$this->production_descriptions = $descriptions;
return $this;
} | [
"public",
"function",
"setProductionDescriptions",
"(",
"$",
"descriptions",
")",
"{",
"foreach",
"(",
"$",
"descriptions",
"as",
"$",
"description",
")",
"{",
"$",
"description",
"->",
"setVariety",
"(",
"$",
"this",
")",
";",
"}",
"$",
"this",
"->",
"production_descriptions",
"=",
"$",
"descriptions",
";",
"return",
"$",
"this",
";",
"}"
] | Set production descriptions.
@param \Doctrine\Common\Collections\Collection $descriptions
@return Variety | [
"Set",
"production",
"descriptions",
"."
] | e9508ce13a4bb277d10bdcd925fdb84bc01f453f | https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/Variety.php#L1351-L1359 | train |
sil-project/VarietyBundle | src/Entity/Variety.php | Variety.addCommercialDescription | public function addCommercialDescription(\Librinfo\VarietiesBundle\Entity\VarietyDescriptionCommercial $commercialDescription)
{
$this->commercial_descriptions[] = $commercialDescription;
return $this;
} | php | public function addCommercialDescription(\Librinfo\VarietiesBundle\Entity\VarietyDescriptionCommercial $commercialDescription)
{
$this->commercial_descriptions[] = $commercialDescription;
return $this;
} | [
"public",
"function",
"addCommercialDescription",
"(",
"\\",
"Librinfo",
"\\",
"VarietiesBundle",
"\\",
"Entity",
"\\",
"VarietyDescriptionCommercial",
"$",
"commercialDescription",
")",
"{",
"$",
"this",
"->",
"commercial_descriptions",
"[",
"]",
"=",
"$",
"commercialDescription",
";",
"return",
"$",
"this",
";",
"}"
] | Add commercialDescription.
@param \Librinfo\VarietiesBundle\Entity\VarietyDescriptionCommercial $commercialDescription
@return Variety | [
"Add",
"commercialDescription",
"."
] | e9508ce13a4bb277d10bdcd925fdb84bc01f453f | https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/Variety.php#L1368-L1373 | train |
sil-project/VarietyBundle | src/Entity/Variety.php | Variety.removeCommercialDescription | public function removeCommercialDescription(\Librinfo\VarietiesBundle\Entity\VarietyDescriptionCommercial $commercialDescription)
{
return $this->commercial_descriptions->removeElement($commercialDescription);
} | php | public function removeCommercialDescription(\Librinfo\VarietiesBundle\Entity\VarietyDescriptionCommercial $commercialDescription)
{
return $this->commercial_descriptions->removeElement($commercialDescription);
} | [
"public",
"function",
"removeCommercialDescription",
"(",
"\\",
"Librinfo",
"\\",
"VarietiesBundle",
"\\",
"Entity",
"\\",
"VarietyDescriptionCommercial",
"$",
"commercialDescription",
")",
"{",
"return",
"$",
"this",
"->",
"commercial_descriptions",
"->",
"removeElement",
"(",
"$",
"commercialDescription",
")",
";",
"}"
] | Remove commercialDescription.
@param \Librinfo\VarietiesBundle\Entity\VarietyDescriptionCommercial $commercialDescription
@return bool tRUE if this collection contained the specified element, FALSE otherwise | [
"Remove",
"commercialDescription",
"."
] | e9508ce13a4bb277d10bdcd925fdb84bc01f453f | https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/Variety.php#L1382-L1385 | train |
sil-project/VarietyBundle | src/Entity/Variety.php | Variety.setCommercialDescriptions | public function setCommercialDescriptions($descriptions)
{
foreach ($descriptions as $description) {
$description->setVariety($this);
}
$this->commercial_descriptions = $descriptions;
return $this;
} | php | public function setCommercialDescriptions($descriptions)
{
foreach ($descriptions as $description) {
$description->setVariety($this);
}
$this->commercial_descriptions = $descriptions;
return $this;
} | [
"public",
"function",
"setCommercialDescriptions",
"(",
"$",
"descriptions",
")",
"{",
"foreach",
"(",
"$",
"descriptions",
"as",
"$",
"description",
")",
"{",
"$",
"description",
"->",
"setVariety",
"(",
"$",
"this",
")",
";",
"}",
"$",
"this",
"->",
"commercial_descriptions",
"=",
"$",
"descriptions",
";",
"return",
"$",
"this",
";",
"}"
] | Set commercial descriptions.
@param \Doctrine\Common\Collections\Collection $descriptions
@return Variety | [
"Set",
"commercial",
"descriptions",
"."
] | e9508ce13a4bb277d10bdcd925fdb84bc01f453f | https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/Variety.php#L1414-L1422 | train |
sil-project/VarietyBundle | src/Entity/Variety.php | Variety.addPlantDescription | public function addPlantDescription(\Librinfo\VarietiesBundle\Entity\VarietyDescriptionPlant $plantDescription)
{
$this->plant_descriptions[] = $plantDescription;
return $this;
} | php | public function addPlantDescription(\Librinfo\VarietiesBundle\Entity\VarietyDescriptionPlant $plantDescription)
{
$this->plant_descriptions[] = $plantDescription;
return $this;
} | [
"public",
"function",
"addPlantDescription",
"(",
"\\",
"Librinfo",
"\\",
"VarietiesBundle",
"\\",
"Entity",
"\\",
"VarietyDescriptionPlant",
"$",
"plantDescription",
")",
"{",
"$",
"this",
"->",
"plant_descriptions",
"[",
"]",
"=",
"$",
"plantDescription",
";",
"return",
"$",
"this",
";",
"}"
] | Add plantDescription.
@param \Librinfo\VarietiesBundle\Entity\VarietyDescriptionPlant $plantDescription
@return Variety | [
"Add",
"plantDescription",
"."
] | e9508ce13a4bb277d10bdcd925fdb84bc01f453f | https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/Variety.php#L1431-L1436 | train |
sil-project/VarietyBundle | src/Entity/Variety.php | Variety.removePlantDescription | public function removePlantDescription(\Librinfo\VarietiesBundle\Entity\VarietyDescriptionPlant $plantDescription)
{
return $this->plant_descriptions->removeElement($plantDescription);
} | php | public function removePlantDescription(\Librinfo\VarietiesBundle\Entity\VarietyDescriptionPlant $plantDescription)
{
return $this->plant_descriptions->removeElement($plantDescription);
} | [
"public",
"function",
"removePlantDescription",
"(",
"\\",
"Librinfo",
"\\",
"VarietiesBundle",
"\\",
"Entity",
"\\",
"VarietyDescriptionPlant",
"$",
"plantDescription",
")",
"{",
"return",
"$",
"this",
"->",
"plant_descriptions",
"->",
"removeElement",
"(",
"$",
"plantDescription",
")",
";",
"}"
] | Remove plantDescription.
@param \Librinfo\VarietiesBundle\Entity\VarietyDescriptionPlant $plantDescription
@return bool tRUE if this collection contained the specified element, FALSE otherwise | [
"Remove",
"plantDescription",
"."
] | e9508ce13a4bb277d10bdcd925fdb84bc01f453f | https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/Variety.php#L1445-L1448 | train |
sil-project/VarietyBundle | src/Entity/Variety.php | Variety.setPlantDescriptions | public function setPlantDescriptions($descriptions)
{
foreach ($descriptions as $description) {
$description->setVariety($this);
}
$this->plant_descriptions = $descriptions;
return $this;
} | php | public function setPlantDescriptions($descriptions)
{
foreach ($descriptions as $description) {
$description->setVariety($this);
}
$this->plant_descriptions = $descriptions;
return $this;
} | [
"public",
"function",
"setPlantDescriptions",
"(",
"$",
"descriptions",
")",
"{",
"foreach",
"(",
"$",
"descriptions",
"as",
"$",
"description",
")",
"{",
"$",
"description",
"->",
"setVariety",
"(",
"$",
"this",
")",
";",
"}",
"$",
"this",
"->",
"plant_descriptions",
"=",
"$",
"descriptions",
";",
"return",
"$",
"this",
";",
"}"
] | Set plant descriptions.
@param \Doctrine\Common\Collections\Collection $descriptions
@return Variety | [
"Set",
"plant",
"descriptions",
"."
] | e9508ce13a4bb277d10bdcd925fdb84bc01f453f | https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/Variety.php#L1477-L1485 | train |
sil-project/VarietyBundle | src/Entity/Variety.php | Variety.addCultureDescription | public function addCultureDescription(\Librinfo\VarietiesBundle\Entity\VarietyDescriptionCulture $cultureDescription)
{
$this->culture_descriptions[] = $cultureDescription;
return $this;
} | php | public function addCultureDescription(\Librinfo\VarietiesBundle\Entity\VarietyDescriptionCulture $cultureDescription)
{
$this->culture_descriptions[] = $cultureDescription;
return $this;
} | [
"public",
"function",
"addCultureDescription",
"(",
"\\",
"Librinfo",
"\\",
"VarietiesBundle",
"\\",
"Entity",
"\\",
"VarietyDescriptionCulture",
"$",
"cultureDescription",
")",
"{",
"$",
"this",
"->",
"culture_descriptions",
"[",
"]",
"=",
"$",
"cultureDescription",
";",
"return",
"$",
"this",
";",
"}"
] | Add cultureDescription.
@param \Librinfo\VarietiesBundle\Entity\VarietyDescriptionCulture $cultureDescription
@return Variety | [
"Add",
"cultureDescription",
"."
] | e9508ce13a4bb277d10bdcd925fdb84bc01f453f | https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/Variety.php#L1494-L1499 | train |
sil-project/VarietyBundle | src/Entity/Variety.php | Variety.removeCultureDescription | public function removeCultureDescription(\Librinfo\VarietiesBundle\Entity\VarietyDescriptionCulture $cultureDescription)
{
return $this->culture_descriptions->removeElement($cultureDescription);
} | php | public function removeCultureDescription(\Librinfo\VarietiesBundle\Entity\VarietyDescriptionCulture $cultureDescription)
{
return $this->culture_descriptions->removeElement($cultureDescription);
} | [
"public",
"function",
"removeCultureDescription",
"(",
"\\",
"Librinfo",
"\\",
"VarietiesBundle",
"\\",
"Entity",
"\\",
"VarietyDescriptionCulture",
"$",
"cultureDescription",
")",
"{",
"return",
"$",
"this",
"->",
"culture_descriptions",
"->",
"removeElement",
"(",
"$",
"cultureDescription",
")",
";",
"}"
] | Remove cultureDescription.
@param \Librinfo\VarietiesBundle\Entity\VarietyDescriptionCulture $cultureDescription
@return bool tRUE if this collection contained the specified element, FALSE otherwise | [
"Remove",
"cultureDescription",
"."
] | e9508ce13a4bb277d10bdcd925fdb84bc01f453f | https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/Variety.php#L1508-L1511 | train |
sil-project/VarietyBundle | src/Entity/Variety.php | Variety.setCultureDescriptions | public function setCultureDescriptions($descriptions)
{
foreach ($descriptions as $description) {
$description->setVariety($this);
}
$this->culture_descriptions = $descriptions;
return $this;
} | php | public function setCultureDescriptions($descriptions)
{
foreach ($descriptions as $description) {
$description->setVariety($this);
}
$this->culture_descriptions = $descriptions;
return $this;
} | [
"public",
"function",
"setCultureDescriptions",
"(",
"$",
"descriptions",
")",
"{",
"foreach",
"(",
"$",
"descriptions",
"as",
"$",
"description",
")",
"{",
"$",
"description",
"->",
"setVariety",
"(",
"$",
"this",
")",
";",
"}",
"$",
"this",
"->",
"culture_descriptions",
"=",
"$",
"descriptions",
";",
"return",
"$",
"this",
";",
"}"
] | Set culture descriptions.
@param \Doctrine\Common\Collections\Collection $descriptions
@return Variety | [
"Set",
"culture",
"descriptions",
"."
] | e9508ce13a4bb277d10bdcd925fdb84bc01f453f | https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/Variety.php#L1540-L1548 | train |
sil-project/VarietyBundle | src/Entity/Variety.php | Variety.addInnerDescription | public function addInnerDescription(\Librinfo\VarietiesBundle\Entity\VarietyDescriptionInner $innerDescription)
{
$this->inner_descriptions[] = $innerDescription;
return $this;
} | php | public function addInnerDescription(\Librinfo\VarietiesBundle\Entity\VarietyDescriptionInner $innerDescription)
{
$this->inner_descriptions[] = $innerDescription;
return $this;
} | [
"public",
"function",
"addInnerDescription",
"(",
"\\",
"Librinfo",
"\\",
"VarietiesBundle",
"\\",
"Entity",
"\\",
"VarietyDescriptionInner",
"$",
"innerDescription",
")",
"{",
"$",
"this",
"->",
"inner_descriptions",
"[",
"]",
"=",
"$",
"innerDescription",
";",
"return",
"$",
"this",
";",
"}"
] | Add innerDescription.
@param \Librinfo\VarietiesBundle\Entity\VarietyDescriptionInner $innerDescription
@return Variety | [
"Add",
"innerDescription",
"."
] | e9508ce13a4bb277d10bdcd925fdb84bc01f453f | https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/Variety.php#L1557-L1562 | train |
sil-project/VarietyBundle | src/Entity/Variety.php | Variety.removeInnerDescription | public function removeInnerDescription(\Librinfo\VarietiesBundle\Entity\VarietyDescriptionInner $innerDescription)
{
return $this->inner_descriptions->removeElement($innerDescription);
} | php | public function removeInnerDescription(\Librinfo\VarietiesBundle\Entity\VarietyDescriptionInner $innerDescription)
{
return $this->inner_descriptions->removeElement($innerDescription);
} | [
"public",
"function",
"removeInnerDescription",
"(",
"\\",
"Librinfo",
"\\",
"VarietiesBundle",
"\\",
"Entity",
"\\",
"VarietyDescriptionInner",
"$",
"innerDescription",
")",
"{",
"return",
"$",
"this",
"->",
"inner_descriptions",
"->",
"removeElement",
"(",
"$",
"innerDescription",
")",
";",
"}"
] | Remove innerDescription.
@param \Librinfo\VarietiesBundle\Entity\VarietyDescriptionInner $innerDescription
@return bool tRUE if this collection contained the specified element, FALSE otherwise | [
"Remove",
"innerDescription",
"."
] | e9508ce13a4bb277d10bdcd925fdb84bc01f453f | https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/Variety.php#L1571-L1574 | train |
modulusphp/http | Controller.php | Controller.search | public function search(string $model, array $fields) : ?array
{
$response = array();
foreach($fields as $param => $value) {
$check = $model::where($param, $value)->first();
if ($check != null) {
$response = array_merge($response, array($param => "The $param has already been taken."));
}
}
return $response;
} | php | public function search(string $model, array $fields) : ?array
{
$response = array();
foreach($fields as $param => $value) {
$check = $model::where($param, $value)->first();
if ($check != null) {
$response = array_merge($response, array($param => "The $param has already been taken."));
}
}
return $response;
} | [
"public",
"function",
"search",
"(",
"string",
"$",
"model",
",",
"array",
"$",
"fields",
")",
":",
"?",
"array",
"{",
"$",
"response",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"param",
"=>",
"$",
"value",
")",
"{",
"$",
"check",
"=",
"$",
"model",
"::",
"where",
"(",
"$",
"param",
",",
"$",
"value",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"$",
"check",
"!=",
"null",
")",
"{",
"$",
"response",
"=",
"array_merge",
"(",
"$",
"response",
",",
"array",
"(",
"$",
"param",
"=>",
"\"The $param has already been taken.\"",
")",
")",
";",
"}",
"}",
"return",
"$",
"response",
";",
"}"
] | Check if a model value has already been used or not
@param Eloquent $model
@param array $fields
@return array $response | [
"Check",
"if",
"a",
"model",
"value",
"has",
"already",
"been",
"used",
"or",
"not"
] | fc5c0f2b582a04de1685578d3fb790686a0a240c | https://github.com/modulusphp/http/blob/fc5c0f2b582a04de1685578d3fb790686a0a240c/Controller.php#L49-L61 | train |
lwiesel/FeatureChecker | src/FeatureChecker.php | FeatureChecker.isFeatureEnabled | public function isFeatureEnabled($featureName)
{
try {
$path = preg_split('/\./', $featureName);
$foundValue = $this->findValueInMultiArray($path, $this->features);
if (is_array($foundValue)) {
return $this->checkEveryChild($foundValue);
} else {
return $foundValue;
}
} catch (\OutOfRangeException $e) {
throw new FeatureNotDefinedException($featureName);
}
} | php | public function isFeatureEnabled($featureName)
{
try {
$path = preg_split('/\./', $featureName);
$foundValue = $this->findValueInMultiArray($path, $this->features);
if (is_array($foundValue)) {
return $this->checkEveryChild($foundValue);
} else {
return $foundValue;
}
} catch (\OutOfRangeException $e) {
throw new FeatureNotDefinedException($featureName);
}
} | [
"public",
"function",
"isFeatureEnabled",
"(",
"$",
"featureName",
")",
"{",
"try",
"{",
"$",
"path",
"=",
"preg_split",
"(",
"'/\\./'",
",",
"$",
"featureName",
")",
";",
"$",
"foundValue",
"=",
"$",
"this",
"->",
"findValueInMultiArray",
"(",
"$",
"path",
",",
"$",
"this",
"->",
"features",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"foundValue",
")",
")",
"{",
"return",
"$",
"this",
"->",
"checkEveryChild",
"(",
"$",
"foundValue",
")",
";",
"}",
"else",
"{",
"return",
"$",
"foundValue",
";",
"}",
"}",
"catch",
"(",
"\\",
"OutOfRangeException",
"$",
"e",
")",
"{",
"throw",
"new",
"FeatureNotDefinedException",
"(",
"$",
"featureName",
")",
";",
"}",
"}"
] | Tests if given feature is enabled
@param string $featureName
@return bool
@throws FeatureNotDefinedException | [
"Tests",
"if",
"given",
"feature",
"is",
"enabled"
] | 90aec8f267417922e452759ca5dbf5ceb6ab6898 | https://github.com/lwiesel/FeatureChecker/blob/90aec8f267417922e452759ca5dbf5ceb6ab6898/src/FeatureChecker.php#L33-L48 | train |
lwiesel/FeatureChecker | src/FeatureChecker.php | FeatureChecker.findValueInMultiArray | protected function findValueInMultiArray(array $path, array $reference)
{
// Checks path existence
if (
count($path) == 0
|| !isset($reference[$path[0]])
) {
throw new \OutOfRangeException();
}
$currentElement = $reference[$path[0]];
if (!isset($path[1])) {
return $currentElement;
} else if (is_array($currentElement)) {
return $this->findValueInMultiArray(array_slice($path, 1), $currentElement);
} else {
throw new \OutOfRangeException();
}
} | php | protected function findValueInMultiArray(array $path, array $reference)
{
// Checks path existence
if (
count($path) == 0
|| !isset($reference[$path[0]])
) {
throw new \OutOfRangeException();
}
$currentElement = $reference[$path[0]];
if (!isset($path[1])) {
return $currentElement;
} else if (is_array($currentElement)) {
return $this->findValueInMultiArray(array_slice($path, 1), $currentElement);
} else {
throw new \OutOfRangeException();
}
} | [
"protected",
"function",
"findValueInMultiArray",
"(",
"array",
"$",
"path",
",",
"array",
"$",
"reference",
")",
"{",
"// Checks path existence",
"if",
"(",
"count",
"(",
"$",
"path",
")",
"==",
"0",
"||",
"!",
"isset",
"(",
"$",
"reference",
"[",
"$",
"path",
"[",
"0",
"]",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"OutOfRangeException",
"(",
")",
";",
"}",
"$",
"currentElement",
"=",
"$",
"reference",
"[",
"$",
"path",
"[",
"0",
"]",
"]",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"path",
"[",
"1",
"]",
")",
")",
"{",
"return",
"$",
"currentElement",
";",
"}",
"else",
"if",
"(",
"is_array",
"(",
"$",
"currentElement",
")",
")",
"{",
"return",
"$",
"this",
"->",
"findValueInMultiArray",
"(",
"array_slice",
"(",
"$",
"path",
",",
"1",
")",
",",
"$",
"currentElement",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"OutOfRangeException",
"(",
")",
";",
"}",
"}"
] | Find value in a multi-array
Recursively find a value in a multi-array, successively
following the different keys defined in a path.
@param array $path
@param array $reference
@return bool
@throws \OutOfRangeException | [
"Find",
"value",
"in",
"a",
"multi",
"-",
"array"
] | 90aec8f267417922e452759ca5dbf5ceb6ab6898 | https://github.com/lwiesel/FeatureChecker/blob/90aec8f267417922e452759ca5dbf5ceb6ab6898/src/FeatureChecker.php#L96-L115 | train |
lwiesel/FeatureChecker | src/FeatureChecker.php | FeatureChecker.checkEveryChild | protected function checkEveryChild(array $features)
{
foreach ($features as $feature) {
$result = is_array($feature) ? $this->checkEveryChild($feature) : $feature;
if (!$result) {
return false;
}
}
return true;
} | php | protected function checkEveryChild(array $features)
{
foreach ($features as $feature) {
$result = is_array($feature) ? $this->checkEveryChild($feature) : $feature;
if (!$result) {
return false;
}
}
return true;
} | [
"protected",
"function",
"checkEveryChild",
"(",
"array",
"$",
"features",
")",
"{",
"foreach",
"(",
"$",
"features",
"as",
"$",
"feature",
")",
"{",
"$",
"result",
"=",
"is_array",
"(",
"$",
"feature",
")",
"?",
"$",
"this",
"->",
"checkEveryChild",
"(",
"$",
"feature",
")",
":",
"$",
"feature",
";",
"if",
"(",
"!",
"$",
"result",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Checks every child of the array
Returns true if every child and sub-child is true
@param array $features
@return bool | [
"Checks",
"every",
"child",
"of",
"the",
"array"
] | 90aec8f267417922e452759ca5dbf5ceb6ab6898 | https://github.com/lwiesel/FeatureChecker/blob/90aec8f267417922e452759ca5dbf5ceb6ab6898/src/FeatureChecker.php#L125-L136 | train |
jabernardo/lollipop-php | Library/DOM/Tag.php | Tag.add | public function add($key, $val) {
if (!isset($this->_attrs[$key])) {
$this->_attrs[$key] = [];
}
if (!strcasecmp($key, 'id')) {
// value for `id` should be one only
$this->_attrs[$key] = $val;
} else {
// else append it
array_push($this->_attrs[$key], $val);
}
return $this;
} | php | public function add($key, $val) {
if (!isset($this->_attrs[$key])) {
$this->_attrs[$key] = [];
}
if (!strcasecmp($key, 'id')) {
// value for `id` should be one only
$this->_attrs[$key] = $val;
} else {
// else append it
array_push($this->_attrs[$key], $val);
}
return $this;
} | [
"public",
"function",
"add",
"(",
"$",
"key",
",",
"$",
"val",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_attrs",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"this",
"->",
"_attrs",
"[",
"$",
"key",
"]",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"!",
"strcasecmp",
"(",
"$",
"key",
",",
"'id'",
")",
")",
"{",
"// value for `id` should be one only",
"$",
"this",
"->",
"_attrs",
"[",
"$",
"key",
"]",
"=",
"$",
"val",
";",
"}",
"else",
"{",
"// else append it",
"array_push",
"(",
"$",
"this",
"->",
"_attrs",
"[",
"$",
"key",
"]",
",",
"$",
"val",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Add attribute to tag
@access public
@param string $key Attribute
@param string $val Attribute value
@return object Tag instance | [
"Add",
"attribute",
"to",
"tag"
] | 004d80b21f7246bb3e08c7b9f74a165b0d3ca0f5 | https://github.com/jabernardo/lollipop-php/blob/004d80b21f7246bb3e08c7b9f74a165b0d3ca0f5/Library/DOM/Tag.php#L70-L84 | train |
jabernardo/lollipop-php | Library/DOM/Tag.php | Tag.remove | public function remove($key) {
if (isset($this->_attrs[$key])) {
unset($this->_attrs[$key]);
}
return $this;
} | php | public function remove($key) {
if (isset($this->_attrs[$key])) {
unset($this->_attrs[$key]);
}
return $this;
} | [
"public",
"function",
"remove",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_attrs",
"[",
"$",
"key",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"_attrs",
"[",
"$",
"key",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Remove tag attribute
@access public
@param string $key
@return object Tag instance | [
"Remove",
"tag",
"attribute"
] | 004d80b21f7246bb3e08c7b9f74a165b0d3ca0f5 | https://github.com/jabernardo/lollipop-php/blob/004d80b21f7246bb3e08c7b9f74a165b0d3ca0f5/Library/DOM/Tag.php#L94-L100 | train |
jabernardo/lollipop-php | Library/DOM/Tag.php | Tag.contains | public function contains($data, $append = true) {
$this->_content = $append ? $this->_content . $data : $data;
return $this;
} | php | public function contains($data, $append = true) {
$this->_content = $append ? $this->_content . $data : $data;
return $this;
} | [
"public",
"function",
"contains",
"(",
"$",
"data",
",",
"$",
"append",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"_content",
"=",
"$",
"append",
"?",
"$",
"this",
"->",
"_content",
".",
"$",
"data",
":",
"$",
"data",
";",
"return",
"$",
"this",
";",
"}"
] | Set contents of tag
@access public
@param string $data Contents
@param bool $append Append or set tag content. (default true)
@return object Tag instance | [
"Set",
"contents",
"of",
"tag"
] | 004d80b21f7246bb3e08c7b9f74a165b0d3ca0f5 | https://github.com/jabernardo/lollipop-php/blob/004d80b21f7246bb3e08c7b9f74a165b0d3ca0f5/Library/DOM/Tag.php#L111-L115 | train |
jabernardo/lollipop-php | Library/HTTP/Response.php | Response._format | private function _format($data) {
$output_callback_function = '';
// If data is in array format then set content-type
// to application/json
if (is_array($data) || is_object($data)) {
$this->header('Content-type: application/json');
// Convert to json
$output_callback_function = json_encode($data);
} else {
// Default
$output_callback_function = $data;
}
$output = $output_callback_function;
// GZIP output compression
if ($this->_compress) {
// Set Content coding a gzip
$this->header('Content-Encoding: gzip');
// Set headers for gzip
$output = "\x1f\x8b\x08\x00\x00\x00\x00\x00";
$output .= gzcompress($output_callback_function);
}
return $output;
} | php | private function _format($data) {
$output_callback_function = '';
// If data is in array format then set content-type
// to application/json
if (is_array($data) || is_object($data)) {
$this->header('Content-type: application/json');
// Convert to json
$output_callback_function = json_encode($data);
} else {
// Default
$output_callback_function = $data;
}
$output = $output_callback_function;
// GZIP output compression
if ($this->_compress) {
// Set Content coding a gzip
$this->header('Content-Encoding: gzip');
// Set headers for gzip
$output = "\x1f\x8b\x08\x00\x00\x00\x00\x00";
$output .= gzcompress($output_callback_function);
}
return $output;
} | [
"private",
"function",
"_format",
"(",
"$",
"data",
")",
"{",
"$",
"output_callback_function",
"=",
"''",
";",
"// If data is in array format then set content-type",
"// to application/json",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
"||",
"is_object",
"(",
"$",
"data",
")",
")",
"{",
"$",
"this",
"->",
"header",
"(",
"'Content-type: application/json'",
")",
";",
"// Convert to json",
"$",
"output_callback_function",
"=",
"json_encode",
"(",
"$",
"data",
")",
";",
"}",
"else",
"{",
"// Default",
"$",
"output_callback_function",
"=",
"$",
"data",
";",
"}",
"$",
"output",
"=",
"$",
"output_callback_function",
";",
"// GZIP output compression",
"if",
"(",
"$",
"this",
"->",
"_compress",
")",
"{",
"// Set Content coding a gzip",
"$",
"this",
"->",
"header",
"(",
"'Content-Encoding: gzip'",
")",
";",
"// Set headers for gzip",
"$",
"output",
"=",
"\"\\x1f\\x8b\\x08\\x00\\x00\\x00\\x00\\x00\"",
";",
"$",
"output",
".=",
"gzcompress",
"(",
"$",
"output_callback_function",
")",
";",
"}",
"return",
"$",
"output",
";",
"}"
] | Return string value for data
@access private
@param object $data Data to convert
@return string | [
"Return",
"string",
"value",
"for",
"data"
] | 004d80b21f7246bb3e08c7b9f74a165b0d3ca0f5 | https://github.com/jabernardo/lollipop-php/blob/004d80b21f7246bb3e08c7b9f74a165b0d3ca0f5/Library/HTTP/Response.php#L64-L91 | train |
jabernardo/lollipop-php | Library/HTTP/Response.php | Response.get | public function get($raw = false) {
return $raw
? $this->_data
: $this->_format($this->_data);
} | php | public function get($raw = false) {
return $raw
? $this->_data
: $this->_format($this->_data);
} | [
"public",
"function",
"get",
"(",
"$",
"raw",
"=",
"false",
")",
"{",
"return",
"$",
"raw",
"?",
"$",
"this",
"->",
"_data",
":",
"$",
"this",
"->",
"_format",
"(",
"$",
"this",
"->",
"_data",
")",
";",
"}"
] | Get formatted responsed data
@access public
@return string | [
"Get",
"formatted",
"responsed",
"data"
] | 004d80b21f7246bb3e08c7b9f74a165b0d3ca0f5 | https://github.com/jabernardo/lollipop-php/blob/004d80b21f7246bb3e08c7b9f74a165b0d3ca0f5/Library/HTTP/Response.php#L142-L146 | train |
jabernardo/lollipop-php | Library/HTTP/Response.php | Response.render | public function render() {
// Parse contents
$res = $this->get();
// Set HTTP Headers
foreach ($this->_headers as $header) {
header($header);
}
// Set cookies
foreach($this->_cookies as $k => $v) {
Cookie::set($k, $v);
}
print($res);
} | php | public function render() {
// Parse contents
$res = $this->get();
// Set HTTP Headers
foreach ($this->_headers as $header) {
header($header);
}
// Set cookies
foreach($this->_cookies as $k => $v) {
Cookie::set($k, $v);
}
print($res);
} | [
"public",
"function",
"render",
"(",
")",
"{",
"// Parse contents",
"$",
"res",
"=",
"$",
"this",
"->",
"get",
"(",
")",
";",
"// Set HTTP Headers",
"foreach",
"(",
"$",
"this",
"->",
"_headers",
"as",
"$",
"header",
")",
"{",
"header",
"(",
"$",
"header",
")",
";",
"}",
"// Set cookies",
"foreach",
"(",
"$",
"this",
"->",
"_cookies",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"Cookie",
"::",
"set",
"(",
"$",
"k",
",",
"$",
"v",
")",
";",
"}",
"print",
"(",
"$",
"res",
")",
";",
"}"
] | Set response headers and print response text
@access public
@return object | [
"Set",
"response",
"headers",
"and",
"print",
"response",
"text"
] | 004d80b21f7246bb3e08c7b9f74a165b0d3ca0f5 | https://github.com/jabernardo/lollipop-php/blob/004d80b21f7246bb3e08c7b9f74a165b0d3ca0f5/Library/HTTP/Response.php#L197-L212 | train |
vukbgit/PHPCraft.Subject | src/Traits/Upload.php | Upload.execUpload | protected function execUpload()
{
$this->loadTranslations('form', sprintf('private/global/locales/%s/form.ini', LANGUAGE));
//fields instances
foreach($this->uploadFieldsDefinitions as $fieldName => $definition) {
$validations = isset($definition['validations']) ? $definition['validations'] : null;
$previewTemplate = isset($definition['previewTemplate']) ? $definition['previewTemplate'] : null;
$this->uploadFields[$fieldName] = new Upload\Field($fieldName, $validations, $previewTemplate);
foreach($definition['outputs'] as $outputName => $output) {
$this->uploadFields[$fieldName]->addOutput($outputName, $output['destination']);
}
}
$this->handleUpload();
echo $this->outputUploadOutcome();
} | php | protected function execUpload()
{
$this->loadTranslations('form', sprintf('private/global/locales/%s/form.ini', LANGUAGE));
//fields instances
foreach($this->uploadFieldsDefinitions as $fieldName => $definition) {
$validations = isset($definition['validations']) ? $definition['validations'] : null;
$previewTemplate = isset($definition['previewTemplate']) ? $definition['previewTemplate'] : null;
$this->uploadFields[$fieldName] = new Upload\Field($fieldName, $validations, $previewTemplate);
foreach($definition['outputs'] as $outputName => $output) {
$this->uploadFields[$fieldName]->addOutput($outputName, $output['destination']);
}
}
$this->handleUpload();
echo $this->outputUploadOutcome();
} | [
"protected",
"function",
"execUpload",
"(",
")",
"{",
"$",
"this",
"->",
"loadTranslations",
"(",
"'form'",
",",
"sprintf",
"(",
"'private/global/locales/%s/form.ini'",
",",
"LANGUAGE",
")",
")",
";",
"//fields instances",
"foreach",
"(",
"$",
"this",
"->",
"uploadFieldsDefinitions",
"as",
"$",
"fieldName",
"=>",
"$",
"definition",
")",
"{",
"$",
"validations",
"=",
"isset",
"(",
"$",
"definition",
"[",
"'validations'",
"]",
")",
"?",
"$",
"definition",
"[",
"'validations'",
"]",
":",
"null",
";",
"$",
"previewTemplate",
"=",
"isset",
"(",
"$",
"definition",
"[",
"'previewTemplate'",
"]",
")",
"?",
"$",
"definition",
"[",
"'previewTemplate'",
"]",
":",
"null",
";",
"$",
"this",
"->",
"uploadFields",
"[",
"$",
"fieldName",
"]",
"=",
"new",
"Upload",
"\\",
"Field",
"(",
"$",
"fieldName",
",",
"$",
"validations",
",",
"$",
"previewTemplate",
")",
";",
"foreach",
"(",
"$",
"definition",
"[",
"'outputs'",
"]",
"as",
"$",
"outputName",
"=>",
"$",
"output",
")",
"{",
"$",
"this",
"->",
"uploadFields",
"[",
"$",
"fieldName",
"]",
"->",
"addOutput",
"(",
"$",
"outputName",
",",
"$",
"output",
"[",
"'destination'",
"]",
")",
";",
"}",
"}",
"$",
"this",
"->",
"handleUpload",
"(",
")",
";",
"echo",
"$",
"this",
"->",
"outputUploadOutcome",
"(",
")",
";",
"}"
] | Execs upload action | [
"Execs",
"upload",
"action"
] | a43ad7868098ff1e7bda6819547ea64f9a853732 | https://github.com/vukbgit/PHPCraft.Subject/blob/a43ad7868098ff1e7bda6819547ea64f9a853732/src/Traits/Upload.php#L112-L126 | train |
vukbgit/PHPCraft.Subject | src/Traits/Upload.php | Upload.checkUpload | protected function checkUpload()
{
//no upload field defined for uploaded field
if(!isset($this->uploadFields[$this->uploadedField])) {
$this->uploadMessages[] = sprintf('No definition set for POST uploadField field "%s"', $this->uploadedField);
return false;
}
//no processing method implemented for any of outputs
foreach($this->uploadFieldsDefinitions[$this->uploadedField]['outputs'] as $output => $outputDefinition) {
if(isset($outputDefinition['processor'])) {
if(!method_exists($this, $outputDefinition['processor'])) {
$this->uploadMessages[] = sprintf('Class <b>%s</b> must define method <b>%s</b> to process output <b>%s</b> of upload field <b>%s</b>', $this->name, $outputDefinition['processor'], $output, $this->uploadedField);
return false;
}
}
}
return true;
} | php | protected function checkUpload()
{
//no upload field defined for uploaded field
if(!isset($this->uploadFields[$this->uploadedField])) {
$this->uploadMessages[] = sprintf('No definition set for POST uploadField field "%s"', $this->uploadedField);
return false;
}
//no processing method implemented for any of outputs
foreach($this->uploadFieldsDefinitions[$this->uploadedField]['outputs'] as $output => $outputDefinition) {
if(isset($outputDefinition['processor'])) {
if(!method_exists($this, $outputDefinition['processor'])) {
$this->uploadMessages[] = sprintf('Class <b>%s</b> must define method <b>%s</b> to process output <b>%s</b> of upload field <b>%s</b>', $this->name, $outputDefinition['processor'], $output, $this->uploadedField);
return false;
}
}
}
return true;
} | [
"protected",
"function",
"checkUpload",
"(",
")",
"{",
"//no upload field defined for uploaded field",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"uploadFields",
"[",
"$",
"this",
"->",
"uploadedField",
"]",
")",
")",
"{",
"$",
"this",
"->",
"uploadMessages",
"[",
"]",
"=",
"sprintf",
"(",
"'No definition set for POST uploadField field \"%s\"'",
",",
"$",
"this",
"->",
"uploadedField",
")",
";",
"return",
"false",
";",
"}",
"//no processing method implemented for any of outputs",
"foreach",
"(",
"$",
"this",
"->",
"uploadFieldsDefinitions",
"[",
"$",
"this",
"->",
"uploadedField",
"]",
"[",
"'outputs'",
"]",
"as",
"$",
"output",
"=>",
"$",
"outputDefinition",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"outputDefinition",
"[",
"'processor'",
"]",
")",
")",
"{",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"this",
",",
"$",
"outputDefinition",
"[",
"'processor'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"uploadMessages",
"[",
"]",
"=",
"sprintf",
"(",
"'Class <b>%s</b> must define method <b>%s</b> to process output <b>%s</b> of upload field <b>%s</b>'",
",",
"$",
"this",
"->",
"name",
",",
"$",
"outputDefinition",
"[",
"'processor'",
"]",
",",
"$",
"output",
",",
"$",
"this",
"->",
"uploadedField",
")",
";",
"return",
"false",
";",
"}",
"}",
"}",
"return",
"true",
";",
"}"
] | Checks whether an upload has been tried
@return boolean, true on success false on failure | [
"Checks",
"whether",
"an",
"upload",
"has",
"been",
"tried"
] | a43ad7868098ff1e7bda6819547ea64f9a853732 | https://github.com/vukbgit/PHPCraft.Subject/blob/a43ad7868098ff1e7bda6819547ea64f9a853732/src/Traits/Upload.php#L132-L149 | train |
vukbgit/PHPCraft.Subject | src/Traits/Upload.php | Upload.handleUpload | protected function handleUpload()
{
$this->uploadedField = array_keys($_FILES)[0];
//check if any uploaded file for a defined field
$this->uploadOk = $this->checkUpload();
if(!$this->uploadOk) {
return;
}
//exec upload
$this->uploadOk = $this->uploadFields[$this->uploadedField]->handleUpload($this->uploader);
if(!$this->uploadOk) {
return;
}
//outputs post processing
$outputs = $this->uploadFields[$this->uploadedField]->getOutputsFiles();
foreach($this->uploadFieldsDefinitions[$this->uploadedField]['outputs'] as $output => $outputDefinition) {
if(isset($outputDefinition['processor'])) {
$this->{$outputDefinition['processor']}($outputs[$output]['path']);
}
}
} | php | protected function handleUpload()
{
$this->uploadedField = array_keys($_FILES)[0];
//check if any uploaded file for a defined field
$this->uploadOk = $this->checkUpload();
if(!$this->uploadOk) {
return;
}
//exec upload
$this->uploadOk = $this->uploadFields[$this->uploadedField]->handleUpload($this->uploader);
if(!$this->uploadOk) {
return;
}
//outputs post processing
$outputs = $this->uploadFields[$this->uploadedField]->getOutputsFiles();
foreach($this->uploadFieldsDefinitions[$this->uploadedField]['outputs'] as $output => $outputDefinition) {
if(isset($outputDefinition['processor'])) {
$this->{$outputDefinition['processor']}($outputs[$output]['path']);
}
}
} | [
"protected",
"function",
"handleUpload",
"(",
")",
"{",
"$",
"this",
"->",
"uploadedField",
"=",
"array_keys",
"(",
"$",
"_FILES",
")",
"[",
"0",
"]",
";",
"//check if any uploaded file for a defined field",
"$",
"this",
"->",
"uploadOk",
"=",
"$",
"this",
"->",
"checkUpload",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"uploadOk",
")",
"{",
"return",
";",
"}",
"//exec upload",
"$",
"this",
"->",
"uploadOk",
"=",
"$",
"this",
"->",
"uploadFields",
"[",
"$",
"this",
"->",
"uploadedField",
"]",
"->",
"handleUpload",
"(",
"$",
"this",
"->",
"uploader",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"uploadOk",
")",
"{",
"return",
";",
"}",
"//outputs post processing",
"$",
"outputs",
"=",
"$",
"this",
"->",
"uploadFields",
"[",
"$",
"this",
"->",
"uploadedField",
"]",
"->",
"getOutputsFiles",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"uploadFieldsDefinitions",
"[",
"$",
"this",
"->",
"uploadedField",
"]",
"[",
"'outputs'",
"]",
"as",
"$",
"output",
"=>",
"$",
"outputDefinition",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"outputDefinition",
"[",
"'processor'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"{",
"$",
"outputDefinition",
"[",
"'processor'",
"]",
"}",
"(",
"$",
"outputs",
"[",
"$",
"output",
"]",
"[",
"'path'",
"]",
")",
";",
"}",
"}",
"}"
] | Executes the upload action | [
"Executes",
"the",
"upload",
"action"
] | a43ad7868098ff1e7bda6819547ea64f9a853732 | https://github.com/vukbgit/PHPCraft.Subject/blob/a43ad7868098ff1e7bda6819547ea64f9a853732/src/Traits/Upload.php#L154-L174 | train |
vukbgit/PHPCraft.Subject | src/Traits/Upload.php | Upload.outputUploadOutcome | protected function outputUploadOutcome()
{
$json = new \stdClass();
// errors
if(!$this->uploadOk) {
if($this->uploader->getMessages()) {
$this->uploadMessages[] = implode('\n', $this->uploader->getMessages());
}
$json->error = implode('\n', $this->uploadMessages);
$this->httpResponse = $this->httpResponse->withStatus('412', $json->error);
} else {
//input file informations
$json->input = [
'name' => $this->uploadFields[$this->uploadedField]->getInputFile(),
'hash' => $this->uploadFields[$this->uploadedField]->getInputHash()
];
// generated file(s) paths
$json->outputs = $this->uploadFields[$this->uploadedField]->getOutputsFiles();
}
return json_encode($json);
} | php | protected function outputUploadOutcome()
{
$json = new \stdClass();
// errors
if(!$this->uploadOk) {
if($this->uploader->getMessages()) {
$this->uploadMessages[] = implode('\n', $this->uploader->getMessages());
}
$json->error = implode('\n', $this->uploadMessages);
$this->httpResponse = $this->httpResponse->withStatus('412', $json->error);
} else {
//input file informations
$json->input = [
'name' => $this->uploadFields[$this->uploadedField]->getInputFile(),
'hash' => $this->uploadFields[$this->uploadedField]->getInputHash()
];
// generated file(s) paths
$json->outputs = $this->uploadFields[$this->uploadedField]->getOutputsFiles();
}
return json_encode($json);
} | [
"protected",
"function",
"outputUploadOutcome",
"(",
")",
"{",
"$",
"json",
"=",
"new",
"\\",
"stdClass",
"(",
")",
";",
"// errors",
"if",
"(",
"!",
"$",
"this",
"->",
"uploadOk",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"uploader",
"->",
"getMessages",
"(",
")",
")",
"{",
"$",
"this",
"->",
"uploadMessages",
"[",
"]",
"=",
"implode",
"(",
"'\\n'",
",",
"$",
"this",
"->",
"uploader",
"->",
"getMessages",
"(",
")",
")",
";",
"}",
"$",
"json",
"->",
"error",
"=",
"implode",
"(",
"'\\n'",
",",
"$",
"this",
"->",
"uploadMessages",
")",
";",
"$",
"this",
"->",
"httpResponse",
"=",
"$",
"this",
"->",
"httpResponse",
"->",
"withStatus",
"(",
"'412'",
",",
"$",
"json",
"->",
"error",
")",
";",
"}",
"else",
"{",
"//input file informations",
"$",
"json",
"->",
"input",
"=",
"[",
"'name'",
"=>",
"$",
"this",
"->",
"uploadFields",
"[",
"$",
"this",
"->",
"uploadedField",
"]",
"->",
"getInputFile",
"(",
")",
",",
"'hash'",
"=>",
"$",
"this",
"->",
"uploadFields",
"[",
"$",
"this",
"->",
"uploadedField",
"]",
"->",
"getInputHash",
"(",
")",
"]",
";",
"// generated file(s) paths",
"$",
"json",
"->",
"outputs",
"=",
"$",
"this",
"->",
"uploadFields",
"[",
"$",
"this",
"->",
"uploadedField",
"]",
"->",
"getOutputsFiles",
"(",
")",
";",
"}",
"return",
"json_encode",
"(",
"$",
"json",
")",
";",
"}"
] | Outputs to browser upload outcome in json format for ajax calls benefit
@return string json code | [
"Outputs",
"to",
"browser",
"upload",
"outcome",
"in",
"json",
"format",
"for",
"ajax",
"calls",
"benefit"
] | a43ad7868098ff1e7bda6819547ea64f9a853732 | https://github.com/vukbgit/PHPCraft.Subject/blob/a43ad7868098ff1e7bda6819547ea64f9a853732/src/Traits/Upload.php#L180-L200 | train |
vukbgit/PHPCraft.Subject | src/Traits/Upload.php | Upload.purgeFiles | protected function purgeFiles()
{
//get record
//validate and extract input
$input = $this->processSaveInput(filter_input_array(INPUT_POST, $this->configuration['subjects'][$this->name]['CRUD']['inputFields']));
//extract primary key value
$primaryKeyValue = $this->extractPrimaryKeyValue($input, 'a');
$record = $this->getByPrimaryKey($primaryKeyValue);
$fields = array_keys($this->uploadFieldsDefinitions);
//loop defined upload fields
foreach($fields as $field) {
//skip other subject field (in case this subject handles upload for other tables)
if(!isset($record->$field)) {
continue;
}
//get record field value
$fieldValue = json_decode($record->$field);
//skip empty field
if(!$fieldValue) {
continue;
}
//ERRORE "Cannot use object of type stdClass as array" ALLA RIGA 230
continue;
//get posted value
if($this->action == 'update') {
$a = $input[$field];
$fieldObject = json_decode($a);
//$a = get_object_vars($a);
//$postedInputs = array_keys($a);
}
//loop inputs
foreach((array) $fieldValue as $hash => $input) {
//if($this->action == 'delete' || !in_array($hash, $postedInputs)) {
if($this->action == 'delete' || !isset($fieldObject->$hash)) {
//loop outputs
foreach($input->outputs as $output) {
if(is_file($output->path)) {
unlink($output->path);
}
}
}
}
}
} | php | protected function purgeFiles()
{
//get record
//validate and extract input
$input = $this->processSaveInput(filter_input_array(INPUT_POST, $this->configuration['subjects'][$this->name]['CRUD']['inputFields']));
//extract primary key value
$primaryKeyValue = $this->extractPrimaryKeyValue($input, 'a');
$record = $this->getByPrimaryKey($primaryKeyValue);
$fields = array_keys($this->uploadFieldsDefinitions);
//loop defined upload fields
foreach($fields as $field) {
//skip other subject field (in case this subject handles upload for other tables)
if(!isset($record->$field)) {
continue;
}
//get record field value
$fieldValue = json_decode($record->$field);
//skip empty field
if(!$fieldValue) {
continue;
}
//ERRORE "Cannot use object of type stdClass as array" ALLA RIGA 230
continue;
//get posted value
if($this->action == 'update') {
$a = $input[$field];
$fieldObject = json_decode($a);
//$a = get_object_vars($a);
//$postedInputs = array_keys($a);
}
//loop inputs
foreach((array) $fieldValue as $hash => $input) {
//if($this->action == 'delete' || !in_array($hash, $postedInputs)) {
if($this->action == 'delete' || !isset($fieldObject->$hash)) {
//loop outputs
foreach($input->outputs as $output) {
if(is_file($output->path)) {
unlink($output->path);
}
}
}
}
}
} | [
"protected",
"function",
"purgeFiles",
"(",
")",
"{",
"//get record",
"//validate and extract input",
"$",
"input",
"=",
"$",
"this",
"->",
"processSaveInput",
"(",
"filter_input_array",
"(",
"INPUT_POST",
",",
"$",
"this",
"->",
"configuration",
"[",
"'subjects'",
"]",
"[",
"$",
"this",
"->",
"name",
"]",
"[",
"'CRUD'",
"]",
"[",
"'inputFields'",
"]",
")",
")",
";",
"//extract primary key value",
"$",
"primaryKeyValue",
"=",
"$",
"this",
"->",
"extractPrimaryKeyValue",
"(",
"$",
"input",
",",
"'a'",
")",
";",
"$",
"record",
"=",
"$",
"this",
"->",
"getByPrimaryKey",
"(",
"$",
"primaryKeyValue",
")",
";",
"$",
"fields",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"uploadFieldsDefinitions",
")",
";",
"//loop defined upload fields",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
")",
"{",
"//skip other subject field (in case this subject handles upload for other tables)",
"if",
"(",
"!",
"isset",
"(",
"$",
"record",
"->",
"$",
"field",
")",
")",
"{",
"continue",
";",
"}",
"//get record field value",
"$",
"fieldValue",
"=",
"json_decode",
"(",
"$",
"record",
"->",
"$",
"field",
")",
";",
"//skip empty field",
"if",
"(",
"!",
"$",
"fieldValue",
")",
"{",
"continue",
";",
"}",
"//ERRORE \"Cannot use object of type stdClass as array\" ALLA RIGA 230",
"continue",
";",
"//get posted value",
"if",
"(",
"$",
"this",
"->",
"action",
"==",
"'update'",
")",
"{",
"$",
"a",
"=",
"$",
"input",
"[",
"$",
"field",
"]",
";",
"$",
"fieldObject",
"=",
"json_decode",
"(",
"$",
"a",
")",
";",
"//$a = get_object_vars($a);",
"//$postedInputs = array_keys($a);",
"}",
"//loop inputs",
"foreach",
"(",
"(",
"array",
")",
"$",
"fieldValue",
"as",
"$",
"hash",
"=>",
"$",
"input",
")",
"{",
"//if($this->action == 'delete' || !in_array($hash, $postedInputs)) {",
"if",
"(",
"$",
"this",
"->",
"action",
"==",
"'delete'",
"||",
"!",
"isset",
"(",
"$",
"fieldObject",
"->",
"$",
"hash",
")",
")",
"{",
"//loop outputs",
"foreach",
"(",
"$",
"input",
"->",
"outputs",
"as",
"$",
"output",
")",
"{",
"if",
"(",
"is_file",
"(",
"$",
"output",
"->",
"path",
")",
")",
"{",
"unlink",
"(",
"$",
"output",
"->",
"path",
")",
";",
"}",
"}",
"}",
"}",
"}",
"}"
] | Checks in case of CRUD update or delete if any file is to be deleted | [
"Checks",
"in",
"case",
"of",
"CRUD",
"update",
"or",
"delete",
"if",
"any",
"file",
"is",
"to",
"be",
"deleted"
] | a43ad7868098ff1e7bda6819547ea64f9a853732 | https://github.com/vukbgit/PHPCraft.Subject/blob/a43ad7868098ff1e7bda6819547ea64f9a853732/src/Traits/Upload.php#L205-L248 | train |
vukbgit/PHPCraft.Subject | src/Traits/Upload.php | Upload.extractFieldsOutputs | public function extractFieldsOutputs(&$record, $fieldsOutputs, $propertyName = '_files')
{
foreach($fieldsOutputs as $field => $outputs) {
$this->extractFieldOutputs($record, $field, $outputs, $propertyName);
}
} | php | public function extractFieldsOutputs(&$record, $fieldsOutputs, $propertyName = '_files')
{
foreach($fieldsOutputs as $field => $outputs) {
$this->extractFieldOutputs($record, $field, $outputs, $propertyName);
}
} | [
"public",
"function",
"extractFieldsOutputs",
"(",
"&",
"$",
"record",
",",
"$",
"fieldsOutputs",
",",
"$",
"propertyName",
"=",
"'_files'",
")",
"{",
"foreach",
"(",
"$",
"fieldsOutputs",
"as",
"$",
"field",
"=>",
"$",
"outputs",
")",
"{",
"$",
"this",
"->",
"extractFieldOutputs",
"(",
"$",
"record",
",",
"$",
"field",
",",
"$",
"outputs",
",",
"$",
"propertyName",
")",
";",
"}",
"}"
] | extracts for a record, for one or more upload fields, one or more outputs paths
@param object $record
@param array $fieldsOutputs: indexes are fields names, elements are arrays of outputs names
@param string $propertyName name of property with files paths that is added to record | [
"extracts",
"for",
"a",
"record",
"for",
"one",
"or",
"more",
"upload",
"fields",
"one",
"or",
"more",
"outputs",
"paths"
] | a43ad7868098ff1e7bda6819547ea64f9a853732 | https://github.com/vukbgit/PHPCraft.Subject/blob/a43ad7868098ff1e7bda6819547ea64f9a853732/src/Traits/Upload.php#L295-L300 | train |
vukbgit/PHPCraft.Subject | src/Traits/Upload.php | Upload.extractFieldsOutputsList | public function extractFieldsOutputsList(&$records, $fieldsOutputs, $propertyName = '_files')
{
foreach($records as $record) {
$this->extractFieldsOutputs($record, $fieldsOutputs, $propertyName);
}
} | php | public function extractFieldsOutputsList(&$records, $fieldsOutputs, $propertyName = '_files')
{
foreach($records as $record) {
$this->extractFieldsOutputs($record, $fieldsOutputs, $propertyName);
}
} | [
"public",
"function",
"extractFieldsOutputsList",
"(",
"&",
"$",
"records",
",",
"$",
"fieldsOutputs",
",",
"$",
"propertyName",
"=",
"'_files'",
")",
"{",
"foreach",
"(",
"$",
"records",
"as",
"$",
"record",
")",
"{",
"$",
"this",
"->",
"extractFieldsOutputs",
"(",
"$",
"record",
",",
"$",
"fieldsOutputs",
",",
"$",
"propertyName",
")",
";",
"}",
"}"
] | extracts for a list of records, for one or more upload fields, one or more outputs paths
@param object $record
@param array $fieldsOutputs: indexes are fields names, elements are arrays of outputs names
@param string $propertyName name of property with files paths that is added to record | [
"extracts",
"for",
"a",
"list",
"of",
"records",
"for",
"one",
"or",
"more",
"upload",
"fields",
"one",
"or",
"more",
"outputs",
"paths"
] | a43ad7868098ff1e7bda6819547ea64f9a853732 | https://github.com/vukbgit/PHPCraft.Subject/blob/a43ad7868098ff1e7bda6819547ea64f9a853732/src/Traits/Upload.php#L308-L313 | train |
Wedeto/DB | src/Query/Operator.php | Operator.toSQL | public function toSQL(Parameters $params, bool $inner_clause)
{
$drv = $params->getDriver();
$lhs = $this->getLHS() === null ? null : $drv->toSQL($params, $this->getLHS(), true);
$rhs = $drv->toSQL($params, $this->getRHS(), true);
$op = $this->getOperator();
if ($lhs !== null)
{
$sql = $lhs . ' ' . $op . ' ' . $rhs;
if ($inner_clause)
return '(' . $sql . ')';
return $sql;
}
return $op . ' ' . $rhs;
} | php | public function toSQL(Parameters $params, bool $inner_clause)
{
$drv = $params->getDriver();
$lhs = $this->getLHS() === null ? null : $drv->toSQL($params, $this->getLHS(), true);
$rhs = $drv->toSQL($params, $this->getRHS(), true);
$op = $this->getOperator();
if ($lhs !== null)
{
$sql = $lhs . ' ' . $op . ' ' . $rhs;
if ($inner_clause)
return '(' . $sql . ')';
return $sql;
}
return $op . ' ' . $rhs;
} | [
"public",
"function",
"toSQL",
"(",
"Parameters",
"$",
"params",
",",
"bool",
"$",
"inner_clause",
")",
"{",
"$",
"drv",
"=",
"$",
"params",
"->",
"getDriver",
"(",
")",
";",
"$",
"lhs",
"=",
"$",
"this",
"->",
"getLHS",
"(",
")",
"===",
"null",
"?",
"null",
":",
"$",
"drv",
"->",
"toSQL",
"(",
"$",
"params",
",",
"$",
"this",
"->",
"getLHS",
"(",
")",
",",
"true",
")",
";",
"$",
"rhs",
"=",
"$",
"drv",
"->",
"toSQL",
"(",
"$",
"params",
",",
"$",
"this",
"->",
"getRHS",
"(",
")",
",",
"true",
")",
";",
"$",
"op",
"=",
"$",
"this",
"->",
"getOperator",
"(",
")",
";",
"if",
"(",
"$",
"lhs",
"!==",
"null",
")",
"{",
"$",
"sql",
"=",
"$",
"lhs",
".",
"' '",
".",
"$",
"op",
".",
"' '",
".",
"$",
"rhs",
";",
"if",
"(",
"$",
"inner_clause",
")",
"return",
"'('",
".",
"$",
"sql",
".",
"')'",
";",
"return",
"$",
"sql",
";",
"}",
"return",
"$",
"op",
".",
"' '",
".",
"$",
"rhs",
";",
"}"
] | Write an operator expression as SQL query syntax
@param Parameters $params The query parameters: tables and placeholder values
@param bool $inner_clause Whether this is a inner or outer clause. An
inner clause will be wrapped in braces when
it's a binary operator.
@return string The generated SQL | [
"Write",
"an",
"operator",
"expression",
"as",
"SQL",
"query",
"syntax"
] | 715f8f2e3ae6b53c511c40b620921cb9c87e6f62 | https://github.com/Wedeto/DB/blob/715f8f2e3ae6b53c511c40b620921cb9c87e6f62/src/Query/Operator.php#L73-L90 | train |
RocketPropelledTortoise/Core | src/Entities/Fields/Date.php | Date.prepareValue | protected function prepareValue($value)
{
$value = $this->asDateTime($value)->startOfDay();
return $value->format($this->getDateFormat());
} | php | protected function prepareValue($value)
{
$value = $this->asDateTime($value)->startOfDay();
return $value->format($this->getDateFormat());
} | [
"protected",
"function",
"prepareValue",
"(",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"asDateTime",
"(",
"$",
"value",
")",
"->",
"startOfDay",
"(",
")",
";",
"return",
"$",
"value",
"->",
"format",
"(",
"$",
"this",
"->",
"getDateFormat",
"(",
")",
")",
";",
"}"
] | Prepare the value to be stored.
@param mixed $value The value to prepare
@return string | [
"Prepare",
"the",
"value",
"to",
"be",
"stored",
"."
] | 78b65663fc463e21e494257140ddbed0a9ccb3c3 | https://github.com/RocketPropelledTortoise/Core/blob/78b65663fc463e21e494257140ddbed0a9ccb3c3/src/Entities/Fields/Date.php#L35-L40 | train |
ChristianGaertner/DaContainer | src/DaGardner/DaContainer/Container.php | Container.bind | public function bind($id, $concrete, $singleton = false)
{
$concrete = $concrete ?: $id;
if (!$concrete instanceof Closure) {
// If the factory (resolver) is NOT a closure we assume,
// that it is a classname and wrap it into a closure so it' s
// easier when resolving.
$concrete = function (Container $container) use ($id, $concrete) {
$method = ($id == $concrete) ? 'build' : 'resolve';
return $container->$method($concrete, array());
};
}
$this->binds[$id] = compact('concrete', 'singleton');
} | php | public function bind($id, $concrete, $singleton = false)
{
$concrete = $concrete ?: $id;
if (!$concrete instanceof Closure) {
// If the factory (resolver) is NOT a closure we assume,
// that it is a classname and wrap it into a closure so it' s
// easier when resolving.
$concrete = function (Container $container) use ($id, $concrete) {
$method = ($id == $concrete) ? 'build' : 'resolve';
return $container->$method($concrete, array());
};
}
$this->binds[$id] = compact('concrete', 'singleton');
} | [
"public",
"function",
"bind",
"(",
"$",
"id",
",",
"$",
"concrete",
",",
"$",
"singleton",
"=",
"false",
")",
"{",
"$",
"concrete",
"=",
"$",
"concrete",
"?",
":",
"$",
"id",
";",
"if",
"(",
"!",
"$",
"concrete",
"instanceof",
"Closure",
")",
"{",
"// If the factory (resolver) is NOT a closure we assume,",
"// that it is a classname and wrap it into a closure so it' s",
"// easier when resolving.",
"$",
"concrete",
"=",
"function",
"(",
"Container",
"$",
"container",
")",
"use",
"(",
"$",
"id",
",",
"$",
"concrete",
")",
"{",
"$",
"method",
"=",
"(",
"$",
"id",
"==",
"$",
"concrete",
")",
"?",
"'build'",
":",
"'resolve'",
";",
"return",
"$",
"container",
"->",
"$",
"method",
"(",
"$",
"concrete",
",",
"array",
"(",
")",
")",
";",
"}",
";",
"}",
"$",
"this",
"->",
"binds",
"[",
"$",
"id",
"]",
"=",
"compact",
"(",
"'concrete'",
",",
"'singleton'",
")",
";",
"}"
] | Register a binding
@param string $id The id (needed for resolving)
@param Closure|string|null $concrete The factory
@param boolean $singleton Whether the binding should be a singelton | [
"Register",
"a",
"binding"
] | 2fbb2062f000f26af05cafee1148b892155008d5 | https://github.com/ChristianGaertner/DaContainer/blob/2fbb2062f000f26af05cafee1148b892155008d5/src/DaGardner/DaContainer/Container.php#L72-L93 | train |
ChristianGaertner/DaContainer | src/DaGardner/DaContainer/Container.php | Container.enableInjecterDetection | public function enableInjecterDetection(array $blacklist = array(), $version = PHP_VERSION)
{
if (version_compare($version, '5.4.0') <= 0) {
throw new RunTimeException('This feature requires PHP 5.4 or higher');
}
if ($this->detector === null) {
$this->setDetector(new SimpleDetector);
}
$blacklist = $this->buildDimdBlacklist($blacklist);
$this->dimbBlacklist = $blacklist;
$this->onResolving(function ($object) use ($blacklist) {
$class = get_class($object);
$reflection = new ReflectionClass($class);
$methods = $reflection->getMethods();
/**
* Cycle thru all methods. Filtering in the next control-construct
*/
foreach ($methods as $method) {
/**
* This is not a complex detection, but most injecter methods are starting with a set[...]
*/
if ($this->detector->detect($method)) {
// Just check if the method is in the blacklist
if (in_array($method->name, $blacklist) || (isset($blacklist['_CLASSES_'][$class]) && in_array($method->name, $blacklist['_CLASSES_'][$class]))) {
continue;
}
try {
$dependencies = $this->getDependencies($method->getParameters());
/**
* We keep this line in the try/catch block as well in order to skip it if an exception is thrown,
* otherwise we would get native PHP errors.. Nasty.
*/
call_user_func_array(array($object, $method->name), $dependencies);
/**
* If an ParameterResolveException is thrown it hit a non class injector method and we simply ignore these
* We do NOT catch ResolveExceptions since a not found class is something we' re not responsible for.
*/
} catch (ParameterResolveException $e) {
}
}
}
return $object;
}, -255);
} | php | public function enableInjecterDetection(array $blacklist = array(), $version = PHP_VERSION)
{
if (version_compare($version, '5.4.0') <= 0) {
throw new RunTimeException('This feature requires PHP 5.4 or higher');
}
if ($this->detector === null) {
$this->setDetector(new SimpleDetector);
}
$blacklist = $this->buildDimdBlacklist($blacklist);
$this->dimbBlacklist = $blacklist;
$this->onResolving(function ($object) use ($blacklist) {
$class = get_class($object);
$reflection = new ReflectionClass($class);
$methods = $reflection->getMethods();
/**
* Cycle thru all methods. Filtering in the next control-construct
*/
foreach ($methods as $method) {
/**
* This is not a complex detection, but most injecter methods are starting with a set[...]
*/
if ($this->detector->detect($method)) {
// Just check if the method is in the blacklist
if (in_array($method->name, $blacklist) || (isset($blacklist['_CLASSES_'][$class]) && in_array($method->name, $blacklist['_CLASSES_'][$class]))) {
continue;
}
try {
$dependencies = $this->getDependencies($method->getParameters());
/**
* We keep this line in the try/catch block as well in order to skip it if an exception is thrown,
* otherwise we would get native PHP errors.. Nasty.
*/
call_user_func_array(array($object, $method->name), $dependencies);
/**
* If an ParameterResolveException is thrown it hit a non class injector method and we simply ignore these
* We do NOT catch ResolveExceptions since a not found class is something we' re not responsible for.
*/
} catch (ParameterResolveException $e) {
}
}
}
return $object;
}, -255);
} | [
"public",
"function",
"enableInjecterDetection",
"(",
"array",
"$",
"blacklist",
"=",
"array",
"(",
")",
",",
"$",
"version",
"=",
"PHP_VERSION",
")",
"{",
"if",
"(",
"version_compare",
"(",
"$",
"version",
",",
"'5.4.0'",
")",
"<=",
"0",
")",
"{",
"throw",
"new",
"RunTimeException",
"(",
"'This feature requires PHP 5.4 or higher'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"detector",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"setDetector",
"(",
"new",
"SimpleDetector",
")",
";",
"}",
"$",
"blacklist",
"=",
"$",
"this",
"->",
"buildDimdBlacklist",
"(",
"$",
"blacklist",
")",
";",
"$",
"this",
"->",
"dimbBlacklist",
"=",
"$",
"blacklist",
";",
"$",
"this",
"->",
"onResolving",
"(",
"function",
"(",
"$",
"object",
")",
"use",
"(",
"$",
"blacklist",
")",
"{",
"$",
"class",
"=",
"get_class",
"(",
"$",
"object",
")",
";",
"$",
"reflection",
"=",
"new",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"$",
"methods",
"=",
"$",
"reflection",
"->",
"getMethods",
"(",
")",
";",
"/**\n * Cycle thru all methods. Filtering in the next control-construct\n */",
"foreach",
"(",
"$",
"methods",
"as",
"$",
"method",
")",
"{",
"/**\n * This is not a complex detection, but most injecter methods are starting with a set[...]\n */",
"if",
"(",
"$",
"this",
"->",
"detector",
"->",
"detect",
"(",
"$",
"method",
")",
")",
"{",
"// Just check if the method is in the blacklist",
"if",
"(",
"in_array",
"(",
"$",
"method",
"->",
"name",
",",
"$",
"blacklist",
")",
"||",
"(",
"isset",
"(",
"$",
"blacklist",
"[",
"'_CLASSES_'",
"]",
"[",
"$",
"class",
"]",
")",
"&&",
"in_array",
"(",
"$",
"method",
"->",
"name",
",",
"$",
"blacklist",
"[",
"'_CLASSES_'",
"]",
"[",
"$",
"class",
"]",
")",
")",
")",
"{",
"continue",
";",
"}",
"try",
"{",
"$",
"dependencies",
"=",
"$",
"this",
"->",
"getDependencies",
"(",
"$",
"method",
"->",
"getParameters",
"(",
")",
")",
";",
"/**\n * We keep this line in the try/catch block as well in order to skip it if an exception is thrown,\n * otherwise we would get native PHP errors.. Nasty.\n */",
"call_user_func_array",
"(",
"array",
"(",
"$",
"object",
",",
"$",
"method",
"->",
"name",
")",
",",
"$",
"dependencies",
")",
";",
"/**\n * If an ParameterResolveException is thrown it hit a non class injector method and we simply ignore these\n * We do NOT catch ResolveExceptions since a not found class is something we' re not responsible for.\n */",
"}",
"catch",
"(",
"ParameterResolveException",
"$",
"e",
")",
"{",
"}",
"}",
"}",
"return",
"$",
"object",
";",
"}",
",",
"-",
"255",
")",
";",
"}"
] | Enable the powerful injector method detection.
Example blacklist array:
[
'setString',
'setArray',
'_CLASSES_' => [
SomeClass' => [
'setMailer'
]
]
]
Strings in the main array are consired to be global and are ignored everytime.
The class specific blacklist is only checked if the object is an instance of this class
If the blacklist is empty it will try to recover the previous used.
<strong>This feature requires PHP 5.4 or higher</strong>
@param array $blacklist A blacklist of method names
@param string $version The current PHP_VERSION, default is the constant. This argument can be ignored! (used for unit-tests only)
@throws \DaGardner\DaContainer\Exceptions\ResolveException
@throws \RunTimeException (if PHP version is below 5.4.0) | [
"Enable",
"the",
"powerful",
"injector",
"method",
"detection",
"."
] | 2fbb2062f000f26af05cafee1148b892155008d5 | https://github.com/ChristianGaertner/DaContainer/blob/2fbb2062f000f26af05cafee1148b892155008d5/src/DaGardner/DaContainer/Container.php#L257-L318 | train |
ChristianGaertner/DaContainer | src/DaGardner/DaContainer/Container.php | Container.onResolving | public function onResolving(Closure $callback, $priority = 0)
{
if (!isset($this->callbacks[$priority])) {
$this->callbacks[$priority] = array();
}
$this->callbacks[$priority][] = $callback;
} | php | public function onResolving(Closure $callback, $priority = 0)
{
if (!isset($this->callbacks[$priority])) {
$this->callbacks[$priority] = array();
}
$this->callbacks[$priority][] = $callback;
} | [
"public",
"function",
"onResolving",
"(",
"Closure",
"$",
"callback",
",",
"$",
"priority",
"=",
"0",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"callbacks",
"[",
"$",
"priority",
"]",
")",
")",
"{",
"$",
"this",
"->",
"callbacks",
"[",
"$",
"priority",
"]",
"=",
"array",
"(",
")",
";",
"}",
"$",
"this",
"->",
"callbacks",
"[",
"$",
"priority",
"]",
"[",
"]",
"=",
"$",
"callback",
";",
"}"
] | Register a listener for the resolving event.
This is only fired on the main resolve, not internal dependency resolves.
NOTE: The high priorities are getting fired LAST, while negative (lower)
are getting fired FIRST.
<strong>Reserved priorities</strong>
- -255 Injector Method Detection (this should fire as the first callback.)
@param Closure $callback The listener
@param int $priority The priortiy of the listener | [
"Register",
"a",
"listener",
"for",
"the",
"resolving",
"event",
".",
"This",
"is",
"only",
"fired",
"on",
"the",
"main",
"resolve",
"not",
"internal",
"dependency",
"resolves",
"."
] | 2fbb2062f000f26af05cafee1148b892155008d5 | https://github.com/ChristianGaertner/DaContainer/blob/2fbb2062f000f26af05cafee1148b892155008d5/src/DaGardner/DaContainer/Container.php#L338-L346 | train |
ChristianGaertner/DaContainer | src/DaGardner/DaContainer/Container.php | Container.isSingelton | protected function isSingelton($id)
{
return (isset($this->binds[$id]['singleton']) && $this->binds[$id]['singleton'] === true);
} | php | protected function isSingelton($id)
{
return (isset($this->binds[$id]['singleton']) && $this->binds[$id]['singleton'] === true);
} | [
"protected",
"function",
"isSingelton",
"(",
"$",
"id",
")",
"{",
"return",
"(",
"isset",
"(",
"$",
"this",
"->",
"binds",
"[",
"$",
"id",
"]",
"[",
"'singleton'",
"]",
")",
"&&",
"$",
"this",
"->",
"binds",
"[",
"$",
"id",
"]",
"[",
"'singleton'",
"]",
"===",
"true",
")",
";",
"}"
] | Checks whether the binding is a singelton
@param string $id The id
@return boolean Whether the binding is a singelton | [
"Checks",
"whether",
"the",
"binding",
"is",
"a",
"singelton"
] | 2fbb2062f000f26af05cafee1148b892155008d5 | https://github.com/ChristianGaertner/DaContainer/blob/2fbb2062f000f26af05cafee1148b892155008d5/src/DaGardner/DaContainer/Container.php#L383-L386 | train |
ChristianGaertner/DaContainer | src/DaGardner/DaContainer/Container.php | Container.buildDimdBlacklist | protected function buildDimdBlacklist(array $blacklist)
{
if (!empty($blacklist)) {
return $blacklist;
} elseif (!empty($this->dimbBlacklist)) {
return $this->dimbBlacklist;
} else {
return array();
}
} | php | protected function buildDimdBlacklist(array $blacklist)
{
if (!empty($blacklist)) {
return $blacklist;
} elseif (!empty($this->dimbBlacklist)) {
return $this->dimbBlacklist;
} else {
return array();
}
} | [
"protected",
"function",
"buildDimdBlacklist",
"(",
"array",
"$",
"blacklist",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"blacklist",
")",
")",
"{",
"return",
"$",
"blacklist",
";",
"}",
"elseif",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"dimbBlacklist",
")",
")",
"{",
"return",
"$",
"this",
"->",
"dimbBlacklist",
";",
"}",
"else",
"{",
"return",
"array",
"(",
")",
";",
"}",
"}"
] | Just a wrapper for some basic control structured
@param array $blacklist The blacklist
@return array The newly builded blacklist | [
"Just",
"a",
"wrapper",
"for",
"some",
"basic",
"control",
"structured"
] | 2fbb2062f000f26af05cafee1148b892155008d5 | https://github.com/ChristianGaertner/DaContainer/blob/2fbb2062f000f26af05cafee1148b892155008d5/src/DaGardner/DaContainer/Container.php#L444-L459 | train |
helsingborg-stad/multisite-role-propagation | source/php/Profile.php | Profile.loadSitesList | public function loadSitesList($user)
{
if (!is_super_admin()) {
return;
}
if (!is_network_admin()) {
return;
}
if (file_exists(MSROLEPROPAGINATION_TEMPLATE_PATH . 'profile.php')) {
//Get data for view
$data = array(
'sites' => array_chunk(get_sites(), 3),
'savedState' => $this->getUserRoles($user->ID)
);
//Require view
require MSROLEPROPAGINATION_TEMPLATE_PATH.'profile.php';
} else {
wp_die("Profile page view does not exists at " . MSROLEPROPAGINATION_TEMPLATE_PATH.'profile.php');
}
} | php | public function loadSitesList($user)
{
if (!is_super_admin()) {
return;
}
if (!is_network_admin()) {
return;
}
if (file_exists(MSROLEPROPAGINATION_TEMPLATE_PATH . 'profile.php')) {
//Get data for view
$data = array(
'sites' => array_chunk(get_sites(), 3),
'savedState' => $this->getUserRoles($user->ID)
);
//Require view
require MSROLEPROPAGINATION_TEMPLATE_PATH.'profile.php';
} else {
wp_die("Profile page view does not exists at " . MSROLEPROPAGINATION_TEMPLATE_PATH.'profile.php');
}
} | [
"public",
"function",
"loadSitesList",
"(",
"$",
"user",
")",
"{",
"if",
"(",
"!",
"is_super_admin",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"is_network_admin",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"file_exists",
"(",
"MSROLEPROPAGINATION_TEMPLATE_PATH",
".",
"'profile.php'",
")",
")",
"{",
"//Get data for view",
"$",
"data",
"=",
"array",
"(",
"'sites'",
"=>",
"array_chunk",
"(",
"get_sites",
"(",
")",
",",
"3",
")",
",",
"'savedState'",
"=>",
"$",
"this",
"->",
"getUserRoles",
"(",
"$",
"user",
"->",
"ID",
")",
")",
";",
"//Require view",
"require",
"MSROLEPROPAGINATION_TEMPLATE_PATH",
".",
"'profile.php'",
";",
"}",
"else",
"{",
"wp_die",
"(",
"\"Profile page view does not exists at \"",
".",
"MSROLEPROPAGINATION_TEMPLATE_PATH",
".",
"'profile.php'",
")",
";",
"}",
"}"
] | Fetch the view
@return void | [
"Fetch",
"the",
"view"
] | 16d4992b8d32b3e3d8ef99ed51d37ac54bf917cc | https://github.com/helsingborg-stad/multisite-role-propagation/blob/16d4992b8d32b3e3d8ef99ed51d37ac54bf917cc/source/php/Profile.php#L29-L52 | train |
helsingborg-stad/multisite-role-propagation | source/php/Profile.php | Profile.saveUserPofile | public function saveUserPofile($user_id)
{
//Authentication check
if (!is_super_admin()) {
return;
}
if (!is_network_admin()) {
return;
}
if (isset($_POST['userEnabled']) && is_array($_POST['userEnabled']) && !empty($_POST['userEnabled'])) {
foreach ((array) $_POST['userEnabled'] as $site_key => $role) {
if (get_role($role) !== null) {
if ($site_key != 1) {
update_user_meta($user_id, $this->db->prefix . $site_key . '_capabilities', array($role => true));
} else {
update_user_meta($user_id, $this->db->prefix . 'capabilities', array($role => true));
}
} else {
if ($site_key != 1) {
delete_user_meta($user_id, $this->db->prefix . $site_key . '_capabilities');
} else {
delete_user_meta($user_id, $this->db->prefix . 'capabilities');
}
}
}
}
} | php | public function saveUserPofile($user_id)
{
//Authentication check
if (!is_super_admin()) {
return;
}
if (!is_network_admin()) {
return;
}
if (isset($_POST['userEnabled']) && is_array($_POST['userEnabled']) && !empty($_POST['userEnabled'])) {
foreach ((array) $_POST['userEnabled'] as $site_key => $role) {
if (get_role($role) !== null) {
if ($site_key != 1) {
update_user_meta($user_id, $this->db->prefix . $site_key . '_capabilities', array($role => true));
} else {
update_user_meta($user_id, $this->db->prefix . 'capabilities', array($role => true));
}
} else {
if ($site_key != 1) {
delete_user_meta($user_id, $this->db->prefix . $site_key . '_capabilities');
} else {
delete_user_meta($user_id, $this->db->prefix . 'capabilities');
}
}
}
}
} | [
"public",
"function",
"saveUserPofile",
"(",
"$",
"user_id",
")",
"{",
"//Authentication check",
"if",
"(",
"!",
"is_super_admin",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"is_network_admin",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"_POST",
"[",
"'userEnabled'",
"]",
")",
"&&",
"is_array",
"(",
"$",
"_POST",
"[",
"'userEnabled'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"_POST",
"[",
"'userEnabled'",
"]",
")",
")",
"{",
"foreach",
"(",
"(",
"array",
")",
"$",
"_POST",
"[",
"'userEnabled'",
"]",
"as",
"$",
"site_key",
"=>",
"$",
"role",
")",
"{",
"if",
"(",
"get_role",
"(",
"$",
"role",
")",
"!==",
"null",
")",
"{",
"if",
"(",
"$",
"site_key",
"!=",
"1",
")",
"{",
"update_user_meta",
"(",
"$",
"user_id",
",",
"$",
"this",
"->",
"db",
"->",
"prefix",
".",
"$",
"site_key",
".",
"'_capabilities'",
",",
"array",
"(",
"$",
"role",
"=>",
"true",
")",
")",
";",
"}",
"else",
"{",
"update_user_meta",
"(",
"$",
"user_id",
",",
"$",
"this",
"->",
"db",
"->",
"prefix",
".",
"'capabilities'",
",",
"array",
"(",
"$",
"role",
"=>",
"true",
")",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"$",
"site_key",
"!=",
"1",
")",
"{",
"delete_user_meta",
"(",
"$",
"user_id",
",",
"$",
"this",
"->",
"db",
"->",
"prefix",
".",
"$",
"site_key",
".",
"'_capabilities'",
")",
";",
"}",
"else",
"{",
"delete_user_meta",
"(",
"$",
"user_id",
",",
"$",
"this",
"->",
"db",
"->",
"prefix",
".",
"'capabilities'",
")",
";",
"}",
"}",
"}",
"}",
"}"
] | Handle save data
@return void | [
"Handle",
"save",
"data"
] | 16d4992b8d32b3e3d8ef99ed51d37ac54bf917cc | https://github.com/helsingborg-stad/multisite-role-propagation/blob/16d4992b8d32b3e3d8ef99ed51d37ac54bf917cc/source/php/Profile.php#L58-L86 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.