id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
221,600
|
radphp/radphp
|
src/Network/Session/Flash/FlashBag.php
|
FlashBag.getSessionBag
|
public function getSessionBag()
{
if (null === $this->sessionBag) {
if (!$this->container) {
throw new Exception('A container object is required to access the \'session_bag\' service.');
}
$this->sessionBag = $this->container->get('session_bag', [$this->bagName]);
}
return $this->sessionBag;
}
|
php
|
public function getSessionBag()
{
if (null === $this->sessionBag) {
if (!$this->container) {
throw new Exception('A container object is required to access the \'session_bag\' service.');
}
$this->sessionBag = $this->container->get('session_bag', [$this->bagName]);
}
return $this->sessionBag;
}
|
[
"public",
"function",
"getSessionBag",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"sessionBag",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"container",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'A container object is required to access the \\'session_bag\\' service.'",
")",
";",
"}",
"$",
"this",
"->",
"sessionBag",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'session_bag'",
",",
"[",
"$",
"this",
"->",
"bagName",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"sessionBag",
";",
"}"
] |
Get session bag
@throws Exception
@throws \Rad\DependencyInjection\Exception\ServiceNotFoundException
@return SessionBag
|
[
"Get",
"session",
"bag"
] |
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
|
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/Network/Session/Flash/FlashBag.php#L69-L80
|
221,601
|
radphp/radphp
|
src/Network/Session/Flash/FlashBag.php
|
FlashBag.get
|
public function get($type, array $default = [], $remove = true)
{
if ($this->has($type)) {
if (true === $remove) {
unset($this->messages[$type]);
}
return $this->messages[$type];
}
return $default;
}
|
php
|
public function get($type, array $default = [], $remove = true)
{
if ($this->has($type)) {
if (true === $remove) {
unset($this->messages[$type]);
}
return $this->messages[$type];
}
return $default;
}
|
[
"public",
"function",
"get",
"(",
"$",
"type",
",",
"array",
"$",
"default",
"=",
"[",
"]",
",",
"$",
"remove",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"type",
")",
")",
"{",
"if",
"(",
"true",
"===",
"$",
"remove",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"messages",
"[",
"$",
"type",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"messages",
"[",
"$",
"type",
"]",
";",
"}",
"return",
"$",
"default",
";",
"}"
] |
Peek type messages
@param string $type
@param array $default
@param bool $remove
@return array
|
[
"Peek",
"type",
"messages"
] |
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
|
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/Network/Session/Flash/FlashBag.php#L143-L154
|
221,602
|
radphp/radphp
|
src/Network/Session/Flash/FlashBag.php
|
FlashBag.getAll
|
public function getAll($remove = true)
{
$output = $this->messages;
if (true === $remove) {
$this->clear();
}
return $output;
}
|
php
|
public function getAll($remove = true)
{
$output = $this->messages;
if (true === $remove) {
$this->clear();
}
return $output;
}
|
[
"public",
"function",
"getAll",
"(",
"$",
"remove",
"=",
"true",
")",
"{",
"$",
"output",
"=",
"$",
"this",
"->",
"messages",
";",
"if",
"(",
"true",
"===",
"$",
"remove",
")",
"{",
"$",
"this",
"->",
"clear",
"(",
")",
";",
"}",
"return",
"$",
"output",
";",
"}"
] |
Get all messages and remove theirs
@param bool $remove Remove all messages
@return array
|
[
"Get",
"all",
"messages",
"and",
"remove",
"theirs"
] |
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
|
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/Network/Session/Flash/FlashBag.php#L163-L171
|
221,603
|
neos/fluid
|
Classes/TYPO3/Fluid/Core/ViewHelper/TagBuilder.php
|
TagBuilder.reset
|
public function reset()
{
$this->tagName = '';
$this->content = '';
$this->attributes = array();
$this->forceClosingTag = false;
}
|
php
|
public function reset()
{
$this->tagName = '';
$this->content = '';
$this->attributes = array();
$this->forceClosingTag = false;
}
|
[
"public",
"function",
"reset",
"(",
")",
"{",
"$",
"this",
"->",
"tagName",
"=",
"''",
";",
"$",
"this",
"->",
"content",
"=",
"''",
";",
"$",
"this",
"->",
"attributes",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"forceClosingTag",
"=",
"false",
";",
"}"
] |
Resets the TagBuilder by setting all members to their default value
@return void
@api
|
[
"Resets",
"the",
"TagBuilder",
"by",
"setting",
"all",
"members",
"to",
"their",
"default",
"value"
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/ViewHelper/TagBuilder.php#L223-L229
|
221,604
|
neos/fluid
|
Classes/TYPO3/Fluid/Core/ViewHelper/TagBuilder.php
|
TagBuilder.render
|
public function render()
{
if (empty($this->tagName)) {
return '';
}
$output = '<' . $this->tagName;
foreach ($this->attributes as $attributeName => $attributeValue) {
$output .= ' ' . $attributeName . '="' . $attributeValue . '"';
}
if ($this->hasContent() || $this->forceClosingTag) {
$output .= '>' . $this->content . '</' . $this->tagName . '>';
} else {
$output .= ' />';
}
return $output;
}
|
php
|
public function render()
{
if (empty($this->tagName)) {
return '';
}
$output = '<' . $this->tagName;
foreach ($this->attributes as $attributeName => $attributeValue) {
$output .= ' ' . $attributeName . '="' . $attributeValue . '"';
}
if ($this->hasContent() || $this->forceClosingTag) {
$output .= '>' . $this->content . '</' . $this->tagName . '>';
} else {
$output .= ' />';
}
return $output;
}
|
[
"public",
"function",
"render",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"tagName",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"output",
"=",
"'<'",
".",
"$",
"this",
"->",
"tagName",
";",
"foreach",
"(",
"$",
"this",
"->",
"attributes",
"as",
"$",
"attributeName",
"=>",
"$",
"attributeValue",
")",
"{",
"$",
"output",
".=",
"' '",
".",
"$",
"attributeName",
".",
"'=\"'",
".",
"$",
"attributeValue",
".",
"'\"'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"hasContent",
"(",
")",
"||",
"$",
"this",
"->",
"forceClosingTag",
")",
"{",
"$",
"output",
".=",
"'>'",
".",
"$",
"this",
"->",
"content",
".",
"'</'",
".",
"$",
"this",
"->",
"tagName",
".",
"'>'",
";",
"}",
"else",
"{",
"$",
"output",
".=",
"' />'",
";",
"}",
"return",
"$",
"output",
";",
"}"
] |
Renders and returns the tag
@return string
@api
|
[
"Renders",
"and",
"returns",
"the",
"tag"
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/ViewHelper/TagBuilder.php#L237-L252
|
221,605
|
neos/fluid
|
Classes/TYPO3/Fluid/Core/Parser/SyntaxTree/ArrayNode.php
|
ArrayNode.evaluate
|
public function evaluate(RenderingContextInterface $renderingContext)
{
$arrayToBuild = array();
foreach ($this->internalArray as $key => $value) {
if ($value instanceof AbstractNode) {
$arrayToBuild[$key] = $value->evaluate($renderingContext);
} else {
// TODO - this case should not happen!
$arrayToBuild[$key] = $value;
}
}
return $arrayToBuild;
}
|
php
|
public function evaluate(RenderingContextInterface $renderingContext)
{
$arrayToBuild = array();
foreach ($this->internalArray as $key => $value) {
if ($value instanceof AbstractNode) {
$arrayToBuild[$key] = $value->evaluate($renderingContext);
} else {
// TODO - this case should not happen!
$arrayToBuild[$key] = $value;
}
}
return $arrayToBuild;
}
|
[
"public",
"function",
"evaluate",
"(",
"RenderingContextInterface",
"$",
"renderingContext",
")",
"{",
"$",
"arrayToBuild",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"internalArray",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"AbstractNode",
")",
"{",
"$",
"arrayToBuild",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
"->",
"evaluate",
"(",
"$",
"renderingContext",
")",
";",
"}",
"else",
"{",
"// TODO - this case should not happen!",
"$",
"arrayToBuild",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"arrayToBuild",
";",
"}"
] |
Evaluate the array and return an evaluated array
@param RenderingContextInterface $renderingContext
@return array An associative array with literal values
|
[
"Evaluate",
"the",
"array",
"and",
"return",
"an",
"evaluated",
"array"
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/Parser/SyntaxTree/ArrayNode.php#L44-L56
|
221,606
|
radphp/radphp
|
src/OAuthentication/Provider/GithubProvider.php
|
GithubProvider.getEmail
|
protected function getEmail($token)
{
if (in_array(self::SCOPE_USER_EMAIL, $this->getScopes())) {
$request = new Request(self::USER_API_URI . '/emails?access_token=' . $token, Request::METHOD_GET);
$request = $this->request($request);
$client = new Curl();
$response = $client->send($request);
$result = json_decode($response->getBody()->getContents(), true);
if ($response->getStatusCode() !== 200) {
throw new Exception(
sprintf(
'%s (%s)',
$result['message'],
$result['documentation_url']
)
);
}
foreach ($result as $email) {
if ($email['primary'] && $email['verified']) {
return $email['email'];
}
}
}
return null;
}
|
php
|
protected function getEmail($token)
{
if (in_array(self::SCOPE_USER_EMAIL, $this->getScopes())) {
$request = new Request(self::USER_API_URI . '/emails?access_token=' . $token, Request::METHOD_GET);
$request = $this->request($request);
$client = new Curl();
$response = $client->send($request);
$result = json_decode($response->getBody()->getContents(), true);
if ($response->getStatusCode() !== 200) {
throw new Exception(
sprintf(
'%s (%s)',
$result['message'],
$result['documentation_url']
)
);
}
foreach ($result as $email) {
if ($email['primary'] && $email['verified']) {
return $email['email'];
}
}
}
return null;
}
|
[
"protected",
"function",
"getEmail",
"(",
"$",
"token",
")",
"{",
"if",
"(",
"in_array",
"(",
"self",
"::",
"SCOPE_USER_EMAIL",
",",
"$",
"this",
"->",
"getScopes",
"(",
")",
")",
")",
"{",
"$",
"request",
"=",
"new",
"Request",
"(",
"self",
"::",
"USER_API_URI",
".",
"'/emails?access_token='",
".",
"$",
"token",
",",
"Request",
"::",
"METHOD_GET",
")",
";",
"$",
"request",
"=",
"$",
"this",
"->",
"request",
"(",
"$",
"request",
")",
";",
"$",
"client",
"=",
"new",
"Curl",
"(",
")",
";",
"$",
"response",
"=",
"$",
"client",
"->",
"send",
"(",
"$",
"request",
")",
";",
"$",
"result",
"=",
"json_decode",
"(",
"$",
"response",
"->",
"getBody",
"(",
")",
"->",
"getContents",
"(",
")",
",",
"true",
")",
";",
"if",
"(",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
"!==",
"200",
")",
"{",
"throw",
"new",
"Exception",
"(",
"sprintf",
"(",
"'%s (%s)'",
",",
"$",
"result",
"[",
"'message'",
"]",
",",
"$",
"result",
"[",
"'documentation_url'",
"]",
")",
")",
";",
"}",
"foreach",
"(",
"$",
"result",
"as",
"$",
"email",
")",
"{",
"if",
"(",
"$",
"email",
"[",
"'primary'",
"]",
"&&",
"$",
"email",
"[",
"'verified'",
"]",
")",
"{",
"return",
"$",
"email",
"[",
"'email'",
"]",
";",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] |
Get user email
@param string $token Access token
@return null|string
@throws Exception
|
[
"Get",
"user",
"email"
] |
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
|
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/OAuthentication/Provider/GithubProvider.php#L247-L275
|
221,607
|
paquettg/leaguewrap
|
src/LeagueWrap/Dto/Game.php
|
Game.player
|
public function player($playerId)
{
if ( ! isset($this->info['fellowPlayers']))
{
// no players
return null;
}
$players = $this->info['fellowPlayers'];
if (isset($players[$playerId]))
{
return $players[$playerId];
}
return null;
}
|
php
|
public function player($playerId)
{
if ( ! isset($this->info['fellowPlayers']))
{
// no players
return null;
}
$players = $this->info['fellowPlayers'];
if (isset($players[$playerId]))
{
return $players[$playerId];
}
return null;
}
|
[
"public",
"function",
"player",
"(",
"$",
"playerId",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"info",
"[",
"'fellowPlayers'",
"]",
")",
")",
"{",
"// no players",
"return",
"null",
";",
"}",
"$",
"players",
"=",
"$",
"this",
"->",
"info",
"[",
"'fellowPlayers'",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"players",
"[",
"$",
"playerId",
"]",
")",
")",
"{",
"return",
"$",
"players",
"[",
"$",
"playerId",
"]",
";",
"}",
"return",
"null",
";",
"}"
] |
Attempts to get a fellow player from this game.
@param int $playerId
@return Player|null
|
[
"Attempts",
"to",
"get",
"a",
"fellow",
"player",
"from",
"this",
"game",
"."
] |
0f91813b5d8292054e5e13619d591b6b14dc63e6
|
https://github.com/paquettg/leaguewrap/blob/0f91813b5d8292054e5e13619d591b6b14dc63e6/src/LeagueWrap/Dto/Game.php#L53-L67
|
221,608
|
thiagof/laravelrpc
|
src/RpcClientWrapper.php
|
RpcClientWrapper.connection_init
|
private function connection_init()
{
$opts = $this->config;
// Headers format
$headers = [];
foreach ($opts['headers'] as $key => $value)
$headers[] = "$key: $value";
$connection = new JsonRPC\Client($opts['url'], $opts['timeout'], $headers);
$connection->ssl_verify_peer = $opts['ssl_verify_peer'];
$connection->debug = $opts['debug'];
$connection->named_arguments = isset($opts['named_arguments']) && $opts['named_arguments']===true;
if (isset($opts['username']) && $opts['username']) {
$connection->authentication($opts['username'], $opts['password']);
}
return $connection;
}
|
php
|
private function connection_init()
{
$opts = $this->config;
// Headers format
$headers = [];
foreach ($opts['headers'] as $key => $value)
$headers[] = "$key: $value";
$connection = new JsonRPC\Client($opts['url'], $opts['timeout'], $headers);
$connection->ssl_verify_peer = $opts['ssl_verify_peer'];
$connection->debug = $opts['debug'];
$connection->named_arguments = isset($opts['named_arguments']) && $opts['named_arguments']===true;
if (isset($opts['username']) && $opts['username']) {
$connection->authentication($opts['username'], $opts['password']);
}
return $connection;
}
|
[
"private",
"function",
"connection_init",
"(",
")",
"{",
"$",
"opts",
"=",
"$",
"this",
"->",
"config",
";",
"// Headers format",
"$",
"headers",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"opts",
"[",
"'headers'",
"]",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"$",
"headers",
"[",
"]",
"=",
"\"$key: $value\"",
";",
"$",
"connection",
"=",
"new",
"JsonRPC",
"\\",
"Client",
"(",
"$",
"opts",
"[",
"'url'",
"]",
",",
"$",
"opts",
"[",
"'timeout'",
"]",
",",
"$",
"headers",
")",
";",
"$",
"connection",
"->",
"ssl_verify_peer",
"=",
"$",
"opts",
"[",
"'ssl_verify_peer'",
"]",
";",
"$",
"connection",
"->",
"debug",
"=",
"$",
"opts",
"[",
"'debug'",
"]",
";",
"$",
"connection",
"->",
"named_arguments",
"=",
"isset",
"(",
"$",
"opts",
"[",
"'named_arguments'",
"]",
")",
"&&",
"$",
"opts",
"[",
"'named_arguments'",
"]",
"===",
"true",
";",
"if",
"(",
"isset",
"(",
"$",
"opts",
"[",
"'username'",
"]",
")",
"&&",
"$",
"opts",
"[",
"'username'",
"]",
")",
"{",
"$",
"connection",
"->",
"authentication",
"(",
"$",
"opts",
"[",
"'username'",
"]",
",",
"$",
"opts",
"[",
"'password'",
"]",
")",
";",
"}",
"return",
"$",
"connection",
";",
"}"
] |
Inits Client Connection based on instance params
@return JsonRPC\Client
|
[
"Inits",
"Client",
"Connection",
"based",
"on",
"instance",
"params"
] |
a6634abec6e299c6b91835f1c46481afedf3c4bc
|
https://github.com/thiagof/laravelrpc/blob/a6634abec6e299c6b91835f1c46481afedf3c4bc/src/RpcClientWrapper.php#L45-L65
|
221,609
|
thiagof/laravelrpc
|
src/RpcClientWrapper.php
|
RpcClientWrapper.request
|
protected function request($method, $params)
{
Log::debug('RpcClient call', ['method'=>$method, 'params'=>$params, 'config'=>$this->config]);
return call_user_func_array(
[$this->connection(), 'execute'],
[$method,$params]
);
}
|
php
|
protected function request($method, $params)
{
Log::debug('RpcClient call', ['method'=>$method, 'params'=>$params, 'config'=>$this->config]);
return call_user_func_array(
[$this->connection(), 'execute'],
[$method,$params]
);
}
|
[
"protected",
"function",
"request",
"(",
"$",
"method",
",",
"$",
"params",
")",
"{",
"Log",
"::",
"debug",
"(",
"'RpcClient call'",
",",
"[",
"'method'",
"=>",
"$",
"method",
",",
"'params'",
"=>",
"$",
"params",
",",
"'config'",
"=>",
"$",
"this",
"->",
"config",
"]",
")",
";",
"return",
"call_user_func_array",
"(",
"[",
"$",
"this",
"->",
"connection",
"(",
")",
",",
"'execute'",
"]",
",",
"[",
"$",
"method",
",",
"$",
"params",
"]",
")",
";",
"}"
] |
Execute a remote method
@param string $method Remote method
@param array $params Params to be run
@return mixed Response from remote execution
|
[
"Execute",
"a",
"remote",
"method"
] |
a6634abec6e299c6b91835f1c46481afedf3c4bc
|
https://github.com/thiagof/laravelrpc/blob/a6634abec6e299c6b91835f1c46481afedf3c4bc/src/RpcClientWrapper.php#L73-L81
|
221,610
|
radphp/radphp
|
src/DependencyInjection/Registry.php
|
Registry.set
|
public static function set($key, $value, $scope = self::DEFAULT_SCOPE)
{
self::$storage[$scope][$key] = $value;
}
|
php
|
public static function set($key, $value, $scope = self::DEFAULT_SCOPE)
{
self::$storage[$scope][$key] = $value;
}
|
[
"public",
"static",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"scope",
"=",
"self",
"::",
"DEFAULT_SCOPE",
")",
"{",
"self",
"::",
"$",
"storage",
"[",
"$",
"scope",
"]",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}"
] |
Store key in registry
@param string $key
@param mixed $value
@param string $scope
|
[
"Store",
"key",
"in",
"registry"
] |
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
|
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/DependencyInjection/Registry.php#L27-L30
|
221,611
|
radphp/radphp
|
src/DependencyInjection/Registry.php
|
Registry.get
|
public static function get($key, $scope = self::DEFAULT_SCOPE)
{
if (isset(self::$storage[$scope][$key])) {
return self::$storage[$scope][$key];
}
return null;
}
|
php
|
public static function get($key, $scope = self::DEFAULT_SCOPE)
{
if (isset(self::$storage[$scope][$key])) {
return self::$storage[$scope][$key];
}
return null;
}
|
[
"public",
"static",
"function",
"get",
"(",
"$",
"key",
",",
"$",
"scope",
"=",
"self",
"::",
"DEFAULT_SCOPE",
")",
"{",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"storage",
"[",
"$",
"scope",
"]",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"self",
"::",
"$",
"storage",
"[",
"$",
"scope",
"]",
"[",
"$",
"key",
"]",
";",
"}",
"return",
"null",
";",
"}"
] |
Get key from registry
@param string $key
@param string $scope
@return null
|
[
"Get",
"key",
"from",
"registry"
] |
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
|
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/DependencyInjection/Registry.php#L40-L47
|
221,612
|
radphp/radphp
|
src/DependencyInjection/Registry.php
|
Registry.has
|
public static function has($key, $scope = self::DEFAULT_SCOPE)
{
return isset(self::$storage[$scope][$key]);
}
|
php
|
public static function has($key, $scope = self::DEFAULT_SCOPE)
{
return isset(self::$storage[$scope][$key]);
}
|
[
"public",
"static",
"function",
"has",
"(",
"$",
"key",
",",
"$",
"scope",
"=",
"self",
"::",
"DEFAULT_SCOPE",
")",
"{",
"return",
"isset",
"(",
"self",
"::",
"$",
"storage",
"[",
"$",
"scope",
"]",
"[",
"$",
"key",
"]",
")",
";",
"}"
] |
Check key exist or not
@param string $key
@param string $scope
@return bool
|
[
"Check",
"key",
"exist",
"or",
"not"
] |
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
|
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/DependencyInjection/Registry.php#L57-L60
|
221,613
|
paquettg/leaguewrap
|
src/LeagueWrap/StaticOptimizer.php
|
StaticOptimizer.setStaticInfo
|
public function setStaticInfo(Staticdata $staticData)
{
$results = [];
foreach ($this->requests as $source => $ids)
{
$result = [];
$method = 'get'.ucfirst($source);
if (count($ids) > 1)
{
// group up the calls
if (preg_match('/(?<![aeiou])y$/', $method))
{
// if last char is 'y' preceeded by a vowel replace for plural
$method = substr($method, 0, -1).'ie';
}
$method .= 's';
$data = $staticData->$method();
foreach ($ids as $id)
{
$result[$id] = $data[$id];
}
}
else
{
$id = reset($ids);
$data = $staticData->$method($id);
$result[$id] = $data;
}
$results[$source] = $result;
}
$this->results = $results;
}
|
php
|
public function setStaticInfo(Staticdata $staticData)
{
$results = [];
foreach ($this->requests as $source => $ids)
{
$result = [];
$method = 'get'.ucfirst($source);
if (count($ids) > 1)
{
// group up the calls
if (preg_match('/(?<![aeiou])y$/', $method))
{
// if last char is 'y' preceeded by a vowel replace for plural
$method = substr($method, 0, -1).'ie';
}
$method .= 's';
$data = $staticData->$method();
foreach ($ids as $id)
{
$result[$id] = $data[$id];
}
}
else
{
$id = reset($ids);
$data = $staticData->$method($id);
$result[$id] = $data;
}
$results[$source] = $result;
}
$this->results = $results;
}
|
[
"public",
"function",
"setStaticInfo",
"(",
"Staticdata",
"$",
"staticData",
")",
"{",
"$",
"results",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"requests",
"as",
"$",
"source",
"=>",
"$",
"ids",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"$",
"method",
"=",
"'get'",
".",
"ucfirst",
"(",
"$",
"source",
")",
";",
"if",
"(",
"count",
"(",
"$",
"ids",
")",
">",
"1",
")",
"{",
"// group up the calls\r",
"if",
"(",
"preg_match",
"(",
"'/(?<![aeiou])y$/'",
",",
"$",
"method",
")",
")",
"{",
"// if last char is 'y' preceeded by a vowel replace for plural\r",
"$",
"method",
"=",
"substr",
"(",
"$",
"method",
",",
"0",
",",
"-",
"1",
")",
".",
"'ie'",
";",
"}",
"$",
"method",
".=",
"'s'",
";",
"$",
"data",
"=",
"$",
"staticData",
"->",
"$",
"method",
"(",
")",
";",
"foreach",
"(",
"$",
"ids",
"as",
"$",
"id",
")",
"{",
"$",
"result",
"[",
"$",
"id",
"]",
"=",
"$",
"data",
"[",
"$",
"id",
"]",
";",
"}",
"}",
"else",
"{",
"$",
"id",
"=",
"reset",
"(",
"$",
"ids",
")",
";",
"$",
"data",
"=",
"$",
"staticData",
"->",
"$",
"method",
"(",
"$",
"id",
")",
";",
"$",
"result",
"[",
"$",
"id",
"]",
"=",
"$",
"data",
";",
"}",
"$",
"results",
"[",
"$",
"source",
"]",
"=",
"$",
"result",
";",
"}",
"$",
"this",
"->",
"results",
"=",
"$",
"results",
";",
"}"
] |
Uses the static api to get all the static information we need
that have already been optimized.
@param Staticdata $staticData
@return void
|
[
"Uses",
"the",
"static",
"api",
"to",
"get",
"all",
"the",
"static",
"information",
"we",
"need",
"that",
"have",
"already",
"been",
"optimized",
"."
] |
0f91813b5d8292054e5e13619d591b6b14dc63e6
|
https://github.com/paquettg/leaguewrap/blob/0f91813b5d8292054e5e13619d591b6b14dc63e6/src/LeagueWrap/StaticOptimizer.php#L68-L99
|
221,614
|
paquettg/leaguewrap
|
src/LeagueWrap/StaticOptimizer.php
|
StaticOptimizer.getDataFromHash
|
public function getDataFromHash($hash)
{
$data = [];
$fields = $this->fields[$hash];
foreach ($fields as $source => $ids)
{
$result = [];
$results = $this->results[$source];
foreach ($ids as $id)
{
$result[$id] = $results[$id];
}
$data[$source] = $result;
}
return $data;
}
|
php
|
public function getDataFromHash($hash)
{
$data = [];
$fields = $this->fields[$hash];
foreach ($fields as $source => $ids)
{
$result = [];
$results = $this->results[$source];
foreach ($ids as $id)
{
$result[$id] = $results[$id];
}
$data[$source] = $result;
}
return $data;
}
|
[
"public",
"function",
"getDataFromHash",
"(",
"$",
"hash",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"$",
"fields",
"=",
"$",
"this",
"->",
"fields",
"[",
"$",
"hash",
"]",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"source",
"=>",
"$",
"ids",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"$",
"results",
"=",
"$",
"this",
"->",
"results",
"[",
"$",
"source",
"]",
";",
"foreach",
"(",
"$",
"ids",
"as",
"$",
"id",
")",
"{",
"$",
"result",
"[",
"$",
"id",
"]",
"=",
"$",
"results",
"[",
"$",
"id",
"]",
";",
"}",
"$",
"data",
"[",
"$",
"source",
"]",
"=",
"$",
"result",
";",
"}",
"return",
"$",
"data",
";",
"}"
] |
Gets the result data array from the static api by
the given hash.
@param string $hash
@return array
|
[
"Gets",
"the",
"result",
"data",
"array",
"from",
"the",
"static",
"api",
"by",
"the",
"given",
"hash",
"."
] |
0f91813b5d8292054e5e13619d591b6b14dc63e6
|
https://github.com/paquettg/leaguewrap/blob/0f91813b5d8292054e5e13619d591b6b14dc63e6/src/LeagueWrap/StaticOptimizer.php#L108-L124
|
221,615
|
ThibaudDauce/mattermost-php
|
src/Attachment.php
|
Attachment.field
|
public function field($title, $value, $short = true)
{
$this->fields[] = [
'title' => (string) $title,
'value' => $value,
'short' => $short,
];
return $this;
}
|
php
|
public function field($title, $value, $short = true)
{
$this->fields[] = [
'title' => (string) $title,
'value' => $value,
'short' => $short,
];
return $this;
}
|
[
"public",
"function",
"field",
"(",
"$",
"title",
",",
"$",
"value",
",",
"$",
"short",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"fields",
"[",
"]",
"=",
"[",
"'title'",
"=>",
"(",
"string",
")",
"$",
"title",
",",
"'value'",
"=>",
"$",
"value",
",",
"'short'",
"=>",
"$",
"short",
",",
"]",
";",
"return",
"$",
"this",
";",
"}"
] |
Add a field to the attachment
@param string $title A title shown in the table above the value.
@param string $value The text value of the field. It can be formatted using markdown.
@param bool $short Optionally set to “True” or “False” to indicate whether the value is short enough to be displayed beside other values.
@return $this
|
[
"Add",
"a",
"field",
"to",
"the",
"attachment"
] |
7542208205ba160589f54cd8636cbba6fee29a37
|
https://github.com/ThibaudDauce/mattermost-php/blob/7542208205ba160589f54cd8636cbba6fee29a37/src/Attachment.php#L253-L262
|
221,616
|
neos/fluid
|
Classes/TYPO3/Fluid/Core/Widget/AbstractWidgetViewHelper.php
|
AbstractWidgetViewHelper.resetState
|
public function resetState()
{
if ($this->ajaxWidget) {
$this->widgetContext = $this->objectManager->get(\TYPO3\Fluid\Core\Widget\WidgetContext::class);
}
}
|
php
|
public function resetState()
{
if ($this->ajaxWidget) {
$this->widgetContext = $this->objectManager->get(\TYPO3\Fluid\Core\Widget\WidgetContext::class);
}
}
|
[
"public",
"function",
"resetState",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"ajaxWidget",
")",
"{",
"$",
"this",
"->",
"widgetContext",
"=",
"$",
"this",
"->",
"objectManager",
"->",
"get",
"(",
"\\",
"TYPO3",
"\\",
"Fluid",
"\\",
"Core",
"\\",
"Widget",
"\\",
"WidgetContext",
"::",
"class",
")",
";",
"}",
"}"
] |
Resets the ViewHelper state by creating a fresh WidgetContext
@return void
|
[
"Resets",
"the",
"ViewHelper",
"state",
"by",
"creating",
"a",
"fresh",
"WidgetContext"
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/Widget/AbstractWidgetViewHelper.php#L288-L293
|
221,617
|
neos/fluid
|
Classes/TYPO3/Fluid/Core/ViewHelper/ViewHelperVariableContainer.php
|
ViewHelperVariableContainer.get
|
public function get($viewHelperName, $key)
{
if (!$this->exists($viewHelperName, $key)) {
throw new InvalidVariableException(sprintf('No value found for key "%s->%s"', $viewHelperName, $key), 1243325768);
}
return $this->objects[$viewHelperName][$key];
}
|
php
|
public function get($viewHelperName, $key)
{
if (!$this->exists($viewHelperName, $key)) {
throw new InvalidVariableException(sprintf('No value found for key "%s->%s"', $viewHelperName, $key), 1243325768);
}
return $this->objects[$viewHelperName][$key];
}
|
[
"public",
"function",
"get",
"(",
"$",
"viewHelperName",
",",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"exists",
"(",
"$",
"viewHelperName",
",",
"$",
"key",
")",
")",
"{",
"throw",
"new",
"InvalidVariableException",
"(",
"sprintf",
"(",
"'No value found for key \"%s->%s\"'",
",",
"$",
"viewHelperName",
",",
"$",
"key",
")",
",",
"1243325768",
")",
";",
"}",
"return",
"$",
"this",
"->",
"objects",
"[",
"$",
"viewHelperName",
"]",
"[",
"$",
"key",
"]",
";",
"}"
] |
Gets a variable which is stored
@param string $viewHelperName The ViewHelper Class name (Fully qualified, like "TYPO3\Fluid\ViewHelpers\ForViewHelper")
@param string $key Key of the data
@return mixed The object stored
@throws InvalidVariableException if there was no key with the specified name
@api
|
[
"Gets",
"a",
"variable",
"which",
"is",
"stored"
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/ViewHelper/ViewHelperVariableContainer.php#L86-L92
|
221,618
|
neos/fluid
|
Classes/TYPO3/Fluid/Core/ViewHelper/ViewHelperVariableContainer.php
|
ViewHelperVariableContainer.exists
|
public function exists($viewHelperName, $key)
{
return isset($this->objects[$viewHelperName]) && array_key_exists($key, $this->objects[$viewHelperName]);
}
|
php
|
public function exists($viewHelperName, $key)
{
return isset($this->objects[$viewHelperName]) && array_key_exists($key, $this->objects[$viewHelperName]);
}
|
[
"public",
"function",
"exists",
"(",
"$",
"viewHelperName",
",",
"$",
"key",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"objects",
"[",
"$",
"viewHelperName",
"]",
")",
"&&",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"objects",
"[",
"$",
"viewHelperName",
"]",
")",
";",
"}"
] |
Determine whether there is a variable stored for the given key
@param string $viewHelperName The ViewHelper Class name (Fully qualified, like "TYPO3\Fluid\ViewHelpers\ForViewHelper")
@param string $key Key of the data
@return boolean TRUE if a value for the given ViewHelperName / Key is stored, FALSE otherwise.
@api
|
[
"Determine",
"whether",
"there",
"is",
"a",
"variable",
"stored",
"for",
"the",
"given",
"key"
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/ViewHelper/ViewHelperVariableContainer.php#L102-L105
|
221,619
|
neos/fluid
|
Classes/TYPO3/Fluid/Core/ViewHelper/ViewHelperVariableContainer.php
|
ViewHelperVariableContainer.remove
|
public function remove($viewHelperName, $key)
{
if (!$this->exists($viewHelperName, $key)) {
throw new InvalidVariableException(sprintf('No value found for key "%s->%s", thus the key cannot be removed.', $viewHelperName, $key), 1243352249);
}
unset($this->objects[$viewHelperName][$key]);
}
|
php
|
public function remove($viewHelperName, $key)
{
if (!$this->exists($viewHelperName, $key)) {
throw new InvalidVariableException(sprintf('No value found for key "%s->%s", thus the key cannot be removed.', $viewHelperName, $key), 1243352249);
}
unset($this->objects[$viewHelperName][$key]);
}
|
[
"public",
"function",
"remove",
"(",
"$",
"viewHelperName",
",",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"exists",
"(",
"$",
"viewHelperName",
",",
"$",
"key",
")",
")",
"{",
"throw",
"new",
"InvalidVariableException",
"(",
"sprintf",
"(",
"'No value found for key \"%s->%s\", thus the key cannot be removed.'",
",",
"$",
"viewHelperName",
",",
"$",
"key",
")",
",",
"1243352249",
")",
";",
"}",
"unset",
"(",
"$",
"this",
"->",
"objects",
"[",
"$",
"viewHelperName",
"]",
"[",
"$",
"key",
"]",
")",
";",
"}"
] |
Remove a value from the variable container
@param string $viewHelperName The ViewHelper Class name (Fully qualified, like "TYPO3\Fluid\ViewHelpers\ForViewHelper")
@param string $key Key of the data to remove
@return void
@throws InvalidVariableException if there was no key with the specified name
@api
|
[
"Remove",
"a",
"value",
"from",
"the",
"variable",
"container"
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/ViewHelper/ViewHelperVariableContainer.php#L116-L122
|
221,620
|
neos/fluid
|
Classes/TYPO3/Fluid/Core/Parser/Interceptor/Escape.php
|
Escape.process
|
public function process(NodeInterface $node, $interceptorPosition, ParsingState $parsingState)
{
if ($interceptorPosition === InterceptorInterface::INTERCEPT_OPENING_VIEWHELPER) {
/** @var $node ViewHelperNode */
if (!$node->getUninitializedViewHelper()->isChildrenEscapingEnabled()) {
$this->childrenEscapingEnabled = false;
$this->viewHelperNodesWhichDisableTheInterceptor[] = $node;
}
} elseif ($interceptorPosition === InterceptorInterface::INTERCEPT_CLOSING_VIEWHELPER) {
if (end($this->viewHelperNodesWhichDisableTheInterceptor) === $node) {
array_pop($this->viewHelperNodesWhichDisableTheInterceptor);
if (count($this->viewHelperNodesWhichDisableTheInterceptor) === 0) {
$this->childrenEscapingEnabled = true;
}
}
/** @var $node ViewHelperNode */
if ($this->childrenEscapingEnabled && $node->getUninitializedViewHelper()->isOutputEscapingEnabled()) {
$node = $this->wrapNode($node);
}
} elseif ($this->childrenEscapingEnabled && $node instanceof ObjectAccessorNode) {
$node = $this->wrapNode($node);
}
return $node;
}
|
php
|
public function process(NodeInterface $node, $interceptorPosition, ParsingState $parsingState)
{
if ($interceptorPosition === InterceptorInterface::INTERCEPT_OPENING_VIEWHELPER) {
/** @var $node ViewHelperNode */
if (!$node->getUninitializedViewHelper()->isChildrenEscapingEnabled()) {
$this->childrenEscapingEnabled = false;
$this->viewHelperNodesWhichDisableTheInterceptor[] = $node;
}
} elseif ($interceptorPosition === InterceptorInterface::INTERCEPT_CLOSING_VIEWHELPER) {
if (end($this->viewHelperNodesWhichDisableTheInterceptor) === $node) {
array_pop($this->viewHelperNodesWhichDisableTheInterceptor);
if (count($this->viewHelperNodesWhichDisableTheInterceptor) === 0) {
$this->childrenEscapingEnabled = true;
}
}
/** @var $node ViewHelperNode */
if ($this->childrenEscapingEnabled && $node->getUninitializedViewHelper()->isOutputEscapingEnabled()) {
$node = $this->wrapNode($node);
}
} elseif ($this->childrenEscapingEnabled && $node instanceof ObjectAccessorNode) {
$node = $this->wrapNode($node);
}
return $node;
}
|
[
"public",
"function",
"process",
"(",
"NodeInterface",
"$",
"node",
",",
"$",
"interceptorPosition",
",",
"ParsingState",
"$",
"parsingState",
")",
"{",
"if",
"(",
"$",
"interceptorPosition",
"===",
"InterceptorInterface",
"::",
"INTERCEPT_OPENING_VIEWHELPER",
")",
"{",
"/** @var $node ViewHelperNode */",
"if",
"(",
"!",
"$",
"node",
"->",
"getUninitializedViewHelper",
"(",
")",
"->",
"isChildrenEscapingEnabled",
"(",
")",
")",
"{",
"$",
"this",
"->",
"childrenEscapingEnabled",
"=",
"false",
";",
"$",
"this",
"->",
"viewHelperNodesWhichDisableTheInterceptor",
"[",
"]",
"=",
"$",
"node",
";",
"}",
"}",
"elseif",
"(",
"$",
"interceptorPosition",
"===",
"InterceptorInterface",
"::",
"INTERCEPT_CLOSING_VIEWHELPER",
")",
"{",
"if",
"(",
"end",
"(",
"$",
"this",
"->",
"viewHelperNodesWhichDisableTheInterceptor",
")",
"===",
"$",
"node",
")",
"{",
"array_pop",
"(",
"$",
"this",
"->",
"viewHelperNodesWhichDisableTheInterceptor",
")",
";",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"viewHelperNodesWhichDisableTheInterceptor",
")",
"===",
"0",
")",
"{",
"$",
"this",
"->",
"childrenEscapingEnabled",
"=",
"true",
";",
"}",
"}",
"/** @var $node ViewHelperNode */",
"if",
"(",
"$",
"this",
"->",
"childrenEscapingEnabled",
"&&",
"$",
"node",
"->",
"getUninitializedViewHelper",
"(",
")",
"->",
"isOutputEscapingEnabled",
"(",
")",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"wrapNode",
"(",
"$",
"node",
")",
";",
"}",
"}",
"elseif",
"(",
"$",
"this",
"->",
"childrenEscapingEnabled",
"&&",
"$",
"node",
"instanceof",
"ObjectAccessorNode",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"wrapNode",
"(",
"$",
"node",
")",
";",
"}",
"return",
"$",
"node",
";",
"}"
] |
Adds a ViewHelper node using the Format\HtmlspecialcharsViewHelper to the given node.
If "escapingInterceptorEnabled" in the ViewHelper is FALSE, will disable itself inside the ViewHelpers body.
@param NodeInterface $node
@param integer $interceptorPosition One of the INTERCEPT_* constants for the current interception point
@param ParsingState $parsingState the current parsing state. Not needed in this interceptor.
@return NodeInterface
|
[
"Adds",
"a",
"ViewHelper",
"node",
"using",
"the",
"Format",
"\\",
"HtmlspecialcharsViewHelper",
"to",
"the",
"given",
"node",
".",
"If",
"escapingInterceptorEnabled",
"in",
"the",
"ViewHelper",
"is",
"FALSE",
"will",
"disable",
"itself",
"inside",
"the",
"ViewHelpers",
"body",
"."
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/Parser/Interceptor/Escape.php#L66-L89
|
221,621
|
twizoapi/lib-api-php
|
src/Entity/Application/VerificationTypes.php
|
VerificationTypes.loadData
|
public function loadData()
{
$response = $this->sendApiCall(self::ACTION_RETRIEVE, $this->getCreateUrl());
$this->verificationTypes = $response->getBody();
}
|
php
|
public function loadData()
{
$response = $this->sendApiCall(self::ACTION_RETRIEVE, $this->getCreateUrl());
$this->verificationTypes = $response->getBody();
}
|
[
"public",
"function",
"loadData",
"(",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"sendApiCall",
"(",
"self",
"::",
"ACTION_RETRIEVE",
",",
"$",
"this",
"->",
"getCreateUrl",
"(",
")",
")",
";",
"$",
"this",
"->",
"verificationTypes",
"=",
"$",
"response",
"->",
"getBody",
"(",
")",
";",
"}"
] |
Load the balance data from the server
@throws Exception
|
[
"Load",
"the",
"balance",
"data",
"from",
"the",
"server"
] |
2e545d859784184138332c9b5bfc063940e3c926
|
https://github.com/twizoapi/lib-api-php/blob/2e545d859784184138332c9b5bfc063940e3c926/src/Entity/Application/VerificationTypes.php#L46-L50
|
221,622
|
neos/fluid
|
Classes/TYPO3/Fluid/Core/Compiler/TemplateCompiler.php
|
TemplateCompiler.convertViewHelperNode
|
protected function convertViewHelperNode(ViewHelperNode $node)
{
$initializationPhpCode = '// Rendering ViewHelper ' . $node->getViewHelperClassName() . chr(10);
// Build up $arguments array
$argumentsVariableName = $this->variableName('arguments');
$initializationPhpCode .= sprintf('%s = array();', $argumentsVariableName) . chr(10);
$alreadyBuiltArguments = array();
foreach ($node->getArguments() as $argumentName => $argumentValue) {
$converted = $this->convert($argumentValue);
$initializationPhpCode .= $converted['initialization'];
$initializationPhpCode .= sprintf('%s[\'%s\'] = %s;', $argumentsVariableName, $argumentName, $converted['execution']) . chr(10);
$alreadyBuiltArguments[$argumentName] = true;
}
/** @var $argumentDefinition ArgumentDefinition */
foreach ($node->getUninitializedViewHelper()->prepareArguments() as $argumentName => $argumentDefinition) {
if (!isset($alreadyBuiltArguments[$argumentName])) {
$initializationPhpCode .= sprintf('%s[\'%s\'] = %s;', $argumentsVariableName, $argumentName, var_export($argumentDefinition->getDefaultValue(), true)) . chr(10);
}
}
// Build up closure which renders the child nodes
$renderChildrenClosureVariableName = $this->variableName('renderChildrenClosure');
$initializationPhpCode .= sprintf('%s = %s;', $renderChildrenClosureVariableName, $this->wrapChildNodesInClosure($node)) . chr(10);
if ($node->getUninitializedViewHelper() instanceof CompilableInterface) {
// ViewHelper is compilable
$viewHelperInitializationPhpCode = '';
$convertedViewHelperExecutionCode = $node->getUninitializedViewHelper()->compile($argumentsVariableName, $renderChildrenClosureVariableName, $viewHelperInitializationPhpCode, $node, $this);
$initializationPhpCode .= $viewHelperInitializationPhpCode;
if ($convertedViewHelperExecutionCode !== self::SHOULD_GENERATE_VIEWHELPER_INVOCATION) {
return array(
'initialization' => $initializationPhpCode,
'execution' => $convertedViewHelperExecutionCode
);
}
}
// ViewHelper is not compilable, so we need to instanciate it directly and render it.
$viewHelperVariableName = $this->variableName('viewHelper');
$initializationPhpCode .= sprintf('%s = $self->getViewHelper(\'%s\', $renderingContext, \'%s\');', $viewHelperVariableName, $viewHelperVariableName, $node->getViewHelperClassName()) . chr(10);
$initializationPhpCode .= sprintf('%s->setArguments(%s);', $viewHelperVariableName, $argumentsVariableName) . chr(10);
$initializationPhpCode .= sprintf('%s->setRenderingContext($renderingContext);', $viewHelperVariableName) . chr(10);
$initializationPhpCode .= sprintf('%s->setRenderChildrenClosure(%s);', $viewHelperVariableName, $renderChildrenClosureVariableName) . chr(10);
$initializationPhpCode .= '// End of ViewHelper ' . $node->getViewHelperClassName() . chr(10);
return array(
'initialization' => $initializationPhpCode,
'execution' => sprintf('%s->initializeArgumentsAndRender()', $viewHelperVariableName)
);
}
|
php
|
protected function convertViewHelperNode(ViewHelperNode $node)
{
$initializationPhpCode = '// Rendering ViewHelper ' . $node->getViewHelperClassName() . chr(10);
// Build up $arguments array
$argumentsVariableName = $this->variableName('arguments');
$initializationPhpCode .= sprintf('%s = array();', $argumentsVariableName) . chr(10);
$alreadyBuiltArguments = array();
foreach ($node->getArguments() as $argumentName => $argumentValue) {
$converted = $this->convert($argumentValue);
$initializationPhpCode .= $converted['initialization'];
$initializationPhpCode .= sprintf('%s[\'%s\'] = %s;', $argumentsVariableName, $argumentName, $converted['execution']) . chr(10);
$alreadyBuiltArguments[$argumentName] = true;
}
/** @var $argumentDefinition ArgumentDefinition */
foreach ($node->getUninitializedViewHelper()->prepareArguments() as $argumentName => $argumentDefinition) {
if (!isset($alreadyBuiltArguments[$argumentName])) {
$initializationPhpCode .= sprintf('%s[\'%s\'] = %s;', $argumentsVariableName, $argumentName, var_export($argumentDefinition->getDefaultValue(), true)) . chr(10);
}
}
// Build up closure which renders the child nodes
$renderChildrenClosureVariableName = $this->variableName('renderChildrenClosure');
$initializationPhpCode .= sprintf('%s = %s;', $renderChildrenClosureVariableName, $this->wrapChildNodesInClosure($node)) . chr(10);
if ($node->getUninitializedViewHelper() instanceof CompilableInterface) {
// ViewHelper is compilable
$viewHelperInitializationPhpCode = '';
$convertedViewHelperExecutionCode = $node->getUninitializedViewHelper()->compile($argumentsVariableName, $renderChildrenClosureVariableName, $viewHelperInitializationPhpCode, $node, $this);
$initializationPhpCode .= $viewHelperInitializationPhpCode;
if ($convertedViewHelperExecutionCode !== self::SHOULD_GENERATE_VIEWHELPER_INVOCATION) {
return array(
'initialization' => $initializationPhpCode,
'execution' => $convertedViewHelperExecutionCode
);
}
}
// ViewHelper is not compilable, so we need to instanciate it directly and render it.
$viewHelperVariableName = $this->variableName('viewHelper');
$initializationPhpCode .= sprintf('%s = $self->getViewHelper(\'%s\', $renderingContext, \'%s\');', $viewHelperVariableName, $viewHelperVariableName, $node->getViewHelperClassName()) . chr(10);
$initializationPhpCode .= sprintf('%s->setArguments(%s);', $viewHelperVariableName, $argumentsVariableName) . chr(10);
$initializationPhpCode .= sprintf('%s->setRenderingContext($renderingContext);', $viewHelperVariableName) . chr(10);
$initializationPhpCode .= sprintf('%s->setRenderChildrenClosure(%s);', $viewHelperVariableName, $renderChildrenClosureVariableName) . chr(10);
$initializationPhpCode .= '// End of ViewHelper ' . $node->getViewHelperClassName() . chr(10);
return array(
'initialization' => $initializationPhpCode,
'execution' => sprintf('%s->initializeArgumentsAndRender()', $viewHelperVariableName)
);
}
|
[
"protected",
"function",
"convertViewHelperNode",
"(",
"ViewHelperNode",
"$",
"node",
")",
"{",
"$",
"initializationPhpCode",
"=",
"'// Rendering ViewHelper '",
".",
"$",
"node",
"->",
"getViewHelperClassName",
"(",
")",
".",
"chr",
"(",
"10",
")",
";",
"// Build up $arguments array",
"$",
"argumentsVariableName",
"=",
"$",
"this",
"->",
"variableName",
"(",
"'arguments'",
")",
";",
"$",
"initializationPhpCode",
".=",
"sprintf",
"(",
"'%s = array();'",
",",
"$",
"argumentsVariableName",
")",
".",
"chr",
"(",
"10",
")",
";",
"$",
"alreadyBuiltArguments",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"node",
"->",
"getArguments",
"(",
")",
"as",
"$",
"argumentName",
"=>",
"$",
"argumentValue",
")",
"{",
"$",
"converted",
"=",
"$",
"this",
"->",
"convert",
"(",
"$",
"argumentValue",
")",
";",
"$",
"initializationPhpCode",
".=",
"$",
"converted",
"[",
"'initialization'",
"]",
";",
"$",
"initializationPhpCode",
".=",
"sprintf",
"(",
"'%s[\\'%s\\'] = %s;'",
",",
"$",
"argumentsVariableName",
",",
"$",
"argumentName",
",",
"$",
"converted",
"[",
"'execution'",
"]",
")",
".",
"chr",
"(",
"10",
")",
";",
"$",
"alreadyBuiltArguments",
"[",
"$",
"argumentName",
"]",
"=",
"true",
";",
"}",
"/** @var $argumentDefinition ArgumentDefinition */",
"foreach",
"(",
"$",
"node",
"->",
"getUninitializedViewHelper",
"(",
")",
"->",
"prepareArguments",
"(",
")",
"as",
"$",
"argumentName",
"=>",
"$",
"argumentDefinition",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"alreadyBuiltArguments",
"[",
"$",
"argumentName",
"]",
")",
")",
"{",
"$",
"initializationPhpCode",
".=",
"sprintf",
"(",
"'%s[\\'%s\\'] = %s;'",
",",
"$",
"argumentsVariableName",
",",
"$",
"argumentName",
",",
"var_export",
"(",
"$",
"argumentDefinition",
"->",
"getDefaultValue",
"(",
")",
",",
"true",
")",
")",
".",
"chr",
"(",
"10",
")",
";",
"}",
"}",
"// Build up closure which renders the child nodes",
"$",
"renderChildrenClosureVariableName",
"=",
"$",
"this",
"->",
"variableName",
"(",
"'renderChildrenClosure'",
")",
";",
"$",
"initializationPhpCode",
".=",
"sprintf",
"(",
"'%s = %s;'",
",",
"$",
"renderChildrenClosureVariableName",
",",
"$",
"this",
"->",
"wrapChildNodesInClosure",
"(",
"$",
"node",
")",
")",
".",
"chr",
"(",
"10",
")",
";",
"if",
"(",
"$",
"node",
"->",
"getUninitializedViewHelper",
"(",
")",
"instanceof",
"CompilableInterface",
")",
"{",
"// ViewHelper is compilable",
"$",
"viewHelperInitializationPhpCode",
"=",
"''",
";",
"$",
"convertedViewHelperExecutionCode",
"=",
"$",
"node",
"->",
"getUninitializedViewHelper",
"(",
")",
"->",
"compile",
"(",
"$",
"argumentsVariableName",
",",
"$",
"renderChildrenClosureVariableName",
",",
"$",
"viewHelperInitializationPhpCode",
",",
"$",
"node",
",",
"$",
"this",
")",
";",
"$",
"initializationPhpCode",
".=",
"$",
"viewHelperInitializationPhpCode",
";",
"if",
"(",
"$",
"convertedViewHelperExecutionCode",
"!==",
"self",
"::",
"SHOULD_GENERATE_VIEWHELPER_INVOCATION",
")",
"{",
"return",
"array",
"(",
"'initialization'",
"=>",
"$",
"initializationPhpCode",
",",
"'execution'",
"=>",
"$",
"convertedViewHelperExecutionCode",
")",
";",
"}",
"}",
"// ViewHelper is not compilable, so we need to instanciate it directly and render it.",
"$",
"viewHelperVariableName",
"=",
"$",
"this",
"->",
"variableName",
"(",
"'viewHelper'",
")",
";",
"$",
"initializationPhpCode",
".=",
"sprintf",
"(",
"'%s = $self->getViewHelper(\\'%s\\', $renderingContext, \\'%s\\');'",
",",
"$",
"viewHelperVariableName",
",",
"$",
"viewHelperVariableName",
",",
"$",
"node",
"->",
"getViewHelperClassName",
"(",
")",
")",
".",
"chr",
"(",
"10",
")",
";",
"$",
"initializationPhpCode",
".=",
"sprintf",
"(",
"'%s->setArguments(%s);'",
",",
"$",
"viewHelperVariableName",
",",
"$",
"argumentsVariableName",
")",
".",
"chr",
"(",
"10",
")",
";",
"$",
"initializationPhpCode",
".=",
"sprintf",
"(",
"'%s->setRenderingContext($renderingContext);'",
",",
"$",
"viewHelperVariableName",
")",
".",
"chr",
"(",
"10",
")",
";",
"$",
"initializationPhpCode",
".=",
"sprintf",
"(",
"'%s->setRenderChildrenClosure(%s);'",
",",
"$",
"viewHelperVariableName",
",",
"$",
"renderChildrenClosureVariableName",
")",
".",
"chr",
"(",
"10",
")",
";",
"$",
"initializationPhpCode",
".=",
"'// End of ViewHelper '",
".",
"$",
"node",
"->",
"getViewHelperClassName",
"(",
")",
".",
"chr",
"(",
"10",
")",
";",
"return",
"array",
"(",
"'initialization'",
"=>",
"$",
"initializationPhpCode",
",",
"'execution'",
"=>",
"sprintf",
"(",
"'%s->initializeArgumentsAndRender()'",
",",
"$",
"viewHelperVariableName",
")",
")",
";",
"}"
] |
Convert a single ViewHelperNode into its cached representation. If the ViewHelper implements the "Compilable" facet,
the ViewHelper itself is asked for its cached PHP code representation. If not, a ViewHelper is built and then invoked.
@param ViewHelperNode $node
@return array
@see convert()
|
[
"Convert",
"a",
"single",
"ViewHelperNode",
"into",
"its",
"cached",
"representation",
".",
"If",
"the",
"ViewHelper",
"implements",
"the",
"Compilable",
"facet",
"the",
"ViewHelper",
"itself",
"is",
"asked",
"for",
"its",
"cached",
"PHP",
"code",
"representation",
".",
"If",
"not",
"a",
"ViewHelper",
"is",
"built",
"and",
"then",
"invoked",
"."
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/Compiler/TemplateCompiler.php#L245-L300
|
221,623
|
neos/fluid
|
Classes/TYPO3/Fluid/Core/Compiler/TemplateCompiler.php
|
TemplateCompiler.flushTemplatesOnViewHelperChanges
|
public function flushTemplatesOnViewHelperChanges(array $changedFiles)
{
if (!$this->templateCache instanceof FrontendInterface) {
return;
}
foreach ($changedFiles as $pathAndFilename => $status) {
if (strrpos($pathAndFilename, 'ViewHelper.php') !== false) {
$this->templateCache->flush();
return;
}
}
}
|
php
|
public function flushTemplatesOnViewHelperChanges(array $changedFiles)
{
if (!$this->templateCache instanceof FrontendInterface) {
return;
}
foreach ($changedFiles as $pathAndFilename => $status) {
if (strrpos($pathAndFilename, 'ViewHelper.php') !== false) {
$this->templateCache->flush();
return;
}
}
}
|
[
"public",
"function",
"flushTemplatesOnViewHelperChanges",
"(",
"array",
"$",
"changedFiles",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"templateCache",
"instanceof",
"FrontendInterface",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"changedFiles",
"as",
"$",
"pathAndFilename",
"=>",
"$",
"status",
")",
"{",
"if",
"(",
"strrpos",
"(",
"$",
"pathAndFilename",
",",
"'ViewHelper.php'",
")",
"!==",
"false",
")",
"{",
"$",
"this",
"->",
"templateCache",
"->",
"flush",
"(",
")",
";",
"return",
";",
"}",
"}",
"}"
] |
Flush cached templates if a ViewHelper class is changed
@param array $changedFiles An array of changed class files
@return void
|
[
"Flush",
"cached",
"templates",
"if",
"a",
"ViewHelper",
"class",
"is",
"changed"
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/Compiler/TemplateCompiler.php#L448-L460
|
221,624
|
salebab/database
|
src/database/DB.php
|
DB.setConfig
|
static function setConfig($config, $instance = 'default')
{
self::$config[$instance]['dsn'] = array_key_exists('dsn', $config) ? $config['dsn'] : "";
self::$config[$instance]['username'] = array_key_exists('username', $config) ? $config['username'] : null;
self::$config[$instance]['password'] = array_key_exists('password', $config) ? $config['password'] : null;
self::$config[$instance]['options'] = array_key_exists('options', $config) ? $config['options'] : array();
}
|
php
|
static function setConfig($config, $instance = 'default')
{
self::$config[$instance]['dsn'] = array_key_exists('dsn', $config) ? $config['dsn'] : "";
self::$config[$instance]['username'] = array_key_exists('username', $config) ? $config['username'] : null;
self::$config[$instance]['password'] = array_key_exists('password', $config) ? $config['password'] : null;
self::$config[$instance]['options'] = array_key_exists('options', $config) ? $config['options'] : array();
}
|
[
"static",
"function",
"setConfig",
"(",
"$",
"config",
",",
"$",
"instance",
"=",
"'default'",
")",
"{",
"self",
"::",
"$",
"config",
"[",
"$",
"instance",
"]",
"[",
"'dsn'",
"]",
"=",
"array_key_exists",
"(",
"'dsn'",
",",
"$",
"config",
")",
"?",
"$",
"config",
"[",
"'dsn'",
"]",
":",
"\"\"",
";",
"self",
"::",
"$",
"config",
"[",
"$",
"instance",
"]",
"[",
"'username'",
"]",
"=",
"array_key_exists",
"(",
"'username'",
",",
"$",
"config",
")",
"?",
"$",
"config",
"[",
"'username'",
"]",
":",
"null",
";",
"self",
"::",
"$",
"config",
"[",
"$",
"instance",
"]",
"[",
"'password'",
"]",
"=",
"array_key_exists",
"(",
"'password'",
",",
"$",
"config",
")",
"?",
"$",
"config",
"[",
"'password'",
"]",
":",
"null",
";",
"self",
"::",
"$",
"config",
"[",
"$",
"instance",
"]",
"[",
"'options'",
"]",
"=",
"array_key_exists",
"(",
"'options'",
",",
"$",
"config",
")",
"?",
"$",
"config",
"[",
"'options'",
"]",
":",
"array",
"(",
")",
";",
"}"
] |
Set database config params
config param should contains dsn, username, password and options
@param array $config
@param string $instance
|
[
"Set",
"database",
"config",
"params",
"config",
"param",
"should",
"contains",
"dsn",
"username",
"password",
"and",
"options"
] |
26e9253f274fb0719ad86c1db6e25ea5400b58a6
|
https://github.com/salebab/database/blob/26e9253f274fb0719ad86c1db6e25ea5400b58a6/src/database/DB.php#L91-L97
|
221,625
|
salebab/database
|
src/database/DB.php
|
DB.getSetStmt
|
private function getSetStmt($syntax, $table, $data, $where = null)
{
$columns = array();
foreach (array_keys($data) as $column) {
$columns[] = "`" . $column . "` = ?";
}
$columns = implode(", ", $columns);
$sql = "$syntax `$table` SET " . $columns . $this->buildWhere($where);
return $this->prepare($sql);
}
|
php
|
private function getSetStmt($syntax, $table, $data, $where = null)
{
$columns = array();
foreach (array_keys($data) as $column) {
$columns[] = "`" . $column . "` = ?";
}
$columns = implode(", ", $columns);
$sql = "$syntax `$table` SET " . $columns . $this->buildWhere($where);
return $this->prepare($sql);
}
|
[
"private",
"function",
"getSetStmt",
"(",
"$",
"syntax",
",",
"$",
"table",
",",
"$",
"data",
",",
"$",
"where",
"=",
"null",
")",
"{",
"$",
"columns",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"array_keys",
"(",
"$",
"data",
")",
"as",
"$",
"column",
")",
"{",
"$",
"columns",
"[",
"]",
"=",
"\"`\"",
".",
"$",
"column",
".",
"\"` = ?\"",
";",
"}",
"$",
"columns",
"=",
"implode",
"(",
"\", \"",
",",
"$",
"columns",
")",
";",
"$",
"sql",
"=",
"\"$syntax `$table` SET \"",
".",
"$",
"columns",
".",
"$",
"this",
"->",
"buildWhere",
"(",
"$",
"where",
")",
";",
"return",
"$",
"this",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"}"
] |
Build and Get SET statement
$this->getSetStmt(DB::INSERT, "mytable", array("name" => "John"));
will return:
INSERT INTO
@param string $syntax INSERT, UPDATE, REPLACE
@param string $table
@param array $data
@param null $where
@return \PDOStatement
|
[
"Build",
"and",
"Get",
"SET",
"statement"
] |
26e9253f274fb0719ad86c1db6e25ea5400b58a6
|
https://github.com/salebab/database/blob/26e9253f274fb0719ad86c1db6e25ea5400b58a6/src/database/DB.php#L188-L200
|
221,626
|
salebab/database
|
src/database/DB.php
|
DB.executeBySyntax
|
private function executeBySyntax($syntax, $table, $data, $where = null, $where_params = array(), $stmt_key = null)
{
if (!is_null($where) && !is_array($where)) {
$where = array($where);
}
if (is_object($data)) {
$data = (array) $data;
}
$data = $this->removeNonExistentColumns($table, $data, $stmt_key);
// support for scalar param
if (!is_array($where_params)) {
$where_params = array($where_params);
}
if (empty($stmt_key)) {
$stmt = $this->getSetStmt($syntax, $table, $data, $where);
} elseif (empty($this->prev_stmt[$stmt_key])) {
$stmt = $this->getSetStmt($syntax, $table, $data, $where);
$this->prev_stmt[$stmt_key] = $stmt;
} else {
$stmt = $this->prev_stmt[$stmt_key];
}
$stmt->execute(array_merge(array_values($data), $where_params));
return $stmt;
}
|
php
|
private function executeBySyntax($syntax, $table, $data, $where = null, $where_params = array(), $stmt_key = null)
{
if (!is_null($where) && !is_array($where)) {
$where = array($where);
}
if (is_object($data)) {
$data = (array) $data;
}
$data = $this->removeNonExistentColumns($table, $data, $stmt_key);
// support for scalar param
if (!is_array($where_params)) {
$where_params = array($where_params);
}
if (empty($stmt_key)) {
$stmt = $this->getSetStmt($syntax, $table, $data, $where);
} elseif (empty($this->prev_stmt[$stmt_key])) {
$stmt = $this->getSetStmt($syntax, $table, $data, $where);
$this->prev_stmt[$stmt_key] = $stmt;
} else {
$stmt = $this->prev_stmt[$stmt_key];
}
$stmt->execute(array_merge(array_values($data), $where_params));
return $stmt;
}
|
[
"private",
"function",
"executeBySyntax",
"(",
"$",
"syntax",
",",
"$",
"table",
",",
"$",
"data",
",",
"$",
"where",
"=",
"null",
",",
"$",
"where_params",
"=",
"array",
"(",
")",
",",
"$",
"stmt_key",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"where",
")",
"&&",
"!",
"is_array",
"(",
"$",
"where",
")",
")",
"{",
"$",
"where",
"=",
"array",
"(",
"$",
"where",
")",
";",
"}",
"if",
"(",
"is_object",
"(",
"$",
"data",
")",
")",
"{",
"$",
"data",
"=",
"(",
"array",
")",
"$",
"data",
";",
"}",
"$",
"data",
"=",
"$",
"this",
"->",
"removeNonExistentColumns",
"(",
"$",
"table",
",",
"$",
"data",
",",
"$",
"stmt_key",
")",
";",
"// support for scalar param",
"if",
"(",
"!",
"is_array",
"(",
"$",
"where_params",
")",
")",
"{",
"$",
"where_params",
"=",
"array",
"(",
"$",
"where_params",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"stmt_key",
")",
")",
"{",
"$",
"stmt",
"=",
"$",
"this",
"->",
"getSetStmt",
"(",
"$",
"syntax",
",",
"$",
"table",
",",
"$",
"data",
",",
"$",
"where",
")",
";",
"}",
"elseif",
"(",
"empty",
"(",
"$",
"this",
"->",
"prev_stmt",
"[",
"$",
"stmt_key",
"]",
")",
")",
"{",
"$",
"stmt",
"=",
"$",
"this",
"->",
"getSetStmt",
"(",
"$",
"syntax",
",",
"$",
"table",
",",
"$",
"data",
",",
"$",
"where",
")",
";",
"$",
"this",
"->",
"prev_stmt",
"[",
"$",
"stmt_key",
"]",
"=",
"$",
"stmt",
";",
"}",
"else",
"{",
"$",
"stmt",
"=",
"$",
"this",
"->",
"prev_stmt",
"[",
"$",
"stmt_key",
"]",
";",
"}",
"$",
"stmt",
"->",
"execute",
"(",
"array_merge",
"(",
"array_values",
"(",
"$",
"data",
")",
",",
"$",
"where_params",
")",
")",
";",
"return",
"$",
"stmt",
";",
"}"
] |
Perform INSERT, UPDATE, REPLACE
@param string $syntax
@param string $table
@param array $data
@param null $where
@param array $where_params
@param null $stmt_key
@return Statement|\PDOStatement
|
[
"Perform",
"INSERT",
"UPDATE",
"REPLACE"
] |
26e9253f274fb0719ad86c1db6e25ea5400b58a6
|
https://github.com/salebab/database/blob/26e9253f274fb0719ad86c1db6e25ea5400b58a6/src/database/DB.php#L213-L242
|
221,627
|
salebab/database
|
src/database/DB.php
|
DB.insert
|
function insert($table, $data, $stmt_key = null)
{
return $this->executeBySyntax(self::INSERT, $table, $data, null, array(), $stmt_key);
}
|
php
|
function insert($table, $data, $stmt_key = null)
{
return $this->executeBySyntax(self::INSERT, $table, $data, null, array(), $stmt_key);
}
|
[
"function",
"insert",
"(",
"$",
"table",
",",
"$",
"data",
",",
"$",
"stmt_key",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"executeBySyntax",
"(",
"self",
"::",
"INSERT",
",",
"$",
"table",
",",
"$",
"data",
",",
"null",
",",
"array",
"(",
")",
",",
"$",
"stmt_key",
")",
";",
"}"
] |
Insert one row
@throw PDOException
@param string $table
@param array $data
@param int|string|null $stmt_key Unique key to use previous prepared stmt
@return Statement
|
[
"Insert",
"one",
"row"
] |
26e9253f274fb0719ad86c1db6e25ea5400b58a6
|
https://github.com/salebab/database/blob/26e9253f274fb0719ad86c1db6e25ea5400b58a6/src/database/DB.php#L253-L256
|
221,628
|
salebab/database
|
src/database/DB.php
|
DB.update
|
function update($table, $data, $where, $where_params = array(), $stmt_key = null)
{
return $this->executeBySyntax(self::UPDATE, $table, $data, $where, $where_params, $stmt_key);
}
|
php
|
function update($table, $data, $where, $where_params = array(), $stmt_key = null)
{
return $this->executeBySyntax(self::UPDATE, $table, $data, $where, $where_params, $stmt_key);
}
|
[
"function",
"update",
"(",
"$",
"table",
",",
"$",
"data",
",",
"$",
"where",
",",
"$",
"where_params",
"=",
"array",
"(",
")",
",",
"$",
"stmt_key",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"executeBySyntax",
"(",
"self",
"::",
"UPDATE",
",",
"$",
"table",
",",
"$",
"data",
",",
"$",
"where",
",",
"$",
"where_params",
",",
"$",
"stmt_key",
")",
";",
"}"
] |
Update row in table, optionally use previous prepared stmt by stmt_key
@throw PDOException
@param string $table
@param array $data
@param mixed $where
@param mixed|array $where_params
@param int|string|null $stmt_key Unique key to use previous prepared stmt
@return Statement
|
[
"Update",
"row",
"in",
"table",
"optionally",
"use",
"previous",
"prepared",
"stmt",
"by",
"stmt_key"
] |
26e9253f274fb0719ad86c1db6e25ea5400b58a6
|
https://github.com/salebab/database/blob/26e9253f274fb0719ad86c1db6e25ea5400b58a6/src/database/DB.php#L270-L273
|
221,629
|
salebab/database
|
src/database/DB.php
|
DB.replace
|
function replace($table, $data, $stmt_key = null)
{
return $this->executeBySyntax(self::REPLACE, $table, $data, null, array(), $stmt_key);
}
|
php
|
function replace($table, $data, $stmt_key = null)
{
return $this->executeBySyntax(self::REPLACE, $table, $data, null, array(), $stmt_key);
}
|
[
"function",
"replace",
"(",
"$",
"table",
",",
"$",
"data",
",",
"$",
"stmt_key",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"executeBySyntax",
"(",
"self",
"::",
"REPLACE",
",",
"$",
"table",
",",
"$",
"data",
",",
"null",
",",
"array",
"(",
")",
",",
"$",
"stmt_key",
")",
";",
"}"
] |
Insert or replace row in a table
@throw PDOException
@param string $table
@param array $data
@param int|string|null $stmt_key
@return Statement
|
[
"Insert",
"or",
"replace",
"row",
"in",
"a",
"table"
] |
26e9253f274fb0719ad86c1db6e25ea5400b58a6
|
https://github.com/salebab/database/blob/26e9253f274fb0719ad86c1db6e25ea5400b58a6/src/database/DB.php#L285-L288
|
221,630
|
salebab/database
|
src/database/DB.php
|
DB.count
|
function count($table, $where, $where_params = null)
{
$sql = "SELECT COUNT(*) FROM " . $table . $this->buildWhere($where);
$stmt = $this->executeQuery($sql, $where_params);
return $stmt->fetchColumn();
}
|
php
|
function count($table, $where, $where_params = null)
{
$sql = "SELECT COUNT(*) FROM " . $table . $this->buildWhere($where);
$stmt = $this->executeQuery($sql, $where_params);
return $stmt->fetchColumn();
}
|
[
"function",
"count",
"(",
"$",
"table",
",",
"$",
"where",
",",
"$",
"where_params",
"=",
"null",
")",
"{",
"$",
"sql",
"=",
"\"SELECT COUNT(*) FROM \"",
".",
"$",
"table",
".",
"$",
"this",
"->",
"buildWhere",
"(",
"$",
"where",
")",
";",
"$",
"stmt",
"=",
"$",
"this",
"->",
"executeQuery",
"(",
"$",
"sql",
",",
"$",
"where_params",
")",
";",
"return",
"$",
"stmt",
"->",
"fetchColumn",
"(",
")",
";",
"}"
] |
Count rows in one table - very simple implementation
@param string $table
@param mixed $where
@param array $where_params
@return int
|
[
"Count",
"rows",
"in",
"one",
"table",
"-",
"very",
"simple",
"implementation"
] |
26e9253f274fb0719ad86c1db6e25ea5400b58a6
|
https://github.com/salebab/database/blob/26e9253f274fb0719ad86c1db6e25ea5400b58a6/src/database/DB.php#L316-L322
|
221,631
|
salebab/database
|
src/database/DB.php
|
DB.execQueryString
|
function execQueryString($sql, $params = null)
{
if (!is_array($params) && !is_null($params)) {
$params = array($params);
}
$stmt = $this->prepare($sql);
$stmt->execute($params);
return $stmt;
}
|
php
|
function execQueryString($sql, $params = null)
{
if (!is_array($params) && !is_null($params)) {
$params = array($params);
}
$stmt = $this->prepare($sql);
$stmt->execute($params);
return $stmt;
}
|
[
"function",
"execQueryString",
"(",
"$",
"sql",
",",
"$",
"params",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"params",
")",
"&&",
"!",
"is_null",
"(",
"$",
"params",
")",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"$",
"params",
")",
";",
"}",
"$",
"stmt",
"=",
"$",
"this",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"$",
"stmt",
"->",
"execute",
"(",
"$",
"params",
")",
";",
"return",
"$",
"stmt",
";",
"}"
] |
Prepare & execute query with params
@throw PDOException
@param string $sql
@param array|null $params
@return Statement
|
[
"Prepare",
"&",
"execute",
"query",
"with",
"params"
] |
26e9253f274fb0719ad86c1db6e25ea5400b58a6
|
https://github.com/salebab/database/blob/26e9253f274fb0719ad86c1db6e25ea5400b58a6/src/database/DB.php#L341-L350
|
221,632
|
salebab/database
|
src/database/DB.php
|
DB.buildWhere
|
function buildWhere($where, $operand = "AND")
{
if (empty($where)) {
return "";
}
if (is_array($where)) {
$wheres = array();
foreach ($where as $k => $w) {
$wheres[] = "(" . $w . ")";
}
$where = implode(" $operand ", $wheres);
}
return " WHERE " . $where;
}
|
php
|
function buildWhere($where, $operand = "AND")
{
if (empty($where)) {
return "";
}
if (is_array($where)) {
$wheres = array();
foreach ($where as $k => $w) {
$wheres[] = "(" . $w . ")";
}
$where = implode(" $operand ", $wheres);
}
return " WHERE " . $where;
}
|
[
"function",
"buildWhere",
"(",
"$",
"where",
",",
"$",
"operand",
"=",
"\"AND\"",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"where",
")",
")",
"{",
"return",
"\"\"",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"where",
")",
")",
"{",
"$",
"wheres",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"where",
"as",
"$",
"k",
"=>",
"$",
"w",
")",
"{",
"$",
"wheres",
"[",
"]",
"=",
"\"(\"",
".",
"$",
"w",
".",
"\")\"",
";",
"}",
"$",
"where",
"=",
"implode",
"(",
"\" $operand \"",
",",
"$",
"wheres",
")",
";",
"}",
"return",
"\" WHERE \"",
".",
"$",
"where",
";",
"}"
] |
Build where statement for SQL query
@param mixed $where
@param string $operand AND | OR
@return string
|
[
"Build",
"where",
"statement",
"for",
"SQL",
"query"
] |
26e9253f274fb0719ad86c1db6e25ea5400b58a6
|
https://github.com/salebab/database/blob/26e9253f274fb0719ad86c1db6e25ea5400b58a6/src/database/DB.php#L368-L383
|
221,633
|
salebab/database
|
src/database/DB.php
|
DB.save
|
function save($table, $data, $primary_key, $stmt_key = null)
{
// Update if primary key exists in data set or insert new row
if (!empty($data[$primary_key])) {
return $this->update($table, $data, $primary_key . " = ?", $data[$primary_key], $stmt_key);
} else {
return $this->insert($table, $data, $stmt_key);
}
}
|
php
|
function save($table, $data, $primary_key, $stmt_key = null)
{
// Update if primary key exists in data set or insert new row
if (!empty($data[$primary_key])) {
return $this->update($table, $data, $primary_key . " = ?", $data[$primary_key], $stmt_key);
} else {
return $this->insert($table, $data, $stmt_key);
}
}
|
[
"function",
"save",
"(",
"$",
"table",
",",
"$",
"data",
",",
"$",
"primary_key",
",",
"$",
"stmt_key",
"=",
"null",
")",
"{",
"// Update if primary key exists in data set or insert new row",
"if",
"(",
"!",
"empty",
"(",
"$",
"data",
"[",
"$",
"primary_key",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"update",
"(",
"$",
"table",
",",
"$",
"data",
",",
"$",
"primary_key",
".",
"\" = ?\"",
",",
"$",
"data",
"[",
"$",
"primary_key",
"]",
",",
"$",
"stmt_key",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"insert",
"(",
"$",
"table",
",",
"$",
"data",
",",
"$",
"stmt_key",
")",
";",
"}",
"}"
] |
Save data to table
@throw PDOException
@param string $table
@param array $data
@param string $primary_key Name of primary key column
@param string|int $stmt_key
@return Statement
|
[
"Save",
"data",
"to",
"table"
] |
26e9253f274fb0719ad86c1db6e25ea5400b58a6
|
https://github.com/salebab/database/blob/26e9253f274fb0719ad86c1db6e25ea5400b58a6/src/database/DB.php#L432-L440
|
221,634
|
salebab/database
|
src/database/DB.php
|
DB.setFetchTableNames
|
function setFetchTableNames($option = 1)
{
$this->setAttribute(self::ATTR_FETCH_TABLE_NAMES, $option);
$this->fetch_table_names = $option;
}
|
php
|
function setFetchTableNames($option = 1)
{
$this->setAttribute(self::ATTR_FETCH_TABLE_NAMES, $option);
$this->fetch_table_names = $option;
}
|
[
"function",
"setFetchTableNames",
"(",
"$",
"option",
"=",
"1",
")",
"{",
"$",
"this",
"->",
"setAttribute",
"(",
"self",
"::",
"ATTR_FETCH_TABLE_NAMES",
",",
"$",
"option",
")",
";",
"$",
"this",
"->",
"fetch_table_names",
"=",
"$",
"option",
";",
"}"
] |
Set fetch table names attribute
@param int $option 1 or 0
|
[
"Set",
"fetch",
"table",
"names",
"attribute"
] |
26e9253f274fb0719ad86c1db6e25ea5400b58a6
|
https://github.com/salebab/database/blob/26e9253f274fb0719ad86c1db6e25ea5400b58a6/src/database/DB.php#L448-L452
|
221,635
|
paquettg/leaguewrap
|
src/LeagueWrap/Api/Summoner.php
|
Summoner.get
|
public function get($key)
{
$key = strtolower($key);
if (isset($this->summoners[$key]))
{
return $this->summoners[$key];
}
return null;
}
|
php
|
public function get($key)
{
$key = strtolower($key);
if (isset($this->summoners[$key]))
{
return $this->summoners[$key];
}
return null;
}
|
[
"public",
"function",
"get",
"(",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"strtolower",
"(",
"$",
"key",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"summoners",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"summoners",
"[",
"$",
"key",
"]",
";",
"}",
"return",
"null",
";",
"}"
] |
Attempt to get a summoner by key.
@param string $key
@return object|null
|
[
"Attempt",
"to",
"get",
"a",
"summoner",
"by",
"key",
"."
] |
0f91813b5d8292054e5e13619d591b6b14dc63e6
|
https://github.com/paquettg/leaguewrap/blob/0f91813b5d8292054e5e13619d591b6b14dc63e6/src/LeagueWrap/Api/Summoner.php#L80-L89
|
221,636
|
paquettg/leaguewrap
|
src/LeagueWrap/Api/Summoner.php
|
Summoner.info
|
public function info($identities)
{
$ids = [];
$names = [];
if (is_array($identities))
{
foreach ($identities as $identity)
{
if (gettype($identity) === 'integer')
{
// it's the id
$ids[] = $identity;
}
else
{
// the summoner name
$names[] = $identity;
}
}
}
else
{
if (gettype($identities) === 'integer')
{
// it's the id
$ids[] = $identities;
}
else
{
// the summoner name
$names[] = $identities;
}
}
if (count($ids) > 0)
{
// it's the id
$ids = $this->infoByIds($ids);
}
if (count($names) > 0)
{
// the summoner name
$names = $this->infoByNames($names);
}
$summoners = $ids + $names;
if (count($summoners) == 1)
{
return reset($summoners);
}
else
{
return $summoners;
}
}
|
php
|
public function info($identities)
{
$ids = [];
$names = [];
if (is_array($identities))
{
foreach ($identities as $identity)
{
if (gettype($identity) === 'integer')
{
// it's the id
$ids[] = $identity;
}
else
{
// the summoner name
$names[] = $identity;
}
}
}
else
{
if (gettype($identities) === 'integer')
{
// it's the id
$ids[] = $identities;
}
else
{
// the summoner name
$names[] = $identities;
}
}
if (count($ids) > 0)
{
// it's the id
$ids = $this->infoByIds($ids);
}
if (count($names) > 0)
{
// the summoner name
$names = $this->infoByNames($names);
}
$summoners = $ids + $names;
if (count($summoners) == 1)
{
return reset($summoners);
}
else
{
return $summoners;
}
}
|
[
"public",
"function",
"info",
"(",
"$",
"identities",
")",
"{",
"$",
"ids",
"=",
"[",
"]",
";",
"$",
"names",
"=",
"[",
"]",
";",
"if",
"(",
"is_array",
"(",
"$",
"identities",
")",
")",
"{",
"foreach",
"(",
"$",
"identities",
"as",
"$",
"identity",
")",
"{",
"if",
"(",
"gettype",
"(",
"$",
"identity",
")",
"===",
"'integer'",
")",
"{",
"// it's the id",
"$",
"ids",
"[",
"]",
"=",
"$",
"identity",
";",
"}",
"else",
"{",
"// the summoner name",
"$",
"names",
"[",
"]",
"=",
"$",
"identity",
";",
"}",
"}",
"}",
"else",
"{",
"if",
"(",
"gettype",
"(",
"$",
"identities",
")",
"===",
"'integer'",
")",
"{",
"// it's the id",
"$",
"ids",
"[",
"]",
"=",
"$",
"identities",
";",
"}",
"else",
"{",
"// the summoner name",
"$",
"names",
"[",
"]",
"=",
"$",
"identities",
";",
"}",
"}",
"if",
"(",
"count",
"(",
"$",
"ids",
")",
">",
"0",
")",
"{",
"// it's the id",
"$",
"ids",
"=",
"$",
"this",
"->",
"infoByIds",
"(",
"$",
"ids",
")",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"names",
")",
">",
"0",
")",
"{",
"// the summoner name",
"$",
"names",
"=",
"$",
"this",
"->",
"infoByNames",
"(",
"$",
"names",
")",
";",
"}",
"$",
"summoners",
"=",
"$",
"ids",
"+",
"$",
"names",
";",
"if",
"(",
"count",
"(",
"$",
"summoners",
")",
"==",
"1",
")",
"{",
"return",
"reset",
"(",
"$",
"summoners",
")",
";",
"}",
"else",
"{",
"return",
"$",
"summoners",
";",
"}",
"}"
] |
Gets the information about the user by the given identification. IDs must be of type integer, otherwise,
numeric string values will be assumed to be names.
@param mixed $identities
@return Dto\Summoner
|
[
"Gets",
"the",
"information",
"about",
"the",
"user",
"by",
"the",
"given",
"identification",
".",
"IDs",
"must",
"be",
"of",
"type",
"integer",
"otherwise",
"numeric",
"string",
"values",
"will",
"be",
"assumed",
"to",
"be",
"names",
"."
] |
0f91813b5d8292054e5e13619d591b6b14dc63e6
|
https://github.com/paquettg/leaguewrap/blob/0f91813b5d8292054e5e13619d591b6b14dc63e6/src/LeagueWrap/Api/Summoner.php#L98-L154
|
221,637
|
paquettg/leaguewrap
|
src/LeagueWrap/Api/Summoner.php
|
Summoner.allInfo
|
public function allInfo($identities)
{
$summoners = $this->info($identities);
$this->runePages($summoners);
$this->masteryPages($summoners);
return $summoners;
}
|
php
|
public function allInfo($identities)
{
$summoners = $this->info($identities);
$this->runePages($summoners);
$this->masteryPages($summoners);
return $summoners;
}
|
[
"public",
"function",
"allInfo",
"(",
"$",
"identities",
")",
"{",
"$",
"summoners",
"=",
"$",
"this",
"->",
"info",
"(",
"$",
"identities",
")",
";",
"$",
"this",
"->",
"runePages",
"(",
"$",
"summoners",
")",
";",
"$",
"this",
"->",
"masteryPages",
"(",
"$",
"summoners",
")",
";",
"return",
"$",
"summoners",
";",
"}"
] |
Attempts to get all information about this user. This method
will make 3 requests!
@param mixed $identities
@return Dto\Summoner;
|
[
"Attempts",
"to",
"get",
"all",
"information",
"about",
"this",
"user",
".",
"This",
"method",
"will",
"make",
"3",
"requests!"
] |
0f91813b5d8292054e5e13619d591b6b14dc63e6
|
https://github.com/paquettg/leaguewrap/blob/0f91813b5d8292054e5e13619d591b6b14dc63e6/src/LeagueWrap/Api/Summoner.php#L163-L170
|
221,638
|
paquettg/leaguewrap
|
src/LeagueWrap/Api/Summoner.php
|
Summoner.name
|
public function name($identities)
{
$ids = $this->extractIds($identities);
$ids = implode(',', $ids);
$array = $this->request('summoner/'.$ids.'/name');
$names = [];
foreach ($array as $id => $name)
{
$names[$id] = $name;
}
return $names;
}
|
php
|
public function name($identities)
{
$ids = $this->extractIds($identities);
$ids = implode(',', $ids);
$array = $this->request('summoner/'.$ids.'/name');
$names = [];
foreach ($array as $id => $name)
{
$names[$id] = $name;
}
return $names;
}
|
[
"public",
"function",
"name",
"(",
"$",
"identities",
")",
"{",
"$",
"ids",
"=",
"$",
"this",
"->",
"extractIds",
"(",
"$",
"identities",
")",
";",
"$",
"ids",
"=",
"implode",
"(",
"','",
",",
"$",
"ids",
")",
";",
"$",
"array",
"=",
"$",
"this",
"->",
"request",
"(",
"'summoner/'",
".",
"$",
"ids",
".",
"'/name'",
")",
";",
"$",
"names",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"id",
"=>",
"$",
"name",
")",
"{",
"$",
"names",
"[",
"$",
"id",
"]",
"=",
"$",
"name",
";",
"}",
"return",
"$",
"names",
";",
"}"
] |
Gets the name of each summoner from a list of ids.
@param mixed $identities
@return array
|
[
"Gets",
"the",
"name",
"of",
"each",
"summoner",
"from",
"a",
"list",
"of",
"ids",
"."
] |
0f91813b5d8292054e5e13619d591b6b14dc63e6
|
https://github.com/paquettg/leaguewrap/blob/0f91813b5d8292054e5e13619d591b6b14dc63e6/src/LeagueWrap/Api/Summoner.php#L178-L191
|
221,639
|
paquettg/leaguewrap
|
src/LeagueWrap/Api/Summoner.php
|
Summoner.runePages
|
public function runePages($identities)
{
$ids = $this->extractIds($identities);
$ids = implode(',', $ids);
$array = $this->request('summoner/'.$ids.'/runes');
$summoners = [];
foreach ($array as $summonerId => $data)
{
$runePages = [];
foreach ($data['pages'] as $info)
{
if ( ! isset($info['slots']))
{
// no runes in this page
$info['slots'] = [];
}
$slots = $info['slots'];
unset($info['slots']);
$runePage = $this->attachStaticDataToDto(new RunePage($info));
// set runes
$runes = [];
foreach ($slots as $slot)
{
$id = $slot['runeSlotId'];
$rune = $this->attachStaticDataToDto(new Rune($slot));
$runes[$id] = $rune;
}
$runePage->runes = $runes;
$runePages[] = $runePage;
}
$summoners[$summonerId] = $runePages;
}
$this->attachResponses($identities, $summoners, 'runePages');
if (is_array($identities))
{
return $summoners;
}
else
{
return reset($summoners);
}
}
|
php
|
public function runePages($identities)
{
$ids = $this->extractIds($identities);
$ids = implode(',', $ids);
$array = $this->request('summoner/'.$ids.'/runes');
$summoners = [];
foreach ($array as $summonerId => $data)
{
$runePages = [];
foreach ($data['pages'] as $info)
{
if ( ! isset($info['slots']))
{
// no runes in this page
$info['slots'] = [];
}
$slots = $info['slots'];
unset($info['slots']);
$runePage = $this->attachStaticDataToDto(new RunePage($info));
// set runes
$runes = [];
foreach ($slots as $slot)
{
$id = $slot['runeSlotId'];
$rune = $this->attachStaticDataToDto(new Rune($slot));
$runes[$id] = $rune;
}
$runePage->runes = $runes;
$runePages[] = $runePage;
}
$summoners[$summonerId] = $runePages;
}
$this->attachResponses($identities, $summoners, 'runePages');
if (is_array($identities))
{
return $summoners;
}
else
{
return reset($summoners);
}
}
|
[
"public",
"function",
"runePages",
"(",
"$",
"identities",
")",
"{",
"$",
"ids",
"=",
"$",
"this",
"->",
"extractIds",
"(",
"$",
"identities",
")",
";",
"$",
"ids",
"=",
"implode",
"(",
"','",
",",
"$",
"ids",
")",
";",
"$",
"array",
"=",
"$",
"this",
"->",
"request",
"(",
"'summoner/'",
".",
"$",
"ids",
".",
"'/runes'",
")",
";",
"$",
"summoners",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"summonerId",
"=>",
"$",
"data",
")",
"{",
"$",
"runePages",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"data",
"[",
"'pages'",
"]",
"as",
"$",
"info",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"info",
"[",
"'slots'",
"]",
")",
")",
"{",
"// no runes in this page",
"$",
"info",
"[",
"'slots'",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"slots",
"=",
"$",
"info",
"[",
"'slots'",
"]",
";",
"unset",
"(",
"$",
"info",
"[",
"'slots'",
"]",
")",
";",
"$",
"runePage",
"=",
"$",
"this",
"->",
"attachStaticDataToDto",
"(",
"new",
"RunePage",
"(",
"$",
"info",
")",
")",
";",
"// set runes",
"$",
"runes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"slots",
"as",
"$",
"slot",
")",
"{",
"$",
"id",
"=",
"$",
"slot",
"[",
"'runeSlotId'",
"]",
";",
"$",
"rune",
"=",
"$",
"this",
"->",
"attachStaticDataToDto",
"(",
"new",
"Rune",
"(",
"$",
"slot",
")",
")",
";",
"$",
"runes",
"[",
"$",
"id",
"]",
"=",
"$",
"rune",
";",
"}",
"$",
"runePage",
"->",
"runes",
"=",
"$",
"runes",
";",
"$",
"runePages",
"[",
"]",
"=",
"$",
"runePage",
";",
"}",
"$",
"summoners",
"[",
"$",
"summonerId",
"]",
"=",
"$",
"runePages",
";",
"}",
"$",
"this",
"->",
"attachResponses",
"(",
"$",
"identities",
",",
"$",
"summoners",
",",
"'runePages'",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"identities",
")",
")",
"{",
"return",
"$",
"summoners",
";",
"}",
"else",
"{",
"return",
"reset",
"(",
"$",
"summoners",
")",
";",
"}",
"}"
] |
Gets all rune pages of the given user object or id.
@param mixed $identities
@return array
|
[
"Gets",
"all",
"rune",
"pages",
"of",
"the",
"given",
"user",
"object",
"or",
"id",
"."
] |
0f91813b5d8292054e5e13619d591b6b14dc63e6
|
https://github.com/paquettg/leaguewrap/blob/0f91813b5d8292054e5e13619d591b6b14dc63e6/src/LeagueWrap/Api/Summoner.php#L199-L246
|
221,640
|
paquettg/leaguewrap
|
src/LeagueWrap/Api/Summoner.php
|
Summoner.masteryPages
|
public function masteryPages($identities)
{
$ids = $this->extractIds($identities);
$ids = implode(',', $ids);
$array = $this->request('summoner/'.$ids.'/masteries');
$summoners = [];
foreach ($array as $summonerId => $data)
{
$masteryPages = [];
foreach ($data['pages'] as $info)
{
if ( ! isset($info['masteries']))
{
// seting the talents to an empty array
$info['masteries'] = [];
}
$masteriesInfo = $info['masteries'];
unset($info['masteries']);
$masteryPage = $this->attachStaticDataToDto(new MasteryPage($info));
// set masterys
$masteries = [];
foreach ($masteriesInfo as $mastery)
{
$id = $mastery['id'];
$mastery = $this->attachStaticDataToDto(new Mastery($mastery));
$masteries[$id] = $mastery;
}
$masteryPage->masteries = $masteries;
$masteryPages[] = $masteryPage;
}
$summoners[$summonerId] = $masteryPages;
}
$this->attachResponses($identities, $summoners, 'masteryPages');
if (is_array($identities))
{
return $summoners;
}
else
{
return reset($summoners);
}
}
|
php
|
public function masteryPages($identities)
{
$ids = $this->extractIds($identities);
$ids = implode(',', $ids);
$array = $this->request('summoner/'.$ids.'/masteries');
$summoners = [];
foreach ($array as $summonerId => $data)
{
$masteryPages = [];
foreach ($data['pages'] as $info)
{
if ( ! isset($info['masteries']))
{
// seting the talents to an empty array
$info['masteries'] = [];
}
$masteriesInfo = $info['masteries'];
unset($info['masteries']);
$masteryPage = $this->attachStaticDataToDto(new MasteryPage($info));
// set masterys
$masteries = [];
foreach ($masteriesInfo as $mastery)
{
$id = $mastery['id'];
$mastery = $this->attachStaticDataToDto(new Mastery($mastery));
$masteries[$id] = $mastery;
}
$masteryPage->masteries = $masteries;
$masteryPages[] = $masteryPage;
}
$summoners[$summonerId] = $masteryPages;
}
$this->attachResponses($identities, $summoners, 'masteryPages');
if (is_array($identities))
{
return $summoners;
}
else
{
return reset($summoners);
}
}
|
[
"public",
"function",
"masteryPages",
"(",
"$",
"identities",
")",
"{",
"$",
"ids",
"=",
"$",
"this",
"->",
"extractIds",
"(",
"$",
"identities",
")",
";",
"$",
"ids",
"=",
"implode",
"(",
"','",
",",
"$",
"ids",
")",
";",
"$",
"array",
"=",
"$",
"this",
"->",
"request",
"(",
"'summoner/'",
".",
"$",
"ids",
".",
"'/masteries'",
")",
";",
"$",
"summoners",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"summonerId",
"=>",
"$",
"data",
")",
"{",
"$",
"masteryPages",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"data",
"[",
"'pages'",
"]",
"as",
"$",
"info",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"info",
"[",
"'masteries'",
"]",
")",
")",
"{",
"// seting the talents to an empty array",
"$",
"info",
"[",
"'masteries'",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"masteriesInfo",
"=",
"$",
"info",
"[",
"'masteries'",
"]",
";",
"unset",
"(",
"$",
"info",
"[",
"'masteries'",
"]",
")",
";",
"$",
"masteryPage",
"=",
"$",
"this",
"->",
"attachStaticDataToDto",
"(",
"new",
"MasteryPage",
"(",
"$",
"info",
")",
")",
";",
"// set masterys",
"$",
"masteries",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"masteriesInfo",
"as",
"$",
"mastery",
")",
"{",
"$",
"id",
"=",
"$",
"mastery",
"[",
"'id'",
"]",
";",
"$",
"mastery",
"=",
"$",
"this",
"->",
"attachStaticDataToDto",
"(",
"new",
"Mastery",
"(",
"$",
"mastery",
")",
")",
";",
"$",
"masteries",
"[",
"$",
"id",
"]",
"=",
"$",
"mastery",
";",
"}",
"$",
"masteryPage",
"->",
"masteries",
"=",
"$",
"masteries",
";",
"$",
"masteryPages",
"[",
"]",
"=",
"$",
"masteryPage",
";",
"}",
"$",
"summoners",
"[",
"$",
"summonerId",
"]",
"=",
"$",
"masteryPages",
";",
"}",
"$",
"this",
"->",
"attachResponses",
"(",
"$",
"identities",
",",
"$",
"summoners",
",",
"'masteryPages'",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"identities",
")",
")",
"{",
"return",
"$",
"summoners",
";",
"}",
"else",
"{",
"return",
"reset",
"(",
"$",
"summoners",
")",
";",
"}",
"}"
] |
Gets all the mastery pages of the given user object or id.
@param mixed $identities
@return array
|
[
"Gets",
"all",
"the",
"mastery",
"pages",
"of",
"the",
"given",
"user",
"object",
"or",
"id",
"."
] |
0f91813b5d8292054e5e13619d591b6b14dc63e6
|
https://github.com/paquettg/leaguewrap/blob/0f91813b5d8292054e5e13619d591b6b14dc63e6/src/LeagueWrap/Api/Summoner.php#L254-L299
|
221,641
|
paquettg/leaguewrap
|
src/LeagueWrap/Api/Summoner.php
|
Summoner.infoByIds
|
protected function infoByIds($ids)
{
if (count($ids) > 40)
{
throw new ListMaxException('This request can only support a list of 40 elements, '.count($ids).' given.');
}
$idList = implode(',', $ids);
$array = $this->request('summoner/'.$idList);
$summoners = [];
foreach ($array as $info)
{
$summoner = $this->attachStaticDataToDto(new Dto\Summoner($info));
$name = $summoner->name;
$this->summoners[$name] = $summoner;
$summoners[$name] = $summoner;
}
return $summoners;
}
|
php
|
protected function infoByIds($ids)
{
if (count($ids) > 40)
{
throw new ListMaxException('This request can only support a list of 40 elements, '.count($ids).' given.');
}
$idList = implode(',', $ids);
$array = $this->request('summoner/'.$idList);
$summoners = [];
foreach ($array as $info)
{
$summoner = $this->attachStaticDataToDto(new Dto\Summoner($info));
$name = $summoner->name;
$this->summoners[$name] = $summoner;
$summoners[$name] = $summoner;
}
return $summoners;
}
|
[
"protected",
"function",
"infoByIds",
"(",
"$",
"ids",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"ids",
")",
">",
"40",
")",
"{",
"throw",
"new",
"ListMaxException",
"(",
"'This request can only support a list of 40 elements, '",
".",
"count",
"(",
"$",
"ids",
")",
".",
"' given.'",
")",
";",
"}",
"$",
"idList",
"=",
"implode",
"(",
"','",
",",
"$",
"ids",
")",
";",
"$",
"array",
"=",
"$",
"this",
"->",
"request",
"(",
"'summoner/'",
".",
"$",
"idList",
")",
";",
"$",
"summoners",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"info",
")",
"{",
"$",
"summoner",
"=",
"$",
"this",
"->",
"attachStaticDataToDto",
"(",
"new",
"Dto",
"\\",
"Summoner",
"(",
"$",
"info",
")",
")",
";",
"$",
"name",
"=",
"$",
"summoner",
"->",
"name",
";",
"$",
"this",
"->",
"summoners",
"[",
"$",
"name",
"]",
"=",
"$",
"summoner",
";",
"$",
"summoners",
"[",
"$",
"name",
"]",
"=",
"$",
"summoner",
";",
"}",
"return",
"$",
"summoners",
";",
"}"
] |
Gets the information by the id of the summoner.
@param array $ids
@return Dto\Summoner|Dto\Summoner[];
@throws ListMaxException
|
[
"Gets",
"the",
"information",
"by",
"the",
"id",
"of",
"the",
"summoner",
"."
] |
0f91813b5d8292054e5e13619d591b6b14dc63e6
|
https://github.com/paquettg/leaguewrap/blob/0f91813b5d8292054e5e13619d591b6b14dc63e6/src/LeagueWrap/Api/Summoner.php#L308-L327
|
221,642
|
paquettg/leaguewrap
|
src/LeagueWrap/Api/Summoner.php
|
Summoner.infoByNames
|
protected function infoByNames(array $names)
{
if (count($names) > 40)
{
throw new ListMaxException('this request can only support a list of 40 elements, '.count($names).' given.');
}
$nameList = implode(',', $names);
// clean the name
$nameList = htmlspecialchars($nameList);
$array = $this->request('summoner/by-name/'.$nameList);
$summoners = [];
if ( ! empty($array))
{
foreach ($array as $name => $info)
{
$summoner = $this->attachStaticDataToDto(new Dto\Summoner($info));
$this->summoners[$name] = $summoner;
$summoners[$name] = $summoner;
}
}
return $summoners;
}
|
php
|
protected function infoByNames(array $names)
{
if (count($names) > 40)
{
throw new ListMaxException('this request can only support a list of 40 elements, '.count($names).' given.');
}
$nameList = implode(',', $names);
// clean the name
$nameList = htmlspecialchars($nameList);
$array = $this->request('summoner/by-name/'.$nameList);
$summoners = [];
if ( ! empty($array))
{
foreach ($array as $name => $info)
{
$summoner = $this->attachStaticDataToDto(new Dto\Summoner($info));
$this->summoners[$name] = $summoner;
$summoners[$name] = $summoner;
}
}
return $summoners;
}
|
[
"protected",
"function",
"infoByNames",
"(",
"array",
"$",
"names",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"names",
")",
">",
"40",
")",
"{",
"throw",
"new",
"ListMaxException",
"(",
"'this request can only support a list of 40 elements, '",
".",
"count",
"(",
"$",
"names",
")",
".",
"' given.'",
")",
";",
"}",
"$",
"nameList",
"=",
"implode",
"(",
"','",
",",
"$",
"names",
")",
";",
"// clean the name",
"$",
"nameList",
"=",
"htmlspecialchars",
"(",
"$",
"nameList",
")",
";",
"$",
"array",
"=",
"$",
"this",
"->",
"request",
"(",
"'summoner/by-name/'",
".",
"$",
"nameList",
")",
";",
"$",
"summoners",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"array",
")",
")",
"{",
"foreach",
"(",
"$",
"array",
"as",
"$",
"name",
"=>",
"$",
"info",
")",
"{",
"$",
"summoner",
"=",
"$",
"this",
"->",
"attachStaticDataToDto",
"(",
"new",
"Dto",
"\\",
"Summoner",
"(",
"$",
"info",
")",
")",
";",
"$",
"this",
"->",
"summoners",
"[",
"$",
"name",
"]",
"=",
"$",
"summoner",
";",
"$",
"summoners",
"[",
"$",
"name",
"]",
"=",
"$",
"summoner",
";",
"}",
"}",
"return",
"$",
"summoners",
";",
"}"
] |
Gets the information by the name of the summoner.
@param array $names
@return Dto\Summoner|Dto\Summoner[];
@throws ListMaxException
|
[
"Gets",
"the",
"information",
"by",
"the",
"name",
"of",
"the",
"summoner",
"."
] |
0f91813b5d8292054e5e13619d591b6b14dc63e6
|
https://github.com/paquettg/leaguewrap/blob/0f91813b5d8292054e5e13619d591b6b14dc63e6/src/LeagueWrap/Api/Summoner.php#L336-L360
|
221,643
|
neos/fluid
|
Classes/TYPO3/Fluid/Core/Parser/Configuration.php
|
Configuration.addInterceptorToArray
|
protected function addInterceptorToArray(InterceptorInterface $interceptor, array &$interceptorArray)
{
foreach ($interceptor->getInterceptionPoints() as $interceptionPoint) {
if (!isset($interceptorArray[$interceptionPoint])) {
$interceptorArray[$interceptionPoint] = new \SplObjectStorage();
}
/** @var $interceptors \SplObjectStorage */
$interceptors = $interceptorArray[$interceptionPoint];
if (!$interceptors->contains($interceptor)) {
$interceptors->attach($interceptor);
}
}
}
|
php
|
protected function addInterceptorToArray(InterceptorInterface $interceptor, array &$interceptorArray)
{
foreach ($interceptor->getInterceptionPoints() as $interceptionPoint) {
if (!isset($interceptorArray[$interceptionPoint])) {
$interceptorArray[$interceptionPoint] = new \SplObjectStorage();
}
/** @var $interceptors \SplObjectStorage */
$interceptors = $interceptorArray[$interceptionPoint];
if (!$interceptors->contains($interceptor)) {
$interceptors->attach($interceptor);
}
}
}
|
[
"protected",
"function",
"addInterceptorToArray",
"(",
"InterceptorInterface",
"$",
"interceptor",
",",
"array",
"&",
"$",
"interceptorArray",
")",
"{",
"foreach",
"(",
"$",
"interceptor",
"->",
"getInterceptionPoints",
"(",
")",
"as",
"$",
"interceptionPoint",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"interceptorArray",
"[",
"$",
"interceptionPoint",
"]",
")",
")",
"{",
"$",
"interceptorArray",
"[",
"$",
"interceptionPoint",
"]",
"=",
"new",
"\\",
"SplObjectStorage",
"(",
")",
";",
"}",
"/** @var $interceptors \\SplObjectStorage */",
"$",
"interceptors",
"=",
"$",
"interceptorArray",
"[",
"$",
"interceptionPoint",
"]",
";",
"if",
"(",
"!",
"$",
"interceptors",
"->",
"contains",
"(",
"$",
"interceptor",
")",
")",
"{",
"$",
"interceptors",
"->",
"attach",
"(",
"$",
"interceptor",
")",
";",
"}",
"}",
"}"
] |
Adds an interceptor to apply to values coming from object accessors.
@param InterceptorInterface $interceptor
@param array $interceptorArray
@return void
|
[
"Adds",
"an",
"interceptor",
"to",
"apply",
"to",
"values",
"coming",
"from",
"object",
"accessors",
"."
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/Parser/Configuration.php#L64-L76
|
221,644
|
neos/fluid
|
Classes/TYPO3/Fluid/Core/Parser/Configuration.php
|
Configuration.getInterceptors
|
public function getInterceptors($interceptionPoint)
{
return isset($this->interceptors[$interceptionPoint]) ? $this->interceptors[$interceptionPoint] : new \SplObjectStorage();
}
|
php
|
public function getInterceptors($interceptionPoint)
{
return isset($this->interceptors[$interceptionPoint]) ? $this->interceptors[$interceptionPoint] : new \SplObjectStorage();
}
|
[
"public",
"function",
"getInterceptors",
"(",
"$",
"interceptionPoint",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"interceptors",
"[",
"$",
"interceptionPoint",
"]",
")",
"?",
"$",
"this",
"->",
"interceptors",
"[",
"$",
"interceptionPoint",
"]",
":",
"new",
"\\",
"SplObjectStorage",
"(",
")",
";",
"}"
] |
Returns all interceptors for a given Interception Point.
@param integer $interceptionPoint one of the \TYPO3\Fluid\Core\Parser\InterceptorInterface::INTERCEPT_* constants,
@return \SplObjectStorage<\TYPO3\Fluid\Core\Parser\InterceptorInterface>
|
[
"Returns",
"all",
"interceptors",
"for",
"a",
"given",
"Interception",
"Point",
"."
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/Parser/Configuration.php#L84-L87
|
221,645
|
neos/fluid
|
Classes/TYPO3/Fluid/Core/Parser/Configuration.php
|
Configuration.getEscapingInterceptors
|
public function getEscapingInterceptors($interceptionPoint)
{
return isset($this->escapingInterceptors[$interceptionPoint]) ? $this->escapingInterceptors[$interceptionPoint] : new \SplObjectStorage();
}
|
php
|
public function getEscapingInterceptors($interceptionPoint)
{
return isset($this->escapingInterceptors[$interceptionPoint]) ? $this->escapingInterceptors[$interceptionPoint] : new \SplObjectStorage();
}
|
[
"public",
"function",
"getEscapingInterceptors",
"(",
"$",
"interceptionPoint",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"escapingInterceptors",
"[",
"$",
"interceptionPoint",
"]",
")",
"?",
"$",
"this",
"->",
"escapingInterceptors",
"[",
"$",
"interceptionPoint",
"]",
":",
"new",
"\\",
"SplObjectStorage",
"(",
")",
";",
"}"
] |
Returns all escaping interceptors for a given Interception Point.
@param integer $interceptionPoint one of the \TYPO3\Fluid\Core\Parser\InterceptorInterface::INTERCEPT_* constants,
@return \SplObjectStorage<\TYPO3\Fluid\Core\Parser\InterceptorInterface>
|
[
"Returns",
"all",
"escaping",
"interceptors",
"for",
"a",
"given",
"Interception",
"Point",
"."
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/Parser/Configuration.php#L95-L98
|
221,646
|
neos/fluid
|
Classes/TYPO3/Fluid/ViewHelpers/CountViewHelper.php
|
CountViewHelper.render
|
public function render($subject = null)
{
if ($subject === null) {
$subject = $this->renderChildren();
}
if (is_object($subject) && !$subject instanceof \Countable) {
throw new ViewHelper\Exception('CountViewHelper only supports arrays and objects implementing \Countable interface. Given: "' . get_class($subject) . '"', 1279808078);
}
return count($subject);
}
|
php
|
public function render($subject = null)
{
if ($subject === null) {
$subject = $this->renderChildren();
}
if (is_object($subject) && !$subject instanceof \Countable) {
throw new ViewHelper\Exception('CountViewHelper only supports arrays and objects implementing \Countable interface. Given: "' . get_class($subject) . '"', 1279808078);
}
return count($subject);
}
|
[
"public",
"function",
"render",
"(",
"$",
"subject",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"subject",
"===",
"null",
")",
"{",
"$",
"subject",
"=",
"$",
"this",
"->",
"renderChildren",
"(",
")",
";",
"}",
"if",
"(",
"is_object",
"(",
"$",
"subject",
")",
"&&",
"!",
"$",
"subject",
"instanceof",
"\\",
"Countable",
")",
"{",
"throw",
"new",
"ViewHelper",
"\\",
"Exception",
"(",
"'CountViewHelper only supports arrays and objects implementing \\Countable interface. Given: \"'",
".",
"get_class",
"(",
"$",
"subject",
")",
".",
"'\"'",
",",
"1279808078",
")",
";",
"}",
"return",
"count",
"(",
"$",
"subject",
")",
";",
"}"
] |
Counts the items of a given property.
@param array|\Countable $subject The array or \Countable to be counted
@return integer The number of elements
@throws ViewHelper\Exception
@api
|
[
"Counts",
"the",
"items",
"of",
"a",
"given",
"property",
"."
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/ViewHelpers/CountViewHelper.php#L58-L67
|
221,647
|
radphp/radphp
|
src/Network/Http/Response/JsonResponse.php
|
JsonResponse.throwJsonException
|
protected function throwJsonException()
{
if (JSON_ERROR_NONE === json_last_error()) {
return;
}
switch (json_last_error()) {
case JSON_ERROR_DEPTH:
$error = 'The maximum stack depth has been exceeded';
break;
case JSON_ERROR_STATE_MISMATCH:
$error = 'Invalid or malformed JSON';
break;
case JSON_ERROR_CTRL_CHAR:
$error = 'Control character error, possibly incorrectly encoded';
break;
case JSON_ERROR_SYNTAX:
$error = 'Syntax error';
break;
case JSON_ERROR_UTF8:
$error = 'Malformed UTF-8 characters, possibly incorrectly encoded';
break;
case JSON_ERROR_RECURSION:
$error = 'One or more recursive references in the value to be encoded';
break;
case JSON_ERROR_INF_OR_NAN:
$error = 'One or more NAN or INF values in the value to be encoded';
break;
case JSON_ERROR_UNSUPPORTED_TYPE:
$error = 'A value of a type that cannot be encoded was given';
break;
default:
$error = 'Occurred error.';
break;
}
throw new InvalidArgumentException($error);
}
|
php
|
protected function throwJsonException()
{
if (JSON_ERROR_NONE === json_last_error()) {
return;
}
switch (json_last_error()) {
case JSON_ERROR_DEPTH:
$error = 'The maximum stack depth has been exceeded';
break;
case JSON_ERROR_STATE_MISMATCH:
$error = 'Invalid or malformed JSON';
break;
case JSON_ERROR_CTRL_CHAR:
$error = 'Control character error, possibly incorrectly encoded';
break;
case JSON_ERROR_SYNTAX:
$error = 'Syntax error';
break;
case JSON_ERROR_UTF8:
$error = 'Malformed UTF-8 characters, possibly incorrectly encoded';
break;
case JSON_ERROR_RECURSION:
$error = 'One or more recursive references in the value to be encoded';
break;
case JSON_ERROR_INF_OR_NAN:
$error = 'One or more NAN or INF values in the value to be encoded';
break;
case JSON_ERROR_UNSUPPORTED_TYPE:
$error = 'A value of a type that cannot be encoded was given';
break;
default:
$error = 'Occurred error.';
break;
}
throw new InvalidArgumentException($error);
}
|
[
"protected",
"function",
"throwJsonException",
"(",
")",
"{",
"if",
"(",
"JSON_ERROR_NONE",
"===",
"json_last_error",
"(",
")",
")",
"{",
"return",
";",
"}",
"switch",
"(",
"json_last_error",
"(",
")",
")",
"{",
"case",
"JSON_ERROR_DEPTH",
":",
"$",
"error",
"=",
"'The maximum stack depth has been exceeded'",
";",
"break",
";",
"case",
"JSON_ERROR_STATE_MISMATCH",
":",
"$",
"error",
"=",
"'Invalid or malformed JSON'",
";",
"break",
";",
"case",
"JSON_ERROR_CTRL_CHAR",
":",
"$",
"error",
"=",
"'Control character error, possibly incorrectly encoded'",
";",
"break",
";",
"case",
"JSON_ERROR_SYNTAX",
":",
"$",
"error",
"=",
"'Syntax error'",
";",
"break",
";",
"case",
"JSON_ERROR_UTF8",
":",
"$",
"error",
"=",
"'Malformed UTF-8 characters, possibly incorrectly encoded'",
";",
"break",
";",
"case",
"JSON_ERROR_RECURSION",
":",
"$",
"error",
"=",
"'One or more recursive references in the value to be encoded'",
";",
"break",
";",
"case",
"JSON_ERROR_INF_OR_NAN",
":",
"$",
"error",
"=",
"'One or more NAN or INF values in the value to be encoded'",
";",
"break",
";",
"case",
"JSON_ERROR_UNSUPPORTED_TYPE",
":",
"$",
"error",
"=",
"'A value of a type that cannot be encoded was given'",
";",
"break",
";",
"default",
":",
"$",
"error",
"=",
"'Occurred error.'",
";",
"break",
";",
"}",
"throw",
"new",
"InvalidArgumentException",
"(",
"$",
"error",
")",
";",
"}"
] |
Throw Json exception
|
[
"Throw",
"Json",
"exception"
] |
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
|
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/Network/Http/Response/JsonResponse.php#L53-L98
|
221,648
|
paquettg/leaguewrap
|
src/LeagueWrap/Region.php
|
Region.isLocked
|
public function isLocked(array $regions)
{
if (count($regions) == 0)
{
// no regions are locked from this call.
return true;
}
foreach ($regions as $region)
{
if ($this->region == strtolower($region))
{
// the region is fine
return false;
}
}
// the region was not found
return true;
}
|
php
|
public function isLocked(array $regions)
{
if (count($regions) == 0)
{
// no regions are locked from this call.
return true;
}
foreach ($regions as $region)
{
if ($this->region == strtolower($region))
{
// the region is fine
return false;
}
}
// the region was not found
return true;
}
|
[
"public",
"function",
"isLocked",
"(",
"array",
"$",
"regions",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"regions",
")",
"==",
"0",
")",
"{",
"// no regions are locked from this call.",
"return",
"true",
";",
"}",
"foreach",
"(",
"$",
"regions",
"as",
"$",
"region",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"region",
"==",
"strtolower",
"(",
"$",
"region",
")",
")",
"{",
"// the region is fine",
"return",
"false",
";",
"}",
"}",
"// the region was not found",
"return",
"true",
";",
"}"
] |
Determines wether the given region is locked out.
@param array $regions
@return bool
|
[
"Determines",
"wether",
"the",
"given",
"region",
"is",
"locked",
"out",
"."
] |
0f91813b5d8292054e5e13619d591b6b14dc63e6
|
https://github.com/paquettg/leaguewrap/blob/0f91813b5d8292054e5e13619d591b6b14dc63e6/src/LeagueWrap/Region.php#L127-L146
|
221,649
|
radphp/radphp
|
src/Authorization/Rbac/ResourceCollection.php
|
ResourceCollection.add
|
public function add(ResourceInterface $resource)
{
$this->resources[$resource->getName()] = $resource;
$this->indexes[] = $resource->getName();
return $this;
}
|
php
|
public function add(ResourceInterface $resource)
{
$this->resources[$resource->getName()] = $resource;
$this->indexes[] = $resource->getName();
return $this;
}
|
[
"public",
"function",
"add",
"(",
"ResourceInterface",
"$",
"resource",
")",
"{",
"$",
"this",
"->",
"resources",
"[",
"$",
"resource",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"resource",
";",
"$",
"this",
"->",
"indexes",
"[",
"]",
"=",
"$",
"resource",
"->",
"getName",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds a resource in the collection
@param ResourceInterface $resource The Resource to add.
@return self
|
[
"Adds",
"a",
"resource",
"in",
"the",
"collection"
] |
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
|
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/Authorization/Rbac/ResourceCollection.php#L68-L74
|
221,650
|
radphp/radphp
|
src/Authorization/Rbac/ResourceCollection.php
|
ResourceCollection.remove
|
public function remove($resource)
{
$resourceName = $this->getResourceName($resource);
$index = array_search($resourceName, $this->indexes, true);
if (false !== $index) {
unset($this->indexes[$index]);
unset($this->resources[$resourceName]);
return true;
}
return false;
}
|
php
|
public function remove($resource)
{
$resourceName = $this->getResourceName($resource);
$index = array_search($resourceName, $this->indexes, true);
if (false !== $index) {
unset($this->indexes[$index]);
unset($this->resources[$resourceName]);
return true;
}
return false;
}
|
[
"public",
"function",
"remove",
"(",
"$",
"resource",
")",
"{",
"$",
"resourceName",
"=",
"$",
"this",
"->",
"getResourceName",
"(",
"$",
"resource",
")",
";",
"$",
"index",
"=",
"array_search",
"(",
"$",
"resourceName",
",",
"$",
"this",
"->",
"indexes",
",",
"true",
")",
";",
"if",
"(",
"false",
"!==",
"$",
"index",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"indexes",
"[",
"$",
"index",
"]",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"resources",
"[",
"$",
"resourceName",
"]",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Removes an resource from the collection
@param ResourceInterface|string $resource The object or resource name to remove.
@return bool If resource exists remove it and return true otherwise return false.
|
[
"Removes",
"an",
"resource",
"from",
"the",
"collection"
] |
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
|
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/Authorization/Rbac/ResourceCollection.php#L123-L136
|
221,651
|
radphp/radphp
|
src/Network/Session/SessionBag.php
|
SessionBag.initialize
|
public function initialize()
{
if (false === $this->initialized) {
if (!$this->container) {
throw new Exception('A container object is required to access the \'session\' service.');
}
$this->session = $this->container->get('session');
$this->data = $this->session->get($this->name, []);
$this->initialized = true;
}
}
|
php
|
public function initialize()
{
if (false === $this->initialized) {
if (!$this->container) {
throw new Exception('A container object is required to access the \'session\' service.');
}
$this->session = $this->container->get('session');
$this->data = $this->session->get($this->name, []);
$this->initialized = true;
}
}
|
[
"public",
"function",
"initialize",
"(",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"initialized",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"container",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'A container object is required to access the \\'session\\' service.'",
")",
";",
"}",
"$",
"this",
"->",
"session",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'session'",
")",
";",
"$",
"this",
"->",
"data",
"=",
"$",
"this",
"->",
"session",
"->",
"get",
"(",
"$",
"this",
"->",
"name",
",",
"[",
"]",
")",
";",
"$",
"this",
"->",
"initialized",
"=",
"true",
";",
"}",
"}"
] |
Initialize session bag
@throws Exception
@throws \Rad\DependencyInjection\Exception\ServiceNotFoundException
|
[
"Initialize",
"session",
"bag"
] |
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
|
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/Network/Session/SessionBag.php#L68-L80
|
221,652
|
radphp/radphp
|
src/Network/Session/SessionBag.php
|
SessionBag.set
|
public function set($key, $value)
{
$this->initialize();
$ids = explode('.', $key);
$base = &$this->data;
while ($current = array_shift($ids)) {
if (is_array($base) && array_key_exists($current, $base)) {
$base = &$base[$current];
} else {
$base[$current] = [];
$base = &$base[$current];
}
}
$base = $value;
$this->session->set($this->name, $this->data);
}
|
php
|
public function set($key, $value)
{
$this->initialize();
$ids = explode('.', $key);
$base = &$this->data;
while ($current = array_shift($ids)) {
if (is_array($base) && array_key_exists($current, $base)) {
$base = &$base[$current];
} else {
$base[$current] = [];
$base = &$base[$current];
}
}
$base = $value;
$this->session->set($this->name, $this->data);
}
|
[
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"initialize",
"(",
")",
";",
"$",
"ids",
"=",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
";",
"$",
"base",
"=",
"&",
"$",
"this",
"->",
"data",
";",
"while",
"(",
"$",
"current",
"=",
"array_shift",
"(",
"$",
"ids",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"base",
")",
"&&",
"array_key_exists",
"(",
"$",
"current",
",",
"$",
"base",
")",
")",
"{",
"$",
"base",
"=",
"&",
"$",
"base",
"[",
"$",
"current",
"]",
";",
"}",
"else",
"{",
"$",
"base",
"[",
"$",
"current",
"]",
"=",
"[",
"]",
";",
"$",
"base",
"=",
"&",
"$",
"base",
"[",
"$",
"current",
"]",
";",
"}",
"}",
"$",
"base",
"=",
"$",
"value",
";",
"$",
"this",
"->",
"session",
"->",
"set",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"this",
"->",
"data",
")",
";",
"}"
] |
Set in bag
@param string $key
@param mixed $value
@throws Exception
|
[
"Set",
"in",
"bag"
] |
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
|
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/Network/Session/SessionBag.php#L90-L108
|
221,653
|
radphp/radphp
|
src/Network/Session/SessionBag.php
|
SessionBag.get
|
public function get($key)
{
$this->initialize();
$ids = explode('.', $key);
$base = &$this->data;
while ($current = array_shift($ids)) {
if (is_array($base) && array_key_exists($current, $base)) {
$base = &$base[$current];
} else {
return null;
}
}
return $base;
}
|
php
|
public function get($key)
{
$this->initialize();
$ids = explode('.', $key);
$base = &$this->data;
while ($current = array_shift($ids)) {
if (is_array($base) && array_key_exists($current, $base)) {
$base = &$base[$current];
} else {
return null;
}
}
return $base;
}
|
[
"public",
"function",
"get",
"(",
"$",
"key",
")",
"{",
"$",
"this",
"->",
"initialize",
"(",
")",
";",
"$",
"ids",
"=",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
";",
"$",
"base",
"=",
"&",
"$",
"this",
"->",
"data",
";",
"while",
"(",
"$",
"current",
"=",
"array_shift",
"(",
"$",
"ids",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"base",
")",
"&&",
"array_key_exists",
"(",
"$",
"current",
",",
"$",
"base",
")",
")",
"{",
"$",
"base",
"=",
"&",
"$",
"base",
"[",
"$",
"current",
"]",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}",
"return",
"$",
"base",
";",
"}"
] |
Get from bag
@param string $key
@return array|null
@throws Exception
|
[
"Get",
"from",
"bag"
] |
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
|
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/Network/Session/SessionBag.php#L118-L134
|
221,654
|
radphp/radphp
|
src/AbstractApplication.php
|
AbstractApplication.handleWeb
|
public function handleWeb(ServerRequestInterface $request)
{
$this->container->set('request', $request);
/** @var Router $router */
$router = $this->container->get('router');
$router->handle();
$dispatcher = new Dispatcher();
$response = $dispatcher->setAction($router->getAction())
->setActionNamespace($router->getActionNamespace())
->setBundle($router->getBundle())
->setParams($router->getParams())
->setResponderNamespace($router->getResponderNamespace())
->setRouteMatched($router->isMatched())
->dispatch($request);
if (!$response instanceof Response) {
$response = new Response();
}
$response->send();
}
|
php
|
public function handleWeb(ServerRequestInterface $request)
{
$this->container->set('request', $request);
/** @var Router $router */
$router = $this->container->get('router');
$router->handle();
$dispatcher = new Dispatcher();
$response = $dispatcher->setAction($router->getAction())
->setActionNamespace($router->getActionNamespace())
->setBundle($router->getBundle())
->setParams($router->getParams())
->setResponderNamespace($router->getResponderNamespace())
->setRouteMatched($router->isMatched())
->dispatch($request);
if (!$response instanceof Response) {
$response = new Response();
}
$response->send();
}
|
[
"public",
"function",
"handleWeb",
"(",
"ServerRequestInterface",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"container",
"->",
"set",
"(",
"'request'",
",",
"$",
"request",
")",
";",
"/** @var Router $router */",
"$",
"router",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'router'",
")",
";",
"$",
"router",
"->",
"handle",
"(",
")",
";",
"$",
"dispatcher",
"=",
"new",
"Dispatcher",
"(",
")",
";",
"$",
"response",
"=",
"$",
"dispatcher",
"->",
"setAction",
"(",
"$",
"router",
"->",
"getAction",
"(",
")",
")",
"->",
"setActionNamespace",
"(",
"$",
"router",
"->",
"getActionNamespace",
"(",
")",
")",
"->",
"setBundle",
"(",
"$",
"router",
"->",
"getBundle",
"(",
")",
")",
"->",
"setParams",
"(",
"$",
"router",
"->",
"getParams",
"(",
")",
")",
"->",
"setResponderNamespace",
"(",
"$",
"router",
"->",
"getResponderNamespace",
"(",
")",
")",
"->",
"setRouteMatched",
"(",
"$",
"router",
"->",
"isMatched",
"(",
")",
")",
"->",
"dispatch",
"(",
"$",
"request",
")",
";",
"if",
"(",
"!",
"$",
"response",
"instanceof",
"Response",
")",
"{",
"$",
"response",
"=",
"new",
"Response",
"(",
")",
";",
"}",
"$",
"response",
"->",
"send",
"(",
")",
";",
"}"
] |
Handle Web Request
@param ServerRequestInterface $request
@throws BaseException
@throws DependencyInjection\Exception\ServiceLockedException
@throws DependencyInjection\Exception\ServiceNotFoundException
@throws NotFoundException
@throws Response\Exception
|
[
"Handle",
"Web",
"Request"
] |
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
|
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/AbstractApplication.php#L111-L133
|
221,655
|
radphp/radphp
|
src/AbstractApplication.php
|
AbstractApplication.handleCli
|
public function handleCli($argv)
{
if (!$this->run) {
if (!(count($argv) >= 2)) {
return;
}
$route = str_replace(':', '/', $argv[1]);
unset($argv[0]);
$this->getRouter()->handle($route);
$this->callCli(array_values($argv));
$this->run = true;
} else {
throw new BaseException('Application is run.');
}
}
|
php
|
public function handleCli($argv)
{
if (!$this->run) {
if (!(count($argv) >= 2)) {
return;
}
$route = str_replace(':', '/', $argv[1]);
unset($argv[0]);
$this->getRouter()->handle($route);
$this->callCli(array_values($argv));
$this->run = true;
} else {
throw new BaseException('Application is run.');
}
}
|
[
"public",
"function",
"handleCli",
"(",
"$",
"argv",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"run",
")",
"{",
"if",
"(",
"!",
"(",
"count",
"(",
"$",
"argv",
")",
">=",
"2",
")",
")",
"{",
"return",
";",
"}",
"$",
"route",
"=",
"str_replace",
"(",
"':'",
",",
"'/'",
",",
"$",
"argv",
"[",
"1",
"]",
")",
";",
"unset",
"(",
"$",
"argv",
"[",
"0",
"]",
")",
";",
"$",
"this",
"->",
"getRouter",
"(",
")",
"->",
"handle",
"(",
"$",
"route",
")",
";",
"$",
"this",
"->",
"callCli",
"(",
"array_values",
"(",
"$",
"argv",
")",
")",
";",
"$",
"this",
"->",
"run",
"=",
"true",
";",
"}",
"else",
"{",
"throw",
"new",
"BaseException",
"(",
"'Application is run.'",
")",
";",
"}",
"}"
] |
Run application in cli request
@param $argv
@throws BaseException
@throws MissingMethodException
|
[
"Run",
"application",
"in",
"cli",
"request"
] |
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
|
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/AbstractApplication.php#L143-L159
|
221,656
|
radphp/radphp
|
src/AbstractApplication.php
|
AbstractApplication.loadConfig
|
private function loadConfig()
{
$appBundle = null;
$this->getEventManager()->dispatch(self::EVENT_BEFORE_LOAD_CONFIG, $this);
foreach ($this->registerBundles() as $bundle) {
if ($bundle instanceof \App\AppBundle) {
$appBundle = $bundle;
continue;
}
$bundle->loadConfig();
}
if (!$appBundle instanceof \App\AppBundle) {
throw new BaseException('AppBundle does not exist.');
}
$appBundle->loadConfig();
$this->getEventManager()->dispatch(self::EVENT_AFTER_LOAD_CONFIG, $this);
}
|
php
|
private function loadConfig()
{
$appBundle = null;
$this->getEventManager()->dispatch(self::EVENT_BEFORE_LOAD_CONFIG, $this);
foreach ($this->registerBundles() as $bundle) {
if ($bundle instanceof \App\AppBundle) {
$appBundle = $bundle;
continue;
}
$bundle->loadConfig();
}
if (!$appBundle instanceof \App\AppBundle) {
throw new BaseException('AppBundle does not exist.');
}
$appBundle->loadConfig();
$this->getEventManager()->dispatch(self::EVENT_AFTER_LOAD_CONFIG, $this);
}
|
[
"private",
"function",
"loadConfig",
"(",
")",
"{",
"$",
"appBundle",
"=",
"null",
";",
"$",
"this",
"->",
"getEventManager",
"(",
")",
"->",
"dispatch",
"(",
"self",
"::",
"EVENT_BEFORE_LOAD_CONFIG",
",",
"$",
"this",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"registerBundles",
"(",
")",
"as",
"$",
"bundle",
")",
"{",
"if",
"(",
"$",
"bundle",
"instanceof",
"\\",
"App",
"\\",
"AppBundle",
")",
"{",
"$",
"appBundle",
"=",
"$",
"bundle",
";",
"continue",
";",
"}",
"$",
"bundle",
"->",
"loadConfig",
"(",
")",
";",
"}",
"if",
"(",
"!",
"$",
"appBundle",
"instanceof",
"\\",
"App",
"\\",
"AppBundle",
")",
"{",
"throw",
"new",
"BaseException",
"(",
"'AppBundle does not exist.'",
")",
";",
"}",
"$",
"appBundle",
"->",
"loadConfig",
"(",
")",
";",
"$",
"this",
"->",
"getEventManager",
"(",
")",
"->",
"dispatch",
"(",
"self",
"::",
"EVENT_AFTER_LOAD_CONFIG",
",",
"$",
"this",
")",
";",
"}"
] |
Load config from bundles
@throws BaseException
|
[
"Load",
"config",
"from",
"bundles"
] |
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
|
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/AbstractApplication.php#L261-L281
|
221,657
|
radphp/radphp
|
src/AbstractApplication.php
|
AbstractApplication.loadService
|
private function loadService()
{
$this->getEventManager()->dispatch(self::EVENT_BEFORE_LOAD_SERVICE, $this);
foreach ($this->registerBundles() as $bundle) {
$bundle->loadService();
}
$this->getEventManager()->dispatch(self::EVENT_AFTER_LOAD_SERVICE, $this);
}
|
php
|
private function loadService()
{
$this->getEventManager()->dispatch(self::EVENT_BEFORE_LOAD_SERVICE, $this);
foreach ($this->registerBundles() as $bundle) {
$bundle->loadService();
}
$this->getEventManager()->dispatch(self::EVENT_AFTER_LOAD_SERVICE, $this);
}
|
[
"private",
"function",
"loadService",
"(",
")",
"{",
"$",
"this",
"->",
"getEventManager",
"(",
")",
"->",
"dispatch",
"(",
"self",
"::",
"EVENT_BEFORE_LOAD_SERVICE",
",",
"$",
"this",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"registerBundles",
"(",
")",
"as",
"$",
"bundle",
")",
"{",
"$",
"bundle",
"->",
"loadService",
"(",
")",
";",
"}",
"$",
"this",
"->",
"getEventManager",
"(",
")",
"->",
"dispatch",
"(",
"self",
"::",
"EVENT_AFTER_LOAD_SERVICE",
",",
"$",
"this",
")",
";",
"}"
] |
Load services from bundles
|
[
"Load",
"services",
"from",
"bundles"
] |
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
|
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/AbstractApplication.php#L286-L295
|
221,658
|
radphp/radphp
|
src/AbstractApplication.php
|
AbstractApplication.loadServicesFromConfig
|
protected function loadServicesFromConfig()
{
foreach (Config::get('services', []) as $name => $service) {
$service += [
'shared' => false,
'locked' => false,
'definition' => []
];
$this->container->set($name, $service['definition'], $service['shared'], $service['locked']);
}
}
|
php
|
protected function loadServicesFromConfig()
{
foreach (Config::get('services', []) as $name => $service) {
$service += [
'shared' => false,
'locked' => false,
'definition' => []
];
$this->container->set($name, $service['definition'], $service['shared'], $service['locked']);
}
}
|
[
"protected",
"function",
"loadServicesFromConfig",
"(",
")",
"{",
"foreach",
"(",
"Config",
"::",
"get",
"(",
"'services'",
",",
"[",
"]",
")",
"as",
"$",
"name",
"=>",
"$",
"service",
")",
"{",
"$",
"service",
"+=",
"[",
"'shared'",
"=>",
"false",
",",
"'locked'",
"=>",
"false",
",",
"'definition'",
"=>",
"[",
"]",
"]",
";",
"$",
"this",
"->",
"container",
"->",
"set",
"(",
"$",
"name",
",",
"$",
"service",
"[",
"'definition'",
"]",
",",
"$",
"service",
"[",
"'shared'",
"]",
",",
"$",
"service",
"[",
"'locked'",
"]",
")",
";",
"}",
"}"
] |
Load services from config
@throws DependencyInjection\Exception\ServiceLockedException
|
[
"Load",
"services",
"from",
"config"
] |
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
|
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/AbstractApplication.php#L302-L313
|
221,659
|
neos/fluid
|
Classes/TYPO3/Fluid/ViewHelpers/Form/UploadViewHelper.php
|
UploadViewHelper.render
|
public function render()
{
$nameAttribute = $this->getName();
$this->registerFieldNameForFormTokenGeneration($nameAttribute);
$output = '';
$resource = $this->getUploadedResource();
if ($resource !== null) {
$resourceIdentityAttribute = '';
if ($this->hasArgument('id')) {
$resourceIdentityAttribute = ' id="' . htmlspecialchars($this->arguments['id']) . '-resource-identity"';
}
$output .= '<input type="hidden" name="'. htmlspecialchars($nameAttribute) . '[originallySubmittedResource][__identity]" value="' . $this->persistenceManager->getIdentifierByObject($resource) . '"' . $resourceIdentityAttribute . ' />';
}
if ($this->hasArgument('collection') && $this->arguments['collection'] !== false && $this->arguments['collection'] !== '') {
$output .= '<input type="hidden" name="'. htmlspecialchars($nameAttribute) . '[__collectionName]" value="' . htmlspecialchars($this->arguments['collection']) . '" />';
}
$this->tag->addAttribute('type', 'file');
$this->tag->addAttribute('name', $nameAttribute);
$this->addAdditionalIdentityPropertiesIfNeeded();
$this->setErrorClassAttribute();
$output .= $this->tag->render();
return $output;
}
|
php
|
public function render()
{
$nameAttribute = $this->getName();
$this->registerFieldNameForFormTokenGeneration($nameAttribute);
$output = '';
$resource = $this->getUploadedResource();
if ($resource !== null) {
$resourceIdentityAttribute = '';
if ($this->hasArgument('id')) {
$resourceIdentityAttribute = ' id="' . htmlspecialchars($this->arguments['id']) . '-resource-identity"';
}
$output .= '<input type="hidden" name="'. htmlspecialchars($nameAttribute) . '[originallySubmittedResource][__identity]" value="' . $this->persistenceManager->getIdentifierByObject($resource) . '"' . $resourceIdentityAttribute . ' />';
}
if ($this->hasArgument('collection') && $this->arguments['collection'] !== false && $this->arguments['collection'] !== '') {
$output .= '<input type="hidden" name="'. htmlspecialchars($nameAttribute) . '[__collectionName]" value="' . htmlspecialchars($this->arguments['collection']) . '" />';
}
$this->tag->addAttribute('type', 'file');
$this->tag->addAttribute('name', $nameAttribute);
$this->addAdditionalIdentityPropertiesIfNeeded();
$this->setErrorClassAttribute();
$output .= $this->tag->render();
return $output;
}
|
[
"public",
"function",
"render",
"(",
")",
"{",
"$",
"nameAttribute",
"=",
"$",
"this",
"->",
"getName",
"(",
")",
";",
"$",
"this",
"->",
"registerFieldNameForFormTokenGeneration",
"(",
"$",
"nameAttribute",
")",
";",
"$",
"output",
"=",
"''",
";",
"$",
"resource",
"=",
"$",
"this",
"->",
"getUploadedResource",
"(",
")",
";",
"if",
"(",
"$",
"resource",
"!==",
"null",
")",
"{",
"$",
"resourceIdentityAttribute",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"hasArgument",
"(",
"'id'",
")",
")",
"{",
"$",
"resourceIdentityAttribute",
"=",
"' id=\"'",
".",
"htmlspecialchars",
"(",
"$",
"this",
"->",
"arguments",
"[",
"'id'",
"]",
")",
".",
"'-resource-identity\"'",
";",
"}",
"$",
"output",
".=",
"'<input type=\"hidden\" name=\"'",
".",
"htmlspecialchars",
"(",
"$",
"nameAttribute",
")",
".",
"'[originallySubmittedResource][__identity]\" value=\"'",
".",
"$",
"this",
"->",
"persistenceManager",
"->",
"getIdentifierByObject",
"(",
"$",
"resource",
")",
".",
"'\"'",
".",
"$",
"resourceIdentityAttribute",
".",
"' />'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"hasArgument",
"(",
"'collection'",
")",
"&&",
"$",
"this",
"->",
"arguments",
"[",
"'collection'",
"]",
"!==",
"false",
"&&",
"$",
"this",
"->",
"arguments",
"[",
"'collection'",
"]",
"!==",
"''",
")",
"{",
"$",
"output",
".=",
"'<input type=\"hidden\" name=\"'",
".",
"htmlspecialchars",
"(",
"$",
"nameAttribute",
")",
".",
"'[__collectionName]\" value=\"'",
".",
"htmlspecialchars",
"(",
"$",
"this",
"->",
"arguments",
"[",
"'collection'",
"]",
")",
".",
"'\" />'",
";",
"}",
"$",
"this",
"->",
"tag",
"->",
"addAttribute",
"(",
"'type'",
",",
"'file'",
")",
";",
"$",
"this",
"->",
"tag",
"->",
"addAttribute",
"(",
"'name'",
",",
"$",
"nameAttribute",
")",
";",
"$",
"this",
"->",
"addAdditionalIdentityPropertiesIfNeeded",
"(",
")",
";",
"$",
"this",
"->",
"setErrorClassAttribute",
"(",
")",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"tag",
"->",
"render",
"(",
")",
";",
"return",
"$",
"output",
";",
"}"
] |
Renders the upload field.
@return string
@api
|
[
"Renders",
"the",
"upload",
"field",
"."
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/ViewHelpers/Form/UploadViewHelper.php#L96-L123
|
221,660
|
mediamonks/php-rest-api
|
src/EventSubscriber/RestApiEventSubscriber.php
|
RestApiEventSubscriber.onException
|
public function onException(GetResponseForExceptionEvent $event)
{
if (!$this->eventRequestMatches($event)) {
return;
}
$event->setResponse($this->responseTransformer->createResponseFromContent($event->getException()));
}
|
php
|
public function onException(GetResponseForExceptionEvent $event)
{
if (!$this->eventRequestMatches($event)) {
return;
}
$event->setResponse($this->responseTransformer->createResponseFromContent($event->getException()));
}
|
[
"public",
"function",
"onException",
"(",
"GetResponseForExceptionEvent",
"$",
"event",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"eventRequestMatches",
"(",
"$",
"event",
")",
")",
"{",
"return",
";",
"}",
"$",
"event",
"->",
"setResponse",
"(",
"$",
"this",
"->",
"responseTransformer",
"->",
"createResponseFromContent",
"(",
"$",
"event",
"->",
"getException",
"(",
")",
")",
")",
";",
"}"
] |
convert exception to rest api response
@param GetResponseForExceptionEvent $event
|
[
"convert",
"exception",
"to",
"rest",
"api",
"response"
] |
96253c974238771ec3229c9a09a561c83c484c00
|
https://github.com/mediamonks/php-rest-api/blob/96253c974238771ec3229c9a09a561c83c484c00/src/EventSubscriber/RestApiEventSubscriber.php#L86-L92
|
221,661
|
mediamonks/php-rest-api
|
src/EventSubscriber/RestApiEventSubscriber.php
|
RestApiEventSubscriber.onView
|
public function onView(GetResponseForControllerResultEvent $event)
{
if (!$this->eventRequestMatches($event)) {
return;
}
$event->setResponse($this->responseTransformer->createResponseFromContent($event->getControllerResult()));
}
|
php
|
public function onView(GetResponseForControllerResultEvent $event)
{
if (!$this->eventRequestMatches($event)) {
return;
}
$event->setResponse($this->responseTransformer->createResponseFromContent($event->getControllerResult()));
}
|
[
"public",
"function",
"onView",
"(",
"GetResponseForControllerResultEvent",
"$",
"event",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"eventRequestMatches",
"(",
"$",
"event",
")",
")",
"{",
"return",
";",
"}",
"$",
"event",
"->",
"setResponse",
"(",
"$",
"this",
"->",
"responseTransformer",
"->",
"createResponseFromContent",
"(",
"$",
"event",
"->",
"getControllerResult",
"(",
")",
")",
")",
";",
"}"
] |
convert response to rest api response
@param GetResponseForControllerResultEvent $event
|
[
"convert",
"response",
"to",
"rest",
"api",
"response"
] |
96253c974238771ec3229c9a09a561c83c484c00
|
https://github.com/mediamonks/php-rest-api/blob/96253c974238771ec3229c9a09a561c83c484c00/src/EventSubscriber/RestApiEventSubscriber.php#L99-L105
|
221,662
|
mediamonks/php-rest-api
|
src/EventSubscriber/RestApiEventSubscriber.php
|
RestApiEventSubscriber.onResponseEarly
|
public function onResponseEarly(FilterResponseEvent $event)
{
if (!$this->eventRequestMatches($event)) {
return;
}
$event->setResponse($this->responseTransformer->transformEarly($event->getRequest(), $event->getResponse()));
}
|
php
|
public function onResponseEarly(FilterResponseEvent $event)
{
if (!$this->eventRequestMatches($event)) {
return;
}
$event->setResponse($this->responseTransformer->transformEarly($event->getRequest(), $event->getResponse()));
}
|
[
"public",
"function",
"onResponseEarly",
"(",
"FilterResponseEvent",
"$",
"event",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"eventRequestMatches",
"(",
"$",
"event",
")",
")",
"{",
"return",
";",
"}",
"$",
"event",
"->",
"setResponse",
"(",
"$",
"this",
"->",
"responseTransformer",
"->",
"transformEarly",
"(",
"$",
"event",
"->",
"getRequest",
"(",
")",
",",
"$",
"event",
"->",
"getResponse",
"(",
")",
")",
")",
";",
"}"
] |
converts content to correct output format
@param FilterResponseEvent $event
|
[
"converts",
"content",
"to",
"correct",
"output",
"format"
] |
96253c974238771ec3229c9a09a561c83c484c00
|
https://github.com/mediamonks/php-rest-api/blob/96253c974238771ec3229c9a09a561c83c484c00/src/EventSubscriber/RestApiEventSubscriber.php#L112-L118
|
221,663
|
mediamonks/php-rest-api
|
src/EventSubscriber/RestApiEventSubscriber.php
|
RestApiEventSubscriber.onResponseLate
|
public function onResponseLate(FilterResponseEvent $event)
{
if (!$this->eventRequestMatches($event)) {
return;
}
$this->responseTransformer->transformLate($event->getRequest(), $event->getResponse());
}
|
php
|
public function onResponseLate(FilterResponseEvent $event)
{
if (!$this->eventRequestMatches($event)) {
return;
}
$this->responseTransformer->transformLate($event->getRequest(), $event->getResponse());
}
|
[
"public",
"function",
"onResponseLate",
"(",
"FilterResponseEvent",
"$",
"event",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"eventRequestMatches",
"(",
"$",
"event",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"responseTransformer",
"->",
"transformLate",
"(",
"$",
"event",
"->",
"getRequest",
"(",
")",
",",
"$",
"event",
"->",
"getResponse",
"(",
")",
")",
";",
"}"
] |
wrap the content if needed
@param FilterResponseEvent $event
|
[
"wrap",
"the",
"content",
"if",
"needed"
] |
96253c974238771ec3229c9a09a561c83c484c00
|
https://github.com/mediamonks/php-rest-api/blob/96253c974238771ec3229c9a09a561c83c484c00/src/EventSubscriber/RestApiEventSubscriber.php#L125-L131
|
221,664
|
radphp/radphp
|
src/Network/Http/Cookie.php
|
Cookie.send
|
public function send()
{
if ($this->useEncryption && !empty($this->value)) {
$value = $this->encrypt($this->value);
} else {
$value = $this->value;
}
setcookie($this->name, $value, $this->expire, $this->path, $this->domain, $this->secure, $this->httpOnly);
return $this;
}
|
php
|
public function send()
{
if ($this->useEncryption && !empty($this->value)) {
$value = $this->encrypt($this->value);
} else {
$value = $this->value;
}
setcookie($this->name, $value, $this->expire, $this->path, $this->domain, $this->secure, $this->httpOnly);
return $this;
}
|
[
"public",
"function",
"send",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"useEncryption",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"value",
")",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"encrypt",
"(",
"$",
"this",
"->",
"value",
")",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"value",
";",
"}",
"setcookie",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"value",
",",
"$",
"this",
"->",
"expire",
",",
"$",
"this",
"->",
"path",
",",
"$",
"this",
"->",
"domain",
",",
"$",
"this",
"->",
"secure",
",",
"$",
"this",
"->",
"httpOnly",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sends the cookie to the HTTP client Stores the cookie definition in session
@return Cookie
|
[
"Sends",
"the",
"cookie",
"to",
"the",
"HTTP",
"client",
"Stores",
"the",
"cookie",
"definition",
"in",
"session"
] |
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
|
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/Network/Http/Cookie.php#L150-L161
|
221,665
|
radphp/radphp
|
src/Network/Http/Cookie.php
|
Cookie.delete
|
public function delete()
{
return setcookie(
$this->name,
null,
1,
$this->path,
$this->domain,
$this->secure,
$this->httpOnly
);
}
|
php
|
public function delete()
{
return setcookie(
$this->name,
null,
1,
$this->path,
$this->domain,
$this->secure,
$this->httpOnly
);
}
|
[
"public",
"function",
"delete",
"(",
")",
"{",
"return",
"setcookie",
"(",
"$",
"this",
"->",
"name",
",",
"null",
",",
"1",
",",
"$",
"this",
"->",
"path",
",",
"$",
"this",
"->",
"domain",
",",
"$",
"this",
"->",
"secure",
",",
"$",
"this",
"->",
"httpOnly",
")",
";",
"}"
] |
Deletes the cookie by setting an expire time in the past
@return bool
|
[
"Deletes",
"the",
"cookie",
"by",
"setting",
"an",
"expire",
"time",
"in",
"the",
"past"
] |
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
|
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/Network/Http/Cookie.php#L168-L179
|
221,666
|
radphp/radphp
|
src/Network/Http/Cookie.php
|
Cookie.encrypt
|
protected function encrypt($string)
{
$iv = mcrypt_create_iv(mcrypt_get_iv_size($this->cipher, $this->cipherMode), MCRYPT_RAND);
return mcrypt_encrypt($this->cipher, $this->secretKey, $string, $this->cipherMode, $iv);
}
|
php
|
protected function encrypt($string)
{
$iv = mcrypt_create_iv(mcrypt_get_iv_size($this->cipher, $this->cipherMode), MCRYPT_RAND);
return mcrypt_encrypt($this->cipher, $this->secretKey, $string, $this->cipherMode, $iv);
}
|
[
"protected",
"function",
"encrypt",
"(",
"$",
"string",
")",
"{",
"$",
"iv",
"=",
"mcrypt_create_iv",
"(",
"mcrypt_get_iv_size",
"(",
"$",
"this",
"->",
"cipher",
",",
"$",
"this",
"->",
"cipherMode",
")",
",",
"MCRYPT_RAND",
")",
";",
"return",
"mcrypt_encrypt",
"(",
"$",
"this",
"->",
"cipher",
",",
"$",
"this",
"->",
"secretKey",
",",
"$",
"string",
",",
"$",
"this",
"->",
"cipherMode",
",",
"$",
"iv",
")",
";",
"}"
] |
Encrypt cookie value
@param string $string
@return string
|
[
"Encrypt",
"cookie",
"value"
] |
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
|
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/Network/Http/Cookie.php#L342-L347
|
221,667
|
radphp/radphp
|
src/Network/Http/Cookie.php
|
Cookie.decrypt
|
protected function decrypt($encryptedString)
{
$iv = mcrypt_create_iv(mcrypt_get_iv_size($this->cipher, $this->cipherMode), MCRYPT_RAND);
return mcrypt_decrypt($this->cipher, $this->secretKey, $encryptedString, $this->cipherMode, $iv);
}
|
php
|
protected function decrypt($encryptedString)
{
$iv = mcrypt_create_iv(mcrypt_get_iv_size($this->cipher, $this->cipherMode), MCRYPT_RAND);
return mcrypt_decrypt($this->cipher, $this->secretKey, $encryptedString, $this->cipherMode, $iv);
}
|
[
"protected",
"function",
"decrypt",
"(",
"$",
"encryptedString",
")",
"{",
"$",
"iv",
"=",
"mcrypt_create_iv",
"(",
"mcrypt_get_iv_size",
"(",
"$",
"this",
"->",
"cipher",
",",
"$",
"this",
"->",
"cipherMode",
")",
",",
"MCRYPT_RAND",
")",
";",
"return",
"mcrypt_decrypt",
"(",
"$",
"this",
"->",
"cipher",
",",
"$",
"this",
"->",
"secretKey",
",",
"$",
"encryptedString",
",",
"$",
"this",
"->",
"cipherMode",
",",
"$",
"iv",
")",
";",
"}"
] |
Decrypt cookie value
@param string $encryptedString
@return string
|
[
"Decrypt",
"cookie",
"value"
] |
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
|
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/Network/Http/Cookie.php#L356-L361
|
221,668
|
radphp/radphp
|
src/Authorization/Rbac.php
|
Rbac.addRole
|
public function addRole($role, array $resources = [])
{
if ($role instanceof RoleInterface) {
$this->roles[$role->getName()] = $role;
} else {
$role = new Role($role, $resources);
$this->roles[$role->getName()] = $role;
}
}
|
php
|
public function addRole($role, array $resources = [])
{
if ($role instanceof RoleInterface) {
$this->roles[$role->getName()] = $role;
} else {
$role = new Role($role, $resources);
$this->roles[$role->getName()] = $role;
}
}
|
[
"public",
"function",
"addRole",
"(",
"$",
"role",
",",
"array",
"$",
"resources",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"role",
"instanceof",
"RoleInterface",
")",
"{",
"$",
"this",
"->",
"roles",
"[",
"$",
"role",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"role",
";",
"}",
"else",
"{",
"$",
"role",
"=",
"new",
"Role",
"(",
"$",
"role",
",",
"$",
"resources",
")",
";",
"$",
"this",
"->",
"roles",
"[",
"$",
"role",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"role",
";",
"}",
"}"
] |
Add role override if exists
@param RoleInterface|string $role Role name or object
@param ResourceCollection|array $resources Role resources
|
[
"Add",
"role",
"override",
"if",
"exists"
] |
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
|
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/Authorization/Rbac.php#L31-L39
|
221,669
|
radphp/radphp
|
src/Authorization/Rbac.php
|
Rbac.hasRole
|
public function hasRole($role)
{
if ($role instanceof RoleInterface) {
$role = $role->getName();
}
if (!is_string($role)) {
throw new InvalidArgumentException(
'Role argument must be string or an object implemented "Rad\Authorization\Rbac\RoleInterface".'
);
}
return isset($this->roles[$role]);
}
|
php
|
public function hasRole($role)
{
if ($role instanceof RoleInterface) {
$role = $role->getName();
}
if (!is_string($role)) {
throw new InvalidArgumentException(
'Role argument must be string or an object implemented "Rad\Authorization\Rbac\RoleInterface".'
);
}
return isset($this->roles[$role]);
}
|
[
"public",
"function",
"hasRole",
"(",
"$",
"role",
")",
"{",
"if",
"(",
"$",
"role",
"instanceof",
"RoleInterface",
")",
"{",
"$",
"role",
"=",
"$",
"role",
"->",
"getName",
"(",
")",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"role",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Role argument must be string or an object implemented \"Rad\\Authorization\\Rbac\\RoleInterface\".'",
")",
";",
"}",
"return",
"isset",
"(",
"$",
"this",
"->",
"roles",
"[",
"$",
"role",
"]",
")",
";",
"}"
] |
Has role exists
@param RoleInterface|string $role Role name or object
@return bool
|
[
"Has",
"role",
"exists"
] |
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
|
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/Authorization/Rbac.php#L64-L77
|
221,670
|
radphp/radphp
|
src/Authorization/Rbac.php
|
Rbac.isGranted
|
public function isGranted($resource)
{
foreach ($this->roles as $role) {
if (true === $role->hasResource($resource)) {
return true;
}
}
return false;
}
|
php
|
public function isGranted($resource)
{
foreach ($this->roles as $role) {
if (true === $role->hasResource($resource)) {
return true;
}
}
return false;
}
|
[
"public",
"function",
"isGranted",
"(",
"$",
"resource",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"roles",
"as",
"$",
"role",
")",
"{",
"if",
"(",
"true",
"===",
"$",
"role",
"->",
"hasResource",
"(",
"$",
"resource",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
User is granted
@param ResourceInterface|string $resource Resource name or object
@return bool
|
[
"User",
"is",
"granted"
] |
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
|
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/Authorization/Rbac.php#L86-L95
|
221,671
|
radphp/radphp
|
src/DependencyInjection/DefinitionResolver.php
|
DefinitionResolver.fromArray
|
protected function fromArray(array $definition)
{
$definition += $this->defaultDefinition;
$refClass = new ReflectionClass($definition['class']);
$instance = $refClass->newInstanceArgs(self::parseArguments($definition['arguments']));
foreach ($definition['call'] as $methodName => $args) {
$refMethod = new ReflectionMethod($instance, $methodName);
$refMethod->invokeArgs($instance, self::parseArguments($args));
}
return $instance;
}
|
php
|
protected function fromArray(array $definition)
{
$definition += $this->defaultDefinition;
$refClass = new ReflectionClass($definition['class']);
$instance = $refClass->newInstanceArgs(self::parseArguments($definition['arguments']));
foreach ($definition['call'] as $methodName => $args) {
$refMethod = new ReflectionMethod($instance, $methodName);
$refMethod->invokeArgs($instance, self::parseArguments($args));
}
return $instance;
}
|
[
"protected",
"function",
"fromArray",
"(",
"array",
"$",
"definition",
")",
"{",
"$",
"definition",
"+=",
"$",
"this",
"->",
"defaultDefinition",
";",
"$",
"refClass",
"=",
"new",
"ReflectionClass",
"(",
"$",
"definition",
"[",
"'class'",
"]",
")",
";",
"$",
"instance",
"=",
"$",
"refClass",
"->",
"newInstanceArgs",
"(",
"self",
"::",
"parseArguments",
"(",
"$",
"definition",
"[",
"'arguments'",
"]",
")",
")",
";",
"foreach",
"(",
"$",
"definition",
"[",
"'call'",
"]",
"as",
"$",
"methodName",
"=>",
"$",
"args",
")",
"{",
"$",
"refMethod",
"=",
"new",
"ReflectionMethod",
"(",
"$",
"instance",
",",
"$",
"methodName",
")",
";",
"$",
"refMethod",
"->",
"invokeArgs",
"(",
"$",
"instance",
",",
"self",
"::",
"parseArguments",
"(",
"$",
"args",
")",
")",
";",
"}",
"return",
"$",
"instance",
";",
"}"
] |
Load definition from array
@param array $definition
@return object
|
[
"Load",
"definition",
"from",
"array"
] |
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
|
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/DependencyInjection/DefinitionResolver.php#L71-L84
|
221,672
|
twizoapi/lib-api-php
|
src/AbstractClient.php
|
AbstractClient.generateResponse
|
protected function generateResponse($statusCode, $json)
{
if (empty($json) && $statusCode == Response::REST_SUCCESS_NO_CONTENT) {
return new Response(array(), $statusCode);
} else {
$body = json_decode($json, true);
if ($body == null) {
throw new ClientException('Error while sending request to api; Received invalid json: ' . $json, ClientException::SERVER_UNAVAILABLE);
}
$response = new Response($body, $statusCode);
$this->validateServerResponse($response);
return $response;
}
}
|
php
|
protected function generateResponse($statusCode, $json)
{
if (empty($json) && $statusCode == Response::REST_SUCCESS_NO_CONTENT) {
return new Response(array(), $statusCode);
} else {
$body = json_decode($json, true);
if ($body == null) {
throw new ClientException('Error while sending request to api; Received invalid json: ' . $json, ClientException::SERVER_UNAVAILABLE);
}
$response = new Response($body, $statusCode);
$this->validateServerResponse($response);
return $response;
}
}
|
[
"protected",
"function",
"generateResponse",
"(",
"$",
"statusCode",
",",
"$",
"json",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"json",
")",
"&&",
"$",
"statusCode",
"==",
"Response",
"::",
"REST_SUCCESS_NO_CONTENT",
")",
"{",
"return",
"new",
"Response",
"(",
"array",
"(",
")",
",",
"$",
"statusCode",
")",
";",
"}",
"else",
"{",
"$",
"body",
"=",
"json_decode",
"(",
"$",
"json",
",",
"true",
")",
";",
"if",
"(",
"$",
"body",
"==",
"null",
")",
"{",
"throw",
"new",
"ClientException",
"(",
"'Error while sending request to api; Received invalid json: '",
".",
"$",
"json",
",",
"ClientException",
"::",
"SERVER_UNAVAILABLE",
")",
";",
"}",
"$",
"response",
"=",
"new",
"Response",
"(",
"$",
"body",
",",
"$",
"statusCode",
")",
";",
"$",
"this",
"->",
"validateServerResponse",
"(",
"$",
"response",
")",
";",
"return",
"$",
"response",
";",
"}",
"}"
] |
Decode json array and convert it to an array
@param int $statusCode
@param string $json
@return Response
@throws ClientException
|
[
"Decode",
"json",
"array",
"and",
"convert",
"it",
"to",
"an",
"array"
] |
2e545d859784184138332c9b5bfc063940e3c926
|
https://github.com/twizoapi/lib-api-php/blob/2e545d859784184138332c9b5bfc063940e3c926/src/AbstractClient.php#L55-L69
|
221,673
|
twizoapi/lib-api-php
|
src/AbstractClient.php
|
AbstractClient.validateServerResponse
|
protected function validateServerResponse(Response $response)
{
switch ($response->getStatusCode()) {
case Response::REST_CLIENT_ERROR_UNAUTHORIZED:
throw new ClientException('You have provided an invalid API key', ClientException::INVALID_APPLICATION_SECRET, $response);
break;
case Response::REST_CLIENT_ERROR_FORBIDDEN:
throw new ClientException('Your account is not enabled for the service', ClientException::INVALID_APPLICATION_SECRET, $response);
break;
case Response::REST_CLIENT_ERROR_NOT_FOUND:
throw new ClientException('The requested entity was not found on the server', ClientException::ENTITY_NOT_FOUND, $response);
break;
case Response::REST_CLIENT_ERROR_CONFLICT:
$body = $response->getBody();
$message = (isset($body['detail'])) ? $body['detail'] : 'The request was rejected due to an conflict.';
throw new ClientException($message, ClientException::INVALID_RESPONSE, $response);
break;
case Response::REST_CLIENT_ERROR_UNPROCESSABLE_ENTITY:
$body = $response->getBody();
$message = (isset($body['detail'])) ? $body['detail'] : 'Unable to process the request';
throw new ClientException($message, ClientException::INVALID_RESPONSE, $response);
break;
case Response::REST_CLIENT_ERROR_LOCKED:
$body = $response->getBody();
$message = (isset($body['detail'])) ? $body['detail'] : 'The request could not be processed as the entity was locked.';
throw new ClientException($message, ClientException::INVALID_RESPONSE, $response);
break;
case Response::REST_CLIENT_ERROR_TOO_MANY_REQUESTS:
throw new ClientException('You are sending too fast and your calls are throttled', ClientException::SERVER_UNAVAILABLE, $response);
break;
case Response::REST_CLIENT_ERROR_PAYMENT_REQUIRED:
throw new ClientException('Insufficient credit for your wallet', ClientException::INSUFFICIENT_CREDIT, $response);
break;
case Response::REST_SUCCESS_OK:
case Response::REST_SUCCESS_CREATED:
break; // Valid response
default:
throw new ClientException(sprintf('Unknown status code %d received from server', $response->getStatusCode()), ClientException::INVALID_RESPONSE, $response);
break;
}
}
|
php
|
protected function validateServerResponse(Response $response)
{
switch ($response->getStatusCode()) {
case Response::REST_CLIENT_ERROR_UNAUTHORIZED:
throw new ClientException('You have provided an invalid API key', ClientException::INVALID_APPLICATION_SECRET, $response);
break;
case Response::REST_CLIENT_ERROR_FORBIDDEN:
throw new ClientException('Your account is not enabled for the service', ClientException::INVALID_APPLICATION_SECRET, $response);
break;
case Response::REST_CLIENT_ERROR_NOT_FOUND:
throw new ClientException('The requested entity was not found on the server', ClientException::ENTITY_NOT_FOUND, $response);
break;
case Response::REST_CLIENT_ERROR_CONFLICT:
$body = $response->getBody();
$message = (isset($body['detail'])) ? $body['detail'] : 'The request was rejected due to an conflict.';
throw new ClientException($message, ClientException::INVALID_RESPONSE, $response);
break;
case Response::REST_CLIENT_ERROR_UNPROCESSABLE_ENTITY:
$body = $response->getBody();
$message = (isset($body['detail'])) ? $body['detail'] : 'Unable to process the request';
throw new ClientException($message, ClientException::INVALID_RESPONSE, $response);
break;
case Response::REST_CLIENT_ERROR_LOCKED:
$body = $response->getBody();
$message = (isset($body['detail'])) ? $body['detail'] : 'The request could not be processed as the entity was locked.';
throw new ClientException($message, ClientException::INVALID_RESPONSE, $response);
break;
case Response::REST_CLIENT_ERROR_TOO_MANY_REQUESTS:
throw new ClientException('You are sending too fast and your calls are throttled', ClientException::SERVER_UNAVAILABLE, $response);
break;
case Response::REST_CLIENT_ERROR_PAYMENT_REQUIRED:
throw new ClientException('Insufficient credit for your wallet', ClientException::INSUFFICIENT_CREDIT, $response);
break;
case Response::REST_SUCCESS_OK:
case Response::REST_SUCCESS_CREATED:
break; // Valid response
default:
throw new ClientException(sprintf('Unknown status code %d received from server', $response->getStatusCode()), ClientException::INVALID_RESPONSE, $response);
break;
}
}
|
[
"protected",
"function",
"validateServerResponse",
"(",
"Response",
"$",
"response",
")",
"{",
"switch",
"(",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
")",
"{",
"case",
"Response",
"::",
"REST_CLIENT_ERROR_UNAUTHORIZED",
":",
"throw",
"new",
"ClientException",
"(",
"'You have provided an invalid API key'",
",",
"ClientException",
"::",
"INVALID_APPLICATION_SECRET",
",",
"$",
"response",
")",
";",
"break",
";",
"case",
"Response",
"::",
"REST_CLIENT_ERROR_FORBIDDEN",
":",
"throw",
"new",
"ClientException",
"(",
"'Your account is not enabled for the service'",
",",
"ClientException",
"::",
"INVALID_APPLICATION_SECRET",
",",
"$",
"response",
")",
";",
"break",
";",
"case",
"Response",
"::",
"REST_CLIENT_ERROR_NOT_FOUND",
":",
"throw",
"new",
"ClientException",
"(",
"'The requested entity was not found on the server'",
",",
"ClientException",
"::",
"ENTITY_NOT_FOUND",
",",
"$",
"response",
")",
";",
"break",
";",
"case",
"Response",
"::",
"REST_CLIENT_ERROR_CONFLICT",
":",
"$",
"body",
"=",
"$",
"response",
"->",
"getBody",
"(",
")",
";",
"$",
"message",
"=",
"(",
"isset",
"(",
"$",
"body",
"[",
"'detail'",
"]",
")",
")",
"?",
"$",
"body",
"[",
"'detail'",
"]",
":",
"'The request was rejected due to an conflict.'",
";",
"throw",
"new",
"ClientException",
"(",
"$",
"message",
",",
"ClientException",
"::",
"INVALID_RESPONSE",
",",
"$",
"response",
")",
";",
"break",
";",
"case",
"Response",
"::",
"REST_CLIENT_ERROR_UNPROCESSABLE_ENTITY",
":",
"$",
"body",
"=",
"$",
"response",
"->",
"getBody",
"(",
")",
";",
"$",
"message",
"=",
"(",
"isset",
"(",
"$",
"body",
"[",
"'detail'",
"]",
")",
")",
"?",
"$",
"body",
"[",
"'detail'",
"]",
":",
"'Unable to process the request'",
";",
"throw",
"new",
"ClientException",
"(",
"$",
"message",
",",
"ClientException",
"::",
"INVALID_RESPONSE",
",",
"$",
"response",
")",
";",
"break",
";",
"case",
"Response",
"::",
"REST_CLIENT_ERROR_LOCKED",
":",
"$",
"body",
"=",
"$",
"response",
"->",
"getBody",
"(",
")",
";",
"$",
"message",
"=",
"(",
"isset",
"(",
"$",
"body",
"[",
"'detail'",
"]",
")",
")",
"?",
"$",
"body",
"[",
"'detail'",
"]",
":",
"'The request could not be processed as the entity was locked.'",
";",
"throw",
"new",
"ClientException",
"(",
"$",
"message",
",",
"ClientException",
"::",
"INVALID_RESPONSE",
",",
"$",
"response",
")",
";",
"break",
";",
"case",
"Response",
"::",
"REST_CLIENT_ERROR_TOO_MANY_REQUESTS",
":",
"throw",
"new",
"ClientException",
"(",
"'You are sending too fast and your calls are throttled'",
",",
"ClientException",
"::",
"SERVER_UNAVAILABLE",
",",
"$",
"response",
")",
";",
"break",
";",
"case",
"Response",
"::",
"REST_CLIENT_ERROR_PAYMENT_REQUIRED",
":",
"throw",
"new",
"ClientException",
"(",
"'Insufficient credit for your wallet'",
",",
"ClientException",
"::",
"INSUFFICIENT_CREDIT",
",",
"$",
"response",
")",
";",
"break",
";",
"case",
"Response",
"::",
"REST_SUCCESS_OK",
":",
"case",
"Response",
"::",
"REST_SUCCESS_CREATED",
":",
"break",
";",
"// Valid response",
"default",
":",
"throw",
"new",
"ClientException",
"(",
"sprintf",
"(",
"'Unknown status code %d received from server'",
",",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
")",
",",
"ClientException",
"::",
"INVALID_RESPONSE",
",",
"$",
"response",
")",
";",
"break",
";",
"}",
"}"
] |
Validate response from server
@param Response $response
@throws ClientException
|
[
"Validate",
"response",
"from",
"server"
] |
2e545d859784184138332c9b5bfc063940e3c926
|
https://github.com/twizoapi/lib-api-php/blob/2e545d859784184138332c9b5bfc063940e3c926/src/AbstractClient.php#L119-L162
|
221,674
|
paquettg/leaguewrap
|
src/LeagueWrap/Client.php
|
Client.addMock
|
public function addMock($mock)
{
// Replace the current guzzle client with the mocked version
$this->guzzle = $this->buildGuzzle(
$this->guzzle->getConfig()['base_uri'],
$mock
);
}
|
php
|
public function addMock($mock)
{
// Replace the current guzzle client with the mocked version
$this->guzzle = $this->buildGuzzle(
$this->guzzle->getConfig()['base_uri'],
$mock
);
}
|
[
"public",
"function",
"addMock",
"(",
"$",
"mock",
")",
"{",
"// Replace the current guzzle client with the mocked version",
"$",
"this",
"->",
"guzzle",
"=",
"$",
"this",
"->",
"buildGuzzle",
"(",
"$",
"this",
"->",
"guzzle",
"->",
"getConfig",
"(",
")",
"[",
"'base_uri'",
"]",
",",
"$",
"mock",
")",
";",
"}"
] |
Attempt to add a mocked handler stack to guzzle, primary usage is
to be able to test this code.
@param \GuzzleHttp\HandlerStack $mock
@return void
|
[
"Attempt",
"to",
"add",
"a",
"mocked",
"handler",
"stack",
"to",
"guzzle",
"primary",
"usage",
"is",
"to",
"be",
"able",
"to",
"test",
"this",
"code",
"."
] |
0f91813b5d8292054e5e13619d591b6b14dc63e6
|
https://github.com/paquettg/leaguewrap/blob/0f91813b5d8292054e5e13619d591b6b14dc63e6/src/LeagueWrap/Client.php#L58-L65
|
221,675
|
paquettg/leaguewrap
|
src/LeagueWrap/Client.php
|
Client.request
|
public function request($path, array $params = [])
{
if ( ! $this->guzzle instanceof Guzzle)
{
throw new BaseUrlException('BaseUrl was never set. Please call baseUrl($url).');
}
$uri = $path.'?'.http_build_query($params);
$response = $this->guzzle
->get($uri, ['timeout' => $this->timeout,
'http_errors' => false]);
$body = $response->getBody();
$code = $response->getStatusCode();
$headers = $response->getHeaders();
if ($body instanceof Stream)
{
$body->seek(0);
$content = ($body->getSize() > 0) ? $body->read($body->getSize()) : null;
}
else
{
// no content
$content = '';
}
$response = new Response($content, $code, $headers);
return $response;
}
|
php
|
public function request($path, array $params = [])
{
if ( ! $this->guzzle instanceof Guzzle)
{
throw new BaseUrlException('BaseUrl was never set. Please call baseUrl($url).');
}
$uri = $path.'?'.http_build_query($params);
$response = $this->guzzle
->get($uri, ['timeout' => $this->timeout,
'http_errors' => false]);
$body = $response->getBody();
$code = $response->getStatusCode();
$headers = $response->getHeaders();
if ($body instanceof Stream)
{
$body->seek(0);
$content = ($body->getSize() > 0) ? $body->read($body->getSize()) : null;
}
else
{
// no content
$content = '';
}
$response = new Response($content, $code, $headers);
return $response;
}
|
[
"public",
"function",
"request",
"(",
"$",
"path",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"guzzle",
"instanceof",
"Guzzle",
")",
"{",
"throw",
"new",
"BaseUrlException",
"(",
"'BaseUrl was never set. Please call baseUrl($url).'",
")",
";",
"}",
"$",
"uri",
"=",
"$",
"path",
".",
"'?'",
".",
"http_build_query",
"(",
"$",
"params",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"guzzle",
"->",
"get",
"(",
"$",
"uri",
",",
"[",
"'timeout'",
"=>",
"$",
"this",
"->",
"timeout",
",",
"'http_errors'",
"=>",
"false",
"]",
")",
";",
"$",
"body",
"=",
"$",
"response",
"->",
"getBody",
"(",
")",
";",
"$",
"code",
"=",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
";",
"$",
"headers",
"=",
"$",
"response",
"->",
"getHeaders",
"(",
")",
";",
"if",
"(",
"$",
"body",
"instanceof",
"Stream",
")",
"{",
"$",
"body",
"->",
"seek",
"(",
"0",
")",
";",
"$",
"content",
"=",
"(",
"$",
"body",
"->",
"getSize",
"(",
")",
">",
"0",
")",
"?",
"$",
"body",
"->",
"read",
"(",
"$",
"body",
"->",
"getSize",
"(",
")",
")",
":",
"null",
";",
"}",
"else",
"{",
"// no content",
"$",
"content",
"=",
"''",
";",
"}",
"$",
"response",
"=",
"new",
"Response",
"(",
"$",
"content",
",",
"$",
"code",
",",
"$",
"headers",
")",
";",
"return",
"$",
"response",
";",
"}"
] |
Attempts to do a request of the given path.
@param string $path
@param array $params
@return \LeagueWrap\Response
@throws BaseUrlException
|
[
"Attempts",
"to",
"do",
"a",
"request",
"of",
"the",
"given",
"path",
"."
] |
0f91813b5d8292054e5e13619d591b6b14dc63e6
|
https://github.com/paquettg/leaguewrap/blob/0f91813b5d8292054e5e13619d591b6b14dc63e6/src/LeagueWrap/Client.php#L75-L102
|
221,676
|
neos/fluid
|
Classes/TYPO3/Fluid/Core/ViewHelper/AbstractViewHelper.php
|
AbstractViewHelper.renderChildren
|
public function renderChildren()
{
if ($this->renderChildrenClosure !== null) {
$closure = $this->renderChildrenClosure;
return $closure();
}
return $this->viewHelperNode->evaluateChildNodes($this->renderingContext);
}
|
php
|
public function renderChildren()
{
if ($this->renderChildrenClosure !== null) {
$closure = $this->renderChildrenClosure;
return $closure();
}
return $this->viewHelperNode->evaluateChildNodes($this->renderingContext);
}
|
[
"public",
"function",
"renderChildren",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"renderChildrenClosure",
"!==",
"null",
")",
"{",
"$",
"closure",
"=",
"$",
"this",
"->",
"renderChildrenClosure",
";",
"return",
"$",
"closure",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"viewHelperNode",
"->",
"evaluateChildNodes",
"(",
"$",
"this",
"->",
"renderingContext",
")",
";",
"}"
] |
Helper method which triggers the rendering of everything between the
opening and the closing tag.
@return mixed The finally rendered child nodes.
@api
|
[
"Helper",
"method",
"which",
"triggers",
"the",
"rendering",
"of",
"everything",
"between",
"the",
"opening",
"and",
"the",
"closing",
"tag",
"."
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/ViewHelper/AbstractViewHelper.php#L345-L352
|
221,677
|
neos/fluid
|
Classes/TYPO3/Fluid/Core/ViewHelper/AbstractViewHelper.php
|
AbstractViewHelper.prepareArguments
|
public function prepareArguments()
{
if (!$this->argumentsInitialized) {
$thisClassName = get_class($this);
if (isset(self::$argumentDefinitionCache[$thisClassName])) {
$this->argumentDefinitions = self::$argumentDefinitionCache[$thisClassName];
} else {
$this->registerRenderMethodArguments();
$this->initializeArguments();
self::$argumentDefinitionCache[$thisClassName] = $this->argumentDefinitions;
}
$this->argumentsInitialized = true;
}
return $this->argumentDefinitions;
}
|
php
|
public function prepareArguments()
{
if (!$this->argumentsInitialized) {
$thisClassName = get_class($this);
if (isset(self::$argumentDefinitionCache[$thisClassName])) {
$this->argumentDefinitions = self::$argumentDefinitionCache[$thisClassName];
} else {
$this->registerRenderMethodArguments();
$this->initializeArguments();
self::$argumentDefinitionCache[$thisClassName] = $this->argumentDefinitions;
}
$this->argumentsInitialized = true;
}
return $this->argumentDefinitions;
}
|
[
"public",
"function",
"prepareArguments",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"argumentsInitialized",
")",
"{",
"$",
"thisClassName",
"=",
"get_class",
"(",
"$",
"this",
")",
";",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"argumentDefinitionCache",
"[",
"$",
"thisClassName",
"]",
")",
")",
"{",
"$",
"this",
"->",
"argumentDefinitions",
"=",
"self",
"::",
"$",
"argumentDefinitionCache",
"[",
"$",
"thisClassName",
"]",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"registerRenderMethodArguments",
"(",
")",
";",
"$",
"this",
"->",
"initializeArguments",
"(",
")",
";",
"self",
"::",
"$",
"argumentDefinitionCache",
"[",
"$",
"thisClassName",
"]",
"=",
"$",
"this",
"->",
"argumentDefinitions",
";",
"}",
"$",
"this",
"->",
"argumentsInitialized",
"=",
"true",
";",
"}",
"return",
"$",
"this",
"->",
"argumentDefinitions",
";",
"}"
] |
Initialize all arguments and return them
@return array Array of \TYPO3\Fluid\Core\ViewHelper\ArgumentDefinition instances.
|
[
"Initialize",
"all",
"arguments",
"and",
"return",
"them"
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/ViewHelper/AbstractViewHelper.php#L375-L389
|
221,678
|
neos/fluid
|
Classes/TYPO3/Fluid/Core/ViewHelper/AbstractViewHelper.php
|
AbstractViewHelper.registerRenderMethodArguments
|
private function registerRenderMethodArguments()
{
$methodParameters = static::getRenderMethodParameters($this->objectManager);
if (count($methodParameters) === 0) {
return;
}
if (Fluid::$debugMode) {
$methodTags = static::getRenderMethodTagsValues($this->objectManager);
$paramAnnotations = array();
if (isset($methodTags['param'])) {
$paramAnnotations = $methodTags['param'];
}
}
$i = 0;
foreach ($methodParameters as $parameterName => $parameterInfo) {
$dataType = null;
if (isset($parameterInfo['type'])) {
$dataType = $parameterInfo['type'];
} elseif ($parameterInfo['array']) {
$dataType = 'array';
}
if ($dataType === null) {
throw new Parser\Exception('could not determine type of argument "' . $parameterName . '" of the render-method in ViewHelper "' . get_class($this) . '". Either the methods docComment is invalid or some PHP optimizer strips off comments.', 1242292003);
}
$description = '';
if (Fluid::$debugMode && isset($paramAnnotations[$i])) {
$explodedAnnotation = explode(' ', $paramAnnotations[$i]);
array_shift($explodedAnnotation);
array_shift($explodedAnnotation);
$description = implode(' ', $explodedAnnotation);
}
$defaultValue = null;
if (isset($parameterInfo['defaultValue'])) {
$defaultValue = $parameterInfo['defaultValue'];
}
$this->argumentDefinitions[$parameterName] = new ArgumentDefinition($parameterName, $dataType, $description, ($parameterInfo['optional'] === false), $defaultValue, true);
$i++;
}
}
|
php
|
private function registerRenderMethodArguments()
{
$methodParameters = static::getRenderMethodParameters($this->objectManager);
if (count($methodParameters) === 0) {
return;
}
if (Fluid::$debugMode) {
$methodTags = static::getRenderMethodTagsValues($this->objectManager);
$paramAnnotations = array();
if (isset($methodTags['param'])) {
$paramAnnotations = $methodTags['param'];
}
}
$i = 0;
foreach ($methodParameters as $parameterName => $parameterInfo) {
$dataType = null;
if (isset($parameterInfo['type'])) {
$dataType = $parameterInfo['type'];
} elseif ($parameterInfo['array']) {
$dataType = 'array';
}
if ($dataType === null) {
throw new Parser\Exception('could not determine type of argument "' . $parameterName . '" of the render-method in ViewHelper "' . get_class($this) . '". Either the methods docComment is invalid or some PHP optimizer strips off comments.', 1242292003);
}
$description = '';
if (Fluid::$debugMode && isset($paramAnnotations[$i])) {
$explodedAnnotation = explode(' ', $paramAnnotations[$i]);
array_shift($explodedAnnotation);
array_shift($explodedAnnotation);
$description = implode(' ', $explodedAnnotation);
}
$defaultValue = null;
if (isset($parameterInfo['defaultValue'])) {
$defaultValue = $parameterInfo['defaultValue'];
}
$this->argumentDefinitions[$parameterName] = new ArgumentDefinition($parameterName, $dataType, $description, ($parameterInfo['optional'] === false), $defaultValue, true);
$i++;
}
}
|
[
"private",
"function",
"registerRenderMethodArguments",
"(",
")",
"{",
"$",
"methodParameters",
"=",
"static",
"::",
"getRenderMethodParameters",
"(",
"$",
"this",
"->",
"objectManager",
")",
";",
"if",
"(",
"count",
"(",
"$",
"methodParameters",
")",
"===",
"0",
")",
"{",
"return",
";",
"}",
"if",
"(",
"Fluid",
"::",
"$",
"debugMode",
")",
"{",
"$",
"methodTags",
"=",
"static",
"::",
"getRenderMethodTagsValues",
"(",
"$",
"this",
"->",
"objectManager",
")",
";",
"$",
"paramAnnotations",
"=",
"array",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"methodTags",
"[",
"'param'",
"]",
")",
")",
"{",
"$",
"paramAnnotations",
"=",
"$",
"methodTags",
"[",
"'param'",
"]",
";",
"}",
"}",
"$",
"i",
"=",
"0",
";",
"foreach",
"(",
"$",
"methodParameters",
"as",
"$",
"parameterName",
"=>",
"$",
"parameterInfo",
")",
"{",
"$",
"dataType",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"parameterInfo",
"[",
"'type'",
"]",
")",
")",
"{",
"$",
"dataType",
"=",
"$",
"parameterInfo",
"[",
"'type'",
"]",
";",
"}",
"elseif",
"(",
"$",
"parameterInfo",
"[",
"'array'",
"]",
")",
"{",
"$",
"dataType",
"=",
"'array'",
";",
"}",
"if",
"(",
"$",
"dataType",
"===",
"null",
")",
"{",
"throw",
"new",
"Parser",
"\\",
"Exception",
"(",
"'could not determine type of argument \"'",
".",
"$",
"parameterName",
".",
"'\" of the render-method in ViewHelper \"'",
".",
"get_class",
"(",
"$",
"this",
")",
".",
"'\". Either the methods docComment is invalid or some PHP optimizer strips off comments.'",
",",
"1242292003",
")",
";",
"}",
"$",
"description",
"=",
"''",
";",
"if",
"(",
"Fluid",
"::",
"$",
"debugMode",
"&&",
"isset",
"(",
"$",
"paramAnnotations",
"[",
"$",
"i",
"]",
")",
")",
"{",
"$",
"explodedAnnotation",
"=",
"explode",
"(",
"' '",
",",
"$",
"paramAnnotations",
"[",
"$",
"i",
"]",
")",
";",
"array_shift",
"(",
"$",
"explodedAnnotation",
")",
";",
"array_shift",
"(",
"$",
"explodedAnnotation",
")",
";",
"$",
"description",
"=",
"implode",
"(",
"' '",
",",
"$",
"explodedAnnotation",
")",
";",
"}",
"$",
"defaultValue",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"parameterInfo",
"[",
"'defaultValue'",
"]",
")",
")",
"{",
"$",
"defaultValue",
"=",
"$",
"parameterInfo",
"[",
"'defaultValue'",
"]",
";",
"}",
"$",
"this",
"->",
"argumentDefinitions",
"[",
"$",
"parameterName",
"]",
"=",
"new",
"ArgumentDefinition",
"(",
"$",
"parameterName",
",",
"$",
"dataType",
",",
"$",
"description",
",",
"(",
"$",
"parameterInfo",
"[",
"'optional'",
"]",
"===",
"false",
")",
",",
"$",
"defaultValue",
",",
"true",
")",
";",
"$",
"i",
"++",
";",
"}",
"}"
] |
Register method arguments for "render" by analysing the doc comment above.
@return void
@throws Parser\Exception
|
[
"Register",
"method",
"arguments",
"for",
"render",
"by",
"analysing",
"the",
"doc",
"comment",
"above",
"."
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/ViewHelper/AbstractViewHelper.php#L397-L439
|
221,679
|
neos/fluid
|
Classes/TYPO3/Fluid/Core/ViewHelper/AbstractViewHelper.php
|
AbstractViewHelper.getRenderMethodParameters
|
public static function getRenderMethodParameters($objectManager)
{
$className = get_called_class();
if (!is_callable(array($className, 'render'))) {
return array();
}
$reflectionService = $objectManager->get(\TYPO3\Flow\Reflection\ReflectionService::class);
return $reflectionService->getMethodParameters($className, 'render');
}
|
php
|
public static function getRenderMethodParameters($objectManager)
{
$className = get_called_class();
if (!is_callable(array($className, 'render'))) {
return array();
}
$reflectionService = $objectManager->get(\TYPO3\Flow\Reflection\ReflectionService::class);
return $reflectionService->getMethodParameters($className, 'render');
}
|
[
"public",
"static",
"function",
"getRenderMethodParameters",
"(",
"$",
"objectManager",
")",
"{",
"$",
"className",
"=",
"get_called_class",
"(",
")",
";",
"if",
"(",
"!",
"is_callable",
"(",
"array",
"(",
"$",
"className",
",",
"'render'",
")",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"$",
"reflectionService",
"=",
"$",
"objectManager",
"->",
"get",
"(",
"\\",
"TYPO3",
"\\",
"Flow",
"\\",
"Reflection",
"\\",
"ReflectionService",
"::",
"class",
")",
";",
"return",
"$",
"reflectionService",
"->",
"getMethodParameters",
"(",
"$",
"className",
",",
"'render'",
")",
";",
"}"
] |
Returns a map of render method parameters.
@param \TYPO3\Flow\Object\ObjectManagerInterface $objectManager
@return array Array of render method parameters
@Flow\CompileStatic
|
[
"Returns",
"a",
"map",
"of",
"render",
"method",
"parameters",
"."
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/ViewHelper/AbstractViewHelper.php#L448-L457
|
221,680
|
neos/fluid
|
Classes/TYPO3/Fluid/Core/ViewHelper/AbstractViewHelper.php
|
AbstractViewHelper.getRenderMethodTagsValues
|
public static function getRenderMethodTagsValues($objectManager)
{
$className = get_called_class();
if (!is_callable(array($className, 'render'))) {
return array();
}
$reflectionService = $objectManager->get(\TYPO3\Flow\Reflection\ReflectionService::class);
return $reflectionService->getMethodTagsValues($className, 'render');
}
|
php
|
public static function getRenderMethodTagsValues($objectManager)
{
$className = get_called_class();
if (!is_callable(array($className, 'render'))) {
return array();
}
$reflectionService = $objectManager->get(\TYPO3\Flow\Reflection\ReflectionService::class);
return $reflectionService->getMethodTagsValues($className, 'render');
}
|
[
"public",
"static",
"function",
"getRenderMethodTagsValues",
"(",
"$",
"objectManager",
")",
"{",
"$",
"className",
"=",
"get_called_class",
"(",
")",
";",
"if",
"(",
"!",
"is_callable",
"(",
"array",
"(",
"$",
"className",
",",
"'render'",
")",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"$",
"reflectionService",
"=",
"$",
"objectManager",
"->",
"get",
"(",
"\\",
"TYPO3",
"\\",
"Flow",
"\\",
"Reflection",
"\\",
"ReflectionService",
"::",
"class",
")",
";",
"return",
"$",
"reflectionService",
"->",
"getMethodTagsValues",
"(",
"$",
"className",
",",
"'render'",
")",
";",
"}"
] |
Returns a map of render method tag values.
@param \TYPO3\Flow\Object\ObjectManagerInterface $objectManager
@return array An array of tags and their values or an empty array if no tags were found
@Flow\CompileStatic
|
[
"Returns",
"a",
"map",
"of",
"render",
"method",
"tag",
"values",
"."
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/ViewHelper/AbstractViewHelper.php#L466-L475
|
221,681
|
neos/fluid
|
Classes/TYPO3/Fluid/Core/ViewHelper/AbstractViewHelper.php
|
AbstractViewHelper.validateArguments
|
public function validateArguments()
{
$argumentDefinitions = $this->prepareArguments();
if (!count($argumentDefinitions)) {
return;
}
/** @var $registeredArgument ArgumentDefinition */
foreach ($argumentDefinitions as $argumentName => $registeredArgument) {
if ($this->hasArgument($argumentName)) {
if ($this->arguments[$argumentName] === $registeredArgument->getDefaultValue()) {
continue;
}
$type = $registeredArgument->getType();
if ($type === 'array') {
if (!is_array($this->arguments[$argumentName]) && !$this->arguments[$argumentName] instanceof \ArrayAccess && !$this->arguments[$argumentName] instanceof \Traversable) {
throw new \InvalidArgumentException('The argument "' . $argumentName . '" was registered with type "array", but is of type "' . gettype($this->arguments[$argumentName]) . '" in view helper "' . get_class($this) . '"', 1237900529);
}
} elseif ($type === 'boolean') {
if (!is_bool($this->arguments[$argumentName])) {
throw new \InvalidArgumentException('The argument "' . $argumentName . '" was registered with type "boolean", but is of type "' . gettype($this->arguments[$argumentName]) . '" in view helper "' . get_class($this) . '".', 1240227732);
}
} elseif (class_exists($type, false)) {
if (!($this->arguments[$argumentName] instanceof $type)) {
if (is_object($this->arguments[$argumentName])) {
throw new \InvalidArgumentException('The argument "' . $argumentName . '" was registered with type "' . $type . '", but is of type "' . get_class($this->arguments[$argumentName]) . '" in view helper "' . get_class($this) . '".', 1256475114);
} else {
throw new \InvalidArgumentException('The argument "' . $argumentName . '" was registered with type "' . $type . '", but is of type "' . gettype($this->arguments[$argumentName]) . '" in view helper "' . get_class($this) . '".', 1256475113);
}
}
}
}
}
}
|
php
|
public function validateArguments()
{
$argumentDefinitions = $this->prepareArguments();
if (!count($argumentDefinitions)) {
return;
}
/** @var $registeredArgument ArgumentDefinition */
foreach ($argumentDefinitions as $argumentName => $registeredArgument) {
if ($this->hasArgument($argumentName)) {
if ($this->arguments[$argumentName] === $registeredArgument->getDefaultValue()) {
continue;
}
$type = $registeredArgument->getType();
if ($type === 'array') {
if (!is_array($this->arguments[$argumentName]) && !$this->arguments[$argumentName] instanceof \ArrayAccess && !$this->arguments[$argumentName] instanceof \Traversable) {
throw new \InvalidArgumentException('The argument "' . $argumentName . '" was registered with type "array", but is of type "' . gettype($this->arguments[$argumentName]) . '" in view helper "' . get_class($this) . '"', 1237900529);
}
} elseif ($type === 'boolean') {
if (!is_bool($this->arguments[$argumentName])) {
throw new \InvalidArgumentException('The argument "' . $argumentName . '" was registered with type "boolean", but is of type "' . gettype($this->arguments[$argumentName]) . '" in view helper "' . get_class($this) . '".', 1240227732);
}
} elseif (class_exists($type, false)) {
if (!($this->arguments[$argumentName] instanceof $type)) {
if (is_object($this->arguments[$argumentName])) {
throw new \InvalidArgumentException('The argument "' . $argumentName . '" was registered with type "' . $type . '", but is of type "' . get_class($this->arguments[$argumentName]) . '" in view helper "' . get_class($this) . '".', 1256475114);
} else {
throw new \InvalidArgumentException('The argument "' . $argumentName . '" was registered with type "' . $type . '", but is of type "' . gettype($this->arguments[$argumentName]) . '" in view helper "' . get_class($this) . '".', 1256475113);
}
}
}
}
}
}
|
[
"public",
"function",
"validateArguments",
"(",
")",
"{",
"$",
"argumentDefinitions",
"=",
"$",
"this",
"->",
"prepareArguments",
"(",
")",
";",
"if",
"(",
"!",
"count",
"(",
"$",
"argumentDefinitions",
")",
")",
"{",
"return",
";",
"}",
"/** @var $registeredArgument ArgumentDefinition */",
"foreach",
"(",
"$",
"argumentDefinitions",
"as",
"$",
"argumentName",
"=>",
"$",
"registeredArgument",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasArgument",
"(",
"$",
"argumentName",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"arguments",
"[",
"$",
"argumentName",
"]",
"===",
"$",
"registeredArgument",
"->",
"getDefaultValue",
"(",
")",
")",
"{",
"continue",
";",
"}",
"$",
"type",
"=",
"$",
"registeredArgument",
"->",
"getType",
"(",
")",
";",
"if",
"(",
"$",
"type",
"===",
"'array'",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"this",
"->",
"arguments",
"[",
"$",
"argumentName",
"]",
")",
"&&",
"!",
"$",
"this",
"->",
"arguments",
"[",
"$",
"argumentName",
"]",
"instanceof",
"\\",
"ArrayAccess",
"&&",
"!",
"$",
"this",
"->",
"arguments",
"[",
"$",
"argumentName",
"]",
"instanceof",
"\\",
"Traversable",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The argument \"'",
".",
"$",
"argumentName",
".",
"'\" was registered with type \"array\", but is of type \"'",
".",
"gettype",
"(",
"$",
"this",
"->",
"arguments",
"[",
"$",
"argumentName",
"]",
")",
".",
"'\" in view helper \"'",
".",
"get_class",
"(",
"$",
"this",
")",
".",
"'\"'",
",",
"1237900529",
")",
";",
"}",
"}",
"elseif",
"(",
"$",
"type",
"===",
"'boolean'",
")",
"{",
"if",
"(",
"!",
"is_bool",
"(",
"$",
"this",
"->",
"arguments",
"[",
"$",
"argumentName",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The argument \"'",
".",
"$",
"argumentName",
".",
"'\" was registered with type \"boolean\", but is of type \"'",
".",
"gettype",
"(",
"$",
"this",
"->",
"arguments",
"[",
"$",
"argumentName",
"]",
")",
".",
"'\" in view helper \"'",
".",
"get_class",
"(",
"$",
"this",
")",
".",
"'\".'",
",",
"1240227732",
")",
";",
"}",
"}",
"elseif",
"(",
"class_exists",
"(",
"$",
"type",
",",
"false",
")",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"this",
"->",
"arguments",
"[",
"$",
"argumentName",
"]",
"instanceof",
"$",
"type",
")",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"this",
"->",
"arguments",
"[",
"$",
"argumentName",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The argument \"'",
".",
"$",
"argumentName",
".",
"'\" was registered with type \"'",
".",
"$",
"type",
".",
"'\", but is of type \"'",
".",
"get_class",
"(",
"$",
"this",
"->",
"arguments",
"[",
"$",
"argumentName",
"]",
")",
".",
"'\" in view helper \"'",
".",
"get_class",
"(",
"$",
"this",
")",
".",
"'\".'",
",",
"1256475114",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The argument \"'",
".",
"$",
"argumentName",
".",
"'\" was registered with type \"'",
".",
"$",
"type",
".",
"'\", but is of type \"'",
".",
"gettype",
"(",
"$",
"this",
"->",
"arguments",
"[",
"$",
"argumentName",
"]",
")",
".",
"'\" in view helper \"'",
".",
"get_class",
"(",
"$",
"this",
")",
".",
"'\".'",
",",
"1256475113",
")",
";",
"}",
"}",
"}",
"}",
"}",
"}"
] |
Validate arguments, and throw exception if arguments do not validate.
@return void
@throws \InvalidArgumentException
|
[
"Validate",
"arguments",
"and",
"throw",
"exception",
"if",
"arguments",
"do",
"not",
"validate",
"."
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/ViewHelper/AbstractViewHelper.php#L483-L517
|
221,682
|
neos/fluid
|
Classes/TYPO3/Fluid/ViewHelpers/SectionViewHelper.php
|
SectionViewHelper.postParseEvent
|
public static function postParseEvent(ViewHelperNode $syntaxTreeNode, array $viewHelperArguments, TemplateVariableContainer $variableContainer)
{
/** @var $nameArgument TextNode */
$nameArgument = $viewHelperArguments['name'];
$sectionName = $nameArgument->getText();
if (!$variableContainer->exists('sections')) {
$variableContainer->add('sections', array());
}
$sections = $variableContainer->get('sections');
$sections[$sectionName] = $syntaxTreeNode;
$variableContainer->remove('sections');
$variableContainer->add('sections', $sections);
}
|
php
|
public static function postParseEvent(ViewHelperNode $syntaxTreeNode, array $viewHelperArguments, TemplateVariableContainer $variableContainer)
{
/** @var $nameArgument TextNode */
$nameArgument = $viewHelperArguments['name'];
$sectionName = $nameArgument->getText();
if (!$variableContainer->exists('sections')) {
$variableContainer->add('sections', array());
}
$sections = $variableContainer->get('sections');
$sections[$sectionName] = $syntaxTreeNode;
$variableContainer->remove('sections');
$variableContainer->add('sections', $sections);
}
|
[
"public",
"static",
"function",
"postParseEvent",
"(",
"ViewHelperNode",
"$",
"syntaxTreeNode",
",",
"array",
"$",
"viewHelperArguments",
",",
"TemplateVariableContainer",
"$",
"variableContainer",
")",
"{",
"/** @var $nameArgument TextNode */",
"$",
"nameArgument",
"=",
"$",
"viewHelperArguments",
"[",
"'name'",
"]",
";",
"$",
"sectionName",
"=",
"$",
"nameArgument",
"->",
"getText",
"(",
")",
";",
"if",
"(",
"!",
"$",
"variableContainer",
"->",
"exists",
"(",
"'sections'",
")",
")",
"{",
"$",
"variableContainer",
"->",
"add",
"(",
"'sections'",
",",
"array",
"(",
")",
")",
";",
"}",
"$",
"sections",
"=",
"$",
"variableContainer",
"->",
"get",
"(",
"'sections'",
")",
";",
"$",
"sections",
"[",
"$",
"sectionName",
"]",
"=",
"$",
"syntaxTreeNode",
";",
"$",
"variableContainer",
"->",
"remove",
"(",
"'sections'",
")",
";",
"$",
"variableContainer",
"->",
"add",
"(",
"'sections'",
",",
"$",
"sections",
")",
";",
"}"
] |
Save the associated ViewHelper node in a static public class variable.
called directly after the ViewHelper was built.
@param ViewHelperNode $syntaxTreeNode
@param array $viewHelperArguments<TextNode>
@param TemplateVariableContainer $variableContainer
@return void
|
[
"Save",
"the",
"associated",
"ViewHelper",
"node",
"in",
"a",
"static",
"public",
"class",
"variable",
".",
"called",
"directly",
"after",
"the",
"ViewHelper",
"was",
"built",
"."
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/ViewHelpers/SectionViewHelper.php#L92-L104
|
221,683
|
neos/fluid
|
Classes/TYPO3/Fluid/ViewHelpers/SectionViewHelper.php
|
SectionViewHelper.render
|
public function render()
{
if ($this->viewHelperVariableContainer->exists(\TYPO3\Fluid\ViewHelpers\SectionViewHelper::class, 'isCurrentlyRenderingSection')) {
$this->viewHelperVariableContainer->remove(\TYPO3\Fluid\ViewHelpers\SectionViewHelper::class, 'isCurrentlyRenderingSection');
return $this->renderChildren();
}
return '';
}
|
php
|
public function render()
{
if ($this->viewHelperVariableContainer->exists(\TYPO3\Fluid\ViewHelpers\SectionViewHelper::class, 'isCurrentlyRenderingSection')) {
$this->viewHelperVariableContainer->remove(\TYPO3\Fluid\ViewHelpers\SectionViewHelper::class, 'isCurrentlyRenderingSection');
return $this->renderChildren();
}
return '';
}
|
[
"public",
"function",
"render",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"viewHelperVariableContainer",
"->",
"exists",
"(",
"\\",
"TYPO3",
"\\",
"Fluid",
"\\",
"ViewHelpers",
"\\",
"SectionViewHelper",
"::",
"class",
",",
"'isCurrentlyRenderingSection'",
")",
")",
"{",
"$",
"this",
"->",
"viewHelperVariableContainer",
"->",
"remove",
"(",
"\\",
"TYPO3",
"\\",
"Fluid",
"\\",
"ViewHelpers",
"\\",
"SectionViewHelper",
"::",
"class",
",",
"'isCurrentlyRenderingSection'",
")",
";",
"return",
"$",
"this",
"->",
"renderChildren",
"(",
")",
";",
"}",
"return",
"''",
";",
"}"
] |
Rendering directly returns all child nodes.
@return string HTML String of all child nodes.
@api
|
[
"Rendering",
"directly",
"returns",
"all",
"child",
"nodes",
"."
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/ViewHelpers/SectionViewHelper.php#L112-L119
|
221,684
|
CapMousse/React-Restify
|
src/Http/Response.php
|
Response.write
|
public function write($data)
{
$this->contentLength += strlen($data);
$this->data .= $data;
return $this;
}
|
php
|
public function write($data)
{
$this->contentLength += strlen($data);
$this->data .= $data;
return $this;
}
|
[
"public",
"function",
"write",
"(",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"contentLength",
"+=",
"strlen",
"(",
"$",
"data",
")",
";",
"$",
"this",
"->",
"data",
".=",
"$",
"data",
";",
"return",
"$",
"this",
";",
"}"
] |
Write data to the response
@param string $data
@return Reponse
|
[
"Write",
"data",
"to",
"the",
"response"
] |
51fe94d6e4c7fafec06fb304f9e44badde4bfe71
|
https://github.com/CapMousse/React-Restify/blob/51fe94d6e4c7fafec06fb304f9e44badde4bfe71/src/Http/Response.php#L116-L122
|
221,685
|
CapMousse/React-Restify
|
src/Http/Response.php
|
Response.writeJson
|
public function writeJson($data)
{
$data = json_encode($data);
$this->write($data);
$this->addHeader("Content-Type", "application/json");
return $this;
}
|
php
|
public function writeJson($data)
{
$data = json_encode($data);
$this->write($data);
$this->addHeader("Content-Type", "application/json");
return $this;
}
|
[
"public",
"function",
"writeJson",
"(",
"$",
"data",
")",
"{",
"$",
"data",
"=",
"json_encode",
"(",
"$",
"data",
")",
";",
"$",
"this",
"->",
"write",
"(",
"$",
"data",
")",
";",
"$",
"this",
"->",
"addHeader",
"(",
"\"Content-Type\"",
",",
"\"application/json\"",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Write json to the response
@param mixed $data
@return Reponse
|
[
"Write",
"json",
"to",
"the",
"response"
] |
51fe94d6e4c7fafec06fb304f9e44badde4bfe71
|
https://github.com/CapMousse/React-Restify/blob/51fe94d6e4c7fafec06fb304f9e44badde4bfe71/src/Http/Response.php#L130-L138
|
221,686
|
CapMousse/React-Restify
|
src/Http/Response.php
|
Response.reset
|
public function reset()
{
$this->contentLength = 0;
$this->data = "";
$this->headers = [];
$this->status = 200;
return $this;
}
|
php
|
public function reset()
{
$this->contentLength = 0;
$this->data = "";
$this->headers = [];
$this->status = 200;
return $this;
}
|
[
"public",
"function",
"reset",
"(",
")",
"{",
"$",
"this",
"->",
"contentLength",
"=",
"0",
";",
"$",
"this",
"->",
"data",
"=",
"\"\"",
";",
"$",
"this",
"->",
"headers",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"status",
"=",
"200",
";",
"return",
"$",
"this",
";",
"}"
] |
Empty current response
@return Reponse
|
[
"Empty",
"current",
"response"
] |
51fe94d6e4c7fafec06fb304f9e44badde4bfe71
|
https://github.com/CapMousse/React-Restify/blob/51fe94d6e4c7fafec06fb304f9e44badde4bfe71/src/Http/Response.php#L145-L153
|
221,687
|
CapMousse/React-Restify
|
src/Http/Response.php
|
Response.end
|
public function end()
{
$this->sendHeaders();
$this->httpResponse->write($this->data);
$this->httpResponse->end();
}
|
php
|
public function end()
{
$this->sendHeaders();
$this->httpResponse->write($this->data);
$this->httpResponse->end();
}
|
[
"public",
"function",
"end",
"(",
")",
"{",
"$",
"this",
"->",
"sendHeaders",
"(",
")",
";",
"$",
"this",
"->",
"httpResponse",
"->",
"write",
"(",
"$",
"this",
"->",
"data",
")",
";",
"$",
"this",
"->",
"httpResponse",
"->",
"end",
"(",
")",
";",
"}"
] |
End the connexion
|
[
"End",
"the",
"connexion"
] |
51fe94d6e4c7fafec06fb304f9e44badde4bfe71
|
https://github.com/CapMousse/React-Restify/blob/51fe94d6e4c7fafec06fb304f9e44badde4bfe71/src/Http/Response.php#L158-L163
|
221,688
|
CapMousse/React-Restify
|
src/Http/Response.php
|
Response.close
|
public function close()
{
$this->sendHeaders();
$this->httpResponse->write($this->data);
$this->httpResponse->close();
}
|
php
|
public function close()
{
$this->sendHeaders();
$this->httpResponse->write($this->data);
$this->httpResponse->close();
}
|
[
"public",
"function",
"close",
"(",
")",
"{",
"$",
"this",
"->",
"sendHeaders",
"(",
")",
";",
"$",
"this",
"->",
"httpResponse",
"->",
"write",
"(",
"$",
"this",
"->",
"data",
")",
";",
"$",
"this",
"->",
"httpResponse",
"->",
"close",
"(",
")",
";",
"}"
] |
Close the connexion
|
[
"Close",
"the",
"connexion"
] |
51fe94d6e4c7fafec06fb304f9e44badde4bfe71
|
https://github.com/CapMousse/React-Restify/blob/51fe94d6e4c7fafec06fb304f9e44badde4bfe71/src/Http/Response.php#L168-L173
|
221,689
|
CapMousse/React-Restify
|
src/Http/Response.php
|
Response.sendHeaders
|
public function sendHeaders()
{
if ($this->headersSent) {
return;
}
if (!isset($this->headers["Content-Length"])) {
$this->sendContentLengthHeaders();
}
$this->httpResponse->writeHead($this->status, $this->headers);
$this->headersSent = true;
}
|
php
|
public function sendHeaders()
{
if ($this->headersSent) {
return;
}
if (!isset($this->headers["Content-Length"])) {
$this->sendContentLengthHeaders();
}
$this->httpResponse->writeHead($this->status, $this->headers);
$this->headersSent = true;
}
|
[
"public",
"function",
"sendHeaders",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"headersSent",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"headers",
"[",
"\"Content-Length\"",
"]",
")",
")",
"{",
"$",
"this",
"->",
"sendContentLengthHeaders",
"(",
")",
";",
"}",
"$",
"this",
"->",
"httpResponse",
"->",
"writeHead",
"(",
"$",
"this",
"->",
"status",
",",
"$",
"this",
"->",
"headers",
")",
";",
"$",
"this",
"->",
"headersSent",
"=",
"true",
";",
"}"
] |
Send all headers to the response
|
[
"Send",
"all",
"headers",
"to",
"the",
"response"
] |
51fe94d6e4c7fafec06fb304f9e44badde4bfe71
|
https://github.com/CapMousse/React-Restify/blob/51fe94d6e4c7fafec06fb304f9e44badde4bfe71/src/Http/Response.php#L178-L190
|
221,690
|
paquettg/leaguewrap
|
src/LeagueWrap/Dto/AbstractListDto.php
|
AbstractListDto.offsetGet
|
public function offsetGet($offset)
{
$info = $this->getListByKey();
if ( ! isset($info[$offset]))
{
return null;
}
return $info[$offset];
}
|
php
|
public function offsetGet($offset)
{
$info = $this->getListByKey();
if ( ! isset($info[$offset]))
{
return null;
}
return $info[$offset];
}
|
[
"public",
"function",
"offsetGet",
"(",
"$",
"offset",
")",
"{",
"$",
"info",
"=",
"$",
"this",
"->",
"getListByKey",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"info",
"[",
"$",
"offset",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"info",
"[",
"$",
"offset",
"]",
";",
"}"
] |
Get the value at the given offset.
@param mixed $offset
@return null
@throws ListKeyNotSetException
|
[
"Get",
"the",
"value",
"at",
"the",
"given",
"offset",
"."
] |
0f91813b5d8292054e5e13619d591b6b14dc63e6
|
https://github.com/paquettg/leaguewrap/blob/0f91813b5d8292054e5e13619d591b6b14dc63e6/src/LeagueWrap/Dto/AbstractListDto.php#L35-L44
|
221,691
|
paquettg/leaguewrap
|
src/LeagueWrap/Dto/AbstractListDto.php
|
AbstractListDto.offsetSet
|
public function offsetSet($offset, $value)
{
// just to make sure the listKey exists
$this->getListByKey();
if (is_null($offset))
{
$this->info[$this->listKey][] = $value;
}
else
{
$this->info[$this->listKey][$offset] = $value;
}
}
|
php
|
public function offsetSet($offset, $value)
{
// just to make sure the listKey exists
$this->getListByKey();
if (is_null($offset))
{
$this->info[$this->listKey][] = $value;
}
else
{
$this->info[$this->listKey][$offset] = $value;
}
}
|
[
"public",
"function",
"offsetSet",
"(",
"$",
"offset",
",",
"$",
"value",
")",
"{",
"// just to make sure the listKey exists",
"$",
"this",
"->",
"getListByKey",
"(",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"offset",
")",
")",
"{",
"$",
"this",
"->",
"info",
"[",
"$",
"this",
"->",
"listKey",
"]",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"info",
"[",
"$",
"this",
"->",
"listKey",
"]",
"[",
"$",
"offset",
"]",
"=",
"$",
"value",
";",
"}",
"}"
] |
Set a value at the given offset.
@param mixed $offset
@param mixed $value
@throws ListKeyNotSetException
|
[
"Set",
"a",
"value",
"at",
"the",
"given",
"offset",
"."
] |
0f91813b5d8292054e5e13619d591b6b14dc63e6
|
https://github.com/paquettg/leaguewrap/blob/0f91813b5d8292054e5e13619d591b6b14dc63e6/src/LeagueWrap/Dto/AbstractListDto.php#L53-L65
|
221,692
|
paquettg/leaguewrap
|
src/LeagueWrap/Dto/AbstractListDto.php
|
AbstractListDto.getListByKey
|
protected function getListByKey()
{
if($this->listKey == "")
return $this->info;
if (is_null($this->listKey) ||
! isset($this->info[$this->listKey])
)
{
throw new ListKeyNotSetException('The listKey is not found in the abstract list DTO');
}
return $this->info[$this->listKey];
}
|
php
|
protected function getListByKey()
{
if($this->listKey == "")
return $this->info;
if (is_null($this->listKey) ||
! isset($this->info[$this->listKey])
)
{
throw new ListKeyNotSetException('The listKey is not found in the abstract list DTO');
}
return $this->info[$this->listKey];
}
|
[
"protected",
"function",
"getListByKey",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"listKey",
"==",
"\"\"",
")",
"return",
"$",
"this",
"->",
"info",
";",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"listKey",
")",
"||",
"!",
"isset",
"(",
"$",
"this",
"->",
"info",
"[",
"$",
"this",
"->",
"listKey",
"]",
")",
")",
"{",
"throw",
"new",
"ListKeyNotSetException",
"(",
"'The listKey is not found in the abstract list DTO'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"info",
"[",
"$",
"this",
"->",
"listKey",
"]",
";",
"}"
] |
Returns the list by key.
@return mixed
@throws ListKeyNotSetException
|
[
"Returns",
"the",
"list",
"by",
"key",
"."
] |
0f91813b5d8292054e5e13619d591b6b14dc63e6
|
https://github.com/paquettg/leaguewrap/blob/0f91813b5d8292054e5e13619d591b6b14dc63e6/src/LeagueWrap/Dto/AbstractListDto.php#L107-L120
|
221,693
|
radphp/radphp
|
src/DependencyInjection/Container.php
|
Container.setShared
|
public static function setShared($name, $definition, $locked = false)
{
if (isset(self::$services[$name]) && self::$services[$name]->isLocked()) {
throw new ServiceLockedException(sprintf('Service "%s" is locked.', $name));
}
self::$services[$name] = new Service($name, $definition, true, $locked);
}
|
php
|
public static function setShared($name, $definition, $locked = false)
{
if (isset(self::$services[$name]) && self::$services[$name]->isLocked()) {
throw new ServiceLockedException(sprintf('Service "%s" is locked.', $name));
}
self::$services[$name] = new Service($name, $definition, true, $locked);
}
|
[
"public",
"static",
"function",
"setShared",
"(",
"$",
"name",
",",
"$",
"definition",
",",
"$",
"locked",
"=",
"false",
")",
"{",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"services",
"[",
"$",
"name",
"]",
")",
"&&",
"self",
"::",
"$",
"services",
"[",
"$",
"name",
"]",
"->",
"isLocked",
"(",
")",
")",
"{",
"throw",
"new",
"ServiceLockedException",
"(",
"sprintf",
"(",
"'Service \"%s\" is locked.'",
",",
"$",
"name",
")",
")",
";",
"}",
"self",
"::",
"$",
"services",
"[",
"$",
"name",
"]",
"=",
"new",
"Service",
"(",
"$",
"name",
",",
"$",
"definition",
",",
"true",
",",
"$",
"locked",
")",
";",
"}"
] |
Set service as shared
@param string $name
@param callable|object|string $definition
@param bool $locked
@throws Exception
|
[
"Set",
"service",
"as",
"shared"
] |
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
|
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/DependencyInjection/Container.php#L52-L59
|
221,694
|
radphp/radphp
|
src/DependencyInjection/Container.php
|
Container.get
|
public static function get($name, array $args = [])
{
if (!isset(self::$services[$name])) {
throw new ServiceNotFoundException(sprintf('Service "%s" does not exist.', $name));
}
$instance = self::$services[$name]->resolve(self::getInstance(), $args);
if ($instance instanceof ContainerAwareInterface) {
$instance->setContainer(self::getInstance());
}
return $instance;
}
|
php
|
public static function get($name, array $args = [])
{
if (!isset(self::$services[$name])) {
throw new ServiceNotFoundException(sprintf('Service "%s" does not exist.', $name));
}
$instance = self::$services[$name]->resolve(self::getInstance(), $args);
if ($instance instanceof ContainerAwareInterface) {
$instance->setContainer(self::getInstance());
}
return $instance;
}
|
[
"public",
"static",
"function",
"get",
"(",
"$",
"name",
",",
"array",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"services",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"ServiceNotFoundException",
"(",
"sprintf",
"(",
"'Service \"%s\" does not exist.'",
",",
"$",
"name",
")",
")",
";",
"}",
"$",
"instance",
"=",
"self",
"::",
"$",
"services",
"[",
"$",
"name",
"]",
"->",
"resolve",
"(",
"self",
"::",
"getInstance",
"(",
")",
",",
"$",
"args",
")",
";",
"if",
"(",
"$",
"instance",
"instanceof",
"ContainerAwareInterface",
")",
"{",
"$",
"instance",
"->",
"setContainer",
"(",
"self",
"::",
"getInstance",
"(",
")",
")",
";",
"}",
"return",
"$",
"instance",
";",
"}"
] |
Get and resolve service
@param string $name
@param array $args
@return mixed|object
@throws Exception
|
[
"Get",
"and",
"resolve",
"service"
] |
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
|
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/DependencyInjection/Container.php#L70-L83
|
221,695
|
adhocore/php-cron-expr
|
src/Validator.php
|
Validator.inRange
|
public function inRange($value, $offset)
{
$parts = \explode('-', $offset);
return $parts[0] <= $value && $value <= $parts[1];
}
|
php
|
public function inRange($value, $offset)
{
$parts = \explode('-', $offset);
return $parts[0] <= $value && $value <= $parts[1];
}
|
[
"public",
"function",
"inRange",
"(",
"$",
"value",
",",
"$",
"offset",
")",
"{",
"$",
"parts",
"=",
"\\",
"explode",
"(",
"'-'",
",",
"$",
"offset",
")",
";",
"return",
"$",
"parts",
"[",
"0",
"]",
"<=",
"$",
"value",
"&&",
"$",
"value",
"<=",
"$",
"parts",
"[",
"1",
"]",
";",
"}"
] |
Check if the value is in range of given offset.
@param int $value
@param string $offset
@return bool
|
[
"Check",
"if",
"the",
"value",
"is",
"in",
"range",
"of",
"given",
"offset",
"."
] |
d7bfd342d62795a50ad6377964cf567eb727961a
|
https://github.com/adhocore/php-cron-expr/blob/d7bfd342d62795a50ad6377964cf567eb727961a/src/Validator.php#L31-L36
|
221,696
|
adhocore/php-cron-expr
|
src/Validator.php
|
Validator.inStep
|
public function inStep($value, $offset)
{
$parts = \explode('/', $offset, 2);
if (empty($parts[1])) {
return false;
}
if (\strpos($offset, '*/') !== false || \strpos($offset, '0/') !== false) {
return $value % $parts[1] === 0;
}
$parts = \explode('/', $offset, 2);
$subparts = \explode('-', $parts[0], 2) + [1 => $value];
return $this->inStepRange($value, $subparts[0], $subparts[1], $parts[1]);
}
|
php
|
public function inStep($value, $offset)
{
$parts = \explode('/', $offset, 2);
if (empty($parts[1])) {
return false;
}
if (\strpos($offset, '*/') !== false || \strpos($offset, '0/') !== false) {
return $value % $parts[1] === 0;
}
$parts = \explode('/', $offset, 2);
$subparts = \explode('-', $parts[0], 2) + [1 => $value];
return $this->inStepRange($value, $subparts[0], $subparts[1], $parts[1]);
}
|
[
"public",
"function",
"inStep",
"(",
"$",
"value",
",",
"$",
"offset",
")",
"{",
"$",
"parts",
"=",
"\\",
"explode",
"(",
"'/'",
",",
"$",
"offset",
",",
"2",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"parts",
"[",
"1",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"\\",
"strpos",
"(",
"$",
"offset",
",",
"'*/'",
")",
"!==",
"false",
"||",
"\\",
"strpos",
"(",
"$",
"offset",
",",
"'0/'",
")",
"!==",
"false",
")",
"{",
"return",
"$",
"value",
"%",
"$",
"parts",
"[",
"1",
"]",
"===",
"0",
";",
"}",
"$",
"parts",
"=",
"\\",
"explode",
"(",
"'/'",
",",
"$",
"offset",
",",
"2",
")",
";",
"$",
"subparts",
"=",
"\\",
"explode",
"(",
"'-'",
",",
"$",
"parts",
"[",
"0",
"]",
",",
"2",
")",
"+",
"[",
"1",
"=>",
"$",
"value",
"]",
";",
"return",
"$",
"this",
"->",
"inStepRange",
"(",
"$",
"value",
",",
"$",
"subparts",
"[",
"0",
"]",
",",
"$",
"subparts",
"[",
"1",
"]",
",",
"$",
"parts",
"[",
"1",
"]",
")",
";",
"}"
] |
Check if the value is in step of given offset.
@param int $value
@param string $offset
@return bool
|
[
"Check",
"if",
"the",
"value",
"is",
"in",
"step",
"of",
"given",
"offset",
"."
] |
d7bfd342d62795a50ad6377964cf567eb727961a
|
https://github.com/adhocore/php-cron-expr/blob/d7bfd342d62795a50ad6377964cf567eb727961a/src/Validator.php#L46-L62
|
221,697
|
adhocore/php-cron-expr
|
src/Validator.php
|
Validator.inStepRange
|
public function inStepRange($value, $start, $end, $step)
{
if (($start + $step) > $end) {
return false;
}
if ($start <= $value && $value <= $end) {
return \in_array($value, \range($start, $end, $step));
}
return false;
}
|
php
|
public function inStepRange($value, $start, $end, $step)
{
if (($start + $step) > $end) {
return false;
}
if ($start <= $value && $value <= $end) {
return \in_array($value, \range($start, $end, $step));
}
return false;
}
|
[
"public",
"function",
"inStepRange",
"(",
"$",
"value",
",",
"$",
"start",
",",
"$",
"end",
",",
"$",
"step",
")",
"{",
"if",
"(",
"(",
"$",
"start",
"+",
"$",
"step",
")",
">",
"$",
"end",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"start",
"<=",
"$",
"value",
"&&",
"$",
"value",
"<=",
"$",
"end",
")",
"{",
"return",
"\\",
"in_array",
"(",
"$",
"value",
",",
"\\",
"range",
"(",
"$",
"start",
",",
"$",
"end",
",",
"$",
"step",
")",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Check if the value falls between start and end when advanved by step.
@param int $value
@param int $start
@param int $end
@param int $step
@return bool
|
[
"Check",
"if",
"the",
"value",
"falls",
"between",
"start",
"and",
"end",
"when",
"advanved",
"by",
"step",
"."
] |
d7bfd342d62795a50ad6377964cf567eb727961a
|
https://github.com/adhocore/php-cron-expr/blob/d7bfd342d62795a50ad6377964cf567eb727961a/src/Validator.php#L74-L85
|
221,698
|
neos/fluid
|
Classes/TYPO3/Fluid/ViewHelpers/FormViewHelper.php
|
FormViewHelper.renderHiddenReferrerFields
|
protected function renderHiddenReferrerFields()
{
$result = chr(10);
$request = $this->controllerContext->getRequest();
$argumentNamespace = null;
if (!$request->isMainRequest()) {
$argumentNamespace = $request->getArgumentNamespace();
$referrer = array(
'@package' => $request->getControllerPackageKey(),
'@subpackage' => $request->getControllerSubpackageKey(),
'@controller' => $request->getControllerName(),
'@action' => $request->getControllerActionName(),
'arguments' => $this->hashService->appendHmac(base64_encode(serialize($request->getArguments())))
);
foreach ($referrer as $referrerKey => $referrerValue) {
$referrerValue = htmlspecialchars($referrerValue);
$result .= '<input type="hidden" name="' . $argumentNamespace . '[__referrer][' . $referrerKey . ']" value="' . $referrerValue . '" />' . chr(10);
}
$request = $request->getParentRequest();
}
$arguments = $request->getArguments();
if ($argumentNamespace !== null && isset($arguments[$argumentNamespace])) {
// A sub request was there; thus we can unset the sub requests arguments,
// as they are transferred separately via the code block shown above.
unset($arguments[$argumentNamespace]);
}
$referrer = array(
'@package' => $request->getControllerPackageKey(),
'@subpackage' => $request->getControllerSubpackageKey(),
'@controller' => $request->getControllerName(),
'@action' => $request->getControllerActionName(),
'arguments' => $this->hashService->appendHmac(base64_encode(serialize($arguments)))
);
foreach ($referrer as $referrerKey => $referrerValue) {
$result .= '<input type="hidden" name="__referrer[' . $referrerKey . ']" value="' . htmlspecialchars($referrerValue) . '" />' . chr(10);
}
return $result;
}
|
php
|
protected function renderHiddenReferrerFields()
{
$result = chr(10);
$request = $this->controllerContext->getRequest();
$argumentNamespace = null;
if (!$request->isMainRequest()) {
$argumentNamespace = $request->getArgumentNamespace();
$referrer = array(
'@package' => $request->getControllerPackageKey(),
'@subpackage' => $request->getControllerSubpackageKey(),
'@controller' => $request->getControllerName(),
'@action' => $request->getControllerActionName(),
'arguments' => $this->hashService->appendHmac(base64_encode(serialize($request->getArguments())))
);
foreach ($referrer as $referrerKey => $referrerValue) {
$referrerValue = htmlspecialchars($referrerValue);
$result .= '<input type="hidden" name="' . $argumentNamespace . '[__referrer][' . $referrerKey . ']" value="' . $referrerValue . '" />' . chr(10);
}
$request = $request->getParentRequest();
}
$arguments = $request->getArguments();
if ($argumentNamespace !== null && isset($arguments[$argumentNamespace])) {
// A sub request was there; thus we can unset the sub requests arguments,
// as they are transferred separately via the code block shown above.
unset($arguments[$argumentNamespace]);
}
$referrer = array(
'@package' => $request->getControllerPackageKey(),
'@subpackage' => $request->getControllerSubpackageKey(),
'@controller' => $request->getControllerName(),
'@action' => $request->getControllerActionName(),
'arguments' => $this->hashService->appendHmac(base64_encode(serialize($arguments)))
);
foreach ($referrer as $referrerKey => $referrerValue) {
$result .= '<input type="hidden" name="__referrer[' . $referrerKey . ']" value="' . htmlspecialchars($referrerValue) . '" />' . chr(10);
}
return $result;
}
|
[
"protected",
"function",
"renderHiddenReferrerFields",
"(",
")",
"{",
"$",
"result",
"=",
"chr",
"(",
"10",
")",
";",
"$",
"request",
"=",
"$",
"this",
"->",
"controllerContext",
"->",
"getRequest",
"(",
")",
";",
"$",
"argumentNamespace",
"=",
"null",
";",
"if",
"(",
"!",
"$",
"request",
"->",
"isMainRequest",
"(",
")",
")",
"{",
"$",
"argumentNamespace",
"=",
"$",
"request",
"->",
"getArgumentNamespace",
"(",
")",
";",
"$",
"referrer",
"=",
"array",
"(",
"'@package'",
"=>",
"$",
"request",
"->",
"getControllerPackageKey",
"(",
")",
",",
"'@subpackage'",
"=>",
"$",
"request",
"->",
"getControllerSubpackageKey",
"(",
")",
",",
"'@controller'",
"=>",
"$",
"request",
"->",
"getControllerName",
"(",
")",
",",
"'@action'",
"=>",
"$",
"request",
"->",
"getControllerActionName",
"(",
")",
",",
"'arguments'",
"=>",
"$",
"this",
"->",
"hashService",
"->",
"appendHmac",
"(",
"base64_encode",
"(",
"serialize",
"(",
"$",
"request",
"->",
"getArguments",
"(",
")",
")",
")",
")",
")",
";",
"foreach",
"(",
"$",
"referrer",
"as",
"$",
"referrerKey",
"=>",
"$",
"referrerValue",
")",
"{",
"$",
"referrerValue",
"=",
"htmlspecialchars",
"(",
"$",
"referrerValue",
")",
";",
"$",
"result",
".=",
"'<input type=\"hidden\" name=\"'",
".",
"$",
"argumentNamespace",
".",
"'[__referrer]['",
".",
"$",
"referrerKey",
".",
"']\" value=\"'",
".",
"$",
"referrerValue",
".",
"'\" />'",
".",
"chr",
"(",
"10",
")",
";",
"}",
"$",
"request",
"=",
"$",
"request",
"->",
"getParentRequest",
"(",
")",
";",
"}",
"$",
"arguments",
"=",
"$",
"request",
"->",
"getArguments",
"(",
")",
";",
"if",
"(",
"$",
"argumentNamespace",
"!==",
"null",
"&&",
"isset",
"(",
"$",
"arguments",
"[",
"$",
"argumentNamespace",
"]",
")",
")",
"{",
"// A sub request was there; thus we can unset the sub requests arguments,",
"// as they are transferred separately via the code block shown above.",
"unset",
"(",
"$",
"arguments",
"[",
"$",
"argumentNamespace",
"]",
")",
";",
"}",
"$",
"referrer",
"=",
"array",
"(",
"'@package'",
"=>",
"$",
"request",
"->",
"getControllerPackageKey",
"(",
")",
",",
"'@subpackage'",
"=>",
"$",
"request",
"->",
"getControllerSubpackageKey",
"(",
")",
",",
"'@controller'",
"=>",
"$",
"request",
"->",
"getControllerName",
"(",
")",
",",
"'@action'",
"=>",
"$",
"request",
"->",
"getControllerActionName",
"(",
")",
",",
"'arguments'",
"=>",
"$",
"this",
"->",
"hashService",
"->",
"appendHmac",
"(",
"base64_encode",
"(",
"serialize",
"(",
"$",
"arguments",
")",
")",
")",
")",
";",
"foreach",
"(",
"$",
"referrer",
"as",
"$",
"referrerKey",
"=>",
"$",
"referrerValue",
")",
"{",
"$",
"result",
".=",
"'<input type=\"hidden\" name=\"__referrer['",
".",
"$",
"referrerKey",
".",
"']\" value=\"'",
".",
"htmlspecialchars",
"(",
"$",
"referrerValue",
")",
".",
"'\" />'",
".",
"chr",
"(",
"10",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Renders hidden form fields for referrer information about
the current controller and action.
@return string Hidden fields with referrer information
@todo filter out referrer information that is equal to the target (e.g. same packageKey)
|
[
"Renders",
"hidden",
"form",
"fields",
"for",
"referrer",
"information",
"about",
"the",
"current",
"controller",
"and",
"action",
"."
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/ViewHelpers/FormViewHelper.php#L281-L322
|
221,699
|
radphp/radphp
|
src/Utility/Inflection.php
|
Inflection.camelize
|
public static function camelize($word, $uppercaseFirstLetter = true)
{
$word = self::underscore($word);
$word = str_replace(' ', '', ucwords(str_replace('_', ' ', $word)));
if ($uppercaseFirstLetter === false) {
$word = lcfirst($word);
}
return $word;
}
|
php
|
public static function camelize($word, $uppercaseFirstLetter = true)
{
$word = self::underscore($word);
$word = str_replace(' ', '', ucwords(str_replace('_', ' ', $word)));
if ($uppercaseFirstLetter === false) {
$word = lcfirst($word);
}
return $word;
}
|
[
"public",
"static",
"function",
"camelize",
"(",
"$",
"word",
",",
"$",
"uppercaseFirstLetter",
"=",
"true",
")",
"{",
"$",
"word",
"=",
"self",
"::",
"underscore",
"(",
"$",
"word",
")",
";",
"$",
"word",
"=",
"str_replace",
"(",
"' '",
",",
"''",
",",
"ucwords",
"(",
"str_replace",
"(",
"'_'",
",",
"' '",
",",
"$",
"word",
")",
")",
")",
";",
"if",
"(",
"$",
"uppercaseFirstLetter",
"===",
"false",
")",
"{",
"$",
"word",
"=",
"lcfirst",
"(",
"$",
"word",
")",
";",
"}",
"return",
"$",
"word",
";",
"}"
] |
Convert strings to CamelCase.
@param string $word
@param bool $uppercaseFirstLetter
@return mixed|string
|
[
"Convert",
"strings",
"to",
"CamelCase",
"."
] |
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
|
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/Utility/Inflection.php#L20-L30
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.