repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_code_tokens
listlengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
listlengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
marqu3s/nrsgateway
|
src/SMSService.php
|
SMSService.send
|
public function send()
{
# Check it $this->to is an array.
if (!is_array($this->to)) {
return [
0 => [
'result' => [
'httpCode' => 400,
'header' => '',
'body' => '{"error":{"code":101,"description":"$to must be an array"}}'
]
]
];
}
# Check if there are any recipients.
if (count($this->to) === 0) {
return [
0 => [
'result' => [
'httpCode' => 400,
'header' => '',
'body' => '{"error":{"code":102,"description":"No valid recipients"}}'
]
]
];
}
# Check if there is a sender.
if (strlen($this->from) === 0) {
return [
0 => [
'result' => [
'httpCode' => 400,
'header' => '',
'body' => '{"error":{"code":106,"description":"Sender missing"}}'
]
]
];
}
# Check if there is a message.
if (strlen($this->msg) === 0) {
return [
0 => [
'result' => [
'httpCode' => 400,
'header' => '',
'body' => '{"error":{"code":104,"description":"Text message missing"}}'
]
]
];
}
# Send the messages in chunks.
$arrChunk = array_chunk($this->to, self::TO_LIMIT_PER_REQUEST);
foreach ($arrChunk as $i => $to) {
$data = [
'encoding' => $this->encoding,
'to' => $to,
'message' => $this->msg,
'from' => $this->from,
'parts' => $this->parts
];
if (!empty($this->campaignName)) {
$data['campaignName'] = $this->campaignName;
}
$arrChunk[$i]['result'] = $this->doSend($data);
}
return $arrChunk;
}
|
php
|
public function send()
{
# Check it $this->to is an array.
if (!is_array($this->to)) {
return [
0 => [
'result' => [
'httpCode' => 400,
'header' => '',
'body' => '{"error":{"code":101,"description":"$to must be an array"}}'
]
]
];
}
# Check if there are any recipients.
if (count($this->to) === 0) {
return [
0 => [
'result' => [
'httpCode' => 400,
'header' => '',
'body' => '{"error":{"code":102,"description":"No valid recipients"}}'
]
]
];
}
# Check if there is a sender.
if (strlen($this->from) === 0) {
return [
0 => [
'result' => [
'httpCode' => 400,
'header' => '',
'body' => '{"error":{"code":106,"description":"Sender missing"}}'
]
]
];
}
# Check if there is a message.
if (strlen($this->msg) === 0) {
return [
0 => [
'result' => [
'httpCode' => 400,
'header' => '',
'body' => '{"error":{"code":104,"description":"Text message missing"}}'
]
]
];
}
# Send the messages in chunks.
$arrChunk = array_chunk($this->to, self::TO_LIMIT_PER_REQUEST);
foreach ($arrChunk as $i => $to) {
$data = [
'encoding' => $this->encoding,
'to' => $to,
'message' => $this->msg,
'from' => $this->from,
'parts' => $this->parts
];
if (!empty($this->campaignName)) {
$data['campaignName'] = $this->campaignName;
}
$arrChunk[$i]['result'] = $this->doSend($data);
}
return $arrChunk;
}
|
[
"public",
"function",
"send",
"(",
")",
"{",
"# Check it $this->to is an array.",
"if",
"(",
"!",
"is_array",
"(",
"$",
"this",
"->",
"to",
")",
")",
"{",
"return",
"[",
"0",
"=>",
"[",
"'result'",
"=>",
"[",
"'httpCode'",
"=>",
"400",
",",
"'header'",
"=>",
"''",
",",
"'body'",
"=>",
"'{\"error\":{\"code\":101,\"description\":\"$to must be an array\"}}'",
"]",
"]",
"]",
";",
"}",
"# Check if there are any recipients.",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"to",
")",
"===",
"0",
")",
"{",
"return",
"[",
"0",
"=>",
"[",
"'result'",
"=>",
"[",
"'httpCode'",
"=>",
"400",
",",
"'header'",
"=>",
"''",
",",
"'body'",
"=>",
"'{\"error\":{\"code\":102,\"description\":\"No valid recipients\"}}'",
"]",
"]",
"]",
";",
"}",
"# Check if there is a sender.",
"if",
"(",
"strlen",
"(",
"$",
"this",
"->",
"from",
")",
"===",
"0",
")",
"{",
"return",
"[",
"0",
"=>",
"[",
"'result'",
"=>",
"[",
"'httpCode'",
"=>",
"400",
",",
"'header'",
"=>",
"''",
",",
"'body'",
"=>",
"'{\"error\":{\"code\":106,\"description\":\"Sender missing\"}}'",
"]",
"]",
"]",
";",
"}",
"# Check if there is a message.",
"if",
"(",
"strlen",
"(",
"$",
"this",
"->",
"msg",
")",
"===",
"0",
")",
"{",
"return",
"[",
"0",
"=>",
"[",
"'result'",
"=>",
"[",
"'httpCode'",
"=>",
"400",
",",
"'header'",
"=>",
"''",
",",
"'body'",
"=>",
"'{\"error\":{\"code\":104,\"description\":\"Text message missing\"}}'",
"]",
"]",
"]",
";",
"}",
"# Send the messages in chunks.",
"$",
"arrChunk",
"=",
"array_chunk",
"(",
"$",
"this",
"->",
"to",
",",
"self",
"::",
"TO_LIMIT_PER_REQUEST",
")",
";",
"foreach",
"(",
"$",
"arrChunk",
"as",
"$",
"i",
"=>",
"$",
"to",
")",
"{",
"$",
"data",
"=",
"[",
"'encoding'",
"=>",
"$",
"this",
"->",
"encoding",
",",
"'to'",
"=>",
"$",
"to",
",",
"'message'",
"=>",
"$",
"this",
"->",
"msg",
",",
"'from'",
"=>",
"$",
"this",
"->",
"from",
",",
"'parts'",
"=>",
"$",
"this",
"->",
"parts",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"campaignName",
")",
")",
"{",
"$",
"data",
"[",
"'campaignName'",
"]",
"=",
"$",
"this",
"->",
"campaignName",
";",
"}",
"$",
"arrChunk",
"[",
"$",
"i",
"]",
"[",
"'result'",
"]",
"=",
"$",
"this",
"->",
"doSend",
"(",
"$",
"data",
")",
";",
"}",
"return",
"$",
"arrChunk",
";",
"}"
] |
Splits the the $to list in chunks of self::TO_LIMIT_PER_REQUEST.
Send the message to every element in all chunks.
@return array|boolean
|
[
"Splits",
"the",
"the",
"$to",
"list",
"in",
"chunks",
"of",
"self",
"::",
"TO_LIMIT_PER_REQUEST",
".",
"Send",
"the",
"message",
"to",
"every",
"element",
"in",
"all",
"chunks",
"."
] |
train
|
https://github.com/marqu3s/nrsgateway/blob/37af229810468518c6c0d25d9742f20f778b9ad1/src/SMSService.php#L58-L131
|
phramework/jsonapi
|
src/Controller/Base.php
|
Base.viewData
|
public static function viewData(
$data,
$links = null,
$meta = null,
$included = null
) {
$viewParameters = new \stdClass();
if ($links) {
$viewParameters->links = $links;
}
$viewParameters->data = $data;
if ($included !== null) {
$viewParameters->included = $included;
}
if ($meta) {
$viewParameters->meta = $meta;
}
\Phramework\Phramework::view($viewParameters);
unset($viewParameters);
return true;
}
|
php
|
public static function viewData(
$data,
$links = null,
$meta = null,
$included = null
) {
$viewParameters = new \stdClass();
if ($links) {
$viewParameters->links = $links;
}
$viewParameters->data = $data;
if ($included !== null) {
$viewParameters->included = $included;
}
if ($meta) {
$viewParameters->meta = $meta;
}
\Phramework\Phramework::view($viewParameters);
unset($viewParameters);
return true;
}
|
[
"public",
"static",
"function",
"viewData",
"(",
"$",
"data",
",",
"$",
"links",
"=",
"null",
",",
"$",
"meta",
"=",
"null",
",",
"$",
"included",
"=",
"null",
")",
"{",
"$",
"viewParameters",
"=",
"new",
"\\",
"stdClass",
"(",
")",
";",
"if",
"(",
"$",
"links",
")",
"{",
"$",
"viewParameters",
"->",
"links",
"=",
"$",
"links",
";",
"}",
"$",
"viewParameters",
"->",
"data",
"=",
"$",
"data",
";",
"if",
"(",
"$",
"included",
"!==",
"null",
")",
"{",
"$",
"viewParameters",
"->",
"included",
"=",
"$",
"included",
";",
"}",
"if",
"(",
"$",
"meta",
")",
"{",
"$",
"viewParameters",
"->",
"meta",
"=",
"$",
"meta",
";",
"}",
"\\",
"Phramework",
"\\",
"Phramework",
"::",
"view",
"(",
"$",
"viewParameters",
")",
";",
"unset",
"(",
"$",
"viewParameters",
")",
";",
"return",
"true",
";",
"}"
] |
View JSONAPI data
@param object $data
@uses \Phramework\Viewers\JSONAPI
@return boolean
|
[
"View",
"JSONAPI",
"data"
] |
train
|
https://github.com/phramework/jsonapi/blob/af20882a8b6f6e5be9c8e09e5b87f6c23a4b0726/src/Controller/Base.php#L85-L112
|
phramework/jsonapi
|
src/Controller/Base.php
|
Base.getRequestInclude
|
protected static function getRequestInclude($parameters, $modelClass = null)
{
//work with arrays
if (!is_object($parameters) && is_array($parameters)) {
$parameters = (object) $parameters;
}
$include = [];
if ($modelClass !== null) {
//Add additional include by default from resource model's relationships
foreach ($modelClass::getRelationships() as $relationshipKey => $relationship) {
if (($relationship->flags & Relationship::FLAG_INCLUDE_BY_DEFAULT) != 0) {
$include[] = $include;
}
}
}
if (!isset($parameters->include) || empty($parameters->include)) {
return $include;
}
//split parameter using , (for multiple values)
foreach (explode(',', $parameters->include) as $i) {
$include[] = trim($i);
}
return array_unique($include);
}
|
php
|
protected static function getRequestInclude($parameters, $modelClass = null)
{
//work with arrays
if (!is_object($parameters) && is_array($parameters)) {
$parameters = (object) $parameters;
}
$include = [];
if ($modelClass !== null) {
//Add additional include by default from resource model's relationships
foreach ($modelClass::getRelationships() as $relationshipKey => $relationship) {
if (($relationship->flags & Relationship::FLAG_INCLUDE_BY_DEFAULT) != 0) {
$include[] = $include;
}
}
}
if (!isset($parameters->include) || empty($parameters->include)) {
return $include;
}
//split parameter using , (for multiple values)
foreach (explode(',', $parameters->include) as $i) {
$include[] = trim($i);
}
return array_unique($include);
}
|
[
"protected",
"static",
"function",
"getRequestInclude",
"(",
"$",
"parameters",
",",
"$",
"modelClass",
"=",
"null",
")",
"{",
"//work with arrays",
"if",
"(",
"!",
"is_object",
"(",
"$",
"parameters",
")",
"&&",
"is_array",
"(",
"$",
"parameters",
")",
")",
"{",
"$",
"parameters",
"=",
"(",
"object",
")",
"$",
"parameters",
";",
"}",
"$",
"include",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"modelClass",
"!==",
"null",
")",
"{",
"//Add additional include by default from resource model's relationships",
"foreach",
"(",
"$",
"modelClass",
"::",
"getRelationships",
"(",
")",
"as",
"$",
"relationshipKey",
"=>",
"$",
"relationship",
")",
"{",
"if",
"(",
"(",
"$",
"relationship",
"->",
"flags",
"&",
"Relationship",
"::",
"FLAG_INCLUDE_BY_DEFAULT",
")",
"!=",
"0",
")",
"{",
"$",
"include",
"[",
"]",
"=",
"$",
"include",
";",
"}",
"}",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"parameters",
"->",
"include",
")",
"||",
"empty",
"(",
"$",
"parameters",
"->",
"include",
")",
")",
"{",
"return",
"$",
"include",
";",
"}",
"//split parameter using , (for multiple values)",
"foreach",
"(",
"explode",
"(",
"','",
",",
"$",
"parameters",
"->",
"include",
")",
"as",
"$",
"i",
")",
"{",
"$",
"include",
"[",
"]",
"=",
"trim",
"(",
"$",
"i",
")",
";",
"}",
"return",
"array_unique",
"(",
"$",
"include",
")",
";",
"}"
] |
Extract included related resources from parameters
@param object $parameters Request parameters
@param string|null $modelClass If not null, will add additional include by default from resource model's relationships
@return string[]
|
[
"Extract",
"included",
"related",
"resources",
"from",
"parameters"
] |
train
|
https://github.com/phramework/jsonapi/blob/af20882a8b6f6e5be9c8e09e5b87f6c23a4b0726/src/Controller/Base.php#L120-L148
|
phramework/jsonapi
|
src/Controller/Base.php
|
Base.getRequestAttributes
|
protected static function getRequestAttributes($parameters)
{
//work with objects
if (is_array($parameters)) {
$parameters = (object) $parameters;
}
//Require data
Request::requireParameters($parameters, ['data']);
//Require data attributes
Request::requireParameters($parameters->data, ['attributes']);
//work with objects
if (is_array($parameters->data)) {
$parameters->data = (object) $parameters->data;
}
return (object) $parameters->data->attributes;
}
|
php
|
protected static function getRequestAttributes($parameters)
{
//work with objects
if (is_array($parameters)) {
$parameters = (object) $parameters;
}
//Require data
Request::requireParameters($parameters, ['data']);
//Require data attributes
Request::requireParameters($parameters->data, ['attributes']);
//work with objects
if (is_array($parameters->data)) {
$parameters->data = (object) $parameters->data;
}
return (object) $parameters->data->attributes;
}
|
[
"protected",
"static",
"function",
"getRequestAttributes",
"(",
"$",
"parameters",
")",
"{",
"//work with objects",
"if",
"(",
"is_array",
"(",
"$",
"parameters",
")",
")",
"{",
"$",
"parameters",
"=",
"(",
"object",
")",
"$",
"parameters",
";",
"}",
"//Require data",
"Request",
"::",
"requireParameters",
"(",
"$",
"parameters",
",",
"[",
"'data'",
"]",
")",
";",
"//Require data attributes",
"Request",
"::",
"requireParameters",
"(",
"$",
"parameters",
"->",
"data",
",",
"[",
"'attributes'",
"]",
")",
";",
"//work with objects",
"if",
"(",
"is_array",
"(",
"$",
"parameters",
"->",
"data",
")",
")",
"{",
"$",
"parameters",
"->",
"data",
"=",
"(",
"object",
")",
"$",
"parameters",
"->",
"data",
";",
"}",
"return",
"(",
"object",
")",
"$",
"parameters",
"->",
"data",
"->",
"attributes",
";",
"}"
] |
Get request data attributes.
The request is expected to have json api structure
Like the following example:
```
(object) [
data => (object) [
'type' => 'user',
'attributes' => [(object)
'email' => '[email protected]',
'password' => 'XXXXXXXXXXXXXXXXXX'
]
]
]
```
@param object $parameters Request parameters
@uses Request::requireParameters
@return object
|
[
"Get",
"request",
"data",
"attributes",
".",
"The",
"request",
"is",
"expected",
"to",
"have",
"json",
"api",
"structure",
"Like",
"the",
"following",
"example",
":",
"(",
"object",
")",
"[",
"data",
"=",
">",
"(",
"object",
")",
"[",
"type",
"=",
">",
"user",
"attributes",
"=",
">",
"[",
"(",
"object",
")",
"email",
"=",
">",
"nohponex"
] |
train
|
https://github.com/phramework/jsonapi/blob/af20882a8b6f6e5be9c8e09e5b87f6c23a4b0726/src/Controller/Base.php#L169-L188
|
phramework/jsonapi
|
src/Controller/Base.php
|
Base.getRequestData
|
protected static function getRequestData($parameters)
{
//work with objects
if (!is_object($parameters) && is_array($parameters)) {
$parameters = (object) $parameters;
}
//Require data
Request::requireParameters($parameters, ['data']);
return $parameters->data;
}
|
php
|
protected static function getRequestData($parameters)
{
//work with objects
if (!is_object($parameters) && is_array($parameters)) {
$parameters = (object) $parameters;
}
//Require data
Request::requireParameters($parameters, ['data']);
return $parameters->data;
}
|
[
"protected",
"static",
"function",
"getRequestData",
"(",
"$",
"parameters",
")",
"{",
"//work with objects",
"if",
"(",
"!",
"is_object",
"(",
"$",
"parameters",
")",
"&&",
"is_array",
"(",
"$",
"parameters",
")",
")",
"{",
"$",
"parameters",
"=",
"(",
"object",
")",
"$",
"parameters",
";",
"}",
"//Require data",
"Request",
"::",
"requireParameters",
"(",
"$",
"parameters",
",",
"[",
"'data'",
"]",
")",
";",
"return",
"$",
"parameters",
"->",
"data",
";",
"}"
] |
Get request primary data
@param object $parameters Request parameters
@uses Request::requireParameters
@return object|object[]
|
[
"Get",
"request",
"primary",
"data"
] |
train
|
https://github.com/phramework/jsonapi/blob/af20882a8b6f6e5be9c8e09e5b87f6c23a4b0726/src/Controller/Base.php#L196-L207
|
phramework/jsonapi
|
src/Controller/Base.php
|
Base.getRequestRelationships
|
protected static function getRequestRelationships($parameters)
{
//work with objects
if (!is_object($parameters) && is_array($parameters)) {
$parameters = (object) $parameters;
}
//Require data
Request::requireParameters($parameters, ['data']);
//Require data['relationships']
if (isset($parameters->data->relationships)) {
return (object) $parameters->data->relationships;
} else {
return new \stdClass();
}
}
|
php
|
protected static function getRequestRelationships($parameters)
{
//work with objects
if (!is_object($parameters) && is_array($parameters)) {
$parameters = (object) $parameters;
}
//Require data
Request::requireParameters($parameters, ['data']);
//Require data['relationships']
if (isset($parameters->data->relationships)) {
return (object) $parameters->data->relationships;
} else {
return new \stdClass();
}
}
|
[
"protected",
"static",
"function",
"getRequestRelationships",
"(",
"$",
"parameters",
")",
"{",
"//work with objects",
"if",
"(",
"!",
"is_object",
"(",
"$",
"parameters",
")",
"&&",
"is_array",
"(",
"$",
"parameters",
")",
")",
"{",
"$",
"parameters",
"=",
"(",
"object",
")",
"$",
"parameters",
";",
"}",
"//Require data",
"Request",
"::",
"requireParameters",
"(",
"$",
"parameters",
",",
"[",
"'data'",
"]",
")",
";",
"//Require data['relationships']",
"if",
"(",
"isset",
"(",
"$",
"parameters",
"->",
"data",
"->",
"relationships",
")",
")",
"{",
"return",
"(",
"object",
")",
"$",
"parameters",
"->",
"data",
"->",
"relationships",
";",
"}",
"else",
"{",
"return",
"new",
"\\",
"stdClass",
"(",
")",
";",
"}",
"}"
] |
Get request relationships if any attributes.
@param object $parameters Request parameters
@return object
|
[
"Get",
"request",
"relationships",
"if",
"any",
"attributes",
"."
] |
train
|
https://github.com/phramework/jsonapi/blob/af20882a8b6f6e5be9c8e09e5b87f6c23a4b0726/src/Controller/Base.php#L214-L230
|
sasedev/composer-plugin-filecopier
|
src/Sasedev/Composer/Plugin/Filescopier/Processor.php
|
Processor.startsWith
|
private function startsWith($string, $prefix) {
return $prefix === "" || strrpos($string, $prefix, -strlen($string)) !== FALSE;
}
|
php
|
private function startsWith($string, $prefix) {
return $prefix === "" || strrpos($string, $prefix, -strlen($string)) !== FALSE;
}
|
[
"private",
"function",
"startsWith",
"(",
"$",
"string",
",",
"$",
"prefix",
")",
"{",
"return",
"$",
"prefix",
"===",
"\"\"",
"||",
"strrpos",
"(",
"$",
"string",
",",
"$",
"prefix",
",",
"-",
"strlen",
"(",
"$",
"string",
")",
")",
"!==",
"FALSE",
";",
"}"
] |
Check if a string starts with a prefix
@param string $string
@param string $prefix
@return boolean
|
[
"Check",
"if",
"a",
"string",
"starts",
"with",
"a",
"prefix"
] |
train
|
https://github.com/sasedev/composer-plugin-filecopier/blob/0cb2430d9a95b3955e05a8fe43054751c08b9f07/src/Sasedev/Composer/Plugin/Filescopier/Processor.php#L189-L191
|
sasedev/composer-plugin-filecopier
|
src/Sasedev/Composer/Plugin/Filescopier/Processor.php
|
Processor.endswith
|
private function endswith($string, $suffix)
{
$strlen = strlen($string);
$testlen = strlen($suffix);
if ($testlen > $strlen) {
return false;
}
return substr_compare($string, $suffix, -$testlen) === 0;
}
|
php
|
private function endswith($string, $suffix)
{
$strlen = strlen($string);
$testlen = strlen($suffix);
if ($testlen > $strlen) {
return false;
}
return substr_compare($string, $suffix, -$testlen) === 0;
}
|
[
"private",
"function",
"endswith",
"(",
"$",
"string",
",",
"$",
"suffix",
")",
"{",
"$",
"strlen",
"=",
"strlen",
"(",
"$",
"string",
")",
";",
"$",
"testlen",
"=",
"strlen",
"(",
"$",
"suffix",
")",
";",
"if",
"(",
"$",
"testlen",
">",
"$",
"strlen",
")",
"{",
"return",
"false",
";",
"}",
"return",
"substr_compare",
"(",
"$",
"string",
",",
"$",
"suffix",
",",
"-",
"$",
"testlen",
")",
"===",
"0",
";",
"}"
] |
Check if a string ends with a suffix
@param string $string
@param string $suffix
@return boolean
|
[
"Check",
"if",
"a",
"string",
"ends",
"with",
"a",
"suffix"
] |
train
|
https://github.com/sasedev/composer-plugin-filecopier/blob/0cb2430d9a95b3955e05a8fe43054751c08b9f07/src/Sasedev/Composer/Plugin/Filescopier/Processor.php#L201-L210
|
harp-orm/query
|
src/Compiler/Delete.php
|
Delete.render
|
public static function render(Query\Delete $query)
{
return Compiler::withDb($query->getDb(), function () use ($query) {
return Compiler::expression(array(
'DELETE',
$query->getType(),
Aliased::combine($query->getTable()),
Compiler::word('FROM', Aliased::combine($query->getFrom())),
Join::combine($query->getJoin()),
Compiler::word('WHERE', Condition::combine($query->getWhere())),
Compiler::word('ORDER BY', Direction::combine($query->getOrder())),
Compiler::word('LIMIT', $query->getLimit()),
));
});
}
|
php
|
public static function render(Query\Delete $query)
{
return Compiler::withDb($query->getDb(), function () use ($query) {
return Compiler::expression(array(
'DELETE',
$query->getType(),
Aliased::combine($query->getTable()),
Compiler::word('FROM', Aliased::combine($query->getFrom())),
Join::combine($query->getJoin()),
Compiler::word('WHERE', Condition::combine($query->getWhere())),
Compiler::word('ORDER BY', Direction::combine($query->getOrder())),
Compiler::word('LIMIT', $query->getLimit()),
));
});
}
|
[
"public",
"static",
"function",
"render",
"(",
"Query",
"\\",
"Delete",
"$",
"query",
")",
"{",
"return",
"Compiler",
"::",
"withDb",
"(",
"$",
"query",
"->",
"getDb",
"(",
")",
",",
"function",
"(",
")",
"use",
"(",
"$",
"query",
")",
"{",
"return",
"Compiler",
"::",
"expression",
"(",
"array",
"(",
"'DELETE'",
",",
"$",
"query",
"->",
"getType",
"(",
")",
",",
"Aliased",
"::",
"combine",
"(",
"$",
"query",
"->",
"getTable",
"(",
")",
")",
",",
"Compiler",
"::",
"word",
"(",
"'FROM'",
",",
"Aliased",
"::",
"combine",
"(",
"$",
"query",
"->",
"getFrom",
"(",
")",
")",
")",
",",
"Join",
"::",
"combine",
"(",
"$",
"query",
"->",
"getJoin",
"(",
")",
")",
",",
"Compiler",
"::",
"word",
"(",
"'WHERE'",
",",
"Condition",
"::",
"combine",
"(",
"$",
"query",
"->",
"getWhere",
"(",
")",
")",
")",
",",
"Compiler",
"::",
"word",
"(",
"'ORDER BY'",
",",
"Direction",
"::",
"combine",
"(",
"$",
"query",
"->",
"getOrder",
"(",
")",
")",
")",
",",
"Compiler",
"::",
"word",
"(",
"'LIMIT'",
",",
"$",
"query",
"->",
"getLimit",
"(",
")",
")",
",",
")",
")",
";",
"}",
")",
";",
"}"
] |
Render a Delete object
@param Query\Delete $query
@return string
|
[
"Render",
"a",
"Delete",
"object"
] |
train
|
https://github.com/harp-orm/query/blob/98ce2468a0a31fe15ed3692bad32547bf6dbe41a/src/Compiler/Delete.php#L19-L33
|
darkwebdesign/doctrine-unit-testing
|
src/Mocks/CacheRegionMock.php
|
CacheRegionMock.getReturn
|
private function getReturn($method, $default)
{
if (isset($this->returns[$method]) && ! empty($this->returns[$method])) {
return array_shift($this->returns[$method]);
}
return $default;
}
|
php
|
private function getReturn($method, $default)
{
if (isset($this->returns[$method]) && ! empty($this->returns[$method])) {
return array_shift($this->returns[$method]);
}
return $default;
}
|
[
"private",
"function",
"getReturn",
"(",
"$",
"method",
",",
"$",
"default",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"returns",
"[",
"$",
"method",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"returns",
"[",
"$",
"method",
"]",
")",
")",
"{",
"return",
"array_shift",
"(",
"$",
"this",
"->",
"returns",
"[",
"$",
"method",
"]",
")",
";",
"}",
"return",
"$",
"default",
";",
"}"
] |
Dequeue a value for a specific method invocation
@param string $method
@param mixed $default
@return mixed
|
[
"Dequeue",
"a",
"value",
"for",
"a",
"specific",
"method",
"invocation"
] |
train
|
https://github.com/darkwebdesign/doctrine-unit-testing/blob/0daf50359563bc0679925e573a7105d6cd57168a/src/Mocks/CacheRegionMock.php#L39-L46
|
darkwebdesign/doctrine-unit-testing
|
src/Mocks/CacheRegionMock.php
|
CacheRegionMock.contains
|
public function contains(CacheKey $key)
{
$this->calls[__FUNCTION__][] = ['key' => $key];
return $this->getReturn(__FUNCTION__, false);
}
|
php
|
public function contains(CacheKey $key)
{
$this->calls[__FUNCTION__][] = ['key' => $key];
return $this->getReturn(__FUNCTION__, false);
}
|
[
"public",
"function",
"contains",
"(",
"CacheKey",
"$",
"key",
")",
"{",
"$",
"this",
"->",
"calls",
"[",
"__FUNCTION__",
"]",
"[",
"]",
"=",
"[",
"'key'",
"=>",
"$",
"key",
"]",
";",
"return",
"$",
"this",
"->",
"getReturn",
"(",
"__FUNCTION__",
",",
"false",
")",
";",
"}"
] |
{@inheritdoc}
|
[
"{"
] |
train
|
https://github.com/darkwebdesign/doctrine-unit-testing/blob/0daf50359563bc0679925e573a7105d6cd57168a/src/Mocks/CacheRegionMock.php#L61-L66
|
darkwebdesign/doctrine-unit-testing
|
src/Mocks/CacheRegionMock.php
|
CacheRegionMock.evict
|
public function evict(CacheKey $key)
{
$this->calls[__FUNCTION__][] = ['key' => $key];
return $this->getReturn(__FUNCTION__, true);
}
|
php
|
public function evict(CacheKey $key)
{
$this->calls[__FUNCTION__][] = ['key' => $key];
return $this->getReturn(__FUNCTION__, true);
}
|
[
"public",
"function",
"evict",
"(",
"CacheKey",
"$",
"key",
")",
"{",
"$",
"this",
"->",
"calls",
"[",
"__FUNCTION__",
"]",
"[",
"]",
"=",
"[",
"'key'",
"=>",
"$",
"key",
"]",
";",
"return",
"$",
"this",
"->",
"getReturn",
"(",
"__FUNCTION__",
",",
"true",
")",
";",
"}"
] |
{@inheritdoc}
|
[
"{"
] |
train
|
https://github.com/darkwebdesign/doctrine-unit-testing/blob/0daf50359563bc0679925e573a7105d6cd57168a/src/Mocks/CacheRegionMock.php#L71-L76
|
darkwebdesign/doctrine-unit-testing
|
src/Mocks/CacheRegionMock.php
|
CacheRegionMock.get
|
public function get(CacheKey $key)
{
$this->calls[__FUNCTION__][] = ['key' => $key];
return $this->getReturn(__FUNCTION__, null);
}
|
php
|
public function get(CacheKey $key)
{
$this->calls[__FUNCTION__][] = ['key' => $key];
return $this->getReturn(__FUNCTION__, null);
}
|
[
"public",
"function",
"get",
"(",
"CacheKey",
"$",
"key",
")",
"{",
"$",
"this",
"->",
"calls",
"[",
"__FUNCTION__",
"]",
"[",
"]",
"=",
"[",
"'key'",
"=>",
"$",
"key",
"]",
";",
"return",
"$",
"this",
"->",
"getReturn",
"(",
"__FUNCTION__",
",",
"null",
")",
";",
"}"
] |
{@inheritdoc}
|
[
"{"
] |
train
|
https://github.com/darkwebdesign/doctrine-unit-testing/blob/0daf50359563bc0679925e573a7105d6cd57168a/src/Mocks/CacheRegionMock.php#L91-L96
|
darkwebdesign/doctrine-unit-testing
|
src/Mocks/CacheRegionMock.php
|
CacheRegionMock.getMultiple
|
public function getMultiple(CollectionCacheEntry $collection)
{
$this->calls[__FUNCTION__][] = ['collection' => $collection];
return $this->getReturn(__FUNCTION__, null);
}
|
php
|
public function getMultiple(CollectionCacheEntry $collection)
{
$this->calls[__FUNCTION__][] = ['collection' => $collection];
return $this->getReturn(__FUNCTION__, null);
}
|
[
"public",
"function",
"getMultiple",
"(",
"CollectionCacheEntry",
"$",
"collection",
")",
"{",
"$",
"this",
"->",
"calls",
"[",
"__FUNCTION__",
"]",
"[",
"]",
"=",
"[",
"'collection'",
"=>",
"$",
"collection",
"]",
";",
"return",
"$",
"this",
"->",
"getReturn",
"(",
"__FUNCTION__",
",",
"null",
")",
";",
"}"
] |
{@inheritdoc}
|
[
"{"
] |
train
|
https://github.com/darkwebdesign/doctrine-unit-testing/blob/0daf50359563bc0679925e573a7105d6cd57168a/src/Mocks/CacheRegionMock.php#L101-L106
|
darkwebdesign/doctrine-unit-testing
|
src/Mocks/CacheRegionMock.php
|
CacheRegionMock.put
|
public function put(CacheKey $key, CacheEntry $entry, Lock $lock = null)
{
$this->calls[__FUNCTION__][] = ['key' => $key, 'entry' => $entry];
return $this->getReturn(__FUNCTION__, true);
}
|
php
|
public function put(CacheKey $key, CacheEntry $entry, Lock $lock = null)
{
$this->calls[__FUNCTION__][] = ['key' => $key, 'entry' => $entry];
return $this->getReturn(__FUNCTION__, true);
}
|
[
"public",
"function",
"put",
"(",
"CacheKey",
"$",
"key",
",",
"CacheEntry",
"$",
"entry",
",",
"Lock",
"$",
"lock",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"calls",
"[",
"__FUNCTION__",
"]",
"[",
"]",
"=",
"[",
"'key'",
"=>",
"$",
"key",
",",
"'entry'",
"=>",
"$",
"entry",
"]",
";",
"return",
"$",
"this",
"->",
"getReturn",
"(",
"__FUNCTION__",
",",
"true",
")",
";",
"}"
] |
{@inheritdoc}
|
[
"{"
] |
train
|
https://github.com/darkwebdesign/doctrine-unit-testing/blob/0daf50359563bc0679925e573a7105d6cd57168a/src/Mocks/CacheRegionMock.php#L111-L116
|
fsi-open/datasource-bundle
|
DataSource/Extension/Symfony/Core/EventSubscriber/BindParameters.php
|
BindParameters.preBindParameters
|
public function preBindParameters(DataSourceEvent\ParametersEventArgs $event)
{
$parameters = $event->getParameters();
if ($parameters instanceof Request) {
$event->setParameters($parameters->query->all());
}
}
|
php
|
public function preBindParameters(DataSourceEvent\ParametersEventArgs $event)
{
$parameters = $event->getParameters();
if ($parameters instanceof Request) {
$event->setParameters($parameters->query->all());
}
}
|
[
"public",
"function",
"preBindParameters",
"(",
"DataSourceEvent",
"\\",
"ParametersEventArgs",
"$",
"event",
")",
"{",
"$",
"parameters",
"=",
"$",
"event",
"->",
"getParameters",
"(",
")",
";",
"if",
"(",
"$",
"parameters",
"instanceof",
"Request",
")",
"{",
"$",
"event",
"->",
"setParameters",
"(",
"$",
"parameters",
"->",
"query",
"->",
"all",
"(",
")",
")",
";",
"}",
"}"
] |
Method called at PreBindParameters event.
@param DataSourceEvent\ParametersEventArgs $event
|
[
"Method",
"called",
"at",
"PreBindParameters",
"event",
"."
] |
train
|
https://github.com/fsi-open/datasource-bundle/blob/06964672c838af9f4125065e3a90b2df4e8aa077/DataSource/Extension/Symfony/Core/EventSubscriber/BindParameters.php#L35-L41
|
vincentchalamon/VinceCmsSonataAdminBundle
|
Form/Type/MetaType.php
|
MetaType.buildForm
|
public function buildForm(FormBuilderInterface $builder, array $options)
{
foreach ($options['metas'] as $meta) {
/** @var Meta $meta */
$builder->add($meta->getName(), $meta->getType(), array(
'label' => $meta->getTitle(),
'required' => false,
)
);
}
}
|
php
|
public function buildForm(FormBuilderInterface $builder, array $options)
{
foreach ($options['metas'] as $meta) {
/** @var Meta $meta */
$builder->add($meta->getName(), $meta->getType(), array(
'label' => $meta->getTitle(),
'required' => false,
)
);
}
}
|
[
"public",
"function",
"buildForm",
"(",
"FormBuilderInterface",
"$",
"builder",
",",
"array",
"$",
"options",
")",
"{",
"foreach",
"(",
"$",
"options",
"[",
"'metas'",
"]",
"as",
"$",
"meta",
")",
"{",
"/** @var Meta $meta */",
"$",
"builder",
"->",
"add",
"(",
"$",
"meta",
"->",
"getName",
"(",
")",
",",
"$",
"meta",
"->",
"getType",
"(",
")",
",",
"array",
"(",
"'label'",
"=>",
"$",
"meta",
"->",
"getTitle",
"(",
")",
",",
"'required'",
"=>",
"false",
",",
")",
")",
";",
"}",
"}"
] |
{@inheritdoc}
|
[
"{"
] |
train
|
https://github.com/vincentchalamon/VinceCmsSonataAdminBundle/blob/edc768061734a92ba116488dd7b61ad40af21ceb/Form/Type/MetaType.php#L28-L38
|
bestit/commercetools-order-export-bundle
|
src/DependencyInjection/Configuration.php
|
Configuration.getConfigTreeBuilder
|
public function getConfigTreeBuilder()
{
$builder = new TreeBuilder();
$rootNode = $builder->root('best_it_ct_order_export');
$rootNode
->children()
->arrayNode('commercetools_client')
->isRequired()
->children()
->scalarNode('id')->cannotBeEmpty()->isRequired()->end()
->scalarNode('secret')->cannotBeEmpty()->isRequired()->end()
->scalarNode('project')->cannotBeEmpty()->isRequired()->end()
->scalarNode('scope')->cannotBeEmpty()->isRequired()->end()
->end()
->end()
->scalarNode('filesystem')
->info('Please provide the service id for your flysystem file system.')
->isRequired()
->end()
->scalarNode('logger')
->info('Please provide the service id for your logging service.')
->defaultValue('logger')
->end()
->arrayNode('orders')
->children()
->booleanNode('with_pagination')
->defaultValue(true)
->info(
'Should we use a paginated list of orders (or is the result list changing by "itself")?'
)
->end()
->arrayNode('default_where')
->info(
'Add where clauses for orders: ' .
'https://dev.commercetools.com/http-api-projects-orders.html#query-orders'
)
->prototype('scalar')->end()
->end()
->scalarNode('file_template')
->info('Which template is used for the export of a single order?')
->defaultValue('detail.xml.twig')
->end()
->scalarNode('name_scheme')
->defaultValue('order_{{id}}_{{YmdHis}}.xml')
->info(
'Provide an order field name or a format string for the date function enclosed ' .
'with {{ and }}.'
)
->end()
->end()
->end();
return $builder;
}
|
php
|
public function getConfigTreeBuilder()
{
$builder = new TreeBuilder();
$rootNode = $builder->root('best_it_ct_order_export');
$rootNode
->children()
->arrayNode('commercetools_client')
->isRequired()
->children()
->scalarNode('id')->cannotBeEmpty()->isRequired()->end()
->scalarNode('secret')->cannotBeEmpty()->isRequired()->end()
->scalarNode('project')->cannotBeEmpty()->isRequired()->end()
->scalarNode('scope')->cannotBeEmpty()->isRequired()->end()
->end()
->end()
->scalarNode('filesystem')
->info('Please provide the service id for your flysystem file system.')
->isRequired()
->end()
->scalarNode('logger')
->info('Please provide the service id for your logging service.')
->defaultValue('logger')
->end()
->arrayNode('orders')
->children()
->booleanNode('with_pagination')
->defaultValue(true)
->info(
'Should we use a paginated list of orders (or is the result list changing by "itself")?'
)
->end()
->arrayNode('default_where')
->info(
'Add where clauses for orders: ' .
'https://dev.commercetools.com/http-api-projects-orders.html#query-orders'
)
->prototype('scalar')->end()
->end()
->scalarNode('file_template')
->info('Which template is used for the export of a single order?')
->defaultValue('detail.xml.twig')
->end()
->scalarNode('name_scheme')
->defaultValue('order_{{id}}_{{YmdHis}}.xml')
->info(
'Provide an order field name or a format string for the date function enclosed ' .
'with {{ and }}.'
)
->end()
->end()
->end();
return $builder;
}
|
[
"public",
"function",
"getConfigTreeBuilder",
"(",
")",
"{",
"$",
"builder",
"=",
"new",
"TreeBuilder",
"(",
")",
";",
"$",
"rootNode",
"=",
"$",
"builder",
"->",
"root",
"(",
"'best_it_ct_order_export'",
")",
";",
"$",
"rootNode",
"->",
"children",
"(",
")",
"->",
"arrayNode",
"(",
"'commercetools_client'",
")",
"->",
"isRequired",
"(",
")",
"->",
"children",
"(",
")",
"->",
"scalarNode",
"(",
"'id'",
")",
"->",
"cannotBeEmpty",
"(",
")",
"->",
"isRequired",
"(",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'secret'",
")",
"->",
"cannotBeEmpty",
"(",
")",
"->",
"isRequired",
"(",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'project'",
")",
"->",
"cannotBeEmpty",
"(",
")",
"->",
"isRequired",
"(",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'scope'",
")",
"->",
"cannotBeEmpty",
"(",
")",
"->",
"isRequired",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'filesystem'",
")",
"->",
"info",
"(",
"'Please provide the service id for your flysystem file system.'",
")",
"->",
"isRequired",
"(",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'logger'",
")",
"->",
"info",
"(",
"'Please provide the service id for your logging service.'",
")",
"->",
"defaultValue",
"(",
"'logger'",
")",
"->",
"end",
"(",
")",
"->",
"arrayNode",
"(",
"'orders'",
")",
"->",
"children",
"(",
")",
"->",
"booleanNode",
"(",
"'with_pagination'",
")",
"->",
"defaultValue",
"(",
"true",
")",
"->",
"info",
"(",
"'Should we use a paginated list of orders (or is the result list changing by \"itself\")?'",
")",
"->",
"end",
"(",
")",
"->",
"arrayNode",
"(",
"'default_where'",
")",
"->",
"info",
"(",
"'Add where clauses for orders: '",
".",
"'https://dev.commercetools.com/http-api-projects-orders.html#query-orders'",
")",
"->",
"prototype",
"(",
"'scalar'",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'file_template'",
")",
"->",
"info",
"(",
"'Which template is used for the export of a single order?'",
")",
"->",
"defaultValue",
"(",
"'detail.xml.twig'",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'name_scheme'",
")",
"->",
"defaultValue",
"(",
"'order_{{id}}_{{YmdHis}}.xml'",
")",
"->",
"info",
"(",
"'Provide an order field name or a format string for the date function enclosed '",
".",
"'with {{ and }}.'",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
";",
"return",
"$",
"builder",
";",
"}"
] |
Parses the config.
@return TreeBuilder
|
[
"Parses",
"the",
"config",
"."
] |
train
|
https://github.com/bestit/commercetools-order-export-bundle/blob/44bd0dedff6edab5ecf5803dcf6d24ffe0dbf845/src/DependencyInjection/Configuration.php#L21-L76
|
movoin/one-swoole
|
src/Swoole/Components/Task/Provider.php
|
Provider.register
|
public function register()
{
$this->bind('task', function ($server) {
$scheduler = new Scheduler;
$scheduler->setSwoole($server->getSwoole());
// {{ Attach Task Handlers
$tasks = $this->config('task', []);
foreach ($tasks as $name => $handler) {
$scheduler->push($name, $handler);
}
unset($tasks);
// }}
return $scheduler;
});
}
|
php
|
public function register()
{
$this->bind('task', function ($server) {
$scheduler = new Scheduler;
$scheduler->setSwoole($server->getSwoole());
// {{ Attach Task Handlers
$tasks = $this->config('task', []);
foreach ($tasks as $name => $handler) {
$scheduler->push($name, $handler);
}
unset($tasks);
// }}
return $scheduler;
});
}
|
[
"public",
"function",
"register",
"(",
")",
"{",
"$",
"this",
"->",
"bind",
"(",
"'task'",
",",
"function",
"(",
"$",
"server",
")",
"{",
"$",
"scheduler",
"=",
"new",
"Scheduler",
";",
"$",
"scheduler",
"->",
"setSwoole",
"(",
"$",
"server",
"->",
"getSwoole",
"(",
")",
")",
";",
"// {{ Attach Task Handlers",
"$",
"tasks",
"=",
"$",
"this",
"->",
"config",
"(",
"'task'",
",",
"[",
"]",
")",
";",
"foreach",
"(",
"$",
"tasks",
"as",
"$",
"name",
"=>",
"$",
"handler",
")",
"{",
"$",
"scheduler",
"->",
"push",
"(",
"$",
"name",
",",
"$",
"handler",
")",
";",
"}",
"unset",
"(",
"$",
"tasks",
")",
";",
"// }}",
"return",
"$",
"scheduler",
";",
"}",
")",
";",
"}"
] |
注册服务
|
[
"注册服务"
] |
train
|
https://github.com/movoin/one-swoole/blob/b9b175963ead91416cc50902a04e05ff3ef571de/src/Swoole/Components/Task/Provider.php#L22-L40
|
phramework/jsonapi
|
src/Model/Directives.php
|
Directives.handleGet
|
protected static function handleGet(
$query,
Page $page = null,
Filter $filter = null,
Sort $sort = null,
Fields $fields = null,
$hasWhere = true
) {
$query = str_replace('{{table}}', static::getTable(), $query);
$query = trim(self::handleFields(
self::handlePage(
self::handleSort(
self::handleFilter(
$query,
$filter,
$hasWhere
),
$sort ?? static::getSort()
),
$page
),
$fields
));
return $query;
}
|
php
|
protected static function handleGet(
$query,
Page $page = null,
Filter $filter = null,
Sort $sort = null,
Fields $fields = null,
$hasWhere = true
) {
$query = str_replace('{{table}}', static::getTable(), $query);
$query = trim(self::handleFields(
self::handlePage(
self::handleSort(
self::handleFilter(
$query,
$filter,
$hasWhere
),
$sort ?? static::getSort()
),
$page
),
$fields
));
return $query;
}
|
[
"protected",
"static",
"function",
"handleGet",
"(",
"$",
"query",
",",
"Page",
"$",
"page",
"=",
"null",
",",
"Filter",
"$",
"filter",
"=",
"null",
",",
"Sort",
"$",
"sort",
"=",
"null",
",",
"Fields",
"$",
"fields",
"=",
"null",
",",
"$",
"hasWhere",
"=",
"true",
")",
"{",
"$",
"query",
"=",
"str_replace",
"(",
"'{{table}}'",
",",
"static",
"::",
"getTable",
"(",
")",
",",
"$",
"query",
")",
";",
"$",
"query",
"=",
"trim",
"(",
"self",
"::",
"handleFields",
"(",
"self",
"::",
"handlePage",
"(",
"self",
"::",
"handleSort",
"(",
"self",
"::",
"handleFilter",
"(",
"$",
"query",
",",
"$",
"filter",
",",
"$",
"hasWhere",
")",
",",
"$",
"sort",
"??",
"static",
"::",
"getSort",
"(",
")",
")",
",",
"$",
"page",
")",
",",
"$",
"fields",
")",
")",
";",
"return",
"$",
"query",
";",
"}"
] |
Apply page, filter, sort and fields directives to query.
This method will replace `{{table}}`, `{{sort}}`, `{{page}}`, `{{filter}}` and `{{fields}}` in query.
@uses static::handlePage
@uses static::handleSort
@uses static::handleFilter
@uses static::handleFields
@param string $query Query string
@param Page|null $page See handlePage $page parameter
@param Filter|null $filter See handleFilter $filter parameter
@param Sort|null $sort See handleSort $sort parameter
@param Fields|null $fields See handleFields $fields parameter
@param boolean $hasWhere If query already has an WHERE, default is true
@return string Query
@example
```php
$query = static::handleGet(
'SELECT {{fields}}
FROM "{{table}}"
WHERE
"{{table}}"."status" <> \'DISABLED\'
{{filter}}
{{sort}}
{{page}}',
$page,
$filter,
$sort,
$fields,
$page,
true //query contains WHERE directive
);
```
|
[
"Apply",
"page",
"filter",
"sort",
"and",
"fields",
"directives",
"to",
"query",
".",
"This",
"method",
"will",
"replace",
"{{",
"table",
"}}",
"{{",
"sort",
"}}",
"{{",
"page",
"}}",
"{{",
"filter",
"}}",
"and",
"{{",
"fields",
"}}",
"in",
"query",
"."
] |
train
|
https://github.com/phramework/jsonapi/blob/af20882a8b6f6e5be9c8e09e5b87f6c23a4b0726/src/Model/Directives.php#L71-L97
|
phramework/jsonapi
|
src/Model/Directives.php
|
Directives.handleSort
|
private static function handleSort($query, $sort = null)
{
$replace = '';
if ($sort !== null) {
$sort ->validate(static::class);
$tableAttribute = (
$sort->table === null
? $sort->attribute
: $sort->table . '"."' .$sort->attribute
);
$replace = "\n" . sprintf(
'ORDER BY "%s" %s',
$tableAttribute,
($sort->ascending ? 'ASC' : 'DESC')
);
}
$query = str_replace(
'{{sort}}',
$replace,
$query
);
return $query;
}
|
php
|
private static function handleSort($query, $sort = null)
{
$replace = '';
if ($sort !== null) {
$sort ->validate(static::class);
$tableAttribute = (
$sort->table === null
? $sort->attribute
: $sort->table . '"."' .$sort->attribute
);
$replace = "\n" . sprintf(
'ORDER BY "%s" %s',
$tableAttribute,
($sort->ascending ? 'ASC' : 'DESC')
);
}
$query = str_replace(
'{{sort}}',
$replace,
$query
);
return $query;
}
|
[
"private",
"static",
"function",
"handleSort",
"(",
"$",
"query",
",",
"$",
"sort",
"=",
"null",
")",
"{",
"$",
"replace",
"=",
"''",
";",
"if",
"(",
"$",
"sort",
"!==",
"null",
")",
"{",
"$",
"sort",
"->",
"validate",
"(",
"static",
"::",
"class",
")",
";",
"$",
"tableAttribute",
"=",
"(",
"$",
"sort",
"->",
"table",
"===",
"null",
"?",
"$",
"sort",
"->",
"attribute",
":",
"$",
"sort",
"->",
"table",
".",
"'\".\"'",
".",
"$",
"sort",
"->",
"attribute",
")",
";",
"$",
"replace",
"=",
"\"\\n\"",
".",
"sprintf",
"(",
"'ORDER BY \"%s\" %s'",
",",
"$",
"tableAttribute",
",",
"(",
"$",
"sort",
"->",
"ascending",
"?",
"'ASC'",
":",
"'DESC'",
")",
")",
";",
"}",
"$",
"query",
"=",
"str_replace",
"(",
"'{{sort}}'",
",",
"$",
"replace",
",",
"$",
"query",
")",
";",
"return",
"$",
"query",
";",
"}"
] |
This method will update `{{sort}}` string inside query parameter with
the provided sort directive
@param string $query Query
@param Sort|null $sort
@return string Query
|
[
"This",
"method",
"will",
"update",
"{{",
"sort",
"}}",
"string",
"inside",
"query",
"parameter",
"with",
"the",
"provided",
"sort",
"directive"
] |
train
|
https://github.com/phramework/jsonapi/blob/af20882a8b6f6e5be9c8e09e5b87f6c23a4b0726/src/Model/Directives.php#L106-L133
|
phramework/jsonapi
|
src/Model/Directives.php
|
Directives.handlePage
|
private static function handlePage($query, $page = null)
{
/**
* string[]
*/
$additionalQuery = [];
if ($page === null) {
//Use resource model's default page
$page = static::getDefaultPage();
}
if ($page->limit !== null) {
if ($page->limit > static::getMaxPageLimit()) {
throw new RequestException(
'Page object limit is greater than resource model`s maximum limit'
);
}
$additionalQuery[] = sprintf(
'LIMIT %s',
$page->limit
);
}
if ($page->offset) {
$additionalQuery[] = sprintf(
'OFFSET %s',
$page->offset
);
}
$query = str_replace(
'{{page}}',
implode("\n", $additionalQuery),
$query
);
return $query;
}
|
php
|
private static function handlePage($query, $page = null)
{
/**
* string[]
*/
$additionalQuery = [];
if ($page === null) {
//Use resource model's default page
$page = static::getDefaultPage();
}
if ($page->limit !== null) {
if ($page->limit > static::getMaxPageLimit()) {
throw new RequestException(
'Page object limit is greater than resource model`s maximum limit'
);
}
$additionalQuery[] = sprintf(
'LIMIT %s',
$page->limit
);
}
if ($page->offset) {
$additionalQuery[] = sprintf(
'OFFSET %s',
$page->offset
);
}
$query = str_replace(
'{{page}}',
implode("\n", $additionalQuery),
$query
);
return $query;
}
|
[
"private",
"static",
"function",
"handlePage",
"(",
"$",
"query",
",",
"$",
"page",
"=",
"null",
")",
"{",
"/**\n * string[]\n */",
"$",
"additionalQuery",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"page",
"===",
"null",
")",
"{",
"//Use resource model's default page",
"$",
"page",
"=",
"static",
"::",
"getDefaultPage",
"(",
")",
";",
"}",
"if",
"(",
"$",
"page",
"->",
"limit",
"!==",
"null",
")",
"{",
"if",
"(",
"$",
"page",
"->",
"limit",
">",
"static",
"::",
"getMaxPageLimit",
"(",
")",
")",
"{",
"throw",
"new",
"RequestException",
"(",
"'Page object limit is greater than resource model`s maximum limit'",
")",
";",
"}",
"$",
"additionalQuery",
"[",
"]",
"=",
"sprintf",
"(",
"'LIMIT %s'",
",",
"$",
"page",
"->",
"limit",
")",
";",
"}",
"if",
"(",
"$",
"page",
"->",
"offset",
")",
"{",
"$",
"additionalQuery",
"[",
"]",
"=",
"sprintf",
"(",
"'OFFSET %s'",
",",
"$",
"page",
"->",
"offset",
")",
";",
"}",
"$",
"query",
"=",
"str_replace",
"(",
"'{{page}}'",
",",
"implode",
"(",
"\"\\n\"",
",",
"$",
"additionalQuery",
")",
",",
"$",
"query",
")",
";",
"return",
"$",
"query",
";",
"}"
] |
This method will update `{{page}}` string inside query parameter with
the provided pagination directive
@param string $query Query
@param Page|null $page
@return string Query
@uses Model::getDefaultPage if page is null
@throws RequestException
|
[
"This",
"method",
"will",
"update",
"{{",
"page",
"}}",
"string",
"inside",
"query",
"parameter",
"with",
"the",
"provided",
"pagination",
"directive"
] |
train
|
https://github.com/phramework/jsonapi/blob/af20882a8b6f6e5be9c8e09e5b87f6c23a4b0726/src/Model/Directives.php#L144-L183
|
phramework/jsonapi
|
src/Model/Directives.php
|
Directives.handleFields
|
private static function handleFields(
$query,
Fields $fields = null
) {
$type = static::getType();
if ($fields === null || empty($fields->get($type))) {
//Use resource model's default fields
$fields = static::getDefaultFields();
$attributes = array_merge(
$fields->get($type),
[static::getIdAttribute()] //[static::getTable() . '.' . static::getIdAttribute()]
);
} else {
$attributes = $fields->get($type);
if ($fields->get($type) !== ['*']) {
//Get field attributes for this type and force id attribute
$attributes = array_merge(
$fields->get($type),
[static::getIdAttribute()]
);
}
}
//if ($fields !== null && !empty($fields->get($type))) {
$fields->validate(static::class);
$attributes = array_unique($attributes);
/**
* @param string $column
* @return string
*/
$escape = function ($column) {
if ($column === '*') {
return $column;
}
return sprintf('"%s"', $column);
};
/**
* This method will prepare the attributes by prefixing then with "
* - * -> *
* - table.* -> "table".*
* - id -> "id"
* - table.id -> "table"."id"
* and glue them with comma separator
*/
$queryPart = implode(
',',
array_map(
function ($attribute) use ($escape) {
return implode(
'.',
array_map($escape, explode('.', $attribute))
);
},
$attributes
)
);
//}
$query = str_replace(
'{{fields}}',
$queryPart,
$query
);
return $query;
}
|
php
|
private static function handleFields(
$query,
Fields $fields = null
) {
$type = static::getType();
if ($fields === null || empty($fields->get($type))) {
//Use resource model's default fields
$fields = static::getDefaultFields();
$attributes = array_merge(
$fields->get($type),
[static::getIdAttribute()] //[static::getTable() . '.' . static::getIdAttribute()]
);
} else {
$attributes = $fields->get($type);
if ($fields->get($type) !== ['*']) {
//Get field attributes for this type and force id attribute
$attributes = array_merge(
$fields->get($type),
[static::getIdAttribute()]
);
}
}
//if ($fields !== null && !empty($fields->get($type))) {
$fields->validate(static::class);
$attributes = array_unique($attributes);
/**
* @param string $column
* @return string
*/
$escape = function ($column) {
if ($column === '*') {
return $column;
}
return sprintf('"%s"', $column);
};
/**
* This method will prepare the attributes by prefixing then with "
* - * -> *
* - table.* -> "table".*
* - id -> "id"
* - table.id -> "table"."id"
* and glue them with comma separator
*/
$queryPart = implode(
',',
array_map(
function ($attribute) use ($escape) {
return implode(
'.',
array_map($escape, explode('.', $attribute))
);
},
$attributes
)
);
//}
$query = str_replace(
'{{fields}}',
$queryPart,
$query
);
return $query;
}
|
[
"private",
"static",
"function",
"handleFields",
"(",
"$",
"query",
",",
"Fields",
"$",
"fields",
"=",
"null",
")",
"{",
"$",
"type",
"=",
"static",
"::",
"getType",
"(",
")",
";",
"if",
"(",
"$",
"fields",
"===",
"null",
"||",
"empty",
"(",
"$",
"fields",
"->",
"get",
"(",
"$",
"type",
")",
")",
")",
"{",
"//Use resource model's default fields",
"$",
"fields",
"=",
"static",
"::",
"getDefaultFields",
"(",
")",
";",
"$",
"attributes",
"=",
"array_merge",
"(",
"$",
"fields",
"->",
"get",
"(",
"$",
"type",
")",
",",
"[",
"static",
"::",
"getIdAttribute",
"(",
")",
"]",
"//[static::getTable() . '.' . static::getIdAttribute()]",
")",
";",
"}",
"else",
"{",
"$",
"attributes",
"=",
"$",
"fields",
"->",
"get",
"(",
"$",
"type",
")",
";",
"if",
"(",
"$",
"fields",
"->",
"get",
"(",
"$",
"type",
")",
"!==",
"[",
"'*'",
"]",
")",
"{",
"//Get field attributes for this type and force id attribute",
"$",
"attributes",
"=",
"array_merge",
"(",
"$",
"fields",
"->",
"get",
"(",
"$",
"type",
")",
",",
"[",
"static",
"::",
"getIdAttribute",
"(",
")",
"]",
")",
";",
"}",
"}",
"//if ($fields !== null && !empty($fields->get($type))) {",
"$",
"fields",
"->",
"validate",
"(",
"static",
"::",
"class",
")",
";",
"$",
"attributes",
"=",
"array_unique",
"(",
"$",
"attributes",
")",
";",
"/**\n * @param string $column\n * @return string\n */",
"$",
"escape",
"=",
"function",
"(",
"$",
"column",
")",
"{",
"if",
"(",
"$",
"column",
"===",
"'*'",
")",
"{",
"return",
"$",
"column",
";",
"}",
"return",
"sprintf",
"(",
"'\"%s\"'",
",",
"$",
"column",
")",
";",
"}",
";",
"/**\n * This method will prepare the attributes by prefixing then with \"\n * - * -> *\n * - table.* -> \"table\".*\n * - id -> \"id\"\n * - table.id -> \"table\".\"id\"\n * and glue them with comma separator\n */",
"$",
"queryPart",
"=",
"implode",
"(",
"','",
",",
"array_map",
"(",
"function",
"(",
"$",
"attribute",
")",
"use",
"(",
"$",
"escape",
")",
"{",
"return",
"implode",
"(",
"'.'",
",",
"array_map",
"(",
"$",
"escape",
",",
"explode",
"(",
"'.'",
",",
"$",
"attribute",
")",
")",
")",
";",
"}",
",",
"$",
"attributes",
")",
")",
";",
"//}",
"$",
"query",
"=",
"str_replace",
"(",
"'{{fields}}'",
",",
"$",
"queryPart",
",",
"$",
"query",
")",
";",
"return",
"$",
"query",
";",
"}"
] |
This method will update `{{fields}}` string inside query parameter with
the provided fields directives
@param string $query
@param Fields|null $fields
@return string
@since 1.0.0
@todo add table prefix
@uses Model::getDefaultFields if fields is null
|
[
"This",
"method",
"will",
"update",
"{{",
"fields",
"}}",
"string",
"inside",
"query",
"parameter",
"with",
"the",
"provided",
"fields",
"directives"
] |
train
|
https://github.com/phramework/jsonapi/blob/af20882a8b6f6e5be9c8e09e5b87f6c23a4b0726/src/Model/Directives.php#L447-L519
|
heyday/heystack
|
src/Output/GroupedProcessor.php
|
GroupedProcessor.process
|
public function process(\Controller $controller, $result = null)
{
foreach ($this->processors as $processor) {
$processor->process($controller, $result);
}
return $controller->getResponse();
}
|
php
|
public function process(\Controller $controller, $result = null)
{
foreach ($this->processors as $processor) {
$processor->process($controller, $result);
}
return $controller->getResponse();
}
|
[
"public",
"function",
"process",
"(",
"\\",
"Controller",
"$",
"controller",
",",
"$",
"result",
"=",
"null",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"processors",
"as",
"$",
"processor",
")",
"{",
"$",
"processor",
"->",
"process",
"(",
"$",
"controller",
",",
"$",
"result",
")",
";",
"}",
"return",
"$",
"controller",
"->",
"getResponse",
"(",
")",
";",
"}"
] |
Runs over the list of processors running them all in turn
@param \Controller $controller The controller the request was handled by
@param mixed $result The result from the previosly run input processor/s
@return \SS_HTTPResponse Controller response
|
[
"Runs",
"over",
"the",
"list",
"of",
"processors",
"running",
"them",
"all",
"in",
"turn"
] |
train
|
https://github.com/heyday/heystack/blob/2c051933f8c532d0a9a23be6ee1ff5c619e47dfe/src/Output/GroupedProcessor.php#L70-L77
|
Atlantic18/CoralCoreBundle
|
Service/Request/Request.php
|
Request.isCacheable
|
private function isCacheable(RequestHandleInterface $handle)
{
if(null === $this->cache)
{
return false;
}
if($handle->getMethod() != self::GET)
{
return false;
}
return true;
}
|
php
|
private function isCacheable(RequestHandleInterface $handle)
{
if(null === $this->cache)
{
return false;
}
if($handle->getMethod() != self::GET)
{
return false;
}
return true;
}
|
[
"private",
"function",
"isCacheable",
"(",
"RequestHandleInterface",
"$",
"handle",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"cache",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"handle",
"->",
"getMethod",
"(",
")",
"!=",
"self",
"::",
"GET",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Returns true if handle is possible to be cached
@param RequestHandleInterface $handle Request handle
@return boolean True if can be cached
|
[
"Returns",
"true",
"if",
"handle",
"is",
"possible",
"to",
"be",
"cached"
] |
train
|
https://github.com/Atlantic18/CoralCoreBundle/blob/7d74ffaf51046ad13cbfc2b0b69d656a499f38ab/Service/Request/Request.php#L49-L61
|
Atlantic18/CoralCoreBundle
|
Service/Request/Request.php
|
Request.doRequestAndParse
|
public function doRequestAndParse(RequestHandleInterface $handle, $contentType = 'application/json')
{
if($this->isCacheable($handle) && (false !== ($params = $this->cache->fetch('parser_' . $handle->hash()))))
{
$parser = new JsonParser;
$parser->setParams($params);
return $parser;
}
$handle->setHeader('Content-Type', $contentType);
$handle->setHeader('X-Requested-With', 'XMLHttpRequest');
$rawResponse = $handle->execute();
$httpCode = $handle->getResponseCode();
$header_size = $handle->getResponseHeaderSize();
$headers = substr($rawResponse, 0, $header_size);
$rawResponse = substr($rawResponse, $header_size);
if($httpCode < 200 || $httpCode > 299)
{
$type = $handle->getMethod();
$uri = $handle->getUrl();
$exception = new ConnectorException(
"Error connecting to:
Uri: $type $uri
Response code: $httpCode.
Error: " . substr($rawResponse, 0, 255));
$exception->setHttpTrace(new HttpTrace($uri, $httpCode, $rawResponse));
throw $exception;
}
$parser = new JsonParser($rawResponse, true);
//Save response to cache
if($this->isCacheable($handle))
{
$cacheTTL = false;
//Cache-Control header with max-age
if(preg_match('/cache\-control\:\s*(private|public),\s*max\-age=([0-9]+)/i', $headers, $matches))
{
//Whether it's private or public is in $matches[1]
$cacheTTL = $matches[2];
}
if($cacheTTL)
{
$this->cache->save('parser_' . $handle->hash(), $parser->getParams(), $cacheTTL);
}
}
return $parser;
}
|
php
|
public function doRequestAndParse(RequestHandleInterface $handle, $contentType = 'application/json')
{
if($this->isCacheable($handle) && (false !== ($params = $this->cache->fetch('parser_' . $handle->hash()))))
{
$parser = new JsonParser;
$parser->setParams($params);
return $parser;
}
$handle->setHeader('Content-Type', $contentType);
$handle->setHeader('X-Requested-With', 'XMLHttpRequest');
$rawResponse = $handle->execute();
$httpCode = $handle->getResponseCode();
$header_size = $handle->getResponseHeaderSize();
$headers = substr($rawResponse, 0, $header_size);
$rawResponse = substr($rawResponse, $header_size);
if($httpCode < 200 || $httpCode > 299)
{
$type = $handle->getMethod();
$uri = $handle->getUrl();
$exception = new ConnectorException(
"Error connecting to:
Uri: $type $uri
Response code: $httpCode.
Error: " . substr($rawResponse, 0, 255));
$exception->setHttpTrace(new HttpTrace($uri, $httpCode, $rawResponse));
throw $exception;
}
$parser = new JsonParser($rawResponse, true);
//Save response to cache
if($this->isCacheable($handle))
{
$cacheTTL = false;
//Cache-Control header with max-age
if(preg_match('/cache\-control\:\s*(private|public),\s*max\-age=([0-9]+)/i', $headers, $matches))
{
//Whether it's private or public is in $matches[1]
$cacheTTL = $matches[2];
}
if($cacheTTL)
{
$this->cache->save('parser_' . $handle->hash(), $parser->getParams(), $cacheTTL);
}
}
return $parser;
}
|
[
"public",
"function",
"doRequestAndParse",
"(",
"RequestHandleInterface",
"$",
"handle",
",",
"$",
"contentType",
"=",
"'application/json'",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isCacheable",
"(",
"$",
"handle",
")",
"&&",
"(",
"false",
"!==",
"(",
"$",
"params",
"=",
"$",
"this",
"->",
"cache",
"->",
"fetch",
"(",
"'parser_'",
".",
"$",
"handle",
"->",
"hash",
"(",
")",
")",
")",
")",
")",
"{",
"$",
"parser",
"=",
"new",
"JsonParser",
";",
"$",
"parser",
"->",
"setParams",
"(",
"$",
"params",
")",
";",
"return",
"$",
"parser",
";",
"}",
"$",
"handle",
"->",
"setHeader",
"(",
"'Content-Type'",
",",
"$",
"contentType",
")",
";",
"$",
"handle",
"->",
"setHeader",
"(",
"'X-Requested-With'",
",",
"'XMLHttpRequest'",
")",
";",
"$",
"rawResponse",
"=",
"$",
"handle",
"->",
"execute",
"(",
")",
";",
"$",
"httpCode",
"=",
"$",
"handle",
"->",
"getResponseCode",
"(",
")",
";",
"$",
"header_size",
"=",
"$",
"handle",
"->",
"getResponseHeaderSize",
"(",
")",
";",
"$",
"headers",
"=",
"substr",
"(",
"$",
"rawResponse",
",",
"0",
",",
"$",
"header_size",
")",
";",
"$",
"rawResponse",
"=",
"substr",
"(",
"$",
"rawResponse",
",",
"$",
"header_size",
")",
";",
"if",
"(",
"$",
"httpCode",
"<",
"200",
"||",
"$",
"httpCode",
">",
"299",
")",
"{",
"$",
"type",
"=",
"$",
"handle",
"->",
"getMethod",
"(",
")",
";",
"$",
"uri",
"=",
"$",
"handle",
"->",
"getUrl",
"(",
")",
";",
"$",
"exception",
"=",
"new",
"ConnectorException",
"(",
"\"Error connecting to:\n Uri: $type $uri\n Response code: $httpCode.\n Error: \"",
".",
"substr",
"(",
"$",
"rawResponse",
",",
"0",
",",
"255",
")",
")",
";",
"$",
"exception",
"->",
"setHttpTrace",
"(",
"new",
"HttpTrace",
"(",
"$",
"uri",
",",
"$",
"httpCode",
",",
"$",
"rawResponse",
")",
")",
";",
"throw",
"$",
"exception",
";",
"}",
"$",
"parser",
"=",
"new",
"JsonParser",
"(",
"$",
"rawResponse",
",",
"true",
")",
";",
"//Save response to cache",
"if",
"(",
"$",
"this",
"->",
"isCacheable",
"(",
"$",
"handle",
")",
")",
"{",
"$",
"cacheTTL",
"=",
"false",
";",
"//Cache-Control header with max-age",
"if",
"(",
"preg_match",
"(",
"'/cache\\-control\\:\\s*(private|public),\\s*max\\-age=([0-9]+)/i'",
",",
"$",
"headers",
",",
"$",
"matches",
")",
")",
"{",
"//Whether it's private or public is in $matches[1]",
"$",
"cacheTTL",
"=",
"$",
"matches",
"[",
"2",
"]",
";",
"}",
"if",
"(",
"$",
"cacheTTL",
")",
"{",
"$",
"this",
"->",
"cache",
"->",
"save",
"(",
"'parser_'",
".",
"$",
"handle",
"->",
"hash",
"(",
")",
",",
"$",
"parser",
"->",
"getParams",
"(",
")",
",",
"$",
"cacheTTL",
")",
";",
"}",
"}",
"return",
"$",
"parser",
";",
"}"
] |
Do request and return response as a Parser instance. Note: if you need
response headers use doRequest instead.
@param RequestHandleInterface $handle Request handle
@param string $contentType ContentType of the request
@return Parser
|
[
"Do",
"request",
"and",
"return",
"response",
"as",
"a",
"Parser",
"instance",
".",
"Note",
":",
"if",
"you",
"need",
"response",
"headers",
"use",
"doRequest",
"instead",
"."
] |
train
|
https://github.com/Atlantic18/CoralCoreBundle/blob/7d74ffaf51046ad13cbfc2b0b69d656a499f38ab/Service/Request/Request.php#L83-L136
|
Atlantic18/CoralCoreBundle
|
Service/Request/Request.php
|
Request.doRequest
|
public function doRequest(RequestHandleInterface $handle, $contentType = 'application/json')
{
if
(
$this->isCacheable($handle)
&&
(false !== ($rawResponse = $this->cache->fetch('response_' . $handle->hash())))
)
{
return new Response($rawResponse);
}
$handle->setHeader('Content-Type', $contentType);
$handle->setHeader('X-Requested-With', 'XMLHttpRequest');
$rawResponse = $handle->execute();
$httpCode = $handle->getResponseCode();
if($httpCode < 200 || $httpCode > 299)
{
$type = $handle->getMethod();
$uri = $handle->getUrl();
$exception = new ConnectorException(
"Error connecting to:
Uri: $type $uri
Response code: $httpCode.
Error: " . substr($rawResponse, 0, 255));
$exception->setHttpTrace(new HttpTrace($uri, $httpCode, $rawResponse));
throw $exception;
}
$response = new Response($rawResponse);
//Save response to cache
if($this->isCacheable($handle))
{
$cacheTTL = $response->getMaxAge();
if(null !== $cacheTTL)
{
$this->cache->save('response_' . $handle->hash(), $rawResponse, $cacheTTL);
}
}
return $response;
}
|
php
|
public function doRequest(RequestHandleInterface $handle, $contentType = 'application/json')
{
if
(
$this->isCacheable($handle)
&&
(false !== ($rawResponse = $this->cache->fetch('response_' . $handle->hash())))
)
{
return new Response($rawResponse);
}
$handle->setHeader('Content-Type', $contentType);
$handle->setHeader('X-Requested-With', 'XMLHttpRequest');
$rawResponse = $handle->execute();
$httpCode = $handle->getResponseCode();
if($httpCode < 200 || $httpCode > 299)
{
$type = $handle->getMethod();
$uri = $handle->getUrl();
$exception = new ConnectorException(
"Error connecting to:
Uri: $type $uri
Response code: $httpCode.
Error: " . substr($rawResponse, 0, 255));
$exception->setHttpTrace(new HttpTrace($uri, $httpCode, $rawResponse));
throw $exception;
}
$response = new Response($rawResponse);
//Save response to cache
if($this->isCacheable($handle))
{
$cacheTTL = $response->getMaxAge();
if(null !== $cacheTTL)
{
$this->cache->save('response_' . $handle->hash(), $rawResponse, $cacheTTL);
}
}
return $response;
}
|
[
"public",
"function",
"doRequest",
"(",
"RequestHandleInterface",
"$",
"handle",
",",
"$",
"contentType",
"=",
"'application/json'",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isCacheable",
"(",
"$",
"handle",
")",
"&&",
"(",
"false",
"!==",
"(",
"$",
"rawResponse",
"=",
"$",
"this",
"->",
"cache",
"->",
"fetch",
"(",
"'response_'",
".",
"$",
"handle",
"->",
"hash",
"(",
")",
")",
")",
")",
")",
"{",
"return",
"new",
"Response",
"(",
"$",
"rawResponse",
")",
";",
"}",
"$",
"handle",
"->",
"setHeader",
"(",
"'Content-Type'",
",",
"$",
"contentType",
")",
";",
"$",
"handle",
"->",
"setHeader",
"(",
"'X-Requested-With'",
",",
"'XMLHttpRequest'",
")",
";",
"$",
"rawResponse",
"=",
"$",
"handle",
"->",
"execute",
"(",
")",
";",
"$",
"httpCode",
"=",
"$",
"handle",
"->",
"getResponseCode",
"(",
")",
";",
"if",
"(",
"$",
"httpCode",
"<",
"200",
"||",
"$",
"httpCode",
">",
"299",
")",
"{",
"$",
"type",
"=",
"$",
"handle",
"->",
"getMethod",
"(",
")",
";",
"$",
"uri",
"=",
"$",
"handle",
"->",
"getUrl",
"(",
")",
";",
"$",
"exception",
"=",
"new",
"ConnectorException",
"(",
"\"Error connecting to:\n Uri: $type $uri\n Response code: $httpCode.\n Error: \"",
".",
"substr",
"(",
"$",
"rawResponse",
",",
"0",
",",
"255",
")",
")",
";",
"$",
"exception",
"->",
"setHttpTrace",
"(",
"new",
"HttpTrace",
"(",
"$",
"uri",
",",
"$",
"httpCode",
",",
"$",
"rawResponse",
")",
")",
";",
"throw",
"$",
"exception",
";",
"}",
"$",
"response",
"=",
"new",
"Response",
"(",
"$",
"rawResponse",
")",
";",
"//Save response to cache",
"if",
"(",
"$",
"this",
"->",
"isCacheable",
"(",
"$",
"handle",
")",
")",
"{",
"$",
"cacheTTL",
"=",
"$",
"response",
"->",
"getMaxAge",
"(",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"cacheTTL",
")",
"{",
"$",
"this",
"->",
"cache",
"->",
"save",
"(",
"'response_'",
".",
"$",
"handle",
"->",
"hash",
"(",
")",
",",
"$",
"rawResponse",
",",
"$",
"cacheTTL",
")",
";",
"}",
"}",
"return",
"$",
"response",
";",
"}"
] |
Do request
@param RequestHandleInterface $handle Request handle
@param string $contentType ContentType of the request
@return Response
|
[
"Do",
"request"
] |
train
|
https://github.com/Atlantic18/CoralCoreBundle/blob/7d74ffaf51046ad13cbfc2b0b69d656a499f38ab/Service/Request/Request.php#L146-L190
|
stubbles/stubbles-webapp-core
|
src/main/php/routing/Routing.php
|
Routing.onGet
|
public function onGet(string $path, $target): ConfigurableRoute
{
return $this->addRoute(new Route($path, $target, 'GET'));
}
|
php
|
public function onGet(string $path, $target): ConfigurableRoute
{
return $this->addRoute(new Route($path, $target, 'GET'));
}
|
[
"public",
"function",
"onGet",
"(",
"string",
"$",
"path",
",",
"$",
"target",
")",
":",
"ConfigurableRoute",
"{",
"return",
"$",
"this",
"->",
"addRoute",
"(",
"new",
"Route",
"(",
"$",
"path",
",",
"$",
"target",
",",
"'GET'",
")",
")",
";",
"}"
] |
reply with given class or callable for GET request on given path
@param string $path path this route is applicable for
@param string|callable|\stubbles\webapp\Target $target code to be executed when the route is active
@return \stubbles\webapp\routing\ConfigurableRoute
|
[
"reply",
"with",
"given",
"class",
"or",
"callable",
"for",
"GET",
"request",
"on",
"given",
"path"
] |
train
|
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L88-L91
|
stubbles/stubbles-webapp-core
|
src/main/php/routing/Routing.php
|
Routing.passThroughOnGet
|
public function passThroughOnGet(
string $path = '/[a-zA-Z0-9-_]+.html$',
$target = HtmlFilePassThrough::class
): ConfigurableRoute {
return $this->onGet($path, $target);
}
|
php
|
public function passThroughOnGet(
string $path = '/[a-zA-Z0-9-_]+.html$',
$target = HtmlFilePassThrough::class
): ConfigurableRoute {
return $this->onGet($path, $target);
}
|
[
"public",
"function",
"passThroughOnGet",
"(",
"string",
"$",
"path",
"=",
"'/[a-zA-Z0-9-_]+.html$'",
",",
"$",
"target",
"=",
"HtmlFilePassThrough",
"::",
"class",
")",
":",
"ConfigurableRoute",
"{",
"return",
"$",
"this",
"->",
"onGet",
"(",
"$",
"path",
",",
"$",
"target",
")",
";",
"}"
] |
reply with HTML file stored in pages path
@param string $path optional path this route is applicable for
@param string|callable|\stubbles\webapp\Target $target optional code to be executed when the route is active
@return \stubbles\webapp\routing\ConfigurableRoute
@since 4.0.0
|
[
"reply",
"with",
"HTML",
"file",
"stored",
"in",
"pages",
"path"
] |
train
|
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L101-L106
|
stubbles/stubbles-webapp-core
|
src/main/php/routing/Routing.php
|
Routing.apiIndexOnGet
|
public function apiIndexOnGet(string $path): ConfigurableRoute
{
return $this->onGet($path, new Index($this->routes, $this->mimeTypes));
}
|
php
|
public function apiIndexOnGet(string $path): ConfigurableRoute
{
return $this->onGet($path, new Index($this->routes, $this->mimeTypes));
}
|
[
"public",
"function",
"apiIndexOnGet",
"(",
"string",
"$",
"path",
")",
":",
"ConfigurableRoute",
"{",
"return",
"$",
"this",
"->",
"onGet",
"(",
"$",
"path",
",",
"new",
"Index",
"(",
"$",
"this",
"->",
"routes",
",",
"$",
"this",
"->",
"mimeTypes",
")",
")",
";",
"}"
] |
reply with API index overview
@param string $path
@return \stubbles\webapp\routing\ConfigurableRoute
@since 6.1.0
|
[
"reply",
"with",
"API",
"index",
"overview"
] |
train
|
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L115-L118
|
stubbles/stubbles-webapp-core
|
src/main/php/routing/Routing.php
|
Routing.redirectOnGet
|
public function redirectOnGet(string $path, $target, int $statusCode = 302): ConfigurableRoute
{
return $this->onGet($path, new Redirect($target, $statusCode));
}
|
php
|
public function redirectOnGet(string $path, $target, int $statusCode = 302): ConfigurableRoute
{
return $this->onGet($path, new Redirect($target, $statusCode));
}
|
[
"public",
"function",
"redirectOnGet",
"(",
"string",
"$",
"path",
",",
"$",
"target",
",",
"int",
"$",
"statusCode",
"=",
"302",
")",
":",
"ConfigurableRoute",
"{",
"return",
"$",
"this",
"->",
"onGet",
"(",
"$",
"path",
",",
"new",
"Redirect",
"(",
"$",
"target",
",",
"$",
"statusCode",
")",
")",
";",
"}"
] |
reply with a redirect
If the given $target is a string it is used in different ways:
- if the string starts with http it is assumed to be a complete uri
- else it is assumed to be a path within the application
@param string $path path this route is applicable for
@param string|\stubbles\peer\http\HttpUri $target path or uri to redirect to
@param int $statusCode optional status code for redirect, defaults to 302
@return \stubbles\webapp\routing\ConfigurableRoute
@since 6.1.0
|
[
"reply",
"with",
"a",
"redirect"
] |
train
|
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L133-L136
|
stubbles/stubbles-webapp-core
|
src/main/php/routing/Routing.php
|
Routing.onHead
|
public function onHead(string $path, $target): ConfigurableRoute
{
return $this->addRoute(new Route($path, $target, 'HEAD'));
}
|
php
|
public function onHead(string $path, $target): ConfigurableRoute
{
return $this->addRoute(new Route($path, $target, 'HEAD'));
}
|
[
"public",
"function",
"onHead",
"(",
"string",
"$",
"path",
",",
"$",
"target",
")",
":",
"ConfigurableRoute",
"{",
"return",
"$",
"this",
"->",
"addRoute",
"(",
"new",
"Route",
"(",
"$",
"path",
",",
"$",
"target",
",",
"'HEAD'",
")",
")",
";",
"}"
] |
reply with given class or callable for HEAD request on given path
@param string $path path this route is applicable for
@param string|callable|\stubbles\webapp\Target $target code to be executed when the route is active
@return \stubbles\webapp\routing\ConfigurableRoute
|
[
"reply",
"with",
"given",
"class",
"or",
"callable",
"for",
"HEAD",
"request",
"on",
"given",
"path"
] |
train
|
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L145-L148
|
stubbles/stubbles-webapp-core
|
src/main/php/routing/Routing.php
|
Routing.onPost
|
public function onPost(string $path, $target): ConfigurableRoute
{
return $this->addRoute(new Route($path, $target, 'POST'));
}
|
php
|
public function onPost(string $path, $target): ConfigurableRoute
{
return $this->addRoute(new Route($path, $target, 'POST'));
}
|
[
"public",
"function",
"onPost",
"(",
"string",
"$",
"path",
",",
"$",
"target",
")",
":",
"ConfigurableRoute",
"{",
"return",
"$",
"this",
"->",
"addRoute",
"(",
"new",
"Route",
"(",
"$",
"path",
",",
"$",
"target",
",",
"'POST'",
")",
")",
";",
"}"
] |
reply with given class or callable for POST request on given path
@param string $path path this route is applicable for
@param string|callable|\stubbles\webapp\Target $target code to be executed when the route is active
@return \stubbles\webapp\routing\ConfigurableRoute
|
[
"reply",
"with",
"given",
"class",
"or",
"callable",
"for",
"POST",
"request",
"on",
"given",
"path"
] |
train
|
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L157-L160
|
stubbles/stubbles-webapp-core
|
src/main/php/routing/Routing.php
|
Routing.onPut
|
public function onPut(string $path, $target): ConfigurableRoute
{
return $this->addRoute(new Route($path, $target, 'PUT'));
}
|
php
|
public function onPut(string $path, $target): ConfigurableRoute
{
return $this->addRoute(new Route($path, $target, 'PUT'));
}
|
[
"public",
"function",
"onPut",
"(",
"string",
"$",
"path",
",",
"$",
"target",
")",
":",
"ConfigurableRoute",
"{",
"return",
"$",
"this",
"->",
"addRoute",
"(",
"new",
"Route",
"(",
"$",
"path",
",",
"$",
"target",
",",
"'PUT'",
")",
")",
";",
"}"
] |
reply with given class or callable for PUT request on given path
@param string $path path this route is applicable for
@param string|callable|\stubbles\webapp\Target $target code to be executed when the route is active
@return \stubbles\webapp\routing\ConfigurableRoute
|
[
"reply",
"with",
"given",
"class",
"or",
"callable",
"for",
"PUT",
"request",
"on",
"given",
"path"
] |
train
|
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L169-L172
|
stubbles/stubbles-webapp-core
|
src/main/php/routing/Routing.php
|
Routing.onDelete
|
public function onDelete(string $path, $target): ConfigurableRoute
{
return $this->addRoute(new Route($path, $target, 'DELETE'));
}
|
php
|
public function onDelete(string $path, $target): ConfigurableRoute
{
return $this->addRoute(new Route($path, $target, 'DELETE'));
}
|
[
"public",
"function",
"onDelete",
"(",
"string",
"$",
"path",
",",
"$",
"target",
")",
":",
"ConfigurableRoute",
"{",
"return",
"$",
"this",
"->",
"addRoute",
"(",
"new",
"Route",
"(",
"$",
"path",
",",
"$",
"target",
",",
"'DELETE'",
")",
")",
";",
"}"
] |
reply with given class or callable for DELETE request on given path
@param string $path path this route is applicable for
@param string|callable|\stubbles\webapp\Target $target code to be executed when the route is active
@return \stubbles\webapp\routing\ConfigurableRoute
|
[
"reply",
"with",
"given",
"class",
"or",
"callable",
"for",
"DELETE",
"request",
"on",
"given",
"path"
] |
train
|
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L181-L184
|
stubbles/stubbles-webapp-core
|
src/main/php/routing/Routing.php
|
Routing.onAll
|
public function onAll(string $path, $target, $requestMethod = null): ConfigurableRoute
{
return $this->addRoute(new Route($path, $target, $requestMethod));
}
|
php
|
public function onAll(string $path, $target, $requestMethod = null): ConfigurableRoute
{
return $this->addRoute(new Route($path, $target, $requestMethod));
}
|
[
"public",
"function",
"onAll",
"(",
"string",
"$",
"path",
",",
"$",
"target",
",",
"$",
"requestMethod",
"=",
"null",
")",
":",
"ConfigurableRoute",
"{",
"return",
"$",
"this",
"->",
"addRoute",
"(",
"new",
"Route",
"(",
"$",
"path",
",",
"$",
"target",
",",
"$",
"requestMethod",
")",
")",
";",
"}"
] |
reply with given class or callable for request method(s) on given path
If no request method(s) specified it replies to request methods GET, HEAD,
POST, PUT and DELETE.
@param string $path path this route is applicable for
@param string|callable|\stubbles\webapp\Target $target code to be executed when the route is active
@param string|string[] $requestMethod optional request method(s) this route is applicable for
@return \stubbles\webapp\routing\ConfigurableRoute
@since 4.0.0
|
[
"reply",
"with",
"given",
"class",
"or",
"callable",
"for",
"request",
"method",
"(",
"s",
")",
"on",
"given",
"path"
] |
train
|
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L198-L201
|
stubbles/stubbles-webapp-core
|
src/main/php/routing/Routing.php
|
Routing.findResource
|
public function findResource($uri, string $requestMethod = null): UriResource
{
$calledUri = CalledUri::castFrom($uri, $requestMethod);
$matchingRoutes = $this->routes->match($calledUri);
if ($matchingRoutes->hasExactMatch()) {
return $this->handleMatchingRoute(
$calledUri,
$matchingRoutes->exactMatch()
);
}
if ($matchingRoutes->exist()) {
return $this->handleNonMethodMatchingRoutes(
$calledUri,
$matchingRoutes
);
}
return new NotFound(
$this->injector,
$calledUri,
$this->collectInterceptors($calledUri),
$this->supportedMimeTypes()
);
}
|
php
|
public function findResource($uri, string $requestMethod = null): UriResource
{
$calledUri = CalledUri::castFrom($uri, $requestMethod);
$matchingRoutes = $this->routes->match($calledUri);
if ($matchingRoutes->hasExactMatch()) {
return $this->handleMatchingRoute(
$calledUri,
$matchingRoutes->exactMatch()
);
}
if ($matchingRoutes->exist()) {
return $this->handleNonMethodMatchingRoutes(
$calledUri,
$matchingRoutes
);
}
return new NotFound(
$this->injector,
$calledUri,
$this->collectInterceptors($calledUri),
$this->supportedMimeTypes()
);
}
|
[
"public",
"function",
"findResource",
"(",
"$",
"uri",
",",
"string",
"$",
"requestMethod",
"=",
"null",
")",
":",
"UriResource",
"{",
"$",
"calledUri",
"=",
"CalledUri",
"::",
"castFrom",
"(",
"$",
"uri",
",",
"$",
"requestMethod",
")",
";",
"$",
"matchingRoutes",
"=",
"$",
"this",
"->",
"routes",
"->",
"match",
"(",
"$",
"calledUri",
")",
";",
"if",
"(",
"$",
"matchingRoutes",
"->",
"hasExactMatch",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"handleMatchingRoute",
"(",
"$",
"calledUri",
",",
"$",
"matchingRoutes",
"->",
"exactMatch",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"matchingRoutes",
"->",
"exist",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"handleNonMethodMatchingRoutes",
"(",
"$",
"calledUri",
",",
"$",
"matchingRoutes",
")",
";",
"}",
"return",
"new",
"NotFound",
"(",
"$",
"this",
"->",
"injector",
",",
"$",
"calledUri",
",",
"$",
"this",
"->",
"collectInterceptors",
"(",
"$",
"calledUri",
")",
",",
"$",
"this",
"->",
"supportedMimeTypes",
"(",
")",
")",
";",
"}"
] |
returns resource which is applicable for given request
@param string|\stubbles\webapp\routing\CalledUri $uri actually called uri
@param string $requestMethod optional when $calledUri is an instance of stubbles\webapp\routing\CalledUri
@return \stubbles\webapp\routing\UriResource
|
[
"returns",
"resource",
"which",
"is",
"applicable",
"for",
"given",
"request"
] |
train
|
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L221-L245
|
stubbles/stubbles-webapp-core
|
src/main/php/routing/Routing.php
|
Routing.handleMatchingRoute
|
private function handleMatchingRoute(CalledUri $calledUri, Route $route): UriResource
{
if ($route->requiresAuth()) {
return new ProtectedResource(
$route->authConstraint(),
$this->resolveResource($calledUri, $route),
$this->injector
);
}
return $this->resolveResource($calledUri, $route);
}
|
php
|
private function handleMatchingRoute(CalledUri $calledUri, Route $route): UriResource
{
if ($route->requiresAuth()) {
return new ProtectedResource(
$route->authConstraint(),
$this->resolveResource($calledUri, $route),
$this->injector
);
}
return $this->resolveResource($calledUri, $route);
}
|
[
"private",
"function",
"handleMatchingRoute",
"(",
"CalledUri",
"$",
"calledUri",
",",
"Route",
"$",
"route",
")",
":",
"UriResource",
"{",
"if",
"(",
"$",
"route",
"->",
"requiresAuth",
"(",
")",
")",
"{",
"return",
"new",
"ProtectedResource",
"(",
"$",
"route",
"->",
"authConstraint",
"(",
")",
",",
"$",
"this",
"->",
"resolveResource",
"(",
"$",
"calledUri",
",",
"$",
"route",
")",
",",
"$",
"this",
"->",
"injector",
")",
";",
"}",
"return",
"$",
"this",
"->",
"resolveResource",
"(",
"$",
"calledUri",
",",
"$",
"route",
")",
";",
"}"
] |
creates a processable route for given route
@param \stubbles\webapp\routing\CalledUri $calledUri
@param \stubbles\webapp\routing\Route $route
@return \stubbles\webapp\routing\UriResource
|
[
"creates",
"a",
"processable",
"route",
"for",
"given",
"route"
] |
train
|
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L254-L265
|
stubbles/stubbles-webapp-core
|
src/main/php/routing/Routing.php
|
Routing.resolveResource
|
private function resolveResource(CalledUri $calledUri, Route $route): ResolvingResource
{
return new ResolvingResource(
$this->injector,
$calledUri,
$this->collectInterceptors($calledUri, $route),
$this->supportedMimeTypes($route),
$route
);
}
|
php
|
private function resolveResource(CalledUri $calledUri, Route $route): ResolvingResource
{
return new ResolvingResource(
$this->injector,
$calledUri,
$this->collectInterceptors($calledUri, $route),
$this->supportedMimeTypes($route),
$route
);
}
|
[
"private",
"function",
"resolveResource",
"(",
"CalledUri",
"$",
"calledUri",
",",
"Route",
"$",
"route",
")",
":",
"ResolvingResource",
"{",
"return",
"new",
"ResolvingResource",
"(",
"$",
"this",
"->",
"injector",
",",
"$",
"calledUri",
",",
"$",
"this",
"->",
"collectInterceptors",
"(",
"$",
"calledUri",
",",
"$",
"route",
")",
",",
"$",
"this",
"->",
"supportedMimeTypes",
"(",
"$",
"route",
")",
",",
"$",
"route",
")",
";",
"}"
] |
creates matching route
@param \stubbles\webapp\routing\CalledUri $calledUri
@param \stubbles\webapp\routing\Route $route
@return \stubbles\webapp\routing\ResolvingResource
|
[
"creates",
"matching",
"route"
] |
train
|
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L274-L283
|
stubbles/stubbles-webapp-core
|
src/main/php/routing/Routing.php
|
Routing.handleNonMethodMatchingRoutes
|
private function handleNonMethodMatchingRoutes(
CalledUri $calledUri,
MatchingRoutes $matchingRoutes
): UriResource {
if ($calledUri->methodEquals('OPTIONS')) {
return new ResourceOptions(
$this->injector,
$calledUri,
$this->collectInterceptors($calledUri),
$this->supportedMimeTypes(),
$matchingRoutes
);
}
return new MethodNotAllowed(
$this->injector,
$calledUri,
$this->collectInterceptors($calledUri),
$this->supportedMimeTypes(),
$matchingRoutes->allowedMethods()
);
}
|
php
|
private function handleNonMethodMatchingRoutes(
CalledUri $calledUri,
MatchingRoutes $matchingRoutes
): UriResource {
if ($calledUri->methodEquals('OPTIONS')) {
return new ResourceOptions(
$this->injector,
$calledUri,
$this->collectInterceptors($calledUri),
$this->supportedMimeTypes(),
$matchingRoutes
);
}
return new MethodNotAllowed(
$this->injector,
$calledUri,
$this->collectInterceptors($calledUri),
$this->supportedMimeTypes(),
$matchingRoutes->allowedMethods()
);
}
|
[
"private",
"function",
"handleNonMethodMatchingRoutes",
"(",
"CalledUri",
"$",
"calledUri",
",",
"MatchingRoutes",
"$",
"matchingRoutes",
")",
":",
"UriResource",
"{",
"if",
"(",
"$",
"calledUri",
"->",
"methodEquals",
"(",
"'OPTIONS'",
")",
")",
"{",
"return",
"new",
"ResourceOptions",
"(",
"$",
"this",
"->",
"injector",
",",
"$",
"calledUri",
",",
"$",
"this",
"->",
"collectInterceptors",
"(",
"$",
"calledUri",
")",
",",
"$",
"this",
"->",
"supportedMimeTypes",
"(",
")",
",",
"$",
"matchingRoutes",
")",
";",
"}",
"return",
"new",
"MethodNotAllowed",
"(",
"$",
"this",
"->",
"injector",
",",
"$",
"calledUri",
",",
"$",
"this",
"->",
"collectInterceptors",
"(",
"$",
"calledUri",
")",
",",
"$",
"this",
"->",
"supportedMimeTypes",
"(",
")",
",",
"$",
"matchingRoutes",
"->",
"allowedMethods",
"(",
")",
")",
";",
"}"
] |
creates a processable route when a route can be found regardless of request method
@param \stubbles\webapp\routing\CalledUri $calledUri
@param \stubbles\webapp\routing\MatchingRoutes $matchingRoutes
@return \stubbles\webapp\routing\UriResource
|
[
"creates",
"a",
"processable",
"route",
"when",
"a",
"route",
"can",
"be",
"found",
"regardless",
"of",
"request",
"method"
] |
train
|
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L292-L314
|
stubbles/stubbles-webapp-core
|
src/main/php/routing/Routing.php
|
Routing.preInterceptOnGet
|
public function preInterceptOnGet($preInterceptor, string $path = null): RoutingConfigurator
{
return $this->preIntercept($preInterceptor, $path, 'GET');
}
|
php
|
public function preInterceptOnGet($preInterceptor, string $path = null): RoutingConfigurator
{
return $this->preIntercept($preInterceptor, $path, 'GET');
}
|
[
"public",
"function",
"preInterceptOnGet",
"(",
"$",
"preInterceptor",
",",
"string",
"$",
"path",
"=",
"null",
")",
":",
"RoutingConfigurator",
"{",
"return",
"$",
"this",
"->",
"preIntercept",
"(",
"$",
"preInterceptor",
",",
"$",
"path",
",",
"'GET'",
")",
";",
"}"
] |
pre intercept with given class or callable on all GET requests
@param string|callable|\stubbles\webapp\intercepto\PreInterceptor $preInterceptor pre interceptor to add
@param string $path optional path for which pre interceptor should be executed
@return \stubbles\webapp\RoutingConfigurator
|
[
"pre",
"intercept",
"with",
"given",
"class",
"or",
"callable",
"on",
"all",
"GET",
"requests"
] |
train
|
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L323-L326
|
stubbles/stubbles-webapp-core
|
src/main/php/routing/Routing.php
|
Routing.preInterceptOnHead
|
public function preInterceptOnHead($preInterceptor, string $path = null): RoutingConfigurator
{
return $this->preIntercept($preInterceptor, $path, 'HEAD');
}
|
php
|
public function preInterceptOnHead($preInterceptor, string $path = null): RoutingConfigurator
{
return $this->preIntercept($preInterceptor, $path, 'HEAD');
}
|
[
"public",
"function",
"preInterceptOnHead",
"(",
"$",
"preInterceptor",
",",
"string",
"$",
"path",
"=",
"null",
")",
":",
"RoutingConfigurator",
"{",
"return",
"$",
"this",
"->",
"preIntercept",
"(",
"$",
"preInterceptor",
",",
"$",
"path",
",",
"'HEAD'",
")",
";",
"}"
] |
pre intercept with given class or callable on all HEAD requests
@param string|callable|\stubbles\webapp\interceptor\PreInterceptor $preInterceptor pre interceptor to add
@param string $path optional path for which pre interceptor should be executed
@return \stubbles\webapp\RoutingConfigurator
|
[
"pre",
"intercept",
"with",
"given",
"class",
"or",
"callable",
"on",
"all",
"HEAD",
"requests"
] |
train
|
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L335-L338
|
stubbles/stubbles-webapp-core
|
src/main/php/routing/Routing.php
|
Routing.preInterceptOnPost
|
public function preInterceptOnPost($preInterceptor, string $path = null): RoutingConfigurator
{
return $this->preIntercept($preInterceptor, $path, 'POST');
}
|
php
|
public function preInterceptOnPost($preInterceptor, string $path = null): RoutingConfigurator
{
return $this->preIntercept($preInterceptor, $path, 'POST');
}
|
[
"public",
"function",
"preInterceptOnPost",
"(",
"$",
"preInterceptor",
",",
"string",
"$",
"path",
"=",
"null",
")",
":",
"RoutingConfigurator",
"{",
"return",
"$",
"this",
"->",
"preIntercept",
"(",
"$",
"preInterceptor",
",",
"$",
"path",
",",
"'POST'",
")",
";",
"}"
] |
pre intercept with given class or callable on all POST requests
@param string|callable|\stubbles\webapp\interceptor\PreInterceptor $preInterceptor pre interceptor to add
@param string $path optional path for which pre interceptor should be executed
@return \stubbles\webapp\RoutingConfigurator
|
[
"pre",
"intercept",
"with",
"given",
"class",
"or",
"callable",
"on",
"all",
"POST",
"requests"
] |
train
|
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L347-L350
|
stubbles/stubbles-webapp-core
|
src/main/php/routing/Routing.php
|
Routing.preInterceptOnPut
|
public function preInterceptOnPut($preInterceptor, string $path = null): RoutingConfigurator
{
return $this->preIntercept($preInterceptor, $path, 'PUT');
}
|
php
|
public function preInterceptOnPut($preInterceptor, string $path = null): RoutingConfigurator
{
return $this->preIntercept($preInterceptor, $path, 'PUT');
}
|
[
"public",
"function",
"preInterceptOnPut",
"(",
"$",
"preInterceptor",
",",
"string",
"$",
"path",
"=",
"null",
")",
":",
"RoutingConfigurator",
"{",
"return",
"$",
"this",
"->",
"preIntercept",
"(",
"$",
"preInterceptor",
",",
"$",
"path",
",",
"'PUT'",
")",
";",
"}"
] |
pre intercept with given class or callable on all PUT requests
@param string|callable|\stubbles\webapp\interceptor\PreInterceptor $preInterceptor pre interceptor to add
@param string $path optional path for which pre interceptor should be executed
@return \stubbles\webapp\RoutingConfigurator
|
[
"pre",
"intercept",
"with",
"given",
"class",
"or",
"callable",
"on",
"all",
"PUT",
"requests"
] |
train
|
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L359-L362
|
stubbles/stubbles-webapp-core
|
src/main/php/routing/Routing.php
|
Routing.preInterceptOnDelete
|
public function preInterceptOnDelete($preInterceptor, string $path = null): RoutingConfigurator
{
return $this->preIntercept($preInterceptor, $path, 'DELETE');
}
|
php
|
public function preInterceptOnDelete($preInterceptor, string $path = null): RoutingConfigurator
{
return $this->preIntercept($preInterceptor, $path, 'DELETE');
}
|
[
"public",
"function",
"preInterceptOnDelete",
"(",
"$",
"preInterceptor",
",",
"string",
"$",
"path",
"=",
"null",
")",
":",
"RoutingConfigurator",
"{",
"return",
"$",
"this",
"->",
"preIntercept",
"(",
"$",
"preInterceptor",
",",
"$",
"path",
",",
"'DELETE'",
")",
";",
"}"
] |
pre intercept with given class or callable on all DELETE requests
@param string|callable|\stubbles\webapp\interceptor\PreInterceptor $preInterceptor pre interceptor to add
@param string $path optional path for which pre interceptor should be executed
@return \stubbles\webapp\RoutingConfigurator
|
[
"pre",
"intercept",
"with",
"given",
"class",
"or",
"callable",
"on",
"all",
"DELETE",
"requests"
] |
train
|
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L371-L374
|
stubbles/stubbles-webapp-core
|
src/main/php/routing/Routing.php
|
Routing.preIntercept
|
public function preIntercept($preInterceptor, string $path = null, string $requestMethod = null): RoutingConfigurator
{
if (!is_callable($preInterceptor) && !($preInterceptor instanceof PreInterceptor) && !class_exists((string) $preInterceptor)) {
throw new \InvalidArgumentException(
'Given pre interceptor must be a callable, an instance of '
. PreInterceptor::class
. ' or a class name of an existing pre interceptor class'
);
}
$this->preInterceptors[] = [
'interceptor' => $preInterceptor,
'requestMethod' => $requestMethod,
'path' => $path
];
return $this;
}
|
php
|
public function preIntercept($preInterceptor, string $path = null, string $requestMethod = null): RoutingConfigurator
{
if (!is_callable($preInterceptor) && !($preInterceptor instanceof PreInterceptor) && !class_exists((string) $preInterceptor)) {
throw new \InvalidArgumentException(
'Given pre interceptor must be a callable, an instance of '
. PreInterceptor::class
. ' or a class name of an existing pre interceptor class'
);
}
$this->preInterceptors[] = [
'interceptor' => $preInterceptor,
'requestMethod' => $requestMethod,
'path' => $path
];
return $this;
}
|
[
"public",
"function",
"preIntercept",
"(",
"$",
"preInterceptor",
",",
"string",
"$",
"path",
"=",
"null",
",",
"string",
"$",
"requestMethod",
"=",
"null",
")",
":",
"RoutingConfigurator",
"{",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"preInterceptor",
")",
"&&",
"!",
"(",
"$",
"preInterceptor",
"instanceof",
"PreInterceptor",
")",
"&&",
"!",
"class_exists",
"(",
"(",
"string",
")",
"$",
"preInterceptor",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Given pre interceptor must be a callable, an instance of '",
".",
"PreInterceptor",
"::",
"class",
".",
"' or a class name of an existing pre interceptor class'",
")",
";",
"}",
"$",
"this",
"->",
"preInterceptors",
"[",
"]",
"=",
"[",
"'interceptor'",
"=>",
"$",
"preInterceptor",
",",
"'requestMethod'",
"=>",
"$",
"requestMethod",
",",
"'path'",
"=>",
"$",
"path",
"]",
";",
"return",
"$",
"this",
";",
"}"
] |
pre intercept with given class or callable on all requests
@param string|callable|\stubbles\webapp\interceptor\PreInterceptor $preInterceptor pre interceptor to add
@param string $path optional path for which pre interceptor should be executed
@param string $requestMethod request method for which interceptor should be executed
@return \stubbles\webapp\RoutingConfigurator
@throws \InvalidArgumentException
|
[
"pre",
"intercept",
"with",
"given",
"class",
"or",
"callable",
"on",
"all",
"requests"
] |
train
|
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L385-L401
|
stubbles/stubbles-webapp-core
|
src/main/php/routing/Routing.php
|
Routing.postInterceptOnGet
|
public function postInterceptOnGet($postInterceptor, string $path = null): RoutingConfigurator
{
return $this->postIntercept($postInterceptor, $path, 'GET');
}
|
php
|
public function postInterceptOnGet($postInterceptor, string $path = null): RoutingConfigurator
{
return $this->postIntercept($postInterceptor, $path, 'GET');
}
|
[
"public",
"function",
"postInterceptOnGet",
"(",
"$",
"postInterceptor",
",",
"string",
"$",
"path",
"=",
"null",
")",
":",
"RoutingConfigurator",
"{",
"return",
"$",
"this",
"->",
"postIntercept",
"(",
"$",
"postInterceptor",
",",
"$",
"path",
",",
"'GET'",
")",
";",
"}"
] |
post intercept with given class or callable on all GET requests
@param string|callable|\stubbles\webapp\interceptor\PostInterceptor $postInterceptor post interceptor to add
@param string $path optional path for which post interceptor should be executed
@return \stubbles\webapp\RoutingConfigurator
|
[
"post",
"intercept",
"with",
"given",
"class",
"or",
"callable",
"on",
"all",
"GET",
"requests"
] |
train
|
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L410-L413
|
stubbles/stubbles-webapp-core
|
src/main/php/routing/Routing.php
|
Routing.postInterceptOnHead
|
public function postInterceptOnHead($postInterceptor, string $path = null): RoutingConfigurator
{
return $this->postIntercept($postInterceptor, $path, 'HEAD');
}
|
php
|
public function postInterceptOnHead($postInterceptor, string $path = null): RoutingConfigurator
{
return $this->postIntercept($postInterceptor, $path, 'HEAD');
}
|
[
"public",
"function",
"postInterceptOnHead",
"(",
"$",
"postInterceptor",
",",
"string",
"$",
"path",
"=",
"null",
")",
":",
"RoutingConfigurator",
"{",
"return",
"$",
"this",
"->",
"postIntercept",
"(",
"$",
"postInterceptor",
",",
"$",
"path",
",",
"'HEAD'",
")",
";",
"}"
] |
post intercept with given class or callable on all HEAD requests
@param string|callable|\stubbles\webapp\interceptor\PostInterceptor $postInterceptor post interceptor to add
@param string $path optional path for which post interceptor should be executed
@return \stubbles\webapp\RoutingConfigurator
|
[
"post",
"intercept",
"with",
"given",
"class",
"or",
"callable",
"on",
"all",
"HEAD",
"requests"
] |
train
|
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L422-L425
|
stubbles/stubbles-webapp-core
|
src/main/php/routing/Routing.php
|
Routing.postInterceptOnPost
|
public function postInterceptOnPost($postInterceptor, string $path = null): RoutingConfigurator
{
return $this->postIntercept($postInterceptor, $path, 'POST');
}
|
php
|
public function postInterceptOnPost($postInterceptor, string $path = null): RoutingConfigurator
{
return $this->postIntercept($postInterceptor, $path, 'POST');
}
|
[
"public",
"function",
"postInterceptOnPost",
"(",
"$",
"postInterceptor",
",",
"string",
"$",
"path",
"=",
"null",
")",
":",
"RoutingConfigurator",
"{",
"return",
"$",
"this",
"->",
"postIntercept",
"(",
"$",
"postInterceptor",
",",
"$",
"path",
",",
"'POST'",
")",
";",
"}"
] |
post intercept with given class or callable on all POST requests
@param string|callable|\stubbles\webapp\interceptor\PostInterceptor $postInterceptor post interceptor to add
@param string $path optional path for which post interceptor should be executed
@return \stubbles\webapp\RoutingConfigurator
|
[
"post",
"intercept",
"with",
"given",
"class",
"or",
"callable",
"on",
"all",
"POST",
"requests"
] |
train
|
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L434-L437
|
stubbles/stubbles-webapp-core
|
src/main/php/routing/Routing.php
|
Routing.postInterceptOnPut
|
public function postInterceptOnPut($postInterceptor, string $path = null): RoutingConfigurator
{
return $this->postIntercept($postInterceptor, $path, 'PUT');
}
|
php
|
public function postInterceptOnPut($postInterceptor, string $path = null): RoutingConfigurator
{
return $this->postIntercept($postInterceptor, $path, 'PUT');
}
|
[
"public",
"function",
"postInterceptOnPut",
"(",
"$",
"postInterceptor",
",",
"string",
"$",
"path",
"=",
"null",
")",
":",
"RoutingConfigurator",
"{",
"return",
"$",
"this",
"->",
"postIntercept",
"(",
"$",
"postInterceptor",
",",
"$",
"path",
",",
"'PUT'",
")",
";",
"}"
] |
post intercept with given class or callable on all PUT requests
@param string|callable|\stubbles\webapp\interceptor\PostInterceptor $postInterceptor post interceptor to add
@param string $path optional path for which post interceptor should be executed
@return \stubbles\webapp\RoutingConfigurator
|
[
"post",
"intercept",
"with",
"given",
"class",
"or",
"callable",
"on",
"all",
"PUT",
"requests"
] |
train
|
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L446-L449
|
stubbles/stubbles-webapp-core
|
src/main/php/routing/Routing.php
|
Routing.postInterceptOnDelete
|
public function postInterceptOnDelete($postInterceptor, string $path = null): RoutingConfigurator
{
return $this->postIntercept($postInterceptor, $path, 'DELETE');
}
|
php
|
public function postInterceptOnDelete($postInterceptor, string $path = null): RoutingConfigurator
{
return $this->postIntercept($postInterceptor, $path, 'DELETE');
}
|
[
"public",
"function",
"postInterceptOnDelete",
"(",
"$",
"postInterceptor",
",",
"string",
"$",
"path",
"=",
"null",
")",
":",
"RoutingConfigurator",
"{",
"return",
"$",
"this",
"->",
"postIntercept",
"(",
"$",
"postInterceptor",
",",
"$",
"path",
",",
"'DELETE'",
")",
";",
"}"
] |
post intercept with given class or callable on all DELETE requests
@param string|callable|\stubbles\webapp\interceptor\PostInterceptor $postInterceptor post interceptor to add
@param string $path optional path for which post interceptor should be executed
@return \stubbles\webapp\RoutingConfigurator
|
[
"post",
"intercept",
"with",
"given",
"class",
"or",
"callable",
"on",
"all",
"DELETE",
"requests"
] |
train
|
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L458-L461
|
stubbles/stubbles-webapp-core
|
src/main/php/routing/Routing.php
|
Routing.postIntercept
|
public function postIntercept($postInterceptor, string $path = null, string $requestMethod = null): RoutingConfigurator
{
if (!is_callable($postInterceptor) && !($postInterceptor instanceof PostInterceptor) && !class_exists((string) $postInterceptor)) {
throw new \InvalidArgumentException(
'Given pre interceptor must be a callable, an instance of '
. PostInterceptor::class
. ' or a class name of an existing post interceptor class'
);
}
$this->postInterceptors[] = [
'interceptor' => $postInterceptor,
'requestMethod' => $requestMethod,
'path' => $path
];
return $this;
}
|
php
|
public function postIntercept($postInterceptor, string $path = null, string $requestMethod = null): RoutingConfigurator
{
if (!is_callable($postInterceptor) && !($postInterceptor instanceof PostInterceptor) && !class_exists((string) $postInterceptor)) {
throw new \InvalidArgumentException(
'Given pre interceptor must be a callable, an instance of '
. PostInterceptor::class
. ' or a class name of an existing post interceptor class'
);
}
$this->postInterceptors[] = [
'interceptor' => $postInterceptor,
'requestMethod' => $requestMethod,
'path' => $path
];
return $this;
}
|
[
"public",
"function",
"postIntercept",
"(",
"$",
"postInterceptor",
",",
"string",
"$",
"path",
"=",
"null",
",",
"string",
"$",
"requestMethod",
"=",
"null",
")",
":",
"RoutingConfigurator",
"{",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"postInterceptor",
")",
"&&",
"!",
"(",
"$",
"postInterceptor",
"instanceof",
"PostInterceptor",
")",
"&&",
"!",
"class_exists",
"(",
"(",
"string",
")",
"$",
"postInterceptor",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Given pre interceptor must be a callable, an instance of '",
".",
"PostInterceptor",
"::",
"class",
".",
"' or a class name of an existing post interceptor class'",
")",
";",
"}",
"$",
"this",
"->",
"postInterceptors",
"[",
"]",
"=",
"[",
"'interceptor'",
"=>",
"$",
"postInterceptor",
",",
"'requestMethod'",
"=>",
"$",
"requestMethod",
",",
"'path'",
"=>",
"$",
"path",
"]",
";",
"return",
"$",
"this",
";",
"}"
] |
post intercept with given class or callable on all requests
@param string|callable|\stubbles\webapp\interceptor\PostInterceptor $postInterceptor post interceptor to add
@param string $path optional path for which post interceptor should be executed
@param string $requestMethod optional request method for which interceptor should be executed
@return \stubbles\webapp\RoutingConfigurator
@throws \InvalidArgumentException
|
[
"post",
"intercept",
"with",
"given",
"class",
"or",
"callable",
"on",
"all",
"requests"
] |
train
|
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L472-L488
|
stubbles/stubbles-webapp-core
|
src/main/php/routing/Routing.php
|
Routing.collectInterceptors
|
private function collectInterceptors(CalledUri $calledUri, Route $route = null): Interceptors
{
return new Interceptors(
$this->injector,
$this->getPreInterceptors($calledUri, $route),
$this->getPostInterceptors($calledUri, $route)
);
}
|
php
|
private function collectInterceptors(CalledUri $calledUri, Route $route = null): Interceptors
{
return new Interceptors(
$this->injector,
$this->getPreInterceptors($calledUri, $route),
$this->getPostInterceptors($calledUri, $route)
);
}
|
[
"private",
"function",
"collectInterceptors",
"(",
"CalledUri",
"$",
"calledUri",
",",
"Route",
"$",
"route",
"=",
"null",
")",
":",
"Interceptors",
"{",
"return",
"new",
"Interceptors",
"(",
"$",
"this",
"->",
"injector",
",",
"$",
"this",
"->",
"getPreInterceptors",
"(",
"$",
"calledUri",
",",
"$",
"route",
")",
",",
"$",
"this",
"->",
"getPostInterceptors",
"(",
"$",
"calledUri",
",",
"$",
"route",
")",
")",
";",
"}"
] |
collects interceptors
@param \stubbles\webapp\routing\CalledUri $calledUri
@param \stubbles\webapp\routing\Route $route
@return \stubbles\webapp\interceptor\Interceptors
|
[
"collects",
"interceptors"
] |
train
|
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L497-L504
|
stubbles/stubbles-webapp-core
|
src/main/php/routing/Routing.php
|
Routing.getPreInterceptors
|
private function getPreInterceptors(CalledUri $calledUri, Route $route = null): array
{
$global = $this->getApplicable($calledUri, $this->preInterceptors);
if (null === $route) {
return $global;
}
return array_merge($global, $route->preInterceptors());
}
|
php
|
private function getPreInterceptors(CalledUri $calledUri, Route $route = null): array
{
$global = $this->getApplicable($calledUri, $this->preInterceptors);
if (null === $route) {
return $global;
}
return array_merge($global, $route->preInterceptors());
}
|
[
"private",
"function",
"getPreInterceptors",
"(",
"CalledUri",
"$",
"calledUri",
",",
"Route",
"$",
"route",
"=",
"null",
")",
":",
"array",
"{",
"$",
"global",
"=",
"$",
"this",
"->",
"getApplicable",
"(",
"$",
"calledUri",
",",
"$",
"this",
"->",
"preInterceptors",
")",
";",
"if",
"(",
"null",
"===",
"$",
"route",
")",
"{",
"return",
"$",
"global",
";",
"}",
"return",
"array_merge",
"(",
"$",
"global",
",",
"$",
"route",
"->",
"preInterceptors",
"(",
")",
")",
";",
"}"
] |
returns list of applicable pre interceptors for this request
@param \stubbles\webapp\routing\CalledUri $calledUri
@param \stubbles\webapp\routing\Route $route
@return array
|
[
"returns",
"list",
"of",
"applicable",
"pre",
"interceptors",
"for",
"this",
"request"
] |
train
|
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L513-L521
|
stubbles/stubbles-webapp-core
|
src/main/php/routing/Routing.php
|
Routing.getPostInterceptors
|
private function getPostInterceptors(CalledUri $calledUri, Route $route = null): array
{
$global = $this->getApplicable($calledUri, $this->postInterceptors);
if (null === $route) {
return $global;
}
return array_merge($route->postInterceptors(), $global);
}
|
php
|
private function getPostInterceptors(CalledUri $calledUri, Route $route = null): array
{
$global = $this->getApplicable($calledUri, $this->postInterceptors);
if (null === $route) {
return $global;
}
return array_merge($route->postInterceptors(), $global);
}
|
[
"private",
"function",
"getPostInterceptors",
"(",
"CalledUri",
"$",
"calledUri",
",",
"Route",
"$",
"route",
"=",
"null",
")",
":",
"array",
"{",
"$",
"global",
"=",
"$",
"this",
"->",
"getApplicable",
"(",
"$",
"calledUri",
",",
"$",
"this",
"->",
"postInterceptors",
")",
";",
"if",
"(",
"null",
"===",
"$",
"route",
")",
"{",
"return",
"$",
"global",
";",
"}",
"return",
"array_merge",
"(",
"$",
"route",
"->",
"postInterceptors",
"(",
")",
",",
"$",
"global",
")",
";",
"}"
] |
returns list of applicable post interceptors for this request
@param \stubbles\webapp\routing\CalledUri $calledUri
@param \stubbles\webapp\routing\Route $route
@return array
|
[
"returns",
"list",
"of",
"applicable",
"post",
"interceptors",
"for",
"this",
"request"
] |
train
|
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L530-L538
|
stubbles/stubbles-webapp-core
|
src/main/php/routing/Routing.php
|
Routing.getApplicable
|
private function getApplicable(CalledUri $calledUri, array $interceptors): array
{
$applicable = [];
foreach ($interceptors as $interceptor) {
if ($calledUri->satisfies($interceptor['requestMethod'], $interceptor['path'])) {
$applicable[] = $interceptor['interceptor'];
}
}
return $applicable;
}
|
php
|
private function getApplicable(CalledUri $calledUri, array $interceptors): array
{
$applicable = [];
foreach ($interceptors as $interceptor) {
if ($calledUri->satisfies($interceptor['requestMethod'], $interceptor['path'])) {
$applicable[] = $interceptor['interceptor'];
}
}
return $applicable;
}
|
[
"private",
"function",
"getApplicable",
"(",
"CalledUri",
"$",
"calledUri",
",",
"array",
"$",
"interceptors",
")",
":",
"array",
"{",
"$",
"applicable",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"interceptors",
"as",
"$",
"interceptor",
")",
"{",
"if",
"(",
"$",
"calledUri",
"->",
"satisfies",
"(",
"$",
"interceptor",
"[",
"'requestMethod'",
"]",
",",
"$",
"interceptor",
"[",
"'path'",
"]",
")",
")",
"{",
"$",
"applicable",
"[",
"]",
"=",
"$",
"interceptor",
"[",
"'interceptor'",
"]",
";",
"}",
"}",
"return",
"$",
"applicable",
";",
"}"
] |
calculates which interceptors are applicable for given request method
@param \stubbles\webapp\routing\CalledUri $calledUri
@param array[] $interceptors list of interceptors to check
@return array
|
[
"calculates",
"which",
"interceptors",
"are",
"applicable",
"for",
"given",
"request",
"method"
] |
train
|
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L547-L557
|
stubbles/stubbles-webapp-core
|
src/main/php/routing/Routing.php
|
Routing.setDefaultMimeTypeClass
|
public function setDefaultMimeTypeClass(string $mimeType, $mimeTypeClass): RoutingConfigurator
{
SupportedMimeTypes::setDefaultMimeTypeClass($mimeType, $mimeTypeClass);
return $this;
}
|
php
|
public function setDefaultMimeTypeClass(string $mimeType, $mimeTypeClass): RoutingConfigurator
{
SupportedMimeTypes::setDefaultMimeTypeClass($mimeType, $mimeTypeClass);
return $this;
}
|
[
"public",
"function",
"setDefaultMimeTypeClass",
"(",
"string",
"$",
"mimeType",
",",
"$",
"mimeTypeClass",
")",
":",
"RoutingConfigurator",
"{",
"SupportedMimeTypes",
"::",
"setDefaultMimeTypeClass",
"(",
"$",
"mimeType",
",",
"$",
"mimeTypeClass",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
sets a default mime type class for given mime type, but doesn't mark the mime type as supported for all routes
@param string $mimeType mime type to set default class for
@param string $mimeTypeClass class to use
@return \stubbles\webapp\routing\Routing
@since 5.1.0
|
[
"sets",
"a",
"default",
"mime",
"type",
"class",
"for",
"given",
"mime",
"type",
"but",
"doesn",
"t",
"mark",
"the",
"mime",
"type",
"as",
"supported",
"for",
"all",
"routes"
] |
train
|
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L567-L571
|
stubbles/stubbles-webapp-core
|
src/main/php/routing/Routing.php
|
Routing.supportsMimeType
|
public function supportsMimeType(string $mimeType, $mimeTypeClass = null): RoutingConfigurator
{
if (null === $mimeTypeClass && !SupportedMimeTypes::provideDefaultClassFor($mimeType)) {
throw new \InvalidArgumentException(
'No default class known for mime type ' . $mimeType
. ', please provide a class'
);
}
$this->mimeTypes[] = $mimeType;
if (null !== $mimeTypeClass) {
$this->mimeTypeClasses[$mimeType] = $mimeTypeClass;
}
return $this;
}
|
php
|
public function supportsMimeType(string $mimeType, $mimeTypeClass = null): RoutingConfigurator
{
if (null === $mimeTypeClass && !SupportedMimeTypes::provideDefaultClassFor($mimeType)) {
throw new \InvalidArgumentException(
'No default class known for mime type ' . $mimeType
. ', please provide a class'
);
}
$this->mimeTypes[] = $mimeType;
if (null !== $mimeTypeClass) {
$this->mimeTypeClasses[$mimeType] = $mimeTypeClass;
}
return $this;
}
|
[
"public",
"function",
"supportsMimeType",
"(",
"string",
"$",
"mimeType",
",",
"$",
"mimeTypeClass",
"=",
"null",
")",
":",
"RoutingConfigurator",
"{",
"if",
"(",
"null",
"===",
"$",
"mimeTypeClass",
"&&",
"!",
"SupportedMimeTypes",
"::",
"provideDefaultClassFor",
"(",
"$",
"mimeType",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'No default class known for mime type '",
".",
"$",
"mimeType",
".",
"', please provide a class'",
")",
";",
"}",
"$",
"this",
"->",
"mimeTypes",
"[",
"]",
"=",
"$",
"mimeType",
";",
"if",
"(",
"null",
"!==",
"$",
"mimeTypeClass",
")",
"{",
"$",
"this",
"->",
"mimeTypeClasses",
"[",
"$",
"mimeType",
"]",
"=",
"$",
"mimeTypeClass",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
add a supported mime type
@param string $mimeType
@param string $mimeTypeClass optional special class to be used for given mime type on this route
@return \stubbles\webapp\routing\Routing
@throws \InvalidArgumentException
|
[
"add",
"a",
"supported",
"mime",
"type"
] |
train
|
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L581-L596
|
stubbles/stubbles-webapp-core
|
src/main/php/routing/Routing.php
|
Routing.supportedMimeTypes
|
private function supportedMimeTypes(Route $route = null): SupportedMimeTypes
{
if ($this->disableContentNegotation) {
return SupportedMimeTypes::createWithDisabledContentNegotation();
}
if (null !== $route) {
return $route->supportedMimeTypes(
$this->mimeTypes,
$this->mimeTypeClasses
);
}
return new SupportedMimeTypes($this->mimeTypes, $this->mimeTypeClasses);
}
|
php
|
private function supportedMimeTypes(Route $route = null): SupportedMimeTypes
{
if ($this->disableContentNegotation) {
return SupportedMimeTypes::createWithDisabledContentNegotation();
}
if (null !== $route) {
return $route->supportedMimeTypes(
$this->mimeTypes,
$this->mimeTypeClasses
);
}
return new SupportedMimeTypes($this->mimeTypes, $this->mimeTypeClasses);
}
|
[
"private",
"function",
"supportedMimeTypes",
"(",
"Route",
"$",
"route",
"=",
"null",
")",
":",
"SupportedMimeTypes",
"{",
"if",
"(",
"$",
"this",
"->",
"disableContentNegotation",
")",
"{",
"return",
"SupportedMimeTypes",
"::",
"createWithDisabledContentNegotation",
"(",
")",
";",
"}",
"if",
"(",
"null",
"!==",
"$",
"route",
")",
"{",
"return",
"$",
"route",
"->",
"supportedMimeTypes",
"(",
"$",
"this",
"->",
"mimeTypes",
",",
"$",
"this",
"->",
"mimeTypeClasses",
")",
";",
"}",
"return",
"new",
"SupportedMimeTypes",
"(",
"$",
"this",
"->",
"mimeTypes",
",",
"$",
"this",
"->",
"mimeTypeClasses",
")",
";",
"}"
] |
retrieves list of supported mime types
@param \stubbles\webapp\routing\Route $route
@return \stubbles\webapp\routing\SupportedMimeTypes
|
[
"retrieves",
"list",
"of",
"supported",
"mime",
"types"
] |
train
|
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L616-L630
|
jan-dolata/crude-crud
|
src/Engine/CrudeSetup.php
|
CrudeSetup.getJSData
|
public function getJSData()
{
return [
'name' => $this->name,
'title' => $this->title,
'description' => $this->description,
'column' => $this->column,
'extraColumn' => $this->extraColumn,
'columnFormat' => $this->columnFormat,
'addForm' => $this->addForm,
'editForm' => $this->editForm,
'inputType' => $this->inputType,
'actions' => $this->actions,
'deleteOption' => $this->deleteOption,
'editOption' => $this->editOption,
'addOption' => $this->addOption,
'orderOption' => $this->orderOption,
'exportOption' => $this->exportOption,
'microEditOption' => $this->microEditOption,
'modelDefaults' => $this->modelDefaults,
'selectOptions' => $this->selectOptions,
'filters' => $this->filters,
'richFilters' => $this->richFilters,
'showFilters' => $this->showFilters,
'trans' => $this->trans,
'moduleInPopup' => $this->moduleInPopup,
'customActions' => $this->customActions,
'panelView' => $this->panelView,
'orderParameters' => $this->orderParameters,
'checkboxColumn' => $this->checkboxColumn,
'defaultSortAttr' => $this->defaultSortAttr,
'defaultSortOrder' => $this->defaultSortOrder,
'interfaceTrans' => $this->getInterfaceTrans(),
'thumbnailColumns' => $this->getThumbnailColumns(),
'dateTimePickerOptions' => $this->getDateTimePickerOptions(),
'config' => [
'routePrefix' => config('crude.routePrefix'),
'numRowsOptions' => config('crude.numRowsOptions'),
'iconClassName' => config('crude.iconClassName'),
'refreshAll' => config('crude.refreshAll'),
'mapCenter' => config('crude.mapCenter'),
'sortAttr' => $this->getOrderAttribute(),
],
];
}
|
php
|
public function getJSData()
{
return [
'name' => $this->name,
'title' => $this->title,
'description' => $this->description,
'column' => $this->column,
'extraColumn' => $this->extraColumn,
'columnFormat' => $this->columnFormat,
'addForm' => $this->addForm,
'editForm' => $this->editForm,
'inputType' => $this->inputType,
'actions' => $this->actions,
'deleteOption' => $this->deleteOption,
'editOption' => $this->editOption,
'addOption' => $this->addOption,
'orderOption' => $this->orderOption,
'exportOption' => $this->exportOption,
'microEditOption' => $this->microEditOption,
'modelDefaults' => $this->modelDefaults,
'selectOptions' => $this->selectOptions,
'filters' => $this->filters,
'richFilters' => $this->richFilters,
'showFilters' => $this->showFilters,
'trans' => $this->trans,
'moduleInPopup' => $this->moduleInPopup,
'customActions' => $this->customActions,
'panelView' => $this->panelView,
'orderParameters' => $this->orderParameters,
'checkboxColumn' => $this->checkboxColumn,
'defaultSortAttr' => $this->defaultSortAttr,
'defaultSortOrder' => $this->defaultSortOrder,
'interfaceTrans' => $this->getInterfaceTrans(),
'thumbnailColumns' => $this->getThumbnailColumns(),
'dateTimePickerOptions' => $this->getDateTimePickerOptions(),
'config' => [
'routePrefix' => config('crude.routePrefix'),
'numRowsOptions' => config('crude.numRowsOptions'),
'iconClassName' => config('crude.iconClassName'),
'refreshAll' => config('crude.refreshAll'),
'mapCenter' => config('crude.mapCenter'),
'sortAttr' => $this->getOrderAttribute(),
],
];
}
|
[
"public",
"function",
"getJSData",
"(",
")",
"{",
"return",
"[",
"'name'",
"=>",
"$",
"this",
"->",
"name",
",",
"'title'",
"=>",
"$",
"this",
"->",
"title",
",",
"'description'",
"=>",
"$",
"this",
"->",
"description",
",",
"'column'",
"=>",
"$",
"this",
"->",
"column",
",",
"'extraColumn'",
"=>",
"$",
"this",
"->",
"extraColumn",
",",
"'columnFormat'",
"=>",
"$",
"this",
"->",
"columnFormat",
",",
"'addForm'",
"=>",
"$",
"this",
"->",
"addForm",
",",
"'editForm'",
"=>",
"$",
"this",
"->",
"editForm",
",",
"'inputType'",
"=>",
"$",
"this",
"->",
"inputType",
",",
"'actions'",
"=>",
"$",
"this",
"->",
"actions",
",",
"'deleteOption'",
"=>",
"$",
"this",
"->",
"deleteOption",
",",
"'editOption'",
"=>",
"$",
"this",
"->",
"editOption",
",",
"'addOption'",
"=>",
"$",
"this",
"->",
"addOption",
",",
"'orderOption'",
"=>",
"$",
"this",
"->",
"orderOption",
",",
"'exportOption'",
"=>",
"$",
"this",
"->",
"exportOption",
",",
"'microEditOption'",
"=>",
"$",
"this",
"->",
"microEditOption",
",",
"'modelDefaults'",
"=>",
"$",
"this",
"->",
"modelDefaults",
",",
"'selectOptions'",
"=>",
"$",
"this",
"->",
"selectOptions",
",",
"'filters'",
"=>",
"$",
"this",
"->",
"filters",
",",
"'richFilters'",
"=>",
"$",
"this",
"->",
"richFilters",
",",
"'showFilters'",
"=>",
"$",
"this",
"->",
"showFilters",
",",
"'trans'",
"=>",
"$",
"this",
"->",
"trans",
",",
"'moduleInPopup'",
"=>",
"$",
"this",
"->",
"moduleInPopup",
",",
"'customActions'",
"=>",
"$",
"this",
"->",
"customActions",
",",
"'panelView'",
"=>",
"$",
"this",
"->",
"panelView",
",",
"'orderParameters'",
"=>",
"$",
"this",
"->",
"orderParameters",
",",
"'checkboxColumn'",
"=>",
"$",
"this",
"->",
"checkboxColumn",
",",
"'defaultSortAttr'",
"=>",
"$",
"this",
"->",
"defaultSortAttr",
",",
"'defaultSortOrder'",
"=>",
"$",
"this",
"->",
"defaultSortOrder",
",",
"'interfaceTrans'",
"=>",
"$",
"this",
"->",
"getInterfaceTrans",
"(",
")",
",",
"'thumbnailColumns'",
"=>",
"$",
"this",
"->",
"getThumbnailColumns",
"(",
")",
",",
"'dateTimePickerOptions'",
"=>",
"$",
"this",
"->",
"getDateTimePickerOptions",
"(",
")",
",",
"'config'",
"=>",
"[",
"'routePrefix'",
"=>",
"config",
"(",
"'crude.routePrefix'",
")",
",",
"'numRowsOptions'",
"=>",
"config",
"(",
"'crude.numRowsOptions'",
")",
",",
"'iconClassName'",
"=>",
"config",
"(",
"'crude.iconClassName'",
")",
",",
"'refreshAll'",
"=>",
"config",
"(",
"'crude.refreshAll'",
")",
",",
"'mapCenter'",
"=>",
"config",
"(",
"'crude.mapCenter'",
")",
",",
"'sortAttr'",
"=>",
"$",
"this",
"->",
"getOrderAttribute",
"(",
")",
",",
"]",
",",
"]",
";",
"}"
] |
Prepare data for JS list config model
@return array
|
[
"Prepare",
"data",
"for",
"JS",
"list",
"config",
"model"
] |
train
|
https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Engine/CrudeSetup.php#L73-L120
|
blast-project/CoreBundle
|
src/Admin/CoreAdmin.php
|
CoreAdmin.configureRoutes
|
protected function configureRoutes(RouteCollection $collection)
{
parent::configureRoutes($collection);
$collection->add('duplicate', $this->getRouterIdParameter() . '/duplicate');
$collection->add('generateEntityCode');
/* Needed or not needed ...
* in sonata-project/admin-bundle/Controller/CRUDController.php
* the batchAction method
* throw exception if the http method is not POST
*/
if ($collection->get('batch')) {
$collection->get('batch')->setMethods(['POST']);
}
}
|
php
|
protected function configureRoutes(RouteCollection $collection)
{
parent::configureRoutes($collection);
$collection->add('duplicate', $this->getRouterIdParameter() . '/duplicate');
$collection->add('generateEntityCode');
/* Needed or not needed ...
* in sonata-project/admin-bundle/Controller/CRUDController.php
* the batchAction method
* throw exception if the http method is not POST
*/
if ($collection->get('batch')) {
$collection->get('batch')->setMethods(['POST']);
}
}
|
[
"protected",
"function",
"configureRoutes",
"(",
"RouteCollection",
"$",
"collection",
")",
"{",
"parent",
"::",
"configureRoutes",
"(",
"$",
"collection",
")",
";",
"$",
"collection",
"->",
"add",
"(",
"'duplicate'",
",",
"$",
"this",
"->",
"getRouterIdParameter",
"(",
")",
".",
"'/duplicate'",
")",
";",
"$",
"collection",
"->",
"add",
"(",
"'generateEntityCode'",
")",
";",
"/* Needed or not needed ...\n * in sonata-project/admin-bundle/Controller/CRUDController.php\n * the batchAction method\n * throw exception if the http method is not POST\n */",
"if",
"(",
"$",
"collection",
"->",
"get",
"(",
"'batch'",
")",
")",
"{",
"$",
"collection",
"->",
"get",
"(",
"'batch'",
")",
"->",
"setMethods",
"(",
"[",
"'POST'",
"]",
")",
";",
"}",
"}"
] |
Configure routes for list actions.
@param RouteCollection $collection
|
[
"Configure",
"routes",
"for",
"list",
"actions",
"."
] |
train
|
https://github.com/blast-project/CoreBundle/blob/7a0832758ca14e5bc5d65515532c1220df3930ae/src/Admin/CoreAdmin.php#L72-L86
|
blast-project/CoreBundle
|
src/Admin/CoreAdmin.php
|
CoreAdmin.arrayDepth
|
private static function arrayDepth($array, $level = 0)
{
if (!$array) {
return $level;
}
if (!is_array($array)) {
return $level;
}
++$level;
foreach ($array as $key => $value) {
if (is_array($value)) {
$level = $level < self::arrayDepth($value, $level) ? self::arrayDepth($value, $level) : $level;
}
}
return $level;
}
|
php
|
private static function arrayDepth($array, $level = 0)
{
if (!$array) {
return $level;
}
if (!is_array($array)) {
return $level;
}
++$level;
foreach ($array as $key => $value) {
if (is_array($value)) {
$level = $level < self::arrayDepth($value, $level) ? self::arrayDepth($value, $level) : $level;
}
}
return $level;
}
|
[
"private",
"static",
"function",
"arrayDepth",
"(",
"$",
"array",
",",
"$",
"level",
"=",
"0",
")",
"{",
"if",
"(",
"!",
"$",
"array",
")",
"{",
"return",
"$",
"level",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"array",
")",
")",
"{",
"return",
"$",
"level",
";",
"}",
"++",
"$",
"level",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"level",
"=",
"$",
"level",
"<",
"self",
"::",
"arrayDepth",
"(",
"$",
"value",
",",
"$",
"level",
")",
"?",
"self",
"::",
"arrayDepth",
"(",
"$",
"value",
",",
"$",
"level",
")",
":",
"$",
"level",
";",
"}",
"}",
"return",
"$",
"level",
";",
"}"
] |
Returns the level of depth of an array.
@param array $array
@param int $level : do not use, just used for recursivity
@return int : depth
|
[
"Returns",
"the",
"level",
"of",
"depth",
"of",
"an",
"array",
"."
] |
train
|
https://github.com/blast-project/CoreBundle/blob/7a0832758ca14e5bc5d65515532c1220df3930ae/src/Admin/CoreAdmin.php#L216-L234
|
blast-project/CoreBundle
|
src/Admin/CoreAdmin.php
|
CoreAdmin.getExtraTemplates
|
public function getExtraTemplates($view)
{
if (empty($this->extraTemplates[$view])) {
$this->extraTemplates[$view] = [];
}
return $this->extraTemplates[$view];
}
|
php
|
public function getExtraTemplates($view)
{
if (empty($this->extraTemplates[$view])) {
$this->extraTemplates[$view] = [];
}
return $this->extraTemplates[$view];
}
|
[
"public",
"function",
"getExtraTemplates",
"(",
"$",
"view",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"extraTemplates",
"[",
"$",
"view",
"]",
")",
")",
"{",
"$",
"this",
"->",
"extraTemplates",
"[",
"$",
"view",
"]",
"=",
"[",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"extraTemplates",
"[",
"$",
"view",
"]",
";",
"}"
] |
@param string $view 'list', 'show', 'form', etc
@return array array of template names
|
[
"@param",
"string",
"$view",
"list",
"show",
"form",
"etc"
] |
train
|
https://github.com/blast-project/CoreBundle/blob/7a0832758ca14e5bc5d65515532c1220df3930ae/src/Admin/CoreAdmin.php#L275-L282
|
blast-project/CoreBundle
|
src/Admin/CoreAdmin.php
|
CoreAdmin.getHelperLinks
|
public function getHelperLinks($view)
{
if (empty($this->helperLinks[$view])) {
$this->helperLinks[$view] = [];
}
return $this->helperLinks[$view];
}
|
php
|
public function getHelperLinks($view)
{
if (empty($this->helperLinks[$view])) {
$this->helperLinks[$view] = [];
}
return $this->helperLinks[$view];
}
|
[
"public",
"function",
"getHelperLinks",
"(",
"$",
"view",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"helperLinks",
"[",
"$",
"view",
"]",
")",
")",
"{",
"$",
"this",
"->",
"helperLinks",
"[",
"$",
"view",
"]",
"=",
"[",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"helperLinks",
"[",
"$",
"view",
"]",
";",
"}"
] |
@param string $view 'list', 'show', 'form', etc
@return array array of links (each link is an array with keys 'label', 'url', 'class' and 'title')
|
[
"@param",
"string",
"$view",
"list",
"show",
"form",
"etc"
] |
train
|
https://github.com/blast-project/CoreBundle/blob/7a0832758ca14e5bc5d65515532c1220df3930ae/src/Admin/CoreAdmin.php#L314-L321
|
blast-project/CoreBundle
|
src/Admin/CoreAdmin.php
|
CoreAdmin.bundleExists
|
public function bundleExists($bundle)
{
$kernelBundles = $this->getConfigurationPool()->getContainer()->getParameter('kernel.bundles');
if (array_key_exists($bundle, $kernelBundles)) {
return true;
}
if (in_array($bundle, $kernelBundles)) {
return true;
}
return false;
}
|
php
|
public function bundleExists($bundle)
{
$kernelBundles = $this->getConfigurationPool()->getContainer()->getParameter('kernel.bundles');
if (array_key_exists($bundle, $kernelBundles)) {
return true;
}
if (in_array($bundle, $kernelBundles)) {
return true;
}
return false;
}
|
[
"public",
"function",
"bundleExists",
"(",
"$",
"bundle",
")",
"{",
"$",
"kernelBundles",
"=",
"$",
"this",
"->",
"getConfigurationPool",
"(",
")",
"->",
"getContainer",
"(",
")",
"->",
"getParameter",
"(",
"'kernel.bundles'",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"bundle",
",",
"$",
"kernelBundles",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"in_array",
"(",
"$",
"bundle",
",",
"$",
"kernelBundles",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Checks if a Bundle is installed.
@param string $bundle Bundle name or class FQN
|
[
"Checks",
"if",
"a",
"Bundle",
"is",
"installed",
"."
] |
train
|
https://github.com/blast-project/CoreBundle/blob/7a0832758ca14e5bc5d65515532c1220df3930ae/src/Admin/CoreAdmin.php#L328-L339
|
blast-project/CoreBundle
|
src/Admin/CoreAdmin.php
|
CoreAdmin.renameFormTab
|
public function renameFormTab($tabName, $newTabName, $keepOrder = true)
{
$tabs = $this->getFormTabs();
if (!$tabs) {
return;
}
if (!isset($tabs[$tabName])) {
throw new \Exception(sprintf('Tab %s does not exist.', $tabName));
}
if (isset($tabs[$newTabName])) {
return;
}
if ($keepOrder) {
$keys = array_keys($tabs);
$keys[array_search($tabName, $keys)] = $newTabName;
$tabs = array_combine($keys, $tabs);
} else {
$tabs[$newTabName] = $tabs[$tabName];
unset($tabs[$tabName]);
}
$this->setFormTabs($tabs);
}
|
php
|
public function renameFormTab($tabName, $newTabName, $keepOrder = true)
{
$tabs = $this->getFormTabs();
if (!$tabs) {
return;
}
if (!isset($tabs[$tabName])) {
throw new \Exception(sprintf('Tab %s does not exist.', $tabName));
}
if (isset($tabs[$newTabName])) {
return;
}
if ($keepOrder) {
$keys = array_keys($tabs);
$keys[array_search($tabName, $keys)] = $newTabName;
$tabs = array_combine($keys, $tabs);
} else {
$tabs[$newTabName] = $tabs[$tabName];
unset($tabs[$tabName]);
}
$this->setFormTabs($tabs);
}
|
[
"public",
"function",
"renameFormTab",
"(",
"$",
"tabName",
",",
"$",
"newTabName",
",",
"$",
"keepOrder",
"=",
"true",
")",
"{",
"$",
"tabs",
"=",
"$",
"this",
"->",
"getFormTabs",
"(",
")",
";",
"if",
"(",
"!",
"$",
"tabs",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"tabs",
"[",
"$",
"tabName",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"'Tab %s does not exist.'",
",",
"$",
"tabName",
")",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"tabs",
"[",
"$",
"newTabName",
"]",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"keepOrder",
")",
"{",
"$",
"keys",
"=",
"array_keys",
"(",
"$",
"tabs",
")",
";",
"$",
"keys",
"[",
"array_search",
"(",
"$",
"tabName",
",",
"$",
"keys",
")",
"]",
"=",
"$",
"newTabName",
";",
"$",
"tabs",
"=",
"array_combine",
"(",
"$",
"keys",
",",
"$",
"tabs",
")",
";",
"}",
"else",
"{",
"$",
"tabs",
"[",
"$",
"newTabName",
"]",
"=",
"$",
"tabs",
"[",
"$",
"tabName",
"]",
";",
"unset",
"(",
"$",
"tabs",
"[",
"$",
"tabName",
"]",
")",
";",
"}",
"$",
"this",
"->",
"setFormTabs",
"(",
"$",
"tabs",
")",
";",
"}"
] |
Rename a form tab after form fields have been configured.
TODO: groups of the renamed tab are still prefixed with the old tab name
@param type $tabName the name of the tab to be renamed
@param type $newTabName the new name for the tab
|
[
"Rename",
"a",
"form",
"tab",
"after",
"form",
"fields",
"have",
"been",
"configured",
"."
] |
train
|
https://github.com/blast-project/CoreBundle/blob/7a0832758ca14e5bc5d65515532c1220df3930ae/src/Admin/CoreAdmin.php#L349-L374
|
blast-project/CoreBundle
|
src/Admin/CoreAdmin.php
|
CoreAdmin.renameShowTab
|
public function renameShowTab($tabName, $newTabName, $keepOrder = true)
{
$tabs = $this->getShowTabs();
if (!$tabs) {
return;
}
if (!isset($tabs[$tabName])) {
throw new \Exception(sprintf('Tab %s does not exist.', $tabName));
}
if (isset($tabs[$newTabName])) {
return;
}
if ($keepOrder) {
$keys = array_keys($tabs);
$keys[array_search($tabName, $keys)] = $newTabName;
$tabs = array_combine($keys, $tabs);
} else {
$tabs[$newTabName] = $tabs[$tabName];
unset($tabs[$tabName]);
}
$this->setShowTabs($tabs);
}
|
php
|
public function renameShowTab($tabName, $newTabName, $keepOrder = true)
{
$tabs = $this->getShowTabs();
if (!$tabs) {
return;
}
if (!isset($tabs[$tabName])) {
throw new \Exception(sprintf('Tab %s does not exist.', $tabName));
}
if (isset($tabs[$newTabName])) {
return;
}
if ($keepOrder) {
$keys = array_keys($tabs);
$keys[array_search($tabName, $keys)] = $newTabName;
$tabs = array_combine($keys, $tabs);
} else {
$tabs[$newTabName] = $tabs[$tabName];
unset($tabs[$tabName]);
}
$this->setShowTabs($tabs);
}
|
[
"public",
"function",
"renameShowTab",
"(",
"$",
"tabName",
",",
"$",
"newTabName",
",",
"$",
"keepOrder",
"=",
"true",
")",
"{",
"$",
"tabs",
"=",
"$",
"this",
"->",
"getShowTabs",
"(",
")",
";",
"if",
"(",
"!",
"$",
"tabs",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"tabs",
"[",
"$",
"tabName",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"'Tab %s does not exist.'",
",",
"$",
"tabName",
")",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"tabs",
"[",
"$",
"newTabName",
"]",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"keepOrder",
")",
"{",
"$",
"keys",
"=",
"array_keys",
"(",
"$",
"tabs",
")",
";",
"$",
"keys",
"[",
"array_search",
"(",
"$",
"tabName",
",",
"$",
"keys",
")",
"]",
"=",
"$",
"newTabName",
";",
"$",
"tabs",
"=",
"array_combine",
"(",
"$",
"keys",
",",
"$",
"tabs",
")",
";",
"}",
"else",
"{",
"$",
"tabs",
"[",
"$",
"newTabName",
"]",
"=",
"$",
"tabs",
"[",
"$",
"tabName",
"]",
";",
"unset",
"(",
"$",
"tabs",
"[",
"$",
"tabName",
"]",
")",
";",
"}",
"$",
"this",
"->",
"setShowTabs",
"(",
"$",
"tabs",
")",
";",
"}"
] |
Rename a show tab after show fields have been configured.
TODO: groups of the renamed tab are still prefixed with the old tab name
@param type $tabName the name of the tab to be renamed
@param type $newTabName the new name for the tab
|
[
"Rename",
"a",
"show",
"tab",
"after",
"show",
"fields",
"have",
"been",
"configured",
"."
] |
train
|
https://github.com/blast-project/CoreBundle/blob/7a0832758ca14e5bc5d65515532c1220df3930ae/src/Admin/CoreAdmin.php#L384-L409
|
blast-project/CoreBundle
|
src/Admin/CoreAdmin.php
|
CoreAdmin.renameFormGroup
|
public function renameFormGroup($group, $tab, $newGroupName)
{
$groups = $this->getFormGroups();
// When the default tab is used, the tabname is not prepended to the index in the group array
if ($tab !== 'default') {
$group = $tab . '.' . $group;
}
$newGroup = ($tab !== 'default') ? $tab . '.' . $newGroupName : $newGroupName;
if (isset($groups[$newGroup])) {
throw new \Exception(sprintf('%s form group already exists.', $newGroup));
}
if (!array_key_exists($group, $groups)) {
throw new \Exception(sprintf('form group « %s » doesn\'t exist.', $group));
}
$groups[$newGroup] = $groups[$group];
$groups[$newGroup]['name'] = $newGroupName;
unset($groups[$group]);
$tabs = $this->getFormTabs();
$key = array_search($group, $tabs[$tab]['groups']);
if (false !== $key) {
$tabs[$tab]['groups'][$key] = $newGroup;
}
$this->setFormTabs($tabs);
$this->setFormGroups($groups);
return $this;
}
|
php
|
public function renameFormGroup($group, $tab, $newGroupName)
{
$groups = $this->getFormGroups();
// When the default tab is used, the tabname is not prepended to the index in the group array
if ($tab !== 'default') {
$group = $tab . '.' . $group;
}
$newGroup = ($tab !== 'default') ? $tab . '.' . $newGroupName : $newGroupName;
if (isset($groups[$newGroup])) {
throw new \Exception(sprintf('%s form group already exists.', $newGroup));
}
if (!array_key_exists($group, $groups)) {
throw new \Exception(sprintf('form group « %s » doesn\'t exist.', $group));
}
$groups[$newGroup] = $groups[$group];
$groups[$newGroup]['name'] = $newGroupName;
unset($groups[$group]);
$tabs = $this->getFormTabs();
$key = array_search($group, $tabs[$tab]['groups']);
if (false !== $key) {
$tabs[$tab]['groups'][$key] = $newGroup;
}
$this->setFormTabs($tabs);
$this->setFormGroups($groups);
return $this;
}
|
[
"public",
"function",
"renameFormGroup",
"(",
"$",
"group",
",",
"$",
"tab",
",",
"$",
"newGroupName",
")",
"{",
"$",
"groups",
"=",
"$",
"this",
"->",
"getFormGroups",
"(",
")",
";",
"// When the default tab is used, the tabname is not prepended to the index in the group array",
"if",
"(",
"$",
"tab",
"!==",
"'default'",
")",
"{",
"$",
"group",
"=",
"$",
"tab",
".",
"'.'",
".",
"$",
"group",
";",
"}",
"$",
"newGroup",
"=",
"(",
"$",
"tab",
"!==",
"'default'",
")",
"?",
"$",
"tab",
".",
"'.'",
".",
"$",
"newGroupName",
":",
"$",
"newGroupName",
";",
"if",
"(",
"isset",
"(",
"$",
"groups",
"[",
"$",
"newGroup",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"'%s form group already exists.'",
",",
"$",
"newGroup",
")",
")",
";",
"}",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"group",
",",
"$",
"groups",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"'form group « %s » doesn\\'t exist.', ",
"$",
"r",
"oup))",
";",
"",
"",
"}",
"$",
"groups",
"[",
"$",
"newGroup",
"]",
"=",
"$",
"groups",
"[",
"$",
"group",
"]",
";",
"$",
"groups",
"[",
"$",
"newGroup",
"]",
"[",
"'name'",
"]",
"=",
"$",
"newGroupName",
";",
"unset",
"(",
"$",
"groups",
"[",
"$",
"group",
"]",
")",
";",
"$",
"tabs",
"=",
"$",
"this",
"->",
"getFormTabs",
"(",
")",
";",
"$",
"key",
"=",
"array_search",
"(",
"$",
"group",
",",
"$",
"tabs",
"[",
"$",
"tab",
"]",
"[",
"'groups'",
"]",
")",
";",
"if",
"(",
"false",
"!==",
"$",
"key",
")",
"{",
"$",
"tabs",
"[",
"$",
"tab",
"]",
"[",
"'groups'",
"]",
"[",
"$",
"key",
"]",
"=",
"$",
"newGroup",
";",
"}",
"$",
"this",
"->",
"setFormTabs",
"(",
"$",
"tabs",
")",
";",
"$",
"this",
"->",
"setFormGroups",
"(",
"$",
"groups",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Rename a form group.
@param string $group the old group name
@param string $tab the tab the group belongs to
@param string $newGroupName the new group name
@return self
|
[
"Rename",
"a",
"form",
"group",
"."
] |
train
|
https://github.com/blast-project/CoreBundle/blob/7a0832758ca14e5bc5d65515532c1220df3930ae/src/Admin/CoreAdmin.php#L420-L452
|
blast-project/CoreBundle
|
src/Admin/CoreAdmin.php
|
CoreAdmin.removeTab
|
public function removeTab($tabNames, $mapper)
{
$currentTabs = $this->getFormTabs();
foreach ($currentTabs as $k => $item) {
if (is_array($tabNames) && in_array($item['name'], $tabNames) || !is_array($tabNames) && $item['name'] === $tabNames) {
foreach ($item['groups'] as $groupName) {
$this->removeAllFieldsFromFormGroup($groupName, $mapper);
}
unset($currentTabs[$k]);
}
}
$this->setFormTabs($currentTabs);
}
|
php
|
public function removeTab($tabNames, $mapper)
{
$currentTabs = $this->getFormTabs();
foreach ($currentTabs as $k => $item) {
if (is_array($tabNames) && in_array($item['name'], $tabNames) || !is_array($tabNames) && $item['name'] === $tabNames) {
foreach ($item['groups'] as $groupName) {
$this->removeAllFieldsFromFormGroup($groupName, $mapper);
}
unset($currentTabs[$k]);
}
}
$this->setFormTabs($currentTabs);
}
|
[
"public",
"function",
"removeTab",
"(",
"$",
"tabNames",
",",
"$",
"mapper",
")",
"{",
"$",
"currentTabs",
"=",
"$",
"this",
"->",
"getFormTabs",
"(",
")",
";",
"foreach",
"(",
"$",
"currentTabs",
"as",
"$",
"k",
"=>",
"$",
"item",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"tabNames",
")",
"&&",
"in_array",
"(",
"$",
"item",
"[",
"'name'",
"]",
",",
"$",
"tabNames",
")",
"||",
"!",
"is_array",
"(",
"$",
"tabNames",
")",
"&&",
"$",
"item",
"[",
"'name'",
"]",
"===",
"$",
"tabNames",
")",
"{",
"foreach",
"(",
"$",
"item",
"[",
"'groups'",
"]",
"as",
"$",
"groupName",
")",
"{",
"$",
"this",
"->",
"removeAllFieldsFromFormGroup",
"(",
"$",
"groupName",
",",
"$",
"mapper",
")",
";",
"}",
"unset",
"(",
"$",
"currentTabs",
"[",
"$",
"k",
"]",
")",
";",
"}",
"}",
"$",
"this",
"->",
"setFormTabs",
"(",
"$",
"currentTabs",
")",
";",
"}"
] |
Removes tab in current form Mapper.
@param string|array $tabNames name or array of names of tabs to be removed
@param FormMapper $mapper Sonata Admin form mapper
|
[
"Removes",
"tab",
"in",
"current",
"form",
"Mapper",
"."
] |
train
|
https://github.com/blast-project/CoreBundle/blob/7a0832758ca14e5bc5d65515532c1220df3930ae/src/Admin/CoreAdmin.php#L460-L472
|
blast-project/CoreBundle
|
src/Admin/CoreAdmin.php
|
CoreAdmin.removeAllFieldsFromFormGroup
|
public function removeAllFieldsFromFormGroup($groupName, $mapper)
{
$formGroups = $this->getFormGroups();
foreach ($formGroups as $name => $formGroup) {
if ($name === $groupName) {
foreach ($formGroups[$name]['fields'] as $key => $field) {
$mapper->remove($key);
}
}
}
}
|
php
|
public function removeAllFieldsFromFormGroup($groupName, $mapper)
{
$formGroups = $this->getFormGroups();
foreach ($formGroups as $name => $formGroup) {
if ($name === $groupName) {
foreach ($formGroups[$name]['fields'] as $key => $field) {
$mapper->remove($key);
}
}
}
}
|
[
"public",
"function",
"removeAllFieldsFromFormGroup",
"(",
"$",
"groupName",
",",
"$",
"mapper",
")",
"{",
"$",
"formGroups",
"=",
"$",
"this",
"->",
"getFormGroups",
"(",
")",
";",
"foreach",
"(",
"$",
"formGroups",
"as",
"$",
"name",
"=>",
"$",
"formGroup",
")",
"{",
"if",
"(",
"$",
"name",
"===",
"$",
"groupName",
")",
"{",
"foreach",
"(",
"$",
"formGroups",
"[",
"$",
"name",
"]",
"[",
"'fields'",
"]",
"as",
"$",
"key",
"=>",
"$",
"field",
")",
"{",
"$",
"mapper",
"->",
"remove",
"(",
"$",
"key",
")",
";",
"}",
"}",
"}",
"}"
] |
Removes all fields from form groups and remove them from mapper.
@param string $groupName Name of the group to remove
@param FormMapper $mapper Sonata Admin form mapper
|
[
"Removes",
"all",
"fields",
"from",
"form",
"groups",
"and",
"remove",
"them",
"from",
"mapper",
"."
] |
train
|
https://github.com/blast-project/CoreBundle/blob/7a0832758ca14e5bc5d65515532c1220df3930ae/src/Admin/CoreAdmin.php#L480-L490
|
blast-project/CoreBundle
|
src/Admin/CoreAdmin.php
|
CoreAdmin.prePersist
|
public function prePersist($object)
{
parent::prePersist($object);
$hasCodeGenerator = CodeGeneratorRegistry::hasGeneratorForClass(get_class($object));
if ($hasCodeGenerator) {
$accessor = PropertyAccess::createPropertyAccessor();
foreach (CodeGeneratorRegistry::getCodeGenerators(get_class($object)) as $name => $generator) {
$accessor->setValue($object, $name, $generator->generate($object));
}
}
}
|
php
|
public function prePersist($object)
{
parent::prePersist($object);
$hasCodeGenerator = CodeGeneratorRegistry::hasGeneratorForClass(get_class($object));
if ($hasCodeGenerator) {
$accessor = PropertyAccess::createPropertyAccessor();
foreach (CodeGeneratorRegistry::getCodeGenerators(get_class($object)) as $name => $generator) {
$accessor->setValue($object, $name, $generator->generate($object));
}
}
}
|
[
"public",
"function",
"prePersist",
"(",
"$",
"object",
")",
"{",
"parent",
"::",
"prePersist",
"(",
"$",
"object",
")",
";",
"$",
"hasCodeGenerator",
"=",
"CodeGeneratorRegistry",
"::",
"hasGeneratorForClass",
"(",
"get_class",
"(",
"$",
"object",
")",
")",
";",
"if",
"(",
"$",
"hasCodeGenerator",
")",
"{",
"$",
"accessor",
"=",
"PropertyAccess",
"::",
"createPropertyAccessor",
"(",
")",
";",
"foreach",
"(",
"CodeGeneratorRegistry",
"::",
"getCodeGenerators",
"(",
"get_class",
"(",
"$",
"object",
")",
")",
"as",
"$",
"name",
"=>",
"$",
"generator",
")",
"{",
"$",
"accessor",
"->",
"setValue",
"(",
"$",
"object",
",",
"$",
"name",
",",
"$",
"generator",
"->",
"generate",
"(",
"$",
"object",
")",
")",
";",
"}",
"}",
"}"
] |
{@inheritdoc}
|
[
"{"
] |
train
|
https://github.com/blast-project/CoreBundle/blob/7a0832758ca14e5bc5d65515532c1220df3930ae/src/Admin/CoreAdmin.php#L547-L558
|
blast-project/CoreBundle
|
src/Admin/CoreAdmin.php
|
CoreAdmin.preBatchAction
|
public function preBatchAction($actionName, ProxyQueryInterface $query, array &$idx, $allElements)
{
parent::preBatchAction($actionName, $query, $idx, $allElements);
if ($actionName === 'delete') {
$cascadingRelationChecker = $this->getConfigurationPool()->getContainer()->get('blast_core.doctrine.orm.cascading_relation_checker');
foreach ($idx as $id) {
$entity = $this->getModelManager()->find($this->getClass(), $id);
if ($entity !== null) {
$undeletableAssociations = $cascadingRelationChecker->beforeEntityDelete($entity, $idx);
if (count($undeletableAssociations) > 0) {
foreach ($undeletableAssociations as $key => $undeletableAssociation) {
$undeletableAssociations[$key] = $this->getConfigurationPool()->getContainer()->get('translator')->trans('blast.doctrine_relations.' . $undeletableAssociation, [], 'messages');
}
$errorMessage = 'Cannot delete "%entity%" because it has remaining relation(s) %relations%';
$message = $this->getTranslator()->trans(
$errorMessage,
[
'%relations%' => trim(implode(', ', $undeletableAssociations)),
'%entity%' => (string) $entity,
],
'SonataCoreBundle'
);
$this->getConfigurationPool()->getContainer()->get('session')->getFlashBag()->add('warning', $message);
}
}
}
}
}
|
php
|
public function preBatchAction($actionName, ProxyQueryInterface $query, array &$idx, $allElements)
{
parent::preBatchAction($actionName, $query, $idx, $allElements);
if ($actionName === 'delete') {
$cascadingRelationChecker = $this->getConfigurationPool()->getContainer()->get('blast_core.doctrine.orm.cascading_relation_checker');
foreach ($idx as $id) {
$entity = $this->getModelManager()->find($this->getClass(), $id);
if ($entity !== null) {
$undeletableAssociations = $cascadingRelationChecker->beforeEntityDelete($entity, $idx);
if (count($undeletableAssociations) > 0) {
foreach ($undeletableAssociations as $key => $undeletableAssociation) {
$undeletableAssociations[$key] = $this->getConfigurationPool()->getContainer()->get('translator')->trans('blast.doctrine_relations.' . $undeletableAssociation, [], 'messages');
}
$errorMessage = 'Cannot delete "%entity%" because it has remaining relation(s) %relations%';
$message = $this->getTranslator()->trans(
$errorMessage,
[
'%relations%' => trim(implode(', ', $undeletableAssociations)),
'%entity%' => (string) $entity,
],
'SonataCoreBundle'
);
$this->getConfigurationPool()->getContainer()->get('session')->getFlashBag()->add('warning', $message);
}
}
}
}
}
|
[
"public",
"function",
"preBatchAction",
"(",
"$",
"actionName",
",",
"ProxyQueryInterface",
"$",
"query",
",",
"array",
"&",
"$",
"idx",
",",
"$",
"allElements",
")",
"{",
"parent",
"::",
"preBatchAction",
"(",
"$",
"actionName",
",",
"$",
"query",
",",
"$",
"idx",
",",
"$",
"allElements",
")",
";",
"if",
"(",
"$",
"actionName",
"===",
"'delete'",
")",
"{",
"$",
"cascadingRelationChecker",
"=",
"$",
"this",
"->",
"getConfigurationPool",
"(",
")",
"->",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'blast_core.doctrine.orm.cascading_relation_checker'",
")",
";",
"foreach",
"(",
"$",
"idx",
"as",
"$",
"id",
")",
"{",
"$",
"entity",
"=",
"$",
"this",
"->",
"getModelManager",
"(",
")",
"->",
"find",
"(",
"$",
"this",
"->",
"getClass",
"(",
")",
",",
"$",
"id",
")",
";",
"if",
"(",
"$",
"entity",
"!==",
"null",
")",
"{",
"$",
"undeletableAssociations",
"=",
"$",
"cascadingRelationChecker",
"->",
"beforeEntityDelete",
"(",
"$",
"entity",
",",
"$",
"idx",
")",
";",
"if",
"(",
"count",
"(",
"$",
"undeletableAssociations",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"undeletableAssociations",
"as",
"$",
"key",
"=>",
"$",
"undeletableAssociation",
")",
"{",
"$",
"undeletableAssociations",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"getConfigurationPool",
"(",
")",
"->",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'translator'",
")",
"->",
"trans",
"(",
"'blast.doctrine_relations.'",
".",
"$",
"undeletableAssociation",
",",
"[",
"]",
",",
"'messages'",
")",
";",
"}",
"$",
"errorMessage",
"=",
"'Cannot delete \"%entity%\" because it has remaining relation(s) %relations%'",
";",
"$",
"message",
"=",
"$",
"this",
"->",
"getTranslator",
"(",
")",
"->",
"trans",
"(",
"$",
"errorMessage",
",",
"[",
"'%relations%'",
"=>",
"trim",
"(",
"implode",
"(",
"', '",
",",
"$",
"undeletableAssociations",
")",
")",
",",
"'%entity%'",
"=>",
"(",
"string",
")",
"$",
"entity",
",",
"]",
",",
"'SonataCoreBundle'",
")",
";",
"$",
"this",
"->",
"getConfigurationPool",
"(",
")",
"->",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'session'",
")",
"->",
"getFlashBag",
"(",
")",
"->",
"add",
"(",
"'warning'",
",",
"$",
"message",
")",
";",
"}",
"}",
"}",
"}",
"}"
] |
{@inheritdoc}
|
[
"{"
] |
train
|
https://github.com/blast-project/CoreBundle/blob/7a0832758ca14e5bc5d65515532c1220df3930ae/src/Admin/CoreAdmin.php#L568-L602
|
ekyna/GlsUniBox
|
Api/Response.php
|
Response.create
|
public static function create($body)
{
if (0 !== strpos($body, static::START_TOKEN)) {
throw new InvalidArgumentException("Unexpected response body.");
}
if (static::END_TOKEN !== substr($body, -strlen(static::END_TOKEN))) {
throw new InvalidArgumentException("Unexpected response body.");
}
$body = substr($body, strlen(static::START_TOKEN), -strlen(static::END_TOKEN));
$parts = explode('|', trim($body, '|'));
if (empty($parts)) {
throw new InvalidArgumentException("Unexpected response body.");
}
$response = new static();
for ($i = 0; $i < count($parts); $i++) {
list($key, $value) = explode(':', $parts[$i], 2);
if ($key === Config::RESULT) {
if (0 < strpos($value, ':')) {
list($code, $field) = explode(':', $value, 2);
} else {
$code = $value;
$field = 'unknown';
}
$response->set(Config::RESULT, $code);
$response->set(Config::FIELD, $field);
} else {
$response->set($key, $value);
}
}
return $response;
}
|
php
|
public static function create($body)
{
if (0 !== strpos($body, static::START_TOKEN)) {
throw new InvalidArgumentException("Unexpected response body.");
}
if (static::END_TOKEN !== substr($body, -strlen(static::END_TOKEN))) {
throw new InvalidArgumentException("Unexpected response body.");
}
$body = substr($body, strlen(static::START_TOKEN), -strlen(static::END_TOKEN));
$parts = explode('|', trim($body, '|'));
if (empty($parts)) {
throw new InvalidArgumentException("Unexpected response body.");
}
$response = new static();
for ($i = 0; $i < count($parts); $i++) {
list($key, $value) = explode(':', $parts[$i], 2);
if ($key === Config::RESULT) {
if (0 < strpos($value, ':')) {
list($code, $field) = explode(':', $value, 2);
} else {
$code = $value;
$field = 'unknown';
}
$response->set(Config::RESULT, $code);
$response->set(Config::FIELD, $field);
} else {
$response->set($key, $value);
}
}
return $response;
}
|
[
"public",
"static",
"function",
"create",
"(",
"$",
"body",
")",
"{",
"if",
"(",
"0",
"!==",
"strpos",
"(",
"$",
"body",
",",
"static",
"::",
"START_TOKEN",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Unexpected response body.\"",
")",
";",
"}",
"if",
"(",
"static",
"::",
"END_TOKEN",
"!==",
"substr",
"(",
"$",
"body",
",",
"-",
"strlen",
"(",
"static",
"::",
"END_TOKEN",
")",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Unexpected response body.\"",
")",
";",
"}",
"$",
"body",
"=",
"substr",
"(",
"$",
"body",
",",
"strlen",
"(",
"static",
"::",
"START_TOKEN",
")",
",",
"-",
"strlen",
"(",
"static",
"::",
"END_TOKEN",
")",
")",
";",
"$",
"parts",
"=",
"explode",
"(",
"'|'",
",",
"trim",
"(",
"$",
"body",
",",
"'|'",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"parts",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Unexpected response body.\"",
")",
";",
"}",
"$",
"response",
"=",
"new",
"static",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"parts",
")",
";",
"$",
"i",
"++",
")",
"{",
"list",
"(",
"$",
"key",
",",
"$",
"value",
")",
"=",
"explode",
"(",
"':'",
",",
"$",
"parts",
"[",
"$",
"i",
"]",
",",
"2",
")",
";",
"if",
"(",
"$",
"key",
"===",
"Config",
"::",
"RESULT",
")",
"{",
"if",
"(",
"0",
"<",
"strpos",
"(",
"$",
"value",
",",
"':'",
")",
")",
"{",
"list",
"(",
"$",
"code",
",",
"$",
"field",
")",
"=",
"explode",
"(",
"':'",
",",
"$",
"value",
",",
"2",
")",
";",
"}",
"else",
"{",
"$",
"code",
"=",
"$",
"value",
";",
"$",
"field",
"=",
"'unknown'",
";",
"}",
"$",
"response",
"->",
"set",
"(",
"Config",
"::",
"RESULT",
",",
"$",
"code",
")",
";",
"$",
"response",
"->",
"set",
"(",
"Config",
"::",
"FIELD",
",",
"$",
"field",
")",
";",
"}",
"else",
"{",
"$",
"response",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"}",
"return",
"$",
"response",
";",
"}"
] |
Creates a response from the given http response body.
@param string $body
@return Response
|
[
"Creates",
"a",
"response",
"from",
"the",
"given",
"http",
"response",
"body",
"."
] |
train
|
https://github.com/ekyna/GlsUniBox/blob/b474271ba355c3917074422306dc64abf09584d0/Api/Response.php#L27-L63
|
czim/laravel-pxlcms
|
src/Commands/GenerateCommand.php
|
GenerateCommand.handle
|
public function handle()
{
$modelsOnly = (bool) $this->option('models-only');
$dryRun = (bool) $this->option('dry-run');
$interactive = ! (bool) $this->option('auto');
$this->listenForLogEvents();
$generator = new Generator( ! $dryRun, $this);
$generator->generate();
$this->info('Done.');
}
|
php
|
public function handle()
{
$modelsOnly = (bool) $this->option('models-only');
$dryRun = (bool) $this->option('dry-run');
$interactive = ! (bool) $this->option('auto');
$this->listenForLogEvents();
$generator = new Generator( ! $dryRun, $this);
$generator->generate();
$this->info('Done.');
}
|
[
"public",
"function",
"handle",
"(",
")",
"{",
"$",
"modelsOnly",
"=",
"(",
"bool",
")",
"$",
"this",
"->",
"option",
"(",
"'models-only'",
")",
";",
"$",
"dryRun",
"=",
"(",
"bool",
")",
"$",
"this",
"->",
"option",
"(",
"'dry-run'",
")",
";",
"$",
"interactive",
"=",
"!",
"(",
"bool",
")",
"$",
"this",
"->",
"option",
"(",
"'auto'",
")",
";",
"$",
"this",
"->",
"listenForLogEvents",
"(",
")",
";",
"$",
"generator",
"=",
"new",
"Generator",
"(",
"!",
"$",
"dryRun",
",",
"$",
"this",
")",
";",
"$",
"generator",
"->",
"generate",
"(",
")",
";",
"$",
"this",
"->",
"info",
"(",
"'Done.'",
")",
";",
"}"
] |
Execute the console command.
@return mixed
|
[
"Execute",
"the",
"console",
"command",
"."
] |
train
|
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Commands/GenerateCommand.php#L39-L52
|
movoin/one-swoole
|
src/Swoole/Commands/StartCommand.php
|
StartCommand.execute
|
protected function execute(InputInterface $input, OutputInterface $output)
{
// 读取所有服务
$servers = array_keys(Config::get('server', []));
// 当前服务
$server = $input->getArgument('server');
if ($server !== null && ! isset($servers[$server])) {
$this->error('启动失败, 未定义 [' . $server . '] 服务');
return 0;
} elseif ($server === null && $servers === []) {
$this->error('启动失败, 未定义任何服务');
return 0;
}
// {{
$this->title('启动服务进程');
// }}
if ($server !== null) {
$servers = (array) $server;
}
unset($server);
$runner = new Runner($output);
try {
foreach ($servers as $server) {
if ($runner->isRunning($server)) {
$this->fail('<label>' . $server . '</> 处于运行中');
} else {
$ret = $runner->runCommand('start', $server);
$this->result(
'启动 <label>' . $server . '</> 服务进程',
$ret['code'] === 0
);
}
$this->wait();
}
} catch (\Exception $e) {
$this->fail($e->getMessage());
}
$this->newLine();
return 0;
}
|
php
|
protected function execute(InputInterface $input, OutputInterface $output)
{
// 读取所有服务
$servers = array_keys(Config::get('server', []));
// 当前服务
$server = $input->getArgument('server');
if ($server !== null && ! isset($servers[$server])) {
$this->error('启动失败, 未定义 [' . $server . '] 服务');
return 0;
} elseif ($server === null && $servers === []) {
$this->error('启动失败, 未定义任何服务');
return 0;
}
// {{
$this->title('启动服务进程');
// }}
if ($server !== null) {
$servers = (array) $server;
}
unset($server);
$runner = new Runner($output);
try {
foreach ($servers as $server) {
if ($runner->isRunning($server)) {
$this->fail('<label>' . $server . '</> 处于运行中');
} else {
$ret = $runner->runCommand('start', $server);
$this->result(
'启动 <label>' . $server . '</> 服务进程',
$ret['code'] === 0
);
}
$this->wait();
}
} catch (\Exception $e) {
$this->fail($e->getMessage());
}
$this->newLine();
return 0;
}
|
[
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"// 读取所有服务",
"$",
"servers",
"=",
"array_keys",
"(",
"Config",
"::",
"get",
"(",
"'server'",
",",
"[",
"]",
")",
")",
";",
"// 当前服务",
"$",
"server",
"=",
"$",
"input",
"->",
"getArgument",
"(",
"'server'",
")",
";",
"if",
"(",
"$",
"server",
"!==",
"null",
"&&",
"!",
"isset",
"(",
"$",
"servers",
"[",
"$",
"server",
"]",
")",
")",
"{",
"$",
"this",
"->",
"error",
"(",
"'启动失败, 未定义 [' . $server . '",
" ",
"务",
"');",
"",
"",
"",
"",
"return",
"0",
";",
"}",
"elseif",
"(",
"$",
"server",
"===",
"null",
"&&",
"$",
"servers",
"===",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"error",
"(",
"'启动失败, 未定义任何服务');",
"",
"",
"return",
"0",
";",
"}",
"// {{",
"$",
"this",
"->",
"title",
"(",
"'启动服务进程');",
"",
"",
"// }}",
"if",
"(",
"$",
"server",
"!==",
"null",
")",
"{",
"$",
"servers",
"=",
"(",
"array",
")",
"$",
"server",
";",
"}",
"unset",
"(",
"$",
"server",
")",
";",
"$",
"runner",
"=",
"new",
"Runner",
"(",
"$",
"output",
")",
";",
"try",
"{",
"foreach",
"(",
"$",
"servers",
"as",
"$",
"server",
")",
"{",
"if",
"(",
"$",
"runner",
"->",
"isRunning",
"(",
"$",
"server",
")",
")",
"{",
"$",
"this",
"->",
"fail",
"(",
"'<label>'",
".",
"$",
"server",
".",
"'</> 处于运行中');",
"",
"",
"}",
"else",
"{",
"$",
"ret",
"=",
"$",
"runner",
"->",
"runCommand",
"(",
"'start'",
",",
"$",
"server",
")",
";",
"$",
"this",
"->",
"result",
"(",
"'启动 <label>' . $",
"e",
"v",
"er . '",
"/",
" 服务进程',",
"",
"$",
"ret",
"[",
"'code'",
"]",
"===",
"0",
")",
";",
"}",
"$",
"this",
"->",
"wait",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"fail",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"newLine",
"(",
")",
";",
"return",
"0",
";",
"}"
] |
执行命令
@param \Symfony\Component\Console\Input\InputInterface $input
@param \Symfony\Component\Console\Output\OutputInterface $output
|
[
"执行命令"
] |
train
|
https://github.com/movoin/one-swoole/blob/b9b175963ead91416cc50902a04e05ff3ef571de/src/Swoole/Commands/StartCommand.php#L43-L92
|
huasituo/hstcms
|
src/Http/Controllers/Manage/FormController.php
|
FormController.content
|
public function content($formid, Request $request)
{
if(!$formid) {
return $this->showError('hstcms::public.no.id', '', 5);
}
$info = CommonFormModel::getForm($formid);
if(!$info) {
return $this->showError('hstcms::public.no.data', '', 5);
}
$commonFormContentModel = new CommonFormContentModel();
$commonFormContentModel->setTable($info['table']);
$type = $request->input('type');
$uid = $request->input('uid');
$stime = $request->input('stime');
$etime = $request->input('etime');
$listQuery = $commonFormContentModel->where('id', '>', 0);
$args = ['status'=>0, 'type'=>''];
if($uid) {
$args['uid'] = $uid;
$listQuery->where('created_uid', $uid);
}
if($stime) {
$args['stime'] = $stime;
$stime = hst_str2time($stime);
$listQuery->where('created_time', '>=', $stime);
}
if($etime) {
$args['etime'] = $etime;
$etime = hst_str2time($etime);
$listQuery->where('created_time', '<=', $etime);
}
$list = $listQuery->orderby('created_time', 'desc')->paginate($this->paginate);
$showFields = CommonFieldsModel::getManageContentListShowFields($info['table']);
$fields = CommonFieldsModel::getFields($info['table'], true);
$hstcmsFields = new HstcmsFields();
foreach ($list as $key => $value) {
$list[$key] = $hstcmsFields->field_format_value($fields, $value->toArray());
}
$this->navs = [];
$this->navs['content'] = ['name'=>$info['name'].hst_lang('hstcms::manage.form.content'), 'url'=>route('manageFormContent', ['formid'=>$formid])];
$this->navs['contentAdd'] = ['name'=>$info['name'].hst_lang('hstcms::public.add'), 'url'=>route('manageFormContentAdd', ['formid'=>$formid])];
$view = [
'formid'=> $formid,
'info'=> $info,
'list'=>$list,
'args'=>$args,
'showFields'=>$showFields,
'navs'=>$this->getNavs('content')
];
return $this->loadTemplate('hstcms::manage.form.content', $view);
}
|
php
|
public function content($formid, Request $request)
{
if(!$formid) {
return $this->showError('hstcms::public.no.id', '', 5);
}
$info = CommonFormModel::getForm($formid);
if(!$info) {
return $this->showError('hstcms::public.no.data', '', 5);
}
$commonFormContentModel = new CommonFormContentModel();
$commonFormContentModel->setTable($info['table']);
$type = $request->input('type');
$uid = $request->input('uid');
$stime = $request->input('stime');
$etime = $request->input('etime');
$listQuery = $commonFormContentModel->where('id', '>', 0);
$args = ['status'=>0, 'type'=>''];
if($uid) {
$args['uid'] = $uid;
$listQuery->where('created_uid', $uid);
}
if($stime) {
$args['stime'] = $stime;
$stime = hst_str2time($stime);
$listQuery->where('created_time', '>=', $stime);
}
if($etime) {
$args['etime'] = $etime;
$etime = hst_str2time($etime);
$listQuery->where('created_time', '<=', $etime);
}
$list = $listQuery->orderby('created_time', 'desc')->paginate($this->paginate);
$showFields = CommonFieldsModel::getManageContentListShowFields($info['table']);
$fields = CommonFieldsModel::getFields($info['table'], true);
$hstcmsFields = new HstcmsFields();
foreach ($list as $key => $value) {
$list[$key] = $hstcmsFields->field_format_value($fields, $value->toArray());
}
$this->navs = [];
$this->navs['content'] = ['name'=>$info['name'].hst_lang('hstcms::manage.form.content'), 'url'=>route('manageFormContent', ['formid'=>$formid])];
$this->navs['contentAdd'] = ['name'=>$info['name'].hst_lang('hstcms::public.add'), 'url'=>route('manageFormContentAdd', ['formid'=>$formid])];
$view = [
'formid'=> $formid,
'info'=> $info,
'list'=>$list,
'args'=>$args,
'showFields'=>$showFields,
'navs'=>$this->getNavs('content')
];
return $this->loadTemplate('hstcms::manage.form.content', $view);
}
|
[
"public",
"function",
"content",
"(",
"$",
"formid",
",",
"Request",
"$",
"request",
")",
"{",
"if",
"(",
"!",
"$",
"formid",
")",
"{",
"return",
"$",
"this",
"->",
"showError",
"(",
"'hstcms::public.no.id'",
",",
"''",
",",
"5",
")",
";",
"}",
"$",
"info",
"=",
"CommonFormModel",
"::",
"getForm",
"(",
"$",
"formid",
")",
";",
"if",
"(",
"!",
"$",
"info",
")",
"{",
"return",
"$",
"this",
"->",
"showError",
"(",
"'hstcms::public.no.data'",
",",
"''",
",",
"5",
")",
";",
"}",
"$",
"commonFormContentModel",
"=",
"new",
"CommonFormContentModel",
"(",
")",
";",
"$",
"commonFormContentModel",
"->",
"setTable",
"(",
"$",
"info",
"[",
"'table'",
"]",
")",
";",
"$",
"type",
"=",
"$",
"request",
"->",
"input",
"(",
"'type'",
")",
";",
"$",
"uid",
"=",
"$",
"request",
"->",
"input",
"(",
"'uid'",
")",
";",
"$",
"stime",
"=",
"$",
"request",
"->",
"input",
"(",
"'stime'",
")",
";",
"$",
"etime",
"=",
"$",
"request",
"->",
"input",
"(",
"'etime'",
")",
";",
"$",
"listQuery",
"=",
"$",
"commonFormContentModel",
"->",
"where",
"(",
"'id'",
",",
"'>'",
",",
"0",
")",
";",
"$",
"args",
"=",
"[",
"'status'",
"=>",
"0",
",",
"'type'",
"=>",
"''",
"]",
";",
"if",
"(",
"$",
"uid",
")",
"{",
"$",
"args",
"[",
"'uid'",
"]",
"=",
"$",
"uid",
";",
"$",
"listQuery",
"->",
"where",
"(",
"'created_uid'",
",",
"$",
"uid",
")",
";",
"}",
"if",
"(",
"$",
"stime",
")",
"{",
"$",
"args",
"[",
"'stime'",
"]",
"=",
"$",
"stime",
";",
"$",
"stime",
"=",
"hst_str2time",
"(",
"$",
"stime",
")",
";",
"$",
"listQuery",
"->",
"where",
"(",
"'created_time'",
",",
"'>='",
",",
"$",
"stime",
")",
";",
"}",
"if",
"(",
"$",
"etime",
")",
"{",
"$",
"args",
"[",
"'etime'",
"]",
"=",
"$",
"etime",
";",
"$",
"etime",
"=",
"hst_str2time",
"(",
"$",
"etime",
")",
";",
"$",
"listQuery",
"->",
"where",
"(",
"'created_time'",
",",
"'<='",
",",
"$",
"etime",
")",
";",
"}",
"$",
"list",
"=",
"$",
"listQuery",
"->",
"orderby",
"(",
"'created_time'",
",",
"'desc'",
")",
"->",
"paginate",
"(",
"$",
"this",
"->",
"paginate",
")",
";",
"$",
"showFields",
"=",
"CommonFieldsModel",
"::",
"getManageContentListShowFields",
"(",
"$",
"info",
"[",
"'table'",
"]",
")",
";",
"$",
"fields",
"=",
"CommonFieldsModel",
"::",
"getFields",
"(",
"$",
"info",
"[",
"'table'",
"]",
",",
"true",
")",
";",
"$",
"hstcmsFields",
"=",
"new",
"HstcmsFields",
"(",
")",
";",
"foreach",
"(",
"$",
"list",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"list",
"[",
"$",
"key",
"]",
"=",
"$",
"hstcmsFields",
"->",
"field_format_value",
"(",
"$",
"fields",
",",
"$",
"value",
"->",
"toArray",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"navs",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"navs",
"[",
"'content'",
"]",
"=",
"[",
"'name'",
"=>",
"$",
"info",
"[",
"'name'",
"]",
".",
"hst_lang",
"(",
"'hstcms::manage.form.content'",
")",
",",
"'url'",
"=>",
"route",
"(",
"'manageFormContent'",
",",
"[",
"'formid'",
"=>",
"$",
"formid",
"]",
")",
"]",
";",
"$",
"this",
"->",
"navs",
"[",
"'contentAdd'",
"]",
"=",
"[",
"'name'",
"=>",
"$",
"info",
"[",
"'name'",
"]",
".",
"hst_lang",
"(",
"'hstcms::public.add'",
")",
",",
"'url'",
"=>",
"route",
"(",
"'manageFormContentAdd'",
",",
"[",
"'formid'",
"=>",
"$",
"formid",
"]",
")",
"]",
";",
"$",
"view",
"=",
"[",
"'formid'",
"=>",
"$",
"formid",
",",
"'info'",
"=>",
"$",
"info",
",",
"'list'",
"=>",
"$",
"list",
",",
"'args'",
"=>",
"$",
"args",
",",
"'showFields'",
"=>",
"$",
"showFields",
",",
"'navs'",
"=>",
"$",
"this",
"->",
"getNavs",
"(",
"'content'",
")",
"]",
";",
"return",
"$",
"this",
"->",
"loadTemplate",
"(",
"'hstcms::manage.form.content'",
",",
"$",
"view",
")",
";",
"}"
] |
内容管理
|
[
"内容管理"
] |
train
|
https://github.com/huasituo/hstcms/blob/12819979289e58ce38e3e92540aeeb16e205e525/src/Http/Controllers/Manage/FormController.php#L172-L222
|
dreamcommerce/common-bundle
|
src/DreamCommerce/Bundle/CommonBundle/Command/LogViewCommand.php
|
LogViewCommand.execute
|
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->output = $output;
$this->input = $input;
$helper = $this->getHelper('question');
$logs = $this->getLogsList();
$question = new ChoiceQuestion(
'Choose file to view',
$logs,
0
);
$filename = $helper->ask($input, $output, $question);
$filePath = sprintf('%s/%s', $this->getContainer()->get('kernel')->getLogDir(), $filename);
if (file_exists($filePath)) {
$this->showLog($filePath);
} else {
$this->printMessageBox($output, 'File "' . $filePath . '" does not exist');
}
$output->writeln('');
}
|
php
|
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->output = $output;
$this->input = $input;
$helper = $this->getHelper('question');
$logs = $this->getLogsList();
$question = new ChoiceQuestion(
'Choose file to view',
$logs,
0
);
$filename = $helper->ask($input, $output, $question);
$filePath = sprintf('%s/%s', $this->getContainer()->get('kernel')->getLogDir(), $filename);
if (file_exists($filePath)) {
$this->showLog($filePath);
} else {
$this->printMessageBox($output, 'File "' . $filePath . '" does not exist');
}
$output->writeln('');
}
|
[
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"this",
"->",
"output",
"=",
"$",
"output",
";",
"$",
"this",
"->",
"input",
"=",
"$",
"input",
";",
"$",
"helper",
"=",
"$",
"this",
"->",
"getHelper",
"(",
"'question'",
")",
";",
"$",
"logs",
"=",
"$",
"this",
"->",
"getLogsList",
"(",
")",
";",
"$",
"question",
"=",
"new",
"ChoiceQuestion",
"(",
"'Choose file to view'",
",",
"$",
"logs",
",",
"0",
")",
";",
"$",
"filename",
"=",
"$",
"helper",
"->",
"ask",
"(",
"$",
"input",
",",
"$",
"output",
",",
"$",
"question",
")",
";",
"$",
"filePath",
"=",
"sprintf",
"(",
"'%s/%s'",
",",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'kernel'",
")",
"->",
"getLogDir",
"(",
")",
",",
"$",
"filename",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"filePath",
")",
")",
"{",
"$",
"this",
"->",
"showLog",
"(",
"$",
"filePath",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"printMessageBox",
"(",
"$",
"output",
",",
"'File \"'",
".",
"$",
"filePath",
".",
"'\" does not exist'",
")",
";",
"}",
"$",
"output",
"->",
"writeln",
"(",
"''",
")",
";",
"}"
] |
{@inheritdoc}
|
[
"{"
] |
train
|
https://github.com/dreamcommerce/common-bundle/blob/adb0850e90e63c3997f10d1ce110bf13a84b63ab/src/DreamCommerce/Bundle/CommonBundle/Command/LogViewCommand.php#L47-L70
|
harp-orm/query
|
src/Compiler/Join.php
|
Join.render
|
public static function render(SQL\Join $join)
{
$condition = $join->getCondition();
$table = $join->getTable();
return Compiler::expression(array(
$join->getType(),
'JOIN',
$table instanceof SQL\Aliased ? Aliased::render($table) : $table,
is_array($condition) ? self::renderArrayCondition($condition) : $condition,
));
}
|
php
|
public static function render(SQL\Join $join)
{
$condition = $join->getCondition();
$table = $join->getTable();
return Compiler::expression(array(
$join->getType(),
'JOIN',
$table instanceof SQL\Aliased ? Aliased::render($table) : $table,
is_array($condition) ? self::renderArrayCondition($condition) : $condition,
));
}
|
[
"public",
"static",
"function",
"render",
"(",
"SQL",
"\\",
"Join",
"$",
"join",
")",
"{",
"$",
"condition",
"=",
"$",
"join",
"->",
"getCondition",
"(",
")",
";",
"$",
"table",
"=",
"$",
"join",
"->",
"getTable",
"(",
")",
";",
"return",
"Compiler",
"::",
"expression",
"(",
"array",
"(",
"$",
"join",
"->",
"getType",
"(",
")",
",",
"'JOIN'",
",",
"$",
"table",
"instanceof",
"SQL",
"\\",
"Aliased",
"?",
"Aliased",
"::",
"render",
"(",
"$",
"table",
")",
":",
"$",
"table",
",",
"is_array",
"(",
"$",
"condition",
")",
"?",
"self",
"::",
"renderArrayCondition",
"(",
"$",
"condition",
")",
":",
"$",
"condition",
",",
")",
")",
";",
"}"
] |
Render a Join object
@param SQL\Join $join
@return string
|
[
"Render",
"a",
"Join",
"object"
] |
train
|
https://github.com/harp-orm/query/blob/98ce2468a0a31fe15ed3692bad32547bf6dbe41a/src/Compiler/Join.php#L50-L61
|
discophp/framework
|
core/classes/Controller.class.php
|
Controller.template
|
public function template($template, $data = Array()){
\Template::with($template, $data);
\View::serve();
}
|
php
|
public function template($template, $data = Array()){
\Template::with($template, $data);
\View::serve();
}
|
[
"public",
"function",
"template",
"(",
"$",
"template",
",",
"$",
"data",
"=",
"Array",
"(",
")",
")",
"{",
"\\",
"Template",
"::",
"with",
"(",
"$",
"template",
",",
"$",
"data",
")",
";",
"\\",
"View",
"::",
"serve",
"(",
")",
";",
"}"
] |
A template to add to the view and return.
@param string $template The template name to load into the view.
@param array $data The data to bind into the template. Defaults to empty array.
|
[
"A",
"template",
"to",
"add",
"to",
"the",
"view",
"and",
"return",
"."
] |
train
|
https://github.com/discophp/framework/blob/40ff3ea5225810534195494dc6c21083da4d1356/core/classes/Controller.class.php#L42-L45
|
esperecyan/dictionary-php
|
src/parser/CatchmParser.php
|
CatchmParser.parseLine
|
protected function parseLine(Dictionary $dictionary, string $line)
{
// コメントの分離
$textAndDescription = preg_split('#(/+|;+|\\[)#u', $line, 2, PREG_SPLIT_DELIM_CAPTURE);
if ($textAndDescription[0] !== '' && str_replace(' ', '', $textAndDescription[0]) === '') {
// 空行でなく、半角スペースのみで構成されている行なら
throw new SyntaxException(_('半角スペースとコメントのみの行は作ることができません。'));
}
$answers = array_filter(array_map(function ($answer) {
// 正規表現文字列扱いを抑止
return (new \esperecyan\dictionary_php\validator\AnswerValidator())->isRegExp($answer)
? trim($answer, '/')
: $answer;
}, explode(',', rtrim($textAndDescription[0], ' '))));
if ($answers) {
if (count($answers) === 1) {
$fieldsAsMultiDimensionalArray['text'] = $answers;
} else {
$fieldsAsMultiDimensionalArray = [
'text' => [$answers[0]],
'answer' => $answers,
];
}
if (isset($textAndDescription[1])) {
$comment = trim(
$textAndDescription[1] === '[' ? rtrim($textAndDescription[2], ']') : $textAndDescription[2]
);
if ($comment !== '') {
$fieldsAsMultiDimensionalArray['description'][] = $comment;
}
}
try {
$dictionary->addWord($fieldsAsMultiDimensionalArray);
} catch (SyntaxException $e) {
$this->logInconvertibleError($line, $e);
}
}
}
|
php
|
protected function parseLine(Dictionary $dictionary, string $line)
{
// コメントの分離
$textAndDescription = preg_split('#(/+|;+|\\[)#u', $line, 2, PREG_SPLIT_DELIM_CAPTURE);
if ($textAndDescription[0] !== '' && str_replace(' ', '', $textAndDescription[0]) === '') {
// 空行でなく、半角スペースのみで構成されている行なら
throw new SyntaxException(_('半角スペースとコメントのみの行は作ることができません。'));
}
$answers = array_filter(array_map(function ($answer) {
// 正規表現文字列扱いを抑止
return (new \esperecyan\dictionary_php\validator\AnswerValidator())->isRegExp($answer)
? trim($answer, '/')
: $answer;
}, explode(',', rtrim($textAndDescription[0], ' '))));
if ($answers) {
if (count($answers) === 1) {
$fieldsAsMultiDimensionalArray['text'] = $answers;
} else {
$fieldsAsMultiDimensionalArray = [
'text' => [$answers[0]],
'answer' => $answers,
];
}
if (isset($textAndDescription[1])) {
$comment = trim(
$textAndDescription[1] === '[' ? rtrim($textAndDescription[2], ']') : $textAndDescription[2]
);
if ($comment !== '') {
$fieldsAsMultiDimensionalArray['description'][] = $comment;
}
}
try {
$dictionary->addWord($fieldsAsMultiDimensionalArray);
} catch (SyntaxException $e) {
$this->logInconvertibleError($line, $e);
}
}
}
|
[
"protected",
"function",
"parseLine",
"(",
"Dictionary",
"$",
"dictionary",
",",
"string",
"$",
"line",
")",
"{",
"// コメントの分離",
"$",
"textAndDescription",
"=",
"preg_split",
"(",
"'#(/+|;+|\\\\[)#u'",
",",
"$",
"line",
",",
"2",
",",
"PREG_SPLIT_DELIM_CAPTURE",
")",
";",
"if",
"(",
"$",
"textAndDescription",
"[",
"0",
"]",
"!==",
"''",
"&&",
"str_replace",
"(",
"' '",
",",
"''",
",",
"$",
"textAndDescription",
"[",
"0",
"]",
")",
"===",
"''",
")",
"{",
"// 空行でなく、半角スペースのみで構成されている行なら",
"throw",
"new",
"SyntaxException",
"(",
"_",
"(",
"'半角スペースとコメントのみの行は作ることができません。'));",
"",
"",
"",
"}",
"$",
"answers",
"=",
"array_filter",
"(",
"array_map",
"(",
"function",
"(",
"$",
"answer",
")",
"{",
"// 正規表現文字列扱いを抑止",
"return",
"(",
"new",
"\\",
"esperecyan",
"\\",
"dictionary_php",
"\\",
"validator",
"\\",
"AnswerValidator",
"(",
")",
")",
"->",
"isRegExp",
"(",
"$",
"answer",
")",
"?",
"trim",
"(",
"$",
"answer",
",",
"'/'",
")",
":",
"$",
"answer",
";",
"}",
",",
"explode",
"(",
"','",
",",
"rtrim",
"(",
"$",
"textAndDescription",
"[",
"0",
"]",
",",
"' '",
")",
")",
")",
")",
";",
"if",
"(",
"$",
"answers",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"answers",
")",
"===",
"1",
")",
"{",
"$",
"fieldsAsMultiDimensionalArray",
"[",
"'text'",
"]",
"=",
"$",
"answers",
";",
"}",
"else",
"{",
"$",
"fieldsAsMultiDimensionalArray",
"=",
"[",
"'text'",
"=>",
"[",
"$",
"answers",
"[",
"0",
"]",
"]",
",",
"'answer'",
"=>",
"$",
"answers",
",",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"textAndDescription",
"[",
"1",
"]",
")",
")",
"{",
"$",
"comment",
"=",
"trim",
"(",
"$",
"textAndDescription",
"[",
"1",
"]",
"===",
"'['",
"?",
"rtrim",
"(",
"$",
"textAndDescription",
"[",
"2",
"]",
",",
"']'",
")",
":",
"$",
"textAndDescription",
"[",
"2",
"]",
")",
";",
"if",
"(",
"$",
"comment",
"!==",
"''",
")",
"{",
"$",
"fieldsAsMultiDimensionalArray",
"[",
"'description'",
"]",
"[",
"]",
"=",
"$",
"comment",
";",
"}",
"}",
"try",
"{",
"$",
"dictionary",
"->",
"addWord",
"(",
"$",
"fieldsAsMultiDimensionalArray",
")",
";",
"}",
"catch",
"(",
"SyntaxException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"logInconvertibleError",
"(",
"$",
"line",
",",
"$",
"e",
")",
";",
"}",
"}",
"}"
] |
行を解析し、text、answer、descriptionフィールドに対応する文字列を取り出します。
@param Dictionary $dictionary
@param string $line
|
[
"行を解析し、text、answer、descriptionフィールドに対応する文字列を取り出します。"
] |
train
|
https://github.com/esperecyan/dictionary-php/blob/14fad08fb43006995c763094e8e7ed0dc0e26676/src/parser/CatchmParser.php#L13-L54
|
ray-di/Ray.WebFormModule
|
src/VndErrorHandler.php
|
VndErrorHandler.handle
|
public function handle(AbstractValidation $formValidation, MethodInvocation $invocation, AbstractForm $form)
{
unset($formValidation);
$vndError = $this->reader->getMethodAnnotation($invocation->getMethod(), VndError::class);
$error = new FormValidationError($this->makeVndError($form, $vndError));
throw new ValidationException('Validation failed.', 400, null, $error);
}
|
php
|
public function handle(AbstractValidation $formValidation, MethodInvocation $invocation, AbstractForm $form)
{
unset($formValidation);
$vndError = $this->reader->getMethodAnnotation($invocation->getMethod(), VndError::class);
$error = new FormValidationError($this->makeVndError($form, $vndError));
throw new ValidationException('Validation failed.', 400, null, $error);
}
|
[
"public",
"function",
"handle",
"(",
"AbstractValidation",
"$",
"formValidation",
",",
"MethodInvocation",
"$",
"invocation",
",",
"AbstractForm",
"$",
"form",
")",
"{",
"unset",
"(",
"$",
"formValidation",
")",
";",
"$",
"vndError",
"=",
"$",
"this",
"->",
"reader",
"->",
"getMethodAnnotation",
"(",
"$",
"invocation",
"->",
"getMethod",
"(",
")",
",",
"VndError",
"::",
"class",
")",
";",
"$",
"error",
"=",
"new",
"FormValidationError",
"(",
"$",
"this",
"->",
"makeVndError",
"(",
"$",
"form",
",",
"$",
"vndError",
")",
")",
";",
"throw",
"new",
"ValidationException",
"(",
"'Validation failed.'",
",",
"400",
",",
"null",
",",
"$",
"error",
")",
";",
"}"
] |
{@inheritdoc}
|
[
"{"
] |
train
|
https://github.com/ray-di/Ray.WebFormModule/blob/4b6d33adb4a5c285278a068f3e7a5afdc4e680d9/src/VndErrorHandler.php#L30-L37
|
jan-dolata/crude-crud
|
src/CrudeCRUDServiceProvider.php
|
CrudeCRUDServiceProvider.boot
|
public function boot()
{
// use this if your package has views
$this->loadViewsFrom(__DIR__.'/resources/views', 'CrudeCRUD');
// use this if your package has lang files
$this->loadTranslationsFrom(__DIR__.'/resources/lang', 'CrudeCRUD');
// use this if your package has routes
$this->setupRoutes($this->app->router);
// use this if your package needs a config file
$this->publishes([
__DIR__.'/config/crude.php' => config_path('crude.php'),
__DIR__.'/config/crude_navbar.php' => config_path('crude_navbar.php'),
__DIR__.'/config/crude_special_files.php' => config_path('crude_special_files.php')
], 'config');
$this->publishes([
__DIR__.'/../public/' => public_path('vendor/jan-dolata/crude-crud')
], 'tg_assets');
$this->publishes([
__DIR__.'/database/migrations/2016_05_04_091202_create_file_logs_table.php' => app_path('../database/migrations/2016_05_04_091202_create_file_logs_table.php')
], 'files');
// use the vendor configuration file as fallback
$this->mergeConfigFrom(
__DIR__.'/config/crude.php', 'crude'
);
$this->mergeConfigFrom(
__DIR__.'/config/crude_navbar.php', 'crude_navbar'
);
$this->mergeConfigFrom(
__DIR__.'/config/crude_special_files.php', 'crude_special_files'
);
}
|
php
|
public function boot()
{
// use this if your package has views
$this->loadViewsFrom(__DIR__.'/resources/views', 'CrudeCRUD');
// use this if your package has lang files
$this->loadTranslationsFrom(__DIR__.'/resources/lang', 'CrudeCRUD');
// use this if your package has routes
$this->setupRoutes($this->app->router);
// use this if your package needs a config file
$this->publishes([
__DIR__.'/config/crude.php' => config_path('crude.php'),
__DIR__.'/config/crude_navbar.php' => config_path('crude_navbar.php'),
__DIR__.'/config/crude_special_files.php' => config_path('crude_special_files.php')
], 'config');
$this->publishes([
__DIR__.'/../public/' => public_path('vendor/jan-dolata/crude-crud')
], 'tg_assets');
$this->publishes([
__DIR__.'/database/migrations/2016_05_04_091202_create_file_logs_table.php' => app_path('../database/migrations/2016_05_04_091202_create_file_logs_table.php')
], 'files');
// use the vendor configuration file as fallback
$this->mergeConfigFrom(
__DIR__.'/config/crude.php', 'crude'
);
$this->mergeConfigFrom(
__DIR__.'/config/crude_navbar.php', 'crude_navbar'
);
$this->mergeConfigFrom(
__DIR__.'/config/crude_special_files.php', 'crude_special_files'
);
}
|
[
"public",
"function",
"boot",
"(",
")",
"{",
"// use this if your package has views",
"$",
"this",
"->",
"loadViewsFrom",
"(",
"__DIR__",
".",
"'/resources/views'",
",",
"'CrudeCRUD'",
")",
";",
"// use this if your package has lang files",
"$",
"this",
"->",
"loadTranslationsFrom",
"(",
"__DIR__",
".",
"'/resources/lang'",
",",
"'CrudeCRUD'",
")",
";",
"// use this if your package has routes",
"$",
"this",
"->",
"setupRoutes",
"(",
"$",
"this",
"->",
"app",
"->",
"router",
")",
";",
"// use this if your package needs a config file",
"$",
"this",
"->",
"publishes",
"(",
"[",
"__DIR__",
".",
"'/config/crude.php'",
"=>",
"config_path",
"(",
"'crude.php'",
")",
",",
"__DIR__",
".",
"'/config/crude_navbar.php'",
"=>",
"config_path",
"(",
"'crude_navbar.php'",
")",
",",
"__DIR__",
".",
"'/config/crude_special_files.php'",
"=>",
"config_path",
"(",
"'crude_special_files.php'",
")",
"]",
",",
"'config'",
")",
";",
"$",
"this",
"->",
"publishes",
"(",
"[",
"__DIR__",
".",
"'/../public/'",
"=>",
"public_path",
"(",
"'vendor/jan-dolata/crude-crud'",
")",
"]",
",",
"'tg_assets'",
")",
";",
"$",
"this",
"->",
"publishes",
"(",
"[",
"__DIR__",
".",
"'/database/migrations/2016_05_04_091202_create_file_logs_table.php'",
"=>",
"app_path",
"(",
"'../database/migrations/2016_05_04_091202_create_file_logs_table.php'",
")",
"]",
",",
"'files'",
")",
";",
"// use the vendor configuration file as fallback",
"$",
"this",
"->",
"mergeConfigFrom",
"(",
"__DIR__",
".",
"'/config/crude.php'",
",",
"'crude'",
")",
";",
"$",
"this",
"->",
"mergeConfigFrom",
"(",
"__DIR__",
".",
"'/config/crude_navbar.php'",
",",
"'crude_navbar'",
")",
";",
"$",
"this",
"->",
"mergeConfigFrom",
"(",
"__DIR__",
".",
"'/config/crude_special_files.php'",
",",
"'crude_special_files'",
")",
";",
"}"
] |
Perform post-registration booting of services.
@return void
|
[
"Perform",
"post",
"-",
"registration",
"booting",
"of",
"services",
"."
] |
train
|
https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/CrudeCRUDServiceProvider.php#L22-L60
|
jan-dolata/crude-crud
|
src/CrudeCRUDServiceProvider.php
|
CrudeCRUDServiceProvider.register
|
public function register()
{
$this->registerCrudeCRUD();
config([
'config/crude.php',
]);
$loader = \Illuminate\Foundation\AliasLoader::getInstance();
$loader->alias('Crude', 'JanDolata\CrudeCRUD\Engine\Crude');
$loader->alias('CrudeListInterface', 'JanDolata\CrudeCRUD\Engine\Interfaces\ListInterface');
$loader->alias('CrudeUpdateInterface', 'JanDolata\CrudeCRUD\Engine\Interfaces\UpdateInterface');
$loader->alias('CrudeDeleteInterface', 'JanDolata\CrudeCRUD\Engine\Interfaces\DeleteInterface');
$loader->alias('CrudeStoreInterface', 'JanDolata\CrudeCRUD\Engine\Interfaces\StoreInterface');
$loader->alias('CrudeOrderInterface', 'JanDolata\CrudeCRUD\Engine\Interfaces\OrderInterface');
$loader->alias('CrudeWithValidationInterface', 'JanDolata\CrudeCRUD\Engine\Interfaces\WithValidationInterface');
$loader->alias('CrudeWithThumbnailInterface', 'JanDolata\CrudeCRUD\Engine\Interfaces\WithThumbnailInterface');
$loader->alias('CrudeWithFileInterface', 'JanDolata\CrudeCRUD\Engine\Interfaces\WithFileInterface');
$loader->alias('CrudeCRUDInterface', 'JanDolata\CrudeCRUD\Engine\Interfaces\CRUDInterface');
$loader->alias('CrudeCRUDWithValidationInterface', 'JanDolata\CrudeCRUD\Engine\Interfaces\CRUDWithValidationInterface');
$loader->alias('CrudeFromModelTrait', 'JanDolata\CrudeCRUD\Engine\Traits\FromModelTrait');
$loader->alias('CrudeWithValidationTrait', 'JanDolata\CrudeCRUD\Engine\Traits\WithValidationTrait');
$loader->alias('CrudeWithThumbnailTrait', 'JanDolata\CrudeCRUD\Engine\Traits\WithThumbnailTrait');
$loader->alias('CrudeWithFileTrait', 'JanDolata\CrudeCRUD\Engine\Traits\WithFileTrait');
$loader->alias('CrudeCrudeSetup', 'JanDolata\CrudeCRUD\Engine\CrudeSetup');
$loader->alias('CrudeFileLog', 'JanDolata\CrudeCRUD\Engine\Models\FileLog');
$loader->alias('CrudeFiles', 'JanDolata\CrudeCRUD\Engine\Helpers\CrudeFiles');
$loader->alias('CrudeData', 'JanDolata\CrudeCRUD\Engine\Helpers\CrudeData');
$loader->alias('CrudeOptions', 'JanDolata\CrudeCRUD\Engine\Helpers\CrudeOptions');
$loader->alias('CrudeQueryHelper', 'JanDolata\CrudeCRUD\Engine\Helpers\CrudeQueryHelper');
$loader->alias('CrudeMagic', 'JanDolata\CrudeCRUD\Engine\Helpers\CrudeMagic');
$loader->alias('CrudeSpecialFiles', 'JanDolata\CrudeCRUD\Engine\Helpers\CrudeSpecialFiles');
}
|
php
|
public function register()
{
$this->registerCrudeCRUD();
config([
'config/crude.php',
]);
$loader = \Illuminate\Foundation\AliasLoader::getInstance();
$loader->alias('Crude', 'JanDolata\CrudeCRUD\Engine\Crude');
$loader->alias('CrudeListInterface', 'JanDolata\CrudeCRUD\Engine\Interfaces\ListInterface');
$loader->alias('CrudeUpdateInterface', 'JanDolata\CrudeCRUD\Engine\Interfaces\UpdateInterface');
$loader->alias('CrudeDeleteInterface', 'JanDolata\CrudeCRUD\Engine\Interfaces\DeleteInterface');
$loader->alias('CrudeStoreInterface', 'JanDolata\CrudeCRUD\Engine\Interfaces\StoreInterface');
$loader->alias('CrudeOrderInterface', 'JanDolata\CrudeCRUD\Engine\Interfaces\OrderInterface');
$loader->alias('CrudeWithValidationInterface', 'JanDolata\CrudeCRUD\Engine\Interfaces\WithValidationInterface');
$loader->alias('CrudeWithThumbnailInterface', 'JanDolata\CrudeCRUD\Engine\Interfaces\WithThumbnailInterface');
$loader->alias('CrudeWithFileInterface', 'JanDolata\CrudeCRUD\Engine\Interfaces\WithFileInterface');
$loader->alias('CrudeCRUDInterface', 'JanDolata\CrudeCRUD\Engine\Interfaces\CRUDInterface');
$loader->alias('CrudeCRUDWithValidationInterface', 'JanDolata\CrudeCRUD\Engine\Interfaces\CRUDWithValidationInterface');
$loader->alias('CrudeFromModelTrait', 'JanDolata\CrudeCRUD\Engine\Traits\FromModelTrait');
$loader->alias('CrudeWithValidationTrait', 'JanDolata\CrudeCRUD\Engine\Traits\WithValidationTrait');
$loader->alias('CrudeWithThumbnailTrait', 'JanDolata\CrudeCRUD\Engine\Traits\WithThumbnailTrait');
$loader->alias('CrudeWithFileTrait', 'JanDolata\CrudeCRUD\Engine\Traits\WithFileTrait');
$loader->alias('CrudeCrudeSetup', 'JanDolata\CrudeCRUD\Engine\CrudeSetup');
$loader->alias('CrudeFileLog', 'JanDolata\CrudeCRUD\Engine\Models\FileLog');
$loader->alias('CrudeFiles', 'JanDolata\CrudeCRUD\Engine\Helpers\CrudeFiles');
$loader->alias('CrudeData', 'JanDolata\CrudeCRUD\Engine\Helpers\CrudeData');
$loader->alias('CrudeOptions', 'JanDolata\CrudeCRUD\Engine\Helpers\CrudeOptions');
$loader->alias('CrudeQueryHelper', 'JanDolata\CrudeCRUD\Engine\Helpers\CrudeQueryHelper');
$loader->alias('CrudeMagic', 'JanDolata\CrudeCRUD\Engine\Helpers\CrudeMagic');
$loader->alias('CrudeSpecialFiles', 'JanDolata\CrudeCRUD\Engine\Helpers\CrudeSpecialFiles');
}
|
[
"public",
"function",
"register",
"(",
")",
"{",
"$",
"this",
"->",
"registerCrudeCRUD",
"(",
")",
";",
"config",
"(",
"[",
"'config/crude.php'",
",",
"]",
")",
";",
"$",
"loader",
"=",
"\\",
"Illuminate",
"\\",
"Foundation",
"\\",
"AliasLoader",
"::",
"getInstance",
"(",
")",
";",
"$",
"loader",
"->",
"alias",
"(",
"'Crude'",
",",
"'JanDolata\\CrudeCRUD\\Engine\\Crude'",
")",
";",
"$",
"loader",
"->",
"alias",
"(",
"'CrudeListInterface'",
",",
"'JanDolata\\CrudeCRUD\\Engine\\Interfaces\\ListInterface'",
")",
";",
"$",
"loader",
"->",
"alias",
"(",
"'CrudeUpdateInterface'",
",",
"'JanDolata\\CrudeCRUD\\Engine\\Interfaces\\UpdateInterface'",
")",
";",
"$",
"loader",
"->",
"alias",
"(",
"'CrudeDeleteInterface'",
",",
"'JanDolata\\CrudeCRUD\\Engine\\Interfaces\\DeleteInterface'",
")",
";",
"$",
"loader",
"->",
"alias",
"(",
"'CrudeStoreInterface'",
",",
"'JanDolata\\CrudeCRUD\\Engine\\Interfaces\\StoreInterface'",
")",
";",
"$",
"loader",
"->",
"alias",
"(",
"'CrudeOrderInterface'",
",",
"'JanDolata\\CrudeCRUD\\Engine\\Interfaces\\OrderInterface'",
")",
";",
"$",
"loader",
"->",
"alias",
"(",
"'CrudeWithValidationInterface'",
",",
"'JanDolata\\CrudeCRUD\\Engine\\Interfaces\\WithValidationInterface'",
")",
";",
"$",
"loader",
"->",
"alias",
"(",
"'CrudeWithThumbnailInterface'",
",",
"'JanDolata\\CrudeCRUD\\Engine\\Interfaces\\WithThumbnailInterface'",
")",
";",
"$",
"loader",
"->",
"alias",
"(",
"'CrudeWithFileInterface'",
",",
"'JanDolata\\CrudeCRUD\\Engine\\Interfaces\\WithFileInterface'",
")",
";",
"$",
"loader",
"->",
"alias",
"(",
"'CrudeCRUDInterface'",
",",
"'JanDolata\\CrudeCRUD\\Engine\\Interfaces\\CRUDInterface'",
")",
";",
"$",
"loader",
"->",
"alias",
"(",
"'CrudeCRUDWithValidationInterface'",
",",
"'JanDolata\\CrudeCRUD\\Engine\\Interfaces\\CRUDWithValidationInterface'",
")",
";",
"$",
"loader",
"->",
"alias",
"(",
"'CrudeFromModelTrait'",
",",
"'JanDolata\\CrudeCRUD\\Engine\\Traits\\FromModelTrait'",
")",
";",
"$",
"loader",
"->",
"alias",
"(",
"'CrudeWithValidationTrait'",
",",
"'JanDolata\\CrudeCRUD\\Engine\\Traits\\WithValidationTrait'",
")",
";",
"$",
"loader",
"->",
"alias",
"(",
"'CrudeWithThumbnailTrait'",
",",
"'JanDolata\\CrudeCRUD\\Engine\\Traits\\WithThumbnailTrait'",
")",
";",
"$",
"loader",
"->",
"alias",
"(",
"'CrudeWithFileTrait'",
",",
"'JanDolata\\CrudeCRUD\\Engine\\Traits\\WithFileTrait'",
")",
";",
"$",
"loader",
"->",
"alias",
"(",
"'CrudeCrudeSetup'",
",",
"'JanDolata\\CrudeCRUD\\Engine\\CrudeSetup'",
")",
";",
"$",
"loader",
"->",
"alias",
"(",
"'CrudeFileLog'",
",",
"'JanDolata\\CrudeCRUD\\Engine\\Models\\FileLog'",
")",
";",
"$",
"loader",
"->",
"alias",
"(",
"'CrudeFiles'",
",",
"'JanDolata\\CrudeCRUD\\Engine\\Helpers\\CrudeFiles'",
")",
";",
"$",
"loader",
"->",
"alias",
"(",
"'CrudeData'",
",",
"'JanDolata\\CrudeCRUD\\Engine\\Helpers\\CrudeData'",
")",
";",
"$",
"loader",
"->",
"alias",
"(",
"'CrudeOptions'",
",",
"'JanDolata\\CrudeCRUD\\Engine\\Helpers\\CrudeOptions'",
")",
";",
"$",
"loader",
"->",
"alias",
"(",
"'CrudeQueryHelper'",
",",
"'JanDolata\\CrudeCRUD\\Engine\\Helpers\\CrudeQueryHelper'",
")",
";",
"$",
"loader",
"->",
"alias",
"(",
"'CrudeMagic'",
",",
"'JanDolata\\CrudeCRUD\\Engine\\Helpers\\CrudeMagic'",
")",
";",
"$",
"loader",
"->",
"alias",
"(",
"'CrudeSpecialFiles'",
",",
"'JanDolata\\CrudeCRUD\\Engine\\Helpers\\CrudeSpecialFiles'",
")",
";",
"}"
] |
Register any package services.
@return void
|
[
"Register",
"any",
"package",
"services",
"."
] |
train
|
https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/CrudeCRUDServiceProvider.php#L81-L118
|
refinery29/piston
|
src/Request.php
|
Request.setOffsetLimit
|
public function setOffsetLimit($offset, $limit)
{
$this->offset = $offset;
$this->limit = $limit;
$this->paginationType = self::OFFSET_LIMIT_PAGINATION;
}
|
php
|
public function setOffsetLimit($offset, $limit)
{
$this->offset = $offset;
$this->limit = $limit;
$this->paginationType = self::OFFSET_LIMIT_PAGINATION;
}
|
[
"public",
"function",
"setOffsetLimit",
"(",
"$",
"offset",
",",
"$",
"limit",
")",
"{",
"$",
"this",
"->",
"offset",
"=",
"$",
"offset",
";",
"$",
"this",
"->",
"limit",
"=",
"$",
"limit",
";",
"$",
"this",
"->",
"paginationType",
"=",
"self",
"::",
"OFFSET_LIMIT_PAGINATION",
";",
"}"
] |
@param string $offset
@param string $limit
@deprecated
|
[
"@param",
"string",
"$offset",
"@param",
"string",
"$limit"
] |
train
|
https://github.com/refinery29/piston/blob/75c402e814136577fa9a02479e8803aca664c865/src/Request.php#L178-L183
|
refinery29/piston
|
src/Request.php
|
Request.withCookie
|
public function withCookie($key, $val)
{
$this->cookieJar->set($key, $val);
return $this->withCookieParams($this->cookieJar->all());
}
|
php
|
public function withCookie($key, $val)
{
$this->cookieJar->set($key, $val);
return $this->withCookieParams($this->cookieJar->all());
}
|
[
"public",
"function",
"withCookie",
"(",
"$",
"key",
",",
"$",
"val",
")",
"{",
"$",
"this",
"->",
"cookieJar",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"val",
")",
";",
"return",
"$",
"this",
"->",
"withCookieParams",
"(",
"$",
"this",
"->",
"cookieJar",
"->",
"all",
"(",
")",
")",
";",
"}"
] |
@param string $key
@param mixed $val
@return ServerRequest
|
[
"@param",
"string",
"$key",
"@param",
"mixed",
"$val"
] |
train
|
https://github.com/refinery29/piston/blob/75c402e814136577fa9a02479e8803aca664c865/src/Request.php#L211-L216
|
refinery29/piston
|
src/Request.php
|
Request.clearCookie
|
public function clearCookie($key)
{
$this->cookieJar->clear($key);
return $this->withCookieParams($this->cookieJar->all());
}
|
php
|
public function clearCookie($key)
{
$this->cookieJar->clear($key);
return $this->withCookieParams($this->cookieJar->all());
}
|
[
"public",
"function",
"clearCookie",
"(",
"$",
"key",
")",
"{",
"$",
"this",
"->",
"cookieJar",
"->",
"clear",
"(",
"$",
"key",
")",
";",
"return",
"$",
"this",
"->",
"withCookieParams",
"(",
"$",
"this",
"->",
"cookieJar",
"->",
"all",
"(",
")",
")",
";",
"}"
] |
@param string $key
@return ServerRequest
|
[
"@param",
"string",
"$key"
] |
train
|
https://github.com/refinery29/piston/blob/75c402e814136577fa9a02479e8803aca664c865/src/Request.php#L241-L246
|
refinery29/piston
|
src/Request.php
|
Request.withOffsetLimit
|
public function withOffsetLimit($offset, $limit)
{
$new = clone $this;
$new->offset = $offset;
$new->limit = $limit;
$new->paginationType = self::OFFSET_LIMIT_PAGINATION;
return $new;
}
|
php
|
public function withOffsetLimit($offset, $limit)
{
$new = clone $this;
$new->offset = $offset;
$new->limit = $limit;
$new->paginationType = self::OFFSET_LIMIT_PAGINATION;
return $new;
}
|
[
"public",
"function",
"withOffsetLimit",
"(",
"$",
"offset",
",",
"$",
"limit",
")",
"{",
"$",
"new",
"=",
"clone",
"$",
"this",
";",
"$",
"new",
"->",
"offset",
"=",
"$",
"offset",
";",
"$",
"new",
"->",
"limit",
"=",
"$",
"limit",
";",
"$",
"new",
"->",
"paginationType",
"=",
"self",
"::",
"OFFSET_LIMIT_PAGINATION",
";",
"return",
"$",
"new",
";",
"}"
] |
@param int $offset
@param int $limit
@return Request
|
[
"@param",
"int",
"$offset",
"@param",
"int",
"$limit"
] |
train
|
https://github.com/refinery29/piston/blob/75c402e814136577fa9a02479e8803aca664c865/src/Request.php#L319-L327
|
refinery29/piston
|
src/Request.php
|
Request.withPageAndPerPage
|
public function withPageAndPerPage($page, $perPage)
{
$new = clone $this;
$new->offset = ($page - 1) * $perPage;
$new->limit = $perPage;
$new->paginationType = self::PAGED_PAGINATION;
return $new;
}
|
php
|
public function withPageAndPerPage($page, $perPage)
{
$new = clone $this;
$new->offset = ($page - 1) * $perPage;
$new->limit = $perPage;
$new->paginationType = self::PAGED_PAGINATION;
return $new;
}
|
[
"public",
"function",
"withPageAndPerPage",
"(",
"$",
"page",
",",
"$",
"perPage",
")",
"{",
"$",
"new",
"=",
"clone",
"$",
"this",
";",
"$",
"new",
"->",
"offset",
"=",
"(",
"$",
"page",
"-",
"1",
")",
"*",
"$",
"perPage",
";",
"$",
"new",
"->",
"limit",
"=",
"$",
"perPage",
";",
"$",
"new",
"->",
"paginationType",
"=",
"self",
"::",
"PAGED_PAGINATION",
";",
"return",
"$",
"new",
";",
"}"
] |
@param int $page
@param int $perPage
@return Request
|
[
"@param",
"int",
"$page",
"@param",
"int",
"$perPage"
] |
train
|
https://github.com/refinery29/piston/blob/75c402e814136577fa9a02479e8803aca664c865/src/Request.php#L405-L413
|
phpmob/twig-modify-bundle
|
Modifier/CSSMin.php
|
CSSMin.minify
|
public static function minify($content, array $options = [])
{
$compressor = new Minifier();
if (array_key_exists('remove_important_comments', $options)) {
$compressor->removeImportantComments($options['remove_important_comments']);
}
if (array_key_exists('keep_source_map_comment', $options)) {
$compressor->keepSourceMapComment($options['keep_source_map_comment']);
}
return $compressor->run($content);
}
|
php
|
public static function minify($content, array $options = [])
{
$compressor = new Minifier();
if (array_key_exists('remove_important_comments', $options)) {
$compressor->removeImportantComments($options['remove_important_comments']);
}
if (array_key_exists('keep_source_map_comment', $options)) {
$compressor->keepSourceMapComment($options['keep_source_map_comment']);
}
return $compressor->run($content);
}
|
[
"public",
"static",
"function",
"minify",
"(",
"$",
"content",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"compressor",
"=",
"new",
"Minifier",
"(",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"'remove_important_comments'",
",",
"$",
"options",
")",
")",
"{",
"$",
"compressor",
"->",
"removeImportantComments",
"(",
"$",
"options",
"[",
"'remove_important_comments'",
"]",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"'keep_source_map_comment'",
",",
"$",
"options",
")",
")",
"{",
"$",
"compressor",
"->",
"keepSourceMapComment",
"(",
"$",
"options",
"[",
"'keep_source_map_comment'",
"]",
")",
";",
"}",
"return",
"$",
"compressor",
"->",
"run",
"(",
"$",
"content",
")",
";",
"}"
] |
@param $content
@param array $options
@return string
|
[
"@param",
"$content",
"@param",
"array",
"$options"
] |
train
|
https://github.com/phpmob/twig-modify-bundle/blob/30b70ca3ea7b902f2f29c8457cd4f8da45b1d29e/Modifier/CSSMin.php#L27-L40
|
VDMi/Guzzle-oAuth
|
src/GuzzleOauth/BaseConsumerOauth2.php
|
BaseConsumerOauth2.getAuthorizeUrl
|
public function getAuthorizeUrl($request_token, $callback_uri = NULL, $state = NULL) {
if (empty($callback_uri) && isset($request_token['callback_uri'])) {
$callback_uri = $request_token['callback_uri'];
}
if (empty($state)) {
$state = md5(mt_rand());
}
$params = array();
if ($this->getConfig()->get('offline_access')) {
$params += $this->getOfflineAccessParams();
}
$query = array(
'response_type' => 'code',
'client_id' => $this->getConfig('consumer_key'),
'redirect_uri' => $callback_uri,
'scope' => implode($this->getConfig('scope_delimiter'), $this->getScope()),
'state' => $state,
) + $params;
// authorize
$url = Url::factory($this->getConfig('base_url'));
$url->addPath($this->getConfig('authorize_path'));
$url->setQuery($query);
return (string)$url;
}
|
php
|
public function getAuthorizeUrl($request_token, $callback_uri = NULL, $state = NULL) {
if (empty($callback_uri) && isset($request_token['callback_uri'])) {
$callback_uri = $request_token['callback_uri'];
}
if (empty($state)) {
$state = md5(mt_rand());
}
$params = array();
if ($this->getConfig()->get('offline_access')) {
$params += $this->getOfflineAccessParams();
}
$query = array(
'response_type' => 'code',
'client_id' => $this->getConfig('consumer_key'),
'redirect_uri' => $callback_uri,
'scope' => implode($this->getConfig('scope_delimiter'), $this->getScope()),
'state' => $state,
) + $params;
// authorize
$url = Url::factory($this->getConfig('base_url'));
$url->addPath($this->getConfig('authorize_path'));
$url->setQuery($query);
return (string)$url;
}
|
[
"public",
"function",
"getAuthorizeUrl",
"(",
"$",
"request_token",
",",
"$",
"callback_uri",
"=",
"NULL",
",",
"$",
"state",
"=",
"NULL",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"callback_uri",
")",
"&&",
"isset",
"(",
"$",
"request_token",
"[",
"'callback_uri'",
"]",
")",
")",
"{",
"$",
"callback_uri",
"=",
"$",
"request_token",
"[",
"'callback_uri'",
"]",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"state",
")",
")",
"{",
"$",
"state",
"=",
"md5",
"(",
"mt_rand",
"(",
")",
")",
";",
"}",
"$",
"params",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getConfig",
"(",
")",
"->",
"get",
"(",
"'offline_access'",
")",
")",
"{",
"$",
"params",
"+=",
"$",
"this",
"->",
"getOfflineAccessParams",
"(",
")",
";",
"}",
"$",
"query",
"=",
"array",
"(",
"'response_type'",
"=>",
"'code'",
",",
"'client_id'",
"=>",
"$",
"this",
"->",
"getConfig",
"(",
"'consumer_key'",
")",
",",
"'redirect_uri'",
"=>",
"$",
"callback_uri",
",",
"'scope'",
"=>",
"implode",
"(",
"$",
"this",
"->",
"getConfig",
"(",
"'scope_delimiter'",
")",
",",
"$",
"this",
"->",
"getScope",
"(",
")",
")",
",",
"'state'",
"=>",
"$",
"state",
",",
")",
"+",
"$",
"params",
";",
"// authorize",
"$",
"url",
"=",
"Url",
"::",
"factory",
"(",
"$",
"this",
"->",
"getConfig",
"(",
"'base_url'",
")",
")",
";",
"$",
"url",
"->",
"addPath",
"(",
"$",
"this",
"->",
"getConfig",
"(",
"'authorize_path'",
")",
")",
";",
"$",
"url",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"return",
"(",
"string",
")",
"$",
"url",
";",
"}"
] |
Return a redirect url.
|
[
"Return",
"a",
"redirect",
"url",
"."
] |
train
|
https://github.com/VDMi/Guzzle-oAuth/blob/e2b2561e4e402e13ba605082bf768b29942f90cb/src/GuzzleOauth/BaseConsumerOauth2.php#L75-L99
|
VDMi/Guzzle-oAuth
|
src/GuzzleOauth/BaseConsumerOauth2.php
|
BaseConsumerOauth2.getAccessToken
|
public function getAccessToken($query_data, $request_token) {
$post = array(
'client_id' => $this->getConfig('consumer_key'),
'client_secret' => $this->getConfig('consumer_secret'),
'redirect_uri' => $request_token['callback_uri'],
'code' => $query_data['code'],
'grant_type' => 'authorization_code',
);
//Get request token
$response = $this->post($this->getConfig('access_token_path'), NULL, $post)->send();
$access_token = array();
parse_str($response->getBody(), $access_token);
if (!isset($access_token['access_token'])) {
// try to read json
$access_token = $response->json();
}
$access_token['request_time'] = time();
// Throw exception if there isn't a access token.
if (!isset($access_token['access_token'])) {
throw new \Exception('No access token found in response.');
}
if ($this->getConfig()->get('exchange_short_access_token')) {
$access_token = $this->exchangeAccessToken($access_token);
}
// Return AccessToken
return $this->normalizeAccessToken($access_token);
}
|
php
|
public function getAccessToken($query_data, $request_token) {
$post = array(
'client_id' => $this->getConfig('consumer_key'),
'client_secret' => $this->getConfig('consumer_secret'),
'redirect_uri' => $request_token['callback_uri'],
'code' => $query_data['code'],
'grant_type' => 'authorization_code',
);
//Get request token
$response = $this->post($this->getConfig('access_token_path'), NULL, $post)->send();
$access_token = array();
parse_str($response->getBody(), $access_token);
if (!isset($access_token['access_token'])) {
// try to read json
$access_token = $response->json();
}
$access_token['request_time'] = time();
// Throw exception if there isn't a access token.
if (!isset($access_token['access_token'])) {
throw new \Exception('No access token found in response.');
}
if ($this->getConfig()->get('exchange_short_access_token')) {
$access_token = $this->exchangeAccessToken($access_token);
}
// Return AccessToken
return $this->normalizeAccessToken($access_token);
}
|
[
"public",
"function",
"getAccessToken",
"(",
"$",
"query_data",
",",
"$",
"request_token",
")",
"{",
"$",
"post",
"=",
"array",
"(",
"'client_id'",
"=>",
"$",
"this",
"->",
"getConfig",
"(",
"'consumer_key'",
")",
",",
"'client_secret'",
"=>",
"$",
"this",
"->",
"getConfig",
"(",
"'consumer_secret'",
")",
",",
"'redirect_uri'",
"=>",
"$",
"request_token",
"[",
"'callback_uri'",
"]",
",",
"'code'",
"=>",
"$",
"query_data",
"[",
"'code'",
"]",
",",
"'grant_type'",
"=>",
"'authorization_code'",
",",
")",
";",
"//Get request token",
"$",
"response",
"=",
"$",
"this",
"->",
"post",
"(",
"$",
"this",
"->",
"getConfig",
"(",
"'access_token_path'",
")",
",",
"NULL",
",",
"$",
"post",
")",
"->",
"send",
"(",
")",
";",
"$",
"access_token",
"=",
"array",
"(",
")",
";",
"parse_str",
"(",
"$",
"response",
"->",
"getBody",
"(",
")",
",",
"$",
"access_token",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"access_token",
"[",
"'access_token'",
"]",
")",
")",
"{",
"// try to read json",
"$",
"access_token",
"=",
"$",
"response",
"->",
"json",
"(",
")",
";",
"}",
"$",
"access_token",
"[",
"'request_time'",
"]",
"=",
"time",
"(",
")",
";",
"// Throw exception if there isn't a access token.",
"if",
"(",
"!",
"isset",
"(",
"$",
"access_token",
"[",
"'access_token'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'No access token found in response.'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"getConfig",
"(",
")",
"->",
"get",
"(",
"'exchange_short_access_token'",
")",
")",
"{",
"$",
"access_token",
"=",
"$",
"this",
"->",
"exchangeAccessToken",
"(",
"$",
"access_token",
")",
";",
"}",
"// Return AccessToken",
"return",
"$",
"this",
"->",
"normalizeAccessToken",
"(",
"$",
"access_token",
")",
";",
"}"
] |
Get a Access Token.
|
[
"Get",
"a",
"Access",
"Token",
"."
] |
train
|
https://github.com/VDMi/Guzzle-oAuth/blob/e2b2561e4e402e13ba605082bf768b29942f90cb/src/GuzzleOauth/BaseConsumerOauth2.php#L111-L141
|
VDMi/Guzzle-oAuth
|
src/GuzzleOauth/BaseConsumerOauth2.php
|
BaseConsumerOauth2.normalizeAccessToken
|
protected function normalizeAccessToken($access_token) {
if (!isset($access_token['token_type'])) {
$access_token['token_type'] = 'Bearer';
}
if (!isset($access_token['expires_at']) && isset($access_token['expires_in'])) {
$access_token['expires_at'] = $access_token['expires_in'] + $access_token['request_time'];
}
return $access_token;
}
|
php
|
protected function normalizeAccessToken($access_token) {
if (!isset($access_token['token_type'])) {
$access_token['token_type'] = 'Bearer';
}
if (!isset($access_token['expires_at']) && isset($access_token['expires_in'])) {
$access_token['expires_at'] = $access_token['expires_in'] + $access_token['request_time'];
}
return $access_token;
}
|
[
"protected",
"function",
"normalizeAccessToken",
"(",
"$",
"access_token",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"access_token",
"[",
"'token_type'",
"]",
")",
")",
"{",
"$",
"access_token",
"[",
"'token_type'",
"]",
"=",
"'Bearer'",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"access_token",
"[",
"'expires_at'",
"]",
")",
"&&",
"isset",
"(",
"$",
"access_token",
"[",
"'expires_in'",
"]",
")",
")",
"{",
"$",
"access_token",
"[",
"'expires_at'",
"]",
"=",
"$",
"access_token",
"[",
"'expires_in'",
"]",
"+",
"$",
"access_token",
"[",
"'request_time'",
"]",
";",
"}",
"return",
"$",
"access_token",
";",
"}"
] |
Normalize access token
|
[
"Normalize",
"access",
"token"
] |
train
|
https://github.com/VDMi/Guzzle-oAuth/blob/e2b2561e4e402e13ba605082bf768b29942f90cb/src/GuzzleOauth/BaseConsumerOauth2.php#L153-L161
|
VDMi/Guzzle-oAuth
|
src/GuzzleOauth/BaseConsumerOauth2.php
|
BaseConsumerOauth2.setToken
|
public function setToken($token, $token_secret = '') {
$this->getOauthPlugin()->setToken($token, $token_secret);
$this->getConfig()->set('access_token', $token);
return $this;
}
|
php
|
public function setToken($token, $token_secret = '') {
$this->getOauthPlugin()->setToken($token, $token_secret);
$this->getConfig()->set('access_token', $token);
return $this;
}
|
[
"public",
"function",
"setToken",
"(",
"$",
"token",
",",
"$",
"token_secret",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"getOauthPlugin",
"(",
")",
"->",
"setToken",
"(",
"$",
"token",
",",
"$",
"token_secret",
")",
";",
"$",
"this",
"->",
"getConfig",
"(",
")",
"->",
"set",
"(",
"'access_token'",
",",
"$",
"token",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Set Token (and secret)
|
[
"Set",
"Token",
"(",
"and",
"secret",
")"
] |
train
|
https://github.com/VDMi/Guzzle-oAuth/blob/e2b2561e4e402e13ba605082bf768b29942f90cb/src/GuzzleOauth/BaseConsumerOauth2.php#L166-L170
|
VDMi/Guzzle-oAuth
|
src/GuzzleOauth/BaseConsumerOauth2.php
|
BaseConsumerOauth2.getScope
|
public function getScope() {
$scope = $this->getConfig('scope');
if (empty($scope)) {
$scope = array();
}
if (is_string($scope)) {
$this->addScope($scope);
$scope = $this->getConfig('scope');
}
return $scope;
}
|
php
|
public function getScope() {
$scope = $this->getConfig('scope');
if (empty($scope)) {
$scope = array();
}
if (is_string($scope)) {
$this->addScope($scope);
$scope = $this->getConfig('scope');
}
return $scope;
}
|
[
"public",
"function",
"getScope",
"(",
")",
"{",
"$",
"scope",
"=",
"$",
"this",
"->",
"getConfig",
"(",
"'scope'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"scope",
")",
")",
"{",
"$",
"scope",
"=",
"array",
"(",
")",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"scope",
")",
")",
"{",
"$",
"this",
"->",
"addScope",
"(",
"$",
"scope",
")",
";",
"$",
"scope",
"=",
"$",
"this",
"->",
"getConfig",
"(",
"'scope'",
")",
";",
"}",
"return",
"$",
"scope",
";",
"}"
] |
Get Scope
|
[
"Get",
"Scope"
] |
train
|
https://github.com/VDMi/Guzzle-oAuth/blob/e2b2561e4e402e13ba605082bf768b29942f90cb/src/GuzzleOauth/BaseConsumerOauth2.php#L183-L193
|
VDMi/Guzzle-oAuth
|
src/GuzzleOauth/BaseConsumerOauth2.php
|
BaseConsumerOauth2.addScope
|
public function addScope($extra_scope) {
$scope = $this->getConfig('scope');
if (empty($scope)) {
$scope = array();
}
if (is_string($scope)) {
$scope = preg_split('/\s,\s|\s,|,\s|,|\s/', $scope);
}
if (is_string($extra_scope)) {
$extra_scope = preg_split('/\s,\s|\s,|,\s|,|\s/', $extra_scope);
}
$scope = array_unique(array_merge($scope, $extra_scope));
foreach ($scope as $key => $value) {
if (empty($value)) {
unset($scope[$key]);
}
}
$scope = array_values($scope);
$this->getConfig()->set('scope', $scope);
return $this;
}
|
php
|
public function addScope($extra_scope) {
$scope = $this->getConfig('scope');
if (empty($scope)) {
$scope = array();
}
if (is_string($scope)) {
$scope = preg_split('/\s,\s|\s,|,\s|,|\s/', $scope);
}
if (is_string($extra_scope)) {
$extra_scope = preg_split('/\s,\s|\s,|,\s|,|\s/', $extra_scope);
}
$scope = array_unique(array_merge($scope, $extra_scope));
foreach ($scope as $key => $value) {
if (empty($value)) {
unset($scope[$key]);
}
}
$scope = array_values($scope);
$this->getConfig()->set('scope', $scope);
return $this;
}
|
[
"public",
"function",
"addScope",
"(",
"$",
"extra_scope",
")",
"{",
"$",
"scope",
"=",
"$",
"this",
"->",
"getConfig",
"(",
"'scope'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"scope",
")",
")",
"{",
"$",
"scope",
"=",
"array",
"(",
")",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"scope",
")",
")",
"{",
"$",
"scope",
"=",
"preg_split",
"(",
"'/\\s,\\s|\\s,|,\\s|,|\\s/'",
",",
"$",
"scope",
")",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"extra_scope",
")",
")",
"{",
"$",
"extra_scope",
"=",
"preg_split",
"(",
"'/\\s,\\s|\\s,|,\\s|,|\\s/'",
",",
"$",
"extra_scope",
")",
";",
"}",
"$",
"scope",
"=",
"array_unique",
"(",
"array_merge",
"(",
"$",
"scope",
",",
"$",
"extra_scope",
")",
")",
";",
"foreach",
"(",
"$",
"scope",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"unset",
"(",
"$",
"scope",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"$",
"scope",
"=",
"array_values",
"(",
"$",
"scope",
")",
";",
"$",
"this",
"->",
"getConfig",
"(",
")",
"->",
"set",
"(",
"'scope'",
",",
"$",
"scope",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Add Scope
|
[
"Add",
"Scope"
] |
train
|
https://github.com/VDMi/Guzzle-oAuth/blob/e2b2561e4e402e13ba605082bf768b29942f90cb/src/GuzzleOauth/BaseConsumerOauth2.php#L198-L219
|
phramework/jsonapi
|
src/Model/Relationship.php
|
Relationship.getRelationshipData
|
public static function getRelationshipData(
$relationshipKey,
$id,
Fields $fields = null,
$primaryDataParameters = [],
$relationshipParameters = []
) {
if (!static::relationshipExists($relationshipKey)) {
throw new \Phramework\Exceptions\ServerException(sprintf(
'"%s" is not a valid relationship key',
$relationshipKey
));
}
$relationship = static::getRelationship($relationshipKey);
switch ($relationship->type) {
case \Phramework\JSONAPI\Relationship::TYPE_TO_ONE:
$resource = $callMethod = static::getById(
$id,
$fields,
...$primaryDataParameters
);
if (!$resource) {
return null;
}
//And use it's relationships data for this relationship
return (
isset($resource->relationships->{$relationshipKey}->data)
? $resource->relationships->{$relationshipKey}->data
: null
);
case \Phramework\JSONAPI\Relationship::TYPE_TO_MANY:
default:
if (!isset($relationship->callbacks->{Phramework::METHOD_GET})) {
return [];
}
$callMethod = $relationship->callbacks->{Phramework::METHOD_GET};
if (!is_callable($callMethod)) {
throw new \Phramework\Exceptions\ServerException(
$callMethod[0] . '::' . $callMethod[1]
. ' is not implemented'
);
}
//also we could attempt to use getById like the above TO_ONE
//to use relationships data
return call_user_func(
$callMethod,
$id,
$fields,
...$relationshipParameters
);
}
}
|
php
|
public static function getRelationshipData(
$relationshipKey,
$id,
Fields $fields = null,
$primaryDataParameters = [],
$relationshipParameters = []
) {
if (!static::relationshipExists($relationshipKey)) {
throw new \Phramework\Exceptions\ServerException(sprintf(
'"%s" is not a valid relationship key',
$relationshipKey
));
}
$relationship = static::getRelationship($relationshipKey);
switch ($relationship->type) {
case \Phramework\JSONAPI\Relationship::TYPE_TO_ONE:
$resource = $callMethod = static::getById(
$id,
$fields,
...$primaryDataParameters
);
if (!$resource) {
return null;
}
//And use it's relationships data for this relationship
return (
isset($resource->relationships->{$relationshipKey}->data)
? $resource->relationships->{$relationshipKey}->data
: null
);
case \Phramework\JSONAPI\Relationship::TYPE_TO_MANY:
default:
if (!isset($relationship->callbacks->{Phramework::METHOD_GET})) {
return [];
}
$callMethod = $relationship->callbacks->{Phramework::METHOD_GET};
if (!is_callable($callMethod)) {
throw new \Phramework\Exceptions\ServerException(
$callMethod[0] . '::' . $callMethod[1]
. ' is not implemented'
);
}
//also we could attempt to use getById like the above TO_ONE
//to use relationships data
return call_user_func(
$callMethod,
$id,
$fields,
...$relationshipParameters
);
}
}
|
[
"public",
"static",
"function",
"getRelationshipData",
"(",
"$",
"relationshipKey",
",",
"$",
"id",
",",
"Fields",
"$",
"fields",
"=",
"null",
",",
"$",
"primaryDataParameters",
"=",
"[",
"]",
",",
"$",
"relationshipParameters",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"static",
"::",
"relationshipExists",
"(",
"$",
"relationshipKey",
")",
")",
"{",
"throw",
"new",
"\\",
"Phramework",
"\\",
"Exceptions",
"\\",
"ServerException",
"(",
"sprintf",
"(",
"'\"%s\" is not a valid relationship key'",
",",
"$",
"relationshipKey",
")",
")",
";",
"}",
"$",
"relationship",
"=",
"static",
"::",
"getRelationship",
"(",
"$",
"relationshipKey",
")",
";",
"switch",
"(",
"$",
"relationship",
"->",
"type",
")",
"{",
"case",
"\\",
"Phramework",
"\\",
"JSONAPI",
"\\",
"Relationship",
"::",
"TYPE_TO_ONE",
":",
"$",
"resource",
"=",
"$",
"callMethod",
"=",
"static",
"::",
"getById",
"(",
"$",
"id",
",",
"$",
"fields",
",",
"...",
"$",
"primaryDataParameters",
")",
";",
"if",
"(",
"!",
"$",
"resource",
")",
"{",
"return",
"null",
";",
"}",
"//And use it's relationships data for this relationship",
"return",
"(",
"isset",
"(",
"$",
"resource",
"->",
"relationships",
"->",
"{",
"$",
"relationshipKey",
"}",
"->",
"data",
")",
"?",
"$",
"resource",
"->",
"relationships",
"->",
"{",
"$",
"relationshipKey",
"}",
"->",
"data",
":",
"null",
")",
";",
"case",
"\\",
"Phramework",
"\\",
"JSONAPI",
"\\",
"Relationship",
"::",
"TYPE_TO_MANY",
":",
"default",
":",
"if",
"(",
"!",
"isset",
"(",
"$",
"relationship",
"->",
"callbacks",
"->",
"{",
"Phramework",
"::",
"METHOD_GET",
"}",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"callMethod",
"=",
"$",
"relationship",
"->",
"callbacks",
"->",
"{",
"Phramework",
"::",
"METHOD_GET",
"}",
";",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"callMethod",
")",
")",
"{",
"throw",
"new",
"\\",
"Phramework",
"\\",
"Exceptions",
"\\",
"ServerException",
"(",
"$",
"callMethod",
"[",
"0",
"]",
".",
"'::'",
".",
"$",
"callMethod",
"[",
"1",
"]",
".",
"' is not implemented'",
")",
";",
"}",
"//also we could attempt to use getById like the above TO_ONE",
"//to use relationships data",
"return",
"call_user_func",
"(",
"$",
"callMethod",
",",
"$",
"id",
",",
"$",
"fields",
",",
"...",
"$",
"relationshipParameters",
")",
";",
"}",
"}"
] |
Get records from a relationship link
@param string $relationshipKey
@param string $id
@param Fields|null $fields
@return RelationshipResource|RelationshipResource[]
@throws \Phramework\Exceptions\ServerException If relationship doesn't exist
@throws \Phramework\Exceptions\ServerException If relationship's class method is
not defined
|
[
"Get",
"records",
"from",
"a",
"relationship",
"link"
] |
train
|
https://github.com/phramework/jsonapi/blob/af20882a8b6f6e5be9c8e09e5b87f6c23a4b0726/src/Model/Relationship.php#L69-L128
|
phramework/jsonapi
|
src/Model/Relationship.php
|
Relationship.getIncludedData
|
public static function getIncludedData(
$primaryData,
$include = [],
Fields $fields = null,
$additionalResourceParameters = []
) {
/**
* Store relationshipKeys as key and ids of their related data as value
* @example
* ```php
* (object) [
* 'author' => [1],
* 'comment' => [1, 2, 3, 4]
* ]
* ```
*/
$tempRelationshipIds = new \stdClass();
//check if relationship exists
foreach ($include as $relationshipKey) {
if (!static::relationshipExists($relationshipKey)) {
throw new RequestException(sprintf(
'Relationship "%s" not found',
$relationshipKey
));
}
//Will hold ids of related data
$tempRelationshipIds->{$relationshipKey} = [];
}
if (empty($include) || empty($primaryData)) {
return [];
}
//iterate all primary data
//if a single resource convert it to array
//so it can be iterated in the same way
if (!is_array($primaryData)) {
$primaryData = [$primaryData];
}
foreach ($primaryData as $resource) {
//Ignore resource if it's relationships are not set or empty
if (empty($resource->relationships)) {
continue;
}
foreach ($include as $relationshipKey) {
//ignore if requested relationship is not set
if (!isset($resource->relationships->{$relationshipKey})) {
continue;
}
//ignore if requested relationship data are not set
if (!isset($resource->relationships->{$relationshipKey}->data)) {
continue;
}
$relationshipData = $resource->relationships->{$relationshipKey}->data;
if (!$relationshipData || empty($relationshipData)) {
continue;
}
//if single relationship resource convert it to array
//so it can be iterated in the same way
if (!is_array($relationshipData)) {
$relationshipData = [$relationshipData];
}
//Push relationship id for this requested relationship
foreach ($relationshipData as $primaryKeyAndType) {
//push primary key (use type? $primaryKeyAndType->type)
$tempRelationshipIds->{$relationshipKey}[] = $primaryKeyAndType->id;
}
}
}
$included = [];
foreach ($include as $relationshipKey) {
$relationship = static::getRelationship($relationshipKey);
$relationshipModelClass = $relationship->modelClass;
$ids = array_unique($tempRelationshipIds->{$relationshipKey});
$additionalArgument = (
isset($additionalResourceParameters[$relationshipKey])
? $additionalResourceParameters[$relationshipKey]
: []
);
$resources = $relationshipModelClass::getById(
$ids,
$fields,
...$additionalArgument
);
foreach ($resources as $key => $resource) {
if ($resource === null) {
continue;
}
$included[] = $resource;
}
}
return $included;
}
|
php
|
public static function getIncludedData(
$primaryData,
$include = [],
Fields $fields = null,
$additionalResourceParameters = []
) {
/**
* Store relationshipKeys as key and ids of their related data as value
* @example
* ```php
* (object) [
* 'author' => [1],
* 'comment' => [1, 2, 3, 4]
* ]
* ```
*/
$tempRelationshipIds = new \stdClass();
//check if relationship exists
foreach ($include as $relationshipKey) {
if (!static::relationshipExists($relationshipKey)) {
throw new RequestException(sprintf(
'Relationship "%s" not found',
$relationshipKey
));
}
//Will hold ids of related data
$tempRelationshipIds->{$relationshipKey} = [];
}
if (empty($include) || empty($primaryData)) {
return [];
}
//iterate all primary data
//if a single resource convert it to array
//so it can be iterated in the same way
if (!is_array($primaryData)) {
$primaryData = [$primaryData];
}
foreach ($primaryData as $resource) {
//Ignore resource if it's relationships are not set or empty
if (empty($resource->relationships)) {
continue;
}
foreach ($include as $relationshipKey) {
//ignore if requested relationship is not set
if (!isset($resource->relationships->{$relationshipKey})) {
continue;
}
//ignore if requested relationship data are not set
if (!isset($resource->relationships->{$relationshipKey}->data)) {
continue;
}
$relationshipData = $resource->relationships->{$relationshipKey}->data;
if (!$relationshipData || empty($relationshipData)) {
continue;
}
//if single relationship resource convert it to array
//so it can be iterated in the same way
if (!is_array($relationshipData)) {
$relationshipData = [$relationshipData];
}
//Push relationship id for this requested relationship
foreach ($relationshipData as $primaryKeyAndType) {
//push primary key (use type? $primaryKeyAndType->type)
$tempRelationshipIds->{$relationshipKey}[] = $primaryKeyAndType->id;
}
}
}
$included = [];
foreach ($include as $relationshipKey) {
$relationship = static::getRelationship($relationshipKey);
$relationshipModelClass = $relationship->modelClass;
$ids = array_unique($tempRelationshipIds->{$relationshipKey});
$additionalArgument = (
isset($additionalResourceParameters[$relationshipKey])
? $additionalResourceParameters[$relationshipKey]
: []
);
$resources = $relationshipModelClass::getById(
$ids,
$fields,
...$additionalArgument
);
foreach ($resources as $key => $resource) {
if ($resource === null) {
continue;
}
$included[] = $resource;
}
}
return $included;
}
|
[
"public",
"static",
"function",
"getIncludedData",
"(",
"$",
"primaryData",
",",
"$",
"include",
"=",
"[",
"]",
",",
"Fields",
"$",
"fields",
"=",
"null",
",",
"$",
"additionalResourceParameters",
"=",
"[",
"]",
")",
"{",
"/**\n * Store relationshipKeys as key and ids of their related data as value\n * @example\n * ```php\n * (object) [\n * 'author' => [1],\n * 'comment' => [1, 2, 3, 4]\n * ]\n * ```\n */",
"$",
"tempRelationshipIds",
"=",
"new",
"\\",
"stdClass",
"(",
")",
";",
"//check if relationship exists",
"foreach",
"(",
"$",
"include",
"as",
"$",
"relationshipKey",
")",
"{",
"if",
"(",
"!",
"static",
"::",
"relationshipExists",
"(",
"$",
"relationshipKey",
")",
")",
"{",
"throw",
"new",
"RequestException",
"(",
"sprintf",
"(",
"'Relationship \"%s\" not found'",
",",
"$",
"relationshipKey",
")",
")",
";",
"}",
"//Will hold ids of related data",
"$",
"tempRelationshipIds",
"->",
"{",
"$",
"relationshipKey",
"}",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"include",
")",
"||",
"empty",
"(",
"$",
"primaryData",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"//iterate all primary data",
"//if a single resource convert it to array",
"//so it can be iterated in the same way",
"if",
"(",
"!",
"is_array",
"(",
"$",
"primaryData",
")",
")",
"{",
"$",
"primaryData",
"=",
"[",
"$",
"primaryData",
"]",
";",
"}",
"foreach",
"(",
"$",
"primaryData",
"as",
"$",
"resource",
")",
"{",
"//Ignore resource if it's relationships are not set or empty",
"if",
"(",
"empty",
"(",
"$",
"resource",
"->",
"relationships",
")",
")",
"{",
"continue",
";",
"}",
"foreach",
"(",
"$",
"include",
"as",
"$",
"relationshipKey",
")",
"{",
"//ignore if requested relationship is not set",
"if",
"(",
"!",
"isset",
"(",
"$",
"resource",
"->",
"relationships",
"->",
"{",
"$",
"relationshipKey",
"}",
")",
")",
"{",
"continue",
";",
"}",
"//ignore if requested relationship data are not set",
"if",
"(",
"!",
"isset",
"(",
"$",
"resource",
"->",
"relationships",
"->",
"{",
"$",
"relationshipKey",
"}",
"->",
"data",
")",
")",
"{",
"continue",
";",
"}",
"$",
"relationshipData",
"=",
"$",
"resource",
"->",
"relationships",
"->",
"{",
"$",
"relationshipKey",
"}",
"->",
"data",
";",
"if",
"(",
"!",
"$",
"relationshipData",
"||",
"empty",
"(",
"$",
"relationshipData",
")",
")",
"{",
"continue",
";",
"}",
"//if single relationship resource convert it to array",
"//so it can be iterated in the same way",
"if",
"(",
"!",
"is_array",
"(",
"$",
"relationshipData",
")",
")",
"{",
"$",
"relationshipData",
"=",
"[",
"$",
"relationshipData",
"]",
";",
"}",
"//Push relationship id for this requested relationship",
"foreach",
"(",
"$",
"relationshipData",
"as",
"$",
"primaryKeyAndType",
")",
"{",
"//push primary key (use type? $primaryKeyAndType->type)",
"$",
"tempRelationshipIds",
"->",
"{",
"$",
"relationshipKey",
"}",
"[",
"]",
"=",
"$",
"primaryKeyAndType",
"->",
"id",
";",
"}",
"}",
"}",
"$",
"included",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"include",
"as",
"$",
"relationshipKey",
")",
"{",
"$",
"relationship",
"=",
"static",
"::",
"getRelationship",
"(",
"$",
"relationshipKey",
")",
";",
"$",
"relationshipModelClass",
"=",
"$",
"relationship",
"->",
"modelClass",
";",
"$",
"ids",
"=",
"array_unique",
"(",
"$",
"tempRelationshipIds",
"->",
"{",
"$",
"relationshipKey",
"}",
")",
";",
"$",
"additionalArgument",
"=",
"(",
"isset",
"(",
"$",
"additionalResourceParameters",
"[",
"$",
"relationshipKey",
"]",
")",
"?",
"$",
"additionalResourceParameters",
"[",
"$",
"relationshipKey",
"]",
":",
"[",
"]",
")",
";",
"$",
"resources",
"=",
"$",
"relationshipModelClass",
"::",
"getById",
"(",
"$",
"ids",
",",
"$",
"fields",
",",
"...",
"$",
"additionalArgument",
")",
";",
"foreach",
"(",
"$",
"resources",
"as",
"$",
"key",
"=>",
"$",
"resource",
")",
"{",
"if",
"(",
"$",
"resource",
"===",
"null",
")",
"{",
"continue",
";",
"}",
"$",
"included",
"[",
"]",
"=",
"$",
"resource",
";",
"}",
"}",
"return",
"$",
"included",
";",
"}"
] |
Get jsonapi's included object, selected by include argument,
using id's of relationship's data from resources in primary data object
@param Resource|Resource[] $primaryData Primary data resource or resources
@param string[] $include An array with the keys of relationships to include
@param Fields|null $fields
@param array $additionalResourceParameters *[Optional]*
@return Resource[] An array with all included related data
@throws \Phramework\Exceptions\RequestException When a relationship is not found
@throws \Phramework\Exceptions\ServerException
@todo handle Relationship resource cannot be accessed
@todo include second level relationships
@example
```php
Relationship::getIncludedData(
Article::get(),
['tag', 'author']
);
```
|
[
"Get",
"jsonapi",
"s",
"included",
"object",
"selected",
"by",
"include",
"argument",
"using",
"id",
"s",
"of",
"relationship",
"s",
"data",
"from",
"resources",
"in",
"primary",
"data",
"object"
] |
train
|
https://github.com/phramework/jsonapi/blob/af20882a8b6f6e5be9c8e09e5b87f6c23a4b0726/src/Model/Relationship.php#L150-L261
|
acasademont/wurfl
|
WURFL/WURFLManagerFactory.php
|
WURFL_WURFLManagerFactory.reload
|
private function reload()
{
$this->persistenceStorage->setWURFLLoaded(false);
$this->invalidateCache();
$this->init();
$this->persistenceStorage->save(self::WURFL_API_STATE, $this->getState());
}
|
php
|
private function reload()
{
$this->persistenceStorage->setWURFLLoaded(false);
$this->invalidateCache();
$this->init();
$this->persistenceStorage->save(self::WURFL_API_STATE, $this->getState());
}
|
[
"private",
"function",
"reload",
"(",
")",
"{",
"$",
"this",
"->",
"persistenceStorage",
"->",
"setWURFLLoaded",
"(",
"false",
")",
";",
"$",
"this",
"->",
"invalidateCache",
"(",
")",
";",
"$",
"this",
"->",
"init",
"(",
")",
";",
"$",
"this",
"->",
"persistenceStorage",
"->",
"save",
"(",
"self",
"::",
"WURFL_API_STATE",
",",
"$",
"this",
"->",
"getState",
"(",
")",
")",
";",
"}"
] |
Reload the WURFL Data into the persistence provider
|
[
"Reload",
"the",
"WURFL",
"Data",
"into",
"the",
"persistence",
"provider"
] |
train
|
https://github.com/acasademont/wurfl/blob/0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2/WURFL/WURFLManagerFactory.php#L91-L97
|
acasademont/wurfl
|
WURFL/WURFLManagerFactory.php
|
WURFL_WURFLManagerFactory.hasToBeReloaded
|
public function hasToBeReloaded()
{
if (!$this->wurflConfig->allowReload) {
return false;
}
$state = $this->persistenceStorage->load(self::WURFL_API_STATE);
return !$this->isStateCurrent($state);
}
|
php
|
public function hasToBeReloaded()
{
if (!$this->wurflConfig->allowReload) {
return false;
}
$state = $this->persistenceStorage->load(self::WURFL_API_STATE);
return !$this->isStateCurrent($state);
}
|
[
"public",
"function",
"hasToBeReloaded",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"wurflConfig",
"->",
"allowReload",
")",
"{",
"return",
"false",
";",
"}",
"$",
"state",
"=",
"$",
"this",
"->",
"persistenceStorage",
"->",
"load",
"(",
"self",
"::",
"WURFL_API_STATE",
")",
";",
"return",
"!",
"$",
"this",
"->",
"isStateCurrent",
"(",
"$",
"state",
")",
";",
"}"
] |
Returns true if the WURFL is out of date or otherwise needs to be reloaded
@return bool
|
[
"Returns",
"true",
"if",
"the",
"WURFL",
"is",
"out",
"of",
"date",
"or",
"otherwise",
"needs",
"to",
"be",
"reloaded"
] |
train
|
https://github.com/acasademont/wurfl/blob/0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2/WURFL/WURFLManagerFactory.php#L103-L110
|
acasademont/wurfl
|
WURFL/WURFLManagerFactory.php
|
WURFL_WURFLManagerFactory.init
|
private function init()
{
$logger = null; //$this->logger($wurflConfig->logger);
$context = new WURFL_Context($this->persistenceStorage, $this->cacheStorage, $logger);
$userAgentHandlerChain = WURFL_UserAgentHandlerChainFactory::createFrom($context);
$deviceRepository = $this->deviceRepository($this->persistenceStorage, $userAgentHandlerChain);
$wurflService = new WURFL_WURFLService($deviceRepository, $userAgentHandlerChain, $this->cacheStorage);
$requestFactory = new WURFL_Request_GenericRequestFactory();
$this->wurflManager = new WURFL_WURFLManager($wurflService, $requestFactory);
}
|
php
|
private function init()
{
$logger = null; //$this->logger($wurflConfig->logger);
$context = new WURFL_Context($this->persistenceStorage, $this->cacheStorage, $logger);
$userAgentHandlerChain = WURFL_UserAgentHandlerChainFactory::createFrom($context);
$deviceRepository = $this->deviceRepository($this->persistenceStorage, $userAgentHandlerChain);
$wurflService = new WURFL_WURFLService($deviceRepository, $userAgentHandlerChain, $this->cacheStorage);
$requestFactory = new WURFL_Request_GenericRequestFactory();
$this->wurflManager = new WURFL_WURFLManager($wurflService, $requestFactory);
}
|
[
"private",
"function",
"init",
"(",
")",
"{",
"$",
"logger",
"=",
"null",
";",
"//$this->logger($wurflConfig->logger);",
"$",
"context",
"=",
"new",
"WURFL_Context",
"(",
"$",
"this",
"->",
"persistenceStorage",
",",
"$",
"this",
"->",
"cacheStorage",
",",
"$",
"logger",
")",
";",
"$",
"userAgentHandlerChain",
"=",
"WURFL_UserAgentHandlerChainFactory",
"::",
"createFrom",
"(",
"$",
"context",
")",
";",
"$",
"deviceRepository",
"=",
"$",
"this",
"->",
"deviceRepository",
"(",
"$",
"this",
"->",
"persistenceStorage",
",",
"$",
"userAgentHandlerChain",
")",
";",
"$",
"wurflService",
"=",
"new",
"WURFL_WURFLService",
"(",
"$",
"deviceRepository",
",",
"$",
"userAgentHandlerChain",
",",
"$",
"this",
"->",
"cacheStorage",
")",
";",
"$",
"requestFactory",
"=",
"new",
"WURFL_Request_GenericRequestFactory",
"(",
")",
";",
"$",
"this",
"->",
"wurflManager",
"=",
"new",
"WURFL_WURFLManager",
"(",
"$",
"wurflService",
",",
"$",
"requestFactory",
")",
";",
"}"
] |
Initializes the WURFL Manager Factory by assigning cache and persistence providers
|
[
"Initializes",
"the",
"WURFL",
"Manager",
"Factory",
"by",
"assigning",
"cache",
"and",
"persistence",
"providers"
] |
train
|
https://github.com/acasademont/wurfl/blob/0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2/WURFL/WURFLManagerFactory.php#L155-L164
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.