id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
233,100
|
phillies2k/ratchet-bundle
|
WebSocket/Server/Factory.php
|
Factory.addPeriodicTimer
|
public function addPeriodicTimer(PeriodicTimerInterface $periodicTimer)
{
if (array_key_exists($periodicTimer->getName(), $this->periodicTimers)) {
throw new TimerAlreadyAddedException();
}
$this->periodicTimers[$periodicTimer->getName()] = $periodicTimer;
return $this;
}
|
php
|
public function addPeriodicTimer(PeriodicTimerInterface $periodicTimer)
{
if (array_key_exists($periodicTimer->getName(), $this->periodicTimers)) {
throw new TimerAlreadyAddedException();
}
$this->periodicTimers[$periodicTimer->getName()] = $periodicTimer;
return $this;
}
|
[
"public",
"function",
"addPeriodicTimer",
"(",
"PeriodicTimerInterface",
"$",
"periodicTimer",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"periodicTimer",
"->",
"getName",
"(",
")",
",",
"$",
"this",
"->",
"periodicTimers",
")",
")",
"{",
"throw",
"new",
"TimerAlreadyAddedException",
"(",
")",
";",
"}",
"$",
"this",
"->",
"periodicTimers",
"[",
"$",
"periodicTimer",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"periodicTimer",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds a periodic timer to the loop. Throws TimerAlreadyAddedException when the timer was already added to the
event loop.
@param PeriodicTimerInterface $periodicTimer
@return Factory
@throws \P2\Bundle\RatchetBundle\WebSocket\Exception\TimerAlreadyAddedException
|
[
"Adds",
"a",
"periodic",
"timer",
"to",
"the",
"loop",
".",
"Throws",
"TimerAlreadyAddedException",
"when",
"the",
"timer",
"was",
"already",
"added",
"to",
"the",
"event",
"loop",
"."
] |
1ea60f42d04c6e5e2c63c7f8c53262d382b0b5f3
|
https://github.com/phillies2k/ratchet-bundle/blob/1ea60f42d04c6e5e2c63c7f8c53262d382b0b5f3/WebSocket/Server/Factory.php#L76-L85
|
233,101
|
phillies2k/ratchet-bundle
|
WebSocket/Server/Factory.php
|
Factory.configure
|
protected function configure(IoServer $server)
{
foreach ($this->periodicTimers as $periodicTimer) {
$server->loop->addPeriodicTimer($periodicTimer->getInterval(), $periodicTimer->getCallback());
}
}
|
php
|
protected function configure(IoServer $server)
{
foreach ($this->periodicTimers as $periodicTimer) {
$server->loop->addPeriodicTimer($periodicTimer->getInterval(), $periodicTimer->getCallback());
}
}
|
[
"protected",
"function",
"configure",
"(",
"IoServer",
"$",
"server",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"periodicTimers",
"as",
"$",
"periodicTimer",
")",
"{",
"$",
"server",
"->",
"loop",
"->",
"addPeriodicTimer",
"(",
"$",
"periodicTimer",
"->",
"getInterval",
"(",
")",
",",
"$",
"periodicTimer",
"->",
"getCallback",
"(",
")",
")",
";",
"}",
"}"
] |
Configures the io server
@param IoServer $server
|
[
"Configures",
"the",
"io",
"server"
] |
1ea60f42d04c6e5e2c63c7f8c53262d382b0b5f3
|
https://github.com/phillies2k/ratchet-bundle/blob/1ea60f42d04c6e5e2c63c7f8c53262d382b0b5f3/WebSocket/Server/Factory.php#L105-L110
|
233,102
|
jkphl/rdfa-lite-microdata
|
src/RdfaLiteMicrodata/Ports/Parser/RdfaLite.php
|
RdfaLite.parseHtml
|
public function parseHtml($string)
{
return $this->parseSource(
$string,
new HtmlDocumentFactory(),
(new RdfaLiteElementProcessor())->setHtml(true),
new RdfaLiteContext()
);
}
|
php
|
public function parseHtml($string)
{
return $this->parseSource(
$string,
new HtmlDocumentFactory(),
(new RdfaLiteElementProcessor())->setHtml(true),
new RdfaLiteContext()
);
}
|
[
"public",
"function",
"parseHtml",
"(",
"$",
"string",
")",
"{",
"return",
"$",
"this",
"->",
"parseSource",
"(",
"$",
"string",
",",
"new",
"HtmlDocumentFactory",
"(",
")",
",",
"(",
"new",
"RdfaLiteElementProcessor",
"(",
")",
")",
"->",
"setHtml",
"(",
"true",
")",
",",
"new",
"RdfaLiteContext",
"(",
")",
")",
";",
"}"
] |
Parse an HTML string
@param string $string HTML string
@return \stdClass Extracted things
|
[
"Parse",
"an",
"HTML",
"string"
] |
12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8
|
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Ports/Parser/RdfaLite.php#L98-L106
|
233,103
|
civicrm/civicrm-setup
|
src/Setup/SmartyUtil.php
|
SmartyUtil.createSmarty
|
public static function createSmarty($srcPath) {
require_once 'CRM/Core/I18n.php';
$packagePath = implode(DIRECTORY_SEPARATOR, [$srcPath, 'packages']);
require_once $packagePath . DIRECTORY_SEPARATOR . 'Smarty' . DIRECTORY_SEPARATOR . 'Smarty.class.php';
$smarty = new \Smarty();
$smarty->template_dir = implode(DIRECTORY_SEPARATOR, [$srcPath, 'xml', 'templates']);
$smarty->plugins_dir = [
implode(DIRECTORY_SEPARATOR, [$packagePath, 'Smarty', 'plugins']),
implode(DIRECTORY_SEPARATOR, [$srcPath, 'CRM', 'Core', 'Smarty', 'plugins']),
];
$smarty->compile_dir = \Civi\Setup\FileUtil::createTempDir('templates_c');
$smarty->clear_all_cache();
// CRM-5308 / CRM-3507 - we need {localize} to work in the templates
require_once implode(DIRECTORY_SEPARATOR, [$srcPath, 'CRM', 'Core', 'Smarty', 'plugins', 'block.localize.php']);
$smarty->register_block('localize', 'smarty_block_localize');
return $smarty;
}
|
php
|
public static function createSmarty($srcPath) {
require_once 'CRM/Core/I18n.php';
$packagePath = implode(DIRECTORY_SEPARATOR, [$srcPath, 'packages']);
require_once $packagePath . DIRECTORY_SEPARATOR . 'Smarty' . DIRECTORY_SEPARATOR . 'Smarty.class.php';
$smarty = new \Smarty();
$smarty->template_dir = implode(DIRECTORY_SEPARATOR, [$srcPath, 'xml', 'templates']);
$smarty->plugins_dir = [
implode(DIRECTORY_SEPARATOR, [$packagePath, 'Smarty', 'plugins']),
implode(DIRECTORY_SEPARATOR, [$srcPath, 'CRM', 'Core', 'Smarty', 'plugins']),
];
$smarty->compile_dir = \Civi\Setup\FileUtil::createTempDir('templates_c');
$smarty->clear_all_cache();
// CRM-5308 / CRM-3507 - we need {localize} to work in the templates
require_once implode(DIRECTORY_SEPARATOR, [$srcPath, 'CRM', 'Core', 'Smarty', 'plugins', 'block.localize.php']);
$smarty->register_block('localize', 'smarty_block_localize');
return $smarty;
}
|
[
"public",
"static",
"function",
"createSmarty",
"(",
"$",
"srcPath",
")",
"{",
"require_once",
"'CRM/Core/I18n.php'",
";",
"$",
"packagePath",
"=",
"implode",
"(",
"DIRECTORY_SEPARATOR",
",",
"[",
"$",
"srcPath",
",",
"'packages'",
"]",
")",
";",
"require_once",
"$",
"packagePath",
".",
"DIRECTORY_SEPARATOR",
".",
"'Smarty'",
".",
"DIRECTORY_SEPARATOR",
".",
"'Smarty.class.php'",
";",
"$",
"smarty",
"=",
"new",
"\\",
"Smarty",
"(",
")",
";",
"$",
"smarty",
"->",
"template_dir",
"=",
"implode",
"(",
"DIRECTORY_SEPARATOR",
",",
"[",
"$",
"srcPath",
",",
"'xml'",
",",
"'templates'",
"]",
")",
";",
"$",
"smarty",
"->",
"plugins_dir",
"=",
"[",
"implode",
"(",
"DIRECTORY_SEPARATOR",
",",
"[",
"$",
"packagePath",
",",
"'Smarty'",
",",
"'plugins'",
"]",
")",
",",
"implode",
"(",
"DIRECTORY_SEPARATOR",
",",
"[",
"$",
"srcPath",
",",
"'CRM'",
",",
"'Core'",
",",
"'Smarty'",
",",
"'plugins'",
"]",
")",
",",
"]",
";",
"$",
"smarty",
"->",
"compile_dir",
"=",
"\\",
"Civi",
"\\",
"Setup",
"\\",
"FileUtil",
"::",
"createTempDir",
"(",
"'templates_c'",
")",
";",
"$",
"smarty",
"->",
"clear_all_cache",
"(",
")",
";",
"// CRM-5308 / CRM-3507 - we need {localize} to work in the templates",
"require_once",
"implode",
"(",
"DIRECTORY_SEPARATOR",
",",
"[",
"$",
"srcPath",
",",
"'CRM'",
",",
"'Core'",
",",
"'Smarty'",
",",
"'plugins'",
",",
"'block.localize.php'",
"]",
")",
";",
"$",
"smarty",
"->",
"register_block",
"(",
"'localize'",
",",
"'smarty_block_localize'",
")",
";",
"return",
"$",
"smarty",
";",
"}"
] |
Create a Smarty instance.
@return \Smarty
|
[
"Create",
"a",
"Smarty",
"instance",
"."
] |
556b312faf78781c85c4fc4ae6c1c3b658da9e09
|
https://github.com/civicrm/civicrm-setup/blob/556b312faf78781c85c4fc4ae6c1c3b658da9e09/src/Setup/SmartyUtil.php#L11-L31
|
233,104
|
tableau-mkt/elomentary
|
src/Api/AbstractBulkApi.php
|
AbstractBulkApi.getResponse
|
public function getResponse($key, $expectedResponse = null) {
if (isset($expectedResponse)) {
return $expectedResponse;
}
if (!isset($this->_responses[$key])) {
throw new InvalidArgumentException("Response value for $key is not available");
}
return $this->_responses[$key];
}
|
php
|
public function getResponse($key, $expectedResponse = null) {
if (isset($expectedResponse)) {
return $expectedResponse;
}
if (!isset($this->_responses[$key])) {
throw new InvalidArgumentException("Response value for $key is not available");
}
return $this->_responses[$key];
}
|
[
"public",
"function",
"getResponse",
"(",
"$",
"key",
",",
"$",
"expectedResponse",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"expectedResponse",
")",
")",
"{",
"return",
"$",
"expectedResponse",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_responses",
"[",
"$",
"key",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Response value for $key is not available\"",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_responses",
"[",
"$",
"key",
"]",
";",
"}"
] |
Get accessor for _responses array
@param string $key
_responses key
@param \Eloqua\HttpClient\Message\ResponseMediator $expectedResponse
Set if you want to force $expectedResponse to be returned
@return array
Value of requested Eloqua bulk API response
@throws \Eloqua\Exception\InvalidArgumentException
|
[
"Get",
"accessor",
"for",
"_responses",
"array"
] |
c9e8e67f8239cfd813fae59fe665ed7130c439d2
|
https://github.com/tableau-mkt/elomentary/blob/c9e8e67f8239cfd813fae59fe665ed7130c439d2/src/Api/AbstractBulkApi.php#L57-L67
|
233,105
|
tableau-mkt/elomentary
|
src/Api/AbstractBulkApi.php
|
AbstractBulkApi.upload
|
public function upload($contactObject, $mapResponse = null) {
$mapResponse = $this->getResponse('map', $mapResponse);
$uri = trim($mapResponse['uri'], '/');
return $this->setResponse('load', $this->post("$uri/data", $contactObject));
}
|
php
|
public function upload($contactObject, $mapResponse = null) {
$mapResponse = $this->getResponse('map', $mapResponse);
$uri = trim($mapResponse['uri'], '/');
return $this->setResponse('load', $this->post("$uri/data", $contactObject));
}
|
[
"public",
"function",
"upload",
"(",
"$",
"contactObject",
",",
"$",
"mapResponse",
"=",
"null",
")",
"{",
"$",
"mapResponse",
"=",
"$",
"this",
"->",
"getResponse",
"(",
"'map'",
",",
"$",
"mapResponse",
")",
";",
"$",
"uri",
"=",
"trim",
"(",
"$",
"mapResponse",
"[",
"'uri'",
"]",
",",
"'/'",
")",
";",
"return",
"$",
"this",
"->",
"setResponse",
"(",
"'load'",
",",
"$",
"this",
"->",
"post",
"(",
"\"$uri/data\"",
",",
"$",
"contactObject",
")",
")",
";",
"}"
] |
Upload imports file to Eloqua bulk staging area.
@param array $contactObject
Data to be uploaded
@param array $mapResponse
Response from $this->map(). Defaults to whatever is returned from the
last $this->map() call.
@return array
Eloqua response, required for sync() step.
|
[
"Upload",
"imports",
"file",
"to",
"Eloqua",
"bulk",
"staging",
"area",
"."
] |
c9e8e67f8239cfd813fae59fe665ed7130c439d2
|
https://github.com/tableau-mkt/elomentary/blob/c9e8e67f8239cfd813fae59fe665ed7130c439d2/src/Api/AbstractBulkApi.php#L111-L116
|
233,106
|
tableau-mkt/elomentary
|
src/Api/AbstractBulkApi.php
|
AbstractBulkApi.sync
|
public function sync($mapResponse = null) {
$mapResponse = $this->getResponse('map', $mapResponse);
return $this->setResponse('sync', $this->post('syncs', array (
'syncedInstanceUri' => $mapResponse['uri']
)));
}
|
php
|
public function sync($mapResponse = null) {
$mapResponse = $this->getResponse('map', $mapResponse);
return $this->setResponse('sync', $this->post('syncs', array (
'syncedInstanceUri' => $mapResponse['uri']
)));
}
|
[
"public",
"function",
"sync",
"(",
"$",
"mapResponse",
"=",
"null",
")",
"{",
"$",
"mapResponse",
"=",
"$",
"this",
"->",
"getResponse",
"(",
"'map'",
",",
"$",
"mapResponse",
")",
";",
"return",
"$",
"this",
"->",
"setResponse",
"(",
"'sync'",
",",
"$",
"this",
"->",
"post",
"(",
"'syncs'",
",",
"array",
"(",
"'syncedInstanceUri'",
"=>",
"$",
"mapResponse",
"[",
"'uri'",
"]",
")",
")",
")",
";",
"}"
] |
Syncs an import file to your Eloqua database, or syncs and export to a
downloadable file
@param array $mapResponse
Response from $this->map(). Defaults to whatever is returned from the
last $this->map() call.
@return array
Eloqua response, including URI for status() step.
|
[
"Syncs",
"an",
"import",
"file",
"to",
"your",
"Eloqua",
"database",
"or",
"syncs",
"and",
"export",
"to",
"a",
"downloadable",
"file"
] |
c9e8e67f8239cfd813fae59fe665ed7130c439d2
|
https://github.com/tableau-mkt/elomentary/blob/c9e8e67f8239cfd813fae59fe665ed7130c439d2/src/Api/AbstractBulkApi.php#L129-L135
|
233,107
|
tableau-mkt/elomentary
|
src/Api/AbstractBulkApi.php
|
AbstractBulkApi.status
|
public function status($wait = false, $syncResponse = null) {
$syncResponse = $this->getResponse('sync', $syncResponse);
$uri = trim($syncResponse['uri'], '/');
do {
$status = $this->get($uri);
} while ($wait and $this->isWaitingStatus($status) and sleep(1) === 0);
return $this->setResponse('status', $status);
}
|
php
|
public function status($wait = false, $syncResponse = null) {
$syncResponse = $this->getResponse('sync', $syncResponse);
$uri = trim($syncResponse['uri'], '/');
do {
$status = $this->get($uri);
} while ($wait and $this->isWaitingStatus($status) and sleep(1) === 0);
return $this->setResponse('status', $status);
}
|
[
"public",
"function",
"status",
"(",
"$",
"wait",
"=",
"false",
",",
"$",
"syncResponse",
"=",
"null",
")",
"{",
"$",
"syncResponse",
"=",
"$",
"this",
"->",
"getResponse",
"(",
"'sync'",
",",
"$",
"syncResponse",
")",
";",
"$",
"uri",
"=",
"trim",
"(",
"$",
"syncResponse",
"[",
"'uri'",
"]",
",",
"'/'",
")",
";",
"do",
"{",
"$",
"status",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"uri",
")",
";",
"}",
"while",
"(",
"$",
"wait",
"and",
"$",
"this",
"->",
"isWaitingStatus",
"(",
"$",
"status",
")",
"and",
"sleep",
"(",
"1",
")",
"===",
"0",
")",
";",
"return",
"$",
"this",
"->",
"setResponse",
"(",
"'status'",
",",
"$",
"status",
")",
";",
"}"
] |
Checks the status of the last sync.
@param bool $wait
If true, the function will block until the sync either
completes or fails. It will wait one second between the last response
and the next check.
This should be set to false for asynchronous operations.
@param array $syncResponse
Response from $this->sync(). Defaults to whatever is returned from the
last $this->sync() call.
@return array
Eloqua response, including URI for next steps.
|
[
"Checks",
"the",
"status",
"of",
"the",
"last",
"sync",
"."
] |
c9e8e67f8239cfd813fae59fe665ed7130c439d2
|
https://github.com/tableau-mkt/elomentary/blob/c9e8e67f8239cfd813fae59fe665ed7130c439d2/src/Api/AbstractBulkApi.php#L154-L163
|
233,108
|
tableau-mkt/elomentary
|
src/Api/AbstractBulkApi.php
|
AbstractBulkApi.download
|
public function download($statusResponse = null, $limit = null, $offset = null) {
$statusResponse = $this->getResponse('status', $statusResponse);
$uri = trim($statusResponse['syncedInstanceUri'], '/');
if (isset($limit) && isset($offset) && $limit > 0 && $offset >= 0){
return $this->get("$uri/data?limit=$limit&offset=$offset");
} elseif (isset($limit) && !isset($offset) && $limit > 0) {
return $this->get("$uri/data?limit=$limit");
} elseif (!isset($limit) && isset($offset) && $offset >= 0) {
return $this->get("$uri/data?offset=$offset");
} else {
return $this->get("$uri/data");
}
}
|
php
|
public function download($statusResponse = null, $limit = null, $offset = null) {
$statusResponse = $this->getResponse('status', $statusResponse);
$uri = trim($statusResponse['syncedInstanceUri'], '/');
if (isset($limit) && isset($offset) && $limit > 0 && $offset >= 0){
return $this->get("$uri/data?limit=$limit&offset=$offset");
} elseif (isset($limit) && !isset($offset) && $limit > 0) {
return $this->get("$uri/data?limit=$limit");
} elseif (!isset($limit) && isset($offset) && $offset >= 0) {
return $this->get("$uri/data?offset=$offset");
} else {
return $this->get("$uri/data");
}
}
|
[
"public",
"function",
"download",
"(",
"$",
"statusResponse",
"=",
"null",
",",
"$",
"limit",
"=",
"null",
",",
"$",
"offset",
"=",
"null",
")",
"{",
"$",
"statusResponse",
"=",
"$",
"this",
"->",
"getResponse",
"(",
"'status'",
",",
"$",
"statusResponse",
")",
";",
"$",
"uri",
"=",
"trim",
"(",
"$",
"statusResponse",
"[",
"'syncedInstanceUri'",
"]",
",",
"'/'",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"limit",
")",
"&&",
"isset",
"(",
"$",
"offset",
")",
"&&",
"$",
"limit",
">",
"0",
"&&",
"$",
"offset",
">=",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"get",
"(",
"\"$uri/data?limit=$limit&offset=$offset\"",
")",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"limit",
")",
"&&",
"!",
"isset",
"(",
"$",
"offset",
")",
"&&",
"$",
"limit",
">",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"get",
"(",
"\"$uri/data?limit=$limit\"",
")",
";",
"}",
"elseif",
"(",
"!",
"isset",
"(",
"$",
"limit",
")",
"&&",
"isset",
"(",
"$",
"offset",
")",
"&&",
"$",
"offset",
">=",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"get",
"(",
"\"$uri/data?offset=$offset\"",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"get",
"(",
"\"$uri/data\"",
")",
";",
"}",
"}"
] |
Retrieves data from the staging area.
@param array $statusResponse
Response from $this->status call. Defaults to last $this->status()
response.
@param integer $limit
A URL parameter that specifies the maximum number of records to return.
This can be any positive integer between 1 and 50000 inclusive.
If not specified, eloqua will automatically default to 1000.
@param integer $offset
Specifies an offset that allows you to retrieve the next batch of records.
For example, if your limit is 1000, specifying an offset of 1000 will return
records 1000 through 2000. If not specified, eloqua will automatically default to 0.
(Any positive integer).
@return array
Download response, including records matched from mapping() call.
|
[
"Retrieves",
"data",
"from",
"the",
"staging",
"area",
"."
] |
c9e8e67f8239cfd813fae59fe665ed7130c439d2
|
https://github.com/tableau-mkt/elomentary/blob/c9e8e67f8239cfd813fae59fe665ed7130c439d2/src/Api/AbstractBulkApi.php#L201-L214
|
233,109
|
tableau-mkt/elomentary
|
src/Api/AbstractBulkApi.php
|
AbstractBulkApi.log
|
public function log($statusResponse = null) {
$statusResponse = $this->getResponse('status', $statusResponse);
$uri = trim($statusResponse['uri'], '/');
return $this->get("$uri/logs");
}
|
php
|
public function log($statusResponse = null) {
$statusResponse = $this->getResponse('status', $statusResponse);
$uri = trim($statusResponse['uri'], '/');
return $this->get("$uri/logs");
}
|
[
"public",
"function",
"log",
"(",
"$",
"statusResponse",
"=",
"null",
")",
"{",
"$",
"statusResponse",
"=",
"$",
"this",
"->",
"getResponse",
"(",
"'status'",
",",
"$",
"statusResponse",
")",
";",
"$",
"uri",
"=",
"trim",
"(",
"$",
"statusResponse",
"[",
"'uri'",
"]",
",",
"'/'",
")",
";",
"return",
"$",
"this",
"->",
"get",
"(",
"\"$uri/logs\"",
")",
";",
"}"
] |
Returns log from last bulk API transfer.
@param array $statusResponse
Response from $this->status call. Defaults to last $this->status()
response.
@return array
Bulk API log from last transfer.
|
[
"Returns",
"log",
"from",
"last",
"bulk",
"API",
"transfer",
"."
] |
c9e8e67f8239cfd813fae59fe665ed7130c439d2
|
https://github.com/tableau-mkt/elomentary/blob/c9e8e67f8239cfd813fae59fe665ed7130c439d2/src/Api/AbstractBulkApi.php#L226-L231
|
233,110
|
canis-io/lumen-jwt-auth
|
src/Token.php
|
Token.ensureClaimValues
|
public function ensureClaimValues(array $validateClaims)
{
foreach ($validateClaims as $claim => $value) {
if (!isset($this->claims[$claim]) || $this->claims[$claim] !== $value) {
return false;
}
}
return true;
}
|
php
|
public function ensureClaimValues(array $validateClaims)
{
foreach ($validateClaims as $claim => $value) {
if (!isset($this->claims[$claim]) || $this->claims[$claim] !== $value) {
return false;
}
}
return true;
}
|
[
"public",
"function",
"ensureClaimValues",
"(",
"array",
"$",
"validateClaims",
")",
"{",
"foreach",
"(",
"$",
"validateClaims",
"as",
"$",
"claim",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"claims",
"[",
"$",
"claim",
"]",
")",
"||",
"$",
"this",
"->",
"claims",
"[",
"$",
"claim",
"]",
"!==",
"$",
"value",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Validate the claims of the token
@param array $validateClaims
@return boolean
|
[
"Validate",
"the",
"claims",
"of",
"the",
"token"
] |
5e1a76a9878ec58348a76aeea382e6cb9c104ef9
|
https://github.com/canis-io/lumen-jwt-auth/blob/5e1a76a9878ec58348a76aeea382e6cb9c104ef9/src/Token.php#L90-L98
|
233,111
|
civicrm/civicrm-setup
|
src/Setup/BasicRunner.php
|
BasicRunner.run
|
public static function run($ctrl) {
$method = $_SERVER['REQUEST_METHOD'];
list ($headers, $body) = $ctrl->run($method, ($method === 'GET' ? $_GET : $_POST));
foreach ($headers as $k => $v) {
header("$k: $v");
}
echo $body;
}
|
php
|
public static function run($ctrl) {
$method = $_SERVER['REQUEST_METHOD'];
list ($headers, $body) = $ctrl->run($method, ($method === 'GET' ? $_GET : $_POST));
foreach ($headers as $k => $v) {
header("$k: $v");
}
echo $body;
}
|
[
"public",
"static",
"function",
"run",
"(",
"$",
"ctrl",
")",
"{",
"$",
"method",
"=",
"$",
"_SERVER",
"[",
"'REQUEST_METHOD'",
"]",
";",
"list",
"(",
"$",
"headers",
",",
"$",
"body",
")",
"=",
"$",
"ctrl",
"->",
"run",
"(",
"$",
"method",
",",
"(",
"$",
"method",
"===",
"'GET'",
"?",
"$",
"_GET",
":",
"$",
"_POST",
")",
")",
";",
"foreach",
"(",
"$",
"headers",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"header",
"(",
"\"$k: $v\"",
")",
";",
"}",
"echo",
"$",
"body",
";",
"}"
] |
Execute the controller and display the output.
Note: This is really just an example which handles input and output using
stock PHP variables and functions. Depending on the environment,
it may be easier to work directly with `getCtrl()->run(...)` which
handles inputs/outputs in a more abstract fashion.
@param object $ctrl
A web controller.
|
[
"Execute",
"the",
"controller",
"and",
"display",
"the",
"output",
"."
] |
556b312faf78781c85c4fc4ae6c1c3b658da9e09
|
https://github.com/civicrm/civicrm-setup/blob/556b312faf78781c85c4fc4ae6c1c3b658da9e09/src/Setup/BasicRunner.php#L17-L24
|
233,112
|
ionux/phactor
|
src/BaseObject.php
|
BaseObject.genBytes
|
private function genBytes()
{
$tempvals = array();
for ($x = 0; $x < 256; $x++) {
$tempvals[$x] = chr($x);
}
return $tempvals;
}
|
php
|
private function genBytes()
{
$tempvals = array();
for ($x = 0; $x < 256; $x++) {
$tempvals[$x] = chr($x);
}
return $tempvals;
}
|
[
"private",
"function",
"genBytes",
"(",
")",
"{",
"$",
"tempvals",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"x",
"=",
"0",
";",
"$",
"x",
"<",
"256",
";",
"$",
"x",
"++",
")",
"{",
"$",
"tempvals",
"[",
"$",
"x",
"]",
"=",
"chr",
"(",
"$",
"x",
")",
";",
"}",
"return",
"$",
"tempvals",
";",
"}"
] |
Generates an array of byte values.
@return array $tempvals An array of bytes.
|
[
"Generates",
"an",
"array",
"of",
"byte",
"values",
"."
] |
667064d3930e043fd78abed9a2324aee52466fa5
|
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/BaseObject.php#L62-L71
|
233,113
|
mcustiel/php-simple-config
|
src/ConfigLoader.php
|
ConfigLoader.readFromCache
|
private function readFromCache()
{
if (($config = $this->cacheConfig->getCacheManager()->get($this->cacheConfig->getKey())) !== null) {
return $config;
}
$config = $this->read();
$this->cacheConfig->getCacheManager()->set(
$this->cacheConfig->getKey(),
$config,
$this->cacheConfig->getTtl()
);
return $config;
}
|
php
|
private function readFromCache()
{
if (($config = $this->cacheConfig->getCacheManager()->get($this->cacheConfig->getKey())) !== null) {
return $config;
}
$config = $this->read();
$this->cacheConfig->getCacheManager()->set(
$this->cacheConfig->getKey(),
$config,
$this->cacheConfig->getTtl()
);
return $config;
}
|
[
"private",
"function",
"readFromCache",
"(",
")",
"{",
"if",
"(",
"(",
"$",
"config",
"=",
"$",
"this",
"->",
"cacheConfig",
"->",
"getCacheManager",
"(",
")",
"->",
"get",
"(",
"$",
"this",
"->",
"cacheConfig",
"->",
"getKey",
"(",
")",
")",
")",
"!==",
"null",
")",
"{",
"return",
"$",
"config",
";",
"}",
"$",
"config",
"=",
"$",
"this",
"->",
"read",
"(",
")",
";",
"$",
"this",
"->",
"cacheConfig",
"->",
"getCacheManager",
"(",
")",
"->",
"set",
"(",
"$",
"this",
"->",
"cacheConfig",
"->",
"getKey",
"(",
")",
",",
"$",
"config",
",",
"$",
"this",
"->",
"cacheConfig",
"->",
"getTtl",
"(",
")",
")",
";",
"return",
"$",
"config",
";",
"}"
] |
Tries to read the configuration from cache, if it's not cached loads it from file and caches it.
@return array|object
|
[
"Tries",
"to",
"read",
"the",
"configuration",
"from",
"cache",
"if",
"it",
"s",
"not",
"cached",
"loads",
"it",
"from",
"file",
"and",
"caches",
"it",
"."
] |
da1b56cb9c3d4582a00da9d2380295a79f318ebb
|
https://github.com/mcustiel/php-simple-config/blob/da1b56cb9c3d4582a00da9d2380295a79f318ebb/src/ConfigLoader.php#L74-L87
|
233,114
|
CampaignChain/core
|
Controller/MilestoneController.php
|
MilestoneController.moveApiAction
|
public function moveApiAction(Request $request)
{
$serializer = $this->get('campaignchain.core.serializer.default');
$responseData = array();
$id = $request->request->get('id');
$newDue = new \DateTime($request->request->get('start_date'));
$milestoneService = $this->get('campaignchain.core.milestone');
$milestone = $milestoneService->getMilestone($id);
$responseData['id'] = $milestone->getId();
$oldDue = clone $milestone->getStartDate();
$responseData['old_due_date'] = $oldDue->format(\DateTime::ISO8601);
// Calculate time difference.
// TODO: Check whether start = end date.
$interval = $milestone->getStartDate()->diff($newDue);
$responseData['interval']['object'] = json_encode($interval, true);
$responseData['interval']['string'] = $interval->format(self::FORMAT_DATEINTERVAL);
// Set new due date.
$milestone = $milestoneService->moveMilestone($milestone, $interval);
$responseData['new_due_date'] = $milestone->getStartDate()->format(\DateTime::ISO8601);
$em = $this->getDoctrine()->getManager();
$em->flush();
return new Response($serializer->serialize($responseData, 'json'));
}
|
php
|
public function moveApiAction(Request $request)
{
$serializer = $this->get('campaignchain.core.serializer.default');
$responseData = array();
$id = $request->request->get('id');
$newDue = new \DateTime($request->request->get('start_date'));
$milestoneService = $this->get('campaignchain.core.milestone');
$milestone = $milestoneService->getMilestone($id);
$responseData['id'] = $milestone->getId();
$oldDue = clone $milestone->getStartDate();
$responseData['old_due_date'] = $oldDue->format(\DateTime::ISO8601);
// Calculate time difference.
// TODO: Check whether start = end date.
$interval = $milestone->getStartDate()->diff($newDue);
$responseData['interval']['object'] = json_encode($interval, true);
$responseData['interval']['string'] = $interval->format(self::FORMAT_DATEINTERVAL);
// Set new due date.
$milestone = $milestoneService->moveMilestone($milestone, $interval);
$responseData['new_due_date'] = $milestone->getStartDate()->format(\DateTime::ISO8601);
$em = $this->getDoctrine()->getManager();
$em->flush();
return new Response($serializer->serialize($responseData, 'json'));
}
|
[
"public",
"function",
"moveApiAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"serializer",
"=",
"$",
"this",
"->",
"get",
"(",
"'campaignchain.core.serializer.default'",
")",
";",
"$",
"responseData",
"=",
"array",
"(",
")",
";",
"$",
"id",
"=",
"$",
"request",
"->",
"request",
"->",
"get",
"(",
"'id'",
")",
";",
"$",
"newDue",
"=",
"new",
"\\",
"DateTime",
"(",
"$",
"request",
"->",
"request",
"->",
"get",
"(",
"'start_date'",
")",
")",
";",
"$",
"milestoneService",
"=",
"$",
"this",
"->",
"get",
"(",
"'campaignchain.core.milestone'",
")",
";",
"$",
"milestone",
"=",
"$",
"milestoneService",
"->",
"getMilestone",
"(",
"$",
"id",
")",
";",
"$",
"responseData",
"[",
"'id'",
"]",
"=",
"$",
"milestone",
"->",
"getId",
"(",
")",
";",
"$",
"oldDue",
"=",
"clone",
"$",
"milestone",
"->",
"getStartDate",
"(",
")",
";",
"$",
"responseData",
"[",
"'old_due_date'",
"]",
"=",
"$",
"oldDue",
"->",
"format",
"(",
"\\",
"DateTime",
"::",
"ISO8601",
")",
";",
"// Calculate time difference.",
"// TODO: Check whether start = end date.",
"$",
"interval",
"=",
"$",
"milestone",
"->",
"getStartDate",
"(",
")",
"->",
"diff",
"(",
"$",
"newDue",
")",
";",
"$",
"responseData",
"[",
"'interval'",
"]",
"[",
"'object'",
"]",
"=",
"json_encode",
"(",
"$",
"interval",
",",
"true",
")",
";",
"$",
"responseData",
"[",
"'interval'",
"]",
"[",
"'string'",
"]",
"=",
"$",
"interval",
"->",
"format",
"(",
"self",
"::",
"FORMAT_DATEINTERVAL",
")",
";",
"// Set new due date.",
"$",
"milestone",
"=",
"$",
"milestoneService",
"->",
"moveMilestone",
"(",
"$",
"milestone",
",",
"$",
"interval",
")",
";",
"$",
"responseData",
"[",
"'new_due_date'",
"]",
"=",
"$",
"milestone",
"->",
"getStartDate",
"(",
")",
"->",
"format",
"(",
"\\",
"DateTime",
"::",
"ISO8601",
")",
";",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"return",
"new",
"Response",
"(",
"$",
"serializer",
"->",
"serialize",
"(",
"$",
"responseData",
",",
"'json'",
")",
")",
";",
"}"
] |
Move a Milestone to a new start date.
@ApiDoc(
section = "Core",
views = { "private" },
requirements={
{
"name"="id",
"description" = "Milestone ID",
"requirement"="\d+"
},
{
"name"="start_date",
"description" = "Start date in ISO8601 format",
"requirement"="/(\d{4})-(\d{2})-(\d{2})T(\d{2})\:(\d{2})\:(\d{2})[+-](\d{2})\:(\d{2})/"
}
}
)
@param Request $request
@return Response
|
[
"Move",
"a",
"Milestone",
"to",
"a",
"new",
"start",
"date",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/MilestoneController.php#L172-L202
|
233,115
|
jkphl/rdfa-lite-microdata
|
src/RdfaLiteMicrodata/Infrastructure/Service/ThingGateway.php
|
ThingGateway.exportProperty
|
protected function exportProperty(PropertyInterface $property)
{
$value = $property->getValue();
return ($value instanceof ThingInterface) ? $this->exportThing($value) : $value;
}
|
php
|
protected function exportProperty(PropertyInterface $property)
{
$value = $property->getValue();
return ($value instanceof ThingInterface) ? $this->exportThing($value) : $value;
}
|
[
"protected",
"function",
"exportProperty",
"(",
"PropertyInterface",
"$",
"property",
")",
"{",
"$",
"value",
"=",
"$",
"property",
"->",
"getValue",
"(",
")",
";",
"return",
"(",
"$",
"value",
"instanceof",
"ThingInterface",
")",
"?",
"$",
"this",
"->",
"exportThing",
"(",
"$",
"value",
")",
":",
"$",
"value",
";",
"}"
] |
Export a property
@param PropertyInterface $property Property
@return ThingInterface|string Exported property
|
[
"Export",
"a",
"property"
] |
12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8
|
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Infrastructure/Service/ThingGateway.php#L85-L89
|
233,116
|
jkphl/rdfa-lite-microdata
|
src/RdfaLiteMicrodata/Infrastructure/Service/ThingGateway.php
|
ThingGateway.exportThing
|
protected function exportThing(ThingInterface $thing)
{
$iri = $this->iri;
return (object)[
'type' => array_map(
function (TypeInterface $type) use ($iri) {
return $iri ?
(object)[
'profile' => $type->getVocabulary()->getUri(),
'name' => $type->getType(),
] :
$type->getVocabulary()->expand($type->getType());
},
$thing->getTypes()
),
'id' => $thing->getResourceId(),
'properties' => $this->exportProperties($thing),
];
}
|
php
|
protected function exportThing(ThingInterface $thing)
{
$iri = $this->iri;
return (object)[
'type' => array_map(
function (TypeInterface $type) use ($iri) {
return $iri ?
(object)[
'profile' => $type->getVocabulary()->getUri(),
'name' => $type->getType(),
] :
$type->getVocabulary()->expand($type->getType());
},
$thing->getTypes()
),
'id' => $thing->getResourceId(),
'properties' => $this->exportProperties($thing),
];
}
|
[
"protected",
"function",
"exportThing",
"(",
"ThingInterface",
"$",
"thing",
")",
"{",
"$",
"iri",
"=",
"$",
"this",
"->",
"iri",
";",
"return",
"(",
"object",
")",
"[",
"'type'",
"=>",
"array_map",
"(",
"function",
"(",
"TypeInterface",
"$",
"type",
")",
"use",
"(",
"$",
"iri",
")",
"{",
"return",
"$",
"iri",
"?",
"(",
"object",
")",
"[",
"'profile'",
"=>",
"$",
"type",
"->",
"getVocabulary",
"(",
")",
"->",
"getUri",
"(",
")",
",",
"'name'",
"=>",
"$",
"type",
"->",
"getType",
"(",
")",
",",
"]",
":",
"$",
"type",
"->",
"getVocabulary",
"(",
")",
"->",
"expand",
"(",
"$",
"type",
"->",
"getType",
"(",
")",
")",
";",
"}",
",",
"$",
"thing",
"->",
"getTypes",
"(",
")",
")",
",",
"'id'",
"=>",
"$",
"thing",
"->",
"getResourceId",
"(",
")",
",",
"'properties'",
"=>",
"$",
"this",
"->",
"exportProperties",
"(",
"$",
"thing",
")",
",",
"]",
";",
"}"
] |
Export a single thing
@param ThingInterface $thing Thing
@return \stdClass Exported thing
|
[
"Export",
"a",
"single",
"thing"
] |
12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8
|
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Infrastructure/Service/ThingGateway.php#L97-L116
|
233,117
|
jkphl/rdfa-lite-microdata
|
src/RdfaLiteMicrodata/Infrastructure/Service/ThingGateway.php
|
ThingGateway.exportProperties
|
protected function exportProperties(ThingInterface $thing)
{
$properties = [];
foreach ($thing->getProperties() as $propertyIri => $propertyValues) {
if (count($propertyValues)) {
$propertyValues = array_map([$this, 'exportProperty'], $propertyValues);
$properties[strval($propertyIri)] = $this->iri ?
(object)[
'profile' => $propertyIri->getProfile(),
'name' => $propertyIri->getName(),
'values' => $propertyValues,
] : $propertyValues;
}
}
return $properties;
}
|
php
|
protected function exportProperties(ThingInterface $thing)
{
$properties = [];
foreach ($thing->getProperties() as $propertyIri => $propertyValues) {
if (count($propertyValues)) {
$propertyValues = array_map([$this, 'exportProperty'], $propertyValues);
$properties[strval($propertyIri)] = $this->iri ?
(object)[
'profile' => $propertyIri->getProfile(),
'name' => $propertyIri->getName(),
'values' => $propertyValues,
] : $propertyValues;
}
}
return $properties;
}
|
[
"protected",
"function",
"exportProperties",
"(",
"ThingInterface",
"$",
"thing",
")",
"{",
"$",
"properties",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"thing",
"->",
"getProperties",
"(",
")",
"as",
"$",
"propertyIri",
"=>",
"$",
"propertyValues",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"propertyValues",
")",
")",
"{",
"$",
"propertyValues",
"=",
"array_map",
"(",
"[",
"$",
"this",
",",
"'exportProperty'",
"]",
",",
"$",
"propertyValues",
")",
";",
"$",
"properties",
"[",
"strval",
"(",
"$",
"propertyIri",
")",
"]",
"=",
"$",
"this",
"->",
"iri",
"?",
"(",
"object",
")",
"[",
"'profile'",
"=>",
"$",
"propertyIri",
"->",
"getProfile",
"(",
")",
",",
"'name'",
"=>",
"$",
"propertyIri",
"->",
"getName",
"(",
")",
",",
"'values'",
"=>",
"$",
"propertyValues",
",",
"]",
":",
"$",
"propertyValues",
";",
"}",
"}",
"return",
"$",
"properties",
";",
"}"
] |
Export the properties list
@param ThingInterface $thing Thing
@return array Properties list
|
[
"Export",
"the",
"properties",
"list"
] |
12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8
|
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Infrastructure/Service/ThingGateway.php#L124-L140
|
233,118
|
prooph/link-process-manager
|
src/Model/Workflow.php
|
Workflow.isForeachProcessPossible
|
private function isForeachProcessPossible(Message $message, MessageHandler $messageHandler)
{
if ($message->processingType()->typeDescription()->nativeType() !== NativeType::COLLECTION) {
return false;
}
$itemMessage = Message::emulateProcessingWorkflowMessage(
$message->messageType(),
$message->processingType()->typeProperties()['item']->typePrototype(),
$message->processingMetadata()
);
return $messageHandler->canHandleMessage($itemMessage);
}
|
php
|
private function isForeachProcessPossible(Message $message, MessageHandler $messageHandler)
{
if ($message->processingType()->typeDescription()->nativeType() !== NativeType::COLLECTION) {
return false;
}
$itemMessage = Message::emulateProcessingWorkflowMessage(
$message->messageType(),
$message->processingType()->typeProperties()['item']->typePrototype(),
$message->processingMetadata()
);
return $messageHandler->canHandleMessage($itemMessage);
}
|
[
"private",
"function",
"isForeachProcessPossible",
"(",
"Message",
"$",
"message",
",",
"MessageHandler",
"$",
"messageHandler",
")",
"{",
"if",
"(",
"$",
"message",
"->",
"processingType",
"(",
")",
"->",
"typeDescription",
"(",
")",
"->",
"nativeType",
"(",
")",
"!==",
"NativeType",
"::",
"COLLECTION",
")",
"{",
"return",
"false",
";",
"}",
"$",
"itemMessage",
"=",
"Message",
"::",
"emulateProcessingWorkflowMessage",
"(",
"$",
"message",
"->",
"messageType",
"(",
")",
",",
"$",
"message",
"->",
"processingType",
"(",
")",
"->",
"typeProperties",
"(",
")",
"[",
"'item'",
"]",
"->",
"typePrototype",
"(",
")",
",",
"$",
"message",
"->",
"processingMetadata",
"(",
")",
")",
";",
"return",
"$",
"messageHandler",
"->",
"canHandleMessage",
"(",
"$",
"itemMessage",
")",
";",
"}"
] |
Checks if the message handler can handle a workflow message with the item processing type of a collection.
@param Message $message
@param MessageHandler $messageHandler
@return bool
|
[
"Checks",
"if",
"the",
"message",
"handler",
"can",
"handle",
"a",
"workflow",
"message",
"with",
"the",
"item",
"processing",
"type",
"of",
"a",
"collection",
"."
] |
3d6c8bdc72e855786227747bf06bcf8221f7860a
|
https://github.com/prooph/link-process-manager/blob/3d6c8bdc72e855786227747bf06bcf8221f7860a/src/Model/Workflow.php#L295-L308
|
233,119
|
prooph/link-process-manager
|
src/Model/Workflow.php
|
Workflow.determineProcessType
|
private function determineProcessType(Message $message, MessageHandler $messageHandler)
{
if ($messageHandler->canHandleMessage($message)) {
if ($message->processingMetadata()->shouldCollectionBeSplitIntoChunks()) {
$processType = ProcessType::parallelChunk();
} else {
$processType = ProcessType::linearMessaging();
}
} else {
//We create the error before trying the foreach alternative to provide the client with the original error message
//if the alternative fails too.
$originalError = MessageIsNotManageable::byMessageHandler($messageHandler, $message);
//Check if we can use a foreach process to avoid the rejection of the message
if ($this->isForeachProcessPossible($message, $messageHandler)) {
$processType = ProcessType::parallelForeach();
} else {
throw $originalError;
}
}
return $processType;
}
|
php
|
private function determineProcessType(Message $message, MessageHandler $messageHandler)
{
if ($messageHandler->canHandleMessage($message)) {
if ($message->processingMetadata()->shouldCollectionBeSplitIntoChunks()) {
$processType = ProcessType::parallelChunk();
} else {
$processType = ProcessType::linearMessaging();
}
} else {
//We create the error before trying the foreach alternative to provide the client with the original error message
//if the alternative fails too.
$originalError = MessageIsNotManageable::byMessageHandler($messageHandler, $message);
//Check if we can use a foreach process to avoid the rejection of the message
if ($this->isForeachProcessPossible($message, $messageHandler)) {
$processType = ProcessType::parallelForeach();
} else {
throw $originalError;
}
}
return $processType;
}
|
[
"private",
"function",
"determineProcessType",
"(",
"Message",
"$",
"message",
",",
"MessageHandler",
"$",
"messageHandler",
")",
"{",
"if",
"(",
"$",
"messageHandler",
"->",
"canHandleMessage",
"(",
"$",
"message",
")",
")",
"{",
"if",
"(",
"$",
"message",
"->",
"processingMetadata",
"(",
")",
"->",
"shouldCollectionBeSplitIntoChunks",
"(",
")",
")",
"{",
"$",
"processType",
"=",
"ProcessType",
"::",
"parallelChunk",
"(",
")",
";",
"}",
"else",
"{",
"$",
"processType",
"=",
"ProcessType",
"::",
"linearMessaging",
"(",
")",
";",
"}",
"}",
"else",
"{",
"//We create the error before trying the foreach alternative to provide the client with the original error message",
"//if the alternative fails too.",
"$",
"originalError",
"=",
"MessageIsNotManageable",
"::",
"byMessageHandler",
"(",
"$",
"messageHandler",
",",
"$",
"message",
")",
";",
"//Check if we can use a foreach process to avoid the rejection of the message",
"if",
"(",
"$",
"this",
"->",
"isForeachProcessPossible",
"(",
"$",
"message",
",",
"$",
"messageHandler",
")",
")",
"{",
"$",
"processType",
"=",
"ProcessType",
"::",
"parallelForeach",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"$",
"originalError",
";",
"}",
"}",
"return",
"$",
"processType",
";",
"}"
] |
Determine the required process type based on given message and the message handler which will receive the message.
@param Message $message
@param MessageHandler $messageHandler
@return ProcessType
@throws Workflow\Exception\MessageIsNotManageable
|
[
"Determine",
"the",
"required",
"process",
"type",
"based",
"on",
"given",
"message",
"and",
"the",
"message",
"handler",
"which",
"will",
"receive",
"the",
"message",
"."
] |
3d6c8bdc72e855786227747bf06bcf8221f7860a
|
https://github.com/prooph/link-process-manager/blob/3d6c8bdc72e855786227747bf06bcf8221f7860a/src/Model/Workflow.php#L318-L340
|
233,120
|
prooph/link-process-manager
|
src/Model/Workflow.php
|
Workflow.scheduleTaskFor
|
private function scheduleTaskFor(MessageHandler $messageHandler, ProcessingMetadata $taskMetadata, Message $workflowMessage)
{
if ($workflowMessage->messageType()->isCollectDataMessage()) {
$taskType = TaskType::collectData();
} elseif ($workflowMessage->messageType()->isDataCollectedMessage() || $workflowMessage->messageType()->isDataProcessedMessage()) {
$taskType = TaskType::processData();
} else {
throw new \RuntimeException(
sprintf(
"Failed to determine a task type which can handle a %s message",
$workflowMessage->messageType()->toString()
)
);
}
if (! empty($messageHandler->processingMetadata()->toArray())) {
$taskMetadata = $taskMetadata->merge($messageHandler->processingMetadata());
}
return Task::setUp($messageHandler, $taskType, $workflowMessage->processingType(), $taskMetadata);
}
|
php
|
private function scheduleTaskFor(MessageHandler $messageHandler, ProcessingMetadata $taskMetadata, Message $workflowMessage)
{
if ($workflowMessage->messageType()->isCollectDataMessage()) {
$taskType = TaskType::collectData();
} elseif ($workflowMessage->messageType()->isDataCollectedMessage() || $workflowMessage->messageType()->isDataProcessedMessage()) {
$taskType = TaskType::processData();
} else {
throw new \RuntimeException(
sprintf(
"Failed to determine a task type which can handle a %s message",
$workflowMessage->messageType()->toString()
)
);
}
if (! empty($messageHandler->processingMetadata()->toArray())) {
$taskMetadata = $taskMetadata->merge($messageHandler->processingMetadata());
}
return Task::setUp($messageHandler, $taskType, $workflowMessage->processingType(), $taskMetadata);
}
|
[
"private",
"function",
"scheduleTaskFor",
"(",
"MessageHandler",
"$",
"messageHandler",
",",
"ProcessingMetadata",
"$",
"taskMetadata",
",",
"Message",
"$",
"workflowMessage",
")",
"{",
"if",
"(",
"$",
"workflowMessage",
"->",
"messageType",
"(",
")",
"->",
"isCollectDataMessage",
"(",
")",
")",
"{",
"$",
"taskType",
"=",
"TaskType",
"::",
"collectData",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"workflowMessage",
"->",
"messageType",
"(",
")",
"->",
"isDataCollectedMessage",
"(",
")",
"||",
"$",
"workflowMessage",
"->",
"messageType",
"(",
")",
"->",
"isDataProcessedMessage",
"(",
")",
")",
"{",
"$",
"taskType",
"=",
"TaskType",
"::",
"processData",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"\"Failed to determine a task type which can handle a %s message\"",
",",
"$",
"workflowMessage",
"->",
"messageType",
"(",
")",
"->",
"toString",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"messageHandler",
"->",
"processingMetadata",
"(",
")",
"->",
"toArray",
"(",
")",
")",
")",
"{",
"$",
"taskMetadata",
"=",
"$",
"taskMetadata",
"->",
"merge",
"(",
"$",
"messageHandler",
"->",
"processingMetadata",
"(",
")",
")",
";",
"}",
"return",
"Task",
"::",
"setUp",
"(",
"$",
"messageHandler",
",",
"$",
"taskType",
",",
"$",
"workflowMessage",
"->",
"processingType",
"(",
")",
",",
"$",
"taskMetadata",
")",
";",
"}"
] |
Creates a new task for given message handler and workflow message
@param MessageHandler $messageHandler
@param ProcessingMetadata $taskMetadata
@param Workflow\Message $workflowMessage
@return \Prooph\Link\ProcessManager\Model\Task
@throws \RuntimeException
|
[
"Creates",
"a",
"new",
"task",
"for",
"given",
"message",
"handler",
"and",
"workflow",
"message"
] |
3d6c8bdc72e855786227747bf06bcf8221f7860a
|
https://github.com/prooph/link-process-manager/blob/3d6c8bdc72e855786227747bf06bcf8221f7860a/src/Model/Workflow.php#L351-L371
|
233,121
|
opus-online/yii2-payment
|
lib/services/Payment.php
|
Payment.generateForms
|
public function generateForms(Transaction $transaction)
{
$paymentForms = array();
foreach ($this->paymentAdapters as $bankId => $paymentAdapter) {
if ($paymentAdapter->enabled) {
$form = new Form([], $paymentAdapter);
$paymentAdapter->fillPaymentFormDataset($form, $transaction);
$this->paymentHandler->finalizeForm($form, $paymentAdapter);
$paymentForms[$bankId] = $form;
}
}
return $paymentForms;
}
|
php
|
public function generateForms(Transaction $transaction)
{
$paymentForms = array();
foreach ($this->paymentAdapters as $bankId => $paymentAdapter) {
if ($paymentAdapter->enabled) {
$form = new Form([], $paymentAdapter);
$paymentAdapter->fillPaymentFormDataset($form, $transaction);
$this->paymentHandler->finalizeForm($form, $paymentAdapter);
$paymentForms[$bankId] = $form;
}
}
return $paymentForms;
}
|
[
"public",
"function",
"generateForms",
"(",
"Transaction",
"$",
"transaction",
")",
"{",
"$",
"paymentForms",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"paymentAdapters",
"as",
"$",
"bankId",
"=>",
"$",
"paymentAdapter",
")",
"{",
"if",
"(",
"$",
"paymentAdapter",
"->",
"enabled",
")",
"{",
"$",
"form",
"=",
"new",
"Form",
"(",
"[",
"]",
",",
"$",
"paymentAdapter",
")",
";",
"$",
"paymentAdapter",
"->",
"fillPaymentFormDataset",
"(",
"$",
"form",
",",
"$",
"transaction",
")",
";",
"$",
"this",
"->",
"paymentHandler",
"->",
"finalizeForm",
"(",
"$",
"form",
",",
"$",
"paymentAdapter",
")",
";",
"$",
"paymentForms",
"[",
"$",
"bankId",
"]",
"=",
"$",
"form",
";",
"}",
"}",
"return",
"$",
"paymentForms",
";",
"}"
] |
Generates payment forms for all enabled adapters
@param Transaction $transaction
@return Form[]
|
[
"Generates",
"payment",
"forms",
"for",
"all",
"enabled",
"adapters"
] |
df48093f7ef1368a0992460bc66f12f0f090044c
|
https://github.com/opus-online/yii2-payment/blob/df48093f7ef1368a0992460bc66f12f0f090044c/lib/services/Payment.php#L40-L56
|
233,122
|
opus-online/yii2-payment
|
lib/services/Payment.php
|
Payment.handleResponse
|
public function handleResponse(array $request)
{
foreach ($this->paymentAdapters as $adapter) {
$response = new Response($request, $adapter);
if ($adapter->enabled && $adapter->canHandlePaymentResponse($response)) {
$adapter->handlePaymentResponse($response);
$transaction = new Transaction();
$adapter->loadTransactionFromResponse($response, $transaction);
$response->setTransaction($transaction);
return $response;
}
}
throw new Exception("No adapters found that could handle the payment response");
}
|
php
|
public function handleResponse(array $request)
{
foreach ($this->paymentAdapters as $adapter) {
$response = new Response($request, $adapter);
if ($adapter->enabled && $adapter->canHandlePaymentResponse($response)) {
$adapter->handlePaymentResponse($response);
$transaction = new Transaction();
$adapter->loadTransactionFromResponse($response, $transaction);
$response->setTransaction($transaction);
return $response;
}
}
throw new Exception("No adapters found that could handle the payment response");
}
|
[
"public",
"function",
"handleResponse",
"(",
"array",
"$",
"request",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"paymentAdapters",
"as",
"$",
"adapter",
")",
"{",
"$",
"response",
"=",
"new",
"Response",
"(",
"$",
"request",
",",
"$",
"adapter",
")",
";",
"if",
"(",
"$",
"adapter",
"->",
"enabled",
"&&",
"$",
"adapter",
"->",
"canHandlePaymentResponse",
"(",
"$",
"response",
")",
")",
"{",
"$",
"adapter",
"->",
"handlePaymentResponse",
"(",
"$",
"response",
")",
";",
"$",
"transaction",
"=",
"new",
"Transaction",
"(",
")",
";",
"$",
"adapter",
"->",
"loadTransactionFromResponse",
"(",
"$",
"response",
",",
"$",
"transaction",
")",
";",
"$",
"response",
"->",
"setTransaction",
"(",
"$",
"transaction",
")",
";",
"return",
"$",
"response",
";",
"}",
"}",
"throw",
"new",
"Exception",
"(",
"\"No adapters found that could handle the payment response\"",
")",
";",
"}"
] |
Handles the response received from the server after payment
@param array $request Data from $_REQUEST
@return Response
@throws \opus\payment\Exception
|
[
"Handles",
"the",
"response",
"received",
"from",
"the",
"server",
"after",
"payment"
] |
df48093f7ef1368a0992460bc66f12f0f090044c
|
https://github.com/opus-online/yii2-payment/blob/df48093f7ef1368a0992460bc66f12f0f090044c/lib/services/Payment.php#L65-L79
|
233,123
|
Deathnerd/php-wtforms
|
src/widgets/core/Select.php
|
Select.renderOption
|
public static function renderOption($value, $label, $selected, $options = [])
{
if ($value === true) {
// Handle the special case of a true value
$value = "true";
}
$options = array_merge($options, ["value" => $value]);
if ($selected) {
$options['selected'] = true;
}
return sprintf("<option %s>%s</option>", html_params($options), $label);
}
|
php
|
public static function renderOption($value, $label, $selected, $options = [])
{
if ($value === true) {
// Handle the special case of a true value
$value = "true";
}
$options = array_merge($options, ["value" => $value]);
if ($selected) {
$options['selected'] = true;
}
return sprintf("<option %s>%s</option>", html_params($options), $label);
}
|
[
"public",
"static",
"function",
"renderOption",
"(",
"$",
"value",
",",
"$",
"label",
",",
"$",
"selected",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"true",
")",
"{",
"// Handle the special case of a true value",
"$",
"value",
"=",
"\"true\"",
";",
"}",
"$",
"options",
"=",
"array_merge",
"(",
"$",
"options",
",",
"[",
"\"value\"",
"=>",
"$",
"value",
"]",
")",
";",
"if",
"(",
"$",
"selected",
")",
"{",
"$",
"options",
"[",
"'selected'",
"]",
"=",
"true",
";",
"}",
"return",
"sprintf",
"(",
"\"<option %s>%s</option>\"",
",",
"html_params",
"(",
"$",
"options",
")",
",",
"$",
"label",
")",
";",
"}"
] |
Private method called when rendering each option as HTML
@param mixed $value
@param string $label
@param boolean $selected
@param array $options
@return string
|
[
"Private",
"method",
"called",
"when",
"rendering",
"each",
"option",
"as",
"HTML"
] |
2e1f9ad515f6241c9fac57edc472bf657267f4a1
|
https://github.com/Deathnerd/php-wtforms/blob/2e1f9ad515f6241c9fac57edc472bf657267f4a1/src/widgets/core/Select.php#L63-L75
|
233,124
|
kgilden/php-digidoc
|
src/Exception/ApiException.php
|
ApiException.createIncorrectStatus
|
public static function createIncorrectStatus($status, \Exception $e = null)
{
$message = 'Expected server status to be "OK", got "%s" instead';
return new static(sprintf($message, $status), null, $e);
}
|
php
|
public static function createIncorrectStatus($status, \Exception $e = null)
{
$message = 'Expected server status to be "OK", got "%s" instead';
return new static(sprintf($message, $status), null, $e);
}
|
[
"public",
"static",
"function",
"createIncorrectStatus",
"(",
"$",
"status",
",",
"\\",
"Exception",
"$",
"e",
"=",
"null",
")",
"{",
"$",
"message",
"=",
"'Expected server status to be \"OK\", got \"%s\" instead'",
";",
"return",
"new",
"static",
"(",
"sprintf",
"(",
"$",
"message",
",",
"$",
"status",
")",
",",
"null",
",",
"$",
"e",
")",
";",
"}"
] |
Creates a new ApiException for incorrect response statuses.
@param string $status
@param \Exception|null $e
@return ApiException
|
[
"Creates",
"a",
"new",
"ApiException",
"for",
"incorrect",
"response",
"statuses",
"."
] |
88112ba05688fc1d32c0ff948cb8e1f4d2f264d3
|
https://github.com/kgilden/php-digidoc/blob/88112ba05688fc1d32c0ff948cb8e1f4d2f264d3/src/Exception/ApiException.php#L90-L95
|
233,125
|
kgilden/php-digidoc
|
src/Exception/ApiException.php
|
ApiException.createNotMerged
|
public static function createNotMerged(Envelope $envelope, \Exception $e = null)
{
$message = 'The given DigiDoc envelope must be merged with Api (using Api::merge) before calling this method.';
return new static($message, null, $e);
}
|
php
|
public static function createNotMerged(Envelope $envelope, \Exception $e = null)
{
$message = 'The given DigiDoc envelope must be merged with Api (using Api::merge) before calling this method.';
return new static($message, null, $e);
}
|
[
"public",
"static",
"function",
"createNotMerged",
"(",
"Envelope",
"$",
"envelope",
",",
"\\",
"Exception",
"$",
"e",
"=",
"null",
")",
"{",
"$",
"message",
"=",
"'The given DigiDoc envelope must be merged with Api (using Api::merge) before calling this method.'",
";",
"return",
"new",
"static",
"(",
"$",
"message",
",",
"null",
",",
"$",
"e",
")",
";",
"}"
] |
Creates a new ApiException for non-merged DigiDoc envelopes.
@param Envelope $envelope
@param \Exception|null $e
@return ApiException
|
[
"Creates",
"a",
"new",
"ApiException",
"for",
"non",
"-",
"merged",
"DigiDoc",
"envelopes",
"."
] |
88112ba05688fc1d32c0ff948cb8e1f4d2f264d3
|
https://github.com/kgilden/php-digidoc/blob/88112ba05688fc1d32c0ff948cb8e1f4d2f264d3/src/Exception/ApiException.php#L105-L110
|
233,126
|
netgen/ngpush
|
classes/twitteroauth.php
|
TwitterOAuth.getXAuthToken
|
function getXAuthToken($username, $password) {
$parameters = array();
$parameters['x_auth_username'] = $username;
$parameters['x_auth_password'] = $password;
$parameters['x_auth_mode'] = 'client_auth';
$request = $this->oAuthRequest($this->accessTokenURL(), 'POST', $parameters);
$token = OAuthUtil::parse_parameters($request);
$this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
return $token;
}
|
php
|
function getXAuthToken($username, $password) {
$parameters = array();
$parameters['x_auth_username'] = $username;
$parameters['x_auth_password'] = $password;
$parameters['x_auth_mode'] = 'client_auth';
$request = $this->oAuthRequest($this->accessTokenURL(), 'POST', $parameters);
$token = OAuthUtil::parse_parameters($request);
$this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
return $token;
}
|
[
"function",
"getXAuthToken",
"(",
"$",
"username",
",",
"$",
"password",
")",
"{",
"$",
"parameters",
"=",
"array",
"(",
")",
";",
"$",
"parameters",
"[",
"'x_auth_username'",
"]",
"=",
"$",
"username",
";",
"$",
"parameters",
"[",
"'x_auth_password'",
"]",
"=",
"$",
"password",
";",
"$",
"parameters",
"[",
"'x_auth_mode'",
"]",
"=",
"'client_auth'",
";",
"$",
"request",
"=",
"$",
"this",
"->",
"oAuthRequest",
"(",
"$",
"this",
"->",
"accessTokenURL",
"(",
")",
",",
"'POST'",
",",
"$",
"parameters",
")",
";",
"$",
"token",
"=",
"OAuthUtil",
"::",
"parse_parameters",
"(",
"$",
"request",
")",
";",
"$",
"this",
"->",
"token",
"=",
"new",
"OAuthConsumer",
"(",
"$",
"token",
"[",
"'oauth_token'",
"]",
",",
"$",
"token",
"[",
"'oauth_token_secret'",
"]",
")",
";",
"return",
"$",
"token",
";",
"}"
] |
One time exchange of username and password for access token and secret.
@returns array("oauth_token" => "the-access-token",
"oauth_token_secret" => "the-access-secret",
"user_id" => "9436992",
"screen_name" => "abraham",
"x_auth_expires" => "0")
|
[
"One",
"time",
"exchange",
"of",
"username",
"and",
"password",
"for",
"access",
"token",
"and",
"secret",
"."
] |
0e12d13876b34ae2a1bf51cee35b44736cefba0b
|
https://github.com/netgen/ngpush/blob/0e12d13876b34ae2a1bf51cee35b44736cefba0b/classes/twitteroauth.php#L127-L136
|
233,127
|
czukowski/I18n_Plural
|
classes/I18n/Core.php
|
Core.form
|
public function form($string, $form = NULL, $lang = NULL)
{
$translation = $this->get($string, $lang);
if (is_array($translation))
{
if (array_key_exists($form, $translation))
{
return $translation[$form];
}
elseif (array_key_exists('other', $translation))
{
return $translation['other'];
}
return reset($translation);
}
return $translation;
}
|
php
|
public function form($string, $form = NULL, $lang = NULL)
{
$translation = $this->get($string, $lang);
if (is_array($translation))
{
if (array_key_exists($form, $translation))
{
return $translation[$form];
}
elseif (array_key_exists('other', $translation))
{
return $translation['other'];
}
return reset($translation);
}
return $translation;
}
|
[
"public",
"function",
"form",
"(",
"$",
"string",
",",
"$",
"form",
"=",
"NULL",
",",
"$",
"lang",
"=",
"NULL",
")",
"{",
"$",
"translation",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"string",
",",
"$",
"lang",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"translation",
")",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"form",
",",
"$",
"translation",
")",
")",
"{",
"return",
"$",
"translation",
"[",
"$",
"form",
"]",
";",
"}",
"elseif",
"(",
"array_key_exists",
"(",
"'other'",
",",
"$",
"translation",
")",
")",
"{",
"return",
"$",
"translation",
"[",
"'other'",
"]",
";",
"}",
"return",
"reset",
"(",
"$",
"translation",
")",
";",
"}",
"return",
"$",
"translation",
";",
"}"
] |
Returns specified form of a string translation. If no translation exists, the original string will be
returned. No parameters are replaced.
$hello = $i18n->form('I\'ve met :name, he is my friend now.', 'fem');
// I've met :name, she is my friend now.
@param string $string
@param string $form if NULL, looking for 'other' form, else the very first form
@param string $lang
@return string
|
[
"Returns",
"specified",
"form",
"of",
"a",
"string",
"translation",
".",
"If",
"no",
"translation",
"exists",
"the",
"original",
"string",
"will",
"be",
"returned",
".",
"No",
"parameters",
"are",
"replaced",
"."
] |
6782aeac50e22a194d3840759c9da97d1f9c50d0
|
https://github.com/czukowski/I18n_Plural/blob/6782aeac50e22a194d3840759c9da97d1f9c50d0/classes/I18n/Core.php#L86-L102
|
233,128
|
czukowski/I18n_Plural
|
classes/I18n/Core.php
|
Core.get
|
protected function get($string, $lang)
{
// If fallbacks are used, split language parts and iterate each reader using each part.
// If fallbacks are not used, just use the specified language and let the reader implementation
// take care of the translation fallbacks.
$lang_fallback_path = $this->_use_fallback
? $this->split_lang($lang)
: array($lang);
foreach ($lang_fallback_path as $lang)
{
foreach ($this->_readers as $reader)
{
if (($translation = $reader->get($string, $lang)))
{
return $translation;
}
}
}
return $string;
}
|
php
|
protected function get($string, $lang)
{
// If fallbacks are used, split language parts and iterate each reader using each part.
// If fallbacks are not used, just use the specified language and let the reader implementation
// take care of the translation fallbacks.
$lang_fallback_path = $this->_use_fallback
? $this->split_lang($lang)
: array($lang);
foreach ($lang_fallback_path as $lang)
{
foreach ($this->_readers as $reader)
{
if (($translation = $reader->get($string, $lang)))
{
return $translation;
}
}
}
return $string;
}
|
[
"protected",
"function",
"get",
"(",
"$",
"string",
",",
"$",
"lang",
")",
"{",
"// If fallbacks are used, split language parts and iterate each reader using each part.",
"// If fallbacks are not used, just use the specified language and let the reader implementation",
"// take care of the translation fallbacks.",
"$",
"lang_fallback_path",
"=",
"$",
"this",
"->",
"_use_fallback",
"?",
"$",
"this",
"->",
"split_lang",
"(",
"$",
"lang",
")",
":",
"array",
"(",
"$",
"lang",
")",
";",
"foreach",
"(",
"$",
"lang_fallback_path",
"as",
"$",
"lang",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_readers",
"as",
"$",
"reader",
")",
"{",
"if",
"(",
"(",
"$",
"translation",
"=",
"$",
"reader",
"->",
"get",
"(",
"$",
"string",
",",
"$",
"lang",
")",
")",
")",
"{",
"return",
"$",
"translation",
";",
"}",
"}",
"}",
"return",
"$",
"string",
";",
"}"
] |
Returns the translation from the first reader where it exists, or the input string
if no translation is available.
@param string $string
@param string $lang
@return string
|
[
"Returns",
"the",
"translation",
"from",
"the",
"first",
"reader",
"where",
"it",
"exists",
"or",
"the",
"input",
"string",
"if",
"no",
"translation",
"is",
"available",
"."
] |
6782aeac50e22a194d3840759c9da97d1f9c50d0
|
https://github.com/czukowski/I18n_Plural/blob/6782aeac50e22a194d3840759c9da97d1f9c50d0/classes/I18n/Core.php#L133-L152
|
233,129
|
czukowski/I18n_Plural
|
classes/I18n/Core.php
|
Core.use_fallback
|
public function use_fallback($boolean = NULL)
{
if ($boolean === NULL)
{
return $this->_use_fallback;
}
$this->_use_fallback = $boolean;
return $this;
}
|
php
|
public function use_fallback($boolean = NULL)
{
if ($boolean === NULL)
{
return $this->_use_fallback;
}
$this->_use_fallback = $boolean;
return $this;
}
|
[
"public",
"function",
"use_fallback",
"(",
"$",
"boolean",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"boolean",
"===",
"NULL",
")",
"{",
"return",
"$",
"this",
"->",
"_use_fallback",
";",
"}",
"$",
"this",
"->",
"_use_fallback",
"=",
"$",
"boolean",
";",
"return",
"$",
"this",
";",
"}"
] |
Switch `get` method behavior to either request the translation from the readers with
or without fallback to less specific languages. If called without parameters, returns
the current internal value.
@param boolean|NULL $boolean
@return $this|boolean
|
[
"Switch",
"get",
"method",
"behavior",
"to",
"either",
"request",
"the",
"translation",
"from",
"the",
"readers",
"with",
"or",
"without",
"fallback",
"to",
"less",
"specific",
"languages",
".",
"If",
"called",
"without",
"parameters",
"returns",
"the",
"current",
"internal",
"value",
"."
] |
6782aeac50e22a194d3840759c9da97d1f9c50d0
|
https://github.com/czukowski/I18n_Plural/blob/6782aeac50e22a194d3840759c9da97d1f9c50d0/classes/I18n/Core.php#L185-L193
|
233,130
|
czukowski/I18n_Plural
|
classes/I18n/Core.php
|
Core.plural_rules
|
protected function plural_rules($lang)
{
if ( ! isset($this->_rules[$lang]))
{
// Get language code prefix
$parts = explode('-', $lang, 2);
$this->_rules[$lang] = $this->plural_rules_factory()
->create_rules($parts[0]);
}
return $this->_rules[$lang];
}
|
php
|
protected function plural_rules($lang)
{
if ( ! isset($this->_rules[$lang]))
{
// Get language code prefix
$parts = explode('-', $lang, 2);
$this->_rules[$lang] = $this->plural_rules_factory()
->create_rules($parts[0]);
}
return $this->_rules[$lang];
}
|
[
"protected",
"function",
"plural_rules",
"(",
"$",
"lang",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_rules",
"[",
"$",
"lang",
"]",
")",
")",
"{",
"// Get language code prefix",
"$",
"parts",
"=",
"explode",
"(",
"'-'",
",",
"$",
"lang",
",",
"2",
")",
";",
"$",
"this",
"->",
"_rules",
"[",
"$",
"lang",
"]",
"=",
"$",
"this",
"->",
"plural_rules_factory",
"(",
")",
"->",
"create_rules",
"(",
"$",
"parts",
"[",
"0",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_rules",
"[",
"$",
"lang",
"]",
";",
"}"
] |
Plural rules lazy initialization
@param string $lang
@return Plural\Rules
|
[
"Plural",
"rules",
"lazy",
"initialization"
] |
6782aeac50e22a194d3840759c9da97d1f9c50d0
|
https://github.com/czukowski/I18n_Plural/blob/6782aeac50e22a194d3840759c9da97d1f9c50d0/classes/I18n/Core.php#L201-L211
|
233,131
|
CampaignChain/core
|
Module/BundleConfig.php
|
BundleConfig.getNewBundles
|
public function getNewBundles()
{
$bundles = $this->bundleLocatorService->getAvailableBundles();
$newBundles = [];
foreach ($bundles as $bundle) {
// Check whether this bundle has already been installed
switch ($this->isRegisteredBundle($bundle)) {
case Installer::STATUS_REGISTERED_NO:
$bundle->setStatus(Installer::STATUS_REGISTERED_NO);
$newBundles[] = $bundle;
break;
case Installer::STATUS_REGISTERED_OLDER:
// Get the existing bundle.
/** @var Bundle $registeredBundle */
$registeredBundle = $this->em
->getRepository('CampaignChainCoreBundle:Bundle')
->findOneByName($bundle->getName());
// Update the existing bundle's data.
$registeredBundle->setType($bundle->getType());
$registeredBundle->setDescription($bundle->getDescription());
$registeredBundle->setLicense($bundle->getLicense());
$registeredBundle->setAuthors($bundle->getAuthors());
$registeredBundle->setHomepage($bundle->getHomepage());
$registeredBundle->setVersion($bundle->getVersion());
$registeredBundle->setExtra($bundle->getExtra());
$registeredBundle->setStatus(Installer::STATUS_REGISTERED_OLDER);
$newBundles[] = $registeredBundle;
break;
case Installer::STATUS_REGISTERED_SAME:
$bundle->setStatus(Installer::STATUS_REGISTERED_SAME);
break;
}
}
return $newBundles;
}
|
php
|
public function getNewBundles()
{
$bundles = $this->bundleLocatorService->getAvailableBundles();
$newBundles = [];
foreach ($bundles as $bundle) {
// Check whether this bundle has already been installed
switch ($this->isRegisteredBundle($bundle)) {
case Installer::STATUS_REGISTERED_NO:
$bundle->setStatus(Installer::STATUS_REGISTERED_NO);
$newBundles[] = $bundle;
break;
case Installer::STATUS_REGISTERED_OLDER:
// Get the existing bundle.
/** @var Bundle $registeredBundle */
$registeredBundle = $this->em
->getRepository('CampaignChainCoreBundle:Bundle')
->findOneByName($bundle->getName());
// Update the existing bundle's data.
$registeredBundle->setType($bundle->getType());
$registeredBundle->setDescription($bundle->getDescription());
$registeredBundle->setLicense($bundle->getLicense());
$registeredBundle->setAuthors($bundle->getAuthors());
$registeredBundle->setHomepage($bundle->getHomepage());
$registeredBundle->setVersion($bundle->getVersion());
$registeredBundle->setExtra($bundle->getExtra());
$registeredBundle->setStatus(Installer::STATUS_REGISTERED_OLDER);
$newBundles[] = $registeredBundle;
break;
case Installer::STATUS_REGISTERED_SAME:
$bundle->setStatus(Installer::STATUS_REGISTERED_SAME);
break;
}
}
return $newBundles;
}
|
[
"public",
"function",
"getNewBundles",
"(",
")",
"{",
"$",
"bundles",
"=",
"$",
"this",
"->",
"bundleLocatorService",
"->",
"getAvailableBundles",
"(",
")",
";",
"$",
"newBundles",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"bundles",
"as",
"$",
"bundle",
")",
"{",
"// Check whether this bundle has already been installed",
"switch",
"(",
"$",
"this",
"->",
"isRegisteredBundle",
"(",
"$",
"bundle",
")",
")",
"{",
"case",
"Installer",
"::",
"STATUS_REGISTERED_NO",
":",
"$",
"bundle",
"->",
"setStatus",
"(",
"Installer",
"::",
"STATUS_REGISTERED_NO",
")",
";",
"$",
"newBundles",
"[",
"]",
"=",
"$",
"bundle",
";",
"break",
";",
"case",
"Installer",
"::",
"STATUS_REGISTERED_OLDER",
":",
"// Get the existing bundle.",
"/** @var Bundle $registeredBundle */",
"$",
"registeredBundle",
"=",
"$",
"this",
"->",
"em",
"->",
"getRepository",
"(",
"'CampaignChainCoreBundle:Bundle'",
")",
"->",
"findOneByName",
"(",
"$",
"bundle",
"->",
"getName",
"(",
")",
")",
";",
"// Update the existing bundle's data.",
"$",
"registeredBundle",
"->",
"setType",
"(",
"$",
"bundle",
"->",
"getType",
"(",
")",
")",
";",
"$",
"registeredBundle",
"->",
"setDescription",
"(",
"$",
"bundle",
"->",
"getDescription",
"(",
")",
")",
";",
"$",
"registeredBundle",
"->",
"setLicense",
"(",
"$",
"bundle",
"->",
"getLicense",
"(",
")",
")",
";",
"$",
"registeredBundle",
"->",
"setAuthors",
"(",
"$",
"bundle",
"->",
"getAuthors",
"(",
")",
")",
";",
"$",
"registeredBundle",
"->",
"setHomepage",
"(",
"$",
"bundle",
"->",
"getHomepage",
"(",
")",
")",
";",
"$",
"registeredBundle",
"->",
"setVersion",
"(",
"$",
"bundle",
"->",
"getVersion",
"(",
")",
")",
";",
"$",
"registeredBundle",
"->",
"setExtra",
"(",
"$",
"bundle",
"->",
"getExtra",
"(",
")",
")",
";",
"$",
"registeredBundle",
"->",
"setStatus",
"(",
"Installer",
"::",
"STATUS_REGISTERED_OLDER",
")",
";",
"$",
"newBundles",
"[",
"]",
"=",
"$",
"registeredBundle",
";",
"break",
";",
"case",
"Installer",
"::",
"STATUS_REGISTERED_SAME",
":",
"$",
"bundle",
"->",
"setStatus",
"(",
"Installer",
"::",
"STATUS_REGISTERED_SAME",
")",
";",
"break",
";",
"}",
"}",
"return",
"$",
"newBundles",
";",
"}"
] |
Return only new or need to be updated Bundles
skipVersion == false
@return Bundle[]
|
[
"Return",
"only",
"new",
"or",
"need",
"to",
"be",
"updated",
"Bundles",
"skipVersion",
"==",
"false"
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Module/BundleConfig.php#L52-L91
|
233,132
|
swoft-cloud/swoft-console
|
src/Router/HandlerMapping.php
|
HandlerMapping.getPrefix
|
public function getPrefix(string $prefix, string $className): string
{
// the prefix of annotation is exist
if (! empty($prefix)) {
return $prefix;
}
// the prefix of annotation is empty
$reg = '/^.*\\\(\w+)' . $this->suffix . '$/';
$prefix = '';
if ($result = preg_match($reg, $className, $match)) {
$prefix = lcfirst($match[1]);
}
return $prefix;
}
|
php
|
public function getPrefix(string $prefix, string $className): string
{
// the prefix of annotation is exist
if (! empty($prefix)) {
return $prefix;
}
// the prefix of annotation is empty
$reg = '/^.*\\\(\w+)' . $this->suffix . '$/';
$prefix = '';
if ($result = preg_match($reg, $className, $match)) {
$prefix = lcfirst($match[1]);
}
return $prefix;
}
|
[
"public",
"function",
"getPrefix",
"(",
"string",
"$",
"prefix",
",",
"string",
"$",
"className",
")",
":",
"string",
"{",
"// the prefix of annotation is exist",
"if",
"(",
"!",
"empty",
"(",
"$",
"prefix",
")",
")",
"{",
"return",
"$",
"prefix",
";",
"}",
"// the prefix of annotation is empty",
"$",
"reg",
"=",
"'/^.*\\\\\\(\\w+)'",
".",
"$",
"this",
"->",
"suffix",
".",
"'$/'",
";",
"$",
"prefix",
"=",
"''",
";",
"if",
"(",
"$",
"result",
"=",
"preg_match",
"(",
"$",
"reg",
",",
"$",
"className",
",",
"$",
"match",
")",
")",
"{",
"$",
"prefix",
"=",
"lcfirst",
"(",
"$",
"match",
"[",
"1",
"]",
")",
";",
"}",
"return",
"$",
"prefix",
";",
"}"
] |
Get command from class name
@param string $prefix
@param string $className
@return string
|
[
"Get",
"command",
"from",
"class",
"name"
] |
d7153f56505a9be420ebae9eb29f7e45bfb2982e
|
https://github.com/swoft-cloud/swoft-console/blob/d7153f56505a9be420ebae9eb29f7e45bfb2982e/src/Router/HandlerMapping.php#L167-L183
|
233,133
|
jkphl/rdfa-lite-microdata
|
src/RdfaLiteMicrodata/Infrastructure/Parser/PropertyProcessorTrait.php
|
PropertyProcessorTrait.processPropertyPrefixName
|
protected function processPropertyPrefixName($prefix, $name, \DOMElement $element, ContextInterface $context, $last)
{
$vocabulary = $this->getVocabulary($prefix, $context);
if ($vocabulary instanceof VocabularyInterface) {
try {
$context = $this->addProperty($element, $context, $name, $vocabulary, $last);
} catch (RuntimeException $e) {
// Skip invalid property
}
}
return $context;
}
|
php
|
protected function processPropertyPrefixName($prefix, $name, \DOMElement $element, ContextInterface $context, $last)
{
$vocabulary = $this->getVocabulary($prefix, $context);
if ($vocabulary instanceof VocabularyInterface) {
try {
$context = $this->addProperty($element, $context, $name, $vocabulary, $last);
} catch (RuntimeException $e) {
// Skip invalid property
}
}
return $context;
}
|
[
"protected",
"function",
"processPropertyPrefixName",
"(",
"$",
"prefix",
",",
"$",
"name",
",",
"\\",
"DOMElement",
"$",
"element",
",",
"ContextInterface",
"$",
"context",
",",
"$",
"last",
")",
"{",
"$",
"vocabulary",
"=",
"$",
"this",
"->",
"getVocabulary",
"(",
"$",
"prefix",
",",
"$",
"context",
")",
";",
"if",
"(",
"$",
"vocabulary",
"instanceof",
"VocabularyInterface",
")",
"{",
"try",
"{",
"$",
"context",
"=",
"$",
"this",
"->",
"addProperty",
"(",
"$",
"element",
",",
"$",
"context",
",",
"$",
"name",
",",
"$",
"vocabulary",
",",
"$",
"last",
")",
";",
"}",
"catch",
"(",
"RuntimeException",
"$",
"e",
")",
"{",
"// Skip invalid property",
"}",
"}",
"return",
"$",
"context",
";",
"}"
] |
Create a property by prefix and name
@param string $prefix Property prefix
@param string $name Property name
@param \DOMElement $element DOM element
@param ContextInterface $context Inherited Context
@param boolean $last Last property
@return ContextInterface Local context for this element
|
[
"Create",
"a",
"property",
"by",
"prefix",
"and",
"name"
] |
12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8
|
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Infrastructure/Parser/PropertyProcessorTrait.php#L65-L77
|
233,134
|
jkphl/rdfa-lite-microdata
|
src/RdfaLiteMicrodata/Infrastructure/Parser/PropertyProcessorTrait.php
|
PropertyProcessorTrait.addProperty
|
protected function addProperty(
\DOMElement $element,
ContextInterface $context,
$name,
VocabularyInterface $vocabulary,
$last
) {
$resourceId = $this->getResourceId($element);
// Get the property value
$propertyValue = $this->getPropertyValue($element, $context);
$property = new Property($name, $vocabulary, $propertyValue, $resourceId);
// Add the property to the current parent thing
$context->getParentThing()->addProperty($property);
return $this->addPropertyChild($propertyValue, $context, $last);
}
|
php
|
protected function addProperty(
\DOMElement $element,
ContextInterface $context,
$name,
VocabularyInterface $vocabulary,
$last
) {
$resourceId = $this->getResourceId($element);
// Get the property value
$propertyValue = $this->getPropertyValue($element, $context);
$property = new Property($name, $vocabulary, $propertyValue, $resourceId);
// Add the property to the current parent thing
$context->getParentThing()->addProperty($property);
return $this->addPropertyChild($propertyValue, $context, $last);
}
|
[
"protected",
"function",
"addProperty",
"(",
"\\",
"DOMElement",
"$",
"element",
",",
"ContextInterface",
"$",
"context",
",",
"$",
"name",
",",
"VocabularyInterface",
"$",
"vocabulary",
",",
"$",
"last",
")",
"{",
"$",
"resourceId",
"=",
"$",
"this",
"->",
"getResourceId",
"(",
"$",
"element",
")",
";",
"// Get the property value",
"$",
"propertyValue",
"=",
"$",
"this",
"->",
"getPropertyValue",
"(",
"$",
"element",
",",
"$",
"context",
")",
";",
"$",
"property",
"=",
"new",
"Property",
"(",
"$",
"name",
",",
"$",
"vocabulary",
",",
"$",
"propertyValue",
",",
"$",
"resourceId",
")",
";",
"// Add the property to the current parent thing",
"$",
"context",
"->",
"getParentThing",
"(",
")",
"->",
"addProperty",
"(",
"$",
"property",
")",
";",
"return",
"$",
"this",
"->",
"addPropertyChild",
"(",
"$",
"propertyValue",
",",
"$",
"context",
",",
"$",
"last",
")",
";",
"}"
] |
Add a single property
@param \DOMElement $element DOM element
@param ContextInterface $context Inherited Context
@param string $name Property name
@param VocabularyInterface $vocabulary Property vocabulary
@param boolean $last Last property
@return ContextInterface Local context for this element
|
[
"Add",
"a",
"single",
"property"
] |
12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8
|
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Infrastructure/Parser/PropertyProcessorTrait.php#L98-L115
|
233,135
|
jkphl/rdfa-lite-microdata
|
src/RdfaLiteMicrodata/Infrastructure/Parser/PropertyProcessorTrait.php
|
PropertyProcessorTrait.getPropertyContentAttrValue
|
protected function getPropertyContentAttrValue(\DOMElement $element)
{
$value = trim($element->getAttribute('content'));
return strlen($value) ? $value : null;
}
|
php
|
protected function getPropertyContentAttrValue(\DOMElement $element)
{
$value = trim($element->getAttribute('content'));
return strlen($value) ? $value : null;
}
|
[
"protected",
"function",
"getPropertyContentAttrValue",
"(",
"\\",
"DOMElement",
"$",
"element",
")",
"{",
"$",
"value",
"=",
"trim",
"(",
"$",
"element",
"->",
"getAttribute",
"(",
"'content'",
")",
")",
";",
"return",
"strlen",
"(",
"$",
"value",
")",
"?",
"$",
"value",
":",
"null",
";",
"}"
] |
Return a content attribute property value
@param \DOMElement $element DOM element
@return null|string Property value
|
[
"Return",
"a",
"content",
"attribute",
"property",
"value"
] |
12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8
|
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Infrastructure/Parser/PropertyProcessorTrait.php#L210-L214
|
233,136
|
jkphl/rdfa-lite-microdata
|
src/RdfaLiteMicrodata/Infrastructure/Parser/PropertyProcessorTrait.php
|
PropertyProcessorTrait.addPropertyChild
|
protected function addPropertyChild($propertyValue, ContextInterface $context, $last)
{
// If the property value is a thing and this is the element's last property
if (($propertyValue instanceof ThingInterface) && $last) {
// Set the thing as parent thing for nested iterations
$context = $context->setParentThing($propertyValue);
}
return $context;
}
|
php
|
protected function addPropertyChild($propertyValue, ContextInterface $context, $last)
{
// If the property value is a thing and this is the element's last property
if (($propertyValue instanceof ThingInterface) && $last) {
// Set the thing as parent thing for nested iterations
$context = $context->setParentThing($propertyValue);
}
return $context;
}
|
[
"protected",
"function",
"addPropertyChild",
"(",
"$",
"propertyValue",
",",
"ContextInterface",
"$",
"context",
",",
"$",
"last",
")",
"{",
"// If the property value is a thing and this is the element's last property",
"if",
"(",
"(",
"$",
"propertyValue",
"instanceof",
"ThingInterface",
")",
"&&",
"$",
"last",
")",
"{",
"// Set the thing as parent thing for nested iterations",
"$",
"context",
"=",
"$",
"context",
"->",
"setParentThing",
"(",
"$",
"propertyValue",
")",
";",
"}",
"return",
"$",
"context",
";",
"}"
] |
Add a property child
@param string|ThingInterface Property value
@param ContextInterface $context Inherited Context
@param boolean $last Last property
@return ContextInterface Local context for this element
|
[
"Add",
"a",
"property",
"child"
] |
12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8
|
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Infrastructure/Parser/PropertyProcessorTrait.php#L243-L252
|
233,137
|
jkphl/rdfa-lite-microdata
|
src/RdfaLiteMicrodata/Application/Context/AbstractContext.php
|
AbstractContext.setParentThing
|
public function setParentThing(ThingInterface $parentThing)
{
// If the new parent thing differs from the current one
if ($this->parentThing !== $parentThing) {
$context = clone $this;
$context->parentThing = $parentThing;
return $context;
}
return $this;
}
|
php
|
public function setParentThing(ThingInterface $parentThing)
{
// If the new parent thing differs from the current one
if ($this->parentThing !== $parentThing) {
$context = clone $this;
$context->parentThing = $parentThing;
return $context;
}
return $this;
}
|
[
"public",
"function",
"setParentThing",
"(",
"ThingInterface",
"$",
"parentThing",
")",
"{",
"// If the new parent thing differs from the current one",
"if",
"(",
"$",
"this",
"->",
"parentThing",
"!==",
"$",
"parentThing",
")",
"{",
"$",
"context",
"=",
"clone",
"$",
"this",
";",
"$",
"context",
"->",
"parentThing",
"=",
"$",
"parentThing",
";",
"return",
"$",
"context",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set the parent thing
@param ThingInterface $parentThing Parent thing
@return ContextInterface Self reference
|
[
"Set",
"the",
"parent",
"thing"
] |
12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8
|
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Application/Context/AbstractContext.php#L106-L116
|
233,138
|
CampaignChain/core
|
Controller/SecurityController.php
|
SecurityController.loginAction
|
public function loginAction(Request $request)
{
if ($this->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
return $this->redirectToRoute('campaignchain_core_homepage');
}
return parent::loginAction($request);
}
|
php
|
public function loginAction(Request $request)
{
if ($this->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
return $this->redirectToRoute('campaignchain_core_homepage');
}
return parent::loginAction($request);
}
|
[
"public",
"function",
"loginAction",
"(",
"Request",
"$",
"request",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"get",
"(",
"'security.authorization_checker'",
")",
"->",
"isGranted",
"(",
"'IS_AUTHENTICATED_REMEMBERED'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"redirectToRoute",
"(",
"'campaignchain_core_homepage'",
")",
";",
"}",
"return",
"parent",
"::",
"loginAction",
"(",
"$",
"request",
")",
";",
"}"
] |
redirect to home when already authenticated
@param Request $request
@return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
[
"redirect",
"to",
"home",
"when",
"already",
"authenticated"
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/SecurityController.php#L32-L40
|
233,139
|
CampaignChain/core
|
Module/Repository.php
|
Repository.getModulesFromRepository
|
public function getModulesFromRepository()
{
$modules = array();
$system = $this->systemService->getActiveSystem();
foreach($this->repositories as $repository){
// Retrieve compatible modules.
$client = new Client([
'base_uri' => $repository,
]);
$response = $client->get('d/'.$system->getPackage().'/'.$this->distributionVersion.'.json');
$compatibleModules = json_decode($response->getBody());
// TODO: What to do if same module exists in different repositories?
$modules = array_merge($modules, $compatibleModules->results);
}
if(count($modules) === 0){
return self::STATUS_NO_MODULES;
}
return $modules;
}
|
php
|
public function getModulesFromRepository()
{
$modules = array();
$system = $this->systemService->getActiveSystem();
foreach($this->repositories as $repository){
// Retrieve compatible modules.
$client = new Client([
'base_uri' => $repository,
]);
$response = $client->get('d/'.$system->getPackage().'/'.$this->distributionVersion.'.json');
$compatibleModules = json_decode($response->getBody());
// TODO: What to do if same module exists in different repositories?
$modules = array_merge($modules, $compatibleModules->results);
}
if(count($modules) === 0){
return self::STATUS_NO_MODULES;
}
return $modules;
}
|
[
"public",
"function",
"getModulesFromRepository",
"(",
")",
"{",
"$",
"modules",
"=",
"array",
"(",
")",
";",
"$",
"system",
"=",
"$",
"this",
"->",
"systemService",
"->",
"getActiveSystem",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"repositories",
"as",
"$",
"repository",
")",
"{",
"// Retrieve compatible modules.",
"$",
"client",
"=",
"new",
"Client",
"(",
"[",
"'base_uri'",
"=>",
"$",
"repository",
",",
"]",
")",
";",
"$",
"response",
"=",
"$",
"client",
"->",
"get",
"(",
"'d/'",
".",
"$",
"system",
"->",
"getPackage",
"(",
")",
".",
"'/'",
".",
"$",
"this",
"->",
"distributionVersion",
".",
"'.json'",
")",
";",
"$",
"compatibleModules",
"=",
"json_decode",
"(",
"$",
"response",
"->",
"getBody",
"(",
")",
")",
";",
"// TODO: What to do if same module exists in different repositories?",
"$",
"modules",
"=",
"array_merge",
"(",
"$",
"modules",
",",
"$",
"compatibleModules",
"->",
"results",
")",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"modules",
")",
"===",
"0",
")",
"{",
"return",
"self",
"::",
"STATUS_NO_MODULES",
";",
"}",
"return",
"$",
"modules",
";",
"}"
] |
Retrieve compatible modules from repositories.
@return array
|
[
"Retrieve",
"compatible",
"modules",
"from",
"repositories",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Module/Repository.php#L90-L112
|
233,140
|
CampaignChain/core
|
Module/Repository.php
|
Repository.getAll
|
public function getAll()
{
if (!$this->loadRepositories()) {
return Repository::STATUS_NO_REPOSITORIES;
}
$modules = $this->getModulesFromRepository();
// Is a higher version of an already installed package available?
foreach ($modules as $key => $module) {
$version = $this->packageService->getVersion($module->name);
if (!$version) {
// Not installed at all.
unset($modules[$key]);
} elseif (version_compare($version, $module->version, '<')) {
// Older version installed.
$modules[$key]->hasUpdate = true;
$modules[$key]->versionInstalled = $version;
} else {
$modules[$key]->hasUpdate = false;
$modules[$key]->versionInstalled = $version;
}
}
return $modules;
}
|
php
|
public function getAll()
{
if (!$this->loadRepositories()) {
return Repository::STATUS_NO_REPOSITORIES;
}
$modules = $this->getModulesFromRepository();
// Is a higher version of an already installed package available?
foreach ($modules as $key => $module) {
$version = $this->packageService->getVersion($module->name);
if (!$version) {
// Not installed at all.
unset($modules[$key]);
} elseif (version_compare($version, $module->version, '<')) {
// Older version installed.
$modules[$key]->hasUpdate = true;
$modules[$key]->versionInstalled = $version;
} else {
$modules[$key]->hasUpdate = false;
$modules[$key]->versionInstalled = $version;
}
}
return $modules;
}
|
[
"public",
"function",
"getAll",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"loadRepositories",
"(",
")",
")",
"{",
"return",
"Repository",
"::",
"STATUS_NO_REPOSITORIES",
";",
"}",
"$",
"modules",
"=",
"$",
"this",
"->",
"getModulesFromRepository",
"(",
")",
";",
"// Is a higher version of an already installed package available?",
"foreach",
"(",
"$",
"modules",
"as",
"$",
"key",
"=>",
"$",
"module",
")",
"{",
"$",
"version",
"=",
"$",
"this",
"->",
"packageService",
"->",
"getVersion",
"(",
"$",
"module",
"->",
"name",
")",
";",
"if",
"(",
"!",
"$",
"version",
")",
"{",
"// Not installed at all.",
"unset",
"(",
"$",
"modules",
"[",
"$",
"key",
"]",
")",
";",
"}",
"elseif",
"(",
"version_compare",
"(",
"$",
"version",
",",
"$",
"module",
"->",
"version",
",",
"'<'",
")",
")",
"{",
"// Older version installed.",
"$",
"modules",
"[",
"$",
"key",
"]",
"->",
"hasUpdate",
"=",
"true",
";",
"$",
"modules",
"[",
"$",
"key",
"]",
"->",
"versionInstalled",
"=",
"$",
"version",
";",
"}",
"else",
"{",
"$",
"modules",
"[",
"$",
"key",
"]",
"->",
"hasUpdate",
"=",
"false",
";",
"$",
"modules",
"[",
"$",
"key",
"]",
"->",
"versionInstalled",
"=",
"$",
"version",
";",
"}",
"}",
"return",
"$",
"modules",
";",
"}"
] |
Get module versions from CampaignChain.
@return array|string
|
[
"Get",
"module",
"versions",
"from",
"CampaignChain",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Module/Repository.php#L119-L145
|
233,141
|
CampaignChain/core
|
Module/Repository.php
|
Repository.getInstalls
|
public function getInstalls()
{
if (!$this->loadRepositories()) {
return Repository::STATUS_NO_REPOSITORIES;
}
$modules = $this->getModulesFromRepository();
// Is the package already installed? If yes, is a higher version available?
foreach ($modules as $key => $module) {
$version = $this->packageService->getVersion($module->name);
// Not installed yet.
if ($version) {
// Older version installed.
unset($modules[$key]);
}
}
return $modules;
}
|
php
|
public function getInstalls()
{
if (!$this->loadRepositories()) {
return Repository::STATUS_NO_REPOSITORIES;
}
$modules = $this->getModulesFromRepository();
// Is the package already installed? If yes, is a higher version available?
foreach ($modules as $key => $module) {
$version = $this->packageService->getVersion($module->name);
// Not installed yet.
if ($version) {
// Older version installed.
unset($modules[$key]);
}
}
return $modules;
}
|
[
"public",
"function",
"getInstalls",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"loadRepositories",
"(",
")",
")",
"{",
"return",
"Repository",
"::",
"STATUS_NO_REPOSITORIES",
";",
"}",
"$",
"modules",
"=",
"$",
"this",
"->",
"getModulesFromRepository",
"(",
")",
";",
"// Is the package already installed? If yes, is a higher version available?",
"foreach",
"(",
"$",
"modules",
"as",
"$",
"key",
"=>",
"$",
"module",
")",
"{",
"$",
"version",
"=",
"$",
"this",
"->",
"packageService",
"->",
"getVersion",
"(",
"$",
"module",
"->",
"name",
")",
";",
"// Not installed yet.",
"if",
"(",
"$",
"version",
")",
"{",
"// Older version installed.",
"unset",
"(",
"$",
"modules",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"return",
"$",
"modules",
";",
"}"
] |
Get modules that needs to be installed.
@return array|string
|
[
"Get",
"modules",
"that",
"needs",
"to",
"be",
"installed",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Module/Repository.php#L152-L171
|
233,142
|
CampaignChain/core
|
Module/Repository.php
|
Repository.getUpdates
|
public function getUpdates()
{
if (!$this->loadRepositories()) {
return Repository::STATUS_NO_REPOSITORIES;
}
$modules = $this->getModulesFromRepository();
// Is a higher version of an already installed package available?
foreach ($modules as $key => $module) {
$version = $this->packageService->getVersion($module->name);
if (!$version) {
// Not installed at all.
unset($modules[$key]);
} elseif (version_compare($version, $module->version, '<')) {
// Older version installed.
$modules[$key]->versionInstalled = $version;
} else {
unset($modules[$key]);
}
}
return $modules;
}
|
php
|
public function getUpdates()
{
if (!$this->loadRepositories()) {
return Repository::STATUS_NO_REPOSITORIES;
}
$modules = $this->getModulesFromRepository();
// Is a higher version of an already installed package available?
foreach ($modules as $key => $module) {
$version = $this->packageService->getVersion($module->name);
if (!$version) {
// Not installed at all.
unset($modules[$key]);
} elseif (version_compare($version, $module->version, '<')) {
// Older version installed.
$modules[$key]->versionInstalled = $version;
} else {
unset($modules[$key]);
}
}
return $modules;
}
|
[
"public",
"function",
"getUpdates",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"loadRepositories",
"(",
")",
")",
"{",
"return",
"Repository",
"::",
"STATUS_NO_REPOSITORIES",
";",
"}",
"$",
"modules",
"=",
"$",
"this",
"->",
"getModulesFromRepository",
"(",
")",
";",
"// Is a higher version of an already installed package available?",
"foreach",
"(",
"$",
"modules",
"as",
"$",
"key",
"=>",
"$",
"module",
")",
"{",
"$",
"version",
"=",
"$",
"this",
"->",
"packageService",
"->",
"getVersion",
"(",
"$",
"module",
"->",
"name",
")",
";",
"if",
"(",
"!",
"$",
"version",
")",
"{",
"// Not installed at all.",
"unset",
"(",
"$",
"modules",
"[",
"$",
"key",
"]",
")",
";",
"}",
"elseif",
"(",
"version_compare",
"(",
"$",
"version",
",",
"$",
"module",
"->",
"version",
",",
"'<'",
")",
")",
"{",
"// Older version installed.",
"$",
"modules",
"[",
"$",
"key",
"]",
"->",
"versionInstalled",
"=",
"$",
"version",
";",
"}",
"else",
"{",
"unset",
"(",
"$",
"modules",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"return",
"$",
"modules",
";",
"}"
] |
Get updates from CampaignChain.
@return array|string
|
[
"Get",
"updates",
"from",
"CampaignChain",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Module/Repository.php#L178-L202
|
233,143
|
sveneisenschmidt/bmecat
|
src/SE/Component/BMEcat/DocumentBuilder.php
|
DocumentBuilder.build
|
public function build()
{
if(($document = $this->getDocument()) === null) {
$document = $this->loader->getInstance(NodeLoader::DOCUMENT_NODE);
$this->setDocument($document);
}
if(($header = $document->getHeader()) === null) {
$header = $this->loader->getInstance(NodeLoader::HEADER_NODE);
$document->setHeader($header);
}
if(($supplier = $header->getSupplier()) === null) {
$supplier = $this->loader->getInstance(NodeLoader::SUPPLIER_NODE);
$header->setSupplier($supplier);
}
if(($catalog = $header->getCatalog()) === null) {
$catalog = $this->loader->getInstance(NodeLoader::CATALOG_NODE);
$header->setCatalog($catalog);
}
if(($datetime = $catalog->getDateTime()) === null) {
$datetime = $this->loader->getInstance(NodeLoader::DATE_TIME_NODE);
$catalog->setDateTime($datetime);
}
if(($newCatalog = $document->getNewCatalog()) === null) {
$newCatalog = $this->loader->getInstance(NodeLoader::NEW_CATALOG_NODE);
$document->setNewCatalog($newCatalog);
}
return $document;
}
|
php
|
public function build()
{
if(($document = $this->getDocument()) === null) {
$document = $this->loader->getInstance(NodeLoader::DOCUMENT_NODE);
$this->setDocument($document);
}
if(($header = $document->getHeader()) === null) {
$header = $this->loader->getInstance(NodeLoader::HEADER_NODE);
$document->setHeader($header);
}
if(($supplier = $header->getSupplier()) === null) {
$supplier = $this->loader->getInstance(NodeLoader::SUPPLIER_NODE);
$header->setSupplier($supplier);
}
if(($catalog = $header->getCatalog()) === null) {
$catalog = $this->loader->getInstance(NodeLoader::CATALOG_NODE);
$header->setCatalog($catalog);
}
if(($datetime = $catalog->getDateTime()) === null) {
$datetime = $this->loader->getInstance(NodeLoader::DATE_TIME_NODE);
$catalog->setDateTime($datetime);
}
if(($newCatalog = $document->getNewCatalog()) === null) {
$newCatalog = $this->loader->getInstance(NodeLoader::NEW_CATALOG_NODE);
$document->setNewCatalog($newCatalog);
}
return $document;
}
|
[
"public",
"function",
"build",
"(",
")",
"{",
"if",
"(",
"(",
"$",
"document",
"=",
"$",
"this",
"->",
"getDocument",
"(",
")",
")",
"===",
"null",
")",
"{",
"$",
"document",
"=",
"$",
"this",
"->",
"loader",
"->",
"getInstance",
"(",
"NodeLoader",
"::",
"DOCUMENT_NODE",
")",
";",
"$",
"this",
"->",
"setDocument",
"(",
"$",
"document",
")",
";",
"}",
"if",
"(",
"(",
"$",
"header",
"=",
"$",
"document",
"->",
"getHeader",
"(",
")",
")",
"===",
"null",
")",
"{",
"$",
"header",
"=",
"$",
"this",
"->",
"loader",
"->",
"getInstance",
"(",
"NodeLoader",
"::",
"HEADER_NODE",
")",
";",
"$",
"document",
"->",
"setHeader",
"(",
"$",
"header",
")",
";",
"}",
"if",
"(",
"(",
"$",
"supplier",
"=",
"$",
"header",
"->",
"getSupplier",
"(",
")",
")",
"===",
"null",
")",
"{",
"$",
"supplier",
"=",
"$",
"this",
"->",
"loader",
"->",
"getInstance",
"(",
"NodeLoader",
"::",
"SUPPLIER_NODE",
")",
";",
"$",
"header",
"->",
"setSupplier",
"(",
"$",
"supplier",
")",
";",
"}",
"if",
"(",
"(",
"$",
"catalog",
"=",
"$",
"header",
"->",
"getCatalog",
"(",
")",
")",
"===",
"null",
")",
"{",
"$",
"catalog",
"=",
"$",
"this",
"->",
"loader",
"->",
"getInstance",
"(",
"NodeLoader",
"::",
"CATALOG_NODE",
")",
";",
"$",
"header",
"->",
"setCatalog",
"(",
"$",
"catalog",
")",
";",
"}",
"if",
"(",
"(",
"$",
"datetime",
"=",
"$",
"catalog",
"->",
"getDateTime",
"(",
")",
")",
"===",
"null",
")",
"{",
"$",
"datetime",
"=",
"$",
"this",
"->",
"loader",
"->",
"getInstance",
"(",
"NodeLoader",
"::",
"DATE_TIME_NODE",
")",
";",
"$",
"catalog",
"->",
"setDateTime",
"(",
"$",
"datetime",
")",
";",
"}",
"if",
"(",
"(",
"$",
"newCatalog",
"=",
"$",
"document",
"->",
"getNewCatalog",
"(",
")",
")",
"===",
"null",
")",
"{",
"$",
"newCatalog",
"=",
"$",
"this",
"->",
"loader",
"->",
"getInstance",
"(",
"NodeLoader",
"::",
"NEW_CATALOG_NODE",
")",
";",
"$",
"document",
"->",
"setNewCatalog",
"(",
"$",
"newCatalog",
")",
";",
"}",
"return",
"$",
"document",
";",
"}"
] |
Builds the BMEcat document tree
@return \SE\Component\BMEcat\Node\DocumentNode
|
[
"Builds",
"the",
"BMEcat",
"document",
"tree"
] |
1f0713fb4ee910b60ccdf8fda4ae35ab5d6c5c2e
|
https://github.com/sveneisenschmidt/bmecat/blob/1f0713fb4ee910b60ccdf8fda4ae35ab5d6c5c2e/src/SE/Component/BMEcat/DocumentBuilder.php#L140-L173
|
233,144
|
prooph/link-process-manager
|
src/Projection/MessageHandler/MessageHandlerFinder.php
|
MessageHandlerFinder.findByProcessingId
|
public function findByProcessingId($processingId)
{
$handlers = [];
$builder = $this->connection->createQueryBuilder();
$builder->select('*')->from(Tables::MESSAGE_HANDLER)
->where($builder->expr()->eq('processing_id', ':processing_id'))
->setParameter('processing_id', $processingId);
foreach($builder->execute() as $row) {
$this->fromDatabase($row);
array_push($handlers, $row);
}
return $handlers;
}
|
php
|
public function findByProcessingId($processingId)
{
$handlers = [];
$builder = $this->connection->createQueryBuilder();
$builder->select('*')->from(Tables::MESSAGE_HANDLER)
->where($builder->expr()->eq('processing_id', ':processing_id'))
->setParameter('processing_id', $processingId);
foreach($builder->execute() as $row) {
$this->fromDatabase($row);
array_push($handlers, $row);
}
return $handlers;
}
|
[
"public",
"function",
"findByProcessingId",
"(",
"$",
"processingId",
")",
"{",
"$",
"handlers",
"=",
"[",
"]",
";",
"$",
"builder",
"=",
"$",
"this",
"->",
"connection",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"builder",
"->",
"select",
"(",
"'*'",
")",
"->",
"from",
"(",
"Tables",
"::",
"MESSAGE_HANDLER",
")",
"->",
"where",
"(",
"$",
"builder",
"->",
"expr",
"(",
")",
"->",
"eq",
"(",
"'processing_id'",
",",
"':processing_id'",
")",
")",
"->",
"setParameter",
"(",
"'processing_id'",
",",
"$",
"processingId",
")",
";",
"foreach",
"(",
"$",
"builder",
"->",
"execute",
"(",
")",
"as",
"$",
"row",
")",
"{",
"$",
"this",
"->",
"fromDatabase",
"(",
"$",
"row",
")",
";",
"array_push",
"(",
"$",
"handlers",
",",
"$",
"row",
")",
";",
"}",
"return",
"$",
"handlers",
";",
"}"
] |
Find all message handler with given processing_id
@param string $processingId
@return array of message handlers data
|
[
"Find",
"all",
"message",
"handler",
"with",
"given",
"processing_id"
] |
3d6c8bdc72e855786227747bf06bcf8221f7860a
|
https://github.com/prooph/link-process-manager/blob/3d6c8bdc72e855786227747bf06bcf8221f7860a/src/Projection/MessageHandler/MessageHandlerFinder.php#L70-L86
|
233,145
|
joomla-framework/twitter-api
|
src/Statuses.php
|
Statuses.getHomeTimeline
|
public function getHomeTimeline($count = 20, $noReplies = null, $sinceId = 0, $maxId = 0, $trimUser = null, $contributor = null, $entities = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('statuses', 'home_timeline');
$data = array();
// Set the API base
$path = '/statuses/home_timeline.json';
// Set the count string
$data['count'] = $count;
// Check if no_replies is specified
if ($noReplies !== null)
{
$data['exclude_replies'] = $noReplies;
}
// Check if a since_id is specified
if ($sinceId > 0)
{
$data['since_id'] = (int) $sinceId;
}
// Check if a max_id is specified
if ($maxId > 0)
{
$data['max_id'] = (int) $maxId;
}
// Check if trim_user is specified
if ($trimUser !== null)
{
$data['trim_user'] = $trimUser;
}
// Check if contributor details is specified
if ($contributor !== null)
{
$data['contributor_details'] = $contributor;
}
// Check if entities is specified
if ($entities !== null)
{
$data['include_entities'] = $entities;
}
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
|
php
|
public function getHomeTimeline($count = 20, $noReplies = null, $sinceId = 0, $maxId = 0, $trimUser = null, $contributor = null, $entities = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('statuses', 'home_timeline');
$data = array();
// Set the API base
$path = '/statuses/home_timeline.json';
// Set the count string
$data['count'] = $count;
// Check if no_replies is specified
if ($noReplies !== null)
{
$data['exclude_replies'] = $noReplies;
}
// Check if a since_id is specified
if ($sinceId > 0)
{
$data['since_id'] = (int) $sinceId;
}
// Check if a max_id is specified
if ($maxId > 0)
{
$data['max_id'] = (int) $maxId;
}
// Check if trim_user is specified
if ($trimUser !== null)
{
$data['trim_user'] = $trimUser;
}
// Check if contributor details is specified
if ($contributor !== null)
{
$data['contributor_details'] = $contributor;
}
// Check if entities is specified
if ($entities !== null)
{
$data['include_entities'] = $entities;
}
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
|
[
"public",
"function",
"getHomeTimeline",
"(",
"$",
"count",
"=",
"20",
",",
"$",
"noReplies",
"=",
"null",
",",
"$",
"sinceId",
"=",
"0",
",",
"$",
"maxId",
"=",
"0",
",",
"$",
"trimUser",
"=",
"null",
",",
"$",
"contributor",
"=",
"null",
",",
"$",
"entities",
"=",
"null",
")",
"{",
"// Check the rate limit for remaining hits",
"$",
"this",
"->",
"checkRateLimit",
"(",
"'statuses'",
",",
"'home_timeline'",
")",
";",
"$",
"data",
"=",
"array",
"(",
")",
";",
"// Set the API base",
"$",
"path",
"=",
"'/statuses/home_timeline.json'",
";",
"// Set the count string",
"$",
"data",
"[",
"'count'",
"]",
"=",
"$",
"count",
";",
"// Check if no_replies is specified",
"if",
"(",
"$",
"noReplies",
"!==",
"null",
")",
"{",
"$",
"data",
"[",
"'exclude_replies'",
"]",
"=",
"$",
"noReplies",
";",
"}",
"// Check if a since_id is specified",
"if",
"(",
"$",
"sinceId",
">",
"0",
")",
"{",
"$",
"data",
"[",
"'since_id'",
"]",
"=",
"(",
"int",
")",
"$",
"sinceId",
";",
"}",
"// Check if a max_id is specified",
"if",
"(",
"$",
"maxId",
">",
"0",
")",
"{",
"$",
"data",
"[",
"'max_id'",
"]",
"=",
"(",
"int",
")",
"$",
"maxId",
";",
"}",
"// Check if trim_user is specified",
"if",
"(",
"$",
"trimUser",
"!==",
"null",
")",
"{",
"$",
"data",
"[",
"'trim_user'",
"]",
"=",
"$",
"trimUser",
";",
"}",
"// Check if contributor details is specified",
"if",
"(",
"$",
"contributor",
"!==",
"null",
")",
"{",
"$",
"data",
"[",
"'contributor_details'",
"]",
"=",
"$",
"contributor",
";",
"}",
"// Check if entities is specified",
"if",
"(",
"$",
"entities",
"!==",
"null",
")",
"{",
"$",
"data",
"[",
"'include_entities'",
"]",
"=",
"$",
"entities",
";",
"}",
"// Send the request.",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"$",
"path",
",",
"'GET'",
",",
"$",
"data",
")",
";",
"}"
] |
Method to retrieve collection of the most recent Tweets and retweets posted by the authenticating user and the users they follow.
The home timeline is central to how most users interact with the Twitter service.
@param integer $count Specifies the number of tweets to try and retrieve, up to a maximum of 200. Retweets are always included
in the count, so it is always suggested to set $includeRts to true
@param boolean $noReplies This parameter will prevent replies from appearing in the returned timeline. This parameter is only supported
for JSON and XML responses.
@param integer $sinceId Returns results with an ID greater than (that is, more recent than) the specified ID.
@param integer $maxId Returns results with an ID less than (that is, older than) the specified ID.
@param boolean $trimUser When set to true, each tweet returned in a timeline will include a user object including only
the status author's numerical ID.
@param boolean $contributor This parameter enhances the contributors element of the status response to include the screen_name of the
contributor. By default only the user_id of the contributor is included.
@param boolean $entities If set to true, this will include an addition entities node in the response object.
@return array The decoded JSON response
@since 1.2.0
@throws \RuntimeException
|
[
"Method",
"to",
"retrieve",
"collection",
"of",
"the",
"most",
"recent",
"Tweets",
"and",
"retweets",
"posted",
"by",
"the",
"authenticating",
"user",
"and",
"the",
"users",
"they",
"follow",
".",
"The",
"home",
"timeline",
"is",
"central",
"to",
"how",
"most",
"users",
"interact",
"with",
"the",
"Twitter",
"service",
"."
] |
289719bbd67e83c7cfaf515b94b1d5497b1f0525
|
https://github.com/joomla-framework/twitter-api/blob/289719bbd67e83c7cfaf515b94b1d5497b1f0525/src/Statuses.php#L178-L229
|
233,146
|
joomla-framework/twitter-api
|
src/Statuses.php
|
Statuses.retweet
|
public function retweet($id, $trimUser = null)
{
// Set the API path
$path = '/statuses/retweet/' . $id . '.json';
$data = array();
// Check if trim_user is specified
if ($trimUser !== null)
{
$data['trim_user'] = $trimUser;
}
// Send the request.
return $this->sendRequest($path, 'POST', $data);
}
|
php
|
public function retweet($id, $trimUser = null)
{
// Set the API path
$path = '/statuses/retweet/' . $id . '.json';
$data = array();
// Check if trim_user is specified
if ($trimUser !== null)
{
$data['trim_user'] = $trimUser;
}
// Send the request.
return $this->sendRequest($path, 'POST', $data);
}
|
[
"public",
"function",
"retweet",
"(",
"$",
"id",
",",
"$",
"trimUser",
"=",
"null",
")",
"{",
"// Set the API path",
"$",
"path",
"=",
"'/statuses/retweet/'",
".",
"$",
"id",
".",
"'.json'",
";",
"$",
"data",
"=",
"array",
"(",
")",
";",
"// Check if trim_user is specified",
"if",
"(",
"$",
"trimUser",
"!==",
"null",
")",
"{",
"$",
"data",
"[",
"'trim_user'",
"]",
"=",
"$",
"trimUser",
";",
"}",
"// Send the request.",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"$",
"path",
",",
"'POST'",
",",
"$",
"data",
")",
";",
"}"
] |
Method to retweet a tweet.
@param integer $id The numerical ID of the desired status.
@param boolean $trimUser When set to true, each tweet returned in a timeline will include a user object including only the status author's
numerical ID.
@return array The decoded JSON response
@since 1.0
|
[
"Method",
"to",
"retweet",
"a",
"tweet",
"."
] |
289719bbd67e83c7cfaf515b94b1d5497b1f0525
|
https://github.com/joomla-framework/twitter-api/blob/289719bbd67e83c7cfaf515b94b1d5497b1f0525/src/Statuses.php#L547-L562
|
233,147
|
prooph/link-process-manager
|
src/Model/MessageHandler/ProcessingTypes.php
|
ProcessingTypes.support
|
public static function support(array $processingTypes)
{
$prototypes = [];
foreach ($processingTypes as $typeClassOrPrototype) {
if ($typeClassOrPrototype instanceof Prototype) {
$prototypes[] = $typeClassOrPrototype;
} else {
Assertion::string($typeClassOrPrototype);
Assertion::classExists($typeClassOrPrototype);
Assertion::implementsInterface($typeClassOrPrototype, Type::class);
$prototypes[] = $typeClassOrPrototype::prototype();
}
}
return new self($prototypes, false);
}
|
php
|
public static function support(array $processingTypes)
{
$prototypes = [];
foreach ($processingTypes as $typeClassOrPrototype) {
if ($typeClassOrPrototype instanceof Prototype) {
$prototypes[] = $typeClassOrPrototype;
} else {
Assertion::string($typeClassOrPrototype);
Assertion::classExists($typeClassOrPrototype);
Assertion::implementsInterface($typeClassOrPrototype, Type::class);
$prototypes[] = $typeClassOrPrototype::prototype();
}
}
return new self($prototypes, false);
}
|
[
"public",
"static",
"function",
"support",
"(",
"array",
"$",
"processingTypes",
")",
"{",
"$",
"prototypes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"processingTypes",
"as",
"$",
"typeClassOrPrototype",
")",
"{",
"if",
"(",
"$",
"typeClassOrPrototype",
"instanceof",
"Prototype",
")",
"{",
"$",
"prototypes",
"[",
"]",
"=",
"$",
"typeClassOrPrototype",
";",
"}",
"else",
"{",
"Assertion",
"::",
"string",
"(",
"$",
"typeClassOrPrototype",
")",
";",
"Assertion",
"::",
"classExists",
"(",
"$",
"typeClassOrPrototype",
")",
";",
"Assertion",
"::",
"implementsInterface",
"(",
"$",
"typeClassOrPrototype",
",",
"Type",
"::",
"class",
")",
";",
"$",
"prototypes",
"[",
"]",
"=",
"$",
"typeClassOrPrototype",
"::",
"prototype",
"(",
")",
";",
"}",
"}",
"return",
"new",
"self",
"(",
"$",
"prototypes",
",",
"false",
")",
";",
"}"
] |
Supported processing types can be given as processing prototypes or a list of type classes
@param Prototype[]|array $processingTypes
@return ProcessingTypes
|
[
"Supported",
"processing",
"types",
"can",
"be",
"given",
"as",
"processing",
"prototypes",
"or",
"a",
"list",
"of",
"type",
"classes"
] |
3d6c8bdc72e855786227747bf06bcf8221f7860a
|
https://github.com/prooph/link-process-manager/blob/3d6c8bdc72e855786227747bf06bcf8221f7860a/src/Model/MessageHandler/ProcessingTypes.php#L47-L63
|
233,148
|
snelg/cakephp-3-cas
|
src/Auth/CasAuthenticate.php
|
CasAuthenticate.logout
|
public function logout(Event $event)
{
if (phpCAS::isAuthenticated()) {
//Step 1. When the client clicks logout, this will run.
// phpCAS::logout will redirect the client to the CAS server.
// The CAS server will, in turn, redirect the client back to
// this same logout URL.
//
// phpCAS will stop script execution after it sends the redirect
// header, which is a problem because CakePHP still thinks the
// user is logged in. See Step 2.
$auth = $event->subject();
if ($auth instanceof AuthComponent) {
$redirectUrl = $auth->config('logoutRedirect');
}
if (empty($redirectUrl)) {
$redirectUrl = '/';
}
phpCAS::logout(['url' => Router::url($redirectUrl, true)]);
}
//Step 2. We reach this line when the CAS server has redirected the
// client back to us. Do nothing in this block; then after this
// method returns, CakePHP will do whatever is necessary to log
// the user out from its end (destroying the session or whatever).
}
|
php
|
public function logout(Event $event)
{
if (phpCAS::isAuthenticated()) {
//Step 1. When the client clicks logout, this will run.
// phpCAS::logout will redirect the client to the CAS server.
// The CAS server will, in turn, redirect the client back to
// this same logout URL.
//
// phpCAS will stop script execution after it sends the redirect
// header, which is a problem because CakePHP still thinks the
// user is logged in. See Step 2.
$auth = $event->subject();
if ($auth instanceof AuthComponent) {
$redirectUrl = $auth->config('logoutRedirect');
}
if (empty($redirectUrl)) {
$redirectUrl = '/';
}
phpCAS::logout(['url' => Router::url($redirectUrl, true)]);
}
//Step 2. We reach this line when the CAS server has redirected the
// client back to us. Do nothing in this block; then after this
// method returns, CakePHP will do whatever is necessary to log
// the user out from its end (destroying the session or whatever).
}
|
[
"public",
"function",
"logout",
"(",
"Event",
"$",
"event",
")",
"{",
"if",
"(",
"phpCAS",
"::",
"isAuthenticated",
"(",
")",
")",
"{",
"//Step 1. When the client clicks logout, this will run.",
"// phpCAS::logout will redirect the client to the CAS server.",
"// The CAS server will, in turn, redirect the client back to",
"// this same logout URL.",
"//",
"// phpCAS will stop script execution after it sends the redirect",
"// header, which is a problem because CakePHP still thinks the",
"// user is logged in. See Step 2.",
"$",
"auth",
"=",
"$",
"event",
"->",
"subject",
"(",
")",
";",
"if",
"(",
"$",
"auth",
"instanceof",
"AuthComponent",
")",
"{",
"$",
"redirectUrl",
"=",
"$",
"auth",
"->",
"config",
"(",
"'logoutRedirect'",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"redirectUrl",
")",
")",
"{",
"$",
"redirectUrl",
"=",
"'/'",
";",
"}",
"phpCAS",
"::",
"logout",
"(",
"[",
"'url'",
"=>",
"Router",
"::",
"url",
"(",
"$",
"redirectUrl",
",",
"true",
")",
"]",
")",
";",
"}",
"//Step 2. We reach this line when the CAS server has redirected the",
"// client back to us. Do nothing in this block; then after this",
"// method returns, CakePHP will do whatever is necessary to log",
"// the user out from its end (destroying the session or whatever).",
"}"
] |
Log a user out. Interrupts initial call to AuthComponent logout
to handle CAS logout, which happens on separate CAS server
@param Event $event Auth.logout event
@return void
|
[
"Log",
"a",
"user",
"out",
".",
"Interrupts",
"initial",
"call",
"to",
"AuthComponent",
"logout",
"to",
"handle",
"CAS",
"logout",
"which",
"happens",
"on",
"separate",
"CAS",
"server"
] |
eb60ad37c0afd404e7a33d8783e3a3add0bdf2cb
|
https://github.com/snelg/cakephp-3-cas/blob/eb60ad37c0afd404e7a33d8783e3a3add0bdf2cb/src/Auth/CasAuthenticate.php#L134-L158
|
233,149
|
ionux/phactor
|
src/Signature.php
|
Signature.Generate
|
public function Generate($message, $private_key)
{
$e = '';
$k = '';
$r = '';
$s = '';
$R = array();
$signature = array();
$private_key = $this->encodeHex($private_key);
$this->hexLenCheck($private_key);
try {
do {
/* Get the message hash and a new random number */
$e = $this->decodeHex('0x' . hash('sha256', $message));
$k = $this->SecureRandomNumber();
/* Calculate a new curve point from R=k*G (x1,y1) */
$R = $this->DoubleAndAdd($this->P, $k);
$R['x'] = $this->addHexPrefix(str_pad($this->encodeHex($R['x'], false), 64, "0", STR_PAD_LEFT));
/* r = x1 mod n */
$r = $this->Modulo($this->decodeHex($R['x']), $this->n);
/* s = k^-1 * (e+d*r) mod n */
$dr = $this->Multiply($this->decodeHex($private_key), $r);
$edr = $this->Add($e, $dr);
$s = $this->Modulo($this->Multiply($this->Invert($k, $this->n), $edr), $this->n);
} while ($this->zeroCompare($r, $s));
} catch (\Exception $e) {
throw $e;
}
$signature = array(
'r' => $this->addHexPrefix(str_pad($this->encodeHex($r, false), 64, "0", STR_PAD_LEFT)),
's' => $this->addHexPrefix(str_pad($this->encodeHex($s, false), 64, "0", STR_PAD_LEFT))
);
$this->r_coordinate = $signature['r'];
$this->s_coordinate = $signature['s'];
$this->encoded_signature = $this->Encode($this->r_coordinate, $this->s_coordinate);
return $this->encoded_signature;
}
|
php
|
public function Generate($message, $private_key)
{
$e = '';
$k = '';
$r = '';
$s = '';
$R = array();
$signature = array();
$private_key = $this->encodeHex($private_key);
$this->hexLenCheck($private_key);
try {
do {
/* Get the message hash and a new random number */
$e = $this->decodeHex('0x' . hash('sha256', $message));
$k = $this->SecureRandomNumber();
/* Calculate a new curve point from R=k*G (x1,y1) */
$R = $this->DoubleAndAdd($this->P, $k);
$R['x'] = $this->addHexPrefix(str_pad($this->encodeHex($R['x'], false), 64, "0", STR_PAD_LEFT));
/* r = x1 mod n */
$r = $this->Modulo($this->decodeHex($R['x']), $this->n);
/* s = k^-1 * (e+d*r) mod n */
$dr = $this->Multiply($this->decodeHex($private_key), $r);
$edr = $this->Add($e, $dr);
$s = $this->Modulo($this->Multiply($this->Invert($k, $this->n), $edr), $this->n);
} while ($this->zeroCompare($r, $s));
} catch (\Exception $e) {
throw $e;
}
$signature = array(
'r' => $this->addHexPrefix(str_pad($this->encodeHex($r, false), 64, "0", STR_PAD_LEFT)),
's' => $this->addHexPrefix(str_pad($this->encodeHex($s, false), 64, "0", STR_PAD_LEFT))
);
$this->r_coordinate = $signature['r'];
$this->s_coordinate = $signature['s'];
$this->encoded_signature = $this->Encode($this->r_coordinate, $this->s_coordinate);
return $this->encoded_signature;
}
|
[
"public",
"function",
"Generate",
"(",
"$",
"message",
",",
"$",
"private_key",
")",
"{",
"$",
"e",
"=",
"''",
";",
"$",
"k",
"=",
"''",
";",
"$",
"r",
"=",
"''",
";",
"$",
"s",
"=",
"''",
";",
"$",
"R",
"=",
"array",
"(",
")",
";",
"$",
"signature",
"=",
"array",
"(",
")",
";",
"$",
"private_key",
"=",
"$",
"this",
"->",
"encodeHex",
"(",
"$",
"private_key",
")",
";",
"$",
"this",
"->",
"hexLenCheck",
"(",
"$",
"private_key",
")",
";",
"try",
"{",
"do",
"{",
"/* Get the message hash and a new random number */",
"$",
"e",
"=",
"$",
"this",
"->",
"decodeHex",
"(",
"'0x'",
".",
"hash",
"(",
"'sha256'",
",",
"$",
"message",
")",
")",
";",
"$",
"k",
"=",
"$",
"this",
"->",
"SecureRandomNumber",
"(",
")",
";",
"/* Calculate a new curve point from R=k*G (x1,y1) */",
"$",
"R",
"=",
"$",
"this",
"->",
"DoubleAndAdd",
"(",
"$",
"this",
"->",
"P",
",",
"$",
"k",
")",
";",
"$",
"R",
"[",
"'x'",
"]",
"=",
"$",
"this",
"->",
"addHexPrefix",
"(",
"str_pad",
"(",
"$",
"this",
"->",
"encodeHex",
"(",
"$",
"R",
"[",
"'x'",
"]",
",",
"false",
")",
",",
"64",
",",
"\"0\"",
",",
"STR_PAD_LEFT",
")",
")",
";",
"/* r = x1 mod n */",
"$",
"r",
"=",
"$",
"this",
"->",
"Modulo",
"(",
"$",
"this",
"->",
"decodeHex",
"(",
"$",
"R",
"[",
"'x'",
"]",
")",
",",
"$",
"this",
"->",
"n",
")",
";",
"/* s = k^-1 * (e+d*r) mod n */",
"$",
"dr",
"=",
"$",
"this",
"->",
"Multiply",
"(",
"$",
"this",
"->",
"decodeHex",
"(",
"$",
"private_key",
")",
",",
"$",
"r",
")",
";",
"$",
"edr",
"=",
"$",
"this",
"->",
"Add",
"(",
"$",
"e",
",",
"$",
"dr",
")",
";",
"$",
"s",
"=",
"$",
"this",
"->",
"Modulo",
"(",
"$",
"this",
"->",
"Multiply",
"(",
"$",
"this",
"->",
"Invert",
"(",
"$",
"k",
",",
"$",
"this",
"->",
"n",
")",
",",
"$",
"edr",
")",
",",
"$",
"this",
"->",
"n",
")",
";",
"}",
"while",
"(",
"$",
"this",
"->",
"zeroCompare",
"(",
"$",
"r",
",",
"$",
"s",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"$",
"signature",
"=",
"array",
"(",
"'r'",
"=>",
"$",
"this",
"->",
"addHexPrefix",
"(",
"str_pad",
"(",
"$",
"this",
"->",
"encodeHex",
"(",
"$",
"r",
",",
"false",
")",
",",
"64",
",",
"\"0\"",
",",
"STR_PAD_LEFT",
")",
")",
",",
"'s'",
"=>",
"$",
"this",
"->",
"addHexPrefix",
"(",
"str_pad",
"(",
"$",
"this",
"->",
"encodeHex",
"(",
"$",
"s",
",",
"false",
")",
",",
"64",
",",
"\"0\"",
",",
"STR_PAD_LEFT",
")",
")",
")",
";",
"$",
"this",
"->",
"r_coordinate",
"=",
"$",
"signature",
"[",
"'r'",
"]",
";",
"$",
"this",
"->",
"s_coordinate",
"=",
"$",
"signature",
"[",
"'s'",
"]",
";",
"$",
"this",
"->",
"encoded_signature",
"=",
"$",
"this",
"->",
"Encode",
"(",
"$",
"this",
"->",
"r_coordinate",
",",
"$",
"this",
"->",
"s_coordinate",
")",
";",
"return",
"$",
"this",
"->",
"encoded_signature",
";",
"}"
] |
Generates an ECDSA signature for a message using the private key
parameter in hex format. Returns an associative array of all the
signature data including raw point information and the signature.
@param string $message The message to be signed.
@param string $private_key The private key in hex.
@return string $signature The signature data.
@throws \Exception
|
[
"Generates",
"an",
"ECDSA",
"signature",
"for",
"a",
"message",
"using",
"the",
"private",
"key",
"parameter",
"in",
"hex",
"format",
".",
"Returns",
"an",
"associative",
"array",
"of",
"all",
"the",
"signature",
"data",
"including",
"raw",
"point",
"information",
"and",
"the",
"signature",
"."
] |
667064d3930e043fd78abed9a2324aee52466fa5
|
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Signature.php#L113-L162
|
233,150
|
ionux/phactor
|
src/Signature.php
|
Signature.Verify
|
public function Verify($sig, $msg, $pubkey)
{
if (true === empty($sig) || true === empty($msg) || true === empty($pubkey)) {
throw new \Exception('The signature, public key and message parameters are required to verify a signature. Value received for first parameter was "' . var_export($sig, true) . '", second parameter was "' . var_export($msg, true) . '" and third parameter was "' . var_export($pubkey, true) . '".');
}
$e = '';
$w = '';
$u1 = '';
$u2 = '';
$Z = array();
$coords = $this->parseSig($sig);
$r = $this->CoordinateCheck($this->prepAndClean($coords['r']));
$s = $this->CoordinateCheck($this->prepAndClean($coords['s']));
$r_dec = $this->decodeHex($r);
$s_dec = $this->decodeHex($s);
/* Convert the hash of the hex message to decimal */
$e = $this->decodeHex(hash('sha256', $msg));
$n_dec = $this->decodeHex($this->n);
$pubkey = (substr($pubkey, 0, 2) == '04') ? $this->keyUtil->parseUncompressedPublicKey($pubkey) : $this->keyUtil->parseCompressedPublicKey($pubkey);
/* Parse the x,y coordinates */
$Q = $this->keyUtil->parseCoordinatePairFromPublicKey($pubkey);
list($Q['x'], $Q['y']) = array($this->decodeHex($Q['x']), $this->decodeHex($Q['y']));
$this->coordsRangeCheck($Q['x'], $Q['y']);
try {
/* Calculate w = s^-1 (mod n) */
$w = $this->Invert($s_dec, $n_dec);
/* Calculate u1 = e*w (mod n) */
$u1 = $this->Modulo($this->Multiply($e, $w), $n_dec);
/* Calculate u2 = r*w (mod n) */
$u2 = $this->Modulo($this->Multiply($r_dec, $w), $n_dec);
/* Get new point Z(x1,y1) = (u1 * G) + (u2 * Q) */
$Z = $this->pointAddW($this->DoubleAndAdd($this->P, $u1), $this->DoubleAndAdd($Q, $u2));
/*
* A signature is valid if r is congruent to x1 (mod n)
* or in other words, if r - x1 is an integer multiple of n.
*/
$congruent = $this->congruencyCheck($this->decodeHex($r), $this->decodeHex($Z['x']));
return $congruent;
} catch (\Exception $e) {
throw $e;
}
}
|
php
|
public function Verify($sig, $msg, $pubkey)
{
if (true === empty($sig) || true === empty($msg) || true === empty($pubkey)) {
throw new \Exception('The signature, public key and message parameters are required to verify a signature. Value received for first parameter was "' . var_export($sig, true) . '", second parameter was "' . var_export($msg, true) . '" and third parameter was "' . var_export($pubkey, true) . '".');
}
$e = '';
$w = '';
$u1 = '';
$u2 = '';
$Z = array();
$coords = $this->parseSig($sig);
$r = $this->CoordinateCheck($this->prepAndClean($coords['r']));
$s = $this->CoordinateCheck($this->prepAndClean($coords['s']));
$r_dec = $this->decodeHex($r);
$s_dec = $this->decodeHex($s);
/* Convert the hash of the hex message to decimal */
$e = $this->decodeHex(hash('sha256', $msg));
$n_dec = $this->decodeHex($this->n);
$pubkey = (substr($pubkey, 0, 2) == '04') ? $this->keyUtil->parseUncompressedPublicKey($pubkey) : $this->keyUtil->parseCompressedPublicKey($pubkey);
/* Parse the x,y coordinates */
$Q = $this->keyUtil->parseCoordinatePairFromPublicKey($pubkey);
list($Q['x'], $Q['y']) = array($this->decodeHex($Q['x']), $this->decodeHex($Q['y']));
$this->coordsRangeCheck($Q['x'], $Q['y']);
try {
/* Calculate w = s^-1 (mod n) */
$w = $this->Invert($s_dec, $n_dec);
/* Calculate u1 = e*w (mod n) */
$u1 = $this->Modulo($this->Multiply($e, $w), $n_dec);
/* Calculate u2 = r*w (mod n) */
$u2 = $this->Modulo($this->Multiply($r_dec, $w), $n_dec);
/* Get new point Z(x1,y1) = (u1 * G) + (u2 * Q) */
$Z = $this->pointAddW($this->DoubleAndAdd($this->P, $u1), $this->DoubleAndAdd($Q, $u2));
/*
* A signature is valid if r is congruent to x1 (mod n)
* or in other words, if r - x1 is an integer multiple of n.
*/
$congruent = $this->congruencyCheck($this->decodeHex($r), $this->decodeHex($Z['x']));
return $congruent;
} catch (\Exception $e) {
throw $e;
}
}
|
[
"public",
"function",
"Verify",
"(",
"$",
"sig",
",",
"$",
"msg",
",",
"$",
"pubkey",
")",
"{",
"if",
"(",
"true",
"===",
"empty",
"(",
"$",
"sig",
")",
"||",
"true",
"===",
"empty",
"(",
"$",
"msg",
")",
"||",
"true",
"===",
"empty",
"(",
"$",
"pubkey",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'The signature, public key and message parameters are required to verify a signature. Value received for first parameter was \"'",
".",
"var_export",
"(",
"$",
"sig",
",",
"true",
")",
".",
"'\", second parameter was \"'",
".",
"var_export",
"(",
"$",
"msg",
",",
"true",
")",
".",
"'\" and third parameter was \"'",
".",
"var_export",
"(",
"$",
"pubkey",
",",
"true",
")",
".",
"'\".'",
")",
";",
"}",
"$",
"e",
"=",
"''",
";",
"$",
"w",
"=",
"''",
";",
"$",
"u1",
"=",
"''",
";",
"$",
"u2",
"=",
"''",
";",
"$",
"Z",
"=",
"array",
"(",
")",
";",
"$",
"coords",
"=",
"$",
"this",
"->",
"parseSig",
"(",
"$",
"sig",
")",
";",
"$",
"r",
"=",
"$",
"this",
"->",
"CoordinateCheck",
"(",
"$",
"this",
"->",
"prepAndClean",
"(",
"$",
"coords",
"[",
"'r'",
"]",
")",
")",
";",
"$",
"s",
"=",
"$",
"this",
"->",
"CoordinateCheck",
"(",
"$",
"this",
"->",
"prepAndClean",
"(",
"$",
"coords",
"[",
"'s'",
"]",
")",
")",
";",
"$",
"r_dec",
"=",
"$",
"this",
"->",
"decodeHex",
"(",
"$",
"r",
")",
";",
"$",
"s_dec",
"=",
"$",
"this",
"->",
"decodeHex",
"(",
"$",
"s",
")",
";",
"/* Convert the hash of the hex message to decimal */",
"$",
"e",
"=",
"$",
"this",
"->",
"decodeHex",
"(",
"hash",
"(",
"'sha256'",
",",
"$",
"msg",
")",
")",
";",
"$",
"n_dec",
"=",
"$",
"this",
"->",
"decodeHex",
"(",
"$",
"this",
"->",
"n",
")",
";",
"$",
"pubkey",
"=",
"(",
"substr",
"(",
"$",
"pubkey",
",",
"0",
",",
"2",
")",
"==",
"'04'",
")",
"?",
"$",
"this",
"->",
"keyUtil",
"->",
"parseUncompressedPublicKey",
"(",
"$",
"pubkey",
")",
":",
"$",
"this",
"->",
"keyUtil",
"->",
"parseCompressedPublicKey",
"(",
"$",
"pubkey",
")",
";",
"/* Parse the x,y coordinates */",
"$",
"Q",
"=",
"$",
"this",
"->",
"keyUtil",
"->",
"parseCoordinatePairFromPublicKey",
"(",
"$",
"pubkey",
")",
";",
"list",
"(",
"$",
"Q",
"[",
"'x'",
"]",
",",
"$",
"Q",
"[",
"'y'",
"]",
")",
"=",
"array",
"(",
"$",
"this",
"->",
"decodeHex",
"(",
"$",
"Q",
"[",
"'x'",
"]",
")",
",",
"$",
"this",
"->",
"decodeHex",
"(",
"$",
"Q",
"[",
"'y'",
"]",
")",
")",
";",
"$",
"this",
"->",
"coordsRangeCheck",
"(",
"$",
"Q",
"[",
"'x'",
"]",
",",
"$",
"Q",
"[",
"'y'",
"]",
")",
";",
"try",
"{",
"/* Calculate w = s^-1 (mod n) */",
"$",
"w",
"=",
"$",
"this",
"->",
"Invert",
"(",
"$",
"s_dec",
",",
"$",
"n_dec",
")",
";",
"/* Calculate u1 = e*w (mod n) */",
"$",
"u1",
"=",
"$",
"this",
"->",
"Modulo",
"(",
"$",
"this",
"->",
"Multiply",
"(",
"$",
"e",
",",
"$",
"w",
")",
",",
"$",
"n_dec",
")",
";",
"/* Calculate u2 = r*w (mod n) */",
"$",
"u2",
"=",
"$",
"this",
"->",
"Modulo",
"(",
"$",
"this",
"->",
"Multiply",
"(",
"$",
"r_dec",
",",
"$",
"w",
")",
",",
"$",
"n_dec",
")",
";",
"/* Get new point Z(x1,y1) = (u1 * G) + (u2 * Q) */",
"$",
"Z",
"=",
"$",
"this",
"->",
"pointAddW",
"(",
"$",
"this",
"->",
"DoubleAndAdd",
"(",
"$",
"this",
"->",
"P",
",",
"$",
"u1",
")",
",",
"$",
"this",
"->",
"DoubleAndAdd",
"(",
"$",
"Q",
",",
"$",
"u2",
")",
")",
";",
"/*\n * A signature is valid if r is congruent to x1 (mod n)\n * or in other words, if r - x1 is an integer multiple of n.\n */",
"$",
"congruent",
"=",
"$",
"this",
"->",
"congruencyCheck",
"(",
"$",
"this",
"->",
"decodeHex",
"(",
"$",
"r",
")",
",",
"$",
"this",
"->",
"decodeHex",
"(",
"$",
"Z",
"[",
"'x'",
"]",
")",
")",
";",
"return",
"$",
"congruent",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"}"
] |
Verifies an ECDSA signature previously generated.
@param string $sig The signature in hex.
@param string $msg The message signed.
@param string $pubkey The uncompressed public key of the signer.
@return bool The result of the verification.
@throws \Exception
|
[
"Verifies",
"an",
"ECDSA",
"signature",
"previously",
"generated",
"."
] |
667064d3930e043fd78abed9a2324aee52466fa5
|
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Signature.php#L173-L231
|
233,151
|
ionux/phactor
|
src/Signature.php
|
Signature.parseSig
|
private function parseSig($signature)
{
$signature = trim($signature);
/* This is the main structure we'll use for storing our parsed signature. */
$ecdsa_struct = array(
'sigstart' => '',
'siglen' => '',
'rtype' => '',
'rlen' => '',
'roffset' => 0,
'r' => '',
'stype' => '',
'slen' => '',
'soffset' => 0,
's' => '',
'original' => '',
'totallen' => 0
);
$ecdsa_struct['original'] = $signature;
$ecdsa_struct['totallen'] = strlen($signature);
$this->ecdsaSigTotalLenCheck($ecdsa_struct['totallen']);
$ecdsa_struct['sigstart'] = substr($signature, 0, 2);
$this->derRecordStartCheck($ecdsa_struct['sigstart']);
$signature = substr($signature, 2);
$ecdsa_struct['siglen'] = substr($signature, 0, 2);
$this->derRecordTotalLenCheck($ecdsa_struct['siglen']);
$signature = substr($signature, 2);
$ecdsa_struct['rtype'] = substr($signature, 0, 2);
$this->derDataTypeCheck($ecdsa_struct['rtype']);
$signature = substr($signature, 2);
$ecdsa_struct['rlen'] = substr($signature, 0, 2);
$this->derDataLenCheck($ecdsa_struct['rlen']);
$ecdsa_struct['roffset'] = ($ecdsa_struct['rlen'] == '21') ? 2 : 0;
$signature = substr($signature, 2);
$ecdsa_struct['r'] = substr($signature, $ecdsa_struct['roffset'], 64);
$this->RangeCheck($ecdsa_struct['r']);
$signature = substr($signature, $ecdsa_struct['roffset'] + 64);
$ecdsa_struct['stype'] = substr($signature, 0, 2);
$this->derDataTypeCheck($ecdsa_struct['stype']);
$signature = substr($signature, 2);
$ecdsa_struct['slen'] = substr($signature, 0, 2);
$this->derDataLenCheck($ecdsa_struct['slen']);
$ecdsa_struct['soffset'] = ($ecdsa_struct['slen'] == '21') ? 2 : 0;
$signature = substr($signature, 2);
$ecdsa_struct['s'] = substr($signature, $ecdsa_struct['soffset'], 64);
$this->RangeCheck($ecdsa_struct['r']);
return array(
'r' => $ecdsa_struct['r'],
's' => $ecdsa_struct['s']
);
}
|
php
|
private function parseSig($signature)
{
$signature = trim($signature);
/* This is the main structure we'll use for storing our parsed signature. */
$ecdsa_struct = array(
'sigstart' => '',
'siglen' => '',
'rtype' => '',
'rlen' => '',
'roffset' => 0,
'r' => '',
'stype' => '',
'slen' => '',
'soffset' => 0,
's' => '',
'original' => '',
'totallen' => 0
);
$ecdsa_struct['original'] = $signature;
$ecdsa_struct['totallen'] = strlen($signature);
$this->ecdsaSigTotalLenCheck($ecdsa_struct['totallen']);
$ecdsa_struct['sigstart'] = substr($signature, 0, 2);
$this->derRecordStartCheck($ecdsa_struct['sigstart']);
$signature = substr($signature, 2);
$ecdsa_struct['siglen'] = substr($signature, 0, 2);
$this->derRecordTotalLenCheck($ecdsa_struct['siglen']);
$signature = substr($signature, 2);
$ecdsa_struct['rtype'] = substr($signature, 0, 2);
$this->derDataTypeCheck($ecdsa_struct['rtype']);
$signature = substr($signature, 2);
$ecdsa_struct['rlen'] = substr($signature, 0, 2);
$this->derDataLenCheck($ecdsa_struct['rlen']);
$ecdsa_struct['roffset'] = ($ecdsa_struct['rlen'] == '21') ? 2 : 0;
$signature = substr($signature, 2);
$ecdsa_struct['r'] = substr($signature, $ecdsa_struct['roffset'], 64);
$this->RangeCheck($ecdsa_struct['r']);
$signature = substr($signature, $ecdsa_struct['roffset'] + 64);
$ecdsa_struct['stype'] = substr($signature, 0, 2);
$this->derDataTypeCheck($ecdsa_struct['stype']);
$signature = substr($signature, 2);
$ecdsa_struct['slen'] = substr($signature, 0, 2);
$this->derDataLenCheck($ecdsa_struct['slen']);
$ecdsa_struct['soffset'] = ($ecdsa_struct['slen'] == '21') ? 2 : 0;
$signature = substr($signature, 2);
$ecdsa_struct['s'] = substr($signature, $ecdsa_struct['soffset'], 64);
$this->RangeCheck($ecdsa_struct['r']);
return array(
'r' => $ecdsa_struct['r'],
's' => $ecdsa_struct['s']
);
}
|
[
"private",
"function",
"parseSig",
"(",
"$",
"signature",
")",
"{",
"$",
"signature",
"=",
"trim",
"(",
"$",
"signature",
")",
";",
"/* This is the main structure we'll use for storing our parsed signature. */",
"$",
"ecdsa_struct",
"=",
"array",
"(",
"'sigstart'",
"=>",
"''",
",",
"'siglen'",
"=>",
"''",
",",
"'rtype'",
"=>",
"''",
",",
"'rlen'",
"=>",
"''",
",",
"'roffset'",
"=>",
"0",
",",
"'r'",
"=>",
"''",
",",
"'stype'",
"=>",
"''",
",",
"'slen'",
"=>",
"''",
",",
"'soffset'",
"=>",
"0",
",",
"'s'",
"=>",
"''",
",",
"'original'",
"=>",
"''",
",",
"'totallen'",
"=>",
"0",
")",
";",
"$",
"ecdsa_struct",
"[",
"'original'",
"]",
"=",
"$",
"signature",
";",
"$",
"ecdsa_struct",
"[",
"'totallen'",
"]",
"=",
"strlen",
"(",
"$",
"signature",
")",
";",
"$",
"this",
"->",
"ecdsaSigTotalLenCheck",
"(",
"$",
"ecdsa_struct",
"[",
"'totallen'",
"]",
")",
";",
"$",
"ecdsa_struct",
"[",
"'sigstart'",
"]",
"=",
"substr",
"(",
"$",
"signature",
",",
"0",
",",
"2",
")",
";",
"$",
"this",
"->",
"derRecordStartCheck",
"(",
"$",
"ecdsa_struct",
"[",
"'sigstart'",
"]",
")",
";",
"$",
"signature",
"=",
"substr",
"(",
"$",
"signature",
",",
"2",
")",
";",
"$",
"ecdsa_struct",
"[",
"'siglen'",
"]",
"=",
"substr",
"(",
"$",
"signature",
",",
"0",
",",
"2",
")",
";",
"$",
"this",
"->",
"derRecordTotalLenCheck",
"(",
"$",
"ecdsa_struct",
"[",
"'siglen'",
"]",
")",
";",
"$",
"signature",
"=",
"substr",
"(",
"$",
"signature",
",",
"2",
")",
";",
"$",
"ecdsa_struct",
"[",
"'rtype'",
"]",
"=",
"substr",
"(",
"$",
"signature",
",",
"0",
",",
"2",
")",
";",
"$",
"this",
"->",
"derDataTypeCheck",
"(",
"$",
"ecdsa_struct",
"[",
"'rtype'",
"]",
")",
";",
"$",
"signature",
"=",
"substr",
"(",
"$",
"signature",
",",
"2",
")",
";",
"$",
"ecdsa_struct",
"[",
"'rlen'",
"]",
"=",
"substr",
"(",
"$",
"signature",
",",
"0",
",",
"2",
")",
";",
"$",
"this",
"->",
"derDataLenCheck",
"(",
"$",
"ecdsa_struct",
"[",
"'rlen'",
"]",
")",
";",
"$",
"ecdsa_struct",
"[",
"'roffset'",
"]",
"=",
"(",
"$",
"ecdsa_struct",
"[",
"'rlen'",
"]",
"==",
"'21'",
")",
"?",
"2",
":",
"0",
";",
"$",
"signature",
"=",
"substr",
"(",
"$",
"signature",
",",
"2",
")",
";",
"$",
"ecdsa_struct",
"[",
"'r'",
"]",
"=",
"substr",
"(",
"$",
"signature",
",",
"$",
"ecdsa_struct",
"[",
"'roffset'",
"]",
",",
"64",
")",
";",
"$",
"this",
"->",
"RangeCheck",
"(",
"$",
"ecdsa_struct",
"[",
"'r'",
"]",
")",
";",
"$",
"signature",
"=",
"substr",
"(",
"$",
"signature",
",",
"$",
"ecdsa_struct",
"[",
"'roffset'",
"]",
"+",
"64",
")",
";",
"$",
"ecdsa_struct",
"[",
"'stype'",
"]",
"=",
"substr",
"(",
"$",
"signature",
",",
"0",
",",
"2",
")",
";",
"$",
"this",
"->",
"derDataTypeCheck",
"(",
"$",
"ecdsa_struct",
"[",
"'stype'",
"]",
")",
";",
"$",
"signature",
"=",
"substr",
"(",
"$",
"signature",
",",
"2",
")",
";",
"$",
"ecdsa_struct",
"[",
"'slen'",
"]",
"=",
"substr",
"(",
"$",
"signature",
",",
"0",
",",
"2",
")",
";",
"$",
"this",
"->",
"derDataLenCheck",
"(",
"$",
"ecdsa_struct",
"[",
"'slen'",
"]",
")",
";",
"$",
"ecdsa_struct",
"[",
"'soffset'",
"]",
"=",
"(",
"$",
"ecdsa_struct",
"[",
"'slen'",
"]",
"==",
"'21'",
")",
"?",
"2",
":",
"0",
";",
"$",
"signature",
"=",
"substr",
"(",
"$",
"signature",
",",
"2",
")",
";",
"$",
"ecdsa_struct",
"[",
"'s'",
"]",
"=",
"substr",
"(",
"$",
"signature",
",",
"$",
"ecdsa_struct",
"[",
"'soffset'",
"]",
",",
"64",
")",
";",
"$",
"this",
"->",
"RangeCheck",
"(",
"$",
"ecdsa_struct",
"[",
"'r'",
"]",
")",
";",
"return",
"array",
"(",
"'r'",
"=>",
"$",
"ecdsa_struct",
"[",
"'r'",
"]",
",",
"'s'",
"=>",
"$",
"ecdsa_struct",
"[",
"'s'",
"]",
")",
";",
"}"
] |
Parses a ECDSA signature to retrieve the r and s coordinate pair. Used to verify a point.
@param string $signature The ECDSA signature to parse.
@return array The r and s coordinates.
|
[
"Parses",
"a",
"ECDSA",
"signature",
"to",
"retrieve",
"the",
"r",
"and",
"s",
"coordinate",
"pair",
".",
"Used",
"to",
"verify",
"a",
"point",
"."
] |
667064d3930e043fd78abed9a2324aee52466fa5
|
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Signature.php#L265-L337
|
233,152
|
ionux/phactor
|
src/Signature.php
|
Signature.generateFromConstructor
|
private function generateFromConstructor($message, $private_key)
{
if (empty($message) === false && empty($private_key) === false) {
$this->Generate($message, $private_key);
}
}
|
php
|
private function generateFromConstructor($message, $private_key)
{
if (empty($message) === false && empty($private_key) === false) {
$this->Generate($message, $private_key);
}
}
|
[
"private",
"function",
"generateFromConstructor",
"(",
"$",
"message",
",",
"$",
"private_key",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"message",
")",
"===",
"false",
"&&",
"empty",
"(",
"$",
"private_key",
")",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"Generate",
"(",
"$",
"message",
",",
"$",
"private_key",
")",
";",
"}",
"}"
] |
Called to generate a signature if values are passed to the constructor.
@param string $message The message to sign.
@param string $private_key The signer's private key.
|
[
"Called",
"to",
"generate",
"a",
"signature",
"if",
"values",
"are",
"passed",
"to",
"the",
"constructor",
"."
] |
667064d3930e043fd78abed9a2324aee52466fa5
|
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Signature.php#L410-L415
|
233,153
|
stanislav-web/phalcon-translate
|
src/Translate/Translator.php
|
Translator.assign
|
public function assign($signature) {
$file = $this->path.$this->language.DIRECTORY_SEPARATOR.$signature.'.php';
// content does not loaded yet
if(isset($this->required[$file]) === false) {
if (file_exists($file) === true) {
$content = include $file;
$this->required[$file] = true;
}
else {
// set default path by default language
$file = $this->path.$this->default.DIRECTORY_SEPARATOR.$signature.'.php';
if (file_exists($file) === true) {
$content = include $file;
$this->required[$file] = true;
}
}
// assign to translate
$this->adapter = new TranslateAdapterArray(['content' => [
$signature => (isset($content)) ? $content : false
]]);
}
// $this->adapter->offsetGet() was thrown error with Phalcon 2.0 (??)
$reflection = new \ReflectionClass($this->adapter);
$property = $reflection->getProperty('_translate');
$property->setAccessible(true);
//$this->signature = $this->adapter->offsetGet($signature);
// setup signature
$this->signature = $property->getValue($this->adapter)[$signature];
return $this;
}
|
php
|
public function assign($signature) {
$file = $this->path.$this->language.DIRECTORY_SEPARATOR.$signature.'.php';
// content does not loaded yet
if(isset($this->required[$file]) === false) {
if (file_exists($file) === true) {
$content = include $file;
$this->required[$file] = true;
}
else {
// set default path by default language
$file = $this->path.$this->default.DIRECTORY_SEPARATOR.$signature.'.php';
if (file_exists($file) === true) {
$content = include $file;
$this->required[$file] = true;
}
}
// assign to translate
$this->adapter = new TranslateAdapterArray(['content' => [
$signature => (isset($content)) ? $content : false
]]);
}
// $this->adapter->offsetGet() was thrown error with Phalcon 2.0 (??)
$reflection = new \ReflectionClass($this->adapter);
$property = $reflection->getProperty('_translate');
$property->setAccessible(true);
//$this->signature = $this->adapter->offsetGet($signature);
// setup signature
$this->signature = $property->getValue($this->adapter)[$signature];
return $this;
}
|
[
"public",
"function",
"assign",
"(",
"$",
"signature",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"path",
".",
"$",
"this",
"->",
"language",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"signature",
".",
"'.php'",
";",
"// content does not loaded yet",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"required",
"[",
"$",
"file",
"]",
")",
"===",
"false",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"file",
")",
"===",
"true",
")",
"{",
"$",
"content",
"=",
"include",
"$",
"file",
";",
"$",
"this",
"->",
"required",
"[",
"$",
"file",
"]",
"=",
"true",
";",
"}",
"else",
"{",
"// set default path by default language",
"$",
"file",
"=",
"$",
"this",
"->",
"path",
".",
"$",
"this",
"->",
"default",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"signature",
".",
"'.php'",
";",
"if",
"(",
"file_exists",
"(",
"$",
"file",
")",
"===",
"true",
")",
"{",
"$",
"content",
"=",
"include",
"$",
"file",
";",
"$",
"this",
"->",
"required",
"[",
"$",
"file",
"]",
"=",
"true",
";",
"}",
"}",
"// assign to translate",
"$",
"this",
"->",
"adapter",
"=",
"new",
"TranslateAdapterArray",
"(",
"[",
"'content'",
"=>",
"[",
"$",
"signature",
"=>",
"(",
"isset",
"(",
"$",
"content",
")",
")",
"?",
"$",
"content",
":",
"false",
"]",
"]",
")",
";",
"}",
"// $this->adapter->offsetGet() was thrown error with Phalcon 2.0 (??)",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"this",
"->",
"adapter",
")",
";",
"$",
"property",
"=",
"$",
"reflection",
"->",
"getProperty",
"(",
"'_translate'",
")",
";",
"$",
"property",
"->",
"setAccessible",
"(",
"true",
")",
";",
"//$this->signature = $this->adapter->offsetGet($signature);",
"// setup signature",
"$",
"this",
"->",
"signature",
"=",
"$",
"property",
"->",
"getValue",
"(",
"$",
"this",
"->",
"adapter",
")",
"[",
"$",
"signature",
"]",
";",
"return",
"$",
"this",
";",
"}"
] |
Assign content to loaded translate file
@param string $signature
@throws Exception
@return Translator
|
[
"Assign",
"content",
"to",
"loaded",
"translate",
"file"
] |
aadd56d87553274d316a8db9ebb2ec921cf43160
|
https://github.com/stanislav-web/phalcon-translate/blob/aadd56d87553274d316a8db9ebb2ec921cf43160/src/Translate/Translator.php#L97-L135
|
233,154
|
stanislav-web/phalcon-translate
|
src/Translate/Translator.php
|
Translator.translate
|
public function translate($string) {
// get selected signature
if(empty($this->signature) === false) {
if (array_key_exists($string, $this->signature) === false) {
return $string;
}
return $this->signature[$string];
}
else {
throw new Exception('Could not find translate signature');
}
}
|
php
|
public function translate($string) {
// get selected signature
if(empty($this->signature) === false) {
if (array_key_exists($string, $this->signature) === false) {
return $string;
}
return $this->signature[$string];
}
else {
throw new Exception('Could not find translate signature');
}
}
|
[
"public",
"function",
"translate",
"(",
"$",
"string",
")",
"{",
"// get selected signature",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"signature",
")",
"===",
"false",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"string",
",",
"$",
"this",
"->",
"signature",
")",
"===",
"false",
")",
"{",
"return",
"$",
"string",
";",
"}",
"return",
"$",
"this",
"->",
"signature",
"[",
"$",
"string",
"]",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"'Could not find translate signature'",
")",
";",
"}",
"}"
] |
Translate original string
@param $string
@throws Exception
@return string
|
[
"Translate",
"original",
"string"
] |
aadd56d87553274d316a8db9ebb2ec921cf43160
|
https://github.com/stanislav-web/phalcon-translate/blob/aadd56d87553274d316a8db9ebb2ec921cf43160/src/Translate/Translator.php#L156-L169
|
233,155
|
kgilden/php-digidoc
|
src/Envelope.php
|
Envelope.addFile
|
public function addFile($pathOrFile)
{
$file = is_string($pathOrFile) ? new File($pathOrFile) : $pathOrFile;
if (!($file instanceof File)) {
throw new UnexpectedTypeException('string" or "\KG\DigiDoc\File', $file);
}
$this->getFiles()->add($file);
}
|
php
|
public function addFile($pathOrFile)
{
$file = is_string($pathOrFile) ? new File($pathOrFile) : $pathOrFile;
if (!($file instanceof File)) {
throw new UnexpectedTypeException('string" or "\KG\DigiDoc\File', $file);
}
$this->getFiles()->add($file);
}
|
[
"public",
"function",
"addFile",
"(",
"$",
"pathOrFile",
")",
"{",
"$",
"file",
"=",
"is_string",
"(",
"$",
"pathOrFile",
")",
"?",
"new",
"File",
"(",
"$",
"pathOrFile",
")",
":",
"$",
"pathOrFile",
";",
"if",
"(",
"!",
"(",
"$",
"file",
"instanceof",
"File",
")",
")",
"{",
"throw",
"new",
"UnexpectedTypeException",
"(",
"'string\" or \"\\KG\\DigiDoc\\File'",
",",
"$",
"file",
")",
";",
"}",
"$",
"this",
"->",
"getFiles",
"(",
")",
"->",
"add",
"(",
"$",
"file",
")",
";",
"}"
] |
Adds a new file to the envelope. NB! Files cannot be added once the
envelope has at least 1 signature.
@param string|File $pathOrFile
|
[
"Adds",
"a",
"new",
"file",
"to",
"the",
"envelope",
".",
"NB!",
"Files",
"cannot",
"be",
"added",
"once",
"the",
"envelope",
"has",
"at",
"least",
"1",
"signature",
"."
] |
88112ba05688fc1d32c0ff948cb8e1f4d2f264d3
|
https://github.com/kgilden/php-digidoc/blob/88112ba05688fc1d32c0ff948cb8e1f4d2f264d3/src/Envelope.php#L61-L70
|
233,156
|
kgilden/php-digidoc
|
src/Envelope.php
|
Envelope.getSignature
|
public function getSignature($signatureId)
{
foreach ($this->getSignatures() as $signature) {
if ($signature->getId() === $signatureId) {
return $signature;
}
}
}
|
php
|
public function getSignature($signatureId)
{
foreach ($this->getSignatures() as $signature) {
if ($signature->getId() === $signatureId) {
return $signature;
}
}
}
|
[
"public",
"function",
"getSignature",
"(",
"$",
"signatureId",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getSignatures",
"(",
")",
"as",
"$",
"signature",
")",
"{",
"if",
"(",
"$",
"signature",
"->",
"getId",
"(",
")",
"===",
"$",
"signatureId",
")",
"{",
"return",
"$",
"signature",
";",
"}",
"}",
"}"
] |
Gets a signature given it's id in the envelope.
@param string $signatureId The signature id (e.g. "S01")
@return Signature|null The found signature or null, if no match was found
|
[
"Gets",
"a",
"signature",
"given",
"it",
"s",
"id",
"in",
"the",
"envelope",
"."
] |
88112ba05688fc1d32c0ff948cb8e1f4d2f264d3
|
https://github.com/kgilden/php-digidoc/blob/88112ba05688fc1d32c0ff948cb8e1f4d2f264d3/src/Envelope.php#L105-L112
|
233,157
|
sulu/SuluAutomationBundle
|
Tasks/Scheduler/TaskScheduler.php
|
TaskScheduler.scheduleTask
|
private function scheduleTask(TaskInterface $task, array $workload)
{
return $this->taskScheduler->createTask($task->getHandlerClass(), $workload)
->executeAt($task->getSchedule())
->schedule();
}
|
php
|
private function scheduleTask(TaskInterface $task, array $workload)
{
return $this->taskScheduler->createTask($task->getHandlerClass(), $workload)
->executeAt($task->getSchedule())
->schedule();
}
|
[
"private",
"function",
"scheduleTask",
"(",
"TaskInterface",
"$",
"task",
",",
"array",
"$",
"workload",
")",
"{",
"return",
"$",
"this",
"->",
"taskScheduler",
"->",
"createTask",
"(",
"$",
"task",
"->",
"getHandlerClass",
"(",
")",
",",
"$",
"workload",
")",
"->",
"executeAt",
"(",
"$",
"task",
"->",
"getSchedule",
"(",
")",
")",
"->",
"schedule",
"(",
")",
";",
"}"
] |
Schedule php-task.
@param TaskInterface $task
@param array $workload
@return PHPTaskInterface
|
[
"Schedule",
"php",
"-",
"task",
"."
] |
2cfc3a7122a96939d2f203f6fe54bcb74e2cfd46
|
https://github.com/sulu/SuluAutomationBundle/blob/2cfc3a7122a96939d2f203f6fe54bcb74e2cfd46/Tasks/Scheduler/TaskScheduler.php#L121-L126
|
233,158
|
sulu/SuluAutomationBundle
|
Tasks/Scheduler/TaskScheduler.php
|
TaskScheduler.createWorkload
|
private function createWorkload(TaskInterface $task)
{
// TODO get from additional form of handler
$workload = [];
$optionsResolver = new OptionsResolver();
$optionsResolver->setDefaults(
[
'class' => $task->getEntityClass(),
'id' => $task->getEntityId(),
'locale' => $task->getLocale(),
]
);
$handler = $this->taskHandlerFactory->create($task->getHandlerClass());
if (!$handler instanceof AutomationTaskHandlerInterface) {
throw new TaskHandlerNotSupportedException($handler, $task);
}
$optionsResolver = $handler->configureOptionsResolver($optionsResolver);
return $optionsResolver->resolve($workload);
}
|
php
|
private function createWorkload(TaskInterface $task)
{
// TODO get from additional form of handler
$workload = [];
$optionsResolver = new OptionsResolver();
$optionsResolver->setDefaults(
[
'class' => $task->getEntityClass(),
'id' => $task->getEntityId(),
'locale' => $task->getLocale(),
]
);
$handler = $this->taskHandlerFactory->create($task->getHandlerClass());
if (!$handler instanceof AutomationTaskHandlerInterface) {
throw new TaskHandlerNotSupportedException($handler, $task);
}
$optionsResolver = $handler->configureOptionsResolver($optionsResolver);
return $optionsResolver->resolve($workload);
}
|
[
"private",
"function",
"createWorkload",
"(",
"TaskInterface",
"$",
"task",
")",
"{",
"// TODO get from additional form of handler",
"$",
"workload",
"=",
"[",
"]",
";",
"$",
"optionsResolver",
"=",
"new",
"OptionsResolver",
"(",
")",
";",
"$",
"optionsResolver",
"->",
"setDefaults",
"(",
"[",
"'class'",
"=>",
"$",
"task",
"->",
"getEntityClass",
"(",
")",
",",
"'id'",
"=>",
"$",
"task",
"->",
"getEntityId",
"(",
")",
",",
"'locale'",
"=>",
"$",
"task",
"->",
"getLocale",
"(",
")",
",",
"]",
")",
";",
"$",
"handler",
"=",
"$",
"this",
"->",
"taskHandlerFactory",
"->",
"create",
"(",
"$",
"task",
"->",
"getHandlerClass",
"(",
")",
")",
";",
"if",
"(",
"!",
"$",
"handler",
"instanceof",
"AutomationTaskHandlerInterface",
")",
"{",
"throw",
"new",
"TaskHandlerNotSupportedException",
"(",
"$",
"handler",
",",
"$",
"task",
")",
";",
"}",
"$",
"optionsResolver",
"=",
"$",
"handler",
"->",
"configureOptionsResolver",
"(",
"$",
"optionsResolver",
")",
";",
"return",
"$",
"optionsResolver",
"->",
"resolve",
"(",
"$",
"workload",
")",
";",
"}"
] |
Create and validate workload for given task.
@param TaskInterface $task
@return array
@throws TaskHandlerNotSupportedException
|
[
"Create",
"and",
"validate",
"workload",
"for",
"given",
"task",
"."
] |
2cfc3a7122a96939d2f203f6fe54bcb74e2cfd46
|
https://github.com/sulu/SuluAutomationBundle/blob/2cfc3a7122a96939d2f203f6fe54bcb74e2cfd46/Tasks/Scheduler/TaskScheduler.php#L137-L159
|
233,159
|
CampaignChain/core
|
EventListener/EntryPoint.php
|
EntryPoint.start
|
public function start(Request $request, AuthenticationException $authException = null)
{
// AJAX request?
if ($request->isXmlHttpRequest()) {
return new JsonResponse('', Response::HTTP_UNAUTHORIZED);
}
return new RedirectResponse($this->router->generate('fos_user_security_login'));
}
|
php
|
public function start(Request $request, AuthenticationException $authException = null)
{
// AJAX request?
if ($request->isXmlHttpRequest()) {
return new JsonResponse('', Response::HTTP_UNAUTHORIZED);
}
return new RedirectResponse($this->router->generate('fos_user_security_login'));
}
|
[
"public",
"function",
"start",
"(",
"Request",
"$",
"request",
",",
"AuthenticationException",
"$",
"authException",
"=",
"null",
")",
"{",
"// AJAX request?",
"if",
"(",
"$",
"request",
"->",
"isXmlHttpRequest",
"(",
")",
")",
"{",
"return",
"new",
"JsonResponse",
"(",
"''",
",",
"Response",
"::",
"HTTP_UNAUTHORIZED",
")",
";",
"}",
"return",
"new",
"RedirectResponse",
"(",
"$",
"this",
"->",
"router",
"->",
"generate",
"(",
"'fos_user_security_login'",
")",
")",
";",
"}"
] |
Checks prior to creating a new session whether the request is an AJAX
request. If so, then we issue a 401 error to avoid that the AJAX returns
the login page as the response. The AJAX request would handle the 401
by redirecting to the login page. If not an AJAX request, we automatically
go to the login page.
@param Request $request
@param AuthenticationException|null $authException
@return JsonResponse|RedirectResponse
|
[
"Checks",
"prior",
"to",
"creating",
"a",
"new",
"session",
"whether",
"the",
"request",
"is",
"an",
"AJAX",
"request",
".",
"If",
"so",
"then",
"we",
"issue",
"a",
"401",
"error",
"to",
"avoid",
"that",
"the",
"AJAX",
"returns",
"the",
"login",
"page",
"as",
"the",
"response",
".",
"The",
"AJAX",
"request",
"would",
"handle",
"the",
"401",
"by",
"redirecting",
"to",
"the",
"login",
"page",
".",
"If",
"not",
"an",
"AJAX",
"request",
"we",
"automatically",
"go",
"to",
"the",
"login",
"page",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/EventListener/EntryPoint.php#L52-L60
|
233,160
|
CampaignChain/core
|
EventListener/UserDateTimeListener.php
|
UserDateTimeListener.storeDateTimeSettingsInSession
|
protected function storeDateTimeSettingsInSession(UserInterface $user, SessionInterface $session)
{
$session->set('campaignchain.locale', $user->getLocale());
$session->set('campaignchain.timezone', $user->getTimezone());
$session->set('campaignchain.dateFormat', $user->getDateFormat());
$session->set('campaignchain.timeFormat', $user->getTimeFormat());
}
|
php
|
protected function storeDateTimeSettingsInSession(UserInterface $user, SessionInterface $session)
{
$session->set('campaignchain.locale', $user->getLocale());
$session->set('campaignchain.timezone', $user->getTimezone());
$session->set('campaignchain.dateFormat', $user->getDateFormat());
$session->set('campaignchain.timeFormat', $user->getTimeFormat());
}
|
[
"protected",
"function",
"storeDateTimeSettingsInSession",
"(",
"UserInterface",
"$",
"user",
",",
"SessionInterface",
"$",
"session",
")",
"{",
"$",
"session",
"->",
"set",
"(",
"'campaignchain.locale'",
",",
"$",
"user",
"->",
"getLocale",
"(",
")",
")",
";",
"$",
"session",
"->",
"set",
"(",
"'campaignchain.timezone'",
",",
"$",
"user",
"->",
"getTimezone",
"(",
")",
")",
";",
"$",
"session",
"->",
"set",
"(",
"'campaignchain.dateFormat'",
",",
"$",
"user",
"->",
"getDateFormat",
"(",
")",
")",
";",
"$",
"session",
"->",
"set",
"(",
"'campaignchain.timeFormat'",
",",
"$",
"user",
"->",
"getTimeFormat",
"(",
")",
")",
";",
"}"
] |
Make user date and time settings sticky
@param UserInterface $user
@param SessionInterface $session
|
[
"Make",
"user",
"date",
"and",
"time",
"settings",
"sticky"
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/EventListener/UserDateTimeListener.php#L88-L94
|
233,161
|
yeriomin/getopt
|
src/Yeriomin/Getopt/UsageProvider.php
|
UsageProvider.getUsageMessage
|
public function getUsageMessage()
{
if (empty($this->scriptName)) {
throw new GetoptException('Script name can not be empty');
}
$helpText = 'Usage: ' . $this->scriptName . ' '
. $this->argumentsDescription . "\n\n" . 'Options:' ."\n"
;
$args = array();
$charCount = 0;
foreach ($this->optionDefinitions as $option) {
$arg = $this->getOptionString($option);
$charCount = $charCount < strlen($arg) ? strlen($arg) : $charCount;
$args[$arg] = $option->getDescription();
}
foreach ($args as $arg => $description) {
$helpText .= str_pad($arg, $charCount + 1) . $description . "\n";
}
return $helpText;
}
|
php
|
public function getUsageMessage()
{
if (empty($this->scriptName)) {
throw new GetoptException('Script name can not be empty');
}
$helpText = 'Usage: ' . $this->scriptName . ' '
. $this->argumentsDescription . "\n\n" . 'Options:' ."\n"
;
$args = array();
$charCount = 0;
foreach ($this->optionDefinitions as $option) {
$arg = $this->getOptionString($option);
$charCount = $charCount < strlen($arg) ? strlen($arg) : $charCount;
$args[$arg] = $option->getDescription();
}
foreach ($args as $arg => $description) {
$helpText .= str_pad($arg, $charCount + 1) . $description . "\n";
}
return $helpText;
}
|
[
"public",
"function",
"getUsageMessage",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"scriptName",
")",
")",
"{",
"throw",
"new",
"GetoptException",
"(",
"'Script name can not be empty'",
")",
";",
"}",
"$",
"helpText",
"=",
"'Usage: '",
".",
"$",
"this",
"->",
"scriptName",
".",
"' '",
".",
"$",
"this",
"->",
"argumentsDescription",
".",
"\"\\n\\n\"",
".",
"'Options:'",
".",
"\"\\n\"",
";",
"$",
"args",
"=",
"array",
"(",
")",
";",
"$",
"charCount",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"optionDefinitions",
"as",
"$",
"option",
")",
"{",
"$",
"arg",
"=",
"$",
"this",
"->",
"getOptionString",
"(",
"$",
"option",
")",
";",
"$",
"charCount",
"=",
"$",
"charCount",
"<",
"strlen",
"(",
"$",
"arg",
")",
"?",
"strlen",
"(",
"$",
"arg",
")",
":",
"$",
"charCount",
";",
"$",
"args",
"[",
"$",
"arg",
"]",
"=",
"$",
"option",
"->",
"getDescription",
"(",
")",
";",
"}",
"foreach",
"(",
"$",
"args",
"as",
"$",
"arg",
"=>",
"$",
"description",
")",
"{",
"$",
"helpText",
".=",
"str_pad",
"(",
"$",
"arg",
",",
"$",
"charCount",
"+",
"1",
")",
".",
"$",
"description",
".",
"\"\\n\"",
";",
"}",
"return",
"$",
"helpText",
";",
"}"
] |
Get usage message
@return string
|
[
"Get",
"usage",
"message"
] |
0b86fca451799e594aab7bc04a399a8f15d3119d
|
https://github.com/yeriomin/getopt/blob/0b86fca451799e594aab7bc04a399a8f15d3119d/src/Yeriomin/Getopt/UsageProvider.php#L80-L99
|
233,162
|
yeriomin/getopt
|
src/Yeriomin/Getopt/UsageProvider.php
|
UsageProvider.getOptionString
|
private function getOptionString(OptionDefinition $option)
{
$short = $option->getShort();
$long = $option->getLong();
$result = ' ';
if ($short !== null && $long !== null) {
$result .= '-' . $short . ', --' . $long;
} else {
$result .= $short !== null ? '-' . $short : '--' . $long;
}
return $result;
}
|
php
|
private function getOptionString(OptionDefinition $option)
{
$short = $option->getShort();
$long = $option->getLong();
$result = ' ';
if ($short !== null && $long !== null) {
$result .= '-' . $short . ', --' . $long;
} else {
$result .= $short !== null ? '-' . $short : '--' . $long;
}
return $result;
}
|
[
"private",
"function",
"getOptionString",
"(",
"OptionDefinition",
"$",
"option",
")",
"{",
"$",
"short",
"=",
"$",
"option",
"->",
"getShort",
"(",
")",
";",
"$",
"long",
"=",
"$",
"option",
"->",
"getLong",
"(",
")",
";",
"$",
"result",
"=",
"' '",
";",
"if",
"(",
"$",
"short",
"!==",
"null",
"&&",
"$",
"long",
"!==",
"null",
")",
"{",
"$",
"result",
".=",
"'-'",
".",
"$",
"short",
".",
"', --'",
".",
"$",
"long",
";",
"}",
"else",
"{",
"$",
"result",
".=",
"$",
"short",
"!==",
"null",
"?",
"'-'",
".",
"$",
"short",
":",
"'--'",
".",
"$",
"long",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Get a human-readable string definition of an option
@param \Yeriomin\Getopt\OptionDefinition $option
@return string
|
[
"Get",
"a",
"human",
"-",
"readable",
"string",
"definition",
"of",
"an",
"option"
] |
0b86fca451799e594aab7bc04a399a8f15d3119d
|
https://github.com/yeriomin/getopt/blob/0b86fca451799e594aab7bc04a399a8f15d3119d/src/Yeriomin/Getopt/UsageProvider.php#L107-L118
|
233,163
|
CampaignChain/core
|
EventListener/ConsoleExceptionListener.php
|
ConsoleExceptionListener.onConsoleException
|
public function onConsoleException(ConsoleExceptionEvent $event)
{
/** @var SchedulerCommand $command */
$command = $event->getCommand();
if ($command->getName() != 'campaignchain:scheduler') {
return;
}
// if scheduler is null exception happened in early stage
// maybe email should be sent
if (!$command->getScheduler()) {
return;
}
/** @var Scheduler $scheduler */
$scheduler = $command->getScheduler();
$scheduler->setMessage($event->getException()->getMessage());
$scheduler->setStatus(Scheduler::STATUS_ERROR);
$scheduler->setExecutionEnd(new \DateTime());
$this->em->persist($scheduler);
$this->em->flush();
$command->getIo()->error($scheduler->getMessage());
$this->logger->critical($scheduler->getMessage());
}
|
php
|
public function onConsoleException(ConsoleExceptionEvent $event)
{
/** @var SchedulerCommand $command */
$command = $event->getCommand();
if ($command->getName() != 'campaignchain:scheduler') {
return;
}
// if scheduler is null exception happened in early stage
// maybe email should be sent
if (!$command->getScheduler()) {
return;
}
/** @var Scheduler $scheduler */
$scheduler = $command->getScheduler();
$scheduler->setMessage($event->getException()->getMessage());
$scheduler->setStatus(Scheduler::STATUS_ERROR);
$scheduler->setExecutionEnd(new \DateTime());
$this->em->persist($scheduler);
$this->em->flush();
$command->getIo()->error($scheduler->getMessage());
$this->logger->critical($scheduler->getMessage());
}
|
[
"public",
"function",
"onConsoleException",
"(",
"ConsoleExceptionEvent",
"$",
"event",
")",
"{",
"/** @var SchedulerCommand $command */",
"$",
"command",
"=",
"$",
"event",
"->",
"getCommand",
"(",
")",
";",
"if",
"(",
"$",
"command",
"->",
"getName",
"(",
")",
"!=",
"'campaignchain:scheduler'",
")",
"{",
"return",
";",
"}",
"// if scheduler is null exception happened in early stage",
"// maybe email should be sent",
"if",
"(",
"!",
"$",
"command",
"->",
"getScheduler",
"(",
")",
")",
"{",
"return",
";",
"}",
"/** @var Scheduler $scheduler */",
"$",
"scheduler",
"=",
"$",
"command",
"->",
"getScheduler",
"(",
")",
";",
"$",
"scheduler",
"->",
"setMessage",
"(",
"$",
"event",
"->",
"getException",
"(",
")",
"->",
"getMessage",
"(",
")",
")",
";",
"$",
"scheduler",
"->",
"setStatus",
"(",
"Scheduler",
"::",
"STATUS_ERROR",
")",
";",
"$",
"scheduler",
"->",
"setExecutionEnd",
"(",
"new",
"\\",
"DateTime",
"(",
")",
")",
";",
"$",
"this",
"->",
"em",
"->",
"persist",
"(",
"$",
"scheduler",
")",
";",
"$",
"this",
"->",
"em",
"->",
"flush",
"(",
")",
";",
"$",
"command",
"->",
"getIo",
"(",
")",
"->",
"error",
"(",
"$",
"scheduler",
"->",
"getMessage",
"(",
")",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"critical",
"(",
"$",
"scheduler",
"->",
"getMessage",
"(",
")",
")",
";",
"}"
] |
In case of an exception in scheduler console command
the message should be saved into the scheduler entity
@param ConsoleExceptionEvent $event
|
[
"In",
"case",
"of",
"an",
"exception",
"in",
"scheduler",
"console",
"command",
"the",
"message",
"should",
"be",
"saved",
"into",
"the",
"scheduler",
"entity"
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/EventListener/ConsoleExceptionListener.php#L61-L88
|
233,164
|
CampaignChain/core
|
Util/ParserUtil.php
|
ParserUtil.sanitizeUrl
|
static function sanitizeUrl($url)
{
if(
self::validateUrl($url) &&
substr($url, -1) === '/'
) {
$urlParts = parse_url($url);
if(
!isset($urlParts['path']) ||
($urlParts['path'] == '/' && !isset($urlParts['query'])) ||
(isset($urlParts['query']) && substr($urlParts['query'], -1) === '/')
){
$url = rtrim($url, '/');
}
}
return $url;
}
|
php
|
static function sanitizeUrl($url)
{
if(
self::validateUrl($url) &&
substr($url, -1) === '/'
) {
$urlParts = parse_url($url);
if(
!isset($urlParts['path']) ||
($urlParts['path'] == '/' && !isset($urlParts['query'])) ||
(isset($urlParts['query']) && substr($urlParts['query'], -1) === '/')
){
$url = rtrim($url, '/');
}
}
return $url;
}
|
[
"static",
"function",
"sanitizeUrl",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"self",
"::",
"validateUrl",
"(",
"$",
"url",
")",
"&&",
"substr",
"(",
"$",
"url",
",",
"-",
"1",
")",
"===",
"'/'",
")",
"{",
"$",
"urlParts",
"=",
"parse_url",
"(",
"$",
"url",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"urlParts",
"[",
"'path'",
"]",
")",
"||",
"(",
"$",
"urlParts",
"[",
"'path'",
"]",
"==",
"'/'",
"&&",
"!",
"isset",
"(",
"$",
"urlParts",
"[",
"'query'",
"]",
")",
")",
"||",
"(",
"isset",
"(",
"$",
"urlParts",
"[",
"'query'",
"]",
")",
"&&",
"substr",
"(",
"$",
"urlParts",
"[",
"'query'",
"]",
",",
"-",
"1",
")",
"===",
"'/'",
")",
")",
"{",
"$",
"url",
"=",
"rtrim",
"(",
"$",
"url",
",",
"'/'",
")",
";",
"}",
"}",
"return",
"$",
"url",
";",
"}"
] |
Remove trailing slash if no path included in URL.
For example:
- http://www.example.com/ <- remove
- http://www.example.com/news/ <- do not remove
- http://www.exmaple.com/?id=2/ <- remove
- http://www.example.com/?id=2 <- do not remove
@param $url
@return string
@throws \Exception
|
[
"Remove",
"trailing",
"slash",
"if",
"no",
"path",
"included",
"in",
"URL",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Util/ParserUtil.php#L266-L283
|
233,165
|
CampaignChain/core
|
Util/ParserUtil.php
|
ParserUtil.getTextLengthWithShortUrls
|
static function getTextLengthWithShortUrls($text, $shortUrlLength = 23)
{
if($shortUrlLength < 7){
throw new \Exception('URL must be at least 7 characters long.');
}
// Create dummy short URL.
$shortUrl = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, $shortUrlLength - 7);
$shortUrl = 'http://'.$shortUrl;
return mb_strlen(preg_replace(self::REGEX_URL, $shortUrl, $text), 'UTF-8');
}
|
php
|
static function getTextLengthWithShortUrls($text, $shortUrlLength = 23)
{
if($shortUrlLength < 7){
throw new \Exception('URL must be at least 7 characters long.');
}
// Create dummy short URL.
$shortUrl = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, $shortUrlLength - 7);
$shortUrl = 'http://'.$shortUrl;
return mb_strlen(preg_replace(self::REGEX_URL, $shortUrl, $text), 'UTF-8');
}
|
[
"static",
"function",
"getTextLengthWithShortUrls",
"(",
"$",
"text",
",",
"$",
"shortUrlLength",
"=",
"23",
")",
"{",
"if",
"(",
"$",
"shortUrlLength",
"<",
"7",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'URL must be at least 7 characters long.'",
")",
";",
"}",
"// Create dummy short URL.",
"$",
"shortUrl",
"=",
"substr",
"(",
"str_shuffle",
"(",
"\"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\"",
")",
",",
"0",
",",
"$",
"shortUrlLength",
"-",
"7",
")",
";",
"$",
"shortUrl",
"=",
"'http://'",
".",
"$",
"shortUrl",
";",
"return",
"mb_strlen",
"(",
"preg_replace",
"(",
"self",
"::",
"REGEX_URL",
",",
"$",
"shortUrl",
",",
"$",
"text",
")",
",",
"'UTF-8'",
")",
";",
"}"
] |
Get length of a text which includes URLs that will be shortened.
Basically, this function can be used to calculate the length of a Twitter
message.
@param $text
@param int $shortUrlLength
@return int
@throws \Exception
|
[
"Get",
"length",
"of",
"a",
"text",
"which",
"includes",
"URLs",
"that",
"will",
"be",
"shortened",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Util/ParserUtil.php#L335-L346
|
233,166
|
CampaignChain/core
|
Util/SchedulerUtil.php
|
SchedulerUtil.isDueNow
|
public function isDueNow(\DateTime $moment)
{
$startInterval = new \DateTime();
$startInterval->modify('-'.$this->schedulerInterval.' mins');
if($moment > $startInterval && $moment <= new \DateTime()){
return true;
} else {
return false;
}
}
|
php
|
public function isDueNow(\DateTime $moment)
{
$startInterval = new \DateTime();
$startInterval->modify('-'.$this->schedulerInterval.' mins');
if($moment > $startInterval && $moment <= new \DateTime()){
return true;
} else {
return false;
}
}
|
[
"public",
"function",
"isDueNow",
"(",
"\\",
"DateTime",
"$",
"moment",
")",
"{",
"$",
"startInterval",
"=",
"new",
"\\",
"DateTime",
"(",
")",
";",
"$",
"startInterval",
"->",
"modify",
"(",
"'-'",
".",
"$",
"this",
"->",
"schedulerInterval",
".",
"' mins'",
")",
";",
"if",
"(",
"$",
"moment",
">",
"$",
"startInterval",
"&&",
"$",
"moment",
"<=",
"new",
"\\",
"DateTime",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
If the post is within the scheduler's interval, then this means that
it is supposed to be published now.
@param \DateTime $moment
@return bool
|
[
"If",
"the",
"post",
"is",
"within",
"the",
"scheduler",
"s",
"interval",
"then",
"this",
"means",
"that",
"it",
"is",
"supposed",
"to",
"be",
"published",
"now",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Util/SchedulerUtil.php#L36-L45
|
233,167
|
CampaignChain/core
|
Controller/REST/ModuleController.php
|
ModuleController.getTypesMetaAction
|
public function getTypesMetaAction()
{
$typeClasses = $this->getDoctrine()->getEntityManager()->getClassMetadata('CampaignChain\CoreBundle\Entity\Module')->discriminatorMap;
return $this->response(
VariableUtil::arrayFlatten(array_keys($typeClasses))
);
}
|
php
|
public function getTypesMetaAction()
{
$typeClasses = $this->getDoctrine()->getEntityManager()->getClassMetadata('CampaignChain\CoreBundle\Entity\Module')->discriminatorMap;
return $this->response(
VariableUtil::arrayFlatten(array_keys($typeClasses))
);
}
|
[
"public",
"function",
"getTypesMetaAction",
"(",
")",
"{",
"$",
"typeClasses",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getEntityManager",
"(",
")",
"->",
"getClassMetadata",
"(",
"'CampaignChain\\CoreBundle\\Entity\\Module'",
")",
"->",
"discriminatorMap",
";",
"return",
"$",
"this",
"->",
"response",
"(",
"VariableUtil",
"::",
"arrayFlatten",
"(",
"array_keys",
"(",
"$",
"typeClasses",
")",
")",
")",
";",
"}"
] |
List all available types for modules
Example Request
===============
GET /api/v1/modules/types
Example Response
================
[
"activity",
"campaign",
"channel",
"location",
"milestone",
"operation",
"report",
"security"
]
@ApiDoc(
section="Core"
)
@REST\GET("/types")
@return \Symfony\Component\HttpFoundation\Response
|
[
"List",
"all",
"available",
"types",
"for",
"modules"
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/REST/ModuleController.php#L70-L77
|
233,168
|
CampaignChain/core
|
Controller/REST/ModuleController.php
|
ModuleController.getTypesAction
|
public function getTypesAction($type)
{
$qb = $this->getQueryBuilder();
$qb->select(self::SELECT_STATEMENT);
$typeClasses = $this->getDoctrine()->getEntityManager()->getClassMetadata('CampaignChain\CoreBundle\Entity\Module')->discriminatorMap;
$qb->from($typeClasses[$type], 'm');
$qb->join('m.bundle', 'b');
$qb->where('b.id = m.bundle');
$qb->orderBy('m.identifier');
$query = $qb->getQuery();
return $this->response(
$query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY)
);
}
|
php
|
public function getTypesAction($type)
{
$qb = $this->getQueryBuilder();
$qb->select(self::SELECT_STATEMENT);
$typeClasses = $this->getDoctrine()->getEntityManager()->getClassMetadata('CampaignChain\CoreBundle\Entity\Module')->discriminatorMap;
$qb->from($typeClasses[$type], 'm');
$qb->join('m.bundle', 'b');
$qb->where('b.id = m.bundle');
$qb->orderBy('m.identifier');
$query = $qb->getQuery();
return $this->response(
$query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY)
);
}
|
[
"public",
"function",
"getTypesAction",
"(",
"$",
"type",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"getQueryBuilder",
"(",
")",
";",
"$",
"qb",
"->",
"select",
"(",
"self",
"::",
"SELECT_STATEMENT",
")",
";",
"$",
"typeClasses",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getEntityManager",
"(",
")",
"->",
"getClassMetadata",
"(",
"'CampaignChain\\CoreBundle\\Entity\\Module'",
")",
"->",
"discriminatorMap",
";",
"$",
"qb",
"->",
"from",
"(",
"$",
"typeClasses",
"[",
"$",
"type",
"]",
",",
"'m'",
")",
";",
"$",
"qb",
"->",
"join",
"(",
"'m.bundle'",
",",
"'b'",
")",
";",
"$",
"qb",
"->",
"where",
"(",
"'b.id = m.bundle'",
")",
";",
"$",
"qb",
"->",
"orderBy",
"(",
"'m.identifier'",
")",
";",
"$",
"query",
"=",
"$",
"qb",
"->",
"getQuery",
"(",
")",
";",
"return",
"$",
"this",
"->",
"response",
"(",
"$",
"query",
"->",
"getResult",
"(",
"\\",
"Doctrine",
"\\",
"ORM",
"\\",
"Query",
"::",
"HYDRATE_ARRAY",
")",
")",
";",
"}"
] |
Get all modules of same type.
Example Request
===============
GET /api/v1/modules/types/location
Example Response
================
[
{
"composerPackage": "campaignchain/location-facebook",
"moduleIdentifier": "campaignchain-facebook-page",
"displayName": "Facebook page stream",
"hooks": {
"default": {
"campaignchain-assignee": true
}
},
"createdDate": "2015-11-26T11:08:29+0000"
},
{
"composerPackage": "campaignchain/location-facebook",
"moduleIdentifier": "campaignchain-facebook-status",
"displayName": "Facebook status",
"createdDate": "2015-11-26T11:08:29+0000"
},
{
"composerPackage": "campaignchain/location-facebook",
"moduleIdentifier": "campaignchain-facebook-user",
"displayName": "Facebook user stream",
"hooks": {
"default": {
"campaignchain-assignee": true
}
},
"createdDate": "2015-11-26T11:08:29+0000"
},
{
"composerPackage": "campaignchain/location-linkedin",
"moduleIdentifier": "campaignchain-linkedin-user",
"displayName": "LinkedIn user stream",
"createdDate": "2015-11-26T11:08:29+0000"
},
{
"composerPackage": "campaignchain/location-twitter",
"moduleIdentifier": "campaignchain-twitter-status",
"displayName": "Twitter post (aka Tweet)",
"createdDate": "2015-11-26T11:08:29+0000"
},
{
"composerPackage": "campaignchain/location-twitter",
"moduleIdentifier": "campaignchain-twitter-user",
"displayName": "Twitter user stream",
"hooks": {
"default": {
"campaignchain-assignee": true
}
},
"createdDate": "2015-11-26T11:08:29+0000"
}
]
@ApiDoc(
section="Core",
requirements={
{
"name"="type",
"requirement"="(campaign|channel|location|activity|operation|report|security)"
}
}
)
@param string $type The type of a module, e.g. 'location'.
@return \Symfony\Component\HttpFoundation\Response
|
[
"Get",
"all",
"modules",
"of",
"same",
"type",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/REST/ModuleController.php#L158-L172
|
233,169
|
CampaignChain/core
|
Controller/REST/ModuleController.php
|
ModuleController.getPackagesMetaAction
|
public function getPackagesMetaAction()
{
$qb = $this->getQueryBuilder();
$qb->select("b.name");
$qb->from('CampaignChain\CoreBundle\Entity\Module', 'm');
$qb->from('CampaignChain\CoreBundle\Entity\Bundle', 'b');
$qb->where('b.id = m.bundle');
$qb->orderBy('m.identifier');
$query = $qb->getQuery();
return $this->response(
VariableUtil::arrayFlatten(
$query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY)
)
);
}
|
php
|
public function getPackagesMetaAction()
{
$qb = $this->getQueryBuilder();
$qb->select("b.name");
$qb->from('CampaignChain\CoreBundle\Entity\Module', 'm');
$qb->from('CampaignChain\CoreBundle\Entity\Bundle', 'b');
$qb->where('b.id = m.bundle');
$qb->orderBy('m.identifier');
$query = $qb->getQuery();
return $this->response(
VariableUtil::arrayFlatten(
$query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY)
)
);
}
|
[
"public",
"function",
"getPackagesMetaAction",
"(",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"getQueryBuilder",
"(",
")",
";",
"$",
"qb",
"->",
"select",
"(",
"\"b.name\"",
")",
";",
"$",
"qb",
"->",
"from",
"(",
"'CampaignChain\\CoreBundle\\Entity\\Module'",
",",
"'m'",
")",
";",
"$",
"qb",
"->",
"from",
"(",
"'CampaignChain\\CoreBundle\\Entity\\Bundle'",
",",
"'b'",
")",
";",
"$",
"qb",
"->",
"where",
"(",
"'b.id = m.bundle'",
")",
";",
"$",
"qb",
"->",
"orderBy",
"(",
"'m.identifier'",
")",
";",
"$",
"query",
"=",
"$",
"qb",
"->",
"getQuery",
"(",
")",
";",
"return",
"$",
"this",
"->",
"response",
"(",
"VariableUtil",
"::",
"arrayFlatten",
"(",
"$",
"query",
"->",
"getResult",
"(",
"\\",
"Doctrine",
"\\",
"ORM",
"\\",
"Query",
"::",
"HYDRATE_ARRAY",
")",
")",
")",
";",
"}"
] |
List all installed Composer packages which include CampaignChain Modules.
Example Request
===============
GET /api/v1/modules/packages
Example Response
================
[
"campaignchain/report-analytics-cta-tracking",
"campaignchain/location-citrix",
"campaignchain/channel-facebook",
"campaignchain/location-facebook",
"campaignchain/activity-facebook",
"campaignchain/operation-facebook",
"campaignchain/location-facebook",
"campaignchain/location-facebook",
"campaignchain/channel-google",
"campaignchain/report-google",
"campaignchain/report-google-analytics",
"campaignchain/channel-google-analytics",
"campaignchain/location-google-analytics",
"campaignchain/activity-gotowebinar",
"campaignchain/channel-citrix",
"campaignchain/location-citrix",
"campaignchain/operation-gotowebinar",
"campaignchain/channel-linkedin",
"campaignchain/activity-linkedin",
"campaignchain/operation-linkedin",
"campaignchain/location-linkedin",
"campaignchain/activity-mailchimp",
"campaignchain/channel-mailchimp",
"campaignchain/operation-mailchimp",
"campaignchain/location-mailchimp",
"campaignchain/location-mailchimp",
"campaignchain/report-analytics-metrics-per-activity",
"campaignchain/campaign-repeating",
"campaignchain/campaign-scheduled",
"campaignchain/milestone-scheduled",
"campaignchain/security-authentication-client-oauth",
"campaignchain/security-authentication-server-oauth",
"campaignchain/operation-slideshare",
"campaignchain/activity-slideshare",
"campaignchain/channel-slideshare",
"campaignchain/location-slideshare",
"campaignchain/campaign-template",
"campaignchain/channel-twitter",
"campaignchain/location-twitter",
"campaignchain/operation-twitter",
"campaignchain/activity-twitter",
"campaignchain/location-twitter",
"campaignchain/channel-website",
"campaignchain/location-citrix",
"campaignchain/location-website",
"campaignchain/location-citrix",
"campaignchain/location-website"
]
@ApiDoc(
section="Core"
)
@REST\GET("/packages")
@return \Symfony\Component\HttpFoundation\Response
|
[
"List",
"all",
"installed",
"Composer",
"packages",
"which",
"include",
"CampaignChain",
"Modules",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/REST/ModuleController.php#L243-L258
|
233,170
|
CampaignChain/core
|
Controller/REST/ModuleController.php
|
ModuleController.getUrisAction
|
public function getUrisAction($uri)
{
$uri = new URI($uri);
$qb = $this->getQueryBuilder();
$qb->select(self::SELECT_STATEMENT);
$qb->from('CampaignChain\CoreBundle\Entity\Module', 'm');
$qb->from('CampaignChain\CoreBundle\Entity\Bundle', 'b');
$qb->where('b.id = m.bundle');
$qb->andWhere('b.name = :package');
$qb->andWhere('m.identifier = :module');
$qb->setParameter('package', $uri->getPackage());
$qb->setParameter('module', $uri->getModule());
$qb->orderBy('m.identifier');
$query = $qb->getQuery();
return $this->response(
$query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY)
);
}
|
php
|
public function getUrisAction($uri)
{
$uri = new URI($uri);
$qb = $this->getQueryBuilder();
$qb->select(self::SELECT_STATEMENT);
$qb->from('CampaignChain\CoreBundle\Entity\Module', 'm');
$qb->from('CampaignChain\CoreBundle\Entity\Bundle', 'b');
$qb->where('b.id = m.bundle');
$qb->andWhere('b.name = :package');
$qb->andWhere('m.identifier = :module');
$qb->setParameter('package', $uri->getPackage());
$qb->setParameter('module', $uri->getModule());
$qb->orderBy('m.identifier');
$query = $qb->getQuery();
return $this->response(
$query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY)
);
}
|
[
"public",
"function",
"getUrisAction",
"(",
"$",
"uri",
")",
"{",
"$",
"uri",
"=",
"new",
"URI",
"(",
"$",
"uri",
")",
";",
"$",
"qb",
"=",
"$",
"this",
"->",
"getQueryBuilder",
"(",
")",
";",
"$",
"qb",
"->",
"select",
"(",
"self",
"::",
"SELECT_STATEMENT",
")",
";",
"$",
"qb",
"->",
"from",
"(",
"'CampaignChain\\CoreBundle\\Entity\\Module'",
",",
"'m'",
")",
";",
"$",
"qb",
"->",
"from",
"(",
"'CampaignChain\\CoreBundle\\Entity\\Bundle'",
",",
"'b'",
")",
";",
"$",
"qb",
"->",
"where",
"(",
"'b.id = m.bundle'",
")",
";",
"$",
"qb",
"->",
"andWhere",
"(",
"'b.name = :package'",
")",
";",
"$",
"qb",
"->",
"andWhere",
"(",
"'m.identifier = :module'",
")",
";",
"$",
"qb",
"->",
"setParameter",
"(",
"'package'",
",",
"$",
"uri",
"->",
"getPackage",
"(",
")",
")",
";",
"$",
"qb",
"->",
"setParameter",
"(",
"'module'",
",",
"$",
"uri",
"->",
"getModule",
"(",
")",
")",
";",
"$",
"qb",
"->",
"orderBy",
"(",
"'m.identifier'",
")",
";",
"$",
"query",
"=",
"$",
"qb",
"->",
"getQuery",
"(",
")",
";",
"return",
"$",
"this",
"->",
"response",
"(",
"$",
"query",
"->",
"getResult",
"(",
"\\",
"Doctrine",
"\\",
"ORM",
"\\",
"Query",
"::",
"HYDRATE_ARRAY",
")",
")",
";",
"}"
] |
Get one specific module by Module URI.
Example Request
===============
GET /api/v1/modules/uris/campaignchain%2Flocation-facebook%2Fcampaignchain-facebook-user
Example Response
================
[
{
"id": 10,
"identifier": "campaignchain-facebook-user",
"displayName": "Facebook user stream",
"hooks":
{
"default":
{
"campaignchain-assignee": true
}
},
"createdDate": "2015-11-26T11:08:29+0000",
"type": "location"
}
]
@ApiDoc(
section="Core",
requirements={
{
"name"="uri",
"requirement"="[A-Za-z0-9][A-Za-z0-9_.-]*\/[A-Za-z0-9][A-Za-z0-9_.-]*\/[A-Za-z0-9][A-Za-z0-9_.-]*"
}
}
)
@REST\NoRoute() // We have specified a route manually.
@param string $uri A Module URI, e.g. 'campaignchain/location-facebook/campaignchain-facebook-user'. The value should be URL encoded.
@return \Symfony\Component\HttpFoundation\Response
|
[
"Get",
"one",
"specific",
"module",
"by",
"Module",
"URI",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/REST/ModuleController.php#L472-L491
|
233,171
|
CampaignChain/core
|
Controller/REST/ModuleController.php
|
ModuleController.postToggleStatusAction
|
public function postToggleStatusAction(Request $request)
{
$uri = new URI($request->request->get('uri'));
$service = $this->get('campaignchain.core.module');
try {
$status = $service->toggleStatus($uri->getPackage(), $uri->getModule());
$response = $this->forward(
'CampaignChainCoreBundle:REST/Module:getUris',
array(
'uri' => $request->request->get('uri')
)
);
return $response->setStatusCode(Response::HTTP_CREATED);
} catch (\Exception $e) {
return $this->errorResponse($e->getMessage());
}
}
|
php
|
public function postToggleStatusAction(Request $request)
{
$uri = new URI($request->request->get('uri'));
$service = $this->get('campaignchain.core.module');
try {
$status = $service->toggleStatus($uri->getPackage(), $uri->getModule());
$response = $this->forward(
'CampaignChainCoreBundle:REST/Module:getUris',
array(
'uri' => $request->request->get('uri')
)
);
return $response->setStatusCode(Response::HTTP_CREATED);
} catch (\Exception $e) {
return $this->errorResponse($e->getMessage());
}
}
|
[
"public",
"function",
"postToggleStatusAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"uri",
"=",
"new",
"URI",
"(",
"$",
"request",
"->",
"request",
"->",
"get",
"(",
"'uri'",
")",
")",
";",
"$",
"service",
"=",
"$",
"this",
"->",
"get",
"(",
"'campaignchain.core.module'",
")",
";",
"try",
"{",
"$",
"status",
"=",
"$",
"service",
"->",
"toggleStatus",
"(",
"$",
"uri",
"->",
"getPackage",
"(",
")",
",",
"$",
"uri",
"->",
"getModule",
"(",
")",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"forward",
"(",
"'CampaignChainCoreBundle:REST/Module:getUris'",
",",
"array",
"(",
"'uri'",
"=>",
"$",
"request",
"->",
"request",
"->",
"get",
"(",
"'uri'",
")",
")",
")",
";",
"return",
"$",
"response",
"->",
"setStatusCode",
"(",
"Response",
"::",
"HTTP_CREATED",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"return",
"$",
"this",
"->",
"errorResponse",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] |
Toggle the status of a Module to active or inactive.
Example Request
===============
POST /api/v1/modules/toggle-status
Example Input
=============
{
"uri": "campaignchain/channel-twitter/campaignchain-twitter"
}
Example Response
================
See:
GET /api/v1/modules/uris/{uri}
@ApiDoc(
section="Core",
requirements={
{
"name"="uri",
"requirement"="[A-Za-z0-9][A-Za-z0-9_.-]*\/[A-Za-z0-9][A-Za-z0-9_.-]*\/[A-Za-z0-9][A-Za-z0-9_.-]*"
}
}
)
@REST\Post("/toggle-status")
@return \Symfony\Component\HttpFoundation\Response
|
[
"Toggle",
"the",
"status",
"of",
"a",
"Module",
"to",
"active",
"or",
"inactive",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/REST/ModuleController.php#L529-L546
|
233,172
|
et-soft/yii2-widget-select-year
|
YearSelectbox.php
|
YearSelectbox._getItems
|
private function _getItems()
{
$typesAvailable = ['fix', 'calculation'];
$this->yearStart = intval($this->yearStart);
$this->yearEnd = intval($this->yearEnd);
if (!in_array($this->yearStartType, $typesAvailable)) throw new InvalidConfigException("The 'yearStartType' option is must be: 'fix' or 'calculation'.");
if (!in_array($this->yearEndType, $typesAvailable)) throw new InvalidConfigException("The 'yearEndType' option is must be: 'fix' or 'calculation'.");
if ($this->yearStartType == 'calculation') $this->yearStart += date('Y');
if ($this->yearEndType == 'calculation') $this->yearEnd += date('Y');
$yearsRange = range($this->yearStart, $this->yearEnd);
return array_combine($yearsRange, $yearsRange);
}
|
php
|
private function _getItems()
{
$typesAvailable = ['fix', 'calculation'];
$this->yearStart = intval($this->yearStart);
$this->yearEnd = intval($this->yearEnd);
if (!in_array($this->yearStartType, $typesAvailable)) throw new InvalidConfigException("The 'yearStartType' option is must be: 'fix' or 'calculation'.");
if (!in_array($this->yearEndType, $typesAvailable)) throw new InvalidConfigException("The 'yearEndType' option is must be: 'fix' or 'calculation'.");
if ($this->yearStartType == 'calculation') $this->yearStart += date('Y');
if ($this->yearEndType == 'calculation') $this->yearEnd += date('Y');
$yearsRange = range($this->yearStart, $this->yearEnd);
return array_combine($yearsRange, $yearsRange);
}
|
[
"private",
"function",
"_getItems",
"(",
")",
"{",
"$",
"typesAvailable",
"=",
"[",
"'fix'",
",",
"'calculation'",
"]",
";",
"$",
"this",
"->",
"yearStart",
"=",
"intval",
"(",
"$",
"this",
"->",
"yearStart",
")",
";",
"$",
"this",
"->",
"yearEnd",
"=",
"intval",
"(",
"$",
"this",
"->",
"yearEnd",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"this",
"->",
"yearStartType",
",",
"$",
"typesAvailable",
")",
")",
"throw",
"new",
"InvalidConfigException",
"(",
"\"The 'yearStartType' option is must be: 'fix' or 'calculation'.\"",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"this",
"->",
"yearEndType",
",",
"$",
"typesAvailable",
")",
")",
"throw",
"new",
"InvalidConfigException",
"(",
"\"The 'yearEndType' option is must be: 'fix' or 'calculation'.\"",
")",
";",
"if",
"(",
"$",
"this",
"->",
"yearStartType",
"==",
"'calculation'",
")",
"$",
"this",
"->",
"yearStart",
"+=",
"date",
"(",
"'Y'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"yearEndType",
"==",
"'calculation'",
")",
"$",
"this",
"->",
"yearEnd",
"+=",
"date",
"(",
"'Y'",
")",
";",
"$",
"yearsRange",
"=",
"range",
"(",
"$",
"this",
"->",
"yearStart",
",",
"$",
"this",
"->",
"yearEnd",
")",
";",
"return",
"array_combine",
"(",
"$",
"yearsRange",
",",
"$",
"yearsRange",
")",
";",
"}"
] |
Create array of the years.
@return array
@throws InvalidConfigException
|
[
"Create",
"array",
"of",
"the",
"years",
"."
] |
54e50594810fb2e094cbbc759db7a70d35b1f7e7
|
https://github.com/et-soft/yii2-widget-select-year/blob/54e50594810fb2e094cbbc759db7a70d35b1f7e7/YearSelectbox.php#L87-L103
|
233,173
|
Deathnerd/php-wtforms
|
src/fields/core/FieldList.php
|
FieldList.addEntry
|
private function addEntry($formdata = [], $data = null, $index = null)
{
if (!(!$this->max_entries || count($this->entries) < $this->max_entries)) {
throw new AssertionError("You cannot have more than max_entries entries in the FieldList");
}
if ($index === null) {
$index = $this->last_index + 1;
}
$this->last_index = $index;
$name = "$this->short_name-$index";
$id = "$this->id-$index";
// I feel so dirty... There's gotta be a better way - Deathnerd
$inner_field_options = $this->inner_field->constructor_options;
$inner_field_options['meta'] = $this->meta;
$inner_field_options['prefix'] = $this->prefix;
$inner_field_options['name'] = $name;
$inner_field_options['id'] = $id;
if ($this->inner_field instanceof FormField) {
$inner_field_options['form_class'] = $this->inner_field->form_class;
unset($inner_field_options['filters']);
unset($inner_field_options['validators']);
}
/**
* @var $field Field
*/
$field = new $this->inner_field($inner_field_options);
$field->process($formdata, $data);
$this->entries[] = $field;
return $field;
}
|
php
|
private function addEntry($formdata = [], $data = null, $index = null)
{
if (!(!$this->max_entries || count($this->entries) < $this->max_entries)) {
throw new AssertionError("You cannot have more than max_entries entries in the FieldList");
}
if ($index === null) {
$index = $this->last_index + 1;
}
$this->last_index = $index;
$name = "$this->short_name-$index";
$id = "$this->id-$index";
// I feel so dirty... There's gotta be a better way - Deathnerd
$inner_field_options = $this->inner_field->constructor_options;
$inner_field_options['meta'] = $this->meta;
$inner_field_options['prefix'] = $this->prefix;
$inner_field_options['name'] = $name;
$inner_field_options['id'] = $id;
if ($this->inner_field instanceof FormField) {
$inner_field_options['form_class'] = $this->inner_field->form_class;
unset($inner_field_options['filters']);
unset($inner_field_options['validators']);
}
/**
* @var $field Field
*/
$field = new $this->inner_field($inner_field_options);
$field->process($formdata, $data);
$this->entries[] = $field;
return $field;
}
|
[
"private",
"function",
"addEntry",
"(",
"$",
"formdata",
"=",
"[",
"]",
",",
"$",
"data",
"=",
"null",
",",
"$",
"index",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"(",
"!",
"$",
"this",
"->",
"max_entries",
"||",
"count",
"(",
"$",
"this",
"->",
"entries",
")",
"<",
"$",
"this",
"->",
"max_entries",
")",
")",
"{",
"throw",
"new",
"AssertionError",
"(",
"\"You cannot have more than max_entries entries in the FieldList\"",
")",
";",
"}",
"if",
"(",
"$",
"index",
"===",
"null",
")",
"{",
"$",
"index",
"=",
"$",
"this",
"->",
"last_index",
"+",
"1",
";",
"}",
"$",
"this",
"->",
"last_index",
"=",
"$",
"index",
";",
"$",
"name",
"=",
"\"$this->short_name-$index\"",
";",
"$",
"id",
"=",
"\"$this->id-$index\"",
";",
"// I feel so dirty... There's gotta be a better way - Deathnerd",
"$",
"inner_field_options",
"=",
"$",
"this",
"->",
"inner_field",
"->",
"constructor_options",
";",
"$",
"inner_field_options",
"[",
"'meta'",
"]",
"=",
"$",
"this",
"->",
"meta",
";",
"$",
"inner_field_options",
"[",
"'prefix'",
"]",
"=",
"$",
"this",
"->",
"prefix",
";",
"$",
"inner_field_options",
"[",
"'name'",
"]",
"=",
"$",
"name",
";",
"$",
"inner_field_options",
"[",
"'id'",
"]",
"=",
"$",
"id",
";",
"if",
"(",
"$",
"this",
"->",
"inner_field",
"instanceof",
"FormField",
")",
"{",
"$",
"inner_field_options",
"[",
"'form_class'",
"]",
"=",
"$",
"this",
"->",
"inner_field",
"->",
"form_class",
";",
"unset",
"(",
"$",
"inner_field_options",
"[",
"'filters'",
"]",
")",
";",
"unset",
"(",
"$",
"inner_field_options",
"[",
"'validators'",
"]",
")",
";",
"}",
"/**\n * @var $field Field\n */",
"$",
"field",
"=",
"new",
"$",
"this",
"->",
"inner_field",
"(",
"$",
"inner_field_options",
")",
";",
"$",
"field",
"->",
"process",
"(",
"$",
"formdata",
",",
"$",
"data",
")",
";",
"$",
"this",
"->",
"entries",
"[",
"]",
"=",
"$",
"field",
";",
"return",
"$",
"field",
";",
"}"
] |
Processes an unbound field and inserts it as a field type in this field list
@param array $formdata
@param null|array $data
@param null|integer $index
@return Field
@throws AssertionError
|
[
"Processes",
"an",
"unbound",
"field",
"and",
"inserts",
"it",
"as",
"a",
"field",
"type",
"in",
"this",
"field",
"list"
] |
2e1f9ad515f6241c9fac57edc472bf657267f4a1
|
https://github.com/Deathnerd/php-wtforms/blob/2e1f9ad515f6241c9fac57edc472bf657267f4a1/src/fields/core/FieldList.php#L196-L229
|
233,174
|
Deathnerd/php-wtforms
|
src/fields/core/FieldList.php
|
FieldList.popEntry
|
public function popEntry()
{
if (count($this->entries) == 0) {
throw new IndexError;
}
$entry = array_pop($this->entries);
$this->last_index -= 1;
return $entry;
}
|
php
|
public function popEntry()
{
if (count($this->entries) == 0) {
throw new IndexError;
}
$entry = array_pop($this->entries);
$this->last_index -= 1;
return $entry;
}
|
[
"public",
"function",
"popEntry",
"(",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"entries",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"IndexError",
";",
"}",
"$",
"entry",
"=",
"array_pop",
"(",
"$",
"this",
"->",
"entries",
")",
";",
"$",
"this",
"->",
"last_index",
"-=",
"1",
";",
"return",
"$",
"entry",
";",
"}"
] |
Removes the last entry from the list and returns it
@return mixed
@throws IndexError
|
[
"Removes",
"the",
"last",
"entry",
"from",
"the",
"list",
"and",
"returns",
"it"
] |
2e1f9ad515f6241c9fac57edc472bf657267f4a1
|
https://github.com/Deathnerd/php-wtforms/blob/2e1f9ad515f6241c9fac57edc472bf657267f4a1/src/fields/core/FieldList.php#L251-L260
|
233,175
|
Deathnerd/php-wtforms
|
src/fields/core/FieldList.php
|
FieldList.validate
|
public function validate(Form $form, array $extra_validators = [])
{
$this->errors = [];
// Run validators on all entries within
foreach ($this->entries as $subfield) {
/**
* @var Field $subfield
*/
if (!$subfield->validate($form)) {
$this->errors[] = $subfield->errors;
}
}
$this->runValidationChain($form, array_merge($this->validators, $extra_validators));
return count($this->errors) == 0;
}
|
php
|
public function validate(Form $form, array $extra_validators = [])
{
$this->errors = [];
// Run validators on all entries within
foreach ($this->entries as $subfield) {
/**
* @var Field $subfield
*/
if (!$subfield->validate($form)) {
$this->errors[] = $subfield->errors;
}
}
$this->runValidationChain($form, array_merge($this->validators, $extra_validators));
return count($this->errors) == 0;
}
|
[
"public",
"function",
"validate",
"(",
"Form",
"$",
"form",
",",
"array",
"$",
"extra_validators",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"errors",
"=",
"[",
"]",
";",
"// Run validators on all entries within",
"foreach",
"(",
"$",
"this",
"->",
"entries",
"as",
"$",
"subfield",
")",
"{",
"/**\n * @var Field $subfield\n */",
"if",
"(",
"!",
"$",
"subfield",
"->",
"validate",
"(",
"$",
"form",
")",
")",
"{",
"$",
"this",
"->",
"errors",
"[",
"]",
"=",
"$",
"subfield",
"->",
"errors",
";",
"}",
"}",
"$",
"this",
"->",
"runValidationChain",
"(",
"$",
"form",
",",
"array_merge",
"(",
"$",
"this",
"->",
"validators",
",",
"$",
"extra_validators",
")",
")",
";",
"return",
"count",
"(",
"$",
"this",
"->",
"errors",
")",
"==",
"0",
";",
"}"
] |
Validate this FieldList.
Note that the FieldList differs from normal field validation in
that FieldList validates all its enclosed fields first before running any
of its own validators.
@param \WTForms\Form $form
@param array $extra_validators
@return bool|void
|
[
"Validate",
"this",
"FieldList",
"."
] |
2e1f9ad515f6241c9fac57edc472bf657267f4a1
|
https://github.com/Deathnerd/php-wtforms/blob/2e1f9ad515f6241c9fac57edc472bf657267f4a1/src/fields/core/FieldList.php#L274-L290
|
233,176
|
notthatbad/silverstripe-rest-api
|
code/extensions/PaginationExtension.php
|
PaginationExtension.offset
|
public function offset($request) {
$offset = (int)$request->getVar('offset');
if($offset && is_int($offset) && $offset >= 0) {
return $offset;
} else {
return static::$default_offset;
}
}
|
php
|
public function offset($request) {
$offset = (int)$request->getVar('offset');
if($offset && is_int($offset) && $offset >= 0) {
return $offset;
} else {
return static::$default_offset;
}
}
|
[
"public",
"function",
"offset",
"(",
"$",
"request",
")",
"{",
"$",
"offset",
"=",
"(",
"int",
")",
"$",
"request",
"->",
"getVar",
"(",
"'offset'",
")",
";",
"if",
"(",
"$",
"offset",
"&&",
"is_int",
"(",
"$",
"offset",
")",
"&&",
"$",
"offset",
">=",
"0",
")",
"{",
"return",
"$",
"offset",
";",
"}",
"else",
"{",
"return",
"static",
"::",
"$",
"default_offset",
";",
"}",
"}"
] |
Returns the offset, either given in request by `offset` or from the default settings in the controller.
@param \SS_HTTPRequest $request
@return int the offset value
|
[
"Returns",
"the",
"offset",
"either",
"given",
"in",
"request",
"by",
"offset",
"or",
"from",
"the",
"default",
"settings",
"in",
"the",
"controller",
"."
] |
aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621
|
https://github.com/notthatbad/silverstripe-rest-api/blob/aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621/code/extensions/PaginationExtension.php#L31-L38
|
233,177
|
notthatbad/silverstripe-rest-api
|
code/extensions/PaginationExtension.php
|
PaginationExtension.limit
|
public function limit($request) {
$limit = (int)$request->getVar('limit');
if($limit && is_int($limit) && $limit > 0) {
return $limit;
} else {
return static::$default_limit;
}
}
|
php
|
public function limit($request) {
$limit = (int)$request->getVar('limit');
if($limit && is_int($limit) && $limit > 0) {
return $limit;
} else {
return static::$default_limit;
}
}
|
[
"public",
"function",
"limit",
"(",
"$",
"request",
")",
"{",
"$",
"limit",
"=",
"(",
"int",
")",
"$",
"request",
"->",
"getVar",
"(",
"'limit'",
")",
";",
"if",
"(",
"$",
"limit",
"&&",
"is_int",
"(",
"$",
"limit",
")",
"&&",
"$",
"limit",
">",
"0",
")",
"{",
"return",
"$",
"limit",
";",
"}",
"else",
"{",
"return",
"static",
"::",
"$",
"default_limit",
";",
"}",
"}"
] |
Returns the limit, either given in request by `limit` or from the default settings in the controller.
@param \SS_HTTPRequest $request
@return int the limit value
|
[
"Returns",
"the",
"limit",
"either",
"given",
"in",
"request",
"by",
"limit",
"or",
"from",
"the",
"default",
"settings",
"in",
"the",
"controller",
"."
] |
aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621
|
https://github.com/notthatbad/silverstripe-rest-api/blob/aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621/code/extensions/PaginationExtension.php#L46-L53
|
233,178
|
Patroklo/yii2-comments
|
models/CommentSearchModel.php
|
CommentSearchModel.search
|
public function search($params, $pageSize = 20)
{
$query = self::find()->joinWith('author');
$dataProvider = new ActiveDataProvider([
'query' => $query,
'pagination' => [
'pageSize' => $pageSize
]
]);
$dataProvider->setSort([
'defaultOrder' => ['id' => SORT_DESC],
]);
// load the search form data and validate
if (!($this->load($params)))
{
return $dataProvider;
}
//adjust the query by adding the filters
$query->andFilterWhere(['id' => $this->id]);
$query->andFilterWhere(['like', 'username', $this->createdBy]);
$query->orFilterWhere(['like', 'anonymousUsername', $this->createdBy]);
$query->andFilterWhere([self::tableName().'.status' => $this->status]);
$query->andFilterWhere(['like', 'content', $this->content]);
return $dataProvider;
}
|
php
|
public function search($params, $pageSize = 20)
{
$query = self::find()->joinWith('author');
$dataProvider = new ActiveDataProvider([
'query' => $query,
'pagination' => [
'pageSize' => $pageSize
]
]);
$dataProvider->setSort([
'defaultOrder' => ['id' => SORT_DESC],
]);
// load the search form data and validate
if (!($this->load($params)))
{
return $dataProvider;
}
//adjust the query by adding the filters
$query->andFilterWhere(['id' => $this->id]);
$query->andFilterWhere(['like', 'username', $this->createdBy]);
$query->orFilterWhere(['like', 'anonymousUsername', $this->createdBy]);
$query->andFilterWhere([self::tableName().'.status' => $this->status]);
$query->andFilterWhere(['like', 'content', $this->content]);
return $dataProvider;
}
|
[
"public",
"function",
"search",
"(",
"$",
"params",
",",
"$",
"pageSize",
"=",
"20",
")",
"{",
"$",
"query",
"=",
"self",
"::",
"find",
"(",
")",
"->",
"joinWith",
"(",
"'author'",
")",
";",
"$",
"dataProvider",
"=",
"new",
"ActiveDataProvider",
"(",
"[",
"'query'",
"=>",
"$",
"query",
",",
"'pagination'",
"=>",
"[",
"'pageSize'",
"=>",
"$",
"pageSize",
"]",
"]",
")",
";",
"$",
"dataProvider",
"->",
"setSort",
"(",
"[",
"'defaultOrder'",
"=>",
"[",
"'id'",
"=>",
"SORT_DESC",
"]",
",",
"]",
")",
";",
"// load the search form data and validate",
"if",
"(",
"!",
"(",
"$",
"this",
"->",
"load",
"(",
"$",
"params",
")",
")",
")",
"{",
"return",
"$",
"dataProvider",
";",
"}",
"//adjust the query by adding the filters",
"$",
"query",
"->",
"andFilterWhere",
"(",
"[",
"'id'",
"=>",
"$",
"this",
"->",
"id",
"]",
")",
";",
"$",
"query",
"->",
"andFilterWhere",
"(",
"[",
"'like'",
",",
"'username'",
",",
"$",
"this",
"->",
"createdBy",
"]",
")",
";",
"$",
"query",
"->",
"orFilterWhere",
"(",
"[",
"'like'",
",",
"'anonymousUsername'",
",",
"$",
"this",
"->",
"createdBy",
"]",
")",
";",
"$",
"query",
"->",
"andFilterWhere",
"(",
"[",
"self",
"::",
"tableName",
"(",
")",
".",
"'.status'",
"=>",
"$",
"this",
"->",
"status",
"]",
")",
";",
"$",
"query",
"->",
"andFilterWhere",
"(",
"[",
"'like'",
",",
"'content'",
",",
"$",
"this",
"->",
"content",
"]",
")",
";",
"return",
"$",
"dataProvider",
";",
"}"
] |
Setup search function for filtering and sorting based on fullName field
@param $params
@param int $pageSize
@return ActiveDataProvider
|
[
"Setup",
"search",
"function",
"for",
"filtering",
"and",
"sorting",
"based",
"on",
"fullName",
"field"
] |
e06409ea52b12dc14d0594030088fd7d2c2e160a
|
https://github.com/Patroklo/yii2-comments/blob/e06409ea52b12dc14d0594030088fd7d2c2e160a/models/CommentSearchModel.php#L41-L69
|
233,179
|
malenkiki/aleavatar
|
src/Malenki/Aleavatar/Quarter.php
|
Quarter.tr
|
public function tr()
{
$q = new self(self::TOP_RIGHT, $this->bool_rotate_way);
$q->units($this->arr_units);
return $q;
}
|
php
|
public function tr()
{
$q = new self(self::TOP_RIGHT, $this->bool_rotate_way);
$q->units($this->arr_units);
return $q;
}
|
[
"public",
"function",
"tr",
"(",
")",
"{",
"$",
"q",
"=",
"new",
"self",
"(",
"self",
"::",
"TOP_RIGHT",
",",
"$",
"this",
"->",
"bool_rotate_way",
")",
";",
"$",
"q",
"->",
"units",
"(",
"$",
"this",
"->",
"arr_units",
")",
";",
"return",
"$",
"q",
";",
"}"
] |
Returns new quarter copied from current one and rotated for the top
right corner.
@access public
@return Quarter
|
[
"Returns",
"new",
"quarter",
"copied",
"from",
"current",
"one",
"and",
"rotated",
"for",
"the",
"top",
"right",
"corner",
"."
] |
91affa83f8580c8e6da62c77ce34b1c4451784bf
|
https://github.com/malenkiki/aleavatar/blob/91affa83f8580c8e6da62c77ce34b1c4451784bf/src/Malenki/Aleavatar/Quarter.php#L119-L125
|
233,180
|
malenkiki/aleavatar
|
src/Malenki/Aleavatar/Quarter.php
|
Quarter.br
|
public function br()
{
$q = new self(self::BOTTOM_RIGHT, $this->bool_rotate_way);
$q->units($this->arr_units);
return $q;
}
|
php
|
public function br()
{
$q = new self(self::BOTTOM_RIGHT, $this->bool_rotate_way);
$q->units($this->arr_units);
return $q;
}
|
[
"public",
"function",
"br",
"(",
")",
"{",
"$",
"q",
"=",
"new",
"self",
"(",
"self",
"::",
"BOTTOM_RIGHT",
",",
"$",
"this",
"->",
"bool_rotate_way",
")",
";",
"$",
"q",
"->",
"units",
"(",
"$",
"this",
"->",
"arr_units",
")",
";",
"return",
"$",
"q",
";",
"}"
] |
Returns new quarter copied from current one and rotated for the bottom
right corner.
@access public
@return Quarter
|
[
"Returns",
"new",
"quarter",
"copied",
"from",
"current",
"one",
"and",
"rotated",
"for",
"the",
"bottom",
"right",
"corner",
"."
] |
91affa83f8580c8e6da62c77ce34b1c4451784bf
|
https://github.com/malenkiki/aleavatar/blob/91affa83f8580c8e6da62c77ce34b1c4451784bf/src/Malenki/Aleavatar/Quarter.php#L134-L140
|
233,181
|
malenkiki/aleavatar
|
src/Malenki/Aleavatar/Quarter.php
|
Quarter.bl
|
public function bl()
{
$q = new self(self::BOTTOM_LEFT, $this->bool_rotate_way);
$q->units($this->arr_units);
return $q;
}
|
php
|
public function bl()
{
$q = new self(self::BOTTOM_LEFT, $this->bool_rotate_way);
$q->units($this->arr_units);
return $q;
}
|
[
"public",
"function",
"bl",
"(",
")",
"{",
"$",
"q",
"=",
"new",
"self",
"(",
"self",
"::",
"BOTTOM_LEFT",
",",
"$",
"this",
"->",
"bool_rotate_way",
")",
";",
"$",
"q",
"->",
"units",
"(",
"$",
"this",
"->",
"arr_units",
")",
";",
"return",
"$",
"q",
";",
"}"
] |
Returns new quarter copied from current one and rotated for the bottom
left corner.
@access public
@return Quarter
|
[
"Returns",
"new",
"quarter",
"copied",
"from",
"current",
"one",
"and",
"rotated",
"for",
"the",
"bottom",
"left",
"corner",
"."
] |
91affa83f8580c8e6da62c77ce34b1c4451784bf
|
https://github.com/malenkiki/aleavatar/blob/91affa83f8580c8e6da62c77ce34b1c4451784bf/src/Malenki/Aleavatar/Quarter.php#L149-L155
|
233,182
|
malenkiki/aleavatar
|
src/Malenki/Aleavatar/Quarter.php
|
Quarter.svg
|
public function svg()
{
$str_g = '';
foreach ($this->arr_units as $k => $u) {
$int_dx = 0;
$int_dy = 0;
if ($k == self::TOP_RIGHT) {
$int_dx = Unit::SIZE;
} elseif ($k == self::BOTTOM_RIGHT) {
$int_dx = Unit::SIZE;
$int_dy = Unit::SIZE;
} elseif ($k == self::BOTTOM_LEFT) {
$int_dy = Unit::SIZE;
}
$str_attr_translate = sprintf(
' transform="translate(%d, %d)"',
$int_dx,
$int_dy
);
if ($int_dx || $int_dy) {
$str_g .= sprintf('<g%s>%s</g>', $str_attr_translate, $u->svg()) . "\n";
} else {
$str_g .= $u->svg() . "\n";
}
}
$str_attr = '';
if ($this->type != self::TOP_LEFT) {
$int_dx = 0;
$int_dy = 0;
if ($this->type == self::TOP_RIGHT) {
$int_dx = self::SIZE;
} elseif ($this->type == self::BOTTOM_RIGHT) {
$int_dx = self::SIZE;
$int_dy = self::SIZE;
} elseif ($this->type == self::BOTTOM_LEFT) {
$int_dy = self::SIZE;
}
$int_way = $this->bool_rotate_way ? -1 : 1;
$str_attr = sprintf(
' transform="translate(%d, %d) rotate(%d, %d, %d)"',
$int_dx,
$int_dy,
$this->type * 90 * $int_way,
Unit::SIZE,
Unit::SIZE
);
}
return sprintf(
'<g id="quarter-%d"%s>%s</g>'."\n",
$this->type,
$str_attr,
$str_g
);
}
|
php
|
public function svg()
{
$str_g = '';
foreach ($this->arr_units as $k => $u) {
$int_dx = 0;
$int_dy = 0;
if ($k == self::TOP_RIGHT) {
$int_dx = Unit::SIZE;
} elseif ($k == self::BOTTOM_RIGHT) {
$int_dx = Unit::SIZE;
$int_dy = Unit::SIZE;
} elseif ($k == self::BOTTOM_LEFT) {
$int_dy = Unit::SIZE;
}
$str_attr_translate = sprintf(
' transform="translate(%d, %d)"',
$int_dx,
$int_dy
);
if ($int_dx || $int_dy) {
$str_g .= sprintf('<g%s>%s</g>', $str_attr_translate, $u->svg()) . "\n";
} else {
$str_g .= $u->svg() . "\n";
}
}
$str_attr = '';
if ($this->type != self::TOP_LEFT) {
$int_dx = 0;
$int_dy = 0;
if ($this->type == self::TOP_RIGHT) {
$int_dx = self::SIZE;
} elseif ($this->type == self::BOTTOM_RIGHT) {
$int_dx = self::SIZE;
$int_dy = self::SIZE;
} elseif ($this->type == self::BOTTOM_LEFT) {
$int_dy = self::SIZE;
}
$int_way = $this->bool_rotate_way ? -1 : 1;
$str_attr = sprintf(
' transform="translate(%d, %d) rotate(%d, %d, %d)"',
$int_dx,
$int_dy,
$this->type * 90 * $int_way,
Unit::SIZE,
Unit::SIZE
);
}
return sprintf(
'<g id="quarter-%d"%s>%s</g>'."\n",
$this->type,
$str_attr,
$str_g
);
}
|
[
"public",
"function",
"svg",
"(",
")",
"{",
"$",
"str_g",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"arr_units",
"as",
"$",
"k",
"=>",
"$",
"u",
")",
"{",
"$",
"int_dx",
"=",
"0",
";",
"$",
"int_dy",
"=",
"0",
";",
"if",
"(",
"$",
"k",
"==",
"self",
"::",
"TOP_RIGHT",
")",
"{",
"$",
"int_dx",
"=",
"Unit",
"::",
"SIZE",
";",
"}",
"elseif",
"(",
"$",
"k",
"==",
"self",
"::",
"BOTTOM_RIGHT",
")",
"{",
"$",
"int_dx",
"=",
"Unit",
"::",
"SIZE",
";",
"$",
"int_dy",
"=",
"Unit",
"::",
"SIZE",
";",
"}",
"elseif",
"(",
"$",
"k",
"==",
"self",
"::",
"BOTTOM_LEFT",
")",
"{",
"$",
"int_dy",
"=",
"Unit",
"::",
"SIZE",
";",
"}",
"$",
"str_attr_translate",
"=",
"sprintf",
"(",
"' transform=\"translate(%d, %d)\"'",
",",
"$",
"int_dx",
",",
"$",
"int_dy",
")",
";",
"if",
"(",
"$",
"int_dx",
"||",
"$",
"int_dy",
")",
"{",
"$",
"str_g",
".=",
"sprintf",
"(",
"'<g%s>%s</g>'",
",",
"$",
"str_attr_translate",
",",
"$",
"u",
"->",
"svg",
"(",
")",
")",
".",
"\"\\n\"",
";",
"}",
"else",
"{",
"$",
"str_g",
".=",
"$",
"u",
"->",
"svg",
"(",
")",
".",
"\"\\n\"",
";",
"}",
"}",
"$",
"str_attr",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"type",
"!=",
"self",
"::",
"TOP_LEFT",
")",
"{",
"$",
"int_dx",
"=",
"0",
";",
"$",
"int_dy",
"=",
"0",
";",
"if",
"(",
"$",
"this",
"->",
"type",
"==",
"self",
"::",
"TOP_RIGHT",
")",
"{",
"$",
"int_dx",
"=",
"self",
"::",
"SIZE",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"type",
"==",
"self",
"::",
"BOTTOM_RIGHT",
")",
"{",
"$",
"int_dx",
"=",
"self",
"::",
"SIZE",
";",
"$",
"int_dy",
"=",
"self",
"::",
"SIZE",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"type",
"==",
"self",
"::",
"BOTTOM_LEFT",
")",
"{",
"$",
"int_dy",
"=",
"self",
"::",
"SIZE",
";",
"}",
"$",
"int_way",
"=",
"$",
"this",
"->",
"bool_rotate_way",
"?",
"-",
"1",
":",
"1",
";",
"$",
"str_attr",
"=",
"sprintf",
"(",
"' transform=\"translate(%d, %d) rotate(%d, %d, %d)\"'",
",",
"$",
"int_dx",
",",
"$",
"int_dy",
",",
"$",
"this",
"->",
"type",
"*",
"90",
"*",
"$",
"int_way",
",",
"Unit",
"::",
"SIZE",
",",
"Unit",
"::",
"SIZE",
")",
";",
"}",
"return",
"sprintf",
"(",
"'<g id=\"quarter-%d\"%s>%s</g>'",
".",
"\"\\n\"",
",",
"$",
"this",
"->",
"type",
",",
"$",
"str_attr",
",",
"$",
"str_g",
")",
";",
"}"
] |
SVG rendering.
If quarter's type is different of Quarter::TOP_LEFT, a translation and a
rotation are apply.
@access public
@return string SVG code
|
[
"SVG",
"rendering",
"."
] |
91affa83f8580c8e6da62c77ce34b1c4451784bf
|
https://github.com/malenkiki/aleavatar/blob/91affa83f8580c8e6da62c77ce34b1c4451784bf/src/Malenki/Aleavatar/Quarter.php#L191-L253
|
233,183
|
joomla-framework/twitter-api
|
src/Mute.php
|
Mute.getMutedUserIds
|
public function getMutedUserIds($cursor = null)
{
// Check if cursor is specified
if ($cursor !== null)
{
$data['cursor'] = $cursor;
}
// Set the API path
$path = '/mutes/users/ids.json';
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
|
php
|
public function getMutedUserIds($cursor = null)
{
// Check if cursor is specified
if ($cursor !== null)
{
$data['cursor'] = $cursor;
}
// Set the API path
$path = '/mutes/users/ids.json';
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
|
[
"public",
"function",
"getMutedUserIds",
"(",
"$",
"cursor",
"=",
"null",
")",
"{",
"// Check if cursor is specified",
"if",
"(",
"$",
"cursor",
"!==",
"null",
")",
"{",
"$",
"data",
"[",
"'cursor'",
"]",
"=",
"$",
"cursor",
";",
"}",
"// Set the API path",
"$",
"path",
"=",
"'/mutes/users/ids.json'",
";",
"// Send the request.",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"$",
"path",
",",
"'GET'",
",",
"$",
"data",
")",
";",
"}"
] |
Method to get a list of muted user ID's
@param integer $cursor Breaks the results into pages. A single page contains 20 lists. Provide a value of -1 to begin paging.
@return array The decoded JSON response
@since 1.2.0
|
[
"Method",
"to",
"get",
"a",
"list",
"of",
"muted",
"user",
"ID",
"s"
] |
289719bbd67e83c7cfaf515b94b1d5497b1f0525
|
https://github.com/joomla-framework/twitter-api/blob/289719bbd67e83c7cfaf515b94b1d5497b1f0525/src/Mute.php#L96-L109
|
233,184
|
joomla-framework/twitter-api
|
src/Mute.php
|
Mute.getMutedUsers
|
public function getMutedUsers($cursor = null, $entities = null, $skipStatus = null)
{
// Check if cursor is specified
if ($cursor !== null)
{
$data['cursor'] = $cursor;
}
// Check if entities is specified
if ($entities !== null)
{
$data['include_entities'] = $entities;
}
// Check if skip_status is specified
if ($skipStatus !== null)
{
$data['skip_status'] = $skipStatus;
}
// Set the API path
$path = '/mutes/users/list.json';
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
|
php
|
public function getMutedUsers($cursor = null, $entities = null, $skipStatus = null)
{
// Check if cursor is specified
if ($cursor !== null)
{
$data['cursor'] = $cursor;
}
// Check if entities is specified
if ($entities !== null)
{
$data['include_entities'] = $entities;
}
// Check if skip_status is specified
if ($skipStatus !== null)
{
$data['skip_status'] = $skipStatus;
}
// Set the API path
$path = '/mutes/users/list.json';
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
|
[
"public",
"function",
"getMutedUsers",
"(",
"$",
"cursor",
"=",
"null",
",",
"$",
"entities",
"=",
"null",
",",
"$",
"skipStatus",
"=",
"null",
")",
"{",
"// Check if cursor is specified",
"if",
"(",
"$",
"cursor",
"!==",
"null",
")",
"{",
"$",
"data",
"[",
"'cursor'",
"]",
"=",
"$",
"cursor",
";",
"}",
"// Check if entities is specified",
"if",
"(",
"$",
"entities",
"!==",
"null",
")",
"{",
"$",
"data",
"[",
"'include_entities'",
"]",
"=",
"$",
"entities",
";",
"}",
"// Check if skip_status is specified",
"if",
"(",
"$",
"skipStatus",
"!==",
"null",
")",
"{",
"$",
"data",
"[",
"'skip_status'",
"]",
"=",
"$",
"skipStatus",
";",
"}",
"// Set the API path",
"$",
"path",
"=",
"'/mutes/users/list.json'",
";",
"// Send the request.",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"$",
"path",
",",
"'GET'",
",",
"$",
"data",
")",
";",
"}"
] |
Method to get a list of muted users
@param integer $cursor Breaks the results into pages. A single page contains 20 lists. Provide a value of -1 to begin paging.
@param boolean $entities When set to either true, t or 1, each user will include a node called "entities". This node offers a variety
of metadata about the user in a discreet structure.
@param boolean $skipStatus When set to either true, t or 1 statuses will not be included in the returned user objects.
@return array The decoded JSON response
@since 1.2.0
|
[
"Method",
"to",
"get",
"a",
"list",
"of",
"muted",
"users"
] |
289719bbd67e83c7cfaf515b94b1d5497b1f0525
|
https://github.com/joomla-framework/twitter-api/blob/289719bbd67e83c7cfaf515b94b1d5497b1f0525/src/Mute.php#L123-L148
|
233,185
|
CampaignChain/core
|
Controller/ActivityController.php
|
ActivityController.moveApiAction
|
public function moveApiAction(Request $request)
{
$serializer = $this->get('campaignchain.core.serializer.default');
$responseData = array();
$id = $request->request->get('id');
$newDue = new \DateTime($request->request->get('start_date'));
$activityService = $this->get('campaignchain.core.activity');
$activity = $activityService->getActivity($id);
$responseData['id'] = $activity->getId();
$oldActivityStartDate = clone $activity->getStartDate();
$responseData['old_start_date'] = $oldActivityStartDate->format(\DateTime::ISO8601);
// $oldActivityEndDate = clone $activity->getEndDate();
// TODO: Check whether start = end date.
$responseData['old_end_date'] = $responseData['old_start_date'];
// Calculate time difference.
$interval = $activity->getStartDate()->diff($newDue);
$responseData['interval']['object'] = json_encode($interval, true);
$responseData['interval']['string'] = $interval->format(self::FORMAT_DATEINTERVAL);
// TODO: Also move operations.
$activity = $activityService->moveActivity($activity, $interval);
// Set new dates.
$responseData['new_start_date'] = $activity->getStartDate()->format(\DateTime::ISO8601);
// TODO: Check whether start = end date.
$responseData['new_end_date'] = $responseData['new_start_date'];
$em = $this->getDoctrine()->getManager();
$em->persist($activity);
$em->flush();
return new Response($serializer->serialize($responseData, 'json'));
}
|
php
|
public function moveApiAction(Request $request)
{
$serializer = $this->get('campaignchain.core.serializer.default');
$responseData = array();
$id = $request->request->get('id');
$newDue = new \DateTime($request->request->get('start_date'));
$activityService = $this->get('campaignchain.core.activity');
$activity = $activityService->getActivity($id);
$responseData['id'] = $activity->getId();
$oldActivityStartDate = clone $activity->getStartDate();
$responseData['old_start_date'] = $oldActivityStartDate->format(\DateTime::ISO8601);
// $oldActivityEndDate = clone $activity->getEndDate();
// TODO: Check whether start = end date.
$responseData['old_end_date'] = $responseData['old_start_date'];
// Calculate time difference.
$interval = $activity->getStartDate()->diff($newDue);
$responseData['interval']['object'] = json_encode($interval, true);
$responseData['interval']['string'] = $interval->format(self::FORMAT_DATEINTERVAL);
// TODO: Also move operations.
$activity = $activityService->moveActivity($activity, $interval);
// Set new dates.
$responseData['new_start_date'] = $activity->getStartDate()->format(\DateTime::ISO8601);
// TODO: Check whether start = end date.
$responseData['new_end_date'] = $responseData['new_start_date'];
$em = $this->getDoctrine()->getManager();
$em->persist($activity);
$em->flush();
return new Response($serializer->serialize($responseData, 'json'));
}
|
[
"public",
"function",
"moveApiAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"serializer",
"=",
"$",
"this",
"->",
"get",
"(",
"'campaignchain.core.serializer.default'",
")",
";",
"$",
"responseData",
"=",
"array",
"(",
")",
";",
"$",
"id",
"=",
"$",
"request",
"->",
"request",
"->",
"get",
"(",
"'id'",
")",
";",
"$",
"newDue",
"=",
"new",
"\\",
"DateTime",
"(",
"$",
"request",
"->",
"request",
"->",
"get",
"(",
"'start_date'",
")",
")",
";",
"$",
"activityService",
"=",
"$",
"this",
"->",
"get",
"(",
"'campaignchain.core.activity'",
")",
";",
"$",
"activity",
"=",
"$",
"activityService",
"->",
"getActivity",
"(",
"$",
"id",
")",
";",
"$",
"responseData",
"[",
"'id'",
"]",
"=",
"$",
"activity",
"->",
"getId",
"(",
")",
";",
"$",
"oldActivityStartDate",
"=",
"clone",
"$",
"activity",
"->",
"getStartDate",
"(",
")",
";",
"$",
"responseData",
"[",
"'old_start_date'",
"]",
"=",
"$",
"oldActivityStartDate",
"->",
"format",
"(",
"\\",
"DateTime",
"::",
"ISO8601",
")",
";",
"// $oldActivityEndDate = clone $activity->getEndDate();",
"// TODO: Check whether start = end date.",
"$",
"responseData",
"[",
"'old_end_date'",
"]",
"=",
"$",
"responseData",
"[",
"'old_start_date'",
"]",
";",
"// Calculate time difference.",
"$",
"interval",
"=",
"$",
"activity",
"->",
"getStartDate",
"(",
")",
"->",
"diff",
"(",
"$",
"newDue",
")",
";",
"$",
"responseData",
"[",
"'interval'",
"]",
"[",
"'object'",
"]",
"=",
"json_encode",
"(",
"$",
"interval",
",",
"true",
")",
";",
"$",
"responseData",
"[",
"'interval'",
"]",
"[",
"'string'",
"]",
"=",
"$",
"interval",
"->",
"format",
"(",
"self",
"::",
"FORMAT_DATEINTERVAL",
")",
";",
"// TODO: Also move operations.",
"$",
"activity",
"=",
"$",
"activityService",
"->",
"moveActivity",
"(",
"$",
"activity",
",",
"$",
"interval",
")",
";",
"// Set new dates.",
"$",
"responseData",
"[",
"'new_start_date'",
"]",
"=",
"$",
"activity",
"->",
"getStartDate",
"(",
")",
"->",
"format",
"(",
"\\",
"DateTime",
"::",
"ISO8601",
")",
";",
"// TODO: Check whether start = end date.",
"$",
"responseData",
"[",
"'new_end_date'",
"]",
"=",
"$",
"responseData",
"[",
"'new_start_date'",
"]",
";",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"em",
"->",
"persist",
"(",
"$",
"activity",
")",
";",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"return",
"new",
"Response",
"(",
"$",
"serializer",
"->",
"serialize",
"(",
"$",
"responseData",
",",
"'json'",
")",
")",
";",
"}"
] |
Move an Activity to a new start date.
@ApiDoc(
section = "Core",
views = { "private" },
requirements={
{
"name"="id",
"description" = "Campaign ID",
"requirement"="\d+"
},
{
"name"="start_date",
"description" = "Start date in ISO8601 format",
"requirement"="/(\d{4})-(\d{2})-(\d{2})T(\d{2})\:(\d{2})\:(\d{2})[+-](\d{2})\:(\d{2})/"
}
}
)
@param Request $request
@return Response
|
[
"Move",
"an",
"Activity",
"to",
"a",
"new",
"start",
"date",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/ActivityController.php#L316-L355
|
233,186
|
CampaignChain/core
|
EntityService/CTAService.php
|
CTAService.expandUrl
|
protected function expandUrl($url)
{
// skip if no short url
if (!ParserUtil::isShortUrl($url)) {
return $url;
}
$header_location = get_headers($url, 1)['Location'];
return $header_location ?: $url;
}
|
php
|
protected function expandUrl($url)
{
// skip if no short url
if (!ParserUtil::isShortUrl($url)) {
return $url;
}
$header_location = get_headers($url, 1)['Location'];
return $header_location ?: $url;
}
|
[
"protected",
"function",
"expandUrl",
"(",
"$",
"url",
")",
"{",
"// skip if no short url",
"if",
"(",
"!",
"ParserUtil",
"::",
"isShortUrl",
"(",
"$",
"url",
")",
")",
"{",
"return",
"$",
"url",
";",
"}",
"$",
"header_location",
"=",
"get_headers",
"(",
"$",
"url",
",",
"1",
")",
"[",
"'Location'",
"]",
";",
"return",
"$",
"header_location",
"?",
":",
"$",
"url",
";",
"}"
] |
Expand if url is already a short url
@param $url
@return mixed
|
[
"Expand",
"if",
"url",
"is",
"already",
"a",
"short",
"url"
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/EntityService/CTAService.php#L223-L233
|
233,187
|
CampaignChain/core
|
EntityService/CTAService.php
|
CTAService.generateTrackingUrl
|
protected function generateTrackingUrl($url, $trackingId)
{
$trackingUrl = ParserUtil::addUrlParam($url, $this->trackingIdName, $trackingId);
// Pass the base URL if tracking script runs in dev or dev-stay mode.
if($this->trackingJsMode == 'dev' || $this->trackingJsMode == 'dev-stay'){
$trackingUrl = ParserUtil::addUrlParam($trackingUrl, 'cctapi', urlencode($this->baseUrl));
}
return $trackingUrl;
}
|
php
|
protected function generateTrackingUrl($url, $trackingId)
{
$trackingUrl = ParserUtil::addUrlParam($url, $this->trackingIdName, $trackingId);
// Pass the base URL if tracking script runs in dev or dev-stay mode.
if($this->trackingJsMode == 'dev' || $this->trackingJsMode == 'dev-stay'){
$trackingUrl = ParserUtil::addUrlParam($trackingUrl, 'cctapi', urlencode($this->baseUrl));
}
return $trackingUrl;
}
|
[
"protected",
"function",
"generateTrackingUrl",
"(",
"$",
"url",
",",
"$",
"trackingId",
")",
"{",
"$",
"trackingUrl",
"=",
"ParserUtil",
"::",
"addUrlParam",
"(",
"$",
"url",
",",
"$",
"this",
"->",
"trackingIdName",
",",
"$",
"trackingId",
")",
";",
"// Pass the base URL if tracking script runs in dev or dev-stay mode.",
"if",
"(",
"$",
"this",
"->",
"trackingJsMode",
"==",
"'dev'",
"||",
"$",
"this",
"->",
"trackingJsMode",
"==",
"'dev-stay'",
")",
"{",
"$",
"trackingUrl",
"=",
"ParserUtil",
"::",
"addUrlParam",
"(",
"$",
"trackingUrl",
",",
"'cctapi'",
",",
"urlencode",
"(",
"$",
"this",
"->",
"baseUrl",
")",
")",
";",
"}",
"return",
"$",
"trackingUrl",
";",
"}"
] |
Append the CampaignChain Tracking ID to the URL.
@param $url
@param $trackingId
@return mixed|string
|
[
"Append",
"the",
"CampaignChain",
"Tracking",
"ID",
"to",
"the",
"URL",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/EntityService/CTAService.php#L242-L252
|
233,188
|
CampaignChain/core
|
EntityService/CTAService.php
|
CTAService.getUniqueUrl
|
public function getUniqueUrl($url, $uniqueId)
{
// If the shortened URL is supposed to be unique, then we modify the URL.
$urlParts = parse_url($url);
if(!isset($urlParts['fragment'])){
//
$url .= '#'.$uniqueId;
} else {
//
$url = ParserUtil::addUrlParam($url, $this->uniqueParamName, $uniqueId);
}
return $url;
}
|
php
|
public function getUniqueUrl($url, $uniqueId)
{
// If the shortened URL is supposed to be unique, then we modify the URL.
$urlParts = parse_url($url);
if(!isset($urlParts['fragment'])){
//
$url .= '#'.$uniqueId;
} else {
//
$url = ParserUtil::addUrlParam($url, $this->uniqueParamName, $uniqueId);
}
return $url;
}
|
[
"public",
"function",
"getUniqueUrl",
"(",
"$",
"url",
",",
"$",
"uniqueId",
")",
"{",
"// If the shortened URL is supposed to be unique, then we modify the URL.",
"$",
"urlParts",
"=",
"parse_url",
"(",
"$",
"url",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"urlParts",
"[",
"'fragment'",
"]",
")",
")",
"{",
"//",
"$",
"url",
".=",
"'#'",
".",
"$",
"uniqueId",
";",
"}",
"else",
"{",
"//",
"$",
"url",
"=",
"ParserUtil",
"::",
"addUrlParam",
"(",
"$",
"url",
",",
"$",
"this",
"->",
"uniqueParamName",
",",
"$",
"uniqueId",
")",
";",
"}",
"return",
"$",
"url",
";",
"}"
] |
Modifies a URL so that it results into a unique short URL.
If a URL has no fragment, we add a unique ID as one. For example:
http://www.example.com/#2
If a URL fragment exists, we add a query parameter instead. For example:
http:/www.example.com/?ccshortly=2#fragment
@param string $url
@param integer $uniqueId
@return string
|
[
"Modifies",
"a",
"URL",
"so",
"that",
"it",
"results",
"into",
"a",
"unique",
"short",
"URL",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/EntityService/CTAService.php#L267-L280
|
233,189
|
CampaignChain/core
|
EntityService/CTAService.php
|
CTAService.getShortenedUrl
|
protected function getShortenedUrl($url, $uniqueId = null)
{
// skip if localhost
if (in_array(parse_url($url, PHP_URL_HOST), array('localhost', '127.0.0.1'))) {
return $url;
}
$link = new Link();
$link->setLongUrl($url);
$this->urlShortener->shorten($link);
return $link->getShortUrl();
}
|
php
|
protected function getShortenedUrl($url, $uniqueId = null)
{
// skip if localhost
if (in_array(parse_url($url, PHP_URL_HOST), array('localhost', '127.0.0.1'))) {
return $url;
}
$link = new Link();
$link->setLongUrl($url);
$this->urlShortener->shorten($link);
return $link->getShortUrl();
}
|
[
"protected",
"function",
"getShortenedUrl",
"(",
"$",
"url",
",",
"$",
"uniqueId",
"=",
"null",
")",
"{",
"// skip if localhost",
"if",
"(",
"in_array",
"(",
"parse_url",
"(",
"$",
"url",
",",
"PHP_URL_HOST",
")",
",",
"array",
"(",
"'localhost'",
",",
"'127.0.0.1'",
")",
")",
")",
"{",
"return",
"$",
"url",
";",
"}",
"$",
"link",
"=",
"new",
"Link",
"(",
")",
";",
"$",
"link",
"->",
"setLongUrl",
"(",
"$",
"url",
")",
";",
"$",
"this",
"->",
"urlShortener",
"->",
"shorten",
"(",
"$",
"link",
")",
";",
"return",
"$",
"link",
"->",
"getShortUrl",
"(",
")",
";",
"}"
] |
Use shortener service to shorten url
@param $url
@param integer $uniqueId
@return mixed
|
[
"Use",
"shortener",
"service",
"to",
"shorten",
"url"
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/EntityService/CTAService.php#L289-L302
|
233,190
|
CampaignChain/core
|
EntityService/CTAService.php
|
CTAService.countShortenedUrls
|
protected function countShortenedUrls($url, Operation $operation, Location $location = null)
{
if($operation->getActivity()->getCampaign()->getInterval()){
$isParentCampaign = false;
$campaign = $operation->getActivity()->getCampaign();
} elseif(
$operation->getActivity()->getCampaign()->getParent() &&
$operation->getActivity()->getCampaign()->getParent()->getInterval()
){
$isParentCampaign = true;
$campaign = $operation->getActivity()->getCampaign()->getParent();
}
$qb = $this->em
->getRepository('CampaignChainCoreBundle:CTA')
->createQueryBuilder('cta')
->from('CampaignChainCoreBundle:Campaign', 'c')
->from('CampaignChainCoreBundle:Activity', 'a')
->from('CampaignChainCoreBundle:Operation', 'o')
->where('cta.originalUrl = :originalUrl')
->setParameter('originalUrl', $url)
->andWhere('a.location = :location')
->setParameter('location', $operation->getActivity()->getLocation())
->andWhere('cta.operation = o.id')
->andWhere('o.activity = a.id');
if(!$isParentCampaign) {
$qb->andWhere('a.campaign = :campaign');
} else {
$qb->andWhere('a.campaign = c.id')
->andWhere('c.parent = :campaign');
}
$qb->setParameter('campaign', $campaign);
if($location) {
$qb->andWhere('cta.location = :location')
->setParameter('location', $location);
} else {
$qb->andWhere('cta.location IS NULL');
}
$results = $qb->getQuery()->getResult();
return count($results);
}
|
php
|
protected function countShortenedUrls($url, Operation $operation, Location $location = null)
{
if($operation->getActivity()->getCampaign()->getInterval()){
$isParentCampaign = false;
$campaign = $operation->getActivity()->getCampaign();
} elseif(
$operation->getActivity()->getCampaign()->getParent() &&
$operation->getActivity()->getCampaign()->getParent()->getInterval()
){
$isParentCampaign = true;
$campaign = $operation->getActivity()->getCampaign()->getParent();
}
$qb = $this->em
->getRepository('CampaignChainCoreBundle:CTA')
->createQueryBuilder('cta')
->from('CampaignChainCoreBundle:Campaign', 'c')
->from('CampaignChainCoreBundle:Activity', 'a')
->from('CampaignChainCoreBundle:Operation', 'o')
->where('cta.originalUrl = :originalUrl')
->setParameter('originalUrl', $url)
->andWhere('a.location = :location')
->setParameter('location', $operation->getActivity()->getLocation())
->andWhere('cta.operation = o.id')
->andWhere('o.activity = a.id');
if(!$isParentCampaign) {
$qb->andWhere('a.campaign = :campaign');
} else {
$qb->andWhere('a.campaign = c.id')
->andWhere('c.parent = :campaign');
}
$qb->setParameter('campaign', $campaign);
if($location) {
$qb->andWhere('cta.location = :location')
->setParameter('location', $location);
} else {
$qb->andWhere('cta.location IS NULL');
}
$results = $qb->getQuery()->getResult();
return count($results);
}
|
[
"protected",
"function",
"countShortenedUrls",
"(",
"$",
"url",
",",
"Operation",
"$",
"operation",
",",
"Location",
"$",
"location",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"operation",
"->",
"getActivity",
"(",
")",
"->",
"getCampaign",
"(",
")",
"->",
"getInterval",
"(",
")",
")",
"{",
"$",
"isParentCampaign",
"=",
"false",
";",
"$",
"campaign",
"=",
"$",
"operation",
"->",
"getActivity",
"(",
")",
"->",
"getCampaign",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"operation",
"->",
"getActivity",
"(",
")",
"->",
"getCampaign",
"(",
")",
"->",
"getParent",
"(",
")",
"&&",
"$",
"operation",
"->",
"getActivity",
"(",
")",
"->",
"getCampaign",
"(",
")",
"->",
"getParent",
"(",
")",
"->",
"getInterval",
"(",
")",
")",
"{",
"$",
"isParentCampaign",
"=",
"true",
";",
"$",
"campaign",
"=",
"$",
"operation",
"->",
"getActivity",
"(",
")",
"->",
"getCampaign",
"(",
")",
"->",
"getParent",
"(",
")",
";",
"}",
"$",
"qb",
"=",
"$",
"this",
"->",
"em",
"->",
"getRepository",
"(",
"'CampaignChainCoreBundle:CTA'",
")",
"->",
"createQueryBuilder",
"(",
"'cta'",
")",
"->",
"from",
"(",
"'CampaignChainCoreBundle:Campaign'",
",",
"'c'",
")",
"->",
"from",
"(",
"'CampaignChainCoreBundle:Activity'",
",",
"'a'",
")",
"->",
"from",
"(",
"'CampaignChainCoreBundle:Operation'",
",",
"'o'",
")",
"->",
"where",
"(",
"'cta.originalUrl = :originalUrl'",
")",
"->",
"setParameter",
"(",
"'originalUrl'",
",",
"$",
"url",
")",
"->",
"andWhere",
"(",
"'a.location = :location'",
")",
"->",
"setParameter",
"(",
"'location'",
",",
"$",
"operation",
"->",
"getActivity",
"(",
")",
"->",
"getLocation",
"(",
")",
")",
"->",
"andWhere",
"(",
"'cta.operation = o.id'",
")",
"->",
"andWhere",
"(",
"'o.activity = a.id'",
")",
";",
"if",
"(",
"!",
"$",
"isParentCampaign",
")",
"{",
"$",
"qb",
"->",
"andWhere",
"(",
"'a.campaign = :campaign'",
")",
";",
"}",
"else",
"{",
"$",
"qb",
"->",
"andWhere",
"(",
"'a.campaign = c.id'",
")",
"->",
"andWhere",
"(",
"'c.parent = :campaign'",
")",
";",
"}",
"$",
"qb",
"->",
"setParameter",
"(",
"'campaign'",
",",
"$",
"campaign",
")",
";",
"if",
"(",
"$",
"location",
")",
"{",
"$",
"qb",
"->",
"andWhere",
"(",
"'cta.location = :location'",
")",
"->",
"setParameter",
"(",
"'location'",
",",
"$",
"location",
")",
";",
"}",
"else",
"{",
"$",
"qb",
"->",
"andWhere",
"(",
"'cta.location IS NULL'",
")",
";",
"}",
"$",
"results",
"=",
"$",
"qb",
"->",
"getQuery",
"(",
")",
"->",
"getResult",
"(",
")",
";",
"return",
"count",
"(",
"$",
"results",
")",
";",
"}"
] |
Counts the number of shortened URLs available for the same URL.
@param $url
@param Operation $operation
@param Location $location
@return mixed
|
[
"Counts",
"the",
"number",
"of",
"shortened",
"URLs",
"available",
"for",
"the",
"same",
"URL",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/EntityService/CTAService.php#L347-L390
|
233,191
|
CampaignChain/core
|
Util/VariableUtil.php
|
VariableUtil.arrayMerge
|
static function arrayMerge($array1, $array2, $overwriteValue = true)
{
// if($overwriteValue) {
// foreach ($array2 as $key => $Value) {
// if (array_key_exists($key, $array1) && is_array($Value)) {
// $array1[$key] = self::arrayMergeRecursively(
// $array1[$key], $array2[$key], $overwriteValue
// );
// } else {
// $array1[$key] = $Value;
// }
// }
// } else {
// $array1 = array_merge_recursive($array1, $array2);
// }
$arrayMerged = array_merge_recursive($array1, $array2);
$arrayUnique = array_unique($arrayMerged, SORT_STRING);
return $arrayUnique;
}
|
php
|
static function arrayMerge($array1, $array2, $overwriteValue = true)
{
// if($overwriteValue) {
// foreach ($array2 as $key => $Value) {
// if (array_key_exists($key, $array1) && is_array($Value)) {
// $array1[$key] = self::arrayMergeRecursively(
// $array1[$key], $array2[$key], $overwriteValue
// );
// } else {
// $array1[$key] = $Value;
// }
// }
// } else {
// $array1 = array_merge_recursive($array1, $array2);
// }
$arrayMerged = array_merge_recursive($array1, $array2);
$arrayUnique = array_unique($arrayMerged, SORT_STRING);
return $arrayUnique;
}
|
[
"static",
"function",
"arrayMerge",
"(",
"$",
"array1",
",",
"$",
"array2",
",",
"$",
"overwriteValue",
"=",
"true",
")",
"{",
"// if($overwriteValue) {",
"// foreach ($array2 as $key => $Value) {",
"// if (array_key_exists($key, $array1) && is_array($Value)) {",
"// $array1[$key] = self::arrayMergeRecursively(",
"// $array1[$key], $array2[$key], $overwriteValue",
"// );",
"// } else {",
"// $array1[$key] = $Value;",
"// }",
"// }",
"// } else {",
"// $array1 = array_merge_recursive($array1, $array2);",
"// }",
"$",
"arrayMerged",
"=",
"array_merge_recursive",
"(",
"$",
"array1",
",",
"$",
"array2",
")",
";",
"$",
"arrayUnique",
"=",
"array_unique",
"(",
"$",
"arrayMerged",
",",
"SORT_STRING",
")",
";",
"return",
"$",
"arrayUnique",
";",
"}"
] |
Merges two arrays recursively, either by allowing for duplicate values
for a key or by overwriting identical values.
@param $array1
@param $array2
@param bool|true $overwriteValue
@return array
|
[
"Merges",
"two",
"arrays",
"recursively",
"either",
"by",
"allowing",
"for",
"duplicate",
"values",
"for",
"a",
"key",
"or",
"by",
"overwriting",
"identical",
"values",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Util/VariableUtil.php#L31-L51
|
233,192
|
CampaignChain/core
|
Util/VariableUtil.php
|
VariableUtil.arraysIntersect
|
static function arraysIntersect(array $array1, array $array2)
{
$match = array_intersect($array1, $array2);
if(is_array($match) && count($match)){
return true;
}
return false;
}
|
php
|
static function arraysIntersect(array $array1, array $array2)
{
$match = array_intersect($array1, $array2);
if(is_array($match) && count($match)){
return true;
}
return false;
}
|
[
"static",
"function",
"arraysIntersect",
"(",
"array",
"$",
"array1",
",",
"array",
"$",
"array2",
")",
"{",
"$",
"match",
"=",
"array_intersect",
"(",
"$",
"array1",
",",
"$",
"array2",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"match",
")",
"&&",
"count",
"(",
"$",
"match",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
At least 1 value in 1 array is identical with 1 value in the other array.
@param array $array1
@param array $array2
@return bool
|
[
"At",
"least",
"1",
"value",
"in",
"1",
"array",
"is",
"identical",
"with",
"1",
"value",
"in",
"the",
"other",
"array",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Util/VariableUtil.php#L112-L120
|
233,193
|
CampaignChain/core
|
Util/VariableUtil.php
|
VariableUtil.stringContainsWord
|
static function stringContainsWord($str, array $arr)
{
foreach($arr as $a) {
if (stripos($str,$a) !== false) return true;
}
return false;
}
|
php
|
static function stringContainsWord($str, array $arr)
{
foreach($arr as $a) {
if (stripos($str,$a) !== false) return true;
}
return false;
}
|
[
"static",
"function",
"stringContainsWord",
"(",
"$",
"str",
",",
"array",
"$",
"arr",
")",
"{",
"foreach",
"(",
"$",
"arr",
"as",
"$",
"a",
")",
"{",
"if",
"(",
"stripos",
"(",
"$",
"str",
",",
"$",
"a",
")",
"!==",
"false",
")",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Minimum 1 word in the array can be found in the string.
@param $str
@param array $arr
@return bool
|
[
"Minimum",
"1",
"word",
"in",
"the",
"array",
"can",
"be",
"found",
"in",
"the",
"string",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Util/VariableUtil.php#L129-L135
|
233,194
|
prooph/link-process-manager
|
src/Model/ProcessingMetadata.php
|
ProcessingMetadata.merge
|
public function merge(ProcessingMetadata $metadata)
{
return new self(ArrayUtils::merge($this->metadata->toArray(), $metadata->toArray()));
}
|
php
|
public function merge(ProcessingMetadata $metadata)
{
return new self(ArrayUtils::merge($this->metadata->toArray(), $metadata->toArray()));
}
|
[
"public",
"function",
"merge",
"(",
"ProcessingMetadata",
"$",
"metadata",
")",
"{",
"return",
"new",
"self",
"(",
"ArrayUtils",
"::",
"merge",
"(",
"$",
"this",
"->",
"metadata",
"->",
"toArray",
"(",
")",
",",
"$",
"metadata",
"->",
"toArray",
"(",
")",
")",
")",
";",
"}"
] |
Merges given metadata recursive into existing metadata and returns a new ProcessingMetadata object
@param ProcessingMetadata $metadata
@return ProcessingMetadata
|
[
"Merges",
"given",
"metadata",
"recursive",
"into",
"existing",
"metadata",
"and",
"returns",
"a",
"new",
"ProcessingMetadata",
"object"
] |
3d6c8bdc72e855786227747bf06bcf8221f7860a
|
https://github.com/prooph/link-process-manager/blob/3d6c8bdc72e855786227747bf06bcf8221f7860a/src/Model/ProcessingMetadata.php#L67-L70
|
233,195
|
prooph/link-process-manager
|
src/Model/ProcessingMetadata.php
|
ProcessingMetadata.setMetadata
|
private function setMetadata(array $metadata)
{
foreach($metadata as $key => &$partial) {
$this->assertArrayOrScalar($partial, $key);
}
$this->metadata = new ArrayReader($metadata);
}
|
php
|
private function setMetadata(array $metadata)
{
foreach($metadata as $key => &$partial) {
$this->assertArrayOrScalar($partial, $key);
}
$this->metadata = new ArrayReader($metadata);
}
|
[
"private",
"function",
"setMetadata",
"(",
"array",
"$",
"metadata",
")",
"{",
"foreach",
"(",
"$",
"metadata",
"as",
"$",
"key",
"=>",
"&",
"$",
"partial",
")",
"{",
"$",
"this",
"->",
"assertArrayOrScalar",
"(",
"$",
"partial",
",",
"$",
"key",
")",
";",
"}",
"$",
"this",
"->",
"metadata",
"=",
"new",
"ArrayReader",
"(",
"$",
"metadata",
")",
";",
"}"
] |
Assert that metadata only contains scalar values and arrays
@param array $metadata
|
[
"Assert",
"that",
"metadata",
"only",
"contains",
"scalar",
"values",
"and",
"arrays"
] |
3d6c8bdc72e855786227747bf06bcf8221f7860a
|
https://github.com/prooph/link-process-manager/blob/3d6c8bdc72e855786227747bf06bcf8221f7860a/src/Model/ProcessingMetadata.php#L107-L114
|
233,196
|
prooph/link-process-manager
|
src/Model/ProcessingMetadata.php
|
ProcessingMetadata.assertArrayOrScalar
|
private function assertArrayOrScalar(&$partialMetadata, $partialKey)
{
if (is_scalar($partialMetadata)) return;
if (! is_array($partialMetadata)) {
throw new \InvalidArgumentException(sprintf(
'The metadata key %s contains an invalid data type. Allowed types are all scalar types and arrays. Got %s',
$partialKey,
(is_object($partialMetadata)? get_class($partialMetadata) : gettype($partialMetadata))
));
}
foreach ($partialMetadata as $subKey => &$subPartial) {
$this->assertArrayOrScalar($subPartial, $subKey);
}
}
|
php
|
private function assertArrayOrScalar(&$partialMetadata, $partialKey)
{
if (is_scalar($partialMetadata)) return;
if (! is_array($partialMetadata)) {
throw new \InvalidArgumentException(sprintf(
'The metadata key %s contains an invalid data type. Allowed types are all scalar types and arrays. Got %s',
$partialKey,
(is_object($partialMetadata)? get_class($partialMetadata) : gettype($partialMetadata))
));
}
foreach ($partialMetadata as $subKey => &$subPartial) {
$this->assertArrayOrScalar($subPartial, $subKey);
}
}
|
[
"private",
"function",
"assertArrayOrScalar",
"(",
"&",
"$",
"partialMetadata",
",",
"$",
"partialKey",
")",
"{",
"if",
"(",
"is_scalar",
"(",
"$",
"partialMetadata",
")",
")",
"return",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"partialMetadata",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The metadata key %s contains an invalid data type. Allowed types are all scalar types and arrays. Got %s'",
",",
"$",
"partialKey",
",",
"(",
"is_object",
"(",
"$",
"partialMetadata",
")",
"?",
"get_class",
"(",
"$",
"partialMetadata",
")",
":",
"gettype",
"(",
"$",
"partialMetadata",
")",
")",
")",
")",
";",
"}",
"foreach",
"(",
"$",
"partialMetadata",
"as",
"$",
"subKey",
"=>",
"&",
"$",
"subPartial",
")",
"{",
"$",
"this",
"->",
"assertArrayOrScalar",
"(",
"$",
"subPartial",
",",
"$",
"subKey",
")",
";",
"}",
"}"
] |
Recursive assertion of metadata
@param mixed $partialMetadata
@param string $partialKey
@throws \InvalidArgumentException
|
[
"Recursive",
"assertion",
"of",
"metadata"
] |
3d6c8bdc72e855786227747bf06bcf8221f7860a
|
https://github.com/prooph/link-process-manager/blob/3d6c8bdc72e855786227747bf06bcf8221f7860a/src/Model/ProcessingMetadata.php#L123-L138
|
233,197
|
civicrm/civicrm-setup
|
src/Setup/DbUtil.php
|
DbUtil.execute
|
public static function execute($conn, $sql) {
$conn = is_array($conn) ? self::connect($conn) : $conn;
$result = $conn->query($sql);
if (!$result) {
throw new SqlException("Cannot execute $sql: " . $conn->error);
}
if ($result && $result !== TRUE) {
$result->free_result();
}
}
|
php
|
public static function execute($conn, $sql) {
$conn = is_array($conn) ? self::connect($conn) : $conn;
$result = $conn->query($sql);
if (!$result) {
throw new SqlException("Cannot execute $sql: " . $conn->error);
}
if ($result && $result !== TRUE) {
$result->free_result();
}
}
|
[
"public",
"static",
"function",
"execute",
"(",
"$",
"conn",
",",
"$",
"sql",
")",
"{",
"$",
"conn",
"=",
"is_array",
"(",
"$",
"conn",
")",
"?",
"self",
"::",
"connect",
"(",
"$",
"conn",
")",
":",
"$",
"conn",
";",
"$",
"result",
"=",
"$",
"conn",
"->",
"query",
"(",
"$",
"sql",
")",
";",
"if",
"(",
"!",
"$",
"result",
")",
"{",
"throw",
"new",
"SqlException",
"(",
"\"Cannot execute $sql: \"",
".",
"$",
"conn",
"->",
"error",
")",
";",
"}",
"if",
"(",
"$",
"result",
"&&",
"$",
"result",
"!==",
"TRUE",
")",
"{",
"$",
"result",
"->",
"free_result",
"(",
")",
";",
"}",
"}"
] |
Execute query. Ignore the results.
@param \mysqli|array $conn
The DB to query. Either a mysqli connection, or credentials for
establishing one.
@param string $sql
@throws SqlException
|
[
"Execute",
"query",
".",
"Ignore",
"the",
"results",
"."
] |
556b312faf78781c85c4fc4ae6c1c3b658da9e09
|
https://github.com/civicrm/civicrm-setup/blob/556b312faf78781c85c4fc4ae6c1c3b658da9e09/src/Setup/DbUtil.php#L166-L177
|
233,198
|
civicrm/civicrm-setup
|
src/Setup/DbUtil.php
|
DbUtil.fetchAll
|
public static function fetchAll($conn, $sql) {
$conn = is_array($conn) ? self::connect($conn) : $conn;
$result = $conn->query($sql);
if (!$result) {
throw new SqlException("Cannot execute $sql: " . $conn->error);
}
$rows = array();
while ($row = $result->fetch_assoc()) {
$rows[] = $row;
}
$result->free_result();
return $rows;
}
|
php
|
public static function fetchAll($conn, $sql) {
$conn = is_array($conn) ? self::connect($conn) : $conn;
$result = $conn->query($sql);
if (!$result) {
throw new SqlException("Cannot execute $sql: " . $conn->error);
}
$rows = array();
while ($row = $result->fetch_assoc()) {
$rows[] = $row;
}
$result->free_result();
return $rows;
}
|
[
"public",
"static",
"function",
"fetchAll",
"(",
"$",
"conn",
",",
"$",
"sql",
")",
"{",
"$",
"conn",
"=",
"is_array",
"(",
"$",
"conn",
")",
"?",
"self",
"::",
"connect",
"(",
"$",
"conn",
")",
":",
"$",
"conn",
";",
"$",
"result",
"=",
"$",
"conn",
"->",
"query",
"(",
"$",
"sql",
")",
";",
"if",
"(",
"!",
"$",
"result",
")",
"{",
"throw",
"new",
"SqlException",
"(",
"\"Cannot execute $sql: \"",
".",
"$",
"conn",
"->",
"error",
")",
";",
"}",
"$",
"rows",
"=",
"array",
"(",
")",
";",
"while",
"(",
"$",
"row",
"=",
"$",
"result",
"->",
"fetch_assoc",
"(",
")",
")",
"{",
"$",
"rows",
"[",
"]",
"=",
"$",
"row",
";",
"}",
"$",
"result",
"->",
"free_result",
"(",
")",
";",
"return",
"$",
"rows",
";",
"}"
] |
Get all the results of a SQL query, as an array.
@param \mysqli|array $conn
The DB to query. Either a mysqli connection, or credentials for
establishing one.
@param string $sql
@return array
@throws \Exception
|
[
"Get",
"all",
"the",
"results",
"of",
"a",
"SQL",
"query",
"as",
"an",
"array",
"."
] |
556b312faf78781c85c4fc4ae6c1c3b658da9e09
|
https://github.com/civicrm/civicrm-setup/blob/556b312faf78781c85c4fc4ae6c1c3b658da9e09/src/Setup/DbUtil.php#L189-L203
|
233,199
|
civicrm/civicrm-setup
|
src/Setup/DbUtil.php
|
DbUtil.findViews
|
public static function findViews($conn, $databaseName) {
$sql = sprintf("SELECT table_name FROM information_schema.TABLES WHERE TABLE_SCHEMA='%s' AND TABLE_TYPE = 'VIEW'",
$conn->escape_string($databaseName));
return array_map(function($arr){
return $arr['table_name'];
}, self::fetchAll($conn, $sql));
}
|
php
|
public static function findViews($conn, $databaseName) {
$sql = sprintf("SELECT table_name FROM information_schema.TABLES WHERE TABLE_SCHEMA='%s' AND TABLE_TYPE = 'VIEW'",
$conn->escape_string($databaseName));
return array_map(function($arr){
return $arr['table_name'];
}, self::fetchAll($conn, $sql));
}
|
[
"public",
"static",
"function",
"findViews",
"(",
"$",
"conn",
",",
"$",
"databaseName",
")",
"{",
"$",
"sql",
"=",
"sprintf",
"(",
"\"SELECT table_name FROM information_schema.TABLES WHERE TABLE_SCHEMA='%s' AND TABLE_TYPE = 'VIEW'\"",
",",
"$",
"conn",
"->",
"escape_string",
"(",
"$",
"databaseName",
")",
")",
";",
"return",
"array_map",
"(",
"function",
"(",
"$",
"arr",
")",
"{",
"return",
"$",
"arr",
"[",
"'table_name'",
"]",
";",
"}",
",",
"self",
"::",
"fetchAll",
"(",
"$",
"conn",
",",
"$",
"sql",
")",
")",
";",
"}"
] |
Get a list of views in the given database.
@param \mysqli|array $conn
The DB to query. Either a mysqli connection, or credentials for
establishing one.
@param string $databaseName
@return array
Ex: ['civicrm_view1', 'civicrm_view2']
|
[
"Get",
"a",
"list",
"of",
"views",
"in",
"the",
"given",
"database",
"."
] |
556b312faf78781c85c4fc4ae6c1c3b658da9e09
|
https://github.com/civicrm/civicrm-setup/blob/556b312faf78781c85c4fc4ae6c1c3b658da9e09/src/Setup/DbUtil.php#L215-L222
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.