repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
| partition
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
Bynder/bynder-php-sdk | src/Bynder/Api/Impl/Upload/FileUploader.php | FileUploader.uploadChunkIterator | public function uploadChunkIterator($file, $filePath, $uploadRequestInfo, $numberOfChunks, &$chunkNumber)
{
while ($chunk = fread($file, self::CHUNK_SIZE)) {
$chunkNumber++;
yield $this->uploadChunkAsync($filePath, $chunk, $uploadRequestInfo, $numberOfChunks, $chunkNumber);
}
} | php | public function uploadChunkIterator($file, $filePath, $uploadRequestInfo, $numberOfChunks, &$chunkNumber)
{
while ($chunk = fread($file, self::CHUNK_SIZE)) {
$chunkNumber++;
yield $this->uploadChunkAsync($filePath, $chunk, $uploadRequestInfo, $numberOfChunks, $chunkNumber);
}
} | [
"public",
"function",
"uploadChunkIterator",
"(",
"$",
"file",
",",
"$",
"filePath",
",",
"$",
"uploadRequestInfo",
",",
"$",
"numberOfChunks",
",",
"&",
"$",
"chunkNumber",
")",
"{",
"while",
"(",
"$",
"chunk",
"=",
"fread",
"(",
"$",
"file",
",",
"self",
"::",
"CHUNK_SIZE",
")",
")",
"{",
"$",
"chunkNumber",
"++",
";",
"yield",
"$",
"this",
"->",
"uploadChunkAsync",
"(",
"$",
"filePath",
",",
"$",
"chunk",
",",
"$",
"uploadRequestInfo",
",",
"$",
"numberOfChunks",
",",
"$",
"chunkNumber",
")",
";",
"}",
"}"
]
| Iterator function used to control how many file upload promises are sent out.
@param $file
@param $filePath
@param $uploadRequestInfo
@param $numberOfChunks
@param $chunkNumber
@return \Generator A promise representing a chunk file upload. | [
"Iterator",
"function",
"used",
"to",
"control",
"how",
"many",
"file",
"upload",
"promises",
"are",
"sent",
"out",
"."
]
| 1ba47afff4c986d91a473b69183d4aa35fd913b6 | https://github.com/Bynder/bynder-php-sdk/blob/1ba47afff4c986d91a473b69183d4aa35fd913b6/src/Bynder/Api/Impl/Upload/FileUploader.php#L173-L179 | train |
Bynder/bynder-php-sdk | src/Bynder/Api/Impl/Upload/FileUploader.php | FileUploader.uploadChunkAsync | private function uploadChunkAsync($filePath, $chunk, $uploadRequestInfo, $numberOfChunks, $chunkNumber)
{
return $this->amazonApi->uploadPartToAmazon($filePath, $this->awsBucket, $uploadRequestInfo,
$chunkNumber, $chunk, $numberOfChunks)
->then(
function () use ($uploadRequestInfo, $chunkNumber) {
return $this->registerChunkAsync($uploadRequestInfo, $chunkNumber);
}
);
} | php | private function uploadChunkAsync($filePath, $chunk, $uploadRequestInfo, $numberOfChunks, $chunkNumber)
{
return $this->amazonApi->uploadPartToAmazon($filePath, $this->awsBucket, $uploadRequestInfo,
$chunkNumber, $chunk, $numberOfChunks)
->then(
function () use ($uploadRequestInfo, $chunkNumber) {
return $this->registerChunkAsync($uploadRequestInfo, $chunkNumber);
}
);
} | [
"private",
"function",
"uploadChunkAsync",
"(",
"$",
"filePath",
",",
"$",
"chunk",
",",
"$",
"uploadRequestInfo",
",",
"$",
"numberOfChunks",
",",
"$",
"chunkNumber",
")",
"{",
"return",
"$",
"this",
"->",
"amazonApi",
"->",
"uploadPartToAmazon",
"(",
"$",
"filePath",
",",
"$",
"this",
"->",
"awsBucket",
",",
"$",
"uploadRequestInfo",
",",
"$",
"chunkNumber",
",",
"$",
"chunk",
",",
"$",
"numberOfChunks",
")",
"->",
"then",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"uploadRequestInfo",
",",
"$",
"chunkNumber",
")",
"{",
"return",
"$",
"this",
"->",
"registerChunkAsync",
"(",
"$",
"uploadRequestInfo",
",",
"$",
"chunkNumber",
")",
";",
"}",
")",
";",
"}"
]
| The upload chunk logic function. Gets the closest Amazon endpoint, uploads the chunk to Amazon and registers it
in Bynder.
@param $filePath
@param $chunk
@param $uploadRequestInfo
@param $numberOfChunks
@param $chunkNumber
@return Promise\PromiseInterface|Promise\FulfilledPromise Value returned not used for next steps, just need to make sure it works. | [
"The",
"upload",
"chunk",
"logic",
"function",
".",
"Gets",
"the",
"closest",
"Amazon",
"endpoint",
"uploads",
"the",
"chunk",
"to",
"Amazon",
"and",
"registers",
"it",
"in",
"Bynder",
"."
]
| 1ba47afff4c986d91a473b69183d4aa35fd913b6 | https://github.com/Bynder/bynder-php-sdk/blob/1ba47afff4c986d91a473b69183d4aa35fd913b6/src/Bynder/Api/Impl/Upload/FileUploader.php#L210-L219 | train |
Bynder/bynder-php-sdk | src/Bynder/Api/Impl/Upload/FileUploader.php | FileUploader.getClosestUploadEndpoint | private function getClosestUploadEndpoint()
{
if (isset($this->awsBucket)) {
return new Promise\FulfilledPromise($this->awsBucket);
} else {
return $this->requestHandler->sendRequestAsync('GET', 'api/upload/endpoint')
->then(
function ($result) {
$this->awsBucket = $result;
return $result;
});
}
} | php | private function getClosestUploadEndpoint()
{
if (isset($this->awsBucket)) {
return new Promise\FulfilledPromise($this->awsBucket);
} else {
return $this->requestHandler->sendRequestAsync('GET', 'api/upload/endpoint')
->then(
function ($result) {
$this->awsBucket = $result;
return $result;
});
}
} | [
"private",
"function",
"getClosestUploadEndpoint",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"awsBucket",
")",
")",
"{",
"return",
"new",
"Promise",
"\\",
"FulfilledPromise",
"(",
"$",
"this",
"->",
"awsBucket",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"requestHandler",
"->",
"sendRequestAsync",
"(",
"'GET'",
",",
"'api/upload/endpoint'",
")",
"->",
"then",
"(",
"function",
"(",
"$",
"result",
")",
"{",
"$",
"this",
"->",
"awsBucket",
"=",
"$",
"result",
";",
"return",
"$",
"result",
";",
"}",
")",
";",
"}",
"}"
]
| Gets the closest Amazon S3 bucket location to upload to.
@return Promise\FulfilledPromise Amazon S3 location url.
@throws Exception | [
"Gets",
"the",
"closest",
"Amazon",
"S3",
"bucket",
"location",
"to",
"upload",
"to",
"."
]
| 1ba47afff4c986d91a473b69183d4aa35fd913b6 | https://github.com/Bynder/bynder-php-sdk/blob/1ba47afff4c986d91a473b69183d4aa35fd913b6/src/Bynder/Api/Impl/Upload/FileUploader.php#L227-L239 | train |
Bynder/bynder-php-sdk | src/Bynder/Api/Impl/Upload/FileUploader.php | FileUploader.registerChunkAsync | private function registerChunkAsync($uploadRequestInfo, $chunkNumber)
{
$s3Filename = sprintf("%s/p%d", $uploadRequestInfo['s3_filename'], $chunkNumber);
$data = [
'id' => $uploadRequestInfo['s3file']['uploadid'],
'targetid' => $uploadRequestInfo['s3file']['targetid'],
'filename' => $s3Filename,
'chunkNumber' => $chunkNumber,
];
return $this->requestHandler->sendRequestAsync(
'POST',
sprintf('api/v4/upload/%s/', $uploadRequestInfo['s3file']['uploadid']),
['form_params' => $data]
);
} | php | private function registerChunkAsync($uploadRequestInfo, $chunkNumber)
{
$s3Filename = sprintf("%s/p%d", $uploadRequestInfo['s3_filename'], $chunkNumber);
$data = [
'id' => $uploadRequestInfo['s3file']['uploadid'],
'targetid' => $uploadRequestInfo['s3file']['targetid'],
'filename' => $s3Filename,
'chunkNumber' => $chunkNumber,
];
return $this->requestHandler->sendRequestAsync(
'POST',
sprintf('api/v4/upload/%s/', $uploadRequestInfo['s3file']['uploadid']),
['form_params' => $data]
);
} | [
"private",
"function",
"registerChunkAsync",
"(",
"$",
"uploadRequestInfo",
",",
"$",
"chunkNumber",
")",
"{",
"$",
"s3Filename",
"=",
"sprintf",
"(",
"\"%s/p%d\"",
",",
"$",
"uploadRequestInfo",
"[",
"'s3_filename'",
"]",
",",
"$",
"chunkNumber",
")",
";",
"$",
"data",
"=",
"[",
"'id'",
"=>",
"$",
"uploadRequestInfo",
"[",
"'s3file'",
"]",
"[",
"'uploadid'",
"]",
",",
"'targetid'",
"=>",
"$",
"uploadRequestInfo",
"[",
"'s3file'",
"]",
"[",
"'targetid'",
"]",
",",
"'filename'",
"=>",
"$",
"s3Filename",
",",
"'chunkNumber'",
"=>",
"$",
"chunkNumber",
",",
"]",
";",
"return",
"$",
"this",
"->",
"requestHandler",
"->",
"sendRequestAsync",
"(",
"'POST'",
",",
"sprintf",
"(",
"'api/v4/upload/%s/'",
",",
"$",
"uploadRequestInfo",
"[",
"'s3file'",
"]",
"[",
"'uploadid'",
"]",
")",
",",
"[",
"'form_params'",
"=>",
"$",
"data",
"]",
")",
";",
"}"
]
| Registers a temporary chunk in Bynder.
@param $uploadRequestInfo
@param $chunkNumber
@return Promise\Promise
@throws Exception | [
"Registers",
"a",
"temporary",
"chunk",
"in",
"Bynder",
"."
]
| 1ba47afff4c986d91a473b69183d4aa35fd913b6 | https://github.com/Bynder/bynder-php-sdk/blob/1ba47afff4c986d91a473b69183d4aa35fd913b6/src/Bynder/Api/Impl/Upload/FileUploader.php#L250-L265 | train |
Bynder/bynder-php-sdk | src/Bynder/Api/Impl/Upload/FileUploader.php | FileUploader.hasFinishedSuccessfullyAsync | private function hasFinishedSuccessfullyAsync($finalizeResponse)
{
// Again using an Iterator function to generate the threads.
$promises = $this->pollStatusIterator($finalizeResponse);
$eachPromises = new Promise\EachPromise($promises, [
'concurrency' => 1,
'fulfilled' => function ($pollStatus, $i, $promise) {
if ($pollStatus != null) {
if (!empty($pollStatus['itemsDone'])) {
$promise->resolve($pollStatus['itemsDone']);
}
if (!empty($pollStatus['itemsFailed'])) {
$promise->resolve(false);
}
}
return false;
}
]);
return $eachPromises->promise();
} | php | private function hasFinishedSuccessfullyAsync($finalizeResponse)
{
// Again using an Iterator function to generate the threads.
$promises = $this->pollStatusIterator($finalizeResponse);
$eachPromises = new Promise\EachPromise($promises, [
'concurrency' => 1,
'fulfilled' => function ($pollStatus, $i, $promise) {
if ($pollStatus != null) {
if (!empty($pollStatus['itemsDone'])) {
$promise->resolve($pollStatus['itemsDone']);
}
if (!empty($pollStatus['itemsFailed'])) {
$promise->resolve(false);
}
}
return false;
}
]);
return $eachPromises->promise();
} | [
"private",
"function",
"hasFinishedSuccessfullyAsync",
"(",
"$",
"finalizeResponse",
")",
"{",
"// Again using an Iterator function to generate the threads.",
"$",
"promises",
"=",
"$",
"this",
"->",
"pollStatusIterator",
"(",
"$",
"finalizeResponse",
")",
";",
"$",
"eachPromises",
"=",
"new",
"Promise",
"\\",
"EachPromise",
"(",
"$",
"promises",
",",
"[",
"'concurrency'",
"=>",
"1",
",",
"'fulfilled'",
"=>",
"function",
"(",
"$",
"pollStatus",
",",
"$",
"i",
",",
"$",
"promise",
")",
"{",
"if",
"(",
"$",
"pollStatus",
"!=",
"null",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"pollStatus",
"[",
"'itemsDone'",
"]",
")",
")",
"{",
"$",
"promise",
"->",
"resolve",
"(",
"$",
"pollStatus",
"[",
"'itemsDone'",
"]",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"pollStatus",
"[",
"'itemsFailed'",
"]",
")",
")",
"{",
"$",
"promise",
"->",
"resolve",
"(",
"false",
")",
";",
"}",
"}",
"return",
"false",
";",
"}",
"]",
")",
";",
"return",
"$",
"eachPromises",
"->",
"promise",
"(",
")",
";",
"}"
]
| Polls Bynder to confirm all chunks were uploaded and registered successfully in Bynder.
@param $finalizeResponse
@return Promise\Promise Returns whether or not the file was uploaded successfully.
@throws Exception | [
"Polls",
"Bynder",
"to",
"confirm",
"all",
"chunks",
"were",
"uploaded",
"and",
"registered",
"successfully",
"in",
"Bynder",
"."
]
| 1ba47afff4c986d91a473b69183d4aa35fd913b6 | https://github.com/Bynder/bynder-php-sdk/blob/1ba47afff4c986d91a473b69183d4aa35fd913b6/src/Bynder/Api/Impl/Upload/FileUploader.php#L301-L320 | train |
Bynder/bynder-php-sdk | src/Bynder/Api/Impl/Upload/FileUploader.php | FileUploader.pollStatusIterator | public function pollStatusIterator($finalizeResponse)
{
$iterations = 0;
while ($iterations < self::MAX_POLLING_ITERATIONS) {
$delay = $iterations == 0 ? 0 : self::POLLING_IDLE_TIME;
yield $this->pollStatusAsync(['items' => $finalizeResponse['importId']], $delay);
$iterations++;
}
} | php | public function pollStatusIterator($finalizeResponse)
{
$iterations = 0;
while ($iterations < self::MAX_POLLING_ITERATIONS) {
$delay = $iterations == 0 ? 0 : self::POLLING_IDLE_TIME;
yield $this->pollStatusAsync(['items' => $finalizeResponse['importId']], $delay);
$iterations++;
}
} | [
"public",
"function",
"pollStatusIterator",
"(",
"$",
"finalizeResponse",
")",
"{",
"$",
"iterations",
"=",
"0",
";",
"while",
"(",
"$",
"iterations",
"<",
"self",
"::",
"MAX_POLLING_ITERATIONS",
")",
"{",
"$",
"delay",
"=",
"$",
"iterations",
"==",
"0",
"?",
"0",
":",
"self",
"::",
"POLLING_IDLE_TIME",
";",
"yield",
"$",
"this",
"->",
"pollStatusAsync",
"(",
"[",
"'items'",
"=>",
"$",
"finalizeResponse",
"[",
"'importId'",
"]",
"]",
",",
"$",
"delay",
")",
";",
"$",
"iterations",
"++",
";",
"}",
"}"
]
| Generates polling promises, sleeping between each request and limiting it to 1 thread to make sure enough time
passes after file upload.
@param $finalizeResponse
@return \Generator
@throws Exception | [
"Generates",
"polling",
"promises",
"sleeping",
"between",
"each",
"request",
"and",
"limiting",
"it",
"to",
"1",
"thread",
"to",
"make",
"sure",
"enough",
"time",
"passes",
"after",
"file",
"upload",
"."
]
| 1ba47afff4c986d91a473b69183d4aa35fd913b6 | https://github.com/Bynder/bynder-php-sdk/blob/1ba47afff4c986d91a473b69183d4aa35fd913b6/src/Bynder/Api/Impl/Upload/FileUploader.php#L331-L339 | train |
Bynder/bynder-php-sdk | src/Bynder/Api/Impl/Upload/FileUploader.php | FileUploader.saveMediaAsync | private function saveMediaAsync($data)
{
$uri = "api/v4/media/save/";
if (isset($data['mediaId'])) {
$uri = sprintf("api/v4/media/" . $data['mediaId'] . "/save/");
unset($data['mediaId']);
}
return $this->requestHandler->sendRequestAsync('POST', $uri, ['form_params' => $data]);
} | php | private function saveMediaAsync($data)
{
$uri = "api/v4/media/save/";
if (isset($data['mediaId'])) {
$uri = sprintf("api/v4/media/" . $data['mediaId'] . "/save/");
unset($data['mediaId']);
}
return $this->requestHandler->sendRequestAsync('POST', $uri, ['form_params' => $data]);
} | [
"private",
"function",
"saveMediaAsync",
"(",
"$",
"data",
")",
"{",
"$",
"uri",
"=",
"\"api/v4/media/save/\"",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'mediaId'",
"]",
")",
")",
"{",
"$",
"uri",
"=",
"sprintf",
"(",
"\"api/v4/media/\"",
".",
"$",
"data",
"[",
"'mediaId'",
"]",
".",
"\"/save/\"",
")",
";",
"unset",
"(",
"$",
"data",
"[",
"'mediaId'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"requestHandler",
"->",
"sendRequestAsync",
"(",
"'POST'",
",",
"$",
"uri",
",",
"[",
"'form_params'",
"=>",
"$",
"data",
"]",
")",
";",
"}"
]
| Saves the file in the Bynder Asset Bank. This can be either a new or existing file, depending on whether or not
the mediaId parameter is passed.
@param array $data Array of relevant file upload data, such as uploadId and brandId.
@return Promise\Promise The information of the uploaded file, including IDs and all final file urls.
@throws Exception | [
"Saves",
"the",
"file",
"in",
"the",
"Bynder",
"Asset",
"Bank",
".",
"This",
"can",
"be",
"either",
"a",
"new",
"or",
"existing",
"file",
"depending",
"on",
"whether",
"or",
"not",
"the",
"mediaId",
"parameter",
"is",
"passed",
"."
]
| 1ba47afff4c986d91a473b69183d4aa35fd913b6 | https://github.com/Bynder/bynder-php-sdk/blob/1ba47afff4c986d91a473b69183d4aa35fd913b6/src/Bynder/Api/Impl/Upload/FileUploader.php#L369-L377 | train |
nuvoleweb/drupal-behat | src/DrupalExtension/Context/ContentContext.php | ContentContext.visitContentPage | protected function visitContentPage($op, $type, $title) {
$nid = $this->getCore()->getEntityIdByLabel('node', $type, $title);
$path = [
'view' => "node/$nid",
'edit' => "node/$nid/edit",
'delete' => "node/$nid/delete",
];
$this->visitPath($path[$op]);
} | php | protected function visitContentPage($op, $type, $title) {
$nid = $this->getCore()->getEntityIdByLabel('node', $type, $title);
$path = [
'view' => "node/$nid",
'edit' => "node/$nid/edit",
'delete' => "node/$nid/delete",
];
$this->visitPath($path[$op]);
} | [
"protected",
"function",
"visitContentPage",
"(",
"$",
"op",
",",
"$",
"type",
",",
"$",
"title",
")",
"{",
"$",
"nid",
"=",
"$",
"this",
"->",
"getCore",
"(",
")",
"->",
"getEntityIdByLabel",
"(",
"'node'",
",",
"$",
"type",
",",
"$",
"title",
")",
";",
"$",
"path",
"=",
"[",
"'view'",
"=>",
"\"node/$nid\"",
",",
"'edit'",
"=>",
"\"node/$nid/edit\"",
",",
"'delete'",
"=>",
"\"node/$nid/delete\"",
",",
"]",
";",
"$",
"this",
"->",
"visitPath",
"(",
"$",
"path",
"[",
"$",
"op",
"]",
")",
";",
"}"
]
| Provides a common step definition callback for node pages.
@param string $op
The operation being performed: 'view', 'edit', 'delete'.
@param string $type
The node type either as id or as label.
@param string $title
The node title. | [
"Provides",
"a",
"common",
"step",
"definition",
"callback",
"for",
"node",
"pages",
"."
]
| 0d6cc3f438a6c38c33abc8a059c5f7eead8713c8 | https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/ContentContext.php#L71-L79 | train |
nuvoleweb/drupal-behat | src/DrupalExtension/Context/ContentContext.php | ContentContext.userCanContent | public function userCanContent($name, $op, $title) {
$op = strtr($op, ['edit' => 'update']);
$node = $this->getCore()->loadNodeByName($title);
$access = $this->getCore()->nodeAccess($op, $name, $node);
if (!$access) {
throw new \Exception("{$name} cannot {$op} '{$title}' but it is supposed to.");
}
} | php | public function userCanContent($name, $op, $title) {
$op = strtr($op, ['edit' => 'update']);
$node = $this->getCore()->loadNodeByName($title);
$access = $this->getCore()->nodeAccess($op, $name, $node);
if (!$access) {
throw new \Exception("{$name} cannot {$op} '{$title}' but it is supposed to.");
}
} | [
"public",
"function",
"userCanContent",
"(",
"$",
"name",
",",
"$",
"op",
",",
"$",
"title",
")",
"{",
"$",
"op",
"=",
"strtr",
"(",
"$",
"op",
",",
"[",
"'edit'",
"=>",
"'update'",
"]",
")",
";",
"$",
"node",
"=",
"$",
"this",
"->",
"getCore",
"(",
")",
"->",
"loadNodeByName",
"(",
"$",
"title",
")",
";",
"$",
"access",
"=",
"$",
"this",
"->",
"getCore",
"(",
")",
"->",
"nodeAccess",
"(",
"$",
"op",
",",
"$",
"name",
",",
"$",
"node",
")",
";",
"if",
"(",
"!",
"$",
"access",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"{$name} cannot {$op} '{$title}' but it is supposed to.\"",
")",
";",
"}",
"}"
]
| Assert that given user can perform given operation on given content.
@param string $name
User name.
@param string $op
Operation: view, edit or delete.
@param string $title
Content title.
@throws \Exception
If user cannot perform given operation on given content.
@Then :name can :op content :content
@Then :name can :op :content content | [
"Assert",
"that",
"given",
"user",
"can",
"perform",
"given",
"operation",
"on",
"given",
"content",
"."
]
| 0d6cc3f438a6c38c33abc8a059c5f7eead8713c8 | https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/ContentContext.php#L97-L104 | train |
nuvoleweb/drupal-behat | src/DrupalExtension/Context/ContentContext.php | ContentContext.assertContentEditLink | public function assertContentEditLink($link, $title) {
if (!$this->getContentEditLink($link, $title)) {
throw new ExpectationException("No '$link' link to edit '$title' has been found.", $this->getSession());
}
} | php | public function assertContentEditLink($link, $title) {
if (!$this->getContentEditLink($link, $title)) {
throw new ExpectationException("No '$link' link to edit '$title' has been found.", $this->getSession());
}
} | [
"public",
"function",
"assertContentEditLink",
"(",
"$",
"link",
",",
"$",
"title",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getContentEditLink",
"(",
"$",
"link",
",",
"$",
"title",
")",
")",
"{",
"throw",
"new",
"ExpectationException",
"(",
"\"No '$link' link to edit '$title' has been found.\"",
",",
"$",
"this",
"->",
"getSession",
"(",
")",
")",
";",
"}",
"}"
]
| Assert presence of content edit link given its name and content title.
@param string $link
Link "name" HTML attribute.
@param string $title
Content title.
@throws \Behat\Mink\Exception\ExpectationException
If no edit link for given content has been found.
@Then I should see the link :link to edit content :content
@Then I should see a link :link to edit content :content | [
"Assert",
"presence",
"of",
"content",
"edit",
"link",
"given",
"its",
"name",
"and",
"content",
"title",
"."
]
| 0d6cc3f438a6c38c33abc8a059c5f7eead8713c8 | https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/ContentContext.php#L146-L150 | train |
nuvoleweb/drupal-behat | src/DrupalExtension/Context/ContentContext.php | ContentContext.assertContent | public function assertContent(PyStringNode $string) {
$values = $this->getYamlParser()->parse($string);
$message = __METHOD__ . ": Required fields 'type', 'title' and 'langcode' not found.";
Assert::keyExists($values, 'type', $message);
Assert::keyExists($values, 'title', $message);
Assert::keyExists($values, 'langcode', $message);
$node = $this->getCore()->entityCreate('node', $values);
$this->nodes[] = $node;
} | php | public function assertContent(PyStringNode $string) {
$values = $this->getYamlParser()->parse($string);
$message = __METHOD__ . ": Required fields 'type', 'title' and 'langcode' not found.";
Assert::keyExists($values, 'type', $message);
Assert::keyExists($values, 'title', $message);
Assert::keyExists($values, 'langcode', $message);
$node = $this->getCore()->entityCreate('node', $values);
$this->nodes[] = $node;
} | [
"public",
"function",
"assertContent",
"(",
"PyStringNode",
"$",
"string",
")",
"{",
"$",
"values",
"=",
"$",
"this",
"->",
"getYamlParser",
"(",
")",
"->",
"parse",
"(",
"$",
"string",
")",
";",
"$",
"message",
"=",
"__METHOD__",
".",
"\": Required fields 'type', 'title' and 'langcode' not found.\"",
";",
"Assert",
"::",
"keyExists",
"(",
"$",
"values",
",",
"'type'",
",",
"$",
"message",
")",
";",
"Assert",
"::",
"keyExists",
"(",
"$",
"values",
",",
"'title'",
",",
"$",
"message",
")",
";",
"Assert",
"::",
"keyExists",
"(",
"$",
"values",
",",
"'langcode'",
",",
"$",
"message",
")",
";",
"$",
"node",
"=",
"$",
"this",
"->",
"getCore",
"(",
")",
"->",
"entityCreate",
"(",
"'node'",
",",
"$",
"values",
")",
";",
"$",
"this",
"->",
"nodes",
"[",
"]",
"=",
"$",
"node",
";",
"}"
]
| Create content defined in YAML format.
@param \Behat\Gherkin\Node\PyStringNode $string
The text in yaml format that represents the content.
@Given the following content: | [
"Create",
"content",
"defined",
"in",
"YAML",
"format",
"."
]
| 0d6cc3f438a6c38c33abc8a059c5f7eead8713c8 | https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/ContentContext.php#L178-L186 | train |
nuvoleweb/drupal-behat | src/DrupalExtension/Context/ContentContext.php | ContentContext.assertTranslation | public function assertTranslation($content_type, $title, PyStringNode $string) {
$values = $this->getYamlParser()->parse($string);
Assert::keyExists($values, 'langcode', __METHOD__ . ": Required field 'langcode' not found.");
$nid = $this->getCore()->getEntityIdByLabel('node', $content_type, $title);
$source = $this->getCore()->entityLoad('node', $nid);
$this->getCore()->entityAddTranslation($source, $values['langcode'], $values);
} | php | public function assertTranslation($content_type, $title, PyStringNode $string) {
$values = $this->getYamlParser()->parse($string);
Assert::keyExists($values, 'langcode', __METHOD__ . ": Required field 'langcode' not found.");
$nid = $this->getCore()->getEntityIdByLabel('node', $content_type, $title);
$source = $this->getCore()->entityLoad('node', $nid);
$this->getCore()->entityAddTranslation($source, $values['langcode'], $values);
} | [
"public",
"function",
"assertTranslation",
"(",
"$",
"content_type",
",",
"$",
"title",
",",
"PyStringNode",
"$",
"string",
")",
"{",
"$",
"values",
"=",
"$",
"this",
"->",
"getYamlParser",
"(",
")",
"->",
"parse",
"(",
"$",
"string",
")",
";",
"Assert",
"::",
"keyExists",
"(",
"$",
"values",
",",
"'langcode'",
",",
"__METHOD__",
".",
"\": Required field 'langcode' not found.\"",
")",
";",
"$",
"nid",
"=",
"$",
"this",
"->",
"getCore",
"(",
")",
"->",
"getEntityIdByLabel",
"(",
"'node'",
",",
"$",
"content_type",
",",
"$",
"title",
")",
";",
"$",
"source",
"=",
"$",
"this",
"->",
"getCore",
"(",
")",
"->",
"entityLoad",
"(",
"'node'",
",",
"$",
"nid",
")",
";",
"$",
"this",
"->",
"getCore",
"(",
")",
"->",
"entityAddTranslation",
"(",
"$",
"source",
",",
"$",
"values",
"[",
"'langcode'",
"]",
",",
"$",
"values",
")",
";",
"}"
]
| Assert translation for given content.
@param string $content_type
The node type for which to add the translation.
@param string $title
The title to identify the content by.
@param \Behat\Gherkin\Node\PyStringNode $string
The text in yaml format that represents the translation.
@Given the following translation for :content_type content :title: | [
"Assert",
"translation",
"for",
"given",
"content",
"."
]
| 0d6cc3f438a6c38c33abc8a059c5f7eead8713c8 | https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/ContentContext.php#L200-L208 | train |
nuvoleweb/drupal-behat | src/DrupalExtension/Context/ContentContext.php | ContentContext.getContentEditLink | protected function getContentEditLink($link, $title) {
$node = $this->getCore()->loadNodeByName($title);
/** @var \Behat\Mink\Element\DocumentElement $element */
$element = $this->getSession()->getPage();
$locator = ($link ? array('link', sprintf("'%s'", $link)) : array('link', "."));
/** @var \Behat\Mink\Element\NodeElement[] $links */
$links = $element->findAll('named', $locator);
// Loop over all the links on the page and check for the node edit path.
foreach ($links as $result) {
$target = $result->getAttribute('href');
if (strpos($target, 'node/' . $this->getCore()->getNodeId($node) . '/edit') !== FALSE) {
return $result;
}
}
return NULL;
} | php | protected function getContentEditLink($link, $title) {
$node = $this->getCore()->loadNodeByName($title);
/** @var \Behat\Mink\Element\DocumentElement $element */
$element = $this->getSession()->getPage();
$locator = ($link ? array('link', sprintf("'%s'", $link)) : array('link', "."));
/** @var \Behat\Mink\Element\NodeElement[] $links */
$links = $element->findAll('named', $locator);
// Loop over all the links on the page and check for the node edit path.
foreach ($links as $result) {
$target = $result->getAttribute('href');
if (strpos($target, 'node/' . $this->getCore()->getNodeId($node) . '/edit') !== FALSE) {
return $result;
}
}
return NULL;
} | [
"protected",
"function",
"getContentEditLink",
"(",
"$",
"link",
",",
"$",
"title",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"getCore",
"(",
")",
"->",
"loadNodeByName",
"(",
"$",
"title",
")",
";",
"/** @var \\Behat\\Mink\\Element\\DocumentElement $element */",
"$",
"element",
"=",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"getPage",
"(",
")",
";",
"$",
"locator",
"=",
"(",
"$",
"link",
"?",
"array",
"(",
"'link'",
",",
"sprintf",
"(",
"\"'%s'\"",
",",
"$",
"link",
")",
")",
":",
"array",
"(",
"'link'",
",",
"\".\"",
")",
")",
";",
"/** @var \\Behat\\Mink\\Element\\NodeElement[] $links */",
"$",
"links",
"=",
"$",
"element",
"->",
"findAll",
"(",
"'named'",
",",
"$",
"locator",
")",
";",
"// Loop over all the links on the page and check for the node edit path.",
"foreach",
"(",
"$",
"links",
"as",
"$",
"result",
")",
"{",
"$",
"target",
"=",
"$",
"result",
"->",
"getAttribute",
"(",
"'href'",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"target",
",",
"'node/'",
".",
"$",
"this",
"->",
"getCore",
"(",
")",
"->",
"getNodeId",
"(",
"$",
"node",
")",
".",
"'/edit'",
")",
"!==",
"FALSE",
")",
"{",
"return",
"$",
"result",
";",
"}",
"}",
"return",
"NULL",
";",
"}"
]
| Get the edit link for a node.
@param string $link
The link name.
@param string $title
The node title.
@return \Behat\Mink\Element\NodeElement|null
The link if found.
@throws \Exception | [
"Get",
"the",
"edit",
"link",
"for",
"a",
"node",
"."
]
| 0d6cc3f438a6c38c33abc8a059c5f7eead8713c8 | https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/ContentContext.php#L223-L242 | train |
aimeos/ai-laravel | lib/custom/src/MW/View/Helper/Request/Laravel5.php | Laravel5.createRequest | protected function createRequest( \Illuminate\Http\Request $nativeRequest )
{
$files = ServerRequestFactory::normalizeFiles( $this->getFiles( $nativeRequest->files->all() ) );
$server = ServerRequestFactory::normalizeServer( $nativeRequest->server->all() );
$headers = $nativeRequest->headers->all();
$cookies = $nativeRequest->cookies->all();
$post = $nativeRequest->request->all();
$query = $nativeRequest->query->all();
$method = $nativeRequest->getMethod();
$uri = $nativeRequest->getUri();
$body = new Stream( 'php://temp', 'wb+' );
$body->write( $nativeRequest->getContent() );
$request = new ServerRequest( $server, $files, $uri, $method, $body, $headers, $cookies, $query, $post );
foreach( $nativeRequest->attributes->all() as $key => $value ) {
$request = $request->withAttribute( $key, $value );
}
return $request;
} | php | protected function createRequest( \Illuminate\Http\Request $nativeRequest )
{
$files = ServerRequestFactory::normalizeFiles( $this->getFiles( $nativeRequest->files->all() ) );
$server = ServerRequestFactory::normalizeServer( $nativeRequest->server->all() );
$headers = $nativeRequest->headers->all();
$cookies = $nativeRequest->cookies->all();
$post = $nativeRequest->request->all();
$query = $nativeRequest->query->all();
$method = $nativeRequest->getMethod();
$uri = $nativeRequest->getUri();
$body = new Stream( 'php://temp', 'wb+' );
$body->write( $nativeRequest->getContent() );
$request = new ServerRequest( $server, $files, $uri, $method, $body, $headers, $cookies, $query, $post );
foreach( $nativeRequest->attributes->all() as $key => $value ) {
$request = $request->withAttribute( $key, $value );
}
return $request;
} | [
"protected",
"function",
"createRequest",
"(",
"\\",
"Illuminate",
"\\",
"Http",
"\\",
"Request",
"$",
"nativeRequest",
")",
"{",
"$",
"files",
"=",
"ServerRequestFactory",
"::",
"normalizeFiles",
"(",
"$",
"this",
"->",
"getFiles",
"(",
"$",
"nativeRequest",
"->",
"files",
"->",
"all",
"(",
")",
")",
")",
";",
"$",
"server",
"=",
"ServerRequestFactory",
"::",
"normalizeServer",
"(",
"$",
"nativeRequest",
"->",
"server",
"->",
"all",
"(",
")",
")",
";",
"$",
"headers",
"=",
"$",
"nativeRequest",
"->",
"headers",
"->",
"all",
"(",
")",
";",
"$",
"cookies",
"=",
"$",
"nativeRequest",
"->",
"cookies",
"->",
"all",
"(",
")",
";",
"$",
"post",
"=",
"$",
"nativeRequest",
"->",
"request",
"->",
"all",
"(",
")",
";",
"$",
"query",
"=",
"$",
"nativeRequest",
"->",
"query",
"->",
"all",
"(",
")",
";",
"$",
"method",
"=",
"$",
"nativeRequest",
"->",
"getMethod",
"(",
")",
";",
"$",
"uri",
"=",
"$",
"nativeRequest",
"->",
"getUri",
"(",
")",
";",
"$",
"body",
"=",
"new",
"Stream",
"(",
"'php://temp'",
",",
"'wb+'",
")",
";",
"$",
"body",
"->",
"write",
"(",
"$",
"nativeRequest",
"->",
"getContent",
"(",
")",
")",
";",
"$",
"request",
"=",
"new",
"ServerRequest",
"(",
"$",
"server",
",",
"$",
"files",
",",
"$",
"uri",
",",
"$",
"method",
",",
"$",
"body",
",",
"$",
"headers",
",",
"$",
"cookies",
",",
"$",
"query",
",",
"$",
"post",
")",
";",
"foreach",
"(",
"$",
"nativeRequest",
"->",
"attributes",
"->",
"all",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"request",
"=",
"$",
"request",
"->",
"withAttribute",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"request",
";",
"}"
]
| Transforms a Symfony request into a PSR-7 request object
@param \Illuminate\Http\Request $nativeRequest Laravel request object
@return \Psr\Http\Message\ServerRequestInterface PSR-7 request object | [
"Transforms",
"a",
"Symfony",
"request",
"into",
"a",
"PSR",
"-",
"7",
"request",
"object"
]
| 55b833be51bcfd867d27e6c2e1d2efaa7246c481 | https://github.com/aimeos/ai-laravel/blob/55b833be51bcfd867d27e6c2e1d2efaa7246c481/lib/custom/src/MW/View/Helper/Request/Laravel5.php#L75-L96 | train |
aimeos/ai-laravel | lib/custom/src/MW/View/Helper/Request/Laravel5.php | Laravel5.getFiles | protected function getFiles( array $files )
{
$list = [];
foreach( $files as $key => $value )
{
if( $value instanceof \Symfony\Component\HttpFoundation\File\UploadedFile )
{
$list[$key] = new \Zend\Diactoros\UploadedFile(
$value->getRealPath(),
$value->getSize(),
$value->getError(),
$value->getClientOriginalName(),
$value->getClientMimeType()
);
}
elseif( is_array( $value ) )
{
$list[$key] = $this->getFiles( $value );
}
}
return $list;
} | php | protected function getFiles( array $files )
{
$list = [];
foreach( $files as $key => $value )
{
if( $value instanceof \Symfony\Component\HttpFoundation\File\UploadedFile )
{
$list[$key] = new \Zend\Diactoros\UploadedFile(
$value->getRealPath(),
$value->getSize(),
$value->getError(),
$value->getClientOriginalName(),
$value->getClientMimeType()
);
}
elseif( is_array( $value ) )
{
$list[$key] = $this->getFiles( $value );
}
}
return $list;
} | [
"protected",
"function",
"getFiles",
"(",
"array",
"$",
"files",
")",
"{",
"$",
"list",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"\\",
"Symfony",
"\\",
"Component",
"\\",
"HttpFoundation",
"\\",
"File",
"\\",
"UploadedFile",
")",
"{",
"$",
"list",
"[",
"$",
"key",
"]",
"=",
"new",
"\\",
"Zend",
"\\",
"Diactoros",
"\\",
"UploadedFile",
"(",
"$",
"value",
"->",
"getRealPath",
"(",
")",
",",
"$",
"value",
"->",
"getSize",
"(",
")",
",",
"$",
"value",
"->",
"getError",
"(",
")",
",",
"$",
"value",
"->",
"getClientOriginalName",
"(",
")",
",",
"$",
"value",
"->",
"getClientMimeType",
"(",
")",
")",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"list",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"getFiles",
"(",
"$",
"value",
")",
";",
"}",
"}",
"return",
"$",
"list",
";",
"}"
]
| Converts Symfony uploaded files array to the PSR-7 one.
@param array $files Multi-dimensional list of uploaded files from Symfony request
@return array Multi-dimensional list of uploaded files as PSR-7 objects | [
"Converts",
"Symfony",
"uploaded",
"files",
"array",
"to",
"the",
"PSR",
"-",
"7",
"one",
"."
]
| 55b833be51bcfd867d27e6c2e1d2efaa7246c481 | https://github.com/aimeos/ai-laravel/blob/55b833be51bcfd867d27e6c2e1d2efaa7246c481/lib/custom/src/MW/View/Helper/Request/Laravel5.php#L105-L128 | train |
nuvoleweb/drupal-behat | src/DrupalExtension/Context/EmailContext.php | EmailContext.assertEmailSentWithProperties | public function assertEmailSentWithProperties(TableNode $table) {
$last_mail = $this->getLastEmail();
foreach ($table->getRowsHash() as $name => $value) {
Assert::keyExists($last_mail, $name);
Assert::eq($last_mail[$name], $value);
}
} | php | public function assertEmailSentWithProperties(TableNode $table) {
$last_mail = $this->getLastEmail();
foreach ($table->getRowsHash() as $name => $value) {
Assert::keyExists($last_mail, $name);
Assert::eq($last_mail[$name], $value);
}
} | [
"public",
"function",
"assertEmailSentWithProperties",
"(",
"TableNode",
"$",
"table",
")",
"{",
"$",
"last_mail",
"=",
"$",
"this",
"->",
"getLastEmail",
"(",
")",
";",
"foreach",
"(",
"$",
"table",
"->",
"getRowsHash",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"Assert",
"::",
"keyExists",
"(",
"$",
"last_mail",
",",
"$",
"name",
")",
";",
"Assert",
"::",
"eq",
"(",
"$",
"last_mail",
"[",
"$",
"name",
"]",
",",
"$",
"value",
")",
";",
"}",
"}"
]
| Assert that the email that has been sent has the given properties.
@Then an email with the following properties should have been sent: | [
"Assert",
"that",
"the",
"email",
"that",
"has",
"been",
"sent",
"has",
"the",
"given",
"properties",
"."
]
| 0d6cc3f438a6c38c33abc8a059c5f7eead8713c8 | https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/EmailContext.php#L62-L68 | train |
nuvoleweb/drupal-behat | src/DrupalExtension/Context/EmailContext.php | EmailContext.beforeScenarioNoContactFlood | public function beforeScenarioNoContactFlood(BeforeScenarioScope $scope) {
$config = $this->getCore()->getEditableConfig('contact.settings');
$this->contactSettings = $config->getData();
$config->set('flood.limit', 100000);
$config->set('flood.interval', 100000);
$config->save();
} | php | public function beforeScenarioNoContactFlood(BeforeScenarioScope $scope) {
$config = $this->getCore()->getEditableConfig('contact.settings');
$this->contactSettings = $config->getData();
$config->set('flood.limit', 100000);
$config->set('flood.interval', 100000);
$config->save();
} | [
"public",
"function",
"beforeScenarioNoContactFlood",
"(",
"BeforeScenarioScope",
"$",
"scope",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"getCore",
"(",
")",
"->",
"getEditableConfig",
"(",
"'contact.settings'",
")",
";",
"$",
"this",
"->",
"contactSettings",
"=",
"$",
"config",
"->",
"getData",
"(",
")",
";",
"$",
"config",
"->",
"set",
"(",
"'flood.limit'",
",",
"100000",
")",
";",
"$",
"config",
"->",
"set",
"(",
"'flood.interval'",
",",
"100000",
")",
";",
"$",
"config",
"->",
"save",
"(",
")",
";",
"}"
]
| Increase value of contact form flooding.
@BeforeScenario @no_contact_flood | [
"Increase",
"value",
"of",
"contact",
"form",
"flooding",
"."
]
| 0d6cc3f438a6c38c33abc8a059c5f7eead8713c8 | https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/EmailContext.php#L97-L103 | train |
nuvoleweb/drupal-behat | src/DrupalExtension/Context/EmailContext.php | EmailContext.afterScenarioNoContactFlood | public function afterScenarioNoContactFlood(AfterScenarioScope $scope) {
$config = $this->getCore()->getEditableConfig('contact.settings');
$config->setData($this->contactSettings)->save();
} | php | public function afterScenarioNoContactFlood(AfterScenarioScope $scope) {
$config = $this->getCore()->getEditableConfig('contact.settings');
$config->setData($this->contactSettings)->save();
} | [
"public",
"function",
"afterScenarioNoContactFlood",
"(",
"AfterScenarioScope",
"$",
"scope",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"getCore",
"(",
")",
"->",
"getEditableConfig",
"(",
"'contact.settings'",
")",
";",
"$",
"config",
"->",
"setData",
"(",
"$",
"this",
"->",
"contactSettings",
")",
"->",
"save",
"(",
")",
";",
"}"
]
| Restore contact form flooding settings.
@AfterScenario @no_contact_flood | [
"Restore",
"contact",
"form",
"flooding",
"settings",
"."
]
| 0d6cc3f438a6c38c33abc8a059c5f7eead8713c8 | https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/EmailContext.php#L110-L113 | train |
nuvoleweb/drupal-behat | src/DrupalExtension/Context/EmailContext.php | EmailContext.getCollectedEmails | protected function getCollectedEmails() {
$this->getCore()->state()->resetCache();
$test_mail_collector = $this->getCore()->state()->get('system.test_mail_collector');
if (!$test_mail_collector) {
$test_mail_collector = [];
}
return $test_mail_collector;
} | php | protected function getCollectedEmails() {
$this->getCore()->state()->resetCache();
$test_mail_collector = $this->getCore()->state()->get('system.test_mail_collector');
if (!$test_mail_collector) {
$test_mail_collector = [];
}
return $test_mail_collector;
} | [
"protected",
"function",
"getCollectedEmails",
"(",
")",
"{",
"$",
"this",
"->",
"getCore",
"(",
")",
"->",
"state",
"(",
")",
"->",
"resetCache",
"(",
")",
";",
"$",
"test_mail_collector",
"=",
"$",
"this",
"->",
"getCore",
"(",
")",
"->",
"state",
"(",
")",
"->",
"get",
"(",
"'system.test_mail_collector'",
")",
";",
"if",
"(",
"!",
"$",
"test_mail_collector",
")",
"{",
"$",
"test_mail_collector",
"=",
"[",
"]",
";",
"}",
"return",
"$",
"test_mail_collector",
";",
"}"
]
| Get collected emails.
@return array
Array of collected emails. | [
"Get",
"collected",
"emails",
"."
]
| 0d6cc3f438a6c38c33abc8a059c5f7eead8713c8 | https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/EmailContext.php#L121-L129 | train |
nuvoleweb/drupal-behat | src/DrupalExtension/Context/PositionContext.php | PositionContext.shouldPrecede | public function shouldPrecede($first, $second) {
$page = $this->getSession()->getPage()->getText();
$pos1 = strpos($page, $first);
if ($pos1 === FALSE) {
throw new ExpectationException("Text not found: '$first'.", $this->getSession());
}
$pos2 = strpos($page, $second);
if ($pos2 === FALSE) {
throw new ExpectationException("Text not found: '$second'.", $this->getSession());
}
if ($pos2 < $pos1) {
throw new \Exception("Text '$first' does not precede text '$second'.");
}
} | php | public function shouldPrecede($first, $second) {
$page = $this->getSession()->getPage()->getText();
$pos1 = strpos($page, $first);
if ($pos1 === FALSE) {
throw new ExpectationException("Text not found: '$first'.", $this->getSession());
}
$pos2 = strpos($page, $second);
if ($pos2 === FALSE) {
throw new ExpectationException("Text not found: '$second'.", $this->getSession());
}
if ($pos2 < $pos1) {
throw new \Exception("Text '$first' does not precede text '$second'.");
}
} | [
"public",
"function",
"shouldPrecede",
"(",
"$",
"first",
",",
"$",
"second",
")",
"{",
"$",
"page",
"=",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"getPage",
"(",
")",
"->",
"getText",
"(",
")",
";",
"$",
"pos1",
"=",
"strpos",
"(",
"$",
"page",
",",
"$",
"first",
")",
";",
"if",
"(",
"$",
"pos1",
"===",
"FALSE",
")",
"{",
"throw",
"new",
"ExpectationException",
"(",
"\"Text not found: '$first'.\"",
",",
"$",
"this",
"->",
"getSession",
"(",
")",
")",
";",
"}",
"$",
"pos2",
"=",
"strpos",
"(",
"$",
"page",
",",
"$",
"second",
")",
";",
"if",
"(",
"$",
"pos2",
"===",
"FALSE",
")",
"{",
"throw",
"new",
"ExpectationException",
"(",
"\"Text not found: '$second'.\"",
",",
"$",
"this",
"->",
"getSession",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"pos2",
"<",
"$",
"pos1",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Text '$first' does not precede text '$second'.\"",
")",
";",
"}",
"}"
]
| Assert first element precedes second one.
@Then :first should precede :second | [
"Assert",
"first",
"element",
"precedes",
"second",
"one",
"."
]
| 0d6cc3f438a6c38c33abc8a059c5f7eead8713c8 | https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/PositionContext.php#L19-L32 | train |
nuvoleweb/drupal-behat | src/DrupalExtension/Context/CKEditorContext.php | CKEditorContext.iFillInTheRichTextEditorWith | public function iFillInTheRichTextEditorWith($label, $text) {
/** @var \Behat\Mink\Element\NodeElement $field */
$field = $this->getSession()->getPage()->findField($label);
if (NULL === $field) {
throw new \Exception(sprintf('Field "%s" not found.', $label));
}
$args_as_js_object = json_encode([
'ckeditor_instance_id' => $field->getAttribute('id'),
'value' => $text,
]);
$this->getSession()->executeScript(
"args = {$args_as_js_object};" .
"CKEDITOR.instances[args.ckeditor_instance_id].setData(args.value);"
);
} | php | public function iFillInTheRichTextEditorWith($label, $text) {
/** @var \Behat\Mink\Element\NodeElement $field */
$field = $this->getSession()->getPage()->findField($label);
if (NULL === $field) {
throw new \Exception(sprintf('Field "%s" not found.', $label));
}
$args_as_js_object = json_encode([
'ckeditor_instance_id' => $field->getAttribute('id'),
'value' => $text,
]);
$this->getSession()->executeScript(
"args = {$args_as_js_object};" .
"CKEDITOR.instances[args.ckeditor_instance_id].setData(args.value);"
);
} | [
"public",
"function",
"iFillInTheRichTextEditorWith",
"(",
"$",
"label",
",",
"$",
"text",
")",
"{",
"/** @var \\Behat\\Mink\\Element\\NodeElement $field */",
"$",
"field",
"=",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"getPage",
"(",
")",
"->",
"findField",
"(",
"$",
"label",
")",
";",
"if",
"(",
"NULL",
"===",
"$",
"field",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"'Field \"%s\" not found.'",
",",
"$",
"label",
")",
")",
";",
"}",
"$",
"args_as_js_object",
"=",
"json_encode",
"(",
"[",
"'ckeditor_instance_id'",
"=>",
"$",
"field",
"->",
"getAttribute",
"(",
"'id'",
")",
",",
"'value'",
"=>",
"$",
"text",
",",
"]",
")",
";",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"executeScript",
"(",
"\"args = {$args_as_js_object};\"",
".",
"\"CKEDITOR.instances[args.ckeditor_instance_id].setData(args.value);\"",
")",
";",
"}"
]
| Fill CKEditor with given value.
@Given I fill in the rich text editor :label with :text | [
"Fill",
"CKEditor",
"with",
"given",
"value",
"."
]
| 0d6cc3f438a6c38c33abc8a059c5f7eead8713c8 | https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/CKEditorContext.php#L19-L36 | train |
nuvoleweb/drupal-behat | src/DrupalExtension/Context/DrupalContext.php | DrupalContext.manuallyCreateNodes | public function manuallyCreateNodes($type, TableNode $nodesTable) {
$type = $this->getCore()->convertLabelToNodeTypeId($type);
foreach ($nodesTable->getHash() as $nodeHash) {
$this->getSession()->visit($this->locatePath("/node/add/$type"));
$element = $this->getSession()->getPage();
// Fill in the form.
foreach ($nodeHash as $field => $value) {
$element->fillField($field, $value);
}
$submit = $element->findButton($this->getDrupalText('node_submit_label'));
if (empty($submit)) {
throw new \Exception(sprintf("No submit button at %s", $this->getSession()->getCurrentUrl()));
}
// Submit the form.
$submit->click();
}
} | php | public function manuallyCreateNodes($type, TableNode $nodesTable) {
$type = $this->getCore()->convertLabelToNodeTypeId($type);
foreach ($nodesTable->getHash() as $nodeHash) {
$this->getSession()->visit($this->locatePath("/node/add/$type"));
$element = $this->getSession()->getPage();
// Fill in the form.
foreach ($nodeHash as $field => $value) {
$element->fillField($field, $value);
}
$submit = $element->findButton($this->getDrupalText('node_submit_label'));
if (empty($submit)) {
throw new \Exception(sprintf("No submit button at %s", $this->getSession()->getCurrentUrl()));
}
// Submit the form.
$submit->click();
}
} | [
"public",
"function",
"manuallyCreateNodes",
"(",
"$",
"type",
",",
"TableNode",
"$",
"nodesTable",
")",
"{",
"$",
"type",
"=",
"$",
"this",
"->",
"getCore",
"(",
")",
"->",
"convertLabelToNodeTypeId",
"(",
"$",
"type",
")",
";",
"foreach",
"(",
"$",
"nodesTable",
"->",
"getHash",
"(",
")",
"as",
"$",
"nodeHash",
")",
"{",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"visit",
"(",
"$",
"this",
"->",
"locatePath",
"(",
"\"/node/add/$type\"",
")",
")",
";",
"$",
"element",
"=",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"getPage",
"(",
")",
";",
"// Fill in the form.",
"foreach",
"(",
"$",
"nodeHash",
"as",
"$",
"field",
"=>",
"$",
"value",
")",
"{",
"$",
"element",
"->",
"fillField",
"(",
"$",
"field",
",",
"$",
"value",
")",
";",
"}",
"$",
"submit",
"=",
"$",
"element",
"->",
"findButton",
"(",
"$",
"this",
"->",
"getDrupalText",
"(",
"'node_submit_label'",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"submit",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"\"No submit button at %s\"",
",",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"getCurrentUrl",
"(",
")",
")",
")",
";",
"}",
"// Submit the form.",
"$",
"submit",
"->",
"click",
"(",
")",
";",
"}",
"}"
]
| Creates content by filling specified form fields via the UI.
Use as follow:
| Title | Author | Label | of the field |
| My title | Joe Editor | 1 | 2014-10-17 8:00am |
| ... | ... | ... | ... |
@Given I create :type content: | [
"Creates",
"content",
"by",
"filling",
"specified",
"form",
"fields",
"via",
"the",
"UI",
"."
]
| 0d6cc3f438a6c38c33abc8a059c5f7eead8713c8 | https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/DrupalContext.php#L45-L63 | train |
nuvoleweb/drupal-behat | src/DrupalExtension/Context/DrupalContext.php | DrupalContext.submitContentForm | public function submitContentForm() {
$element = $this->getSession()->getPage();
$submit = $element->findButton($this->getDrupalText('node_submit_label'));
if (empty($submit)) {
throw new \Exception(sprintf("No submit button at %s", $this->getSession()->getCurrentUrl()));
}
// Submit the form.
$submit->click();
} | php | public function submitContentForm() {
$element = $this->getSession()->getPage();
$submit = $element->findButton($this->getDrupalText('node_submit_label'));
if (empty($submit)) {
throw new \Exception(sprintf("No submit button at %s", $this->getSession()->getCurrentUrl()));
}
// Submit the form.
$submit->click();
} | [
"public",
"function",
"submitContentForm",
"(",
")",
"{",
"$",
"element",
"=",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"getPage",
"(",
")",
";",
"$",
"submit",
"=",
"$",
"element",
"->",
"findButton",
"(",
"$",
"this",
"->",
"getDrupalText",
"(",
"'node_submit_label'",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"submit",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"\"No submit button at %s\"",
",",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"getCurrentUrl",
"(",
")",
")",
")",
";",
"}",
"// Submit the form.",
"$",
"submit",
"->",
"click",
"(",
")",
";",
"}"
]
| Submit node form using "node_submit_label" value.
@When I submit the content form | [
"Submit",
"node",
"form",
"using",
"node_submit_label",
"value",
"."
]
| 0d6cc3f438a6c38c33abc8a059c5f7eead8713c8 | https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/DrupalContext.php#L70-L78 | train |
nuvoleweb/drupal-behat | src/DrupalExtension/Context/DrupalContext.php | DrupalContext.iShouldSeeInTheHeader | public function iShouldSeeInTheHeader($header, $value) {
$headers = $this->getSession()->getResponseHeaders();
if ($headers[$header] != $value) {
throw new \Exception(sprintf("Did not see %s with value %s.", $header, $value));
}
} | php | public function iShouldSeeInTheHeader($header, $value) {
$headers = $this->getSession()->getResponseHeaders();
if ($headers[$header] != $value) {
throw new \Exception(sprintf("Did not see %s with value %s.", $header, $value));
}
} | [
"public",
"function",
"iShouldSeeInTheHeader",
"(",
"$",
"header",
",",
"$",
"value",
")",
"{",
"$",
"headers",
"=",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"getResponseHeaders",
"(",
")",
";",
"if",
"(",
"$",
"headers",
"[",
"$",
"header",
"]",
"!=",
"$",
"value",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"\"Did not see %s with value %s.\"",
",",
"$",
"header",
",",
"$",
"value",
")",
")",
";",
"}",
"}"
]
| Assert string in HTTP response header.
@Then I should see in the header :header::value | [
"Assert",
"string",
"in",
"HTTP",
"response",
"header",
"."
]
| 0d6cc3f438a6c38c33abc8a059c5f7eead8713c8 | https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/DrupalContext.php#L85-L90 | train |
nuvoleweb/drupal-behat | src/DrupalExtension/Context/DrupalContext.php | DrupalContext.invalidateCacheTags | public function invalidateCacheTags(TableNode $table) {
$tags = [];
foreach ($table->getRows() as $row) {
$tags[] = $row[0];
}
$this->getCore()->invalidateCacheTags($tags);
} | php | public function invalidateCacheTags(TableNode $table) {
$tags = [];
foreach ($table->getRows() as $row) {
$tags[] = $row[0];
}
$this->getCore()->invalidateCacheTags($tags);
} | [
"public",
"function",
"invalidateCacheTags",
"(",
"TableNode",
"$",
"table",
")",
"{",
"$",
"tags",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"table",
"->",
"getRows",
"(",
")",
"as",
"$",
"row",
")",
"{",
"$",
"tags",
"[",
"]",
"=",
"$",
"row",
"[",
"0",
"]",
";",
"}",
"$",
"this",
"->",
"getCore",
"(",
")",
"->",
"invalidateCacheTags",
"(",
"$",
"tags",
")",
";",
"}"
]
| Invalidate cache tags.
Usage:
Given I invalidate the following cache tags:
| tag_one |
| tag_two |
@Given I invalidate the following cache tags: | [
"Invalidate",
"cache",
"tags",
"."
]
| 0d6cc3f438a6c38c33abc8a059c5f7eead8713c8 | https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/DrupalContext.php#L103-L109 | train |
nuvoleweb/drupal-behat | src/DrupalExtension/Context/AutocompleteContext.php | AutocompleteContext.fillInDrupalAutocomplete | public function fillInDrupalAutocomplete($locator, $text) {
$session = $this->getSession();
$el = $session->getPage()->findField($locator);
if (empty($el)) {
throw new ExpectationException('No such autocomplete element ' . $locator, $session);
}
// Set the text and trigger the autocomplete with a space keystroke.
$el->setValue($text);
try {
$el->keyDown(' ');
$el->keyUp(' ');
// Wait for ajax.
$this->getSession()->wait(1000, '(typeof(jQuery)=="undefined" || (0 === jQuery.active && 0 === jQuery(\':animated\').length))');
// Wait a second, just to be sure.
sleep(1);
// Select the autocomplete popup with the name we are looking for.
$popup = $session->getPage()->find('xpath', "//ul[contains(@class, 'ui-autocomplete')]/li/a[text() = '{$text}']");
if (empty($popup)) {
throw new ExpectationException('No such option ' . $text . ' in ' . $locator, $session);
}
// Clicking on the popup fills the autocomplete properly.
$popup->click();
}
catch (UnsupportedDriverActionException $e) {
// So javascript is not supported.
// We did set the value correctly, so Drupal will figure it out.
}
} | php | public function fillInDrupalAutocomplete($locator, $text) {
$session = $this->getSession();
$el = $session->getPage()->findField($locator);
if (empty($el)) {
throw new ExpectationException('No such autocomplete element ' . $locator, $session);
}
// Set the text and trigger the autocomplete with a space keystroke.
$el->setValue($text);
try {
$el->keyDown(' ');
$el->keyUp(' ');
// Wait for ajax.
$this->getSession()->wait(1000, '(typeof(jQuery)=="undefined" || (0 === jQuery.active && 0 === jQuery(\':animated\').length))');
// Wait a second, just to be sure.
sleep(1);
// Select the autocomplete popup with the name we are looking for.
$popup = $session->getPage()->find('xpath', "//ul[contains(@class, 'ui-autocomplete')]/li/a[text() = '{$text}']");
if (empty($popup)) {
throw new ExpectationException('No such option ' . $text . ' in ' . $locator, $session);
}
// Clicking on the popup fills the autocomplete properly.
$popup->click();
}
catch (UnsupportedDriverActionException $e) {
// So javascript is not supported.
// We did set the value correctly, so Drupal will figure it out.
}
} | [
"public",
"function",
"fillInDrupalAutocomplete",
"(",
"$",
"locator",
",",
"$",
"text",
")",
"{",
"$",
"session",
"=",
"$",
"this",
"->",
"getSession",
"(",
")",
";",
"$",
"el",
"=",
"$",
"session",
"->",
"getPage",
"(",
")",
"->",
"findField",
"(",
"$",
"locator",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"el",
")",
")",
"{",
"throw",
"new",
"ExpectationException",
"(",
"'No such autocomplete element '",
".",
"$",
"locator",
",",
"$",
"session",
")",
";",
"}",
"// Set the text and trigger the autocomplete with a space keystroke.",
"$",
"el",
"->",
"setValue",
"(",
"$",
"text",
")",
";",
"try",
"{",
"$",
"el",
"->",
"keyDown",
"(",
"' '",
")",
";",
"$",
"el",
"->",
"keyUp",
"(",
"' '",
")",
";",
"// Wait for ajax.",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"wait",
"(",
"1000",
",",
"'(typeof(jQuery)==\"undefined\" || (0 === jQuery.active && 0 === jQuery(\\':animated\\').length))'",
")",
";",
"// Wait a second, just to be sure.",
"sleep",
"(",
"1",
")",
";",
"// Select the autocomplete popup with the name we are looking for.",
"$",
"popup",
"=",
"$",
"session",
"->",
"getPage",
"(",
")",
"->",
"find",
"(",
"'xpath'",
",",
"\"//ul[contains(@class, 'ui-autocomplete')]/li/a[text() = '{$text}']\"",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"popup",
")",
")",
"{",
"throw",
"new",
"ExpectationException",
"(",
"'No such option '",
".",
"$",
"text",
".",
"' in '",
".",
"$",
"locator",
",",
"$",
"session",
")",
";",
"}",
"// Clicking on the popup fills the autocomplete properly.",
"$",
"popup",
"->",
"click",
"(",
")",
";",
"}",
"catch",
"(",
"UnsupportedDriverActionException",
"$",
"e",
")",
"{",
"// So javascript is not supported.",
"// We did set the value correctly, so Drupal will figure it out.",
"}",
"}"
]
| Fill out autocomplete fields based on gist.
@When I fill in the autocomplete :autocomplete with :text | [
"Fill",
"out",
"autocomplete",
"fields",
"based",
"on",
"gist",
"."
]
| 0d6cc3f438a6c38c33abc8a059c5f7eead8713c8 | https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/AutocompleteContext.php#L18-L54 | train |
nuvoleweb/drupal-behat | src/DrupalExtension/Component/ResolutionComponent.php | ResolutionComponent.parse | public function parse($resolution) {
preg_match_all(self::RESOLUTION_FORMAT, $resolution, $matches);
$message = "Cannot parse provided resolution '{$resolution}'. It must be in the following format: 360x640";
Assert::notEmpty($matches, $message);
Assert::keyExists($matches, 0, $message);
Assert::keyExists($matches, 1, $message);
Assert::keyExists($matches, 2, $message);
Assert::notEmpty($matches[1][0], $message);
Assert::notEmpty($matches[2][0], $message);
$this->setWidth($matches[1][0]);
$this->setHeight($matches[2][0]);
return $this;
} | php | public function parse($resolution) {
preg_match_all(self::RESOLUTION_FORMAT, $resolution, $matches);
$message = "Cannot parse provided resolution '{$resolution}'. It must be in the following format: 360x640";
Assert::notEmpty($matches, $message);
Assert::keyExists($matches, 0, $message);
Assert::keyExists($matches, 1, $message);
Assert::keyExists($matches, 2, $message);
Assert::notEmpty($matches[1][0], $message);
Assert::notEmpty($matches[2][0], $message);
$this->setWidth($matches[1][0]);
$this->setHeight($matches[2][0]);
return $this;
} | [
"public",
"function",
"parse",
"(",
"$",
"resolution",
")",
"{",
"preg_match_all",
"(",
"self",
"::",
"RESOLUTION_FORMAT",
",",
"$",
"resolution",
",",
"$",
"matches",
")",
";",
"$",
"message",
"=",
"\"Cannot parse provided resolution '{$resolution}'. It must be in the following format: 360x640\"",
";",
"Assert",
"::",
"notEmpty",
"(",
"$",
"matches",
",",
"$",
"message",
")",
";",
"Assert",
"::",
"keyExists",
"(",
"$",
"matches",
",",
"0",
",",
"$",
"message",
")",
";",
"Assert",
"::",
"keyExists",
"(",
"$",
"matches",
",",
"1",
",",
"$",
"message",
")",
";",
"Assert",
"::",
"keyExists",
"(",
"$",
"matches",
",",
"2",
",",
"$",
"message",
")",
";",
"Assert",
"::",
"notEmpty",
"(",
"$",
"matches",
"[",
"1",
"]",
"[",
"0",
"]",
",",
"$",
"message",
")",
";",
"Assert",
"::",
"notEmpty",
"(",
"$",
"matches",
"[",
"2",
"]",
"[",
"0",
"]",
",",
"$",
"message",
")",
";",
"$",
"this",
"->",
"setWidth",
"(",
"$",
"matches",
"[",
"1",
"]",
"[",
"0",
"]",
")",
";",
"$",
"this",
"->",
"setHeight",
"(",
"$",
"matches",
"[",
"2",
"]",
"[",
"0",
"]",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Parse resolution.
@param string $resolution
Resolution string, i.e. "360x640".
@return $this | [
"Parse",
"resolution",
"."
]
| 0d6cc3f438a6c38c33abc8a059c5f7eead8713c8 | https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Component/ResolutionComponent.php#L81-L93 | train |
nuvoleweb/drupal-behat | src/DrupalExtension/Component/PyStringYamlParser.php | PyStringYamlParser.parse | public function parse(PyStringNode $node) {
// Sanitize PyString test by removing initial indentation spaces.
$strings = $node->getStrings();
if ($strings) {
preg_match('/^(\s+)/', $strings[0], $matches);
$indentation_size = isset($matches[1]) ? strlen($matches[1]) : 0;
foreach ($strings as $key => $string) {
$strings[$key] = substr($string, $indentation_size);
}
}
$raw = implode("\n", $strings);
return Yaml::parse($raw);
} | php | public function parse(PyStringNode $node) {
// Sanitize PyString test by removing initial indentation spaces.
$strings = $node->getStrings();
if ($strings) {
preg_match('/^(\s+)/', $strings[0], $matches);
$indentation_size = isset($matches[1]) ? strlen($matches[1]) : 0;
foreach ($strings as $key => $string) {
$strings[$key] = substr($string, $indentation_size);
}
}
$raw = implode("\n", $strings);
return Yaml::parse($raw);
} | [
"public",
"function",
"parse",
"(",
"PyStringNode",
"$",
"node",
")",
"{",
"// Sanitize PyString test by removing initial indentation spaces.",
"$",
"strings",
"=",
"$",
"node",
"->",
"getStrings",
"(",
")",
";",
"if",
"(",
"$",
"strings",
")",
"{",
"preg_match",
"(",
"'/^(\\s+)/'",
",",
"$",
"strings",
"[",
"0",
"]",
",",
"$",
"matches",
")",
";",
"$",
"indentation_size",
"=",
"isset",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
"?",
"strlen",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
":",
"0",
";",
"foreach",
"(",
"$",
"strings",
"as",
"$",
"key",
"=>",
"$",
"string",
")",
"{",
"$",
"strings",
"[",
"$",
"key",
"]",
"=",
"substr",
"(",
"$",
"string",
",",
"$",
"indentation_size",
")",
";",
"}",
"}",
"$",
"raw",
"=",
"implode",
"(",
"\"\\n\"",
",",
"$",
"strings",
")",
";",
"return",
"Yaml",
"::",
"parse",
"(",
"$",
"raw",
")",
";",
"}"
]
| Parse YAML contained in a PyString node.
@param \Behat\Gherkin\Node\PyStringNode $node
PyString containing text in YAML format.
@return array
Parsed YAML. | [
"Parse",
"YAML",
"contained",
"in",
"a",
"PyString",
"node",
"."
]
| 0d6cc3f438a6c38c33abc8a059c5f7eead8713c8 | https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Component/PyStringYamlParser.php#L24-L36 | train |
nuvoleweb/drupal-behat | src/DrupalExtension/Context/TaxonomyTermContext.php | TaxonomyTermContext.visitTermPage | protected function visitTermPage($op, $type, $name) {
$type = $this->getCore()->convertLabelToTermTypeId($type);
$term = $this->getCore()->loadTaxonomyTermByName($type, $name);
if (!empty($term)) {
$path = [
'view' => "taxonomy/term/{$this->getCore()->getTaxonomyTermId($term)}",
'edit' => "taxonomy/term/{$this->getCore()->getTaxonomyTermId($term)}/edit",
'delete' => "taxonomy/term/{$this->getCore()->getTaxonomyTermId($term)}/delete",
];
$this->visitPath($path[$op]);
}
else {
throw new ExpectationException("No taxonomy term with vocabulary '$type' and name '$name' has been found.", $this->getSession());
}
} | php | protected function visitTermPage($op, $type, $name) {
$type = $this->getCore()->convertLabelToTermTypeId($type);
$term = $this->getCore()->loadTaxonomyTermByName($type, $name);
if (!empty($term)) {
$path = [
'view' => "taxonomy/term/{$this->getCore()->getTaxonomyTermId($term)}",
'edit' => "taxonomy/term/{$this->getCore()->getTaxonomyTermId($term)}/edit",
'delete' => "taxonomy/term/{$this->getCore()->getTaxonomyTermId($term)}/delete",
];
$this->visitPath($path[$op]);
}
else {
throw new ExpectationException("No taxonomy term with vocabulary '$type' and name '$name' has been found.", $this->getSession());
}
} | [
"protected",
"function",
"visitTermPage",
"(",
"$",
"op",
",",
"$",
"type",
",",
"$",
"name",
")",
"{",
"$",
"type",
"=",
"$",
"this",
"->",
"getCore",
"(",
")",
"->",
"convertLabelToTermTypeId",
"(",
"$",
"type",
")",
";",
"$",
"term",
"=",
"$",
"this",
"->",
"getCore",
"(",
")",
"->",
"loadTaxonomyTermByName",
"(",
"$",
"type",
",",
"$",
"name",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"term",
")",
")",
"{",
"$",
"path",
"=",
"[",
"'view'",
"=>",
"\"taxonomy/term/{$this->getCore()->getTaxonomyTermId($term)}\"",
",",
"'edit'",
"=>",
"\"taxonomy/term/{$this->getCore()->getTaxonomyTermId($term)}/edit\"",
",",
"'delete'",
"=>",
"\"taxonomy/term/{$this->getCore()->getTaxonomyTermId($term)}/delete\"",
",",
"]",
";",
"$",
"this",
"->",
"visitPath",
"(",
"$",
"path",
"[",
"$",
"op",
"]",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"ExpectationException",
"(",
"\"No taxonomy term with vocabulary '$type' and name '$name' has been found.\"",
",",
"$",
"this",
"->",
"getSession",
"(",
")",
")",
";",
"}",
"}"
]
| Provides a common step definition callback for taxonomy term pages.
@param string $op
The operation being performed: 'view', 'edit', 'delete'.
@param string $type
The term's vocabulary, either as machine name or label.
@param string $name
The term name.
@throws ExpectationException
When the term does not exist. | [
"Provides",
"a",
"common",
"step",
"definition",
"callback",
"for",
"taxonomy",
"term",
"pages",
"."
]
| 0d6cc3f438a6c38c33abc8a059c5f7eead8713c8 | https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/TaxonomyTermContext.php#L57-L72 | train |
nuvoleweb/drupal-behat | src/DrupalExtension/Context/SelectFieldContext.php | SelectFieldContext.assertSelectOptions | public function assertSelectOptions($select, TableNode $options) {
// Retrieve the specified field.
if (!$field = $this->getSession()->getPage()->findField($select)) {
throw new ExpectationException("Field '$select' not found.", $this->getSession());
}
/* @var \Behat\Mink\Element\NodeElement $field */
// Check that the specified field is a <select> field.
$this->assertElementType($field, 'select');
// Retrieve the options table from the test scenario and flatten it.
$expected_options = $options->getColumnsHash();
array_walk($expected_options, function (&$value) {
$value = reset($value);
});
// Retrieve the actual options that are shown in the page.
$actual_options = $field->findAll('css', 'option');
// Convert into a flat list of option text strings.
array_walk($actual_options, function (NodeElement &$value) {
$value = $value->getText();
});
// Check that all expected options are present.
foreach ($expected_options as $expected_option) {
if (!in_array($expected_option, $actual_options)) {
throw new ExpectationException("Option '$expected_option' is missing from select list '$select'.", $this->getSession());
}
}
} | php | public function assertSelectOptions($select, TableNode $options) {
// Retrieve the specified field.
if (!$field = $this->getSession()->getPage()->findField($select)) {
throw new ExpectationException("Field '$select' not found.", $this->getSession());
}
/* @var \Behat\Mink\Element\NodeElement $field */
// Check that the specified field is a <select> field.
$this->assertElementType($field, 'select');
// Retrieve the options table from the test scenario and flatten it.
$expected_options = $options->getColumnsHash();
array_walk($expected_options, function (&$value) {
$value = reset($value);
});
// Retrieve the actual options that are shown in the page.
$actual_options = $field->findAll('css', 'option');
// Convert into a flat list of option text strings.
array_walk($actual_options, function (NodeElement &$value) {
$value = $value->getText();
});
// Check that all expected options are present.
foreach ($expected_options as $expected_option) {
if (!in_array($expected_option, $actual_options)) {
throw new ExpectationException("Option '$expected_option' is missing from select list '$select'.", $this->getSession());
}
}
} | [
"public",
"function",
"assertSelectOptions",
"(",
"$",
"select",
",",
"TableNode",
"$",
"options",
")",
"{",
"// Retrieve the specified field.",
"if",
"(",
"!",
"$",
"field",
"=",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"getPage",
"(",
")",
"->",
"findField",
"(",
"$",
"select",
")",
")",
"{",
"throw",
"new",
"ExpectationException",
"(",
"\"Field '$select' not found.\"",
",",
"$",
"this",
"->",
"getSession",
"(",
")",
")",
";",
"}",
"/* @var \\Behat\\Mink\\Element\\NodeElement $field */",
"// Check that the specified field is a <select> field.",
"$",
"this",
"->",
"assertElementType",
"(",
"$",
"field",
",",
"'select'",
")",
";",
"// Retrieve the options table from the test scenario and flatten it.",
"$",
"expected_options",
"=",
"$",
"options",
"->",
"getColumnsHash",
"(",
")",
";",
"array_walk",
"(",
"$",
"expected_options",
",",
"function",
"(",
"&",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"reset",
"(",
"$",
"value",
")",
";",
"}",
")",
";",
"// Retrieve the actual options that are shown in the page.",
"$",
"actual_options",
"=",
"$",
"field",
"->",
"findAll",
"(",
"'css'",
",",
"'option'",
")",
";",
"// Convert into a flat list of option text strings.",
"array_walk",
"(",
"$",
"actual_options",
",",
"function",
"(",
"NodeElement",
"&",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"$",
"value",
"->",
"getText",
"(",
")",
";",
"}",
")",
";",
"// Check that all expected options are present.",
"foreach",
"(",
"$",
"expected_options",
"as",
"$",
"expected_option",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"expected_option",
",",
"$",
"actual_options",
")",
")",
"{",
"throw",
"new",
"ExpectationException",
"(",
"\"Option '$expected_option' is missing from select list '$select'.\"",
",",
"$",
"this",
"->",
"getSession",
"(",
")",
")",
";",
"}",
"}",
"}"
]
| Checks that the given select field has the options listed in the table.
@Then I should have the following options for :select: | [
"Checks",
"that",
"the",
"given",
"select",
"field",
"has",
"the",
"options",
"listed",
"in",
"the",
"table",
"."
]
| 0d6cc3f438a6c38c33abc8a059c5f7eead8713c8 | https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/SelectFieldContext.php#L21-L52 | train |
nuvoleweb/drupal-behat | src/DrupalExtension/Context/SelectFieldContext.php | SelectFieldContext.getSelectedOptionByLabel | protected function getSelectedOptionByLabel($select, $option_label, $check_selected = TRUE) {
if (!$field = $this->getSession()->getPage()->findField($select)) {
throw new ExpectationException("Field '$select' not found.", $this->getSession());
}
/* @var \Behat\Mink\Element\NodeElement $field */
// Check that the specified field is a <select> field.
$this->assertElementType($field, 'select');
$options = $field->findAll('css', 'option');
$options = array_filter($options, function (NodeElement $option) use ($option_label) {
return $option->getText() == $option_label ? $option : FALSE;
});
if (!($option = $options ? reset($options) : NULL)) {
throw new ExpectationException("Option '$option_label' doesn't exist in '$select' select.", $this->getSession());
}
return $check_selected ? $option->isSelected() : !$option->isSelected();
} | php | protected function getSelectedOptionByLabel($select, $option_label, $check_selected = TRUE) {
if (!$field = $this->getSession()->getPage()->findField($select)) {
throw new ExpectationException("Field '$select' not found.", $this->getSession());
}
/* @var \Behat\Mink\Element\NodeElement $field */
// Check that the specified field is a <select> field.
$this->assertElementType($field, 'select');
$options = $field->findAll('css', 'option');
$options = array_filter($options, function (NodeElement $option) use ($option_label) {
return $option->getText() == $option_label ? $option : FALSE;
});
if (!($option = $options ? reset($options) : NULL)) {
throw new ExpectationException("Option '$option_label' doesn't exist in '$select' select.", $this->getSession());
}
return $check_selected ? $option->isSelected() : !$option->isSelected();
} | [
"protected",
"function",
"getSelectedOptionByLabel",
"(",
"$",
"select",
",",
"$",
"option_label",
",",
"$",
"check_selected",
"=",
"TRUE",
")",
"{",
"if",
"(",
"!",
"$",
"field",
"=",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"getPage",
"(",
")",
"->",
"findField",
"(",
"$",
"select",
")",
")",
"{",
"throw",
"new",
"ExpectationException",
"(",
"\"Field '$select' not found.\"",
",",
"$",
"this",
"->",
"getSession",
"(",
")",
")",
";",
"}",
"/* @var \\Behat\\Mink\\Element\\NodeElement $field */",
"// Check that the specified field is a <select> field.",
"$",
"this",
"->",
"assertElementType",
"(",
"$",
"field",
",",
"'select'",
")",
";",
"$",
"options",
"=",
"$",
"field",
"->",
"findAll",
"(",
"'css'",
",",
"'option'",
")",
";",
"$",
"options",
"=",
"array_filter",
"(",
"$",
"options",
",",
"function",
"(",
"NodeElement",
"$",
"option",
")",
"use",
"(",
"$",
"option_label",
")",
"{",
"return",
"$",
"option",
"->",
"getText",
"(",
")",
"==",
"$",
"option_label",
"?",
"$",
"option",
":",
"FALSE",
";",
"}",
")",
";",
"if",
"(",
"!",
"(",
"$",
"option",
"=",
"$",
"options",
"?",
"reset",
"(",
"$",
"options",
")",
":",
"NULL",
")",
")",
"{",
"throw",
"new",
"ExpectationException",
"(",
"\"Option '$option_label' doesn't exist in '$select' select.\"",
",",
"$",
"this",
"->",
"getSession",
"(",
")",
")",
";",
"}",
"return",
"$",
"check_selected",
"?",
"$",
"option",
"->",
"isSelected",
"(",
")",
":",
"!",
"$",
"option",
"->",
"isSelected",
"(",
")",
";",
"}"
]
| Returns an option from a specific select.
@param string $select
The select name.
@param string $option_label
The option text.
@param bool $check_selected
(optional) If TRUE, will check for selected option, if FALSE for
unselected. Defaults to TRUE.
@return \Behat\Mink\Element\NodeElement|null
The node element or NULL.
@throws \Behat\Mink\Exception\ExpectationException | [
"Returns",
"an",
"option",
"from",
"a",
"specific",
"select",
"."
]
| 0d6cc3f438a6c38c33abc8a059c5f7eead8713c8 | https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/SelectFieldContext.php#L126-L146 | train |
Bynder/bynder-php-sdk | src/Bynder/Api/Impl/Upload/AmazonApi.php | AmazonApi.uploadPartToAmazon | public function uploadPartToAmazon(
$filePath,
$uploadEndpoint,
$uploadRequestInfo,
$chunkNumber,
$chunk,
$numberOfChunks
) {
$finalKey = sprintf("%s/p%d", $uploadRequestInfo['multipart_params']['key'], $chunkNumber);
$formData = [
self::getFormDataParams('x-amz-credential', $uploadRequestInfo['multipart_params']['x-amz-credential']),
self::getFormDataParams('X-Amz-Signature', $uploadRequestInfo['multipart_params']['X-Amz-Signature']),
self::getFormDataParams('x-amz-algorithm', $uploadRequestInfo['multipart_params']['x-amz-algorithm']),
self::getFormDataParams('x-amz-date', $uploadRequestInfo['multipart_params']['x-amz-date']),
self::getFormDataParams('Policy', $uploadRequestInfo['multipart_params']['Policy']),
self::getFormDataParams('key', $finalKey),
self::getFormDataParams('acl', $uploadRequestInfo['multipart_params']['acl']),
self::getFormDataParams('success_action_status',
$uploadRequestInfo['multipart_params']['success_action_status']),
self::getFormDataParams('Content-Type', $uploadRequestInfo['multipart_params']['Content-Type']),
self::getFormDataParams('name', $filePath),
self::getFormDataParams('chunk', $chunkNumber),
self::getFormDataParams('chunks', $numberOfChunks),
self::getFormDataParams('Filename', $finalKey),
self::getFormDataParams('file', $chunk)
];
$stack = HandlerStack::create(new CurlHandler());
$oauthRequestClient = new Client([
'base_uri' => $uploadEndpoint,
'handler' => $stack,
]);
return $oauthRequestClient->postAsync($uploadEndpoint, ['multipart' => $formData])
->then(
function (ResponseInterface $response) {
return json_decode($response->getBody(), true);
}
);
} | php | public function uploadPartToAmazon(
$filePath,
$uploadEndpoint,
$uploadRequestInfo,
$chunkNumber,
$chunk,
$numberOfChunks
) {
$finalKey = sprintf("%s/p%d", $uploadRequestInfo['multipart_params']['key'], $chunkNumber);
$formData = [
self::getFormDataParams('x-amz-credential', $uploadRequestInfo['multipart_params']['x-amz-credential']),
self::getFormDataParams('X-Amz-Signature', $uploadRequestInfo['multipart_params']['X-Amz-Signature']),
self::getFormDataParams('x-amz-algorithm', $uploadRequestInfo['multipart_params']['x-amz-algorithm']),
self::getFormDataParams('x-amz-date', $uploadRequestInfo['multipart_params']['x-amz-date']),
self::getFormDataParams('Policy', $uploadRequestInfo['multipart_params']['Policy']),
self::getFormDataParams('key', $finalKey),
self::getFormDataParams('acl', $uploadRequestInfo['multipart_params']['acl']),
self::getFormDataParams('success_action_status',
$uploadRequestInfo['multipart_params']['success_action_status']),
self::getFormDataParams('Content-Type', $uploadRequestInfo['multipart_params']['Content-Type']),
self::getFormDataParams('name', $filePath),
self::getFormDataParams('chunk', $chunkNumber),
self::getFormDataParams('chunks', $numberOfChunks),
self::getFormDataParams('Filename', $finalKey),
self::getFormDataParams('file', $chunk)
];
$stack = HandlerStack::create(new CurlHandler());
$oauthRequestClient = new Client([
'base_uri' => $uploadEndpoint,
'handler' => $stack,
]);
return $oauthRequestClient->postAsync($uploadEndpoint, ['multipart' => $formData])
->then(
function (ResponseInterface $response) {
return json_decode($response->getBody(), true);
}
);
} | [
"public",
"function",
"uploadPartToAmazon",
"(",
"$",
"filePath",
",",
"$",
"uploadEndpoint",
",",
"$",
"uploadRequestInfo",
",",
"$",
"chunkNumber",
",",
"$",
"chunk",
",",
"$",
"numberOfChunks",
")",
"{",
"$",
"finalKey",
"=",
"sprintf",
"(",
"\"%s/p%d\"",
",",
"$",
"uploadRequestInfo",
"[",
"'multipart_params'",
"]",
"[",
"'key'",
"]",
",",
"$",
"chunkNumber",
")",
";",
"$",
"formData",
"=",
"[",
"self",
"::",
"getFormDataParams",
"(",
"'x-amz-credential'",
",",
"$",
"uploadRequestInfo",
"[",
"'multipart_params'",
"]",
"[",
"'x-amz-credential'",
"]",
")",
",",
"self",
"::",
"getFormDataParams",
"(",
"'X-Amz-Signature'",
",",
"$",
"uploadRequestInfo",
"[",
"'multipart_params'",
"]",
"[",
"'X-Amz-Signature'",
"]",
")",
",",
"self",
"::",
"getFormDataParams",
"(",
"'x-amz-algorithm'",
",",
"$",
"uploadRequestInfo",
"[",
"'multipart_params'",
"]",
"[",
"'x-amz-algorithm'",
"]",
")",
",",
"self",
"::",
"getFormDataParams",
"(",
"'x-amz-date'",
",",
"$",
"uploadRequestInfo",
"[",
"'multipart_params'",
"]",
"[",
"'x-amz-date'",
"]",
")",
",",
"self",
"::",
"getFormDataParams",
"(",
"'Policy'",
",",
"$",
"uploadRequestInfo",
"[",
"'multipart_params'",
"]",
"[",
"'Policy'",
"]",
")",
",",
"self",
"::",
"getFormDataParams",
"(",
"'key'",
",",
"$",
"finalKey",
")",
",",
"self",
"::",
"getFormDataParams",
"(",
"'acl'",
",",
"$",
"uploadRequestInfo",
"[",
"'multipart_params'",
"]",
"[",
"'acl'",
"]",
")",
",",
"self",
"::",
"getFormDataParams",
"(",
"'success_action_status'",
",",
"$",
"uploadRequestInfo",
"[",
"'multipart_params'",
"]",
"[",
"'success_action_status'",
"]",
")",
",",
"self",
"::",
"getFormDataParams",
"(",
"'Content-Type'",
",",
"$",
"uploadRequestInfo",
"[",
"'multipart_params'",
"]",
"[",
"'Content-Type'",
"]",
")",
",",
"self",
"::",
"getFormDataParams",
"(",
"'name'",
",",
"$",
"filePath",
")",
",",
"self",
"::",
"getFormDataParams",
"(",
"'chunk'",
",",
"$",
"chunkNumber",
")",
",",
"self",
"::",
"getFormDataParams",
"(",
"'chunks'",
",",
"$",
"numberOfChunks",
")",
",",
"self",
"::",
"getFormDataParams",
"(",
"'Filename'",
",",
"$",
"finalKey",
")",
",",
"self",
"::",
"getFormDataParams",
"(",
"'file'",
",",
"$",
"chunk",
")",
"]",
";",
"$",
"stack",
"=",
"HandlerStack",
"::",
"create",
"(",
"new",
"CurlHandler",
"(",
")",
")",
";",
"$",
"oauthRequestClient",
"=",
"new",
"Client",
"(",
"[",
"'base_uri'",
"=>",
"$",
"uploadEndpoint",
",",
"'handler'",
"=>",
"$",
"stack",
",",
"]",
")",
";",
"return",
"$",
"oauthRequestClient",
"->",
"postAsync",
"(",
"$",
"uploadEndpoint",
",",
"[",
"'multipart'",
"=>",
"$",
"formData",
"]",
")",
"->",
"then",
"(",
"function",
"(",
"ResponseInterface",
"$",
"response",
")",
"{",
"return",
"json_decode",
"(",
"$",
"response",
"->",
"getBody",
"(",
")",
",",
"true",
")",
";",
"}",
")",
";",
"}"
]
| Uploads a chunk of a file to an S3 bucket using multipart upload.
@param $filePath
@param $uploadEndpoint
@param $uploadRequestInfo
@param $chunkNumber
@param $chunk
@param $numberOfChunks
@return \GuzzleHttp\Promise\PromiseInterface | [
"Uploads",
"a",
"chunk",
"of",
"a",
"file",
"to",
"an",
"S3",
"bucket",
"using",
"multipart",
"upload",
"."
]
| 1ba47afff4c986d91a473b69183d4aa35fd913b6 | https://github.com/Bynder/bynder-php-sdk/blob/1ba47afff4c986d91a473b69183d4aa35fd913b6/src/Bynder/Api/Impl/Upload/AmazonApi.php#L33-L72 | train |
aimeos/ai-laravel | lib/custom/src/MW/Cache/Laravel5.php | Laravel5.getMultiple | public function getMultiple( $keys, $default = null )
{
$result = [];
foreach( $keys as $key )
{
if( ( $entry = $this->object->get( $key ) ) !== false ) {
$result[$key] = $entry;
} else {
$result[$key] = $default;
}
}
return $result;
} | php | public function getMultiple( $keys, $default = null )
{
$result = [];
foreach( $keys as $key )
{
if( ( $entry = $this->object->get( $key ) ) !== false ) {
$result[$key] = $entry;
} else {
$result[$key] = $default;
}
}
return $result;
} | [
"public",
"function",
"getMultiple",
"(",
"$",
"keys",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"(",
"$",
"entry",
"=",
"$",
"this",
"->",
"object",
"->",
"get",
"(",
"$",
"key",
")",
")",
"!==",
"false",
")",
"{",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"$",
"entry",
";",
"}",
"else",
"{",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"$",
"default",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
]
| Returns the cached values for the given cache keys.
@inheritDoc
@param \Traversable|array $keys List of key strings for the requested cache entries
@param mixed $default Default value to return for keys that do not exist
@return array Associative list of key/value pairs for the requested cache
entries. If a cache entry doesn't exist, neither its key nor a value
will be in the result list | [
"Returns",
"the",
"cached",
"values",
"for",
"the",
"given",
"cache",
"keys",
"."
]
| 55b833be51bcfd867d27e6c2e1d2efaa7246c481 | https://github.com/aimeos/ai-laravel/blob/55b833be51bcfd867d27e6c2e1d2efaa7246c481/lib/custom/src/MW/Cache/Laravel5.php#L123-L137 | train |
Bynder/bynder-php-sdk | src/Bynder/Api/Impl/AssetBankManager.php | AssetBankManager.getMetapropertySpecificOptionDependencies | public function getMetapropertySpecificOptionDependencies($propertyId, $optionId, $query)
{
return $this->requestHandler->sendRequestAsync('GET',
'api/v4/metaproperties/' . $propertyId . '/options/' . $optionId . '/dependencies/',
['query' => $query]
);
} | php | public function getMetapropertySpecificOptionDependencies($propertyId, $optionId, $query)
{
return $this->requestHandler->sendRequestAsync('GET',
'api/v4/metaproperties/' . $propertyId . '/options/' . $optionId . '/dependencies/',
['query' => $query]
);
} | [
"public",
"function",
"getMetapropertySpecificOptionDependencies",
"(",
"$",
"propertyId",
",",
"$",
"optionId",
",",
"$",
"query",
")",
"{",
"return",
"$",
"this",
"->",
"requestHandler",
"->",
"sendRequestAsync",
"(",
"'GET'",
",",
"'api/v4/metaproperties/'",
".",
"$",
"propertyId",
".",
"'/options/'",
".",
"$",
"optionId",
".",
"'/dependencies/'",
",",
"[",
"'query'",
"=>",
"$",
"query",
"]",
")",
";",
"}"
]
| Gets a list of all meta property option dependencies for a specific option
@param string $propertyId Meta property id
@param string $optionId Option id
@param array $query Associative array of parameters to filter the results.
@return \GuzzleHttp\Promise\Promise with all meta property options dependencies.
@throws \Exception | [
"Gets",
"a",
"list",
"of",
"all",
"meta",
"property",
"option",
"dependencies",
"for",
"a",
"specific",
"option"
]
| 1ba47afff4c986d91a473b69183d4aa35fd913b6 | https://github.com/Bynder/bynder-php-sdk/blob/1ba47afff4c986d91a473b69183d4aa35fd913b6/src/Bynder/Api/Impl/AssetBankManager.php#L186-L192 | train |
Bynder/bynder-php-sdk | src/Bynder/Api/Impl/AssetBankManager.php | AssetBankManager.getMediaDownloadLocationForAssetItem | public function getMediaDownloadLocationForAssetItem($mediaId, $itemId, $hash = false)
{
return $this->requestHandler->sendRequestAsync('GET', 'api/v4/media/' . $mediaId . '/download/' . $itemId . '/',
[
'query' =>
['hash' => $hash]
]
);
} | php | public function getMediaDownloadLocationForAssetItem($mediaId, $itemId, $hash = false)
{
return $this->requestHandler->sendRequestAsync('GET', 'api/v4/media/' . $mediaId . '/download/' . $itemId . '/',
[
'query' =>
['hash' => $hash]
]
);
} | [
"public",
"function",
"getMediaDownloadLocationForAssetItem",
"(",
"$",
"mediaId",
",",
"$",
"itemId",
",",
"$",
"hash",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"requestHandler",
"->",
"sendRequestAsync",
"(",
"'GET'",
",",
"'api/v4/media/'",
".",
"$",
"mediaId",
".",
"'/download/'",
".",
"$",
"itemId",
".",
"'/'",
",",
"[",
"'query'",
"=>",
"[",
"'hash'",
"=>",
"$",
"hash",
"]",
"]",
")",
";",
"}"
]
| Gets the download location for a specific asset item
@param string $mediaId The Bynder media identifier (Asset id).
@param string $itemId The id of the specific asset item you’d like to download.
@param boolean $hash Indicates whether or not to treat the itemId as a hashed item id.
@return \GuzzleHttp\Promise\Promise with the download location for a specific asset.
@throws \Exception | [
"Gets",
"the",
"download",
"location",
"for",
"a",
"specific",
"asset",
"item"
]
| 1ba47afff4c986d91a473b69183d4aa35fd913b6 | https://github.com/Bynder/bynder-php-sdk/blob/1ba47afff4c986d91a473b69183d4aa35fd913b6/src/Bynder/Api/Impl/AssetBankManager.php#L337-L345 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Util.php | Sailthru_Util.extractParamValues | public static function extractParamValues($params, &$values) {
foreach ($params as $k => $v) {
if (is_array($v) || is_object($v)) {
self::extractParamValues($v, $values);
} else {
if (is_bool($v)) {
//if a value is set as false, invalid hash will generate
//https://github.com/sailthru/sailthru-php5-client/issues/4
$v = intval($v);
}
$values[] = $v;
}
}
} | php | public static function extractParamValues($params, &$values) {
foreach ($params as $k => $v) {
if (is_array($v) || is_object($v)) {
self::extractParamValues($v, $values);
} else {
if (is_bool($v)) {
//if a value is set as false, invalid hash will generate
//https://github.com/sailthru/sailthru-php5-client/issues/4
$v = intval($v);
}
$values[] = $v;
}
}
} | [
"public",
"static",
"function",
"extractParamValues",
"(",
"$",
"params",
",",
"&",
"$",
"values",
")",
"{",
"foreach",
"(",
"$",
"params",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"v",
")",
"||",
"is_object",
"(",
"$",
"v",
")",
")",
"{",
"self",
"::",
"extractParamValues",
"(",
"$",
"v",
",",
"$",
"values",
")",
";",
"}",
"else",
"{",
"if",
"(",
"is_bool",
"(",
"$",
"v",
")",
")",
"{",
"//if a value is set as false, invalid hash will generate",
"//https://github.com/sailthru/sailthru-php5-client/issues/4",
"$",
"v",
"=",
"intval",
"(",
"$",
"v",
")",
";",
"}",
"$",
"values",
"[",
"]",
"=",
"$",
"v",
";",
"}",
"}",
"}"
]
| Extracts the values of a set of parameters, recursing into nested assoc arrays.
@param array $params
@param array $values | [
"Extracts",
"the",
"values",
"of",
"a",
"set",
"of",
"parameters",
"recursing",
"into",
"nested",
"assoc",
"arrays",
"."
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Util.php#L42-L55 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.send | public function send($template, $email, $vars = [ ], $options = [ ], $schedule_time = null) {
$post = [ ];
$post['template'] = $template;
$post['email'] = $email;
$post['vars'] = $vars;
$post['options'] = $options;
if ($schedule_time) {
$post['schedule_time'] = $schedule_time;
}
$result = $this->apiPost('send', $post);
return $result;
} | php | public function send($template, $email, $vars = [ ], $options = [ ], $schedule_time = null) {
$post = [ ];
$post['template'] = $template;
$post['email'] = $email;
$post['vars'] = $vars;
$post['options'] = $options;
if ($schedule_time) {
$post['schedule_time'] = $schedule_time;
}
$result = $this->apiPost('send', $post);
return $result;
} | [
"public",
"function",
"send",
"(",
"$",
"template",
",",
"$",
"email",
",",
"$",
"vars",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
",",
"$",
"schedule_time",
"=",
"null",
")",
"{",
"$",
"post",
"=",
"[",
"]",
";",
"$",
"post",
"[",
"'template'",
"]",
"=",
"$",
"template",
";",
"$",
"post",
"[",
"'email'",
"]",
"=",
"$",
"email",
";",
"$",
"post",
"[",
"'vars'",
"]",
"=",
"$",
"vars",
";",
"$",
"post",
"[",
"'options'",
"]",
"=",
"$",
"options",
";",
"if",
"(",
"$",
"schedule_time",
")",
"{",
"$",
"post",
"[",
"'schedule_time'",
"]",
"=",
"$",
"schedule_time",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"apiPost",
"(",
"'send'",
",",
"$",
"post",
")",
";",
"return",
"$",
"result",
";",
"}"
]
| Remotely send an email template to a single email address.
If you pass the $schedule_time parameter, the send will be scheduled for a future time.
Options:
replyto: override Reply-To header
test: send as test email (subject line will be marked, will not count towards stats)
@param string $template
@param string $email
@param array $vars
@param array $options
@param string $schedule_time
@link http://docs.sailthru.com/api/send
@return array API result | [
"Remotely",
"send",
"an",
"email",
"template",
"to",
"a",
"single",
"email",
"address",
"."
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L125-L136 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.multisend | public function multisend($template_name, $emails, $vars = [ ], $evars = [ ], $options = [ ]) {
$post['template'] = $template_name;
$post['email'] = is_array($emails) ? implode(',', $emails) : $emails;
$post['vars'] = $vars;
$post['evars'] = $evars;
$post['options'] = $options;
$result = $this->apiPost('send', $post);
return $result;
} | php | public function multisend($template_name, $emails, $vars = [ ], $evars = [ ], $options = [ ]) {
$post['template'] = $template_name;
$post['email'] = is_array($emails) ? implode(',', $emails) : $emails;
$post['vars'] = $vars;
$post['evars'] = $evars;
$post['options'] = $options;
$result = $this->apiPost('send', $post);
return $result;
} | [
"public",
"function",
"multisend",
"(",
"$",
"template_name",
",",
"$",
"emails",
",",
"$",
"vars",
"=",
"[",
"]",
",",
"$",
"evars",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"post",
"[",
"'template'",
"]",
"=",
"$",
"template_name",
";",
"$",
"post",
"[",
"'email'",
"]",
"=",
"is_array",
"(",
"$",
"emails",
")",
"?",
"implode",
"(",
"','",
",",
"$",
"emails",
")",
":",
"$",
"emails",
";",
"$",
"post",
"[",
"'vars'",
"]",
"=",
"$",
"vars",
";",
"$",
"post",
"[",
"'evars'",
"]",
"=",
"$",
"evars",
";",
"$",
"post",
"[",
"'options'",
"]",
"=",
"$",
"options",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"apiPost",
"(",
"'send'",
",",
"$",
"post",
")",
";",
"return",
"$",
"result",
";",
"}"
]
| Remotely send an email template to multiple email addresses.
Use the evars parameter to set replacement vars for a particular email address.
@param string $template_name
@param array $emails
@param array $vars
@param array $evars
@param array $options
@link http://docs.sailthru.com/api/send
@return array API result | [
"Remotely",
"send",
"an",
"email",
"template",
"to",
"multiple",
"email",
"addresses",
"."
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L151-L159 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.scheduleBlast | public function scheduleBlast($name, $list, $schedule_time, $from_name,
$from_email, $subject, $content_html, $content_text, $options = [ ]
) {
$data = $options;
$data['name'] = $name;
$data['list'] = $list;
$data['schedule_time'] = $schedule_time;
$data['from_name'] = $from_name;
$data['from_email'] = $from_email;
$data['subject'] = $subject;
$data['content_html'] = $content_html;
$data['content_text'] = $content_text;
return $this->apiPost('blast', $data);
} | php | public function scheduleBlast($name, $list, $schedule_time, $from_name,
$from_email, $subject, $content_html, $content_text, $options = [ ]
) {
$data = $options;
$data['name'] = $name;
$data['list'] = $list;
$data['schedule_time'] = $schedule_time;
$data['from_name'] = $from_name;
$data['from_email'] = $from_email;
$data['subject'] = $subject;
$data['content_html'] = $content_html;
$data['content_text'] = $content_text;
return $this->apiPost('blast', $data);
} | [
"public",
"function",
"scheduleBlast",
"(",
"$",
"name",
",",
"$",
"list",
",",
"$",
"schedule_time",
",",
"$",
"from_name",
",",
"$",
"from_email",
",",
"$",
"subject",
",",
"$",
"content_html",
",",
"$",
"content_text",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"data",
"=",
"$",
"options",
";",
"$",
"data",
"[",
"'name'",
"]",
"=",
"$",
"name",
";",
"$",
"data",
"[",
"'list'",
"]",
"=",
"$",
"list",
";",
"$",
"data",
"[",
"'schedule_time'",
"]",
"=",
"$",
"schedule_time",
";",
"$",
"data",
"[",
"'from_name'",
"]",
"=",
"$",
"from_name",
";",
"$",
"data",
"[",
"'from_email'",
"]",
"=",
"$",
"from_email",
";",
"$",
"data",
"[",
"'subject'",
"]",
"=",
"$",
"subject",
";",
"$",
"data",
"[",
"'content_html'",
"]",
"=",
"$",
"content_html",
";",
"$",
"data",
"[",
"'content_text'",
"]",
"=",
"$",
"content_text",
";",
"return",
"$",
"this",
"->",
"apiPost",
"(",
"'blast'",
",",
"$",
"data",
")",
";",
"}"
]
| Schedule a mass mail blast
@param string $name the name to give to this new blast
@param string $list the mailing list name to send to
@param string $schedule_time when the blast should send. Dates in the past will be scheduled for immediate delivery. Any English textual datetime format known to PHP's strtotime function is acceptable, such as 2009-03-18 23:57:22 UTC, now (immediate delivery), +3 hours (3 hours from now), or February 14, 9:30 EST. Be sure to specify a timezone if you use an exact time.
@param string $from_name the name appearing in the "From" of the email
@param string $from_email The email address to use as the "from" – choose from any of your verified emails
@param string $subject the subject line of the email
@param string $content_html the HTML-format version of the email
@param string $content_text the text-format version of the email
@param array $options associative array
blast_id
copy_blast
copy_template
replyto
report_email
is_link_tracking
is_google_analytics
is_public
suppress_list
test_vars
email_hour_range
abtest
test_percent
data_feed_url
@link http://docs.sailthru.com/api/blast
@return array API result | [
"Schedule",
"a",
"mass",
"mail",
"blast"
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L276-L290 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.scheduleBlastFromTemplate | public function scheduleBlastFromTemplate($template, $list, $schedule_time, $options = [ ]) {
$data = $options;
$data['copy_template'] = $template;
$data['list'] = $list;
$data['schedule_time'] = $schedule_time;
return $this->apiPost('blast', $data);
} | php | public function scheduleBlastFromTemplate($template, $list, $schedule_time, $options = [ ]) {
$data = $options;
$data['copy_template'] = $template;
$data['list'] = $list;
$data['schedule_time'] = $schedule_time;
return $this->apiPost('blast', $data);
} | [
"public",
"function",
"scheduleBlastFromTemplate",
"(",
"$",
"template",
",",
"$",
"list",
",",
"$",
"schedule_time",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"data",
"=",
"$",
"options",
";",
"$",
"data",
"[",
"'copy_template'",
"]",
"=",
"$",
"template",
";",
"$",
"data",
"[",
"'list'",
"]",
"=",
"$",
"list",
";",
"$",
"data",
"[",
"'schedule_time'",
"]",
"=",
"$",
"schedule_time",
";",
"return",
"$",
"this",
"->",
"apiPost",
"(",
"'blast'",
",",
"$",
"data",
")",
";",
"}"
]
| Schedule a mass mail from a template
@param String $template
@param String $list
@param String $schedule_time
@param array $options
@link http://docs.sailthru.com/api/blast
@return array API result | [
"Schedule",
"a",
"mass",
"mail",
"from",
"a",
"template"
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L302-L308 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.scheduleBlastFromBlast | public function scheduleBlastFromBlast($blast_id, $schedule_time, $options = [ ]) {
$data = $options;
$data['copy_blast'] = $blast_id;
$data['schedule_time'] = $schedule_time;
return $this->apiPost('blast', $data);
} | php | public function scheduleBlastFromBlast($blast_id, $schedule_time, $options = [ ]) {
$data = $options;
$data['copy_blast'] = $blast_id;
$data['schedule_time'] = $schedule_time;
return $this->apiPost('blast', $data);
} | [
"public",
"function",
"scheduleBlastFromBlast",
"(",
"$",
"blast_id",
",",
"$",
"schedule_time",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"data",
"=",
"$",
"options",
";",
"$",
"data",
"[",
"'copy_blast'",
"]",
"=",
"$",
"blast_id",
";",
"$",
"data",
"[",
"'schedule_time'",
"]",
"=",
"$",
"schedule_time",
";",
"return",
"$",
"this",
"->",
"apiPost",
"(",
"'blast'",
",",
"$",
"data",
")",
";",
"}"
]
| Schedule a mass mail blast from previous blast
@param String|Integer $blast_id
@param String $schedule_time
@param array $options
@link http://docs.sailthru.com/api/blast
@return array API result | [
"Schedule",
"a",
"mass",
"mail",
"blast",
"from",
"previous",
"blast"
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L319-L324 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.updateBlast | public function updateBlast($blast_id, $name = null, $list = null,
$schedule_time = null, $from_name = null, $from_email = null,
$subject = null, $content_html = null, $content_text = null,
$options = [ ]
) {
$data = $options;
$data['blast_id'] = $blast_id;
if (!is_null($name)) {
$data['name'] = $name;
}
if (!is_null($list)) {
$data['list'] = $list;
}
if (!is_null($schedule_time)) {
$data['schedule_time'] = $schedule_time;
}
if (!is_null($from_name)) {
$data['from_name'] = $from_name;
}
if (!is_null($from_email)) {
$data['from_email'] = $from_email;
}
if (!is_null($subject)) {
$data['subject'] = $subject;
}
if (!is_null($content_html)) {
$data['content_html'] = $content_html;
}
if (!is_null($content_text)) {
$data['content_text'] = $content_text;
}
return $this->apiPost('blast', $data);
} | php | public function updateBlast($blast_id, $name = null, $list = null,
$schedule_time = null, $from_name = null, $from_email = null,
$subject = null, $content_html = null, $content_text = null,
$options = [ ]
) {
$data = $options;
$data['blast_id'] = $blast_id;
if (!is_null($name)) {
$data['name'] = $name;
}
if (!is_null($list)) {
$data['list'] = $list;
}
if (!is_null($schedule_time)) {
$data['schedule_time'] = $schedule_time;
}
if (!is_null($from_name)) {
$data['from_name'] = $from_name;
}
if (!is_null($from_email)) {
$data['from_email'] = $from_email;
}
if (!is_null($subject)) {
$data['subject'] = $subject;
}
if (!is_null($content_html)) {
$data['content_html'] = $content_html;
}
if (!is_null($content_text)) {
$data['content_text'] = $content_text;
}
return $this->apiPost('blast', $data);
} | [
"public",
"function",
"updateBlast",
"(",
"$",
"blast_id",
",",
"$",
"name",
"=",
"null",
",",
"$",
"list",
"=",
"null",
",",
"$",
"schedule_time",
"=",
"null",
",",
"$",
"from_name",
"=",
"null",
",",
"$",
"from_email",
"=",
"null",
",",
"$",
"subject",
"=",
"null",
",",
"$",
"content_html",
"=",
"null",
",",
"$",
"content_text",
"=",
"null",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"data",
"=",
"$",
"options",
";",
"$",
"data",
"[",
"'blast_id'",
"]",
"=",
"$",
"blast_id",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"name",
")",
")",
"{",
"$",
"data",
"[",
"'name'",
"]",
"=",
"$",
"name",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"list",
")",
")",
"{",
"$",
"data",
"[",
"'list'",
"]",
"=",
"$",
"list",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"schedule_time",
")",
")",
"{",
"$",
"data",
"[",
"'schedule_time'",
"]",
"=",
"$",
"schedule_time",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"from_name",
")",
")",
"{",
"$",
"data",
"[",
"'from_name'",
"]",
"=",
"$",
"from_name",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"from_email",
")",
")",
"{",
"$",
"data",
"[",
"'from_email'",
"]",
"=",
"$",
"from_email",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"subject",
")",
")",
"{",
"$",
"data",
"[",
"'subject'",
"]",
"=",
"$",
"subject",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"content_html",
")",
")",
"{",
"$",
"data",
"[",
"'content_html'",
"]",
"=",
"$",
"content_html",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"content_text",
")",
")",
"{",
"$",
"data",
"[",
"'content_text'",
"]",
"=",
"$",
"content_text",
";",
"}",
"return",
"$",
"this",
"->",
"apiPost",
"(",
"'blast'",
",",
"$",
"data",
")",
";",
"}"
]
| updates existing blast
@param string /integer $blast_id
@param string $name
@param string $list
@param string $schedule_time
@param string $from_name
@param string $from_email
@param string $subject
@param string $content_html
@param string $content_text
@param array $options associative array
blast_id
copy_blast
copy_template
replyto
report_email
is_link_tracking
is_google_analytics
is_public
suppress_list
test_vars
email_hour_range
abtest
test_percent
data_feed_url
@link http://docs.sailthru.com/api/blast
@return array API result | [
"updates",
"existing",
"blast"
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L356-L389 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.saveTemplate | public function saveTemplate($template_name, array $template_fields = [ ]) {
$data = $template_fields;
$data['template'] = $template_name;
return $this->apiPost('template', $data);
} | php | public function saveTemplate($template_name, array $template_fields = [ ]) {
$data = $template_fields;
$data['template'] = $template_name;
return $this->apiPost('template', $data);
} | [
"public",
"function",
"saveTemplate",
"(",
"$",
"template_name",
",",
"array",
"$",
"template_fields",
"=",
"[",
"]",
")",
"{",
"$",
"data",
"=",
"$",
"template_fields",
";",
"$",
"data",
"[",
"'template'",
"]",
"=",
"$",
"template_name",
";",
"return",
"$",
"this",
"->",
"apiPost",
"(",
"'template'",
",",
"$",
"data",
")",
";",
"}"
]
| Save a template.
@param string $template_name
@param array $template_fields
@link http://docs.sailthru.com/api/template
@return array API result | [
"Save",
"a",
"template",
"."
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L472-L476 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.saveTemplateFromRevision | public function saveTemplateFromRevision($template_name, $revision_id) {
$revision_id = (int) $revision_id;
return $this->saveTemplate($template_name, [ 'revision' => $revision_id ]);
} | php | public function saveTemplateFromRevision($template_name, $revision_id) {
$revision_id = (int) $revision_id;
return $this->saveTemplate($template_name, [ 'revision' => $revision_id ]);
} | [
"public",
"function",
"saveTemplateFromRevision",
"(",
"$",
"template_name",
",",
"$",
"revision_id",
")",
"{",
"$",
"revision_id",
"=",
"(",
"int",
")",
"$",
"revision_id",
";",
"return",
"$",
"this",
"->",
"saveTemplate",
"(",
"$",
"template_name",
",",
"[",
"'revision'",
"=>",
"$",
"revision_id",
"]",
")",
";",
"}"
]
| Save a template from revision
@param string $template_name
@param $revision_id
@return array API result
@link http://docs.sailthru.com/api/template | [
"Save",
"a",
"template",
"from",
"revision"
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L486-L489 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.saveInclude | public function saveInclude($include_name, array $include_fields = [ ]) {
$data = $include_fields;
$data['include'] = $include_name;
return $this->apiPost('include', $data);
} | php | public function saveInclude($include_name, array $include_fields = [ ]) {
$data = $include_fields;
$data['include'] = $include_name;
return $this->apiPost('include', $data);
} | [
"public",
"function",
"saveInclude",
"(",
"$",
"include_name",
",",
"array",
"$",
"include_fields",
"=",
"[",
"]",
")",
"{",
"$",
"data",
"=",
"$",
"include_fields",
";",
"$",
"data",
"[",
"'include'",
"]",
"=",
"$",
"include_name",
";",
"return",
"$",
"this",
"->",
"apiPost",
"(",
"'include'",
",",
"$",
"data",
")",
";",
"}"
]
| Save an include
@param string $include_name
@param array $include_fields
@return array API result | [
"Save",
"an",
"include"
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L528-L532 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.saveList | public function saveList($list, $type = null, $primary = null, $query = [ ], $vars = []) {
$data = [
'list' => $list,
'type' => $type,
'primary' => $primary ? 1 : 0,
'query' => $query,
'vars' => $vars,
];
return $this->apiPost('list', $data);
} | php | public function saveList($list, $type = null, $primary = null, $query = [ ], $vars = []) {
$data = [
'list' => $list,
'type' => $type,
'primary' => $primary ? 1 : 0,
'query' => $query,
'vars' => $vars,
];
return $this->apiPost('list', $data);
} | [
"public",
"function",
"saveList",
"(",
"$",
"list",
",",
"$",
"type",
"=",
"null",
",",
"$",
"primary",
"=",
"null",
",",
"$",
"query",
"=",
"[",
"]",
",",
"$",
"vars",
"=",
"[",
"]",
")",
"{",
"$",
"data",
"=",
"[",
"'list'",
"=>",
"$",
"list",
",",
"'type'",
"=>",
"$",
"type",
",",
"'primary'",
"=>",
"$",
"primary",
"?",
"1",
":",
"0",
",",
"'query'",
"=>",
"$",
"query",
",",
"'vars'",
"=>",
"$",
"vars",
",",
"]",
";",
"return",
"$",
"this",
"->",
"apiPost",
"(",
"'list'",
",",
"$",
"data",
")",
";",
"}"
]
| Create a list, or update a list.
@param string $list
@param string $list
@param string $type
@param bool $primary
@param array $query
@return array
@link http://docs.sailthru.com/api/list
@link http://docs.sailthru.com/api/query | [
"Create",
"a",
"list",
"or",
"update",
"a",
"list",
"."
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L566-L575 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.purchase | public function purchase($email, array $items, $incomplete = null, $message_id = null, array $options = [ ]) {
$data = $options;
$data['email'] = $email;
$data['items'] = $items;
if (!is_null($incomplete)) {
$data['incomplete'] = (int) $incomplete;
}
if (!is_null($message_id)) {
$data['message_id'] = $message_id;
}
return $this->apiPost('purchase', $data);
} | php | public function purchase($email, array $items, $incomplete = null, $message_id = null, array $options = [ ]) {
$data = $options;
$data['email'] = $email;
$data['items'] = $items;
if (!is_null($incomplete)) {
$data['incomplete'] = (int) $incomplete;
}
if (!is_null($message_id)) {
$data['message_id'] = $message_id;
}
return $this->apiPost('purchase', $data);
} | [
"public",
"function",
"purchase",
"(",
"$",
"email",
",",
"array",
"$",
"items",
",",
"$",
"incomplete",
"=",
"null",
",",
"$",
"message_id",
"=",
"null",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"data",
"=",
"$",
"options",
";",
"$",
"data",
"[",
"'email'",
"]",
"=",
"$",
"email",
";",
"$",
"data",
"[",
"'items'",
"]",
"=",
"$",
"items",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"incomplete",
")",
")",
"{",
"$",
"data",
"[",
"'incomplete'",
"]",
"=",
"(",
"int",
")",
"$",
"incomplete",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"message_id",
")",
")",
"{",
"$",
"data",
"[",
"'message_id'",
"]",
"=",
"$",
"message_id",
";",
"}",
"return",
"$",
"this",
"->",
"apiPost",
"(",
"'purchase'",
",",
"$",
"data",
")",
";",
"}"
]
| Record that a user has made a purchase, or has added items to their purchase total.
@link http://docs.sailthru.com/api/purchase
@return array API result | [
"Record",
"that",
"a",
"user",
"has",
"made",
"a",
"purchase",
"or",
"has",
"added",
"items",
"to",
"their",
"purchase",
"total",
"."
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L691-L702 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.purchaseIncomplete | public function purchaseIncomplete($email, array $items, $message_id, array $options = [ ]) {
return $this->purchase($email, $items, 1, $message_id, $options);
} | php | public function purchaseIncomplete($email, array $items, $message_id, array $options = [ ]) {
return $this->purchase($email, $items, 1, $message_id, $options);
} | [
"public",
"function",
"purchaseIncomplete",
"(",
"$",
"email",
",",
"array",
"$",
"items",
",",
"$",
"message_id",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"purchase",
"(",
"$",
"email",
",",
"$",
"items",
",",
"1",
",",
"$",
"message_id",
",",
"$",
"options",
")",
";",
"}"
]
| Make a purchase API call with incomplete flag
@link http://docs.sailthru.com/api/purchase
@return array API result | [
"Make",
"a",
"purchase",
"API",
"call",
"with",
"incomplete",
"flag"
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L709-L711 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.stats_list | public function stats_list($list = null, $date = null) {
$data = [ ];
if (!is_null($list)) {
$data['list'] = $list;
}
if (!is_null($date)) {
$data['date'] = $date;
}
$data['stat'] = 'list';
return $this->stats($data);
} | php | public function stats_list($list = null, $date = null) {
$data = [ ];
if (!is_null($list)) {
$data['list'] = $list;
}
if (!is_null($date)) {
$data['date'] = $date;
}
$data['stat'] = 'list';
return $this->stats($data);
} | [
"public",
"function",
"stats_list",
"(",
"$",
"list",
"=",
"null",
",",
"$",
"date",
"=",
"null",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"list",
")",
")",
"{",
"$",
"data",
"[",
"'list'",
"]",
"=",
"$",
"list",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"date",
")",
")",
"{",
"$",
"data",
"[",
"'date'",
"]",
"=",
"$",
"date",
";",
"}",
"$",
"data",
"[",
"'stat'",
"]",
"=",
"'list'",
";",
"return",
"$",
"this",
"->",
"stats",
"(",
"$",
"data",
")",
";",
"}"
]
| Retrieve information about your subscriber counts on a particular list, on a particular day.
@link http://docs.sailthru.com/api/stats
@param String $list
@param String $date
@return array API result | [
"Retrieve",
"information",
"about",
"your",
"subscriber",
"counts",
"on",
"a",
"particular",
"list",
"on",
"a",
"particular",
"day",
"."
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L720-L731 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.stats_blast | public function stats_blast($blast_id = null, $start_date = null, $end_date = null, array $data = [ ]) {
$data['stat'] = 'blast';
if (!is_null($blast_id)) {
$data['blast_id'] = $blast_id;
}
if (!is_null($start_date)) {
$data['start_date'] = $start_date;
}
if (!is_null($end_date)) {
$data['end_date'] = $end_date;
}
return $this->stats($data);
} | php | public function stats_blast($blast_id = null, $start_date = null, $end_date = null, array $data = [ ]) {
$data['stat'] = 'blast';
if (!is_null($blast_id)) {
$data['blast_id'] = $blast_id;
}
if (!is_null($start_date)) {
$data['start_date'] = $start_date;
}
if (!is_null($end_date)) {
$data['end_date'] = $end_date;
}
return $this->stats($data);
} | [
"public",
"function",
"stats_blast",
"(",
"$",
"blast_id",
"=",
"null",
",",
"$",
"start_date",
"=",
"null",
",",
"$",
"end_date",
"=",
"null",
",",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"data",
"[",
"'stat'",
"]",
"=",
"'blast'",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"blast_id",
")",
")",
"{",
"$",
"data",
"[",
"'blast_id'",
"]",
"=",
"$",
"blast_id",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"start_date",
")",
")",
"{",
"$",
"data",
"[",
"'start_date'",
"]",
"=",
"$",
"start_date",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"end_date",
")",
")",
"{",
"$",
"data",
"[",
"'end_date'",
"]",
"=",
"$",
"end_date",
";",
"}",
"return",
"$",
"this",
"->",
"stats",
"(",
"$",
"data",
")",
";",
"}"
]
| Retrieve information about a particular blast or aggregated information from all of blasts over a specified date range.
@param array $data
@return array API result | [
"Retrieve",
"information",
"about",
"a",
"particular",
"blast",
"or",
"aggregated",
"information",
"from",
"all",
"of",
"blasts",
"over",
"a",
"specified",
"date",
"range",
"."
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L738-L750 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.stats_send | public function stats_send($template = null, $start_date = null, $end_date = null, array $data = [ ]) {
$data['stat'] = 'send';
if (!is_null($template)) {
$data['template'] = $template;
}
if (!is_null($start_date)) {
$data['start_date'] = $start_date;
}
if (!is_null($end_date)) {
$data['end_date'] = $end_date;
}
return $this->stats($data);
} | php | public function stats_send($template = null, $start_date = null, $end_date = null, array $data = [ ]) {
$data['stat'] = 'send';
if (!is_null($template)) {
$data['template'] = $template;
}
if (!is_null($start_date)) {
$data['start_date'] = $start_date;
}
if (!is_null($end_date)) {
$data['end_date'] = $end_date;
}
return $this->stats($data);
} | [
"public",
"function",
"stats_send",
"(",
"$",
"template",
"=",
"null",
",",
"$",
"start_date",
"=",
"null",
",",
"$",
"end_date",
"=",
"null",
",",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"data",
"[",
"'stat'",
"]",
"=",
"'send'",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"template",
")",
")",
"{",
"$",
"data",
"[",
"'template'",
"]",
"=",
"$",
"template",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"start_date",
")",
")",
"{",
"$",
"data",
"[",
"'start_date'",
"]",
"=",
"$",
"start_date",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"end_date",
")",
")",
"{",
"$",
"data",
"[",
"'end_date'",
"]",
"=",
"$",
"end_date",
";",
"}",
"return",
"$",
"this",
"->",
"stats",
"(",
"$",
"data",
")",
";",
"}"
]
| Retrieve information about a particular send or aggregated information from all of templates over a specified date range.
@param array $data
@return array API result | [
"Retrieve",
"information",
"about",
"a",
"particular",
"send",
"or",
"aggregated",
"information",
"from",
"all",
"of",
"templates",
"over",
"a",
"specified",
"date",
"range",
"."
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L757-L771 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.processJob | protected function processJob($job, array $data = [ ], $report_email = false, $postback_url = false, array $binary_data_param = [ ],
array $options = [ ]) {
$data['job'] = $job;
if ($report_email) {
$data['report_email'] = $report_email;
}
if ($postback_url) {
$data['postback_url'] = $postback_url;
}
return $this->apiPost('job', $data, $binary_data_param, $options);
} | php | protected function processJob($job, array $data = [ ], $report_email = false, $postback_url = false, array $binary_data_param = [ ],
array $options = [ ]) {
$data['job'] = $job;
if ($report_email) {
$data['report_email'] = $report_email;
}
if ($postback_url) {
$data['postback_url'] = $postback_url;
}
return $this->apiPost('job', $data, $binary_data_param, $options);
} | [
"protected",
"function",
"processJob",
"(",
"$",
"job",
",",
"array",
"$",
"data",
"=",
"[",
"]",
",",
"$",
"report_email",
"=",
"false",
",",
"$",
"postback_url",
"=",
"false",
",",
"array",
"$",
"binary_data_param",
"=",
"[",
"]",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"data",
"[",
"'job'",
"]",
"=",
"$",
"job",
";",
"if",
"(",
"$",
"report_email",
")",
"{",
"$",
"data",
"[",
"'report_email'",
"]",
"=",
"$",
"report_email",
";",
"}",
"if",
"(",
"$",
"postback_url",
")",
"{",
"$",
"data",
"[",
"'postback_url'",
"]",
"=",
"$",
"postback_url",
";",
"}",
"return",
"$",
"this",
"->",
"apiPost",
"(",
"'job'",
",",
"$",
"data",
",",
"$",
"binary_data_param",
",",
"$",
"options",
")",
";",
"}"
]
| process job api call
@param String $job
@param array $data
@param bool|String $report_email
@param bool|String $postback_url
@param array $binary_data_param
@param array $options
@return array | [
"process",
"job",
"api",
"call"
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L920-L930 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.processImportJob | public function processImportJob($list, $emails, $report_email = false, $postback_url = false, array $options = [ ]) {
$data = [
'emails' => $emails,
'list' => $list
];
return $this->processJob('import', $data, $report_email, $postback_url, [ ], $options);
} | php | public function processImportJob($list, $emails, $report_email = false, $postback_url = false, array $options = [ ]) {
$data = [
'emails' => $emails,
'list' => $list
];
return $this->processJob('import', $data, $report_email, $postback_url, [ ], $options);
} | [
"public",
"function",
"processImportJob",
"(",
"$",
"list",
",",
"$",
"emails",
",",
"$",
"report_email",
"=",
"false",
",",
"$",
"postback_url",
"=",
"false",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"data",
"=",
"[",
"'emails'",
"=>",
"$",
"emails",
",",
"'list'",
"=>",
"$",
"list",
"]",
";",
"return",
"$",
"this",
"->",
"processJob",
"(",
"'import'",
",",
"$",
"data",
",",
"$",
"report_email",
",",
"$",
"postback_url",
",",
"[",
"]",
",",
"$",
"options",
")",
";",
"}"
]
| Process import job from given email string CSV
@param String $list
@param String $emails
@param bool|String $report_email
@param bool|String $postback_url
@return array | [
"Process",
"import",
"job",
"from",
"given",
"email",
"string",
"CSV"
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L940-L946 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.processImportJobFromFile | public function processImportJobFromFile($list, $file_path, $report_email = false, $postback_url = false, array $options = [ ]) {
$data = [
'file' => $file_path,
'list' => $list
];
return $this->processJob('import', $data, $report_email, $postback_url, [ 'file' ], $options);
} | php | public function processImportJobFromFile($list, $file_path, $report_email = false, $postback_url = false, array $options = [ ]) {
$data = [
'file' => $file_path,
'list' => $list
];
return $this->processJob('import', $data, $report_email, $postback_url, [ 'file' ], $options);
} | [
"public",
"function",
"processImportJobFromFile",
"(",
"$",
"list",
",",
"$",
"file_path",
",",
"$",
"report_email",
"=",
"false",
",",
"$",
"postback_url",
"=",
"false",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"data",
"=",
"[",
"'file'",
"=>",
"$",
"file_path",
",",
"'list'",
"=>",
"$",
"list",
"]",
";",
"return",
"$",
"this",
"->",
"processJob",
"(",
"'import'",
",",
"$",
"data",
",",
"$",
"report_email",
",",
"$",
"postback_url",
",",
"[",
"'file'",
"]",
",",
"$",
"options",
")",
";",
"}"
]
| Process import job from given file path of a CSV or email per line file
@param String $list
@param $file_path
@param bool|String $report_email
@param bool|String $postback_url
@param array $options
@return array | [
"Process",
"import",
"job",
"from",
"given",
"file",
"path",
"of",
"a",
"CSV",
"or",
"email",
"per",
"line",
"file"
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L958-L964 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.processPurchaseImportJobFromFile | public function processPurchaseImportJobFromFile($file_path, $report_email = false, $postback_url = false, array $options = [ ]) {
$data = [
'file' => $file_path
];
return $this->processJob('purchase_import', $data, $report_email, $postback_url, [ 'file' ], $options);
} | php | public function processPurchaseImportJobFromFile($file_path, $report_email = false, $postback_url = false, array $options = [ ]) {
$data = [
'file' => $file_path
];
return $this->processJob('purchase_import', $data, $report_email, $postback_url, [ 'file' ], $options);
} | [
"public",
"function",
"processPurchaseImportJobFromFile",
"(",
"$",
"file_path",
",",
"$",
"report_email",
"=",
"false",
",",
"$",
"postback_url",
"=",
"false",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"data",
"=",
"[",
"'file'",
"=>",
"$",
"file_path",
"]",
";",
"return",
"$",
"this",
"->",
"processJob",
"(",
"'purchase_import'",
",",
"$",
"data",
",",
"$",
"report_email",
",",
"$",
"postback_url",
",",
"[",
"'file'",
"]",
",",
"$",
"options",
")",
";",
"}"
]
| Process purchase import job from given file path of an email per line JSON file
@param String $file_path
@param bool|String $report_email
@param bool|String $postback_url
@param array $options
@return array | [
"Process",
"purchase",
"import",
"job",
"from",
"given",
"file",
"path",
"of",
"an",
"email",
"per",
"line",
"JSON",
"file"
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L975-L980 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.processSnapshotJob | public function processSnapshotJob(array $query, $report_email = false, $postback_url = false, array $options = [ ]) {
$data = [ 'query' => $query ];
return $this->processJob('snaphot', $data, $report_email, $postback_url, [ ], $options);
} | php | public function processSnapshotJob(array $query, $report_email = false, $postback_url = false, array $options = [ ]) {
$data = [ 'query' => $query ];
return $this->processJob('snaphot', $data, $report_email, $postback_url, [ ], $options);
} | [
"public",
"function",
"processSnapshotJob",
"(",
"array",
"$",
"query",
",",
"$",
"report_email",
"=",
"false",
",",
"$",
"postback_url",
"=",
"false",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"data",
"=",
"[",
"'query'",
"=>",
"$",
"query",
"]",
";",
"return",
"$",
"this",
"->",
"processJob",
"(",
"'snaphot'",
",",
"$",
"data",
",",
"$",
"report_email",
",",
"$",
"postback_url",
",",
"[",
"]",
",",
"$",
"options",
")",
";",
"}"
]
| Process a snapshot job
@param array $query
@param bool|String $report_email
@param bool|String $postback_url
@return array | [
"Process",
"a",
"snapshot",
"job"
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L990-L993 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.processExportListJob | public function processExportListJob($list, $report_email = false, $postback_url = false, array $options = [ ]) {
$data = [ 'list' => $list ];
return $this->processJob('export_list_data', $data, $report_email, $postback_url, [ ], $options);
} | php | public function processExportListJob($list, $report_email = false, $postback_url = false, array $options = [ ]) {
$data = [ 'list' => $list ];
return $this->processJob('export_list_data', $data, $report_email, $postback_url, [ ], $options);
} | [
"public",
"function",
"processExportListJob",
"(",
"$",
"list",
",",
"$",
"report_email",
"=",
"false",
",",
"$",
"postback_url",
"=",
"false",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"data",
"=",
"[",
"'list'",
"=>",
"$",
"list",
"]",
";",
"return",
"$",
"this",
"->",
"processJob",
"(",
"'export_list_data'",
",",
"$",
"data",
",",
"$",
"report_email",
",",
"$",
"postback_url",
",",
"[",
"]",
",",
"$",
"options",
")",
";",
"}"
]
| Process a export list job
@param String $list
@param bool|String $report_email
@param bool|String $postback_url
@param array $options
@return array | [
"Process",
"a",
"export",
"list",
"job"
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L1003-L1006 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.processBlastQueryJob | public function processBlastQueryJob($blast_id, $report_email = false, $postback_url = false, array $options = [ ]) {
return $this->processJob('blast_query', [ 'blast_id' => $blast_id ], $report_email, $postback_url, [ ], $options);
} | php | public function processBlastQueryJob($blast_id, $report_email = false, $postback_url = false, array $options = [ ]) {
return $this->processJob('blast_query', [ 'blast_id' => $blast_id ], $report_email, $postback_url, [ ], $options);
} | [
"public",
"function",
"processBlastQueryJob",
"(",
"$",
"blast_id",
",",
"$",
"report_email",
"=",
"false",
",",
"$",
"postback_url",
"=",
"false",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"processJob",
"(",
"'blast_query'",
",",
"[",
"'blast_id'",
"=>",
"$",
"blast_id",
"]",
",",
"$",
"report_email",
",",
"$",
"postback_url",
",",
"[",
"]",
",",
"$",
"options",
")",
";",
"}"
]
| Export blast data in CSV format
@param integer $blast_id
@param bool|String $report_email
@param bool|String $postback_url
@param array $options
@return array | [
"Export",
"blast",
"data",
"in",
"CSV",
"format"
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L1016-L1018 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.processUpdateJobFromUrl | public function processUpdateJobFromUrl($url, array $update = [ ], $report_email = false, $postback_url = false, array $options = [ ]) {
return $this->processUpdateJob('url', $url, $update, $report_email, $postback_url, [ ], $options);
} | php | public function processUpdateJobFromUrl($url, array $update = [ ], $report_email = false, $postback_url = false, array $options = [ ]) {
return $this->processUpdateJob('url', $url, $update, $report_email, $postback_url, [ ], $options);
} | [
"public",
"function",
"processUpdateJobFromUrl",
"(",
"$",
"url",
",",
"array",
"$",
"update",
"=",
"[",
"]",
",",
"$",
"report_email",
"=",
"false",
",",
"$",
"postback_url",
"=",
"false",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"processUpdateJob",
"(",
"'url'",
",",
"$",
"url",
",",
"$",
"update",
",",
"$",
"report_email",
",",
"$",
"postback_url",
",",
"[",
"]",
",",
"$",
"options",
")",
";",
"}"
]
| Perform a bulk update of any number of user profiles from given URL
@param String $url
@param array $update
@param bool|String $report_email
@param bool|String $postback_url
@param array $options
@return array | [
"Perform",
"a",
"bulk",
"update",
"of",
"any",
"number",
"of",
"user",
"profiles",
"from",
"given",
"URL"
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L1050-L1052 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.processUpdateJobFromFile | public function processUpdateJobFromFile($file, array $update = [ ], $report_email = false, $postback_url = false, array $options = [ ]) {
return $this->processUpdateJob('file', $file, $update, $report_email, $postback_url, [ 'file' ], $options);
} | php | public function processUpdateJobFromFile($file, array $update = [ ], $report_email = false, $postback_url = false, array $options = [ ]) {
return $this->processUpdateJob('file', $file, $update, $report_email, $postback_url, [ 'file' ], $options);
} | [
"public",
"function",
"processUpdateJobFromFile",
"(",
"$",
"file",
",",
"array",
"$",
"update",
"=",
"[",
"]",
",",
"$",
"report_email",
"=",
"false",
",",
"$",
"postback_url",
"=",
"false",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"processUpdateJob",
"(",
"'file'",
",",
"$",
"file",
",",
"$",
"update",
",",
"$",
"report_email",
",",
"$",
"postback_url",
",",
"[",
"'file'",
"]",
",",
"$",
"options",
")",
";",
"}"
]
| Perform a bulk update of any number of user profiles from given file
@param $file
@param Array $update
@param bool|String $report_email
@param bool|String $postback_url
@param array $options
@return array
@internal param String $url | [
"Perform",
"a",
"bulk",
"update",
"of",
"any",
"number",
"of",
"user",
"profiles",
"from",
"given",
"file"
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L1064-L1066 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.processUpdateJobFromQuery | public function processUpdateJobFromQuery($query, array $update = [ ], $report_email = false, $postback_url = false, array $options = [ ]) {
return $this->processUpdateJob('query', $query, $update, $report_email, $postback_url, [ ], $options);
} | php | public function processUpdateJobFromQuery($query, array $update = [ ], $report_email = false, $postback_url = false, array $options = [ ]) {
return $this->processUpdateJob('query', $query, $update, $report_email, $postback_url, [ ], $options);
} | [
"public",
"function",
"processUpdateJobFromQuery",
"(",
"$",
"query",
",",
"array",
"$",
"update",
"=",
"[",
"]",
",",
"$",
"report_email",
"=",
"false",
",",
"$",
"postback_url",
"=",
"false",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"processUpdateJob",
"(",
"'query'",
",",
"$",
"query",
",",
"$",
"update",
",",
"$",
"report_email",
",",
"$",
"postback_url",
",",
"[",
"]",
",",
"$",
"options",
")",
";",
"}"
]
| Perform a bulk update of any number of user profiles from a query
@param Array $query
@param Array $update
@param String $report_email
@param String $postback_url | [
"Perform",
"a",
"bulk",
"update",
"of",
"any",
"number",
"of",
"user",
"profiles",
"from",
"a",
"query"
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L1075-L1077 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.processUpdateJobFromEmails | public function processUpdateJobFromEmails($emails, array $update = [ ], $report_email = false, $postback_url = false, array $options = [ ]) {
return $this->processUpdateJob('emails', $emails, $update, $report_email, $postback_url, [ ], $options);
} | php | public function processUpdateJobFromEmails($emails, array $update = [ ], $report_email = false, $postback_url = false, array $options = [ ]) {
return $this->processUpdateJob('emails', $emails, $update, $report_email, $postback_url, [ ], $options);
} | [
"public",
"function",
"processUpdateJobFromEmails",
"(",
"$",
"emails",
",",
"array",
"$",
"update",
"=",
"[",
"]",
",",
"$",
"report_email",
"=",
"false",
",",
"$",
"postback_url",
"=",
"false",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"processUpdateJob",
"(",
"'emails'",
",",
"$",
"emails",
",",
"$",
"update",
",",
"$",
"report_email",
",",
"$",
"postback_url",
",",
"[",
"]",
",",
"$",
"options",
")",
";",
"}"
]
| Perform a bulk update of any number of user profiles from emails CSV
@param String $emails
@param Array $update
@param bool|String $report_email
@param bool|String $postback_url
@return array | [
"Perform",
"a",
"bulk",
"update",
"of",
"any",
"number",
"of",
"user",
"profiles",
"from",
"emails",
"CSV"
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L1087-L1089 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.saveUser | public function saveUser($id, array $options = [ ]) {
$data = $options;
$data['id'] = $id;
return $this->apiPost('user', $data);
} | php | public function saveUser($id, array $options = [ ]) {
$data = $options;
$data['id'] = $id;
return $this->apiPost('user', $data);
} | [
"public",
"function",
"saveUser",
"(",
"$",
"id",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"data",
"=",
"$",
"options",
";",
"$",
"data",
"[",
"'id'",
"]",
"=",
"$",
"id",
";",
"return",
"$",
"this",
"->",
"apiPost",
"(",
"'user'",
",",
"$",
"data",
")",
";",
"}"
]
| Save existing user
@param String $id
@param array $options
@return array | [
"Save",
"existing",
"user"
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L1097-L1101 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.getUserByKey | public function getUserByKey($id, $key, array $fields = [ ]) {
$data = [
'id' => $id,
'key' => $key,
'fields' => $fields
];
return $this->apiGet('user', $data);
} | php | public function getUserByKey($id, $key, array $fields = [ ]) {
$data = [
'id' => $id,
'key' => $key,
'fields' => $fields
];
return $this->apiGet('user', $data);
} | [
"public",
"function",
"getUserByKey",
"(",
"$",
"id",
",",
"$",
"key",
",",
"array",
"$",
"fields",
"=",
"[",
"]",
")",
"{",
"$",
"data",
"=",
"[",
"'id'",
"=>",
"$",
"id",
",",
"'key'",
"=>",
"$",
"key",
",",
"'fields'",
"=>",
"$",
"fields",
"]",
";",
"return",
"$",
"this",
"->",
"apiGet",
"(",
"'user'",
",",
"$",
"data",
")",
";",
"}"
]
| Get user by specified key
@param String $id
@param String $key
@param array $fields
@return array | [
"Get",
"user",
"by",
"specified",
"key"
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L1119-L1126 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.previewTemplateWithHTML | public function previewTemplateWithHTML($template, $email) {
$data = [ ];
$data['template'] = $template;
$data['email'] = $email;
$result = $this->apiPost('preview', $data);
return $result;
} | php | public function previewTemplateWithHTML($template, $email) {
$data = [ ];
$data['template'] = $template;
$data['email'] = $email;
$result = $this->apiPost('preview', $data);
return $result;
} | [
"public",
"function",
"previewTemplateWithHTML",
"(",
"$",
"template",
",",
"$",
"email",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"$",
"data",
"[",
"'template'",
"]",
"=",
"$",
"template",
";",
"$",
"data",
"[",
"'email'",
"]",
"=",
"$",
"email",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"apiPost",
"(",
"'preview'",
",",
"$",
"data",
")",
";",
"return",
"$",
"result",
";",
"}"
]
| Get an HTML preview of a template.
@param $template
@param $email
@return array
@link http://docs.sailthru.com/api/preview | [
"Get",
"an",
"HTML",
"preview",
"of",
"a",
"template",
"."
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L1164-L1171 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.previewBlastWithHTML | public function previewBlastWithHTML($blast_id, $email) {
$data = [ ];
$data['blast_id'] = $blast_id;
$data['email'] = $email;
$result = $this->apiPost('preview', $data);
return $result;
} | php | public function previewBlastWithHTML($blast_id, $email) {
$data = [ ];
$data['blast_id'] = $blast_id;
$data['email'] = $email;
$result = $this->apiPost('preview', $data);
return $result;
} | [
"public",
"function",
"previewBlastWithHTML",
"(",
"$",
"blast_id",
",",
"$",
"email",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"$",
"data",
"[",
"'blast_id'",
"]",
"=",
"$",
"blast_id",
";",
"$",
"data",
"[",
"'email'",
"]",
"=",
"$",
"email",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"apiPost",
"(",
"'preview'",
",",
"$",
"data",
")",
";",
"return",
"$",
"result",
";",
"}"
]
| Get an HTML preview of a blast.
@param $blast_id
@param $email
@return array
@link http://docs.sailthru.com/api/preview | [
"Get",
"an",
"HTML",
"preview",
"of",
"a",
"blast",
"."
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L1180-L1187 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.previewRecurringBlastWithHTML | public function previewRecurringBlastWithHTML($blast_repeat_id, $email) {
$data = [ ];
$data['blast_repeat_id'] = $blast_repeat_id;
$data['email'] = $email;
$result = $this->apiPost('preview', $data);
} | php | public function previewRecurringBlastWithHTML($blast_repeat_id, $email) {
$data = [ ];
$data['blast_repeat_id'] = $blast_repeat_id;
$data['email'] = $email;
$result = $this->apiPost('preview', $data);
} | [
"public",
"function",
"previewRecurringBlastWithHTML",
"(",
"$",
"blast_repeat_id",
",",
"$",
"email",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"$",
"data",
"[",
"'blast_repeat_id'",
"]",
"=",
"$",
"blast_repeat_id",
";",
"$",
"data",
"[",
"'email'",
"]",
"=",
"$",
"email",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"apiPost",
"(",
"'preview'",
",",
"$",
"data",
")",
";",
"}"
]
| Get an HTML preview of a recurring blast.
@param $blast_repeat_id
@param $email
@return array
@link http://docs.sailthru.com/api/preview | [
"Get",
"an",
"HTML",
"preview",
"of",
"a",
"recurring",
"blast",
"."
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L1196-L1202 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.previewContentWithHTML | public function previewContentWithHTML($content_html, $email) {
$data = [ ];
$data['content_html'] = $content_html;
$data['email'] = $email;
$result = $this->apiPost('preview', $data);
return $result;
} | php | public function previewContentWithHTML($content_html, $email) {
$data = [ ];
$data['content_html'] = $content_html;
$data['email'] = $email;
$result = $this->apiPost('preview', $data);
return $result;
} | [
"public",
"function",
"previewContentWithHTML",
"(",
"$",
"content_html",
",",
"$",
"email",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"$",
"data",
"[",
"'content_html'",
"]",
"=",
"$",
"content_html",
";",
"$",
"data",
"[",
"'email'",
"]",
"=",
"$",
"email",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"apiPost",
"(",
"'preview'",
",",
"$",
"data",
")",
";",
"return",
"$",
"result",
";",
"}"
]
| Get an HTML preview of content_html.
@param $content_html
@param $email
@return array
@link http://docs.sailthru.com/api/preview | [
"Get",
"an",
"HTML",
"preview",
"of",
"content_html",
"."
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L1211-L1218 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.previewTemplateWithEmail | public function previewTemplateWithEmail($template, $send_email) {
$data = [ ];
$data['template'] = $template;
$data['send_email'] = $send_email;
$result = $this->apiPost('preview', $data);
return $result;
} | php | public function previewTemplateWithEmail($template, $send_email) {
$data = [ ];
$data['template'] = $template;
$data['send_email'] = $send_email;
$result = $this->apiPost('preview', $data);
return $result;
} | [
"public",
"function",
"previewTemplateWithEmail",
"(",
"$",
"template",
",",
"$",
"send_email",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"$",
"data",
"[",
"'template'",
"]",
"=",
"$",
"template",
";",
"$",
"data",
"[",
"'send_email'",
"]",
"=",
"$",
"send_email",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"apiPost",
"(",
"'preview'",
",",
"$",
"data",
")",
";",
"return",
"$",
"result",
";",
"}"
]
| Get an email preview of a template.
@param $template
@param $send_email
@return array
@link http://docs.sailthru.com/api/preview | [
"Get",
"an",
"email",
"preview",
"of",
"a",
"template",
"."
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L1227-L1234 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.previewBlastWithEmail | public function previewBlastWithEmail($blast_id, $send_email) {
$data = [ ];
$data['blast_id'] = $blast_id;
$data['send_email'] = $send_email;
$result = $this->apiPost('preview', $data);
return $result;
} | php | public function previewBlastWithEmail($blast_id, $send_email) {
$data = [ ];
$data['blast_id'] = $blast_id;
$data['send_email'] = $send_email;
$result = $this->apiPost('preview', $data);
return $result;
} | [
"public",
"function",
"previewBlastWithEmail",
"(",
"$",
"blast_id",
",",
"$",
"send_email",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"$",
"data",
"[",
"'blast_id'",
"]",
"=",
"$",
"blast_id",
";",
"$",
"data",
"[",
"'send_email'",
"]",
"=",
"$",
"send_email",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"apiPost",
"(",
"'preview'",
",",
"$",
"data",
")",
";",
"return",
"$",
"result",
";",
"}"
]
| Get an email preview of a blast.
@param $blast_id
@param $send_email
@return array
@link http://docs.sailthru.com/api/preview | [
"Get",
"an",
"email",
"preview",
"of",
"a",
"blast",
"."
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L1243-L1250 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.previewRecurringBlastWithEmail | public function previewRecurringBlastWithEmail($blast_repeat_id, $send_email) {
$data = [ ];
$data['blast_repeat_id'] = $blast_repeat_id;
$data['send_email'] = $send_email;
$result = $this->apiPost('preview', $data);
return $result;
} | php | public function previewRecurringBlastWithEmail($blast_repeat_id, $send_email) {
$data = [ ];
$data['blast_repeat_id'] = $blast_repeat_id;
$data['send_email'] = $send_email;
$result = $this->apiPost('preview', $data);
return $result;
} | [
"public",
"function",
"previewRecurringBlastWithEmail",
"(",
"$",
"blast_repeat_id",
",",
"$",
"send_email",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"$",
"data",
"[",
"'blast_repeat_id'",
"]",
"=",
"$",
"blast_repeat_id",
";",
"$",
"data",
"[",
"'send_email'",
"]",
"=",
"$",
"send_email",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"apiPost",
"(",
"'preview'",
",",
"$",
"data",
")",
";",
"return",
"$",
"result",
";",
"}"
]
| Get an email preview of a recurring blast.
@param $blast_repeat_id
@param $send_email
@return array
@link http://docs.sailthru.com/api/preview | [
"Get",
"an",
"email",
"preview",
"of",
"a",
"recurring",
"blast",
"."
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L1259-L1266 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.previewContentWithEmail | public function previewContentWithEmail($content_html, $send_email) {
$data = [ ];
$data['content_html'] = $content_html;
$data['send_email'] = $send_email;
$result = $this->apiPost('preview', $data);
return $result;
} | php | public function previewContentWithEmail($content_html, $send_email) {
$data = [ ];
$data['content_html'] = $content_html;
$data['send_email'] = $send_email;
$result = $this->apiPost('preview', $data);
return $result;
} | [
"public",
"function",
"previewContentWithEmail",
"(",
"$",
"content_html",
",",
"$",
"send_email",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"$",
"data",
"[",
"'content_html'",
"]",
"=",
"$",
"content_html",
";",
"$",
"data",
"[",
"'send_email'",
"]",
"=",
"$",
"send_email",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"apiPost",
"(",
"'preview'",
",",
"$",
"data",
")",
";",
"return",
"$",
"result",
";",
"}"
]
| Get an email preview of content_html.
@param $content_html
@param $send_email
@return array
@link http://docs.sailthru.com/api/preview | [
"Get",
"an",
"email",
"preview",
"of",
"content_html",
"."
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L1275-L1282 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.postTrigger | public function postTrigger($template, $time, $time_unit, $event, $zephyr) {
$data = [ ];
$data['template'] = $template;
$data['time'] = $time;
$data['time_unit'] = $time_unit;
$data['event'] = $event;
$data['zephyr'] = $zephyr;
$result = $this->apiPost('trigger', $data);
return $result;
} | php | public function postTrigger($template, $time, $time_unit, $event, $zephyr) {
$data = [ ];
$data['template'] = $template;
$data['time'] = $time;
$data['time_unit'] = $time_unit;
$data['event'] = $event;
$data['zephyr'] = $zephyr;
$result = $this->apiPost('trigger', $data);
return $result;
} | [
"public",
"function",
"postTrigger",
"(",
"$",
"template",
",",
"$",
"time",
",",
"$",
"time_unit",
",",
"$",
"event",
",",
"$",
"zephyr",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"$",
"data",
"[",
"'template'",
"]",
"=",
"$",
"template",
";",
"$",
"data",
"[",
"'time'",
"]",
"=",
"$",
"time",
";",
"$",
"data",
"[",
"'time_unit'",
"]",
"=",
"$",
"time_unit",
";",
"$",
"data",
"[",
"'event'",
"]",
"=",
"$",
"event",
";",
"$",
"data",
"[",
"'zephyr'",
"]",
"=",
"$",
"zephyr",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"apiPost",
"(",
"'trigger'",
",",
"$",
"data",
")",
";",
"return",
"$",
"result",
";",
"}"
]
| Create a trigger for templates
@param string $template
@param integer $time
@param string $time_unit
@param string $event
@param string $zephyr
@return array
@link http://docs.sailthru.com/api/trigger | [
"Create",
"a",
"trigger",
"for",
"templates"
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L1350-L1360 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.postEventTrigger | public function postEventTrigger($event, $time, $time_unit, $zephyr) {
$data = [ ];
$data['time'] = $time;
$data['time_unit'] = $time_unit;
$data['event'] = $event;
$data['zephyr'] = $zephyr;
$result = $this->apiPost('trigger', $data);
return $result;
} | php | public function postEventTrigger($event, $time, $time_unit, $zephyr) {
$data = [ ];
$data['time'] = $time;
$data['time_unit'] = $time_unit;
$data['event'] = $event;
$data['zephyr'] = $zephyr;
$result = $this->apiPost('trigger', $data);
return $result;
} | [
"public",
"function",
"postEventTrigger",
"(",
"$",
"event",
",",
"$",
"time",
",",
"$",
"time_unit",
",",
"$",
"zephyr",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"$",
"data",
"[",
"'time'",
"]",
"=",
"$",
"time",
";",
"$",
"data",
"[",
"'time_unit'",
"]",
"=",
"$",
"time_unit",
";",
"$",
"data",
"[",
"'event'",
"]",
"=",
"$",
"event",
";",
"$",
"data",
"[",
"'zephyr'",
"]",
"=",
"$",
"zephyr",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"apiPost",
"(",
"'trigger'",
",",
"$",
"data",
")",
";",
"return",
"$",
"result",
";",
"}"
]
| Create a trigger for events
@param integer $time
@param string $time_unit
@param string $event
@param string $zephyr
@return array
@link http://docs.sailthru.com/api/trigger | [
"Create",
"a",
"trigger",
"for",
"events"
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L1371-L1380 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.postEvent | public function postEvent($id, $event, $options = [ ]) {
$data = $options;
$data['id'] = $id;
$data['event'] = $event;
$result = $this->apiPost('event', $data);
return $result;
} | php | public function postEvent($id, $event, $options = [ ]) {
$data = $options;
$data['id'] = $id;
$data['event'] = $event;
$result = $this->apiPost('event', $data);
return $result;
} | [
"public",
"function",
"postEvent",
"(",
"$",
"id",
",",
"$",
"event",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"data",
"=",
"$",
"options",
";",
"$",
"data",
"[",
"'id'",
"]",
"=",
"$",
"id",
";",
"$",
"data",
"[",
"'event'",
"]",
"=",
"$",
"event",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"apiPost",
"(",
"'event'",
",",
"$",
"data",
")",
";",
"return",
"$",
"result",
";",
"}"
]
| Notify Sailthru of an event
@param string $id
@param string $event
@param array $options
@return array
@link http://docs.sailthru.com/api/event | [
"Notify",
"Sailthru",
"of",
"an",
"event"
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L1390-L1397 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.httpRequestCurl | protected function httpRequestCurl($action, array $data, $method = 'POST', $options = [ ]) {
$url = $this->api_uri . "/" . $action;
$ch = curl_init();
$options = array_merge($this->options, $options);
if ($method == 'POST') {
curl_setopt($ch, CURLOPT_POST, true);
if ($this->fileUpload === true) {
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$this->fileUpload = false;
} else {
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data, '', '&'));
}
} else {
$url .= '?' . http_build_query($data, '', '&');
if ($method != 'GET') {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
}
}
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
curl_setopt($ch, CURLOPT_TIMEOUT_MS, $options['timeout']);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, $options['connect_timeout']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $this->httpHeaders);
$response = curl_exec($ch);
$this->lastResponseInfo = curl_getinfo($ch);
curl_close($ch);
if (!$response) {
throw new Sailthru_Client_Exception(
"Bad response received from $url",
Sailthru_Client_Exception::CODE_RESPONSE_EMPTY
);
}
// parse headers and body
$parts = explode("\r\n\r\nHTTP/", $response);
$parts = (count($parts) > 1 ? 'HTTP/' : '') . array_pop($parts); // deal with HTTP/1.1 100 Continue before other headers
list($headers, $body) = explode("\r\n\r\n", $parts, 2);
$this->lastRateLimitInfo[$action][$method] = self::parseRateLimitHeaders($headers);
return $body;
} | php | protected function httpRequestCurl($action, array $data, $method = 'POST', $options = [ ]) {
$url = $this->api_uri . "/" . $action;
$ch = curl_init();
$options = array_merge($this->options, $options);
if ($method == 'POST') {
curl_setopt($ch, CURLOPT_POST, true);
if ($this->fileUpload === true) {
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$this->fileUpload = false;
} else {
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data, '', '&'));
}
} else {
$url .= '?' . http_build_query($data, '', '&');
if ($method != 'GET') {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
}
}
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
curl_setopt($ch, CURLOPT_TIMEOUT_MS, $options['timeout']);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, $options['connect_timeout']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $this->httpHeaders);
$response = curl_exec($ch);
$this->lastResponseInfo = curl_getinfo($ch);
curl_close($ch);
if (!$response) {
throw new Sailthru_Client_Exception(
"Bad response received from $url",
Sailthru_Client_Exception::CODE_RESPONSE_EMPTY
);
}
// parse headers and body
$parts = explode("\r\n\r\nHTTP/", $response);
$parts = (count($parts) > 1 ? 'HTTP/' : '') . array_pop($parts); // deal with HTTP/1.1 100 Continue before other headers
list($headers, $body) = explode("\r\n\r\n", $parts, 2);
$this->lastRateLimitInfo[$action][$method] = self::parseRateLimitHeaders($headers);
return $body;
} | [
"protected",
"function",
"httpRequestCurl",
"(",
"$",
"action",
",",
"array",
"$",
"data",
",",
"$",
"method",
"=",
"'POST'",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"api_uri",
".",
"\"/\"",
".",
"$",
"action",
";",
"$",
"ch",
"=",
"curl_init",
"(",
")",
";",
"$",
"options",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"options",
",",
"$",
"options",
")",
";",
"if",
"(",
"$",
"method",
"==",
"'POST'",
")",
"{",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_POST",
",",
"true",
")",
";",
"if",
"(",
"$",
"this",
"->",
"fileUpload",
"===",
"true",
")",
"{",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_POSTFIELDS",
",",
"$",
"data",
")",
";",
"$",
"this",
"->",
"fileUpload",
"=",
"false",
";",
"}",
"else",
"{",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_POSTFIELDS",
",",
"http_build_query",
"(",
"$",
"data",
",",
"''",
",",
"'&'",
")",
")",
";",
"}",
"}",
"else",
"{",
"$",
"url",
".=",
"'?'",
".",
"http_build_query",
"(",
"$",
"data",
",",
"''",
",",
"'&'",
")",
";",
"if",
"(",
"$",
"method",
"!=",
"'GET'",
")",
"{",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_CUSTOMREQUEST",
",",
"$",
"method",
")",
";",
"}",
"}",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_URL",
",",
"$",
"url",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_HEADER",
",",
"true",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_ENCODING",
",",
"'gzip'",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_TIMEOUT_MS",
",",
"$",
"options",
"[",
"'timeout'",
"]",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_CONNECTTIMEOUT_MS",
",",
"$",
"options",
"[",
"'connect_timeout'",
"]",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_RETURNTRANSFER",
",",
"true",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_HTTPHEADER",
",",
"$",
"this",
"->",
"httpHeaders",
")",
";",
"$",
"response",
"=",
"curl_exec",
"(",
"$",
"ch",
")",
";",
"$",
"this",
"->",
"lastResponseInfo",
"=",
"curl_getinfo",
"(",
"$",
"ch",
")",
";",
"curl_close",
"(",
"$",
"ch",
")",
";",
"if",
"(",
"!",
"$",
"response",
")",
"{",
"throw",
"new",
"Sailthru_Client_Exception",
"(",
"\"Bad response received from $url\"",
",",
"Sailthru_Client_Exception",
"::",
"CODE_RESPONSE_EMPTY",
")",
";",
"}",
"// parse headers and body",
"$",
"parts",
"=",
"explode",
"(",
"\"\\r\\n\\r\\nHTTP/\"",
",",
"$",
"response",
")",
";",
"$",
"parts",
"=",
"(",
"count",
"(",
"$",
"parts",
")",
">",
"1",
"?",
"'HTTP/'",
":",
"''",
")",
".",
"array_pop",
"(",
"$",
"parts",
")",
";",
"// deal with HTTP/1.1 100 Continue before other headers",
"list",
"(",
"$",
"headers",
",",
"$",
"body",
")",
"=",
"explode",
"(",
"\"\\r\\n\\r\\n\"",
",",
"$",
"parts",
",",
"2",
")",
";",
"$",
"this",
"->",
"lastRateLimitInfo",
"[",
"$",
"action",
"]",
"[",
"$",
"method",
"]",
"=",
"self",
"::",
"parseRateLimitHeaders",
"(",
"$",
"headers",
")",
";",
"return",
"$",
"body",
";",
"}"
]
| Perform an HTTP request using the curl extension
@param string $action
@param array $data
@param string $method
@param array $options
@return string
@throws Sailthru_Client_Exception | [
"Perform",
"an",
"HTTP",
"request",
"using",
"the",
"curl",
"extension"
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L1409-L1453 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.httpRequest | protected function httpRequest($action, $data, $method = 'POST', $options = [ ]) {
$response = $this->{$this->http_request_type}($action, $data, $method, $options);
$json = json_decode($response, true);
if ($json === NULL) {
throw new Sailthru_Client_Exception(
"Response: {$response} is not a valid JSON",
Sailthru_Client_Exception::CODE_RESPONSE_INVALID
);
}
if (!empty($json['error'])) {
throw new Sailthru_Client_Exception($json['errormsg'], $json['error']);
}
return $json;
} | php | protected function httpRequest($action, $data, $method = 'POST', $options = [ ]) {
$response = $this->{$this->http_request_type}($action, $data, $method, $options);
$json = json_decode($response, true);
if ($json === NULL) {
throw new Sailthru_Client_Exception(
"Response: {$response} is not a valid JSON",
Sailthru_Client_Exception::CODE_RESPONSE_INVALID
);
}
if (!empty($json['error'])) {
throw new Sailthru_Client_Exception($json['errormsg'], $json['error']);
}
return $json;
} | [
"protected",
"function",
"httpRequest",
"(",
"$",
"action",
",",
"$",
"data",
",",
"$",
"method",
"=",
"'POST'",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"{",
"$",
"this",
"->",
"http_request_type",
"}",
"(",
"$",
"action",
",",
"$",
"data",
",",
"$",
"method",
",",
"$",
"options",
")",
";",
"$",
"json",
"=",
"json_decode",
"(",
"$",
"response",
",",
"true",
")",
";",
"if",
"(",
"$",
"json",
"===",
"NULL",
")",
"{",
"throw",
"new",
"Sailthru_Client_Exception",
"(",
"\"Response: {$response} is not a valid JSON\"",
",",
"Sailthru_Client_Exception",
"::",
"CODE_RESPONSE_INVALID",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"json",
"[",
"'error'",
"]",
")",
")",
"{",
"throw",
"new",
"Sailthru_Client_Exception",
"(",
"$",
"json",
"[",
"'errormsg'",
"]",
",",
"$",
"json",
"[",
"'error'",
"]",
")",
";",
"}",
"return",
"$",
"json",
";",
"}"
]
| Perform an HTTP request, checking for curl extension support
@param $action
@param array $data
@param string $method
@param array $options
@return string
@throws Sailthru_Client_Exception | [
"Perform",
"an",
"HTTP",
"request",
"checking",
"for",
"curl",
"extension",
"support"
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L1510-L1524 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.apiGet | public function apiGet($action, $data = [ ], $method = 'GET', $options = [ ]) {
return $this->httpRequest($action, $this->prepareJsonPayload($data), $method, $options);
} | php | public function apiGet($action, $data = [ ], $method = 'GET', $options = [ ]) {
return $this->httpRequest($action, $this->prepareJsonPayload($data), $method, $options);
} | [
"public",
"function",
"apiGet",
"(",
"$",
"action",
",",
"$",
"data",
"=",
"[",
"]",
",",
"$",
"method",
"=",
"'GET'",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"httpRequest",
"(",
"$",
"action",
",",
"$",
"this",
"->",
"prepareJsonPayload",
"(",
"$",
"data",
")",
",",
"$",
"method",
",",
"$",
"options",
")",
";",
"}"
]
| Perform an API GET request, using the shared-secret auth hash.
@param string $action
@param array $data
@return array | [
"Perform",
"an",
"API",
"GET",
"request",
"using",
"the",
"shared",
"-",
"secret",
"auth",
"hash",
"."
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L1560-L1562 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.prepareJsonPayload | protected function prepareJsonPayload(array $data, array $binary_data = [ ]) {
$payload = [
'api_key' => $this->api_key,
'format' => 'json',
'json' => json_encode($data)
];
$payload['sig'] = Sailthru_Util::getSignatureHash($payload, $this->secret);
if (!empty($binary_data)) {
$payload = array_merge($payload, $binary_data);
}
return $payload;
} | php | protected function prepareJsonPayload(array $data, array $binary_data = [ ]) {
$payload = [
'api_key' => $this->api_key,
'format' => 'json',
'json' => json_encode($data)
];
$payload['sig'] = Sailthru_Util::getSignatureHash($payload, $this->secret);
if (!empty($binary_data)) {
$payload = array_merge($payload, $binary_data);
}
return $payload;
} | [
"protected",
"function",
"prepareJsonPayload",
"(",
"array",
"$",
"data",
",",
"array",
"$",
"binary_data",
"=",
"[",
"]",
")",
"{",
"$",
"payload",
"=",
"[",
"'api_key'",
"=>",
"$",
"this",
"->",
"api_key",
",",
"'format'",
"=>",
"'json'",
",",
"'json'",
"=>",
"json_encode",
"(",
"$",
"data",
")",
"]",
";",
"$",
"payload",
"[",
"'sig'",
"]",
"=",
"Sailthru_Util",
"::",
"getSignatureHash",
"(",
"$",
"payload",
",",
"$",
"this",
"->",
"secret",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"binary_data",
")",
")",
"{",
"$",
"payload",
"=",
"array_merge",
"(",
"$",
"payload",
",",
"$",
"binary_data",
")",
";",
"}",
"return",
"$",
"payload",
";",
"}"
]
| Prepare JSON payload | [
"Prepare",
"JSON",
"payload"
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L1587-L1598 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.getLastRateLimitInfo | public function getLastRateLimitInfo($action, $method) {
$rate_limit_info = $this->lastRateLimitInfo;
$method = strtoupper($method);
return (isset($rate_limit_info[$action]) && isset($rate_limit_info[$action][$method])) ?
$rate_limit_info[$action][$method] : null;
} | php | public function getLastRateLimitInfo($action, $method) {
$rate_limit_info = $this->lastRateLimitInfo;
$method = strtoupper($method);
return (isset($rate_limit_info[$action]) && isset($rate_limit_info[$action][$method])) ?
$rate_limit_info[$action][$method] : null;
} | [
"public",
"function",
"getLastRateLimitInfo",
"(",
"$",
"action",
",",
"$",
"method",
")",
"{",
"$",
"rate_limit_info",
"=",
"$",
"this",
"->",
"lastRateLimitInfo",
";",
"$",
"method",
"=",
"strtoupper",
"(",
"$",
"method",
")",
";",
"return",
"(",
"isset",
"(",
"$",
"rate_limit_info",
"[",
"$",
"action",
"]",
")",
"&&",
"isset",
"(",
"$",
"rate_limit_info",
"[",
"$",
"action",
"]",
"[",
"$",
"method",
"]",
")",
")",
"?",
"$",
"rate_limit_info",
"[",
"$",
"action",
"]",
"[",
"$",
"method",
"]",
":",
"null",
";",
"}"
]
| get the rate limit information for the very last call with given action and method
@param string $action
@param string $method GET, POST or DELETE
@return array or null | [
"get",
"the",
"rate",
"limit",
"information",
"for",
"the",
"very",
"last",
"call",
"with",
"given",
"action",
"and",
"method"
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L1606-L1611 | train |
sailthru/sailthru-php5-client | sailthru/Sailthru_Client.php | Sailthru_Client.parseRateLimitHeaders | private function parseRateLimitHeaders($headers) {
if ($headers === null) {
return null;
}
$header_lines = explode("\n", $headers);
$rate_limit_headers = [ ];
foreach ($header_lines as $hl) {
if (strpos($hl, "X-Rate-Limit-Limit") !== FALSE && !isset($rate_limit_headers['limit'])) {
list($header_name, $header_value) = explode(":", $hl, 2);
$rate_limit_headers['limit'] = intval($header_value);
} else if (strpos($hl, "X-Rate-Limit-Remaining") !== FALSE && !isset($rate_limit_headers['remaining'])) {
list($header_name, $header_value) = explode(":", $hl, 2);
$rate_limit_headers['remaining'] = intval($header_value);
} else if (strpos($hl, "X-Rate-Limit-Reset") !== FALSE && !isset($rate_limit_headers['reset'])) {
list($header_name, $header_value) = explode(":", $hl, 2);
$rate_limit_headers['reset'] = intval($header_value);
}
if (count($rate_limit_headers) === 3) {
return $rate_limit_headers;
}
}
return null;
} | php | private function parseRateLimitHeaders($headers) {
if ($headers === null) {
return null;
}
$header_lines = explode("\n", $headers);
$rate_limit_headers = [ ];
foreach ($header_lines as $hl) {
if (strpos($hl, "X-Rate-Limit-Limit") !== FALSE && !isset($rate_limit_headers['limit'])) {
list($header_name, $header_value) = explode(":", $hl, 2);
$rate_limit_headers['limit'] = intval($header_value);
} else if (strpos($hl, "X-Rate-Limit-Remaining") !== FALSE && !isset($rate_limit_headers['remaining'])) {
list($header_name, $header_value) = explode(":", $hl, 2);
$rate_limit_headers['remaining'] = intval($header_value);
} else if (strpos($hl, "X-Rate-Limit-Reset") !== FALSE && !isset($rate_limit_headers['reset'])) {
list($header_name, $header_value) = explode(":", $hl, 2);
$rate_limit_headers['reset'] = intval($header_value);
}
if (count($rate_limit_headers) === 3) {
return $rate_limit_headers;
}
}
return null;
} | [
"private",
"function",
"parseRateLimitHeaders",
"(",
"$",
"headers",
")",
"{",
"if",
"(",
"$",
"headers",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"$",
"header_lines",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"headers",
")",
";",
"$",
"rate_limit_headers",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"header_lines",
"as",
"$",
"hl",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"hl",
",",
"\"X-Rate-Limit-Limit\"",
")",
"!==",
"FALSE",
"&&",
"!",
"isset",
"(",
"$",
"rate_limit_headers",
"[",
"'limit'",
"]",
")",
")",
"{",
"list",
"(",
"$",
"header_name",
",",
"$",
"header_value",
")",
"=",
"explode",
"(",
"\":\"",
",",
"$",
"hl",
",",
"2",
")",
";",
"$",
"rate_limit_headers",
"[",
"'limit'",
"]",
"=",
"intval",
"(",
"$",
"header_value",
")",
";",
"}",
"else",
"if",
"(",
"strpos",
"(",
"$",
"hl",
",",
"\"X-Rate-Limit-Remaining\"",
")",
"!==",
"FALSE",
"&&",
"!",
"isset",
"(",
"$",
"rate_limit_headers",
"[",
"'remaining'",
"]",
")",
")",
"{",
"list",
"(",
"$",
"header_name",
",",
"$",
"header_value",
")",
"=",
"explode",
"(",
"\":\"",
",",
"$",
"hl",
",",
"2",
")",
";",
"$",
"rate_limit_headers",
"[",
"'remaining'",
"]",
"=",
"intval",
"(",
"$",
"header_value",
")",
";",
"}",
"else",
"if",
"(",
"strpos",
"(",
"$",
"hl",
",",
"\"X-Rate-Limit-Reset\"",
")",
"!==",
"FALSE",
"&&",
"!",
"isset",
"(",
"$",
"rate_limit_headers",
"[",
"'reset'",
"]",
")",
")",
"{",
"list",
"(",
"$",
"header_name",
",",
"$",
"header_value",
")",
"=",
"explode",
"(",
"\":\"",
",",
"$",
"hl",
",",
"2",
")",
";",
"$",
"rate_limit_headers",
"[",
"'reset'",
"]",
"=",
"intval",
"(",
"$",
"header_value",
")",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"rate_limit_headers",
")",
"===",
"3",
")",
"{",
"return",
"$",
"rate_limit_headers",
";",
"}",
"}",
"return",
"null",
";",
"}"
]
| parse rate limit headers from http response
@param string $headers
@return array|null | [
"parse",
"rate",
"limit",
"headers",
"from",
"http",
"response"
]
| 37f8ff4981b087a307de4d0c4ea09f326060da60 | https://github.com/sailthru/sailthru-php5-client/blob/37f8ff4981b087a307de4d0c4ea09f326060da60/sailthru/Sailthru_Client.php#L1618-L1643 | train |
QoboLtd/cakephp-csv-migrations | src/FieldHandlers/Provider/RenderInput/SublistRenderer.php | SublistRenderer._dynamicSelectStructure | protected function _dynamicSelectStructure(array $options) : array
{
$result = [];
foreach ($options as $k => $v) {
$result[$v['label']] = !empty($v['children']) ? $this->_dynamicSelectStructure($v['children']) : [];
}
return $result;
} | php | protected function _dynamicSelectStructure(array $options) : array
{
$result = [];
foreach ($options as $k => $v) {
$result[$v['label']] = !empty($v['children']) ? $this->_dynamicSelectStructure($v['children']) : [];
}
return $result;
} | [
"protected",
"function",
"_dynamicSelectStructure",
"(",
"array",
"$",
"options",
")",
":",
"array",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"options",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"result",
"[",
"$",
"v",
"[",
"'label'",
"]",
"]",
"=",
"!",
"empty",
"(",
"$",
"v",
"[",
"'children'",
"]",
")",
"?",
"$",
"this",
"->",
"_dynamicSelectStructure",
"(",
"$",
"v",
"[",
"'children'",
"]",
")",
":",
"[",
"]",
";",
"}",
"return",
"$",
"result",
";",
"}"
]
| Converts list options to supported dynamiSelect lib structure
@link https://github.com/sorites/dynamic-select
@param mixed[] $options List options
@return mixed[] | [
"Converts",
"list",
"options",
"to",
"supported",
"dynamiSelect",
"lib",
"structure"
]
| 49300070cdd9b829670a3c40f747c535c8e539b3 | https://github.com/QoboLtd/cakephp-csv-migrations/blob/49300070cdd9b829670a3c40f747c535c8e539b3/src/FieldHandlers/Provider/RenderInput/SublistRenderer.php#L72-L80 | train |
QoboLtd/cakephp-csv-migrations | src/Controller/Traits/PanelsTrait.php | PanelsTrait.getPanels | public function getPanels(array $config, array $data) : array
{
$result = ['success' => [], 'fail' => []];
foreach (Panel::getPanelNames($config) as $name) {
$panel = new Panel($name, $config);
if (!empty($data) && $panel->evalExpression($data)) {
$result['success'][] = $panel->getName();
} else {
$result['fail'][] = $panel->getName();
}
}
return $result;
} | php | public function getPanels(array $config, array $data) : array
{
$result = ['success' => [], 'fail' => []];
foreach (Panel::getPanelNames($config) as $name) {
$panel = new Panel($name, $config);
if (!empty($data) && $panel->evalExpression($data)) {
$result['success'][] = $panel->getName();
} else {
$result['fail'][] = $panel->getName();
}
}
return $result;
} | [
"public",
"function",
"getPanels",
"(",
"array",
"$",
"config",
",",
"array",
"$",
"data",
")",
":",
"array",
"{",
"$",
"result",
"=",
"[",
"'success'",
"=>",
"[",
"]",
",",
"'fail'",
"=>",
"[",
"]",
"]",
";",
"foreach",
"(",
"Panel",
"::",
"getPanelNames",
"(",
"$",
"config",
")",
"as",
"$",
"name",
")",
"{",
"$",
"panel",
"=",
"new",
"Panel",
"(",
"$",
"name",
",",
"$",
"config",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"data",
")",
"&&",
"$",
"panel",
"->",
"evalExpression",
"(",
"$",
"data",
")",
")",
"{",
"$",
"result",
"[",
"'success'",
"]",
"[",
"]",
"=",
"$",
"panel",
"->",
"getName",
"(",
")",
";",
"}",
"else",
"{",
"$",
"result",
"[",
"'fail'",
"]",
"[",
"]",
"=",
"$",
"panel",
"->",
"getName",
"(",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
]
| List of evaluated Panels.
Returns the all the evaluated panels which are split into two
types success and fail.
Success type contains the panels have been evaluated with success
and vice verca for fail type.
@see \CsvMigrations\Utility\Panel::evalExpression How the expression is evaluated.
@param mixed[] $config Table's config.
@param mixed[] $data to get the values for placeholders
@return mixed[] Evaluated panel list. | [
"List",
"of",
"evaluated",
"Panels",
"."
]
| 49300070cdd9b829670a3c40f747c535c8e539b3 | https://github.com/QoboLtd/cakephp-csv-migrations/blob/49300070cdd9b829670a3c40f747c535c8e539b3/src/Controller/Traits/PanelsTrait.php#L34-L48 | train |
QoboLtd/cakephp-csv-migrations | src/Utility/Validate/Check.php | Check.getInstance | public static function getInstance(string $checkClass) : CheckInterface
{
$checkClass = $checkClass;
if (!class_exists($checkClass)) {
throw new RuntimeException("Check class [$checkClass] does not exist");
}
if (!in_array(static::$interface, array_keys(class_implements($checkClass)))) {
throw new RuntimeException("Check class [$checkClass] does not implement [" . static::$interface . "]");
}
return new $checkClass();
} | php | public static function getInstance(string $checkClass) : CheckInterface
{
$checkClass = $checkClass;
if (!class_exists($checkClass)) {
throw new RuntimeException("Check class [$checkClass] does not exist");
}
if (!in_array(static::$interface, array_keys(class_implements($checkClass)))) {
throw new RuntimeException("Check class [$checkClass] does not implement [" . static::$interface . "]");
}
return new $checkClass();
} | [
"public",
"static",
"function",
"getInstance",
"(",
"string",
"$",
"checkClass",
")",
":",
"CheckInterface",
"{",
"$",
"checkClass",
"=",
"$",
"checkClass",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"checkClass",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Check class [$checkClass] does not exist\"",
")",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"static",
"::",
"$",
"interface",
",",
"array_keys",
"(",
"class_implements",
"(",
"$",
"checkClass",
")",
")",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Check class [$checkClass] does not implement [\"",
".",
"static",
"::",
"$",
"interface",
".",
"\"]\"",
")",
";",
"}",
"return",
"new",
"$",
"checkClass",
"(",
")",
";",
"}"
]
| Get an instance of a given check class
@throws \RuntimeException when class does not exist or is invalid
@param string $checkClass Name of the check class
@return \CsvMigrations\Utility\Validate\Check\CheckInterface | [
"Get",
"an",
"instance",
"of",
"a",
"given",
"check",
"class"
]
| 49300070cdd9b829670a3c40f747c535c8e539b3 | https://github.com/QoboLtd/cakephp-csv-migrations/blob/49300070cdd9b829670a3c40f747c535c8e539b3/src/Utility/Validate/Check.php#L32-L45 | train |
QoboLtd/cakephp-csv-migrations | src/Utility/Validate/Check.php | Check.getList | public static function getList(string $module) : array
{
$default = Configure::read('CsvMigrations.ValidateShell.module._default');
$result = Configure::read('CsvMigrations.ValidateShell.module.' . $module);
$result = empty($result) ? $default : $result;
$result = empty($result['checks']) ? [] : $result['checks'];
return $result;
} | php | public static function getList(string $module) : array
{
$default = Configure::read('CsvMigrations.ValidateShell.module._default');
$result = Configure::read('CsvMigrations.ValidateShell.module.' . $module);
$result = empty($result) ? $default : $result;
$result = empty($result['checks']) ? [] : $result['checks'];
return $result;
} | [
"public",
"static",
"function",
"getList",
"(",
"string",
"$",
"module",
")",
":",
"array",
"{",
"$",
"default",
"=",
"Configure",
"::",
"read",
"(",
"'CsvMigrations.ValidateShell.module._default'",
")",
";",
"$",
"result",
"=",
"Configure",
"::",
"read",
"(",
"'CsvMigrations.ValidateShell.module.'",
".",
"$",
"module",
")",
";",
"$",
"result",
"=",
"empty",
"(",
"$",
"result",
")",
"?",
"$",
"default",
":",
"$",
"result",
";",
"$",
"result",
"=",
"empty",
"(",
"$",
"result",
"[",
"'checks'",
"]",
")",
"?",
"[",
"]",
":",
"$",
"result",
"[",
"'checks'",
"]",
";",
"return",
"$",
"result",
";",
"}"
]
| Get ValidateShell checks configuration for a given module
If no checks configured for the given module, return
the default checks instead (aka checks for module
'_default').
@param string $module Module name
@return mixed[] | [
"Get",
"ValidateShell",
"checks",
"configuration",
"for",
"a",
"given",
"module"
]
| 49300070cdd9b829670a3c40f747c535c8e539b3 | https://github.com/QoboLtd/cakephp-csv-migrations/blob/49300070cdd9b829670a3c40f747c535c8e539b3/src/Utility/Validate/Check.php#L57-L65 | train |
QoboLtd/cakephp-csv-migrations | src/Shell/Task/CsvModuleTask.php | CsvModuleTask.getOptionParser | public function getOptionParser()
{
$parser = parent::getOptionParser();
$parser->setDescription('Bakes Module bootstrap configuration files and MVC classes');
$parser->addArgument('name', [
'help' => 'The Module name to bake',
'required' => true
]);
return $parser;
} | php | public function getOptionParser()
{
$parser = parent::getOptionParser();
$parser->setDescription('Bakes Module bootstrap configuration files and MVC classes');
$parser->addArgument('name', [
'help' => 'The Module name to bake',
'required' => true
]);
return $parser;
} | [
"public",
"function",
"getOptionParser",
"(",
")",
"{",
"$",
"parser",
"=",
"parent",
"::",
"getOptionParser",
"(",
")",
";",
"$",
"parser",
"->",
"setDescription",
"(",
"'Bakes Module bootstrap configuration files and MVC classes'",
")",
";",
"$",
"parser",
"->",
"addArgument",
"(",
"'name'",
",",
"[",
"'help'",
"=>",
"'The Module name to bake'",
",",
"'required'",
"=>",
"true",
"]",
")",
";",
"return",
"$",
"parser",
";",
"}"
]
| Configure option parser
@return \Cake\Console\ConsoleOptionParser | [
"Configure",
"option",
"parser"
]
| 49300070cdd9b829670a3c40f747c535c8e539b3 | https://github.com/QoboLtd/cakephp-csv-migrations/blob/49300070cdd9b829670a3c40f747c535c8e539b3/src/Shell/Task/CsvModuleTask.php#L47-L57 | train |
QoboLtd/cakephp-csv-migrations | src/Shell/Task/CsvModuleTask.php | CsvModuleTask.bake | private function bake(string $name, string $template, array $data = [], string $suffix = '', array $options = []) : bool
{
$this->BakeTemplate->set($data);
$contents = $this->BakeTemplate->generate('CsvMigrations.' . $template);
$path = empty($options['path']) ? $this->getPath() : $options['path'];
$extension = empty($options['ext']) ? $options['ext'] = 'php' : $options['ext'];
return $this->createFile($path . $name . $suffix . '.' . $extension, $contents);
} | php | private function bake(string $name, string $template, array $data = [], string $suffix = '', array $options = []) : bool
{
$this->BakeTemplate->set($data);
$contents = $this->BakeTemplate->generate('CsvMigrations.' . $template);
$path = empty($options['path']) ? $this->getPath() : $options['path'];
$extension = empty($options['ext']) ? $options['ext'] = 'php' : $options['ext'];
return $this->createFile($path . $name . $suffix . '.' . $extension, $contents);
} | [
"private",
"function",
"bake",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"template",
",",
"array",
"$",
"data",
"=",
"[",
"]",
",",
"string",
"$",
"suffix",
"=",
"''",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
":",
"bool",
"{",
"$",
"this",
"->",
"BakeTemplate",
"->",
"set",
"(",
"$",
"data",
")",
";",
"$",
"contents",
"=",
"$",
"this",
"->",
"BakeTemplate",
"->",
"generate",
"(",
"'CsvMigrations.'",
".",
"$",
"template",
")",
";",
"$",
"path",
"=",
"empty",
"(",
"$",
"options",
"[",
"'path'",
"]",
")",
"?",
"$",
"this",
"->",
"getPath",
"(",
")",
":",
"$",
"options",
"[",
"'path'",
"]",
";",
"$",
"extension",
"=",
"empty",
"(",
"$",
"options",
"[",
"'ext'",
"]",
")",
"?",
"$",
"options",
"[",
"'ext'",
"]",
"=",
"'php'",
":",
"$",
"options",
"[",
"'ext'",
"]",
";",
"return",
"$",
"this",
"->",
"createFile",
"(",
"$",
"path",
".",
"$",
"name",
".",
"$",
"suffix",
".",
"'.'",
".",
"$",
"extension",
",",
"$",
"contents",
")",
";",
"}"
]
| Wrapper method responsible for baking the actual files.
@param string $name Filename
@param string $template Template name
@param mixed[] $data Template data
@param string $suffix Filename suffix
@param mixed[] $options Extra options
@return bool | [
"Wrapper",
"method",
"responsible",
"for",
"baking",
"the",
"actual",
"files",
"."
]
| 49300070cdd9b829670a3c40f747c535c8e539b3 | https://github.com/QoboLtd/cakephp-csv-migrations/blob/49300070cdd9b829670a3c40f747c535c8e539b3/src/Shell/Task/CsvModuleTask.php#L112-L121 | train |
QoboLtd/cakephp-csv-migrations | src/Shell/Task/CsvModuleTask.php | CsvModuleTask.bakeModuleConfig | private function bakeModuleConfig(string $name) : void
{
$options = [
'path' => Configure::read('CsvMigrations.modules.path') . $name . DS . 'config' . DS,
'ext' => 'json'
];
$this->bake('config.dist', 'Module/config/config', [], '', $options);
$this->bake('fields.dist', 'Module/config/fields', [], '', $options);
$this->bake(
'menus.dist',
'Module/config/menus',
['label' => Inflector::humanize($name), 'url' => DS . Inflector::dasherize($name) . DS],
'',
$options
);
} | php | private function bakeModuleConfig(string $name) : void
{
$options = [
'path' => Configure::read('CsvMigrations.modules.path') . $name . DS . 'config' . DS,
'ext' => 'json'
];
$this->bake('config.dist', 'Module/config/config', [], '', $options);
$this->bake('fields.dist', 'Module/config/fields', [], '', $options);
$this->bake(
'menus.dist',
'Module/config/menus',
['label' => Inflector::humanize($name), 'url' => DS . Inflector::dasherize($name) . DS],
'',
$options
);
} | [
"private",
"function",
"bakeModuleConfig",
"(",
"string",
"$",
"name",
")",
":",
"void",
"{",
"$",
"options",
"=",
"[",
"'path'",
"=>",
"Configure",
"::",
"read",
"(",
"'CsvMigrations.modules.path'",
")",
".",
"$",
"name",
".",
"DS",
".",
"'config'",
".",
"DS",
",",
"'ext'",
"=>",
"'json'",
"]",
";",
"$",
"this",
"->",
"bake",
"(",
"'config.dist'",
",",
"'Module/config/config'",
",",
"[",
"]",
",",
"''",
",",
"$",
"options",
")",
";",
"$",
"this",
"->",
"bake",
"(",
"'fields.dist'",
",",
"'Module/config/fields'",
",",
"[",
"]",
",",
"''",
",",
"$",
"options",
")",
";",
"$",
"this",
"->",
"bake",
"(",
"'menus.dist'",
",",
"'Module/config/menus'",
",",
"[",
"'label'",
"=>",
"Inflector",
"::",
"humanize",
"(",
"$",
"name",
")",
",",
"'url'",
"=>",
"DS",
".",
"Inflector",
"::",
"dasherize",
"(",
"$",
"name",
")",
".",
"DS",
"]",
",",
"''",
",",
"$",
"options",
")",
";",
"}"
]
| Bake Module configuration files.
@param string $name Module name
@return void | [
"Bake",
"Module",
"configuration",
"files",
"."
]
| 49300070cdd9b829670a3c40f747c535c8e539b3 | https://github.com/QoboLtd/cakephp-csv-migrations/blob/49300070cdd9b829670a3c40f747c535c8e539b3/src/Shell/Task/CsvModuleTask.php#L129-L145 | train |
QoboLtd/cakephp-csv-migrations | src/Shell/Task/CsvModuleTask.php | CsvModuleTask.bakeViewsConfig | private function bakeViewsConfig(string $name) : void
{
$options = [
'path' => Configure::read('CsvMigrations.modules.path') . $name . DS . 'views' . DS,
'ext' => 'json'
];
$this->bake('add.dist', 'Module/views/add', [], '', $options);
$this->bake('edit.dist', 'Module/views/edit', [], '', $options);
$this->bake('index.dist', 'Module/views/index', [], '', $options);
$this->bake('view.dist', 'Module/views/view', [], '', $options);
} | php | private function bakeViewsConfig(string $name) : void
{
$options = [
'path' => Configure::read('CsvMigrations.modules.path') . $name . DS . 'views' . DS,
'ext' => 'json'
];
$this->bake('add.dist', 'Module/views/add', [], '', $options);
$this->bake('edit.dist', 'Module/views/edit', [], '', $options);
$this->bake('index.dist', 'Module/views/index', [], '', $options);
$this->bake('view.dist', 'Module/views/view', [], '', $options);
} | [
"private",
"function",
"bakeViewsConfig",
"(",
"string",
"$",
"name",
")",
":",
"void",
"{",
"$",
"options",
"=",
"[",
"'path'",
"=>",
"Configure",
"::",
"read",
"(",
"'CsvMigrations.modules.path'",
")",
".",
"$",
"name",
".",
"DS",
".",
"'views'",
".",
"DS",
",",
"'ext'",
"=>",
"'json'",
"]",
";",
"$",
"this",
"->",
"bake",
"(",
"'add.dist'",
",",
"'Module/views/add'",
",",
"[",
"]",
",",
"''",
",",
"$",
"options",
")",
";",
"$",
"this",
"->",
"bake",
"(",
"'edit.dist'",
",",
"'Module/views/edit'",
",",
"[",
"]",
",",
"''",
",",
"$",
"options",
")",
";",
"$",
"this",
"->",
"bake",
"(",
"'index.dist'",
",",
"'Module/views/index'",
",",
"[",
"]",
",",
"''",
",",
"$",
"options",
")",
";",
"$",
"this",
"->",
"bake",
"(",
"'view.dist'",
",",
"'Module/views/view'",
",",
"[",
"]",
",",
"''",
",",
"$",
"options",
")",
";",
"}"
]
| Bake Views configuration files.
@param string $name Module name
@return void | [
"Bake",
"Views",
"configuration",
"files",
"."
]
| 49300070cdd9b829670a3c40f747c535c8e539b3 | https://github.com/QoboLtd/cakephp-csv-migrations/blob/49300070cdd9b829670a3c40f747c535c8e539b3/src/Shell/Task/CsvModuleTask.php#L169-L180 | train |
QoboLtd/cakephp-csv-migrations | src/Shell/Task/CsvModuleTask.php | CsvModuleTask.bakeController | private function bakeController(string $name) : void
{
$this->pathFragment = 'Controller/';
$this->bake($name, 'Controller/controller', ['name' => $name], 'Controller');
} | php | private function bakeController(string $name) : void
{
$this->pathFragment = 'Controller/';
$this->bake($name, 'Controller/controller', ['name' => $name], 'Controller');
} | [
"private",
"function",
"bakeController",
"(",
"string",
"$",
"name",
")",
":",
"void",
"{",
"$",
"this",
"->",
"pathFragment",
"=",
"'Controller/'",
";",
"$",
"this",
"->",
"bake",
"(",
"$",
"name",
",",
"'Controller/controller'",
",",
"[",
"'name'",
"=>",
"$",
"name",
"]",
",",
"'Controller'",
")",
";",
"}"
]
| Bake Controller class.
@param string $name Module name
@return void | [
"Bake",
"Controller",
"class",
"."
]
| 49300070cdd9b829670a3c40f747c535c8e539b3 | https://github.com/QoboLtd/cakephp-csv-migrations/blob/49300070cdd9b829670a3c40f747c535c8e539b3/src/Shell/Task/CsvModuleTask.php#L188-L193 | train |
QoboLtd/cakephp-csv-migrations | src/Shell/Task/CsvModuleTask.php | CsvModuleTask.bakeApiController | private function bakeApiController(string $name) : void
{
$apiPaths = $this->getTargetApiPath();
$this->pathFragment = $apiPaths['fragment'];
$this->bake($name, 'Controller/Api/controller', array_merge(['name' => $name], $apiPaths), 'Controller');
} | php | private function bakeApiController(string $name) : void
{
$apiPaths = $this->getTargetApiPath();
$this->pathFragment = $apiPaths['fragment'];
$this->bake($name, 'Controller/Api/controller', array_merge(['name' => $name], $apiPaths), 'Controller');
} | [
"private",
"function",
"bakeApiController",
"(",
"string",
"$",
"name",
")",
":",
"void",
"{",
"$",
"apiPaths",
"=",
"$",
"this",
"->",
"getTargetApiPath",
"(",
")",
";",
"$",
"this",
"->",
"pathFragment",
"=",
"$",
"apiPaths",
"[",
"'fragment'",
"]",
";",
"$",
"this",
"->",
"bake",
"(",
"$",
"name",
",",
"'Controller/Api/controller'",
",",
"array_merge",
"(",
"[",
"'name'",
"=>",
"$",
"name",
"]",
",",
"$",
"apiPaths",
")",
",",
"'Controller'",
")",
";",
"}"
]
| Bake API Controller class.
@param string $name Module name
@return void | [
"Bake",
"API",
"Controller",
"class",
"."
]
| 49300070cdd9b829670a3c40f747c535c8e539b3 | https://github.com/QoboLtd/cakephp-csv-migrations/blob/49300070cdd9b829670a3c40f747c535c8e539b3/src/Shell/Task/CsvModuleTask.php#L201-L207 | train |
QoboLtd/cakephp-csv-migrations | src/Shell/Task/CsvModuleTask.php | CsvModuleTask.bakeFeature | private function bakeFeature(string $name) : void
{
$this->pathFragment = 'Feature/Type/Module/';
$this->bake($name, 'Feature/feature', ['name' => $name], 'Feature');
} | php | private function bakeFeature(string $name) : void
{
$this->pathFragment = 'Feature/Type/Module/';
$this->bake($name, 'Feature/feature', ['name' => $name], 'Feature');
} | [
"private",
"function",
"bakeFeature",
"(",
"string",
"$",
"name",
")",
":",
"void",
"{",
"$",
"this",
"->",
"pathFragment",
"=",
"'Feature/Type/Module/'",
";",
"$",
"this",
"->",
"bake",
"(",
"$",
"name",
",",
"'Feature/feature'",
",",
"[",
"'name'",
"=>",
"$",
"name",
"]",
",",
"'Feature'",
")",
";",
"}"
]
| Bake Feature class.
@param string $name Module name
@return void | [
"Bake",
"Feature",
"class",
"."
]
| 49300070cdd9b829670a3c40f747c535c8e539b3 | https://github.com/QoboLtd/cakephp-csv-migrations/blob/49300070cdd9b829670a3c40f747c535c8e539b3/src/Shell/Task/CsvModuleTask.php#L241-L246 | train |
QoboLtd/cakephp-csv-migrations | src/Shell/Task/CsvModuleTask.php | CsvModuleTask.getTargetApiPath | protected function getTargetApiPath() : array
{
$result = [
'fragment' => 'Controller/Api',
'namespace' => 'App\Controller\Api',
];
$versions = Utility::getApiVersions();
if (empty($versions)) {
return $result;
}
$recent = end($versions);
if (preg_match('/^api(.*)$/', $recent['prefix'], $matches)) {
$postfix = strtoupper($matches[1]);
$result['fragment'] .= $postfix . '/';
$result['namespace'] .= str_replace('/', '\\', $postfix);
}
return $result;
} | php | protected function getTargetApiPath() : array
{
$result = [
'fragment' => 'Controller/Api',
'namespace' => 'App\Controller\Api',
];
$versions = Utility::getApiVersions();
if (empty($versions)) {
return $result;
}
$recent = end($versions);
if (preg_match('/^api(.*)$/', $recent['prefix'], $matches)) {
$postfix = strtoupper($matches[1]);
$result['fragment'] .= $postfix . '/';
$result['namespace'] .= str_replace('/', '\\', $postfix);
}
return $result;
} | [
"protected",
"function",
"getTargetApiPath",
"(",
")",
":",
"array",
"{",
"$",
"result",
"=",
"[",
"'fragment'",
"=>",
"'Controller/Api'",
",",
"'namespace'",
"=>",
"'App\\Controller\\Api'",
",",
"]",
";",
"$",
"versions",
"=",
"Utility",
"::",
"getApiVersions",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"versions",
")",
")",
"{",
"return",
"$",
"result",
";",
"}",
"$",
"recent",
"=",
"end",
"(",
"$",
"versions",
")",
";",
"if",
"(",
"preg_match",
"(",
"'/^api(.*)$/'",
",",
"$",
"recent",
"[",
"'prefix'",
"]",
",",
"$",
"matches",
")",
")",
"{",
"$",
"postfix",
"=",
"strtoupper",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
";",
"$",
"result",
"[",
"'fragment'",
"]",
".=",
"$",
"postfix",
".",
"'/'",
";",
"$",
"result",
"[",
"'namespace'",
"]",
".=",
"str_replace",
"(",
"'/'",
",",
"'\\\\'",
",",
"$",
"postfix",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
]
| Get Target API Path for API Controllers
We create API controllers for the most recent API version.
@return mixed[] $result containing path Fragment for baking. | [
"Get",
"Target",
"API",
"Path",
"for",
"API",
"Controllers"
]
| 49300070cdd9b829670a3c40f747c535c8e539b3 | https://github.com/QoboLtd/cakephp-csv-migrations/blob/49300070cdd9b829670a3c40f747c535c8e539b3/src/Shell/Task/CsvModuleTask.php#L255-L277 | train |
QoboLtd/cakephp-csv-migrations | src/FieldHandlers/FieldHandlerFactory.php | FieldHandlerFactory.getByTableField | public static function getByTableField($table, string $field, array $options = [], ?View $view = null) : FieldHandlerInterface
{
$table = is_string($table) ? TableRegistry::get($table) : $table;
$handler = self::getHandler($table, $field, $options, $view);
return $handler;
} | php | public static function getByTableField($table, string $field, array $options = [], ?View $view = null) : FieldHandlerInterface
{
$table = is_string($table) ? TableRegistry::get($table) : $table;
$handler = self::getHandler($table, $field, $options, $view);
return $handler;
} | [
"public",
"static",
"function",
"getByTableField",
"(",
"$",
"table",
",",
"string",
"$",
"field",
",",
"array",
"$",
"options",
"=",
"[",
"]",
",",
"?",
"View",
"$",
"view",
"=",
"null",
")",
":",
"FieldHandlerInterface",
"{",
"$",
"table",
"=",
"is_string",
"(",
"$",
"table",
")",
"?",
"TableRegistry",
"::",
"get",
"(",
"$",
"table",
")",
":",
"$",
"table",
";",
"$",
"handler",
"=",
"self",
"::",
"getHandler",
"(",
"$",
"table",
",",
"$",
"field",
",",
"$",
"options",
",",
"$",
"view",
")",
";",
"return",
"$",
"handler",
";",
"}"
]
| Get an instance of field handler for given table field.
@param mixed $table Table name or instance of \Cake\ORM\Table
@param string $field Field name
@param mixed[] $options Field handler options
@param \Cake\View\View|null $view CakePHP view instance
@return \CsvMigrations\FieldHandlers\FieldHandlerInterface | [
"Get",
"an",
"instance",
"of",
"field",
"handler",
"for",
"given",
"table",
"field",
"."
]
| 49300070cdd9b829670a3c40f747c535c8e539b3 | https://github.com/QoboLtd/cakephp-csv-migrations/blob/49300070cdd9b829670a3c40f747c535c8e539b3/src/FieldHandlers/FieldHandlerFactory.php#L51-L57 | train |
QoboLtd/cakephp-csv-migrations | src/FieldHandlers/FieldHandlerFactory.php | FieldHandlerFactory.renderInput | public function renderInput($table, string $field, $data = '', array $options = []) : string
{
$handler = self::getByTableField($table, $field, $options, $this->cakeView);
return $handler->renderInput($data, $options);
} | php | public function renderInput($table, string $field, $data = '', array $options = []) : string
{
$handler = self::getByTableField($table, $field, $options, $this->cakeView);
return $handler->renderInput($data, $options);
} | [
"public",
"function",
"renderInput",
"(",
"$",
"table",
",",
"string",
"$",
"field",
",",
"$",
"data",
"=",
"''",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
":",
"string",
"{",
"$",
"handler",
"=",
"self",
"::",
"getByTableField",
"(",
"$",
"table",
",",
"$",
"field",
",",
"$",
"options",
",",
"$",
"this",
"->",
"cakeView",
")",
";",
"return",
"$",
"handler",
"->",
"renderInput",
"(",
"$",
"data",
",",
"$",
"options",
")",
";",
"}"
]
| Render field form input.
@param mixed $table Name or instance of the Table
@param string $field Field name
@param mixed $data Field data
@param mixed[] $options Field options
@return string Field input | [
"Render",
"field",
"form",
"input",
"."
]
| 49300070cdd9b829670a3c40f747c535c8e539b3 | https://github.com/QoboLtd/cakephp-csv-migrations/blob/49300070cdd9b829670a3c40f747c535c8e539b3/src/FieldHandlers/FieldHandlerFactory.php#L68-L73 | train |
QoboLtd/cakephp-csv-migrations | src/FieldHandlers/FieldHandlerFactory.php | FieldHandlerFactory.renderName | public function renderName($table, string $field, array $options = []) : string
{
$handler = self::getByTableField($table, $field, $options, $this->cakeView);
return $handler->renderName();
} | php | public function renderName($table, string $field, array $options = []) : string
{
$handler = self::getByTableField($table, $field, $options, $this->cakeView);
return $handler->renderName();
} | [
"public",
"function",
"renderName",
"(",
"$",
"table",
",",
"string",
"$",
"field",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
":",
"string",
"{",
"$",
"handler",
"=",
"self",
"::",
"getByTableField",
"(",
"$",
"table",
",",
"$",
"field",
",",
"$",
"options",
",",
"$",
"this",
"->",
"cakeView",
")",
";",
"return",
"$",
"handler",
"->",
"renderName",
"(",
")",
";",
"}"
]
| Render field form label.
@param mixed $table Name or instance of the Table
@param string $field Field name
@param mixed[] $options Field options
@return string Field input | [
"Render",
"field",
"form",
"label",
"."
]
| 49300070cdd9b829670a3c40f747c535c8e539b3 | https://github.com/QoboLtd/cakephp-csv-migrations/blob/49300070cdd9b829670a3c40f747c535c8e539b3/src/FieldHandlers/FieldHandlerFactory.php#L83-L88 | train |
QoboLtd/cakephp-csv-migrations | src/FieldHandlers/FieldHandlerFactory.php | FieldHandlerFactory.getSearchOptions | public function getSearchOptions($table, string $field, array $options = []) : array
{
$handler = self::getByTableField($table, $field, $options, $this->cakeView);
return $handler->getSearchOptions($options);
} | php | public function getSearchOptions($table, string $field, array $options = []) : array
{
$handler = self::getByTableField($table, $field, $options, $this->cakeView);
return $handler->getSearchOptions($options);
} | [
"public",
"function",
"getSearchOptions",
"(",
"$",
"table",
",",
"string",
"$",
"field",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
":",
"array",
"{",
"$",
"handler",
"=",
"self",
"::",
"getByTableField",
"(",
"$",
"table",
",",
"$",
"field",
",",
"$",
"options",
",",
"$",
"this",
"->",
"cakeView",
")",
";",
"return",
"$",
"handler",
"->",
"getSearchOptions",
"(",
"$",
"options",
")",
";",
"}"
]
| Get search options.
@param mixed $table Name or instance of the Table
@param string $field Field name
@param mixed[] $options Field options
@return mixed[] Array of fields and their options | [
"Get",
"search",
"options",
"."
]
| 49300070cdd9b829670a3c40f747c535c8e539b3 | https://github.com/QoboLtd/cakephp-csv-migrations/blob/49300070cdd9b829670a3c40f747c535c8e539b3/src/FieldHandlers/FieldHandlerFactory.php#L98-L103 | train |
QoboLtd/cakephp-csv-migrations | src/FieldHandlers/FieldHandlerFactory.php | FieldHandlerFactory.fieldToDb | public function fieldToDb(CsvField $csvField, $table, string $field = '') : array
{
if ('' === $field) {
$field = $csvField->getName();
}
// No options or view is necessary for the fieldToDb currently
$handler = self::getByTableField($table, $field);
return $handler->fieldToDb($csvField);
} | php | public function fieldToDb(CsvField $csvField, $table, string $field = '') : array
{
if ('' === $field) {
$field = $csvField->getName();
}
// No options or view is necessary for the fieldToDb currently
$handler = self::getByTableField($table, $field);
return $handler->fieldToDb($csvField);
} | [
"public",
"function",
"fieldToDb",
"(",
"CsvField",
"$",
"csvField",
",",
"$",
"table",
",",
"string",
"$",
"field",
"=",
"''",
")",
":",
"array",
"{",
"if",
"(",
"''",
"===",
"$",
"field",
")",
"{",
"$",
"field",
"=",
"$",
"csvField",
"->",
"getName",
"(",
")",
";",
"}",
"// No options or view is necessary for the fieldToDb currently",
"$",
"handler",
"=",
"self",
"::",
"getByTableField",
"(",
"$",
"table",
",",
"$",
"field",
")",
";",
"return",
"$",
"handler",
"->",
"fieldToDb",
"(",
"$",
"csvField",
")",
";",
"}"
]
| Convert field CSV into database fields
**NOTE** For the time-being, we are not utilizing $table and $field
parameters. They are here to ease the near-future refactoring
of the FieldHandlerFactory class into a proper (and simple)
factory.
@param \CsvMigrations\FieldHandlers\CsvField $csvField CsvField instance
@param mixed $table Name or instance of the Table
@param string $field Field name
@return mixed[] list of DbField instances | [
"Convert",
"field",
"CSV",
"into",
"database",
"fields"
]
| 49300070cdd9b829670a3c40f747c535c8e539b3 | https://github.com/QoboLtd/cakephp-csv-migrations/blob/49300070cdd9b829670a3c40f747c535c8e539b3/src/FieldHandlers/FieldHandlerFactory.php#L156-L165 | train |
QoboLtd/cakephp-csv-migrations | src/FieldHandlers/FieldHandlerFactory.php | FieldHandlerFactory.getHandler | protected static function getHandler(Table $table, $field, array $options = [], View $view = null) : FieldHandlerInterface
{
if (empty($field)) {
throw new InvalidArgumentException("Field parameter is empty");
}
// Save field name
$fieldName = '';
if (is_string($field)) {
$fieldName = $field;
}
// Overwrite field with field difinitions options
if (!empty($options['fieldDefinitions'])) {
$field = $options['fieldDefinitions'];
}
// Prepare the stub field
$stubFields = [];
if (is_string($field)) {
$stubFields = self::getStubFromString($fieldName);
}
if (is_array($field)) {
$stubFields = self::getStubFromArray($fieldName, $field);
}
if (empty($stubFields)) {
throw new InvalidArgumentException("Field can be either a string or an associative array");
}
$fieldDefinitions = $stubFields;
if ($table instanceof HasFieldsInterface) {
$fieldDefinitions = $table->getFieldsDefinitions($stubFields);
}
if (empty($fieldDefinitions[$fieldName])) {
throw new RuntimeException("Failed to get definition for field '$fieldName'");
}
$field = new CsvField($fieldDefinitions[$fieldName]);
$fieldType = $field->getType();
$config = ConfigFactory::getByType($fieldType, $fieldName, $table);
if ($view) {
$config->setView($view);
}
return new FieldHandler($config);
} | php | protected static function getHandler(Table $table, $field, array $options = [], View $view = null) : FieldHandlerInterface
{
if (empty($field)) {
throw new InvalidArgumentException("Field parameter is empty");
}
// Save field name
$fieldName = '';
if (is_string($field)) {
$fieldName = $field;
}
// Overwrite field with field difinitions options
if (!empty($options['fieldDefinitions'])) {
$field = $options['fieldDefinitions'];
}
// Prepare the stub field
$stubFields = [];
if (is_string($field)) {
$stubFields = self::getStubFromString($fieldName);
}
if (is_array($field)) {
$stubFields = self::getStubFromArray($fieldName, $field);
}
if (empty($stubFields)) {
throw new InvalidArgumentException("Field can be either a string or an associative array");
}
$fieldDefinitions = $stubFields;
if ($table instanceof HasFieldsInterface) {
$fieldDefinitions = $table->getFieldsDefinitions($stubFields);
}
if (empty($fieldDefinitions[$fieldName])) {
throw new RuntimeException("Failed to get definition for field '$fieldName'");
}
$field = new CsvField($fieldDefinitions[$fieldName]);
$fieldType = $field->getType();
$config = ConfigFactory::getByType($fieldType, $fieldName, $table);
if ($view) {
$config->setView($view);
}
return new FieldHandler($config);
} | [
"protected",
"static",
"function",
"getHandler",
"(",
"Table",
"$",
"table",
",",
"$",
"field",
",",
"array",
"$",
"options",
"=",
"[",
"]",
",",
"View",
"$",
"view",
"=",
"null",
")",
":",
"FieldHandlerInterface",
"{",
"if",
"(",
"empty",
"(",
"$",
"field",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Field parameter is empty\"",
")",
";",
"}",
"// Save field name",
"$",
"fieldName",
"=",
"''",
";",
"if",
"(",
"is_string",
"(",
"$",
"field",
")",
")",
"{",
"$",
"fieldName",
"=",
"$",
"field",
";",
"}",
"// Overwrite field with field difinitions options",
"if",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'fieldDefinitions'",
"]",
")",
")",
"{",
"$",
"field",
"=",
"$",
"options",
"[",
"'fieldDefinitions'",
"]",
";",
"}",
"// Prepare the stub field",
"$",
"stubFields",
"=",
"[",
"]",
";",
"if",
"(",
"is_string",
"(",
"$",
"field",
")",
")",
"{",
"$",
"stubFields",
"=",
"self",
"::",
"getStubFromString",
"(",
"$",
"fieldName",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"field",
")",
")",
"{",
"$",
"stubFields",
"=",
"self",
"::",
"getStubFromArray",
"(",
"$",
"fieldName",
",",
"$",
"field",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"stubFields",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Field can be either a string or an associative array\"",
")",
";",
"}",
"$",
"fieldDefinitions",
"=",
"$",
"stubFields",
";",
"if",
"(",
"$",
"table",
"instanceof",
"HasFieldsInterface",
")",
"{",
"$",
"fieldDefinitions",
"=",
"$",
"table",
"->",
"getFieldsDefinitions",
"(",
"$",
"stubFields",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"fieldDefinitions",
"[",
"$",
"fieldName",
"]",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Failed to get definition for field '$fieldName'\"",
")",
";",
"}",
"$",
"field",
"=",
"new",
"CsvField",
"(",
"$",
"fieldDefinitions",
"[",
"$",
"fieldName",
"]",
")",
";",
"$",
"fieldType",
"=",
"$",
"field",
"->",
"getType",
"(",
")",
";",
"$",
"config",
"=",
"ConfigFactory",
"::",
"getByType",
"(",
"$",
"fieldType",
",",
"$",
"fieldName",
",",
"$",
"table",
")",
";",
"if",
"(",
"$",
"view",
")",
"{",
"$",
"config",
"->",
"setView",
"(",
"$",
"view",
")",
";",
"}",
"return",
"new",
"FieldHandler",
"(",
"$",
"config",
")",
";",
"}"
]
| Get field handler instance
This method returns an instance of the appropriate
FieldHandler class.
@throws \RuntimeException when failed to instantiate field handler
@param Table $table Table instance
@param string|array $field Field name
@param mixed[] $options Field options
@param \Cake\View\View $view Optional CakePHP view instance
@return \CsvMigrations\FieldHandlers\FieldHandlerInterface | [
"Get",
"field",
"handler",
"instance"
]
| 49300070cdd9b829670a3c40f747c535c8e539b3 | https://github.com/QoboLtd/cakephp-csv-migrations/blob/49300070cdd9b829670a3c40f747c535c8e539b3/src/FieldHandlers/FieldHandlerFactory.php#L180-L229 | train |
QoboLtd/cakephp-csv-migrations | src/FieldHandlers/FieldHandlerFactory.php | FieldHandlerFactory.getStubFromArray | protected static function getStubFromArray(string $fieldName, array $field) : array
{
// Try our best to find the field name
if (empty($field['name']) && !empty($fieldName)) {
$field['name'] = $fieldName;
}
if (empty($field['name'])) {
throw new InvalidArgumentException("Field array is missing 'name' key");
}
if (empty($field['type'])) {
throw new InvalidArgumentException("Field array is missing 'type' key");
}
return [
$field['name'] => $field,
];
} | php | protected static function getStubFromArray(string $fieldName, array $field) : array
{
// Try our best to find the field name
if (empty($field['name']) && !empty($fieldName)) {
$field['name'] = $fieldName;
}
if (empty($field['name'])) {
throw new InvalidArgumentException("Field array is missing 'name' key");
}
if (empty($field['type'])) {
throw new InvalidArgumentException("Field array is missing 'type' key");
}
return [
$field['name'] => $field,
];
} | [
"protected",
"static",
"function",
"getStubFromArray",
"(",
"string",
"$",
"fieldName",
",",
"array",
"$",
"field",
")",
":",
"array",
"{",
"// Try our best to find the field name",
"if",
"(",
"empty",
"(",
"$",
"field",
"[",
"'name'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"fieldName",
")",
")",
"{",
"$",
"field",
"[",
"'name'",
"]",
"=",
"$",
"fieldName",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"field",
"[",
"'name'",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Field array is missing 'name' key\"",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"field",
"[",
"'type'",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Field array is missing 'type' key\"",
")",
";",
"}",
"return",
"[",
"$",
"field",
"[",
"'name'",
"]",
"=>",
"$",
"field",
",",
"]",
";",
"}"
]
| Get stub fields from a field array
@throws \InvalidArgumentException when field name or type are missing
@param string $fieldName Field name
@param mixed[] $field Field array
@return mixed[] Stub fields | [
"Get",
"stub",
"fields",
"from",
"a",
"field",
"array"
]
| 49300070cdd9b829670a3c40f747c535c8e539b3 | https://github.com/QoboLtd/cakephp-csv-migrations/blob/49300070cdd9b829670a3c40f747c535c8e539b3/src/FieldHandlers/FieldHandlerFactory.php#L255-L272 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.