repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
minkphp/SahiClient | src/Accessor/AbstractDomAccessor.php | AbstractDomAccessor.getArgumentsString | protected function getArgumentsString()
{
$arguments = array($this->getIdentifierArgumentString());
if ($this->hasRelations()) {
$arguments[] = $this->getRelationArgumentsString();
}
return implode(', ', $arguments);
} | php | protected function getArgumentsString()
{
$arguments = array($this->getIdentifierArgumentString());
if ($this->hasRelations()) {
$arguments[] = $this->getRelationArgumentsString();
}
return implode(', ', $arguments);
} | [
"protected",
"function",
"getArgumentsString",
"(",
")",
"{",
"$",
"arguments",
"=",
"array",
"(",
"$",
"this",
"->",
"getIdentifierArgumentString",
"(",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"hasRelations",
"(",
")",
")",
"{",
"$",
"arguments",
"... | Return comma separated Sahi DOM arguments.
@return string | [
"Return",
"comma",
"separated",
"Sahi",
"DOM",
"arguments",
"."
] | edd87e8445c4a1c28233eeae5f226fac7afc5ed8 | https://github.com/minkphp/SahiClient/blob/edd87e8445c4a1c28233eeae5f226fac7afc5ed8/src/Accessor/AbstractDomAccessor.php#L67-L76 | train |
VincentChalnot/SidusFilterBundle | Pagination/DoctrineORMPaginator.php | DoctrineORMPaginator.useOutputWalker | protected function useOutputWalker(Query $query)
{
if (null === $this->useOutputWalkers) {
return false === (bool) $query->getHint(Query::HINT_CUSTOM_OUTPUT_WALKER);
}
return $this->useOutputWalkers;
} | php | protected function useOutputWalker(Query $query)
{
if (null === $this->useOutputWalkers) {
return false === (bool) $query->getHint(Query::HINT_CUSTOM_OUTPUT_WALKER);
}
return $this->useOutputWalkers;
} | [
"protected",
"function",
"useOutputWalker",
"(",
"Query",
"$",
"query",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"useOutputWalkers",
")",
"{",
"return",
"false",
"===",
"(",
"bool",
")",
"$",
"query",
"->",
"getHint",
"(",
"Query",
"::",
... | Determines whether to use an output walker for the query.
@param Query $query The query.
@return bool | [
"Determines",
"whether",
"to",
"use",
"an",
"output",
"walker",
"for",
"the",
"query",
"."
] | c11a60fe29d1410b8092617d8ffd58f3bdd1fd40 | https://github.com/VincentChalnot/SidusFilterBundle/blob/c11a60fe29d1410b8092617d8ffd58f3bdd1fd40/Pagination/DoctrineORMPaginator.php#L192-L199 | train |
VincentChalnot/SidusFilterBundle | Pagination/DoctrineORMPaginator.php | DoctrineORMPaginator.appendTreeWalker | protected function appendTreeWalker(Query $query, $walkerClass)
{
$hints = $query->getHint(Query::HINT_CUSTOM_TREE_WALKERS);
if (false === $hints) {
$hints = [];
}
$hints[] = $walkerClass;
$query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, $hints);
} | php | protected function appendTreeWalker(Query $query, $walkerClass)
{
$hints = $query->getHint(Query::HINT_CUSTOM_TREE_WALKERS);
if (false === $hints) {
$hints = [];
}
$hints[] = $walkerClass;
$query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, $hints);
} | [
"protected",
"function",
"appendTreeWalker",
"(",
"Query",
"$",
"query",
",",
"$",
"walkerClass",
")",
"{",
"$",
"hints",
"=",
"$",
"query",
"->",
"getHint",
"(",
"Query",
"::",
"HINT_CUSTOM_TREE_WALKERS",
")",
";",
"if",
"(",
"false",
"===",
"$",
"hints",... | Appends a custom tree walker to the tree walkers hint.
@param Query $query
@param string $walkerClass | [
"Appends",
"a",
"custom",
"tree",
"walker",
"to",
"the",
"tree",
"walkers",
"hint",
"."
] | c11a60fe29d1410b8092617d8ffd58f3bdd1fd40 | https://github.com/VincentChalnot/SidusFilterBundle/blob/c11a60fe29d1410b8092617d8ffd58f3bdd1fd40/Pagination/DoctrineORMPaginator.php#L207-L217 | train |
dframe/database | src/Helper/PDOHelper.php | PDOHelper.arrayToXml | public function arrayToXml($arrayData = [])
{
$xml = '<?xml version="1.0" encoding="UTF-8"?>';
$xml .= '<root>';
foreach ($arrayData as $key => $value) {
$xml .= '<xml_data>';
if (is_array($value)) {
foreach ($value as $k => $v) {
//$k holds the table column name
$xml .= "<$k>";
//embed the SQL data in a CDATA element to avoid XML entity issues
$xml .= "<![CDATA[$v]]>";
//and close the element
$xml .= "</$k>";
}
} else {
//$key holds the table column name
$xml .= "<$key>";
//embed the SQL data in a CDATA element to avoid XML entity issues
$xml .= "<![CDATA[$value]]>";
//and close the element
$xml .= "</$key>";
}
$xml .= '</xml_data>';
}
$xml .= '</root>';
return $xml;
} | php | public function arrayToXml($arrayData = [])
{
$xml = '<?xml version="1.0" encoding="UTF-8"?>';
$xml .= '<root>';
foreach ($arrayData as $key => $value) {
$xml .= '<xml_data>';
if (is_array($value)) {
foreach ($value as $k => $v) {
//$k holds the table column name
$xml .= "<$k>";
//embed the SQL data in a CDATA element to avoid XML entity issues
$xml .= "<![CDATA[$v]]>";
//and close the element
$xml .= "</$k>";
}
} else {
//$key holds the table column name
$xml .= "<$key>";
//embed the SQL data in a CDATA element to avoid XML entity issues
$xml .= "<![CDATA[$value]]>";
//and close the element
$xml .= "</$key>";
}
$xml .= '</xml_data>';
}
$xml .= '</root>';
return $xml;
} | [
"public",
"function",
"arrayToXml",
"(",
"$",
"arrayData",
"=",
"[",
"]",
")",
"{",
"$",
"xml",
"=",
"'<?xml version=\"1.0\" encoding=\"UTF-8\"?>'",
";",
"$",
"xml",
".=",
"'<root>'",
";",
"foreach",
"(",
"$",
"arrayData",
"as",
"$",
"key",
"=>",
"$",
"val... | function definition to convert array to xml
send an array and get xml.
@param array $arrayData
@return string | [
"function",
"definition",
"to",
"convert",
"array",
"to",
"xml",
"send",
"an",
"array",
"and",
"get",
"xml",
"."
] | 6d9ac90d695c33b5e417b58f2134f86f79918387 | https://github.com/dframe/database/blob/6d9ac90d695c33b5e417b58f2134f86f79918387/src/Helper/PDOHelper.php#L55-L83 | train |
dframe/database | src/Helper/PDOHelper.php | PDOHelper.formatSQL | public function formatSQL($sql = '')
{
// Reserved SQL Keywords Data
$reserveSqlKey = 'select|insert|update|delete|truncate|drop|create|add|except|percent|all|exec|plan|alter|execute|precision|and|exists|primary|any|exit|print|as|fetch|proc|asc|file|procedure|authorization|fillfactor|public|backup|for|raiserror|begin|foreign|read|between|freetext|readtext|break|freetexttable|reconfigure|browse|from|references|bulk|full|replication|by|function|restore|cascade|goto|restrict|case|grant|return|check|group|revoke|checkpoint|having|right|close|holdlock|rollback|clustered|identity|rowcount|coalesce|identity_insert|rowguidcol|collate|identitycol|rule|column|if|save|commit|in|schema|compute|index|select|constraint|inner|session_user|contains|insert|set|containstable|intersect|setuser|continue|into|shutdown|convert|is|some|create|join|statistics|cross|key|system_user|current|kill|table|current_date|left|textsize|current_time|like|then|current_timestamp|lineno|to|current_user|load|top|cursor|national|tran|database|nocheck|transaction|dbcc|nonclustered|trigger|deallocate|not|truncate|declare|null|tsequal|default|nullif|union|delete|of|unique|deny|off|update|desc|offsets|updatetext|disk|on|use|distinct|open|user|distributed|opendatasource|values|double|openquery|varying|drop|openrowset|view|dummy|openxml|waitfor|dump|option|when|else|or|where|end|order|while|errlvl|outer|with|escape|over|writetext|absolute|overlaps|action|pad|ada|partial|external|pascal|extract|position|allocate|false|prepare|first|preserve|float|are|prior|privileges|fortran|assertion|found|at|real|avg|get|global|relative|go|bit|bit_length|both|rows|hour|cascaded|scroll|immediate|second|cast|section|catalog|include|char|session|char_length|indicator|character|initially|character_length|size|input|smallint|insensitive|space|int|sql|collation|integer|sqlca|sqlcode|interval|sqlerror|connect|sqlstate|connection|sqlwarning|isolation|substring|constraints|sum|language|corresponding|last|temporary|count|leading|time|level|timestamp|timezone_hour|local|timezone_minute|lower|match|trailing|max|min|translate|date|minute|translation|day|module|trim|month|true|dec|names|decimal|natural|unknown|nchar|deferrable|next|upper|deferred|no|usage|none|using|describe|value|descriptor|diagnostics|numeric|varchar|disconnect|octet_length|domain|only|whenever|work|end-exec|write|year|output|zone|exception|free|admin|general|after|reads|aggregate|alias|recursive|grouping|ref|host|referencing|array|ignore|result|returns|before|role|binary|initialize|rollup|routine|blob|inout|row|boolean|savepoint|breadth|call|scope|search|iterate|large|sequence|class|lateral|sets|clob|less|completion|limit|specific|specifictype|localtime|constructor|localtimestamp|sqlexception|locator|cube|map|current_path|start|current_role|state|cycle|modifies|statement|data|modify|static|structure|terminate|than|nclob|depth|new|deref|destroy|treat|destructor|object|deterministic|old|under|dictionary|operation|unnest|ordinality|out|dynamic|each|parameter|variable|equals|parameters|every|without|path|postfix|prefix|preorder';
// convert in array
$list = explode('|', $reserveSqlKey);
foreach ($list as &$verb) {
$verb = '/\b' . preg_quote($verb, '/') . '\b/';
}
$regex_sign = ['/\b', '\b/'];
// replace matching words
return str_replace(
$regex_sign,
'',
preg_replace(
$list,
array_map(
[
$this,
'highlight_sql',
],
$list
),
strtolower($sql)
)
);
} | php | public function formatSQL($sql = '')
{
// Reserved SQL Keywords Data
$reserveSqlKey = 'select|insert|update|delete|truncate|drop|create|add|except|percent|all|exec|plan|alter|execute|precision|and|exists|primary|any|exit|print|as|fetch|proc|asc|file|procedure|authorization|fillfactor|public|backup|for|raiserror|begin|foreign|read|between|freetext|readtext|break|freetexttable|reconfigure|browse|from|references|bulk|full|replication|by|function|restore|cascade|goto|restrict|case|grant|return|check|group|revoke|checkpoint|having|right|close|holdlock|rollback|clustered|identity|rowcount|coalesce|identity_insert|rowguidcol|collate|identitycol|rule|column|if|save|commit|in|schema|compute|index|select|constraint|inner|session_user|contains|insert|set|containstable|intersect|setuser|continue|into|shutdown|convert|is|some|create|join|statistics|cross|key|system_user|current|kill|table|current_date|left|textsize|current_time|like|then|current_timestamp|lineno|to|current_user|load|top|cursor|national|tran|database|nocheck|transaction|dbcc|nonclustered|trigger|deallocate|not|truncate|declare|null|tsequal|default|nullif|union|delete|of|unique|deny|off|update|desc|offsets|updatetext|disk|on|use|distinct|open|user|distributed|opendatasource|values|double|openquery|varying|drop|openrowset|view|dummy|openxml|waitfor|dump|option|when|else|or|where|end|order|while|errlvl|outer|with|escape|over|writetext|absolute|overlaps|action|pad|ada|partial|external|pascal|extract|position|allocate|false|prepare|first|preserve|float|are|prior|privileges|fortran|assertion|found|at|real|avg|get|global|relative|go|bit|bit_length|both|rows|hour|cascaded|scroll|immediate|second|cast|section|catalog|include|char|session|char_length|indicator|character|initially|character_length|size|input|smallint|insensitive|space|int|sql|collation|integer|sqlca|sqlcode|interval|sqlerror|connect|sqlstate|connection|sqlwarning|isolation|substring|constraints|sum|language|corresponding|last|temporary|count|leading|time|level|timestamp|timezone_hour|local|timezone_minute|lower|match|trailing|max|min|translate|date|minute|translation|day|module|trim|month|true|dec|names|decimal|natural|unknown|nchar|deferrable|next|upper|deferred|no|usage|none|using|describe|value|descriptor|diagnostics|numeric|varchar|disconnect|octet_length|domain|only|whenever|work|end-exec|write|year|output|zone|exception|free|admin|general|after|reads|aggregate|alias|recursive|grouping|ref|host|referencing|array|ignore|result|returns|before|role|binary|initialize|rollup|routine|blob|inout|row|boolean|savepoint|breadth|call|scope|search|iterate|large|sequence|class|lateral|sets|clob|less|completion|limit|specific|specifictype|localtime|constructor|localtimestamp|sqlexception|locator|cube|map|current_path|start|current_role|state|cycle|modifies|statement|data|modify|static|structure|terminate|than|nclob|depth|new|deref|destroy|treat|destructor|object|deterministic|old|under|dictionary|operation|unnest|ordinality|out|dynamic|each|parameter|variable|equals|parameters|every|without|path|postfix|prefix|preorder';
// convert in array
$list = explode('|', $reserveSqlKey);
foreach ($list as &$verb) {
$verb = '/\b' . preg_quote($verb, '/') . '\b/';
}
$regex_sign = ['/\b', '\b/'];
// replace matching words
return str_replace(
$regex_sign,
'',
preg_replace(
$list,
array_map(
[
$this,
'highlight_sql',
],
$list
),
strtolower($sql)
)
);
} | [
"public",
"function",
"formatSQL",
"(",
"$",
"sql",
"=",
"''",
")",
"{",
"// Reserved SQL Keywords Data",
"$",
"reserveSqlKey",
"=",
"'select|insert|update|delete|truncate|drop|create|add|except|percent|all|exec|plan|alter|execute|precision|and|exists|primary|any|exit|print|as|fetch|proc... | Format the SQL Query.
@param $sql string
@return mixed | [
"Format",
"the",
"SQL",
"Query",
"."
] | 6d9ac90d695c33b5e417b58f2134f86f79918387 | https://github.com/dframe/database/blob/6d9ac90d695c33b5e417b58f2134f86f79918387/src/Helper/PDOHelper.php#L92-L118 | train |
dframe/database | src/Helper/PDOHelper.php | PDOHelper.displayHtmlTable | public function displayHtmlTable($aColList = [])
{
$r = '';
if (count($aColList) > 0) {
$r .= '<table border="1">';
$r .= '<thead>';
$r .= '<tr>';
foreach ($aColList[0] as $k => $v) {
$r .= '<td>' . $k . '</td>';
}
$r .= '</tr>';
$r .= '</thead>';
$r .= '<tbody>';
foreach ($aColList as $record) {
$r .= '<tr>';
foreach ($record as $data) {
$r .= '<td>' . $data . '</td>';
}
$r .= '</tr>';
}
$r .= '</tbody>';
$r .= '<table>';
} else {
$r .= '<div class="no-results">No results found for query.</div>';
}
return $r;
} | php | public function displayHtmlTable($aColList = [])
{
$r = '';
if (count($aColList) > 0) {
$r .= '<table border="1">';
$r .= '<thead>';
$r .= '<tr>';
foreach ($aColList[0] as $k => $v) {
$r .= '<td>' . $k . '</td>';
}
$r .= '</tr>';
$r .= '</thead>';
$r .= '<tbody>';
foreach ($aColList as $record) {
$r .= '<tr>';
foreach ($record as $data) {
$r .= '<td>' . $data . '</td>';
}
$r .= '</tr>';
}
$r .= '</tbody>';
$r .= '<table>';
} else {
$r .= '<div class="no-results">No results found for query.</div>';
}
return $r;
} | [
"public",
"function",
"displayHtmlTable",
"(",
"$",
"aColList",
"=",
"[",
"]",
")",
"{",
"$",
"r",
"=",
"''",
";",
"if",
"(",
"count",
"(",
"$",
"aColList",
")",
">",
"0",
")",
"{",
"$",
"r",
".=",
"'<table border=\"1\">'",
";",
"$",
"r",
".=",
"... | Get HTML Table with Data
Send complete array data and get an HTML table with mysql data.
@param array $aColList Result Array data
@return string HTML Table with data | [
"Get",
"HTML",
"Table",
"with",
"Data",
"Send",
"complete",
"array",
"data",
"and",
"get",
"an",
"HTML",
"table",
"with",
"mysql",
"data",
"."
] | 6d9ac90d695c33b5e417b58f2134f86f79918387 | https://github.com/dframe/database/blob/6d9ac90d695c33b5e417b58f2134f86f79918387/src/Helper/PDOHelper.php#L140-L167 | train |
jbouzekri/FileUploaderBundle | Service/Validator/Constraints/FileOwnerValidator.php | FileOwnerValidator.validate | public function validate($value, Constraint $constraint)
{
if (!$value) {
return;
}
$fileHistory = $this->em->getRepository('JbFileUploaderBundle:FileHistory')->find($value);
if (!$fileHistory) {
return;
}
// No userid associated with file. Every one can use it.
if (!$fileHistory->getUserId()) {
return;
}
// No token. Violation as there is a user id associate with file.
$token = $this->tokenStorage->getToken();
if (!$token) {
return $this->createViolation($value, $constraint);
}
// No user. Violation as there is a user id associate with file.
$user = $token->getUser();
if (!$user) {
return $this->createViolation($value, $constraint);
}
if ($user->getId() !== $fileHistory->getUserId()) {
return $this->createViolation($value, $constraint);
}
return;
} | php | public function validate($value, Constraint $constraint)
{
if (!$value) {
return;
}
$fileHistory = $this->em->getRepository('JbFileUploaderBundle:FileHistory')->find($value);
if (!$fileHistory) {
return;
}
// No userid associated with file. Every one can use it.
if (!$fileHistory->getUserId()) {
return;
}
// No token. Violation as there is a user id associate with file.
$token = $this->tokenStorage->getToken();
if (!$token) {
return $this->createViolation($value, $constraint);
}
// No user. Violation as there is a user id associate with file.
$user = $token->getUser();
if (!$user) {
return $this->createViolation($value, $constraint);
}
if ($user->getId() !== $fileHistory->getUserId()) {
return $this->createViolation($value, $constraint);
}
return;
} | [
"public",
"function",
"validate",
"(",
"$",
"value",
",",
"Constraint",
"$",
"constraint",
")",
"{",
"if",
"(",
"!",
"$",
"value",
")",
"{",
"return",
";",
"}",
"$",
"fileHistory",
"=",
"$",
"this",
"->",
"em",
"->",
"getRepository",
"(",
"'JbFileUploa... | Validate that the submitted file is owned by the authenticated user
@param string $value
@param Constraint $constraint | [
"Validate",
"that",
"the",
"submitted",
"file",
"is",
"owned",
"by",
"the",
"authenticated",
"user"
] | 592e7ed827eaa4e7f8f6f52947ca5e5a86835f6c | https://github.com/jbouzekri/FileUploaderBundle/blob/592e7ed827eaa4e7f8f6f52947ca5e5a86835f6c/Service/Validator/Constraints/FileOwnerValidator.php#L53-L86 | train |
jbouzekri/FileUploaderBundle | Service/Validator/Constraints/FileOwnerValidator.php | FileOwnerValidator.createViolation | protected function createViolation($value, Constraint $constraint)
{
$this
->context
->buildViolation($constraint->message)
->setParameter('%filename%', $value)
->addViolation();
} | php | protected function createViolation($value, Constraint $constraint)
{
$this
->context
->buildViolation($constraint->message)
->setParameter('%filename%', $value)
->addViolation();
} | [
"protected",
"function",
"createViolation",
"(",
"$",
"value",
",",
"Constraint",
"$",
"constraint",
")",
"{",
"$",
"this",
"->",
"context",
"->",
"buildViolation",
"(",
"$",
"constraint",
"->",
"message",
")",
"->",
"setParameter",
"(",
"'%filename%'",
",",
... | Create violation for validator
@param string $value
@param Constraint $constraint | [
"Create",
"violation",
"for",
"validator"
] | 592e7ed827eaa4e7f8f6f52947ca5e5a86835f6c | https://github.com/jbouzekri/FileUploaderBundle/blob/592e7ed827eaa4e7f8f6f52947ca5e5a86835f6c/Service/Validator/Constraints/FileOwnerValidator.php#L94-L101 | train |
jbouzekri/FileUploaderBundle | Service/Croper.php | Croper.getCropResolver | protected function getCropResolver($endpoint)
{
$cropedResolver = $this->configuration->getValue($endpoint, 'croped_resolver');
if (!$cropedResolver) {
throw new JbFileUploaderException('No croped_resolver configuration for endpoint '.$endpoint);
}
return $cropedResolver;
} | php | protected function getCropResolver($endpoint)
{
$cropedResolver = $this->configuration->getValue($endpoint, 'croped_resolver');
if (!$cropedResolver) {
throw new JbFileUploaderException('No croped_resolver configuration for endpoint '.$endpoint);
}
return $cropedResolver;
} | [
"protected",
"function",
"getCropResolver",
"(",
"$",
"endpoint",
")",
"{",
"$",
"cropedResolver",
"=",
"$",
"this",
"->",
"configuration",
"->",
"getValue",
"(",
"$",
"endpoint",
",",
"'croped_resolver'",
")",
";",
"if",
"(",
"!",
"$",
"cropedResolver",
")"... | Get crop resolver configuration
@param string $endpoint
@return string
@throws JbFileUploaderException | [
"Get",
"crop",
"resolver",
"configuration"
] | 592e7ed827eaa4e7f8f6f52947ca5e5a86835f6c | https://github.com/jbouzekri/FileUploaderBundle/blob/592e7ed827eaa4e7f8f6f52947ca5e5a86835f6c/Service/Croper.php#L100-L108 | train |
melisplatform/melis-front | src/Listener/MelisFrontMinifiedAssetsCheckerListener.php | MelisFrontMinifiedAssetsCheckerListener.loadAssetsFromConfig | private function loadAssetsFromConfig($content, $dir, $type = null, $isFromVendor = false, $siteName = '')
{
$newContent = $content;
$assetsConfig = $dir.'assets.config.php';
/**
* check if the config exist
*/
if (file_exists($assetsConfig)) {
$files = include($assetsConfig);
/**
* check if assets config is not empty
*/
if (!empty($files)) {
foreach($files as $key => $file){
/**
* check if type to know what asset are
* we going to load
*/
if(empty($type)) {
/**
* this will load the assets from the config
*/
$cssToAdd = "\n";
$jsToLoad = "\n";
if (strtolower($key) == 'css') {
foreach ($file as $k => $css) {
$css = str_replace('/public', '', $css);
$css = $this->editFileName($css, $isFromVendor, $siteName);
$cssToAdd .= '<link href="' . $css . '" media="screen" rel="stylesheet" type="text/css">' . "\n";
}
}
elseif (strtolower($key) == 'js') {
foreach ($file as $k => $js) {
$js = str_replace('/public', '', $js);
$js = $this->editFileName($js, $isFromVendor, $siteName);
$jsToLoad .= '<script type="text/javascript" src="' . $js . '"></script>' . "\n";
}
}
$newContent = $this->createLink($newContent, $cssToAdd, $jsToLoad);
}
elseif($type == 'css'){
/**
* this will load only the css
* from the config
*/
if (strtolower($key) == 'css') {
$cssToAdd = "\n";
foreach ($file as $k => $css) {
$css = str_replace('/public', '', $css);
$css = $this->editFileName($css, $isFromVendor, $siteName);
$cssToAdd .= '<link href="' . $css . '" media="screen" rel="stylesheet" type="text/css">' . "\n";
}
$newContent = $this->createCssLink($content, $cssToAdd);
}
}elseif($type == 'js'){
/**
* this will load the js only from the config
*/
if (strtolower($key) == 'js') {
$jsToLoad = "\n";
foreach ($file as $k => $js) {
$js = str_replace('/public', '', $js);
$js = $this->editFileName($js, $isFromVendor, $siteName);
$jsToLoad .= '<script type="text/javascript" src="' . $js . '"></script>' . "\n";
}
$newContent = $this->createJsLink($content, $jsToLoad);
}
}
}
}
}
return $newContent;
} | php | private function loadAssetsFromConfig($content, $dir, $type = null, $isFromVendor = false, $siteName = '')
{
$newContent = $content;
$assetsConfig = $dir.'assets.config.php';
/**
* check if the config exist
*/
if (file_exists($assetsConfig)) {
$files = include($assetsConfig);
/**
* check if assets config is not empty
*/
if (!empty($files)) {
foreach($files as $key => $file){
/**
* check if type to know what asset are
* we going to load
*/
if(empty($type)) {
/**
* this will load the assets from the config
*/
$cssToAdd = "\n";
$jsToLoad = "\n";
if (strtolower($key) == 'css') {
foreach ($file as $k => $css) {
$css = str_replace('/public', '', $css);
$css = $this->editFileName($css, $isFromVendor, $siteName);
$cssToAdd .= '<link href="' . $css . '" media="screen" rel="stylesheet" type="text/css">' . "\n";
}
}
elseif (strtolower($key) == 'js') {
foreach ($file as $k => $js) {
$js = str_replace('/public', '', $js);
$js = $this->editFileName($js, $isFromVendor, $siteName);
$jsToLoad .= '<script type="text/javascript" src="' . $js . '"></script>' . "\n";
}
}
$newContent = $this->createLink($newContent, $cssToAdd, $jsToLoad);
}
elseif($type == 'css'){
/**
* this will load only the css
* from the config
*/
if (strtolower($key) == 'css') {
$cssToAdd = "\n";
foreach ($file as $k => $css) {
$css = str_replace('/public', '', $css);
$css = $this->editFileName($css, $isFromVendor, $siteName);
$cssToAdd .= '<link href="' . $css . '" media="screen" rel="stylesheet" type="text/css">' . "\n";
}
$newContent = $this->createCssLink($content, $cssToAdd);
}
}elseif($type == 'js'){
/**
* this will load the js only from the config
*/
if (strtolower($key) == 'js') {
$jsToLoad = "\n";
foreach ($file as $k => $js) {
$js = str_replace('/public', '', $js);
$js = $this->editFileName($js, $isFromVendor, $siteName);
$jsToLoad .= '<script type="text/javascript" src="' . $js . '"></script>' . "\n";
}
$newContent = $this->createJsLink($content, $jsToLoad);
}
}
}
}
}
return $newContent;
} | [
"private",
"function",
"loadAssetsFromConfig",
"(",
"$",
"content",
",",
"$",
"dir",
",",
"$",
"type",
"=",
"null",
",",
"$",
"isFromVendor",
"=",
"false",
",",
"$",
"siteName",
"=",
"''",
")",
"{",
"$",
"newContent",
"=",
"$",
"content",
";",
"$",
"... | Function to get all the assets for the
config to load if the bundle does'nt exist
@param $content
@param $dir
@param null $type
@param bool $isFromVendor
@param string $siteName
@return string | [
"Function",
"to",
"get",
"all",
"the",
"assets",
"for",
"the",
"config",
"to",
"load",
"if",
"the",
"bundle",
"does",
"nt",
"exist"
] | 5e03e32687970bb2201e4205612d5539500dc514 | https://github.com/melisplatform/melis-front/blob/5e03e32687970bb2201e4205612d5539500dc514/src/Listener/MelisFrontMinifiedAssetsCheckerListener.php#L173-L245 | train |
melisplatform/melis-front | src/Listener/MelisFrontMinifiedAssetsCheckerListener.php | MelisFrontMinifiedAssetsCheckerListener.editFileName | private function editFileName($fileName, $isFromVendor, $siteName){
if($isFromVendor){
$pathInfo = explode('/', $fileName);
for($i = 0; $i <= sizeof($pathInfo); $i++){
if(!empty($pathInfo[1])){
if(str_replace('-', '', ucwords($pathInfo[1], '-')) == $siteName){
$fileName = preg_replace('/'.$pathInfo[1].'/', $siteName, $fileName, 1);
}
}
}
}
return $fileName;
} | php | private function editFileName($fileName, $isFromVendor, $siteName){
if($isFromVendor){
$pathInfo = explode('/', $fileName);
for($i = 0; $i <= sizeof($pathInfo); $i++){
if(!empty($pathInfo[1])){
if(str_replace('-', '', ucwords($pathInfo[1], '-')) == $siteName){
$fileName = preg_replace('/'.$pathInfo[1].'/', $siteName, $fileName, 1);
}
}
}
}
return $fileName;
} | [
"private",
"function",
"editFileName",
"(",
"$",
"fileName",
",",
"$",
"isFromVendor",
",",
"$",
"siteName",
")",
"{",
"if",
"(",
"$",
"isFromVendor",
")",
"{",
"$",
"pathInfo",
"=",
"explode",
"(",
"'/'",
",",
"$",
"fileName",
")",
";",
"for",
"(",
... | Edit the filename only if site came from vendor
to make the module name camel case
Ex. melis-demo-cms turns into MelisDemoCms
@param $fileName
@param $isFromVendor
@param $siteName
@return string|string[]|null | [
"Edit",
"the",
"filename",
"only",
"if",
"site",
"came",
"from",
"vendor",
"to",
"make",
"the",
"module",
"name",
"camel",
"case",
"Ex",
".",
"melis",
"-",
"demo",
"-",
"cms",
"turns",
"into",
"MelisDemoCms"
] | 5e03e32687970bb2201e4205612d5539500dc514 | https://github.com/melisplatform/melis-front/blob/5e03e32687970bb2201e4205612d5539500dc514/src/Listener/MelisFrontMinifiedAssetsCheckerListener.php#L257-L269 | train |
orchestral/installer | src/Http/Presenters/Setup.php | Setup.form | public function form(Fluent $model)
{
return $this->form->of('orchestra.install', function (FormGrid $form) use ($model) {
$form->fieldset(\trans('orchestra/foundation::install.steps.account'), function (Fieldset $fieldset) use ($model) {
$this->userForm($fieldset, $model);
});
$form->fieldset(\trans('orchestra/foundation::install.steps.application'), function (Fieldset $fieldset) use ($model) {
$this->applicationForm($fieldset, $model);
});
});
} | php | public function form(Fluent $model)
{
return $this->form->of('orchestra.install', function (FormGrid $form) use ($model) {
$form->fieldset(\trans('orchestra/foundation::install.steps.account'), function (Fieldset $fieldset) use ($model) {
$this->userForm($fieldset, $model);
});
$form->fieldset(\trans('orchestra/foundation::install.steps.application'), function (Fieldset $fieldset) use ($model) {
$this->applicationForm($fieldset, $model);
});
});
} | [
"public",
"function",
"form",
"(",
"Fluent",
"$",
"model",
")",
"{",
"return",
"$",
"this",
"->",
"form",
"->",
"of",
"(",
"'orchestra.install'",
",",
"function",
"(",
"FormGrid",
"$",
"form",
")",
"use",
"(",
"$",
"model",
")",
"{",
"$",
"form",
"->... | Create form.
@param \Illuminate\Support\Fluent $model
@return \Orchestra\Html\Form\FormBuilder | [
"Create",
"form",
"."
] | f49e251916567ce461b2dc47017fc8d8959ae6cc | https://github.com/orchestral/installer/blob/f49e251916567ce461b2dc47017fc8d8959ae6cc/src/Http/Presenters/Setup.php#L29-L40 | train |
orchestral/installer | src/Http/Presenters/Setup.php | Setup.applicationForm | protected function applicationForm(Fieldset $fieldset, Fluent $model): void
{
$fieldset->control('text', 'site_name')
->label(\trans('orchestra/foundation::label.name'))
->value(\data_get($model, 'site.name'))
->attributes(['autocomplete' => 'off']);
} | php | protected function applicationForm(Fieldset $fieldset, Fluent $model): void
{
$fieldset->control('text', 'site_name')
->label(\trans('orchestra/foundation::label.name'))
->value(\data_get($model, 'site.name'))
->attributes(['autocomplete' => 'off']);
} | [
"protected",
"function",
"applicationForm",
"(",
"Fieldset",
"$",
"fieldset",
",",
"Fluent",
"$",
"model",
")",
":",
"void",
"{",
"$",
"fieldset",
"->",
"control",
"(",
"'text'",
",",
"'site_name'",
")",
"->",
"label",
"(",
"\\",
"trans",
"(",
"'orchestra/... | Application form section.
@param \Orchestra\Contracts\Html\Form\Fieldset $fieldset
@param \Illuminate\Support\Fluent $model
@return void | [
"Application",
"form",
"section",
"."
] | f49e251916567ce461b2dc47017fc8d8959ae6cc | https://github.com/orchestral/installer/blob/f49e251916567ce461b2dc47017fc8d8959ae6cc/src/Http/Presenters/Setup.php#L50-L56 | train |
orchestral/installer | src/Http/Presenters/Setup.php | Setup.userForm | protected function userForm(Fieldset $fieldset, Fluent $model): void
{
$fieldset->control('input:email', 'email')
->label(\trans('orchestra/foundation::label.users.email'));
$fieldset->control('password', 'password')
->label(\trans('orchestra/foundation::label.users.password'));
$fieldset->control('text', 'fullname')
->label(\trans('orchestra/foundation::label.users.fullname'))
->value('Administrator');
} | php | protected function userForm(Fieldset $fieldset, Fluent $model): void
{
$fieldset->control('input:email', 'email')
->label(\trans('orchestra/foundation::label.users.email'));
$fieldset->control('password', 'password')
->label(\trans('orchestra/foundation::label.users.password'));
$fieldset->control('text', 'fullname')
->label(\trans('orchestra/foundation::label.users.fullname'))
->value('Administrator');
} | [
"protected",
"function",
"userForm",
"(",
"Fieldset",
"$",
"fieldset",
",",
"Fluent",
"$",
"model",
")",
":",
"void",
"{",
"$",
"fieldset",
"->",
"control",
"(",
"'input:email'",
",",
"'email'",
")",
"->",
"label",
"(",
"\\",
"trans",
"(",
"'orchestra/foun... | User form section.
@param \Orchestra\Contracts\Html\Form\Fieldset $fieldset
@param \Illuminate\Support\Fluent $model
@return void | [
"User",
"form",
"section",
"."
] | f49e251916567ce461b2dc47017fc8d8959ae6cc | https://github.com/orchestral/installer/blob/f49e251916567ce461b2dc47017fc8d8959ae6cc/src/Http/Presenters/Setup.php#L66-L77 | train |
undera/pwe | PWE/Modules/SimpleWiki/GitHubMarkdownSyntax/Paragraph.php | Paragraph._renderInlineTag | protected function _renderInlineTag($string)
{
$string = $this->engine->inlineParser->parse($string);
// handling of carriage-returns inside paragraphs
$string = (!$this->_firstLine) ? " $string" : $string;
$this->_firstLine = false;
return ($string);
} | php | protected function _renderInlineTag($string)
{
$string = $this->engine->inlineParser->parse($string);
// handling of carriage-returns inside paragraphs
$string = (!$this->_firstLine) ? " $string" : $string;
$this->_firstLine = false;
return ($string);
} | [
"protected",
"function",
"_renderInlineTag",
"(",
"$",
"string",
")",
"{",
"$",
"string",
"=",
"$",
"this",
"->",
"engine",
"->",
"inlineParser",
"->",
"parse",
"(",
"$",
"string",
")",
";",
"// handling of carriage-returns inside paragraphs",
"$",
"string",
"="... | Rendering of the text insed a paragraph.
@param string $string Text to render.
@return string Rendered result. | [
"Rendering",
"of",
"the",
"text",
"insed",
"a",
"paragraph",
"."
] | 4795f3a9755657c2a8be8ef3236992580b7954b3 | https://github.com/undera/pwe/blob/4795f3a9755657c2a8be8ef3236992580b7954b3/PWE/Modules/SimpleWiki/GitHubMarkdownSyntax/Paragraph.php#L49-L56 | train |
arcanedev-maroc/QrCode | src/Builder.php | Builder.setText | public function setText($text)
{
$this->text = $text;
$this->encodeManager->setData($text);
return $this;
} | php | public function setText($text)
{
$this->text = $text;
$this->encodeManager->setData($text);
return $this;
} | [
"public",
"function",
"setText",
"(",
"$",
"text",
")",
"{",
"$",
"this",
"->",
"text",
"=",
"$",
"text",
";",
"$",
"this",
"->",
"encodeManager",
"->",
"setData",
"(",
"$",
"text",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set text to hide in QR Code
@param string $text Text to hide
@return Builder | [
"Set",
"text",
"to",
"hide",
"in",
"QR",
"Code"
] | c0e3429df86bf9e4668c1e4f083c742ae677f6fe | https://github.com/arcanedev-maroc/QrCode/blob/c0e3429df86bf9e4668c1e4f083c742ae677f6fe/src/Builder.php#L91-L97 | train |
arcanedev-maroc/QrCode | src/Builder.php | Builder.setForegroundColor | public function setForegroundColor($foregroundColor)
{
if ( is_null($this->frontColor) ) {
$this->frontColor = new Color;
}
$this->frontColor->setFromArray($foregroundColor);
return $this;
} | php | public function setForegroundColor($foregroundColor)
{
if ( is_null($this->frontColor) ) {
$this->frontColor = new Color;
}
$this->frontColor->setFromArray($foregroundColor);
return $this;
} | [
"public",
"function",
"setForegroundColor",
"(",
"$",
"foregroundColor",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"frontColor",
")",
")",
"{",
"$",
"this",
"->",
"frontColor",
"=",
"new",
"Color",
";",
"}",
"$",
"this",
"->",
"frontColor",... | Set foreground color of the QR Code
@param array $foregroundColor
@return Builder | [
"Set",
"foreground",
"color",
"of",
"the",
"QR",
"Code"
] | c0e3429df86bf9e4668c1e4f083c742ae677f6fe | https://github.com/arcanedev-maroc/QrCode/blob/c0e3429df86bf9e4668c1e4f083c742ae677f6fe/src/Builder.php#L176-L185 | train |
arcanedev-maroc/QrCode | src/Builder.php | Builder.setBackgroundColor | public function setBackgroundColor($backgroundColor)
{
if ( is_null($this->backColor) ) {
$this->backColor = new Color;
}
$this->backColor->setFromArray($backgroundColor);
return $this;
} | php | public function setBackgroundColor($backgroundColor)
{
if ( is_null($this->backColor) ) {
$this->backColor = new Color;
}
$this->backColor->setFromArray($backgroundColor);
return $this;
} | [
"public",
"function",
"setBackgroundColor",
"(",
"$",
"backgroundColor",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"backColor",
")",
")",
"{",
"$",
"this",
"->",
"backColor",
"=",
"new",
"Color",
";",
"}",
"$",
"this",
"->",
"backColor",
... | Set background color of the QR Code
@param array $backgroundColor
@return Builder | [
"Set",
"background",
"color",
"of",
"the",
"QR",
"Code"
] | c0e3429df86bf9e4668c1e4f083c742ae677f6fe | https://github.com/arcanedev-maroc/QrCode/blob/c0e3429df86bf9e4668c1e4f083c742ae677f6fe/src/Builder.php#L220-L229 | train |
arcanedev-maroc/QrCode | src/Builder.php | Builder.getModuleSize | public function getModuleSize()
{
if ( is_null($this->moduleSize) )
{
$this->moduleSize = $this->getImageFormat() == "jpeg" ? 8 : 4;
}
return $this->moduleSize;
} | php | public function getModuleSize()
{
if ( is_null($this->moduleSize) )
{
$this->moduleSize = $this->getImageFormat() == "jpeg" ? 8 : 4;
}
return $this->moduleSize;
} | [
"public",
"function",
"getModuleSize",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"moduleSize",
")",
")",
"{",
"$",
"this",
"->",
"moduleSize",
"=",
"$",
"this",
"->",
"getImageFormat",
"(",
")",
"==",
"\"jpeg\"",
"?",
"8",
":",
"4"... | Return QR Code module size
@return int | [
"Return",
"QR",
"Code",
"module",
"size"
] | c0e3429df86bf9e4668c1e4f083c742ae677f6fe | https://github.com/arcanedev-maroc/QrCode/blob/c0e3429df86bf9e4668c1e4f083c742ae677f6fe/src/Builder.php#L329-L337 | train |
arcanedev-maroc/QrCode | src/Builder.php | Builder.autoVersionAndGetMaxDataBits | private function autoVersionAndGetMaxDataBits($codewordNumPlus, $dataBitsTotal)
{
$i = 1 + 40 * $this->getEccCharacter();
$j = $i + 39;
$version = 1;
while ($i <= $j) {
$maxDataBits = $this->getMaxDataBitsByIndexFormArray($i);
if ( ($maxDataBits) >= ($dataBitsTotal + $codewordNumPlus[$version]) ) {
$this->setVersion($version);
return $maxDataBits;
}
$i++; $version++;
}
return 0;
} | php | private function autoVersionAndGetMaxDataBits($codewordNumPlus, $dataBitsTotal)
{
$i = 1 + 40 * $this->getEccCharacter();
$j = $i + 39;
$version = 1;
while ($i <= $j) {
$maxDataBits = $this->getMaxDataBitsByIndexFormArray($i);
if ( ($maxDataBits) >= ($dataBitsTotal + $codewordNumPlus[$version]) ) {
$this->setVersion($version);
return $maxDataBits;
}
$i++; $version++;
}
return 0;
} | [
"private",
"function",
"autoVersionAndGetMaxDataBits",
"(",
"$",
"codewordNumPlus",
",",
"$",
"dataBitsTotal",
")",
"{",
"$",
"i",
"=",
"1",
"+",
"40",
"*",
"$",
"this",
"->",
"getEccCharacter",
"(",
")",
";",
"$",
"j",
"=",
"$",
"i",
"+",
"39",
";",
... | Auto version select and Get Max Data Bits
@param $codewordNumPlus
@param $dataBitsTotal
@return int | [
"Auto",
"version",
"select",
"and",
"Get",
"Max",
"Data",
"Bits"
] | c0e3429df86bf9e4668c1e4f083c742ae677f6fe | https://github.com/arcanedev-maroc/QrCode/blob/c0e3429df86bf9e4668c1e4f083c742ae677f6fe/src/Builder.php#L527-L546 | train |
arrilot/bitrix-cacher | src/Cache.php | Cache.remember | public static function remember($key, $seconds, Closure $callback, $initDir = '/', $basedir = 'cache')
{
$debug = \Bitrix\Main\Data\Cache::getShowCacheStat();
if ($seconds <= 0) {
try {
$result = $callback();
} catch (AbortCacheException $e) {
$result = null;
}
if ($debug) {
CacheDebugger::track('zero_ttl', $initDir, $basedir, $key, $result);
}
return $result;
}
$obCache = new CPHPCache();
if ($obCache->InitCache($seconds, $key, $initDir, $basedir)) {
$vars = $obCache->GetVars();
if ($debug) {
CacheDebugger::track('hits', $initDir, $basedir, $key, $vars['cache']);
}
return $vars['cache'];
}
$obCache->StartDataCache();
try {
$cache = $callback();
$obCache->EndDataCache(['cache' => $cache]);
} catch (AbortCacheException $e) {
$obCache->AbortDataCache();
$cache = null;
}
if ($debug) {
CacheDebugger::track('misses', $initDir, $basedir, $key, $cache);
}
return $cache;
} | php | public static function remember($key, $seconds, Closure $callback, $initDir = '/', $basedir = 'cache')
{
$debug = \Bitrix\Main\Data\Cache::getShowCacheStat();
if ($seconds <= 0) {
try {
$result = $callback();
} catch (AbortCacheException $e) {
$result = null;
}
if ($debug) {
CacheDebugger::track('zero_ttl', $initDir, $basedir, $key, $result);
}
return $result;
}
$obCache = new CPHPCache();
if ($obCache->InitCache($seconds, $key, $initDir, $basedir)) {
$vars = $obCache->GetVars();
if ($debug) {
CacheDebugger::track('hits', $initDir, $basedir, $key, $vars['cache']);
}
return $vars['cache'];
}
$obCache->StartDataCache();
try {
$cache = $callback();
$obCache->EndDataCache(['cache' => $cache]);
} catch (AbortCacheException $e) {
$obCache->AbortDataCache();
$cache = null;
}
if ($debug) {
CacheDebugger::track('misses', $initDir, $basedir, $key, $cache);
}
return $cache;
} | [
"public",
"static",
"function",
"remember",
"(",
"$",
"key",
",",
"$",
"seconds",
",",
"Closure",
"$",
"callback",
",",
"$",
"initDir",
"=",
"'/'",
",",
"$",
"basedir",
"=",
"'cache'",
")",
"{",
"$",
"debug",
"=",
"\\",
"Bitrix",
"\\",
"Main",
"\\",
... | Store closure's result in the cache for a given number of seconds.
@param string $key
@param int $seconds
@param Closure $callback
@param bool|string $initDir
@param string $basedir
@return mixed | [
"Store",
"closure",
"s",
"result",
"in",
"the",
"cache",
"for",
"a",
"given",
"number",
"of",
"seconds",
"."
] | 85421bac022b5986ada164f2787eb60699d90290 | https://github.com/arrilot/bitrix-cacher/blob/85421bac022b5986ada164f2787eb60699d90290/src/Cache.php#L22-L65 | train |
arrilot/bitrix-cacher | src/Cache.php | Cache.rememberForever | public static function rememberForever($key, Closure $callback, $initDir = '/', $basedir = 'cache')
{
return static::remember($key, 99999999, $callback, $initDir, $basedir);
} | php | public static function rememberForever($key, Closure $callback, $initDir = '/', $basedir = 'cache')
{
return static::remember($key, 99999999, $callback, $initDir, $basedir);
} | [
"public",
"static",
"function",
"rememberForever",
"(",
"$",
"key",
",",
"Closure",
"$",
"callback",
",",
"$",
"initDir",
"=",
"'/'",
",",
"$",
"basedir",
"=",
"'cache'",
")",
"{",
"return",
"static",
"::",
"remember",
"(",
"$",
"key",
",",
"99999999",
... | Store closure's result in the cache for a long time.
@param string $key
@param Closure $callback
@param bool|string $initDir
@param string $basedir
@return mixed | [
"Store",
"closure",
"s",
"result",
"in",
"the",
"cache",
"for",
"a",
"long",
"time",
"."
] | 85421bac022b5986ada164f2787eb60699d90290 | https://github.com/arrilot/bitrix-cacher/blob/85421bac022b5986ada164f2787eb60699d90290/src/Cache.php#L76-L79 | train |
arrilot/bitrix-cacher | src/Cache.php | Cache.flushAll | public static function flushAll()
{
$GLOBALS["CACHE_MANAGER"]->cleanAll();
$GLOBALS["stackCacheManager"]->cleanAll();
$staticHtmlCache = StaticHtmlCache::getInstance();
$staticHtmlCache->deleteAll();
BXClearCache(true);
} | php | public static function flushAll()
{
$GLOBALS["CACHE_MANAGER"]->cleanAll();
$GLOBALS["stackCacheManager"]->cleanAll();
$staticHtmlCache = StaticHtmlCache::getInstance();
$staticHtmlCache->deleteAll();
BXClearCache(true);
} | [
"public",
"static",
"function",
"flushAll",
"(",
")",
"{",
"$",
"GLOBALS",
"[",
"\"CACHE_MANAGER\"",
"]",
"->",
"cleanAll",
"(",
")",
";",
"$",
"GLOBALS",
"[",
"\"stackCacheManager\"",
"]",
"->",
"cleanAll",
"(",
")",
";",
"$",
"staticHtmlCache",
"=",
"Sta... | Flushes all bitrix cache.
@return void | [
"Flushes",
"all",
"bitrix",
"cache",
"."
] | 85421bac022b5986ada164f2787eb60699d90290 | https://github.com/arrilot/bitrix-cacher/blob/85421bac022b5986ada164f2787eb60699d90290/src/Cache.php#L98-L105 | train |
undera/pwe | PWE/Modules/SimpleWiki/GoogleCodeWikiSyntax/Config.php | Config.getParam | public function getParam($param)
{
if (isset($this->_parentConfig))
return ($this->_parentConfig->getParam($param));
return (isset($this->_params[$param]) ? $this->_params[$param] : null);
} | php | public function getParam($param)
{
if (isset($this->_parentConfig))
return ($this->_parentConfig->getParam($param));
return (isset($this->_params[$param]) ? $this->_params[$param] : null);
} | [
"public",
"function",
"getParam",
"(",
"$",
"param",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_parentConfig",
")",
")",
"return",
"(",
"$",
"this",
"->",
"_parentConfig",
"->",
"getParam",
"(",
"$",
"param",
")",
")",
";",
"return",
"("... | Returns a specific configuration parameter. If a parent configuration object exists, the parameter is asked to it.
@param string $param Parameter's name.
@return mixed Value of the configuration parameter. | [
"Returns",
"a",
"specific",
"configuration",
"parameter",
".",
"If",
"a",
"parent",
"configuration",
"object",
"exists",
"the",
"parameter",
"is",
"asked",
"to",
"it",
"."
] | 4795f3a9755657c2a8be8ef3236992580b7954b3 | https://github.com/undera/pwe/blob/4795f3a9755657c2a8be8ef3236992580b7954b3/PWE/Modules/SimpleWiki/GoogleCodeWikiSyntax/Config.php#L218-L223 | train |
undera/pwe | PWE/Modules/SimpleWiki/GoogleCodeWikiSyntax/Config.php | Config.titleToIdentifier | public function titleToIdentifier($depth, $text)
{
/** @var callable $func */
$func = $this->getParam('titleToIdFunction');
if (isset($func)) {
return ($func($depth, $text));
}
// conversion of accented characters
// see http://www.weirdog.com/blog/php/supprimer-les-accents-des-caracteres-accentues.html
$text = htmlentities($text, ENT_NOQUOTES, 'utf-8');
$text = preg_replace('#&([A-za-z])(?:acute|cedil|circ|grave|orn|ring|slash|th|tilde|uml);#', '\1', $text);
$text = preg_replace('#&([A-za-z]{2})(?:lig);#', '\1', $text); // for ligatures e.g. 'œ'
$text = preg_replace('#&([lr]s|sb|[lrb]d)(quo);#', ' ', $text); // for *quote (http://www.degraeve.com/reference/specialcharacters.php)
$text = str_replace(' ', ' ', $text); // for non breaking space
$text = preg_replace('#&[^;]+;#', '', $text); // strips other characters
$text = preg_replace("/[^a-zA-Z0-9_-]/", ' ', $text); // remove any other characters
$text = str_replace(' ', '-', $text);
$text = preg_replace('/\s+/', " ", $text);
$text = preg_replace('/-+/', "-", $text);
$text = trim($text, '-');
$text = trim($text);
$text = empty($text) ? '-' : $text;
return ($text);
} | php | public function titleToIdentifier($depth, $text)
{
/** @var callable $func */
$func = $this->getParam('titleToIdFunction');
if (isset($func)) {
return ($func($depth, $text));
}
// conversion of accented characters
// see http://www.weirdog.com/blog/php/supprimer-les-accents-des-caracteres-accentues.html
$text = htmlentities($text, ENT_NOQUOTES, 'utf-8');
$text = preg_replace('#&([A-za-z])(?:acute|cedil|circ|grave|orn|ring|slash|th|tilde|uml);#', '\1', $text);
$text = preg_replace('#&([A-za-z]{2})(?:lig);#', '\1', $text); // for ligatures e.g. 'œ'
$text = preg_replace('#&([lr]s|sb|[lrb]d)(quo);#', ' ', $text); // for *quote (http://www.degraeve.com/reference/specialcharacters.php)
$text = str_replace(' ', ' ', $text); // for non breaking space
$text = preg_replace('#&[^;]+;#', '', $text); // strips other characters
$text = preg_replace("/[^a-zA-Z0-9_-]/", ' ', $text); // remove any other characters
$text = str_replace(' ', '-', $text);
$text = preg_replace('/\s+/', " ", $text);
$text = preg_replace('/-+/', "-", $text);
$text = trim($text, '-');
$text = trim($text);
$text = empty($text) ? '-' : $text;
return ($text);
} | [
"public",
"function",
"titleToIdentifier",
"(",
"$",
"depth",
",",
"$",
"text",
")",
"{",
"/** @var callable $func */",
"$",
"func",
"=",
"$",
"this",
"->",
"getParam",
"(",
"'titleToIdFunction'",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"func",
")",
")",
... | Convert title string to a usable HTML identifier.
@param int $depth Depth of the title.
@param string $text Input string.
@return string The converted string. | [
"Convert",
"title",
"string",
"to",
"a",
"usable",
"HTML",
"identifier",
"."
] | 4795f3a9755657c2a8be8ef3236992580b7954b3 | https://github.com/undera/pwe/blob/4795f3a9755657c2a8be8ef3236992580b7954b3/PWE/Modules/SimpleWiki/GoogleCodeWikiSyntax/Config.php#L233-L258 | train |
undera/pwe | PWE/Modules/SimpleWiki/GoogleCodeWikiSyntax/Config.php | Config.onStart | public function onStart($text)
{
// process of smileys and other special characters
if ($this->getParam('convertSmileys'))
$text = Smiley::convertSmileys($text);
if ($this->getParam('convertSymbols'))
$text = Smiley::convertSymbols($text);
// if a specific pre-parse function was defined, it is called
/** @var callable $func */
$func = $this->getParam('preParseFunction');
if (isset($func))
$text = $func($text);
return ($text);
} | php | public function onStart($text)
{
// process of smileys and other special characters
if ($this->getParam('convertSmileys'))
$text = Smiley::convertSmileys($text);
if ($this->getParam('convertSymbols'))
$text = Smiley::convertSymbols($text);
// if a specific pre-parse function was defined, it is called
/** @var callable $func */
$func = $this->getParam('preParseFunction');
if (isset($func))
$text = $func($text);
return ($text);
} | [
"public",
"function",
"onStart",
"(",
"$",
"text",
")",
"{",
"// process of smileys and other special characters",
"if",
"(",
"$",
"this",
"->",
"getParam",
"(",
"'convertSmileys'",
")",
")",
"$",
"text",
"=",
"Smiley",
"::",
"convertSmileys",
"(",
"$",
"text",
... | Method called for pre-parse processing.
@param string $text The input text.
@return string The text that will be parsed. | [
"Method",
"called",
"for",
"pre",
"-",
"parse",
"processing",
"."
] | 4795f3a9755657c2a8be8ef3236992580b7954b3 | https://github.com/undera/pwe/blob/4795f3a9755657c2a8be8ef3236992580b7954b3/PWE/Modules/SimpleWiki/GoogleCodeWikiSyntax/Config.php#L267-L281 | train |
undera/pwe | PWE/Modules/SimpleWiki/GoogleCodeWikiSyntax/Config.php | Config.onParse | public function onParse($finalText)
{
// if a specific post-parse function was defined, it is called
/** @var callable $func */
$func = $this->getParam('postParseFunction');
if (isset($func))
$finalText = $func($finalText);
// add footnotes' content if needed
if ($this->getParam('addFootnotes')) {
$footnotes = $this->getFootnotes();
if (!empty($footnotes))
$finalText .= "\n" . $footnotes;
}
return ($finalText);
} | php | public function onParse($finalText)
{
// if a specific post-parse function was defined, it is called
/** @var callable $func */
$func = $this->getParam('postParseFunction');
if (isset($func))
$finalText = $func($finalText);
// add footnotes' content if needed
if ($this->getParam('addFootnotes')) {
$footnotes = $this->getFootnotes();
if (!empty($footnotes))
$finalText .= "\n" . $footnotes;
}
return ($finalText);
} | [
"public",
"function",
"onParse",
"(",
"$",
"finalText",
")",
"{",
"// if a specific post-parse function was defined, it is called",
"/** @var callable $func */",
"$",
"func",
"=",
"$",
"this",
"->",
"getParam",
"(",
"'postParseFunction'",
")",
";",
"if",
"(",
"isset",
... | Method called for post-parse processing.
@param string $finalText The generated text.
@return string The text after post-processing. | [
"Method",
"called",
"for",
"post",
"-",
"parse",
"processing",
"."
] | 4795f3a9755657c2a8be8ef3236992580b7954b3 | https://github.com/undera/pwe/blob/4795f3a9755657c2a8be8ef3236992580b7954b3/PWE/Modules/SimpleWiki/GoogleCodeWikiSyntax/Config.php#L288-L302 | train |
undera/pwe | PWE/Modules/SimpleWiki/GoogleCodeWikiSyntax/Config.php | Config.processLink | public function processLink($url, $tagName = '')
{
$label = $url = trim($url);
$targetBlank = $this->getParam('targetBlank');
$nofollow = $this->getParam('nofollow');
// shortening of long URLs
if ($this->getParam('shortenLongUrl') && strlen($label) > 40)
$label = substr($label, 0, 40) . '...';
// Javascript XSS check
if (substr($url, 0, strlen('javascript:')) === 'javascript:')
$url = '#';
else {
// email check
if (filter_var($url, FILTER_VALIDATE_EMAIL)) {
$url = "mailto:$url";
$targetBlank = $nofollow = false;
} else if (substr($url, 0, strlen('mailto:')) === 'mailto:') {
$label = substr($url, strlen('mailto:'));
$targetBlank = $nofollow = false;
}
// if a specific URL process function was defined, it is called
/** @var callable $func */
$func = $this->getParam('urlProcessFunction');
if (isset($func))
list($url, $label, $targetBlank, $nofollow) = $func($url, $label, $targetBlank, $nofollow);
}
return (array($url, $label, $targetBlank, $nofollow));
} | php | public function processLink($url, $tagName = '')
{
$label = $url = trim($url);
$targetBlank = $this->getParam('targetBlank');
$nofollow = $this->getParam('nofollow');
// shortening of long URLs
if ($this->getParam('shortenLongUrl') && strlen($label) > 40)
$label = substr($label, 0, 40) . '...';
// Javascript XSS check
if (substr($url, 0, strlen('javascript:')) === 'javascript:')
$url = '#';
else {
// email check
if (filter_var($url, FILTER_VALIDATE_EMAIL)) {
$url = "mailto:$url";
$targetBlank = $nofollow = false;
} else if (substr($url, 0, strlen('mailto:')) === 'mailto:') {
$label = substr($url, strlen('mailto:'));
$targetBlank = $nofollow = false;
}
// if a specific URL process function was defined, it is called
/** @var callable $func */
$func = $this->getParam('urlProcessFunction');
if (isset($func))
list($url, $label, $targetBlank, $nofollow) = $func($url, $label, $targetBlank, $nofollow);
}
return (array($url, $label, $targetBlank, $nofollow));
} | [
"public",
"function",
"processLink",
"(",
"$",
"url",
",",
"$",
"tagName",
"=",
"''",
")",
"{",
"$",
"label",
"=",
"$",
"url",
"=",
"trim",
"(",
"$",
"url",
")",
";",
"$",
"targetBlank",
"=",
"$",
"this",
"->",
"getParam",
"(",
"'targetBlank'",
")"... | Links processing.
@param string $url The URL to process.
@param string $tagName Name of the calling tag.
@return array Array with the processed URL and the generated label.
Third parameter is about blank targeting of the link. It could be
null (use the default behaviour), true (add a blank targeting) or
false (no blank targeting). | [
"Links",
"processing",
"."
] | 4795f3a9755657c2a8be8ef3236992580b7954b3 | https://github.com/undera/pwe/blob/4795f3a9755657c2a8be8ef3236992580b7954b3/PWE/Modules/SimpleWiki/GoogleCodeWikiSyntax/Config.php#L313-L341 | train |
undera/pwe | PWE/Modules/SimpleWiki/GoogleCodeWikiSyntax/Config.php | Config.addTocEntry | public function addTocEntry($depth, $title, $identifier)
{
if (!isset($this->_toc))
$this->_toc = array();
$this->_addTocSubEntry($depth, $depth, $title, $identifier, $this->_toc);
} | php | public function addTocEntry($depth, $title, $identifier)
{
if (!isset($this->_toc))
$this->_toc = array();
$this->_addTocSubEntry($depth, $depth, $title, $identifier, $this->_toc);
} | [
"public",
"function",
"addTocEntry",
"(",
"$",
"depth",
",",
"$",
"title",
",",
"$",
"identifier",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_toc",
")",
")",
"$",
"this",
"->",
"_toc",
"=",
"array",
"(",
")",
";",
"$",
"this",
... | Add a TOC entry.
@param int $depth Depth in the tree.
@param string $title Name of the new entry.
@param string $identifier Identifier of the new entry. | [
"Add",
"a",
"TOC",
"entry",
"."
] | 4795f3a9755657c2a8be8ef3236992580b7954b3 | https://github.com/undera/pwe/blob/4795f3a9755657c2a8be8ef3236992580b7954b3/PWE/Modules/SimpleWiki/GoogleCodeWikiSyntax/Config.php#L351-L356 | train |
undera/pwe | PWE/Modules/SimpleWiki/GoogleCodeWikiSyntax/Config.php | Config.getToc | public function getToc($raw = false)
{
if ($raw === true)
return ($this->_toc['sub']);
$html = "<b>On this page:</b>" . $this->_getRenderedToc($this->_toc['sub']);
return ($html);
} | php | public function getToc($raw = false)
{
if ($raw === true)
return ($this->_toc['sub']);
$html = "<b>On this page:</b>" . $this->_getRenderedToc($this->_toc['sub']);
return ($html);
} | [
"public",
"function",
"getToc",
"(",
"$",
"raw",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"raw",
"===",
"true",
")",
"return",
"(",
"$",
"this",
"->",
"_toc",
"[",
"'sub'",
"]",
")",
";",
"$",
"html",
"=",
"\"<b>On this page:</b>\"",
".",
"$",
"this... | Returns the TOC content. By default, the rendered HTML is returned, but the
raw TOC tree is available.
@param bool $raw (optional) Set to True to get the raw TOC tree. False by default.
@return string|array The TOC rendered HTML or the TOC tree. | [
"Returns",
"the",
"TOC",
"content",
".",
"By",
"default",
"the",
"rendered",
"HTML",
"is",
"returned",
"but",
"the",
"raw",
"TOC",
"tree",
"is",
"available",
"."
] | 4795f3a9755657c2a8be8ef3236992580b7954b3 | https://github.com/undera/pwe/blob/4795f3a9755657c2a8be8ef3236992580b7954b3/PWE/Modules/SimpleWiki/GoogleCodeWikiSyntax/Config.php#L364-L370 | train |
undera/pwe | PWE/Modules/SimpleWiki/GoogleCodeWikiSyntax/Config.php | Config.addFootnote | public function addFootnote($text, $label = null)
{
if (isset($this->_parentConfig))
return ($this->_parentConfig->addFootnote($text, $label));
if (is_null($label))
$this->_footnotes[] = $text;
else
$this->_footnotes[] = array(
'label' => $label,
'text' => $text
);
$index = count($this->_footnotes);
return (array(
'id' => $this->getParam('footnotesPrefix') . "-$index",
'index' => $index
));
} | php | public function addFootnote($text, $label = null)
{
if (isset($this->_parentConfig))
return ($this->_parentConfig->addFootnote($text, $label));
if (is_null($label))
$this->_footnotes[] = $text;
else
$this->_footnotes[] = array(
'label' => $label,
'text' => $text
);
$index = count($this->_footnotes);
return (array(
'id' => $this->getParam('footnotesPrefix') . "-$index",
'index' => $index
));
} | [
"public",
"function",
"addFootnote",
"(",
"$",
"text",
",",
"$",
"label",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_parentConfig",
")",
")",
"return",
"(",
"$",
"this",
"->",
"_parentConfig",
"->",
"addFootnote",
"(",
"$",
... | Add a footnote.
@param string $text Footnote's text.
@param string $label (optionnel) Footnote's label. If not given, an auto-incremented
number will be used.
@return array Hash with 'id' and 'index' keys. | [
"Add",
"a",
"footnote",
"."
] | 4795f3a9755657c2a8be8ef3236992580b7954b3 | https://github.com/undera/pwe/blob/4795f3a9755657c2a8be8ef3236992580b7954b3/PWE/Modules/SimpleWiki/GoogleCodeWikiSyntax/Config.php#L381-L397 | train |
undera/pwe | PWE/Modules/SimpleWiki/GoogleCodeWikiSyntax/Config.php | Config.getFootnotes | public function getFootnotes($raw = false)
{
if ($raw === true)
return ($this->_footnotes);
if (empty($this->_footnotes))
return (null);
$footnotes = '';
$index = 1;
foreach ($this->_footnotes as $note) {
$id = $this->getParam('footnotesPrefix') . "-$index";
$noteHtml = "<p class=\"footnote\"><a href=\"#cite_ref-$id\" name=\"cite_note-$id\" id=\"cite_note-$id\">";
if (is_string($note))
$noteHtml .= "$index</a>. $note";
else
$noteHtml .= htmlspecialchars($note['label']) . "</a>. " . $note['text'];
$noteHtml .= "</p>\n";
$footnotes .= $noteHtml;
$index++;
}
$footnotes = "<div class=\"footnotes\">\n$footnotes</div>\n";
return ($footnotes);
} | php | public function getFootnotes($raw = false)
{
if ($raw === true)
return ($this->_footnotes);
if (empty($this->_footnotes))
return (null);
$footnotes = '';
$index = 1;
foreach ($this->_footnotes as $note) {
$id = $this->getParam('footnotesPrefix') . "-$index";
$noteHtml = "<p class=\"footnote\"><a href=\"#cite_ref-$id\" name=\"cite_note-$id\" id=\"cite_note-$id\">";
if (is_string($note))
$noteHtml .= "$index</a>. $note";
else
$noteHtml .= htmlspecialchars($note['label']) . "</a>. " . $note['text'];
$noteHtml .= "</p>\n";
$footnotes .= $noteHtml;
$index++;
}
$footnotes = "<div class=\"footnotes\">\n$footnotes</div>\n";
return ($footnotes);
} | [
"public",
"function",
"getFootnotes",
"(",
"$",
"raw",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"raw",
"===",
"true",
")",
"return",
"(",
"$",
"this",
"->",
"_footnotes",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"_footnotes",
")",
")",
... | Returns the footnotes content. By default, the rendered HTML is returned, but the
raw list of footnotes is available.
@param bool $raw (optional) Set to True to get the raw list of footnotes.
False by default.
@return string|array The footnotes' rendered HTML or the list of footnotes. | [
"Returns",
"the",
"footnotes",
"content",
".",
"By",
"default",
"the",
"rendered",
"HTML",
"is",
"returned",
"but",
"the",
"raw",
"list",
"of",
"footnotes",
"is",
"available",
"."
] | 4795f3a9755657c2a8be8ef3236992580b7954b3 | https://github.com/undera/pwe/blob/4795f3a9755657c2a8be8ef3236992580b7954b3/PWE/Modules/SimpleWiki/GoogleCodeWikiSyntax/Config.php#L406-L427 | train |
undera/pwe | PWE/Modules/SimpleWiki/GoogleCodeWikiSyntax/Config.php | Config._addTocSubEntry | private function _addTocSubEntry($depth, $level, $title, $identifier, &$list)
{
if (!isset($list['sub']))
$list['sub'] = array();
$offset = count($list['sub']);
if ($depth === 1) {
$list['sub'][$offset] = array(
'id' => $identifier,
'value' => $title
);
return;
}
$offset--;
if (!isset($list['sub'][$offset]))
$list['sub'][$offset] = array();
$this->_addTocSubEntry($depth - 1, $level, $title, $identifier, $list['sub'][$offset]);
} | php | private function _addTocSubEntry($depth, $level, $title, $identifier, &$list)
{
if (!isset($list['sub']))
$list['sub'] = array();
$offset = count($list['sub']);
if ($depth === 1) {
$list['sub'][$offset] = array(
'id' => $identifier,
'value' => $title
);
return;
}
$offset--;
if (!isset($list['sub'][$offset]))
$list['sub'][$offset] = array();
$this->_addTocSubEntry($depth - 1, $level, $title, $identifier, $list['sub'][$offset]);
} | [
"private",
"function",
"_addTocSubEntry",
"(",
"$",
"depth",
",",
"$",
"level",
",",
"$",
"title",
",",
"$",
"identifier",
",",
"&",
"$",
"list",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"list",
"[",
"'sub'",
"]",
")",
")",
"$",
"list",
"[",
... | Add a sub-TOC entry.
@param int $depth Depth in the tree.
@param int $level Level of the title.
@param string $title Name of the new entry.
@param string $identifier Identifier of the new entry.
@param array $list List of sibbling nodes. | [
"Add",
"a",
"sub",
"-",
"TOC",
"entry",
"."
] | 4795f3a9755657c2a8be8ef3236992580b7954b3 | https://github.com/undera/pwe/blob/4795f3a9755657c2a8be8ef3236992580b7954b3/PWE/Modules/SimpleWiki/GoogleCodeWikiSyntax/Config.php#L439-L455 | train |
CraftRemote/plugin | src/Craftremote.php | Craftremote.key | private function key(int $length, string $extraChars = ''): string
{
$licenseKey = '';
$codeAlphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'.$extraChars;
$alphabetLength = strlen($codeAlphabet);
$log = log($alphabetLength, 2);
$bytes = (int)($log / 8) + 1; // length in bytes
$bits = (int)$log + 1; // length in bits
$filter = (int)(1 << $bits) - 1; // set all lower bits to 1
for ($i = 0; $i < $length; $i++) {
do {
$rnd = hexdec(bin2hex(openssl_random_pseudo_bytes($bytes)));
$rnd = $rnd & $filter; // discard irrelevant bits
} while ($rnd >= $alphabetLength);
$licenseKey .= $codeAlphabet[$rnd];
}
return $licenseKey;
} | php | private function key(int $length, string $extraChars = ''): string
{
$licenseKey = '';
$codeAlphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'.$extraChars;
$alphabetLength = strlen($codeAlphabet);
$log = log($alphabetLength, 2);
$bytes = (int)($log / 8) + 1; // length in bytes
$bits = (int)$log + 1; // length in bits
$filter = (int)(1 << $bits) - 1; // set all lower bits to 1
for ($i = 0; $i < $length; $i++) {
do {
$rnd = hexdec(bin2hex(openssl_random_pseudo_bytes($bytes)));
$rnd = $rnd & $filter; // discard irrelevant bits
} while ($rnd >= $alphabetLength);
$licenseKey .= $codeAlphabet[$rnd];
}
return $licenseKey;
} | [
"private",
"function",
"key",
"(",
"int",
"$",
"length",
",",
"string",
"$",
"extraChars",
"=",
"''",
")",
":",
"string",
"{",
"$",
"licenseKey",
"=",
"''",
";",
"$",
"codeAlphabet",
"=",
"'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'",
".",
"$",
"extraChars",
";",... | Generates a new license key.
@param int $length
@param string $extraChars
@return string | [
"Generates",
"a",
"new",
"license",
"key",
"."
] | cf61d486e18218e877c2fdbfb538e8939985eac0 | https://github.com/CraftRemote/plugin/blob/cf61d486e18218e877c2fdbfb538e8939985eac0/src/Craftremote.php#L120-L137 | train |
globalis-ms/puppet-skilled-framework | src/View/Asset.php | Asset.printStyles | public function printStyles()
{
foreach ($this->styles as $key => $options) {
$href = (is_string($options['src'])) ? $options['src'] : $this->getStyleLink($key);
if ($options['with_version']) {
$href = call_user_func_array($this->assetInsertMethod, [$href, $this->assetVersion]);
}
echo "<link rel='stylesheet' href='" . $href . "' type='text/css' media='" . $options["media"] . "' />\n";
}
} | php | public function printStyles()
{
foreach ($this->styles as $key => $options) {
$href = (is_string($options['src'])) ? $options['src'] : $this->getStyleLink($key);
if ($options['with_version']) {
$href = call_user_func_array($this->assetInsertMethod, [$href, $this->assetVersion]);
}
echo "<link rel='stylesheet' href='" . $href . "' type='text/css' media='" . $options["media"] . "' />\n";
}
} | [
"public",
"function",
"printStyles",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"styles",
"as",
"$",
"key",
"=>",
"$",
"options",
")",
"{",
"$",
"href",
"=",
"(",
"is_string",
"(",
"$",
"options",
"[",
"'src'",
"]",
")",
")",
"?",
"$",
"op... | Display links to loaded css files
@return void | [
"Display",
"links",
"to",
"loaded",
"css",
"files"
] | 4bb9ff30a32210f54add1f0e53d4769d26eb3c29 | https://github.com/globalis-ms/puppet-skilled-framework/blob/4bb9ff30a32210f54add1f0e53d4769d26eb3c29/src/View/Asset.php#L130-L139 | train |
globalis-ms/puppet-skilled-framework | src/View/Asset.php | Asset.enqueueStyle | public function enqueueStyle($slug, $src = false, $media = 'all', $withVersion = true)
{
$this->styles[$slug] = [
'src' => $src,
'media' => $media,
'with_version' => $withVersion,
];
} | php | public function enqueueStyle($slug, $src = false, $media = 'all', $withVersion = true)
{
$this->styles[$slug] = [
'src' => $src,
'media' => $media,
'with_version' => $withVersion,
];
} | [
"public",
"function",
"enqueueStyle",
"(",
"$",
"slug",
",",
"$",
"src",
"=",
"false",
",",
"$",
"media",
"=",
"'all'",
",",
"$",
"withVersion",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"styles",
"[",
"$",
"slug",
"]",
"=",
"[",
"'src'",
"=>",
"... | Add css file to the loader
@param string $slug Slug or source file
@param mixed $src Source file, if src = false src = slug
@param string $media Media link type default = all
@return void | [
"Add",
"css",
"file",
"to",
"the",
"loader"
] | 4bb9ff30a32210f54add1f0e53d4769d26eb3c29 | https://github.com/globalis-ms/puppet-skilled-framework/blob/4bb9ff30a32210f54add1f0e53d4769d26eb3c29/src/View/Asset.php#L149-L156 | train |
globalis-ms/puppet-skilled-framework | src/View/Asset.php | Asset.printInlineScript | public function printInlineScript($print = true)
{
$this->scriptNonces[] = ($nonce = $this->newNonce());
if ($print) {
echo "<script type='text/javascript' nonce='".$nonce."'>" . $this->scriptInline . "</script>\n";
} else {
return "<script type='text/javascript' nonce='".$nonce."'>" . $this->scriptInline . "</script>\n";
}
} | php | public function printInlineScript($print = true)
{
$this->scriptNonces[] = ($nonce = $this->newNonce());
if ($print) {
echo "<script type='text/javascript' nonce='".$nonce."'>" . $this->scriptInline . "</script>\n";
} else {
return "<script type='text/javascript' nonce='".$nonce."'>" . $this->scriptInline . "</script>\n";
}
} | [
"public",
"function",
"printInlineScript",
"(",
"$",
"print",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"scriptNonces",
"[",
"]",
"=",
"(",
"$",
"nonce",
"=",
"$",
"this",
"->",
"newNonce",
"(",
")",
")",
";",
"if",
"(",
"$",
"print",
")",
"{",
"... | Dispaly or return script balsie with all inline script loaded
@param boolean $print If true print (default true)
@return mixed | [
"Dispaly",
"or",
"return",
"script",
"balsie",
"with",
"all",
"inline",
"script",
"loaded"
] | 4bb9ff30a32210f54add1f0e53d4769d26eb3c29 | https://github.com/globalis-ms/puppet-skilled-framework/blob/4bb9ff30a32210f54add1f0e53d4769d26eb3c29/src/View/Asset.php#L164-L172 | train |
globalis-ms/puppet-skilled-framework | src/View/Asset.php | Asset.printScript | public function printScript()
{
foreach ($this->scripts as $key => $options) {
$src = (is_string($options['src'])) ? $options['src'] : $this->getScriptLink($key);
if ($options['with_version']) {
$src = call_user_func_array($this->assetInsertMethod, [$src, $this->assetVersion]);
}
echo "<script type='text/javascript' src='$src'></script>\n";
}
$this->printInlineScript();
} | php | public function printScript()
{
foreach ($this->scripts as $key => $options) {
$src = (is_string($options['src'])) ? $options['src'] : $this->getScriptLink($key);
if ($options['with_version']) {
$src = call_user_func_array($this->assetInsertMethod, [$src, $this->assetVersion]);
}
echo "<script type='text/javascript' src='$src'></script>\n";
}
$this->printInlineScript();
} | [
"public",
"function",
"printScript",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"scripts",
"as",
"$",
"key",
"=>",
"$",
"options",
")",
"{",
"$",
"src",
"=",
"(",
"is_string",
"(",
"$",
"options",
"[",
"'src'",
"]",
")",
")",
"?",
"$",
"op... | Display links to loaded javascripts files and loaded inline script
@return void | [
"Display",
"links",
"to",
"loaded",
"javascripts",
"files",
"and",
"loaded",
"inline",
"script"
] | 4bb9ff30a32210f54add1f0e53d4769d26eb3c29 | https://github.com/globalis-ms/puppet-skilled-framework/blob/4bb9ff30a32210f54add1f0e53d4769d26eb3c29/src/View/Asset.php#L193-L203 | train |
globalis-ms/puppet-skilled-framework | src/View/Asset.php | Asset.enqueueScript | public function enqueueScript($slug, $src = false, $withVersion = true)
{
$this->scripts[$slug] = [
'src' => $src,
'with_version' => $withVersion,
];
} | php | public function enqueueScript($slug, $src = false, $withVersion = true)
{
$this->scripts[$slug] = [
'src' => $src,
'with_version' => $withVersion,
];
} | [
"public",
"function",
"enqueueScript",
"(",
"$",
"slug",
",",
"$",
"src",
"=",
"false",
",",
"$",
"withVersion",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"scripts",
"[",
"$",
"slug",
"]",
"=",
"[",
"'src'",
"=>",
"$",
"src",
",",
"'with_version'",
... | Add javascript file to the loader
@param string $slug Slug or source file
@param mixed $src Source file, if src = false src = slug
@return void | [
"Add",
"javascript",
"file",
"to",
"the",
"loader"
] | 4bb9ff30a32210f54add1f0e53d4769d26eb3c29 | https://github.com/globalis-ms/puppet-skilled-framework/blob/4bb9ff30a32210f54add1f0e53d4769d26eb3c29/src/View/Asset.php#L212-L218 | train |
arcanedev-maroc/QrCode | src/QrCode.php | QrCode.get | public function get($format = null)
{
if ( ! is_null($format) )
$this->setFormat($format);
ob_start();
call_user_func($this->getFunctionName(), $this->getImage());
return ob_get_clean();
} | php | public function get($format = null)
{
if ( ! is_null($format) )
$this->setFormat($format);
ob_start();
call_user_func($this->getFunctionName(), $this->getImage());
return ob_get_clean();
} | [
"public",
"function",
"get",
"(",
"$",
"format",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"format",
")",
")",
"$",
"this",
"->",
"setFormat",
"(",
"$",
"format",
")",
";",
"ob_start",
"(",
")",
";",
"call_user_func",
"(",
"$",
... | Create QR Code and return its content
@param string|null $format - Image type (gif, png, wbmp, jpeg)
@throws ImageFunctionUnknownException
@return string | [
"Create",
"QR",
"Code",
"and",
"return",
"its",
"content"
] | c0e3429df86bf9e4668c1e4f083c742ae677f6fe | https://github.com/arcanedev-maroc/QrCode/blob/c0e3429df86bf9e4668c1e4f083c742ae677f6fe/src/QrCode.php#L364-L373 | train |
arcanedev-maroc/QrCode | src/QrCode.php | QrCode.save | public function save($filename)
{
$this->setFilename($filename);
call_user_func_array($this->getFunctionName(), [$this->getImage(), $filename]);
return $filename;
} | php | public function save($filename)
{
$this->setFilename($filename);
call_user_func_array($this->getFunctionName(), [$this->getImage(), $filename]);
return $filename;
} | [
"public",
"function",
"save",
"(",
"$",
"filename",
")",
"{",
"$",
"this",
"->",
"setFilename",
"(",
"$",
"filename",
")",
";",
"call_user_func_array",
"(",
"$",
"this",
"->",
"getFunctionName",
"(",
")",
",",
"[",
"$",
"this",
"->",
"getImage",
"(",
"... | Render the QR Code then save it to given file name
@param string $filename
@throws ImageFunctionUnknownException
@return string | [
"Render",
"the",
"QR",
"Code",
"then",
"save",
"it",
"to",
"given",
"file",
"name"
] | c0e3429df86bf9e4668c1e4f083c742ae677f6fe | https://github.com/arcanedev-maroc/QrCode/blob/c0e3429df86bf9e4668c1e4f083c742ae677f6fe/src/QrCode.php#L413-L420 | train |
orchestral/installer | src/Requirement.php | Requirement.add | public function add(SpecificationContract $specification)
{
$this->items->put($specification->uid(), $specification);
return $this;
} | php | public function add(SpecificationContract $specification)
{
$this->items->put($specification->uid(), $specification);
return $this;
} | [
"public",
"function",
"add",
"(",
"SpecificationContract",
"$",
"specification",
")",
"{",
"$",
"this",
"->",
"items",
"->",
"put",
"(",
"$",
"specification",
"->",
"uid",
"(",
")",
",",
"$",
"specification",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Add requirement specification.
@param \Orchestra\Contracts\Installation\Specification $specification
@return $this | [
"Add",
"requirement",
"specification",
"."
] | f49e251916567ce461b2dc47017fc8d8959ae6cc | https://github.com/orchestral/installer/blob/f49e251916567ce461b2dc47017fc8d8959ae6cc/src/Requirement.php#L41-L46 | train |
orchestral/installer | src/Requirement.php | Requirement.check | public function check(): bool
{
return $this->installable = $this->items->filter(function ($specification) {
return $specification->check() === false && $specification->optional() === false;
})->isEmpty();
} | php | public function check(): bool
{
return $this->installable = $this->items->filter(function ($specification) {
return $specification->check() === false && $specification->optional() === false;
})->isEmpty();
} | [
"public",
"function",
"check",
"(",
")",
":",
"bool",
"{",
"return",
"$",
"this",
"->",
"installable",
"=",
"$",
"this",
"->",
"items",
"->",
"filter",
"(",
"function",
"(",
"$",
"specification",
")",
"{",
"return",
"$",
"specification",
"->",
"check",
... | Check all requirement.
@return bool | [
"Check",
"all",
"requirement",
"."
] | f49e251916567ce461b2dc47017fc8d8959ae6cc | https://github.com/orchestral/installer/blob/f49e251916567ce461b2dc47017fc8d8959ae6cc/src/Requirement.php#L53-L58 | train |
bearsunday/BEAR.QueryRepository | src/EtagSetter.php | EtagSetter.getEtag | private function getEtag(ResourceObject $ro, HttpCache $httpCache = null) : string
{
$etag = $httpCache instanceof HttpCache && $httpCache->etag ? $this->getEtagByPartialBody($httpCache, $ro) : $this->getEtagByEitireView($ro);
return (string) \crc32(\get_class($ro) . $etag);
} | php | private function getEtag(ResourceObject $ro, HttpCache $httpCache = null) : string
{
$etag = $httpCache instanceof HttpCache && $httpCache->etag ? $this->getEtagByPartialBody($httpCache, $ro) : $this->getEtagByEitireView($ro);
return (string) \crc32(\get_class($ro) . $etag);
} | [
"private",
"function",
"getEtag",
"(",
"ResourceObject",
"$",
"ro",
",",
"HttpCache",
"$",
"httpCache",
"=",
"null",
")",
":",
"string",
"{",
"$",
"etag",
"=",
"$",
"httpCache",
"instanceof",
"HttpCache",
"&&",
"$",
"httpCache",
"->",
"etag",
"?",
"$",
"... | Return crc32 encoded Etag
Is crc32 enough for Etag ?
@see https://cloud.google.com/storage/docs/hashes-etags | [
"Return",
"crc32",
"encoded",
"Etag"
] | 45fd9f2e02e188fb48d0f085022de29840672272 | https://github.com/bearsunday/BEAR.QueryRepository/blob/45fd9f2e02e188fb48d0f085022de29840672272/src/EtagSetter.php#L49-L54 | train |
jbouzekri/FileUploaderBundle | EventListener/Validation/ConfiguredValidationListener.php | ConfiguredValidationListener.onValidate | public function onValidate(ValidationEvent $event)
{
try {
$this->validator->validate(
$event->getType(),
$event->getFile(),
'upload_validators'
);
} catch (JbFileUploaderValidationException $e) {
throw new ValidationException($e->getMessage(), null, $e);
}
} | php | public function onValidate(ValidationEvent $event)
{
try {
$this->validator->validate(
$event->getType(),
$event->getFile(),
'upload_validators'
);
} catch (JbFileUploaderValidationException $e) {
throw new ValidationException($e->getMessage(), null, $e);
}
} | [
"public",
"function",
"onValidate",
"(",
"ValidationEvent",
"$",
"event",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"validator",
"->",
"validate",
"(",
"$",
"event",
"->",
"getType",
"(",
")",
",",
"$",
"event",
"->",
"getFile",
"(",
")",
",",
"'upload_... | Validate a submited file
@param ValidationEvent $event
@throws \Oneup\UploaderBundle\Uploader\Exception\ValidationException | [
"Validate",
"a",
"submited",
"file"
] | 592e7ed827eaa4e7f8f6f52947ca5e5a86835f6c | https://github.com/jbouzekri/FileUploaderBundle/blob/592e7ed827eaa4e7f8f6f52947ca5e5a86835f6c/EventListener/Validation/ConfiguredValidationListener.php#L46-L57 | train |
maximebf/CacheCache | src/CacheCache/Backends/File.php | File.encode | public function encode($data, $ttl)
{
$expire = null;
if ($ttl !== null) {
$expire = time() + $ttl;
}
return serialize(array($data, $expire));
} | php | public function encode($data, $ttl)
{
$expire = null;
if ($ttl !== null) {
$expire = time() + $ttl;
}
return serialize(array($data, $expire));
} | [
"public",
"function",
"encode",
"(",
"$",
"data",
",",
"$",
"ttl",
")",
"{",
"$",
"expire",
"=",
"null",
";",
"if",
"(",
"$",
"ttl",
"!==",
"null",
")",
"{",
"$",
"expire",
"=",
"time",
"(",
")",
"+",
"$",
"ttl",
";",
"}",
"return",
"serialize"... | Encodes some data to a string so it can be written to disk
@param mixed $data
@param int $ttl
@return string | [
"Encodes",
"some",
"data",
"to",
"a",
"string",
"so",
"it",
"can",
"be",
"written",
"to",
"disk"
] | eb64a3748aad4ddaf236ef4738a83267576a0f97 | https://github.com/maximebf/CacheCache/blob/eb64a3748aad4ddaf236ef4738a83267576a0f97/src/CacheCache/Backends/File.php#L142-L149 | train |
voku/twig-wrapper | src/voku/twig/TwigWrapper.php | TwigWrapper.setTemplatePath | private function setTemplatePath($templatePath)
{
$return = false;
if (is_string($templatePath)) {
if ($this->checkTemplatePath($templatePath) === true) {
$this->templatePath[] = $templatePath;
$return = true;
}
}
else if (is_array($templatePath)) {
foreach ($templatePath as $path) {
if ($this->checkTemplatePath($path) === true) {
$this->templatePath[] = $path;
$return = true;
}
}
}
return $return;
} | php | private function setTemplatePath($templatePath)
{
$return = false;
if (is_string($templatePath)) {
if ($this->checkTemplatePath($templatePath) === true) {
$this->templatePath[] = $templatePath;
$return = true;
}
}
else if (is_array($templatePath)) {
foreach ($templatePath as $path) {
if ($this->checkTemplatePath($path) === true) {
$this->templatePath[] = $path;
$return = true;
}
}
}
return $return;
} | [
"private",
"function",
"setTemplatePath",
"(",
"$",
"templatePath",
")",
"{",
"$",
"return",
"=",
"false",
";",
"if",
"(",
"is_string",
"(",
"$",
"templatePath",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"checkTemplatePath",
"(",
"$",
"templatePath",
... | set the template-path or use the path from config
@param array|string $templatePath
@return bool | [
"set",
"the",
"template",
"-",
"path",
"or",
"use",
"the",
"path",
"from",
"config"
] | 0f7f8f2413ea9832f010036e9b89bf92589f411e | https://github.com/voku/twig-wrapper/blob/0f7f8f2413ea9832f010036e9b89bf92589f411e/src/voku/twig/TwigWrapper.php#L75-L97 | train |
voku/twig-wrapper | src/voku/twig/TwigWrapper.php | TwigWrapper.checkTemplatePath | private function checkTemplatePath($templatePath, $exitOnError = true)
{
if (!is_dir($templatePath)) {
if ($exitOnError === true) {
exit();
}
return false;
} else {
return true;
}
} | php | private function checkTemplatePath($templatePath, $exitOnError = true)
{
if (!is_dir($templatePath)) {
if ($exitOnError === true) {
exit();
}
return false;
} else {
return true;
}
} | [
"private",
"function",
"checkTemplatePath",
"(",
"$",
"templatePath",
",",
"$",
"exitOnError",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"templatePath",
")",
")",
"{",
"if",
"(",
"$",
"exitOnError",
"===",
"true",
")",
"{",
"exit",
"("... | check if the the template-directory exists
@param string $templatePath
@param bool $exitOnError
@return bool | [
"check",
"if",
"the",
"the",
"template",
"-",
"directory",
"exists"
] | 0f7f8f2413ea9832f010036e9b89bf92589f411e | https://github.com/voku/twig-wrapper/blob/0f7f8f2413ea9832f010036e9b89bf92589f411e/src/voku/twig/TwigWrapper.php#L107-L119 | train |
voku/twig-wrapper | src/voku/twig/TwigWrapper.php | TwigWrapper.optimizer | private function optimizer()
{
$optimizeOption = -1;
if ($this->environment['cache'] === false) {
$optimizeOption = 2;
}
switch ($optimizeOption) {
case -1:
$nodeVisitorOptimizer = Twig_NodeVisitor_Optimizer::OPTIMIZE_ALL;
break;
case 0:
$nodeVisitorOptimizer = Twig_NodeVisitor_Optimizer::OPTIMIZE_NONE;
break;
case 2:
$nodeVisitorOptimizer = Twig_NodeVisitor_Optimizer::OPTIMIZE_FOR;
break;
case 4:
$nodeVisitorOptimizer = Twig_NodeVisitor_Optimizer::OPTIMIZE_RAW_FILTER;
break;
case 8:
$nodeVisitorOptimizer = Twig_NodeVisitor_Optimizer::OPTIMIZE_VAR_ACCESS;
break;
default:
$nodeVisitorOptimizer = Twig_NodeVisitor_Optimizer::OPTIMIZE_ALL;
break;
}
$optimizer = new Twig_Extension_Optimizer($nodeVisitorOptimizer);
$this->twig->addExtension($optimizer);
} | php | private function optimizer()
{
$optimizeOption = -1;
if ($this->environment['cache'] === false) {
$optimizeOption = 2;
}
switch ($optimizeOption) {
case -1:
$nodeVisitorOptimizer = Twig_NodeVisitor_Optimizer::OPTIMIZE_ALL;
break;
case 0:
$nodeVisitorOptimizer = Twig_NodeVisitor_Optimizer::OPTIMIZE_NONE;
break;
case 2:
$nodeVisitorOptimizer = Twig_NodeVisitor_Optimizer::OPTIMIZE_FOR;
break;
case 4:
$nodeVisitorOptimizer = Twig_NodeVisitor_Optimizer::OPTIMIZE_RAW_FILTER;
break;
case 8:
$nodeVisitorOptimizer = Twig_NodeVisitor_Optimizer::OPTIMIZE_VAR_ACCESS;
break;
default:
$nodeVisitorOptimizer = Twig_NodeVisitor_Optimizer::OPTIMIZE_ALL;
break;
}
$optimizer = new Twig_Extension_Optimizer($nodeVisitorOptimizer);
$this->twig->addExtension($optimizer);
} | [
"private",
"function",
"optimizer",
"(",
")",
"{",
"$",
"optimizeOption",
"=",
"-",
"1",
";",
"if",
"(",
"$",
"this",
"->",
"environment",
"[",
"'cache'",
"]",
"===",
"false",
")",
"{",
"$",
"optimizeOption",
"=",
"2",
";",
"}",
"switch",
"(",
"$",
... | optimize twig-output
OPTIMIZE_ALL (-1) | OPTIMIZE_NONE (0) | OPTIMIZE_FOR (2) | OPTIMIZE_RAW_FILTER (4) | OPTIMIZE_VAR_ACCESS (8) | [
"optimize",
"twig",
"-",
"output"
] | 0f7f8f2413ea9832f010036e9b89bf92589f411e | https://github.com/voku/twig-wrapper/blob/0f7f8f2413ea9832f010036e9b89bf92589f411e/src/voku/twig/TwigWrapper.php#L142-L178 | train |
voku/twig-wrapper | src/voku/twig/TwigWrapper.php | TwigWrapper.render | public function render($withHeader = true)
{
// DEBUG
if (isset($_GET['twigDebug']) && $_GET['twigDebug'] == 1) {
$this->debug();
}
$this->template = $this->twig->loadTemplate($this->filename);
if ($withHeader === true) {
header('X-UA-Compatible: IE=edge,chrome=1');
header('Content-Type: text/html; charset=utf-8');
}
return $this->template->render($this->data);
} | php | public function render($withHeader = true)
{
// DEBUG
if (isset($_GET['twigDebug']) && $_GET['twigDebug'] == 1) {
$this->debug();
}
$this->template = $this->twig->loadTemplate($this->filename);
if ($withHeader === true) {
header('X-UA-Compatible: IE=edge,chrome=1');
header('Content-Type: text/html; charset=utf-8');
}
return $this->template->render($this->data);
} | [
"public",
"function",
"render",
"(",
"$",
"withHeader",
"=",
"true",
")",
"{",
"// DEBUG",
"if",
"(",
"isset",
"(",
"$",
"_GET",
"[",
"'twigDebug'",
"]",
")",
"&&",
"$",
"_GET",
"[",
"'twigDebug'",
"]",
"==",
"1",
")",
"{",
"$",
"this",
"->",
"debu... | render the template
@param bool $withHeader
@return string | [
"render",
"the",
"template"
] | 0f7f8f2413ea9832f010036e9b89bf92589f411e | https://github.com/voku/twig-wrapper/blob/0f7f8f2413ea9832f010036e9b89bf92589f411e/src/voku/twig/TwigWrapper.php#L219-L234 | train |
dframe/database | src/WhereChunk.php | WhereChunk.build | public function build()
{
$params = [];
if ($this->value !== null) {
$op = !is_null($this->operator) ? $this->operator : '=';
$paramName = str_replace('.', '_', $this->key);
if ($op == 'BETWEEN') {
$sql = "{$this->key} $op ? AND ?";
$between = explode('AND', $this->value);
$params[':dateFrom'] = trim($between[0]);
$params[':dateTo'] = trim($between[1]);
} else {
$sql = "{$this->key} $op ?"; // $sql = "{$this->key} $op {$paramName}";
$params[":{$paramName}"] = $this->value;
}
} else {
$sql = $sql = "{$this->key} IS NULL ";
}
return [$sql, $params];
} | php | public function build()
{
$params = [];
if ($this->value !== null) {
$op = !is_null($this->operator) ? $this->operator : '=';
$paramName = str_replace('.', '_', $this->key);
if ($op == 'BETWEEN') {
$sql = "{$this->key} $op ? AND ?";
$between = explode('AND', $this->value);
$params[':dateFrom'] = trim($between[0]);
$params[':dateTo'] = trim($between[1]);
} else {
$sql = "{$this->key} $op ?"; // $sql = "{$this->key} $op {$paramName}";
$params[":{$paramName}"] = $this->value;
}
} else {
$sql = $sql = "{$this->key} IS NULL ";
}
return [$sql, $params];
} | [
"public",
"function",
"build",
"(",
")",
"{",
"$",
"params",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"value",
"!==",
"null",
")",
"{",
"$",
"op",
"=",
"!",
"is_null",
"(",
"$",
"this",
"->",
"operator",
")",
"?",
"$",
"this",
"->",
... | Build function.
@return array | [
"Build",
"function",
"."
] | 6d9ac90d695c33b5e417b58f2134f86f79918387 | https://github.com/dframe/database/blob/6d9ac90d695c33b5e417b58f2134f86f79918387/src/WhereChunk.php#L45-L68 | train |
rchouinard/rych-otp | src/Seed.php | Seed.getFormat | public function getFormat()
{
switch (true) {
case ($this->encoder instanceof Base32Encoder):
$format = self::FORMAT_BASE32;
break;
case ($this->encoder instanceof HexEncoder):
$format = self::FORMAT_HEX;
break;
case ($this->encoder instanceof RawEncoder):
default:
$format = self::FORMAT_RAW;
}
return $format;
} | php | public function getFormat()
{
switch (true) {
case ($this->encoder instanceof Base32Encoder):
$format = self::FORMAT_BASE32;
break;
case ($this->encoder instanceof HexEncoder):
$format = self::FORMAT_HEX;
break;
case ($this->encoder instanceof RawEncoder):
default:
$format = self::FORMAT_RAW;
}
return $format;
} | [
"public",
"function",
"getFormat",
"(",
")",
"{",
"switch",
"(",
"true",
")",
"{",
"case",
"(",
"$",
"this",
"->",
"encoder",
"instanceof",
"Base32Encoder",
")",
":",
"$",
"format",
"=",
"self",
"::",
"FORMAT_BASE32",
";",
"break",
";",
"case",
"(",
"$... | Get the output format
@return string Returns the current output format. | [
"Get",
"the",
"output",
"format"
] | b3c7fc11284c546cd291f14fb383a7d49ab23832 | https://github.com/rchouinard/rych-otp/blob/b3c7fc11284c546cd291f14fb383a7d49ab23832/src/Seed.php#L60-L75 | train |
rchouinard/rych-otp | src/Seed.php | Seed.setFormat | public function setFormat($format)
{
switch ($format) {
case self::FORMAT_BASE32:
$this->encoder = new Base32Encoder();
break;
case self::FORMAT_HEX:
$this->encoder = new HexEncoder();
break;
case self::FORMAT_RAW:
default:
$this->encoder = new RawEncoder();
}
return $this;
} | php | public function setFormat($format)
{
switch ($format) {
case self::FORMAT_BASE32:
$this->encoder = new Base32Encoder();
break;
case self::FORMAT_HEX:
$this->encoder = new HexEncoder();
break;
case self::FORMAT_RAW:
default:
$this->encoder = new RawEncoder();
}
return $this;
} | [
"public",
"function",
"setFormat",
"(",
"$",
"format",
")",
"{",
"switch",
"(",
"$",
"format",
")",
"{",
"case",
"self",
"::",
"FORMAT_BASE32",
":",
"$",
"this",
"->",
"encoder",
"=",
"new",
"Base32Encoder",
"(",
")",
";",
"break",
";",
"case",
"self",... | Set the output format
@param string $format The new output format.
@return self Returns an instance of self for method chaining. | [
"Set",
"the",
"output",
"format"
] | b3c7fc11284c546cd291f14fb383a7d49ab23832 | https://github.com/rchouinard/rych-otp/blob/b3c7fc11284c546cd291f14fb383a7d49ab23832/src/Seed.php#L83-L98 | train |
rchouinard/rych-otp | src/Seed.php | Seed.setValue | public function setValue($value, $format = null)
{
$this->value = $this->decode($value, $format);
} | php | public function setValue($value, $format = null)
{
$this->value = $this->decode($value, $format);
} | [
"public",
"function",
"setValue",
"(",
"$",
"value",
",",
"$",
"format",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"value",
"=",
"$",
"this",
"->",
"decode",
"(",
"$",
"value",
",",
"$",
"format",
")",
";",
"}"
] | Set the seed value, optionally specifying an input format
@param string $value The seed value.
@param string $format Optional; input format. If not provided, format
will be auto-detected.
@return self Returns an instance of self for method chaining. | [
"Set",
"the",
"seed",
"value",
"optionally",
"specifying",
"an",
"input",
"format"
] | b3c7fc11284c546cd291f14fb383a7d49ab23832 | https://github.com/rchouinard/rych-otp/blob/b3c7fc11284c546cd291f14fb383a7d49ab23832/src/Seed.php#L120-L123 | train |
rchouinard/rych-otp | src/Seed.php | Seed.decode | private function decode($seed, $format = null)
{
$encoder = new RawEncoder();
// Auto-detect
if ($format === null) {
if (preg_match('/^[0-9a-f]+$/i', $seed)) {
$encoder = new HexEncoder();
} elseif (preg_match('/^[2-7a-z]+$/i', $seed)) {
$encoder = new Base32Encoder();
}
// User-specified
} else {
if ($format == self::FORMAT_HEX) {
$encoder = new HexEncoder();
} elseif ($format == self::FORMAT_BASE32) {
$encoder = new Base32Encoder();
}
}
$output = $encoder->decode($seed);
return $output;
} | php | private function decode($seed, $format = null)
{
$encoder = new RawEncoder();
// Auto-detect
if ($format === null) {
if (preg_match('/^[0-9a-f]+$/i', $seed)) {
$encoder = new HexEncoder();
} elseif (preg_match('/^[2-7a-z]+$/i', $seed)) {
$encoder = new Base32Encoder();
}
// User-specified
} else {
if ($format == self::FORMAT_HEX) {
$encoder = new HexEncoder();
} elseif ($format == self::FORMAT_BASE32) {
$encoder = new Base32Encoder();
}
}
$output = $encoder->decode($seed);
return $output;
} | [
"private",
"function",
"decode",
"(",
"$",
"seed",
",",
"$",
"format",
"=",
"null",
")",
"{",
"$",
"encoder",
"=",
"new",
"RawEncoder",
"(",
")",
";",
"// Auto-detect",
"if",
"(",
"$",
"format",
"===",
"null",
")",
"{",
"if",
"(",
"preg_match",
"(",
... | Attempt to decode a seed value
@param string $seed The encoded seed value.
@param string $format Optional; value encoding format. If not
provided, format will be auto-detected.
@return string Returns the decoded seed value. | [
"Attempt",
"to",
"decode",
"a",
"seed",
"value"
] | b3c7fc11284c546cd291f14fb383a7d49ab23832 | https://github.com/rchouinard/rych-otp/blob/b3c7fc11284c546cd291f14fb383a7d49ab23832/src/Seed.php#L168-L191 | train |
rchouinard/rych-otp | src/Seed.php | Seed.encode | private function encode($seed, $format = null)
{
$encoder = $this->encoder;
if ($format == self::FORMAT_HEX) {
$encoder = new HexEncoder();
} elseif ($format == self::FORMAT_BASE32) {
$encoder = new Base32Encoder();
} elseif ($format == self::FORMAT_RAW) {
$encoder = new RawEncoder();
}
$output = $encoder->encode($seed);
return $output;
} | php | private function encode($seed, $format = null)
{
$encoder = $this->encoder;
if ($format == self::FORMAT_HEX) {
$encoder = new HexEncoder();
} elseif ($format == self::FORMAT_BASE32) {
$encoder = new Base32Encoder();
} elseif ($format == self::FORMAT_RAW) {
$encoder = new RawEncoder();
}
$output = $encoder->encode($seed);
return $output;
} | [
"private",
"function",
"encode",
"(",
"$",
"seed",
",",
"$",
"format",
"=",
"null",
")",
"{",
"$",
"encoder",
"=",
"$",
"this",
"->",
"encoder",
";",
"if",
"(",
"$",
"format",
"==",
"self",
"::",
"FORMAT_HEX",
")",
"{",
"$",
"encoder",
"=",
"new",
... | Attempt to encode a seed value
@param string $seed The seed value.
@param string $format Optional; target encode format. If not provided,
default format is assumed.
@return string Returns the encoded seed value. | [
"Attempt",
"to",
"encode",
"a",
"seed",
"value"
] | b3c7fc11284c546cd291f14fb383a7d49ab23832 | https://github.com/rchouinard/rych-otp/blob/b3c7fc11284c546cd291f14fb383a7d49ab23832/src/Seed.php#L201-L216 | train |
brightnucleus/shortcodes | src/TemplatedShortcode.php | TemplatedShortcode.init_template_loader | public function init_template_loader() {
$loader_class = $this->hasConfigKey( 'template', 'custom_loader' )
? $this->getConfigKey( 'template', 'custom_loader' )
: $this->get_default_template_loader_class();
$filter_prefix = $this->hasConfigKey( 'template', 'filter_prefix' )
? $this->getConfigKey( 'template', 'filter_prefix' )
: $this->get_default_filter_prefix();
$template_dir = $this->hasConfigKey( 'template', 'template_directory' )
? $this->getConfigKey( 'template', 'template_directory' )
: $this->get_default_template_directory();
$view_dir = $this->hasConfigKey( 'view' )
? $this->get_directory_from_view( $this->getConfigKey( 'view' ) )
: $this->get_default_view_directory();
return new $loader_class(
$filter_prefix,
$template_dir,
$view_dir
);
} | php | public function init_template_loader() {
$loader_class = $this->hasConfigKey( 'template', 'custom_loader' )
? $this->getConfigKey( 'template', 'custom_loader' )
: $this->get_default_template_loader_class();
$filter_prefix = $this->hasConfigKey( 'template', 'filter_prefix' )
? $this->getConfigKey( 'template', 'filter_prefix' )
: $this->get_default_filter_prefix();
$template_dir = $this->hasConfigKey( 'template', 'template_directory' )
? $this->getConfigKey( 'template', 'template_directory' )
: $this->get_default_template_directory();
$view_dir = $this->hasConfigKey( 'view' )
? $this->get_directory_from_view( $this->getConfigKey( 'view' ) )
: $this->get_default_view_directory();
return new $loader_class(
$filter_prefix,
$template_dir,
$view_dir
);
} | [
"public",
"function",
"init_template_loader",
"(",
")",
"{",
"$",
"loader_class",
"=",
"$",
"this",
"->",
"hasConfigKey",
"(",
"'template'",
",",
"'custom_loader'",
")",
"?",
"$",
"this",
"->",
"getConfigKey",
"(",
"'template'",
",",
"'custom_loader'",
")",
":... | Initialize the template loader class.
@since 0.2.6
@return Gamajo_Template_Loader | [
"Initialize",
"the",
"template",
"loader",
"class",
"."
] | 5db6fa3c18db856ab550e56960a844d6aa99dabb | https://github.com/brightnucleus/shortcodes/blob/5db6fa3c18db856ab550e56960a844d6aa99dabb/src/TemplatedShortcode.php#L77-L96 | train |
fadion/ValidatorAssistant | src/Bindings.php | Bindings.prepare | private function prepare($args)
{
$bindings = array();
// Two parameters (key, value).
if (count($args) == 2) {
$bindings[$args[0]] = $args[1];
}
// Array of parameters.
elseif (is_array($args[0])) {
$bindings = $args[0];
}
return $bindings;
} | php | private function prepare($args)
{
$bindings = array();
// Two parameters (key, value).
if (count($args) == 2) {
$bindings[$args[0]] = $args[1];
}
// Array of parameters.
elseif (is_array($args[0])) {
$bindings = $args[0];
}
return $bindings;
} | [
"private",
"function",
"prepare",
"(",
"$",
"args",
")",
"{",
"$",
"bindings",
"=",
"array",
"(",
")",
";",
"// Two parameters (key, value).",
"if",
"(",
"count",
"(",
"$",
"args",
")",
"==",
"2",
")",
"{",
"$",
"bindings",
"[",
"$",
"args",
"[",
"0"... | Prepares binding parameters.
@param array $args
@return void | [
"Prepares",
"binding",
"parameters",
"."
] | 8ed6f134fdcf9a8c6ce2dd6a5c9eeb5d4cddf178 | https://github.com/fadion/ValidatorAssistant/blob/8ed6f134fdcf9a8c6ce2dd6a5c9eeb5d4cddf178/src/Bindings.php#L61-L75 | train |
fadion/ValidatorAssistant | src/Bindings.php | Bindings.replace | private function replace($bindings)
{
$search = array_keys($bindings);
$replace = array_values($bindings);
foreach ($search as $key => &$value) {
$value = $this->delimiters[0].$value.$this->delimiters[1];
}
array_walk_recursive($this->rules, function(&$value, $key) use($search, $replace) {
$value = str_ireplace($search, $replace, $value);
});
} | php | private function replace($bindings)
{
$search = array_keys($bindings);
$replace = array_values($bindings);
foreach ($search as $key => &$value) {
$value = $this->delimiters[0].$value.$this->delimiters[1];
}
array_walk_recursive($this->rules, function(&$value, $key) use($search, $replace) {
$value = str_ireplace($search, $replace, $value);
});
} | [
"private",
"function",
"replace",
"(",
"$",
"bindings",
")",
"{",
"$",
"search",
"=",
"array_keys",
"(",
"$",
"bindings",
")",
";",
"$",
"replace",
"=",
"array_values",
"(",
"$",
"bindings",
")",
";",
"foreach",
"(",
"$",
"search",
"as",
"$",
"key",
... | Replaces binding occurrences.
@param array $bindings
@return void | [
"Replaces",
"binding",
"occurrences",
"."
] | 8ed6f134fdcf9a8c6ce2dd6a5c9eeb5d4cddf178 | https://github.com/fadion/ValidatorAssistant/blob/8ed6f134fdcf9a8c6ce2dd6a5c9eeb5d4cddf178/src/Bindings.php#L83-L95 | train |
nekudo/Angela | src/Worker.php | Worker.registerJob | public function registerJob(string $jobName, callable $callback) : bool
{
$this->callbacks[$jobName] = $callback;
$this->jobSocket->subscribe($jobName);
// register job at server:
$this->replySocket->send(json_encode([
'request' => 'register_job',
'worker_id' => $this->workerId,
'job_name' => $jobName
]));
$response = $this->replySocket->recv();
return ($response === 'ok');
} | php | public function registerJob(string $jobName, callable $callback) : bool
{
$this->callbacks[$jobName] = $callback;
$this->jobSocket->subscribe($jobName);
// register job at server:
$this->replySocket->send(json_encode([
'request' => 'register_job',
'worker_id' => $this->workerId,
'job_name' => $jobName
]));
$response = $this->replySocket->recv();
return ($response === 'ok');
} | [
"public",
"function",
"registerJob",
"(",
"string",
"$",
"jobName",
",",
"callable",
"$",
"callback",
")",
":",
"bool",
"{",
"$",
"this",
"->",
"callbacks",
"[",
"$",
"jobName",
"]",
"=",
"$",
"callback",
";",
"$",
"this",
"->",
"jobSocket",
"->",
"sub... | Registers a type of job the worker is able to do.
@param string $jobName
@param callable $callback
@return bool | [
"Registers",
"a",
"type",
"of",
"job",
"the",
"worker",
"is",
"able",
"to",
"do",
"."
] | 6b8c0bef6f56be38155c9b78b0c888aa91271ebc | https://github.com/nekudo/Angela/blob/6b8c0bef6f56be38155c9b78b0c888aa91271ebc/src/Worker.php#L110-L123 | train |
nekudo/Angela | src/Worker.php | Worker.createJobSocket | protected function createJobSocket()
{
/** @var Context|\ZMQContext $jobContext */
$jobContext = new Context($this->loop);
$this->jobSocket = $jobContext->getSocket(\ZMQ::SOCKET_SUB);
$this->jobSocket->connect($this->config['sockets']['worker_job']);
$this->jobSocket->on('messages', [$this, 'onJobMessage']);
} | php | protected function createJobSocket()
{
/** @var Context|\ZMQContext $jobContext */
$jobContext = new Context($this->loop);
$this->jobSocket = $jobContext->getSocket(\ZMQ::SOCKET_SUB);
$this->jobSocket->connect($this->config['sockets']['worker_job']);
$this->jobSocket->on('messages', [$this, 'onJobMessage']);
} | [
"protected",
"function",
"createJobSocket",
"(",
")",
"{",
"/** @var Context|\\ZMQContext $jobContext */",
"$",
"jobContext",
"=",
"new",
"Context",
"(",
"$",
"this",
"->",
"loop",
")",
";",
"$",
"this",
"->",
"jobSocket",
"=",
"$",
"jobContext",
"->",
"getSocke... | Creates socket to receive jobs from server and registers corresponding callbacks. | [
"Creates",
"socket",
"to",
"receive",
"jobs",
"from",
"server",
"and",
"registers",
"corresponding",
"callbacks",
"."
] | 6b8c0bef6f56be38155c9b78b0c888aa91271ebc | https://github.com/nekudo/Angela/blob/6b8c0bef6f56be38155c9b78b0c888aa91271ebc/src/Worker.php#L128-L135 | train |
nekudo/Angela | src/Worker.php | Worker.createReplySocket | protected function createReplySocket()
{
$replyContext = new \ZMQContext;
$this->replySocket = $replyContext->getSocket(\ZMQ::SOCKET_REQ);
$this->replySocket->connect($this->config['sockets']['worker_reply']);
} | php | protected function createReplySocket()
{
$replyContext = new \ZMQContext;
$this->replySocket = $replyContext->getSocket(\ZMQ::SOCKET_REQ);
$this->replySocket->connect($this->config['sockets']['worker_reply']);
} | [
"protected",
"function",
"createReplySocket",
"(",
")",
"{",
"$",
"replyContext",
"=",
"new",
"\\",
"ZMQContext",
";",
"$",
"this",
"->",
"replySocket",
"=",
"$",
"replyContext",
"->",
"getSocket",
"(",
"\\",
"ZMQ",
"::",
"SOCKET_REQ",
")",
";",
"$",
"this... | Creates socket used to reply to server. | [
"Creates",
"socket",
"used",
"to",
"reply",
"to",
"server",
"."
] | 6b8c0bef6f56be38155c9b78b0c888aa91271ebc | https://github.com/nekudo/Angela/blob/6b8c0bef6f56be38155c9b78b0c888aa91271ebc/src/Worker.php#L140-L145 | train |
nekudo/Angela | src/Worker.php | Worker.onJobMessage | public function onJobMessage(array $message) : bool
{
$jobName = $message[0];
$jobId = $message[1];
$workerId = $message[2];
$payload = $message[3];
// Skip if job is assigned to another worker:
if ($workerId !== $this->workerId) {
return false;
}
// Skip if worker can not handle the requested job
if (!isset($this->callbacks[$jobName])) {
throw new WorkerException('No callback found for requested job.');
}
// Switch to busy state handle job and switch back to idle state:
$this->jobId = $jobId;
$this->setState(Worker::WORKER_STATE_BUSY);
$result = call_user_func($this->callbacks[$jobName], $payload);
$this->onJobCompleted($result);
$this->setState(Worker::WORKER_STATE_IDLE);
return true;
} | php | public function onJobMessage(array $message) : bool
{
$jobName = $message[0];
$jobId = $message[1];
$workerId = $message[2];
$payload = $message[3];
// Skip if job is assigned to another worker:
if ($workerId !== $this->workerId) {
return false;
}
// Skip if worker can not handle the requested job
if (!isset($this->callbacks[$jobName])) {
throw new WorkerException('No callback found for requested job.');
}
// Switch to busy state handle job and switch back to idle state:
$this->jobId = $jobId;
$this->setState(Worker::WORKER_STATE_BUSY);
$result = call_user_func($this->callbacks[$jobName], $payload);
$this->onJobCompleted($result);
$this->setState(Worker::WORKER_STATE_IDLE);
return true;
} | [
"public",
"function",
"onJobMessage",
"(",
"array",
"$",
"message",
")",
":",
"bool",
"{",
"$",
"jobName",
"=",
"$",
"message",
"[",
"0",
"]",
";",
"$",
"jobId",
"=",
"$",
"message",
"[",
"1",
"]",
";",
"$",
"workerId",
"=",
"$",
"message",
"[",
... | Handles job requests received from server.
@throws WorkerException
@param array $message
@return bool | [
"Handles",
"job",
"requests",
"received",
"from",
"server",
"."
] | 6b8c0bef6f56be38155c9b78b0c888aa91271ebc | https://github.com/nekudo/Angela/blob/6b8c0bef6f56be38155c9b78b0c888aa91271ebc/src/Worker.php#L154-L178 | train |
nekudo/Angela | src/Worker.php | Worker.setState | protected function setState(int $state) : bool
{
$this->workerState = $state;
// report idle state to server:
$this->replySocket->send(json_encode([
'request' => 'change_state',
'worker_id' => $this->workerId,
'state' => $this->workerState
]));
$response = $this->replySocket->recv();
return ($response === 'ok');
} | php | protected function setState(int $state) : bool
{
$this->workerState = $state;
// report idle state to server:
$this->replySocket->send(json_encode([
'request' => 'change_state',
'worker_id' => $this->workerId,
'state' => $this->workerState
]));
$response = $this->replySocket->recv();
return ($response === 'ok');
} | [
"protected",
"function",
"setState",
"(",
"int",
"$",
"state",
")",
":",
"bool",
"{",
"$",
"this",
"->",
"workerState",
"=",
"$",
"state",
";",
"// report idle state to server:",
"$",
"this",
"->",
"replySocket",
"->",
"send",
"(",
"json_encode",
"(",
"[",
... | Sets a new worker state and reports this state to server.
@param int $state
@return bool | [
"Sets",
"a",
"new",
"worker",
"state",
"and",
"reports",
"this",
"state",
"to",
"server",
"."
] | 6b8c0bef6f56be38155c9b78b0c888aa91271ebc | https://github.com/nekudo/Angela/blob/6b8c0bef6f56be38155c9b78b0c888aa91271ebc/src/Worker.php#L186-L198 | train |
nekudo/Angela | src/Worker.php | Worker.onJobCompleted | protected function onJobCompleted(string $result) : bool
{
$this->replySocket->send(json_encode([
'request' => 'job_completed',
'worker_id' => $this->workerId,
'job_id' => $this->jobId,
'result' => $result
]));
$response = $this->replySocket->recv();
$this->jobId = null;
return ($response === 'ok');
} | php | protected function onJobCompleted(string $result) : bool
{
$this->replySocket->send(json_encode([
'request' => 'job_completed',
'worker_id' => $this->workerId,
'job_id' => $this->jobId,
'result' => $result
]));
$response = $this->replySocket->recv();
$this->jobId = null;
return ($response === 'ok');
} | [
"protected",
"function",
"onJobCompleted",
"(",
"string",
"$",
"result",
")",
":",
"bool",
"{",
"$",
"this",
"->",
"replySocket",
"->",
"send",
"(",
"json_encode",
"(",
"[",
"'request'",
"=>",
"'job_completed'",
",",
"'worker_id'",
"=>",
"$",
"this",
"->",
... | Sends results of a job back to server.
@param string $result
@return bool | [
"Sends",
"results",
"of",
"a",
"job",
"back",
"to",
"server",
"."
] | 6b8c0bef6f56be38155c9b78b0c888aa91271ebc | https://github.com/nekudo/Angela/blob/6b8c0bef6f56be38155c9b78b0c888aa91271ebc/src/Worker.php#L206-L217 | train |
nekudo/Angela | src/Worker.php | Worker.loadConfig | protected function loadConfig()
{
$options = getopt('c:');
if (!isset($options['c'])) {
throw new WorkerException('No path to configuration provided.');
}
$pathToConfig = $options['c'];
if (!file_exists($pathToConfig)) {
throw new WorkerException('Config file not found.');
}
$this->config = require $pathToConfig;
} | php | protected function loadConfig()
{
$options = getopt('c:');
if (!isset($options['c'])) {
throw new WorkerException('No path to configuration provided.');
}
$pathToConfig = $options['c'];
if (!file_exists($pathToConfig)) {
throw new WorkerException('Config file not found.');
}
$this->config = require $pathToConfig;
} | [
"protected",
"function",
"loadConfig",
"(",
")",
"{",
"$",
"options",
"=",
"getopt",
"(",
"'c:'",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"'c'",
"]",
")",
")",
"{",
"throw",
"new",
"WorkerException",
"(",
"'No path to configuration p... | Loads configuration from config file passed in via argument.
@throws WorkerException | [
"Loads",
"configuration",
"from",
"config",
"file",
"passed",
"in",
"via",
"argument",
"."
] | 6b8c0bef6f56be38155c9b78b0c888aa91271ebc | https://github.com/nekudo/Angela/blob/6b8c0bef6f56be38155c9b78b0c888aa91271ebc/src/Worker.php#L224-L235 | train |
nekudo/Angela | src/Worker.php | Worker.run | public function run()
{
try {
$this->loop->run();
} catch (WorkerException $e) {
$this->logger->error('Worker Error: ' . $e->getMessage());
}
} | php | public function run()
{
try {
$this->loop->run();
} catch (WorkerException $e) {
$this->logger->error('Worker Error: ' . $e->getMessage());
}
} | [
"public",
"function",
"run",
"(",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"loop",
"->",
"run",
"(",
")",
";",
"}",
"catch",
"(",
"WorkerException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"error",
"(",
"'Worker Error: '",
".",
"$",
... | Run main loop and wait for jobs. | [
"Run",
"main",
"loop",
"and",
"wait",
"for",
"jobs",
"."
] | 6b8c0bef6f56be38155c9b78b0c888aa91271ebc | https://github.com/nekudo/Angela/blob/6b8c0bef6f56be38155c9b78b0c888aa91271ebc/src/Worker.php#L249-L256 | train |
dreamfactorysoftware/df-system | src/Resources/UserSessionResource.php | UserSessionResource.handleGET | protected function handleGET()
{
$serviceName = $this->getOAuthServiceName();
if (!empty($serviceName)) {
/** @type BaseOAuthService $service */
$service = ServiceManager::getService($serviceName);
$serviceGroup = $service->getServiceTypeInfo()->getGroup();
if ($serviceGroup !== ServiceTypeGroups::OAUTH) {
throw new BadRequestException('Invalid login service provided. Please use an OAuth service.');
}
return $service->handleLogin($this->request->getDriver());
}
return Session::getPublicInfo();
} | php | protected function handleGET()
{
$serviceName = $this->getOAuthServiceName();
if (!empty($serviceName)) {
/** @type BaseOAuthService $service */
$service = ServiceManager::getService($serviceName);
$serviceGroup = $service->getServiceTypeInfo()->getGroup();
if ($serviceGroup !== ServiceTypeGroups::OAUTH) {
throw new BadRequestException('Invalid login service provided. Please use an OAuth service.');
}
return $service->handleLogin($this->request->getDriver());
}
return Session::getPublicInfo();
} | [
"protected",
"function",
"handleGET",
"(",
")",
"{",
"$",
"serviceName",
"=",
"$",
"this",
"->",
"getOAuthServiceName",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"serviceName",
")",
")",
"{",
"/** @type BaseOAuthService $service */",
"$",
"service",
... | Gets basic user session data and performs OAuth login redirect.
@return array
@throws \DreamFactory\Core\Exceptions\BadRequestException
@throws \DreamFactory\Core\Exceptions\UnauthorizedException | [
"Gets",
"basic",
"user",
"session",
"data",
"and",
"performs",
"OAuth",
"login",
"redirect",
"."
] | 18f91d7630d3cdaef85611c5b668c0521130593e | https://github.com/dreamfactorysoftware/df-system/blob/18f91d7630d3cdaef85611c5b668c0521130593e/src/Resources/UserSessionResource.php#L28-L44 | train |
dreamfactorysoftware/df-system | src/Resources/UserSessionResource.php | UserSessionResource.handlePOST | protected function handlePOST()
{
$serviceName = $this->getOAuthServiceName();
if (empty($serviceName)) {
$credentials = [
'email' => $this->getPayloadData('email'),
'username' => $this->getPayloadData('username'),
'password' => $this->getPayloadData('password'),
'is_sys_admin' => false
];
return $this->handleLogin($credentials, boolval($this->getPayloadData('remember_me')));
}
/** @type ADLdap $service */
$service = ServiceManager::getService($serviceName);
$serviceGroup = $service->getServiceTypeInfo()->getGroup();
switch ($serviceGroup) {
case ServiceTypeGroups::LDAP:
if (
config('df.enable_windows_auth', false) === true &&
$service->getServiceTypeInfo()->getName() === 'adldap'
) {
// get windows authenticated user
$username = array_get($_SERVER, 'LOGON_USER', array_get($_SERVER, 'REMOTE_USER'));
if (!empty($username)) {
return $service->handleWindowsAuth($username);
}
}
$credentials = [
'username' => $this->getPayloadData('username'),
'password' => $this->getPayloadData('password')
];
return $service->handleLogin($credentials, $this->getPayloadData('remember_me'));
case ServiceTypeGroups::OAUTH:
$oauthCallback = $this->request->getParameterAsBool('oauth_callback');
/** @type BaseOAuthService $service */
if (!empty($oauthCallback)) {
return $service->handleOAuthCallback();
} else {
return $service->handleLogin($this->request->getDriver());
}
default:
throw new BadRequestException('Invalid login service provided. Please use an OAuth or AD/Ldap service.');
}
} | php | protected function handlePOST()
{
$serviceName = $this->getOAuthServiceName();
if (empty($serviceName)) {
$credentials = [
'email' => $this->getPayloadData('email'),
'username' => $this->getPayloadData('username'),
'password' => $this->getPayloadData('password'),
'is_sys_admin' => false
];
return $this->handleLogin($credentials, boolval($this->getPayloadData('remember_me')));
}
/** @type ADLdap $service */
$service = ServiceManager::getService($serviceName);
$serviceGroup = $service->getServiceTypeInfo()->getGroup();
switch ($serviceGroup) {
case ServiceTypeGroups::LDAP:
if (
config('df.enable_windows_auth', false) === true &&
$service->getServiceTypeInfo()->getName() === 'adldap'
) {
// get windows authenticated user
$username = array_get($_SERVER, 'LOGON_USER', array_get($_SERVER, 'REMOTE_USER'));
if (!empty($username)) {
return $service->handleWindowsAuth($username);
}
}
$credentials = [
'username' => $this->getPayloadData('username'),
'password' => $this->getPayloadData('password')
];
return $service->handleLogin($credentials, $this->getPayloadData('remember_me'));
case ServiceTypeGroups::OAUTH:
$oauthCallback = $this->request->getParameterAsBool('oauth_callback');
/** @type BaseOAuthService $service */
if (!empty($oauthCallback)) {
return $service->handleOAuthCallback();
} else {
return $service->handleLogin($this->request->getDriver());
}
default:
throw new BadRequestException('Invalid login service provided. Please use an OAuth or AD/Ldap service.');
}
} | [
"protected",
"function",
"handlePOST",
"(",
")",
"{",
"$",
"serviceName",
"=",
"$",
"this",
"->",
"getOAuthServiceName",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"serviceName",
")",
")",
"{",
"$",
"credentials",
"=",
"[",
"'email'",
"=>",
"$",
"thi... | Authenticates valid user.
@return array
@throws \DreamFactory\Core\Exceptions\BadRequestException
@throws \DreamFactory\Core\Exceptions\UnauthorizedException | [
"Authenticates",
"valid",
"user",
"."
] | 18f91d7630d3cdaef85611c5b668c0521130593e | https://github.com/dreamfactorysoftware/df-system/blob/18f91d7630d3cdaef85611c5b668c0521130593e/src/Resources/UserSessionResource.php#L53-L103 | train |
dreamfactorysoftware/df-system | src/Resources/UserSessionResource.php | UserSessionResource.getOAuthServiceName | protected function getOAuthServiceName()
{
$serviceName = $this->getPayloadData('service', $this->request->getParameter('service'));
if (empty($serviceName)) {
$state = $this->getPayloadData('state', $this->request->getParameter('state'));
if (empty($state)) {
$state = $this->getPayloadData('oauth_token', $this->request->getParameter('oauth_token'));
}
if (!empty($state)) {
$key = BaseOAuthService::CACHE_KEY_PREFIX . $state;
$serviceName = \Cache::pull($key);
}
}
return $serviceName;
} | php | protected function getOAuthServiceName()
{
$serviceName = $this->getPayloadData('service', $this->request->getParameter('service'));
if (empty($serviceName)) {
$state = $this->getPayloadData('state', $this->request->getParameter('state'));
if (empty($state)) {
$state = $this->getPayloadData('oauth_token', $this->request->getParameter('oauth_token'));
}
if (!empty($state)) {
$key = BaseOAuthService::CACHE_KEY_PREFIX . $state;
$serviceName = \Cache::pull($key);
}
}
return $serviceName;
} | [
"protected",
"function",
"getOAuthServiceName",
"(",
")",
"{",
"$",
"serviceName",
"=",
"$",
"this",
"->",
"getPayloadData",
"(",
"'service'",
",",
"$",
"this",
"->",
"request",
"->",
"getParameter",
"(",
"'service'",
")",
")",
";",
"if",
"(",
"empty",
"("... | Retrieves OAuth service name from request param, payload, or using state identifier.
@return mixed | [
"Retrieves",
"OAuth",
"service",
"name",
"from",
"request",
"param",
"payload",
"or",
"using",
"state",
"identifier",
"."
] | 18f91d7630d3cdaef85611c5b668c0521130593e | https://github.com/dreamfactorysoftware/df-system/blob/18f91d7630d3cdaef85611c5b668c0521130593e/src/Resources/UserSessionResource.php#L110-L126 | train |
dreamfactorysoftware/df-system | src/Resources/UserSessionResource.php | UserSessionResource.handleLogin | protected function handleLogin(array $credentials = [], $remember = false)
{
$loginAttribute = strtolower(config('df.login_attribute', 'email'));
if ($loginAttribute === 'username') {
$username = array_get($credentials, 'username');
if (empty($username)) {
throw new BadRequestException('Login request is missing required username.');
}
unset($credentials['email']);
} else {
$email = array_get($credentials, 'email');
if (empty($email)) {
throw new BadRequestException('Login request is missing required email.');
}
unset($credentials['username']);
}
$password = array_get($credentials, 'password');
if (empty($password)) {
throw new BadRequestException('Login request is missing required password.');
}
$credentials['is_active'] = 1;
// if user management not available then only system admins can login.
if (!class_exists('\DreamFactory\Core\User\Resources\System\User')) {
$credentials['is_sys_admin'] = 1;
}
if (Session::authenticate($credentials, $remember, true, $this->getAppId())) {
return Session::getPublicInfo();
} else {
throw new UnauthorizedException('Invalid credentials supplied.');
}
} | php | protected function handleLogin(array $credentials = [], $remember = false)
{
$loginAttribute = strtolower(config('df.login_attribute', 'email'));
if ($loginAttribute === 'username') {
$username = array_get($credentials, 'username');
if (empty($username)) {
throw new BadRequestException('Login request is missing required username.');
}
unset($credentials['email']);
} else {
$email = array_get($credentials, 'email');
if (empty($email)) {
throw new BadRequestException('Login request is missing required email.');
}
unset($credentials['username']);
}
$password = array_get($credentials, 'password');
if (empty($password)) {
throw new BadRequestException('Login request is missing required password.');
}
$credentials['is_active'] = 1;
// if user management not available then only system admins can login.
if (!class_exists('\DreamFactory\Core\User\Resources\System\User')) {
$credentials['is_sys_admin'] = 1;
}
if (Session::authenticate($credentials, $remember, true, $this->getAppId())) {
return Session::getPublicInfo();
} else {
throw new UnauthorizedException('Invalid credentials supplied.');
}
} | [
"protected",
"function",
"handleLogin",
"(",
"array",
"$",
"credentials",
"=",
"[",
"]",
",",
"$",
"remember",
"=",
"false",
")",
"{",
"$",
"loginAttribute",
"=",
"strtolower",
"(",
"config",
"(",
"'df.login_attribute'",
",",
"'email'",
")",
")",
";",
"if"... | Performs login.
@param array $credentials
@param bool $remember
@return array
@throws BadRequestException
@throws NotFoundException
@throws UnauthorizedException
@throws \Exception | [
"Performs",
"login",
"."
] | 18f91d7630d3cdaef85611c5b668c0521130593e | https://github.com/dreamfactorysoftware/df-system/blob/18f91d7630d3cdaef85611c5b668c0521130593e/src/Resources/UserSessionResource.php#L168-L202 | train |
melisplatform/melis-front | src/Module.php | Module.prepareMiniTemplateConfig | public function prepareMiniTemplateConfig()
{
$pluginsFormat = array();
$userSites = $_SERVER['DOCUMENT_ROOT'] . '/../module/MelisSites';
if(file_exists($userSites) && is_dir($userSites)) {
$sites = $this->getDir($userSites);
if(!empty($sites)){
foreach($sites as $key => $val) {
//public site folder
$publicFolder = $userSites . DIRECTORY_SEPARATOR . $val . DIRECTORY_SEPARATOR . 'public';
//mini template image folder
// $imgFolder = $publicFolder . DIRECTORY_SEPARATOR . 'images' .DIRECTORY_SEPARATOR . 'miniTemplate';
//get the mini template folder path
$miniTplPath = $publicFolder . DIRECTORY_SEPARATOR . 'miniTemplatesTinyMce';
//check if directory is available
if(file_exists($miniTplPath) && is_dir($miniTplPath)) {
//get the plugin config format
$pluginsConfig = include __DIR__ . '/../config/plugins/MiniTemplatePlugin.config.php';
if(!empty($pluginsConfig)) {
//get all the mini template
$tpls = array_diff(scandir($miniTplPath), array('..', '.'));
if (!empty($tpls)) {
//set the site name as sub category title
$pluginsConfig['melis']['subcategory']['title'] = $val;
//set the id of the plugin
$pluginsConfig['melis']['subcategory']['id'] = $pluginsConfig['melis']['subcategory']['id'] . '_' . $val;
//get the content of the mini template
foreach ($tpls as $k => $v) {
//remove the file extension from the filename
$name = pathinfo($v, PATHINFO_FILENAME);
//create a plugin post name
$postName = $k . strtolower($name);
//prepare the content of the mini template
$content = $miniTplPath . DIRECTORY_SEPARATOR . $v;
//set the default layout for the plugin based on mini template
$pluginsConfig['front']['default'] = file_get_contents($content);
//set the plugin name using the template name
$pluginsConfig['melis']['name'] = $name;
//include the mini tpl plugin config
$pluginsFormat['plugins']['MelisMiniTemplate']['plugins']['MiniTemplatePlugin_' . $postName] = $pluginsConfig;
}
}
}
}
}
}
}
return $pluginsFormat;
} | php | public function prepareMiniTemplateConfig()
{
$pluginsFormat = array();
$userSites = $_SERVER['DOCUMENT_ROOT'] . '/../module/MelisSites';
if(file_exists($userSites) && is_dir($userSites)) {
$sites = $this->getDir($userSites);
if(!empty($sites)){
foreach($sites as $key => $val) {
//public site folder
$publicFolder = $userSites . DIRECTORY_SEPARATOR . $val . DIRECTORY_SEPARATOR . 'public';
//mini template image folder
// $imgFolder = $publicFolder . DIRECTORY_SEPARATOR . 'images' .DIRECTORY_SEPARATOR . 'miniTemplate';
//get the mini template folder path
$miniTplPath = $publicFolder . DIRECTORY_SEPARATOR . 'miniTemplatesTinyMce';
//check if directory is available
if(file_exists($miniTplPath) && is_dir($miniTplPath)) {
//get the plugin config format
$pluginsConfig = include __DIR__ . '/../config/plugins/MiniTemplatePlugin.config.php';
if(!empty($pluginsConfig)) {
//get all the mini template
$tpls = array_diff(scandir($miniTplPath), array('..', '.'));
if (!empty($tpls)) {
//set the site name as sub category title
$pluginsConfig['melis']['subcategory']['title'] = $val;
//set the id of the plugin
$pluginsConfig['melis']['subcategory']['id'] = $pluginsConfig['melis']['subcategory']['id'] . '_' . $val;
//get the content of the mini template
foreach ($tpls as $k => $v) {
//remove the file extension from the filename
$name = pathinfo($v, PATHINFO_FILENAME);
//create a plugin post name
$postName = $k . strtolower($name);
//prepare the content of the mini template
$content = $miniTplPath . DIRECTORY_SEPARATOR . $v;
//set the default layout for the plugin based on mini template
$pluginsConfig['front']['default'] = file_get_contents($content);
//set the plugin name using the template name
$pluginsConfig['melis']['name'] = $name;
//include the mini tpl plugin config
$pluginsFormat['plugins']['MelisMiniTemplate']['plugins']['MiniTemplatePlugin_' . $postName] = $pluginsConfig;
}
}
}
}
}
}
}
return $pluginsFormat;
} | [
"public",
"function",
"prepareMiniTemplateConfig",
"(",
")",
"{",
"$",
"pluginsFormat",
"=",
"array",
"(",
")",
";",
"$",
"userSites",
"=",
"$",
"_SERVER",
"[",
"'DOCUMENT_ROOT'",
"]",
".",
"'/../module/MelisSites'",
";",
"if",
"(",
"file_exists",
"(",
"$",
... | Function to prepare the Mini Template config
@return array | [
"Function",
"to",
"prepare",
"the",
"Mini",
"Template",
"config"
] | 5e03e32687970bb2201e4205612d5539500dc514 | https://github.com/melisplatform/melis-front/blob/5e03e32687970bb2201e4205612d5539500dc514/src/Module.php#L200-L248 | train |
nanbando/core | src/Core/EventListener/PresetListener.php | PresetListener.extend | private function extend(array $backup)
{
$preset = $this->presetStore->getPreset($this->application, $this->version, $this->options);
return array_merge($preset, $backup);
} | php | private function extend(array $backup)
{
$preset = $this->presetStore->getPreset($this->application, $this->version, $this->options);
return array_merge($preset, $backup);
} | [
"private",
"function",
"extend",
"(",
"array",
"$",
"backup",
")",
"{",
"$",
"preset",
"=",
"$",
"this",
"->",
"presetStore",
"->",
"getPreset",
"(",
"$",
"this",
"->",
"application",
",",
"$",
"this",
"->",
"version",
",",
"$",
"this",
"->",
"options"... | Extend backup with preset.
@param array $backup
@return array | [
"Extend",
"backup",
"with",
"preset",
"."
] | 790f5c6339753bffafb50a846ccb6bab81f26877 | https://github.com/nanbando/core/blob/790f5c6339753bffafb50a846ccb6bab81f26877/src/Core/EventListener/PresetListener.php#L74-L79 | train |
dframe/database | src/Database.php | Database.prepareWhere | public function prepareWhere($whereObject)
{
$where = null;
$params = [];
if (!empty($whereObject)) {
$arr = [];
/** @var \Dframe\Database\Chunk\ChunkInterface $chunk */
foreach ($whereObject as $chunk) {
list($wSQL, $wParams) = $chunk->build();
$arr[] = $wSQL;
foreach ($wParams as $k => $v) {
$params[] = $v;
}
}
$this->setWhere = ' WHERE ' . implode(' AND ', $arr);
if (is_array($this->setParams) and !empty($this->setParams)) {
$this->setParams = array_merge($this->setParams, $params);
} else {
$this->setParams = $params;
}
} else {
$this->setWhere = null;
//$this->setParams = [];
}
//if (!empty($order))
// $this->prepareOrder($order, $sort);
//
return $this;
} | php | public function prepareWhere($whereObject)
{
$where = null;
$params = [];
if (!empty($whereObject)) {
$arr = [];
/** @var \Dframe\Database\Chunk\ChunkInterface $chunk */
foreach ($whereObject as $chunk) {
list($wSQL, $wParams) = $chunk->build();
$arr[] = $wSQL;
foreach ($wParams as $k => $v) {
$params[] = $v;
}
}
$this->setWhere = ' WHERE ' . implode(' AND ', $arr);
if (is_array($this->setParams) and !empty($this->setParams)) {
$this->setParams = array_merge($this->setParams, $params);
} else {
$this->setParams = $params;
}
} else {
$this->setWhere = null;
//$this->setParams = [];
}
//if (!empty($order))
// $this->prepareOrder($order, $sort);
//
return $this;
} | [
"public",
"function",
"prepareWhere",
"(",
"$",
"whereObject",
")",
"{",
"$",
"where",
"=",
"null",
";",
"$",
"params",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"whereObject",
")",
")",
"{",
"$",
"arr",
"=",
"[",
"]",
";",
"/** @var... | PrepareWhere function.
@param array
@return Database | [
"PrepareWhere",
"function",
"."
] | 6d9ac90d695c33b5e417b58f2134f86f79918387 | https://github.com/dframe/database/blob/6d9ac90d695c33b5e417b58f2134f86f79918387/src/Database.php#L130-L162 | train |
dframe/database | src/Database.php | Database.prepareHaving | public function prepareHaving($havingObject)
{
$where = null;
$params = [];
if (!empty($havingObject)) {
$arr = [];
/** @var \Dframe\Database\Chunk\ChunkInterface $chunk */
foreach ($havingObject as $chunk) {
list($wSQL, $wParams) = $chunk->build();
$arr[] = $wSQL;
foreach ($wParams as $k => $v) {
$params[] = $v;
}
}
$this->setHaving = ' HAVING ' . implode(' AND ', $arr);
if (is_array($this->setParams) and !empty($this->setParams)) {
$this->setParams = array_merge($this->setParams, $params);
} else {
$this->setParams = $params;
}
} else {
$this->setHaving = null;
//$this->setParams = [];
}
//if (!empty($order))
// $this->prepareOrder($order, $sort);
//
return $this;
} | php | public function prepareHaving($havingObject)
{
$where = null;
$params = [];
if (!empty($havingObject)) {
$arr = [];
/** @var \Dframe\Database\Chunk\ChunkInterface $chunk */
foreach ($havingObject as $chunk) {
list($wSQL, $wParams) = $chunk->build();
$arr[] = $wSQL;
foreach ($wParams as $k => $v) {
$params[] = $v;
}
}
$this->setHaving = ' HAVING ' . implode(' AND ', $arr);
if (is_array($this->setParams) and !empty($this->setParams)) {
$this->setParams = array_merge($this->setParams, $params);
} else {
$this->setParams = $params;
}
} else {
$this->setHaving = null;
//$this->setParams = [];
}
//if (!empty($order))
// $this->prepareOrder($order, $sort);
//
return $this;
} | [
"public",
"function",
"prepareHaving",
"(",
"$",
"havingObject",
")",
"{",
"$",
"where",
"=",
"null",
";",
"$",
"params",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"havingObject",
")",
")",
"{",
"$",
"arr",
"=",
"[",
"]",
";",
"/** @... | PrepareHaving function.
@param \Dframe\Database\WhereChunk $havingObject
@return Database | [
"PrepareHaving",
"function",
"."
] | 6d9ac90d695c33b5e417b58f2134f86f79918387 | https://github.com/dframe/database/blob/6d9ac90d695c33b5e417b58f2134f86f79918387/src/Database.php#L171-L204 | train |
dframe/database | src/Database.php | Database.prepareOrder | public function prepareOrder($order = null, $sort = null)
{
if ($order == null or $sort == null) {
$this->setOrderBy = '';
return $this;
}
if (!in_array($sort, ['ASC', 'DESC'])) {
$sort = 'DESC';
}
$this->setOrderBy = ' ORDER BY ' . $order . ' ' . $sort;
return $this;
} | php | public function prepareOrder($order = null, $sort = null)
{
if ($order == null or $sort == null) {
$this->setOrderBy = '';
return $this;
}
if (!in_array($sort, ['ASC', 'DESC'])) {
$sort = 'DESC';
}
$this->setOrderBy = ' ORDER BY ' . $order . ' ' . $sort;
return $this;
} | [
"public",
"function",
"prepareOrder",
"(",
"$",
"order",
"=",
"null",
",",
"$",
"sort",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"order",
"==",
"null",
"or",
"$",
"sort",
"==",
"null",
")",
"{",
"$",
"this",
"->",
"setOrderBy",
"=",
"''",
";",
"ret... | prepareOrder function.
@param string $order
@param string $sort
@return Database | [
"prepareOrder",
"function",
"."
] | 6d9ac90d695c33b5e417b58f2134f86f79918387 | https://github.com/dframe/database/blob/6d9ac90d695c33b5e417b58f2134f86f79918387/src/Database.php#L214-L229 | train |
dframe/database | src/Database.php | Database.prepareQuery | public function prepareQuery($query, $params = false)
{
if (isset($params) and is_array($params)) {
$this->prepareParms($params);
}
if (!isset($this->setQuery)) {
$this->setQuery = $query . ' ';
} else {
$this->setQuery .= $this->getQuery() . ' ' . $query . ' ';
}
return $this;
} | php | public function prepareQuery($query, $params = false)
{
if (isset($params) and is_array($params)) {
$this->prepareParms($params);
}
if (!isset($this->setQuery)) {
$this->setQuery = $query . ' ';
} else {
$this->setQuery .= $this->getQuery() . ' ' . $query . ' ';
}
return $this;
} | [
"public",
"function",
"prepareQuery",
"(",
"$",
"query",
",",
"$",
"params",
"=",
"false",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"params",
")",
"and",
"is_array",
"(",
"$",
"params",
")",
")",
"{",
"$",
"this",
"->",
"prepareParms",
"(",
"$",
"pa... | Undocumented function.
@param string $query
@param bool|array $params
@return Database | [
"Undocumented",
"function",
"."
] | 6d9ac90d695c33b5e417b58f2134f86f79918387 | https://github.com/dframe/database/blob/6d9ac90d695c33b5e417b58f2134f86f79918387/src/Database.php#L239-L252 | train |
dframe/database | src/Database.php | Database.prepareParms | public function prepareParms($params)
{
if (is_array($params)) {
foreach ($params as $key => $value) {
array_push($this->setParams, $value);
}
} else {
array_push($this->setParams, $params);
}
} | php | public function prepareParms($params)
{
if (is_array($params)) {
foreach ($params as $key => $value) {
array_push($this->setParams, $value);
}
} else {
array_push($this->setParams, $params);
}
} | [
"public",
"function",
"prepareParms",
"(",
"$",
"params",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"params",
")",
")",
"{",
"foreach",
"(",
"$",
"params",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"array_push",
"(",
"$",
"this",
"->",
"setP... | PrepareParms function.
@param array|string $params
@return void | [
"PrepareParms",
"function",
"."
] | 6d9ac90d695c33b5e417b58f2134f86f79918387 | https://github.com/dframe/database/blob/6d9ac90d695c33b5e417b58f2134f86f79918387/src/Database.php#L261-L270 | train |
dframe/database | src/Database.php | Database.getQuery | public function getQuery()
{
$sql = $this->setQuery;
$sql .= $this->getWhere();
$sql .= $this->getGroupBy();
$sql .= $this->getOrderBy();
$sql .= $this->getHaving();
$sql .= $this->getLimit();
$this->setQuery = null;
$this->setWhere = null;
$this->setHaving = null;
$this->setOrderBy = null;
$this->setGroupBy = null;
$this->setLimit = null;
return str_replace(' ', ' ', $sql);
} | php | public function getQuery()
{
$sql = $this->setQuery;
$sql .= $this->getWhere();
$sql .= $this->getGroupBy();
$sql .= $this->getOrderBy();
$sql .= $this->getHaving();
$sql .= $this->getLimit();
$this->setQuery = null;
$this->setWhere = null;
$this->setHaving = null;
$this->setOrderBy = null;
$this->setGroupBy = null;
$this->setLimit = null;
return str_replace(' ', ' ', $sql);
} | [
"public",
"function",
"getQuery",
"(",
")",
"{",
"$",
"sql",
"=",
"$",
"this",
"->",
"setQuery",
";",
"$",
"sql",
".=",
"$",
"this",
"->",
"getWhere",
"(",
")",
";",
"$",
"sql",
".=",
"$",
"this",
"->",
"getGroupBy",
"(",
")",
";",
"$",
"sql",
... | GetQuery function.
@return string | [
"GetQuery",
"function",
"."
] | 6d9ac90d695c33b5e417b58f2134f86f79918387 | https://github.com/dframe/database/blob/6d9ac90d695c33b5e417b58f2134f86f79918387/src/Database.php#L277-L294 | train |
dframe/database | src/Database.php | Database.getWhere | public function getWhere()
{
if (!isset($this->setWhere) or empty($this->setWhere)) {
$this->setWhere = null;
}
return $this->setWhere;
} | php | public function getWhere()
{
if (!isset($this->setWhere) or empty($this->setWhere)) {
$this->setWhere = null;
}
return $this->setWhere;
} | [
"public",
"function",
"getWhere",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"setWhere",
")",
"or",
"empty",
"(",
"$",
"this",
"->",
"setWhere",
")",
")",
"{",
"$",
"this",
"->",
"setWhere",
"=",
"null",
";",
"}",
"return",
"... | GetWhere function.
@return string | [
"GetWhere",
"function",
"."
] | 6d9ac90d695c33b5e417b58f2134f86f79918387 | https://github.com/dframe/database/blob/6d9ac90d695c33b5e417b58f2134f86f79918387/src/Database.php#L301-L308 | train |
dframe/database | src/Database.php | Database.getHaving | public function getHaving()
{
if (!isset($this->setHaving) or empty($this->setHaving)) {
$this->setHaving = null;
}
return $this->setHaving;
} | php | public function getHaving()
{
if (!isset($this->setHaving) or empty($this->setHaving)) {
$this->setHaving = null;
}
return $this->setHaving;
} | [
"public",
"function",
"getHaving",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"setHaving",
")",
"or",
"empty",
"(",
"$",
"this",
"->",
"setHaving",
")",
")",
"{",
"$",
"this",
"->",
"setHaving",
"=",
"null",
";",
"}",
"return",... | GetHaving function.
@return string | [
"GetHaving",
"function",
"."
] | 6d9ac90d695c33b5e417b58f2134f86f79918387 | https://github.com/dframe/database/blob/6d9ac90d695c33b5e417b58f2134f86f79918387/src/Database.php#L335-L342 | train |
dframe/database | src/Database.php | Database.prepareLimit | public function prepareLimit($limit, $offset = null)
{
if ($offset) {
$this->setLimit = ' LIMIT ' . $limit . ', ' . $offset . '';
} else {
$this->setLimit = ' LIMIT ' . $limit . '';
}
return $this;
} | php | public function prepareLimit($limit, $offset = null)
{
if ($offset) {
$this->setLimit = ' LIMIT ' . $limit . ', ' . $offset . '';
} else {
$this->setLimit = ' LIMIT ' . $limit . '';
}
return $this;
} | [
"public",
"function",
"prepareLimit",
"(",
"$",
"limit",
",",
"$",
"offset",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"offset",
")",
"{",
"$",
"this",
"->",
"setLimit",
"=",
"' LIMIT '",
".",
"$",
"limit",
".",
"', '",
".",
"$",
"offset",
".",
"''",
... | PrepareLimit function.
@param int $limit
@param int|null $offset
@return Database | [
"PrepareLimit",
"function",
"."
] | 6d9ac90d695c33b5e417b58f2134f86f79918387 | https://github.com/dframe/database/blob/6d9ac90d695c33b5e417b58f2134f86f79918387/src/Database.php#L376-L385 | train |
techdivision/import-product-media | src/Repositories/ProductMediaGalleryRepository.php | ProductMediaGalleryRepository.findOneByAttributeIdAndValue | public function findOneByAttributeIdAndValue($attributeId, $value)
{
// initialize the params
$params = array(
MemberNames::ATTRIBUTE_ID => $attributeId,
MemberNames::VALUE => $value
);
// load and return the prodcut media gallery with the passed attribute ID + value
$this->productMediaGalleryStmt->execute($params);
return $this->productMediaGalleryStmt->fetch(\PDO::FETCH_ASSOC);
} | php | public function findOneByAttributeIdAndValue($attributeId, $value)
{
// initialize the params
$params = array(
MemberNames::ATTRIBUTE_ID => $attributeId,
MemberNames::VALUE => $value
);
// load and return the prodcut media gallery with the passed attribute ID + value
$this->productMediaGalleryStmt->execute($params);
return $this->productMediaGalleryStmt->fetch(\PDO::FETCH_ASSOC);
} | [
"public",
"function",
"findOneByAttributeIdAndValue",
"(",
"$",
"attributeId",
",",
"$",
"value",
")",
"{",
"// initialize the params",
"$",
"params",
"=",
"array",
"(",
"MemberNames",
"::",
"ATTRIBUTE_ID",
"=>",
"$",
"attributeId",
",",
"MemberNames",
"::",
"VALU... | Load's the product media gallery with the passed attribute ID + value.
@param integer $attributeId The attribute ID of the product media gallery to load
@param string $value The value of the product media gallery to load
@return array The product media gallery | [
"Load",
"s",
"the",
"product",
"media",
"gallery",
"with",
"the",
"passed",
"attribute",
"ID",
"+",
"value",
"."
] | 124f4ed08d96f61fdb1eeb5aafde1c5afbd93a06 | https://github.com/techdivision/import-product-media/blob/124f4ed08d96f61fdb1eeb5aafde1c5afbd93a06/src/Repositories/ProductMediaGalleryRepository.php#L76-L88 | train |
esmero/webform_strawberryfield | src/Element/WebformWithOverride.php | WebformWithOverride.preRenderWebformElement | public static function preRenderWebformElement($element) {
$webform = ($element['#webform'] instanceof WebformInterface) ? $element['#webform'] : WebformEntity::load($element['#webform']);
if (!$webform) {
return $element;
}
if ($webform->access('submission_create')) {
$values = [];
// Set data.
$values['data'] = $element['#default_data'];
// Set source entity type and id.
if (!empty($element['#entity']) && $element['#entity'] instanceof EntityInterface) {
$values['entity_type'] = $element['#entity']->getEntityTypeId();
$values['entity_id'] = $element['#entity']->id();
}
elseif (!empty($element['#entity_type']) && !empty($element['#entity_id'])) {
$values['entity_type'] = $element['#entity_type'];
$values['entity_id'] = $element['#entity_id'];
}
if (!empty($element['#override'])) {
$new_settings = $element['#override'];
$webform->setSettingsOverride($new_settings);
$values['strawberryfield:override'] = $new_settings;
}
// Build the webform.
$element['webform_build'] = $webform->getSubmissionForm($values);
// Set custom form action.
if (!empty($element['#action'])) {
$element['webform_build']['#action'] = $element['#action'];
}
}
elseif ($webform->getSetting('form_access_denied') !== WebformInterface::ACCESS_DENIED_DEFAULT) {
// Set access denied message.
$element['webform_access_denied'] = static::buildAccessDenied($webform);
}
else {
// Add config and webform to cache contexts.
$config = \Drupal::configFactory()->get('webform.settings');
$renderer = \Drupal::service('renderer');
$renderer->addCacheableDependency($element, $config);
$renderer->addCacheableDependency($element, $webform);
}
return $element;
} | php | public static function preRenderWebformElement($element) {
$webform = ($element['#webform'] instanceof WebformInterface) ? $element['#webform'] : WebformEntity::load($element['#webform']);
if (!$webform) {
return $element;
}
if ($webform->access('submission_create')) {
$values = [];
// Set data.
$values['data'] = $element['#default_data'];
// Set source entity type and id.
if (!empty($element['#entity']) && $element['#entity'] instanceof EntityInterface) {
$values['entity_type'] = $element['#entity']->getEntityTypeId();
$values['entity_id'] = $element['#entity']->id();
}
elseif (!empty($element['#entity_type']) && !empty($element['#entity_id'])) {
$values['entity_type'] = $element['#entity_type'];
$values['entity_id'] = $element['#entity_id'];
}
if (!empty($element['#override'])) {
$new_settings = $element['#override'];
$webform->setSettingsOverride($new_settings);
$values['strawberryfield:override'] = $new_settings;
}
// Build the webform.
$element['webform_build'] = $webform->getSubmissionForm($values);
// Set custom form action.
if (!empty($element['#action'])) {
$element['webform_build']['#action'] = $element['#action'];
}
}
elseif ($webform->getSetting('form_access_denied') !== WebformInterface::ACCESS_DENIED_DEFAULT) {
// Set access denied message.
$element['webform_access_denied'] = static::buildAccessDenied($webform);
}
else {
// Add config and webform to cache contexts.
$config = \Drupal::configFactory()->get('webform.settings');
$renderer = \Drupal::service('renderer');
$renderer->addCacheableDependency($element, $config);
$renderer->addCacheableDependency($element, $webform);
}
return $element;
} | [
"public",
"static",
"function",
"preRenderWebformElement",
"(",
"$",
"element",
")",
"{",
"$",
"webform",
"=",
"(",
"$",
"element",
"[",
"'#webform'",
"]",
"instanceof",
"WebformInterface",
")",
"?",
"$",
"element",
"[",
"'#webform'",
"]",
":",
"WebformEntity"... | Webform element pre render callback.
@param $element
@return mixed | [
"Webform",
"element",
"pre",
"render",
"callback",
"."
] | 7b2bd47dc01a948325a44499ff0ec3c8d9fb4efa | https://github.com/esmero/webform_strawberryfield/blob/7b2bd47dc01a948325a44499ff0ec3c8d9fb4efa/src/Element/WebformWithOverride.php#L42-L92 | train |
melisplatform/melis-front | src/Service/MinifyAssetsService.php | MinifyAssetsService.generateAllAssets | public function generateAllAssets ($files, $sitePath, $siteName, $isFromVendor)
{
$cssMinifier = new Minify\CSS();
$jsMinifier = new Minify\JS();
if($isFromVendor){
$bundleDir = $sitePath.'/public/';
/**
* we need to remove the site name on the path
* since the site name is already included
* in the file name inside the assets.config
*/
$sitePath = dirname($sitePath);
}else{
$bundleDir = $sitePath.'/'.$siteName.'/public/';
}
$messages = array();
//check if the directory for the bundle is exist
if($this->checkDir($bundleDir)) {
//check if bundle is writable
if (is_writable($bundleDir)) {
if (!empty($files)) {
foreach ($files as $key => $file) {
//create a bundle for js
$key = strtolower($key);
if ($key == 'js') {
$messages['error'] = $this->createBundleFile($jsMinifier, 'bundle.js', $file, $sitePath, $bundleDir);
}
//create a bundle for css
if ($key == 'css') {
$messages['error'] = $this->createBundleFile($cssMinifier, 'bundle.css', $file, $sitePath, $bundleDir, false);
}
}
}
}else {
$messages['error'] = array('message' => $bundleDir . ' is not writable.', 'success' => false);
}
}else{
$messages['error'] = array('message' => $bundleDir . ' does not exist.', 'success' => false);
}
return $messages;
} | php | public function generateAllAssets ($files, $sitePath, $siteName, $isFromVendor)
{
$cssMinifier = new Minify\CSS();
$jsMinifier = new Minify\JS();
if($isFromVendor){
$bundleDir = $sitePath.'/public/';
/**
* we need to remove the site name on the path
* since the site name is already included
* in the file name inside the assets.config
*/
$sitePath = dirname($sitePath);
}else{
$bundleDir = $sitePath.'/'.$siteName.'/public/';
}
$messages = array();
//check if the directory for the bundle is exist
if($this->checkDir($bundleDir)) {
//check if bundle is writable
if (is_writable($bundleDir)) {
if (!empty($files)) {
foreach ($files as $key => $file) {
//create a bundle for js
$key = strtolower($key);
if ($key == 'js') {
$messages['error'] = $this->createBundleFile($jsMinifier, 'bundle.js', $file, $sitePath, $bundleDir);
}
//create a bundle for css
if ($key == 'css') {
$messages['error'] = $this->createBundleFile($cssMinifier, 'bundle.css', $file, $sitePath, $bundleDir, false);
}
}
}
}else {
$messages['error'] = array('message' => $bundleDir . ' is not writable.', 'success' => false);
}
}else{
$messages['error'] = array('message' => $bundleDir . ' does not exist.', 'success' => false);
}
return $messages;
} | [
"public",
"function",
"generateAllAssets",
"(",
"$",
"files",
",",
"$",
"sitePath",
",",
"$",
"siteName",
",",
"$",
"isFromVendor",
")",
"{",
"$",
"cssMinifier",
"=",
"new",
"Minify",
"\\",
"CSS",
"(",
")",
";",
"$",
"jsMinifier",
"=",
"new",
"Minify",
... | Function to generate all assets
@param $files
@param $sitePath
@param $siteName
@param $isFromVendor
@return array | [
"Function",
"to",
"generate",
"all",
"assets"
] | 5e03e32687970bb2201e4205612d5539500dc514 | https://github.com/melisplatform/melis-front/blob/5e03e32687970bb2201e4205612d5539500dc514/src/Service/MinifyAssetsService.php#L147-L191 | train |
melisplatform/melis-front | src/Service/MinifyAssetsService.php | MinifyAssetsService.createBundleFile | private function createBundleFile ($minifier, $fileName, $files, $sitePath, $bundleDir, $cleanCode = true)
{
$translator = $this->getServiceLocator()->get('translator');
$message = '';
$success = false;
if (!empty($files)) {
try {
foreach ($files as $key => $file) {
//remove comments
if($cleanCode) {
$codeToAdd = $this->removeComments($sitePath . $file);
}else{
$codeToAdd = $sitePath . $file;
}
//add the file to minify later
$minifier->add($codeToAdd);
// $minifier = $this->getFileContentsViaCurl($minifier, $file);
}
//minify all the files
$minifier->minify($bundleDir . $fileName);
$message = $translator->translate('tr_front_minify_assets_compiled_successfully');
$success = true;
} catch (\Exception $ex) {
/**
* this will occur only if the bundle.css or bundle.js
* is not writable or no permission or other errors
*/
$message = wordwrap($ex->getMessage(), 20, "\n", true);
}
}else{
$success = true;
}
return array(
'message' => $message,
'success' => $success
);
} | php | private function createBundleFile ($minifier, $fileName, $files, $sitePath, $bundleDir, $cleanCode = true)
{
$translator = $this->getServiceLocator()->get('translator');
$message = '';
$success = false;
if (!empty($files)) {
try {
foreach ($files as $key => $file) {
//remove comments
if($cleanCode) {
$codeToAdd = $this->removeComments($sitePath . $file);
}else{
$codeToAdd = $sitePath . $file;
}
//add the file to minify later
$minifier->add($codeToAdd);
// $minifier = $this->getFileContentsViaCurl($minifier, $file);
}
//minify all the files
$minifier->minify($bundleDir . $fileName);
$message = $translator->translate('tr_front_minify_assets_compiled_successfully');
$success = true;
} catch (\Exception $ex) {
/**
* this will occur only if the bundle.css or bundle.js
* is not writable or no permission or other errors
*/
$message = wordwrap($ex->getMessage(), 20, "\n", true);
}
}else{
$success = true;
}
return array(
'message' => $message,
'success' => $success
);
} | [
"private",
"function",
"createBundleFile",
"(",
"$",
"minifier",
",",
"$",
"fileName",
",",
"$",
"files",
",",
"$",
"sitePath",
",",
"$",
"bundleDir",
",",
"$",
"cleanCode",
"=",
"true",
")",
"{",
"$",
"translator",
"=",
"$",
"this",
"->",
"getServiceLoc... | Function to create a bundle
@param $minifier
@param $fileName
@param $files
@param $sitePath
@param $bundleDir
@param $cleanCode
@return array | [
"Function",
"to",
"create",
"a",
"bundle"
] | 5e03e32687970bb2201e4205612d5539500dc514 | https://github.com/melisplatform/melis-front/blob/5e03e32687970bb2201e4205612d5539500dc514/src/Service/MinifyAssetsService.php#L204-L241 | train |
melisplatform/melis-front | src/Controller/MinifyAssetsController.php | MinifyAssetsController.minifyAssetsAction | public function minifyAssetsAction ()
{
$request = $this->getRequest();
$siteID = $request->getPost('siteId');
/** @var \MelisFront\Service\MinifyAssetsService $minifyAssets */
$minifyAssets = $this->getServiceLocator()->get('MinifyAssets');
$result = $minifyAssets->minifyAssets($siteID);
$title = 'Compiling assets';
/**
* modify a little the result
*/
$success = true;
$message = '';
if(!empty($result['results'])){
foreach($result['results'] as $key => $val){
if(!$val['success']){
$success = false;
$message = $val['message'];
}
}
}
return new JsonModel(array(
'title' => $title,
'message' => wordwrap($message, 20, "\n", true),
'success' => $success,
));
} | php | public function minifyAssetsAction ()
{
$request = $this->getRequest();
$siteID = $request->getPost('siteId');
/** @var \MelisFront\Service\MinifyAssetsService $minifyAssets */
$minifyAssets = $this->getServiceLocator()->get('MinifyAssets');
$result = $minifyAssets->minifyAssets($siteID);
$title = 'Compiling assets';
/**
* modify a little the result
*/
$success = true;
$message = '';
if(!empty($result['results'])){
foreach($result['results'] as $key => $val){
if(!$val['success']){
$success = false;
$message = $val['message'];
}
}
}
return new JsonModel(array(
'title' => $title,
'message' => wordwrap($message, 20, "\n", true),
'success' => $success,
));
} | [
"public",
"function",
"minifyAssetsAction",
"(",
")",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
";",
"$",
"siteID",
"=",
"$",
"request",
"->",
"getPost",
"(",
"'siteId'",
")",
";",
"/** @var \\MelisFront\\Service\\MinifyAssetsService $... | Function to minify assets | [
"Function",
"to",
"minify",
"assets"
] | 5e03e32687970bb2201e4205612d5539500dc514 | https://github.com/melisplatform/melis-front/blob/5e03e32687970bb2201e4205612d5539500dc514/src/Controller/MinifyAssetsController.php#L21-L50 | train |
phug-php/event | src/Phug/EventManagerTrait.php | EventManagerTrait.mergeEventListeners | public function mergeEventListeners($eventListeners)
{
if ($eventListeners instanceof EventManagerInterface) {
$eventListeners = $eventListeners->getEventListeners();
}
foreach (((array) $eventListeners) as $eventName => $listeners) {
$queue = [];
if (isset($this->eventListeners[$eventName])) {
$innerListeners = clone $this->eventListeners[$eventName];
$innerListeners->setExtractFlags(ListenerQueue::EXTR_DATA);
foreach ($innerListeners as $callback) {
$queue[] = $callback;
}
}
$listeners = clone $listeners;
$listeners->setExtractFlags(ListenerQueue::EXTR_BOTH);
foreach ($listeners as $listener) {
if (!in_array($listener['data'], $queue)) {
$this->attach($eventName, $listener['data'], $listener['priority']);
}
}
}
return true;
} | php | public function mergeEventListeners($eventListeners)
{
if ($eventListeners instanceof EventManagerInterface) {
$eventListeners = $eventListeners->getEventListeners();
}
foreach (((array) $eventListeners) as $eventName => $listeners) {
$queue = [];
if (isset($this->eventListeners[$eventName])) {
$innerListeners = clone $this->eventListeners[$eventName];
$innerListeners->setExtractFlags(ListenerQueue::EXTR_DATA);
foreach ($innerListeners as $callback) {
$queue[] = $callback;
}
}
$listeners = clone $listeners;
$listeners->setExtractFlags(ListenerQueue::EXTR_BOTH);
foreach ($listeners as $listener) {
if (!in_array($listener['data'], $queue)) {
$this->attach($eventName, $listener['data'], $listener['priority']);
}
}
}
return true;
} | [
"public",
"function",
"mergeEventListeners",
"(",
"$",
"eventListeners",
")",
"{",
"if",
"(",
"$",
"eventListeners",
"instanceof",
"EventManagerInterface",
")",
"{",
"$",
"eventListeners",
"=",
"$",
"eventListeners",
"->",
"getEventListeners",
"(",
")",
";",
"}",
... | Merge current events listeners with a given list.
@param ListenerQueue[]|EventManagerInterface $eventListeners event listeners by event name
@return bool true on success false on failure | [
"Merge",
"current",
"events",
"listeners",
"with",
"a",
"given",
"list",
"."
] | 03ec80c55f63541bdeebcfc9722b2ea43698b7e3 | https://github.com/phug-php/event/blob/03ec80c55f63541bdeebcfc9722b2ea43698b7e3/src/Phug/EventManagerTrait.php#L31-L56 | train |
phug-php/event | src/Phug/EventManagerTrait.php | EventManagerTrait.attach | public function attach($event, $callback, $priority = 0)
{
if (!isset($this->eventListeners[$event])) {
$this->clearListeners($event);
}
$this->eventListeners[$event]->insert($callback, $priority);
return true;
} | php | public function attach($event, $callback, $priority = 0)
{
if (!isset($this->eventListeners[$event])) {
$this->clearListeners($event);
}
$this->eventListeners[$event]->insert($callback, $priority);
return true;
} | [
"public",
"function",
"attach",
"(",
"$",
"event",
",",
"$",
"callback",
",",
"$",
"priority",
"=",
"0",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"eventListeners",
"[",
"$",
"event",
"]",
")",
")",
"{",
"$",
"this",
"->",
"clear... | Attaches a listener to an event.
@param string $event the event to attach too
@param callable $callback a callable function
@param int $priority the priority at which the $callback executed
@return bool true on success false on failure | [
"Attaches",
"a",
"listener",
"to",
"an",
"event",
"."
] | 03ec80c55f63541bdeebcfc9722b2ea43698b7e3 | https://github.com/phug-php/event/blob/03ec80c55f63541bdeebcfc9722b2ea43698b7e3/src/Phug/EventManagerTrait.php#L67-L76 | train |
phug-php/event | src/Phug/EventManagerTrait.php | EventManagerTrait.detach | public function detach($event, $callback)
{
if (!isset($this->eventListeners[$event]) || $this->eventListeners[$event]->isEmpty()) {
return false;
}
$removed = false;
$listeners = $this->eventListeners[$event];
$newListeners = new ListenerQueue();
$listeners->setExtractFlags(ListenerQueue::EXTR_BOTH);
foreach ($listeners as $item) {
if ($item['data'] === $callback) {
$removed = true;
continue;
}
$newListeners->insert($item['data'], $item['priority']);
}
$listeners->setExtractFlags(ListenerQueue::EXTR_DATA);
$this->eventListeners[$event] = $newListeners;
return $removed;
} | php | public function detach($event, $callback)
{
if (!isset($this->eventListeners[$event]) || $this->eventListeners[$event]->isEmpty()) {
return false;
}
$removed = false;
$listeners = $this->eventListeners[$event];
$newListeners = new ListenerQueue();
$listeners->setExtractFlags(ListenerQueue::EXTR_BOTH);
foreach ($listeners as $item) {
if ($item['data'] === $callback) {
$removed = true;
continue;
}
$newListeners->insert($item['data'], $item['priority']);
}
$listeners->setExtractFlags(ListenerQueue::EXTR_DATA);
$this->eventListeners[$event] = $newListeners;
return $removed;
} | [
"public",
"function",
"detach",
"(",
"$",
"event",
",",
"$",
"callback",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"eventListeners",
"[",
"$",
"event",
"]",
")",
"||",
"$",
"this",
"->",
"eventListeners",
"[",
"$",
"event",
"]",
"-... | Detaches a listener from an event.
@param string $event the event to attach too
@param callable $callback a callable function
@return bool true on success false on failure | [
"Detaches",
"a",
"listener",
"from",
"an",
"event",
"."
] | 03ec80c55f63541bdeebcfc9722b2ea43698b7e3 | https://github.com/phug-php/event/blob/03ec80c55f63541bdeebcfc9722b2ea43698b7e3/src/Phug/EventManagerTrait.php#L86-L110 | train |
trive-digital/fiskalapi | lib/Request.php | Request.toXML | public function toXML()
{
$namespace = 'tns';
$writer = new XMLWriter();
$writer->openMemory();
$writer->setIndent(true);
$writer->setIndentString(' ');
$writer->startElementNs($namespace, $this->getRequestName(), 'http://www.apis-it.hr/fin/2012/types/f73');
$writer->writeAttribute('Id', uniqid());
$writer->startElementNs($namespace, 'Zaglavlje', null);
$writer->writeElementNs($namespace, 'IdPoruke', null, $this->generateUUID());
$writer->writeElementNs($namespace, 'DatumVrijeme', null, $this->generateDateTime());
$writer->endElement();
$writer->writeRaw($this->getRequest()->toXML());
$writer->endElement();
return $writer->outputMemory();
} | php | public function toXML()
{
$namespace = 'tns';
$writer = new XMLWriter();
$writer->openMemory();
$writer->setIndent(true);
$writer->setIndentString(' ');
$writer->startElementNs($namespace, $this->getRequestName(), 'http://www.apis-it.hr/fin/2012/types/f73');
$writer->writeAttribute('Id', uniqid());
$writer->startElementNs($namespace, 'Zaglavlje', null);
$writer->writeElementNs($namespace, 'IdPoruke', null, $this->generateUUID());
$writer->writeElementNs($namespace, 'DatumVrijeme', null, $this->generateDateTime());
$writer->endElement();
$writer->writeRaw($this->getRequest()->toXML());
$writer->endElement();
return $writer->outputMemory();
} | [
"public",
"function",
"toXML",
"(",
")",
"{",
"$",
"namespace",
"=",
"'tns'",
";",
"$",
"writer",
"=",
"new",
"XMLWriter",
"(",
")",
";",
"$",
"writer",
"->",
"openMemory",
"(",
")",
";",
"$",
"writer",
"->",
"setIndent",
"(",
"true",
")",
";",
"$"... | Set headers, get specific request XML body and make request
@return string | [
"Set",
"headers",
"get",
"specific",
"request",
"XML",
"body",
"and",
"make",
"request"
] | 1bed6f4573ea1d6890bcf7da42ede4da9cc0b6b9 | https://github.com/trive-digital/fiskalapi/blob/1bed6f4573ea1d6890bcf7da42ede4da9cc0b6b9/lib/Request.php#L89-L106 | train |
protobuf-php/google-protobuf-proto | src/google/protobuf/EnumDescriptorProto.php | EnumDescriptorProto.addValue | public function addValue(\google\protobuf\EnumValueDescriptorProto $value)
{
if ($this->value === null) {
$this->value = new \Protobuf\MessageCollection();
}
$this->value->add($value);
} | php | public function addValue(\google\protobuf\EnumValueDescriptorProto $value)
{
if ($this->value === null) {
$this->value = new \Protobuf\MessageCollection();
}
$this->value->add($value);
} | [
"public",
"function",
"addValue",
"(",
"\\",
"google",
"\\",
"protobuf",
"\\",
"EnumValueDescriptorProto",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"value",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"value",
"=",
"new",
"\\",
"Protobuf",
... | Add a new element to 'value'
@param \google\protobuf\EnumValueDescriptorProto $value | [
"Add",
"a",
"new",
"element",
"to",
"value"
] | da1827b4a23fccd4eb998a8d4bcd972f2330bc29 | https://github.com/protobuf-php/google-protobuf-proto/blob/da1827b4a23fccd4eb998a8d4bcd972f2330bc29/src/google/protobuf/EnumDescriptorProto.php#L113-L120 | train |
brightnucleus/shortcodes | src/Shortcode.php | Shortcode.register | public function register( $context = null ) {
if ( null !== $context ) {
$this->add_context( $context );
}
if ( ! $this->is_needed( $this->context ) ) {
return;
}
\add_shortcode( $this->get_tag(), [ $this, 'render' ] );
} | php | public function register( $context = null ) {
if ( null !== $context ) {
$this->add_context( $context );
}
if ( ! $this->is_needed( $this->context ) ) {
return;
}
\add_shortcode( $this->get_tag(), [ $this, 'render' ] );
} | [
"public",
"function",
"register",
"(",
"$",
"context",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"context",
")",
"{",
"$",
"this",
"->",
"add_context",
"(",
"$",
"context",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"is_needed",
... | Register the shortcode handler function with WordPress.
@since 0.1.0
@param mixed $context Optional. Arguments to pass on to the Registrable.
@return void | [
"Register",
"the",
"shortcode",
"handler",
"function",
"with",
"WordPress",
"."
] | 5db6fa3c18db856ab550e56960a844d6aa99dabb | https://github.com/brightnucleus/shortcodes/blob/5db6fa3c18db856ab550e56960a844d6aa99dabb/src/Shortcode.php#L125-L135 | train |
brightnucleus/shortcodes | src/Shortcode.php | Shortcode.render | public function render( $atts, $content = null, $tag = null ) {
$atts = $this->atts_parser->parse_atts( $atts, $this->get_tag() );
$this->enqueue_dependencies( $this->get_dependency_handles(), $atts );
return $this->render_view(
$this->get_view(),
$this->context,
$atts,
$content
);
} | php | public function render( $atts, $content = null, $tag = null ) {
$atts = $this->atts_parser->parse_atts( $atts, $this->get_tag() );
$this->enqueue_dependencies( $this->get_dependency_handles(), $atts );
return $this->render_view(
$this->get_view(),
$this->context,
$atts,
$content
);
} | [
"public",
"function",
"render",
"(",
"$",
"atts",
",",
"$",
"content",
"=",
"null",
",",
"$",
"tag",
"=",
"null",
")",
"{",
"$",
"atts",
"=",
"$",
"this",
"->",
"atts_parser",
"->",
"parse_atts",
"(",
"$",
"atts",
",",
"$",
"this",
"->",
"get_tag",... | Render the shortcode.
@since 0.1.0
@throws DomainException
@param array $atts Attributes to modify the standard behavior
of the shortcode.
@param string|null $content Optional. Content between enclosing
shortcodes.
@param string|null $tag Optional. The tag of the shortcode to
render. Ignored by current code.
@return string The shortcode's HTML output. | [
"Render",
"the",
"shortcode",
"."
] | 5db6fa3c18db856ab550e56960a844d6aa99dabb | https://github.com/brightnucleus/shortcodes/blob/5db6fa3c18db856ab550e56960a844d6aa99dabb/src/Shortcode.php#L178-L188 | train |
brightnucleus/shortcodes | src/Shortcode.php | Shortcode.enqueue_dependencies | protected function enqueue_dependencies( $handles, $context = null ) {
if ( null !== $context ) {
$this->add_context( $context );
}
if ( ! $this->dependencies || count( $handles ) < 1 ) {
return;
}
foreach ( $handles as $handle ) {
$found = $this->dependencies->enqueue_handle(
$handle,
$this->context,
true
);
if ( ! $found ) {
$message = sprintf(
__( 'Could not enqueue dependency "%1$s" for shortcode "%2$s".',
'bn-shortcodes' ),
$handle,
$this->get_tag()
);
trigger_error( $message, E_USER_WARNING );
}
}
} | php | protected function enqueue_dependencies( $handles, $context = null ) {
if ( null !== $context ) {
$this->add_context( $context );
}
if ( ! $this->dependencies || count( $handles ) < 1 ) {
return;
}
foreach ( $handles as $handle ) {
$found = $this->dependencies->enqueue_handle(
$handle,
$this->context,
true
);
if ( ! $found ) {
$message = sprintf(
__( 'Could not enqueue dependency "%1$s" for shortcode "%2$s".',
'bn-shortcodes' ),
$handle,
$this->get_tag()
);
trigger_error( $message, E_USER_WARNING );
}
}
} | [
"protected",
"function",
"enqueue_dependencies",
"(",
"$",
"handles",
",",
"$",
"context",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"context",
")",
"{",
"$",
"this",
"->",
"add_context",
"(",
"$",
"context",
")",
";",
"}",
"if",
"(",
"!"... | Enqueue the dependencies that the shortcode needs.
@since 0.2.9
@param array $handles Array of dependency handles to enqueue.
@param mixed $context Optional. Context in which to enqueue. | [
"Enqueue",
"the",
"dependencies",
"that",
"the",
"shortcode",
"needs",
"."
] | 5db6fa3c18db856ab550e56960a844d6aa99dabb | https://github.com/brightnucleus/shortcodes/blob/5db6fa3c18db856ab550e56960a844d6aa99dabb/src/Shortcode.php#L198-L224 | train |
brightnucleus/shortcodes | src/Shortcode.php | Shortcode.do_this | public function do_this( array $atts = [ ], $content = null ) {
return \BrightNucleus\Shortcode\do_tag( $this->get_tag(), $atts, $content );
} | php | public function do_this( array $atts = [ ], $content = null ) {
return \BrightNucleus\Shortcode\do_tag( $this->get_tag(), $atts, $content );
} | [
"public",
"function",
"do_this",
"(",
"array",
"$",
"atts",
"=",
"[",
"]",
",",
"$",
"content",
"=",
"null",
")",
"{",
"return",
"\\",
"BrightNucleus",
"\\",
"Shortcode",
"\\",
"do_tag",
"(",
"$",
"this",
"->",
"get_tag",
"(",
")",
",",
"$",
"atts",
... | Execute this shortcode directly from code.
@since 0.2.4
@param array $atts Array of attributes to pass to the shortcode.
@param string|null $content Inner content to pass to the shortcode.
@return string|false Rendered HTML. | [
"Execute",
"this",
"shortcode",
"directly",
"from",
"code",
"."
] | 5db6fa3c18db856ab550e56960a844d6aa99dabb | https://github.com/brightnucleus/shortcodes/blob/5db6fa3c18db856ab550e56960a844d6aa99dabb/src/Shortcode.php#L302-L304 | train |
techdivision/import-product-media | src/Observers/MediaGalleryObserver.php | MediaGalleryObserver.prepareProductMediaGalleryAttributes | protected function prepareProductMediaGalleryAttributes()
{
// load the attribute ID of the media gallery EAV attribute
$mediaGalleryAttribute = $this->getEavAttributeByAttributeCode(MediaGalleryObserver::ATTRIBUTE_CODE);
$attributeId = $mediaGalleryAttribute[MemberNames::ATTRIBUTE_ID];
// initialize the gallery data
$disabled = 0;
$mediaType = 'image';
$image = $this->getValue(ColumnKeys::IMAGE_PATH_NEW);
// initialize and return the entity
return $this->initializeEntity(
array(
MemberNames::ATTRIBUTE_ID => $attributeId,
MemberNames::VALUE => $image,
MemberNames::MEDIA_TYPE => $mediaType,
MemberNames::DISABLED => $disabled
)
);
} | php | protected function prepareProductMediaGalleryAttributes()
{
// load the attribute ID of the media gallery EAV attribute
$mediaGalleryAttribute = $this->getEavAttributeByAttributeCode(MediaGalleryObserver::ATTRIBUTE_CODE);
$attributeId = $mediaGalleryAttribute[MemberNames::ATTRIBUTE_ID];
// initialize the gallery data
$disabled = 0;
$mediaType = 'image';
$image = $this->getValue(ColumnKeys::IMAGE_PATH_NEW);
// initialize and return the entity
return $this->initializeEntity(
array(
MemberNames::ATTRIBUTE_ID => $attributeId,
MemberNames::VALUE => $image,
MemberNames::MEDIA_TYPE => $mediaType,
MemberNames::DISABLED => $disabled
)
);
} | [
"protected",
"function",
"prepareProductMediaGalleryAttributes",
"(",
")",
"{",
"// load the attribute ID of the media gallery EAV attribute",
"$",
"mediaGalleryAttribute",
"=",
"$",
"this",
"->",
"getEavAttributeByAttributeCode",
"(",
"MediaGalleryObserver",
"::",
"ATTRIBUTE_CODE"... | Prepare the product media gallery that has to be persisted.
@return array The prepared product media gallery attributes | [
"Prepare",
"the",
"product",
"media",
"gallery",
"that",
"has",
"to",
"be",
"persisted",
"."
] | 124f4ed08d96f61fdb1eeb5aafde1c5afbd93a06 | https://github.com/techdivision/import-product-media/blob/124f4ed08d96f61fdb1eeb5aafde1c5afbd93a06/src/Observers/MediaGalleryObserver.php#L126-L147 | train |
techdivision/import-product-media | src/Observers/MediaGalleryObserver.php | MediaGalleryObserver.prepareProductMediaGalleryValueToEntityAttributes | protected function prepareProductMediaGalleryValueToEntityAttributes()
{
// initialize and return the entity
return $this->initializeEntity(
array(
MemberNames::VALUE_ID => $this->valueId,
MemberNames::ENTITY_ID => $this->parentId
)
);
} | php | protected function prepareProductMediaGalleryValueToEntityAttributes()
{
// initialize and return the entity
return $this->initializeEntity(
array(
MemberNames::VALUE_ID => $this->valueId,
MemberNames::ENTITY_ID => $this->parentId
)
);
} | [
"protected",
"function",
"prepareProductMediaGalleryValueToEntityAttributes",
"(",
")",
"{",
"// initialize and return the entity",
"return",
"$",
"this",
"->",
"initializeEntity",
"(",
"array",
"(",
"MemberNames",
"::",
"VALUE_ID",
"=>",
"$",
"this",
"->",
"valueId",
"... | Prepare the product media gallery value to entity that has to be persisted.
@return array The prepared product media gallery value to entity attributes | [
"Prepare",
"the",
"product",
"media",
"gallery",
"value",
"to",
"entity",
"that",
"has",
"to",
"be",
"persisted",
"."
] | 124f4ed08d96f61fdb1eeb5aafde1c5afbd93a06 | https://github.com/techdivision/import-product-media/blob/124f4ed08d96f61fdb1eeb5aafde1c5afbd93a06/src/Observers/MediaGalleryObserver.php#L154-L164 | train |
jbouzekri/FileUploaderBundle | Service/ValidatorChain.php | ValidatorChain.getValidator | public function getValidator($alias)
{
if (array_key_exists($alias, $this->validators)) {
return $this->validators[$alias];
}
throw new JbFileUploaderException('Unknown validator ' . $alias);
} | php | public function getValidator($alias)
{
if (array_key_exists($alias, $this->validators)) {
return $this->validators[$alias];
}
throw new JbFileUploaderException('Unknown validator ' . $alias);
} | [
"public",
"function",
"getValidator",
"(",
"$",
"alias",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"alias",
",",
"$",
"this",
"->",
"validators",
")",
")",
"{",
"return",
"$",
"this",
"->",
"validators",
"[",
"$",
"alias",
"]",
";",
"}",
"th... | Get a validator by its alias
@param string $alias
@return \Jb\Bundle\FileUploaderBundle\Service\Validator\AbstractValidator
@throws \Jb\Bundle\FileUploaderBundle\Exception\JbFileUploaderException | [
"Get",
"a",
"validator",
"by",
"its",
"alias"
] | 592e7ed827eaa4e7f8f6f52947ca5e5a86835f6c | https://github.com/jbouzekri/FileUploaderBundle/blob/592e7ed827eaa4e7f8f6f52947ca5e5a86835f6c/Service/ValidatorChain.php#L55-L62 | train |
CatsSystem/swoole-etcd | etcd/MaintenanceClient.php | MaintenanceClient.Alarm | public function Alarm(AlarmRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Maintenance/Alarm',
$argument,
['\Etcdserverpb\AlarmResponse', 'decode'],
$metadata, $options);
} | php | public function Alarm(AlarmRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Maintenance/Alarm',
$argument,
['\Etcdserverpb\AlarmResponse', 'decode'],
$metadata, $options);
} | [
"public",
"function",
"Alarm",
"(",
"AlarmRequest",
"$",
"argument",
",",
"$",
"metadata",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"_simpleRequest",
"(",
"'/etcdserverpb.Maintenance/Alarm'",
",",
"$",
"argu... | Alarm activates, deactivates, and queries alarms regarding cluster health.
@param AlarmRequest $argument input argument
@param array $metadata metadata
@param array $options call options
@return UnaryCall | [
"Alarm",
"activates",
"deactivates",
"and",
"queries",
"alarms",
"regarding",
"cluster",
"health",
"."
] | 9fe824bbcc39a1cc1609b22ffa030287e7e8912d | https://github.com/CatsSystem/swoole-etcd/blob/9fe824bbcc39a1cc1609b22ffa030287e7e8912d/etcd/MaintenanceClient.php#L38-L45 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.