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,400
|
mysql-workbench-schema-exporter/doctrine2-exporter
|
lib/MwbExporter/Formatter/Doctrine2/ZF2InputFilterAnnotation/Model/Table.php
|
Table.writeGetArrayCopy
|
public function writeGetArrayCopy(WriterInterface $writer)
{
$columns = $this->getColumns();
$relations = $this->getTableRelations();
$writer
->write('/**')
->write(' * Return a array with all fields and data.')
->write(' * Default the relations will be ignored.')
->write(' * ')
->write(' * @param array $fields')
->write(' * @return array')
->write(' */')
->write('public function getArrayCopy(array $fields = array())')
->write('{')
->indent()
->write('$dataFields = array(%s);', implode(', ', array_map(function($column) {
return sprintf('\'%s\'', $column);
}, $columns->getColumnNames())))
->write('$relationFields = array(%s);', implode(', ', array_map(function($relation) {
return sprintf('\'%s\'', lcfirst($relation->getReferencedTable()->getModelName()));
}, $relations)))
->write('$copiedFields = array();')
->write('foreach ($relationFields as $relationField) {')
->indent()
->write('$map = null;')
->write('if (array_key_exists($relationField, $fields)) {')
->indent()
->write('$map = $fields[$relationField];')
->write('$fields[] = $relationField;')
->write('unset($fields[$relationField]);')
->outdent()
->write('}')
->write('if (!in_array($relationField, $fields)) {')
->indent()
->write('continue;')
->outdent()
->write('}')
->write('$getter = sprintf(\'get%s\', ucfirst(str_replace(\' \', \'\', ucwords(str_replace(\'_\', \' \', $relationField)))));')
->write('$relationEntity = $this->{$getter}();')
->write('$copiedFields[$relationField] = (!is_null($map))')
->indent()
->write('? $relationEntity->getArrayCopy($map)')
->write(': $relationEntity->getArrayCopy();')
->outdent()
->write('$fields = array_diff($fields, array($relationField));')
->outdent()
->write('}')
->write('foreach ($dataFields as $dataField) {')
->indent()
->write('if (!in_array($dataField, $fields) && !empty($fields)) {')
->indent()
->write('continue;')
->outdent()
->write('}')
->write('$getter = sprintf(\'get%s\', ucfirst(str_replace(\' \', \'\', ucwords(str_replace(\'_\', \' \', $dataField)))));')
->write('$copiedFields[$dataField] = $this->{$getter}();')
->outdent()
->write('}')
->write('')
->write('return $copiedFields;')
->outdent()
->write('}')
->write('')
;
return $this;
}
|
php
|
public function writeGetArrayCopy(WriterInterface $writer)
{
$columns = $this->getColumns();
$relations = $this->getTableRelations();
$writer
->write('/**')
->write(' * Return a array with all fields and data.')
->write(' * Default the relations will be ignored.')
->write(' * ')
->write(' * @param array $fields')
->write(' * @return array')
->write(' */')
->write('public function getArrayCopy(array $fields = array())')
->write('{')
->indent()
->write('$dataFields = array(%s);', implode(', ', array_map(function($column) {
return sprintf('\'%s\'', $column);
}, $columns->getColumnNames())))
->write('$relationFields = array(%s);', implode(', ', array_map(function($relation) {
return sprintf('\'%s\'', lcfirst($relation->getReferencedTable()->getModelName()));
}, $relations)))
->write('$copiedFields = array();')
->write('foreach ($relationFields as $relationField) {')
->indent()
->write('$map = null;')
->write('if (array_key_exists($relationField, $fields)) {')
->indent()
->write('$map = $fields[$relationField];')
->write('$fields[] = $relationField;')
->write('unset($fields[$relationField]);')
->outdent()
->write('}')
->write('if (!in_array($relationField, $fields)) {')
->indent()
->write('continue;')
->outdent()
->write('}')
->write('$getter = sprintf(\'get%s\', ucfirst(str_replace(\' \', \'\', ucwords(str_replace(\'_\', \' \', $relationField)))));')
->write('$relationEntity = $this->{$getter}();')
->write('$copiedFields[$relationField] = (!is_null($map))')
->indent()
->write('? $relationEntity->getArrayCopy($map)')
->write(': $relationEntity->getArrayCopy();')
->outdent()
->write('$fields = array_diff($fields, array($relationField));')
->outdent()
->write('}')
->write('foreach ($dataFields as $dataField) {')
->indent()
->write('if (!in_array($dataField, $fields) && !empty($fields)) {')
->indent()
->write('continue;')
->outdent()
->write('}')
->write('$getter = sprintf(\'get%s\', ucfirst(str_replace(\' \', \'\', ucwords(str_replace(\'_\', \' \', $dataField)))));')
->write('$copiedFields[$dataField] = $this->{$getter}();')
->outdent()
->write('}')
->write('')
->write('return $copiedFields;')
->outdent()
->write('}')
->write('')
;
return $this;
}
|
[
"public",
"function",
"writeGetArrayCopy",
"(",
"WriterInterface",
"$",
"writer",
")",
"{",
"$",
"columns",
"=",
"$",
"this",
"->",
"getColumns",
"(",
")",
";",
"$",
"relations",
"=",
"$",
"this",
"->",
"getTableRelations",
"(",
")",
";",
"$",
"writer",
"->",
"write",
"(",
"'/**'",
")",
"->",
"write",
"(",
"' * Return a array with all fields and data.'",
")",
"->",
"write",
"(",
"' * Default the relations will be ignored.'",
")",
"->",
"write",
"(",
"' * '",
")",
"->",
"write",
"(",
"' * @param array $fields'",
")",
"->",
"write",
"(",
"' * @return array'",
")",
"->",
"write",
"(",
"' */'",
")",
"->",
"write",
"(",
"'public function getArrayCopy(array $fields = array())'",
")",
"->",
"write",
"(",
"'{'",
")",
"->",
"indent",
"(",
")",
"->",
"write",
"(",
"'$dataFields = array(%s);'",
",",
"implode",
"(",
"', '",
",",
"array_map",
"(",
"function",
"(",
"$",
"column",
")",
"{",
"return",
"sprintf",
"(",
"'\\'%s\\''",
",",
"$",
"column",
")",
";",
"}",
",",
"$",
"columns",
"->",
"getColumnNames",
"(",
")",
")",
")",
")",
"->",
"write",
"(",
"'$relationFields = array(%s);'",
",",
"implode",
"(",
"', '",
",",
"array_map",
"(",
"function",
"(",
"$",
"relation",
")",
"{",
"return",
"sprintf",
"(",
"'\\'%s\\''",
",",
"lcfirst",
"(",
"$",
"relation",
"->",
"getReferencedTable",
"(",
")",
"->",
"getModelName",
"(",
")",
")",
")",
";",
"}",
",",
"$",
"relations",
")",
")",
")",
"->",
"write",
"(",
"'$copiedFields = array();'",
")",
"->",
"write",
"(",
"'foreach ($relationFields as $relationField) {'",
")",
"->",
"indent",
"(",
")",
"->",
"write",
"(",
"'$map = null;'",
")",
"->",
"write",
"(",
"'if (array_key_exists($relationField, $fields)) {'",
")",
"->",
"indent",
"(",
")",
"->",
"write",
"(",
"'$map = $fields[$relationField];'",
")",
"->",
"write",
"(",
"'$fields[] = $relationField;'",
")",
"->",
"write",
"(",
"'unset($fields[$relationField]);'",
")",
"->",
"outdent",
"(",
")",
"->",
"write",
"(",
"'}'",
")",
"->",
"write",
"(",
"'if (!in_array($relationField, $fields)) {'",
")",
"->",
"indent",
"(",
")",
"->",
"write",
"(",
"'continue;'",
")",
"->",
"outdent",
"(",
")",
"->",
"write",
"(",
"'}'",
")",
"->",
"write",
"(",
"'$getter = sprintf(\\'get%s\\', ucfirst(str_replace(\\' \\', \\'\\', ucwords(str_replace(\\'_\\', \\' \\', $relationField)))));'",
")",
"->",
"write",
"(",
"'$relationEntity = $this->{$getter}();'",
")",
"->",
"write",
"(",
"'$copiedFields[$relationField] = (!is_null($map))'",
")",
"->",
"indent",
"(",
")",
"->",
"write",
"(",
"'? $relationEntity->getArrayCopy($map)'",
")",
"->",
"write",
"(",
"': $relationEntity->getArrayCopy();'",
")",
"->",
"outdent",
"(",
")",
"->",
"write",
"(",
"'$fields = array_diff($fields, array($relationField));'",
")",
"->",
"outdent",
"(",
")",
"->",
"write",
"(",
"'}'",
")",
"->",
"write",
"(",
"'foreach ($dataFields as $dataField) {'",
")",
"->",
"indent",
"(",
")",
"->",
"write",
"(",
"'if (!in_array($dataField, $fields) && !empty($fields)) {'",
")",
"->",
"indent",
"(",
")",
"->",
"write",
"(",
"'continue;'",
")",
"->",
"outdent",
"(",
")",
"->",
"write",
"(",
"'}'",
")",
"->",
"write",
"(",
"'$getter = sprintf(\\'get%s\\', ucfirst(str_replace(\\' \\', \\'\\', ucwords(str_replace(\\'_\\', \\' \\', $dataField)))));'",
")",
"->",
"write",
"(",
"'$copiedFields[$dataField] = $this->{$getter}();'",
")",
"->",
"outdent",
"(",
")",
"->",
"write",
"(",
"'}'",
")",
"->",
"write",
"(",
"''",
")",
"->",
"write",
"(",
"'return $copiedFields;'",
")",
"->",
"outdent",
"(",
")",
"->",
"write",
"(",
"'}'",
")",
"->",
"write",
"(",
"''",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Write getArrayCopy method.
@see \Zend\Stdlib\Hydrator\ArraySerializable::hydrate()
@param \MwbExporter\Writer\WriterInterface $writer
@return \MwbExporter\Formatter\Doctrine2\AnnotationZF2InputFilter\Model\Table
|
[
"Write",
"getArrayCopy",
"method",
"."
] |
a62b13cbf4824c05cc791034ffedf419242ba0cb
|
https://github.com/mysql-workbench-schema-exporter/doctrine2-exporter/blob/a62b13cbf4824c05cc791034ffedf419242ba0cb/lib/MwbExporter/Formatter/Doctrine2/ZF2InputFilterAnnotation/Model/Table.php#L297-L364
|
221,401
|
oleh-ozimok/php-centrifugo
|
src/Centrifugo/Centrifugo.php
|
Centrifugo.node
|
public function node($endpoint)
{
$request = new Request($endpoint, $this->secret, 'node', []);
return $this->sendBatchRequest([$request]);
}
|
php
|
public function node($endpoint)
{
$request = new Request($endpoint, $this->secret, 'node', []);
return $this->sendBatchRequest([$request]);
}
|
[
"public",
"function",
"node",
"(",
"$",
"endpoint",
")",
"{",
"$",
"request",
"=",
"new",
"Request",
"(",
"$",
"endpoint",
",",
"$",
"this",
"->",
"secret",
",",
"'node'",
",",
"[",
"]",
")",
";",
"return",
"$",
"this",
"->",
"sendBatchRequest",
"(",
"[",
"$",
"request",
"]",
")",
";",
"}"
] |
Get information about single Centrifugo node.
@param string $endpoint
@return Response
|
[
"Get",
"information",
"about",
"single",
"Centrifugo",
"node",
"."
] |
f90490407474b7f0274f339728f9b0b0e264e09d
|
https://github.com/oleh-ozimok/php-centrifugo/blob/f90490407474b7f0274f339728f9b0b0e264e09d/src/Centrifugo/Centrifugo.php#L157-L162
|
221,402
|
oleh-ozimok/php-centrifugo
|
src/Centrifugo/Centrifugo.php
|
Centrifugo.generateClientToken
|
public function generateClientToken($user, $timestamp, $info = '')
{
$ctx = hash_init('sha256', HASH_HMAC, $this->secret);
hash_update($ctx, $user);
hash_update($ctx, $timestamp);
hash_update($ctx, $info);
return hash_final($ctx);
}
|
php
|
public function generateClientToken($user, $timestamp, $info = '')
{
$ctx = hash_init('sha256', HASH_HMAC, $this->secret);
hash_update($ctx, $user);
hash_update($ctx, $timestamp);
hash_update($ctx, $info);
return hash_final($ctx);
}
|
[
"public",
"function",
"generateClientToken",
"(",
"$",
"user",
",",
"$",
"timestamp",
",",
"$",
"info",
"=",
"''",
")",
"{",
"$",
"ctx",
"=",
"hash_init",
"(",
"'sha256'",
",",
"HASH_HMAC",
",",
"$",
"this",
"->",
"secret",
")",
";",
"hash_update",
"(",
"$",
"ctx",
",",
"$",
"user",
")",
";",
"hash_update",
"(",
"$",
"ctx",
",",
"$",
"timestamp",
")",
";",
"hash_update",
"(",
"$",
"ctx",
",",
"$",
"info",
")",
";",
"return",
"hash_final",
"(",
"$",
"ctx",
")",
";",
"}"
] |
Generate client connection token.
@param string $user
@param string $timestamp
@param string $info
@return string
|
[
"Generate",
"client",
"connection",
"token",
"."
] |
f90490407474b7f0274f339728f9b0b0e264e09d
|
https://github.com/oleh-ozimok/php-centrifugo/blob/f90490407474b7f0274f339728f9b0b0e264e09d/src/Centrifugo/Centrifugo.php#L181-L189
|
221,403
|
oleh-ozimok/php-centrifugo
|
src/Centrifugo/Centrifugo.php
|
Centrifugo.generateChannelSign
|
public function generateChannelSign($client, $channel, $info = '')
{
$ctx = hash_init('sha256', HASH_HMAC, $this->secret);
hash_update($ctx, $client);
hash_update($ctx, $channel);
hash_update($ctx, $info);
return hash_final($ctx);
}
|
php
|
public function generateChannelSign($client, $channel, $info = '')
{
$ctx = hash_init('sha256', HASH_HMAC, $this->secret);
hash_update($ctx, $client);
hash_update($ctx, $channel);
hash_update($ctx, $info);
return hash_final($ctx);
}
|
[
"public",
"function",
"generateChannelSign",
"(",
"$",
"client",
",",
"$",
"channel",
",",
"$",
"info",
"=",
"''",
")",
"{",
"$",
"ctx",
"=",
"hash_init",
"(",
"'sha256'",
",",
"HASH_HMAC",
",",
"$",
"this",
"->",
"secret",
")",
";",
"hash_update",
"(",
"$",
"ctx",
",",
"$",
"client",
")",
";",
"hash_update",
"(",
"$",
"ctx",
",",
"$",
"channel",
")",
";",
"hash_update",
"(",
"$",
"ctx",
",",
"$",
"info",
")",
";",
"return",
"hash_final",
"(",
"$",
"ctx",
")",
";",
"}"
] |
Generate channel sign.
@param string $client
@param string $channel
@param string $info
@return string
|
[
"Generate",
"channel",
"sign",
"."
] |
f90490407474b7f0274f339728f9b0b0e264e09d
|
https://github.com/oleh-ozimok/php-centrifugo/blob/f90490407474b7f0274f339728f9b0b0e264e09d/src/Centrifugo/Centrifugo.php#L200-L208
|
221,404
|
oleh-ozimok/php-centrifugo
|
src/Centrifugo/Centrifugo.php
|
Centrifugo.sendBatchRequest
|
public function sendBatchRequest(array $requests)
{
$batchRequest = new BatchRequest($this->endpoint, $this->secret, $requests);
return $this->lastResponse = $this->client->sendBatchRequest($batchRequest);
}
|
php
|
public function sendBatchRequest(array $requests)
{
$batchRequest = new BatchRequest($this->endpoint, $this->secret, $requests);
return $this->lastResponse = $this->client->sendBatchRequest($batchRequest);
}
|
[
"public",
"function",
"sendBatchRequest",
"(",
"array",
"$",
"requests",
")",
"{",
"$",
"batchRequest",
"=",
"new",
"BatchRequest",
"(",
"$",
"this",
"->",
"endpoint",
",",
"$",
"this",
"->",
"secret",
",",
"$",
"requests",
")",
";",
"return",
"$",
"this",
"->",
"lastResponse",
"=",
"$",
"this",
"->",
"client",
"->",
"sendBatchRequest",
"(",
"$",
"batchRequest",
")",
";",
"}"
] |
Send batch request.
@param Request[] $requests
@return BatchResponse
|
[
"Send",
"batch",
"request",
"."
] |
f90490407474b7f0274f339728f9b0b0e264e09d
|
https://github.com/oleh-ozimok/php-centrifugo/blob/f90490407474b7f0274f339728f9b0b0e264e09d/src/Centrifugo/Centrifugo.php#L237-L242
|
221,405
|
fre5h/FirebaseCloudMessagingBundle
|
Message/Builder/MessageBuilder.php
|
MessageBuilder.buildOptionsPart
|
private function buildOptionsPart(): void
{
$this->optionsPart = [];
if ($this->message instanceof AbstractMessage && $this->message->getOptions() instanceof OptionsInterface) {
$options = $this->message->getOptions();
if (!empty($options->getCollapseKey())) {
$this->optionsPart['collapse_key'] = $options->getCollapseKey();
}
// By default, messages are sent with normal priority.
// If priority is different add it to the set of options.
if (Priority::NORMAL !== $options->getPriority()) {
$this->optionsPart['priority'] = $options->getPriority();
}
// By default `content_available` option is false. Adding it only if it was changed to true.
if ($options->isContentAvailable()) {
$this->optionsPart['content_available'] = true;
}
// By default `mutable_content` option is false. Adding it only if it was changed to true.
if ($options->isMutableContent()) {
$this->optionsPart['mutable_content'] = true;
}
// By default TTL for message in FCM is 4 weeks, it is also the default value if you omitted the TTL option.
// So if the TTL is overwritten and is not equal to the default value, then add this option.
// Otherwise if TTL is still equal to default, then it is not need to send this option.
if (Options::DEFAULT_TTL_IN_SECONDS !== $options->getTimeToLive()) {
$this->optionsPart['time_to_live'] = $options->getTimeToLive();
}
if (!empty($options->getRestrictedPackageName())) {
$this->optionsPart['restricted_package_name'] = $options->getRestrictedPackageName();
}
// By default `dry_run` option is.... @todo
if ($options->isDryRun()) {
$this->optionsPart['dry_run'] = true;
}
}
}
|
php
|
private function buildOptionsPart(): void
{
$this->optionsPart = [];
if ($this->message instanceof AbstractMessage && $this->message->getOptions() instanceof OptionsInterface) {
$options = $this->message->getOptions();
if (!empty($options->getCollapseKey())) {
$this->optionsPart['collapse_key'] = $options->getCollapseKey();
}
// By default, messages are sent with normal priority.
// If priority is different add it to the set of options.
if (Priority::NORMAL !== $options->getPriority()) {
$this->optionsPart['priority'] = $options->getPriority();
}
// By default `content_available` option is false. Adding it only if it was changed to true.
if ($options->isContentAvailable()) {
$this->optionsPart['content_available'] = true;
}
// By default `mutable_content` option is false. Adding it only if it was changed to true.
if ($options->isMutableContent()) {
$this->optionsPart['mutable_content'] = true;
}
// By default TTL for message in FCM is 4 weeks, it is also the default value if you omitted the TTL option.
// So if the TTL is overwritten and is not equal to the default value, then add this option.
// Otherwise if TTL is still equal to default, then it is not need to send this option.
if (Options::DEFAULT_TTL_IN_SECONDS !== $options->getTimeToLive()) {
$this->optionsPart['time_to_live'] = $options->getTimeToLive();
}
if (!empty($options->getRestrictedPackageName())) {
$this->optionsPart['restricted_package_name'] = $options->getRestrictedPackageName();
}
// By default `dry_run` option is.... @todo
if ($options->isDryRun()) {
$this->optionsPart['dry_run'] = true;
}
}
}
|
[
"private",
"function",
"buildOptionsPart",
"(",
")",
":",
"void",
"{",
"$",
"this",
"->",
"optionsPart",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"message",
"instanceof",
"AbstractMessage",
"&&",
"$",
"this",
"->",
"message",
"->",
"getOptions",
"(",
")",
"instanceof",
"OptionsInterface",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"message",
"->",
"getOptions",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"options",
"->",
"getCollapseKey",
"(",
")",
")",
")",
"{",
"$",
"this",
"->",
"optionsPart",
"[",
"'collapse_key'",
"]",
"=",
"$",
"options",
"->",
"getCollapseKey",
"(",
")",
";",
"}",
"// By default, messages are sent with normal priority.",
"// If priority is different add it to the set of options.",
"if",
"(",
"Priority",
"::",
"NORMAL",
"!==",
"$",
"options",
"->",
"getPriority",
"(",
")",
")",
"{",
"$",
"this",
"->",
"optionsPart",
"[",
"'priority'",
"]",
"=",
"$",
"options",
"->",
"getPriority",
"(",
")",
";",
"}",
"// By default `content_available` option is false. Adding it only if it was changed to true.",
"if",
"(",
"$",
"options",
"->",
"isContentAvailable",
"(",
")",
")",
"{",
"$",
"this",
"->",
"optionsPart",
"[",
"'content_available'",
"]",
"=",
"true",
";",
"}",
"// By default `mutable_content` option is false. Adding it only if it was changed to true.",
"if",
"(",
"$",
"options",
"->",
"isMutableContent",
"(",
")",
")",
"{",
"$",
"this",
"->",
"optionsPart",
"[",
"'mutable_content'",
"]",
"=",
"true",
";",
"}",
"// By default TTL for message in FCM is 4 weeks, it is also the default value if you omitted the TTL option.",
"// So if the TTL is overwritten and is not equal to the default value, then add this option.",
"// Otherwise if TTL is still equal to default, then it is not need to send this option.",
"if",
"(",
"Options",
"::",
"DEFAULT_TTL_IN_SECONDS",
"!==",
"$",
"options",
"->",
"getTimeToLive",
"(",
")",
")",
"{",
"$",
"this",
"->",
"optionsPart",
"[",
"'time_to_live'",
"]",
"=",
"$",
"options",
"->",
"getTimeToLive",
"(",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"options",
"->",
"getRestrictedPackageName",
"(",
")",
")",
")",
"{",
"$",
"this",
"->",
"optionsPart",
"[",
"'restricted_package_name'",
"]",
"=",
"$",
"options",
"->",
"getRestrictedPackageName",
"(",
")",
";",
"}",
"// By default `dry_run` option is.... @todo",
"if",
"(",
"$",
"options",
"->",
"isDryRun",
"(",
")",
")",
"{",
"$",
"this",
"->",
"optionsPart",
"[",
"'dry_run'",
"]",
"=",
"true",
";",
"}",
"}",
"}"
] |
Build options part.
|
[
"Build",
"options",
"part",
"."
] |
7e13054d6c81ae0e1c91028e877b332090ae3886
|
https://github.com/fre5h/FirebaseCloudMessagingBundle/blob/7e13054d6c81ae0e1c91028e877b332090ae3886/Message/Builder/MessageBuilder.php#L132-L175
|
221,406
|
webcreate/vcs
|
src/Webcreate/Vcs/Svn/AbstractSvn.php
|
AbstractSvn.getGlobalArguments
|
protected function getGlobalArguments()
{
$args = array(
'--non-interactive' => true,
);
if ($this->username) $args['--username'] = $this->username;
if ($this->password) $args['--password'] = $this->password;
return $args;
}
|
php
|
protected function getGlobalArguments()
{
$args = array(
'--non-interactive' => true,
);
if ($this->username) $args['--username'] = $this->username;
if ($this->password) $args['--password'] = $this->password;
return $args;
}
|
[
"protected",
"function",
"getGlobalArguments",
"(",
")",
"{",
"$",
"args",
"=",
"array",
"(",
"'--non-interactive'",
"=>",
"true",
",",
")",
";",
"if",
"(",
"$",
"this",
"->",
"username",
")",
"$",
"args",
"[",
"'--username'",
"]",
"=",
"$",
"this",
"->",
"username",
";",
"if",
"(",
"$",
"this",
"->",
"password",
")",
"$",
"args",
"[",
"'--password'",
"]",
"=",
"$",
"this",
"->",
"password",
";",
"return",
"$",
"args",
";",
"}"
] |
Global arguments for executing SVN commands
@return array
|
[
"Global",
"arguments",
"for",
"executing",
"SVN",
"commands"
] |
31a680f2501c4e5a599e8dd3ffbc8c0a5185c8ad
|
https://github.com/webcreate/vcs/blob/31a680f2501c4e5a599e8dd3ffbc8c0a5185c8ad/src/Webcreate/Vcs/Svn/AbstractSvn.php#L138-L147
|
221,407
|
webcreate/vcs
|
src/Webcreate/Vcs/Svn/AbstractSvn.php
|
AbstractSvn.execute
|
public function execute($command, array $arguments = array(), $cwd = null)
{
$arguments += $this->getGlobalArguments();
try {
$result = $this->adapter->execute($command, $arguments, $cwd);
} catch (\Exception $e) {
// @todo move to a generic error handler? Something similar to the ParserInterface
if (preg_match('/url \'[^\']+\' non-existent/i', $e->getMessage()) ||
preg_match('/file not found/i', $e->getMessage()) ||
preg_match('/path not found/i', $e->getMessage())
) {
throw new NotFoundException($e->getMessage());
}
throw $e;
}
return $result;
}
|
php
|
public function execute($command, array $arguments = array(), $cwd = null)
{
$arguments += $this->getGlobalArguments();
try {
$result = $this->adapter->execute($command, $arguments, $cwd);
} catch (\Exception $e) {
// @todo move to a generic error handler? Something similar to the ParserInterface
if (preg_match('/url \'[^\']+\' non-existent/i', $e->getMessage()) ||
preg_match('/file not found/i', $e->getMessage()) ||
preg_match('/path not found/i', $e->getMessage())
) {
throw new NotFoundException($e->getMessage());
}
throw $e;
}
return $result;
}
|
[
"public",
"function",
"execute",
"(",
"$",
"command",
",",
"array",
"$",
"arguments",
"=",
"array",
"(",
")",
",",
"$",
"cwd",
"=",
"null",
")",
"{",
"$",
"arguments",
"+=",
"$",
"this",
"->",
"getGlobalArguments",
"(",
")",
";",
"try",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"adapter",
"->",
"execute",
"(",
"$",
"command",
",",
"$",
"arguments",
",",
"$",
"cwd",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"// @todo move to a generic error handler? Something similar to the ParserInterface",
"if",
"(",
"preg_match",
"(",
"'/url \\'[^\\']+\\' non-existent/i'",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
"||",
"preg_match",
"(",
"'/file not found/i'",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
"||",
"preg_match",
"(",
"'/path not found/i'",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
")",
"{",
"throw",
"new",
"NotFoundException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"throw",
"$",
"e",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Execute SVN command
@param string $command
@param array $arguments
@param string $cwd
@throws \Webcreate\Vcs\Exception\NotFoundException
@throws \Exception
@return string
|
[
"Execute",
"SVN",
"command"
] |
31a680f2501c4e5a599e8dd3ffbc8c0a5185c8ad
|
https://github.com/webcreate/vcs/blob/31a680f2501c4e5a599e8dd3ffbc8c0a5185c8ad/src/Webcreate/Vcs/Svn/AbstractSvn.php#L159-L178
|
221,408
|
webcreate/vcs
|
src/Webcreate/Vcs/Svn/AbstractSvn.php
|
AbstractSvn.getSvnUrl
|
public function getSvnUrl($path)
{
$head = $this->head;
if ($path instanceof Reference) {
$head = $path;
$path = '/';
}
if (null === $path) {
$path = '/';
}
if (is_string($path)) {
$path = new VcsFileInfo($path, array($head->getName(), $head->getType()));
}
if ($path->inBranch()) {
$branchName = $path->getReferenceName();
if ('trunk' === $branchName) {
$basePath = $this->basePaths['trunk'];
} else {
$basePath = $this->basePaths['branches'] . '/' . $branchName;
}
} elseif ($path->inTag()) {
$tagName = $path->getReferenceName();
$basePath = $this->basePaths['tags'] . '/' . $tagName;
}
$retval = $this->url;
if (isset($basePath)) {
$retval.= '/' . $basePath;
}
$retval.= '/' . ltrim($path->getPathname(), '/');
$retval = rtrim($retval, '/');
return $retval;
}
|
php
|
public function getSvnUrl($path)
{
$head = $this->head;
if ($path instanceof Reference) {
$head = $path;
$path = '/';
}
if (null === $path) {
$path = '/';
}
if (is_string($path)) {
$path = new VcsFileInfo($path, array($head->getName(), $head->getType()));
}
if ($path->inBranch()) {
$branchName = $path->getReferenceName();
if ('trunk' === $branchName) {
$basePath = $this->basePaths['trunk'];
} else {
$basePath = $this->basePaths['branches'] . '/' . $branchName;
}
} elseif ($path->inTag()) {
$tagName = $path->getReferenceName();
$basePath = $this->basePaths['tags'] . '/' . $tagName;
}
$retval = $this->url;
if (isset($basePath)) {
$retval.= '/' . $basePath;
}
$retval.= '/' . ltrim($path->getPathname(), '/');
$retval = rtrim($retval, '/');
return $retval;
}
|
[
"public",
"function",
"getSvnUrl",
"(",
"$",
"path",
")",
"{",
"$",
"head",
"=",
"$",
"this",
"->",
"head",
";",
"if",
"(",
"$",
"path",
"instanceof",
"Reference",
")",
"{",
"$",
"head",
"=",
"$",
"path",
";",
"$",
"path",
"=",
"'/'",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"'/'",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"path",
")",
")",
"{",
"$",
"path",
"=",
"new",
"VcsFileInfo",
"(",
"$",
"path",
",",
"array",
"(",
"$",
"head",
"->",
"getName",
"(",
")",
",",
"$",
"head",
"->",
"getType",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"$",
"path",
"->",
"inBranch",
"(",
")",
")",
"{",
"$",
"branchName",
"=",
"$",
"path",
"->",
"getReferenceName",
"(",
")",
";",
"if",
"(",
"'trunk'",
"===",
"$",
"branchName",
")",
"{",
"$",
"basePath",
"=",
"$",
"this",
"->",
"basePaths",
"[",
"'trunk'",
"]",
";",
"}",
"else",
"{",
"$",
"basePath",
"=",
"$",
"this",
"->",
"basePaths",
"[",
"'branches'",
"]",
".",
"'/'",
".",
"$",
"branchName",
";",
"}",
"}",
"elseif",
"(",
"$",
"path",
"->",
"inTag",
"(",
")",
")",
"{",
"$",
"tagName",
"=",
"$",
"path",
"->",
"getReferenceName",
"(",
")",
";",
"$",
"basePath",
"=",
"$",
"this",
"->",
"basePaths",
"[",
"'tags'",
"]",
".",
"'/'",
".",
"$",
"tagName",
";",
"}",
"$",
"retval",
"=",
"$",
"this",
"->",
"url",
";",
"if",
"(",
"isset",
"(",
"$",
"basePath",
")",
")",
"{",
"$",
"retval",
".=",
"'/'",
".",
"$",
"basePath",
";",
"}",
"$",
"retval",
".=",
"'/'",
".",
"ltrim",
"(",
"$",
"path",
"->",
"getPathname",
"(",
")",
",",
"'/'",
")",
";",
"$",
"retval",
"=",
"rtrim",
"(",
"$",
"retval",
",",
"'/'",
")",
";",
"return",
"$",
"retval",
";",
"}"
] |
Returns url for a specific path
@param string|VcsFileInfo $path
@return string
|
[
"Returns",
"url",
"for",
"a",
"specific",
"path"
] |
31a680f2501c4e5a599e8dd3ffbc8c0a5185c8ad
|
https://github.com/webcreate/vcs/blob/31a680f2501c4e5a599e8dd3ffbc8c0a5185c8ad/src/Webcreate/Vcs/Svn/AbstractSvn.php#L186-L226
|
221,409
|
webcreate/vcs
|
src/Webcreate/Vcs/Svn/AbstractSvn.php
|
AbstractSvn.cmpSvnEntriesByKind
|
protected function cmpSvnEntriesByKind(array $item1, array $item2)
{
$item1['name'] = strtolower($item1['name']);
$item2['name'] = strtolower($item2['name']);
return ($item1['kind'] == 'dir'
? ($item2['kind'] == 'dir' ? strnatcmp($item1['name'], $item2['name']) : -1)
: ($item2['kind'] == 'dir' ? 1 : strnatcmp($item1['name'], $item2['name'])
));
}
|
php
|
protected function cmpSvnEntriesByKind(array $item1, array $item2)
{
$item1['name'] = strtolower($item1['name']);
$item2['name'] = strtolower($item2['name']);
return ($item1['kind'] == 'dir'
? ($item2['kind'] == 'dir' ? strnatcmp($item1['name'], $item2['name']) : -1)
: ($item2['kind'] == 'dir' ? 1 : strnatcmp($item1['name'], $item2['name'])
));
}
|
[
"protected",
"function",
"cmpSvnEntriesByKind",
"(",
"array",
"$",
"item1",
",",
"array",
"$",
"item2",
")",
"{",
"$",
"item1",
"[",
"'name'",
"]",
"=",
"strtolower",
"(",
"$",
"item1",
"[",
"'name'",
"]",
")",
";",
"$",
"item2",
"[",
"'name'",
"]",
"=",
"strtolower",
"(",
"$",
"item2",
"[",
"'name'",
"]",
")",
";",
"return",
"(",
"$",
"item1",
"[",
"'kind'",
"]",
"==",
"'dir'",
"?",
"(",
"$",
"item2",
"[",
"'kind'",
"]",
"==",
"'dir'",
"?",
"strnatcmp",
"(",
"$",
"item1",
"[",
"'name'",
"]",
",",
"$",
"item2",
"[",
"'name'",
"]",
")",
":",
"-",
"1",
")",
":",
"(",
"$",
"item2",
"[",
"'kind'",
"]",
"==",
"'dir'",
"?",
"1",
":",
"strnatcmp",
"(",
"$",
"item1",
"[",
"'name'",
"]",
",",
"$",
"item2",
"[",
"'name'",
"]",
")",
")",
")",
";",
"}"
] |
Sort function for sorting entries
@param array $item1
@param array $item2
@return number
|
[
"Sort",
"function",
"for",
"sorting",
"entries"
] |
31a680f2501c4e5a599e8dd3ffbc8c0a5185c8ad
|
https://github.com/webcreate/vcs/blob/31a680f2501c4e5a599e8dd3ffbc8c0a5185c8ad/src/Webcreate/Vcs/Svn/AbstractSvn.php#L235-L244
|
221,410
|
iambrosi/IsmaAmbrosiGeneratorBundle
|
Command/GenerateDoctrineCrudCommand.php
|
GenerateDoctrineCrudCommand.generateForm
|
private function generateForm(BundleInterface $bundle, $document, $metadata)
{
try {
$this->getFormGenerator()->generate($bundle, $document, $metadata);
} catch (\RuntimeException $e) {
// form already exists
}
}
|
php
|
private function generateForm(BundleInterface $bundle, $document, $metadata)
{
try {
$this->getFormGenerator()->generate($bundle, $document, $metadata);
} catch (\RuntimeException $e) {
// form already exists
}
}
|
[
"private",
"function",
"generateForm",
"(",
"BundleInterface",
"$",
"bundle",
",",
"$",
"document",
",",
"$",
"metadata",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"getFormGenerator",
"(",
")",
"->",
"generate",
"(",
"$",
"bundle",
",",
"$",
"document",
",",
"$",
"metadata",
")",
";",
"}",
"catch",
"(",
"\\",
"RuntimeException",
"$",
"e",
")",
"{",
"// form already exists",
"}",
"}"
] |
Tries to generate forms if they don't exist yet and if we need write operations on documents.
|
[
"Tries",
"to",
"generate",
"forms",
"if",
"they",
"don",
"t",
"exist",
"yet",
"and",
"if",
"we",
"need",
"write",
"operations",
"on",
"documents",
"."
] |
cd5937ac1db82dfee1b23946f09de4cd778d872d
|
https://github.com/iambrosi/IsmaAmbrosiGeneratorBundle/blob/cd5937ac1db82dfee1b23946f09de4cd778d872d/Command/GenerateDoctrineCrudCommand.php#L234-L241
|
221,411
|
keboola/generic-extractor
|
src/Configuration/Api.php
|
Api.createAuth
|
private function createAuth(array $api, array $configAttributes, array $authorization) : AuthInterface
{
if (empty($api['authentication']['type'])) {
$this->logger->debug("Using no authentication.");
return new Authentication\NoAuth();
}
$this->logger->debug("Using '{$api['authentication']['type']}' authentication.");
switch ($api['authentication']['type']) {
case 'basic':
if (!empty($config['password']) && empty($config['#password'])) {
$this->logger->warning("Using deprecated 'password', use '#password' instead.");
}
return new Authentication\Basic($configAttributes);
break;
/** @noinspection PhpMissingBreakStatementInspection */
case 'url.query':
$this->logger->warning("Method 'url.query' auth is deprecated, use 'query'.");
// intentional, no break
case 'query':
if (empty($api['authentication']['query']) && !empty($api['query'])) {
$this->logger->warning("Using 'api.query' is deprecated, use 'api.authentication.query");
$api['authentication']['query'] = $api['query'];
}
return new Authentication\Query($configAttributes, $api['authentication']);
break;
case 'login':
return new Authentication\Login($configAttributes, $api['authentication']);
break;
case 'oauth10':
return new Authentication\OAuth10($authorization);
case 'oauth20':
return new Authentication\OAuth20($configAttributes, $authorization, $api['authentication']);
case 'oauth20.login':
return new Authentication\OAuth20Login($configAttributes, $authorization, $api['authentication']);
default:
throw new UserException("Unknown authorization type '{$api['authentication']['type']}'.");
break;
}
}
|
php
|
private function createAuth(array $api, array $configAttributes, array $authorization) : AuthInterface
{
if (empty($api['authentication']['type'])) {
$this->logger->debug("Using no authentication.");
return new Authentication\NoAuth();
}
$this->logger->debug("Using '{$api['authentication']['type']}' authentication.");
switch ($api['authentication']['type']) {
case 'basic':
if (!empty($config['password']) && empty($config['#password'])) {
$this->logger->warning("Using deprecated 'password', use '#password' instead.");
}
return new Authentication\Basic($configAttributes);
break;
/** @noinspection PhpMissingBreakStatementInspection */
case 'url.query':
$this->logger->warning("Method 'url.query' auth is deprecated, use 'query'.");
// intentional, no break
case 'query':
if (empty($api['authentication']['query']) && !empty($api['query'])) {
$this->logger->warning("Using 'api.query' is deprecated, use 'api.authentication.query");
$api['authentication']['query'] = $api['query'];
}
return new Authentication\Query($configAttributes, $api['authentication']);
break;
case 'login':
return new Authentication\Login($configAttributes, $api['authentication']);
break;
case 'oauth10':
return new Authentication\OAuth10($authorization);
case 'oauth20':
return new Authentication\OAuth20($configAttributes, $authorization, $api['authentication']);
case 'oauth20.login':
return new Authentication\OAuth20Login($configAttributes, $authorization, $api['authentication']);
default:
throw new UserException("Unknown authorization type '{$api['authentication']['type']}'.");
break;
}
}
|
[
"private",
"function",
"createAuth",
"(",
"array",
"$",
"api",
",",
"array",
"$",
"configAttributes",
",",
"array",
"$",
"authorization",
")",
":",
"AuthInterface",
"{",
"if",
"(",
"empty",
"(",
"$",
"api",
"[",
"'authentication'",
"]",
"[",
"'type'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"\"Using no authentication.\"",
")",
";",
"return",
"new",
"Authentication",
"\\",
"NoAuth",
"(",
")",
";",
"}",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"\"Using '{$api['authentication']['type']}' authentication.\"",
")",
";",
"switch",
"(",
"$",
"api",
"[",
"'authentication'",
"]",
"[",
"'type'",
"]",
")",
"{",
"case",
"'basic'",
":",
"if",
"(",
"!",
"empty",
"(",
"$",
"config",
"[",
"'password'",
"]",
")",
"&&",
"empty",
"(",
"$",
"config",
"[",
"'#password'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"warning",
"(",
"\"Using deprecated 'password', use '#password' instead.\"",
")",
";",
"}",
"return",
"new",
"Authentication",
"\\",
"Basic",
"(",
"$",
"configAttributes",
")",
";",
"break",
";",
"/** @noinspection PhpMissingBreakStatementInspection */",
"case",
"'url.query'",
":",
"$",
"this",
"->",
"logger",
"->",
"warning",
"(",
"\"Method 'url.query' auth is deprecated, use 'query'.\"",
")",
";",
"// intentional, no break",
"case",
"'query'",
":",
"if",
"(",
"empty",
"(",
"$",
"api",
"[",
"'authentication'",
"]",
"[",
"'query'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"api",
"[",
"'query'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"warning",
"(",
"\"Using 'api.query' is deprecated, use 'api.authentication.query\"",
")",
";",
"$",
"api",
"[",
"'authentication'",
"]",
"[",
"'query'",
"]",
"=",
"$",
"api",
"[",
"'query'",
"]",
";",
"}",
"return",
"new",
"Authentication",
"\\",
"Query",
"(",
"$",
"configAttributes",
",",
"$",
"api",
"[",
"'authentication'",
"]",
")",
";",
"break",
";",
"case",
"'login'",
":",
"return",
"new",
"Authentication",
"\\",
"Login",
"(",
"$",
"configAttributes",
",",
"$",
"api",
"[",
"'authentication'",
"]",
")",
";",
"break",
";",
"case",
"'oauth10'",
":",
"return",
"new",
"Authentication",
"\\",
"OAuth10",
"(",
"$",
"authorization",
")",
";",
"case",
"'oauth20'",
":",
"return",
"new",
"Authentication",
"\\",
"OAuth20",
"(",
"$",
"configAttributes",
",",
"$",
"authorization",
",",
"$",
"api",
"[",
"'authentication'",
"]",
")",
";",
"case",
"'oauth20.login'",
":",
"return",
"new",
"Authentication",
"\\",
"OAuth20Login",
"(",
"$",
"configAttributes",
",",
"$",
"authorization",
",",
"$",
"api",
"[",
"'authentication'",
"]",
")",
";",
"default",
":",
"throw",
"new",
"UserException",
"(",
"\"Unknown authorization type '{$api['authentication']['type']}'.\"",
")",
";",
"break",
";",
"}",
"}"
] |
Create Authentication class that accepts a Guzzle client.
@param array $api
@param array $configAttributes
@param array $authorization
@return AuthInterface
@throws UserException
|
[
"Create",
"Authentication",
"class",
"that",
"accepts",
"a",
"Guzzle",
"client",
"."
] |
45ed1164f54b54a60c2bec2d9e3c9ef2ec1f723c
|
https://github.com/keboola/generic-extractor/blob/45ed1164f54b54a60c2bec2d9e3c9ef2ec1f723c/src/Configuration/Api.php#L102-L140
|
221,412
|
demisang/yii2-backup
|
Component.php
|
Component.create
|
public function create()
{
$folder = $this->getBackupFolder();
$files = $this->backupFiles($folder);
$db = $this->backupDatabase($folder);
$resultFilename = $this->getBackupFilename();
$archiveFile = dirname($folder) . DIRECTORY_SEPARATOR . $resultFilename . '.tar';
// Create new archive
$archive = new \PharData($archiveFile);
// add folder
$archive->buildFromDirectory($folder);
// Remove temp directory
FileHelper::removeDirectory($folder);
return $archiveFile;
}
|
php
|
public function create()
{
$folder = $this->getBackupFolder();
$files = $this->backupFiles($folder);
$db = $this->backupDatabase($folder);
$resultFilename = $this->getBackupFilename();
$archiveFile = dirname($folder) . DIRECTORY_SEPARATOR . $resultFilename . '.tar';
// Create new archive
$archive = new \PharData($archiveFile);
// add folder
$archive->buildFromDirectory($folder);
// Remove temp directory
FileHelper::removeDirectory($folder);
return $archiveFile;
}
|
[
"public",
"function",
"create",
"(",
")",
"{",
"$",
"folder",
"=",
"$",
"this",
"->",
"getBackupFolder",
"(",
")",
";",
"$",
"files",
"=",
"$",
"this",
"->",
"backupFiles",
"(",
"$",
"folder",
")",
";",
"$",
"db",
"=",
"$",
"this",
"->",
"backupDatabase",
"(",
"$",
"folder",
")",
";",
"$",
"resultFilename",
"=",
"$",
"this",
"->",
"getBackupFilename",
"(",
")",
";",
"$",
"archiveFile",
"=",
"dirname",
"(",
"$",
"folder",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"resultFilename",
".",
"'.tar'",
";",
"// Create new archive",
"$",
"archive",
"=",
"new",
"\\",
"PharData",
"(",
"$",
"archiveFile",
")",
";",
"// add folder",
"$",
"archive",
"->",
"buildFromDirectory",
"(",
"$",
"folder",
")",
";",
"// Remove temp directory",
"FileHelper",
"::",
"removeDirectory",
"(",
"$",
"folder",
")",
";",
"return",
"$",
"archiveFile",
";",
"}"
] |
Create dump of all directories and all databases and save result to bakup folder with timestamp named tar-archive
@return string Full path to created backup file
@throws Exception
|
[
"Create",
"dump",
"of",
"all",
"directories",
"and",
"all",
"databases",
"and",
"save",
"result",
"to",
"bakup",
"folder",
"with",
"timestamp",
"named",
"tar",
"-",
"archive"
] |
21434b2a125628495e27386aac51b74149fb9380
|
https://github.com/demisang/yii2-backup/blob/21434b2a125628495e27386aac51b74149fb9380/Component.php#L142-L162
|
221,413
|
demisang/yii2-backup
|
Component.php
|
Component.deleteJunk
|
public function deleteJunk()
{
if (empty($this->expireTime)) {
// Prevent deleting if expireTime is disabled
return true;
}
$backupsFolder = Yii::getAlias($this->backupsFolder);
// Calculate expire date
$expireDate = time() - $this->expireTime;
$filter = function ($path) use ($expireDate) {
// Check extension
if (substr($path, -4) !== '.tar') {
return false;
}
if (is_file($path) && filemtime($path) <= $expireDate) {
// if the time has come - delete file
return true;
}
return false;
};
// Find expired backups files
$files = FileHelper::findFiles($backupsFolder, ['recursive' => false, 'filter' => $filter]);
foreach ($files as $file) {
if (@unlink($file)) {
Yii::info('Backup file was deleted: ' . $file, 'demi\backup\Component::deleteJunk()');
} else {
Yii::error('Cannot delete backup file: ' . $file, 'demi\backup\Component::deleteJunk()');
}
}
return true;
}
|
php
|
public function deleteJunk()
{
if (empty($this->expireTime)) {
// Prevent deleting if expireTime is disabled
return true;
}
$backupsFolder = Yii::getAlias($this->backupsFolder);
// Calculate expire date
$expireDate = time() - $this->expireTime;
$filter = function ($path) use ($expireDate) {
// Check extension
if (substr($path, -4) !== '.tar') {
return false;
}
if (is_file($path) && filemtime($path) <= $expireDate) {
// if the time has come - delete file
return true;
}
return false;
};
// Find expired backups files
$files = FileHelper::findFiles($backupsFolder, ['recursive' => false, 'filter' => $filter]);
foreach ($files as $file) {
if (@unlink($file)) {
Yii::info('Backup file was deleted: ' . $file, 'demi\backup\Component::deleteJunk()');
} else {
Yii::error('Cannot delete backup file: ' . $file, 'demi\backup\Component::deleteJunk()');
}
}
return true;
}
|
[
"public",
"function",
"deleteJunk",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"expireTime",
")",
")",
"{",
"// Prevent deleting if expireTime is disabled",
"return",
"true",
";",
"}",
"$",
"backupsFolder",
"=",
"Yii",
"::",
"getAlias",
"(",
"$",
"this",
"->",
"backupsFolder",
")",
";",
"// Calculate expire date",
"$",
"expireDate",
"=",
"time",
"(",
")",
"-",
"$",
"this",
"->",
"expireTime",
";",
"$",
"filter",
"=",
"function",
"(",
"$",
"path",
")",
"use",
"(",
"$",
"expireDate",
")",
"{",
"// Check extension",
"if",
"(",
"substr",
"(",
"$",
"path",
",",
"-",
"4",
")",
"!==",
"'.tar'",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"is_file",
"(",
"$",
"path",
")",
"&&",
"filemtime",
"(",
"$",
"path",
")",
"<=",
"$",
"expireDate",
")",
"{",
"// if the time has come - delete file",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}",
";",
"// Find expired backups files",
"$",
"files",
"=",
"FileHelper",
"::",
"findFiles",
"(",
"$",
"backupsFolder",
",",
"[",
"'recursive'",
"=>",
"false",
",",
"'filter'",
"=>",
"$",
"filter",
"]",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"@",
"unlink",
"(",
"$",
"file",
")",
")",
"{",
"Yii",
"::",
"info",
"(",
"'Backup file was deleted: '",
".",
"$",
"file",
",",
"'demi\\backup\\Component::deleteJunk()'",
")",
";",
"}",
"else",
"{",
"Yii",
"::",
"error",
"(",
"'Cannot delete backup file: '",
".",
"$",
"file",
",",
"'demi\\backup\\Component::deleteJunk()'",
")",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Delete expired files
@return bool
|
[
"Delete",
"expired",
"files"
] |
21434b2a125628495e27386aac51b74149fb9380
|
https://github.com/demisang/yii2-backup/blob/21434b2a125628495e27386aac51b74149fb9380/Component.php#L234-L271
|
221,414
|
demisang/yii2-backup
|
Component.php
|
Component.getBackupFilename
|
public function getBackupFilename()
{
if (is_callable($this->backupFilename)) {
return call_user_func($this->backupFilename, $this);
} else {
return date($this->backupFilename);
}
}
|
php
|
public function getBackupFilename()
{
if (is_callable($this->backupFilename)) {
return call_user_func($this->backupFilename, $this);
} else {
return date($this->backupFilename);
}
}
|
[
"public",
"function",
"getBackupFilename",
"(",
")",
"{",
"if",
"(",
"is_callable",
"(",
"$",
"this",
"->",
"backupFilename",
")",
")",
"{",
"return",
"call_user_func",
"(",
"$",
"this",
"->",
"backupFilename",
",",
"$",
"this",
")",
";",
"}",
"else",
"{",
"return",
"date",
"(",
"$",
"this",
"->",
"backupFilename",
")",
";",
"}",
"}"
] |
Generate backup filename
@return string
|
[
"Generate",
"backup",
"filename"
] |
21434b2a125628495e27386aac51b74149fb9380
|
https://github.com/demisang/yii2-backup/blob/21434b2a125628495e27386aac51b74149fb9380/Component.php#L278-L285
|
221,415
|
demisang/yii2-backup
|
Component.php
|
Component.getBackupFolder
|
public function getBackupFolder()
{
// Base backups folder
$base = Yii::getAlias($this->backupsFolder);
// Temp directory for current backup
$current = $this->getBackupFilename();
$fullpath = $base . DIRECTORY_SEPARATOR . $current;
// Try to create new directory
if (!is_dir($fullpath) && !mkdir($fullpath)) {
throw new Exception('Can not create folder for backup: "' . $fullpath . '"');
}
return $fullpath;
}
|
php
|
public function getBackupFolder()
{
// Base backups folder
$base = Yii::getAlias($this->backupsFolder);
// Temp directory for current backup
$current = $this->getBackupFilename();
$fullpath = $base . DIRECTORY_SEPARATOR . $current;
// Try to create new directory
if (!is_dir($fullpath) && !mkdir($fullpath)) {
throw new Exception('Can not create folder for backup: "' . $fullpath . '"');
}
return $fullpath;
}
|
[
"public",
"function",
"getBackupFolder",
"(",
")",
"{",
"// Base backups folder",
"$",
"base",
"=",
"Yii",
"::",
"getAlias",
"(",
"$",
"this",
"->",
"backupsFolder",
")",
";",
"// Temp directory for current backup",
"$",
"current",
"=",
"$",
"this",
"->",
"getBackupFilename",
"(",
")",
";",
"$",
"fullpath",
"=",
"$",
"base",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"current",
";",
"// Try to create new directory",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"fullpath",
")",
"&&",
"!",
"mkdir",
"(",
"$",
"fullpath",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Can not create folder for backup: \"'",
".",
"$",
"fullpath",
".",
"'\"'",
")",
";",
"}",
"return",
"$",
"fullpath",
";",
"}"
] |
Get full path to backups folder.
Directory will be automatically created.
@return string
@throws Exception
|
[
"Get",
"full",
"path",
"to",
"backups",
"folder",
".",
"Directory",
"will",
"be",
"automatically",
"created",
"."
] |
21434b2a125628495e27386aac51b74149fb9380
|
https://github.com/demisang/yii2-backup/blob/21434b2a125628495e27386aac51b74149fb9380/Component.php#L294-L310
|
221,416
|
keboola/generic-extractor
|
src/Configuration/JuicerRest.php
|
JuicerRest.convertRetry
|
public static function convertRetry(array $config)
{
// TODO: add deprecation
if (isset($config['curlCodes'])) {
$config['curl'] = [];
$config['curl']['codes'] = $config['curlCodes'];
unset($config['curlCodes']);
}
if (isset($config['headerName']) || isset($config['httpCodes'])) {
$config['http'] = [];
if (isset($config['headerName'])) {
$config['http']['retryHeader'] = $config['headerName'];
unset($config['headerName']);
}
if (isset($config['httpCodes'])) {
$config['http']['codes'] = $config['httpCodes'];
unset($config['httpCodes']);
}
}
return $config;
}
|
php
|
public static function convertRetry(array $config)
{
// TODO: add deprecation
if (isset($config['curlCodes'])) {
$config['curl'] = [];
$config['curl']['codes'] = $config['curlCodes'];
unset($config['curlCodes']);
}
if (isset($config['headerName']) || isset($config['httpCodes'])) {
$config['http'] = [];
if (isset($config['headerName'])) {
$config['http']['retryHeader'] = $config['headerName'];
unset($config['headerName']);
}
if (isset($config['httpCodes'])) {
$config['http']['codes'] = $config['httpCodes'];
unset($config['httpCodes']);
}
}
return $config;
}
|
[
"public",
"static",
"function",
"convertRetry",
"(",
"array",
"$",
"config",
")",
"{",
"// TODO: add deprecation",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'curlCodes'",
"]",
")",
")",
"{",
"$",
"config",
"[",
"'curl'",
"]",
"=",
"[",
"]",
";",
"$",
"config",
"[",
"'curl'",
"]",
"[",
"'codes'",
"]",
"=",
"$",
"config",
"[",
"'curlCodes'",
"]",
";",
"unset",
"(",
"$",
"config",
"[",
"'curlCodes'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'headerName'",
"]",
")",
"||",
"isset",
"(",
"$",
"config",
"[",
"'httpCodes'",
"]",
")",
")",
"{",
"$",
"config",
"[",
"'http'",
"]",
"=",
"[",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'headerName'",
"]",
")",
")",
"{",
"$",
"config",
"[",
"'http'",
"]",
"[",
"'retryHeader'",
"]",
"=",
"$",
"config",
"[",
"'headerName'",
"]",
";",
"unset",
"(",
"$",
"config",
"[",
"'headerName'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'httpCodes'",
"]",
")",
")",
"{",
"$",
"config",
"[",
"'http'",
"]",
"[",
"'codes'",
"]",
"=",
"$",
"config",
"[",
"'httpCodes'",
"]",
";",
"unset",
"(",
"$",
"config",
"[",
"'httpCodes'",
"]",
")",
";",
"}",
"}",
"return",
"$",
"config",
";",
"}"
] |
Convert structure of config from Juicer 8 => 9
@param array $config
@return array
|
[
"Convert",
"structure",
"of",
"config",
"from",
"Juicer",
"8",
"=",
">",
"9"
] |
45ed1164f54b54a60c2bec2d9e3c9ef2ec1f723c
|
https://github.com/keboola/generic-extractor/blob/45ed1164f54b54a60c2bec2d9e3c9ef2ec1f723c/src/Configuration/JuicerRest.php#L13-L36
|
221,417
|
allejo/PhpSoda
|
src/Utilities/UrlQuery.php
|
UrlQuery.handleQuery
|
private function handleQuery ($associativeArray, &$headers, $ignoreReturn = false)
{
$result = $this->executeCurl();
// Ignore "100 Continue" headers
$continueHeader = "HTTP/1.1 100 Continue\r\n\r\n";
if (strpos($result, $continueHeader) === 0)
{
$result = str_replace($continueHeader, '', $result);
}
list($header, $body) = explode("\r\n\r\n", $result, 2);
$this->saveHeaders($header, $headers);
if ($ignoreReturn)
{
return NULL;
}
$resultArray = $this->handleResponseBody($body, $result);
return ($associativeArray) ? $resultArray : json_decode($body, false);
}
|
php
|
private function handleQuery ($associativeArray, &$headers, $ignoreReturn = false)
{
$result = $this->executeCurl();
// Ignore "100 Continue" headers
$continueHeader = "HTTP/1.1 100 Continue\r\n\r\n";
if (strpos($result, $continueHeader) === 0)
{
$result = str_replace($continueHeader, '', $result);
}
list($header, $body) = explode("\r\n\r\n", $result, 2);
$this->saveHeaders($header, $headers);
if ($ignoreReturn)
{
return NULL;
}
$resultArray = $this->handleResponseBody($body, $result);
return ($associativeArray) ? $resultArray : json_decode($body, false);
}
|
[
"private",
"function",
"handleQuery",
"(",
"$",
"associativeArray",
",",
"&",
"$",
"headers",
",",
"$",
"ignoreReturn",
"=",
"false",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"executeCurl",
"(",
")",
";",
"// Ignore \"100 Continue\" headers",
"$",
"continueHeader",
"=",
"\"HTTP/1.1 100 Continue\\r\\n\\r\\n\"",
";",
"if",
"(",
"strpos",
"(",
"$",
"result",
",",
"$",
"continueHeader",
")",
"===",
"0",
")",
"{",
"$",
"result",
"=",
"str_replace",
"(",
"$",
"continueHeader",
",",
"''",
",",
"$",
"result",
")",
";",
"}",
"list",
"(",
"$",
"header",
",",
"$",
"body",
")",
"=",
"explode",
"(",
"\"\\r\\n\\r\\n\"",
",",
"$",
"result",
",",
"2",
")",
";",
"$",
"this",
"->",
"saveHeaders",
"(",
"$",
"header",
",",
"$",
"headers",
")",
";",
"if",
"(",
"$",
"ignoreReturn",
")",
"{",
"return",
"NULL",
";",
"}",
"$",
"resultArray",
"=",
"$",
"this",
"->",
"handleResponseBody",
"(",
"$",
"body",
",",
"$",
"result",
")",
";",
"return",
"(",
"$",
"associativeArray",
")",
"?",
"$",
"resultArray",
":",
"json_decode",
"(",
"$",
"body",
",",
"false",
")",
";",
"}"
] |
Handle the execution of the cURL request. This function will also save the returned HTTP headers and handle them
appropriately.
@param bool $associativeArray When true, the returned data will be associative arrays; otherwise, it'll be an
StdClass object.
@param array $headers The reference to the array where the returned HTTP headers will be stored
@param bool $ignoreReturn True if the returned body should be ignored
@since 0.1.0
@throws \allejo\Socrata\Exceptions\CurlException If cURL is misconfigured or encounters an error
@throws \allejo\Socrata\Exceptions\HttpException An HTTP status of something other 200 is returned
@throws \allejo\Socrata\Exceptions\SodaException A SODA API error is returned
@return mixed|NULL
|
[
"Handle",
"the",
"execution",
"of",
"the",
"cURL",
"request",
".",
"This",
"function",
"will",
"also",
"save",
"the",
"returned",
"HTTP",
"headers",
"and",
"handle",
"them",
"appropriately",
"."
] |
74f6ae950de2ebcb15363e6d35239911c54984f3
|
https://github.com/allejo/PhpSoda/blob/74f6ae950de2ebcb15363e6d35239911c54984f3/src/Utilities/UrlQuery.php#L259-L283
|
221,418
|
allejo/PhpSoda
|
src/Utilities/UrlQuery.php
|
UrlQuery.configureCurl
|
private function configureCurl ($email, $password)
{
curl_setopt_array($this->cURL, array(
CURLOPT_URL => $this->url,
CURLOPT_HEADER => true,
CURLOPT_HTTPHEADER => $this->headers,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSLVERSION => 6
));
if (!StringUtilities::isNullOrEmpty($email) && !StringUtilities::isNullOrEmpty($password))
{
curl_setopt_array($this->cURL, array(
CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
CURLOPT_USERPWD => $email . ":" . $password
));
}
}
|
php
|
private function configureCurl ($email, $password)
{
curl_setopt_array($this->cURL, array(
CURLOPT_URL => $this->url,
CURLOPT_HEADER => true,
CURLOPT_HTTPHEADER => $this->headers,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSLVERSION => 6
));
if (!StringUtilities::isNullOrEmpty($email) && !StringUtilities::isNullOrEmpty($password))
{
curl_setopt_array($this->cURL, array(
CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
CURLOPT_USERPWD => $email . ":" . $password
));
}
}
|
[
"private",
"function",
"configureCurl",
"(",
"$",
"email",
",",
"$",
"password",
")",
"{",
"curl_setopt_array",
"(",
"$",
"this",
"->",
"cURL",
",",
"array",
"(",
"CURLOPT_URL",
"=>",
"$",
"this",
"->",
"url",
",",
"CURLOPT_HEADER",
"=>",
"true",
",",
"CURLOPT_HTTPHEADER",
"=>",
"$",
"this",
"->",
"headers",
",",
"CURLOPT_RETURNTRANSFER",
"=>",
"true",
",",
"CURLOPT_SSLVERSION",
"=>",
"6",
")",
")",
";",
"if",
"(",
"!",
"StringUtilities",
"::",
"isNullOrEmpty",
"(",
"$",
"email",
")",
"&&",
"!",
"StringUtilities",
"::",
"isNullOrEmpty",
"(",
"$",
"password",
")",
")",
"{",
"curl_setopt_array",
"(",
"$",
"this",
"->",
"cURL",
",",
"array",
"(",
"CURLOPT_HTTPAUTH",
"=>",
"CURLAUTH_BASIC",
",",
"CURLOPT_USERPWD",
"=>",
"$",
"email",
".",
"\":\"",
".",
"$",
"password",
")",
")",
";",
"}",
"}"
] |
Configure the cURL instance and its credentials for Basic Authentication that this instance will be working with
@param string $email The email for the user with Basic Authentication
@param string $password The password for the user with Basic Authentication
@since 0.1.0
|
[
"Configure",
"the",
"cURL",
"instance",
"and",
"its",
"credentials",
"for",
"Basic",
"Authentication",
"that",
"this",
"instance",
"will",
"be",
"working",
"with"
] |
74f6ae950de2ebcb15363e6d35239911c54984f3
|
https://github.com/allejo/PhpSoda/blob/74f6ae950de2ebcb15363e6d35239911c54984f3/src/Utilities/UrlQuery.php#L293-L310
|
221,419
|
allejo/PhpSoda
|
src/Utilities/UrlQuery.php
|
UrlQuery.executeCurl
|
private function executeCurl ()
{
$result = curl_exec($this->cURL);
if (!$result)
{
throw new CurlException($this->cURL);
}
return $result;
}
|
php
|
private function executeCurl ()
{
$result = curl_exec($this->cURL);
if (!$result)
{
throw new CurlException($this->cURL);
}
return $result;
}
|
[
"private",
"function",
"executeCurl",
"(",
")",
"{",
"$",
"result",
"=",
"curl_exec",
"(",
"$",
"this",
"->",
"cURL",
")",
";",
"if",
"(",
"!",
"$",
"result",
")",
"{",
"throw",
"new",
"CurlException",
"(",
"$",
"this",
"->",
"cURL",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Execute the finalized cURL object that has already been configured
@since 0.1.0
@throws \allejo\Socrata\Exceptions\CurlException If cURL is misconfigured or encounters an error
@return mixed
|
[
"Execute",
"the",
"finalized",
"cURL",
"object",
"that",
"has",
"already",
"been",
"configured"
] |
74f6ae950de2ebcb15363e6d35239911c54984f3
|
https://github.com/allejo/PhpSoda/blob/74f6ae950de2ebcb15363e6d35239911c54984f3/src/Utilities/UrlQuery.php#L321-L331
|
221,420
|
allejo/PhpSoda
|
src/Utilities/UrlQuery.php
|
UrlQuery.handleResponseBody
|
private function handleResponseBody ($body, $result)
{
// We somehow got a server error from Socrata without a JSON object with details
if (!StringUtilities::isJson($body))
{
$httpCode = curl_getinfo($this->cURL, CURLINFO_HTTP_CODE);
throw new HttpException($httpCode, $result);
}
$resultArray = json_decode($body, true);
// We got an error JSON object back from Socrata
if (array_key_exists('error', $resultArray) && $resultArray['error'])
{
throw new SodaException($resultArray);
}
return $resultArray;
}
|
php
|
private function handleResponseBody ($body, $result)
{
// We somehow got a server error from Socrata without a JSON object with details
if (!StringUtilities::isJson($body))
{
$httpCode = curl_getinfo($this->cURL, CURLINFO_HTTP_CODE);
throw new HttpException($httpCode, $result);
}
$resultArray = json_decode($body, true);
// We got an error JSON object back from Socrata
if (array_key_exists('error', $resultArray) && $resultArray['error'])
{
throw new SodaException($resultArray);
}
return $resultArray;
}
|
[
"private",
"function",
"handleResponseBody",
"(",
"$",
"body",
",",
"$",
"result",
")",
"{",
"// We somehow got a server error from Socrata without a JSON object with details",
"if",
"(",
"!",
"StringUtilities",
"::",
"isJson",
"(",
"$",
"body",
")",
")",
"{",
"$",
"httpCode",
"=",
"curl_getinfo",
"(",
"$",
"this",
"->",
"cURL",
",",
"CURLINFO_HTTP_CODE",
")",
";",
"throw",
"new",
"HttpException",
"(",
"$",
"httpCode",
",",
"$",
"result",
")",
";",
"}",
"$",
"resultArray",
"=",
"json_decode",
"(",
"$",
"body",
",",
"true",
")",
";",
"// We got an error JSON object back from Socrata",
"if",
"(",
"array_key_exists",
"(",
"'error'",
",",
"$",
"resultArray",
")",
"&&",
"$",
"resultArray",
"[",
"'error'",
"]",
")",
"{",
"throw",
"new",
"SodaException",
"(",
"$",
"resultArray",
")",
";",
"}",
"return",
"$",
"resultArray",
";",
"}"
] |
Check for unexpected errors or SODA API errors
@param string $body The body of the response
@param string $result The unfiltered result cURL received
@since 0.1.0
@throws \allejo\Socrata\Exceptions\HttpException If the $body returned was not a JSON object
@throws \allejo\Socrata\Exceptions\SodaException The returned JSON object in the $body was a SODA API error
@return mixed An associative array of the decoded JSON response
|
[
"Check",
"for",
"unexpected",
"errors",
"or",
"SODA",
"API",
"errors"
] |
74f6ae950de2ebcb15363e6d35239911c54984f3
|
https://github.com/allejo/PhpSoda/blob/74f6ae950de2ebcb15363e6d35239911c54984f3/src/Utilities/UrlQuery.php#L346-L365
|
221,421
|
allejo/PhpSoda
|
src/Utilities/UrlQuery.php
|
UrlQuery.saveHeaders
|
private function saveHeaders ($header, &$headers)
{
if ($headers === NULL)
{
return;
}
$header = explode("\r\n", $header);
$headers = array();
$headerLength = count($header);
// The 1st element is the HTTP code, so we can safely skip it
for ($i = 1; $i < $headerLength; $i++)
{
list($key, $val) = explode(":", $header[$i]);
$headers[$key] = trim($val);
}
}
|
php
|
private function saveHeaders ($header, &$headers)
{
if ($headers === NULL)
{
return;
}
$header = explode("\r\n", $header);
$headers = array();
$headerLength = count($header);
// The 1st element is the HTTP code, so we can safely skip it
for ($i = 1; $i < $headerLength; $i++)
{
list($key, $val) = explode(":", $header[$i]);
$headers[$key] = trim($val);
}
}
|
[
"private",
"function",
"saveHeaders",
"(",
"$",
"header",
",",
"&",
"$",
"headers",
")",
"{",
"if",
"(",
"$",
"headers",
"===",
"NULL",
")",
"{",
"return",
";",
"}",
"$",
"header",
"=",
"explode",
"(",
"\"\\r\\n\"",
",",
"$",
"header",
")",
";",
"$",
"headers",
"=",
"array",
"(",
")",
";",
"$",
"headerLength",
"=",
"count",
"(",
"$",
"header",
")",
";",
"// The 1st element is the HTTP code, so we can safely skip it",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<",
"$",
"headerLength",
";",
"$",
"i",
"++",
")",
"{",
"list",
"(",
"$",
"key",
",",
"$",
"val",
")",
"=",
"explode",
"(",
"\":\"",
",",
"$",
"header",
"[",
"$",
"i",
"]",
")",
";",
"$",
"headers",
"[",
"$",
"key",
"]",
"=",
"trim",
"(",
"$",
"val",
")",
";",
"}",
"}"
] |
Handle the returned HTTP headers and save them into an array
@param string $header The returned HTTP headers
@param array $headers The reference to the array where our headers will be saved
@since 0.1.0
|
[
"Handle",
"the",
"returned",
"HTTP",
"headers",
"and",
"save",
"them",
"into",
"an",
"array"
] |
74f6ae950de2ebcb15363e6d35239911c54984f3
|
https://github.com/allejo/PhpSoda/blob/74f6ae950de2ebcb15363e6d35239911c54984f3/src/Utilities/UrlQuery.php#L375-L392
|
221,422
|
allejo/PhpSoda
|
src/Utilities/UrlQuery.php
|
UrlQuery.buildQuery
|
private static function buildQuery ($url, $params = array())
{
$full_url = $url;
if (count($params) > 0)
{
$full_url .= "?" . implode("&", $params);
}
return $full_url;
}
|
php
|
private static function buildQuery ($url, $params = array())
{
$full_url = $url;
if (count($params) > 0)
{
$full_url .= "?" . implode("&", $params);
}
return $full_url;
}
|
[
"private",
"static",
"function",
"buildQuery",
"(",
"$",
"url",
",",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"full_url",
"=",
"$",
"url",
";",
"if",
"(",
"count",
"(",
"$",
"params",
")",
">",
"0",
")",
"{",
"$",
"full_url",
".=",
"\"?\"",
".",
"implode",
"(",
"\"&\"",
",",
"$",
"params",
")",
";",
"}",
"return",
"$",
"full_url",
";",
"}"
] |
Build a URL with GET parameters formatted into the URL
@param string $url The base URL
@param array $params The GET parameters that need to be appended to the base URL
@since 0.1.0
@return string A URL with GET parameters
|
[
"Build",
"a",
"URL",
"with",
"GET",
"parameters",
"formatted",
"into",
"the",
"URL"
] |
74f6ae950de2ebcb15363e6d35239911c54984f3
|
https://github.com/allejo/PhpSoda/blob/74f6ae950de2ebcb15363e6d35239911c54984f3/src/Utilities/UrlQuery.php#L404-L414
|
221,423
|
allejo/PhpSoda
|
src/Utilities/UrlQuery.php
|
UrlQuery.formatParameters
|
private static function formatParameters ($params)
{
$parameters = array();
foreach ($params as $key => $value)
{
$parameters[] = rawurlencode($key) . "=" . rawurlencode($value);
}
return $parameters;
}
|
php
|
private static function formatParameters ($params)
{
$parameters = array();
foreach ($params as $key => $value)
{
$parameters[] = rawurlencode($key) . "=" . rawurlencode($value);
}
return $parameters;
}
|
[
"private",
"static",
"function",
"formatParameters",
"(",
"$",
"params",
")",
"{",
"$",
"parameters",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"params",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"parameters",
"[",
"]",
"=",
"rawurlencode",
"(",
"$",
"key",
")",
".",
"\"=\"",
".",
"rawurlencode",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"parameters",
";",
"}"
] |
Format an array into a URL encoded values to be submitted in cURL requests
**Input**
```php
array(
"foo" => "bar",
"param" => "value"
)
```
**Output**
```php
array(
"foo=bar",
"param=value"
)
```
@param array $params An array containing parameter names as keys and parameter values as values in the array.
@return string[] A URL encoded and combined array of GET parameters to be sent
|
[
"Format",
"an",
"array",
"into",
"a",
"URL",
"encoded",
"values",
"to",
"be",
"submitted",
"in",
"cURL",
"requests"
] |
74f6ae950de2ebcb15363e6d35239911c54984f3
|
https://github.com/allejo/PhpSoda/blob/74f6ae950de2ebcb15363e6d35239911c54984f3/src/Utilities/UrlQuery.php#L441-L451
|
221,424
|
iambrosi/IsmaAmbrosiGeneratorBundle
|
Generator/DoctrineFormGenerator.php
|
DoctrineFormGenerator.generate
|
public function generate(BundleInterface $bundle, $document, ClassMetadataInfo $metadata)
{
$parts = explode('\\', $document);
$class = array_pop($parts);
$this->className = $class.'Type';
$dirPath = $bundle->getPath().'/Form';
$this->classPath = $dirPath.'/'.str_replace('\\', '/', $document).'Type.php';
if (file_exists($this->classPath)) {
throw new \RuntimeException(sprintf('Unable to generate the %s form class as it already exists under the %s file', $this->className, $this->classPath));
}
if (count($metadata->identifier) > 1) {
throw new \RuntimeException('The form generator does not support document classes with multiple primary keys.');
}
$parts = explode('\\', $document);
array_pop($parts);
$this->renderFile('FormType.php.twig', $this->classPath, array(
'dir' => $this->skeletonDir,
'fields' => $this->getFieldsFromMetadata($metadata),
'namespace' => $bundle->getNamespace(),
'document_class' => $class,
'document_namespace' => implode('\\', $parts),
'form_class' => $this->className,
'form_type_name' => strtolower(str_replace('\\', '_', $bundle->getNamespace()).($parts ? '_' : '').implode('_', $parts).'_'.$this->className),
));
}
|
php
|
public function generate(BundleInterface $bundle, $document, ClassMetadataInfo $metadata)
{
$parts = explode('\\', $document);
$class = array_pop($parts);
$this->className = $class.'Type';
$dirPath = $bundle->getPath().'/Form';
$this->classPath = $dirPath.'/'.str_replace('\\', '/', $document).'Type.php';
if (file_exists($this->classPath)) {
throw new \RuntimeException(sprintf('Unable to generate the %s form class as it already exists under the %s file', $this->className, $this->classPath));
}
if (count($metadata->identifier) > 1) {
throw new \RuntimeException('The form generator does not support document classes with multiple primary keys.');
}
$parts = explode('\\', $document);
array_pop($parts);
$this->renderFile('FormType.php.twig', $this->classPath, array(
'dir' => $this->skeletonDir,
'fields' => $this->getFieldsFromMetadata($metadata),
'namespace' => $bundle->getNamespace(),
'document_class' => $class,
'document_namespace' => implode('\\', $parts),
'form_class' => $this->className,
'form_type_name' => strtolower(str_replace('\\', '_', $bundle->getNamespace()).($parts ? '_' : '').implode('_', $parts).'_'.$this->className),
));
}
|
[
"public",
"function",
"generate",
"(",
"BundleInterface",
"$",
"bundle",
",",
"$",
"document",
",",
"ClassMetadataInfo",
"$",
"metadata",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'\\\\'",
",",
"$",
"document",
")",
";",
"$",
"class",
"=",
"array_pop",
"(",
"$",
"parts",
")",
";",
"$",
"this",
"->",
"className",
"=",
"$",
"class",
".",
"'Type'",
";",
"$",
"dirPath",
"=",
"$",
"bundle",
"->",
"getPath",
"(",
")",
".",
"'/Form'",
";",
"$",
"this",
"->",
"classPath",
"=",
"$",
"dirPath",
".",
"'/'",
".",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"$",
"document",
")",
".",
"'Type.php'",
";",
"if",
"(",
"file_exists",
"(",
"$",
"this",
"->",
"classPath",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Unable to generate the %s form class as it already exists under the %s file'",
",",
"$",
"this",
"->",
"className",
",",
"$",
"this",
"->",
"classPath",
")",
")",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"metadata",
"->",
"identifier",
")",
">",
"1",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'The form generator does not support document classes with multiple primary keys.'",
")",
";",
"}",
"$",
"parts",
"=",
"explode",
"(",
"'\\\\'",
",",
"$",
"document",
")",
";",
"array_pop",
"(",
"$",
"parts",
")",
";",
"$",
"this",
"->",
"renderFile",
"(",
"'FormType.php.twig'",
",",
"$",
"this",
"->",
"classPath",
",",
"array",
"(",
"'dir'",
"=>",
"$",
"this",
"->",
"skeletonDir",
",",
"'fields'",
"=>",
"$",
"this",
"->",
"getFieldsFromMetadata",
"(",
"$",
"metadata",
")",
",",
"'namespace'",
"=>",
"$",
"bundle",
"->",
"getNamespace",
"(",
")",
",",
"'document_class'",
"=>",
"$",
"class",
",",
"'document_namespace'",
"=>",
"implode",
"(",
"'\\\\'",
",",
"$",
"parts",
")",
",",
"'form_class'",
"=>",
"$",
"this",
"->",
"className",
",",
"'form_type_name'",
"=>",
"strtolower",
"(",
"str_replace",
"(",
"'\\\\'",
",",
"'_'",
",",
"$",
"bundle",
"->",
"getNamespace",
"(",
")",
")",
".",
"(",
"$",
"parts",
"?",
"'_'",
":",
"''",
")",
".",
"implode",
"(",
"'_'",
",",
"$",
"parts",
")",
".",
"'_'",
".",
"$",
"this",
"->",
"className",
")",
",",
")",
")",
";",
"}"
] |
Generates the document form class if it does not exist.
@param \Symfony\Component\HttpKernel\Bundle\BundleInterface $bundle
@param string $document
@param \Doctrine\ODM\MongoDB\Mapping\ClassMetadataInfo $metadata
@throws \RuntimeException
|
[
"Generates",
"the",
"document",
"form",
"class",
"if",
"it",
"does",
"not",
"exist",
"."
] |
cd5937ac1db82dfee1b23946f09de4cd778d872d
|
https://github.com/iambrosi/IsmaAmbrosiGeneratorBundle/blob/cd5937ac1db82dfee1b23946f09de4cd778d872d/Generator/DoctrineFormGenerator.php#L63-L92
|
221,425
|
springbot/magento2-queue
|
Model/Queue.php
|
Queue.process
|
public function process()
{
$maxJobs = $this->scopeConfig->getValue('springbot/queue/max_jobs');
if (!is_numeric($maxJobs)) {
$maxJobs = 1;
}
for ($i = 1; $i <= $maxJobs; $i++) {
if ($this->runNextJob() === null) {
return null;
}
}
return true;
}
|
php
|
public function process()
{
$maxJobs = $this->scopeConfig->getValue('springbot/queue/max_jobs');
if (!is_numeric($maxJobs)) {
$maxJobs = 1;
}
for ($i = 1; $i <= $maxJobs; $i++) {
if ($this->runNextJob() === null) {
return null;
}
}
return true;
}
|
[
"public",
"function",
"process",
"(",
")",
"{",
"$",
"maxJobs",
"=",
"$",
"this",
"->",
"scopeConfig",
"->",
"getValue",
"(",
"'springbot/queue/max_jobs'",
")",
";",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"maxJobs",
")",
")",
"{",
"$",
"maxJobs",
"=",
"1",
";",
"}",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<=",
"$",
"maxJobs",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"runNextJob",
"(",
")",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Process the next N jobs in the queue where N is the max_jobs value
@return bool|null
|
[
"Process",
"the",
"next",
"N",
"jobs",
"in",
"the",
"queue",
"where",
"N",
"is",
"the",
"max_jobs",
"value"
] |
ae3d72b3cb1d2ab03843a4d454c243f04916bd7f
|
https://github.com/springbot/magento2-queue/blob/ae3d72b3cb1d2ab03843a4d454c243f04916bd7f/Model/Queue.php#L178-L191
|
221,426
|
allejo/PhpSoda
|
src/Converters/Converter.php
|
Converter.fromFile
|
public static function fromFile ($filename)
{
if (!file_exists($filename) || !is_readable($filename))
{
throw new FileNotFoundException($filename);
}
$data = file_get_contents($filename);
return new static($data);
}
|
php
|
public static function fromFile ($filename)
{
if (!file_exists($filename) || !is_readable($filename))
{
throw new FileNotFoundException($filename);
}
$data = file_get_contents($filename);
return new static($data);
}
|
[
"public",
"static",
"function",
"fromFile",
"(",
"$",
"filename",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"filename",
")",
"||",
"!",
"is_readable",
"(",
"$",
"filename",
")",
")",
"{",
"throw",
"new",
"FileNotFoundException",
"(",
"$",
"filename",
")",
";",
"}",
"$",
"data",
"=",
"file_get_contents",
"(",
"$",
"filename",
")",
";",
"return",
"new",
"static",
"(",
"$",
"data",
")",
";",
"}"
] |
A convenience method to create a Converter instance from a file name without having to read the file data and
then give it to the CsvConverter constructor.
@param string $filename The path or filename of the CSV file to open and create a CsvConverter for
@throws \allejo\Socrata\Exceptions\FileNotFoundException
@return static
|
[
"A",
"convenience",
"method",
"to",
"create",
"a",
"Converter",
"instance",
"from",
"a",
"file",
"name",
"without",
"having",
"to",
"read",
"the",
"file",
"data",
"and",
"then",
"give",
"it",
"to",
"the",
"CsvConverter",
"constructor",
"."
] |
74f6ae950de2ebcb15363e6d35239911c54984f3
|
https://github.com/allejo/PhpSoda/blob/74f6ae950de2ebcb15363e6d35239911c54984f3/src/Converters/Converter.php#L60-L70
|
221,427
|
keboola/generic-extractor
|
src/GenericExtractorJob.php
|
GenericExtractorJob.run
|
public function run()
{
$this->config->setParams($this->buildParams($this->config));
$parentId = $this->getParentId();
$request = $this->firstPage($this->config);
while ($request !== false) {
$response = $this->download($request);
$responseHash = sha1(serialize($response));
if ($responseHash == $this->lastResponseHash) {
$this->logger->debug(sprintf(
"Job '%s' finished when last response matched the previous!",
$this->getJobId()
));
$this->scroller->reset();
break;
} else {
$data = $this->runResponseModules($response, $this->config);
$data = $this->filterResponse($this->config, $data);
$this->parse($data, $parentId);
$this->lastResponseHash = $responseHash;
}
$request = $this->nextPage($this->config, $response, $data);
}
}
|
php
|
public function run()
{
$this->config->setParams($this->buildParams($this->config));
$parentId = $this->getParentId();
$request = $this->firstPage($this->config);
while ($request !== false) {
$response = $this->download($request);
$responseHash = sha1(serialize($response));
if ($responseHash == $this->lastResponseHash) {
$this->logger->debug(sprintf(
"Job '%s' finished when last response matched the previous!",
$this->getJobId()
));
$this->scroller->reset();
break;
} else {
$data = $this->runResponseModules($response, $this->config);
$data = $this->filterResponse($this->config, $data);
$this->parse($data, $parentId);
$this->lastResponseHash = $responseHash;
}
$request = $this->nextPage($this->config, $response, $data);
}
}
|
[
"public",
"function",
"run",
"(",
")",
"{",
"$",
"this",
"->",
"config",
"->",
"setParams",
"(",
"$",
"this",
"->",
"buildParams",
"(",
"$",
"this",
"->",
"config",
")",
")",
";",
"$",
"parentId",
"=",
"$",
"this",
"->",
"getParentId",
"(",
")",
";",
"$",
"request",
"=",
"$",
"this",
"->",
"firstPage",
"(",
"$",
"this",
"->",
"config",
")",
";",
"while",
"(",
"$",
"request",
"!==",
"false",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"download",
"(",
"$",
"request",
")",
";",
"$",
"responseHash",
"=",
"sha1",
"(",
"serialize",
"(",
"$",
"response",
")",
")",
";",
"if",
"(",
"$",
"responseHash",
"==",
"$",
"this",
"->",
"lastResponseHash",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"sprintf",
"(",
"\"Job '%s' finished when last response matched the previous!\"",
",",
"$",
"this",
"->",
"getJobId",
"(",
")",
")",
")",
";",
"$",
"this",
"->",
"scroller",
"->",
"reset",
"(",
")",
";",
"break",
";",
"}",
"else",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"runResponseModules",
"(",
"$",
"response",
",",
"$",
"this",
"->",
"config",
")",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"filterResponse",
"(",
"$",
"this",
"->",
"config",
",",
"$",
"data",
")",
";",
"$",
"this",
"->",
"parse",
"(",
"$",
"data",
",",
"$",
"parentId",
")",
";",
"$",
"this",
"->",
"lastResponseHash",
"=",
"$",
"responseHash",
";",
"}",
"$",
"request",
"=",
"$",
"this",
"->",
"nextPage",
"(",
"$",
"this",
"->",
"config",
",",
"$",
"response",
",",
"$",
"data",
")",
";",
"}",
"}"
] |
Manages cycling through the requests as long as
scroller provides next page
Verifies the latest response isn't identical as the last one
to prevent infinite loop on awkward pagination APIs
|
[
"Manages",
"cycling",
"through",
"the",
"requests",
"as",
"long",
"as",
"scroller",
"provides",
"next",
"page"
] |
45ed1164f54b54a60c2bec2d9e3c9ef2ec1f723c
|
https://github.com/keboola/generic-extractor/blob/45ed1164f54b54a60c2bec2d9e3c9ef2ec1f723c/src/GenericExtractorJob.php#L138-L166
|
221,428
|
keboola/generic-extractor
|
src/GenericExtractorJob.php
|
GenericExtractorJob.createChild
|
private function createChild(JobConfig $config, array $parentResults) : array
{
// Clone and reset Scroller
$scroller = clone $this->scroller;
$scroller->reset();
$params = [];
$placeholders = !empty($config->getConfig()['placeholders']) ? $config->getConfig()['placeholders'] : [];
if (empty($placeholders)) {
$this->logger->warning("No 'placeholders' set for '" . $config->getConfig()['endpoint'] . "'");
}
foreach ($placeholders as $placeholder => $field) {
$params[$placeholder] = $this->getPlaceholder($placeholder, $field, $parentResults);
}
// Add parent params as well (for 'tagging' child-parent data)
// Same placeholder in deeper nesting replaces parent value
if (!empty($this->parentParams)) {
$params = array_replace($this->parentParams, $params);
}
$params = $this->flattenParameters($params);
$jobs = [];
foreach ($params as $index => $param) {
// Clone the config to prevent overwriting the placeholder(s) in endpoint
$job = new static(
clone $config,
$this->client,
$this->parser,
$this->logger,
$scroller,
$this->attributes,
$this->metadata,
$this->compatLevel
);
$job->setParams($param);
$job->setParentResults($parentResults);
$jobs[] = $job;
}
return $jobs;
}
|
php
|
private function createChild(JobConfig $config, array $parentResults) : array
{
// Clone and reset Scroller
$scroller = clone $this->scroller;
$scroller->reset();
$params = [];
$placeholders = !empty($config->getConfig()['placeholders']) ? $config->getConfig()['placeholders'] : [];
if (empty($placeholders)) {
$this->logger->warning("No 'placeholders' set for '" . $config->getConfig()['endpoint'] . "'");
}
foreach ($placeholders as $placeholder => $field) {
$params[$placeholder] = $this->getPlaceholder($placeholder, $field, $parentResults);
}
// Add parent params as well (for 'tagging' child-parent data)
// Same placeholder in deeper nesting replaces parent value
if (!empty($this->parentParams)) {
$params = array_replace($this->parentParams, $params);
}
$params = $this->flattenParameters($params);
$jobs = [];
foreach ($params as $index => $param) {
// Clone the config to prevent overwriting the placeholder(s) in endpoint
$job = new static(
clone $config,
$this->client,
$this->parser,
$this->logger,
$scroller,
$this->attributes,
$this->metadata,
$this->compatLevel
);
$job->setParams($param);
$job->setParentResults($parentResults);
$jobs[] = $job;
}
return $jobs;
}
|
[
"private",
"function",
"createChild",
"(",
"JobConfig",
"$",
"config",
",",
"array",
"$",
"parentResults",
")",
":",
"array",
"{",
"// Clone and reset Scroller",
"$",
"scroller",
"=",
"clone",
"$",
"this",
"->",
"scroller",
";",
"$",
"scroller",
"->",
"reset",
"(",
")",
";",
"$",
"params",
"=",
"[",
"]",
";",
"$",
"placeholders",
"=",
"!",
"empty",
"(",
"$",
"config",
"->",
"getConfig",
"(",
")",
"[",
"'placeholders'",
"]",
")",
"?",
"$",
"config",
"->",
"getConfig",
"(",
")",
"[",
"'placeholders'",
"]",
":",
"[",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"placeholders",
")",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"warning",
"(",
"\"No 'placeholders' set for '\"",
".",
"$",
"config",
"->",
"getConfig",
"(",
")",
"[",
"'endpoint'",
"]",
".",
"\"'\"",
")",
";",
"}",
"foreach",
"(",
"$",
"placeholders",
"as",
"$",
"placeholder",
"=>",
"$",
"field",
")",
"{",
"$",
"params",
"[",
"$",
"placeholder",
"]",
"=",
"$",
"this",
"->",
"getPlaceholder",
"(",
"$",
"placeholder",
",",
"$",
"field",
",",
"$",
"parentResults",
")",
";",
"}",
"// Add parent params as well (for 'tagging' child-parent data)",
"// Same placeholder in deeper nesting replaces parent value",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"parentParams",
")",
")",
"{",
"$",
"params",
"=",
"array_replace",
"(",
"$",
"this",
"->",
"parentParams",
",",
"$",
"params",
")",
";",
"}",
"$",
"params",
"=",
"$",
"this",
"->",
"flattenParameters",
"(",
"$",
"params",
")",
";",
"$",
"jobs",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"params",
"as",
"$",
"index",
"=>",
"$",
"param",
")",
"{",
"// Clone the config to prevent overwriting the placeholder(s) in endpoint",
"$",
"job",
"=",
"new",
"static",
"(",
"clone",
"$",
"config",
",",
"$",
"this",
"->",
"client",
",",
"$",
"this",
"->",
"parser",
",",
"$",
"this",
"->",
"logger",
",",
"$",
"scroller",
",",
"$",
"this",
"->",
"attributes",
",",
"$",
"this",
"->",
"metadata",
",",
"$",
"this",
"->",
"compatLevel",
")",
";",
"$",
"job",
"->",
"setParams",
"(",
"$",
"param",
")",
";",
"$",
"job",
"->",
"setParentResults",
"(",
"$",
"parentResults",
")",
";",
"$",
"jobs",
"[",
"]",
"=",
"$",
"job",
";",
"}",
"return",
"$",
"jobs",
";",
"}"
] |
Create a child job with current client and parser
@param JobConfig $config
@param array $parentResults
@return static[]
|
[
"Create",
"a",
"child",
"job",
"with",
"current",
"client",
"and",
"parser"
] |
45ed1164f54b54a60c2bec2d9e3c9ef2ec1f723c
|
https://github.com/keboola/generic-extractor/blob/45ed1164f54b54a60c2bec2d9e3c9ef2ec1f723c/src/GenericExtractorJob.php#L207-L248
|
221,429
|
iambrosi/IsmaAmbrosiGeneratorBundle
|
Generator/DoctrineCrudGenerator.php
|
DoctrineCrudGenerator.generateConfiguration
|
private function generateConfiguration()
{
if (!in_array($this->format, array('yml', 'xml', 'php'))) {
return;
}
$target = sprintf(
'%s/Resources/config/routing/%s.%s',
$this->bundle->getPath(),
strtolower(str_replace('\\', '_', $this->document)),
$this->format
);
$this->renderFile('config/routing.'.$this->format.'.twig', $target, array(
'actions' => $this->actions,
'route_prefix' => $this->routePrefix,
'route_name_prefix' => $this->routeNamePrefix,
'bundle' => $this->bundle->getName(),
'document' => $this->document,
));
}
|
php
|
private function generateConfiguration()
{
if (!in_array($this->format, array('yml', 'xml', 'php'))) {
return;
}
$target = sprintf(
'%s/Resources/config/routing/%s.%s',
$this->bundle->getPath(),
strtolower(str_replace('\\', '_', $this->document)),
$this->format
);
$this->renderFile('config/routing.'.$this->format.'.twig', $target, array(
'actions' => $this->actions,
'route_prefix' => $this->routePrefix,
'route_name_prefix' => $this->routeNamePrefix,
'bundle' => $this->bundle->getName(),
'document' => $this->document,
));
}
|
[
"private",
"function",
"generateConfiguration",
"(",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"this",
"->",
"format",
",",
"array",
"(",
"'yml'",
",",
"'xml'",
",",
"'php'",
")",
")",
")",
"{",
"return",
";",
"}",
"$",
"target",
"=",
"sprintf",
"(",
"'%s/Resources/config/routing/%s.%s'",
",",
"$",
"this",
"->",
"bundle",
"->",
"getPath",
"(",
")",
",",
"strtolower",
"(",
"str_replace",
"(",
"'\\\\'",
",",
"'_'",
",",
"$",
"this",
"->",
"document",
")",
")",
",",
"$",
"this",
"->",
"format",
")",
";",
"$",
"this",
"->",
"renderFile",
"(",
"'config/routing.'",
".",
"$",
"this",
"->",
"format",
".",
"'.twig'",
",",
"$",
"target",
",",
"array",
"(",
"'actions'",
"=>",
"$",
"this",
"->",
"actions",
",",
"'route_prefix'",
"=>",
"$",
"this",
"->",
"routePrefix",
",",
"'route_name_prefix'",
"=>",
"$",
"this",
"->",
"routeNamePrefix",
",",
"'bundle'",
"=>",
"$",
"this",
"->",
"bundle",
"->",
"getName",
"(",
")",
",",
"'document'",
"=>",
"$",
"this",
"->",
"document",
",",
")",
")",
";",
"}"
] |
Generates the routing configuration.
|
[
"Generates",
"the",
"routing",
"configuration",
"."
] |
cd5937ac1db82dfee1b23946f09de4cd778d872d
|
https://github.com/iambrosi/IsmaAmbrosiGeneratorBundle/blob/cd5937ac1db82dfee1b23946f09de4cd778d872d/Generator/DoctrineCrudGenerator.php#L153-L173
|
221,430
|
iambrosi/IsmaAmbrosiGeneratorBundle
|
Generator/DoctrineCrudGenerator.php
|
DoctrineCrudGenerator.generateNewView
|
private function generateNewView($dir)
{
$this->renderFile('views/new.html.twig', $dir.'/new.html.twig', array(
'dir' => $this->skeletonDir,
'route_prefix' => $this->routePrefix,
'route_name_prefix' => $this->routeNamePrefix,
'document' => $this->document,
'actions' => $this->actions,
));
}
|
php
|
private function generateNewView($dir)
{
$this->renderFile('views/new.html.twig', $dir.'/new.html.twig', array(
'dir' => $this->skeletonDir,
'route_prefix' => $this->routePrefix,
'route_name_prefix' => $this->routeNamePrefix,
'document' => $this->document,
'actions' => $this->actions,
));
}
|
[
"private",
"function",
"generateNewView",
"(",
"$",
"dir",
")",
"{",
"$",
"this",
"->",
"renderFile",
"(",
"'views/new.html.twig'",
",",
"$",
"dir",
".",
"'/new.html.twig'",
",",
"array",
"(",
"'dir'",
"=>",
"$",
"this",
"->",
"skeletonDir",
",",
"'route_prefix'",
"=>",
"$",
"this",
"->",
"routePrefix",
",",
"'route_name_prefix'",
"=>",
"$",
"this",
"->",
"routeNamePrefix",
",",
"'document'",
"=>",
"$",
"this",
"->",
"document",
",",
"'actions'",
"=>",
"$",
"this",
"->",
"actions",
",",
")",
")",
";",
"}"
] |
Generates the new.html.twig template in the final bundle.
@param string $dir The path to the folder that hosts templates in the bundle
|
[
"Generates",
"the",
"new",
".",
"html",
".",
"twig",
"template",
"in",
"the",
"final",
"bundle",
"."
] |
cd5937ac1db82dfee1b23946f09de4cd778d872d
|
https://github.com/iambrosi/IsmaAmbrosiGeneratorBundle/blob/cd5937ac1db82dfee1b23946f09de4cd778d872d/Generator/DoctrineCrudGenerator.php#L278-L287
|
221,431
|
allejo/PhpSoda
|
src/SoqlQuery.php
|
SoqlQuery.__tostring
|
public function __tostring ()
{
if (is_null($this->queryElements))
{
return "";
}
$query = [];
foreach ($this->queryElements as $soqlKey => $value)
{
$value = (is_array($value)) ? implode(self::DELIMITER, $value) : $value;
$query[] = sprintf("%s=%s", $soqlKey, $value);
}
return implode("&", $query);
}
|
php
|
public function __tostring ()
{
if (is_null($this->queryElements))
{
return "";
}
$query = [];
foreach ($this->queryElements as $soqlKey => $value)
{
$value = (is_array($value)) ? implode(self::DELIMITER, $value) : $value;
$query[] = sprintf("%s=%s", $soqlKey, $value);
}
return implode("&", $query);
}
|
[
"public",
"function",
"__tostring",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"queryElements",
")",
")",
"{",
"return",
"\"\"",
";",
"}",
"$",
"query",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"queryElements",
"as",
"$",
"soqlKey",
"=>",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"?",
"implode",
"(",
"self",
"::",
"DELIMITER",
",",
"$",
"value",
")",
":",
"$",
"value",
";",
"$",
"query",
"[",
"]",
"=",
"sprintf",
"(",
"\"%s=%s\"",
",",
"$",
"soqlKey",
",",
"$",
"value",
")",
";",
"}",
"return",
"implode",
"(",
"\"&\"",
",",
"$",
"query",
")",
";",
"}"
] |
Convert the current information into a URL encoded query that can be appended to the domain
@since 0.1.0
@return string The SoQL query ready to be appended to a URL
|
[
"Convert",
"the",
"current",
"information",
"into",
"a",
"URL",
"encoded",
"query",
"that",
"can",
"be",
"appended",
"to",
"the",
"domain"
] |
74f6ae950de2ebcb15363e6d35239911c54984f3
|
https://github.com/allejo/PhpSoda/blob/74f6ae950de2ebcb15363e6d35239911c54984f3/src/SoqlQuery.php#L99-L116
|
221,432
|
allejo/PhpSoda
|
src/SoqlQuery.php
|
SoqlQuery.select
|
public function select ($columns = self::DEFAULT_SELECT)
{
if (func_num_args() == 1)
{
$this->queryElements[self::SELECT_KEY] = (is_array($columns)) ? $this->formatAssociativeArray("%s AS %s", $columns) : array($columns);
}
else if (func_num_args() > 1)
{
$this->queryElements[self::SELECT_KEY] = func_get_args();
}
return $this;
}
|
php
|
public function select ($columns = self::DEFAULT_SELECT)
{
if (func_num_args() == 1)
{
$this->queryElements[self::SELECT_KEY] = (is_array($columns)) ? $this->formatAssociativeArray("%s AS %s", $columns) : array($columns);
}
else if (func_num_args() > 1)
{
$this->queryElements[self::SELECT_KEY] = func_get_args();
}
return $this;
}
|
[
"public",
"function",
"select",
"(",
"$",
"columns",
"=",
"self",
"::",
"DEFAULT_SELECT",
")",
"{",
"if",
"(",
"func_num_args",
"(",
")",
"==",
"1",
")",
"{",
"$",
"this",
"->",
"queryElements",
"[",
"self",
"::",
"SELECT_KEY",
"]",
"=",
"(",
"is_array",
"(",
"$",
"columns",
")",
")",
"?",
"$",
"this",
"->",
"formatAssociativeArray",
"(",
"\"%s AS %s\"",
",",
"$",
"columns",
")",
":",
"array",
"(",
"$",
"columns",
")",
";",
"}",
"else",
"if",
"(",
"func_num_args",
"(",
")",
">",
"1",
")",
"{",
"$",
"this",
"->",
"queryElements",
"[",
"self",
"::",
"SELECT_KEY",
"]",
"=",
"func_get_args",
"(",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Select only specific columns in your Soql Query. When this function is given no parameters or is not used in a
query, the Soql Query will return all of the columns by default.
```php
// These are all valid usages
$soqlQuery->select();
$soqlQuery->select("foo", "bar", "baz");
$soqlQuery->select(array("foo" => "foo_alias", "bar" => "bar_alias", "baz"));
```
@link https://dev.socrata.com/docs/queries/select.html SoQL $select Parameter
@param array|mixed $columns The columns to select from the dataset. The columns can be specified as an array
of values or it can be specified as multiple parameters separated by commas.
@since 0.1.0
@return $this A SoqlQuery object that can continue to be chained
|
[
"Select",
"only",
"specific",
"columns",
"in",
"your",
"Soql",
"Query",
".",
"When",
"this",
"function",
"is",
"given",
"no",
"parameters",
"or",
"is",
"not",
"used",
"in",
"a",
"query",
"the",
"Soql",
"Query",
"will",
"return",
"all",
"of",
"the",
"columns",
"by",
"default",
"."
] |
74f6ae950de2ebcb15363e6d35239911c54984f3
|
https://github.com/allejo/PhpSoda/blob/74f6ae950de2ebcb15363e6d35239911c54984f3/src/SoqlQuery.php#L138-L150
|
221,433
|
allejo/PhpSoda
|
src/SoqlQuery.php
|
SoqlQuery.limit
|
public function limit ($limit)
{
$this->handleInteger("limit", $limit);
$this->queryElements[self::LIMIT_KEY] = $limit;
return $this;
}
|
php
|
public function limit ($limit)
{
$this->handleInteger("limit", $limit);
$this->queryElements[self::LIMIT_KEY] = $limit;
return $this;
}
|
[
"public",
"function",
"limit",
"(",
"$",
"limit",
")",
"{",
"$",
"this",
"->",
"handleInteger",
"(",
"\"limit\"",
",",
"$",
"limit",
")",
";",
"$",
"this",
"->",
"queryElements",
"[",
"self",
"::",
"LIMIT_KEY",
"]",
"=",
"$",
"limit",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the amount of results that can be retrieved from a dataset per query.
@link https://dev.socrata.com/docs/queries/limit.html SoQL $limit Parameter
@param int $limit The number of results the dataset should be limited to when returned
@throws \InvalidArgumentException If the given argument is not an integer
@throws \OutOfBoundsException If the given argument is less than 0
@since 0.1.0
@return $this A SoqlQuery object that can continue to be chained
|
[
"Set",
"the",
"amount",
"of",
"results",
"that",
"can",
"be",
"retrieved",
"from",
"a",
"dataset",
"per",
"query",
"."
] |
74f6ae950de2ebcb15363e6d35239911c54984f3
|
https://github.com/allejo/PhpSoda/blob/74f6ae950de2ebcb15363e6d35239911c54984f3/src/SoqlQuery.php#L291-L298
|
221,434
|
allejo/PhpSoda
|
src/SoqlQuery.php
|
SoqlQuery.handleInteger
|
private function handleInteger ($variable, $number)
{
if (!is_integer($number))
{
throw new \InvalidArgumentException(sprintf("The %s must be an integer", $variable));
}
if ($number < 0)
{
$message = sprintf("The %s cannot be less than 0.", $variable);
throw new \OutOfBoundsException($message, 1);
}
}
|
php
|
private function handleInteger ($variable, $number)
{
if (!is_integer($number))
{
throw new \InvalidArgumentException(sprintf("The %s must be an integer", $variable));
}
if ($number < 0)
{
$message = sprintf("The %s cannot be less than 0.", $variable);
throw new \OutOfBoundsException($message, 1);
}
}
|
[
"private",
"function",
"handleInteger",
"(",
"$",
"variable",
",",
"$",
"number",
")",
"{",
"if",
"(",
"!",
"is_integer",
"(",
"$",
"number",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"\"The %s must be an integer\"",
",",
"$",
"variable",
")",
")",
";",
"}",
"if",
"(",
"$",
"number",
"<",
"0",
")",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"\"The %s cannot be less than 0.\"",
",",
"$",
"variable",
")",
";",
"throw",
"new",
"\\",
"OutOfBoundsException",
"(",
"$",
"message",
",",
"1",
")",
";",
"}",
"}"
] |
Analyze a given value and ensure the value fits the criteria set by the Socrata API
@param string $variable The literal name of this field
@param int $number The value to analyze
@since 0.1.0
@throws \InvalidArgumentException If the given argument is not an integer
@throws \OutOfBoundsException If the given argument is less than 0
|
[
"Analyze",
"a",
"given",
"value",
"and",
"ensure",
"the",
"value",
"fits",
"the",
"criteria",
"set",
"by",
"the",
"Socrata",
"API"
] |
74f6ae950de2ebcb15363e6d35239911c54984f3
|
https://github.com/allejo/PhpSoda/blob/74f6ae950de2ebcb15363e6d35239911c54984f3/src/SoqlQuery.php#L311-L324
|
221,435
|
allejo/PhpSoda
|
src/SodaDataset.php
|
SodaDataset.getApiVersion
|
public function getApiVersion ()
{
// If we don't have the API version set, send a dummy query with limit 0 since we only care about the headers
if ($this->apiVersion == 0)
{
$soql = new SoqlQuery();
$soql->limit(0);
// When we fetch a dataset, the API version is stored
$this->getDataset($soql);
}
return $this->apiVersion;
}
|
php
|
public function getApiVersion ()
{
// If we don't have the API version set, send a dummy query with limit 0 since we only care about the headers
if ($this->apiVersion == 0)
{
$soql = new SoqlQuery();
$soql->limit(0);
// When we fetch a dataset, the API version is stored
$this->getDataset($soql);
}
return $this->apiVersion;
}
|
[
"public",
"function",
"getApiVersion",
"(",
")",
"{",
"// If we don't have the API version set, send a dummy query with limit 0 since we only care about the headers",
"if",
"(",
"$",
"this",
"->",
"apiVersion",
"==",
"0",
")",
"{",
"$",
"soql",
"=",
"new",
"SoqlQuery",
"(",
")",
";",
"$",
"soql",
"->",
"limit",
"(",
"0",
")",
";",
"// When we fetch a dataset, the API version is stored",
"$",
"this",
"->",
"getDataset",
"(",
"$",
"soql",
")",
";",
"}",
"return",
"$",
"this",
"->",
"apiVersion",
";",
"}"
] |
Get the API version this dataset is using
@since 0.1.0
@return double The API version number
|
[
"Get",
"the",
"API",
"version",
"this",
"dataset",
"is",
"using"
] |
74f6ae950de2ebcb15363e6d35239911c54984f3
|
https://github.com/allejo/PhpSoda/blob/74f6ae950de2ebcb15363e6d35239911c54984f3/src/SodaDataset.php#L95-L108
|
221,436
|
allejo/PhpSoda
|
src/SodaDataset.php
|
SodaDataset.getMetadata
|
public function getMetadata ($forceFetch = false)
{
if (empty($this->metadata) || $forceFetch)
{
$metadataUrlQuery = new UrlQuery($this->buildViewUrl(), $this->sodaClient->getToken(), $this->sodaClient->getEmail(), $this->sodaClient->getPassword());
$metadataUrlQuery->setOAuth2Token($this->sodaClient->getOAuth2Token());
$this->metadata = $metadataUrlQuery->sendGet("", $this->sodaClient->associativeArrayEnabled());
}
return $this->metadata;
}
|
php
|
public function getMetadata ($forceFetch = false)
{
if (empty($this->metadata) || $forceFetch)
{
$metadataUrlQuery = new UrlQuery($this->buildViewUrl(), $this->sodaClient->getToken(), $this->sodaClient->getEmail(), $this->sodaClient->getPassword());
$metadataUrlQuery->setOAuth2Token($this->sodaClient->getOAuth2Token());
$this->metadata = $metadataUrlQuery->sendGet("", $this->sodaClient->associativeArrayEnabled());
}
return $this->metadata;
}
|
[
"public",
"function",
"getMetadata",
"(",
"$",
"forceFetch",
"=",
"false",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"metadata",
")",
"||",
"$",
"forceFetch",
")",
"{",
"$",
"metadataUrlQuery",
"=",
"new",
"UrlQuery",
"(",
"$",
"this",
"->",
"buildViewUrl",
"(",
")",
",",
"$",
"this",
"->",
"sodaClient",
"->",
"getToken",
"(",
")",
",",
"$",
"this",
"->",
"sodaClient",
"->",
"getEmail",
"(",
")",
",",
"$",
"this",
"->",
"sodaClient",
"->",
"getPassword",
"(",
")",
")",
";",
"$",
"metadataUrlQuery",
"->",
"setOAuth2Token",
"(",
"$",
"this",
"->",
"sodaClient",
"->",
"getOAuth2Token",
"(",
")",
")",
";",
"$",
"this",
"->",
"metadata",
"=",
"$",
"metadataUrlQuery",
"->",
"sendGet",
"(",
"\"\"",
",",
"$",
"this",
"->",
"sodaClient",
"->",
"associativeArrayEnabled",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"metadata",
";",
"}"
] |
Get the metadata of a dataset
@param bool $forceFetch Set to true if the cached metadata for the dataset is outdata or needs to be refreshed
@see SodaClient::enableAssociativeArrays()
@see SodaClient::disableAssociativeArrays()
@since 0.1.0
@return array The metadata as a PHP array. The array will contain associative arrays or stdClass objects from
the decoded JSON received from the data set.
|
[
"Get",
"the",
"metadata",
"of",
"a",
"dataset"
] |
74f6ae950de2ebcb15363e6d35239911c54984f3
|
https://github.com/allejo/PhpSoda/blob/74f6ae950de2ebcb15363e6d35239911c54984f3/src/SodaDataset.php#L123-L134
|
221,437
|
allejo/PhpSoda
|
src/SodaDataset.php
|
SodaDataset.getDataset
|
public function getDataset ($filterOrSoqlQuery = "")
{
$headers = array();
if (!($filterOrSoqlQuery instanceof SoqlQuery) && StringUtilities::isNullOrEmpty($filterOrSoqlQuery))
{
$filterOrSoqlQuery = new SoqlQuery();
}
$dataset = $this->urlQuery->sendGet($filterOrSoqlQuery, $this->sodaClient->associativeArrayEnabled(), $headers);
$this->setApiVersion($headers);
return $dataset;
}
|
php
|
public function getDataset ($filterOrSoqlQuery = "")
{
$headers = array();
if (!($filterOrSoqlQuery instanceof SoqlQuery) && StringUtilities::isNullOrEmpty($filterOrSoqlQuery))
{
$filterOrSoqlQuery = new SoqlQuery();
}
$dataset = $this->urlQuery->sendGet($filterOrSoqlQuery, $this->sodaClient->associativeArrayEnabled(), $headers);
$this->setApiVersion($headers);
return $dataset;
}
|
[
"public",
"function",
"getDataset",
"(",
"$",
"filterOrSoqlQuery",
"=",
"\"\"",
")",
"{",
"$",
"headers",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"(",
"$",
"filterOrSoqlQuery",
"instanceof",
"SoqlQuery",
")",
"&&",
"StringUtilities",
"::",
"isNullOrEmpty",
"(",
"$",
"filterOrSoqlQuery",
")",
")",
"{",
"$",
"filterOrSoqlQuery",
"=",
"new",
"SoqlQuery",
"(",
")",
";",
"}",
"$",
"dataset",
"=",
"$",
"this",
"->",
"urlQuery",
"->",
"sendGet",
"(",
"$",
"filterOrSoqlQuery",
",",
"$",
"this",
"->",
"sodaClient",
"->",
"associativeArrayEnabled",
"(",
")",
",",
"$",
"headers",
")",
";",
"$",
"this",
"->",
"setApiVersion",
"(",
"$",
"headers",
")",
";",
"return",
"$",
"dataset",
";",
"}"
] |
Fetch a dataset based on a resource ID.
@param string|SoqlQuery $filterOrSoqlQuery A simple filter or a SoqlQuery to filter the results
@see SodaClient::enableAssociativeArrays()
@see SodaClient::disableAssociativeArrays()
@since 0.1.0
@return array The data set as a PHP array. The array will contain associative arrays or stdClass objects from
the decoded JSON received from the data set.
|
[
"Fetch",
"a",
"dataset",
"based",
"on",
"a",
"resource",
"ID",
"."
] |
74f6ae950de2ebcb15363e6d35239911c54984f3
|
https://github.com/allejo/PhpSoda/blob/74f6ae950de2ebcb15363e6d35239911c54984f3/src/SodaDataset.php#L149-L163
|
221,438
|
allejo/PhpSoda
|
src/SodaDataset.php
|
SodaDataset.replace
|
public function replace ($payload)
{
$upsertData = $this->handleJson($payload);
return $this->urlQuery->sendPut($upsertData, $this->sodaClient->associativeArrayEnabled());
}
|
php
|
public function replace ($payload)
{
$upsertData = $this->handleJson($payload);
return $this->urlQuery->sendPut($upsertData, $this->sodaClient->associativeArrayEnabled());
}
|
[
"public",
"function",
"replace",
"(",
"$",
"payload",
")",
"{",
"$",
"upsertData",
"=",
"$",
"this",
"->",
"handleJson",
"(",
"$",
"payload",
")",
";",
"return",
"$",
"this",
"->",
"urlQuery",
"->",
"sendPut",
"(",
"$",
"upsertData",
",",
"$",
"this",
"->",
"sodaClient",
"->",
"associativeArrayEnabled",
"(",
")",
")",
";",
"}"
] |
Replace the entire dataset with the new payload provided
Data will always be transmitted as JSON to Socrata even though different forms are accepted. In order to pass
other forms of data, you must use a Converter class that has a `toJson()` method, such as the CsvConverter.
@param array|Converter|JSON $payload The data that will be upserted to the Socrata dataset as a PHP array, an
instance of a Converter child class, or a JSON string
@link http://dev.socrata.com/publishers/replace.html Replacing a dataset with Replace
@see Converter
@see CsvConverter
@since 0.1.0
@return mixed
|
[
"Replace",
"the",
"entire",
"dataset",
"with",
"the",
"new",
"payload",
"provided"
] |
74f6ae950de2ebcb15363e6d35239911c54984f3
|
https://github.com/allejo/PhpSoda/blob/74f6ae950de2ebcb15363e6d35239911c54984f3/src/SodaDataset.php#L228-L233
|
221,439
|
allejo/PhpSoda
|
src/SodaDataset.php
|
SodaDataset.upsert
|
public function upsert ($payload)
{
$upsertData = $this->handleJson($payload);
return $this->urlQuery->sendPost($upsertData, $this->sodaClient->associativeArrayEnabled());
}
|
php
|
public function upsert ($payload)
{
$upsertData = $this->handleJson($payload);
return $this->urlQuery->sendPost($upsertData, $this->sodaClient->associativeArrayEnabled());
}
|
[
"public",
"function",
"upsert",
"(",
"$",
"payload",
")",
"{",
"$",
"upsertData",
"=",
"$",
"this",
"->",
"handleJson",
"(",
"$",
"payload",
")",
";",
"return",
"$",
"this",
"->",
"urlQuery",
"->",
"sendPost",
"(",
"$",
"upsertData",
",",
"$",
"this",
"->",
"sodaClient",
"->",
"associativeArrayEnabled",
"(",
")",
")",
";",
"}"
] |
Create, update, and delete rows in a single operation, using their row identifiers.
Data will always be transmitted as JSON to Socrata even though different forms are accepted. In order to pass
other forms of data, you must use a Converter class that has a `toJson()` method, such as the CsvConverter.
@param array|Converter|JSON $payload The data that will be upserted to the Socrata dataset as a PHP array, an
instance of a Converter child class, or a JSON string
@link http://dev.socrata.com/publishers/upsert.html Updating Rows in Bulk with Upsert
@see Converter
@see CsvConverter
@since 0.1.0
@return mixed
|
[
"Create",
"update",
"and",
"delete",
"rows",
"in",
"a",
"single",
"operation",
"using",
"their",
"row",
"identifiers",
"."
] |
74f6ae950de2ebcb15363e6d35239911c54984f3
|
https://github.com/allejo/PhpSoda/blob/74f6ae950de2ebcb15363e6d35239911c54984f3/src/SodaDataset.php#L253-L258
|
221,440
|
allejo/PhpSoda
|
src/SodaDataset.php
|
SodaDataset.buildApiUrl
|
private function buildApiUrl ($location, $identifier = NULL)
{
if ($identifier === NULL)
{
$identifier = $this->resourceId;
}
return sprintf("%s://%s/%s/%s.json", UrlQuery::DEFAULT_PROTOCOL, $this->sodaClient->getDomain(), $location, $identifier);
}
|
php
|
private function buildApiUrl ($location, $identifier = NULL)
{
if ($identifier === NULL)
{
$identifier = $this->resourceId;
}
return sprintf("%s://%s/%s/%s.json", UrlQuery::DEFAULT_PROTOCOL, $this->sodaClient->getDomain(), $location, $identifier);
}
|
[
"private",
"function",
"buildApiUrl",
"(",
"$",
"location",
",",
"$",
"identifier",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"identifier",
"===",
"NULL",
")",
"{",
"$",
"identifier",
"=",
"$",
"this",
"->",
"resourceId",
";",
"}",
"return",
"sprintf",
"(",
"\"%s://%s/%s/%s.json\"",
",",
"UrlQuery",
"::",
"DEFAULT_PROTOCOL",
",",
"$",
"this",
"->",
"sodaClient",
"->",
"getDomain",
"(",
")",
",",
"$",
"location",
",",
"$",
"identifier",
")",
";",
"}"
] |
Build the URL that will be used to access the API for the respective action
@param string $location The location of where to get information from
@param string|null $identifier The part of the URL that will end with .json. This will either be the resource
ID or it will be a row ID prepended with the resource ID
@return string The API URL
|
[
"Build",
"the",
"URL",
"that",
"will",
"be",
"used",
"to",
"access",
"the",
"API",
"for",
"the",
"respective",
"action"
] |
74f6ae950de2ebcb15363e6d35239911c54984f3
|
https://github.com/allejo/PhpSoda/blob/74f6ae950de2ebcb15363e6d35239911c54984f3/src/SodaDataset.php#L289-L297
|
221,441
|
allejo/PhpSoda
|
src/SodaDataset.php
|
SodaDataset.handleJson
|
private function handleJson ($payload)
{
$uploadData = $payload;
if (is_array($payload))
{
$uploadData = json_encode($payload);
}
else if ($payload instanceof Converter)
{
$uploadData = $payload->toJson();
}
else if (!StringUtilities::isJson($payload))
{
throw new \InvalidArgumentException("The given data is not valid JSON");
}
return $uploadData;
}
|
php
|
private function handleJson ($payload)
{
$uploadData = $payload;
if (is_array($payload))
{
$uploadData = json_encode($payload);
}
else if ($payload instanceof Converter)
{
$uploadData = $payload->toJson();
}
else if (!StringUtilities::isJson($payload))
{
throw new \InvalidArgumentException("The given data is not valid JSON");
}
return $uploadData;
}
|
[
"private",
"function",
"handleJson",
"(",
"$",
"payload",
")",
"{",
"$",
"uploadData",
"=",
"$",
"payload",
";",
"if",
"(",
"is_array",
"(",
"$",
"payload",
")",
")",
"{",
"$",
"uploadData",
"=",
"json_encode",
"(",
"$",
"payload",
")",
";",
"}",
"else",
"if",
"(",
"$",
"payload",
"instanceof",
"Converter",
")",
"{",
"$",
"uploadData",
"=",
"$",
"payload",
"->",
"toJson",
"(",
")",
";",
"}",
"else",
"if",
"(",
"!",
"StringUtilities",
"::",
"isJson",
"(",
"$",
"payload",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"The given data is not valid JSON\"",
")",
";",
"}",
"return",
"$",
"uploadData",
";",
"}"
] |
Handle different forms of data to be returned in JSON format so it can be sent to Socrata.
Data will always be transmitted as JSON to Socrata even though different forms are accepted.
@param array|Converter|JSON $payload The data that will be upserted to the Socrata dataset as a PHP array, an
instance of a Converter child class, or a JSON string
@return string A JSON encoded string available to be used for UrlQuery requsts
|
[
"Handle",
"different",
"forms",
"of",
"data",
"to",
"be",
"returned",
"in",
"JSON",
"format",
"so",
"it",
"can",
"be",
"sent",
"to",
"Socrata",
"."
] |
74f6ae950de2ebcb15363e6d35239911c54984f3
|
https://github.com/allejo/PhpSoda/blob/74f6ae950de2ebcb15363e6d35239911c54984f3/src/SodaDataset.php#L309-L327
|
221,442
|
allejo/PhpSoda
|
src/SodaDataset.php
|
SodaDataset.individualRow
|
private function individualRow ($rowID, $method)
{
$headers = array();
// For a single row, the format is the `resourceID/rowID.json`, so we'll use that as the "location" of the Api URL
$apiEndPoint = $this->buildApiUrl("resource", $this->resourceId . "/" . $rowID);
$urlQuery = new UrlQuery($apiEndPoint, $this->sodaClient->getToken(), $this->sodaClient->getEmail(), $this->sodaClient->getPassword());
$urlQuery->setOAuth2Token($this->sodaClient->getOAuth2Token());
$result = $this->sendIndividualRequest($urlQuery, $method, $this->sodaClient->associativeArrayEnabled(), $headers);
$this->setApiVersion($headers);
return $result;
}
|
php
|
private function individualRow ($rowID, $method)
{
$headers = array();
// For a single row, the format is the `resourceID/rowID.json`, so we'll use that as the "location" of the Api URL
$apiEndPoint = $this->buildApiUrl("resource", $this->resourceId . "/" . $rowID);
$urlQuery = new UrlQuery($apiEndPoint, $this->sodaClient->getToken(), $this->sodaClient->getEmail(), $this->sodaClient->getPassword());
$urlQuery->setOAuth2Token($this->sodaClient->getOAuth2Token());
$result = $this->sendIndividualRequest($urlQuery, $method, $this->sodaClient->associativeArrayEnabled(), $headers);
$this->setApiVersion($headers);
return $result;
}
|
[
"private",
"function",
"individualRow",
"(",
"$",
"rowID",
",",
"$",
"method",
")",
"{",
"$",
"headers",
"=",
"array",
"(",
")",
";",
"// For a single row, the format is the `resourceID/rowID.json`, so we'll use that as the \"location\" of the Api URL",
"$",
"apiEndPoint",
"=",
"$",
"this",
"->",
"buildApiUrl",
"(",
"\"resource\"",
",",
"$",
"this",
"->",
"resourceId",
".",
"\"/\"",
".",
"$",
"rowID",
")",
";",
"$",
"urlQuery",
"=",
"new",
"UrlQuery",
"(",
"$",
"apiEndPoint",
",",
"$",
"this",
"->",
"sodaClient",
"->",
"getToken",
"(",
")",
",",
"$",
"this",
"->",
"sodaClient",
"->",
"getEmail",
"(",
")",
",",
"$",
"this",
"->",
"sodaClient",
"->",
"getPassword",
"(",
")",
")",
";",
"$",
"urlQuery",
"->",
"setOAuth2Token",
"(",
"$",
"this",
"->",
"sodaClient",
"->",
"getOAuth2Token",
"(",
")",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"sendIndividualRequest",
"(",
"$",
"urlQuery",
",",
"$",
"method",
",",
"$",
"this",
"->",
"sodaClient",
"->",
"associativeArrayEnabled",
"(",
")",
",",
"$",
"headers",
")",
";",
"$",
"this",
"->",
"setApiVersion",
"(",
"$",
"headers",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Interact with an individual row. Either to retrieve it or to delete it; both actions use the same API endpoint
with the exception of what type of request is sent.
@param string $rowID The 4x4 resource ID of the dataset to work with
@param string $method Either `get` or `delete`
@return mixed
|
[
"Interact",
"with",
"an",
"individual",
"row",
".",
"Either",
"to",
"retrieve",
"it",
"or",
"to",
"delete",
"it",
";",
"both",
"actions",
"use",
"the",
"same",
"API",
"endpoint",
"with",
"the",
"exception",
"of",
"what",
"type",
"of",
"request",
"is",
"sent",
"."
] |
74f6ae950de2ebcb15363e6d35239911c54984f3
|
https://github.com/allejo/PhpSoda/blob/74f6ae950de2ebcb15363e6d35239911c54984f3/src/SodaDataset.php#L338-L353
|
221,443
|
allejo/PhpSoda
|
src/SodaDataset.php
|
SodaDataset.sendIndividualRequest
|
private function sendIndividualRequest ($urlQuery, $method, $associativeArrays, &$headers)
{
if ($method === "get")
{
return $urlQuery->sendGet("", $associativeArrays, $headers);
}
else if ($method === "delete")
{
return $urlQuery->sendDelete($associativeArrays, $headers);
}
throw new \InvalidArgumentException("Invalid request method");
}
|
php
|
private function sendIndividualRequest ($urlQuery, $method, $associativeArrays, &$headers)
{
if ($method === "get")
{
return $urlQuery->sendGet("", $associativeArrays, $headers);
}
else if ($method === "delete")
{
return $urlQuery->sendDelete($associativeArrays, $headers);
}
throw new \InvalidArgumentException("Invalid request method");
}
|
[
"private",
"function",
"sendIndividualRequest",
"(",
"$",
"urlQuery",
",",
"$",
"method",
",",
"$",
"associativeArrays",
",",
"&",
"$",
"headers",
")",
"{",
"if",
"(",
"$",
"method",
"===",
"\"get\"",
")",
"{",
"return",
"$",
"urlQuery",
"->",
"sendGet",
"(",
"\"\"",
",",
"$",
"associativeArrays",
",",
"$",
"headers",
")",
";",
"}",
"else",
"if",
"(",
"$",
"method",
"===",
"\"delete\"",
")",
"{",
"return",
"$",
"urlQuery",
"->",
"sendDelete",
"(",
"$",
"associativeArrays",
",",
"$",
"headers",
")",
";",
"}",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Invalid request method\"",
")",
";",
"}"
] |
Send the appropriate request header based on the method that's required
@param UrlQuery $urlQuery The object for the API endpoint
@param string $method Either `get` or `delete`
@param bool $associativeArrays Whether or not to return the information as an associative array
@param array $headers An array with the cURL headers received
@return mixed
|
[
"Send",
"the",
"appropriate",
"request",
"header",
"based",
"on",
"the",
"method",
"that",
"s",
"required"
] |
74f6ae950de2ebcb15363e6d35239911c54984f3
|
https://github.com/allejo/PhpSoda/blob/74f6ae950de2ebcb15363e6d35239911c54984f3/src/SodaDataset.php#L365-L377
|
221,444
|
allejo/PhpSoda
|
src/SodaDataset.php
|
SodaDataset.parseApiVersion
|
private function parseApiVersion ($responseHeaders)
{
// A header that's unique to the legacy API
if (array_key_exists('X-SODA2-Legacy-Types', $responseHeaders) && $responseHeaders['X-SODA2-Legacy-Types'])
{
return 1;
}
// A header that's unique to the new API
if (array_key_exists('X-SODA2-Truth-Last-Modified', $responseHeaders))
{
if (empty($this->metadata))
{
$this->getMetadata();
}
if ($this->metadata['newBackend'])
{
return 2.1;
}
return 2;
}
return 0;
}
|
php
|
private function parseApiVersion ($responseHeaders)
{
// A header that's unique to the legacy API
if (array_key_exists('X-SODA2-Legacy-Types', $responseHeaders) && $responseHeaders['X-SODA2-Legacy-Types'])
{
return 1;
}
// A header that's unique to the new API
if (array_key_exists('X-SODA2-Truth-Last-Modified', $responseHeaders))
{
if (empty($this->metadata))
{
$this->getMetadata();
}
if ($this->metadata['newBackend'])
{
return 2.1;
}
return 2;
}
return 0;
}
|
[
"private",
"function",
"parseApiVersion",
"(",
"$",
"responseHeaders",
")",
"{",
"// A header that's unique to the legacy API",
"if",
"(",
"array_key_exists",
"(",
"'X-SODA2-Legacy-Types'",
",",
"$",
"responseHeaders",
")",
"&&",
"$",
"responseHeaders",
"[",
"'X-SODA2-Legacy-Types'",
"]",
")",
"{",
"return",
"1",
";",
"}",
"// A header that's unique to the new API",
"if",
"(",
"array_key_exists",
"(",
"'X-SODA2-Truth-Last-Modified'",
",",
"$",
"responseHeaders",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"metadata",
")",
")",
"{",
"$",
"this",
"->",
"getMetadata",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"metadata",
"[",
"'newBackend'",
"]",
")",
"{",
"return",
"2.1",
";",
"}",
"return",
"2",
";",
"}",
"return",
"0",
";",
"}"
] |
Determine the version number of the API this dataset is using
@param array $responseHeaders An array with the cURL headers received
@return double The Socrata API version number this dataset uses
|
[
"Determine",
"the",
"version",
"number",
"of",
"the",
"API",
"this",
"dataset",
"is",
"using"
] |
74f6ae950de2ebcb15363e6d35239911c54984f3
|
https://github.com/allejo/PhpSoda/blob/74f6ae950de2ebcb15363e6d35239911c54984f3/src/SodaDataset.php#L400-L425
|
221,445
|
allejo/PhpSoda
|
src/SoqlOrderDirection.php
|
SoqlOrderDirection.parseOrder
|
public static function parseOrder ($string)
{
if ($string === self::ASC || $string === self::DESC)
{
return $string;
}
throw new \InvalidArgumentException(sprintf("An invalid sort order (%s) was given; you may only sort using ASC or DESC.", $string));
}
|
php
|
public static function parseOrder ($string)
{
if ($string === self::ASC || $string === self::DESC)
{
return $string;
}
throw new \InvalidArgumentException(sprintf("An invalid sort order (%s) was given; you may only sort using ASC or DESC.", $string));
}
|
[
"public",
"static",
"function",
"parseOrder",
"(",
"$",
"string",
")",
"{",
"if",
"(",
"$",
"string",
"===",
"self",
"::",
"ASC",
"||",
"$",
"string",
"===",
"self",
"::",
"DESC",
")",
"{",
"return",
"$",
"string",
";",
"}",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"\"An invalid sort order (%s) was given; you may only sort using ASC or DESC.\"",
",",
"$",
"string",
")",
")",
";",
"}"
] |
Ensure that we have a proper sorting order, so return only valid ordering options
@param string $string The order to be checked if valid
@throws \InvalidArgumentException If an unsupported sort order was given
@return string Supported sorting order option
|
[
"Ensure",
"that",
"we",
"have",
"a",
"proper",
"sorting",
"order",
"so",
"return",
"only",
"valid",
"ordering",
"options"
] |
74f6ae950de2ebcb15363e6d35239911c54984f3
|
https://github.com/allejo/PhpSoda/blob/74f6ae950de2ebcb15363e6d35239911c54984f3/src/SoqlOrderDirection.php#L39-L47
|
221,446
|
paquettg/leaguewrap
|
src/LeagueWrap/Cache.php
|
Cache.set
|
public function set($key, $response, $seconds)
{
return $this->memcached->set($key, $response, $seconds);
}
|
php
|
public function set($key, $response, $seconds)
{
return $this->memcached->set($key, $response, $seconds);
}
|
[
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"response",
",",
"$",
"seconds",
")",
"{",
"return",
"$",
"this",
"->",
"memcached",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"response",
",",
"$",
"seconds",
")",
";",
"}"
] |
Adds the response string into the cache under the given key.
@param string $key
@param \LeagueWrap\Response $response
@param int $seconds
@return bool
|
[
"Adds",
"the",
"response",
"string",
"into",
"the",
"cache",
"under",
"the",
"given",
"key",
"."
] |
0f91813b5d8292054e5e13619d591b6b14dc63e6
|
https://github.com/paquettg/leaguewrap/blob/0f91813b5d8292054e5e13619d591b6b14dc63e6/src/LeagueWrap/Cache.php#L27-L30
|
221,447
|
paquettg/leaguewrap
|
src/LeagueWrap/Cache.php
|
Cache.has
|
public function has($key)
{
$this->memcached->get($key);
if ($this->memcached->getResultCode() == Memcached::RES_NOTFOUND)
{
return false;
}
return true;
}
|
php
|
public function has($key)
{
$this->memcached->get($key);
if ($this->memcached->getResultCode() == Memcached::RES_NOTFOUND)
{
return false;
}
return true;
}
|
[
"public",
"function",
"has",
"(",
"$",
"key",
")",
"{",
"$",
"this",
"->",
"memcached",
"->",
"get",
"(",
"$",
"key",
")",
";",
"if",
"(",
"$",
"this",
"->",
"memcached",
"->",
"getResultCode",
"(",
")",
"==",
"Memcached",
"::",
"RES_NOTFOUND",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Determines if the cache has the given key.
@param string $key
@return bool
|
[
"Determines",
"if",
"the",
"cache",
"has",
"the",
"given",
"key",
"."
] |
0f91813b5d8292054e5e13619d591b6b14dc63e6
|
https://github.com/paquettg/leaguewrap/blob/0f91813b5d8292054e5e13619d591b6b14dc63e6/src/LeagueWrap/Cache.php#L38-L47
|
221,448
|
paquettg/leaguewrap
|
src/LeagueWrap/Api/Matchlist.php
|
Matchlist.matchlist
|
public function matchlist($identity, $rankedQueues = null, $seasons = null, $championIds = null, $beginIndex = null, $endIndex = null, $beginTime = null, $endTime = null)
{
$summonerId = $this->extractId($identity);
$requestParamas = $this->parseParams($rankedQueues, $seasons, $championIds, $beginIndex, $endIndex, $beginTime, $endTime);
$array = $this->request('matchlist/by-summoner/'.$summonerId, $requestParamas);
$matchList = $this->attachStaticDataToDto(new \LeagueWrap\Dto\MatchList($array));
$this->attachResponse($identity, $matchList, 'matchlist');
return $matchList;
}
|
php
|
public function matchlist($identity, $rankedQueues = null, $seasons = null, $championIds = null, $beginIndex = null, $endIndex = null, $beginTime = null, $endTime = null)
{
$summonerId = $this->extractId($identity);
$requestParamas = $this->parseParams($rankedQueues, $seasons, $championIds, $beginIndex, $endIndex, $beginTime, $endTime);
$array = $this->request('matchlist/by-summoner/'.$summonerId, $requestParamas);
$matchList = $this->attachStaticDataToDto(new \LeagueWrap\Dto\MatchList($array));
$this->attachResponse($identity, $matchList, 'matchlist');
return $matchList;
}
|
[
"public",
"function",
"matchlist",
"(",
"$",
"identity",
",",
"$",
"rankedQueues",
"=",
"null",
",",
"$",
"seasons",
"=",
"null",
",",
"$",
"championIds",
"=",
"null",
",",
"$",
"beginIndex",
"=",
"null",
",",
"$",
"endIndex",
"=",
"null",
",",
"$",
"beginTime",
"=",
"null",
",",
"$",
"endTime",
"=",
"null",
")",
"{",
"$",
"summonerId",
"=",
"$",
"this",
"->",
"extractId",
"(",
"$",
"identity",
")",
";",
"$",
"requestParamas",
"=",
"$",
"this",
"->",
"parseParams",
"(",
"$",
"rankedQueues",
",",
"$",
"seasons",
",",
"$",
"championIds",
",",
"$",
"beginIndex",
",",
"$",
"endIndex",
",",
"$",
"beginTime",
",",
"$",
"endTime",
")",
";",
"$",
"array",
"=",
"$",
"this",
"->",
"request",
"(",
"'matchlist/by-summoner/'",
".",
"$",
"summonerId",
",",
"$",
"requestParamas",
")",
";",
"$",
"matchList",
"=",
"$",
"this",
"->",
"attachStaticDataToDto",
"(",
"new",
"\\",
"LeagueWrap",
"\\",
"Dto",
"\\",
"MatchList",
"(",
"$",
"array",
")",
")",
";",
"$",
"this",
"->",
"attachResponse",
"(",
"$",
"identity",
",",
"$",
"matchList",
",",
"'matchlist'",
")",
";",
"return",
"$",
"matchList",
";",
"}"
] |
Get the match list by summoner identity.
@param $identity int|Summoner
@param array|string|null $rankedQueues List of ranked queue types to use for fetching games.
@param array|string|null $seasons List of seasons to use for fetching games.
@param array|string|null $championIds Comma-separated list of champion IDs to use for fetching games.
@param int|null $beginIndex The begin index to use for fetching games.
@param int|null $endIndex The end index to use for fetching games.
@param int|null $beginTime The begin time for fetching games in milliseconds
@param int|null $endTime The end time for fetching games in milliseconds
@return \LeagueWrap\Dto\MatchHistory
@throws \LeagueWrap\Exception\CacheNotFoundException
@throws \LeagueWrap\Exception\InvalidIdentityException
@throws \LeagueWrap\Exception\RegionException
|
[
"Get",
"the",
"match",
"list",
"by",
"summoner",
"identity",
"."
] |
0f91813b5d8292054e5e13619d591b6b14dc63e6
|
https://github.com/paquettg/leaguewrap/blob/0f91813b5d8292054e5e13619d591b6b14dc63e6/src/LeagueWrap/Api/Matchlist.php#L68-L79
|
221,449
|
paquettg/leaguewrap
|
src/LeagueWrap/Api/Matchlist.php
|
Matchlist.parseParams
|
protected function parseParams($rankedQueues = null, $seasons = null, $championIds = null, $beginIndex = null, $endIndex = null, $beginTime = null, $endTime = null)
{
$params = [];
if (isset($rankedQueues))
{
if (is_array($rankedQueues))
{
$params['rankedQueues'] = implode(',', $rankedQueues);
}
else
{
$params['rankedQueues'] = $rankedQueues;
}
}
if (isset($seasons))
{
if (is_array($seasons))
{
$params['seasons'] = implode(',', $seasons);
}
else
{
$params['seasons'] = $seasons;
}
}
if (isset($championIds))
{
if (is_array($championIds))
{
$params['championIds'] = implode(',', $championIds);
}
else
{
$params['championIds'] = $championIds;
}
}
if (isset($beginIndex))
{
$params['beginIndex'] = $beginIndex;
}
if (isset($endIndex))
{
$params['endIndex'] = $endIndex;
}
if (isset($beginTime))
{
$params['beginTime'] = $beginTime;
}
if (isset($endTime))
{
$params['endTime'] = $endTime;
}
return $params;
}
|
php
|
protected function parseParams($rankedQueues = null, $seasons = null, $championIds = null, $beginIndex = null, $endIndex = null, $beginTime = null, $endTime = null)
{
$params = [];
if (isset($rankedQueues))
{
if (is_array($rankedQueues))
{
$params['rankedQueues'] = implode(',', $rankedQueues);
}
else
{
$params['rankedQueues'] = $rankedQueues;
}
}
if (isset($seasons))
{
if (is_array($seasons))
{
$params['seasons'] = implode(',', $seasons);
}
else
{
$params['seasons'] = $seasons;
}
}
if (isset($championIds))
{
if (is_array($championIds))
{
$params['championIds'] = implode(',', $championIds);
}
else
{
$params['championIds'] = $championIds;
}
}
if (isset($beginIndex))
{
$params['beginIndex'] = $beginIndex;
}
if (isset($endIndex))
{
$params['endIndex'] = $endIndex;
}
if (isset($beginTime))
{
$params['beginTime'] = $beginTime;
}
if (isset($endTime))
{
$params['endTime'] = $endTime;
}
return $params;
}
|
[
"protected",
"function",
"parseParams",
"(",
"$",
"rankedQueues",
"=",
"null",
",",
"$",
"seasons",
"=",
"null",
",",
"$",
"championIds",
"=",
"null",
",",
"$",
"beginIndex",
"=",
"null",
",",
"$",
"endIndex",
"=",
"null",
",",
"$",
"beginTime",
"=",
"null",
",",
"$",
"endTime",
"=",
"null",
")",
"{",
"$",
"params",
"=",
"[",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"rankedQueues",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"rankedQueues",
")",
")",
"{",
"$",
"params",
"[",
"'rankedQueues'",
"]",
"=",
"implode",
"(",
"','",
",",
"$",
"rankedQueues",
")",
";",
"}",
"else",
"{",
"$",
"params",
"[",
"'rankedQueues'",
"]",
"=",
"$",
"rankedQueues",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"seasons",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"seasons",
")",
")",
"{",
"$",
"params",
"[",
"'seasons'",
"]",
"=",
"implode",
"(",
"','",
",",
"$",
"seasons",
")",
";",
"}",
"else",
"{",
"$",
"params",
"[",
"'seasons'",
"]",
"=",
"$",
"seasons",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"championIds",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"championIds",
")",
")",
"{",
"$",
"params",
"[",
"'championIds'",
"]",
"=",
"implode",
"(",
"','",
",",
"$",
"championIds",
")",
";",
"}",
"else",
"{",
"$",
"params",
"[",
"'championIds'",
"]",
"=",
"$",
"championIds",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"beginIndex",
")",
")",
"{",
"$",
"params",
"[",
"'beginIndex'",
"]",
"=",
"$",
"beginIndex",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"endIndex",
")",
")",
"{",
"$",
"params",
"[",
"'endIndex'",
"]",
"=",
"$",
"endIndex",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"beginTime",
")",
")",
"{",
"$",
"params",
"[",
"'beginTime'",
"]",
"=",
"$",
"beginTime",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"endTime",
")",
")",
"{",
"$",
"params",
"[",
"'endTime'",
"]",
"=",
"$",
"endTime",
";",
"}",
"return",
"$",
"params",
";",
"}"
] |
Parse the params into an array.
@param mixed $rankedQueues
@param mixed $seasons
@param mixed $championIds
@param mixed $beginIndex
@param mixed $endIndex
@param mixed $beginTime
@param mixed $endTime
@return array
|
[
"Parse",
"the",
"params",
"into",
"an",
"array",
"."
] |
0f91813b5d8292054e5e13619d591b6b14dc63e6
|
https://github.com/paquettg/leaguewrap/blob/0f91813b5d8292054e5e13619d591b6b14dc63e6/src/LeagueWrap/Api/Matchlist.php#L93-L150
|
221,450
|
neos/fluid
|
Classes/TYPO3/Fluid/Core/ViewHelper/TemplateVariableContainer.php
|
TemplateVariableContainer.add
|
public function add($identifier, $value)
{
if (array_key_exists($identifier, $this->variables)) {
throw new InvalidVariableException('Duplicate variable declaration, "' . $identifier . '" already set!', 1224479063);
}
if (in_array(strtolower($identifier), self::$reservedVariableNames)) {
throw new InvalidVariableException('"' . $identifier . '" is a reserved variable name and cannot be used as variable identifier.', 1256730379);
}
$this->variables[$identifier] = $value;
}
|
php
|
public function add($identifier, $value)
{
if (array_key_exists($identifier, $this->variables)) {
throw new InvalidVariableException('Duplicate variable declaration, "' . $identifier . '" already set!', 1224479063);
}
if (in_array(strtolower($identifier), self::$reservedVariableNames)) {
throw new InvalidVariableException('"' . $identifier . '" is a reserved variable name and cannot be used as variable identifier.', 1256730379);
}
$this->variables[$identifier] = $value;
}
|
[
"public",
"function",
"add",
"(",
"$",
"identifier",
",",
"$",
"value",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"identifier",
",",
"$",
"this",
"->",
"variables",
")",
")",
"{",
"throw",
"new",
"InvalidVariableException",
"(",
"'Duplicate variable declaration, \"'",
".",
"$",
"identifier",
".",
"'\" already set!'",
",",
"1224479063",
")",
";",
"}",
"if",
"(",
"in_array",
"(",
"strtolower",
"(",
"$",
"identifier",
")",
",",
"self",
"::",
"$",
"reservedVariableNames",
")",
")",
"{",
"throw",
"new",
"InvalidVariableException",
"(",
"'\"'",
".",
"$",
"identifier",
".",
"'\" is a reserved variable name and cannot be used as variable identifier.'",
",",
"1256730379",
")",
";",
"}",
"$",
"this",
"->",
"variables",
"[",
"$",
"identifier",
"]",
"=",
"$",
"value",
";",
"}"
] |
Add a variable to the context
@param string $identifier Identifier of the variable to add
@param mixed $value The variable's value
@return void
@throws Exception\InvalidVariableException
@api
|
[
"Add",
"a",
"variable",
"to",
"the",
"context"
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/ViewHelper/TemplateVariableContainer.php#L61-L70
|
221,451
|
neos/fluid
|
Classes/TYPO3/Fluid/Core/ViewHelper/TemplateVariableContainer.php
|
TemplateVariableContainer.get
|
public function get($identifier)
{
switch ($identifier) {
case '_all':
return $this->variables;
case 'true':
case 'on':
case 'yes':
return true;
case 'false':
case 'off':
case 'no':
return false;
}
if (!array_key_exists($identifier, $this->variables)) {
throw new InvalidVariableException('Tried to get a variable "' . $identifier . '" which is not stored in the context!', 1224479370);
}
return $this->variables[$identifier];
}
|
php
|
public function get($identifier)
{
switch ($identifier) {
case '_all':
return $this->variables;
case 'true':
case 'on':
case 'yes':
return true;
case 'false':
case 'off':
case 'no':
return false;
}
if (!array_key_exists($identifier, $this->variables)) {
throw new InvalidVariableException('Tried to get a variable "' . $identifier . '" which is not stored in the context!', 1224479370);
}
return $this->variables[$identifier];
}
|
[
"public",
"function",
"get",
"(",
"$",
"identifier",
")",
"{",
"switch",
"(",
"$",
"identifier",
")",
"{",
"case",
"'_all'",
":",
"return",
"$",
"this",
"->",
"variables",
";",
"case",
"'true'",
":",
"case",
"'on'",
":",
"case",
"'yes'",
":",
"return",
"true",
";",
"case",
"'false'",
":",
"case",
"'off'",
":",
"case",
"'no'",
":",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"identifier",
",",
"$",
"this",
"->",
"variables",
")",
")",
"{",
"throw",
"new",
"InvalidVariableException",
"(",
"'Tried to get a variable \"'",
".",
"$",
"identifier",
".",
"'\" which is not stored in the context!'",
",",
"1224479370",
")",
";",
"}",
"return",
"$",
"this",
"->",
"variables",
"[",
"$",
"identifier",
"]",
";",
"}"
] |
Get a variable from the context. Throws exception if variable is not found in context.
If "_all" is given as identifier, all variables are returned in an array,
if one of the other reserved variables are given, their appropriate value
they're representing is returned.
@param string $identifier
@return mixed The variable value identified by $identifier
@throws Exception\InvalidVariableException
@api
|
[
"Get",
"a",
"variable",
"from",
"the",
"context",
".",
"Throws",
"exception",
"if",
"variable",
"is",
"not",
"found",
"in",
"context",
"."
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/ViewHelper/TemplateVariableContainer.php#L84-L105
|
221,452
|
neos/fluid
|
Classes/TYPO3/Fluid/Core/ViewHelper/TemplateVariableContainer.php
|
TemplateVariableContainer.remove
|
public function remove($identifier)
{
if (!array_key_exists($identifier, $this->variables)) {
throw new InvalidVariableException('Tried to remove a variable "' . $identifier . '" which is not stored in the context!', 1224479372);
}
unset($this->variables[$identifier]);
}
|
php
|
public function remove($identifier)
{
if (!array_key_exists($identifier, $this->variables)) {
throw new InvalidVariableException('Tried to remove a variable "' . $identifier . '" which is not stored in the context!', 1224479372);
}
unset($this->variables[$identifier]);
}
|
[
"public",
"function",
"remove",
"(",
"$",
"identifier",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"identifier",
",",
"$",
"this",
"->",
"variables",
")",
")",
"{",
"throw",
"new",
"InvalidVariableException",
"(",
"'Tried to remove a variable \"'",
".",
"$",
"identifier",
".",
"'\" which is not stored in the context!'",
",",
"1224479372",
")",
";",
"}",
"unset",
"(",
"$",
"this",
"->",
"variables",
"[",
"$",
"identifier",
"]",
")",
";",
"}"
] |
Remove a variable from context. Throws exception if variable is not found in context.
@param string $identifier The identifier to remove
@return void
@throws Exception\InvalidVariableException
@api
|
[
"Remove",
"a",
"variable",
"from",
"context",
".",
"Throws",
"exception",
"if",
"variable",
"is",
"not",
"found",
"in",
"context",
"."
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/ViewHelper/TemplateVariableContainer.php#L115-L121
|
221,453
|
neos/fluid
|
Classes/TYPO3/Fluid/Core/ViewHelper/TemplateVariableContainer.php
|
TemplateVariableContainer.exists
|
public function exists($identifier)
{
if (in_array($identifier, self::$reservedVariableNames, true)) {
return true;
}
return array_key_exists($identifier, $this->variables);
}
|
php
|
public function exists($identifier)
{
if (in_array($identifier, self::$reservedVariableNames, true)) {
return true;
}
return array_key_exists($identifier, $this->variables);
}
|
[
"public",
"function",
"exists",
"(",
"$",
"identifier",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"identifier",
",",
"self",
"::",
"$",
"reservedVariableNames",
",",
"true",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"array_key_exists",
"(",
"$",
"identifier",
",",
"$",
"this",
"->",
"variables",
")",
";",
"}"
] |
Checks if this property exists in the VariableContainer.
@param string $identifier
@return boolean TRUE if $identifier exists, FALSE otherwise
@api
|
[
"Checks",
"if",
"this",
"property",
"exists",
"in",
"the",
"VariableContainer",
"."
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/ViewHelper/TemplateVariableContainer.php#L150-L157
|
221,454
|
mediamonks/php-rest-api
|
src/Response/ResponseTransformer.php
|
ResponseTransformer.forceStatusCodeHttpOK
|
protected function forceStatusCodeHttpOK(
Request $request,
SymfonyResponse $response,
ResponseModelInterface $responseModel
) {
if ($request->headers->has('X-Force-Status-Code-200')
|| ($request->getRequestFormat(
) == Format::FORMAT_JSON && $request->query->has(
self::PARAMETER_CALLBACK
))
) {
$responseModel->setReturnStatusCode(true);
$response->setStatusCode(Response::HTTP_OK);
$response->headers->set('X-Status-Code', Response::HTTP_OK);
}
}
|
php
|
protected function forceStatusCodeHttpOK(
Request $request,
SymfonyResponse $response,
ResponseModelInterface $responseModel
) {
if ($request->headers->has('X-Force-Status-Code-200')
|| ($request->getRequestFormat(
) == Format::FORMAT_JSON && $request->query->has(
self::PARAMETER_CALLBACK
))
) {
$responseModel->setReturnStatusCode(true);
$response->setStatusCode(Response::HTTP_OK);
$response->headers->set('X-Status-Code', Response::HTTP_OK);
}
}
|
[
"protected",
"function",
"forceStatusCodeHttpOK",
"(",
"Request",
"$",
"request",
",",
"SymfonyResponse",
"$",
"response",
",",
"ResponseModelInterface",
"$",
"responseModel",
")",
"{",
"if",
"(",
"$",
"request",
"->",
"headers",
"->",
"has",
"(",
"'X-Force-Status-Code-200'",
")",
"||",
"(",
"$",
"request",
"->",
"getRequestFormat",
"(",
")",
"==",
"Format",
"::",
"FORMAT_JSON",
"&&",
"$",
"request",
"->",
"query",
"->",
"has",
"(",
"self",
"::",
"PARAMETER_CALLBACK",
")",
")",
")",
"{",
"$",
"responseModel",
"->",
"setReturnStatusCode",
"(",
"true",
")",
";",
"$",
"response",
"->",
"setStatusCode",
"(",
"Response",
"::",
"HTTP_OK",
")",
";",
"$",
"response",
"->",
"headers",
"->",
"set",
"(",
"'X-Status-Code'",
",",
"Response",
"::",
"HTTP_OK",
")",
";",
"}",
"}"
] |
Check if we should put the status code in the output and force a 200 OK
in the header
@param Request $request
@param SymfonyResponse $response
@param ResponseModelInterface $responseModel
|
[
"Check",
"if",
"we",
"should",
"put",
"the",
"status",
"code",
"in",
"the",
"output",
"and",
"force",
"a",
"200",
"OK",
"in",
"the",
"header"
] |
96253c974238771ec3229c9a09a561c83c484c00
|
https://github.com/mediamonks/php-rest-api/blob/96253c974238771ec3229c9a09a561c83c484c00/src/Response/ResponseTransformer.php#L177-L192
|
221,455
|
mediamonks/php-rest-api
|
src/Response/ResponseTransformer.php
|
ResponseTransformer.forceEmptyResponseOnHttpNoContent
|
protected function forceEmptyResponseOnHttpNoContent(
SymfonyResponse $response
) {
if ($response->getStatusCode() === Response::HTTP_NO_CONTENT) {
$response->setContent(null);
$response->headers->remove('Content-Type');
}
}
|
php
|
protected function forceEmptyResponseOnHttpNoContent(
SymfonyResponse $response
) {
if ($response->getStatusCode() === Response::HTTP_NO_CONTENT) {
$response->setContent(null);
$response->headers->remove('Content-Type');
}
}
|
[
"protected",
"function",
"forceEmptyResponseOnHttpNoContent",
"(",
"SymfonyResponse",
"$",
"response",
")",
"{",
"if",
"(",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
"===",
"Response",
"::",
"HTTP_NO_CONTENT",
")",
"{",
"$",
"response",
"->",
"setContent",
"(",
"null",
")",
";",
"$",
"response",
"->",
"headers",
"->",
"remove",
"(",
"'Content-Type'",
")",
";",
"}",
"}"
] |
Make sure content is empty when the status code is "204 NoContent"
@param SymfonyResponse $response
|
[
"Make",
"sure",
"content",
"is",
"empty",
"when",
"the",
"status",
"code",
"is",
"204",
"NoContent"
] |
96253c974238771ec3229c9a09a561c83c484c00
|
https://github.com/mediamonks/php-rest-api/blob/96253c974238771ec3229c9a09a561c83c484c00/src/Response/ResponseTransformer.php#L199-L206
|
221,456
|
neos/fluid
|
Classes/TYPO3/Fluid/Core/Parser/TemplateParser.php
|
TemplateParser.parse
|
public function parse($templateString)
{
if (!is_string($templateString)) {
throw new Exception('Parse requires a template string as argument, ' . gettype($templateString) . ' given.', 1224237899);
}
$this->reset();
$templateString = $this->extractEscapingModifier($templateString);
$templateString = $this->extractNamespaceDefinitions($templateString);
$splitTemplate = $this->splitTemplateAtDynamicTags($templateString);
$parsingState = $this->buildObjectTree($splitTemplate, self::CONTEXT_OUTSIDE_VIEWHELPER_ARGUMENTS);
$variableContainer = $parsingState->getVariableContainer();
if ($variableContainer !== null && $variableContainer->exists('layoutName')) {
$parsingState->setLayoutNameNode($variableContainer->get('layoutName'));
}
return $parsingState;
}
|
php
|
public function parse($templateString)
{
if (!is_string($templateString)) {
throw new Exception('Parse requires a template string as argument, ' . gettype($templateString) . ' given.', 1224237899);
}
$this->reset();
$templateString = $this->extractEscapingModifier($templateString);
$templateString = $this->extractNamespaceDefinitions($templateString);
$splitTemplate = $this->splitTemplateAtDynamicTags($templateString);
$parsingState = $this->buildObjectTree($splitTemplate, self::CONTEXT_OUTSIDE_VIEWHELPER_ARGUMENTS);
$variableContainer = $parsingState->getVariableContainer();
if ($variableContainer !== null && $variableContainer->exists('layoutName')) {
$parsingState->setLayoutNameNode($variableContainer->get('layoutName'));
}
return $parsingState;
}
|
[
"public",
"function",
"parse",
"(",
"$",
"templateString",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"templateString",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Parse requires a template string as argument, '",
".",
"gettype",
"(",
"$",
"templateString",
")",
".",
"' given.'",
",",
"1224237899",
")",
";",
"}",
"$",
"this",
"->",
"reset",
"(",
")",
";",
"$",
"templateString",
"=",
"$",
"this",
"->",
"extractEscapingModifier",
"(",
"$",
"templateString",
")",
";",
"$",
"templateString",
"=",
"$",
"this",
"->",
"extractNamespaceDefinitions",
"(",
"$",
"templateString",
")",
";",
"$",
"splitTemplate",
"=",
"$",
"this",
"->",
"splitTemplateAtDynamicTags",
"(",
"$",
"templateString",
")",
";",
"$",
"parsingState",
"=",
"$",
"this",
"->",
"buildObjectTree",
"(",
"$",
"splitTemplate",
",",
"self",
"::",
"CONTEXT_OUTSIDE_VIEWHELPER_ARGUMENTS",
")",
";",
"$",
"variableContainer",
"=",
"$",
"parsingState",
"->",
"getVariableContainer",
"(",
")",
";",
"if",
"(",
"$",
"variableContainer",
"!==",
"null",
"&&",
"$",
"variableContainer",
"->",
"exists",
"(",
"'layoutName'",
")",
")",
"{",
"$",
"parsingState",
"->",
"setLayoutNameNode",
"(",
"$",
"variableContainer",
"->",
"get",
"(",
"'layoutName'",
")",
")",
";",
"}",
"return",
"$",
"parsingState",
";",
"}"
] |
Parses a given template string and returns a parsed template object.
The resulting ParsedTemplate can then be rendered by calling evaluate() on it.
Normally, you should use a subclass of AbstractTemplateView instead of calling the
TemplateParser directly.
@param string $templateString The template to parse as a string
@return ParsingState Parsed template
@throws Exception
|
[
"Parses",
"a",
"given",
"template",
"string",
"and",
"returns",
"a",
"parsed",
"template",
"object",
"."
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/Parser/TemplateParser.php#L362-L381
|
221,457
|
neos/fluid
|
Classes/TYPO3/Fluid/Core/Parser/TemplateParser.php
|
TemplateParser.reset
|
protected function reset()
{
$this->escapingEnabled = true;
$this->ignoredNamespaceIdentifierPatterns = array();
$this->namespaces = array(
'f' => 'TYPO3\Fluid\ViewHelpers'
);
$this->emitInitializeNamespaces($this);
}
|
php
|
protected function reset()
{
$this->escapingEnabled = true;
$this->ignoredNamespaceIdentifierPatterns = array();
$this->namespaces = array(
'f' => 'TYPO3\Fluid\ViewHelpers'
);
$this->emitInitializeNamespaces($this);
}
|
[
"protected",
"function",
"reset",
"(",
")",
"{",
"$",
"this",
"->",
"escapingEnabled",
"=",
"true",
";",
"$",
"this",
"->",
"ignoredNamespaceIdentifierPatterns",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"namespaces",
"=",
"array",
"(",
"'f'",
"=>",
"'TYPO3\\Fluid\\ViewHelpers'",
")",
";",
"$",
"this",
"->",
"emitInitializeNamespaces",
"(",
"$",
"this",
")",
";",
"}"
] |
Resets the parser to its default values.
@return void
|
[
"Resets",
"the",
"parser",
"to",
"its",
"default",
"values",
"."
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/Parser/TemplateParser.php#L414-L422
|
221,458
|
neos/fluid
|
Classes/TYPO3/Fluid/Core/Parser/TemplateParser.php
|
TemplateParser.buildObjectTree
|
protected function buildObjectTree($splitTemplate, $context)
{
$regularExpression_openingViewHelperTag = self::$SCAN_PATTERN_TEMPLATE_VIEWHELPERTAG;
$regularExpression_closingViewHelperTag = self::$SCAN_PATTERN_TEMPLATE_CLOSINGVIEWHELPERTAG;
/** @var $state ParsingState */
$state = $this->objectManager->get(\TYPO3\Fluid\Core\Parser\ParsingState::class);
/** @var $rootNode RootNode */
$rootNode = $this->objectManager->get(\TYPO3\Fluid\Core\Parser\SyntaxTree\RootNode::class);
$state->setRootNode($rootNode);
$state->pushNodeToStack($rootNode);
foreach ($splitTemplate as $templateElement) {
$matchedVariables = array();
if (preg_match(self::$SCAN_PATTERN_CDATA, $templateElement, $matchedVariables) > 0) {
$this->textHandler($state, $matchedVariables[1]);
continue;
} elseif (preg_match($regularExpression_openingViewHelperTag, $templateElement, $matchedVariables) > 0) {
$viewHelperWasOpened = $this->openingViewHelperTagHandler($state, $matchedVariables['NamespaceIdentifier'], $matchedVariables['MethodIdentifier'], $matchedVariables['Attributes'], ($matchedVariables['Selfclosing'] === '' ? false : true));
if ($viewHelperWasOpened === true) {
continue;
}
} elseif (preg_match($regularExpression_closingViewHelperTag, $templateElement, $matchedVariables) > 0) {
$viewHelperWasClosed = $this->closingViewHelperTagHandler($state, $matchedVariables['NamespaceIdentifier'], $matchedVariables['MethodIdentifier']);
if ($viewHelperWasClosed === true) {
continue;
}
}
$this->textAndShorthandSyntaxHandler($state, $templateElement, $context);
}
if ($state->countNodeStack() !== 1) {
throw new Exception('Not all tags were closed!', 1238169398);
}
return $state;
}
|
php
|
protected function buildObjectTree($splitTemplate, $context)
{
$regularExpression_openingViewHelperTag = self::$SCAN_PATTERN_TEMPLATE_VIEWHELPERTAG;
$regularExpression_closingViewHelperTag = self::$SCAN_PATTERN_TEMPLATE_CLOSINGVIEWHELPERTAG;
/** @var $state ParsingState */
$state = $this->objectManager->get(\TYPO3\Fluid\Core\Parser\ParsingState::class);
/** @var $rootNode RootNode */
$rootNode = $this->objectManager->get(\TYPO3\Fluid\Core\Parser\SyntaxTree\RootNode::class);
$state->setRootNode($rootNode);
$state->pushNodeToStack($rootNode);
foreach ($splitTemplate as $templateElement) {
$matchedVariables = array();
if (preg_match(self::$SCAN_PATTERN_CDATA, $templateElement, $matchedVariables) > 0) {
$this->textHandler($state, $matchedVariables[1]);
continue;
} elseif (preg_match($regularExpression_openingViewHelperTag, $templateElement, $matchedVariables) > 0) {
$viewHelperWasOpened = $this->openingViewHelperTagHandler($state, $matchedVariables['NamespaceIdentifier'], $matchedVariables['MethodIdentifier'], $matchedVariables['Attributes'], ($matchedVariables['Selfclosing'] === '' ? false : true));
if ($viewHelperWasOpened === true) {
continue;
}
} elseif (preg_match($regularExpression_closingViewHelperTag, $templateElement, $matchedVariables) > 0) {
$viewHelperWasClosed = $this->closingViewHelperTagHandler($state, $matchedVariables['NamespaceIdentifier'], $matchedVariables['MethodIdentifier']);
if ($viewHelperWasClosed === true) {
continue;
}
}
$this->textAndShorthandSyntaxHandler($state, $templateElement, $context);
}
if ($state->countNodeStack() !== 1) {
throw new Exception('Not all tags were closed!', 1238169398);
}
return $state;
}
|
[
"protected",
"function",
"buildObjectTree",
"(",
"$",
"splitTemplate",
",",
"$",
"context",
")",
"{",
"$",
"regularExpression_openingViewHelperTag",
"=",
"self",
"::",
"$",
"SCAN_PATTERN_TEMPLATE_VIEWHELPERTAG",
";",
"$",
"regularExpression_closingViewHelperTag",
"=",
"self",
"::",
"$",
"SCAN_PATTERN_TEMPLATE_CLOSINGVIEWHELPERTAG",
";",
"/** @var $state ParsingState */",
"$",
"state",
"=",
"$",
"this",
"->",
"objectManager",
"->",
"get",
"(",
"\\",
"TYPO3",
"\\",
"Fluid",
"\\",
"Core",
"\\",
"Parser",
"\\",
"ParsingState",
"::",
"class",
")",
";",
"/** @var $rootNode RootNode */",
"$",
"rootNode",
"=",
"$",
"this",
"->",
"objectManager",
"->",
"get",
"(",
"\\",
"TYPO3",
"\\",
"Fluid",
"\\",
"Core",
"\\",
"Parser",
"\\",
"SyntaxTree",
"\\",
"RootNode",
"::",
"class",
")",
";",
"$",
"state",
"->",
"setRootNode",
"(",
"$",
"rootNode",
")",
";",
"$",
"state",
"->",
"pushNodeToStack",
"(",
"$",
"rootNode",
")",
";",
"foreach",
"(",
"$",
"splitTemplate",
"as",
"$",
"templateElement",
")",
"{",
"$",
"matchedVariables",
"=",
"array",
"(",
")",
";",
"if",
"(",
"preg_match",
"(",
"self",
"::",
"$",
"SCAN_PATTERN_CDATA",
",",
"$",
"templateElement",
",",
"$",
"matchedVariables",
")",
">",
"0",
")",
"{",
"$",
"this",
"->",
"textHandler",
"(",
"$",
"state",
",",
"$",
"matchedVariables",
"[",
"1",
"]",
")",
";",
"continue",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"$",
"regularExpression_openingViewHelperTag",
",",
"$",
"templateElement",
",",
"$",
"matchedVariables",
")",
">",
"0",
")",
"{",
"$",
"viewHelperWasOpened",
"=",
"$",
"this",
"->",
"openingViewHelperTagHandler",
"(",
"$",
"state",
",",
"$",
"matchedVariables",
"[",
"'NamespaceIdentifier'",
"]",
",",
"$",
"matchedVariables",
"[",
"'MethodIdentifier'",
"]",
",",
"$",
"matchedVariables",
"[",
"'Attributes'",
"]",
",",
"(",
"$",
"matchedVariables",
"[",
"'Selfclosing'",
"]",
"===",
"''",
"?",
"false",
":",
"true",
")",
")",
";",
"if",
"(",
"$",
"viewHelperWasOpened",
"===",
"true",
")",
"{",
"continue",
";",
"}",
"}",
"elseif",
"(",
"preg_match",
"(",
"$",
"regularExpression_closingViewHelperTag",
",",
"$",
"templateElement",
",",
"$",
"matchedVariables",
")",
">",
"0",
")",
"{",
"$",
"viewHelperWasClosed",
"=",
"$",
"this",
"->",
"closingViewHelperTagHandler",
"(",
"$",
"state",
",",
"$",
"matchedVariables",
"[",
"'NamespaceIdentifier'",
"]",
",",
"$",
"matchedVariables",
"[",
"'MethodIdentifier'",
"]",
")",
";",
"if",
"(",
"$",
"viewHelperWasClosed",
"===",
"true",
")",
"{",
"continue",
";",
"}",
"}",
"$",
"this",
"->",
"textAndShorthandSyntaxHandler",
"(",
"$",
"state",
",",
"$",
"templateElement",
",",
"$",
"context",
")",
";",
"}",
"if",
"(",
"$",
"state",
"->",
"countNodeStack",
"(",
")",
"!==",
"1",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Not all tags were closed!'",
",",
"1238169398",
")",
";",
"}",
"return",
"$",
"state",
";",
"}"
] |
Build object tree from the split template
@param array $splitTemplate The split template, so that every tag with a namespace declaration is already a seperate array element.
@param integer $context one of the CONTEXT_* constants, defining whether we are inside or outside of ViewHelper arguments currently.
@return ParsingState
@throws Exception
|
[
"Build",
"object",
"tree",
"from",
"the",
"split",
"template"
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/Parser/TemplateParser.php#L517-L553
|
221,459
|
neos/fluid
|
Classes/TYPO3/Fluid/Core/Parser/TemplateParser.php
|
TemplateParser.openingViewHelperTagHandler
|
protected function openingViewHelperTagHandler(ParsingState $state, $namespaceIdentifier, $methodIdentifier, $arguments, $selfclosing)
{
$argumentsObjectTree = $this->parseArguments($arguments);
$viewHelperWasOpened = $this->initializeViewHelperAndAddItToStack($state, $namespaceIdentifier, $methodIdentifier, $argumentsObjectTree);
if ($viewHelperWasOpened === true && $selfclosing === true) {
$node = $state->popNodeFromStack();
$this->callInterceptor($node, InterceptorInterface::INTERCEPT_CLOSING_VIEWHELPER, $state);
// This needs to be called here because closingViewHelperTagHandler() is not triggered for self-closing tags
$state->getNodeFromStack()->addChildNode($node);
}
return $viewHelperWasOpened;
}
|
php
|
protected function openingViewHelperTagHandler(ParsingState $state, $namespaceIdentifier, $methodIdentifier, $arguments, $selfclosing)
{
$argumentsObjectTree = $this->parseArguments($arguments);
$viewHelperWasOpened = $this->initializeViewHelperAndAddItToStack($state, $namespaceIdentifier, $methodIdentifier, $argumentsObjectTree);
if ($viewHelperWasOpened === true && $selfclosing === true) {
$node = $state->popNodeFromStack();
$this->callInterceptor($node, InterceptorInterface::INTERCEPT_CLOSING_VIEWHELPER, $state);
// This needs to be called here because closingViewHelperTagHandler() is not triggered for self-closing tags
$state->getNodeFromStack()->addChildNode($node);
}
return $viewHelperWasOpened;
}
|
[
"protected",
"function",
"openingViewHelperTagHandler",
"(",
"ParsingState",
"$",
"state",
",",
"$",
"namespaceIdentifier",
",",
"$",
"methodIdentifier",
",",
"$",
"arguments",
",",
"$",
"selfclosing",
")",
"{",
"$",
"argumentsObjectTree",
"=",
"$",
"this",
"->",
"parseArguments",
"(",
"$",
"arguments",
")",
";",
"$",
"viewHelperWasOpened",
"=",
"$",
"this",
"->",
"initializeViewHelperAndAddItToStack",
"(",
"$",
"state",
",",
"$",
"namespaceIdentifier",
",",
"$",
"methodIdentifier",
",",
"$",
"argumentsObjectTree",
")",
";",
"if",
"(",
"$",
"viewHelperWasOpened",
"===",
"true",
"&&",
"$",
"selfclosing",
"===",
"true",
")",
"{",
"$",
"node",
"=",
"$",
"state",
"->",
"popNodeFromStack",
"(",
")",
";",
"$",
"this",
"->",
"callInterceptor",
"(",
"$",
"node",
",",
"InterceptorInterface",
"::",
"INTERCEPT_CLOSING_VIEWHELPER",
",",
"$",
"state",
")",
";",
"// This needs to be called here because closingViewHelperTagHandler() is not triggered for self-closing tags",
"$",
"state",
"->",
"getNodeFromStack",
"(",
")",
"->",
"addChildNode",
"(",
"$",
"node",
")",
";",
"}",
"return",
"$",
"viewHelperWasOpened",
";",
"}"
] |
Handles an opening or self-closing view helper tag.
@param ParsingState $state Current parsing state
@param string $namespaceIdentifier Namespace identifier - being looked up in $this->namespaces
@param string $methodIdentifier Method identifier
@param string $arguments Arguments string, not yet parsed
@param boolean $selfclosing true, if the tag is a self-closing tag.
@return boolean
|
[
"Handles",
"an",
"opening",
"or",
"self",
"-",
"closing",
"view",
"helper",
"tag",
"."
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/Parser/TemplateParser.php#L565-L578
|
221,460
|
neos/fluid
|
Classes/TYPO3/Fluid/Core/Parser/TemplateParser.php
|
TemplateParser.initializeViewHelperAndAddItToStack
|
protected function initializeViewHelperAndAddItToStack(ParsingState $state, $namespaceIdentifier, $methodIdentifier, $argumentsObjectTree)
{
if ($this->isNamespaceValid($namespaceIdentifier, $methodIdentifier) === false) {
return false;
}
$resolvedViewHelperClassName = $this->resolveViewHelperName($namespaceIdentifier, $methodIdentifier);
$actualViewHelperClassName = $this->objectManager->getCaseSensitiveObjectName($resolvedViewHelperClassName);
if ($actualViewHelperClassName === false) {
throw new Exception(sprintf(
'The ViewHelper "<%s:%s>" could not be resolved.' . chr(10) .
'Based on your spelling, the system would load the class "%s", however this class does not exist.',
$namespaceIdentifier, $methodIdentifier, $resolvedViewHelperClassName), 1407060572);
} elseif ($actualViewHelperClassName !== $resolvedViewHelperClassName) {
throw new Exception(sprintf(
'The ViewHelper "<%s:%s>" inside your template is not written correctly upper/lowercased.' . chr(10) .
'Based on your spelling, the system would load the (non-existant) class "%s", however the real class name is "%s".' . chr(10) .
'This error can be fixed by making sure the ViewHelper is written in the correct upper/lowercase form.',
$namespaceIdentifier, $methodIdentifier, $resolvedViewHelperClassName, $actualViewHelperClassName), 1407060573);
}
$viewHelper = $this->objectManager->get($actualViewHelperClassName);
// The following three checks are only done *in an uncached template*, and not needed anymore in the cached version
$expectedViewHelperArguments = $viewHelper->prepareArguments();
$this->abortIfUnregisteredArgumentsExist($expectedViewHelperArguments, $argumentsObjectTree);
$this->abortIfRequiredArgumentsAreMissing($expectedViewHelperArguments, $argumentsObjectTree);
$this->rewriteBooleanNodesInArgumentsObjectTree($expectedViewHelperArguments, $argumentsObjectTree);
/** @var $currentViewHelperNode ViewHelperNode */
$currentViewHelperNode = $this->objectManager->get(\TYPO3\Fluid\Core\Parser\SyntaxTree\ViewHelperNode::class, $viewHelper, $argumentsObjectTree);
$this->callInterceptor($currentViewHelperNode, InterceptorInterface::INTERCEPT_OPENING_VIEWHELPER, $state);
if ($viewHelper instanceof ChildNodeAccessInterface && !($viewHelper instanceof CompilableInterface)) {
$state->setCompilable(false);
}
// PostParse Facet
if ($viewHelper instanceof PostParseInterface) {
// Don't just use $viewHelper::postParseEvent(...),
// as this will break with PHP < 5.3.
call_user_func(array($viewHelper, 'postParseEvent'), $currentViewHelperNode, $argumentsObjectTree, $state->getVariableContainer());
}
$state->pushNodeToStack($currentViewHelperNode);
return true;
}
|
php
|
protected function initializeViewHelperAndAddItToStack(ParsingState $state, $namespaceIdentifier, $methodIdentifier, $argumentsObjectTree)
{
if ($this->isNamespaceValid($namespaceIdentifier, $methodIdentifier) === false) {
return false;
}
$resolvedViewHelperClassName = $this->resolveViewHelperName($namespaceIdentifier, $methodIdentifier);
$actualViewHelperClassName = $this->objectManager->getCaseSensitiveObjectName($resolvedViewHelperClassName);
if ($actualViewHelperClassName === false) {
throw new Exception(sprintf(
'The ViewHelper "<%s:%s>" could not be resolved.' . chr(10) .
'Based on your spelling, the system would load the class "%s", however this class does not exist.',
$namespaceIdentifier, $methodIdentifier, $resolvedViewHelperClassName), 1407060572);
} elseif ($actualViewHelperClassName !== $resolvedViewHelperClassName) {
throw new Exception(sprintf(
'The ViewHelper "<%s:%s>" inside your template is not written correctly upper/lowercased.' . chr(10) .
'Based on your spelling, the system would load the (non-existant) class "%s", however the real class name is "%s".' . chr(10) .
'This error can be fixed by making sure the ViewHelper is written in the correct upper/lowercase form.',
$namespaceIdentifier, $methodIdentifier, $resolvedViewHelperClassName, $actualViewHelperClassName), 1407060573);
}
$viewHelper = $this->objectManager->get($actualViewHelperClassName);
// The following three checks are only done *in an uncached template*, and not needed anymore in the cached version
$expectedViewHelperArguments = $viewHelper->prepareArguments();
$this->abortIfUnregisteredArgumentsExist($expectedViewHelperArguments, $argumentsObjectTree);
$this->abortIfRequiredArgumentsAreMissing($expectedViewHelperArguments, $argumentsObjectTree);
$this->rewriteBooleanNodesInArgumentsObjectTree($expectedViewHelperArguments, $argumentsObjectTree);
/** @var $currentViewHelperNode ViewHelperNode */
$currentViewHelperNode = $this->objectManager->get(\TYPO3\Fluid\Core\Parser\SyntaxTree\ViewHelperNode::class, $viewHelper, $argumentsObjectTree);
$this->callInterceptor($currentViewHelperNode, InterceptorInterface::INTERCEPT_OPENING_VIEWHELPER, $state);
if ($viewHelper instanceof ChildNodeAccessInterface && !($viewHelper instanceof CompilableInterface)) {
$state->setCompilable(false);
}
// PostParse Facet
if ($viewHelper instanceof PostParseInterface) {
// Don't just use $viewHelper::postParseEvent(...),
// as this will break with PHP < 5.3.
call_user_func(array($viewHelper, 'postParseEvent'), $currentViewHelperNode, $argumentsObjectTree, $state->getVariableContainer());
}
$state->pushNodeToStack($currentViewHelperNode);
return true;
}
|
[
"protected",
"function",
"initializeViewHelperAndAddItToStack",
"(",
"ParsingState",
"$",
"state",
",",
"$",
"namespaceIdentifier",
",",
"$",
"methodIdentifier",
",",
"$",
"argumentsObjectTree",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isNamespaceValid",
"(",
"$",
"namespaceIdentifier",
",",
"$",
"methodIdentifier",
")",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"$",
"resolvedViewHelperClassName",
"=",
"$",
"this",
"->",
"resolveViewHelperName",
"(",
"$",
"namespaceIdentifier",
",",
"$",
"methodIdentifier",
")",
";",
"$",
"actualViewHelperClassName",
"=",
"$",
"this",
"->",
"objectManager",
"->",
"getCaseSensitiveObjectName",
"(",
"$",
"resolvedViewHelperClassName",
")",
";",
"if",
"(",
"$",
"actualViewHelperClassName",
"===",
"false",
")",
"{",
"throw",
"new",
"Exception",
"(",
"sprintf",
"(",
"'The ViewHelper \"<%s:%s>\" could not be resolved.'",
".",
"chr",
"(",
"10",
")",
".",
"'Based on your spelling, the system would load the class \"%s\", however this class does not exist.'",
",",
"$",
"namespaceIdentifier",
",",
"$",
"methodIdentifier",
",",
"$",
"resolvedViewHelperClassName",
")",
",",
"1407060572",
")",
";",
"}",
"elseif",
"(",
"$",
"actualViewHelperClassName",
"!==",
"$",
"resolvedViewHelperClassName",
")",
"{",
"throw",
"new",
"Exception",
"(",
"sprintf",
"(",
"'The ViewHelper \"<%s:%s>\" inside your template is not written correctly upper/lowercased.'",
".",
"chr",
"(",
"10",
")",
".",
"'Based on your spelling, the system would load the (non-existant) class \"%s\", however the real class name is \"%s\".'",
".",
"chr",
"(",
"10",
")",
".",
"'This error can be fixed by making sure the ViewHelper is written in the correct upper/lowercase form.'",
",",
"$",
"namespaceIdentifier",
",",
"$",
"methodIdentifier",
",",
"$",
"resolvedViewHelperClassName",
",",
"$",
"actualViewHelperClassName",
")",
",",
"1407060573",
")",
";",
"}",
"$",
"viewHelper",
"=",
"$",
"this",
"->",
"objectManager",
"->",
"get",
"(",
"$",
"actualViewHelperClassName",
")",
";",
"// The following three checks are only done *in an uncached template*, and not needed anymore in the cached version",
"$",
"expectedViewHelperArguments",
"=",
"$",
"viewHelper",
"->",
"prepareArguments",
"(",
")",
";",
"$",
"this",
"->",
"abortIfUnregisteredArgumentsExist",
"(",
"$",
"expectedViewHelperArguments",
",",
"$",
"argumentsObjectTree",
")",
";",
"$",
"this",
"->",
"abortIfRequiredArgumentsAreMissing",
"(",
"$",
"expectedViewHelperArguments",
",",
"$",
"argumentsObjectTree",
")",
";",
"$",
"this",
"->",
"rewriteBooleanNodesInArgumentsObjectTree",
"(",
"$",
"expectedViewHelperArguments",
",",
"$",
"argumentsObjectTree",
")",
";",
"/** @var $currentViewHelperNode ViewHelperNode */",
"$",
"currentViewHelperNode",
"=",
"$",
"this",
"->",
"objectManager",
"->",
"get",
"(",
"\\",
"TYPO3",
"\\",
"Fluid",
"\\",
"Core",
"\\",
"Parser",
"\\",
"SyntaxTree",
"\\",
"ViewHelperNode",
"::",
"class",
",",
"$",
"viewHelper",
",",
"$",
"argumentsObjectTree",
")",
";",
"$",
"this",
"->",
"callInterceptor",
"(",
"$",
"currentViewHelperNode",
",",
"InterceptorInterface",
"::",
"INTERCEPT_OPENING_VIEWHELPER",
",",
"$",
"state",
")",
";",
"if",
"(",
"$",
"viewHelper",
"instanceof",
"ChildNodeAccessInterface",
"&&",
"!",
"(",
"$",
"viewHelper",
"instanceof",
"CompilableInterface",
")",
")",
"{",
"$",
"state",
"->",
"setCompilable",
"(",
"false",
")",
";",
"}",
"// PostParse Facet",
"if",
"(",
"$",
"viewHelper",
"instanceof",
"PostParseInterface",
")",
"{",
"// Don't just use $viewHelper::postParseEvent(...),",
"// as this will break with PHP < 5.3.",
"call_user_func",
"(",
"array",
"(",
"$",
"viewHelper",
",",
"'postParseEvent'",
")",
",",
"$",
"currentViewHelperNode",
",",
"$",
"argumentsObjectTree",
",",
"$",
"state",
"->",
"getVariableContainer",
"(",
")",
")",
";",
"}",
"$",
"state",
"->",
"pushNodeToStack",
"(",
"$",
"currentViewHelperNode",
")",
";",
"return",
"true",
";",
"}"
] |
Initialize the given ViewHelper and adds it to the current node and to
the stack.
@param ParsingState $state Current parsing state
@param string $namespaceIdentifier Namespace identifier - being looked up in $this->namespaces
@param string $methodIdentifier Method identifier
@param array $argumentsObjectTree Arguments object tree
@return boolean whether the viewHelper was found and added to the stack or not
@throws Exception
|
[
"Initialize",
"the",
"given",
"ViewHelper",
"and",
"adds",
"it",
"to",
"the",
"current",
"node",
"and",
"to",
"the",
"stack",
"."
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/Parser/TemplateParser.php#L591-L637
|
221,461
|
neos/fluid
|
Classes/TYPO3/Fluid/Core/Parser/TemplateParser.php
|
TemplateParser.abortIfUnregisteredArgumentsExist
|
protected function abortIfUnregisteredArgumentsExist($expectedArguments, $actualArguments)
{
$expectedArgumentNames = array();
/** @var $expectedArgument ArgumentDefinition */
foreach ($expectedArguments as $expectedArgument) {
$expectedArgumentNames[] = $expectedArgument->getName();
}
foreach (array_keys($actualArguments) as $argumentName) {
if (!in_array($argumentName, $expectedArgumentNames)) {
throw new Exception('Argument "' . $argumentName . '" was not registered.', 1237823695);
}
}
}
|
php
|
protected function abortIfUnregisteredArgumentsExist($expectedArguments, $actualArguments)
{
$expectedArgumentNames = array();
/** @var $expectedArgument ArgumentDefinition */
foreach ($expectedArguments as $expectedArgument) {
$expectedArgumentNames[] = $expectedArgument->getName();
}
foreach (array_keys($actualArguments) as $argumentName) {
if (!in_array($argumentName, $expectedArgumentNames)) {
throw new Exception('Argument "' . $argumentName . '" was not registered.', 1237823695);
}
}
}
|
[
"protected",
"function",
"abortIfUnregisteredArgumentsExist",
"(",
"$",
"expectedArguments",
",",
"$",
"actualArguments",
")",
"{",
"$",
"expectedArgumentNames",
"=",
"array",
"(",
")",
";",
"/** @var $expectedArgument ArgumentDefinition */",
"foreach",
"(",
"$",
"expectedArguments",
"as",
"$",
"expectedArgument",
")",
"{",
"$",
"expectedArgumentNames",
"[",
"]",
"=",
"$",
"expectedArgument",
"->",
"getName",
"(",
")",
";",
"}",
"foreach",
"(",
"array_keys",
"(",
"$",
"actualArguments",
")",
"as",
"$",
"argumentName",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"argumentName",
",",
"$",
"expectedArgumentNames",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Argument \"'",
".",
"$",
"argumentName",
".",
"'\" was not registered.'",
",",
"1237823695",
")",
";",
"}",
"}",
"}"
] |
Throw an exception if there are arguments which were not registered
before.
@param array $expectedArguments Array of \TYPO3\Fluid\Core\ViewHelper\ArgumentDefinition of all expected arguments
@param array $actualArguments Actual arguments
@throws Exception
|
[
"Throw",
"an",
"exception",
"if",
"there",
"are",
"arguments",
"which",
"were",
"not",
"registered",
"before",
"."
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/Parser/TemplateParser.php#L647-L660
|
221,462
|
neos/fluid
|
Classes/TYPO3/Fluid/Core/Parser/TemplateParser.php
|
TemplateParser.abortIfRequiredArgumentsAreMissing
|
protected function abortIfRequiredArgumentsAreMissing($expectedArguments, $actualArguments)
{
$actualArgumentNames = array_keys($actualArguments);
/** @var $expectedArgument ArgumentDefinition */
foreach ($expectedArguments as $expectedArgument) {
if ($expectedArgument->isRequired() && !in_array($expectedArgument->getName(), $actualArgumentNames)) {
throw new Exception('Required argument "' . $expectedArgument->getName() . '" was not supplied.', 1237823699);
}
}
}
|
php
|
protected function abortIfRequiredArgumentsAreMissing($expectedArguments, $actualArguments)
{
$actualArgumentNames = array_keys($actualArguments);
/** @var $expectedArgument ArgumentDefinition */
foreach ($expectedArguments as $expectedArgument) {
if ($expectedArgument->isRequired() && !in_array($expectedArgument->getName(), $actualArgumentNames)) {
throw new Exception('Required argument "' . $expectedArgument->getName() . '" was not supplied.', 1237823699);
}
}
}
|
[
"protected",
"function",
"abortIfRequiredArgumentsAreMissing",
"(",
"$",
"expectedArguments",
",",
"$",
"actualArguments",
")",
"{",
"$",
"actualArgumentNames",
"=",
"array_keys",
"(",
"$",
"actualArguments",
")",
";",
"/** @var $expectedArgument ArgumentDefinition */",
"foreach",
"(",
"$",
"expectedArguments",
"as",
"$",
"expectedArgument",
")",
"{",
"if",
"(",
"$",
"expectedArgument",
"->",
"isRequired",
"(",
")",
"&&",
"!",
"in_array",
"(",
"$",
"expectedArgument",
"->",
"getName",
"(",
")",
",",
"$",
"actualArgumentNames",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Required argument \"'",
".",
"$",
"expectedArgument",
"->",
"getName",
"(",
")",
".",
"'\" was not supplied.'",
",",
"1237823699",
")",
";",
"}",
"}",
"}"
] |
Throw an exception if required arguments are missing
@param array $expectedArguments Array of \TYPO3\Fluid\Core\ViewHelper\ArgumentDefinition of all expected arguments
@param array $actualArguments Actual arguments
@throws Exception
|
[
"Throw",
"an",
"exception",
"if",
"required",
"arguments",
"are",
"missing"
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/Parser/TemplateParser.php#L669-L678
|
221,463
|
neos/fluid
|
Classes/TYPO3/Fluid/Core/Parser/TemplateParser.php
|
TemplateParser.rewriteBooleanNodesInArgumentsObjectTree
|
protected function rewriteBooleanNodesInArgumentsObjectTree($argumentDefinitions, &$argumentsObjectTree)
{
/** @var $argumentDefinition ArgumentDefinition */
foreach ($argumentDefinitions as $argumentName => $argumentDefinition) {
if ($argumentDefinition->getType() === 'boolean' && isset($argumentsObjectTree[$argumentName])) {
$argumentsObjectTree[$argumentName] = new BooleanNode($argumentsObjectTree[$argumentName]);
}
}
}
|
php
|
protected function rewriteBooleanNodesInArgumentsObjectTree($argumentDefinitions, &$argumentsObjectTree)
{
/** @var $argumentDefinition ArgumentDefinition */
foreach ($argumentDefinitions as $argumentName => $argumentDefinition) {
if ($argumentDefinition->getType() === 'boolean' && isset($argumentsObjectTree[$argumentName])) {
$argumentsObjectTree[$argumentName] = new BooleanNode($argumentsObjectTree[$argumentName]);
}
}
}
|
[
"protected",
"function",
"rewriteBooleanNodesInArgumentsObjectTree",
"(",
"$",
"argumentDefinitions",
",",
"&",
"$",
"argumentsObjectTree",
")",
"{",
"/** @var $argumentDefinition ArgumentDefinition */",
"foreach",
"(",
"$",
"argumentDefinitions",
"as",
"$",
"argumentName",
"=>",
"$",
"argumentDefinition",
")",
"{",
"if",
"(",
"$",
"argumentDefinition",
"->",
"getType",
"(",
")",
"===",
"'boolean'",
"&&",
"isset",
"(",
"$",
"argumentsObjectTree",
"[",
"$",
"argumentName",
"]",
")",
")",
"{",
"$",
"argumentsObjectTree",
"[",
"$",
"argumentName",
"]",
"=",
"new",
"BooleanNode",
"(",
"$",
"argumentsObjectTree",
"[",
"$",
"argumentName",
"]",
")",
";",
"}",
"}",
"}"
] |
Wraps the argument tree, if a node is boolean, into a Boolean syntax tree node
@param array $argumentDefinitions the argument definitions, key is the argument name, value is the ArgumentDefinition object
@param array $argumentsObjectTree the arguments syntax tree, key is the argument name, value is an AbstractNode
@return void
|
[
"Wraps",
"the",
"argument",
"tree",
"if",
"a",
"node",
"is",
"boolean",
"into",
"a",
"Boolean",
"syntax",
"tree",
"node"
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/Parser/TemplateParser.php#L687-L695
|
221,464
|
neos/fluid
|
Classes/TYPO3/Fluid/Core/Parser/TemplateParser.php
|
TemplateParser.resolveViewHelperName
|
protected function resolveViewHelperName($namespaceIdentifier, $methodIdentifier)
{
$explodedViewHelperName = explode('.', $methodIdentifier);
if (count($explodedViewHelperName) > 1) {
$className = implode('\\', array_map('ucfirst', $explodedViewHelperName));
} else {
$className = ucfirst($explodedViewHelperName[0]);
}
$className .= 'ViewHelper';
$name = $this->namespaces[$namespaceIdentifier] . '\\' . $className;
return $name;
}
|
php
|
protected function resolveViewHelperName($namespaceIdentifier, $methodIdentifier)
{
$explodedViewHelperName = explode('.', $methodIdentifier);
if (count($explodedViewHelperName) > 1) {
$className = implode('\\', array_map('ucfirst', $explodedViewHelperName));
} else {
$className = ucfirst($explodedViewHelperName[0]);
}
$className .= 'ViewHelper';
$name = $this->namespaces[$namespaceIdentifier] . '\\' . $className;
return $name;
}
|
[
"protected",
"function",
"resolveViewHelperName",
"(",
"$",
"namespaceIdentifier",
",",
"$",
"methodIdentifier",
")",
"{",
"$",
"explodedViewHelperName",
"=",
"explode",
"(",
"'.'",
",",
"$",
"methodIdentifier",
")",
";",
"if",
"(",
"count",
"(",
"$",
"explodedViewHelperName",
")",
">",
"1",
")",
"{",
"$",
"className",
"=",
"implode",
"(",
"'\\\\'",
",",
"array_map",
"(",
"'ucfirst'",
",",
"$",
"explodedViewHelperName",
")",
")",
";",
"}",
"else",
"{",
"$",
"className",
"=",
"ucfirst",
"(",
"$",
"explodedViewHelperName",
"[",
"0",
"]",
")",
";",
"}",
"$",
"className",
".=",
"'ViewHelper'",
";",
"$",
"name",
"=",
"$",
"this",
"->",
"namespaces",
"[",
"$",
"namespaceIdentifier",
"]",
".",
"'\\\\'",
".",
"$",
"className",
";",
"return",
"$",
"name",
";",
"}"
] |
Resolve a viewhelper name.
@param string $namespaceIdentifier Namespace identifier for the view helper.
@param string $methodIdentifier Method identifier, might be hierarchical like "link.url"
@return string The fully qualified class name of the viewhelper
|
[
"Resolve",
"a",
"viewhelper",
"name",
"."
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/Parser/TemplateParser.php#L704-L717
|
221,465
|
neos/fluid
|
Classes/TYPO3/Fluid/Core/Parser/TemplateParser.php
|
TemplateParser.closingViewHelperTagHandler
|
protected function closingViewHelperTagHandler(ParsingState $state, $namespaceIdentifier, $methodIdentifier)
{
if ($this->isNamespaceValid($namespaceIdentifier, $methodIdentifier) === false) {
return false;
}
$lastStackElement = $state->popNodeFromStack();
if (!($lastStackElement instanceof ViewHelperNode)) {
throw new Exception('You closed a templating tag which you never opened!', 1224485838);
}
if ($lastStackElement->getViewHelperClassName() != $this->resolveViewHelperName($namespaceIdentifier, $methodIdentifier)) {
throw new Exception('Templating tags not properly nested. Expected: ' . $lastStackElement->getViewHelperClassName() . '; Actual: ' . $this->resolveViewHelperName($namespaceIdentifier, $methodIdentifier), 1224485398);
}
$this->callInterceptor($lastStackElement, InterceptorInterface::INTERCEPT_CLOSING_VIEWHELPER, $state);
$state->getNodeFromStack()->addChildNode($lastStackElement);
return true;
}
|
php
|
protected function closingViewHelperTagHandler(ParsingState $state, $namespaceIdentifier, $methodIdentifier)
{
if ($this->isNamespaceValid($namespaceIdentifier, $methodIdentifier) === false) {
return false;
}
$lastStackElement = $state->popNodeFromStack();
if (!($lastStackElement instanceof ViewHelperNode)) {
throw new Exception('You closed a templating tag which you never opened!', 1224485838);
}
if ($lastStackElement->getViewHelperClassName() != $this->resolveViewHelperName($namespaceIdentifier, $methodIdentifier)) {
throw new Exception('Templating tags not properly nested. Expected: ' . $lastStackElement->getViewHelperClassName() . '; Actual: ' . $this->resolveViewHelperName($namespaceIdentifier, $methodIdentifier), 1224485398);
}
$this->callInterceptor($lastStackElement, InterceptorInterface::INTERCEPT_CLOSING_VIEWHELPER, $state);
$state->getNodeFromStack()->addChildNode($lastStackElement);
return true;
}
|
[
"protected",
"function",
"closingViewHelperTagHandler",
"(",
"ParsingState",
"$",
"state",
",",
"$",
"namespaceIdentifier",
",",
"$",
"methodIdentifier",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isNamespaceValid",
"(",
"$",
"namespaceIdentifier",
",",
"$",
"methodIdentifier",
")",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"$",
"lastStackElement",
"=",
"$",
"state",
"->",
"popNodeFromStack",
"(",
")",
";",
"if",
"(",
"!",
"(",
"$",
"lastStackElement",
"instanceof",
"ViewHelperNode",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'You closed a templating tag which you never opened!'",
",",
"1224485838",
")",
";",
"}",
"if",
"(",
"$",
"lastStackElement",
"->",
"getViewHelperClassName",
"(",
")",
"!=",
"$",
"this",
"->",
"resolveViewHelperName",
"(",
"$",
"namespaceIdentifier",
",",
"$",
"methodIdentifier",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Templating tags not properly nested. Expected: '",
".",
"$",
"lastStackElement",
"->",
"getViewHelperClassName",
"(",
")",
".",
"'; Actual: '",
".",
"$",
"this",
"->",
"resolveViewHelperName",
"(",
"$",
"namespaceIdentifier",
",",
"$",
"methodIdentifier",
")",
",",
"1224485398",
")",
";",
"}",
"$",
"this",
"->",
"callInterceptor",
"(",
"$",
"lastStackElement",
",",
"InterceptorInterface",
"::",
"INTERCEPT_CLOSING_VIEWHELPER",
",",
"$",
"state",
")",
";",
"$",
"state",
"->",
"getNodeFromStack",
"(",
")",
"->",
"addChildNode",
"(",
"$",
"lastStackElement",
")",
";",
"return",
"true",
";",
"}"
] |
Handles a closing view helper tag
@param ParsingState $state The current parsing state
@param string $namespaceIdentifier Namespace identifier for the closing tag.
@param string $methodIdentifier Method identifier.
@return boolean whether the viewHelper was found and added to the stack or not
@throws Exception
|
[
"Handles",
"a",
"closing",
"view",
"helper",
"tag"
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/Parser/TemplateParser.php#L728-L745
|
221,466
|
neos/fluid
|
Classes/TYPO3/Fluid/Core/Parser/TemplateParser.php
|
TemplateParser.callInterceptor
|
protected function callInterceptor(NodeInterface &$node, $interceptionPoint, ParsingState $state)
{
if ($this->configuration === null) {
return;
}
if ($this->escapingEnabled) {
/** @var $interceptor InterceptorInterface */
foreach ($this->configuration->getEscapingInterceptors($interceptionPoint) as $interceptor) {
$node = $interceptor->process($node, $interceptionPoint, $state);
}
}
/** @var $interceptor InterceptorInterface */
foreach ($this->configuration->getInterceptors($interceptionPoint) as $interceptor) {
$node = $interceptor->process($node, $interceptionPoint, $state);
}
}
|
php
|
protected function callInterceptor(NodeInterface &$node, $interceptionPoint, ParsingState $state)
{
if ($this->configuration === null) {
return;
}
if ($this->escapingEnabled) {
/** @var $interceptor InterceptorInterface */
foreach ($this->configuration->getEscapingInterceptors($interceptionPoint) as $interceptor) {
$node = $interceptor->process($node, $interceptionPoint, $state);
}
}
/** @var $interceptor InterceptorInterface */
foreach ($this->configuration->getInterceptors($interceptionPoint) as $interceptor) {
$node = $interceptor->process($node, $interceptionPoint, $state);
}
}
|
[
"protected",
"function",
"callInterceptor",
"(",
"NodeInterface",
"&",
"$",
"node",
",",
"$",
"interceptionPoint",
",",
"ParsingState",
"$",
"state",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"configuration",
"===",
"null",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"escapingEnabled",
")",
"{",
"/** @var $interceptor InterceptorInterface */",
"foreach",
"(",
"$",
"this",
"->",
"configuration",
"->",
"getEscapingInterceptors",
"(",
"$",
"interceptionPoint",
")",
"as",
"$",
"interceptor",
")",
"{",
"$",
"node",
"=",
"$",
"interceptor",
"->",
"process",
"(",
"$",
"node",
",",
"$",
"interceptionPoint",
",",
"$",
"state",
")",
";",
"}",
"}",
"/** @var $interceptor InterceptorInterface */",
"foreach",
"(",
"$",
"this",
"->",
"configuration",
"->",
"getInterceptors",
"(",
"$",
"interceptionPoint",
")",
"as",
"$",
"interceptor",
")",
"{",
"$",
"node",
"=",
"$",
"interceptor",
"->",
"process",
"(",
"$",
"node",
",",
"$",
"interceptionPoint",
",",
"$",
"state",
")",
";",
"}",
"}"
] |
Call all interceptors registered for a given interception point.
@param NodeInterface $node The syntax tree node which can be modified by the interceptors.
@param integer $interceptionPoint the interception point. One of the \TYPO3\Fluid\Core\Parser\InterceptorInterface::INTERCEPT_* constants.
@param ParsingState $state the parsing state
@return void
|
[
"Call",
"all",
"interceptors",
"registered",
"for",
"a",
"given",
"interception",
"point",
"."
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/Parser/TemplateParser.php#L815-L831
|
221,467
|
neos/fluid
|
Classes/TYPO3/Fluid/Core/Parser/TemplateParser.php
|
TemplateParser.parseArguments
|
protected function parseArguments($argumentsString)
{
$argumentsObjectTree = array();
$matches = array();
if (preg_match_all(self::$SPLIT_PATTERN_TAGARGUMENTS, $argumentsString, $matches, PREG_SET_ORDER) > 0) {
$escapingEnabledBackup = $this->escapingEnabled;
$this->escapingEnabled = false;
foreach ($matches as $singleMatch) {
$argument = $singleMatch['Argument'];
$value = $this->unquoteString($singleMatch['ValueQuoted']);
$argumentsObjectTree[$argument] = $this->buildArgumentObjectTree($value);
}
$this->escapingEnabled = $escapingEnabledBackup;
}
return $argumentsObjectTree;
}
|
php
|
protected function parseArguments($argumentsString)
{
$argumentsObjectTree = array();
$matches = array();
if (preg_match_all(self::$SPLIT_PATTERN_TAGARGUMENTS, $argumentsString, $matches, PREG_SET_ORDER) > 0) {
$escapingEnabledBackup = $this->escapingEnabled;
$this->escapingEnabled = false;
foreach ($matches as $singleMatch) {
$argument = $singleMatch['Argument'];
$value = $this->unquoteString($singleMatch['ValueQuoted']);
$argumentsObjectTree[$argument] = $this->buildArgumentObjectTree($value);
}
$this->escapingEnabled = $escapingEnabledBackup;
}
return $argumentsObjectTree;
}
|
[
"protected",
"function",
"parseArguments",
"(",
"$",
"argumentsString",
")",
"{",
"$",
"argumentsObjectTree",
"=",
"array",
"(",
")",
";",
"$",
"matches",
"=",
"array",
"(",
")",
";",
"if",
"(",
"preg_match_all",
"(",
"self",
"::",
"$",
"SPLIT_PATTERN_TAGARGUMENTS",
",",
"$",
"argumentsString",
",",
"$",
"matches",
",",
"PREG_SET_ORDER",
")",
">",
"0",
")",
"{",
"$",
"escapingEnabledBackup",
"=",
"$",
"this",
"->",
"escapingEnabled",
";",
"$",
"this",
"->",
"escapingEnabled",
"=",
"false",
";",
"foreach",
"(",
"$",
"matches",
"as",
"$",
"singleMatch",
")",
"{",
"$",
"argument",
"=",
"$",
"singleMatch",
"[",
"'Argument'",
"]",
";",
"$",
"value",
"=",
"$",
"this",
"->",
"unquoteString",
"(",
"$",
"singleMatch",
"[",
"'ValueQuoted'",
"]",
")",
";",
"$",
"argumentsObjectTree",
"[",
"$",
"argument",
"]",
"=",
"$",
"this",
"->",
"buildArgumentObjectTree",
"(",
"$",
"value",
")",
";",
"}",
"$",
"this",
"->",
"escapingEnabled",
"=",
"$",
"escapingEnabledBackup",
";",
"}",
"return",
"$",
"argumentsObjectTree",
";",
"}"
] |
Parse arguments of a given tag, and build up the Arguments Object Tree
for each argument.
Returns an associative array, where the key is the name of the argument,
and the value is a single Argument Object Tree.
@param string $argumentsString All arguments as string
@return array An associative array of objects, where the key is the argument name.
|
[
"Parse",
"arguments",
"of",
"a",
"given",
"tag",
"and",
"build",
"up",
"the",
"Arguments",
"Object",
"Tree",
"for",
"each",
"argument",
".",
"Returns",
"an",
"associative",
"array",
"where",
"the",
"key",
"is",
"the",
"name",
"of",
"the",
"argument",
"and",
"the",
"value",
"is",
"a",
"single",
"Argument",
"Object",
"Tree",
"."
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/Parser/TemplateParser.php#L860-L875
|
221,468
|
neos/fluid
|
Classes/TYPO3/Fluid/Core/Parser/TemplateParser.php
|
TemplateParser.textAndShorthandSyntaxHandler
|
protected function textAndShorthandSyntaxHandler(ParsingState $state, $text, $context)
{
$sections = preg_split(self::$SPLIT_PATTERN_SHORTHANDSYNTAX, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
foreach ($sections as $section) {
$matchedVariables = array();
if (preg_match(self::$SCAN_PATTERN_SHORTHANDSYNTAX_OBJECTACCESSORS, $section, $matchedVariables) > 0) {
$this->objectAccessorHandler($state, $matchedVariables['Object'], $matchedVariables['Delimiter'], (isset($matchedVariables['ViewHelper']) ? $matchedVariables['ViewHelper'] : ''), (isset($matchedVariables['AdditionalViewHelpers']) ? $matchedVariables['AdditionalViewHelpers'] : ''));
} elseif ($context === self::CONTEXT_INSIDE_VIEWHELPER_ARGUMENTS && preg_match(self::$SCAN_PATTERN_SHORTHANDSYNTAX_ARRAYS, $section, $matchedVariables) > 0) {
// We only match arrays if we are INSIDE viewhelper arguments
$this->arrayHandler($state, $matchedVariables['Array']);
} else {
$this->textHandler($state, $section);
}
}
}
|
php
|
protected function textAndShorthandSyntaxHandler(ParsingState $state, $text, $context)
{
$sections = preg_split(self::$SPLIT_PATTERN_SHORTHANDSYNTAX, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
foreach ($sections as $section) {
$matchedVariables = array();
if (preg_match(self::$SCAN_PATTERN_SHORTHANDSYNTAX_OBJECTACCESSORS, $section, $matchedVariables) > 0) {
$this->objectAccessorHandler($state, $matchedVariables['Object'], $matchedVariables['Delimiter'], (isset($matchedVariables['ViewHelper']) ? $matchedVariables['ViewHelper'] : ''), (isset($matchedVariables['AdditionalViewHelpers']) ? $matchedVariables['AdditionalViewHelpers'] : ''));
} elseif ($context === self::CONTEXT_INSIDE_VIEWHELPER_ARGUMENTS && preg_match(self::$SCAN_PATTERN_SHORTHANDSYNTAX_ARRAYS, $section, $matchedVariables) > 0) {
// We only match arrays if we are INSIDE viewhelper arguments
$this->arrayHandler($state, $matchedVariables['Array']);
} else {
$this->textHandler($state, $section);
}
}
}
|
[
"protected",
"function",
"textAndShorthandSyntaxHandler",
"(",
"ParsingState",
"$",
"state",
",",
"$",
"text",
",",
"$",
"context",
")",
"{",
"$",
"sections",
"=",
"preg_split",
"(",
"self",
"::",
"$",
"SPLIT_PATTERN_SHORTHANDSYNTAX",
",",
"$",
"text",
",",
"-",
"1",
",",
"PREG_SPLIT_DELIM_CAPTURE",
"|",
"PREG_SPLIT_NO_EMPTY",
")",
";",
"foreach",
"(",
"$",
"sections",
"as",
"$",
"section",
")",
"{",
"$",
"matchedVariables",
"=",
"array",
"(",
")",
";",
"if",
"(",
"preg_match",
"(",
"self",
"::",
"$",
"SCAN_PATTERN_SHORTHANDSYNTAX_OBJECTACCESSORS",
",",
"$",
"section",
",",
"$",
"matchedVariables",
")",
">",
"0",
")",
"{",
"$",
"this",
"->",
"objectAccessorHandler",
"(",
"$",
"state",
",",
"$",
"matchedVariables",
"[",
"'Object'",
"]",
",",
"$",
"matchedVariables",
"[",
"'Delimiter'",
"]",
",",
"(",
"isset",
"(",
"$",
"matchedVariables",
"[",
"'ViewHelper'",
"]",
")",
"?",
"$",
"matchedVariables",
"[",
"'ViewHelper'",
"]",
":",
"''",
")",
",",
"(",
"isset",
"(",
"$",
"matchedVariables",
"[",
"'AdditionalViewHelpers'",
"]",
")",
"?",
"$",
"matchedVariables",
"[",
"'AdditionalViewHelpers'",
"]",
":",
"''",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"context",
"===",
"self",
"::",
"CONTEXT_INSIDE_VIEWHELPER_ARGUMENTS",
"&&",
"preg_match",
"(",
"self",
"::",
"$",
"SCAN_PATTERN_SHORTHANDSYNTAX_ARRAYS",
",",
"$",
"section",
",",
"$",
"matchedVariables",
")",
">",
"0",
")",
"{",
"// We only match arrays if we are INSIDE viewhelper arguments",
"$",
"this",
"->",
"arrayHandler",
"(",
"$",
"state",
",",
"$",
"matchedVariables",
"[",
"'Array'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"textHandler",
"(",
"$",
"state",
",",
"$",
"section",
")",
";",
"}",
"}",
"}"
] |
Handler for everything which is not a ViewHelperNode.
This includes Text, array syntax, and object accessor syntax.
@param ParsingState $state Current parsing state
@param string $text Text to process
@param integer $context one of the CONTEXT_* constants, defining whether we are inside or outside of ViewHelper arguments currently.
@return void
|
[
"Handler",
"for",
"everything",
"which",
"is",
"not",
"a",
"ViewHelperNode",
"."
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/Parser/TemplateParser.php#L931-L946
|
221,469
|
neos/fluid
|
Classes/TYPO3/Fluid/Core/Parser/TemplateParser.php
|
TemplateParser.arrayHandler
|
protected function arrayHandler(ParsingState $state, $arrayText)
{
/** @var $arrayNode ArrayNode */
$arrayNode = $this->objectManager->get(\TYPO3\Fluid\Core\Parser\SyntaxTree\ArrayNode::class, $this->recursiveArrayHandler($arrayText));
$state->getNodeFromStack()->addChildNode($arrayNode);
}
|
php
|
protected function arrayHandler(ParsingState $state, $arrayText)
{
/** @var $arrayNode ArrayNode */
$arrayNode = $this->objectManager->get(\TYPO3\Fluid\Core\Parser\SyntaxTree\ArrayNode::class, $this->recursiveArrayHandler($arrayText));
$state->getNodeFromStack()->addChildNode($arrayNode);
}
|
[
"protected",
"function",
"arrayHandler",
"(",
"ParsingState",
"$",
"state",
",",
"$",
"arrayText",
")",
"{",
"/** @var $arrayNode ArrayNode */",
"$",
"arrayNode",
"=",
"$",
"this",
"->",
"objectManager",
"->",
"get",
"(",
"\\",
"TYPO3",
"\\",
"Fluid",
"\\",
"Core",
"\\",
"Parser",
"\\",
"SyntaxTree",
"\\",
"ArrayNode",
"::",
"class",
",",
"$",
"this",
"->",
"recursiveArrayHandler",
"(",
"$",
"arrayText",
")",
")",
";",
"$",
"state",
"->",
"getNodeFromStack",
"(",
")",
"->",
"addChildNode",
"(",
"$",
"arrayNode",
")",
";",
"}"
] |
Handler for array syntax. This creates the array object recursively and
adds it to the current node.
@param ParsingState $state The current parsing state
@param string $arrayText The array as string.
@return void
|
[
"Handler",
"for",
"array",
"syntax",
".",
"This",
"creates",
"the",
"array",
"object",
"recursively",
"and",
"adds",
"it",
"to",
"the",
"current",
"node",
"."
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/Parser/TemplateParser.php#L956-L961
|
221,470
|
neos/fluid
|
Classes/TYPO3/Fluid/Core/Parser/TemplateParser.php
|
TemplateParser.recursiveArrayHandler
|
protected function recursiveArrayHandler($arrayText)
{
$matches = array();
if (preg_match_all(self::$SPLIT_PATTERN_SHORTHANDSYNTAX_ARRAY_PARTS, $arrayText, $matches, PREG_SET_ORDER) > 0) {
$arrayToBuild = array();
foreach ($matches as $singleMatch) {
$arrayKey = $this->unquoteString($singleMatch['Key']);
if (!empty($singleMatch['VariableIdentifier'])) {
$arrayToBuild[$arrayKey] = $this->objectManager->get(\TYPO3\Fluid\Core\Parser\SyntaxTree\ObjectAccessorNode::class, $singleMatch['VariableIdentifier']);
} elseif (array_key_exists('Number', $singleMatch) && (!empty($singleMatch['Number']) || $singleMatch['Number'] === '0')) {
$arrayToBuild[$arrayKey] = floatval($singleMatch['Number']);
} elseif ((array_key_exists('QuotedString', $singleMatch) && !empty($singleMatch['QuotedString']))) {
$argumentString = $this->unquoteString($singleMatch['QuotedString']);
$arrayToBuild[$arrayKey] = $this->buildArgumentObjectTree($argumentString);
} elseif (array_key_exists('Subarray', $singleMatch) && !empty($singleMatch['Subarray'])) {
$arrayToBuild[$arrayKey] = $this->objectManager->get(\TYPO3\Fluid\Core\Parser\SyntaxTree\ArrayNode::class, $this->recursiveArrayHandler($singleMatch['Subarray']));
} else {
throw new Exception('This exception should never be thrown, as the array value has to be of some type (Value given: "' . var_export($singleMatch, true) . '"). Please post your template to the bugtracker at forge.typo3.org.', 1225136013);
}
}
return $arrayToBuild;
} else {
throw new Exception('This exception should never be thrown, there is most likely some error in the regular expressions. Please post your template to the bugtracker at forge.typo3.org.', 1225136013);
}
}
|
php
|
protected function recursiveArrayHandler($arrayText)
{
$matches = array();
if (preg_match_all(self::$SPLIT_PATTERN_SHORTHANDSYNTAX_ARRAY_PARTS, $arrayText, $matches, PREG_SET_ORDER) > 0) {
$arrayToBuild = array();
foreach ($matches as $singleMatch) {
$arrayKey = $this->unquoteString($singleMatch['Key']);
if (!empty($singleMatch['VariableIdentifier'])) {
$arrayToBuild[$arrayKey] = $this->objectManager->get(\TYPO3\Fluid\Core\Parser\SyntaxTree\ObjectAccessorNode::class, $singleMatch['VariableIdentifier']);
} elseif (array_key_exists('Number', $singleMatch) && (!empty($singleMatch['Number']) || $singleMatch['Number'] === '0')) {
$arrayToBuild[$arrayKey] = floatval($singleMatch['Number']);
} elseif ((array_key_exists('QuotedString', $singleMatch) && !empty($singleMatch['QuotedString']))) {
$argumentString = $this->unquoteString($singleMatch['QuotedString']);
$arrayToBuild[$arrayKey] = $this->buildArgumentObjectTree($argumentString);
} elseif (array_key_exists('Subarray', $singleMatch) && !empty($singleMatch['Subarray'])) {
$arrayToBuild[$arrayKey] = $this->objectManager->get(\TYPO3\Fluid\Core\Parser\SyntaxTree\ArrayNode::class, $this->recursiveArrayHandler($singleMatch['Subarray']));
} else {
throw new Exception('This exception should never be thrown, as the array value has to be of some type (Value given: "' . var_export($singleMatch, true) . '"). Please post your template to the bugtracker at forge.typo3.org.', 1225136013);
}
}
return $arrayToBuild;
} else {
throw new Exception('This exception should never be thrown, there is most likely some error in the regular expressions. Please post your template to the bugtracker at forge.typo3.org.', 1225136013);
}
}
|
[
"protected",
"function",
"recursiveArrayHandler",
"(",
"$",
"arrayText",
")",
"{",
"$",
"matches",
"=",
"array",
"(",
")",
";",
"if",
"(",
"preg_match_all",
"(",
"self",
"::",
"$",
"SPLIT_PATTERN_SHORTHANDSYNTAX_ARRAY_PARTS",
",",
"$",
"arrayText",
",",
"$",
"matches",
",",
"PREG_SET_ORDER",
")",
">",
"0",
")",
"{",
"$",
"arrayToBuild",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"matches",
"as",
"$",
"singleMatch",
")",
"{",
"$",
"arrayKey",
"=",
"$",
"this",
"->",
"unquoteString",
"(",
"$",
"singleMatch",
"[",
"'Key'",
"]",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"singleMatch",
"[",
"'VariableIdentifier'",
"]",
")",
")",
"{",
"$",
"arrayToBuild",
"[",
"$",
"arrayKey",
"]",
"=",
"$",
"this",
"->",
"objectManager",
"->",
"get",
"(",
"\\",
"TYPO3",
"\\",
"Fluid",
"\\",
"Core",
"\\",
"Parser",
"\\",
"SyntaxTree",
"\\",
"ObjectAccessorNode",
"::",
"class",
",",
"$",
"singleMatch",
"[",
"'VariableIdentifier'",
"]",
")",
";",
"}",
"elseif",
"(",
"array_key_exists",
"(",
"'Number'",
",",
"$",
"singleMatch",
")",
"&&",
"(",
"!",
"empty",
"(",
"$",
"singleMatch",
"[",
"'Number'",
"]",
")",
"||",
"$",
"singleMatch",
"[",
"'Number'",
"]",
"===",
"'0'",
")",
")",
"{",
"$",
"arrayToBuild",
"[",
"$",
"arrayKey",
"]",
"=",
"floatval",
"(",
"$",
"singleMatch",
"[",
"'Number'",
"]",
")",
";",
"}",
"elseif",
"(",
"(",
"array_key_exists",
"(",
"'QuotedString'",
",",
"$",
"singleMatch",
")",
"&&",
"!",
"empty",
"(",
"$",
"singleMatch",
"[",
"'QuotedString'",
"]",
")",
")",
")",
"{",
"$",
"argumentString",
"=",
"$",
"this",
"->",
"unquoteString",
"(",
"$",
"singleMatch",
"[",
"'QuotedString'",
"]",
")",
";",
"$",
"arrayToBuild",
"[",
"$",
"arrayKey",
"]",
"=",
"$",
"this",
"->",
"buildArgumentObjectTree",
"(",
"$",
"argumentString",
")",
";",
"}",
"elseif",
"(",
"array_key_exists",
"(",
"'Subarray'",
",",
"$",
"singleMatch",
")",
"&&",
"!",
"empty",
"(",
"$",
"singleMatch",
"[",
"'Subarray'",
"]",
")",
")",
"{",
"$",
"arrayToBuild",
"[",
"$",
"arrayKey",
"]",
"=",
"$",
"this",
"->",
"objectManager",
"->",
"get",
"(",
"\\",
"TYPO3",
"\\",
"Fluid",
"\\",
"Core",
"\\",
"Parser",
"\\",
"SyntaxTree",
"\\",
"ArrayNode",
"::",
"class",
",",
"$",
"this",
"->",
"recursiveArrayHandler",
"(",
"$",
"singleMatch",
"[",
"'Subarray'",
"]",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"'This exception should never be thrown, as the array value has to be of some type (Value given: \"'",
".",
"var_export",
"(",
"$",
"singleMatch",
",",
"true",
")",
".",
"'\"). Please post your template to the bugtracker at forge.typo3.org.'",
",",
"1225136013",
")",
";",
"}",
"}",
"return",
"$",
"arrayToBuild",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"'This exception should never be thrown, there is most likely some error in the regular expressions. Please post your template to the bugtracker at forge.typo3.org.'",
",",
"1225136013",
")",
";",
"}",
"}"
] |
Recursive function which takes the string representation of an array and
builds an object tree from it.
Deals with the following value types:
- Numbers (Integers and Floats)
- Strings
- Variables
- sub-arrays
@param string $arrayText Array text
@return array<NodeInterface> the array node built up
@throws Exception
|
[
"Recursive",
"function",
"which",
"takes",
"the",
"string",
"representation",
"of",
"an",
"array",
"and",
"builds",
"an",
"object",
"tree",
"from",
"it",
"."
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/Parser/TemplateParser.php#L977-L1001
|
221,471
|
neos/fluid
|
Classes/TYPO3/Fluid/Core/Parser/TemplateParser.php
|
TemplateParser.textHandler
|
protected function textHandler(ParsingState $state, $text)
{
/** @var $node TextNode */
$node = $this->objectManager->get(\TYPO3\Fluid\Core\Parser\SyntaxTree\TextNode::class, $text);
$this->callInterceptor($node, InterceptorInterface::INTERCEPT_TEXT, $state);
$state->getNodeFromStack()->addChildNode($node);
}
|
php
|
protected function textHandler(ParsingState $state, $text)
{
/** @var $node TextNode */
$node = $this->objectManager->get(\TYPO3\Fluid\Core\Parser\SyntaxTree\TextNode::class, $text);
$this->callInterceptor($node, InterceptorInterface::INTERCEPT_TEXT, $state);
$state->getNodeFromStack()->addChildNode($node);
}
|
[
"protected",
"function",
"textHandler",
"(",
"ParsingState",
"$",
"state",
",",
"$",
"text",
")",
"{",
"/** @var $node TextNode */",
"$",
"node",
"=",
"$",
"this",
"->",
"objectManager",
"->",
"get",
"(",
"\\",
"TYPO3",
"\\",
"Fluid",
"\\",
"Core",
"\\",
"Parser",
"\\",
"SyntaxTree",
"\\",
"TextNode",
"::",
"class",
",",
"$",
"text",
")",
";",
"$",
"this",
"->",
"callInterceptor",
"(",
"$",
"node",
",",
"InterceptorInterface",
"::",
"INTERCEPT_TEXT",
",",
"$",
"state",
")",
";",
"$",
"state",
"->",
"getNodeFromStack",
"(",
")",
"->",
"addChildNode",
"(",
"$",
"node",
")",
";",
"}"
] |
Text node handler
@param ParsingState $state
@param string $text
@return void
|
[
"Text",
"node",
"handler"
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/Parser/TemplateParser.php#L1010-L1017
|
221,472
|
neos/fluid
|
Classes/TYPO3/Fluid/Core/Parser/TemplateParser.php
|
TemplateParser.isNamespaceValid
|
protected function isNamespaceValid($namespaceIdentifier, $methodIdentifier)
{
if (array_key_exists($namespaceIdentifier, $this->namespaces)) {
return true;
}
foreach ($this->ignoredNamespaceIdentifierPatterns as $namespaceIdentifierPattern) {
if (preg_match($namespaceIdentifierPattern, $namespaceIdentifier) === 1) {
return false;
}
}
throw new Exception(sprintf('Error while rendering a ViewHelper
The namespace of ViewHelper notation "<%1$s:%2$s.../>" could not be resolved.
Possible reasons are:
* you have a spelling error in the viewHelper namespace
* you forgot to import the namespace using "{namespace %1$s=Some\Package\ViewHelpers}"
* you\'re trying to use a non-fluid xml namespace, in which case you can use "{namespace %1$s}" to ignore this namespace for fluid rendering', $namespaceIdentifier, $methodIdentifier), 1402521855);
}
|
php
|
protected function isNamespaceValid($namespaceIdentifier, $methodIdentifier)
{
if (array_key_exists($namespaceIdentifier, $this->namespaces)) {
return true;
}
foreach ($this->ignoredNamespaceIdentifierPatterns as $namespaceIdentifierPattern) {
if (preg_match($namespaceIdentifierPattern, $namespaceIdentifier) === 1) {
return false;
}
}
throw new Exception(sprintf('Error while rendering a ViewHelper
The namespace of ViewHelper notation "<%1$s:%2$s.../>" could not be resolved.
Possible reasons are:
* you have a spelling error in the viewHelper namespace
* you forgot to import the namespace using "{namespace %1$s=Some\Package\ViewHelpers}"
* you\'re trying to use a non-fluid xml namespace, in which case you can use "{namespace %1$s}" to ignore this namespace for fluid rendering', $namespaceIdentifier, $methodIdentifier), 1402521855);
}
|
[
"protected",
"function",
"isNamespaceValid",
"(",
"$",
"namespaceIdentifier",
",",
"$",
"methodIdentifier",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"namespaceIdentifier",
",",
"$",
"this",
"->",
"namespaces",
")",
")",
"{",
"return",
"true",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"ignoredNamespaceIdentifierPatterns",
"as",
"$",
"namespaceIdentifierPattern",
")",
"{",
"if",
"(",
"preg_match",
"(",
"$",
"namespaceIdentifierPattern",
",",
"$",
"namespaceIdentifier",
")",
"===",
"1",
")",
"{",
"return",
"false",
";",
"}",
"}",
"throw",
"new",
"Exception",
"(",
"sprintf",
"(",
"'Error while rendering a ViewHelper\n\t\t\tThe namespace of ViewHelper notation \"<%1$s:%2$s.../>\" could not be resolved.\n\n\t\t\tPossible reasons are:\n\t\t\t* you have a spelling error in the viewHelper namespace\n\t\t\t* you forgot to import the namespace using \"{namespace %1$s=Some\\Package\\ViewHelpers}\"\n\t\t\t* you\\'re trying to use a non-fluid xml namespace, in which case you can use \"{namespace %1$s}\" to ignore this namespace for fluid rendering'",
",",
"$",
"namespaceIdentifier",
",",
"$",
"methodIdentifier",
")",
",",
"1402521855",
")",
";",
"}"
] |
Validates the given namespaceIdentifier and throws an exception
if the namespace is unknown and not ignored
@param string $namespaceIdentifier
@param string $methodIdentifier
@return boolean TRUE if the given namespace is valid, otherwise FALSE
@throws Exception if the given namespace can't be resolved and is not ignored
|
[
"Validates",
"the",
"given",
"namespaceIdentifier",
"and",
"throws",
"an",
"exception",
"if",
"the",
"namespace",
"is",
"unknown",
"and",
"not",
"ignored"
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/Parser/TemplateParser.php#L1028-L1047
|
221,473
|
paquettg/leaguewrap
|
src/LeagueWrap/Api/Champion.php
|
Champion.all
|
public function all()
{
$params = [
'freeToPlay' => $this->free,
];
$info = $this->request('champion', $params);
// set up the champions
$championList = new ChampionList($info);
return $this->attachStaticDataToDto($championList);
}
|
php
|
public function all()
{
$params = [
'freeToPlay' => $this->free,
];
$info = $this->request('champion', $params);
// set up the champions
$championList = new ChampionList($info);
return $this->attachStaticDataToDto($championList);
}
|
[
"public",
"function",
"all",
"(",
")",
"{",
"$",
"params",
"=",
"[",
"'freeToPlay'",
"=>",
"$",
"this",
"->",
"free",
",",
"]",
";",
"$",
"info",
"=",
"$",
"this",
"->",
"request",
"(",
"'champion'",
",",
"$",
"params",
")",
";",
"// set up the champions",
"$",
"championList",
"=",
"new",
"ChampionList",
"(",
"$",
"info",
")",
";",
"return",
"$",
"this",
"->",
"attachStaticDataToDto",
"(",
"$",
"championList",
")",
";",
"}"
] |
Gets all the champions in the given region.
@return ChampionList
|
[
"Gets",
"all",
"the",
"champions",
"in",
"the",
"given",
"region",
"."
] |
0f91813b5d8292054e5e13619d591b6b14dc63e6
|
https://github.com/paquettg/leaguewrap/blob/0f91813b5d8292054e5e13619d591b6b14dc63e6/src/LeagueWrap/Api/Champion.php#L55-L67
|
221,474
|
paquettg/leaguewrap
|
src/LeagueWrap/Api/Champion.php
|
Champion.championById
|
public function championById($championId)
{
$info = $this->request('champion/'.$championId);
return $this->attachStaticDataToDto(new Champ($info));
}
|
php
|
public function championById($championId)
{
$info = $this->request('champion/'.$championId);
return $this->attachStaticDataToDto(new Champ($info));
}
|
[
"public",
"function",
"championById",
"(",
"$",
"championId",
")",
"{",
"$",
"info",
"=",
"$",
"this",
"->",
"request",
"(",
"'champion/'",
".",
"$",
"championId",
")",
";",
"return",
"$",
"this",
"->",
"attachStaticDataToDto",
"(",
"new",
"Champ",
"(",
"$",
"info",
")",
")",
";",
"}"
] |
Gets the information for a single champion
@param int $championId
@return Champ
|
[
"Gets",
"the",
"information",
"for",
"a",
"single",
"champion"
] |
0f91813b5d8292054e5e13619d591b6b14dc63e6
|
https://github.com/paquettg/leaguewrap/blob/0f91813b5d8292054e5e13619d591b6b14dc63e6/src/LeagueWrap/Api/Champion.php#L83-L88
|
221,475
|
CapMousse/React-Restify
|
src/Runner.php
|
Runner.register
|
public function register(LoopInterface $loop, $port, $host = '127.0.0.1', array $cert = [])
{
$socket = new SocketServer("{$host}:{$port}", $loop);
if (count($cert) > 0) {
$socket = new SecureSocketServer($socket, $loop, $cert);
}
$http = new HttpServer($socket);
$http->on('request', $this->app);
echo("Server running on {$host}:{$port}\n");
$loop->run();
}
|
php
|
public function register(LoopInterface $loop, $port, $host = '127.0.0.1', array $cert = [])
{
$socket = new SocketServer("{$host}:{$port}", $loop);
if (count($cert) > 0) {
$socket = new SecureSocketServer($socket, $loop, $cert);
}
$http = new HttpServer($socket);
$http->on('request', $this->app);
echo("Server running on {$host}:{$port}\n");
$loop->run();
}
|
[
"public",
"function",
"register",
"(",
"LoopInterface",
"$",
"loop",
",",
"$",
"port",
",",
"$",
"host",
"=",
"'127.0.0.1'",
",",
"array",
"$",
"cert",
"=",
"[",
"]",
")",
"{",
"$",
"socket",
"=",
"new",
"SocketServer",
"(",
"\"{$host}:{$port}\"",
",",
"$",
"loop",
")",
";",
"if",
"(",
"count",
"(",
"$",
"cert",
")",
">",
"0",
")",
"{",
"$",
"socket",
"=",
"new",
"SecureSocketServer",
"(",
"$",
"socket",
",",
"$",
"loop",
",",
"$",
"cert",
")",
";",
"}",
"$",
"http",
"=",
"new",
"HttpServer",
"(",
"$",
"socket",
")",
";",
"$",
"http",
"->",
"on",
"(",
"'request'",
",",
"$",
"this",
"->",
"app",
")",
";",
"echo",
"(",
"\"Server running on {$host}:{$port}\\n\"",
")",
";",
"$",
"loop",
"->",
"run",
"(",
")",
";",
"}"
] |
Setup socket for main loop
@param LoopInterface $loop
@param string $port
@param string $host
@param array $cert
|
[
"Setup",
"socket",
"for",
"main",
"loop"
] |
51fe94d6e4c7fafec06fb304f9e44badde4bfe71
|
https://github.com/CapMousse/React-Restify/blob/51fe94d6e4c7fafec06fb304f9e44badde4bfe71/src/Runner.php#L43-L56
|
221,476
|
paquettg/leaguewrap
|
src/LeagueWrap/Dto/RankedStats.php
|
RankedStats.champion
|
public function champion($championId)
{
if ( ! isset($this->info['champions'][$championId]))
{
return null;
}
return $this->info['champions'][$championId];
}
|
php
|
public function champion($championId)
{
if ( ! isset($this->info['champions'][$championId]))
{
return null;
}
return $this->info['champions'][$championId];
}
|
[
"public",
"function",
"champion",
"(",
"$",
"championId",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"info",
"[",
"'champions'",
"]",
"[",
"$",
"championId",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"info",
"[",
"'champions'",
"]",
"[",
"$",
"championId",
"]",
";",
"}"
] |
Get the champion by the id returned by the API.
@param int $championId
@return ChampionStats|null
|
[
"Get",
"the",
"champion",
"by",
"the",
"id",
"returned",
"by",
"the",
"API",
"."
] |
0f91813b5d8292054e5e13619d591b6b14dc63e6
|
https://github.com/paquettg/leaguewrap/blob/0f91813b5d8292054e5e13619d591b6b14dc63e6/src/LeagueWrap/Dto/RankedStats.php#L32-L40
|
221,477
|
paquettg/leaguewrap
|
src/LeagueWrap/Limit/FileLimit.php
|
FileLimit.getPathContent
|
protected function getPathContent($data)
{
$info = file_get_contents($this->path);
list($expires, $hits) = explode(',', $info);
if ($expires <= time())
{
// it has expires
unlink($this->path);
$hits = 0;
$expires = null;
}
if ($data == 'hits')
{
return $hits;
}
if ($data == 'expires')
{
return $expires;
}
return null;
}
|
php
|
protected function getPathContent($data)
{
$info = file_get_contents($this->path);
list($expires, $hits) = explode(',', $info);
if ($expires <= time())
{
// it has expires
unlink($this->path);
$hits = 0;
$expires = null;
}
if ($data == 'hits')
{
return $hits;
}
if ($data == 'expires')
{
return $expires;
}
return null;
}
|
[
"protected",
"function",
"getPathContent",
"(",
"$",
"data",
")",
"{",
"$",
"info",
"=",
"file_get_contents",
"(",
"$",
"this",
"->",
"path",
")",
";",
"list",
"(",
"$",
"expires",
",",
"$",
"hits",
")",
"=",
"explode",
"(",
"','",
",",
"$",
"info",
")",
";",
"if",
"(",
"$",
"expires",
"<=",
"time",
"(",
")",
")",
"{",
"// it has expires",
"unlink",
"(",
"$",
"this",
"->",
"path",
")",
";",
"$",
"hits",
"=",
"0",
";",
"$",
"expires",
"=",
"null",
";",
"}",
"if",
"(",
"$",
"data",
"==",
"'hits'",
")",
"{",
"return",
"$",
"hits",
";",
"}",
"if",
"(",
"$",
"data",
"==",
"'expires'",
")",
"{",
"return",
"$",
"expires",
";",
"}",
"return",
"null",
";",
"}"
] |
Gets the content of the current path and returns
the data requested.
@param string $data
@return int|null
|
[
"Gets",
"the",
"content",
"of",
"the",
"current",
"path",
"and",
"returns",
"the",
"data",
"requested",
"."
] |
0f91813b5d8292054e5e13619d591b6b14dc63e6
|
https://github.com/paquettg/leaguewrap/blob/0f91813b5d8292054e5e13619d591b6b14dc63e6/src/LeagueWrap/Limit/FileLimit.php#L177-L198
|
221,478
|
paquettg/leaguewrap
|
src/LeagueWrap/Limit/FileLimit.php
|
FileLimit.writePathContent
|
protected function writePathContent($expires, $count)
{
$info = $expires.','.$count;
return file_put_contents($this->path, $info);
}
|
php
|
protected function writePathContent($expires, $count)
{
$info = $expires.','.$count;
return file_put_contents($this->path, $info);
}
|
[
"protected",
"function",
"writePathContent",
"(",
"$",
"expires",
",",
"$",
"count",
")",
"{",
"$",
"info",
"=",
"$",
"expires",
".",
"','",
".",
"$",
"count",
";",
"return",
"file_put_contents",
"(",
"$",
"this",
"->",
"path",
",",
"$",
"info",
")",
";",
"}"
] |
Writes the new expiry timestamp and count to the given
path for this limit.
@param int $expires
@param int $count
@return mixed
|
[
"Writes",
"the",
"new",
"expiry",
"timestamp",
"and",
"count",
"to",
"the",
"given",
"path",
"for",
"this",
"limit",
"."
] |
0f91813b5d8292054e5e13619d591b6b14dc63e6
|
https://github.com/paquettg/leaguewrap/blob/0f91813b5d8292054e5e13619d591b6b14dc63e6/src/LeagueWrap/Limit/FileLimit.php#L208-L213
|
221,479
|
salebab/database
|
src/database/Query.php
|
Query.whereIn
|
public function whereIn($column, $params)
{
$this->prepareWhereInStatement($column, $params, false);
$this->addParams($params);
return $this;
}
|
php
|
public function whereIn($column, $params)
{
$this->prepareWhereInStatement($column, $params, false);
$this->addParams($params);
return $this;
}
|
[
"public",
"function",
"whereIn",
"(",
"$",
"column",
",",
"$",
"params",
")",
"{",
"$",
"this",
"->",
"prepareWhereInStatement",
"(",
"$",
"column",
",",
"$",
"params",
",",
"false",
")",
";",
"$",
"this",
"->",
"addParams",
"(",
"$",
"params",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Add where in statement
@param string $column
@param array $params
@return Query
|
[
"Add",
"where",
"in",
"statement"
] |
26e9253f274fb0719ad86c1db6e25ea5400b58a6
|
https://github.com/salebab/database/blob/26e9253f274fb0719ad86c1db6e25ea5400b58a6/src/database/Query.php#L100-L106
|
221,480
|
salebab/database
|
src/database/Query.php
|
Query.whereNotIn
|
public function whereNotIn($column, $params)
{
$this->prepareWhereInStatement($column, $params, true);
$this->addParams($params);
return $this;
}
|
php
|
public function whereNotIn($column, $params)
{
$this->prepareWhereInStatement($column, $params, true);
$this->addParams($params);
return $this;
}
|
[
"public",
"function",
"whereNotIn",
"(",
"$",
"column",
",",
"$",
"params",
")",
"{",
"$",
"this",
"->",
"prepareWhereInStatement",
"(",
"$",
"column",
",",
"$",
"params",
",",
"true",
")",
";",
"$",
"this",
"->",
"addParams",
"(",
"$",
"params",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Add where not in statement
@param $column
@param $params
@return Query
|
[
"Add",
"where",
"not",
"in",
"statement"
] |
26e9253f274fb0719ad86c1db6e25ea5400b58a6
|
https://github.com/salebab/database/blob/26e9253f274fb0719ad86c1db6e25ea5400b58a6/src/database/Query.php#L115-L121
|
221,481
|
salebab/database
|
src/database/Query.php
|
Query.having
|
public function having($statement, $params = null)
{
$this->having[] = $statement;
$this->addParams($params);
return $this;
}
|
php
|
public function having($statement, $params = null)
{
$this->having[] = $statement;
$this->addParams($params);
return $this;
}
|
[
"public",
"function",
"having",
"(",
"$",
"statement",
",",
"$",
"params",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"having",
"[",
"]",
"=",
"$",
"statement",
";",
"$",
"this",
"->",
"addParams",
"(",
"$",
"params",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Add statement for HAVING ...
@param string $statement
@param mixed $params
@return Query
|
[
"Add",
"statement",
"for",
"HAVING",
"..."
] |
26e9253f274fb0719ad86c1db6e25ea5400b58a6
|
https://github.com/salebab/database/blob/26e9253f274fb0719ad86c1db6e25ea5400b58a6/src/database/Query.php#L129-L135
|
221,482
|
salebab/database
|
src/database/Query.php
|
Query.getQuery
|
public function getQuery()
{
$sql = $this->prepareSelectString();
$sql .= $this->prepareJoinString();
$sql .= $this->prepareWhereString();
$sql .= $this->prepareGroupByString();
$sql .= $this->prepareHavingString();
$sql .= $this->prepareOrderByString();
$sql .= $this->prepareLimitString();
return $sql;
}
|
php
|
public function getQuery()
{
$sql = $this->prepareSelectString();
$sql .= $this->prepareJoinString();
$sql .= $this->prepareWhereString();
$sql .= $this->prepareGroupByString();
$sql .= $this->prepareHavingString();
$sql .= $this->prepareOrderByString();
$sql .= $this->prepareLimitString();
return $sql;
}
|
[
"public",
"function",
"getQuery",
"(",
")",
"{",
"$",
"sql",
"=",
"$",
"this",
"->",
"prepareSelectString",
"(",
")",
";",
"$",
"sql",
".=",
"$",
"this",
"->",
"prepareJoinString",
"(",
")",
";",
"$",
"sql",
".=",
"$",
"this",
"->",
"prepareWhereString",
"(",
")",
";",
"$",
"sql",
".=",
"$",
"this",
"->",
"prepareGroupByString",
"(",
")",
";",
"$",
"sql",
".=",
"$",
"this",
"->",
"prepareHavingString",
"(",
")",
";",
"$",
"sql",
".=",
"$",
"this",
"->",
"prepareOrderByString",
"(",
")",
";",
"$",
"sql",
".=",
"$",
"this",
"->",
"prepareLimitString",
"(",
")",
";",
"return",
"$",
"sql",
";",
"}"
] |
Returns generated SQL query
@return string
|
[
"Returns",
"generated",
"SQL",
"query"
] |
26e9253f274fb0719ad86c1db6e25ea5400b58a6
|
https://github.com/salebab/database/blob/26e9253f274fb0719ad86c1db6e25ea5400b58a6/src/database/Query.php#L216-L227
|
221,483
|
salebab/database
|
src/database/Query.php
|
Query.prepareSelectString
|
private function prepareSelectString()
{
if(empty($this->select)) {
$this->select("*");
}
return "SELECT " . implode(", ", $this->select) . " FROM " . implode(", ", $this->from) . " ";
}
|
php
|
private function prepareSelectString()
{
if(empty($this->select)) {
$this->select("*");
}
return "SELECT " . implode(", ", $this->select) . " FROM " . implode(", ", $this->from) . " ";
}
|
[
"private",
"function",
"prepareSelectString",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"select",
")",
")",
"{",
"$",
"this",
"->",
"select",
"(",
"\"*\"",
")",
";",
"}",
"return",
"\"SELECT \"",
".",
"implode",
"(",
"\", \"",
",",
"$",
"this",
"->",
"select",
")",
".",
"\" FROM \"",
".",
"implode",
"(",
"\", \"",
",",
"$",
"this",
"->",
"from",
")",
".",
"\" \"",
";",
"}"
] |
Returns prepared select string
@return string
|
[
"Returns",
"prepared",
"select",
"string"
] |
26e9253f274fb0719ad86c1db6e25ea5400b58a6
|
https://github.com/salebab/database/blob/26e9253f274fb0719ad86c1db6e25ea5400b58a6/src/database/Query.php#L234-L241
|
221,484
|
salebab/database
|
src/database/Query.php
|
Query.execute
|
public function execute()
{
if($this->db === null) {
$this->db = DB::getInstance();
}
return $this->db->execQuery($this);
}
|
php
|
public function execute()
{
if($this->db === null) {
$this->db = DB::getInstance();
}
return $this->db->execQuery($this);
}
|
[
"public",
"function",
"execute",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"db",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"db",
"=",
"DB",
"::",
"getInstance",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"db",
"->",
"execQuery",
"(",
"$",
"this",
")",
";",
"}"
] |
Execute built query
This will prepare query, bind params and execute query
@return Statement
|
[
"Execute",
"built",
"query",
"This",
"will",
"prepare",
"query",
"bind",
"params",
"and",
"execute",
"query"
] |
26e9253f274fb0719ad86c1db6e25ea5400b58a6
|
https://github.com/salebab/database/blob/26e9253f274fb0719ad86c1db6e25ea5400b58a6/src/database/Query.php#L249-L255
|
221,485
|
salebab/database
|
src/database/Query.php
|
Query.prepareWhereInStatement
|
private function prepareWhereInStatement($column, $params, $not_in = false)
{
$qm = array_fill(0, count($params), "?");
$in = ($not_in) ? "NOT IN" : "IN";
$this->where[] = $column . " " . $in . " (" . implode(", ", $qm) . ")";
}
|
php
|
private function prepareWhereInStatement($column, $params, $not_in = false)
{
$qm = array_fill(0, count($params), "?");
$in = ($not_in) ? "NOT IN" : "IN";
$this->where[] = $column . " " . $in . " (" . implode(", ", $qm) . ")";
}
|
[
"private",
"function",
"prepareWhereInStatement",
"(",
"$",
"column",
",",
"$",
"params",
",",
"$",
"not_in",
"=",
"false",
")",
"{",
"$",
"qm",
"=",
"array_fill",
"(",
"0",
",",
"count",
"(",
"$",
"params",
")",
",",
"\"?\"",
")",
";",
"$",
"in",
"=",
"(",
"$",
"not_in",
")",
"?",
"\"NOT IN\"",
":",
"\"IN\"",
";",
"$",
"this",
"->",
"where",
"[",
"]",
"=",
"$",
"column",
".",
"\" \"",
".",
"$",
"in",
".",
"\" (\"",
".",
"implode",
"(",
"\", \"",
",",
"$",
"qm",
")",
".",
"\")\"",
";",
"}"
] |
Prepares where in statement
@param string $column
@param array $params
@param bool $not_in Use NOT IN statement
@return void
|
[
"Prepares",
"where",
"in",
"statement"
] |
26e9253f274fb0719ad86c1db6e25ea5400b58a6
|
https://github.com/salebab/database/blob/26e9253f274fb0719ad86c1db6e25ea5400b58a6/src/database/Query.php#L316-L321
|
221,486
|
neos/fluid
|
Classes/TYPO3/Fluid/ViewHelpers/Format/PrintfViewHelper.php
|
PrintfViewHelper.render
|
public function render(array $arguments, $value = null)
{
return self::renderStatic(array('arguments' => $arguments, 'value' => $value), $this->buildRenderChildrenClosure(), $this->renderingContext);
}
|
php
|
public function render(array $arguments, $value = null)
{
return self::renderStatic(array('arguments' => $arguments, 'value' => $value), $this->buildRenderChildrenClosure(), $this->renderingContext);
}
|
[
"public",
"function",
"render",
"(",
"array",
"$",
"arguments",
",",
"$",
"value",
"=",
"null",
")",
"{",
"return",
"self",
"::",
"renderStatic",
"(",
"array",
"(",
"'arguments'",
"=>",
"$",
"arguments",
",",
"'value'",
"=>",
"$",
"value",
")",
",",
"$",
"this",
"->",
"buildRenderChildrenClosure",
"(",
")",
",",
"$",
"this",
"->",
"renderingContext",
")",
";",
"}"
] |
Format the arguments with the given printf format string.
@param array $arguments The arguments for vsprintf
@param string $value string to format
@return string The formatted value
@api
|
[
"Format",
"the",
"arguments",
"with",
"the",
"given",
"printf",
"format",
"string",
"."
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/ViewHelpers/Format/PrintfViewHelper.php#L65-L68
|
221,487
|
CapMousse/React-Restify
|
src/Evenement/EventEmitter.php
|
EventEmitter.offAny
|
public function offAny(callable $listener)
{
if (false !== $index = array_search($listener, $this->anyListeners, true)) {
unset($this->anyListeners[$index]);
}
}
|
php
|
public function offAny(callable $listener)
{
if (false !== $index = array_search($listener, $this->anyListeners, true)) {
unset($this->anyListeners[$index]);
}
}
|
[
"public",
"function",
"offAny",
"(",
"callable",
"$",
"listener",
")",
"{",
"if",
"(",
"false",
"!==",
"$",
"index",
"=",
"array_search",
"(",
"$",
"listener",
",",
"$",
"this",
"->",
"anyListeners",
",",
"true",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"anyListeners",
"[",
"$",
"index",
"]",
")",
";",
"}",
"}"
] |
Disable a onAny listener
@param Callable $listener
@return Void
|
[
"Disable",
"a",
"onAny",
"listener"
] |
51fe94d6e4c7fafec06fb304f9e44badde4bfe71
|
https://github.com/CapMousse/React-Restify/blob/51fe94d6e4c7fafec06fb304f9e44badde4bfe71/src/Evenement/EventEmitter.php#L31-L36
|
221,488
|
radphp/radphp
|
src/Error/ErrorHandler.php
|
ErrorHandler.handleFatalError
|
public function handleFatalError($code, $message, $file, $line)
{
error_log($message, 0);
$this->handleException(new FatalErrorException($message, 500, $file, $line));
return true;
}
|
php
|
public function handleFatalError($code, $message, $file, $line)
{
error_log($message, 0);
$this->handleException(new FatalErrorException($message, 500, $file, $line));
return true;
}
|
[
"public",
"function",
"handleFatalError",
"(",
"$",
"code",
",",
"$",
"message",
",",
"$",
"file",
",",
"$",
"line",
")",
"{",
"error_log",
"(",
"$",
"message",
",",
"0",
")",
";",
"$",
"this",
"->",
"handleException",
"(",
"new",
"FatalErrorException",
"(",
"$",
"message",
",",
"500",
",",
"$",
"file",
",",
"$",
"line",
")",
")",
";",
"return",
"true",
";",
"}"
] |
Display a fatal error.
@param int $code Error code
@param string $message Error message
@param string $file File on which error occurred
@param int $line Line that triggered the error
@return bool
|
[
"Display",
"a",
"fatal",
"error",
"."
] |
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
|
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/Error/ErrorHandler.php#L195-L201
|
221,489
|
paquettg/leaguewrap
|
src/LeagueWrap/Api/Currentgame.php
|
Currentgame.currentGame
|
public function currentGame($identity)
{
$summonerId = $this->extractId($identity);
$response = $this->request($summonerId, [], false, false);
$game = $this->attachStaticDataToDto(new CurrentGameDto($response));
$this->attachResponse($identity, $game, 'game');
return $game;
}
|
php
|
public function currentGame($identity)
{
$summonerId = $this->extractId($identity);
$response = $this->request($summonerId, [], false, false);
$game = $this->attachStaticDataToDto(new CurrentGameDto($response));
$this->attachResponse($identity, $game, 'game');
return $game;
}
|
[
"public",
"function",
"currentGame",
"(",
"$",
"identity",
")",
"{",
"$",
"summonerId",
"=",
"$",
"this",
"->",
"extractId",
"(",
"$",
"identity",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"request",
"(",
"$",
"summonerId",
",",
"[",
"]",
",",
"false",
",",
"false",
")",
";",
"$",
"game",
"=",
"$",
"this",
"->",
"attachStaticDataToDto",
"(",
"new",
"CurrentGameDto",
"(",
"$",
"response",
")",
")",
";",
"$",
"this",
"->",
"attachResponse",
"(",
"$",
"identity",
",",
"$",
"game",
",",
"'game'",
")",
";",
"return",
"$",
"game",
";",
"}"
] |
Gets the current game of summoner.
@param \LeagueWrap\Api\Summoner|Int $identity
@return \LeagueWrap\Dto\AbstractDto
@throws \Exception
@throws \LeagueWrap\Exception\CacheNotFoundException
@throws \LeagueWrap\Exception\InvalidIdentityException
@throws \LeagueWrap\Exception\RegionException
@throws \LeagueWrap\Response\HttpClientError
@throws \LeagueWrap\Response\HttpServerError
|
[
"Gets",
"the",
"current",
"game",
"of",
"summoner",
"."
] |
0f91813b5d8292054e5e13619d591b6b14dc63e6
|
https://github.com/paquettg/leaguewrap/blob/0f91813b5d8292054e5e13619d591b6b14dc63e6/src/LeagueWrap/Api/Currentgame.php#L66-L75
|
221,490
|
neos/fluid
|
Classes/TYPO3/Fluid/ViewHelpers/Widget/LinkViewHelper.php
|
LinkViewHelper.getWidgetUri
|
protected function getWidgetUri()
{
$uriBuilder = $this->controllerContext->getUriBuilder();
$argumentsToBeExcludedFromQueryString = array(
'@package',
'@subpackage',
'@controller'
);
$uriBuilder
->reset()
->setSection($this->arguments['section'])
->setCreateAbsoluteUri(true)
->setArgumentsToBeExcludedFromQueryString($argumentsToBeExcludedFromQueryString)
->setFormat($this->arguments['format']);
try {
$uri = $uriBuilder->uriFor($this->arguments['action'], $this->arguments['arguments'], '', '', '');
} catch (\Exception $exception) {
throw new ViewHelper\Exception($exception->getMessage(), $exception->getCode(), $exception);
}
return $uri;
}
|
php
|
protected function getWidgetUri()
{
$uriBuilder = $this->controllerContext->getUriBuilder();
$argumentsToBeExcludedFromQueryString = array(
'@package',
'@subpackage',
'@controller'
);
$uriBuilder
->reset()
->setSection($this->arguments['section'])
->setCreateAbsoluteUri(true)
->setArgumentsToBeExcludedFromQueryString($argumentsToBeExcludedFromQueryString)
->setFormat($this->arguments['format']);
try {
$uri = $uriBuilder->uriFor($this->arguments['action'], $this->arguments['arguments'], '', '', '');
} catch (\Exception $exception) {
throw new ViewHelper\Exception($exception->getMessage(), $exception->getCode(), $exception);
}
return $uri;
}
|
[
"protected",
"function",
"getWidgetUri",
"(",
")",
"{",
"$",
"uriBuilder",
"=",
"$",
"this",
"->",
"controllerContext",
"->",
"getUriBuilder",
"(",
")",
";",
"$",
"argumentsToBeExcludedFromQueryString",
"=",
"array",
"(",
"'@package'",
",",
"'@subpackage'",
",",
"'@controller'",
")",
";",
"$",
"uriBuilder",
"->",
"reset",
"(",
")",
"->",
"setSection",
"(",
"$",
"this",
"->",
"arguments",
"[",
"'section'",
"]",
")",
"->",
"setCreateAbsoluteUri",
"(",
"true",
")",
"->",
"setArgumentsToBeExcludedFromQueryString",
"(",
"$",
"argumentsToBeExcludedFromQueryString",
")",
"->",
"setFormat",
"(",
"$",
"this",
"->",
"arguments",
"[",
"'format'",
"]",
")",
";",
"try",
"{",
"$",
"uri",
"=",
"$",
"uriBuilder",
"->",
"uriFor",
"(",
"$",
"this",
"->",
"arguments",
"[",
"'action'",
"]",
",",
"$",
"this",
"->",
"arguments",
"[",
"'arguments'",
"]",
",",
"''",
",",
"''",
",",
"''",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"exception",
")",
"{",
"throw",
"new",
"ViewHelper",
"\\",
"Exception",
"(",
"$",
"exception",
"->",
"getMessage",
"(",
")",
",",
"$",
"exception",
"->",
"getCode",
"(",
")",
",",
"$",
"exception",
")",
";",
"}",
"return",
"$",
"uri",
";",
"}"
] |
Get the URI for a non-AJAX Request.
@return string the Widget URI
@throws ViewHelper\Exception
@todo argumentsToBeExcludedFromQueryString does not work yet, needs to be fixed.
|
[
"Get",
"the",
"URI",
"for",
"a",
"non",
"-",
"AJAX",
"Request",
"."
] |
ded6be84a9487f7e0e204703a30b12d2c58c0efd
|
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/ViewHelpers/Widget/LinkViewHelper.php#L134-L156
|
221,491
|
CapMousse/React-Restify
|
src/Routing/Router.php
|
Router.addMiddleware
|
public function addMiddleware($callback)
{
$this->middlewares[] = function (Callable $next, Request $request, Response $response) use ($callback) {
$container = Container::getInstance();
$parameters = array_merge([
"request" => $request,
"response" => $response,
"next" => $next
], $request->getData());
$container->call($callback, $parameters);
};
}
|
php
|
public function addMiddleware($callback)
{
$this->middlewares[] = function (Callable $next, Request $request, Response $response) use ($callback) {
$container = Container::getInstance();
$parameters = array_merge([
"request" => $request,
"response" => $response,
"next" => $next
], $request->getData());
$container->call($callback, $parameters);
};
}
|
[
"public",
"function",
"addMiddleware",
"(",
"$",
"callback",
")",
"{",
"$",
"this",
"->",
"middlewares",
"[",
"]",
"=",
"function",
"(",
"Callable",
"$",
"next",
",",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
")",
"use",
"(",
"$",
"callback",
")",
"{",
"$",
"container",
"=",
"Container",
"::",
"getInstance",
"(",
")",
";",
"$",
"parameters",
"=",
"array_merge",
"(",
"[",
"\"request\"",
"=>",
"$",
"request",
",",
"\"response\"",
"=>",
"$",
"response",
",",
"\"next\"",
"=>",
"$",
"next",
"]",
",",
"$",
"request",
"->",
"getData",
"(",
")",
")",
";",
"$",
"container",
"->",
"call",
"(",
"$",
"callback",
",",
"$",
"parameters",
")",
";",
"}",
";",
"}"
] |
Add a middleware
@param string|Callable $callback
|
[
"Add",
"a",
"middleware"
] |
51fe94d6e4c7fafec06fb304f9e44badde4bfe71
|
https://github.com/CapMousse/React-Restify/blob/51fe94d6e4c7fafec06fb304f9e44badde4bfe71/src/Routing/Router.php#L98-L110
|
221,492
|
CapMousse/React-Restify
|
src/Routing/Router.php
|
Router.launch
|
public function launch(Request $request, Response $response)
{
if (count($this->routes) === 0) {
throw new \RuntimeException("No routes defined");
}
$this->uri = $request->httpRequest->getPath();
if ($this->uri = null) {
$this->uri = "/";
}
$request->on('end', function () use (&$request, &$response) {
$this->matchRoutes($request, $response);
});
$request->on('error', function ($error) use (&$request, &$response) {
$this->emit('error', [$request, $response, $error]);
});
$request->parseData();
}
|
php
|
public function launch(Request $request, Response $response)
{
if (count($this->routes) === 0) {
throw new \RuntimeException("No routes defined");
}
$this->uri = $request->httpRequest->getPath();
if ($this->uri = null) {
$this->uri = "/";
}
$request->on('end', function () use (&$request, &$response) {
$this->matchRoutes($request, $response);
});
$request->on('error', function ($error) use (&$request, &$response) {
$this->emit('error', [$request, $response, $error]);
});
$request->parseData();
}
|
[
"public",
"function",
"launch",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"routes",
")",
"===",
"0",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"No routes defined\"",
")",
";",
"}",
"$",
"this",
"->",
"uri",
"=",
"$",
"request",
"->",
"httpRequest",
"->",
"getPath",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"uri",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"uri",
"=",
"\"/\"",
";",
"}",
"$",
"request",
"->",
"on",
"(",
"'end'",
",",
"function",
"(",
")",
"use",
"(",
"&",
"$",
"request",
",",
"&",
"$",
"response",
")",
"{",
"$",
"this",
"->",
"matchRoutes",
"(",
"$",
"request",
",",
"$",
"response",
")",
";",
"}",
")",
";",
"$",
"request",
"->",
"on",
"(",
"'error'",
",",
"function",
"(",
"$",
"error",
")",
"use",
"(",
"&",
"$",
"request",
",",
"&",
"$",
"response",
")",
"{",
"$",
"this",
"->",
"emit",
"(",
"'error'",
",",
"[",
"$",
"request",
",",
"$",
"response",
",",
"$",
"error",
"]",
")",
";",
"}",
")",
";",
"$",
"request",
"->",
"parseData",
"(",
")",
";",
"}"
] |
Launch the route parsing
@param \React\Http\Request $request
@param \React\Restify\Response $response
@throws \RuntimeException
@return Void
|
[
"Launch",
"the",
"route",
"parsing"
] |
51fe94d6e4c7fafec06fb304f9e44badde4bfe71
|
https://github.com/CapMousse/React-Restify/blob/51fe94d6e4c7fafec06fb304f9e44badde4bfe71/src/Routing/Router.php#L121-L142
|
221,493
|
CapMousse/React-Restify
|
src/Routing/Router.php
|
Router.matchRoutes
|
private function matchRoutes(Request $request, Response $response)
{
$stack = [];
$path = $request->httpRequest->getPath();
$method = $request->httpRequest->getMethod();
foreach ($this->routes as $route) {
if (!$route->match($path, $method)) {
continue;
}
$methodArgs = $route->getArgs($path);
$request->setData($methodArgs);
$route->on('error', function (...$args) {
$this->emit('error', $args);
});
$stack[] = function (...$params) use ($route) {
$route->run(...$params);
};
}
if (count($stack) == 0) {
$this->emit('NotFound', array($request, $response));
return;
}
$this->runStack($stack, $request, $response);
}
|
php
|
private function matchRoutes(Request $request, Response $response)
{
$stack = [];
$path = $request->httpRequest->getPath();
$method = $request->httpRequest->getMethod();
foreach ($this->routes as $route) {
if (!$route->match($path, $method)) {
continue;
}
$methodArgs = $route->getArgs($path);
$request->setData($methodArgs);
$route->on('error', function (...$args) {
$this->emit('error', $args);
});
$stack[] = function (...$params) use ($route) {
$route->run(...$params);
};
}
if (count($stack) == 0) {
$this->emit('NotFound', array($request, $response));
return;
}
$this->runStack($stack, $request, $response);
}
|
[
"private",
"function",
"matchRoutes",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
")",
"{",
"$",
"stack",
"=",
"[",
"]",
";",
"$",
"path",
"=",
"$",
"request",
"->",
"httpRequest",
"->",
"getPath",
"(",
")",
";",
"$",
"method",
"=",
"$",
"request",
"->",
"httpRequest",
"->",
"getMethod",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"routes",
"as",
"$",
"route",
")",
"{",
"if",
"(",
"!",
"$",
"route",
"->",
"match",
"(",
"$",
"path",
",",
"$",
"method",
")",
")",
"{",
"continue",
";",
"}",
"$",
"methodArgs",
"=",
"$",
"route",
"->",
"getArgs",
"(",
"$",
"path",
")",
";",
"$",
"request",
"->",
"setData",
"(",
"$",
"methodArgs",
")",
";",
"$",
"route",
"->",
"on",
"(",
"'error'",
",",
"function",
"(",
"...",
"$",
"args",
")",
"{",
"$",
"this",
"->",
"emit",
"(",
"'error'",
",",
"$",
"args",
")",
";",
"}",
")",
";",
"$",
"stack",
"[",
"]",
"=",
"function",
"(",
"...",
"$",
"params",
")",
"use",
"(",
"$",
"route",
")",
"{",
"$",
"route",
"->",
"run",
"(",
"...",
"$",
"params",
")",
";",
"}",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"stack",
")",
"==",
"0",
")",
"{",
"$",
"this",
"->",
"emit",
"(",
"'NotFound'",
",",
"array",
"(",
"$",
"request",
",",
"$",
"response",
")",
")",
";",
"return",
";",
"}",
"$",
"this",
"->",
"runStack",
"(",
"$",
"stack",
",",
"$",
"request",
",",
"$",
"response",
")",
";",
"}"
] |
Try to match the current uri with all routes
@param \React\Http\Request $request
@param \React\Restify\Response $response
@throws \RuntimeException
@return Void
|
[
"Try",
"to",
"match",
"the",
"current",
"uri",
"with",
"all",
"routes"
] |
51fe94d6e4c7fafec06fb304f9e44badde4bfe71
|
https://github.com/CapMousse/React-Restify/blob/51fe94d6e4c7fafec06fb304f9e44badde4bfe71/src/Routing/Router.php#L154-L183
|
221,494
|
CapMousse/React-Restify
|
src/Routing/Router.php
|
Router.runStack
|
protected function runStack(array $stack, Request $request, Response $response)
{
$stack[] = function () use ($response) {
$response->end();
};
$finalStack = array_merge($this->middlewares, $stack);
$this->waterfall($finalStack, [$request, $response]);
}
|
php
|
protected function runStack(array $stack, Request $request, Response $response)
{
$stack[] = function () use ($response) {
$response->end();
};
$finalStack = array_merge($this->middlewares, $stack);
$this->waterfall($finalStack, [$request, $response]);
}
|
[
"protected",
"function",
"runStack",
"(",
"array",
"$",
"stack",
",",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
")",
"{",
"$",
"stack",
"[",
"]",
"=",
"function",
"(",
")",
"use",
"(",
"$",
"response",
")",
"{",
"$",
"response",
"->",
"end",
"(",
")",
";",
"}",
";",
"$",
"finalStack",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"middlewares",
",",
"$",
"stack",
")",
";",
"$",
"this",
"->",
"waterfall",
"(",
"$",
"finalStack",
",",
"[",
"$",
"request",
",",
"$",
"response",
"]",
")",
";",
"}"
] |
Launch route stack
@param array $stack
@param Request $request
@param Response $response
@return void
|
[
"Launch",
"route",
"stack"
] |
51fe94d6e4c7fafec06fb304f9e44badde4bfe71
|
https://github.com/CapMousse/React-Restify/blob/51fe94d6e4c7fafec06fb304f9e44badde4bfe71/src/Routing/Router.php#L192-L200
|
221,495
|
twizoapi/lib-api-php
|
src/Entity/Poll.php
|
Poll.delete
|
public function delete()
{
if ($this->batchId !== null) {
$this->sendApiCall(self::ACTION_REMOVE, $this->getCreateUrl() . '/' . urlencode($this->batchId));
}
}
|
php
|
public function delete()
{
if ($this->batchId !== null) {
$this->sendApiCall(self::ACTION_REMOVE, $this->getCreateUrl() . '/' . urlencode($this->batchId));
}
}
|
[
"public",
"function",
"delete",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"batchId",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"sendApiCall",
"(",
"self",
"::",
"ACTION_REMOVE",
",",
"$",
"this",
"->",
"getCreateUrl",
"(",
")",
".",
"'/'",
".",
"urlencode",
"(",
"$",
"this",
"->",
"batchId",
")",
")",
";",
"}",
"}"
] |
Delete the poll messages from the server
|
[
"Delete",
"the",
"poll",
"messages",
"from",
"the",
"server"
] |
2e545d859784184138332c9b5bfc063940e3c926
|
https://github.com/twizoapi/lib-api-php/blob/2e545d859784184138332c9b5bfc063940e3c926/src/Entity/Poll.php#L56-L61
|
221,496
|
twizoapi/lib-api-php
|
src/Entity/Poll.php
|
Poll.setFields
|
public function setFields(array $fields)
{
parent::setFields($fields);
if (empty($this->batchId)) {
$this->batchId = null;
}
if (isset($fields['_embedded']['messages'])) {
$this->messages = $fields['_embedded']['messages'];
}
}
|
php
|
public function setFields(array $fields)
{
parent::setFields($fields);
if (empty($this->batchId)) {
$this->batchId = null;
}
if (isset($fields['_embedded']['messages'])) {
$this->messages = $fields['_embedded']['messages'];
}
}
|
[
"public",
"function",
"setFields",
"(",
"array",
"$",
"fields",
")",
"{",
"parent",
"::",
"setFields",
"(",
"$",
"fields",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"batchId",
")",
")",
"{",
"$",
"this",
"->",
"batchId",
"=",
"null",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"fields",
"[",
"'_embedded'",
"]",
"[",
"'messages'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"messages",
"=",
"$",
"fields",
"[",
"'_embedded'",
"]",
"[",
"'messages'",
"]",
";",
"}",
"}"
] |
Set the fields for the object
@param array $fields
|
[
"Set",
"the",
"fields",
"for",
"the",
"object"
] |
2e545d859784184138332c9b5bfc063940e3c926
|
https://github.com/twizoapi/lib-api-php/blob/2e545d859784184138332c9b5bfc063940e3c926/src/Entity/Poll.php#L98-L108
|
221,497
|
CapMousse/React-Restify
|
src/Server.php
|
Server.initEvents
|
private function initEvents()
{
$this->router->on('NotFound', function($request, $response) {
$response
->setStatus(404)
->write('Not found')
->end();
});
$this->router->on('error', function ($request, $response, $error) {
$response
->reset()
->setStatus(500)
->write($error)
->end();
});
}
|
php
|
private function initEvents()
{
$this->router->on('NotFound', function($request, $response) {
$response
->setStatus(404)
->write('Not found')
->end();
});
$this->router->on('error', function ($request, $response, $error) {
$response
->reset()
->setStatus(500)
->write($error)
->end();
});
}
|
[
"private",
"function",
"initEvents",
"(",
")",
"{",
"$",
"this",
"->",
"router",
"->",
"on",
"(",
"'NotFound'",
",",
"function",
"(",
"$",
"request",
",",
"$",
"response",
")",
"{",
"$",
"response",
"->",
"setStatus",
"(",
"404",
")",
"->",
"write",
"(",
"'Not found'",
")",
"->",
"end",
"(",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"router",
"->",
"on",
"(",
"'error'",
",",
"function",
"(",
"$",
"request",
",",
"$",
"response",
",",
"$",
"error",
")",
"{",
"$",
"response",
"->",
"reset",
"(",
")",
"->",
"setStatus",
"(",
"500",
")",
"->",
"write",
"(",
"$",
"error",
")",
"->",
"end",
"(",
")",
";",
"}",
")",
";",
"}"
] |
Init default event catch
@return void
|
[
"Init",
"default",
"event",
"catch"
] |
51fe94d6e4c7fafec06fb304f9e44badde4bfe71
|
https://github.com/CapMousse/React-Restify/blob/51fe94d6e4c7fafec06fb304f9e44badde4bfe71/src/Server.php#L100-L116
|
221,498
|
CapMousse/React-Restify
|
src/Server.php
|
Server.on
|
public function on($event, $callback)
{
$this->router->removeAllListeners($event);
$this->router->on($event, $callback);
}
|
php
|
public function on($event, $callback)
{
$this->router->removeAllListeners($event);
$this->router->on($event, $callback);
}
|
[
"public",
"function",
"on",
"(",
"$",
"event",
",",
"$",
"callback",
")",
"{",
"$",
"this",
"->",
"router",
"->",
"removeAllListeners",
"(",
"$",
"event",
")",
";",
"$",
"this",
"->",
"router",
"->",
"on",
"(",
"$",
"event",
",",
"$",
"callback",
")",
";",
"}"
] |
Manual router event manager
@param String $event
@param Callable|string $callback
|
[
"Manual",
"router",
"event",
"manager"
] |
51fe94d6e4c7fafec06fb304f9e44badde4bfe71
|
https://github.com/CapMousse/React-Restify/blob/51fe94d6e4c7fafec06fb304f9e44badde4bfe71/src/Server.php#L123-L127
|
221,499
|
CapMousse/React-Restify
|
src/Server.php
|
Server.listen
|
public function listen($port, $host = "127.0.0.1")
{
$runner = new Runner($this);
$runner->listen($port, $host);
return $this;
}
|
php
|
public function listen($port, $host = "127.0.0.1")
{
$runner = new Runner($this);
$runner->listen($port, $host);
return $this;
}
|
[
"public",
"function",
"listen",
"(",
"$",
"port",
",",
"$",
"host",
"=",
"\"127.0.0.1\"",
")",
"{",
"$",
"runner",
"=",
"new",
"Runner",
"(",
"$",
"this",
")",
";",
"$",
"runner",
"->",
"listen",
"(",
"$",
"port",
",",
"$",
"host",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Create runner instance
@param Int $port
@param String $host
@return Server
|
[
"Create",
"runner",
"instance"
] |
51fe94d6e4c7fafec06fb304f9e44badde4bfe71
|
https://github.com/CapMousse/React-Restify/blob/51fe94d6e4c7fafec06fb304f9e44badde4bfe71/src/Server.php#L135-L141
|
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.