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,900
|
ins0/google-measurement-php-client
|
src/Racecore/GATracking/Client/Adapter/Socket.php
|
Socket.writeHeader
|
private function writeHeader($endpoint, Request\TrackingRequest $request, $lastData = false)
{
// create data
$payloadString = http_build_query($request->getPayload());
$payloadLength = strlen($payloadString);
$header = 'POST ' . $endpoint['path'] . ' HTTP/1.1' . "\r\n" .
'Host: ' . $endpoint['host'] . "\r\n" .
'User-Agent: Google-Measurement-PHP-Client' . "\r\n" .
'Content-Length: ' . $payloadLength . "\r\n" .
($lastData ? 'Connection: Close' . "\r\n" : '') . "\r\n";
// fwrite + check if fwrite was ok
if (!socket_write($this->connection, $header) || !socket_write($this->connection, $payloadString)) {
$errorcode = socket_last_error();
$errormsg = socket_strerror($errorcode);
throw new Exception\EndpointServerException('Server closed connection unexpectedly. Error: ' . $errormsg);
}
return $header;
}
|
php
|
private function writeHeader($endpoint, Request\TrackingRequest $request, $lastData = false)
{
// create data
$payloadString = http_build_query($request->getPayload());
$payloadLength = strlen($payloadString);
$header = 'POST ' . $endpoint['path'] . ' HTTP/1.1' . "\r\n" .
'Host: ' . $endpoint['host'] . "\r\n" .
'User-Agent: Google-Measurement-PHP-Client' . "\r\n" .
'Content-Length: ' . $payloadLength . "\r\n" .
($lastData ? 'Connection: Close' . "\r\n" : '') . "\r\n";
// fwrite + check if fwrite was ok
if (!socket_write($this->connection, $header) || !socket_write($this->connection, $payloadString)) {
$errorcode = socket_last_error();
$errormsg = socket_strerror($errorcode);
throw new Exception\EndpointServerException('Server closed connection unexpectedly. Error: ' . $errormsg);
}
return $header;
}
|
[
"private",
"function",
"writeHeader",
"(",
"$",
"endpoint",
",",
"Request",
"\\",
"TrackingRequest",
"$",
"request",
",",
"$",
"lastData",
"=",
"false",
")",
"{",
"// create data",
"$",
"payloadString",
"=",
"http_build_query",
"(",
"$",
"request",
"->",
"getPayload",
"(",
")",
")",
";",
"$",
"payloadLength",
"=",
"strlen",
"(",
"$",
"payloadString",
")",
";",
"$",
"header",
"=",
"'POST '",
".",
"$",
"endpoint",
"[",
"'path'",
"]",
".",
"' HTTP/1.1'",
".",
"\"\\r\\n\"",
".",
"'Host: '",
".",
"$",
"endpoint",
"[",
"'host'",
"]",
".",
"\"\\r\\n\"",
".",
"'User-Agent: Google-Measurement-PHP-Client'",
".",
"\"\\r\\n\"",
".",
"'Content-Length: '",
".",
"$",
"payloadLength",
".",
"\"\\r\\n\"",
".",
"(",
"$",
"lastData",
"?",
"'Connection: Close'",
".",
"\"\\r\\n\"",
":",
"''",
")",
".",
"\"\\r\\n\"",
";",
"// fwrite + check if fwrite was ok",
"if",
"(",
"!",
"socket_write",
"(",
"$",
"this",
"->",
"connection",
",",
"$",
"header",
")",
"||",
"!",
"socket_write",
"(",
"$",
"this",
"->",
"connection",
",",
"$",
"payloadString",
")",
")",
"{",
"$",
"errorcode",
"=",
"socket_last_error",
"(",
")",
";",
"$",
"errormsg",
"=",
"socket_strerror",
"(",
"$",
"errorcode",
")",
";",
"throw",
"new",
"Exception",
"\\",
"EndpointServerException",
"(",
"'Server closed connection unexpectedly. Error: '",
".",
"$",
"errormsg",
")",
";",
"}",
"return",
"$",
"header",
";",
"}"
] |
Write the connection header
@param $endpoint
@param Request\TrackingRequest $request
@param bool $lastData
@return string
@throws Exception\EndpointServerException
|
[
"Write",
"the",
"connection",
"header"
] |
415cabca0c6d83cd0bd6a8ed6fb695b35f892018
|
https://github.com/ins0/google-measurement-php-client/blob/415cabca0c6d83cd0bd6a8ed6fb695b35f892018/src/Racecore/GATracking/Client/Adapter/Socket.php#L55-L75
|
221,901
|
ins0/google-measurement-php-client
|
src/Racecore/GATracking/Client/Adapter/Socket.php
|
Socket.readConnection
|
private function readConnection(Request\TrackingRequest $request)
{
// response
$response = '';
// receive response
do {
$out = @socket_read($this->connection, self::READ_BUFFER);
$response .= $out;
if (!$out || strlen($out) < self::READ_BUFFER) {
break;
}
} while (true);
// response
$responseContainer = explode("\r\n\r\n", $response, 2);
return explode("\r\n", $responseContainer[0]);
}
|
php
|
private function readConnection(Request\TrackingRequest $request)
{
// response
$response = '';
// receive response
do {
$out = @socket_read($this->connection, self::READ_BUFFER);
$response .= $out;
if (!$out || strlen($out) < self::READ_BUFFER) {
break;
}
} while (true);
// response
$responseContainer = explode("\r\n\r\n", $response, 2);
return explode("\r\n", $responseContainer[0]);
}
|
[
"private",
"function",
"readConnection",
"(",
"Request",
"\\",
"TrackingRequest",
"$",
"request",
")",
"{",
"// response",
"$",
"response",
"=",
"''",
";",
"// receive response",
"do",
"{",
"$",
"out",
"=",
"@",
"socket_read",
"(",
"$",
"this",
"->",
"connection",
",",
"self",
"::",
"READ_BUFFER",
")",
";",
"$",
"response",
".=",
"$",
"out",
";",
"if",
"(",
"!",
"$",
"out",
"||",
"strlen",
"(",
"$",
"out",
")",
"<",
"self",
"::",
"READ_BUFFER",
")",
"{",
"break",
";",
"}",
"}",
"while",
"(",
"true",
")",
";",
"// response",
"$",
"responseContainer",
"=",
"explode",
"(",
"\"\\r\\n\\r\\n\"",
",",
"$",
"response",
",",
"2",
")",
";",
"return",
"explode",
"(",
"\"\\r\\n\"",
",",
"$",
"responseContainer",
"[",
"0",
"]",
")",
";",
"}"
] |
Read from the current connection
@param Request\TrackingRequest $request
@return array|false
|
[
"Read",
"from",
"the",
"current",
"connection"
] |
415cabca0c6d83cd0bd6a8ed6fb695b35f892018
|
https://github.com/ins0/google-measurement-php-client/blob/415cabca0c6d83cd0bd6a8ed6fb695b35f892018/src/Racecore/GATracking/Client/Adapter/Socket.php#L82-L100
|
221,902
|
ins0/google-measurement-php-client
|
src/Racecore/GATracking/Client/Adapter/Socket.php
|
Socket.send
|
public function send($url, Request\TrackingRequestCollection $requestCollection)
{
// get endpoint
$endpoint = parse_url($url);
$this->createConnection($endpoint);
/** @var Request\TrackingRequest $request */
while ($requestCollection->valid()) {
$request = $requestCollection->current();
$requestCollection->next();
$this->writeHeader($endpoint, $request, !$requestCollection->valid());
$responseHeader = $this->readConnection($request);
$request->setResponseHeader($responseHeader);
}
// connection close
socket_close($this->connection);
return $requestCollection;
}
|
php
|
public function send($url, Request\TrackingRequestCollection $requestCollection)
{
// get endpoint
$endpoint = parse_url($url);
$this->createConnection($endpoint);
/** @var Request\TrackingRequest $request */
while ($requestCollection->valid()) {
$request = $requestCollection->current();
$requestCollection->next();
$this->writeHeader($endpoint, $request, !$requestCollection->valid());
$responseHeader = $this->readConnection($request);
$request->setResponseHeader($responseHeader);
}
// connection close
socket_close($this->connection);
return $requestCollection;
}
|
[
"public",
"function",
"send",
"(",
"$",
"url",
",",
"Request",
"\\",
"TrackingRequestCollection",
"$",
"requestCollection",
")",
"{",
"// get endpoint",
"$",
"endpoint",
"=",
"parse_url",
"(",
"$",
"url",
")",
";",
"$",
"this",
"->",
"createConnection",
"(",
"$",
"endpoint",
")",
";",
"/** @var Request\\TrackingRequest $request */",
"while",
"(",
"$",
"requestCollection",
"->",
"valid",
"(",
")",
")",
"{",
"$",
"request",
"=",
"$",
"requestCollection",
"->",
"current",
"(",
")",
";",
"$",
"requestCollection",
"->",
"next",
"(",
")",
";",
"$",
"this",
"->",
"writeHeader",
"(",
"$",
"endpoint",
",",
"$",
"request",
",",
"!",
"$",
"requestCollection",
"->",
"valid",
"(",
")",
")",
";",
"$",
"responseHeader",
"=",
"$",
"this",
"->",
"readConnection",
"(",
"$",
"request",
")",
";",
"$",
"request",
"->",
"setResponseHeader",
"(",
"$",
"responseHeader",
")",
";",
"}",
"// connection close",
"socket_close",
"(",
"$",
"this",
"->",
"connection",
")",
";",
"return",
"$",
"requestCollection",
";",
"}"
] |
Send the Request Collection to a Server
@param $url
@param Request\TrackingRequestCollection $requestCollection
@return Request\TrackingRequestCollection|void
@throws Exception\EndpointServerException
|
[
"Send",
"the",
"Request",
"Collection",
"to",
"a",
"Server"
] |
415cabca0c6d83cd0bd6a8ed6fb695b35f892018
|
https://github.com/ins0/google-measurement-php-client/blob/415cabca0c6d83cd0bd6a8ed6fb695b35f892018/src/Racecore/GATracking/Client/Adapter/Socket.php#L109-L130
|
221,903
|
wallee-payment/php-sdk
|
lib/Model/SubscriptionAffiliate.php
|
SubscriptionAffiliate.setMetaData
|
public function setMetaData($metaData) {
if (is_array($metaData) && empty($metaData)) {
$this->metaData = new \stdClass;
} else {
$this->metaData = $metaData;
}
return $this;
}
|
php
|
public function setMetaData($metaData) {
if (is_array($metaData) && empty($metaData)) {
$this->metaData = new \stdClass;
} else {
$this->metaData = $metaData;
}
return $this;
}
|
[
"public",
"function",
"setMetaData",
"(",
"$",
"metaData",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"metaData",
")",
"&&",
"empty",
"(",
"$",
"metaData",
")",
")",
"{",
"$",
"this",
"->",
"metaData",
"=",
"new",
"\\",
"stdClass",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"metaData",
"=",
"$",
"metaData",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Sets metaData.
@param map[string,string] $metaData
@return SubscriptionAffiliate
|
[
"Sets",
"metaData",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/Model/SubscriptionAffiliate.php#L273-L281
|
221,904
|
wallee-payment/php-sdk
|
lib/Model/LineItemCreate.php
|
LineItemCreate.setAttributes
|
public function setAttributes($attributes) {
if (is_array($attributes) && empty($attributes)) {
$this->attributes = new \stdClass;
} else {
$this->attributes = $attributes;
}
return $this;
}
|
php
|
public function setAttributes($attributes) {
if (is_array($attributes) && empty($attributes)) {
$this->attributes = new \stdClass;
} else {
$this->attributes = $attributes;
}
return $this;
}
|
[
"public",
"function",
"setAttributes",
"(",
"$",
"attributes",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"attributes",
")",
"&&",
"empty",
"(",
"$",
"attributes",
")",
")",
"{",
"$",
"this",
"->",
"attributes",
"=",
"new",
"\\",
"stdClass",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"attributes",
"=",
"$",
"attributes",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Sets attributes.
@param map[string,\Wallee\Sdk\Model\LineItemAttributeCreate] $attributes
@return LineItemCreate
|
[
"Sets",
"attributes",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/Model/LineItemCreate.php#L222-L230
|
221,905
|
subugoe/typo3-find
|
Classes/Service/SolrServiceProvider.php
|
SolrServiceProvider.getActiveFacets
|
protected function getActiveFacets($arguments)
{
$activeFacets = [];
// Add facets activated by default.
foreach ($this->settings['facets'] as $facet) {
if (!empty($facet['selectedByDefault'])) {
$this->setActiveFacetSelectionForID($activeFacets, $facet['id'], $facet['selectedByDefault']);
}
}
// Add facets activated by query parameters.
if (array_key_exists('facet', $arguments)) {
foreach ($arguments['facet'] as $facetID => $facetSelection) {
$this->setActiveFacetSelectionForID($activeFacets, $facetID, $facetSelection);
}
}
return $activeFacets;
}
|
php
|
protected function getActiveFacets($arguments)
{
$activeFacets = [];
// Add facets activated by default.
foreach ($this->settings['facets'] as $facet) {
if (!empty($facet['selectedByDefault'])) {
$this->setActiveFacetSelectionForID($activeFacets, $facet['id'], $facet['selectedByDefault']);
}
}
// Add facets activated by query parameters.
if (array_key_exists('facet', $arguments)) {
foreach ($arguments['facet'] as $facetID => $facetSelection) {
$this->setActiveFacetSelectionForID($activeFacets, $facetID, $facetSelection);
}
}
return $activeFacets;
}
|
[
"protected",
"function",
"getActiveFacets",
"(",
"$",
"arguments",
")",
"{",
"$",
"activeFacets",
"=",
"[",
"]",
";",
"// Add facets activated by default.",
"foreach",
"(",
"$",
"this",
"->",
"settings",
"[",
"'facets'",
"]",
"as",
"$",
"facet",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"facet",
"[",
"'selectedByDefault'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"setActiveFacetSelectionForID",
"(",
"$",
"activeFacets",
",",
"$",
"facet",
"[",
"'id'",
"]",
",",
"$",
"facet",
"[",
"'selectedByDefault'",
"]",
")",
";",
"}",
"}",
"// Add facets activated by query parameters.",
"if",
"(",
"array_key_exists",
"(",
"'facet'",
",",
"$",
"arguments",
")",
")",
"{",
"foreach",
"(",
"$",
"arguments",
"[",
"'facet'",
"]",
"as",
"$",
"facetID",
"=>",
"$",
"facetSelection",
")",
"{",
"$",
"this",
"->",
"setActiveFacetSelectionForID",
"(",
"$",
"activeFacets",
",",
"$",
"facetID",
",",
"$",
"facetSelection",
")",
";",
"}",
"}",
"return",
"$",
"activeFacets",
";",
"}"
] |
Returns array with information about active facets.
@param array $arguments request arguments
@return array of arrays with information about active facets
|
[
"Returns",
"array",
"with",
"information",
"about",
"active",
"facets",
"."
] |
d628a0b6a131d05f4842b08a556fe17cba9d7da0
|
https://github.com/subugoe/typo3-find/blob/d628a0b6a131d05f4842b08a556fe17cba9d7da0/Classes/Service/SolrServiceProvider.php#L321-L340
|
221,906
|
subugoe/typo3-find
|
Classes/Service/SolrServiceProvider.php
|
SolrServiceProvider.getOffset
|
protected function getOffset($arguments = null)
{
if (null === $arguments) {
$arguments = $this->requestArguments;
}
$offset = 0;
if (array_key_exists('start', $arguments)) {
$offset = (int) $arguments['start'];
} else {
if (array_key_exists('page', $arguments)) {
$offset = ((int) $arguments['page'] - 1) * $this->getCount();
}
}
$this->setConfigurationValue('offset', $offset);
return $offset;
}
|
php
|
protected function getOffset($arguments = null)
{
if (null === $arguments) {
$arguments = $this->requestArguments;
}
$offset = 0;
if (array_key_exists('start', $arguments)) {
$offset = (int) $arguments['start'];
} else {
if (array_key_exists('page', $arguments)) {
$offset = ((int) $arguments['page'] - 1) * $this->getCount();
}
}
$this->setConfigurationValue('offset', $offset);
return $offset;
}
|
[
"protected",
"function",
"getOffset",
"(",
"$",
"arguments",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"arguments",
")",
"{",
"$",
"arguments",
"=",
"$",
"this",
"->",
"requestArguments",
";",
"}",
"$",
"offset",
"=",
"0",
";",
"if",
"(",
"array_key_exists",
"(",
"'start'",
",",
"$",
"arguments",
")",
")",
"{",
"$",
"offset",
"=",
"(",
"int",
")",
"$",
"arguments",
"[",
"'start'",
"]",
";",
"}",
"else",
"{",
"if",
"(",
"array_key_exists",
"(",
"'page'",
",",
"$",
"arguments",
")",
")",
"{",
"$",
"offset",
"=",
"(",
"(",
"int",
")",
"$",
"arguments",
"[",
"'page'",
"]",
"-",
"1",
")",
"*",
"$",
"this",
"->",
"getCount",
"(",
")",
";",
"}",
"}",
"$",
"this",
"->",
"setConfigurationValue",
"(",
"'offset'",
",",
"$",
"offset",
")",
";",
"return",
"$",
"offset",
";",
"}"
] |
Returns the index of the first row to return.
@param array $arguments overrides $this->requestArguments if set
@return int
|
[
"Returns",
"the",
"index",
"of",
"the",
"first",
"row",
"to",
"return",
"."
] |
d628a0b6a131d05f4842b08a556fe17cba9d7da0
|
https://github.com/subugoe/typo3-find/blob/d628a0b6a131d05f4842b08a556fe17cba9d7da0/Classes/Service/SolrServiceProvider.php#L452-L471
|
221,907
|
subugoe/typo3-find
|
Classes/Service/SolrServiceProvider.php
|
SolrServiceProvider.isExtendedSearch
|
public function isExtendedSearch()
{
$result = false;
if (array_key_exists('extended', $this->requestArguments)) {
// Show extended search when told so by the »extended« argument.
$result = (true == $this->requestArguments['extended']);
} else {
// Show extended search when any of the »extended« fields are used.
if (array_key_exists('q', $this->requestArguments)) {
foreach ($this->settings['queryFields'] as $fieldInfo) {
if ($fieldInfo['extended']
&& array_key_exists($fieldInfo['id'], $this->requestArguments['q'])
&& $this->requestArguments['q'][$fieldInfo['id']]
) {
$result = true;
break;
}
}
}
}
return $result;
}
|
php
|
public function isExtendedSearch()
{
$result = false;
if (array_key_exists('extended', $this->requestArguments)) {
// Show extended search when told so by the »extended« argument.
$result = (true == $this->requestArguments['extended']);
} else {
// Show extended search when any of the »extended« fields are used.
if (array_key_exists('q', $this->requestArguments)) {
foreach ($this->settings['queryFields'] as $fieldInfo) {
if ($fieldInfo['extended']
&& array_key_exists($fieldInfo['id'], $this->requestArguments['q'])
&& $this->requestArguments['q'][$fieldInfo['id']]
) {
$result = true;
break;
}
}
}
}
return $result;
}
|
[
"public",
"function",
"isExtendedSearch",
"(",
")",
"{",
"$",
"result",
"=",
"false",
";",
"if",
"(",
"array_key_exists",
"(",
"'extended'",
",",
"$",
"this",
"->",
"requestArguments",
")",
")",
"{",
"// Show extended search when told so by the »extended« argument.",
"$",
"result",
"=",
"(",
"true",
"==",
"$",
"this",
"->",
"requestArguments",
"[",
"'extended'",
"]",
")",
";",
"}",
"else",
"{",
"// Show extended search when any of the »extended« fields are used.",
"if",
"(",
"array_key_exists",
"(",
"'q'",
",",
"$",
"this",
"->",
"requestArguments",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"settings",
"[",
"'queryFields'",
"]",
"as",
"$",
"fieldInfo",
")",
"{",
"if",
"(",
"$",
"fieldInfo",
"[",
"'extended'",
"]",
"&&",
"array_key_exists",
"(",
"$",
"fieldInfo",
"[",
"'id'",
"]",
",",
"$",
"this",
"->",
"requestArguments",
"[",
"'q'",
"]",
")",
"&&",
"$",
"this",
"->",
"requestArguments",
"[",
"'q'",
"]",
"[",
"$",
"fieldInfo",
"[",
"'id'",
"]",
"]",
")",
"{",
"$",
"result",
"=",
"true",
";",
"break",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Returns whether extended search should be used or not.
@return bool
|
[
"Returns",
"whether",
"extended",
"search",
"should",
"be",
"used",
"or",
"not",
"."
] |
d628a0b6a131d05f4842b08a556fe17cba9d7da0
|
https://github.com/subugoe/typo3-find/blob/d628a0b6a131d05f4842b08a556fe17cba9d7da0/Classes/Service/SolrServiceProvider.php#L478-L501
|
221,908
|
subugoe/typo3-find
|
Classes/Service/SolrServiceProvider.php
|
SolrServiceProvider.getDefaultQuery
|
public function getDefaultQuery()
{
$this->createQueryForArguments($this->getRequestArguments());
$error = null;
$resultSet = null;
try {
$resultSet = $this->connection->execute($this->query);
} catch (HttpException $exception) {
$this->logger->error('Solr Exception (Timeout?)',
[
'requestArguments' => $this->getRequestArguments(),
'exception' => LoggerUtility::exceptionToArray($exception),
]
);
$error = ['solr' => $exception];
}
return [
'results' => $resultSet,
'error' => $error,
];
}
|
php
|
public function getDefaultQuery()
{
$this->createQueryForArguments($this->getRequestArguments());
$error = null;
$resultSet = null;
try {
$resultSet = $this->connection->execute($this->query);
} catch (HttpException $exception) {
$this->logger->error('Solr Exception (Timeout?)',
[
'requestArguments' => $this->getRequestArguments(),
'exception' => LoggerUtility::exceptionToArray($exception),
]
);
$error = ['solr' => $exception];
}
return [
'results' => $resultSet,
'error' => $error,
];
}
|
[
"public",
"function",
"getDefaultQuery",
"(",
")",
"{",
"$",
"this",
"->",
"createQueryForArguments",
"(",
"$",
"this",
"->",
"getRequestArguments",
"(",
")",
")",
";",
"$",
"error",
"=",
"null",
";",
"$",
"resultSet",
"=",
"null",
";",
"try",
"{",
"$",
"resultSet",
"=",
"$",
"this",
"->",
"connection",
"->",
"execute",
"(",
"$",
"this",
"->",
"query",
")",
";",
"}",
"catch",
"(",
"HttpException",
"$",
"exception",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"error",
"(",
"'Solr Exception (Timeout?)'",
",",
"[",
"'requestArguments'",
"=>",
"$",
"this",
"->",
"getRequestArguments",
"(",
")",
",",
"'exception'",
"=>",
"LoggerUtility",
"::",
"exceptionToArray",
"(",
"$",
"exception",
")",
",",
"]",
")",
";",
"$",
"error",
"=",
"[",
"'solr'",
"=>",
"$",
"exception",
"]",
";",
"}",
"return",
"[",
"'results'",
"=>",
"$",
"resultSet",
",",
"'error'",
"=>",
"$",
"error",
",",
"]",
";",
"}"
] |
Main starting point for blank index action.
@return array
|
[
"Main",
"starting",
"point",
"for",
"blank",
"index",
"action",
"."
] |
d628a0b6a131d05f4842b08a556fe17cba9d7da0
|
https://github.com/subugoe/typo3-find/blob/d628a0b6a131d05f4842b08a556fe17cba9d7da0/Classes/Service/SolrServiceProvider.php#L735-L758
|
221,909
|
subugoe/typo3-find
|
Classes/Service/SolrServiceProvider.php
|
SolrServiceProvider.setFields
|
protected function setFields($arguments)
{
$fieldsConfig = SettingsUtility::getMergedSettings('dataFields', $this->settings, $this->getAction());
$fields = [];
// Use field list from query parameters or from defaults.
if (array_key_exists('data-fields', $arguments) && $arguments['data-fields']) {
$fields = explode(',', $arguments['data-fields']);
} else {
if ($fieldsConfig['default']) {
$fields = array_values($fieldsConfig['default']);
}
}
// If allowed fields are configured, keep only those.
$allowedFields = $fieldsConfig['allow'];
if ($allowedFields) {
$fields = array_intersect($fields, $allowedFields);
}
// If disallowed fields are configured, remove those.
$disallowedFields = $fieldsConfig['disallow'];
if ($disallowedFields) {
$fields = array_diff($fields, $disallowedFields);
}
// Only set fields of the query if there is a result. Otherwise use the default setting.
if ($fields) {
$this->query->setFields($fields);
}
}
|
php
|
protected function setFields($arguments)
{
$fieldsConfig = SettingsUtility::getMergedSettings('dataFields', $this->settings, $this->getAction());
$fields = [];
// Use field list from query parameters or from defaults.
if (array_key_exists('data-fields', $arguments) && $arguments['data-fields']) {
$fields = explode(',', $arguments['data-fields']);
} else {
if ($fieldsConfig['default']) {
$fields = array_values($fieldsConfig['default']);
}
}
// If allowed fields are configured, keep only those.
$allowedFields = $fieldsConfig['allow'];
if ($allowedFields) {
$fields = array_intersect($fields, $allowedFields);
}
// If disallowed fields are configured, remove those.
$disallowedFields = $fieldsConfig['disallow'];
if ($disallowedFields) {
$fields = array_diff($fields, $disallowedFields);
}
// Only set fields of the query if there is a result. Otherwise use the default setting.
if ($fields) {
$this->query->setFields($fields);
}
}
|
[
"protected",
"function",
"setFields",
"(",
"$",
"arguments",
")",
"{",
"$",
"fieldsConfig",
"=",
"SettingsUtility",
"::",
"getMergedSettings",
"(",
"'dataFields'",
",",
"$",
"this",
"->",
"settings",
",",
"$",
"this",
"->",
"getAction",
"(",
")",
")",
";",
"$",
"fields",
"=",
"[",
"]",
";",
"// Use field list from query parameters or from defaults.",
"if",
"(",
"array_key_exists",
"(",
"'data-fields'",
",",
"$",
"arguments",
")",
"&&",
"$",
"arguments",
"[",
"'data-fields'",
"]",
")",
"{",
"$",
"fields",
"=",
"explode",
"(",
"','",
",",
"$",
"arguments",
"[",
"'data-fields'",
"]",
")",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"fieldsConfig",
"[",
"'default'",
"]",
")",
"{",
"$",
"fields",
"=",
"array_values",
"(",
"$",
"fieldsConfig",
"[",
"'default'",
"]",
")",
";",
"}",
"}",
"// If allowed fields are configured, keep only those.",
"$",
"allowedFields",
"=",
"$",
"fieldsConfig",
"[",
"'allow'",
"]",
";",
"if",
"(",
"$",
"allowedFields",
")",
"{",
"$",
"fields",
"=",
"array_intersect",
"(",
"$",
"fields",
",",
"$",
"allowedFields",
")",
";",
"}",
"// If disallowed fields are configured, remove those.",
"$",
"disallowedFields",
"=",
"$",
"fieldsConfig",
"[",
"'disallow'",
"]",
";",
"if",
"(",
"$",
"disallowedFields",
")",
"{",
"$",
"fields",
"=",
"array_diff",
"(",
"$",
"fields",
",",
"$",
"disallowedFields",
")",
";",
"}",
"// Only set fields of the query if there is a result. Otherwise use the default setting.",
"if",
"(",
"$",
"fields",
")",
"{",
"$",
"this",
"->",
"query",
"->",
"setFields",
"(",
"$",
"fields",
")",
";",
"}",
"}"
] |
Sets up the fields to be fetched by the query.
@param array $arguments request arguments
|
[
"Sets",
"up",
"the",
"fields",
"to",
"be",
"fetched",
"by",
"the",
"query",
"."
] |
d628a0b6a131d05f4842b08a556fe17cba9d7da0
|
https://github.com/subugoe/typo3-find/blob/d628a0b6a131d05f4842b08a556fe17cba9d7da0/Classes/Service/SolrServiceProvider.php#L809-L839
|
221,910
|
subugoe/typo3-find
|
Classes/Service/SolrServiceProvider.php
|
SolrServiceProvider.createQuery
|
protected function createQuery()
{
$this->query = $this->connection->createSelect();
$this->addFeatures();
$this->addTypoScriptFilters();
$this->setConfigurationValue('solarium', $this->query);
}
|
php
|
protected function createQuery()
{
$this->query = $this->connection->createSelect();
$this->addFeatures();
$this->addTypoScriptFilters();
$this->setConfigurationValue('solarium', $this->query);
}
|
[
"protected",
"function",
"createQuery",
"(",
")",
"{",
"$",
"this",
"->",
"query",
"=",
"$",
"this",
"->",
"connection",
"->",
"createSelect",
"(",
")",
";",
"$",
"this",
"->",
"addFeatures",
"(",
")",
";",
"$",
"this",
"->",
"addTypoScriptFilters",
"(",
")",
";",
"$",
"this",
"->",
"setConfigurationValue",
"(",
"'solarium'",
",",
"$",
"this",
"->",
"query",
")",
";",
"}"
] |
Creates a blank query, sets up TypoScript filters and adds it to the view.
|
[
"Creates",
"a",
"blank",
"query",
"sets",
"up",
"TypoScript",
"filters",
"and",
"adds",
"it",
"to",
"the",
"view",
"."
] |
d628a0b6a131d05f4842b08a556fe17cba9d7da0
|
https://github.com/subugoe/typo3-find/blob/d628a0b6a131d05f4842b08a556fe17cba9d7da0/Classes/Service/SolrServiceProvider.php#L844-L851
|
221,911
|
wallee-payment/php-sdk
|
lib/Http/HttpClientFactory.php
|
HttpClientFactory.getClientInternal
|
private function getClientInternal($type = null) {
if ($type != null) {
if (isset($this->clients[$type])) {
return $this->clients[$type];
} else {
throw new \Exception("No http client with type '$type' found.");
}
} else {
foreach ($this->clients as $client) {
if ($client->isSupported()) {
return $client;
}
}
throw new \Exception('No supported http client found.');
}
}
|
php
|
private function getClientInternal($type = null) {
if ($type != null) {
if (isset($this->clients[$type])) {
return $this->clients[$type];
} else {
throw new \Exception("No http client with type '$type' found.");
}
} else {
foreach ($this->clients as $client) {
if ($client->isSupported()) {
return $client;
}
}
throw new \Exception('No supported http client found.');
}
}
|
[
"private",
"function",
"getClientInternal",
"(",
"$",
"type",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"type",
"!=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"clients",
"[",
"$",
"type",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"clients",
"[",
"$",
"type",
"]",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"No http client with type '$type' found.\"",
")",
";",
"}",
"}",
"else",
"{",
"foreach",
"(",
"$",
"this",
"->",
"clients",
"as",
"$",
"client",
")",
"{",
"if",
"(",
"$",
"client",
"->",
"isSupported",
"(",
")",
")",
"{",
"return",
"$",
"client",
";",
"}",
"}",
"throw",
"new",
"\\",
"Exception",
"(",
"'No supported http client found.'",
")",
";",
"}",
"}"
] |
Returns an HTTP client instance.
@return IHttpClient
|
[
"Returns",
"an",
"HTTP",
"client",
"instance",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/Http/HttpClientFactory.php#L85-L100
|
221,912
|
wallee-payment/php-sdk
|
lib/Model/ManualTaskAction.php
|
ManualTaskAction.setLabel
|
public function setLabel($label) {
if (is_array($label) && empty($label)) {
$this->label = new \stdClass;
} else {
$this->label = $label;
}
return $this;
}
|
php
|
public function setLabel($label) {
if (is_array($label) && empty($label)) {
$this->label = new \stdClass;
} else {
$this->label = $label;
}
return $this;
}
|
[
"public",
"function",
"setLabel",
"(",
"$",
"label",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"label",
")",
"&&",
"empty",
"(",
"$",
"label",
")",
")",
"{",
"$",
"this",
"->",
"label",
"=",
"new",
"\\",
"stdClass",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"label",
"=",
"$",
"label",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Sets label.
@param map[string,string] $label
@return ManualTaskAction
|
[
"Sets",
"label",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/Model/ManualTaskAction.php#L150-L158
|
221,913
|
wallee-payment/php-sdk
|
lib/Http/HttpRequest.php
|
HttpRequest.getHeaders
|
public function getHeaders() {
$headers = array();
foreach ($this->headers as $name => $values) {
foreach ($values as $value) {
$headers[] = strtolower($name) . ': ' . $value;
}
}
$headers[] = self::HEADER_KEY_CONTENT_LENGTH . ': ' . strlen($this->getBody());
return $headers;
}
|
php
|
public function getHeaders() {
$headers = array();
foreach ($this->headers as $name => $values) {
foreach ($values as $value) {
$headers[] = strtolower($name) . ': ' . $value;
}
}
$headers[] = self::HEADER_KEY_CONTENT_LENGTH . ': ' . strlen($this->getBody());
return $headers;
}
|
[
"public",
"function",
"getHeaders",
"(",
")",
"{",
"$",
"headers",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"headers",
"as",
"$",
"name",
"=>",
"$",
"values",
")",
"{",
"foreach",
"(",
"$",
"values",
"as",
"$",
"value",
")",
"{",
"$",
"headers",
"[",
"]",
"=",
"strtolower",
"(",
"$",
"name",
")",
".",
"': '",
".",
"$",
"value",
";",
"}",
"}",
"$",
"headers",
"[",
"]",
"=",
"self",
"::",
"HEADER_KEY_CONTENT_LENGTH",
".",
"': '",
".",
"strlen",
"(",
"$",
"this",
"->",
"getBody",
"(",
")",
")",
";",
"return",
"$",
"headers",
";",
"}"
] |
Returns a list of strings which represent the HTTP headers.
@return string[]
|
[
"Returns",
"a",
"list",
"of",
"strings",
"which",
"represent",
"the",
"HTTP",
"headers",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/Http/HttpRequest.php#L252-L261
|
221,914
|
wallee-payment/php-sdk
|
lib/Http/HttpRequest.php
|
HttpRequest.addHeader
|
public function addHeader($key, $value) {
if (is_array($value)) {
foreach ($value as $v) {
$this->addHeader($key, $v);
}
} else {
$this->headers[$key][] = $value;
}
return $this;
}
|
php
|
public function addHeader($key, $value) {
if (is_array($value)) {
foreach ($value as $v) {
$this->addHeader($key, $v);
}
} else {
$this->headers[$key][] = $value;
}
return $this;
}
|
[
"public",
"function",
"addHeader",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"foreach",
"(",
"$",
"value",
"as",
"$",
"v",
")",
"{",
"$",
"this",
"->",
"addHeader",
"(",
"$",
"key",
",",
"$",
"v",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"headers",
"[",
"$",
"key",
"]",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Adds an HTTP header to the request.
@param string $key the header's key
@param string $value the header's value
@return HttpRequest
|
[
"Adds",
"an",
"HTTP",
"header",
"to",
"the",
"request",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/Http/HttpRequest.php#L283-L292
|
221,915
|
wallee-payment/php-sdk
|
lib/Http/HttpRequest.php
|
HttpRequest.setUserAgent
|
public function setUserAgent($userAgent) {
$this->userAgent = $userAgent;
$this->removeHeader(self::HEADER_KEY_USER_AGENT);
$this->addHeader(self::HEADER_KEY_USER_AGENT, $userAgent);
return $this;
}
|
php
|
public function setUserAgent($userAgent) {
$this->userAgent = $userAgent;
$this->removeHeader(self::HEADER_KEY_USER_AGENT);
$this->addHeader(self::HEADER_KEY_USER_AGENT, $userAgent);
return $this;
}
|
[
"public",
"function",
"setUserAgent",
"(",
"$",
"userAgent",
")",
"{",
"$",
"this",
"->",
"userAgent",
"=",
"$",
"userAgent",
";",
"$",
"this",
"->",
"removeHeader",
"(",
"self",
"::",
"HEADER_KEY_USER_AGENT",
")",
";",
"$",
"this",
"->",
"addHeader",
"(",
"self",
"::",
"HEADER_KEY_USER_AGENT",
",",
"$",
"userAgent",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets the user agent header.
@param string $userAgent the user agent header value
@return HttpRequest
|
[
"Sets",
"the",
"user",
"agent",
"header",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/Http/HttpRequest.php#L322-L327
|
221,916
|
wallee-payment/php-sdk
|
lib/Http/HttpRequest.php
|
HttpRequest.getBody
|
public function getBody() {
if ($this->body && isset($this->headers[self::HEADER_KEY_CONTENT_TYPE]) && $this->headers[self::HEADER_KEY_CONTENT_TYPE] == 'application/x-www-form-urlencoded') {
return http_build_query($this->body);
} elseif ((is_object($this->body) || is_array($this->body)) &&
(!isset($this->headers[self::HEADER_KEY_CONTENT_TYPE]) || $this->headers[self::HEADER_KEY_CONTENT_TYPE] != 'multipart/form-data')) {
return json_encode($this->serializer->sanitizeForSerialization($this->body));
} else {
return $this->body;
}
}
|
php
|
public function getBody() {
if ($this->body && isset($this->headers[self::HEADER_KEY_CONTENT_TYPE]) && $this->headers[self::HEADER_KEY_CONTENT_TYPE] == 'application/x-www-form-urlencoded') {
return http_build_query($this->body);
} elseif ((is_object($this->body) || is_array($this->body)) &&
(!isset($this->headers[self::HEADER_KEY_CONTENT_TYPE]) || $this->headers[self::HEADER_KEY_CONTENT_TYPE] != 'multipart/form-data')) {
return json_encode($this->serializer->sanitizeForSerialization($this->body));
} else {
return $this->body;
}
}
|
[
"public",
"function",
"getBody",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"body",
"&&",
"isset",
"(",
"$",
"this",
"->",
"headers",
"[",
"self",
"::",
"HEADER_KEY_CONTENT_TYPE",
"]",
")",
"&&",
"$",
"this",
"->",
"headers",
"[",
"self",
"::",
"HEADER_KEY_CONTENT_TYPE",
"]",
"==",
"'application/x-www-form-urlencoded'",
")",
"{",
"return",
"http_build_query",
"(",
"$",
"this",
"->",
"body",
")",
";",
"}",
"elseif",
"(",
"(",
"is_object",
"(",
"$",
"this",
"->",
"body",
")",
"||",
"is_array",
"(",
"$",
"this",
"->",
"body",
")",
")",
"&&",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"headers",
"[",
"self",
"::",
"HEADER_KEY_CONTENT_TYPE",
"]",
")",
"||",
"$",
"this",
"->",
"headers",
"[",
"self",
"::",
"HEADER_KEY_CONTENT_TYPE",
"]",
"!=",
"'multipart/form-data'",
")",
")",
"{",
"return",
"json_encode",
"(",
"$",
"this",
"->",
"serializer",
"->",
"sanitizeForSerialization",
"(",
"$",
"this",
"->",
"body",
")",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"body",
";",
"}",
"}"
] |
Returns the HTTP body.
@return string
|
[
"Returns",
"the",
"HTTP",
"body",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/Http/HttpRequest.php#L352-L361
|
221,917
|
wallee-payment/php-sdk
|
lib/Http/HttpRequest.php
|
HttpRequest.toString
|
public function toString() {
$output = $this->getStatusLine() . "\r\n";
foreach ($this->getHeaders() as $header) {
$output .= $header . "\r\n";
}
$output .= "\r\n";
$output .= $this->getBody();
return $output;
}
|
php
|
public function toString() {
$output = $this->getStatusLine() . "\r\n";
foreach ($this->getHeaders() as $header) {
$output .= $header . "\r\n";
}
$output .= "\r\n";
$output .= $this->getBody();
return $output;
}
|
[
"public",
"function",
"toString",
"(",
")",
"{",
"$",
"output",
"=",
"$",
"this",
"->",
"getStatusLine",
"(",
")",
".",
"\"\\r\\n\"",
";",
"foreach",
"(",
"$",
"this",
"->",
"getHeaders",
"(",
")",
"as",
"$",
"header",
")",
"{",
"$",
"output",
".=",
"$",
"header",
".",
"\"\\r\\n\"",
";",
"}",
"$",
"output",
".=",
"\"\\r\\n\"",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"getBody",
"(",
")",
";",
"return",
"$",
"output",
";",
"}"
] |
Returns the message as a string.
@return string
|
[
"Returns",
"the",
"message",
"as",
"a",
"string",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/Http/HttpRequest.php#L379-L387
|
221,918
|
wallee-payment/php-sdk
|
lib/Http/HttpRequest.php
|
HttpRequest.getRequestPath
|
private function getRequestPath($url) {
$urlParts = parse_url($url);
$path = $urlParts['path'];
if (isset($urlParts['query'])) {
$path .= '?' . $urlParts['query'];
}
if (isset($urlParts['fragment'])) {
$path .= '#' . $urlParts['fragment'];
}
return $path;
}
|
php
|
private function getRequestPath($url) {
$urlParts = parse_url($url);
$path = $urlParts['path'];
if (isset($urlParts['query'])) {
$path .= '?' . $urlParts['query'];
}
if (isset($urlParts['fragment'])) {
$path .= '#' . $urlParts['fragment'];
}
return $path;
}
|
[
"private",
"function",
"getRequestPath",
"(",
"$",
"url",
")",
"{",
"$",
"urlParts",
"=",
"parse_url",
"(",
"$",
"url",
")",
";",
"$",
"path",
"=",
"$",
"urlParts",
"[",
"'path'",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"urlParts",
"[",
"'query'",
"]",
")",
")",
"{",
"$",
"path",
".=",
"'?'",
".",
"$",
"urlParts",
"[",
"'query'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"urlParts",
"[",
"'fragment'",
"]",
")",
")",
"{",
"$",
"path",
".=",
"'#'",
".",
"$",
"urlParts",
"[",
"'fragment'",
"]",
";",
"}",
"return",
"$",
"path",
";",
"}"
] |
Returns the request path part of the given url, including query and fragment.
@param string $url the url
@return string
|
[
"Returns",
"the",
"request",
"path",
"part",
"of",
"the",
"given",
"url",
"including",
"query",
"and",
"fragment",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/Http/HttpRequest.php#L404-L414
|
221,919
|
wallee-payment/php-sdk
|
lib/Http/HttpResponse.php
|
HttpResponse.parseHttpHeaders
|
private function parseHttpHeaders($rawHeaders) {
// ref/credit: http://php.net/manual/en/function.http-parse-headers.php#112986
$headers = array();
$key = '';
foreach (explode("\n", $rawHeaders) as $h) {
$h = explode(':', $h, 2);
if (isset($h[1])) {
if (!isset($headers[$h[0]])) {
$headers[$h[0]] = trim($h[1]);
} elseif (is_array($headers[$h[0]])) {
$headers[$h[0]] = array_merge($headers[$h[0]], array(trim($h[1])));
} else {
$headers[$h[0]] = array_merge(array($headers[$h[0]]), array(trim($h[1])));
}
$key = $h[0];
} else {
if (substr($h[0], 0, 1) === "\t") {
$headers[$key] .= "\r\n\t".trim($h[0]);
} elseif (!$key) {
$headers[0] = trim($h[0]);
}
trim($h[0]);
}
}
return $headers;
}
|
php
|
private function parseHttpHeaders($rawHeaders) {
// ref/credit: http://php.net/manual/en/function.http-parse-headers.php#112986
$headers = array();
$key = '';
foreach (explode("\n", $rawHeaders) as $h) {
$h = explode(':', $h, 2);
if (isset($h[1])) {
if (!isset($headers[$h[0]])) {
$headers[$h[0]] = trim($h[1]);
} elseif (is_array($headers[$h[0]])) {
$headers[$h[0]] = array_merge($headers[$h[0]], array(trim($h[1])));
} else {
$headers[$h[0]] = array_merge(array($headers[$h[0]]), array(trim($h[1])));
}
$key = $h[0];
} else {
if (substr($h[0], 0, 1) === "\t") {
$headers[$key] .= "\r\n\t".trim($h[0]);
} elseif (!$key) {
$headers[0] = trim($h[0]);
}
trim($h[0]);
}
}
return $headers;
}
|
[
"private",
"function",
"parseHttpHeaders",
"(",
"$",
"rawHeaders",
")",
"{",
"// ref/credit: http://php.net/manual/en/function.http-parse-headers.php#112986",
"$",
"headers",
"=",
"array",
"(",
")",
";",
"$",
"key",
"=",
"''",
";",
"foreach",
"(",
"explode",
"(",
"\"\\n\"",
",",
"$",
"rawHeaders",
")",
"as",
"$",
"h",
")",
"{",
"$",
"h",
"=",
"explode",
"(",
"':'",
",",
"$",
"h",
",",
"2",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"h",
"[",
"1",
"]",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"headers",
"[",
"$",
"h",
"[",
"0",
"]",
"]",
")",
")",
"{",
"$",
"headers",
"[",
"$",
"h",
"[",
"0",
"]",
"]",
"=",
"trim",
"(",
"$",
"h",
"[",
"1",
"]",
")",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"headers",
"[",
"$",
"h",
"[",
"0",
"]",
"]",
")",
")",
"{",
"$",
"headers",
"[",
"$",
"h",
"[",
"0",
"]",
"]",
"=",
"array_merge",
"(",
"$",
"headers",
"[",
"$",
"h",
"[",
"0",
"]",
"]",
",",
"array",
"(",
"trim",
"(",
"$",
"h",
"[",
"1",
"]",
")",
")",
")",
";",
"}",
"else",
"{",
"$",
"headers",
"[",
"$",
"h",
"[",
"0",
"]",
"]",
"=",
"array_merge",
"(",
"array",
"(",
"$",
"headers",
"[",
"$",
"h",
"[",
"0",
"]",
"]",
")",
",",
"array",
"(",
"trim",
"(",
"$",
"h",
"[",
"1",
"]",
")",
")",
")",
";",
"}",
"$",
"key",
"=",
"$",
"h",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"if",
"(",
"substr",
"(",
"$",
"h",
"[",
"0",
"]",
",",
"0",
",",
"1",
")",
"===",
"\"\\t\"",
")",
"{",
"$",
"headers",
"[",
"$",
"key",
"]",
".=",
"\"\\r\\n\\t\"",
".",
"trim",
"(",
"$",
"h",
"[",
"0",
"]",
")",
";",
"}",
"elseif",
"(",
"!",
"$",
"key",
")",
"{",
"$",
"headers",
"[",
"0",
"]",
"=",
"trim",
"(",
"$",
"h",
"[",
"0",
"]",
")",
";",
"}",
"trim",
"(",
"$",
"h",
"[",
"0",
"]",
")",
";",
"}",
"}",
"return",
"$",
"headers",
";",
"}"
] |
Returns an array of HTTP response headers.
@param string $rawHeaders A string of raw HTTP response headers
@return string[]
|
[
"Returns",
"an",
"array",
"of",
"HTTP",
"response",
"headers",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/Http/HttpResponse.php#L105-L134
|
221,920
|
wallee-payment/php-sdk
|
lib/Http/HttpResponse.php
|
HttpResponse.parseRawMessage
|
private function parseRawMessage($message) {
$positionStartBody = strpos($message, "\r\n\r\n");
$startPositionOffset = 4;
if ($positionStartBody === false) {
$positionStartBody = strpos($message, "\n\n");
$startPositionOffset = 2;
if ($positionStartBody === false) {
throw new \Exception("Invalid HTTP message provided. It does not contain a header part.");
}
}
$headerString = str_replace("\r\n", "\n", trim(substr($message, 0, $positionStartBody), "\r\n"));
$content = substr($message, $positionStartBody + $startPositionOffset);
$this->headers = $this->parseHttpHeaders($headerString);
$statusLine = current(explode("\n", $headerString));
$this->parseStatusLine($statusLine);
$this->body = $content;
}
|
php
|
private function parseRawMessage($message) {
$positionStartBody = strpos($message, "\r\n\r\n");
$startPositionOffset = 4;
if ($positionStartBody === false) {
$positionStartBody = strpos($message, "\n\n");
$startPositionOffset = 2;
if ($positionStartBody === false) {
throw new \Exception("Invalid HTTP message provided. It does not contain a header part.");
}
}
$headerString = str_replace("\r\n", "\n", trim(substr($message, 0, $positionStartBody), "\r\n"));
$content = substr($message, $positionStartBody + $startPositionOffset);
$this->headers = $this->parseHttpHeaders($headerString);
$statusLine = current(explode("\n", $headerString));
$this->parseStatusLine($statusLine);
$this->body = $content;
}
|
[
"private",
"function",
"parseRawMessage",
"(",
"$",
"message",
")",
"{",
"$",
"positionStartBody",
"=",
"strpos",
"(",
"$",
"message",
",",
"\"\\r\\n\\r\\n\"",
")",
";",
"$",
"startPositionOffset",
"=",
"4",
";",
"if",
"(",
"$",
"positionStartBody",
"===",
"false",
")",
"{",
"$",
"positionStartBody",
"=",
"strpos",
"(",
"$",
"message",
",",
"\"\\n\\n\"",
")",
";",
"$",
"startPositionOffset",
"=",
"2",
";",
"if",
"(",
"$",
"positionStartBody",
"===",
"false",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Invalid HTTP message provided. It does not contain a header part.\"",
")",
";",
"}",
"}",
"$",
"headerString",
"=",
"str_replace",
"(",
"\"\\r\\n\"",
",",
"\"\\n\"",
",",
"trim",
"(",
"substr",
"(",
"$",
"message",
",",
"0",
",",
"$",
"positionStartBody",
")",
",",
"\"\\r\\n\"",
")",
")",
";",
"$",
"content",
"=",
"substr",
"(",
"$",
"message",
",",
"$",
"positionStartBody",
"+",
"$",
"startPositionOffset",
")",
";",
"$",
"this",
"->",
"headers",
"=",
"$",
"this",
"->",
"parseHttpHeaders",
"(",
"$",
"headerString",
")",
";",
"$",
"statusLine",
"=",
"current",
"(",
"explode",
"(",
"\"\\n\"",
",",
"$",
"headerString",
")",
")",
";",
"$",
"this",
"->",
"parseStatusLine",
"(",
"$",
"statusLine",
")",
";",
"$",
"this",
"->",
"body",
"=",
"$",
"content",
";",
"}"
] |
Parses the given HTTP message.
@param string $message
@return void
|
[
"Parses",
"the",
"given",
"HTTP",
"message",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/Http/HttpResponse.php#L142-L161
|
221,921
|
wallee-payment/php-sdk
|
lib/Http/HttpResponse.php
|
HttpResponse.parseStatusLine
|
private function parseStatusLine($line) {
if (empty($line)) {
throw new \Exception("Empty status line provided.");
}
preg_match('/HTTP\/([^[:space:]])+[[:space:]]+([0-9]*)(.*)/i', $line, $result);
$this->statusCode = (int)$result[2];
}
|
php
|
private function parseStatusLine($line) {
if (empty($line)) {
throw new \Exception("Empty status line provided.");
}
preg_match('/HTTP\/([^[:space:]])+[[:space:]]+([0-9]*)(.*)/i', $line, $result);
$this->statusCode = (int)$result[2];
}
|
[
"private",
"function",
"parseStatusLine",
"(",
"$",
"line",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"line",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Empty status line provided.\"",
")",
";",
"}",
"preg_match",
"(",
"'/HTTP\\/([^[:space:]])+[[:space:]]+([0-9]*)(.*)/i'",
",",
"$",
"line",
",",
"$",
"result",
")",
";",
"$",
"this",
"->",
"statusCode",
"=",
"(",
"int",
")",
"$",
"result",
"[",
"2",
"]",
";",
"}"
] |
Parses the given status line.
@param string $line the request's status line
|
[
"Parses",
"the",
"given",
"status",
"line",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/Http/HttpResponse.php#L168-L174
|
221,922
|
pavlakis/slim-cli
|
src/CliRequest.php
|
CliRequest.getUri
|
private function getUri($path, $params)
{
$uri = '/';
if (strlen($path) > 0) {
$uri = $path;
}
if (strlen($params) > 0) {
$uri .= '?' . $params;
}
return $uri;
}
|
php
|
private function getUri($path, $params)
{
$uri = '/';
if (strlen($path) > 0) {
$uri = $path;
}
if (strlen($params) > 0) {
$uri .= '?' . $params;
}
return $uri;
}
|
[
"private",
"function",
"getUri",
"(",
"$",
"path",
",",
"$",
"params",
")",
"{",
"$",
"uri",
"=",
"'/'",
";",
"if",
"(",
"strlen",
"(",
"$",
"path",
")",
">",
"0",
")",
"{",
"$",
"uri",
"=",
"$",
"path",
";",
"}",
"if",
"(",
"strlen",
"(",
"$",
"params",
")",
">",
"0",
")",
"{",
"$",
"uri",
".=",
"'?'",
".",
"$",
"params",
";",
"}",
"return",
"$",
"uri",
";",
"}"
] |
Construct the URI if path and params are being passed
@param string $path
@param string $params
@return string
|
[
"Construct",
"the",
"URI",
"if",
"path",
"and",
"params",
"are",
"being",
"passed"
] |
adb02c0fb0ec3357377877ef8fb15f8f195c7471
|
https://github.com/pavlakis/slim-cli/blob/adb02c0fb0ec3357377877ef8fb15f8f195c7471/src/CliRequest.php#L77-L89
|
221,923
|
ins0/google-measurement-php-client
|
src/Racecore/GATracking/Tracking/Ecommerce/Transaction.php
|
Transaction.createPackage
|
public function createPackage()
{
if (!$this->getID()) {
throw new MissingTrackingParameterException('transaction id is missing');
}
return array(
't' => 'transaction',
'ti' => $this->getID(),
'ta' => $this->getAffiliation(),
'tr' => $this->getRevenue(),
'ts' => $this->getShipping(),
'tt' => $this->getTax(),
'cu' => $this->getCurrency()
);
}
|
php
|
public function createPackage()
{
if (!$this->getID()) {
throw new MissingTrackingParameterException('transaction id is missing');
}
return array(
't' => 'transaction',
'ti' => $this->getID(),
'ta' => $this->getAffiliation(),
'tr' => $this->getRevenue(),
'ts' => $this->getShipping(),
'tt' => $this->getTax(),
'cu' => $this->getCurrency()
);
}
|
[
"public",
"function",
"createPackage",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getID",
"(",
")",
")",
"{",
"throw",
"new",
"MissingTrackingParameterException",
"(",
"'transaction id is missing'",
")",
";",
"}",
"return",
"array",
"(",
"'t'",
"=>",
"'transaction'",
",",
"'ti'",
"=>",
"$",
"this",
"->",
"getID",
"(",
")",
",",
"'ta'",
"=>",
"$",
"this",
"->",
"getAffiliation",
"(",
")",
",",
"'tr'",
"=>",
"$",
"this",
"->",
"getRevenue",
"(",
")",
",",
"'ts'",
"=>",
"$",
"this",
"->",
"getShipping",
"(",
")",
",",
"'tt'",
"=>",
"$",
"this",
"->",
"getTax",
"(",
")",
",",
"'cu'",
"=>",
"$",
"this",
"->",
"getCurrency",
"(",
")",
")",
";",
"}"
] |
Returns the Google Paket for Transaction Tracking
@return array
@throws \Racecore\GATracking\Exception\MissingTrackingParameterException
|
[
"Returns",
"the",
"Google",
"Paket",
"for",
"Transaction",
"Tracking"
] |
415cabca0c6d83cd0bd6a8ed6fb695b35f892018
|
https://github.com/ins0/google-measurement-php-client/blob/415cabca0c6d83cd0bd6a8ed6fb695b35f892018/src/Racecore/GATracking/Tracking/Ecommerce/Transaction.php#L176-L191
|
221,924
|
wallee-payment/php-sdk
|
lib/ObjectSerializer.php
|
ObjectSerializer.sanitizeForSerialization
|
public static function sanitizeForSerialization($data) {
if (is_scalar($data) || null === $data) {
return $data;
} elseif ($data instanceof \DateTime) {
return $data->format(\DateTime::ATOM);
} elseif (is_array($data)) {
foreach ($data as $property => $value) {
$data[$property] = self::sanitizeForSerialization($value);
}
return $data;
} elseif ($data instanceof \stdClass) {
return $data;
} elseif (is_object($data)) {
$values = array();
foreach (array_keys($data::swaggerTypes()) as $property) {
$getter = 'get' . ucfirst($property);
$values[$property] = self::sanitizeForSerialization($data->$getter());
}
return (object)$values;
} else {
return (string)$data;
}
}
|
php
|
public static function sanitizeForSerialization($data) {
if (is_scalar($data) || null === $data) {
return $data;
} elseif ($data instanceof \DateTime) {
return $data->format(\DateTime::ATOM);
} elseif (is_array($data)) {
foreach ($data as $property => $value) {
$data[$property] = self::sanitizeForSerialization($value);
}
return $data;
} elseif ($data instanceof \stdClass) {
return $data;
} elseif (is_object($data)) {
$values = array();
foreach (array_keys($data::swaggerTypes()) as $property) {
$getter = 'get' . ucfirst($property);
$values[$property] = self::sanitizeForSerialization($data->$getter());
}
return (object)$values;
} else {
return (string)$data;
}
}
|
[
"public",
"static",
"function",
"sanitizeForSerialization",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"is_scalar",
"(",
"$",
"data",
")",
"||",
"null",
"===",
"$",
"data",
")",
"{",
"return",
"$",
"data",
";",
"}",
"elseif",
"(",
"$",
"data",
"instanceof",
"\\",
"DateTime",
")",
"{",
"return",
"$",
"data",
"->",
"format",
"(",
"\\",
"DateTime",
"::",
"ATOM",
")",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"property",
"=>",
"$",
"value",
")",
"{",
"$",
"data",
"[",
"$",
"property",
"]",
"=",
"self",
"::",
"sanitizeForSerialization",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"data",
";",
"}",
"elseif",
"(",
"$",
"data",
"instanceof",
"\\",
"stdClass",
")",
"{",
"return",
"$",
"data",
";",
"}",
"elseif",
"(",
"is_object",
"(",
"$",
"data",
")",
")",
"{",
"$",
"values",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"array_keys",
"(",
"$",
"data",
"::",
"swaggerTypes",
"(",
")",
")",
"as",
"$",
"property",
")",
"{",
"$",
"getter",
"=",
"'get'",
".",
"ucfirst",
"(",
"$",
"property",
")",
";",
"$",
"values",
"[",
"$",
"property",
"]",
"=",
"self",
"::",
"sanitizeForSerialization",
"(",
"$",
"data",
"->",
"$",
"getter",
"(",
")",
")",
";",
"}",
"return",
"(",
"object",
")",
"$",
"values",
";",
"}",
"else",
"{",
"return",
"(",
"string",
")",
"$",
"data",
";",
"}",
"}"
] |
Prepare data for serialization.
@param mixed $data the data to serialize
@return string|object
|
[
"Prepare",
"data",
"for",
"serialization",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/ObjectSerializer.php#L138-L160
|
221,925
|
ins0/google-measurement-php-client
|
src/Racecore/GATracking/Tracking/Event.php
|
Event.createPackage
|
public function createPackage()
{
if (!$this->getEventCategory()) {
throw new MissingTrackingParameterException('event category must be set');
}
if (!$this->getEventAction()) {
throw new MissingTrackingParameterException('event action must be set');
}
return array(
't' => 'event',
'ec' => $this->getEventCategory(),
'ea' => $this->getEventAction(),
'el' => $this->getEventLabel(),
'ev' => $this->getEventValue()
);
}
|
php
|
public function createPackage()
{
if (!$this->getEventCategory()) {
throw new MissingTrackingParameterException('event category must be set');
}
if (!$this->getEventAction()) {
throw new MissingTrackingParameterException('event action must be set');
}
return array(
't' => 'event',
'ec' => $this->getEventCategory(),
'ea' => $this->getEventAction(),
'el' => $this->getEventLabel(),
'ev' => $this->getEventValue()
);
}
|
[
"public",
"function",
"createPackage",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getEventCategory",
"(",
")",
")",
"{",
"throw",
"new",
"MissingTrackingParameterException",
"(",
"'event category must be set'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"getEventAction",
"(",
")",
")",
"{",
"throw",
"new",
"MissingTrackingParameterException",
"(",
"'event action must be set'",
")",
";",
"}",
"return",
"array",
"(",
"'t'",
"=>",
"'event'",
",",
"'ec'",
"=>",
"$",
"this",
"->",
"getEventCategory",
"(",
")",
",",
"'ea'",
"=>",
"$",
"this",
"->",
"getEventAction",
"(",
")",
",",
"'el'",
"=>",
"$",
"this",
"->",
"getEventLabel",
"(",
")",
",",
"'ev'",
"=>",
"$",
"this",
"->",
"getEventValue",
"(",
")",
")",
";",
"}"
] |
Returns the Paket for Event Tracking
@return array
@throws \Racecore\GATracking\Exception\MissingTrackingParameterException
|
[
"Returns",
"the",
"Paket",
"for",
"Event",
"Tracking"
] |
415cabca0c6d83cd0bd6a8ed6fb695b35f892018
|
https://github.com/ins0/google-measurement-php-client/blob/415cabca0c6d83cd0bd6a8ed6fb695b35f892018/src/Racecore/GATracking/Tracking/Event.php#L131-L148
|
221,926
|
subugoe/typo3-find
|
Classes/Utility/LoggerUtility.php
|
LoggerUtility.exceptionToArray
|
public static function exceptionToArray($exception, $includePrevious = false)
{
$array = [
'message' => $exception->getMessage(),
'code' => $exception->getCode(),
'file' => $exception->getFile(),
'line' => $exception->getLine(),
'trace' => $exception->getTraceAsString(),
];
if ($includePrevious) {
$array['previous'] = self::exceptionToArray($exception->getPrevious(), true);
}
return $array;
}
|
php
|
public static function exceptionToArray($exception, $includePrevious = false)
{
$array = [
'message' => $exception->getMessage(),
'code' => $exception->getCode(),
'file' => $exception->getFile(),
'line' => $exception->getLine(),
'trace' => $exception->getTraceAsString(),
];
if ($includePrevious) {
$array['previous'] = self::exceptionToArray($exception->getPrevious(), true);
}
return $array;
}
|
[
"public",
"static",
"function",
"exceptionToArray",
"(",
"$",
"exception",
",",
"$",
"includePrevious",
"=",
"false",
")",
"{",
"$",
"array",
"=",
"[",
"'message'",
"=>",
"$",
"exception",
"->",
"getMessage",
"(",
")",
",",
"'code'",
"=>",
"$",
"exception",
"->",
"getCode",
"(",
")",
",",
"'file'",
"=>",
"$",
"exception",
"->",
"getFile",
"(",
")",
",",
"'line'",
"=>",
"$",
"exception",
"->",
"getLine",
"(",
")",
",",
"'trace'",
"=>",
"$",
"exception",
"->",
"getTraceAsString",
"(",
")",
",",
"]",
";",
"if",
"(",
"$",
"includePrevious",
")",
"{",
"$",
"array",
"[",
"'previous'",
"]",
"=",
"self",
"::",
"exceptionToArray",
"(",
"$",
"exception",
"->",
"getPrevious",
"(",
")",
",",
"true",
")",
";",
"}",
"return",
"$",
"array",
";",
"}"
] |
Returns an array that can be handled by devLog with the information from an exception.
@param \Exception $exception
@return array
|
[
"Returns",
"an",
"array",
"that",
"can",
"be",
"handled",
"by",
"devLog",
"with",
"the",
"information",
"from",
"an",
"exception",
"."
] |
d628a0b6a131d05f4842b08a556fe17cba9d7da0
|
https://github.com/subugoe/typo3-find/blob/d628a0b6a131d05f4842b08a556fe17cba9d7da0/Classes/Utility/LoggerUtility.php#L42-L57
|
221,927
|
wallee-payment/php-sdk
|
lib/Model/PaymentProcessor.php
|
PaymentProcessor.setCompanyName
|
public function setCompanyName($companyName) {
if (is_array($companyName) && empty($companyName)) {
$this->companyName = new \stdClass;
} else {
$this->companyName = $companyName;
}
return $this;
}
|
php
|
public function setCompanyName($companyName) {
if (is_array($companyName) && empty($companyName)) {
$this->companyName = new \stdClass;
} else {
$this->companyName = $companyName;
}
return $this;
}
|
[
"public",
"function",
"setCompanyName",
"(",
"$",
"companyName",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"companyName",
")",
"&&",
"empty",
"(",
"$",
"companyName",
")",
")",
"{",
"$",
"this",
"->",
"companyName",
"=",
"new",
"\\",
"stdClass",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"companyName",
"=",
"$",
"companyName",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Sets companyName.
@param map[string,string] $companyName
@return PaymentProcessor
|
[
"Sets",
"companyName",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/Model/PaymentProcessor.php#L168-L176
|
221,928
|
wallee-payment/php-sdk
|
lib/Model/PaymentProcessor.php
|
PaymentProcessor.setHeadquartersLocation
|
public function setHeadquartersLocation($headquartersLocation) {
if (is_array($headquartersLocation) && empty($headquartersLocation)) {
$this->headquartersLocation = new \stdClass;
} else {
$this->headquartersLocation = $headquartersLocation;
}
return $this;
}
|
php
|
public function setHeadquartersLocation($headquartersLocation) {
if (is_array($headquartersLocation) && empty($headquartersLocation)) {
$this->headquartersLocation = new \stdClass;
} else {
$this->headquartersLocation = $headquartersLocation;
}
return $this;
}
|
[
"public",
"function",
"setHeadquartersLocation",
"(",
"$",
"headquartersLocation",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"headquartersLocation",
")",
"&&",
"empty",
"(",
"$",
"headquartersLocation",
")",
")",
"{",
"$",
"this",
"->",
"headquartersLocation",
"=",
"new",
"\\",
"stdClass",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"headquartersLocation",
"=",
"$",
"headquartersLocation",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Sets headquartersLocation.
@param map[string,string] $headquartersLocation
@return PaymentProcessor
|
[
"Sets",
"headquartersLocation",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/Model/PaymentProcessor.php#L245-L253
|
221,929
|
wallee-payment/php-sdk
|
lib/Model/PaymentProcessor.php
|
PaymentProcessor.setProductName
|
public function setProductName($productName) {
if (is_array($productName) && empty($productName)) {
$this->productName = new \stdClass;
} else {
$this->productName = $productName;
}
return $this;
}
|
php
|
public function setProductName($productName) {
if (is_array($productName) && empty($productName)) {
$this->productName = new \stdClass;
} else {
$this->productName = $productName;
}
return $this;
}
|
[
"public",
"function",
"setProductName",
"(",
"$",
"productName",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"productName",
")",
"&&",
"empty",
"(",
"$",
"productName",
")",
")",
"{",
"$",
"this",
"->",
"productName",
"=",
"new",
"\\",
"stdClass",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"productName",
"=",
"$",
"productName",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Sets productName.
@param map[string,string] $productName
@return PaymentProcessor
|
[
"Sets",
"productName",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/Model/PaymentProcessor.php#L345-L353
|
221,930
|
fadion/Rule
|
src/Rule.php
|
Rule.add
|
public function add($input, $attribute = null)
{
$this->input = $input;
static::$rules[$input] = [];
if (isset($attribute)) {
static::$attributes[$input] = $attribute;
}
return $this;
}
|
php
|
public function add($input, $attribute = null)
{
$this->input = $input;
static::$rules[$input] = [];
if (isset($attribute)) {
static::$attributes[$input] = $attribute;
}
return $this;
}
|
[
"public",
"function",
"add",
"(",
"$",
"input",
",",
"$",
"attribute",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"input",
"=",
"$",
"input",
";",
"static",
"::",
"$",
"rules",
"[",
"$",
"input",
"]",
"=",
"[",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"attribute",
")",
")",
"{",
"static",
"::",
"$",
"attributes",
"[",
"$",
"input",
"]",
"=",
"$",
"attribute",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Starts the rule builder with an
input target
@param string $input
@param string|null $attribute
@return Rule
|
[
"Starts",
"the",
"rule",
"builder",
"with",
"an",
"input",
"target"
] |
643c22340032ee5c627b6f289de7f87ec26c98e1
|
https://github.com/fadion/Rule/blob/643c22340032ee5c627b6f289de7f87ec26c98e1/src/Rule.php#L40-L50
|
221,931
|
fadion/Rule
|
src/Rule.php
|
Rule.message
|
public function message($message)
{
if (isset($this->currentRule)) {
static::$messages[$this->input.'.'.$this->currentRule] = $message;
}
return $this;
}
|
php
|
public function message($message)
{
if (isset($this->currentRule)) {
static::$messages[$this->input.'.'.$this->currentRule] = $message;
}
return $this;
}
|
[
"public",
"function",
"message",
"(",
"$",
"message",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"currentRule",
")",
")",
"{",
"static",
"::",
"$",
"messages",
"[",
"$",
"this",
"->",
"input",
".",
"'.'",
".",
"$",
"this",
"->",
"currentRule",
"]",
"=",
"$",
"message",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Adds a message for the current rule
@return Rule
|
[
"Adds",
"a",
"message",
"for",
"the",
"current",
"rule"
] |
643c22340032ee5c627b6f289de7f87ec26c98e1
|
https://github.com/fadion/Rule/blob/643c22340032ee5c627b6f289de7f87ec26c98e1/src/Rule.php#L96-L103
|
221,932
|
fadion/Rule
|
src/Rule.php
|
Rule.exists
|
public function exists($table, $column = null)
{
$rule = $table;
// Take any argument after the 2 defined ones
$args = array_slice(func_get_args(), 2);
if (isset($column)) {
$rule .= ",$column";
}
if ($args) {
// Add optional arguments
foreach ($args as $arg) {
$rule .= ",$arg";
}
}
$this->addRule("exists:$rule");
return $this;
}
|
php
|
public function exists($table, $column = null)
{
$rule = $table;
// Take any argument after the 2 defined ones
$args = array_slice(func_get_args(), 2);
if (isset($column)) {
$rule .= ",$column";
}
if ($args) {
// Add optional arguments
foreach ($args as $arg) {
$rule .= ",$arg";
}
}
$this->addRule("exists:$rule");
return $this;
}
|
[
"public",
"function",
"exists",
"(",
"$",
"table",
",",
"$",
"column",
"=",
"null",
")",
"{",
"$",
"rule",
"=",
"$",
"table",
";",
"// Take any argument after the 2 defined ones",
"$",
"args",
"=",
"array_slice",
"(",
"func_get_args",
"(",
")",
",",
"2",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"column",
")",
")",
"{",
"$",
"rule",
".=",
"\",$column\"",
";",
"}",
"if",
"(",
"$",
"args",
")",
"{",
"// Add optional arguments",
"foreach",
"(",
"$",
"args",
"as",
"$",
"arg",
")",
"{",
"$",
"rule",
".=",
"\",$arg\"",
";",
"}",
"}",
"$",
"this",
"->",
"addRule",
"(",
"\"exists:$rule\"",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
The field under validation must exist on
a given database table
@param string $table
@param string $column
@return Rule
|
[
"The",
"field",
"under",
"validation",
"must",
"exist",
"on",
"a",
"given",
"database",
"table"
] |
643c22340032ee5c627b6f289de7f87ec26c98e1
|
https://github.com/fadion/Rule/blob/643c22340032ee5c627b6f289de7f87ec26c98e1/src/Rule.php#L419-L439
|
221,933
|
fadion/Rule
|
src/Rule.php
|
Rule.unique
|
public function unique($table, $column = null, $id = false)
{
$rule = $table;
// Take any argument after the 3 defined ones
$args = array_slice(func_get_args(), 3);
if (isset($column)) {
$rule .= ",$column";
}
// A NULL value is a valid one for the validator,
// so an explicit FALSE is checked
if ($id !== false) {
if ($id === null) {
$rule .= ',NULL';
}
else {
$rule .= ",$id";
}
}
if ($args) {
// Add optional arguments
foreach ($args as $arg) {
$rule .= ",$arg";
}
}
$this->addRule("unique:$rule");
return $this;
}
|
php
|
public function unique($table, $column = null, $id = false)
{
$rule = $table;
// Take any argument after the 3 defined ones
$args = array_slice(func_get_args(), 3);
if (isset($column)) {
$rule .= ",$column";
}
// A NULL value is a valid one for the validator,
// so an explicit FALSE is checked
if ($id !== false) {
if ($id === null) {
$rule .= ',NULL';
}
else {
$rule .= ",$id";
}
}
if ($args) {
// Add optional arguments
foreach ($args as $arg) {
$rule .= ",$arg";
}
}
$this->addRule("unique:$rule");
return $this;
}
|
[
"public",
"function",
"unique",
"(",
"$",
"table",
",",
"$",
"column",
"=",
"null",
",",
"$",
"id",
"=",
"false",
")",
"{",
"$",
"rule",
"=",
"$",
"table",
";",
"// Take any argument after the 3 defined ones",
"$",
"args",
"=",
"array_slice",
"(",
"func_get_args",
"(",
")",
",",
"3",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"column",
")",
")",
"{",
"$",
"rule",
".=",
"\",$column\"",
";",
"}",
"// A NULL value is a valid one for the validator,",
"// so an explicit FALSE is checked",
"if",
"(",
"$",
"id",
"!==",
"false",
")",
"{",
"if",
"(",
"$",
"id",
"===",
"null",
")",
"{",
"$",
"rule",
".=",
"',NULL'",
";",
"}",
"else",
"{",
"$",
"rule",
".=",
"\",$id\"",
";",
"}",
"}",
"if",
"(",
"$",
"args",
")",
"{",
"// Add optional arguments",
"foreach",
"(",
"$",
"args",
"as",
"$",
"arg",
")",
"{",
"$",
"rule",
".=",
"\",$arg\"",
";",
"}",
"}",
"$",
"this",
"->",
"addRule",
"(",
"\"unique:$rule\"",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
The field under validation must be unique on a
given database table. If the column option is
not specified, the field name will be used
@param string $table
@param string $column
@param mixed $id
@return Rule
|
[
"The",
"field",
"under",
"validation",
"must",
"be",
"unique",
"on",
"a",
"given",
"database",
"table",
".",
"If",
"the",
"column",
"option",
"is",
"not",
"specified",
"the",
"field",
"name",
"will",
"be",
"used"
] |
643c22340032ee5c627b6f289de7f87ec26c98e1
|
https://github.com/fadion/Rule/blob/643c22340032ee5c627b6f289de7f87ec26c98e1/src/Rule.php#L826-L857
|
221,934
|
buzzylab/laradown
|
src/Laradown.php
|
Laradown.getContainer
|
public function getContainer($service = null)
{
return is_null($service) ? ($this->container ?: app()) : ($this->container[$service] ?: app($service));
}
|
php
|
public function getContainer($service = null)
{
return is_null($service) ? ($this->container ?: app()) : ($this->container[$service] ?: app($service));
}
|
[
"public",
"function",
"getContainer",
"(",
"$",
"service",
"=",
"null",
")",
"{",
"return",
"is_null",
"(",
"$",
"service",
")",
"?",
"(",
"$",
"this",
"->",
"container",
"?",
":",
"app",
"(",
")",
")",
":",
"(",
"$",
"this",
"->",
"container",
"[",
"$",
"service",
"]",
"?",
":",
"app",
"(",
"$",
"service",
")",
")",
";",
"}"
] |
Get the IoC container instance or any of it's services.
@param string|null $service
@return object
|
[
"Get",
"the",
"IoC",
"container",
"instance",
"or",
"any",
"of",
"it",
"s",
"services",
"."
] |
b726aea44eded0f7da6bf0220dcf1c92697f2412
|
https://github.com/buzzylab/laradown/blob/b726aea44eded0f7da6bf0220dcf1c92697f2412/src/Laradown.php#L63-L66
|
221,935
|
buzzylab/laradown
|
src/Laradown.php
|
Laradown.element
|
protected function element(array $Element)
{
$markup = '';
if (str_is('h[1-6]', $Element['name'])) {
$link = str_replace(' ', '-', strtolower($Element['text']));
$markup = '<a class="header-link" href="#'.$link.'" id="'.$link.'"><i class="glyphicon glyphicon-link"></i></a>';
}
$markup .= parent::element($Element);
return $markup;
}
|
php
|
protected function element(array $Element)
{
$markup = '';
if (str_is('h[1-6]', $Element['name'])) {
$link = str_replace(' ', '-', strtolower($Element['text']));
$markup = '<a class="header-link" href="#'.$link.'" id="'.$link.'"><i class="glyphicon glyphicon-link"></i></a>';
}
$markup .= parent::element($Element);
return $markup;
}
|
[
"protected",
"function",
"element",
"(",
"array",
"$",
"Element",
")",
"{",
"$",
"markup",
"=",
"''",
";",
"if",
"(",
"str_is",
"(",
"'h[1-6]'",
",",
"$",
"Element",
"[",
"'name'",
"]",
")",
")",
"{",
"$",
"link",
"=",
"str_replace",
"(",
"' '",
",",
"'-'",
",",
"strtolower",
"(",
"$",
"Element",
"[",
"'text'",
"]",
")",
")",
";",
"$",
"markup",
"=",
"'<a class=\"header-link\" href=\"#'",
".",
"$",
"link",
".",
"'\" id=\"'",
".",
"$",
"link",
".",
"'\"><i class=\"glyphicon glyphicon-link\"></i></a>'",
";",
"}",
"$",
"markup",
".=",
"parent",
"::",
"element",
"(",
"$",
"Element",
")",
";",
"return",
"$",
"markup",
";",
"}"
] |
Handlers for all elements.
@param array $Element
@return string
|
[
"Handlers",
"for",
"all",
"elements",
"."
] |
b726aea44eded0f7da6bf0220dcf1c92697f2412
|
https://github.com/buzzylab/laradown/blob/b726aea44eded0f7da6bf0220dcf1c92697f2412/src/Laradown.php#L75-L87
|
221,936
|
buzzylab/laradown
|
src/Laradown.php
|
Laradown.convert
|
public function convert($markdown)
{
// Fire converting event
$this->getContainer('events')->dispatch('laradown.entity.converting');
$text = $this->text($markdown);
// Fire converted event
$this->getContainer('events')->dispatch('laradown.entity.converted');
return $text;
}
|
php
|
public function convert($markdown)
{
// Fire converting event
$this->getContainer('events')->dispatch('laradown.entity.converting');
$text = $this->text($markdown);
// Fire converted event
$this->getContainer('events')->dispatch('laradown.entity.converted');
return $text;
}
|
[
"public",
"function",
"convert",
"(",
"$",
"markdown",
")",
"{",
"// Fire converting event",
"$",
"this",
"->",
"getContainer",
"(",
"'events'",
")",
"->",
"dispatch",
"(",
"'laradown.entity.converting'",
")",
";",
"$",
"text",
"=",
"$",
"this",
"->",
"text",
"(",
"$",
"markdown",
")",
";",
"// Fire converted event",
"$",
"this",
"->",
"getContainer",
"(",
"'events'",
")",
"->",
"dispatch",
"(",
"'laradown.entity.converted'",
")",
";",
"return",
"$",
"text",
";",
"}"
] |
Convert markdown to html.
@param $markdown
@return mixed|string
|
[
"Convert",
"markdown",
"to",
"html",
"."
] |
b726aea44eded0f7da6bf0220dcf1c92697f2412
|
https://github.com/buzzylab/laradown/blob/b726aea44eded0f7da6bf0220dcf1c92697f2412/src/Laradown.php#L96-L107
|
221,937
|
buzzylab/laradown
|
src/Laradown.php
|
Laradown.loadStyle
|
public function loadStyle($file = null)
{
// init required vars
$content = '';
// Get style file or get default
if (is_null($file)) {
$file = __DIR__.'/../public/github.css';
}
// check if style file exists
if ($this->filesystem->exists($file)) {
$content = $this->filesystem->get($file);
}
// Finally return style
return "<style>{$content}</style>";
}
|
php
|
public function loadStyle($file = null)
{
// init required vars
$content = '';
// Get style file or get default
if (is_null($file)) {
$file = __DIR__.'/../public/github.css';
}
// check if style file exists
if ($this->filesystem->exists($file)) {
$content = $this->filesystem->get($file);
}
// Finally return style
return "<style>{$content}</style>";
}
|
[
"public",
"function",
"loadStyle",
"(",
"$",
"file",
"=",
"null",
")",
"{",
"// init required vars",
"$",
"content",
"=",
"''",
";",
"// Get style file or get default",
"if",
"(",
"is_null",
"(",
"$",
"file",
")",
")",
"{",
"$",
"file",
"=",
"__DIR__",
".",
"'/../public/github.css'",
";",
"}",
"// check if style file exists",
"if",
"(",
"$",
"this",
"->",
"filesystem",
"->",
"exists",
"(",
"$",
"file",
")",
")",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"filesystem",
"->",
"get",
"(",
"$",
"file",
")",
";",
"}",
"// Finally return style",
"return",
"\"<style>{$content}</style>\"",
";",
"}"
] |
Get style.
@param null $file
@return string
|
[
"Get",
"style",
"."
] |
b726aea44eded0f7da6bf0220dcf1c92697f2412
|
https://github.com/buzzylab/laradown/blob/b726aea44eded0f7da6bf0220dcf1c92697f2412/src/Laradown.php#L173-L190
|
221,938
|
wallee-payment/php-sdk
|
lib/ApiClient.php
|
ApiClient.setConnectionTimeout
|
public function setConnectionTimeout($connectionTimeout) {
if (!is_numeric($connectionTimeout) || $connectionTimeout < 0) {
throw new \InvalidArgumentException('Timeout value must be numeric and a non-negative number.');
}
$this->connectionTimeout = $connectionTimeout;
return $this;
}
|
php
|
public function setConnectionTimeout($connectionTimeout) {
if (!is_numeric($connectionTimeout) || $connectionTimeout < 0) {
throw new \InvalidArgumentException('Timeout value must be numeric and a non-negative number.');
}
$this->connectionTimeout = $connectionTimeout;
return $this;
}
|
[
"public",
"function",
"setConnectionTimeout",
"(",
"$",
"connectionTimeout",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"connectionTimeout",
")",
"||",
"$",
"connectionTimeout",
"<",
"0",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Timeout value must be numeric and a non-negative number.'",
")",
";",
"}",
"$",
"this",
"->",
"connectionTimeout",
"=",
"$",
"connectionTimeout",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets the connection timeout in seconds.
@param int $connectionTimeout the connection timeout in seconds
@return ApiClient
|
[
"Sets",
"the",
"connection",
"timeout",
"in",
"seconds",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/ApiClient.php#L236-L243
|
221,939
|
wallee-payment/php-sdk
|
lib/ApiClient.php
|
ApiClient.addDefaultHeader
|
public function addDefaultHeader($key, $value) {
if (!is_string($key)) {
throw new \InvalidArgumentException('The header key must be a string.');
}
$defaultHeaders[$key] = $value;
return $this;
}
|
php
|
public function addDefaultHeader($key, $value) {
if (!is_string($key)) {
throw new \InvalidArgumentException('The header key must be a string.');
}
$defaultHeaders[$key] = $value;
return $this;
}
|
[
"public",
"function",
"addDefaultHeader",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"key",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The header key must be a string.'",
")",
";",
"}",
"$",
"defaultHeaders",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds a default header.
@param string $key the header's key
@param string $value the header's value
@return ApiClient
|
[
"Adds",
"a",
"default",
"header",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/ApiClient.php#L299-L306
|
221,940
|
wallee-payment/php-sdk
|
lib/ApiClient.php
|
ApiClient.setDebugFile
|
public function setDebugFile($debugFile) {
$this->debugFile = $debugFile;
$this->serializer->setDebugFile($debugFile);
return $this;
}
|
php
|
public function setDebugFile($debugFile) {
$this->debugFile = $debugFile;
$this->serializer->setDebugFile($debugFile);
return $this;
}
|
[
"public",
"function",
"setDebugFile",
"(",
"$",
"debugFile",
")",
"{",
"$",
"this",
"->",
"debugFile",
"=",
"$",
"debugFile",
";",
"$",
"this",
"->",
"serializer",
"->",
"setDebugFile",
"(",
"$",
"debugFile",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets the path to the debug file.
@param string $debugFile the debug file
@return ApiClient
|
[
"Sets",
"the",
"path",
"to",
"the",
"debug",
"file",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/ApiClient.php#L354-L358
|
221,941
|
wallee-payment/php-sdk
|
lib/ApiClient.php
|
ApiClient.selectHeaderContentType
|
public function selectHeaderContentType($contentType) {
if (count($contentType) === 0 or (count($contentType) === 1 and $contentType[0] === '')) {
return 'application/json';
} elseif (preg_grep("/application\/json/i", $contentType)) {
return 'application/json';
} else {
return implode(',', $contentType);
}
}
|
php
|
public function selectHeaderContentType($contentType) {
if (count($contentType) === 0 or (count($contentType) === 1 and $contentType[0] === '')) {
return 'application/json';
} elseif (preg_grep("/application\/json/i", $contentType)) {
return 'application/json';
} else {
return implode(',', $contentType);
}
}
|
[
"public",
"function",
"selectHeaderContentType",
"(",
"$",
"contentType",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"contentType",
")",
"===",
"0",
"or",
"(",
"count",
"(",
"$",
"contentType",
")",
"===",
"1",
"and",
"$",
"contentType",
"[",
"0",
"]",
"===",
"''",
")",
")",
"{",
"return",
"'application/json'",
";",
"}",
"elseif",
"(",
"preg_grep",
"(",
"\"/application\\/json/i\"",
",",
"$",
"contentType",
")",
")",
"{",
"return",
"'application/json'",
";",
"}",
"else",
"{",
"return",
"implode",
"(",
"','",
",",
"$",
"contentType",
")",
";",
"}",
"}"
] |
Returns the 'Content Type' based on an array of content types.
@param string[] $contentType the array of content types
@return string
|
[
"Returns",
"the",
"Content",
"Type",
"based",
"on",
"an",
"array",
"of",
"content",
"types",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/ApiClient.php#L412-L420
|
221,942
|
wallee-payment/php-sdk
|
lib/ApiClient.php
|
ApiClient.buildRequestUrl
|
private function buildRequestUrl($path, $queryParams) {
$url = $this->getBasePath() . $path;
if (!empty($queryParams)) {
$url = ($url . '?' . http_build_query($queryParams));
}
return $url;
}
|
php
|
private function buildRequestUrl($path, $queryParams) {
$url = $this->getBasePath() . $path;
if (!empty($queryParams)) {
$url = ($url . '?' . http_build_query($queryParams));
}
return $url;
}
|
[
"private",
"function",
"buildRequestUrl",
"(",
"$",
"path",
",",
"$",
"queryParams",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"getBasePath",
"(",
")",
".",
"$",
"path",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"queryParams",
")",
")",
"{",
"$",
"url",
"=",
"(",
"$",
"url",
".",
"'?'",
".",
"http_build_query",
"(",
"$",
"queryParams",
")",
")",
";",
"}",
"return",
"$",
"url",
";",
"}"
] |
Returns the request url.
@param string $path the request path
@param array $queryParams an array of query parameters
@return string
|
[
"Returns",
"the",
"request",
"url",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/ApiClient.php#L486-L492
|
221,943
|
wallee-payment/php-sdk
|
lib/ApiClient.php
|
ApiClient.getAuthenticationHeaders
|
private function getAuthenticationHeaders(HttpRequest $request) {
$timestamp = time();
$version = '1';
$path = $request->getPath();
$securedData = $version . '|' . $this->userId . '|' . $timestamp . '|' . $request->getMethod() . '|' . $path;
$headers = array();
$headers['x-mac-version'] = $version;
$headers['x-mac-userid'] = $this->userId;
$headers['x-mac-timestamp'] = $timestamp;
$headers['x-mac-value'] = $this->calculateHmac($securedData);
return $headers;
}
|
php
|
private function getAuthenticationHeaders(HttpRequest $request) {
$timestamp = time();
$version = '1';
$path = $request->getPath();
$securedData = $version . '|' . $this->userId . '|' . $timestamp . '|' . $request->getMethod() . '|' . $path;
$headers = array();
$headers['x-mac-version'] = $version;
$headers['x-mac-userid'] = $this->userId;
$headers['x-mac-timestamp'] = $timestamp;
$headers['x-mac-value'] = $this->calculateHmac($securedData);
return $headers;
}
|
[
"private",
"function",
"getAuthenticationHeaders",
"(",
"HttpRequest",
"$",
"request",
")",
"{",
"$",
"timestamp",
"=",
"time",
"(",
")",
";",
"$",
"version",
"=",
"'1'",
";",
"$",
"path",
"=",
"$",
"request",
"->",
"getPath",
"(",
")",
";",
"$",
"securedData",
"=",
"$",
"version",
".",
"'|'",
".",
"$",
"this",
"->",
"userId",
".",
"'|'",
".",
"$",
"timestamp",
".",
"'|'",
".",
"$",
"request",
"->",
"getMethod",
"(",
")",
".",
"'|'",
".",
"$",
"path",
";",
"$",
"headers",
"=",
"array",
"(",
")",
";",
"$",
"headers",
"[",
"'x-mac-version'",
"]",
"=",
"$",
"version",
";",
"$",
"headers",
"[",
"'x-mac-userid'",
"]",
"=",
"$",
"this",
"->",
"userId",
";",
"$",
"headers",
"[",
"'x-mac-timestamp'",
"]",
"=",
"$",
"timestamp",
";",
"$",
"headers",
"[",
"'x-mac-value'",
"]",
"=",
"$",
"this",
"->",
"calculateHmac",
"(",
"$",
"securedData",
")",
";",
"return",
"$",
"headers",
";",
"}"
] |
Returns the headers used for authentication.
@param HttpRequest $request
@return array
|
[
"Returns",
"the",
"headers",
"used",
"for",
"authentication",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/ApiClient.php#L500-L512
|
221,944
|
wallee-payment/php-sdk
|
lib/ApiClient.php
|
ApiClient.calculateHmac
|
private function calculateHmac($securedData) {
$decodedSecret = base64_decode($this->applicationKey);
return base64_encode(hash_hmac("sha512", $securedData, $decodedSecret, true));
}
|
php
|
private function calculateHmac($securedData) {
$decodedSecret = base64_decode($this->applicationKey);
return base64_encode(hash_hmac("sha512", $securedData, $decodedSecret, true));
}
|
[
"private",
"function",
"calculateHmac",
"(",
"$",
"securedData",
")",
"{",
"$",
"decodedSecret",
"=",
"base64_decode",
"(",
"$",
"this",
"->",
"applicationKey",
")",
";",
"return",
"base64_encode",
"(",
"hash_hmac",
"(",
"\"sha512\"",
",",
"$",
"securedData",
",",
"$",
"decodedSecret",
",",
"true",
")",
")",
";",
"}"
] |
Calculates the hmac of the given data.
@param string $securedData the data to calculate the hmac for
@return string
|
[
"Calculates",
"the",
"hmac",
"of",
"the",
"given",
"data",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/ApiClient.php#L520-L523
|
221,945
|
wallee-payment/php-sdk
|
lib/ApiClient.php
|
ApiClient.generateUniqueToken
|
private function generateUniqueToken() {
$s = strtoupper(md5(uniqid(rand(),true)));
return substr($s,0,8) . '-' .
substr($s,8,4) . '-' .
substr($s,12,4). '-' .
substr($s,16,4). '-' .
substr($s,20);
}
|
php
|
private function generateUniqueToken() {
$s = strtoupper(md5(uniqid(rand(),true)));
return substr($s,0,8) . '-' .
substr($s,8,4) . '-' .
substr($s,12,4). '-' .
substr($s,16,4). '-' .
substr($s,20);
}
|
[
"private",
"function",
"generateUniqueToken",
"(",
")",
"{",
"$",
"s",
"=",
"strtoupper",
"(",
"md5",
"(",
"uniqid",
"(",
"rand",
"(",
")",
",",
"true",
")",
")",
")",
";",
"return",
"substr",
"(",
"$",
"s",
",",
"0",
",",
"8",
")",
".",
"'-'",
".",
"substr",
"(",
"$",
"s",
",",
"8",
",",
"4",
")",
".",
"'-'",
".",
"substr",
"(",
"$",
"s",
",",
"12",
",",
"4",
")",
".",
"'-'",
".",
"substr",
"(",
"$",
"s",
",",
"16",
",",
"4",
")",
".",
"'-'",
".",
"substr",
"(",
"$",
"s",
",",
"20",
")",
";",
"}"
] |
Generates a unique token to assign to the request.
@return string
|
[
"Generates",
"a",
"unique",
"token",
"to",
"assign",
"to",
"the",
"request",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/ApiClient.php#L530-L537
|
221,946
|
wallee-payment/php-sdk
|
lib/Model/PaymentConnector.php
|
PaymentConnector.setDeprecationReason
|
public function setDeprecationReason($deprecationReason) {
if (is_array($deprecationReason) && empty($deprecationReason)) {
$this->deprecationReason = new \stdClass;
} else {
$this->deprecationReason = $deprecationReason;
}
return $this;
}
|
php
|
public function setDeprecationReason($deprecationReason) {
if (is_array($deprecationReason) && empty($deprecationReason)) {
$this->deprecationReason = new \stdClass;
} else {
$this->deprecationReason = $deprecationReason;
}
return $this;
}
|
[
"public",
"function",
"setDeprecationReason",
"(",
"$",
"deprecationReason",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"deprecationReason",
")",
"&&",
"empty",
"(",
"$",
"deprecationReason",
")",
")",
"{",
"$",
"this",
"->",
"deprecationReason",
"=",
"new",
"\\",
"stdClass",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"deprecationReason",
"=",
"$",
"deprecationReason",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Sets deprecationReason.
@param map[string,string] $deprecationReason
@return PaymentConnector
|
[
"Sets",
"deprecationReason",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/Model/PaymentConnector.php#L266-L274
|
221,947
|
wallee-payment/php-sdk
|
lib/Model/PaymentMethod.php
|
PaymentMethod.setMerchantDescription
|
public function setMerchantDescription($merchantDescription) {
if (is_array($merchantDescription) && empty($merchantDescription)) {
$this->merchantDescription = new \stdClass;
} else {
$this->merchantDescription = $merchantDescription;
}
return $this;
}
|
php
|
public function setMerchantDescription($merchantDescription) {
if (is_array($merchantDescription) && empty($merchantDescription)) {
$this->merchantDescription = new \stdClass;
} else {
$this->merchantDescription = $merchantDescription;
}
return $this;
}
|
[
"public",
"function",
"setMerchantDescription",
"(",
"$",
"merchantDescription",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"merchantDescription",
")",
"&&",
"empty",
"(",
"$",
"merchantDescription",
")",
")",
"{",
"$",
"this",
"->",
"merchantDescription",
"=",
"new",
"\\",
"stdClass",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"merchantDescription",
"=",
"$",
"merchantDescription",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Sets merchantDescription.
@param map[string,string] $merchantDescription
@return PaymentMethod
|
[
"Sets",
"merchantDescription",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/Model/PaymentMethod.php#L256-L264
|
221,948
|
wallee-payment/php-sdk
|
lib/Model/MetricUsage.php
|
MetricUsage.setMetricDescription
|
public function setMetricDescription($metricDescription) {
if (is_array($metricDescription) && empty($metricDescription)) {
$this->metricDescription = new \stdClass;
} else {
$this->metricDescription = $metricDescription;
}
return $this;
}
|
php
|
public function setMetricDescription($metricDescription) {
if (is_array($metricDescription) && empty($metricDescription)) {
$this->metricDescription = new \stdClass;
} else {
$this->metricDescription = $metricDescription;
}
return $this;
}
|
[
"public",
"function",
"setMetricDescription",
"(",
"$",
"metricDescription",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"metricDescription",
")",
"&&",
"empty",
"(",
"$",
"metricDescription",
")",
")",
"{",
"$",
"this",
"->",
"metricDescription",
"=",
"new",
"\\",
"stdClass",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"metricDescription",
"=",
"$",
"metricDescription",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Sets metricDescription.
@param map[string,string] $metricDescription
@return MetricUsage
|
[
"Sets",
"metricDescription",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/Model/MetricUsage.php#L150-L158
|
221,949
|
wallee-payment/php-sdk
|
lib/Model/MetricUsage.php
|
MetricUsage.setMetricName
|
public function setMetricName($metricName) {
if (is_array($metricName) && empty($metricName)) {
$this->metricName = new \stdClass;
} else {
$this->metricName = $metricName;
}
return $this;
}
|
php
|
public function setMetricName($metricName) {
if (is_array($metricName) && empty($metricName)) {
$this->metricName = new \stdClass;
} else {
$this->metricName = $metricName;
}
return $this;
}
|
[
"public",
"function",
"setMetricName",
"(",
"$",
"metricName",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"metricName",
")",
"&&",
"empty",
"(",
"$",
"metricName",
")",
")",
"{",
"$",
"this",
"->",
"metricName",
"=",
"new",
"\\",
"stdClass",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"metricName",
"=",
"$",
"metricName",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Sets metricName.
@param map[string,string] $metricName
@return MetricUsage
|
[
"Sets",
"metricName",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/Model/MetricUsage.php#L200-L208
|
221,950
|
ins0/google-measurement-php-client
|
src/Racecore/GATracking/Autoloader.php
|
Autoloader.autoload
|
public function autoload($class)
{
$filePath = $this->folder . '/' . str_replace('\\', '/', $class) . '.php';
if (file_exists($filePath)) {
return ( (require_once $filePath) === false ? true : false );
}
return false;
}
|
php
|
public function autoload($class)
{
$filePath = $this->folder . '/' . str_replace('\\', '/', $class) . '.php';
if (file_exists($filePath)) {
return ( (require_once $filePath) === false ? true : false );
}
return false;
}
|
[
"public",
"function",
"autoload",
"(",
"$",
"class",
")",
"{",
"$",
"filePath",
"=",
"$",
"this",
"->",
"folder",
".",
"'/'",
".",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"$",
"class",
")",
".",
"'.php'",
";",
"if",
"(",
"file_exists",
"(",
"$",
"filePath",
")",
")",
"{",
"return",
"(",
"(",
"require_once",
"$",
"filePath",
")",
"===",
"false",
"?",
"true",
":",
"false",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Handel autoloading of classes
@param $class
@return bool|mixed
|
[
"Handel",
"autoloading",
"of",
"classes"
] |
415cabca0c6d83cd0bd6a8ed6fb695b35f892018
|
https://github.com/ins0/google-measurement-php-client/blob/415cabca0c6d83cd0bd6a8ed6fb695b35f892018/src/Racecore/GATracking/Autoloader.php#L45-L54
|
221,951
|
wallee-payment/php-sdk
|
lib/Http/SocketHttpClient.php
|
SocketHttpClient.readFromSocket
|
private function readFromSocket(ApiClient $apiClient, HttpRequest $request, $socket) {
$inBody = false;
$responseMessage = '';
$chunked = false;
$chunkLength = false;
$maxTime = $this->getStartTime() + $apiClient->getConnectionTimeout();
$contentLength = -1;
$endReached = false;
while ($maxTime > time() && !feof($socket) && !$endReached) {
if ($inBody === false) {
$line = $this->readLineFromSocket($apiClient, $request, $socket, 2048);
if ($line == "\r\n") {
$inBody = true;
} else {
$parts = explode(':', $line, 2);
if (count($parts) == 2) {
$headerName = trim(strtolower($parts[0]));
$headerValue = trim(strtolower($parts[1]));
if ($headerName === 'transfer-encoding' && $headerValue == 'chunked') {
$chunked = true;
}
if ($headerName === 'content-length') {
$contentLength = (int)$headerValue;
}
}
}
$responseMessage .= $line;
} else {
// Check if we can read without chunks
if (!$chunked) {
$readBytes = 4096;
if ($contentLength > 0) {
$readBytes = $contentLength;
}
$tmp = $this->readContentFromSocket($apiClient, $request, $socket, $readBytes);
$responseMessage .= $tmp;
if (strlen($tmp) == $readBytes) {
$endReached = true;
break;
}
} else {
// Since we have not set any content length we assume that we need to read in chunks.
// We have to read the next line to get the chunk length.
if ($chunkLength === false) {
$line = trim(fgets($socket, 128));
$chunkLength = hexdec($line);
} else if ($chunkLength > 0) {
// We have to read the chunk, when it is greater than zero. The last one is always 0.
$responseMessage .= $this->readContentFromSocket($apiClient, $request, $socket, $chunkLength);
// We skip the next line break.
fseek($socket, 2, SEEK_CUR);
$chunkLength = false;
} else {
// The chunk length must be zero. Hence we are finished and we can stop.
$endReached = true;
break;
}
}
}
}
if (feof($socket) || $endReached) {
return $responseMessage;
} else {
throw new ConnectionException(null, $request->getLogToken(),
'The remote server did not respond within ' . $apiClient->getConnectionTimeout() . ' seconds.');
}
}
|
php
|
private function readFromSocket(ApiClient $apiClient, HttpRequest $request, $socket) {
$inBody = false;
$responseMessage = '';
$chunked = false;
$chunkLength = false;
$maxTime = $this->getStartTime() + $apiClient->getConnectionTimeout();
$contentLength = -1;
$endReached = false;
while ($maxTime > time() && !feof($socket) && !$endReached) {
if ($inBody === false) {
$line = $this->readLineFromSocket($apiClient, $request, $socket, 2048);
if ($line == "\r\n") {
$inBody = true;
} else {
$parts = explode(':', $line, 2);
if (count($parts) == 2) {
$headerName = trim(strtolower($parts[0]));
$headerValue = trim(strtolower($parts[1]));
if ($headerName === 'transfer-encoding' && $headerValue == 'chunked') {
$chunked = true;
}
if ($headerName === 'content-length') {
$contentLength = (int)$headerValue;
}
}
}
$responseMessage .= $line;
} else {
// Check if we can read without chunks
if (!$chunked) {
$readBytes = 4096;
if ($contentLength > 0) {
$readBytes = $contentLength;
}
$tmp = $this->readContentFromSocket($apiClient, $request, $socket, $readBytes);
$responseMessage .= $tmp;
if (strlen($tmp) == $readBytes) {
$endReached = true;
break;
}
} else {
// Since we have not set any content length we assume that we need to read in chunks.
// We have to read the next line to get the chunk length.
if ($chunkLength === false) {
$line = trim(fgets($socket, 128));
$chunkLength = hexdec($line);
} else if ($chunkLength > 0) {
// We have to read the chunk, when it is greater than zero. The last one is always 0.
$responseMessage .= $this->readContentFromSocket($apiClient, $request, $socket, $chunkLength);
// We skip the next line break.
fseek($socket, 2, SEEK_CUR);
$chunkLength = false;
} else {
// The chunk length must be zero. Hence we are finished and we can stop.
$endReached = true;
break;
}
}
}
}
if (feof($socket) || $endReached) {
return $responseMessage;
} else {
throw new ConnectionException(null, $request->getLogToken(),
'The remote server did not respond within ' . $apiClient->getConnectionTimeout() . ' seconds.');
}
}
|
[
"private",
"function",
"readFromSocket",
"(",
"ApiClient",
"$",
"apiClient",
",",
"HttpRequest",
"$",
"request",
",",
"$",
"socket",
")",
"{",
"$",
"inBody",
"=",
"false",
";",
"$",
"responseMessage",
"=",
"''",
";",
"$",
"chunked",
"=",
"false",
";",
"$",
"chunkLength",
"=",
"false",
";",
"$",
"maxTime",
"=",
"$",
"this",
"->",
"getStartTime",
"(",
")",
"+",
"$",
"apiClient",
"->",
"getConnectionTimeout",
"(",
")",
";",
"$",
"contentLength",
"=",
"-",
"1",
";",
"$",
"endReached",
"=",
"false",
";",
"while",
"(",
"$",
"maxTime",
">",
"time",
"(",
")",
"&&",
"!",
"feof",
"(",
"$",
"socket",
")",
"&&",
"!",
"$",
"endReached",
")",
"{",
"if",
"(",
"$",
"inBody",
"===",
"false",
")",
"{",
"$",
"line",
"=",
"$",
"this",
"->",
"readLineFromSocket",
"(",
"$",
"apiClient",
",",
"$",
"request",
",",
"$",
"socket",
",",
"2048",
")",
";",
"if",
"(",
"$",
"line",
"==",
"\"\\r\\n\"",
")",
"{",
"$",
"inBody",
"=",
"true",
";",
"}",
"else",
"{",
"$",
"parts",
"=",
"explode",
"(",
"':'",
",",
"$",
"line",
",",
"2",
")",
";",
"if",
"(",
"count",
"(",
"$",
"parts",
")",
"==",
"2",
")",
"{",
"$",
"headerName",
"=",
"trim",
"(",
"strtolower",
"(",
"$",
"parts",
"[",
"0",
"]",
")",
")",
";",
"$",
"headerValue",
"=",
"trim",
"(",
"strtolower",
"(",
"$",
"parts",
"[",
"1",
"]",
")",
")",
";",
"if",
"(",
"$",
"headerName",
"===",
"'transfer-encoding'",
"&&",
"$",
"headerValue",
"==",
"'chunked'",
")",
"{",
"$",
"chunked",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"headerName",
"===",
"'content-length'",
")",
"{",
"$",
"contentLength",
"=",
"(",
"int",
")",
"$",
"headerValue",
";",
"}",
"}",
"}",
"$",
"responseMessage",
".=",
"$",
"line",
";",
"}",
"else",
"{",
"// Check if we can read without chunks",
"if",
"(",
"!",
"$",
"chunked",
")",
"{",
"$",
"readBytes",
"=",
"4096",
";",
"if",
"(",
"$",
"contentLength",
">",
"0",
")",
"{",
"$",
"readBytes",
"=",
"$",
"contentLength",
";",
"}",
"$",
"tmp",
"=",
"$",
"this",
"->",
"readContentFromSocket",
"(",
"$",
"apiClient",
",",
"$",
"request",
",",
"$",
"socket",
",",
"$",
"readBytes",
")",
";",
"$",
"responseMessage",
".=",
"$",
"tmp",
";",
"if",
"(",
"strlen",
"(",
"$",
"tmp",
")",
"==",
"$",
"readBytes",
")",
"{",
"$",
"endReached",
"=",
"true",
";",
"break",
";",
"}",
"}",
"else",
"{",
"// Since we have not set any content length we assume that we need to read in chunks.",
"// We have to read the next line to get the chunk length.",
"if",
"(",
"$",
"chunkLength",
"===",
"false",
")",
"{",
"$",
"line",
"=",
"trim",
"(",
"fgets",
"(",
"$",
"socket",
",",
"128",
")",
")",
";",
"$",
"chunkLength",
"=",
"hexdec",
"(",
"$",
"line",
")",
";",
"}",
"else",
"if",
"(",
"$",
"chunkLength",
">",
"0",
")",
"{",
"// We have to read the chunk, when it is greater than zero. The last one is always 0.",
"$",
"responseMessage",
".=",
"$",
"this",
"->",
"readContentFromSocket",
"(",
"$",
"apiClient",
",",
"$",
"request",
",",
"$",
"socket",
",",
"$",
"chunkLength",
")",
";",
"// We skip the next line break.",
"fseek",
"(",
"$",
"socket",
",",
"2",
",",
"SEEK_CUR",
")",
";",
"$",
"chunkLength",
"=",
"false",
";",
"}",
"else",
"{",
"// The chunk length must be zero. Hence we are finished and we can stop.",
"$",
"endReached",
"=",
"true",
";",
"break",
";",
"}",
"}",
"}",
"}",
"if",
"(",
"feof",
"(",
"$",
"socket",
")",
"||",
"$",
"endReached",
")",
"{",
"return",
"$",
"responseMessage",
";",
"}",
"else",
"{",
"throw",
"new",
"ConnectionException",
"(",
"null",
",",
"$",
"request",
"->",
"getLogToken",
"(",
")",
",",
"'The remote server did not respond within '",
".",
"$",
"apiClient",
"->",
"getConnectionTimeout",
"(",
")",
".",
"' seconds.'",
")",
";",
"}",
"}"
] |
This method reads from the given socket. Depending on the given header the read process may be halted after
reading the last chunk. This method is required, because some servers do not close the connection in chunked
transfer. Hence the timeout of the connection must be reached, before the connection is closed. By tracking the
chunks, the connection can be closed earlier after the last chunk.
@param ApiClient $apiClient the API client instance
@param HttpRequest $request the HTTP request
@param resource $socket the socket
@throws ConnectionException
@return string
|
[
"This",
"method",
"reads",
"from",
"the",
"given",
"socket",
".",
"Depending",
"on",
"the",
"given",
"header",
"the",
"read",
"process",
"may",
"be",
"halted",
"after",
"reading",
"the",
"last",
"chunk",
".",
"This",
"method",
"is",
"required",
"because",
"some",
"servers",
"do",
"not",
"close",
"the",
"connection",
"in",
"chunked",
"transfer",
".",
"Hence",
"the",
"timeout",
"of",
"the",
"connection",
"must",
"be",
"reached",
"before",
"the",
"connection",
"is",
"closed",
".",
"By",
"tracking",
"the",
"chunks",
"the",
"connection",
"can",
"be",
"closed",
"earlier",
"after",
"the",
"last",
"chunk",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/Http/SocketHttpClient.php#L79-L150
|
221,952
|
wallee-payment/php-sdk
|
lib/Http/SocketHttpClient.php
|
SocketHttpClient.readContentFromSocket
|
private function readContentFromSocket(ApiClient $apiClient, HttpRequest $request, $socket, $maxNumberOfBytes) {
stream_set_blocking($socket, false);
$maxTime = $this->getStartTime() + $apiClient->getConnectionTimeout();
$numberOfBytesRead = 0;
$result = '';
while ($maxTime >= time() && $numberOfBytesRead < $maxNumberOfBytes && !feof($socket)) {
$nextChunkSize = min(128, $maxNumberOfBytes - $numberOfBytesRead);
$tmp = stream_get_contents($socket, $nextChunkSize);
if ($tmp !== false && strlen($tmp) > 0) {
$result .= $tmp;
$numberOfBytesRead += strlen($tmp);
} else {
// Wait 100 milliseconds
usleep(100 * 1000);
}
}
stream_set_blocking($socket, true);
if (feof($socket) || $numberOfBytesRead >= $maxNumberOfBytes) {
return $result;
} else {
throw new ConnectionException(null, $request->getLogToken(),
'The remote server did not respond within ' . $apiClient->getConnectionTimeout() . ' seconds.');
}
}
|
php
|
private function readContentFromSocket(ApiClient $apiClient, HttpRequest $request, $socket, $maxNumberOfBytes) {
stream_set_blocking($socket, false);
$maxTime = $this->getStartTime() + $apiClient->getConnectionTimeout();
$numberOfBytesRead = 0;
$result = '';
while ($maxTime >= time() && $numberOfBytesRead < $maxNumberOfBytes && !feof($socket)) {
$nextChunkSize = min(128, $maxNumberOfBytes - $numberOfBytesRead);
$tmp = stream_get_contents($socket, $nextChunkSize);
if ($tmp !== false && strlen($tmp) > 0) {
$result .= $tmp;
$numberOfBytesRead += strlen($tmp);
} else {
// Wait 100 milliseconds
usleep(100 * 1000);
}
}
stream_set_blocking($socket, true);
if (feof($socket) || $numberOfBytesRead >= $maxNumberOfBytes) {
return $result;
} else {
throw new ConnectionException(null, $request->getLogToken(),
'The remote server did not respond within ' . $apiClient->getConnectionTimeout() . ' seconds.');
}
}
|
[
"private",
"function",
"readContentFromSocket",
"(",
"ApiClient",
"$",
"apiClient",
",",
"HttpRequest",
"$",
"request",
",",
"$",
"socket",
",",
"$",
"maxNumberOfBytes",
")",
"{",
"stream_set_blocking",
"(",
"$",
"socket",
",",
"false",
")",
";",
"$",
"maxTime",
"=",
"$",
"this",
"->",
"getStartTime",
"(",
")",
"+",
"$",
"apiClient",
"->",
"getConnectionTimeout",
"(",
")",
";",
"$",
"numberOfBytesRead",
"=",
"0",
";",
"$",
"result",
"=",
"''",
";",
"while",
"(",
"$",
"maxTime",
">=",
"time",
"(",
")",
"&&",
"$",
"numberOfBytesRead",
"<",
"$",
"maxNumberOfBytes",
"&&",
"!",
"feof",
"(",
"$",
"socket",
")",
")",
"{",
"$",
"nextChunkSize",
"=",
"min",
"(",
"128",
",",
"$",
"maxNumberOfBytes",
"-",
"$",
"numberOfBytesRead",
")",
";",
"$",
"tmp",
"=",
"stream_get_contents",
"(",
"$",
"socket",
",",
"$",
"nextChunkSize",
")",
";",
"if",
"(",
"$",
"tmp",
"!==",
"false",
"&&",
"strlen",
"(",
"$",
"tmp",
")",
">",
"0",
")",
"{",
"$",
"result",
".=",
"$",
"tmp",
";",
"$",
"numberOfBytesRead",
"+=",
"strlen",
"(",
"$",
"tmp",
")",
";",
"}",
"else",
"{",
"// Wait 100 milliseconds",
"usleep",
"(",
"100",
"*",
"1000",
")",
";",
"}",
"}",
"stream_set_blocking",
"(",
"$",
"socket",
",",
"true",
")",
";",
"if",
"(",
"feof",
"(",
"$",
"socket",
")",
"||",
"$",
"numberOfBytesRead",
">=",
"$",
"maxNumberOfBytes",
")",
"{",
"return",
"$",
"result",
";",
"}",
"else",
"{",
"throw",
"new",
"ConnectionException",
"(",
"null",
",",
"$",
"request",
"->",
"getLogToken",
"(",
")",
",",
"'The remote server did not respond within '",
".",
"$",
"apiClient",
"->",
"getConnectionTimeout",
"(",
")",
".",
"' seconds.'",
")",
";",
"}",
"}"
] |
This method reads in blocking fashion from the socket.
We need this method because neither fread nor stream_get_contents do respect timeouts.
@param ApiClient $apiClient the API client instance
@param HttpRequest $request the HTTP request
@param resource $socket the socket from which should be read
@param int $maxNumberOfBytes the number of bytes to read
@throws ConnectionException
@return string
|
[
"This",
"method",
"reads",
"in",
"blocking",
"fashion",
"from",
"the",
"socket",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/Http/SocketHttpClient.php#L164-L188
|
221,953
|
wallee-payment/php-sdk
|
lib/Http/SocketHttpClient.php
|
SocketHttpClient.readLineFromSocket
|
private function readLineFromSocket(ApiClient $apiClient, HttpRequest $request, $socket, $maxNumberOfBytes) {
stream_set_blocking($socket, false);
$maxTime = $this->getStartTime() + $apiClient->getConnectionTimeout();
$result = false;
while ($maxTime >= time() && $result === false && !feof($socket)) {
$tmp = fgets($socket, $maxNumberOfBytes);
if ($tmp !== false && strlen($tmp) > 0) {
$result = $tmp;
} else {
// Wait 100 milliseconds
usleep(100 * 1000);
}
}
stream_set_blocking($socket, true);
if ($result !== false) {
return $result;
} else {
throw new ConnectionException(null, $request->getLogToken(),
'The remote server did not respond within ' . $apiClient->getConnectionTimeout() . ' seconds.');
}
}
|
php
|
private function readLineFromSocket(ApiClient $apiClient, HttpRequest $request, $socket, $maxNumberOfBytes) {
stream_set_blocking($socket, false);
$maxTime = $this->getStartTime() + $apiClient->getConnectionTimeout();
$result = false;
while ($maxTime >= time() && $result === false && !feof($socket)) {
$tmp = fgets($socket, $maxNumberOfBytes);
if ($tmp !== false && strlen($tmp) > 0) {
$result = $tmp;
} else {
// Wait 100 milliseconds
usleep(100 * 1000);
}
}
stream_set_blocking($socket, true);
if ($result !== false) {
return $result;
} else {
throw new ConnectionException(null, $request->getLogToken(),
'The remote server did not respond within ' . $apiClient->getConnectionTimeout() . ' seconds.');
}
}
|
[
"private",
"function",
"readLineFromSocket",
"(",
"ApiClient",
"$",
"apiClient",
",",
"HttpRequest",
"$",
"request",
",",
"$",
"socket",
",",
"$",
"maxNumberOfBytes",
")",
"{",
"stream_set_blocking",
"(",
"$",
"socket",
",",
"false",
")",
";",
"$",
"maxTime",
"=",
"$",
"this",
"->",
"getStartTime",
"(",
")",
"+",
"$",
"apiClient",
"->",
"getConnectionTimeout",
"(",
")",
";",
"$",
"result",
"=",
"false",
";",
"while",
"(",
"$",
"maxTime",
">=",
"time",
"(",
")",
"&&",
"$",
"result",
"===",
"false",
"&&",
"!",
"feof",
"(",
"$",
"socket",
")",
")",
"{",
"$",
"tmp",
"=",
"fgets",
"(",
"$",
"socket",
",",
"$",
"maxNumberOfBytes",
")",
";",
"if",
"(",
"$",
"tmp",
"!==",
"false",
"&&",
"strlen",
"(",
"$",
"tmp",
")",
">",
"0",
")",
"{",
"$",
"result",
"=",
"$",
"tmp",
";",
"}",
"else",
"{",
"// Wait 100 milliseconds",
"usleep",
"(",
"100",
"*",
"1000",
")",
";",
"}",
"}",
"stream_set_blocking",
"(",
"$",
"socket",
",",
"true",
")",
";",
"if",
"(",
"$",
"result",
"!==",
"false",
")",
"{",
"return",
"$",
"result",
";",
"}",
"else",
"{",
"throw",
"new",
"ConnectionException",
"(",
"null",
",",
"$",
"request",
"->",
"getLogToken",
"(",
")",
",",
"'The remote server did not respond within '",
".",
"$",
"apiClient",
"->",
"getConnectionTimeout",
"(",
")",
".",
"' seconds.'",
")",
";",
"}",
"}"
] |
This method reads a single line in blocking fashion from the socket. The method does respect the timeout
configured.
@param ApiClient $apiClient the API client instance
@param HttpRequest $request the HTTP request
@param resource $socket the socket from which should be read
@param int $maxNumberOfBytes the number of bytes to read
@throws ConnectionException
@return string
|
[
"This",
"method",
"reads",
"a",
"single",
"line",
"in",
"blocking",
"fashion",
"from",
"the",
"socket",
".",
"The",
"method",
"does",
"respect",
"the",
"timeout",
"configured",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/Http/SocketHttpClient.php#L201-L222
|
221,954
|
wallee-payment/php-sdk
|
lib/Http/SocketHttpClient.php
|
SocketHttpClient.startStreamSocket
|
private function startStreamSocket(ApiClient $apiClient, HttpRequest $request) {
$this->configureRequest($request);
$socket = $this->createSocketStream($apiClient, $request);
$message = $request->toString();
if ($apiClient->isDebuggingEnabled()) {
error_log("[DEBUG] HTTP Request ~BEGIN~".PHP_EOL.$message.PHP_EOL."~END~".PHP_EOL, 3, $apiClient->getDebugFile());
}
$result = fwrite($socket, $message);
if ($result == false) {
throw new ConnectionException($request->getUrl(), $request->getLogToken(), 'Could not send the message to the server.');
}
return $socket;
}
|
php
|
private function startStreamSocket(ApiClient $apiClient, HttpRequest $request) {
$this->configureRequest($request);
$socket = $this->createSocketStream($apiClient, $request);
$message = $request->toString();
if ($apiClient->isDebuggingEnabled()) {
error_log("[DEBUG] HTTP Request ~BEGIN~".PHP_EOL.$message.PHP_EOL."~END~".PHP_EOL, 3, $apiClient->getDebugFile());
}
$result = fwrite($socket, $message);
if ($result == false) {
throw new ConnectionException($request->getUrl(), $request->getLogToken(), 'Could not send the message to the server.');
}
return $socket;
}
|
[
"private",
"function",
"startStreamSocket",
"(",
"ApiClient",
"$",
"apiClient",
",",
"HttpRequest",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"configureRequest",
"(",
"$",
"request",
")",
";",
"$",
"socket",
"=",
"$",
"this",
"->",
"createSocketStream",
"(",
"$",
"apiClient",
",",
"$",
"request",
")",
";",
"$",
"message",
"=",
"$",
"request",
"->",
"toString",
"(",
")",
";",
"if",
"(",
"$",
"apiClient",
"->",
"isDebuggingEnabled",
"(",
")",
")",
"{",
"error_log",
"(",
"\"[DEBUG] HTTP Request ~BEGIN~\"",
".",
"PHP_EOL",
".",
"$",
"message",
".",
"PHP_EOL",
".",
"\"~END~\"",
".",
"PHP_EOL",
",",
"3",
",",
"$",
"apiClient",
"->",
"getDebugFile",
"(",
")",
")",
";",
"}",
"$",
"result",
"=",
"fwrite",
"(",
"$",
"socket",
",",
"$",
"message",
")",
";",
"if",
"(",
"$",
"result",
"==",
"false",
")",
"{",
"throw",
"new",
"ConnectionException",
"(",
"$",
"request",
"->",
"getUrl",
"(",
")",
",",
"$",
"request",
"->",
"getLogToken",
"(",
")",
",",
"'Could not send the message to the server.'",
")",
";",
"}",
"return",
"$",
"socket",
";",
"}"
] |
Creates a socket and sends the request to the remote host.
As result a stream socket is returned. Which can be used to read the response.
@param ApiClient $apiClient the API client instance
@param HttpRequest $request the HTTP request
@throws ConnectionException
@return resource
|
[
"Creates",
"a",
"socket",
"and",
"sends",
"the",
"request",
"to",
"the",
"remote",
"host",
".",
"As",
"result",
"a",
"stream",
"socket",
"is",
"returned",
".",
"Which",
"can",
"be",
"used",
"to",
"read",
"the",
"response",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/Http/SocketHttpClient.php#L233-L248
|
221,955
|
wallee-payment/php-sdk
|
lib/Http/SocketHttpClient.php
|
SocketHttpClient.configureRequest
|
private function configureRequest(HttpRequest $request){
$proxyUrl = $this->readEnvironmentVariable(self::ENVIRONMENT_VARIABLE_PROXY_URL);
if ($proxyUrl !== null) {
$proxyUser = parse_url($proxyUrl, PHP_URL_USER);
$proxyPass = parse_url($proxyUrl, PHP_URL_PASS);
if ($proxyUser !== NULL) {
$auth = $proxyUser;
if ($proxyPass !== NULL) {
$auth .= ':' . $proxyPass;
}
$auth = base64_encode($auth);
$request->addHeader('proxy-authorization', 'Basic ' . $auth);
}
}
}
|
php
|
private function configureRequest(HttpRequest $request){
$proxyUrl = $this->readEnvironmentVariable(self::ENVIRONMENT_VARIABLE_PROXY_URL);
if ($proxyUrl !== null) {
$proxyUser = parse_url($proxyUrl, PHP_URL_USER);
$proxyPass = parse_url($proxyUrl, PHP_URL_PASS);
if ($proxyUser !== NULL) {
$auth = $proxyUser;
if ($proxyPass !== NULL) {
$auth .= ':' . $proxyPass;
}
$auth = base64_encode($auth);
$request->addHeader('proxy-authorization', 'Basic ' . $auth);
}
}
}
|
[
"private",
"function",
"configureRequest",
"(",
"HttpRequest",
"$",
"request",
")",
"{",
"$",
"proxyUrl",
"=",
"$",
"this",
"->",
"readEnvironmentVariable",
"(",
"self",
"::",
"ENVIRONMENT_VARIABLE_PROXY_URL",
")",
";",
"if",
"(",
"$",
"proxyUrl",
"!==",
"null",
")",
"{",
"$",
"proxyUser",
"=",
"parse_url",
"(",
"$",
"proxyUrl",
",",
"PHP_URL_USER",
")",
";",
"$",
"proxyPass",
"=",
"parse_url",
"(",
"$",
"proxyUrl",
",",
"PHP_URL_PASS",
")",
";",
"if",
"(",
"$",
"proxyUser",
"!==",
"NULL",
")",
"{",
"$",
"auth",
"=",
"$",
"proxyUser",
";",
"if",
"(",
"$",
"proxyPass",
"!==",
"NULL",
")",
"{",
"$",
"auth",
".=",
"':'",
".",
"$",
"proxyPass",
";",
"}",
"$",
"auth",
"=",
"base64_encode",
"(",
"$",
"auth",
")",
";",
"$",
"request",
"->",
"addHeader",
"(",
"'proxy-authorization'",
",",
"'Basic '",
".",
"$",
"auth",
")",
";",
"}",
"}",
"}"
] |
This method modifies the request so it can be sent.
Sub classes may
override this method to apply further modifications.
@param HttpRequest $request the HTTP request
|
[
"This",
"method",
"modifies",
"the",
"request",
"so",
"it",
"can",
"be",
"sent",
".",
"Sub",
"classes",
"may",
"override",
"this",
"method",
"to",
"apply",
"further",
"modifications",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/Http/SocketHttpClient.php#L257-L271
|
221,956
|
wallee-payment/php-sdk
|
lib/Http/SocketHttpClient.php
|
SocketHttpClient.createSocketStream
|
private function createSocketStream(ApiClient $apiClient, HttpRequest $request) {
if ($request->isSecureConnection()) {
if (!extension_loaded('openssl')) {
throw new \Exception("You have to enable OpenSSL.");
}
}
$proxyUrl = $this->readEnvironmentVariable(self::ENVIRONMENT_VARIABLE_PROXY_URL);
if ($proxyUrl !== null) {
$host = parse_url($proxyUrl, PHP_URL_HOST);
$port = parse_url($proxyUrl, PHP_URL_PORT);
if(empty($port)) {
throw new ConnectionException($request->getUrl(), $request->getLogToken(), "The Proxy URL must contain a port number.");
}
} else {
$host = ($request->isSecureConnection() ? $this->getSslProtocol() . '://' : '') . $request->getHost();
$port = $request->getPort();
if(empty($port)) {
$port = $request->isSecureConnection() ? 443 : 80;
}
}
$socket = $host . ':' . $port;
$filePointer = @stream_socket_client($socket, $errno, $errstr, $apiClient->getConnectionTimeout(), STREAM_CLIENT_CONNECT,
$this->createStreamContext($apiClient, $request));
if ($filePointer === false) {
throw new ConnectionException($request->getUrl(), $request->getLogToken(), $errstr);
}
if (!(get_resource_type($filePointer) == 'stream')) {
$errorMessage = 'Could not connect to the server. The returned socket was not a stream.';
throw new ConnectionException($request->getUrl(), $request->getLogToken(), $errorMessage);
}
return $filePointer;
}
|
php
|
private function createSocketStream(ApiClient $apiClient, HttpRequest $request) {
if ($request->isSecureConnection()) {
if (!extension_loaded('openssl')) {
throw new \Exception("You have to enable OpenSSL.");
}
}
$proxyUrl = $this->readEnvironmentVariable(self::ENVIRONMENT_VARIABLE_PROXY_URL);
if ($proxyUrl !== null) {
$host = parse_url($proxyUrl, PHP_URL_HOST);
$port = parse_url($proxyUrl, PHP_URL_PORT);
if(empty($port)) {
throw new ConnectionException($request->getUrl(), $request->getLogToken(), "The Proxy URL must contain a port number.");
}
} else {
$host = ($request->isSecureConnection() ? $this->getSslProtocol() . '://' : '') . $request->getHost();
$port = $request->getPort();
if(empty($port)) {
$port = $request->isSecureConnection() ? 443 : 80;
}
}
$socket = $host . ':' . $port;
$filePointer = @stream_socket_client($socket, $errno, $errstr, $apiClient->getConnectionTimeout(), STREAM_CLIENT_CONNECT,
$this->createStreamContext($apiClient, $request));
if ($filePointer === false) {
throw new ConnectionException($request->getUrl(), $request->getLogToken(), $errstr);
}
if (!(get_resource_type($filePointer) == 'stream')) {
$errorMessage = 'Could not connect to the server. The returned socket was not a stream.';
throw new ConnectionException($request->getUrl(), $request->getLogToken(), $errorMessage);
}
return $filePointer;
}
|
[
"private",
"function",
"createSocketStream",
"(",
"ApiClient",
"$",
"apiClient",
",",
"HttpRequest",
"$",
"request",
")",
"{",
"if",
"(",
"$",
"request",
"->",
"isSecureConnection",
"(",
")",
")",
"{",
"if",
"(",
"!",
"extension_loaded",
"(",
"'openssl'",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"You have to enable OpenSSL.\"",
")",
";",
"}",
"}",
"$",
"proxyUrl",
"=",
"$",
"this",
"->",
"readEnvironmentVariable",
"(",
"self",
"::",
"ENVIRONMENT_VARIABLE_PROXY_URL",
")",
";",
"if",
"(",
"$",
"proxyUrl",
"!==",
"null",
")",
"{",
"$",
"host",
"=",
"parse_url",
"(",
"$",
"proxyUrl",
",",
"PHP_URL_HOST",
")",
";",
"$",
"port",
"=",
"parse_url",
"(",
"$",
"proxyUrl",
",",
"PHP_URL_PORT",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"port",
")",
")",
"{",
"throw",
"new",
"ConnectionException",
"(",
"$",
"request",
"->",
"getUrl",
"(",
")",
",",
"$",
"request",
"->",
"getLogToken",
"(",
")",
",",
"\"The Proxy URL must contain a port number.\"",
")",
";",
"}",
"}",
"else",
"{",
"$",
"host",
"=",
"(",
"$",
"request",
"->",
"isSecureConnection",
"(",
")",
"?",
"$",
"this",
"->",
"getSslProtocol",
"(",
")",
".",
"'://'",
":",
"''",
")",
".",
"$",
"request",
"->",
"getHost",
"(",
")",
";",
"$",
"port",
"=",
"$",
"request",
"->",
"getPort",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"port",
")",
")",
"{",
"$",
"port",
"=",
"$",
"request",
"->",
"isSecureConnection",
"(",
")",
"?",
"443",
":",
"80",
";",
"}",
"}",
"$",
"socket",
"=",
"$",
"host",
".",
"':'",
".",
"$",
"port",
";",
"$",
"filePointer",
"=",
"@",
"stream_socket_client",
"(",
"$",
"socket",
",",
"$",
"errno",
",",
"$",
"errstr",
",",
"$",
"apiClient",
"->",
"getConnectionTimeout",
"(",
")",
",",
"STREAM_CLIENT_CONNECT",
",",
"$",
"this",
"->",
"createStreamContext",
"(",
"$",
"apiClient",
",",
"$",
"request",
")",
")",
";",
"if",
"(",
"$",
"filePointer",
"===",
"false",
")",
"{",
"throw",
"new",
"ConnectionException",
"(",
"$",
"request",
"->",
"getUrl",
"(",
")",
",",
"$",
"request",
"->",
"getLogToken",
"(",
")",
",",
"$",
"errstr",
")",
";",
"}",
"if",
"(",
"!",
"(",
"get_resource_type",
"(",
"$",
"filePointer",
")",
"==",
"'stream'",
")",
")",
"{",
"$",
"errorMessage",
"=",
"'Could not connect to the server. The returned socket was not a stream.'",
";",
"throw",
"new",
"ConnectionException",
"(",
"$",
"request",
"->",
"getUrl",
"(",
")",
",",
"$",
"request",
"->",
"getLogToken",
"(",
")",
",",
"$",
"errorMessage",
")",
";",
"}",
"return",
"$",
"filePointer",
";",
"}"
] |
This method creates a stream socket to the server.
@param ApiClient $apiClient the API client instance
@param HttpRequest $request the HTTP request
@throws ConnectionException
@return resource
|
[
"This",
"method",
"creates",
"a",
"stream",
"socket",
"to",
"the",
"server",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/Http/SocketHttpClient.php#L281-L318
|
221,957
|
wallee-payment/php-sdk
|
lib/Http/SocketHttpClient.php
|
SocketHttpClient.getSslProtocol
|
private function getSslProtocol(){
$version = $this->readEnvironmentVariable(self::ENVIRONMENT_VARIABLE_SSL_VERSION);
$rs = null;
switch ($version) {
case self::SSL_VERSION_SSLV2:
$rs = 'sslv2';
break;
case self::SSL_VERSION_SSLV3:
$rs = 'sslv3';
break;
case self::SSL_VERSION_TLSV1:
$rs = 'tls';
break;
case self::SSL_VERSION_TLSV11:
$rs = 'tlsv1.1';
break;
case self::SSL_VERSION_TLSV12:
$rs = 'tlsv1.2';
break;
default:
$rs = 'ssl';
}
if ($rs === null) {
throw new \Exception("Invalid state.");
}
$possibleTransportProtocols = stream_get_transports();
if (!in_array($rs, $possibleTransportProtocols)) {
throw new \Exception("The enforced SSL protocol is '" . $rs . "'. But this protocol is not supported by the web server. Supported stream protocols by the web server are " . implode(', ', $possibleTransportProtocols) . ".");
}
return $rs;
}
|
php
|
private function getSslProtocol(){
$version = $this->readEnvironmentVariable(self::ENVIRONMENT_VARIABLE_SSL_VERSION);
$rs = null;
switch ($version) {
case self::SSL_VERSION_SSLV2:
$rs = 'sslv2';
break;
case self::SSL_VERSION_SSLV3:
$rs = 'sslv3';
break;
case self::SSL_VERSION_TLSV1:
$rs = 'tls';
break;
case self::SSL_VERSION_TLSV11:
$rs = 'tlsv1.1';
break;
case self::SSL_VERSION_TLSV12:
$rs = 'tlsv1.2';
break;
default:
$rs = 'ssl';
}
if ($rs === null) {
throw new \Exception("Invalid state.");
}
$possibleTransportProtocols = stream_get_transports();
if (!in_array($rs, $possibleTransportProtocols)) {
throw new \Exception("The enforced SSL protocol is '" . $rs . "'. But this protocol is not supported by the web server. Supported stream protocols by the web server are " . implode(', ', $possibleTransportProtocols) . ".");
}
return $rs;
}
|
[
"private",
"function",
"getSslProtocol",
"(",
")",
"{",
"$",
"version",
"=",
"$",
"this",
"->",
"readEnvironmentVariable",
"(",
"self",
"::",
"ENVIRONMENT_VARIABLE_SSL_VERSION",
")",
";",
"$",
"rs",
"=",
"null",
";",
"switch",
"(",
"$",
"version",
")",
"{",
"case",
"self",
"::",
"SSL_VERSION_SSLV2",
":",
"$",
"rs",
"=",
"'sslv2'",
";",
"break",
";",
"case",
"self",
"::",
"SSL_VERSION_SSLV3",
":",
"$",
"rs",
"=",
"'sslv3'",
";",
"break",
";",
"case",
"self",
"::",
"SSL_VERSION_TLSV1",
":",
"$",
"rs",
"=",
"'tls'",
";",
"break",
";",
"case",
"self",
"::",
"SSL_VERSION_TLSV11",
":",
"$",
"rs",
"=",
"'tlsv1.1'",
";",
"break",
";",
"case",
"self",
"::",
"SSL_VERSION_TLSV12",
":",
"$",
"rs",
"=",
"'tlsv1.2'",
";",
"break",
";",
"default",
":",
"$",
"rs",
"=",
"'ssl'",
";",
"}",
"if",
"(",
"$",
"rs",
"===",
"null",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Invalid state.\"",
")",
";",
"}",
"$",
"possibleTransportProtocols",
"=",
"stream_get_transports",
"(",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"rs",
",",
"$",
"possibleTransportProtocols",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"The enforced SSL protocol is '\"",
".",
"$",
"rs",
".",
"\"'. But this protocol is not supported by the web server. Supported stream protocols by the web server are \"",
".",
"implode",
"(",
"', '",
",",
"$",
"possibleTransportProtocols",
")",
".",
"\".\"",
")",
";",
"}",
"return",
"$",
"rs",
";",
"}"
] |
Returns the protocol to use in case of an SSL connection.
@return string
|
[
"Returns",
"the",
"protocol",
"to",
"use",
"in",
"case",
"of",
"an",
"SSL",
"connection",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/Http/SocketHttpClient.php#L325-L357
|
221,958
|
wallee-payment/php-sdk
|
lib/Http/SocketHttpClient.php
|
SocketHttpClient.createStreamContext
|
private function createStreamContext(ApiClient $apiClient, HttpRequest $request) {
return stream_context_create($this->buildStreamContextOptions($apiClient, $request));
}
|
php
|
private function createStreamContext(ApiClient $apiClient, HttpRequest $request) {
return stream_context_create($this->buildStreamContextOptions($apiClient, $request));
}
|
[
"private",
"function",
"createStreamContext",
"(",
"ApiClient",
"$",
"apiClient",
",",
"HttpRequest",
"$",
"request",
")",
"{",
"return",
"stream_context_create",
"(",
"$",
"this",
"->",
"buildStreamContextOptions",
"(",
"$",
"apiClient",
",",
"$",
"request",
")",
")",
";",
"}"
] |
Creates and returns a new stream context.
@param ApiClient $apiClient the API client instance
@param HttpRequest $request the HTTP request
@return resource
|
[
"Creates",
"and",
"returns",
"a",
"new",
"stream",
"context",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/Http/SocketHttpClient.php#L366-L368
|
221,959
|
wallee-payment/php-sdk
|
lib/Http/SocketHttpClient.php
|
SocketHttpClient.buildStreamContextOptions
|
private function buildStreamContextOptions(ApiClient $apiClient, HttpRequest $request) {
$options = array(
'http' => array(),
'ssl' => array()
);
if ($request->isSecureConnection()) {
$options['ssl']['verify_host'] = true;
$options['ssl']['allow_self_signed'] = false;
$options['ssl']['verify_peer'] = false;
if ($apiClient->isCertificateAuthorityCheckEnabled()) {
$options['ssl']['verify_peer'] = true;
$options['ssl']['cafile'] = $apiClient->getCertificateAuthority();
}
}
$ipVersion = $this->readEnvironmentVariable(self::ENVIRONMENT_VARIABLE_IP_ADDRESS_VERSION);
if ($ipVersion !== null) {
if ($ipVersion == self::IP_ADDRESS_VERSION_V4) {
$options['socket'] = array(
'bindto' => '0.0.0.0:0'
);
} elseif ($ipVersion == self::IP_ADDRESS_VERSION_V6) {
$options['socket'] = array(
'bindto' => '[::]:0'
);
}
}
return $options;
}
|
php
|
private function buildStreamContextOptions(ApiClient $apiClient, HttpRequest $request) {
$options = array(
'http' => array(),
'ssl' => array()
);
if ($request->isSecureConnection()) {
$options['ssl']['verify_host'] = true;
$options['ssl']['allow_self_signed'] = false;
$options['ssl']['verify_peer'] = false;
if ($apiClient->isCertificateAuthorityCheckEnabled()) {
$options['ssl']['verify_peer'] = true;
$options['ssl']['cafile'] = $apiClient->getCertificateAuthority();
}
}
$ipVersion = $this->readEnvironmentVariable(self::ENVIRONMENT_VARIABLE_IP_ADDRESS_VERSION);
if ($ipVersion !== null) {
if ($ipVersion == self::IP_ADDRESS_VERSION_V4) {
$options['socket'] = array(
'bindto' => '0.0.0.0:0'
);
} elseif ($ipVersion == self::IP_ADDRESS_VERSION_V6) {
$options['socket'] = array(
'bindto' => '[::]:0'
);
}
}
return $options;
}
|
[
"private",
"function",
"buildStreamContextOptions",
"(",
"ApiClient",
"$",
"apiClient",
",",
"HttpRequest",
"$",
"request",
")",
"{",
"$",
"options",
"=",
"array",
"(",
"'http'",
"=>",
"array",
"(",
")",
",",
"'ssl'",
"=>",
"array",
"(",
")",
")",
";",
"if",
"(",
"$",
"request",
"->",
"isSecureConnection",
"(",
")",
")",
"{",
"$",
"options",
"[",
"'ssl'",
"]",
"[",
"'verify_host'",
"]",
"=",
"true",
";",
"$",
"options",
"[",
"'ssl'",
"]",
"[",
"'allow_self_signed'",
"]",
"=",
"false",
";",
"$",
"options",
"[",
"'ssl'",
"]",
"[",
"'verify_peer'",
"]",
"=",
"false",
";",
"if",
"(",
"$",
"apiClient",
"->",
"isCertificateAuthorityCheckEnabled",
"(",
")",
")",
"{",
"$",
"options",
"[",
"'ssl'",
"]",
"[",
"'verify_peer'",
"]",
"=",
"true",
";",
"$",
"options",
"[",
"'ssl'",
"]",
"[",
"'cafile'",
"]",
"=",
"$",
"apiClient",
"->",
"getCertificateAuthority",
"(",
")",
";",
"}",
"}",
"$",
"ipVersion",
"=",
"$",
"this",
"->",
"readEnvironmentVariable",
"(",
"self",
"::",
"ENVIRONMENT_VARIABLE_IP_ADDRESS_VERSION",
")",
";",
"if",
"(",
"$",
"ipVersion",
"!==",
"null",
")",
"{",
"if",
"(",
"$",
"ipVersion",
"==",
"self",
"::",
"IP_ADDRESS_VERSION_V4",
")",
"{",
"$",
"options",
"[",
"'socket'",
"]",
"=",
"array",
"(",
"'bindto'",
"=>",
"'0.0.0.0:0'",
")",
";",
"}",
"elseif",
"(",
"$",
"ipVersion",
"==",
"self",
"::",
"IP_ADDRESS_VERSION_V6",
")",
"{",
"$",
"options",
"[",
"'socket'",
"]",
"=",
"array",
"(",
"'bindto'",
"=>",
"'[::]:0'",
")",
";",
"}",
"}",
"return",
"$",
"options",
";",
"}"
] |
Generates an option array for creating the stream context.
@param ApiClient $apiClient the API client instance
@param HttpRequest $request the HTTP request
@return array
|
[
"Generates",
"an",
"option",
"array",
"for",
"creating",
"the",
"stream",
"context",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/Http/SocketHttpClient.php#L377-L405
|
221,960
|
wallee-payment/php-sdk
|
lib/Http/SocketHttpClient.php
|
SocketHttpClient.readEnvironmentVariable
|
private function readEnvironmentVariable($name){
if (isset($_SERVER[$name])) {
return $_SERVER[$name];
} else if (isset($_SERVER[strtolower($name)])) {
return $_SERVER[strtolower($name)];
} else {
return null;
}
}
|
php
|
private function readEnvironmentVariable($name){
if (isset($_SERVER[$name])) {
return $_SERVER[$name];
} else if (isset($_SERVER[strtolower($name)])) {
return $_SERVER[strtolower($name)];
} else {
return null;
}
}
|
[
"private",
"function",
"readEnvironmentVariable",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"_SERVER",
"[",
"$",
"name",
"]",
";",
"}",
"else",
"if",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"strtolower",
"(",
"$",
"name",
")",
"]",
")",
")",
"{",
"return",
"$",
"_SERVER",
"[",
"strtolower",
"(",
"$",
"name",
")",
"]",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
Reads the environment variable indicated by the name.
Returns null
when the variable is not defined.
@param string $name
@return string
|
[
"Reads",
"the",
"environment",
"variable",
"indicated",
"by",
"the",
"name",
".",
"Returns",
"null",
"when",
"the",
"variable",
"is",
"not",
"defined",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/Http/SocketHttpClient.php#L431-L439
|
221,961
|
ins0/google-measurement-php-client
|
src/Racecore/GATracking/GATracking.php
|
GATracking.setOption
|
public function setOption($key, $value)
{
if (isset($this->options[$key]) && is_array($this->options[$key]) && is_array($value)) {
$oldValues = $this->options[$key];
$value = array_merge($oldValues, $value);
}
$this->options[$key] = $value;
}
|
php
|
public function setOption($key, $value)
{
if (isset($this->options[$key]) && is_array($this->options[$key]) && is_array($value)) {
$oldValues = $this->options[$key];
$value = array_merge($oldValues, $value);
}
$this->options[$key] = $value;
}
|
[
"public",
"function",
"setOption",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"options",
"[",
"$",
"key",
"]",
")",
"&&",
"is_array",
"(",
"$",
"this",
"->",
"options",
"[",
"$",
"key",
"]",
")",
"&&",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"oldValues",
"=",
"$",
"this",
"->",
"options",
"[",
"$",
"key",
"]",
";",
"$",
"value",
"=",
"array_merge",
"(",
"$",
"oldValues",
",",
"$",
"value",
")",
";",
"}",
"$",
"this",
"->",
"options",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}"
] |
Set single Option
@param $key
@param $value
|
[
"Set",
"single",
"Option"
] |
415cabca0c6d83cd0bd6a8ed6fb695b35f892018
|
https://github.com/ins0/google-measurement-php-client/blob/415cabca0c6d83cd0bd6a8ed6fb695b35f892018/src/Racecore/GATracking/GATracking.php#L156-L164
|
221,962
|
ins0/google-measurement-php-client
|
src/Racecore/GATracking/GATracking.php
|
GATracking.getClientId
|
public function getClientId()
{
$clientId = $this->getOption('client_id');
if ($clientId) {
return $clientId;
}
// collect user specific data
if (isset($_COOKIE['_ga'])) {
$gaCookie = explode('.', $_COOKIE['_ga']);
if (isset($gaCookie[2])) {
// check if uuid
if ($this->checkUuid($gaCookie[2])) {
// uuid set in cookie
return $gaCookie[2];
} elseif (isset($gaCookie[2]) && isset($gaCookie[3])) {
// google old client id
return $gaCookie[2] . '.' . $gaCookie[3];
}
}
}
// nothing found - fallback
$generateClientId = $this->getOption('client_create_random_id');
if ($generateClientId) {
return $this->generateUuid();
}
return $this->getOption('client_fallback_id');
}
|
php
|
public function getClientId()
{
$clientId = $this->getOption('client_id');
if ($clientId) {
return $clientId;
}
// collect user specific data
if (isset($_COOKIE['_ga'])) {
$gaCookie = explode('.', $_COOKIE['_ga']);
if (isset($gaCookie[2])) {
// check if uuid
if ($this->checkUuid($gaCookie[2])) {
// uuid set in cookie
return $gaCookie[2];
} elseif (isset($gaCookie[2]) && isset($gaCookie[3])) {
// google old client id
return $gaCookie[2] . '.' . $gaCookie[3];
}
}
}
// nothing found - fallback
$generateClientId = $this->getOption('client_create_random_id');
if ($generateClientId) {
return $this->generateUuid();
}
return $this->getOption('client_fallback_id');
}
|
[
"public",
"function",
"getClientId",
"(",
")",
"{",
"$",
"clientId",
"=",
"$",
"this",
"->",
"getOption",
"(",
"'client_id'",
")",
";",
"if",
"(",
"$",
"clientId",
")",
"{",
"return",
"$",
"clientId",
";",
"}",
"// collect user specific data",
"if",
"(",
"isset",
"(",
"$",
"_COOKIE",
"[",
"'_ga'",
"]",
")",
")",
"{",
"$",
"gaCookie",
"=",
"explode",
"(",
"'.'",
",",
"$",
"_COOKIE",
"[",
"'_ga'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"gaCookie",
"[",
"2",
"]",
")",
")",
"{",
"// check if uuid",
"if",
"(",
"$",
"this",
"->",
"checkUuid",
"(",
"$",
"gaCookie",
"[",
"2",
"]",
")",
")",
"{",
"// uuid set in cookie",
"return",
"$",
"gaCookie",
"[",
"2",
"]",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"gaCookie",
"[",
"2",
"]",
")",
"&&",
"isset",
"(",
"$",
"gaCookie",
"[",
"3",
"]",
")",
")",
"{",
"// google old client id",
"return",
"$",
"gaCookie",
"[",
"2",
"]",
".",
"'.'",
".",
"$",
"gaCookie",
"[",
"3",
"]",
";",
"}",
"}",
"}",
"// nothing found - fallback",
"$",
"generateClientId",
"=",
"$",
"this",
"->",
"getOption",
"(",
"'client_create_random_id'",
")",
";",
"if",
"(",
"$",
"generateClientId",
")",
"{",
"return",
"$",
"this",
"->",
"generateUuid",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"getOption",
"(",
"'client_fallback_id'",
")",
";",
"}"
] |
Return the Current Client Id
@return string
|
[
"Return",
"the",
"Current",
"Client",
"Id"
] |
415cabca0c6d83cd0bd6a8ed6fb695b35f892018
|
https://github.com/ins0/google-measurement-php-client/blob/415cabca0c6d83cd0bd6a8ed6fb695b35f892018/src/Racecore/GATracking/GATracking.php#L206-L235
|
221,963
|
ins0/google-measurement-php-client
|
src/Racecore/GATracking/GATracking.php
|
GATracking.generateUuid
|
final private function generateUuid()
{
return sprintf(
'%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
// 32 bits for "time_low"
mt_rand(0, 0xffff),
mt_rand(0, 0xffff),
// 16 bits for "time_mid"
mt_rand(0, 0xffff),
// 16 bits for "time_hi_and_version",
// four most significant bits holds version number 4
mt_rand(0, 0x0fff) | 0x4000,
// 16 bits, 8 bits for "clk_seq_hi_res",
// 8 bits for "clk_seq_low",
// two most significant bits holds zero and one for variant DCE1.1
mt_rand(0, 0x3fff) | 0x8000,
// 48 bits for "node"
mt_rand(0, 0xffff),
mt_rand(0, 0xffff),
mt_rand(0, 0xffff)
);
}
|
php
|
final private function generateUuid()
{
return sprintf(
'%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
// 32 bits for "time_low"
mt_rand(0, 0xffff),
mt_rand(0, 0xffff),
// 16 bits for "time_mid"
mt_rand(0, 0xffff),
// 16 bits for "time_hi_and_version",
// four most significant bits holds version number 4
mt_rand(0, 0x0fff) | 0x4000,
// 16 bits, 8 bits for "clk_seq_hi_res",
// 8 bits for "clk_seq_low",
// two most significant bits holds zero and one for variant DCE1.1
mt_rand(0, 0x3fff) | 0x8000,
// 48 bits for "node"
mt_rand(0, 0xffff),
mt_rand(0, 0xffff),
mt_rand(0, 0xffff)
);
}
|
[
"final",
"private",
"function",
"generateUuid",
"(",
")",
"{",
"return",
"sprintf",
"(",
"'%04x%04x-%04x-%04x-%04x-%04x%04x%04x'",
",",
"// 32 bits for \"time_low\"",
"mt_rand",
"(",
"0",
",",
"0xffff",
")",
",",
"mt_rand",
"(",
"0",
",",
"0xffff",
")",
",",
"// 16 bits for \"time_mid\"",
"mt_rand",
"(",
"0",
",",
"0xffff",
")",
",",
"// 16 bits for \"time_hi_and_version\",",
"// four most significant bits holds version number 4",
"mt_rand",
"(",
"0",
",",
"0x0fff",
")",
"|",
"0x4000",
",",
"// 16 bits, 8 bits for \"clk_seq_hi_res\",",
"// 8 bits for \"clk_seq_low\",",
"// two most significant bits holds zero and one for variant DCE1.1",
"mt_rand",
"(",
"0",
",",
"0x3fff",
")",
"|",
"0x8000",
",",
"// 48 bits for \"node\"",
"mt_rand",
"(",
"0",
",",
"0xffff",
")",
",",
"mt_rand",
"(",
"0",
",",
"0xffff",
")",
",",
"mt_rand",
"(",
"0",
",",
"0xffff",
")",
")",
";",
"}"
] |
Generate UUID v4 function - needed to generate a CID when one isn't available
@author Andrew Moore http://www.php.net/manual/en/function.uniqid.php#94959
@return string
|
[
"Generate",
"UUID",
"v4",
"function",
"-",
"needed",
"to",
"generate",
"a",
"CID",
"when",
"one",
"isn",
"t",
"available"
] |
415cabca0c6d83cd0bd6a8ed6fb695b35f892018
|
https://github.com/ins0/google-measurement-php-client/blob/415cabca0c6d83cd0bd6a8ed6fb695b35f892018/src/Racecore/GATracking/GATracking.php#L257-L278
|
221,964
|
ins0/google-measurement-php-client
|
src/Racecore/GATracking/GATracking.php
|
GATracking.getTrackingPayloadData
|
protected function getTrackingPayloadData(Tracking\AbstractTracking $event)
{
$payloadData = $event->getPackage();
$payloadData['v'] = $this->apiProtocolVersion; // protocol version
$payloadData['tid'] = $this->analyticsAccountUid; // account id
$payloadData['uid'] = $this->getOption('user_id');
$payloadData['cid'] = $this->getClientId();
$proxy = $this->getOption('proxy');
if ($proxy) {
if (!isset($proxy['ip'])) {
throw new Exception\MissingConfigurationException('proxy options need "ip" key/value');
}
if (isset($proxy['user_agent'])) {
$payloadData['ua'] = $proxy['user_agent'];
}
$payloadData['uip'] = $proxy['ip'];
}
return array_filter($payloadData);
}
|
php
|
protected function getTrackingPayloadData(Tracking\AbstractTracking $event)
{
$payloadData = $event->getPackage();
$payloadData['v'] = $this->apiProtocolVersion; // protocol version
$payloadData['tid'] = $this->analyticsAccountUid; // account id
$payloadData['uid'] = $this->getOption('user_id');
$payloadData['cid'] = $this->getClientId();
$proxy = $this->getOption('proxy');
if ($proxy) {
if (!isset($proxy['ip'])) {
throw new Exception\MissingConfigurationException('proxy options need "ip" key/value');
}
if (isset($proxy['user_agent'])) {
$payloadData['ua'] = $proxy['user_agent'];
}
$payloadData['uip'] = $proxy['ip'];
}
return array_filter($payloadData);
}
|
[
"protected",
"function",
"getTrackingPayloadData",
"(",
"Tracking",
"\\",
"AbstractTracking",
"$",
"event",
")",
"{",
"$",
"payloadData",
"=",
"$",
"event",
"->",
"getPackage",
"(",
")",
";",
"$",
"payloadData",
"[",
"'v'",
"]",
"=",
"$",
"this",
"->",
"apiProtocolVersion",
";",
"// protocol version",
"$",
"payloadData",
"[",
"'tid'",
"]",
"=",
"$",
"this",
"->",
"analyticsAccountUid",
";",
"// account id",
"$",
"payloadData",
"[",
"'uid'",
"]",
"=",
"$",
"this",
"->",
"getOption",
"(",
"'user_id'",
")",
";",
"$",
"payloadData",
"[",
"'cid'",
"]",
"=",
"$",
"this",
"->",
"getClientId",
"(",
")",
";",
"$",
"proxy",
"=",
"$",
"this",
"->",
"getOption",
"(",
"'proxy'",
")",
";",
"if",
"(",
"$",
"proxy",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"proxy",
"[",
"'ip'",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"MissingConfigurationException",
"(",
"'proxy options need \"ip\" key/value'",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"proxy",
"[",
"'user_agent'",
"]",
")",
")",
"{",
"$",
"payloadData",
"[",
"'ua'",
"]",
"=",
"$",
"proxy",
"[",
"'user_agent'",
"]",
";",
"}",
"$",
"payloadData",
"[",
"'uip'",
"]",
"=",
"$",
"proxy",
"[",
"'ip'",
"]",
";",
"}",
"return",
"array_filter",
"(",
"$",
"payloadData",
")",
";",
"}"
] |
Build the Tracking Payload Data
@param Tracking\AbstractTracking $event
@return array
@throws Exception\MissingConfigurationException
|
[
"Build",
"the",
"Tracking",
"Payload",
"Data"
] |
415cabca0c6d83cd0bd6a8ed6fb695b35f892018
|
https://github.com/ins0/google-measurement-php-client/blob/415cabca0c6d83cd0bd6a8ed6fb695b35f892018/src/Racecore/GATracking/GATracking.php#L287-L309
|
221,965
|
ins0/google-measurement-php-client
|
src/Racecore/GATracking/GATracking.php
|
GATracking.callEndpoint
|
private function callEndpoint($tracking)
{
$trackingHolder = is_array($tracking) ? $tracking : array($tracking);
$trackingCollection = new Request\TrackingRequestCollection();
foreach ($trackingHolder as $tracking) {
if (!$tracking instanceof Tracking\AbstractTracking) {
continue;
}
$payloadData = $this->getTrackingPayloadData($tracking);
$trackingRequest = new Request\TrackingRequest($payloadData);
$trackingCollection->add($trackingRequest);
}
$adapterOptions = $this->getOption('adapter');
$clientAdapter = $this->clientAdapter;
$clientAdapter->setOptions($adapterOptions);
return $clientAdapter->send($this->apiEndpointUrl, $trackingCollection);
}
|
php
|
private function callEndpoint($tracking)
{
$trackingHolder = is_array($tracking) ? $tracking : array($tracking);
$trackingCollection = new Request\TrackingRequestCollection();
foreach ($trackingHolder as $tracking) {
if (!$tracking instanceof Tracking\AbstractTracking) {
continue;
}
$payloadData = $this->getTrackingPayloadData($tracking);
$trackingRequest = new Request\TrackingRequest($payloadData);
$trackingCollection->add($trackingRequest);
}
$adapterOptions = $this->getOption('adapter');
$clientAdapter = $this->clientAdapter;
$clientAdapter->setOptions($adapterOptions);
return $clientAdapter->send($this->apiEndpointUrl, $trackingCollection);
}
|
[
"private",
"function",
"callEndpoint",
"(",
"$",
"tracking",
")",
"{",
"$",
"trackingHolder",
"=",
"is_array",
"(",
"$",
"tracking",
")",
"?",
"$",
"tracking",
":",
"array",
"(",
"$",
"tracking",
")",
";",
"$",
"trackingCollection",
"=",
"new",
"Request",
"\\",
"TrackingRequestCollection",
"(",
")",
";",
"foreach",
"(",
"$",
"trackingHolder",
"as",
"$",
"tracking",
")",
"{",
"if",
"(",
"!",
"$",
"tracking",
"instanceof",
"Tracking",
"\\",
"AbstractTracking",
")",
"{",
"continue",
";",
"}",
"$",
"payloadData",
"=",
"$",
"this",
"->",
"getTrackingPayloadData",
"(",
"$",
"tracking",
")",
";",
"$",
"trackingRequest",
"=",
"new",
"Request",
"\\",
"TrackingRequest",
"(",
"$",
"payloadData",
")",
";",
"$",
"trackingCollection",
"->",
"add",
"(",
"$",
"trackingRequest",
")",
";",
"}",
"$",
"adapterOptions",
"=",
"$",
"this",
"->",
"getOption",
"(",
"'adapter'",
")",
";",
"$",
"clientAdapter",
"=",
"$",
"this",
"->",
"clientAdapter",
";",
"$",
"clientAdapter",
"->",
"setOptions",
"(",
"$",
"adapterOptions",
")",
";",
"return",
"$",
"clientAdapter",
"->",
"send",
"(",
"$",
"this",
"->",
"apiEndpointUrl",
",",
"$",
"trackingCollection",
")",
";",
"}"
] |
Call the client adapter
@param $tracking
@throws Exception\InvalidArgumentException
@throws Exception\MissingConfigurationException
@return Request\TrackingRequestCollection
|
[
"Call",
"the",
"client",
"adapter"
] |
415cabca0c6d83cd0bd6a8ed6fb695b35f892018
|
https://github.com/ins0/google-measurement-php-client/blob/415cabca0c6d83cd0bd6a8ed6fb695b35f892018/src/Racecore/GATracking/GATracking.php#L319-L340
|
221,966
|
ins0/google-measurement-php-client
|
src/Racecore/GATracking/GATracking.php
|
GATracking.createTracking
|
public function createTracking($className, $options = null)
{
if (strstr(strtolower($className), 'abstracttracking')) {
return false;
}
$class = 'Racecore\GATracking\Tracking\\' . $className;
if ($options) {
return new $class($options);
}
return new $class;
}
|
php
|
public function createTracking($className, $options = null)
{
if (strstr(strtolower($className), 'abstracttracking')) {
return false;
}
$class = 'Racecore\GATracking\Tracking\\' . $className;
if ($options) {
return new $class($options);
}
return new $class;
}
|
[
"public",
"function",
"createTracking",
"(",
"$",
"className",
",",
"$",
"options",
"=",
"null",
")",
"{",
"if",
"(",
"strstr",
"(",
"strtolower",
"(",
"$",
"className",
")",
",",
"'abstracttracking'",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"class",
"=",
"'Racecore\\GATracking\\Tracking\\\\'",
".",
"$",
"className",
";",
"if",
"(",
"$",
"options",
")",
"{",
"return",
"new",
"$",
"class",
"(",
"$",
"options",
")",
";",
"}",
"return",
"new",
"$",
"class",
";",
"}"
] |
Create a Tracking Class Instance - eg. "Event" or "Ecommerce\Transaction"
@param $className
@param null $options
@return bool
|
[
"Create",
"a",
"Tracking",
"Class",
"Instance",
"-",
"eg",
".",
"Event",
"or",
"Ecommerce",
"\\",
"Transaction"
] |
415cabca0c6d83cd0bd6a8ed6fb695b35f892018
|
https://github.com/ins0/google-measurement-php-client/blob/415cabca0c6d83cd0bd6a8ed6fb695b35f892018/src/Racecore/GATracking/GATracking.php#L349-L360
|
221,967
|
ins0/google-measurement-php-client
|
src/Racecore/GATracking/GATracking.php
|
GATracking.sendTracking
|
public function sendTracking(Tracking\AbstractTracking $tracking)
{
$responseCollection = $this->callEndpoint($tracking);
$responseCollection->rewind();
return $responseCollection->current();
}
|
php
|
public function sendTracking(Tracking\AbstractTracking $tracking)
{
$responseCollection = $this->callEndpoint($tracking);
$responseCollection->rewind();
return $responseCollection->current();
}
|
[
"public",
"function",
"sendTracking",
"(",
"Tracking",
"\\",
"AbstractTracking",
"$",
"tracking",
")",
"{",
"$",
"responseCollection",
"=",
"$",
"this",
"->",
"callEndpoint",
"(",
"$",
"tracking",
")",
";",
"$",
"responseCollection",
"->",
"rewind",
"(",
")",
";",
"return",
"$",
"responseCollection",
"->",
"current",
"(",
")",
";",
"}"
] |
Send single tracking request
@param Tracking\AbstractTracking $tracking
@return Tracking\AbstractTracking
|
[
"Send",
"single",
"tracking",
"request"
] |
415cabca0c6d83cd0bd6a8ed6fb695b35f892018
|
https://github.com/ins0/google-measurement-php-client/blob/415cabca0c6d83cd0bd6a8ed6fb695b35f892018/src/Racecore/GATracking/GATracking.php#L368-L373
|
221,968
|
wallee-payment/php-sdk
|
lib/Model/PaymentMethodConfiguration.php
|
PaymentMethodConfiguration.setResolvedDescription
|
public function setResolvedDescription($resolvedDescription) {
if (is_array($resolvedDescription) && empty($resolvedDescription)) {
$this->resolvedDescription = new \stdClass;
} else {
$this->resolvedDescription = $resolvedDescription;
}
return $this;
}
|
php
|
public function setResolvedDescription($resolvedDescription) {
if (is_array($resolvedDescription) && empty($resolvedDescription)) {
$this->resolvedDescription = new \stdClass;
} else {
$this->resolvedDescription = $resolvedDescription;
}
return $this;
}
|
[
"public",
"function",
"setResolvedDescription",
"(",
"$",
"resolvedDescription",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"resolvedDescription",
")",
"&&",
"empty",
"(",
"$",
"resolvedDescription",
")",
")",
"{",
"$",
"this",
"->",
"resolvedDescription",
"=",
"new",
"\\",
"stdClass",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"resolvedDescription",
"=",
"$",
"resolvedDescription",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Sets resolvedDescription.
@param map[string,string] $resolvedDescription
@return PaymentMethodConfiguration
|
[
"Sets",
"resolvedDescription",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/Model/PaymentMethodConfiguration.php#L462-L470
|
221,969
|
wallee-payment/php-sdk
|
lib/Model/PaymentMethodConfiguration.php
|
PaymentMethodConfiguration.setResolvedTitle
|
public function setResolvedTitle($resolvedTitle) {
if (is_array($resolvedTitle) && empty($resolvedTitle)) {
$this->resolvedTitle = new \stdClass;
} else {
$this->resolvedTitle = $resolvedTitle;
}
return $this;
}
|
php
|
public function setResolvedTitle($resolvedTitle) {
if (is_array($resolvedTitle) && empty($resolvedTitle)) {
$this->resolvedTitle = new \stdClass;
} else {
$this->resolvedTitle = $resolvedTitle;
}
return $this;
}
|
[
"public",
"function",
"setResolvedTitle",
"(",
"$",
"resolvedTitle",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"resolvedTitle",
")",
"&&",
"empty",
"(",
"$",
"resolvedTitle",
")",
")",
"{",
"$",
"this",
"->",
"resolvedTitle",
"=",
"new",
"\\",
"stdClass",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"resolvedTitle",
"=",
"$",
"resolvedTitle",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Sets resolvedTitle.
@param map[string,string] $resolvedTitle
@return PaymentMethodConfiguration
|
[
"Sets",
"resolvedTitle",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/Model/PaymentMethodConfiguration.php#L512-L520
|
221,970
|
claroline/CoreBundle
|
Controller/FileController.php
|
FileController.getCurrentUser
|
private function getCurrentUser()
{
if (is_object($token = $this->get('security.token_storage')->getToken()) and is_object($user = $token->getUser())) {
return $user;
}
}
|
php
|
private function getCurrentUser()
{
if (is_object($token = $this->get('security.token_storage')->getToken()) and is_object($user = $token->getUser())) {
return $user;
}
}
|
[
"private",
"function",
"getCurrentUser",
"(",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"token",
"=",
"$",
"this",
"->",
"get",
"(",
"'security.token_storage'",
")",
"->",
"getToken",
"(",
")",
")",
"and",
"is_object",
"(",
"$",
"user",
"=",
"$",
"token",
"->",
"getUser",
"(",
")",
")",
")",
"{",
"return",
"$",
"user",
";",
"}",
"}"
] |
Get Current User
@return mixed Claroline\CoreBundle\Entity\User or null
|
[
"Get",
"Current",
"User"
] |
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
|
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Controller/FileController.php#L297-L302
|
221,971
|
claroline/CoreBundle
|
Manager/ActivityManager.php
|
ActivityManager.editActivity
|
public function editActivity(Activity $activity)
{
$this->om->persist($activity);
$this->om->flush();
$this->initializePermissions($activity);
return $activity;
}
|
php
|
public function editActivity(Activity $activity)
{
$this->om->persist($activity);
$this->om->flush();
$this->initializePermissions($activity);
return $activity;
}
|
[
"public",
"function",
"editActivity",
"(",
"Activity",
"$",
"activity",
")",
"{",
"$",
"this",
"->",
"om",
"->",
"persist",
"(",
"$",
"activity",
")",
";",
"$",
"this",
"->",
"om",
"->",
"flush",
"(",
")",
";",
"$",
"this",
"->",
"initializePermissions",
"(",
"$",
"activity",
")",
";",
"return",
"$",
"activity",
";",
"}"
] |
Edit an activity
|
[
"Edit",
"an",
"activity"
] |
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
|
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/ActivityManager.php#L82-L89
|
221,972
|
claroline/CoreBundle
|
Manager/ActivityManager.php
|
ActivityManager.addResource
|
public function addResource(Activity $activity, ResourceNode $resource)
{
if (!$activity->getParameters()->getSecondaryResources()->contains($resource)) {
$activity->getParameters()->getSecondaryResources()->add($resource);
$this->initializePermissions($activity);
$this->om->persist($activity);
$this->om->flush();
return true;
}
}
|
php
|
public function addResource(Activity $activity, ResourceNode $resource)
{
if (!$activity->getParameters()->getSecondaryResources()->contains($resource)) {
$activity->getParameters()->getSecondaryResources()->add($resource);
$this->initializePermissions($activity);
$this->om->persist($activity);
$this->om->flush();
return true;
}
}
|
[
"public",
"function",
"addResource",
"(",
"Activity",
"$",
"activity",
",",
"ResourceNode",
"$",
"resource",
")",
"{",
"if",
"(",
"!",
"$",
"activity",
"->",
"getParameters",
"(",
")",
"->",
"getSecondaryResources",
"(",
")",
"->",
"contains",
"(",
"$",
"resource",
")",
")",
"{",
"$",
"activity",
"->",
"getParameters",
"(",
")",
"->",
"getSecondaryResources",
"(",
")",
"->",
"add",
"(",
"$",
"resource",
")",
";",
"$",
"this",
"->",
"initializePermissions",
"(",
"$",
"activity",
")",
";",
"$",
"this",
"->",
"om",
"->",
"persist",
"(",
"$",
"activity",
")",
";",
"$",
"this",
"->",
"om",
"->",
"flush",
"(",
")",
";",
"return",
"true",
";",
"}",
"}"
] |
Link a resource to an activity
|
[
"Link",
"a",
"resource",
"to",
"an",
"activity"
] |
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
|
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/ActivityManager.php#L103-L113
|
221,973
|
claroline/CoreBundle
|
Manager/ActivityManager.php
|
ActivityManager.removePrimaryResource
|
public function removePrimaryResource(Activity $activity)
{
$activity->setPrimaryResource();
$this->om->persist($activity);
$this->om->flush();
}
|
php
|
public function removePrimaryResource(Activity $activity)
{
$activity->setPrimaryResource();
$this->om->persist($activity);
$this->om->flush();
}
|
[
"public",
"function",
"removePrimaryResource",
"(",
"Activity",
"$",
"activity",
")",
"{",
"$",
"activity",
"->",
"setPrimaryResource",
"(",
")",
";",
"$",
"this",
"->",
"om",
"->",
"persist",
"(",
"$",
"activity",
")",
";",
"$",
"this",
"->",
"om",
"->",
"flush",
"(",
")",
";",
"}"
] |
Remove the primary resource of an activity
|
[
"Remove",
"the",
"primary",
"resource",
"of",
"an",
"activity"
] |
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
|
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/ActivityManager.php#L118-L123
|
221,974
|
claroline/CoreBundle
|
Manager/ActivityManager.php
|
ActivityManager.removeResource
|
public function removeResource(Activity $activity, ResourceNode $resource)
{
if ($activity->getParameters()->getSecondaryResources()->contains($resource)) {
$activity->getParameters()->getSecondaryResources()->removeElement($resource);
$this->om->persist($activity);
$this->om->flush();
return true;
}
}
|
php
|
public function removeResource(Activity $activity, ResourceNode $resource)
{
if ($activity->getParameters()->getSecondaryResources()->contains($resource)) {
$activity->getParameters()->getSecondaryResources()->removeElement($resource);
$this->om->persist($activity);
$this->om->flush();
return true;
}
}
|
[
"public",
"function",
"removeResource",
"(",
"Activity",
"$",
"activity",
",",
"ResourceNode",
"$",
"resource",
")",
"{",
"if",
"(",
"$",
"activity",
"->",
"getParameters",
"(",
")",
"->",
"getSecondaryResources",
"(",
")",
"->",
"contains",
"(",
"$",
"resource",
")",
")",
"{",
"$",
"activity",
"->",
"getParameters",
"(",
")",
"->",
"getSecondaryResources",
"(",
")",
"->",
"removeElement",
"(",
"$",
"resource",
")",
";",
"$",
"this",
"->",
"om",
"->",
"persist",
"(",
"$",
"activity",
")",
";",
"$",
"this",
"->",
"om",
"->",
"flush",
"(",
")",
";",
"return",
"true",
";",
"}",
"}"
] |
Remove a resource from an activity
|
[
"Remove",
"a",
"resource",
"from",
"an",
"activity"
] |
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
|
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/ActivityManager.php#L128-L137
|
221,975
|
claroline/CoreBundle
|
Manager/ActivityManager.php
|
ActivityManager.copyActivity
|
public function copyActivity(Activity $resource)
{
$activity = new Activity();
$activity->setTitle($resource->getTitle());
$activity->setDescription($resource->getDescription());
$activity->setParameters($this->copyParameters($resource));
if ($primaryResource = $resource->getPrimaryResource()) {
$activity->setPrimaryResource($primaryResource);
}
return $activity;
}
|
php
|
public function copyActivity(Activity $resource)
{
$activity = new Activity();
$activity->setTitle($resource->getTitle());
$activity->setDescription($resource->getDescription());
$activity->setParameters($this->copyParameters($resource));
if ($primaryResource = $resource->getPrimaryResource()) {
$activity->setPrimaryResource($primaryResource);
}
return $activity;
}
|
[
"public",
"function",
"copyActivity",
"(",
"Activity",
"$",
"resource",
")",
"{",
"$",
"activity",
"=",
"new",
"Activity",
"(",
")",
";",
"$",
"activity",
"->",
"setTitle",
"(",
"$",
"resource",
"->",
"getTitle",
"(",
")",
")",
";",
"$",
"activity",
"->",
"setDescription",
"(",
"$",
"resource",
"->",
"getDescription",
"(",
")",
")",
";",
"$",
"activity",
"->",
"setParameters",
"(",
"$",
"this",
"->",
"copyParameters",
"(",
"$",
"resource",
")",
")",
";",
"if",
"(",
"$",
"primaryResource",
"=",
"$",
"resource",
"->",
"getPrimaryResource",
"(",
")",
")",
"{",
"$",
"activity",
"->",
"setPrimaryResource",
"(",
"$",
"primaryResource",
")",
";",
"}",
"return",
"$",
"activity",
";",
"}"
] |
Copy an activity
|
[
"Copy",
"an",
"activity"
] |
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
|
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/ActivityManager.php#L142-L155
|
221,976
|
claroline/CoreBundle
|
Manager/ActivityManager.php
|
ActivityManager.createBlankEvaluation
|
public function createBlankEvaluation(User $user, ActivityParameters $activityParams)
{
$evaluationType = $activityParams->getEvaluationType();
$status = null;
$nbAttempts = null;
if ($evaluationType === AbstractEvaluation::TYPE_AUTOMATIC) {
$status = AbstractEvaluation::STATUS_NOT_ATTEMPTED;
$nbAttempts = 0;
}
$evaluation = new Evaluation();
$evaluation->setUser($user);
$evaluation->setActivityParameters($activityParams);
$evaluation->setType($evaluationType);
$evaluation->setStatus($status);
$evaluation->setAttemptsCount($nbAttempts);
$this->om->persist($evaluation);
$this->om->flush();
return $evaluation;
}
|
php
|
public function createBlankEvaluation(User $user, ActivityParameters $activityParams)
{
$evaluationType = $activityParams->getEvaluationType();
$status = null;
$nbAttempts = null;
if ($evaluationType === AbstractEvaluation::TYPE_AUTOMATIC) {
$status = AbstractEvaluation::STATUS_NOT_ATTEMPTED;
$nbAttempts = 0;
}
$evaluation = new Evaluation();
$evaluation->setUser($user);
$evaluation->setActivityParameters($activityParams);
$evaluation->setType($evaluationType);
$evaluation->setStatus($status);
$evaluation->setAttemptsCount($nbAttempts);
$this->om->persist($evaluation);
$this->om->flush();
return $evaluation;
}
|
[
"public",
"function",
"createBlankEvaluation",
"(",
"User",
"$",
"user",
",",
"ActivityParameters",
"$",
"activityParams",
")",
"{",
"$",
"evaluationType",
"=",
"$",
"activityParams",
"->",
"getEvaluationType",
"(",
")",
";",
"$",
"status",
"=",
"null",
";",
"$",
"nbAttempts",
"=",
"null",
";",
"if",
"(",
"$",
"evaluationType",
"===",
"AbstractEvaluation",
"::",
"TYPE_AUTOMATIC",
")",
"{",
"$",
"status",
"=",
"AbstractEvaluation",
"::",
"STATUS_NOT_ATTEMPTED",
";",
"$",
"nbAttempts",
"=",
"0",
";",
"}",
"$",
"evaluation",
"=",
"new",
"Evaluation",
"(",
")",
";",
"$",
"evaluation",
"->",
"setUser",
"(",
"$",
"user",
")",
";",
"$",
"evaluation",
"->",
"setActivityParameters",
"(",
"$",
"activityParams",
")",
";",
"$",
"evaluation",
"->",
"setType",
"(",
"$",
"evaluationType",
")",
";",
"$",
"evaluation",
"->",
"setStatus",
"(",
"$",
"status",
")",
";",
"$",
"evaluation",
"->",
"setAttemptsCount",
"(",
"$",
"nbAttempts",
")",
";",
"$",
"this",
"->",
"om",
"->",
"persist",
"(",
"$",
"evaluation",
")",
";",
"$",
"this",
"->",
"om",
"->",
"flush",
"(",
")",
";",
"return",
"$",
"evaluation",
";",
"}"
] |
Creates an empty activity evaluation for a user, so that an evaluation
is available for display and edition even when the user hasn't actually
performed the activity.
@param User $user
@param ActivityParameters $activityParams
@return Evaluation
|
[
"Creates",
"an",
"empty",
"activity",
"evaluation",
"for",
"a",
"user",
"so",
"that",
"an",
"evaluation",
"is",
"available",
"for",
"display",
"and",
"edition",
"even",
"when",
"the",
"user",
"hasn",
"t",
"actually",
"performed",
"the",
"activity",
"."
] |
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
|
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/ActivityManager.php#L423-L445
|
221,977
|
claroline/CoreBundle
|
Manager/ActivityManager.php
|
ActivityManager.initializePermissions
|
public function initializePermissions(Activity $activity)
{
$primary = $activity->getPrimaryResource();
$secondaries = [];
$nodes = [];
$token = $this->tokenStorage->getToken();
$user = $token === null ? $activity->getResourceNode()->getCreator(): $token->getUser();
if ($primary) {
$nodes[] = $primary;
}
foreach ($activity->getParameters()->getSecondaryResources() as $res) {
$secondaries[] = $res;
}
$nodes = array_merge($nodes, $secondaries);
$nodesInitialized = [];
foreach ($nodes as $node) {
$isNodeCreator = $node->getCreator() === $user;
$ws = $node->getWorkspace();
$roleWsManager = $this->roleRepo->findManagerRole($ws);
$isWsManager = $user->hasRole($roleWsManager);
if ($isNodeCreator || $isWsManager) {
$nodesInitialized[] = $node;
}
}
$rolesInitialized = [];
$rights = $activity->getResourceNode()->getRights();
foreach ($rights as $right) {
$role = $right->getRole();
if (!strpos('_' . $role->getName(), 'ROLE_WS_MANAGER')
//the open value is always 1
&& $right->getMask() & 1
) {
$rolesInitialized[] = $role;
}
}
$this->rightsManager->initializePermissions($nodesInitialized, $rolesInitialized);
}
|
php
|
public function initializePermissions(Activity $activity)
{
$primary = $activity->getPrimaryResource();
$secondaries = [];
$nodes = [];
$token = $this->tokenStorage->getToken();
$user = $token === null ? $activity->getResourceNode()->getCreator(): $token->getUser();
if ($primary) {
$nodes[] = $primary;
}
foreach ($activity->getParameters()->getSecondaryResources() as $res) {
$secondaries[] = $res;
}
$nodes = array_merge($nodes, $secondaries);
$nodesInitialized = [];
foreach ($nodes as $node) {
$isNodeCreator = $node->getCreator() === $user;
$ws = $node->getWorkspace();
$roleWsManager = $this->roleRepo->findManagerRole($ws);
$isWsManager = $user->hasRole($roleWsManager);
if ($isNodeCreator || $isWsManager) {
$nodesInitialized[] = $node;
}
}
$rolesInitialized = [];
$rights = $activity->getResourceNode()->getRights();
foreach ($rights as $right) {
$role = $right->getRole();
if (!strpos('_' . $role->getName(), 'ROLE_WS_MANAGER')
//the open value is always 1
&& $right->getMask() & 1
) {
$rolesInitialized[] = $role;
}
}
$this->rightsManager->initializePermissions($nodesInitialized, $rolesInitialized);
}
|
[
"public",
"function",
"initializePermissions",
"(",
"Activity",
"$",
"activity",
")",
"{",
"$",
"primary",
"=",
"$",
"activity",
"->",
"getPrimaryResource",
"(",
")",
";",
"$",
"secondaries",
"=",
"[",
"]",
";",
"$",
"nodes",
"=",
"[",
"]",
";",
"$",
"token",
"=",
"$",
"this",
"->",
"tokenStorage",
"->",
"getToken",
"(",
")",
";",
"$",
"user",
"=",
"$",
"token",
"===",
"null",
"?",
"$",
"activity",
"->",
"getResourceNode",
"(",
")",
"->",
"getCreator",
"(",
")",
":",
"$",
"token",
"->",
"getUser",
"(",
")",
";",
"if",
"(",
"$",
"primary",
")",
"{",
"$",
"nodes",
"[",
"]",
"=",
"$",
"primary",
";",
"}",
"foreach",
"(",
"$",
"activity",
"->",
"getParameters",
"(",
")",
"->",
"getSecondaryResources",
"(",
")",
"as",
"$",
"res",
")",
"{",
"$",
"secondaries",
"[",
"]",
"=",
"$",
"res",
";",
"}",
"$",
"nodes",
"=",
"array_merge",
"(",
"$",
"nodes",
",",
"$",
"secondaries",
")",
";",
"$",
"nodesInitialized",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"nodes",
"as",
"$",
"node",
")",
"{",
"$",
"isNodeCreator",
"=",
"$",
"node",
"->",
"getCreator",
"(",
")",
"===",
"$",
"user",
";",
"$",
"ws",
"=",
"$",
"node",
"->",
"getWorkspace",
"(",
")",
";",
"$",
"roleWsManager",
"=",
"$",
"this",
"->",
"roleRepo",
"->",
"findManagerRole",
"(",
"$",
"ws",
")",
";",
"$",
"isWsManager",
"=",
"$",
"user",
"->",
"hasRole",
"(",
"$",
"roleWsManager",
")",
";",
"if",
"(",
"$",
"isNodeCreator",
"||",
"$",
"isWsManager",
")",
"{",
"$",
"nodesInitialized",
"[",
"]",
"=",
"$",
"node",
";",
"}",
"}",
"$",
"rolesInitialized",
"=",
"[",
"]",
";",
"$",
"rights",
"=",
"$",
"activity",
"->",
"getResourceNode",
"(",
")",
"->",
"getRights",
"(",
")",
";",
"foreach",
"(",
"$",
"rights",
"as",
"$",
"right",
")",
"{",
"$",
"role",
"=",
"$",
"right",
"->",
"getRole",
"(",
")",
";",
"if",
"(",
"!",
"strpos",
"(",
"'_'",
".",
"$",
"role",
"->",
"getName",
"(",
")",
",",
"'ROLE_WS_MANAGER'",
")",
"//the open value is always 1",
"&&",
"$",
"right",
"->",
"getMask",
"(",
")",
"&",
"1",
")",
"{",
"$",
"rolesInitialized",
"[",
"]",
"=",
"$",
"role",
";",
"}",
"}",
"$",
"this",
"->",
"rightsManager",
"->",
"initializePermissions",
"(",
"$",
"nodesInitialized",
",",
"$",
"rolesInitialized",
")",
";",
"}"
] |
What does it do ? I can't remember. It's annoying.
Initialize the resource permissions of an activity
@param Activity $activity
|
[
"What",
"does",
"it",
"do",
"?",
"I",
"can",
"t",
"remember",
".",
"It",
"s",
"annoying",
".",
"Initialize",
"the",
"resource",
"permissions",
"of",
"an",
"activity"
] |
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
|
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/ActivityManager.php#L753-L798
|
221,978
|
claroline/CoreBundle
|
Library/Home/HomeService.php
|
HomeService.defaultTemplate
|
public function defaultTemplate($path)
{
$dir = explode(':', $path);
$controller = preg_split('/(?=[A-Z])/', $dir[0]);
$controller = array_slice($controller, (count($controller) - 2));
$controller = implode('', $controller);
$base = __DIR__ . "/../../Resources/views/";
if ($dir[1] === '') {
$dir[0] = $dir[0] . ':';
$tmp = array_slice($dir, 2);
} else {
$tmp = array_slice($dir, 1);
if (!file_exists($base.$tmp[0])) {
$tmp[0] = 'Default';
}
}
if (file_exists($base.implode('/', $tmp))) {
return $dir[0] . ':' . implode(':', $tmp);
} else {
$file = explode('.', $tmp[count($tmp) - 1]);
$file[0] = 'default';
$tmp[count($tmp) - 1] = implode('.', $file);
if (file_exists($base . implode('/', $tmp))) {
return $dir[0] . ':' . implode(':', $tmp);
}
}
return $path;
}
|
php
|
public function defaultTemplate($path)
{
$dir = explode(':', $path);
$controller = preg_split('/(?=[A-Z])/', $dir[0]);
$controller = array_slice($controller, (count($controller) - 2));
$controller = implode('', $controller);
$base = __DIR__ . "/../../Resources/views/";
if ($dir[1] === '') {
$dir[0] = $dir[0] . ':';
$tmp = array_slice($dir, 2);
} else {
$tmp = array_slice($dir, 1);
if (!file_exists($base.$tmp[0])) {
$tmp[0] = 'Default';
}
}
if (file_exists($base.implode('/', $tmp))) {
return $dir[0] . ':' . implode(':', $tmp);
} else {
$file = explode('.', $tmp[count($tmp) - 1]);
$file[0] = 'default';
$tmp[count($tmp) - 1] = implode('.', $file);
if (file_exists($base . implode('/', $tmp))) {
return $dir[0] . ':' . implode(':', $tmp);
}
}
return $path;
}
|
[
"public",
"function",
"defaultTemplate",
"(",
"$",
"path",
")",
"{",
"$",
"dir",
"=",
"explode",
"(",
"':'",
",",
"$",
"path",
")",
";",
"$",
"controller",
"=",
"preg_split",
"(",
"'/(?=[A-Z])/'",
",",
"$",
"dir",
"[",
"0",
"]",
")",
";",
"$",
"controller",
"=",
"array_slice",
"(",
"$",
"controller",
",",
"(",
"count",
"(",
"$",
"controller",
")",
"-",
"2",
")",
")",
";",
"$",
"controller",
"=",
"implode",
"(",
"''",
",",
"$",
"controller",
")",
";",
"$",
"base",
"=",
"__DIR__",
".",
"\"/../../Resources/views/\"",
";",
"if",
"(",
"$",
"dir",
"[",
"1",
"]",
"===",
"''",
")",
"{",
"$",
"dir",
"[",
"0",
"]",
"=",
"$",
"dir",
"[",
"0",
"]",
".",
"':'",
";",
"$",
"tmp",
"=",
"array_slice",
"(",
"$",
"dir",
",",
"2",
")",
";",
"}",
"else",
"{",
"$",
"tmp",
"=",
"array_slice",
"(",
"$",
"dir",
",",
"1",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"base",
".",
"$",
"tmp",
"[",
"0",
"]",
")",
")",
"{",
"$",
"tmp",
"[",
"0",
"]",
"=",
"'Default'",
";",
"}",
"}",
"if",
"(",
"file_exists",
"(",
"$",
"base",
".",
"implode",
"(",
"'/'",
",",
"$",
"tmp",
")",
")",
")",
"{",
"return",
"$",
"dir",
"[",
"0",
"]",
".",
"':'",
".",
"implode",
"(",
"':'",
",",
"$",
"tmp",
")",
";",
"}",
"else",
"{",
"$",
"file",
"=",
"explode",
"(",
"'.'",
",",
"$",
"tmp",
"[",
"count",
"(",
"$",
"tmp",
")",
"-",
"1",
"]",
")",
";",
"$",
"file",
"[",
"0",
"]",
"=",
"'default'",
";",
"$",
"tmp",
"[",
"count",
"(",
"$",
"tmp",
")",
"-",
"1",
"]",
"=",
"implode",
"(",
"'.'",
",",
"$",
"file",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"base",
".",
"implode",
"(",
"'/'",
",",
"$",
"tmp",
")",
")",
")",
"{",
"return",
"$",
"dir",
"[",
"0",
"]",
".",
"':'",
".",
"implode",
"(",
"':'",
",",
"$",
"tmp",
")",
";",
"}",
"}",
"return",
"$",
"path",
";",
"}"
] |
Verify if a twig template exists, If the template does not exists a default path will be return;
@param string $path The path of the twig template separated by : just as the path for $this->render(...)
@return string
|
[
"Verify",
"if",
"a",
"twig",
"template",
"exists",
"If",
"the",
"template",
"does",
"not",
"exists",
"a",
"default",
"path",
"will",
"be",
"return",
";"
] |
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
|
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Library/Home/HomeService.php#L27-L61
|
221,979
|
claroline/CoreBundle
|
Library/Home/HomeService.php
|
HomeService.isDefinedPush
|
public function isDefinedPush($array, $name, $variable, $method = null)
{
if ($method and $variable) {
$array[$name] = $variable->$method();
} elseif ($variable) {
$array[$name] = $variable;
}
return $array;
}
|
php
|
public function isDefinedPush($array, $name, $variable, $method = null)
{
if ($method and $variable) {
$array[$name] = $variable->$method();
} elseif ($variable) {
$array[$name] = $variable;
}
return $array;
}
|
[
"public",
"function",
"isDefinedPush",
"(",
"$",
"array",
",",
"$",
"name",
",",
"$",
"variable",
",",
"$",
"method",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"method",
"and",
"$",
"variable",
")",
"{",
"$",
"array",
"[",
"$",
"name",
"]",
"=",
"$",
"variable",
"->",
"$",
"method",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"variable",
")",
"{",
"$",
"array",
"[",
"$",
"name",
"]",
"=",
"$",
"variable",
";",
"}",
"return",
"$",
"array",
";",
"}"
] |
Reduce some "overall complexity"
|
[
"Reduce",
"some",
"overall",
"complexity"
] |
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
|
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Library/Home/HomeService.php#L66-L75
|
221,980
|
claroline/CoreBundle
|
Library/Installation/PlatformInstaller.php
|
PlatformInstaller.installFromKernel
|
public function installFromKernel($withOptionalFixtures = true)
{
$this->launchPreInstallActions();
//The core bundle must be installed first
$coreBundle = $this->kernel->getBundle('ClarolineCoreBundle');
$bundles = $this->kernel->getBundles();
$this->baseInstaller->install($coreBundle, !$withOptionalFixtures);
foreach ($bundles as $bundle) {
//we obviously can't install the core bundle twice.
if ($bundle !== $coreBundle) {
if ($bundle instanceof PluginBundle) {
$this->pluginInstaller->install($bundle);
} elseif ($bundle instanceof InstallableInterface) {
$this->baseInstaller->install($bundle, !$withOptionalFixtures);
}
}
}
}
|
php
|
public function installFromKernel($withOptionalFixtures = true)
{
$this->launchPreInstallActions();
//The core bundle must be installed first
$coreBundle = $this->kernel->getBundle('ClarolineCoreBundle');
$bundles = $this->kernel->getBundles();
$this->baseInstaller->install($coreBundle, !$withOptionalFixtures);
foreach ($bundles as $bundle) {
//we obviously can't install the core bundle twice.
if ($bundle !== $coreBundle) {
if ($bundle instanceof PluginBundle) {
$this->pluginInstaller->install($bundle);
} elseif ($bundle instanceof InstallableInterface) {
$this->baseInstaller->install($bundle, !$withOptionalFixtures);
}
}
}
}
|
[
"public",
"function",
"installFromKernel",
"(",
"$",
"withOptionalFixtures",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"launchPreInstallActions",
"(",
")",
";",
"//The core bundle must be installed first",
"$",
"coreBundle",
"=",
"$",
"this",
"->",
"kernel",
"->",
"getBundle",
"(",
"'ClarolineCoreBundle'",
")",
";",
"$",
"bundles",
"=",
"$",
"this",
"->",
"kernel",
"->",
"getBundles",
"(",
")",
";",
"$",
"this",
"->",
"baseInstaller",
"->",
"install",
"(",
"$",
"coreBundle",
",",
"!",
"$",
"withOptionalFixtures",
")",
";",
"foreach",
"(",
"$",
"bundles",
"as",
"$",
"bundle",
")",
"{",
"//we obviously can't install the core bundle twice.",
"if",
"(",
"$",
"bundle",
"!==",
"$",
"coreBundle",
")",
"{",
"if",
"(",
"$",
"bundle",
"instanceof",
"PluginBundle",
")",
"{",
"$",
"this",
"->",
"pluginInstaller",
"->",
"install",
"(",
"$",
"bundle",
")",
";",
"}",
"elseif",
"(",
"$",
"bundle",
"instanceof",
"InstallableInterface",
")",
"{",
"$",
"this",
"->",
"baseInstaller",
"->",
"install",
"(",
"$",
"bundle",
",",
"!",
"$",
"withOptionalFixtures",
")",
";",
"}",
"}",
"}",
"}"
] |
This is the method fired at the 1st installation.
Either command line or from the web installer.
@param bool $withOptionalFixtures
|
[
"This",
"is",
"the",
"method",
"fired",
"at",
"the",
"1st",
"installation",
".",
"Either",
"command",
"line",
"or",
"from",
"the",
"web",
"installer",
"."
] |
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
|
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Library/Installation/PlatformInstaller.php#L110-L128
|
221,981
|
claroline/CoreBundle
|
Manager/ThemeManager.php
|
ThemeManager.createCustomTheme
|
public function createCustomTheme($name, File $file)
{
$theme = new Theme();
$theme->setName($name);
$themeDir = "{$this->themeDir}/{$theme->getNormalizedName()}";
$fs = new Filesystem();
$fs->mkdir($themeDir);
$file->move($themeDir, 'bootstrap.css');
$this->om->persist($theme);
$this->om->flush();
}
|
php
|
public function createCustomTheme($name, File $file)
{
$theme = new Theme();
$theme->setName($name);
$themeDir = "{$this->themeDir}/{$theme->getNormalizedName()}";
$fs = new Filesystem();
$fs->mkdir($themeDir);
$file->move($themeDir, 'bootstrap.css');
$this->om->persist($theme);
$this->om->flush();
}
|
[
"public",
"function",
"createCustomTheme",
"(",
"$",
"name",
",",
"File",
"$",
"file",
")",
"{",
"$",
"theme",
"=",
"new",
"Theme",
"(",
")",
";",
"$",
"theme",
"->",
"setName",
"(",
"$",
"name",
")",
";",
"$",
"themeDir",
"=",
"\"{$this->themeDir}/{$theme->getNormalizedName()}\"",
";",
"$",
"fs",
"=",
"new",
"Filesystem",
"(",
")",
";",
"$",
"fs",
"->",
"mkdir",
"(",
"$",
"themeDir",
")",
";",
"$",
"file",
"->",
"move",
"(",
"$",
"themeDir",
",",
"'bootstrap.css'",
")",
";",
"$",
"this",
"->",
"om",
"->",
"persist",
"(",
"$",
"theme",
")",
";",
"$",
"this",
"->",
"om",
"->",
"flush",
"(",
")",
";",
"}"
] |
Creates a custom theme based on a css file.
@param string $name
@param File $file
|
[
"Creates",
"a",
"custom",
"theme",
"based",
"on",
"a",
"css",
"file",
"."
] |
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
|
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/ThemeManager.php#L151-L164
|
221,982
|
claroline/CoreBundle
|
Repository/WorkspaceRepository.php
|
WorkspaceRepository.findByAnonymous
|
public function findByAnonymous($orderedToolType = 0)
{
$dql = "
SELECT DISTINCT w
FROM Claroline\CoreBundle\Entity\Workspace\Workspace w
JOIN w.orderedTools ot
JOIN ot.rights otr
JOIN otr.role r
WHERE r.name = 'ROLE_ANONYMOUS'
AND ot.type = :type
AND BIT_AND(otr.mask, :openValue) = :openValue
";
$query = $this->_em->createQuery($dql);
$query->setParameter('openValue', ToolMaskDecoder::$defaultValues['open']);
$query->setParameter('type', $orderedToolType);
return $query->getResult();
}
|
php
|
public function findByAnonymous($orderedToolType = 0)
{
$dql = "
SELECT DISTINCT w
FROM Claroline\CoreBundle\Entity\Workspace\Workspace w
JOIN w.orderedTools ot
JOIN ot.rights otr
JOIN otr.role r
WHERE r.name = 'ROLE_ANONYMOUS'
AND ot.type = :type
AND BIT_AND(otr.mask, :openValue) = :openValue
";
$query = $this->_em->createQuery($dql);
$query->setParameter('openValue', ToolMaskDecoder::$defaultValues['open']);
$query->setParameter('type', $orderedToolType);
return $query->getResult();
}
|
[
"public",
"function",
"findByAnonymous",
"(",
"$",
"orderedToolType",
"=",
"0",
")",
"{",
"$",
"dql",
"=",
"\"\n SELECT DISTINCT w\n FROM Claroline\\CoreBundle\\Entity\\Workspace\\Workspace w\n JOIN w.orderedTools ot\n JOIN ot.rights otr\n JOIN otr.role r\n WHERE r.name = 'ROLE_ANONYMOUS'\n AND ot.type = :type\n AND BIT_AND(otr.mask, :openValue) = :openValue\n \"",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"_em",
"->",
"createQuery",
"(",
"$",
"dql",
")",
";",
"$",
"query",
"->",
"setParameter",
"(",
"'openValue'",
",",
"ToolMaskDecoder",
"::",
"$",
"defaultValues",
"[",
"'open'",
"]",
")",
";",
"$",
"query",
"->",
"setParameter",
"(",
"'type'",
",",
"$",
"orderedToolType",
")",
";",
"return",
"$",
"query",
"->",
"getResult",
"(",
")",
";",
"}"
] |
Returns the workspaces whose at least one tool is accessible to anonymous users.
@return array[Workspace]
|
[
"Returns",
"the",
"workspaces",
"whose",
"at",
"least",
"one",
"tool",
"is",
"accessible",
"to",
"anonymous",
"users",
"."
] |
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
|
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Repository/WorkspaceRepository.php#L85-L102
|
221,983
|
claroline/CoreBundle
|
Repository/WorkspaceRepository.php
|
WorkspaceRepository.findOpenWorkspaceIds
|
public function findOpenWorkspaceIds(
array $roleNames,
array $workspaces,
$toolName = null,
$action = 'open',
$orderedToolType = 0
)
{
if (count($roleNames) === 0 || count($workspaces) === 0) {
return array();
} else {
$dql = '
SELECT DISTINCT w.id
FROM Claroline\CoreBundle\Entity\Workspace\Workspace w
JOIN w.orderedTools ot
JOIN ot.tool t
JOIN ot.rights r
JOIN r.role rr
WHERE w IN (:workspaces)
AND rr.name IN (:roleNames)
AND ot.type = :type
AND EXISTS (
SELECT d
FROM Claroline\CoreBundle\Entity\Tool\ToolMaskDecoder d
WHERE d.tool = t
AND d.name = :action
AND BIT_AND(r.mask, d.value) = d.value
)
';
if ($toolName) {
$dql .= 'AND t.name = :toolName';
}
$query = $this->_em->createQuery($dql);
$query->setParameter('workspaces', $workspaces);
$query->setParameter('roleNames', $roleNames);
$query->setParameter('action', $action);
$query->setParameter('type', $orderedToolType);
if ($toolName) {
$query->setParameter('toolName', $toolName);
}
return $query->getResult();
}
}
|
php
|
public function findOpenWorkspaceIds(
array $roleNames,
array $workspaces,
$toolName = null,
$action = 'open',
$orderedToolType = 0
)
{
if (count($roleNames) === 0 || count($workspaces) === 0) {
return array();
} else {
$dql = '
SELECT DISTINCT w.id
FROM Claroline\CoreBundle\Entity\Workspace\Workspace w
JOIN w.orderedTools ot
JOIN ot.tool t
JOIN ot.rights r
JOIN r.role rr
WHERE w IN (:workspaces)
AND rr.name IN (:roleNames)
AND ot.type = :type
AND EXISTS (
SELECT d
FROM Claroline\CoreBundle\Entity\Tool\ToolMaskDecoder d
WHERE d.tool = t
AND d.name = :action
AND BIT_AND(r.mask, d.value) = d.value
)
';
if ($toolName) {
$dql .= 'AND t.name = :toolName';
}
$query = $this->_em->createQuery($dql);
$query->setParameter('workspaces', $workspaces);
$query->setParameter('roleNames', $roleNames);
$query->setParameter('action', $action);
$query->setParameter('type', $orderedToolType);
if ($toolName) {
$query->setParameter('toolName', $toolName);
}
return $query->getResult();
}
}
|
[
"public",
"function",
"findOpenWorkspaceIds",
"(",
"array",
"$",
"roleNames",
",",
"array",
"$",
"workspaces",
",",
"$",
"toolName",
"=",
"null",
",",
"$",
"action",
"=",
"'open'",
",",
"$",
"orderedToolType",
"=",
"0",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"roleNames",
")",
"===",
"0",
"||",
"count",
"(",
"$",
"workspaces",
")",
"===",
"0",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"else",
"{",
"$",
"dql",
"=",
"'\n SELECT DISTINCT w.id\n FROM Claroline\\CoreBundle\\Entity\\Workspace\\Workspace w\n JOIN w.orderedTools ot\n JOIN ot.tool t\n JOIN ot.rights r\n JOIN r.role rr\n WHERE w IN (:workspaces)\n AND rr.name IN (:roleNames)\n AND ot.type = :type\n AND EXISTS (\n SELECT d\n FROM Claroline\\CoreBundle\\Entity\\Tool\\ToolMaskDecoder d\n WHERE d.tool = t\n AND d.name = :action\n AND BIT_AND(r.mask, d.value) = d.value\n )\n '",
";",
"if",
"(",
"$",
"toolName",
")",
"{",
"$",
"dql",
".=",
"'AND t.name = :toolName'",
";",
"}",
"$",
"query",
"=",
"$",
"this",
"->",
"_em",
"->",
"createQuery",
"(",
"$",
"dql",
")",
";",
"$",
"query",
"->",
"setParameter",
"(",
"'workspaces'",
",",
"$",
"workspaces",
")",
";",
"$",
"query",
"->",
"setParameter",
"(",
"'roleNames'",
",",
"$",
"roleNames",
")",
";",
"$",
"query",
"->",
"setParameter",
"(",
"'action'",
",",
"$",
"action",
")",
";",
"$",
"query",
"->",
"setParameter",
"(",
"'type'",
",",
"$",
"orderedToolType",
")",
";",
"if",
"(",
"$",
"toolName",
")",
"{",
"$",
"query",
"->",
"setParameter",
"(",
"'toolName'",
",",
"$",
"toolName",
")",
";",
"}",
"return",
"$",
"query",
"->",
"getResult",
"(",
")",
";",
"}",
"}"
] |
Finds which workspaces can be opened by one of the given roles,
in a given set of workspaces. If a tool name is passed in, the
check will be limited to that tool, otherwise workspaces with
at least one accessible tool will be considered open. Only the
ids are returned.
@param array[string] $roles
@param array[Workspace] $workspaces
@param string|null $toolName
@return array[integer]
|
[
"Finds",
"which",
"workspaces",
"can",
"be",
"opened",
"by",
"one",
"of",
"the",
"given",
"roles",
"in",
"a",
"given",
"set",
"of",
"workspaces",
".",
"If",
"a",
"tool",
"name",
"is",
"passed",
"in",
"the",
"check",
"will",
"be",
"limited",
"to",
"that",
"tool",
"otherwise",
"workspaces",
"with",
"at",
"least",
"one",
"accessible",
"tool",
"will",
"be",
"considered",
"open",
".",
"Only",
"the",
"ids",
"are",
"returned",
"."
] |
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
|
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Repository/WorkspaceRepository.php#L214-L261
|
221,984
|
claroline/CoreBundle
|
Repository/WorkspaceRepository.php
|
WorkspaceRepository.findByRoleNamesBySearch
|
public function findByRoleNamesBySearch(array $roleNames, $search, $orderedToolType = 0)
{
$dql = '
SELECT DISTINCT w
FROM Claroline\CoreBundle\Entity\Workspace\Workspace w
JOIN w.orderedTools ot
JOIN ot.rights otr
JOIN otr.role r
WHERE r.name IN (:roleNames)
AND ot.type = :type
AND BIT_AND(otr.mask, :openValue) = :openValue
AND (
UPPER(w.name) LIKE :search
OR UPPER(w.code) LIKE :search
)
ORDER BY w.name
';
$upperSearch = strtoupper($search);
$query = $this->_em->createQuery($dql);
$query->setParameter('roleNames', $roleNames);
$query->setParameter('openValue', ToolMaskDecoder::$defaultValues['open']);
$query->setParameter('search', "%{$upperSearch}%");
$query->setParameter('type', $orderedToolType);
return $query->getResult();
}
|
php
|
public function findByRoleNamesBySearch(array $roleNames, $search, $orderedToolType = 0)
{
$dql = '
SELECT DISTINCT w
FROM Claroline\CoreBundle\Entity\Workspace\Workspace w
JOIN w.orderedTools ot
JOIN ot.rights otr
JOIN otr.role r
WHERE r.name IN (:roleNames)
AND ot.type = :type
AND BIT_AND(otr.mask, :openValue) = :openValue
AND (
UPPER(w.name) LIKE :search
OR UPPER(w.code) LIKE :search
)
ORDER BY w.name
';
$upperSearch = strtoupper($search);
$query = $this->_em->createQuery($dql);
$query->setParameter('roleNames', $roleNames);
$query->setParameter('openValue', ToolMaskDecoder::$defaultValues['open']);
$query->setParameter('search', "%{$upperSearch}%");
$query->setParameter('type', $orderedToolType);
return $query->getResult();
}
|
[
"public",
"function",
"findByRoleNamesBySearch",
"(",
"array",
"$",
"roleNames",
",",
"$",
"search",
",",
"$",
"orderedToolType",
"=",
"0",
")",
"{",
"$",
"dql",
"=",
"'\n SELECT DISTINCT w\n FROM Claroline\\CoreBundle\\Entity\\Workspace\\Workspace w\n JOIN w.orderedTools ot\n JOIN ot.rights otr\n JOIN otr.role r\n WHERE r.name IN (:roleNames)\n AND ot.type = :type\n AND BIT_AND(otr.mask, :openValue) = :openValue\n AND (\n UPPER(w.name) LIKE :search\n OR UPPER(w.code) LIKE :search\n )\n ORDER BY w.name\n '",
";",
"$",
"upperSearch",
"=",
"strtoupper",
"(",
"$",
"search",
")",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"_em",
"->",
"createQuery",
"(",
"$",
"dql",
")",
";",
"$",
"query",
"->",
"setParameter",
"(",
"'roleNames'",
",",
"$",
"roleNames",
")",
";",
"$",
"query",
"->",
"setParameter",
"(",
"'openValue'",
",",
"ToolMaskDecoder",
"::",
"$",
"defaultValues",
"[",
"'open'",
"]",
")",
";",
"$",
"query",
"->",
"setParameter",
"(",
"'search'",
",",
"\"%{$upperSearch}%\"",
")",
";",
"$",
"query",
"->",
"setParameter",
"(",
"'type'",
",",
"$",
"orderedToolType",
")",
";",
"return",
"$",
"query",
"->",
"getResult",
"(",
")",
";",
"}"
] |
Returns the workspaces whose at least one tool is accessible to one of the given roles
and whose name matches the given search string.
@param array[string] $roleNames
@param string $search
@return array[Workspace]
|
[
"Returns",
"the",
"workspaces",
"whose",
"at",
"least",
"one",
"tool",
"is",
"accessible",
"to",
"one",
"of",
"the",
"given",
"roles",
"and",
"whose",
"name",
"matches",
"the",
"given",
"search",
"string",
"."
] |
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
|
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Repository/WorkspaceRepository.php#L301-L327
|
221,985
|
claroline/CoreBundle
|
Repository/WorkspaceRepository.php
|
WorkspaceRepository.findDisplayableWorkspacesWithout
|
public function findDisplayableWorkspacesWithout(array $excludedWorkspaces)
{
$dql = '
SELECT w
FROM Claroline\CoreBundle\Entity\Workspace\Workspace w
WHERE w.displayable = true
AND w NOT IN (:excludedWorkspaces)
ORDER BY w.name
';
$query = $this->_em->createQuery($dql);
$query->setParameter('excludedWorkspaces', $excludedWorkspaces);
return $query->getResult();
}
|
php
|
public function findDisplayableWorkspacesWithout(array $excludedWorkspaces)
{
$dql = '
SELECT w
FROM Claroline\CoreBundle\Entity\Workspace\Workspace w
WHERE w.displayable = true
AND w NOT IN (:excludedWorkspaces)
ORDER BY w.name
';
$query = $this->_em->createQuery($dql);
$query->setParameter('excludedWorkspaces', $excludedWorkspaces);
return $query->getResult();
}
|
[
"public",
"function",
"findDisplayableWorkspacesWithout",
"(",
"array",
"$",
"excludedWorkspaces",
")",
"{",
"$",
"dql",
"=",
"'\n SELECT w\n FROM Claroline\\CoreBundle\\Entity\\Workspace\\Workspace w\n WHERE w.displayable = true\n AND w NOT IN (:excludedWorkspaces)\n ORDER BY w.name\n '",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"_em",
"->",
"createQuery",
"(",
"$",
"dql",
")",
";",
"$",
"query",
"->",
"setParameter",
"(",
"'excludedWorkspaces'",
",",
"$",
"excludedWorkspaces",
")",
";",
"return",
"$",
"query",
"->",
"getResult",
"(",
")",
";",
"}"
] |
Returns the workspaces which are visible and are not in the given list.
@return array[Workspace]
|
[
"Returns",
"the",
"workspaces",
"which",
"are",
"visible",
"and",
"are",
"not",
"in",
"the",
"given",
"list",
"."
] |
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
|
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Repository/WorkspaceRepository.php#L619-L632
|
221,986
|
claroline/CoreBundle
|
Repository/WorkspaceRepository.php
|
WorkspaceRepository.findMyWorkspacesByRoleNames
|
public function findMyWorkspacesByRoleNames(array $roleNames)
{
$dql = '
SELECT DISTINCT w
FROM Claroline\CoreBundle\Entity\Workspace\Workspace w
WHERE w IN (
SELECT rw.id
FROM Claroline\CoreBundle\Entity\Role r
JOIN Claroline\CoreBundle\Entity\Workspace\Workspace rw
WHERE r.name IN (:roleNames)
)
ORDER BY w.name ASC
';
$query = $this->_em->createQuery($dql);
$query->setParameter('roleNames', $roleNames);
return $query->getResult();
}
|
php
|
public function findMyWorkspacesByRoleNames(array $roleNames)
{
$dql = '
SELECT DISTINCT w
FROM Claroline\CoreBundle\Entity\Workspace\Workspace w
WHERE w IN (
SELECT rw.id
FROM Claroline\CoreBundle\Entity\Role r
JOIN Claroline\CoreBundle\Entity\Workspace\Workspace rw
WHERE r.name IN (:roleNames)
)
ORDER BY w.name ASC
';
$query = $this->_em->createQuery($dql);
$query->setParameter('roleNames', $roleNames);
return $query->getResult();
}
|
[
"public",
"function",
"findMyWorkspacesByRoleNames",
"(",
"array",
"$",
"roleNames",
")",
"{",
"$",
"dql",
"=",
"'\n SELECT DISTINCT w\n FROM Claroline\\CoreBundle\\Entity\\Workspace\\Workspace w\n WHERE w IN (\n SELECT rw.id\n FROM Claroline\\CoreBundle\\Entity\\Role r\n JOIN Claroline\\CoreBundle\\Entity\\Workspace\\Workspace rw\n WHERE r.name IN (:roleNames)\n )\n ORDER BY w.name ASC\n '",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"_em",
"->",
"createQuery",
"(",
"$",
"dql",
")",
";",
"$",
"query",
"->",
"setParameter",
"(",
"'roleNames'",
",",
"$",
"roleNames",
")",
";",
"return",
"$",
"query",
"->",
"getResult",
"(",
")",
";",
"}"
] |
Returns the workspaces accessible by one of the given roles.
@param array[string] $roleNames
@return array[Workspace]
|
[
"Returns",
"the",
"workspaces",
"accessible",
"by",
"one",
"of",
"the",
"given",
"roles",
"."
] |
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
|
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Repository/WorkspaceRepository.php#L779-L797
|
221,987
|
claroline/CoreBundle
|
Repository/WorkspaceRepository.php
|
WorkspaceRepository.findAllPersonalWorkspaces
|
public function findAllPersonalWorkspaces($orderedBy = 'name', $order = 'ASC')
{
$dql = "
SELECT w
FROM Claroline\CoreBundle\Entity\Workspace\Workspace w
WHERE EXISTS (
SELECT u
FROM Claroline\CoreBundle\Entity\User u
JOIN u.personalWorkspace pw
WHERE pw = w
)
ORDER BY w.{$orderedBy} {$order}
";
$query = $this->_em->createQuery($dql);
return $query->getResult();
}
|
php
|
public function findAllPersonalWorkspaces($orderedBy = 'name', $order = 'ASC')
{
$dql = "
SELECT w
FROM Claroline\CoreBundle\Entity\Workspace\Workspace w
WHERE EXISTS (
SELECT u
FROM Claroline\CoreBundle\Entity\User u
JOIN u.personalWorkspace pw
WHERE pw = w
)
ORDER BY w.{$orderedBy} {$order}
";
$query = $this->_em->createQuery($dql);
return $query->getResult();
}
|
[
"public",
"function",
"findAllPersonalWorkspaces",
"(",
"$",
"orderedBy",
"=",
"'name'",
",",
"$",
"order",
"=",
"'ASC'",
")",
"{",
"$",
"dql",
"=",
"\"\n SELECT w\n FROM Claroline\\CoreBundle\\Entity\\Workspace\\Workspace w\n WHERE EXISTS (\n SELECT u\n FROM Claroline\\CoreBundle\\Entity\\User u\n JOIN u.personalWorkspace pw\n WHERE pw = w\n )\n ORDER BY w.{$orderedBy} {$order}\n \"",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"_em",
"->",
"createQuery",
"(",
"$",
"dql",
")",
";",
"return",
"$",
"query",
"->",
"getResult",
"(",
")",
";",
"}"
] |
Returns all personal workspaces.
@return array[Workspace]
|
[
"Returns",
"all",
"personal",
"workspaces",
"."
] |
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
|
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Repository/WorkspaceRepository.php#L975-L991
|
221,988
|
claroline/CoreBundle
|
Event/StrictDispatcher.php
|
StrictDispatcher.dispatch
|
public function dispatch($eventName, $shortEventClassName, array $eventArgs = array())
{
$className = class_exists($shortEventClassName) ?
$shortEventClassName:
"Claroline\CoreBundle\Event\\{$shortEventClassName}Event";
if (!class_exists($className)) {
throw new MissingEventClassException(
"No event class matches the short name '{$shortEventClassName}' (looked for '{$className})"
);
}
$rEvent = new \ReflectionClass($className);
$event = $rEvent->newInstanceArgs($eventArgs);
if ($event instanceof MandatoryEventInterface && !$this->eventDispatcher->hasListeners($eventName)) {
throw new MandatoryEventException("No listener is attached to the '{$eventName}' event");
}
$this->eventDispatcher->dispatch($eventName, $event);
if ($event instanceof DataConveyorEventInterface && !$event->isPopulated()) {
throw new NotPopulatedEventException("Event object for '{$eventName}' was not populated as expected");
}
return $event;
}
|
php
|
public function dispatch($eventName, $shortEventClassName, array $eventArgs = array())
{
$className = class_exists($shortEventClassName) ?
$shortEventClassName:
"Claroline\CoreBundle\Event\\{$shortEventClassName}Event";
if (!class_exists($className)) {
throw new MissingEventClassException(
"No event class matches the short name '{$shortEventClassName}' (looked for '{$className})"
);
}
$rEvent = new \ReflectionClass($className);
$event = $rEvent->newInstanceArgs($eventArgs);
if ($event instanceof MandatoryEventInterface && !$this->eventDispatcher->hasListeners($eventName)) {
throw new MandatoryEventException("No listener is attached to the '{$eventName}' event");
}
$this->eventDispatcher->dispatch($eventName, $event);
if ($event instanceof DataConveyorEventInterface && !$event->isPopulated()) {
throw new NotPopulatedEventException("Event object for '{$eventName}' was not populated as expected");
}
return $event;
}
|
[
"public",
"function",
"dispatch",
"(",
"$",
"eventName",
",",
"$",
"shortEventClassName",
",",
"array",
"$",
"eventArgs",
"=",
"array",
"(",
")",
")",
"{",
"$",
"className",
"=",
"class_exists",
"(",
"$",
"shortEventClassName",
")",
"?",
"$",
"shortEventClassName",
":",
"\"Claroline\\CoreBundle\\Event\\\\{$shortEventClassName}Event\"",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"className",
")",
")",
"{",
"throw",
"new",
"MissingEventClassException",
"(",
"\"No event class matches the short name '{$shortEventClassName}' (looked for '{$className})\"",
")",
";",
"}",
"$",
"rEvent",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"className",
")",
";",
"$",
"event",
"=",
"$",
"rEvent",
"->",
"newInstanceArgs",
"(",
"$",
"eventArgs",
")",
";",
"if",
"(",
"$",
"event",
"instanceof",
"MandatoryEventInterface",
"&&",
"!",
"$",
"this",
"->",
"eventDispatcher",
"->",
"hasListeners",
"(",
"$",
"eventName",
")",
")",
"{",
"throw",
"new",
"MandatoryEventException",
"(",
"\"No listener is attached to the '{$eventName}' event\"",
")",
";",
"}",
"$",
"this",
"->",
"eventDispatcher",
"->",
"dispatch",
"(",
"$",
"eventName",
",",
"$",
"event",
")",
";",
"if",
"(",
"$",
"event",
"instanceof",
"DataConveyorEventInterface",
"&&",
"!",
"$",
"event",
"->",
"isPopulated",
"(",
")",
")",
"{",
"throw",
"new",
"NotPopulatedEventException",
"(",
"\"Event object for '{$eventName}' was not populated as expected\"",
")",
";",
"}",
"return",
"$",
"event",
";",
"}"
] |
Dispatches an event and returns its associated event object. The event object
is created according to the short event class name parameter, which must match
an event class located in the core event directory, without the first path
segments and the "Event" suffix.
@param string $eventName Name of the event
@param string $shortEventClassName Short name of the event class
@param array $eventArgs Parameters to be passed to the event object constructor
@return \Symfony\Component\EventDispatcher\Event
@throws MissingEventClassException if no event class matches the short class name
@throws MandatoryEventException if the event is mandatory but have no listener observing it
@throws NotPopulatedEventException if the event is supposed to be populated with data but it isn't
|
[
"Dispatches",
"an",
"event",
"and",
"returns",
"its",
"associated",
"event",
"object",
".",
"The",
"event",
"object",
"is",
"created",
"according",
"to",
"the",
"short",
"event",
"class",
"name",
"parameter",
"which",
"must",
"match",
"an",
"event",
"class",
"located",
"in",
"the",
"core",
"event",
"directory",
"without",
"the",
"first",
"path",
"segments",
"and",
"the",
"Event",
"suffix",
"."
] |
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
|
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Event/StrictDispatcher.php#L59-L85
|
221,989
|
claroline/CoreBundle
|
Manager/ApiManager.php
|
ApiManager.handleFormView
|
public function handleFormView($template, $form, array $options = array())
{
$httpCode = isset($options['http_code']) ? $options['http_code']: 200;
$parameters = isset($options['form_view']) ? $options['form_view']: array();
$serializerGroup = isset($options['serializer_group']) ? $options['serializer_group']: 'api';
return $form->isValid() ?
$this->createSerialized($options['extra_parameters'], $serializerGroup):
$this->createFormView($template, $form, $httpCode, $parameters);
}
|
php
|
public function handleFormView($template, $form, array $options = array())
{
$httpCode = isset($options['http_code']) ? $options['http_code']: 200;
$parameters = isset($options['form_view']) ? $options['form_view']: array();
$serializerGroup = isset($options['serializer_group']) ? $options['serializer_group']: 'api';
return $form->isValid() ?
$this->createSerialized($options['extra_parameters'], $serializerGroup):
$this->createFormView($template, $form, $httpCode, $parameters);
}
|
[
"public",
"function",
"handleFormView",
"(",
"$",
"template",
",",
"$",
"form",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"httpCode",
"=",
"isset",
"(",
"$",
"options",
"[",
"'http_code'",
"]",
")",
"?",
"$",
"options",
"[",
"'http_code'",
"]",
":",
"200",
";",
"$",
"parameters",
"=",
"isset",
"(",
"$",
"options",
"[",
"'form_view'",
"]",
")",
"?",
"$",
"options",
"[",
"'form_view'",
"]",
":",
"array",
"(",
")",
";",
"$",
"serializerGroup",
"=",
"isset",
"(",
"$",
"options",
"[",
"'serializer_group'",
"]",
")",
"?",
"$",
"options",
"[",
"'serializer_group'",
"]",
":",
"'api'",
";",
"return",
"$",
"form",
"->",
"isValid",
"(",
")",
"?",
"$",
"this",
"->",
"createSerialized",
"(",
"$",
"options",
"[",
"'extra_parameters'",
"]",
",",
"$",
"serializerGroup",
")",
":",
"$",
"this",
"->",
"createFormView",
"(",
"$",
"template",
",",
"$",
"form",
",",
"$",
"httpCode",
",",
"$",
"parameters",
")",
";",
"}"
] |
helper for the API controllers methods. We only do this in case of html request
|
[
"helper",
"for",
"the",
"API",
"controllers",
"methods",
".",
"We",
"only",
"do",
"this",
"in",
"case",
"of",
"html",
"request"
] |
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
|
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/ApiManager.php#L112-L122
|
221,990
|
claroline/CoreBundle
|
Repository/WorkspaceTagHierarchyRepository.php
|
WorkspaceTagHierarchyRepository.findAdminHierarchiesByParent
|
public function findAdminHierarchiesByParent(WorkspaceTag $workspaceTag)
{
$dql = '
SELECT h
FROM Claroline\CoreBundle\Entity\Workspace\WorkspaceTagHierarchy h
WHERE h.user IS NULL
AND h.parent = :workspaceTag
';
$query = $this->_em->createQuery($dql);
$query->setParameter('workspaceTag', $workspaceTag);
return $query->getResult();
}
|
php
|
public function findAdminHierarchiesByParent(WorkspaceTag $workspaceTag)
{
$dql = '
SELECT h
FROM Claroline\CoreBundle\Entity\Workspace\WorkspaceTagHierarchy h
WHERE h.user IS NULL
AND h.parent = :workspaceTag
';
$query = $this->_em->createQuery($dql);
$query->setParameter('workspaceTag', $workspaceTag);
return $query->getResult();
}
|
[
"public",
"function",
"findAdminHierarchiesByParent",
"(",
"WorkspaceTag",
"$",
"workspaceTag",
")",
"{",
"$",
"dql",
"=",
"'\n SELECT h\n FROM Claroline\\CoreBundle\\Entity\\Workspace\\WorkspaceTagHierarchy h\n WHERE h.user IS NULL\n AND h.parent = :workspaceTag\n '",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"_em",
"->",
"createQuery",
"(",
"$",
"dql",
")",
";",
"$",
"query",
"->",
"setParameter",
"(",
"'workspaceTag'",
",",
"$",
"workspaceTag",
")",
";",
"return",
"$",
"query",
"->",
"getResult",
"(",
")",
";",
"}"
] |
Returns all admin relations where given workspaceTag is parent
|
[
"Returns",
"all",
"admin",
"relations",
"where",
"given",
"workspaceTag",
"is",
"parent"
] |
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
|
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Repository/WorkspaceTagHierarchyRepository.php#L23-L35
|
221,991
|
claroline/CoreBundle
|
Repository/WorkspaceTagHierarchyRepository.php
|
WorkspaceTagHierarchyRepository.findHierarchiesByParent
|
public function findHierarchiesByParent(
User $user,
WorkspaceTag $workspaceTag
)
{
$dql = '
SELECT h
FROM Claroline\CoreBundle\Entity\Workspace\WorkspaceTagHierarchy h
WHERE h.user = :user
AND h.parent = :workspaceTag
';
$query = $this->_em->createQuery($dql);
$query->setParameter('user', $user);
$query->setParameter('workspaceTag', $workspaceTag);
return $query->getResult();
}
|
php
|
public function findHierarchiesByParent(
User $user,
WorkspaceTag $workspaceTag
)
{
$dql = '
SELECT h
FROM Claroline\CoreBundle\Entity\Workspace\WorkspaceTagHierarchy h
WHERE h.user = :user
AND h.parent = :workspaceTag
';
$query = $this->_em->createQuery($dql);
$query->setParameter('user', $user);
$query->setParameter('workspaceTag', $workspaceTag);
return $query->getResult();
}
|
[
"public",
"function",
"findHierarchiesByParent",
"(",
"User",
"$",
"user",
",",
"WorkspaceTag",
"$",
"workspaceTag",
")",
"{",
"$",
"dql",
"=",
"'\n SELECT h\n FROM Claroline\\CoreBundle\\Entity\\Workspace\\WorkspaceTagHierarchy h\n WHERE h.user = :user\n AND h.parent = :workspaceTag\n '",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"_em",
"->",
"createQuery",
"(",
"$",
"dql",
")",
";",
"$",
"query",
"->",
"setParameter",
"(",
"'user'",
",",
"$",
"user",
")",
";",
"$",
"query",
"->",
"setParameter",
"(",
"'workspaceTag'",
",",
"$",
"workspaceTag",
")",
";",
"return",
"$",
"query",
"->",
"getResult",
"(",
")",
";",
"}"
] |
Returns all relations where given workspaceTag is parent
|
[
"Returns",
"all",
"relations",
"where",
"given",
"workspaceTag",
"is",
"parent"
] |
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
|
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Repository/WorkspaceTagHierarchyRepository.php#L40-L56
|
221,992
|
claroline/CoreBundle
|
Repository/GroupRepository.php
|
GroupRepository.findAllGroupsBySearch
|
public function findAllGroupsBySearch($search)
{
$upperSearch = strtoupper(trim($search));
if ($search !== '') {
$dql = '
SELECT g
FROM Claroline\CoreBundle\Entity\Group g
WHERE UPPER(g.name) LIKE :search
';
$query = $this->_em->createQuery($dql);
$query->setParameter('search', "%{$upperSearch}%");
return $query->getResult();
}
return parent::findAll();
}
|
php
|
public function findAllGroupsBySearch($search)
{
$upperSearch = strtoupper(trim($search));
if ($search !== '') {
$dql = '
SELECT g
FROM Claroline\CoreBundle\Entity\Group g
WHERE UPPER(g.name) LIKE :search
';
$query = $this->_em->createQuery($dql);
$query->setParameter('search', "%{$upperSearch}%");
return $query->getResult();
}
return parent::findAll();
}
|
[
"public",
"function",
"findAllGroupsBySearch",
"(",
"$",
"search",
")",
"{",
"$",
"upperSearch",
"=",
"strtoupper",
"(",
"trim",
"(",
"$",
"search",
")",
")",
";",
"if",
"(",
"$",
"search",
"!==",
"''",
")",
"{",
"$",
"dql",
"=",
"'\n SELECT g\n FROM Claroline\\CoreBundle\\Entity\\Group g\n WHERE UPPER(g.name) LIKE :search\n '",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"_em",
"->",
"createQuery",
"(",
"$",
"dql",
")",
";",
"$",
"query",
"->",
"setParameter",
"(",
"'search'",
",",
"\"%{$upperSearch}%\"",
")",
";",
"return",
"$",
"query",
"->",
"getResult",
"(",
")",
";",
"}",
"return",
"parent",
"::",
"findAll",
"(",
")",
";",
"}"
] |
Returns all the groups by search.
@param string $search
@return array[Group]
|
[
"Returns",
"all",
"the",
"groups",
"by",
"search",
"."
] |
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
|
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Repository/GroupRepository.php#L241-L259
|
221,993
|
claroline/CoreBundle
|
Repository/UserRepository.php
|
UserRepository.findByName
|
public function findByName($search, $executeQuery = true, $orderedBy = 'id', $order = null)
{
$upperSearch = strtoupper($search);
$upperSearch = trim($upperSearch);
$upperSearch = preg_replace('/\s+/', ' ', $upperSearch);
$dql = "
SELECT u, r, g FROM Claroline\CoreBundle\Entity\User u
JOIN u.roles r
LEFT JOIN u.groups g
WHERE (
UPPER(u.lastName) LIKE :search
OR UPPER(u.firstName) LIKE :search
OR UPPER(u.username) LIKE :search
OR UPPER(u.administrativeCode) LIKE :search
OR UPPER(u.mail) LIKE :search
OR CONCAT(UPPER(u.firstName), CONCAT(' ', UPPER(u.lastName))) LIKE :search
OR CONCAT(UPPER(u.lastName), CONCAT(' ', UPPER(u.firstName))) LIKE :search
)
AND u.isEnabled = true
AND r.type = 1
ORDER BY u.{$orderedBy} {$order}
";
$query = $this->_em->createQuery($dql);
$query->setParameter('search', "%{$upperSearch}%");
return $executeQuery ? $query->getResult() : $query;
}
|
php
|
public function findByName($search, $executeQuery = true, $orderedBy = 'id', $order = null)
{
$upperSearch = strtoupper($search);
$upperSearch = trim($upperSearch);
$upperSearch = preg_replace('/\s+/', ' ', $upperSearch);
$dql = "
SELECT u, r, g FROM Claroline\CoreBundle\Entity\User u
JOIN u.roles r
LEFT JOIN u.groups g
WHERE (
UPPER(u.lastName) LIKE :search
OR UPPER(u.firstName) LIKE :search
OR UPPER(u.username) LIKE :search
OR UPPER(u.administrativeCode) LIKE :search
OR UPPER(u.mail) LIKE :search
OR CONCAT(UPPER(u.firstName), CONCAT(' ', UPPER(u.lastName))) LIKE :search
OR CONCAT(UPPER(u.lastName), CONCAT(' ', UPPER(u.firstName))) LIKE :search
)
AND u.isEnabled = true
AND r.type = 1
ORDER BY u.{$orderedBy} {$order}
";
$query = $this->_em->createQuery($dql);
$query->setParameter('search', "%{$upperSearch}%");
return $executeQuery ? $query->getResult() : $query;
}
|
[
"public",
"function",
"findByName",
"(",
"$",
"search",
",",
"$",
"executeQuery",
"=",
"true",
",",
"$",
"orderedBy",
"=",
"'id'",
",",
"$",
"order",
"=",
"null",
")",
"{",
"$",
"upperSearch",
"=",
"strtoupper",
"(",
"$",
"search",
")",
";",
"$",
"upperSearch",
"=",
"trim",
"(",
"$",
"upperSearch",
")",
";",
"$",
"upperSearch",
"=",
"preg_replace",
"(",
"'/\\s+/'",
",",
"' '",
",",
"$",
"upperSearch",
")",
";",
"$",
"dql",
"=",
"\"\n SELECT u, r, g FROM Claroline\\CoreBundle\\Entity\\User u\n JOIN u.roles r\n LEFT JOIN u.groups g\n WHERE (\n UPPER(u.lastName) LIKE :search\n OR UPPER(u.firstName) LIKE :search\n OR UPPER(u.username) LIKE :search\n OR UPPER(u.administrativeCode) LIKE :search\n OR UPPER(u.mail) LIKE :search\n OR CONCAT(UPPER(u.firstName), CONCAT(' ', UPPER(u.lastName))) LIKE :search\n OR CONCAT(UPPER(u.lastName), CONCAT(' ', UPPER(u.firstName))) LIKE :search\n )\n AND u.isEnabled = true\n AND r.type = 1\n ORDER BY u.{$orderedBy} {$order}\n \"",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"_em",
"->",
"createQuery",
"(",
"$",
"dql",
")",
";",
"$",
"query",
"->",
"setParameter",
"(",
"'search'",
",",
"\"%{$upperSearch}%\"",
")",
";",
"return",
"$",
"executeQuery",
"?",
"$",
"query",
"->",
"getResult",
"(",
")",
":",
"$",
"query",
";",
"}"
] |
Search users whose first name, last name or username match a given search string.
@param string $search
@param boolean $executeQuery
@param string $orderedBy
@param null $order
@return User[]|Query
|
[
"Search",
"users",
"whose",
"first",
"name",
"last",
"name",
"or",
"username",
"match",
"a",
"given",
"search",
"string",
"."
] |
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
|
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Repository/UserRepository.php#L125-L151
|
221,994
|
claroline/CoreBundle
|
Repository/UserRepository.php
|
UserRepository.findByNameAndGroup
|
public function findByNameAndGroup(
$search,
Group $group,
$executeQuery = true,
$orderedBy = 'id',
$order = 'ASC'
)
{
$dql = "
SELECT DISTINCT u FROM Claroline\CoreBundle\Entity\User u
JOIN u.groups g
WHERE g.id = :groupId
AND (UPPER(u.username) LIKE :search
OR UPPER(u.lastName) LIKE :search
OR UPPER(u.firstName) LIKE :search)
AND u.isEnabled = true
ORDER BY u.{$orderedBy} {$order}
";
$upperSearch = strtoupper($search);
$query = $this->_em->createQuery($dql);
$query->setParameter('search', "%{$upperSearch}%");
$query->setParameter('groupId', $group->getId());
return $executeQuery ? $query->getResult() : $query;
}
|
php
|
public function findByNameAndGroup(
$search,
Group $group,
$executeQuery = true,
$orderedBy = 'id',
$order = 'ASC'
)
{
$dql = "
SELECT DISTINCT u FROM Claroline\CoreBundle\Entity\User u
JOIN u.groups g
WHERE g.id = :groupId
AND (UPPER(u.username) LIKE :search
OR UPPER(u.lastName) LIKE :search
OR UPPER(u.firstName) LIKE :search)
AND u.isEnabled = true
ORDER BY u.{$orderedBy} {$order}
";
$upperSearch = strtoupper($search);
$query = $this->_em->createQuery($dql);
$query->setParameter('search', "%{$upperSearch}%");
$query->setParameter('groupId', $group->getId());
return $executeQuery ? $query->getResult() : $query;
}
|
[
"public",
"function",
"findByNameAndGroup",
"(",
"$",
"search",
",",
"Group",
"$",
"group",
",",
"$",
"executeQuery",
"=",
"true",
",",
"$",
"orderedBy",
"=",
"'id'",
",",
"$",
"order",
"=",
"'ASC'",
")",
"{",
"$",
"dql",
"=",
"\"\n SELECT DISTINCT u FROM Claroline\\CoreBundle\\Entity\\User u\n JOIN u.groups g\n WHERE g.id = :groupId\n AND (UPPER(u.username) LIKE :search\n OR UPPER(u.lastName) LIKE :search\n OR UPPER(u.firstName) LIKE :search)\n AND u.isEnabled = true\n ORDER BY u.{$orderedBy} {$order}\n \"",
";",
"$",
"upperSearch",
"=",
"strtoupper",
"(",
"$",
"search",
")",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"_em",
"->",
"createQuery",
"(",
"$",
"dql",
")",
";",
"$",
"query",
"->",
"setParameter",
"(",
"'search'",
",",
"\"%{$upperSearch}%\"",
")",
";",
"$",
"query",
"->",
"setParameter",
"(",
"'groupId'",
",",
"$",
"group",
"->",
"getId",
"(",
")",
")",
";",
"return",
"$",
"executeQuery",
"?",
"$",
"query",
"->",
"getResult",
"(",
")",
":",
"$",
"query",
";",
"}"
] |
Returns the users of a group whose first name, last name or username match
a given search string.
@param string $search
@param Group $group
@param boolean $executeQuery
@param string $orderedBy
@return User[]|Query
|
[
"Returns",
"the",
"users",
"of",
"a",
"group",
"whose",
"first",
"name",
"last",
"name",
"or",
"username",
"match",
"a",
"given",
"search",
"string",
"."
] |
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
|
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Repository/UserRepository.php#L193-L217
|
221,995
|
claroline/CoreBundle
|
Repository/UserRepository.php
|
UserRepository.findUsersByWorkspacesAndSearch
|
public function findUsersByWorkspacesAndSearch(array $workspaces, $search)
{
$upperSearch = strtoupper(trim($search));
$dql = '
SELECT DISTINCT u FROM Claroline\CoreBundle\Entity\User u
JOIN u.roles wr
LEFT JOIN u.groups g
LEFT JOIN g.roles gr
LEFT JOIN gr.workspace gw
LEFT JOIN wr.workspace w
WHERE (
w IN (:workspaces) OR
gw IN (:workspaces)
)
AND (
UPPER(u.firstName) LIKE :search
OR UPPER(u.lastName) LIKE :search
OR UPPER(u.username) LIKE :search
)
AND u.isEnabled = true
ORDER BY u.id
';
$query = $this->_em->createQuery($dql);
$query->setParameter('workspaces', $workspaces);
$query->setParameter('search', "%{$upperSearch}%");
return $query->getResult();
}
|
php
|
public function findUsersByWorkspacesAndSearch(array $workspaces, $search)
{
$upperSearch = strtoupper(trim($search));
$dql = '
SELECT DISTINCT u FROM Claroline\CoreBundle\Entity\User u
JOIN u.roles wr
LEFT JOIN u.groups g
LEFT JOIN g.roles gr
LEFT JOIN gr.workspace gw
LEFT JOIN wr.workspace w
WHERE (
w IN (:workspaces) OR
gw IN (:workspaces)
)
AND (
UPPER(u.firstName) LIKE :search
OR UPPER(u.lastName) LIKE :search
OR UPPER(u.username) LIKE :search
)
AND u.isEnabled = true
ORDER BY u.id
';
$query = $this->_em->createQuery($dql);
$query->setParameter('workspaces', $workspaces);
$query->setParameter('search', "%{$upperSearch}%");
return $query->getResult();
}
|
[
"public",
"function",
"findUsersByWorkspacesAndSearch",
"(",
"array",
"$",
"workspaces",
",",
"$",
"search",
")",
"{",
"$",
"upperSearch",
"=",
"strtoupper",
"(",
"trim",
"(",
"$",
"search",
")",
")",
";",
"$",
"dql",
"=",
"'\n SELECT DISTINCT u FROM Claroline\\CoreBundle\\Entity\\User u\n JOIN u.roles wr\n LEFT JOIN u.groups g\n LEFT JOIN g.roles gr\n LEFT JOIN gr.workspace gw\n LEFT JOIN wr.workspace w\n WHERE (\n w IN (:workspaces) OR\n gw IN (:workspaces)\n )\n AND (\n UPPER(u.firstName) LIKE :search\n OR UPPER(u.lastName) LIKE :search\n OR UPPER(u.username) LIKE :search\n )\n AND u.isEnabled = true\n ORDER BY u.id\n '",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"_em",
"->",
"createQuery",
"(",
"$",
"dql",
")",
";",
"$",
"query",
"->",
"setParameter",
"(",
"'workspaces'",
",",
"$",
"workspaces",
")",
";",
"$",
"query",
"->",
"setParameter",
"(",
"'search'",
",",
"\"%{$upperSearch}%\"",
")",
";",
"return",
"$",
"query",
"->",
"getResult",
"(",
")",
";",
"}"
] |
Returns the users who are members of one of the given workspaces.
User list is filtered by a search on first name, last name and username
@param array $workspaces
@param string $search
@return User[]
|
[
"Returns",
"the",
"users",
"who",
"are",
"members",
"of",
"one",
"of",
"the",
"given",
"workspaces",
".",
"User",
"list",
"is",
"filtered",
"by",
"a",
"search",
"on",
"first",
"name",
"last",
"name",
"and",
"username"
] |
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
|
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Repository/UserRepository.php#L289-L317
|
221,996
|
claroline/CoreBundle
|
Repository/UserRepository.php
|
UserRepository.countUsersByRole
|
public function countUsersByRole($role, $restrictionRoleNames)
{
$qb = $this->createQueryBuilder('user')
->select('COUNT(DISTINCT user.id)')
->leftJoin('user.roles', 'roles')
->andWhere('roles.id = :roleId')
->setParameter('roleId', $role->getId());
if (!empty($restrictionRoleNames)) {
$qb->andWhere('user.id NOT IN (:userIds)')
->setParameter('userIds', $this->findUserIdsInRoles($restrictionRoleNames));
}
$query = $qb->getQuery();
return $query->getSingleScalarResult();
}
|
php
|
public function countUsersByRole($role, $restrictionRoleNames)
{
$qb = $this->createQueryBuilder('user')
->select('COUNT(DISTINCT user.id)')
->leftJoin('user.roles', 'roles')
->andWhere('roles.id = :roleId')
->setParameter('roleId', $role->getId());
if (!empty($restrictionRoleNames)) {
$qb->andWhere('user.id NOT IN (:userIds)')
->setParameter('userIds', $this->findUserIdsInRoles($restrictionRoleNames));
}
$query = $qb->getQuery();
return $query->getSingleScalarResult();
}
|
[
"public",
"function",
"countUsersByRole",
"(",
"$",
"role",
",",
"$",
"restrictionRoleNames",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'user'",
")",
"->",
"select",
"(",
"'COUNT(DISTINCT user.id)'",
")",
"->",
"leftJoin",
"(",
"'user.roles'",
",",
"'roles'",
")",
"->",
"andWhere",
"(",
"'roles.id = :roleId'",
")",
"->",
"setParameter",
"(",
"'roleId'",
",",
"$",
"role",
"->",
"getId",
"(",
")",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"restrictionRoleNames",
")",
")",
"{",
"$",
"qb",
"->",
"andWhere",
"(",
"'user.id NOT IN (:userIds)'",
")",
"->",
"setParameter",
"(",
"'userIds'",
",",
"$",
"this",
"->",
"findUserIdsInRoles",
"(",
"$",
"restrictionRoleNames",
")",
")",
";",
"}",
"$",
"query",
"=",
"$",
"qb",
"->",
"getQuery",
"(",
")",
";",
"return",
"$",
"query",
"->",
"getSingleScalarResult",
"(",
")",
";",
"}"
] |
Counts the users subscribed in a platform role
@param $role
@param $restrictionRoleNames
@return integer
|
[
"Counts",
"the",
"users",
"subscribed",
"in",
"a",
"platform",
"role"
] |
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
|
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Repository/UserRepository.php#L408-L422
|
221,997
|
claroline/CoreBundle
|
Repository/UserRepository.php
|
UserRepository.findUserIdsInRoles
|
public function findUserIdsInRoles($roleNames)
{
$qb = $this->createQueryBuilder('user')
->select('user.id')
->leftJoin('user.roles', 'roles')
->andWhere('roles.name IN (:roleNames)')
->andWhere('user.isEnabled = true')
->setParameter('roleNames', $roleNames);
$query = $qb->getQuery();
return $query->getArrayResult();
}
|
php
|
public function findUserIdsInRoles($roleNames)
{
$qb = $this->createQueryBuilder('user')
->select('user.id')
->leftJoin('user.roles', 'roles')
->andWhere('roles.name IN (:roleNames)')
->andWhere('user.isEnabled = true')
->setParameter('roleNames', $roleNames);
$query = $qb->getQuery();
return $query->getArrayResult();
}
|
[
"public",
"function",
"findUserIdsInRoles",
"(",
"$",
"roleNames",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'user'",
")",
"->",
"select",
"(",
"'user.id'",
")",
"->",
"leftJoin",
"(",
"'user.roles'",
",",
"'roles'",
")",
"->",
"andWhere",
"(",
"'roles.name IN (:roleNames)'",
")",
"->",
"andWhere",
"(",
"'user.isEnabled = true'",
")",
"->",
"setParameter",
"(",
"'roleNames'",
",",
"$",
"roleNames",
")",
";",
"$",
"query",
"=",
"$",
"qb",
"->",
"getQuery",
"(",
")",
";",
"return",
"$",
"query",
"->",
"getArrayResult",
"(",
")",
";",
"}"
] |
Returns user Ids that are subscribed to one of the roles given
@param array $roleNames
@return array
|
[
"Returns",
"user",
"Ids",
"that",
"are",
"subscribed",
"to",
"one",
"of",
"the",
"roles",
"given"
] |
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
|
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Repository/UserRepository.php#L429-L440
|
221,998
|
claroline/CoreBundle
|
Repository/UserRepository.php
|
UserRepository.findGroupOutsidersByName
|
public function findGroupOutsidersByName(Group $group, $search, $executeQuery = true, $orderedBy = 'id')
{
$dql = "
SELECT DISTINCT u FROM Claroline\CoreBundle\Entity\User u
WHERE (
UPPER(u.lastName) LIKE :search
OR UPPER(u.firstName) LIKE :search
OR UPPER(u.lastName) LIKE :search
)
AND u NOT IN (
SELECT us FROM Claroline\CoreBundle\Entity\User us
JOIN us.groups gr
WHERE gr.id = :groupId
)
AND u.isEnabled = true
ORDER BY u.{$orderedBy}
";
$search = strtoupper($search);
$query = $this->_em->createQuery($dql);
$query->setParameter('groupId', $group->getId());
$query->setParameter('search', "%{$search}%");
return $executeQuery ? $query->getResult() : $query;
}
|
php
|
public function findGroupOutsidersByName(Group $group, $search, $executeQuery = true, $orderedBy = 'id')
{
$dql = "
SELECT DISTINCT u FROM Claroline\CoreBundle\Entity\User u
WHERE (
UPPER(u.lastName) LIKE :search
OR UPPER(u.firstName) LIKE :search
OR UPPER(u.lastName) LIKE :search
)
AND u NOT IN (
SELECT us FROM Claroline\CoreBundle\Entity\User us
JOIN us.groups gr
WHERE gr.id = :groupId
)
AND u.isEnabled = true
ORDER BY u.{$orderedBy}
";
$search = strtoupper($search);
$query = $this->_em->createQuery($dql);
$query->setParameter('groupId', $group->getId());
$query->setParameter('search', "%{$search}%");
return $executeQuery ? $query->getResult() : $query;
}
|
[
"public",
"function",
"findGroupOutsidersByName",
"(",
"Group",
"$",
"group",
",",
"$",
"search",
",",
"$",
"executeQuery",
"=",
"true",
",",
"$",
"orderedBy",
"=",
"'id'",
")",
"{",
"$",
"dql",
"=",
"\"\n SELECT DISTINCT u FROM Claroline\\CoreBundle\\Entity\\User u\n WHERE (\n UPPER(u.lastName) LIKE :search\n OR UPPER(u.firstName) LIKE :search\n OR UPPER(u.lastName) LIKE :search\n )\n AND u NOT IN (\n SELECT us FROM Claroline\\CoreBundle\\Entity\\User us\n JOIN us.groups gr\n WHERE gr.id = :groupId\n )\n AND u.isEnabled = true\n ORDER BY u.{$orderedBy}\n \"",
";",
"$",
"search",
"=",
"strtoupper",
"(",
"$",
"search",
")",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"_em",
"->",
"createQuery",
"(",
"$",
"dql",
")",
";",
"$",
"query",
"->",
"setParameter",
"(",
"'groupId'",
",",
"$",
"group",
"->",
"getId",
"(",
")",
")",
";",
"$",
"query",
"->",
"setParameter",
"(",
"'search'",
",",
"\"%{$search}%\"",
")",
";",
"return",
"$",
"executeQuery",
"?",
"$",
"query",
"->",
"getResult",
"(",
")",
":",
"$",
"query",
";",
"}"
] |
Returns the users who are not members of a group and whose first name, last
name or username match a given search string.
@param \Claroline\CoreBundle\Entity\Group $group
@param string $search
@param boolean $executeQuery
@param string $orderedBy
@return User[]|Query
@todo Find out why the join on profile preferences is necessary
|
[
"Returns",
"the",
"users",
"who",
"are",
"not",
"members",
"of",
"a",
"group",
"and",
"whose",
"first",
"name",
"last",
"name",
"or",
"username",
"match",
"a",
"given",
"search",
"string",
"."
] |
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
|
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Repository/UserRepository.php#L1513-L1535
|
221,999
|
claroline/CoreBundle
|
Entity/User.php
|
User.setPlatformRoles
|
public function setPlatformRoles($platformRoles)
{
$roles = $this->getEntityRoles();
$removedRoles = array();
foreach ($roles as $role) {
if ($role->getType() != Role::WS_ROLE) {
$removedRoles[] = $role;
}
}
foreach ($removedRoles as $removedRole) {
$this->roles->removeElement($removedRole);
}
foreach ($platformRoles as $platformRole) {
$this->roles->add($platformRole);
}
}
|
php
|
public function setPlatformRoles($platformRoles)
{
$roles = $this->getEntityRoles();
$removedRoles = array();
foreach ($roles as $role) {
if ($role->getType() != Role::WS_ROLE) {
$removedRoles[] = $role;
}
}
foreach ($removedRoles as $removedRole) {
$this->roles->removeElement($removedRole);
}
foreach ($platformRoles as $platformRole) {
$this->roles->add($platformRole);
}
}
|
[
"public",
"function",
"setPlatformRoles",
"(",
"$",
"platformRoles",
")",
"{",
"$",
"roles",
"=",
"$",
"this",
"->",
"getEntityRoles",
"(",
")",
";",
"$",
"removedRoles",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"roles",
"as",
"$",
"role",
")",
"{",
"if",
"(",
"$",
"role",
"->",
"getType",
"(",
")",
"!=",
"Role",
"::",
"WS_ROLE",
")",
"{",
"$",
"removedRoles",
"[",
"]",
"=",
"$",
"role",
";",
"}",
"}",
"foreach",
"(",
"$",
"removedRoles",
"as",
"$",
"removedRole",
")",
"{",
"$",
"this",
"->",
"roles",
"->",
"removeElement",
"(",
"$",
"removedRole",
")",
";",
"}",
"foreach",
"(",
"$",
"platformRoles",
"as",
"$",
"platformRole",
")",
"{",
"$",
"this",
"->",
"roles",
"->",
"add",
"(",
"$",
"platformRole",
")",
";",
"}",
"}"
] |
Replace the old platform roles of a user by a new array.
@param $platformRoles
|
[
"Replace",
"the",
"old",
"platform",
"roles",
"of",
"a",
"user",
"by",
"a",
"new",
"array",
"."
] |
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
|
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Entity/User.php#L840-L858
|
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.