repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_code_tokens
listlengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
listlengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
phpalchemy/cerberus
|
src/Alchemy/Component/Cerberus/Model/Base/LoginLog.php
|
LoginLog.setClientAgent
|
public function setClientAgent($v)
{
if ($v !== null) {
$v = (string) $v;
}
if ($this->client_agent !== $v) {
$this->client_agent = $v;
$this->modifiedColumns[LoginLogTableMap::COL_CLIENT_AGENT] = true;
}
return $this;
}
|
php
|
public function setClientAgent($v)
{
if ($v !== null) {
$v = (string) $v;
}
if ($this->client_agent !== $v) {
$this->client_agent = $v;
$this->modifiedColumns[LoginLogTableMap::COL_CLIENT_AGENT] = true;
}
return $this;
}
|
[
"public",
"function",
"setClientAgent",
"(",
"$",
"v",
")",
"{",
"if",
"(",
"$",
"v",
"!==",
"null",
")",
"{",
"$",
"v",
"=",
"(",
"string",
")",
"$",
"v",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"client_agent",
"!==",
"$",
"v",
")",
"{",
"$",
"this",
"->",
"client_agent",
"=",
"$",
"v",
";",
"$",
"this",
"->",
"modifiedColumns",
"[",
"LoginLogTableMap",
"::",
"COL_CLIENT_AGENT",
"]",
"=",
"true",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set the value of [client_agent] column.
@param string $v new value
@return $this|\Alchemy\Component\Cerberus\Model\LoginLog The current object (for fluent API support)
|
[
"Set",
"the",
"value",
"of",
"[",
"client_agent",
"]",
"column",
"."
] |
train
|
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/LoginLog.php#L718-L730
|
phpalchemy/cerberus
|
src/Alchemy/Component/Cerberus/Model/Base/LoginLog.php
|
LoginLog.setClientPlatform
|
public function setClientPlatform($v)
{
if ($v !== null) {
$v = (string) $v;
}
if ($this->client_platform !== $v) {
$this->client_platform = $v;
$this->modifiedColumns[LoginLogTableMap::COL_CLIENT_PLATFORM] = true;
}
return $this;
}
|
php
|
public function setClientPlatform($v)
{
if ($v !== null) {
$v = (string) $v;
}
if ($this->client_platform !== $v) {
$this->client_platform = $v;
$this->modifiedColumns[LoginLogTableMap::COL_CLIENT_PLATFORM] = true;
}
return $this;
}
|
[
"public",
"function",
"setClientPlatform",
"(",
"$",
"v",
")",
"{",
"if",
"(",
"$",
"v",
"!==",
"null",
")",
"{",
"$",
"v",
"=",
"(",
"string",
")",
"$",
"v",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"client_platform",
"!==",
"$",
"v",
")",
"{",
"$",
"this",
"->",
"client_platform",
"=",
"$",
"v",
";",
"$",
"this",
"->",
"modifiedColumns",
"[",
"LoginLogTableMap",
"::",
"COL_CLIENT_PLATFORM",
"]",
"=",
"true",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set the value of [client_platform] column.
@param string $v new value
@return $this|\Alchemy\Component\Cerberus\Model\LoginLog The current object (for fluent API support)
|
[
"Set",
"the",
"value",
"of",
"[",
"client_platform",
"]",
"column",
"."
] |
train
|
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/LoginLog.php#L738-L750
|
phpalchemy/cerberus
|
src/Alchemy/Component/Cerberus/Model/Base/LoginLog.php
|
LoginLog.doInsert
|
protected function doInsert(ConnectionInterface $con)
{
$modifiedColumns = array();
$index = 0;
$this->modifiedColumns[LoginLogTableMap::COL_ID] = true;
if (null !== $this->id) {
throw new PropelException('Cannot insert a value for auto-increment primary key (' . LoginLogTableMap::COL_ID . ')');
}
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(LoginLogTableMap::COL_ID)) {
$modifiedColumns[':p' . $index++] = 'ID';
}
if ($this->isColumnModified(LoginLogTableMap::COL_TYPE)) {
$modifiedColumns[':p' . $index++] = 'TYPE';
}
if ($this->isColumnModified(LoginLogTableMap::COL_DATE_TIME)) {
$modifiedColumns[':p' . $index++] = 'DATE_TIME';
}
if ($this->isColumnModified(LoginLogTableMap::COL_USER_ID)) {
$modifiedColumns[':p' . $index++] = 'USER_ID';
}
if ($this->isColumnModified(LoginLogTableMap::COL_USERNAME)) {
$modifiedColumns[':p' . $index++] = 'USERNAME';
}
if ($this->isColumnModified(LoginLogTableMap::COL_SESSION_ID)) {
$modifiedColumns[':p' . $index++] = 'SESSION_ID';
}
if ($this->isColumnModified(LoginLogTableMap::COL_CLIENT_ADDRESS)) {
$modifiedColumns[':p' . $index++] = 'CLIENT_ADDRESS';
}
if ($this->isColumnModified(LoginLogTableMap::COL_CLIENT_IP)) {
$modifiedColumns[':p' . $index++] = 'CLIENT_IP';
}
if ($this->isColumnModified(LoginLogTableMap::COL_CLIENT_AGENT)) {
$modifiedColumns[':p' . $index++] = 'CLIENT_AGENT';
}
if ($this->isColumnModified(LoginLogTableMap::COL_CLIENT_PLATFORM)) {
$modifiedColumns[':p' . $index++] = 'CLIENT_PLATFORM';
}
$sql = sprintf(
'INSERT INTO login_log (%s) VALUES (%s)',
implode(', ', $modifiedColumns),
implode(', ', array_keys($modifiedColumns))
);
try {
$stmt = $con->prepare($sql);
foreach ($modifiedColumns as $identifier => $columnName) {
switch ($columnName) {
case 'ID':
$stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
break;
case 'TYPE':
$stmt->bindValue($identifier, $this->type, PDO::PARAM_STR);
break;
case 'DATE_TIME':
$stmt->bindValue($identifier, $this->date_time ? $this->date_time->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
break;
case 'USER_ID':
$stmt->bindValue($identifier, $this->user_id, PDO::PARAM_STR);
break;
case 'USERNAME':
$stmt->bindValue($identifier, $this->username, PDO::PARAM_STR);
break;
case 'SESSION_ID':
$stmt->bindValue($identifier, $this->session_id, PDO::PARAM_STR);
break;
case 'CLIENT_ADDRESS':
$stmt->bindValue($identifier, $this->client_address, PDO::PARAM_STR);
break;
case 'CLIENT_IP':
$stmt->bindValue($identifier, $this->client_ip, PDO::PARAM_STR);
break;
case 'CLIENT_AGENT':
$stmt->bindValue($identifier, $this->client_agent, PDO::PARAM_STR);
break;
case 'CLIENT_PLATFORM':
$stmt->bindValue($identifier, $this->client_platform, PDO::PARAM_STR);
break;
}
}
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
}
try {
$pk = $con->lastInsertId();
} catch (Exception $e) {
throw new PropelException('Unable to get autoincrement id.', 0, $e);
}
$this->setId($pk);
$this->setNew(false);
}
|
php
|
protected function doInsert(ConnectionInterface $con)
{
$modifiedColumns = array();
$index = 0;
$this->modifiedColumns[LoginLogTableMap::COL_ID] = true;
if (null !== $this->id) {
throw new PropelException('Cannot insert a value for auto-increment primary key (' . LoginLogTableMap::COL_ID . ')');
}
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(LoginLogTableMap::COL_ID)) {
$modifiedColumns[':p' . $index++] = 'ID';
}
if ($this->isColumnModified(LoginLogTableMap::COL_TYPE)) {
$modifiedColumns[':p' . $index++] = 'TYPE';
}
if ($this->isColumnModified(LoginLogTableMap::COL_DATE_TIME)) {
$modifiedColumns[':p' . $index++] = 'DATE_TIME';
}
if ($this->isColumnModified(LoginLogTableMap::COL_USER_ID)) {
$modifiedColumns[':p' . $index++] = 'USER_ID';
}
if ($this->isColumnModified(LoginLogTableMap::COL_USERNAME)) {
$modifiedColumns[':p' . $index++] = 'USERNAME';
}
if ($this->isColumnModified(LoginLogTableMap::COL_SESSION_ID)) {
$modifiedColumns[':p' . $index++] = 'SESSION_ID';
}
if ($this->isColumnModified(LoginLogTableMap::COL_CLIENT_ADDRESS)) {
$modifiedColumns[':p' . $index++] = 'CLIENT_ADDRESS';
}
if ($this->isColumnModified(LoginLogTableMap::COL_CLIENT_IP)) {
$modifiedColumns[':p' . $index++] = 'CLIENT_IP';
}
if ($this->isColumnModified(LoginLogTableMap::COL_CLIENT_AGENT)) {
$modifiedColumns[':p' . $index++] = 'CLIENT_AGENT';
}
if ($this->isColumnModified(LoginLogTableMap::COL_CLIENT_PLATFORM)) {
$modifiedColumns[':p' . $index++] = 'CLIENT_PLATFORM';
}
$sql = sprintf(
'INSERT INTO login_log (%s) VALUES (%s)',
implode(', ', $modifiedColumns),
implode(', ', array_keys($modifiedColumns))
);
try {
$stmt = $con->prepare($sql);
foreach ($modifiedColumns as $identifier => $columnName) {
switch ($columnName) {
case 'ID':
$stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
break;
case 'TYPE':
$stmt->bindValue($identifier, $this->type, PDO::PARAM_STR);
break;
case 'DATE_TIME':
$stmt->bindValue($identifier, $this->date_time ? $this->date_time->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
break;
case 'USER_ID':
$stmt->bindValue($identifier, $this->user_id, PDO::PARAM_STR);
break;
case 'USERNAME':
$stmt->bindValue($identifier, $this->username, PDO::PARAM_STR);
break;
case 'SESSION_ID':
$stmt->bindValue($identifier, $this->session_id, PDO::PARAM_STR);
break;
case 'CLIENT_ADDRESS':
$stmt->bindValue($identifier, $this->client_address, PDO::PARAM_STR);
break;
case 'CLIENT_IP':
$stmt->bindValue($identifier, $this->client_ip, PDO::PARAM_STR);
break;
case 'CLIENT_AGENT':
$stmt->bindValue($identifier, $this->client_agent, PDO::PARAM_STR);
break;
case 'CLIENT_PLATFORM':
$stmt->bindValue($identifier, $this->client_platform, PDO::PARAM_STR);
break;
}
}
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
}
try {
$pk = $con->lastInsertId();
} catch (Exception $e) {
throw new PropelException('Unable to get autoincrement id.', 0, $e);
}
$this->setId($pk);
$this->setNew(false);
}
|
[
"protected",
"function",
"doInsert",
"(",
"ConnectionInterface",
"$",
"con",
")",
"{",
"$",
"modifiedColumns",
"=",
"array",
"(",
")",
";",
"$",
"index",
"=",
"0",
";",
"$",
"this",
"->",
"modifiedColumns",
"[",
"LoginLogTableMap",
"::",
"COL_ID",
"]",
"=",
"true",
";",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"id",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"'Cannot insert a value for auto-increment primary key ('",
".",
"LoginLogTableMap",
"::",
"COL_ID",
".",
"')'",
")",
";",
"}",
"// check the columns in natural order for more readable SQL queries",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"LoginLogTableMap",
"::",
"COL_ID",
")",
")",
"{",
"$",
"modifiedColumns",
"[",
"':p'",
".",
"$",
"index",
"++",
"]",
"=",
"'ID'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"LoginLogTableMap",
"::",
"COL_TYPE",
")",
")",
"{",
"$",
"modifiedColumns",
"[",
"':p'",
".",
"$",
"index",
"++",
"]",
"=",
"'TYPE'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"LoginLogTableMap",
"::",
"COL_DATE_TIME",
")",
")",
"{",
"$",
"modifiedColumns",
"[",
"':p'",
".",
"$",
"index",
"++",
"]",
"=",
"'DATE_TIME'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"LoginLogTableMap",
"::",
"COL_USER_ID",
")",
")",
"{",
"$",
"modifiedColumns",
"[",
"':p'",
".",
"$",
"index",
"++",
"]",
"=",
"'USER_ID'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"LoginLogTableMap",
"::",
"COL_USERNAME",
")",
")",
"{",
"$",
"modifiedColumns",
"[",
"':p'",
".",
"$",
"index",
"++",
"]",
"=",
"'USERNAME'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"LoginLogTableMap",
"::",
"COL_SESSION_ID",
")",
")",
"{",
"$",
"modifiedColumns",
"[",
"':p'",
".",
"$",
"index",
"++",
"]",
"=",
"'SESSION_ID'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"LoginLogTableMap",
"::",
"COL_CLIENT_ADDRESS",
")",
")",
"{",
"$",
"modifiedColumns",
"[",
"':p'",
".",
"$",
"index",
"++",
"]",
"=",
"'CLIENT_ADDRESS'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"LoginLogTableMap",
"::",
"COL_CLIENT_IP",
")",
")",
"{",
"$",
"modifiedColumns",
"[",
"':p'",
".",
"$",
"index",
"++",
"]",
"=",
"'CLIENT_IP'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"LoginLogTableMap",
"::",
"COL_CLIENT_AGENT",
")",
")",
"{",
"$",
"modifiedColumns",
"[",
"':p'",
".",
"$",
"index",
"++",
"]",
"=",
"'CLIENT_AGENT'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"LoginLogTableMap",
"::",
"COL_CLIENT_PLATFORM",
")",
")",
"{",
"$",
"modifiedColumns",
"[",
"':p'",
".",
"$",
"index",
"++",
"]",
"=",
"'CLIENT_PLATFORM'",
";",
"}",
"$",
"sql",
"=",
"sprintf",
"(",
"'INSERT INTO login_log (%s) VALUES (%s)'",
",",
"implode",
"(",
"', '",
",",
"$",
"modifiedColumns",
")",
",",
"implode",
"(",
"', '",
",",
"array_keys",
"(",
"$",
"modifiedColumns",
")",
")",
")",
";",
"try",
"{",
"$",
"stmt",
"=",
"$",
"con",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"foreach",
"(",
"$",
"modifiedColumns",
"as",
"$",
"identifier",
"=>",
"$",
"columnName",
")",
"{",
"switch",
"(",
"$",
"columnName",
")",
"{",
"case",
"'ID'",
":",
"$",
"stmt",
"->",
"bindValue",
"(",
"$",
"identifier",
",",
"$",
"this",
"->",
"id",
",",
"PDO",
"::",
"PARAM_INT",
")",
";",
"break",
";",
"case",
"'TYPE'",
":",
"$",
"stmt",
"->",
"bindValue",
"(",
"$",
"identifier",
",",
"$",
"this",
"->",
"type",
",",
"PDO",
"::",
"PARAM_STR",
")",
";",
"break",
";",
"case",
"'DATE_TIME'",
":",
"$",
"stmt",
"->",
"bindValue",
"(",
"$",
"identifier",
",",
"$",
"this",
"->",
"date_time",
"?",
"$",
"this",
"->",
"date_time",
"->",
"format",
"(",
"\"Y-m-d H:i:s\"",
")",
":",
"null",
",",
"PDO",
"::",
"PARAM_STR",
")",
";",
"break",
";",
"case",
"'USER_ID'",
":",
"$",
"stmt",
"->",
"bindValue",
"(",
"$",
"identifier",
",",
"$",
"this",
"->",
"user_id",
",",
"PDO",
"::",
"PARAM_STR",
")",
";",
"break",
";",
"case",
"'USERNAME'",
":",
"$",
"stmt",
"->",
"bindValue",
"(",
"$",
"identifier",
",",
"$",
"this",
"->",
"username",
",",
"PDO",
"::",
"PARAM_STR",
")",
";",
"break",
";",
"case",
"'SESSION_ID'",
":",
"$",
"stmt",
"->",
"bindValue",
"(",
"$",
"identifier",
",",
"$",
"this",
"->",
"session_id",
",",
"PDO",
"::",
"PARAM_STR",
")",
";",
"break",
";",
"case",
"'CLIENT_ADDRESS'",
":",
"$",
"stmt",
"->",
"bindValue",
"(",
"$",
"identifier",
",",
"$",
"this",
"->",
"client_address",
",",
"PDO",
"::",
"PARAM_STR",
")",
";",
"break",
";",
"case",
"'CLIENT_IP'",
":",
"$",
"stmt",
"->",
"bindValue",
"(",
"$",
"identifier",
",",
"$",
"this",
"->",
"client_ip",
",",
"PDO",
"::",
"PARAM_STR",
")",
";",
"break",
";",
"case",
"'CLIENT_AGENT'",
":",
"$",
"stmt",
"->",
"bindValue",
"(",
"$",
"identifier",
",",
"$",
"this",
"->",
"client_agent",
",",
"PDO",
"::",
"PARAM_STR",
")",
";",
"break",
";",
"case",
"'CLIENT_PLATFORM'",
":",
"$",
"stmt",
"->",
"bindValue",
"(",
"$",
"identifier",
",",
"$",
"this",
"->",
"client_platform",
",",
"PDO",
"::",
"PARAM_STR",
")",
";",
"break",
";",
"}",
"}",
"$",
"stmt",
"->",
"execute",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"Propel",
"::",
"log",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"Propel",
"::",
"LOG_ERR",
")",
";",
"throw",
"new",
"PropelException",
"(",
"sprintf",
"(",
"'Unable to execute INSERT statement [%s]'",
",",
"$",
"sql",
")",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"try",
"{",
"$",
"pk",
"=",
"$",
"con",
"->",
"lastInsertId",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"'Unable to get autoincrement id.'",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"$",
"this",
"->",
"setId",
"(",
"$",
"pk",
")",
";",
"$",
"this",
"->",
"setNew",
"(",
"false",
")",
";",
"}"
] |
Insert the row in the database.
@param ConnectionInterface $con
@throws PropelException
@see doSave()
|
[
"Insert",
"the",
"row",
"in",
"the",
"database",
"."
] |
train
|
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/LoginLog.php#L914-L1012
|
phpalchemy/cerberus
|
src/Alchemy/Component/Cerberus/Model/Base/LoginLog.php
|
LoginLog.getByPosition
|
public function getByPosition($pos)
{
switch ($pos) {
case 0:
return $this->getId();
break;
case 1:
return $this->getType();
break;
case 2:
return $this->getDateTime();
break;
case 3:
return $this->getUserId();
break;
case 4:
return $this->getUsername();
break;
case 5:
return $this->getSessionId();
break;
case 6:
return $this->getClientAddress();
break;
case 7:
return $this->getClientIp();
break;
case 8:
return $this->getClientAgent();
break;
case 9:
return $this->getClientPlatform();
break;
default:
return null;
break;
} // switch()
}
|
php
|
public function getByPosition($pos)
{
switch ($pos) {
case 0:
return $this->getId();
break;
case 1:
return $this->getType();
break;
case 2:
return $this->getDateTime();
break;
case 3:
return $this->getUserId();
break;
case 4:
return $this->getUsername();
break;
case 5:
return $this->getSessionId();
break;
case 6:
return $this->getClientAddress();
break;
case 7:
return $this->getClientIp();
break;
case 8:
return $this->getClientAgent();
break;
case 9:
return $this->getClientPlatform();
break;
default:
return null;
break;
} // switch()
}
|
[
"public",
"function",
"getByPosition",
"(",
"$",
"pos",
")",
"{",
"switch",
"(",
"$",
"pos",
")",
"{",
"case",
"0",
":",
"return",
"$",
"this",
"->",
"getId",
"(",
")",
";",
"break",
";",
"case",
"1",
":",
"return",
"$",
"this",
"->",
"getType",
"(",
")",
";",
"break",
";",
"case",
"2",
":",
"return",
"$",
"this",
"->",
"getDateTime",
"(",
")",
";",
"break",
";",
"case",
"3",
":",
"return",
"$",
"this",
"->",
"getUserId",
"(",
")",
";",
"break",
";",
"case",
"4",
":",
"return",
"$",
"this",
"->",
"getUsername",
"(",
")",
";",
"break",
";",
"case",
"5",
":",
"return",
"$",
"this",
"->",
"getSessionId",
"(",
")",
";",
"break",
";",
"case",
"6",
":",
"return",
"$",
"this",
"->",
"getClientAddress",
"(",
")",
";",
"break",
";",
"case",
"7",
":",
"return",
"$",
"this",
"->",
"getClientIp",
"(",
")",
";",
"break",
";",
"case",
"8",
":",
"return",
"$",
"this",
"->",
"getClientAgent",
"(",
")",
";",
"break",
";",
"case",
"9",
":",
"return",
"$",
"this",
"->",
"getClientPlatform",
"(",
")",
";",
"break",
";",
"default",
":",
"return",
"null",
";",
"break",
";",
"}",
"// switch()",
"}"
] |
Retrieves a field from the object by Position as specified in the xml schema.
Zero-based.
@param int $pos position in xml schema
@return mixed Value of field at $pos
|
[
"Retrieves",
"a",
"field",
"from",
"the",
"object",
"by",
"Position",
"as",
"specified",
"in",
"the",
"xml",
"schema",
".",
"Zero",
"-",
"based",
"."
] |
train
|
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/LoginLog.php#L1055-L1092
|
phpalchemy/cerberus
|
src/Alchemy/Component/Cerberus/Model/Base/LoginLog.php
|
LoginLog.toArray
|
public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array())
{
if (isset($alreadyDumpedObjects['LoginLog'][$this->getPrimaryKey()])) {
return '*RECURSION*';
}
$alreadyDumpedObjects['LoginLog'][$this->getPrimaryKey()] = true;
$keys = LoginLogTableMap::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getId(),
$keys[1] => $this->getType(),
$keys[2] => $this->getDateTime(),
$keys[3] => $this->getUserId(),
$keys[4] => $this->getUsername(),
$keys[5] => $this->getSessionId(),
$keys[6] => $this->getClientAddress(),
$keys[7] => $this->getClientIp(),
$keys[8] => $this->getClientAgent(),
$keys[9] => $this->getClientPlatform(),
);
$virtualColumns = $this->virtualColumns;
foreach ($virtualColumns as $key => $virtualColumn) {
$result[$key] = $virtualColumn;
}
return $result;
}
|
php
|
public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array())
{
if (isset($alreadyDumpedObjects['LoginLog'][$this->getPrimaryKey()])) {
return '*RECURSION*';
}
$alreadyDumpedObjects['LoginLog'][$this->getPrimaryKey()] = true;
$keys = LoginLogTableMap::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getId(),
$keys[1] => $this->getType(),
$keys[2] => $this->getDateTime(),
$keys[3] => $this->getUserId(),
$keys[4] => $this->getUsername(),
$keys[5] => $this->getSessionId(),
$keys[6] => $this->getClientAddress(),
$keys[7] => $this->getClientIp(),
$keys[8] => $this->getClientAgent(),
$keys[9] => $this->getClientPlatform(),
);
$virtualColumns = $this->virtualColumns;
foreach ($virtualColumns as $key => $virtualColumn) {
$result[$key] = $virtualColumn;
}
return $result;
}
|
[
"public",
"function",
"toArray",
"(",
"$",
"keyType",
"=",
"TableMap",
"::",
"TYPE_PHPNAME",
",",
"$",
"includeLazyLoadColumns",
"=",
"true",
",",
"$",
"alreadyDumpedObjects",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"alreadyDumpedObjects",
"[",
"'LoginLog'",
"]",
"[",
"$",
"this",
"->",
"getPrimaryKey",
"(",
")",
"]",
")",
")",
"{",
"return",
"'*RECURSION*'",
";",
"}",
"$",
"alreadyDumpedObjects",
"[",
"'LoginLog'",
"]",
"[",
"$",
"this",
"->",
"getPrimaryKey",
"(",
")",
"]",
"=",
"true",
";",
"$",
"keys",
"=",
"LoginLogTableMap",
"::",
"getFieldNames",
"(",
"$",
"keyType",
")",
";",
"$",
"result",
"=",
"array",
"(",
"$",
"keys",
"[",
"0",
"]",
"=>",
"$",
"this",
"->",
"getId",
"(",
")",
",",
"$",
"keys",
"[",
"1",
"]",
"=>",
"$",
"this",
"->",
"getType",
"(",
")",
",",
"$",
"keys",
"[",
"2",
"]",
"=>",
"$",
"this",
"->",
"getDateTime",
"(",
")",
",",
"$",
"keys",
"[",
"3",
"]",
"=>",
"$",
"this",
"->",
"getUserId",
"(",
")",
",",
"$",
"keys",
"[",
"4",
"]",
"=>",
"$",
"this",
"->",
"getUsername",
"(",
")",
",",
"$",
"keys",
"[",
"5",
"]",
"=>",
"$",
"this",
"->",
"getSessionId",
"(",
")",
",",
"$",
"keys",
"[",
"6",
"]",
"=>",
"$",
"this",
"->",
"getClientAddress",
"(",
")",
",",
"$",
"keys",
"[",
"7",
"]",
"=>",
"$",
"this",
"->",
"getClientIp",
"(",
")",
",",
"$",
"keys",
"[",
"8",
"]",
"=>",
"$",
"this",
"->",
"getClientAgent",
"(",
")",
",",
"$",
"keys",
"[",
"9",
"]",
"=>",
"$",
"this",
"->",
"getClientPlatform",
"(",
")",
",",
")",
";",
"$",
"virtualColumns",
"=",
"$",
"this",
"->",
"virtualColumns",
";",
"foreach",
"(",
"$",
"virtualColumns",
"as",
"$",
"key",
"=>",
"$",
"virtualColumn",
")",
"{",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"$",
"virtualColumn",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Exports the object as an array.
You can specify the key type of the array by passing one of the class
type constants.
@param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
Defaults to TableMap::TYPE_PHPNAME.
@param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
@param array $alreadyDumpedObjects List of objects to skip to avoid recursion
@return array an associative array containing the field names (as keys) and field values
|
[
"Exports",
"the",
"object",
"as",
"an",
"array",
"."
] |
train
|
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/LoginLog.php#L1108-L1134
|
phpalchemy/cerberus
|
src/Alchemy/Component/Cerberus/Model/Base/LoginLog.php
|
LoginLog.setByPosition
|
public function setByPosition($pos, $value)
{
switch ($pos) {
case 0:
$this->setId($value);
break;
case 1:
$this->setType($value);
break;
case 2:
$this->setDateTime($value);
break;
case 3:
$this->setUserId($value);
break;
case 4:
$this->setUsername($value);
break;
case 5:
$this->setSessionId($value);
break;
case 6:
$this->setClientAddress($value);
break;
case 7:
$this->setClientIp($value);
break;
case 8:
$this->setClientAgent($value);
break;
case 9:
$this->setClientPlatform($value);
break;
} // switch()
return $this;
}
|
php
|
public function setByPosition($pos, $value)
{
switch ($pos) {
case 0:
$this->setId($value);
break;
case 1:
$this->setType($value);
break;
case 2:
$this->setDateTime($value);
break;
case 3:
$this->setUserId($value);
break;
case 4:
$this->setUsername($value);
break;
case 5:
$this->setSessionId($value);
break;
case 6:
$this->setClientAddress($value);
break;
case 7:
$this->setClientIp($value);
break;
case 8:
$this->setClientAgent($value);
break;
case 9:
$this->setClientPlatform($value);
break;
} // switch()
return $this;
}
|
[
"public",
"function",
"setByPosition",
"(",
"$",
"pos",
",",
"$",
"value",
")",
"{",
"switch",
"(",
"$",
"pos",
")",
"{",
"case",
"0",
":",
"$",
"this",
"->",
"setId",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"1",
":",
"$",
"this",
"->",
"setType",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"2",
":",
"$",
"this",
"->",
"setDateTime",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"3",
":",
"$",
"this",
"->",
"setUserId",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"4",
":",
"$",
"this",
"->",
"setUsername",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"5",
":",
"$",
"this",
"->",
"setSessionId",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"6",
":",
"$",
"this",
"->",
"setClientAddress",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"7",
":",
"$",
"this",
"->",
"setClientIp",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"8",
":",
"$",
"this",
"->",
"setClientAgent",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"9",
":",
"$",
"this",
"->",
"setClientPlatform",
"(",
"$",
"value",
")",
";",
"break",
";",
"}",
"// switch()",
"return",
"$",
"this",
";",
"}"
] |
Sets a field from the object by Position as specified in the xml schema.
Zero-based.
@param int $pos position in xml schema
@param mixed $value field value
@return $this|\Alchemy\Component\Cerberus\Model\LoginLog
|
[
"Sets",
"a",
"field",
"from",
"the",
"object",
"by",
"Position",
"as",
"specified",
"in",
"the",
"xml",
"schema",
".",
"Zero",
"-",
"based",
"."
] |
train
|
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/LoginLog.php#L1162-L1198
|
phpalchemy/cerberus
|
src/Alchemy/Component/Cerberus/Model/Base/LoginLog.php
|
LoginLog.fromArray
|
public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME)
{
$keys = LoginLogTableMap::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) {
$this->setId($arr[$keys[0]]);
}
if (array_key_exists($keys[1], $arr)) {
$this->setType($arr[$keys[1]]);
}
if (array_key_exists($keys[2], $arr)) {
$this->setDateTime($arr[$keys[2]]);
}
if (array_key_exists($keys[3], $arr)) {
$this->setUserId($arr[$keys[3]]);
}
if (array_key_exists($keys[4], $arr)) {
$this->setUsername($arr[$keys[4]]);
}
if (array_key_exists($keys[5], $arr)) {
$this->setSessionId($arr[$keys[5]]);
}
if (array_key_exists($keys[6], $arr)) {
$this->setClientAddress($arr[$keys[6]]);
}
if (array_key_exists($keys[7], $arr)) {
$this->setClientIp($arr[$keys[7]]);
}
if (array_key_exists($keys[8], $arr)) {
$this->setClientAgent($arr[$keys[8]]);
}
if (array_key_exists($keys[9], $arr)) {
$this->setClientPlatform($arr[$keys[9]]);
}
}
|
php
|
public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME)
{
$keys = LoginLogTableMap::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) {
$this->setId($arr[$keys[0]]);
}
if (array_key_exists($keys[1], $arr)) {
$this->setType($arr[$keys[1]]);
}
if (array_key_exists($keys[2], $arr)) {
$this->setDateTime($arr[$keys[2]]);
}
if (array_key_exists($keys[3], $arr)) {
$this->setUserId($arr[$keys[3]]);
}
if (array_key_exists($keys[4], $arr)) {
$this->setUsername($arr[$keys[4]]);
}
if (array_key_exists($keys[5], $arr)) {
$this->setSessionId($arr[$keys[5]]);
}
if (array_key_exists($keys[6], $arr)) {
$this->setClientAddress($arr[$keys[6]]);
}
if (array_key_exists($keys[7], $arr)) {
$this->setClientIp($arr[$keys[7]]);
}
if (array_key_exists($keys[8], $arr)) {
$this->setClientAgent($arr[$keys[8]]);
}
if (array_key_exists($keys[9], $arr)) {
$this->setClientPlatform($arr[$keys[9]]);
}
}
|
[
"public",
"function",
"fromArray",
"(",
"$",
"arr",
",",
"$",
"keyType",
"=",
"TableMap",
"::",
"TYPE_PHPNAME",
")",
"{",
"$",
"keys",
"=",
"LoginLogTableMap",
"::",
"getFieldNames",
"(",
"$",
"keyType",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"keys",
"[",
"0",
"]",
",",
"$",
"arr",
")",
")",
"{",
"$",
"this",
"->",
"setId",
"(",
"$",
"arr",
"[",
"$",
"keys",
"[",
"0",
"]",
"]",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"$",
"keys",
"[",
"1",
"]",
",",
"$",
"arr",
")",
")",
"{",
"$",
"this",
"->",
"setType",
"(",
"$",
"arr",
"[",
"$",
"keys",
"[",
"1",
"]",
"]",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"$",
"keys",
"[",
"2",
"]",
",",
"$",
"arr",
")",
")",
"{",
"$",
"this",
"->",
"setDateTime",
"(",
"$",
"arr",
"[",
"$",
"keys",
"[",
"2",
"]",
"]",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"$",
"keys",
"[",
"3",
"]",
",",
"$",
"arr",
")",
")",
"{",
"$",
"this",
"->",
"setUserId",
"(",
"$",
"arr",
"[",
"$",
"keys",
"[",
"3",
"]",
"]",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"$",
"keys",
"[",
"4",
"]",
",",
"$",
"arr",
")",
")",
"{",
"$",
"this",
"->",
"setUsername",
"(",
"$",
"arr",
"[",
"$",
"keys",
"[",
"4",
"]",
"]",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"$",
"keys",
"[",
"5",
"]",
",",
"$",
"arr",
")",
")",
"{",
"$",
"this",
"->",
"setSessionId",
"(",
"$",
"arr",
"[",
"$",
"keys",
"[",
"5",
"]",
"]",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"$",
"keys",
"[",
"6",
"]",
",",
"$",
"arr",
")",
")",
"{",
"$",
"this",
"->",
"setClientAddress",
"(",
"$",
"arr",
"[",
"$",
"keys",
"[",
"6",
"]",
"]",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"$",
"keys",
"[",
"7",
"]",
",",
"$",
"arr",
")",
")",
"{",
"$",
"this",
"->",
"setClientIp",
"(",
"$",
"arr",
"[",
"$",
"keys",
"[",
"7",
"]",
"]",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"$",
"keys",
"[",
"8",
"]",
",",
"$",
"arr",
")",
")",
"{",
"$",
"this",
"->",
"setClientAgent",
"(",
"$",
"arr",
"[",
"$",
"keys",
"[",
"8",
"]",
"]",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"$",
"keys",
"[",
"9",
"]",
",",
"$",
"arr",
")",
")",
"{",
"$",
"this",
"->",
"setClientPlatform",
"(",
"$",
"arr",
"[",
"$",
"keys",
"[",
"9",
"]",
"]",
")",
";",
"}",
"}"
] |
Populates the object using an array.
This is particularly useful when populating an object from one of the
request arrays (e.g. $_POST). This method goes through the column
names, checking to see whether a matching key exists in populated
array. If so the setByName() method is called for that column.
You can specify the key type of the array by additionally passing one
of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
The default key type is the column's TableMap::TYPE_PHPNAME.
@param array $arr An array to populate the object from.
@param string $keyType The type of keys the array uses.
@return void
|
[
"Populates",
"the",
"object",
"using",
"an",
"array",
"."
] |
train
|
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/LoginLog.php#L1217-L1251
|
phpalchemy/cerberus
|
src/Alchemy/Component/Cerberus/Model/Base/LoginLog.php
|
LoginLog.buildCriteria
|
public function buildCriteria()
{
$criteria = new Criteria(LoginLogTableMap::DATABASE_NAME);
if ($this->isColumnModified(LoginLogTableMap::COL_ID)) {
$criteria->add(LoginLogTableMap::COL_ID, $this->id);
}
if ($this->isColumnModified(LoginLogTableMap::COL_TYPE)) {
$criteria->add(LoginLogTableMap::COL_TYPE, $this->type);
}
if ($this->isColumnModified(LoginLogTableMap::COL_DATE_TIME)) {
$criteria->add(LoginLogTableMap::COL_DATE_TIME, $this->date_time);
}
if ($this->isColumnModified(LoginLogTableMap::COL_USER_ID)) {
$criteria->add(LoginLogTableMap::COL_USER_ID, $this->user_id);
}
if ($this->isColumnModified(LoginLogTableMap::COL_USERNAME)) {
$criteria->add(LoginLogTableMap::COL_USERNAME, $this->username);
}
if ($this->isColumnModified(LoginLogTableMap::COL_SESSION_ID)) {
$criteria->add(LoginLogTableMap::COL_SESSION_ID, $this->session_id);
}
if ($this->isColumnModified(LoginLogTableMap::COL_CLIENT_ADDRESS)) {
$criteria->add(LoginLogTableMap::COL_CLIENT_ADDRESS, $this->client_address);
}
if ($this->isColumnModified(LoginLogTableMap::COL_CLIENT_IP)) {
$criteria->add(LoginLogTableMap::COL_CLIENT_IP, $this->client_ip);
}
if ($this->isColumnModified(LoginLogTableMap::COL_CLIENT_AGENT)) {
$criteria->add(LoginLogTableMap::COL_CLIENT_AGENT, $this->client_agent);
}
if ($this->isColumnModified(LoginLogTableMap::COL_CLIENT_PLATFORM)) {
$criteria->add(LoginLogTableMap::COL_CLIENT_PLATFORM, $this->client_platform);
}
return $criteria;
}
|
php
|
public function buildCriteria()
{
$criteria = new Criteria(LoginLogTableMap::DATABASE_NAME);
if ($this->isColumnModified(LoginLogTableMap::COL_ID)) {
$criteria->add(LoginLogTableMap::COL_ID, $this->id);
}
if ($this->isColumnModified(LoginLogTableMap::COL_TYPE)) {
$criteria->add(LoginLogTableMap::COL_TYPE, $this->type);
}
if ($this->isColumnModified(LoginLogTableMap::COL_DATE_TIME)) {
$criteria->add(LoginLogTableMap::COL_DATE_TIME, $this->date_time);
}
if ($this->isColumnModified(LoginLogTableMap::COL_USER_ID)) {
$criteria->add(LoginLogTableMap::COL_USER_ID, $this->user_id);
}
if ($this->isColumnModified(LoginLogTableMap::COL_USERNAME)) {
$criteria->add(LoginLogTableMap::COL_USERNAME, $this->username);
}
if ($this->isColumnModified(LoginLogTableMap::COL_SESSION_ID)) {
$criteria->add(LoginLogTableMap::COL_SESSION_ID, $this->session_id);
}
if ($this->isColumnModified(LoginLogTableMap::COL_CLIENT_ADDRESS)) {
$criteria->add(LoginLogTableMap::COL_CLIENT_ADDRESS, $this->client_address);
}
if ($this->isColumnModified(LoginLogTableMap::COL_CLIENT_IP)) {
$criteria->add(LoginLogTableMap::COL_CLIENT_IP, $this->client_ip);
}
if ($this->isColumnModified(LoginLogTableMap::COL_CLIENT_AGENT)) {
$criteria->add(LoginLogTableMap::COL_CLIENT_AGENT, $this->client_agent);
}
if ($this->isColumnModified(LoginLogTableMap::COL_CLIENT_PLATFORM)) {
$criteria->add(LoginLogTableMap::COL_CLIENT_PLATFORM, $this->client_platform);
}
return $criteria;
}
|
[
"public",
"function",
"buildCriteria",
"(",
")",
"{",
"$",
"criteria",
"=",
"new",
"Criteria",
"(",
"LoginLogTableMap",
"::",
"DATABASE_NAME",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"LoginLogTableMap",
"::",
"COL_ID",
")",
")",
"{",
"$",
"criteria",
"->",
"add",
"(",
"LoginLogTableMap",
"::",
"COL_ID",
",",
"$",
"this",
"->",
"id",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"LoginLogTableMap",
"::",
"COL_TYPE",
")",
")",
"{",
"$",
"criteria",
"->",
"add",
"(",
"LoginLogTableMap",
"::",
"COL_TYPE",
",",
"$",
"this",
"->",
"type",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"LoginLogTableMap",
"::",
"COL_DATE_TIME",
")",
")",
"{",
"$",
"criteria",
"->",
"add",
"(",
"LoginLogTableMap",
"::",
"COL_DATE_TIME",
",",
"$",
"this",
"->",
"date_time",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"LoginLogTableMap",
"::",
"COL_USER_ID",
")",
")",
"{",
"$",
"criteria",
"->",
"add",
"(",
"LoginLogTableMap",
"::",
"COL_USER_ID",
",",
"$",
"this",
"->",
"user_id",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"LoginLogTableMap",
"::",
"COL_USERNAME",
")",
")",
"{",
"$",
"criteria",
"->",
"add",
"(",
"LoginLogTableMap",
"::",
"COL_USERNAME",
",",
"$",
"this",
"->",
"username",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"LoginLogTableMap",
"::",
"COL_SESSION_ID",
")",
")",
"{",
"$",
"criteria",
"->",
"add",
"(",
"LoginLogTableMap",
"::",
"COL_SESSION_ID",
",",
"$",
"this",
"->",
"session_id",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"LoginLogTableMap",
"::",
"COL_CLIENT_ADDRESS",
")",
")",
"{",
"$",
"criteria",
"->",
"add",
"(",
"LoginLogTableMap",
"::",
"COL_CLIENT_ADDRESS",
",",
"$",
"this",
"->",
"client_address",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"LoginLogTableMap",
"::",
"COL_CLIENT_IP",
")",
")",
"{",
"$",
"criteria",
"->",
"add",
"(",
"LoginLogTableMap",
"::",
"COL_CLIENT_IP",
",",
"$",
"this",
"->",
"client_ip",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"LoginLogTableMap",
"::",
"COL_CLIENT_AGENT",
")",
")",
"{",
"$",
"criteria",
"->",
"add",
"(",
"LoginLogTableMap",
"::",
"COL_CLIENT_AGENT",
",",
"$",
"this",
"->",
"client_agent",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"LoginLogTableMap",
"::",
"COL_CLIENT_PLATFORM",
")",
")",
"{",
"$",
"criteria",
"->",
"add",
"(",
"LoginLogTableMap",
"::",
"COL_CLIENT_PLATFORM",
",",
"$",
"this",
"->",
"client_platform",
")",
";",
"}",
"return",
"$",
"criteria",
";",
"}"
] |
Build a Criteria object containing the values of all modified columns in this object.
@return Criteria The Criteria object containing all modified values.
|
[
"Build",
"a",
"Criteria",
"object",
"containing",
"the",
"values",
"of",
"all",
"modified",
"columns",
"in",
"this",
"object",
"."
] |
train
|
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/LoginLog.php#L1282-L1318
|
phpalchemy/cerberus
|
src/Alchemy/Component/Cerberus/Model/Base/LoginLog.php
|
LoginLog.buildPkeyCriteria
|
public function buildPkeyCriteria()
{
$criteria = new Criteria(LoginLogTableMap::DATABASE_NAME);
$criteria->add(LoginLogTableMap::COL_ID, $this->id);
return $criteria;
}
|
php
|
public function buildPkeyCriteria()
{
$criteria = new Criteria(LoginLogTableMap::DATABASE_NAME);
$criteria->add(LoginLogTableMap::COL_ID, $this->id);
return $criteria;
}
|
[
"public",
"function",
"buildPkeyCriteria",
"(",
")",
"{",
"$",
"criteria",
"=",
"new",
"Criteria",
"(",
"LoginLogTableMap",
"::",
"DATABASE_NAME",
")",
";",
"$",
"criteria",
"->",
"add",
"(",
"LoginLogTableMap",
"::",
"COL_ID",
",",
"$",
"this",
"->",
"id",
")",
";",
"return",
"$",
"criteria",
";",
"}"
] |
Builds a Criteria object containing the primary key for this object.
Unlike buildCriteria() this method includes the primary key values regardless
of whether or not they have been modified.
@throws LogicException if no primary key is defined
@return Criteria The Criteria object containing value(s) for primary key(s).
|
[
"Builds",
"a",
"Criteria",
"object",
"containing",
"the",
"primary",
"key",
"for",
"this",
"object",
"."
] |
train
|
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/LoginLog.php#L1330-L1336
|
phpalchemy/cerberus
|
src/Alchemy/Component/Cerberus/Model/Base/LoginLog.php
|
LoginLog.clear
|
public function clear()
{
$this->id = null;
$this->type = null;
$this->date_time = null;
$this->user_id = null;
$this->username = null;
$this->session_id = null;
$this->client_address = null;
$this->client_ip = null;
$this->client_agent = null;
$this->client_platform = null;
$this->alreadyInSave = false;
$this->clearAllReferences();
$this->resetModified();
$this->setNew(true);
$this->setDeleted(false);
}
|
php
|
public function clear()
{
$this->id = null;
$this->type = null;
$this->date_time = null;
$this->user_id = null;
$this->username = null;
$this->session_id = null;
$this->client_address = null;
$this->client_ip = null;
$this->client_agent = null;
$this->client_platform = null;
$this->alreadyInSave = false;
$this->clearAllReferences();
$this->resetModified();
$this->setNew(true);
$this->setDeleted(false);
}
|
[
"public",
"function",
"clear",
"(",
")",
"{",
"$",
"this",
"->",
"id",
"=",
"null",
";",
"$",
"this",
"->",
"type",
"=",
"null",
";",
"$",
"this",
"->",
"date_time",
"=",
"null",
";",
"$",
"this",
"->",
"user_id",
"=",
"null",
";",
"$",
"this",
"->",
"username",
"=",
"null",
";",
"$",
"this",
"->",
"session_id",
"=",
"null",
";",
"$",
"this",
"->",
"client_address",
"=",
"null",
";",
"$",
"this",
"->",
"client_ip",
"=",
"null",
";",
"$",
"this",
"->",
"client_agent",
"=",
"null",
";",
"$",
"this",
"->",
"client_platform",
"=",
"null",
";",
"$",
"this",
"->",
"alreadyInSave",
"=",
"false",
";",
"$",
"this",
"->",
"clearAllReferences",
"(",
")",
";",
"$",
"this",
"->",
"resetModified",
"(",
")",
";",
"$",
"this",
"->",
"setNew",
"(",
"true",
")",
";",
"$",
"this",
"->",
"setDeleted",
"(",
"false",
")",
";",
"}"
] |
Clears the current object, sets all attributes to their default values and removes
outgoing references as well as back-references (from other objects to this one. Results probably in a database
change of those foreign objects when you call `save` there).
|
[
"Clears",
"the",
"current",
"object",
"sets",
"all",
"attributes",
"to",
"their",
"default",
"values",
"and",
"removes",
"outgoing",
"references",
"as",
"well",
"as",
"back",
"-",
"references",
"(",
"from",
"other",
"objects",
"to",
"this",
"one",
".",
"Results",
"probably",
"in",
"a",
"database",
"change",
"of",
"those",
"foreign",
"objects",
"when",
"you",
"call",
"save",
"there",
")",
"."
] |
train
|
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/LoginLog.php#L1444-L1461
|
bestit/commercetools-order-export-bundle
|
src/OrderVisitor.php
|
OrderVisitor.getNextOrderCollection
|
private function getNextOrderCollection(int $renderedArticleCount)
{
$count = $this->count();
$logger = $this->getLogger();
$orderCollection = null;
$withPagination = $this->withPagination();
$logger->debug(
'Tries to load the next order collection',
['count' => $count, 'withPagination' => $withPagination]
);
if ((!$withPagination) || ($renderedArticleCount < $count)) {
if ($withPagination) {
$this->getOrderQuery()->offset($renderedArticleCount);
}
$this->loadOrderCollection();
$orderCollection = $this->getOrderCollection();
}
return $orderCollection;
}
|
php
|
private function getNextOrderCollection(int $renderedArticleCount)
{
$count = $this->count();
$logger = $this->getLogger();
$orderCollection = null;
$withPagination = $this->withPagination();
$logger->debug(
'Tries to load the next order collection',
['count' => $count, 'withPagination' => $withPagination]
);
if ((!$withPagination) || ($renderedArticleCount < $count)) {
if ($withPagination) {
$this->getOrderQuery()->offset($renderedArticleCount);
}
$this->loadOrderCollection();
$orderCollection = $this->getOrderCollection();
}
return $orderCollection;
}
|
[
"private",
"function",
"getNextOrderCollection",
"(",
"int",
"$",
"renderedArticleCount",
")",
"{",
"$",
"count",
"=",
"$",
"this",
"->",
"count",
"(",
")",
";",
"$",
"logger",
"=",
"$",
"this",
"->",
"getLogger",
"(",
")",
";",
"$",
"orderCollection",
"=",
"null",
";",
"$",
"withPagination",
"=",
"$",
"this",
"->",
"withPagination",
"(",
")",
";",
"$",
"logger",
"->",
"debug",
"(",
"'Tries to load the next order collection'",
",",
"[",
"'count'",
"=>",
"$",
"count",
",",
"'withPagination'",
"=>",
"$",
"withPagination",
"]",
")",
";",
"if",
"(",
"(",
"!",
"$",
"withPagination",
")",
"||",
"(",
"$",
"renderedArticleCount",
"<",
"$",
"count",
")",
")",
"{",
"if",
"(",
"$",
"withPagination",
")",
"{",
"$",
"this",
"->",
"getOrderQuery",
"(",
")",
"->",
"offset",
"(",
"$",
"renderedArticleCount",
")",
";",
"}",
"$",
"this",
"->",
"loadOrderCollection",
"(",
")",
";",
"$",
"orderCollection",
"=",
"$",
"this",
"->",
"getOrderCollection",
"(",
")",
";",
"}",
"return",
"$",
"orderCollection",
";",
"}"
] |
Returns the next order collection or void.
@param int $renderedArticleCount How many articles are rendered allready.
@return OrderCollection|void
|
[
"Returns",
"the",
"next",
"order",
"collection",
"or",
"void",
"."
] |
train
|
https://github.com/bestit/commercetools-order-export-bundle/blob/44bd0dedff6edab5ecf5803dcf6d24ffe0dbf845/src/OrderVisitor.php#L151-L174
|
bestit/commercetools-order-export-bundle
|
src/OrderVisitor.php
|
OrderVisitor.getTotalCount
|
private function getTotalCount(): int
{
if ($this->totalCount === -1) {
$this->setTotalCount($this->getLastResponse()->getTotal());
}
return $this->totalCount;
}
|
php
|
private function getTotalCount(): int
{
if ($this->totalCount === -1) {
$this->setTotalCount($this->getLastResponse()->getTotal());
}
return $this->totalCount;
}
|
[
"private",
"function",
"getTotalCount",
"(",
")",
":",
"int",
"{",
"if",
"(",
"$",
"this",
"->",
"totalCount",
"===",
"-",
"1",
")",
"{",
"$",
"this",
"->",
"setTotalCount",
"(",
"$",
"this",
"->",
"getLastResponse",
"(",
")",
"->",
"getTotal",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"totalCount",
";",
"}"
] |
Returns the total count of found orders.
@return int
|
[
"Returns",
"the",
"total",
"count",
"of",
"found",
"orders",
"."
] |
train
|
https://github.com/bestit/commercetools-order-export-bundle/blob/44bd0dedff6edab5ecf5803dcf6d24ffe0dbf845/src/OrderVisitor.php#L206-L213
|
bestit/commercetools-order-export-bundle
|
src/OrderVisitor.php
|
OrderVisitor.loadOrderCollection
|
private function loadOrderCollection(): OrderVisitor
{
$logger = $this->getLogger();
/** @var PagedQueryResponse $response */
$response = $this->getClient()->execute($this->getOrderQuery());
if ($response instanceof ErrorResponse) {
$logger->error('Got error response loading the orders.', ['response' => $response]);
throw new RuntimeException($response->getMessage());
} else {
$logger->debug('Found some orders.', ['response' => $response]);
}
$this->setLastResponse($response);
$this->setOrderCollection($this->getLastResponse()->toObject());
return $this;
}
|
php
|
private function loadOrderCollection(): OrderVisitor
{
$logger = $this->getLogger();
/** @var PagedQueryResponse $response */
$response = $this->getClient()->execute($this->getOrderQuery());
if ($response instanceof ErrorResponse) {
$logger->error('Got error response loading the orders.', ['response' => $response]);
throw new RuntimeException($response->getMessage());
} else {
$logger->debug('Found some orders.', ['response' => $response]);
}
$this->setLastResponse($response);
$this->setOrderCollection($this->getLastResponse()->toObject());
return $this;
}
|
[
"private",
"function",
"loadOrderCollection",
"(",
")",
":",
"OrderVisitor",
"{",
"$",
"logger",
"=",
"$",
"this",
"->",
"getLogger",
"(",
")",
";",
"/** @var PagedQueryResponse $response */",
"$",
"response",
"=",
"$",
"this",
"->",
"getClient",
"(",
")",
"->",
"execute",
"(",
"$",
"this",
"->",
"getOrderQuery",
"(",
")",
")",
";",
"if",
"(",
"$",
"response",
"instanceof",
"ErrorResponse",
")",
"{",
"$",
"logger",
"->",
"error",
"(",
"'Got error response loading the orders.'",
",",
"[",
"'response'",
"=>",
"$",
"response",
"]",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"$",
"response",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"logger",
"->",
"debug",
"(",
"'Found some orders.'",
",",
"[",
"'response'",
"=>",
"$",
"response",
"]",
")",
";",
"}",
"$",
"this",
"->",
"setLastResponse",
"(",
"$",
"response",
")",
";",
"$",
"this",
"->",
"setOrderCollection",
"(",
"$",
"this",
"->",
"getLastResponse",
"(",
")",
"->",
"toObject",
"(",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Loads the order collection.
@return OrderVisitor
|
[
"Loads",
"the",
"order",
"collection",
"."
] |
train
|
https://github.com/bestit/commercetools-order-export-bundle/blob/44bd0dedff6edab5ecf5803dcf6d24ffe0dbf845/src/OrderVisitor.php#L219-L239
|
bestit/commercetools-order-export-bundle
|
src/OrderVisitor.php
|
OrderVisitor.loadOrderQuery
|
private function loadOrderQuery(): OrderVisitor
{
$logger = $this->getLogger();
$query = new OrderQueryRequest();
if ($wheres = $this->getDefaultWhere()) {
$logger->debug('Added where-clause to fech orders.', ['predicates' => $wheres]);
array_walk($wheres, function (string $where) use ($logger, $query) {
$query->where($where);
});
} else {
$logger->debug('No where-clause to fetch orders.');
}
$this->setOrderQuery($query);
return $this;
}
|
php
|
private function loadOrderQuery(): OrderVisitor
{
$logger = $this->getLogger();
$query = new OrderQueryRequest();
if ($wheres = $this->getDefaultWhere()) {
$logger->debug('Added where-clause to fech orders.', ['predicates' => $wheres]);
array_walk($wheres, function (string $where) use ($logger, $query) {
$query->where($where);
});
} else {
$logger->debug('No where-clause to fetch orders.');
}
$this->setOrderQuery($query);
return $this;
}
|
[
"private",
"function",
"loadOrderQuery",
"(",
")",
":",
"OrderVisitor",
"{",
"$",
"logger",
"=",
"$",
"this",
"->",
"getLogger",
"(",
")",
";",
"$",
"query",
"=",
"new",
"OrderQueryRequest",
"(",
")",
";",
"if",
"(",
"$",
"wheres",
"=",
"$",
"this",
"->",
"getDefaultWhere",
"(",
")",
")",
"{",
"$",
"logger",
"->",
"debug",
"(",
"'Added where-clause to fech orders.'",
",",
"[",
"'predicates'",
"=>",
"$",
"wheres",
"]",
")",
";",
"array_walk",
"(",
"$",
"wheres",
",",
"function",
"(",
"string",
"$",
"where",
")",
"use",
"(",
"$",
"logger",
",",
"$",
"query",
")",
"{",
"$",
"query",
"->",
"where",
"(",
"$",
"where",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"$",
"logger",
"->",
"debug",
"(",
"'No where-clause to fetch orders.'",
")",
";",
"}",
"$",
"this",
"->",
"setOrderQuery",
"(",
"$",
"query",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Returns the order query request.
@return OrderVisitor
|
[
"Returns",
"the",
"order",
"query",
"request",
"."
] |
train
|
https://github.com/bestit/commercetools-order-export-bundle/blob/44bd0dedff6edab5ecf5803dcf6d24ffe0dbf845/src/OrderVisitor.php#L245-L263
|
bestit/commercetools-order-export-bundle
|
src/OrderVisitor.php
|
OrderVisitor.withPagination
|
private function withPagination(bool $newStatus = true): bool
{
$oldStatus = $this->withPagination;
if (func_num_args()) {
$this->withPagination = $newStatus;
}
return $oldStatus;
}
|
php
|
private function withPagination(bool $newStatus = true): bool
{
$oldStatus = $this->withPagination;
if (func_num_args()) {
$this->withPagination = $newStatus;
}
return $oldStatus;
}
|
[
"private",
"function",
"withPagination",
"(",
"bool",
"$",
"newStatus",
"=",
"true",
")",
":",
"bool",
"{",
"$",
"oldStatus",
"=",
"$",
"this",
"->",
"withPagination",
";",
"if",
"(",
"func_num_args",
"(",
")",
")",
"{",
"$",
"this",
"->",
"withPagination",
"=",
"$",
"newStatus",
";",
"}",
"return",
"$",
"oldStatus",
";",
"}"
] |
Sets the pagination status for this list.
@param bool $newStatus
@return bool
|
[
"Sets",
"the",
"pagination",
"status",
"for",
"this",
"list",
"."
] |
train
|
https://github.com/bestit/commercetools-order-export-bundle/blob/44bd0dedff6edab5ecf5803dcf6d24ffe0dbf845/src/OrderVisitor.php#L342-L351
|
bestit/commercetools-order-export-bundle
|
src/OrderVisitor.php
|
OrderVisitor.yieldOrders
|
public function yieldOrders()
{
$usedIndex = 0;
$orderCollection = $this->getOrderCollection();
while ($orderCollection && count($orderCollection)) {
foreach ($orderCollection as $order) {
set_time_limit(0);
yield $usedIndex++ => $order;
}
$orderCollection = $this->getNextOrderCollection($usedIndex);
}
}
|
php
|
public function yieldOrders()
{
$usedIndex = 0;
$orderCollection = $this->getOrderCollection();
while ($orderCollection && count($orderCollection)) {
foreach ($orderCollection as $order) {
set_time_limit(0);
yield $usedIndex++ => $order;
}
$orderCollection = $this->getNextOrderCollection($usedIndex);
}
}
|
[
"public",
"function",
"yieldOrders",
"(",
")",
"{",
"$",
"usedIndex",
"=",
"0",
";",
"$",
"orderCollection",
"=",
"$",
"this",
"->",
"getOrderCollection",
"(",
")",
";",
"while",
"(",
"$",
"orderCollection",
"&&",
"count",
"(",
"$",
"orderCollection",
")",
")",
"{",
"foreach",
"(",
"$",
"orderCollection",
"as",
"$",
"order",
")",
"{",
"set_time_limit",
"(",
"0",
")",
";",
"yield",
"$",
"usedIndex",
"++",
"=>",
"$",
"order",
";",
"}",
"$",
"orderCollection",
"=",
"$",
"this",
"->",
"getNextOrderCollection",
"(",
"$",
"usedIndex",
")",
";",
"}",
"}"
] |
Yields all found orders.
@return Generator
|
[
"Yields",
"all",
"found",
"orders",
"."
] |
train
|
https://github.com/bestit/commercetools-order-export-bundle/blob/44bd0dedff6edab5ecf5803dcf6d24ffe0dbf845/src/OrderVisitor.php#L357-L371
|
dragosprotung/stc-core
|
src/Workout/Dumper/FileDumper.php
|
FileDumper.dump
|
public function dump(Workout $workout): string
{
$dump = $this->dumper->dump($workout);
file_put_contents($this->outputFile, $dump);
return $dump;
}
|
php
|
public function dump(Workout $workout): string
{
$dump = $this->dumper->dump($workout);
file_put_contents($this->outputFile, $dump);
return $dump;
}
|
[
"public",
"function",
"dump",
"(",
"Workout",
"$",
"workout",
")",
":",
"string",
"{",
"$",
"dump",
"=",
"$",
"this",
"->",
"dumper",
"->",
"dump",
"(",
"$",
"workout",
")",
";",
"file_put_contents",
"(",
"$",
"this",
"->",
"outputFile",
",",
"$",
"dump",
")",
";",
"return",
"$",
"dump",
";",
"}"
] |
{@inheritdoc}
|
[
"{"
] |
train
|
https://github.com/dragosprotung/stc-core/blob/9783e3414294f4ee555a1d538d2807269deeb9e7/src/Workout/Dumper/FileDumper.php#L38-L45
|
chriswoodford/foursquare-php
|
lib/TheTwelve/Foursquare/HttpClient/ZF1HttpClient.php
|
Zend1HttpClient.get
|
public function get( $uri, array $params = array() )
{
$this->_client->setMethod('GET');
return $this->_request($uri, $params);
}
|
php
|
public function get( $uri, array $params = array() )
{
$this->_client->setMethod('GET');
return $this->_request($uri, $params);
}
|
[
"public",
"function",
"get",
"(",
"$",
"uri",
",",
"array",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"_client",
"->",
"setMethod",
"(",
"'GET'",
")",
";",
"return",
"$",
"this",
"->",
"_request",
"(",
"$",
"uri",
",",
"$",
"params",
")",
";",
"}"
] |
(non-PHPdoc)
@see \TheTwelve\Foursquare.HttpClient::get()
@param string $uri
@param array $params
@return string|null|boolean
|
[
"(",
"non",
"-",
"PHPdoc",
")",
"@see",
"\\",
"TheTwelve",
"\\",
"Foursquare",
".",
"HttpClient",
"::",
"get",
"()"
] |
train
|
https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/HttpClient/ZF1HttpClient.php#L23-L27
|
chriswoodford/foursquare-php
|
lib/TheTwelve/Foursquare/HttpClient/ZF1HttpClient.php
|
Zend1HttpClient.post
|
public function post( $uri, array $params = array() )
{
$this->_client->setMethod('POST');
return $this->_request($uri, $params);
}
|
php
|
public function post( $uri, array $params = array() )
{
$this->_client->setMethod('POST');
return $this->_request($uri, $params);
}
|
[
"public",
"function",
"post",
"(",
"$",
"uri",
",",
"array",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"_client",
"->",
"setMethod",
"(",
"'POST'",
")",
";",
"return",
"$",
"this",
"->",
"_request",
"(",
"$",
"uri",
",",
"$",
"params",
")",
";",
"}"
] |
(non-PHPdoc)
@see TheTwelve\Foursquare.HttpClient::post()
@param string $uri
@param array $params
@return string|null|boolean
|
[
"(",
"non",
"-",
"PHPdoc",
")",
"@see",
"TheTwelve",
"\\",
"Foursquare",
".",
"HttpClient",
"::",
"post",
"()"
] |
train
|
https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/HttpClient/ZF1HttpClient.php#L37-L41
|
chriswoodford/foursquare-php
|
lib/TheTwelve/Foursquare/HttpClient/ZF1HttpClient.php
|
Zend1HttpClient._request
|
protected function _request( $uri, array $params = array() )
{
$this->_client->setUri($uri);
$this->_client->setParameterGet($params);
try {
$response = $this->_client->request();
} catch (Exception $e) {
return null;
}
if ( $response->getStatus() != 200 ) {
return false;
}
return $response->getBody();
}
|
php
|
protected function _request( $uri, array $params = array() )
{
$this->_client->setUri($uri);
$this->_client->setParameterGet($params);
try {
$response = $this->_client->request();
} catch (Exception $e) {
return null;
}
if ( $response->getStatus() != 200 ) {
return false;
}
return $response->getBody();
}
|
[
"protected",
"function",
"_request",
"(",
"$",
"uri",
",",
"array",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"_client",
"->",
"setUri",
"(",
"$",
"uri",
")",
";",
"$",
"this",
"->",
"_client",
"->",
"setParameterGet",
"(",
"$",
"params",
")",
";",
"try",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"_client",
"->",
"request",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"$",
"response",
"->",
"getStatus",
"(",
")",
"!=",
"200",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"response",
"->",
"getBody",
"(",
")",
";",
"}"
] |
Process request
@param string $uri
@param array $params
@return string|null|boolean
|
[
"Process",
"request"
] |
train
|
https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/HttpClient/ZF1HttpClient.php#L50-L66
|
ua1-labs/firebug
|
Fire/Bug.php
|
Bug.addPanel
|
public function addPanel(Panel $panel)
{
$id = $panel->getId();
if (!empty($this->_panels[$id])) {
throw new BugException('[FireBug] No panels exist with ID "' . $id . '".');
}
$this->_panels[$id] = $panel;
}
|
php
|
public function addPanel(Panel $panel)
{
$id = $panel->getId();
if (!empty($this->_panels[$id])) {
throw new BugException('[FireBug] No panels exist with ID "' . $id . '".');
}
$this->_panels[$id] = $panel;
}
|
[
"public",
"function",
"addPanel",
"(",
"Panel",
"$",
"panel",
")",
"{",
"$",
"id",
"=",
"$",
"panel",
"->",
"getId",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"_panels",
"[",
"$",
"id",
"]",
")",
")",
"{",
"throw",
"new",
"BugException",
"(",
"'[FireBug] No panels exist with ID \"'",
".",
"$",
"id",
".",
"'\".'",
")",
";",
"}",
"$",
"this",
"->",
"_panels",
"[",
"$",
"id",
"]",
"=",
"$",
"panel",
";",
"}"
] |
Adds a Fire\Bug\Panel object to the the array of panels.
@param \Fire\Bug\Panel $panel The panel you are adding to FireBug
@return void
|
[
"Adds",
"a",
"Fire",
"\\",
"Bug",
"\\",
"Panel",
"object",
"to",
"the",
"the",
"array",
"of",
"panels",
"."
] |
train
|
https://github.com/ua1-labs/firebug/blob/70a45b2c0bbf64978641eb07e5f3cddfc1951162/Fire/Bug.php#L113-L120
|
ua1-labs/firebug
|
Fire/Bug.php
|
Bug.timer
|
public function timer($start = null)
{
if ($start) {
$end = microtime(true);
return round(($end - $start) * 1000, 4);
} else {
return microtime(true);
}
}
|
php
|
public function timer($start = null)
{
if ($start) {
$end = microtime(true);
return round(($end - $start) * 1000, 4);
} else {
return microtime(true);
}
}
|
[
"public",
"function",
"timer",
"(",
"$",
"start",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"start",
")",
"{",
"$",
"end",
"=",
"microtime",
"(",
"true",
")",
";",
"return",
"round",
"(",
"(",
"$",
"end",
"-",
"$",
"start",
")",
"*",
"1000",
",",
"4",
")",
";",
"}",
"else",
"{",
"return",
"microtime",
"(",
"true",
")",
";",
"}",
"}"
] |
Method used to measure the amount of time that passed in milliseconds.
If you pass in a $start time, then you will be returned time length from
the start time. If you don't pass anything in, a start time will be returned.
@param float|null $start The start time.
@return float
|
[
"Method",
"used",
"to",
"measure",
"the",
"amount",
"of",
"time",
"that",
"passed",
"in",
"milliseconds",
".",
"If",
"you",
"pass",
"in",
"a",
"$start",
"time",
"then",
"you",
"will",
"be",
"returned",
"time",
"length",
"from",
"the",
"start",
"time",
".",
"If",
"you",
"don",
"t",
"pass",
"anything",
"in",
"a",
"start",
"time",
"will",
"be",
"returned",
"."
] |
train
|
https://github.com/ua1-labs/firebug/blob/70a45b2c0bbf64978641eb07e5f3cddfc1951162/Fire/Bug.php#L148-L156
|
ua1-labs/firebug
|
Fire/Bug.php
|
Bug.render
|
public function render()
{
if ($this->_enabled) {
if (php_sapi_name() === 'cli') {
echo 'FireBug: ' . $this->getLoadTime() . ' milliseconds' . "\n";
} else {
ob_start();
include $this->_template;
$debugPanel = ob_get_contents();
ob_end_clean();
return $debugPanel;
}
}
}
|
php
|
public function render()
{
if ($this->_enabled) {
if (php_sapi_name() === 'cli') {
echo 'FireBug: ' . $this->getLoadTime() . ' milliseconds' . "\n";
} else {
ob_start();
include $this->_template;
$debugPanel = ob_get_contents();
ob_end_clean();
return $debugPanel;
}
}
}
|
[
"public",
"function",
"render",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_enabled",
")",
"{",
"if",
"(",
"php_sapi_name",
"(",
")",
"===",
"'cli'",
")",
"{",
"echo",
"'FireBug: '",
".",
"$",
"this",
"->",
"getLoadTime",
"(",
")",
".",
"' milliseconds'",
".",
"\"\\n\"",
";",
"}",
"else",
"{",
"ob_start",
"(",
")",
";",
"include",
"$",
"this",
"->",
"_template",
";",
"$",
"debugPanel",
"=",
"ob_get_contents",
"(",
")",
";",
"ob_end_clean",
"(",
")",
";",
"return",
"$",
"debugPanel",
";",
"}",
"}",
"}"
] |
Method used to render FireBug.
@return void
|
[
"Method",
"used",
"to",
"render",
"FireBug",
"."
] |
train
|
https://github.com/ua1-labs/firebug/blob/70a45b2c0bbf64978641eb07e5f3cddfc1951162/Fire/Bug.php#L174-L188
|
sulu/SuluSalesShippingBundle
|
src/Sulu/Bundle/Sales/CoreBundle/Widgets/SimpleContact.php
|
SimpleContact.getData
|
public function getData($options)
{
if (!empty($options) &&
array_key_exists('contact', $options) &&
!empty($options['contact'])
) {
$id = $options['contact'];
$contact = $this->em->getRepository(
$this->contactEntityName
)->find($id);
if (!$contact) {
throw new WidgetEntityNotFoundException(
'Entity ' . $this->contactEntityName . ' with id ' . $id . ' not found!',
$this->widgetName,
$id
);
}
return $this->parseMainContact($contact);
} else {
throw new WidgetParameterException(
'Required parameter account not found or empty!',
$this->widgetName,
'account'
);
}
}
|
php
|
public function getData($options)
{
if (!empty($options) &&
array_key_exists('contact', $options) &&
!empty($options['contact'])
) {
$id = $options['contact'];
$contact = $this->em->getRepository(
$this->contactEntityName
)->find($id);
if (!$contact) {
throw new WidgetEntityNotFoundException(
'Entity ' . $this->contactEntityName . ' with id ' . $id . ' not found!',
$this->widgetName,
$id
);
}
return $this->parseMainContact($contact);
} else {
throw new WidgetParameterException(
'Required parameter account not found or empty!',
$this->widgetName,
'account'
);
}
}
|
[
"public",
"function",
"getData",
"(",
"$",
"options",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"options",
")",
"&&",
"array_key_exists",
"(",
"'contact'",
",",
"$",
"options",
")",
"&&",
"!",
"empty",
"(",
"$",
"options",
"[",
"'contact'",
"]",
")",
")",
"{",
"$",
"id",
"=",
"$",
"options",
"[",
"'contact'",
"]",
";",
"$",
"contact",
"=",
"$",
"this",
"->",
"em",
"->",
"getRepository",
"(",
"$",
"this",
"->",
"contactEntityName",
")",
"->",
"find",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"$",
"contact",
")",
"{",
"throw",
"new",
"WidgetEntityNotFoundException",
"(",
"'Entity '",
".",
"$",
"this",
"->",
"contactEntityName",
".",
"' with id '",
".",
"$",
"id",
".",
"' not found!'",
",",
"$",
"this",
"->",
"widgetName",
",",
"$",
"id",
")",
";",
"}",
"return",
"$",
"this",
"->",
"parseMainContact",
"(",
"$",
"contact",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"WidgetParameterException",
"(",
"'Required parameter account not found or empty!'",
",",
"$",
"this",
"->",
"widgetName",
",",
"'account'",
")",
";",
"}",
"}"
] |
returns data to render template
@param array $options
@throws WidgetException
@return array
|
[
"returns",
"data",
"to",
"render",
"template"
] |
train
|
https://github.com/sulu/SuluSalesShippingBundle/blob/0d39de262d58579e5679db99a77dbf717d600b5e/src/Sulu/Bundle/Sales/CoreBundle/Widgets/SimpleContact.php#L65-L91
|
comelyio/comely
|
src/Comely/IO/DependencyInjection/DependencyInjectionContainer.php
|
DependencyInjectionContainer.add
|
public function add(string $key, $object)
{
$key = self::ProcessKey(__METHOD__, $key);
$objectType = gettype($object);
switch ($objectType) {
case "object":
$this->repository->push($object, $key);
return true;
case "string":
return $this->service($key)->class($object);
default:
throw new DependencyInjectionException(
sprintf('Cannot store "%s" in Dependency Injection container', $objectType)
);
}
}
|
php
|
public function add(string $key, $object)
{
$key = self::ProcessKey(__METHOD__, $key);
$objectType = gettype($object);
switch ($objectType) {
case "object":
$this->repository->push($object, $key);
return true;
case "string":
return $this->service($key)->class($object);
default:
throw new DependencyInjectionException(
sprintf('Cannot store "%s" in Dependency Injection container', $objectType)
);
}
}
|
[
"public",
"function",
"add",
"(",
"string",
"$",
"key",
",",
"$",
"object",
")",
"{",
"$",
"key",
"=",
"self",
"::",
"ProcessKey",
"(",
"__METHOD__",
",",
"$",
"key",
")",
";",
"$",
"objectType",
"=",
"gettype",
"(",
"$",
"object",
")",
";",
"switch",
"(",
"$",
"objectType",
")",
"{",
"case",
"\"object\"",
":",
"$",
"this",
"->",
"repository",
"->",
"push",
"(",
"$",
"object",
",",
"$",
"key",
")",
";",
"return",
"true",
";",
"case",
"\"string\"",
":",
"return",
"$",
"this",
"->",
"service",
"(",
"$",
"key",
")",
"->",
"class",
"(",
"$",
"object",
")",
";",
"default",
":",
"throw",
"new",
"DependencyInjectionException",
"(",
"sprintf",
"(",
"'Cannot store \"%s\" in Dependency Injection container'",
",",
"$",
"objectType",
")",
")",
";",
"}",
"}"
] |
Store an instance or add new server
If second argument is an instance, it will be stored as-is.
If second argument is a class name (string), it will be added as service
and instance to Service will be returned
@param string $key
@param $object
@return Service|bool
@throws DependencyInjectionException
@throws Exception\RepositoryException
@throws Exception\ServicesException
|
[
"Store",
"an",
"instance",
"or",
"add",
"new",
"server"
] |
train
|
https://github.com/comelyio/comely/blob/561ea7aef36fea347a1a79d3ee5597d4057ddf82/src/Comely/IO/DependencyInjection/DependencyInjectionContainer.php#L75-L90
|
nicoSWD/put.io-api-v2
|
src/PutIO/Engines/HTTP/CurlEngine.php
|
CurlEngine.request
|
public function request(
$method,
$url,
array $params = [],
$outFile = '',
$returnBool = \false,
$arrayKey = '',
$verifyPeer = \true
) {
$this->verifyPeer = $verifyPeer;
list($url, $options) = $this->configureRequestOptions($url, $method, $params, $outFile);
$ch = curl_init($url);
curl_setopt_array($ch, $options);
$response = curl_exec($ch);
$this->handleResponse(curl_errno($ch), curl_error($ch), curl_getinfo($ch, CURLINFO_HTTP_CODE));
return $this->getResponse($response, $returnBool, $arrayKey);
}
|
php
|
public function request(
$method,
$url,
array $params = [],
$outFile = '',
$returnBool = \false,
$arrayKey = '',
$verifyPeer = \true
) {
$this->verifyPeer = $verifyPeer;
list($url, $options) = $this->configureRequestOptions($url, $method, $params, $outFile);
$ch = curl_init($url);
curl_setopt_array($ch, $options);
$response = curl_exec($ch);
$this->handleResponse(curl_errno($ch), curl_error($ch), curl_getinfo($ch, CURLINFO_HTTP_CODE));
return $this->getResponse($response, $returnBool, $arrayKey);
}
|
[
"public",
"function",
"request",
"(",
"$",
"method",
",",
"$",
"url",
",",
"array",
"$",
"params",
"=",
"[",
"]",
",",
"$",
"outFile",
"=",
"''",
",",
"$",
"returnBool",
"=",
"\\",
"false",
",",
"$",
"arrayKey",
"=",
"''",
",",
"$",
"verifyPeer",
"=",
"\\",
"true",
")",
"{",
"$",
"this",
"->",
"verifyPeer",
"=",
"$",
"verifyPeer",
";",
"list",
"(",
"$",
"url",
",",
"$",
"options",
")",
"=",
"$",
"this",
"->",
"configureRequestOptions",
"(",
"$",
"url",
",",
"$",
"method",
",",
"$",
"params",
",",
"$",
"outFile",
")",
";",
"$",
"ch",
"=",
"curl_init",
"(",
"$",
"url",
")",
";",
"curl_setopt_array",
"(",
"$",
"ch",
",",
"$",
"options",
")",
";",
"$",
"response",
"=",
"curl_exec",
"(",
"$",
"ch",
")",
";",
"$",
"this",
"->",
"handleResponse",
"(",
"curl_errno",
"(",
"$",
"ch",
")",
",",
"curl_error",
"(",
"$",
"ch",
")",
",",
"curl_getinfo",
"(",
"$",
"ch",
",",
"CURLINFO_HTTP_CODE",
")",
")",
";",
"return",
"$",
"this",
"->",
"getResponse",
"(",
"$",
"response",
",",
"$",
"returnBool",
",",
"$",
"arrayKey",
")",
";",
"}"
] |
Makes an HTTP request to put.io's API and returns the response.
@param string $method
@param string $url
@param array $params
@param string $outFile
@param bool $returnBool
@param string $arrayKey
@param bool $verifyPeer
@return array|bool
@throws LocalStorageException
@throws RemoteConnectionException
|
[
"Makes",
"an",
"HTTP",
"request",
"to",
"put",
".",
"io",
"s",
"API",
"and",
"returns",
"the",
"response",
"."
] |
train
|
https://github.com/nicoSWD/put.io-api-v2/blob/d91bedd91ea75793512a921bfd9aa83e86a6f0a7/src/PutIO/Engines/HTTP/CurlEngine.php#L68-L86
|
bocharsky-bw/FileNamingResolver
|
src/NamingStrategy/ContentHashNamingStrategy.php
|
ContentHashNamingStrategy.provideName
|
public function provideName(FileInfo $srcFileInfo)
{
if (!$srcFileInfo->isFile()) {
throw new \InvalidArgumentException(sprintf(
'The source file does not exist on "%s" specified path.',
$srcFileInfo->toString()
));
}
$hash = hash_file($this->algorithm, $srcFileInfo->toString());
$dstFileInfo = $this->provideNameByHash($srcFileInfo, $hash);
return $dstFileInfo;
}
|
php
|
public function provideName(FileInfo $srcFileInfo)
{
if (!$srcFileInfo->isFile()) {
throw new \InvalidArgumentException(sprintf(
'The source file does not exist on "%s" specified path.',
$srcFileInfo->toString()
));
}
$hash = hash_file($this->algorithm, $srcFileInfo->toString());
$dstFileInfo = $this->provideNameByHash($srcFileInfo, $hash);
return $dstFileInfo;
}
|
[
"public",
"function",
"provideName",
"(",
"FileInfo",
"$",
"srcFileInfo",
")",
"{",
"if",
"(",
"!",
"$",
"srcFileInfo",
"->",
"isFile",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The source file does not exist on \"%s\" specified path.'",
",",
"$",
"srcFileInfo",
"->",
"toString",
"(",
")",
")",
")",
";",
"}",
"$",
"hash",
"=",
"hash_file",
"(",
"$",
"this",
"->",
"algorithm",
",",
"$",
"srcFileInfo",
"->",
"toString",
"(",
")",
")",
";",
"$",
"dstFileInfo",
"=",
"$",
"this",
"->",
"provideNameByHash",
"(",
"$",
"srcFileInfo",
",",
"$",
"hash",
")",
";",
"return",
"$",
"dstFileInfo",
";",
"}"
] |
{@inheritdoc}
@throws \InvalidArgumentException If source file does not exist
|
[
"{",
"@inheritdoc",
"}"
] |
train
|
https://github.com/bocharsky-bw/FileNamingResolver/blob/0a0fe86fee0e7acf1ab43a84c1abd51954ce2fbe/src/NamingStrategy/ContentHashNamingStrategy.php#L17-L30
|
nicoSWD/put.io-api-v2
|
src/PutIO/Engines/HTTP/NativeEngine.php
|
NativeEngine.request
|
public function request(
$method,
$url,
array $params = [],
$outFile = '',
$returnBool = \false,
$arrayKey = '',
$verifyPeer = \true
) {
list($url, $contextOptions) = $this->configureRequestOptions($url, $method, $params, $verifyPeer);
$fp = @fopen($url, 'rb', \false, stream_context_create($contextOptions));
$headers = stream_get_meta_data($fp)['wrapper_data'];
return $this->handleRequest($fp, $headers, $outFile, $returnBool, $arrayKey);
}
|
php
|
public function request(
$method,
$url,
array $params = [],
$outFile = '',
$returnBool = \false,
$arrayKey = '',
$verifyPeer = \true
) {
list($url, $contextOptions) = $this->configureRequestOptions($url, $method, $params, $verifyPeer);
$fp = @fopen($url, 'rb', \false, stream_context_create($contextOptions));
$headers = stream_get_meta_data($fp)['wrapper_data'];
return $this->handleRequest($fp, $headers, $outFile, $returnBool, $arrayKey);
}
|
[
"public",
"function",
"request",
"(",
"$",
"method",
",",
"$",
"url",
",",
"array",
"$",
"params",
"=",
"[",
"]",
",",
"$",
"outFile",
"=",
"''",
",",
"$",
"returnBool",
"=",
"\\",
"false",
",",
"$",
"arrayKey",
"=",
"''",
",",
"$",
"verifyPeer",
"=",
"\\",
"true",
")",
"{",
"list",
"(",
"$",
"url",
",",
"$",
"contextOptions",
")",
"=",
"$",
"this",
"->",
"configureRequestOptions",
"(",
"$",
"url",
",",
"$",
"method",
",",
"$",
"params",
",",
"$",
"verifyPeer",
")",
";",
"$",
"fp",
"=",
"@",
"fopen",
"(",
"$",
"url",
",",
"'rb'",
",",
"\\",
"false",
",",
"stream_context_create",
"(",
"$",
"contextOptions",
")",
")",
";",
"$",
"headers",
"=",
"stream_get_meta_data",
"(",
"$",
"fp",
")",
"[",
"'wrapper_data'",
"]",
";",
"return",
"$",
"this",
"->",
"handleRequest",
"(",
"$",
"fp",
",",
"$",
"headers",
",",
"$",
"outFile",
",",
"$",
"returnBool",
",",
"$",
"arrayKey",
")",
";",
"}"
] |
Makes an HTTP request to put.io's API and returns the response.
Relies on native PHP functions.
NOTE!! Due to restrictions, files must be loaded into the memory when
uploading. I don't recommend uploading large files using native
functions. Only use this if you absolutely must! Otherwise, the cURL
engine is much better!
Downloading is no issue as long as you're saving the file somewhere on
the file system rather than the memory. Set $outFile and you're all set!
Returns false if a file was not found.
@param string $method HTTP request method. Only POST and GET are
supported.
@param string $url Remote path to API module.
@param array $params Variables to be sent.
@param string $outFile If $outFile is set, the response will be
written to this file instead of StdOut.
@param bool $returnBool
@param string $arrayKey Will return all data on a specific array key
of the response.
@param bool $verifyPeer If true, will use proper SSL peer/host
verification.
@return mixed
@throws \PutIO\Exceptions\LocalStorageException
@throws \PutIO\Exceptions\RemoteConnectionException
|
[
"Makes",
"an",
"HTTP",
"request",
"to",
"put",
".",
"io",
"s",
"API",
"and",
"returns",
"the",
"response",
".",
"Relies",
"on",
"native",
"PHP",
"functions",
"."
] |
train
|
https://github.com/nicoSWD/put.io-api-v2/blob/d91bedd91ea75793512a921bfd9aa83e86a6f0a7/src/PutIO/Engines/HTTP/NativeEngine.php#L57-L72
|
codeburnerframework/router
|
src/Matcher.php
|
Matcher.match
|
public function match($httpMethod, $path)
{
$path = $this->parsePath($path);
if (($route = $this->collector->findStaticRoute($httpMethod, $path)) ||
($route = $this->matchDynamicRoute($httpMethod, $path))) {
$route->setMatcher($this);
return $route;
}
$this->matchSimilarRoute($httpMethod, $path);
}
|
php
|
public function match($httpMethod, $path)
{
$path = $this->parsePath($path);
if (($route = $this->collector->findStaticRoute($httpMethod, $path)) ||
($route = $this->matchDynamicRoute($httpMethod, $path))) {
$route->setMatcher($this);
return $route;
}
$this->matchSimilarRoute($httpMethod, $path);
}
|
[
"public",
"function",
"match",
"(",
"$",
"httpMethod",
",",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"parsePath",
"(",
"$",
"path",
")",
";",
"if",
"(",
"(",
"$",
"route",
"=",
"$",
"this",
"->",
"collector",
"->",
"findStaticRoute",
"(",
"$",
"httpMethod",
",",
"$",
"path",
")",
")",
"||",
"(",
"$",
"route",
"=",
"$",
"this",
"->",
"matchDynamicRoute",
"(",
"$",
"httpMethod",
",",
"$",
"path",
")",
")",
")",
"{",
"$",
"route",
"->",
"setMatcher",
"(",
"$",
"this",
")",
";",
"return",
"$",
"route",
";",
"}",
"$",
"this",
"->",
"matchSimilarRoute",
"(",
"$",
"httpMethod",
",",
"$",
"path",
")",
";",
"}"
] |
Find a route that matches the given arguments.
@param string $httpMethod
@param string $path
@throws NotFoundException
@throws MethodNotAllowedException
@return Route
|
[
"Find",
"a",
"route",
"that",
"matches",
"the",
"given",
"arguments",
"."
] |
train
|
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Matcher.php#L71-L83
|
codeburnerframework/router
|
src/Matcher.php
|
Matcher.matchDynamicRoute
|
protected function matchDynamicRoute($httpMethod, $path)
{
if ($routes = $this->collector->findDynamicRoutes($httpMethod, $path)) {
// cache the parser reference
$this->parser = $this->collector->getParser();
// chunk routes for smaller regex groups using the Sturges' Formula
foreach (array_chunk($routes, round(1 + 3.3 * log(count($routes))), true) as $chunk) {
array_map([$this, "buildRoute"], $chunk);
list($pattern, $map) = $this->buildGroup($chunk);
if (!preg_match($pattern, $path, $matches)) {
continue;
}
/** @var Route $route */
$route = $map[count($matches)];
unset($matches[0]);
$route->setParams(array_combine($route->getParams(), array_filter($matches)));
return $route;
}
}
return false;
}
|
php
|
protected function matchDynamicRoute($httpMethod, $path)
{
if ($routes = $this->collector->findDynamicRoutes($httpMethod, $path)) {
// cache the parser reference
$this->parser = $this->collector->getParser();
// chunk routes for smaller regex groups using the Sturges' Formula
foreach (array_chunk($routes, round(1 + 3.3 * log(count($routes))), true) as $chunk) {
array_map([$this, "buildRoute"], $chunk);
list($pattern, $map) = $this->buildGroup($chunk);
if (!preg_match($pattern, $path, $matches)) {
continue;
}
/** @var Route $route */
$route = $map[count($matches)];
unset($matches[0]);
$route->setParams(array_combine($route->getParams(), array_filter($matches)));
return $route;
}
}
return false;
}
|
[
"protected",
"function",
"matchDynamicRoute",
"(",
"$",
"httpMethod",
",",
"$",
"path",
")",
"{",
"if",
"(",
"$",
"routes",
"=",
"$",
"this",
"->",
"collector",
"->",
"findDynamicRoutes",
"(",
"$",
"httpMethod",
",",
"$",
"path",
")",
")",
"{",
"// cache the parser reference",
"$",
"this",
"->",
"parser",
"=",
"$",
"this",
"->",
"collector",
"->",
"getParser",
"(",
")",
";",
"// chunk routes for smaller regex groups using the Sturges' Formula",
"foreach",
"(",
"array_chunk",
"(",
"$",
"routes",
",",
"round",
"(",
"1",
"+",
"3.3",
"*",
"log",
"(",
"count",
"(",
"$",
"routes",
")",
")",
")",
",",
"true",
")",
"as",
"$",
"chunk",
")",
"{",
"array_map",
"(",
"[",
"$",
"this",
",",
"\"buildRoute\"",
"]",
",",
"$",
"chunk",
")",
";",
"list",
"(",
"$",
"pattern",
",",
"$",
"map",
")",
"=",
"$",
"this",
"->",
"buildGroup",
"(",
"$",
"chunk",
")",
";",
"if",
"(",
"!",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"path",
",",
"$",
"matches",
")",
")",
"{",
"continue",
";",
"}",
"/** @var Route $route */",
"$",
"route",
"=",
"$",
"map",
"[",
"count",
"(",
"$",
"matches",
")",
"]",
";",
"unset",
"(",
"$",
"matches",
"[",
"0",
"]",
")",
";",
"$",
"route",
"->",
"setParams",
"(",
"array_combine",
"(",
"$",
"route",
"->",
"getParams",
"(",
")",
",",
"array_filter",
"(",
"$",
"matches",
")",
")",
")",
";",
"return",
"$",
"route",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Find and return the request dynamic route based on the compiled data and Path.
@param string $httpMethod
@param string $path
@return Route|false If the request match an array with the action and parameters will
be returned otherwise a false will.
|
[
"Find",
"and",
"return",
"the",
"request",
"dynamic",
"route",
"based",
"on",
"the",
"compiled",
"data",
"and",
"Path",
"."
] |
train
|
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Matcher.php#L95-L120
|
codeburnerframework/router
|
src/Matcher.php
|
Matcher.buildRoute
|
protected function buildRoute(Route $route)
{
if ($route->getBlock()) {
return $route;
}
list($pattern, $params) = $this->parsePlaceholders($route->getPattern());
return $route->setPatternWithoutReset($pattern)->setParams($params)->setBlock(true);
}
|
php
|
protected function buildRoute(Route $route)
{
if ($route->getBlock()) {
return $route;
}
list($pattern, $params) = $this->parsePlaceholders($route->getPattern());
return $route->setPatternWithoutReset($pattern)->setParams($params)->setBlock(true);
}
|
[
"protected",
"function",
"buildRoute",
"(",
"Route",
"$",
"route",
")",
"{",
"if",
"(",
"$",
"route",
"->",
"getBlock",
"(",
")",
")",
"{",
"return",
"$",
"route",
";",
"}",
"list",
"(",
"$",
"pattern",
",",
"$",
"params",
")",
"=",
"$",
"this",
"->",
"parsePlaceholders",
"(",
"$",
"route",
"->",
"getPattern",
"(",
")",
")",
";",
"return",
"$",
"route",
"->",
"setPatternWithoutReset",
"(",
"$",
"pattern",
")",
"->",
"setParams",
"(",
"$",
"params",
")",
"->",
"setBlock",
"(",
"true",
")",
";",
"}"
] |
Parse the dynamic segments of the pattern and replace then for
corresponding regex.
@param Route $route
@return Route
|
[
"Parse",
"the",
"dynamic",
"segments",
"of",
"the",
"pattern",
"and",
"replace",
"then",
"for",
"corresponding",
"regex",
"."
] |
train
|
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Matcher.php#L130-L138
|
codeburnerframework/router
|
src/Matcher.php
|
Matcher.buildGroup
|
protected function buildGroup(array $routes)
{
$groupCount = (int) $map = $regex = [];
foreach ($routes as $route) {
$params = $route->getParams();
$paramsCount = count($params);
$groupCount = max($groupCount, $paramsCount) + 1;
$regex[] = $route->getPattern() . str_repeat("()", $groupCount - $paramsCount - 1);
$map[$groupCount] = $route;
}
return ["~^(?|" . implode("|", $regex) . ")$~", $map];
}
|
php
|
protected function buildGroup(array $routes)
{
$groupCount = (int) $map = $regex = [];
foreach ($routes as $route) {
$params = $route->getParams();
$paramsCount = count($params);
$groupCount = max($groupCount, $paramsCount) + 1;
$regex[] = $route->getPattern() . str_repeat("()", $groupCount - $paramsCount - 1);
$map[$groupCount] = $route;
}
return ["~^(?|" . implode("|", $regex) . ")$~", $map];
}
|
[
"protected",
"function",
"buildGroup",
"(",
"array",
"$",
"routes",
")",
"{",
"$",
"groupCount",
"=",
"(",
"int",
")",
"$",
"map",
"=",
"$",
"regex",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"routes",
"as",
"$",
"route",
")",
"{",
"$",
"params",
"=",
"$",
"route",
"->",
"getParams",
"(",
")",
";",
"$",
"paramsCount",
"=",
"count",
"(",
"$",
"params",
")",
";",
"$",
"groupCount",
"=",
"max",
"(",
"$",
"groupCount",
",",
"$",
"paramsCount",
")",
"+",
"1",
";",
"$",
"regex",
"[",
"]",
"=",
"$",
"route",
"->",
"getPattern",
"(",
")",
".",
"str_repeat",
"(",
"\"()\"",
",",
"$",
"groupCount",
"-",
"$",
"paramsCount",
"-",
"1",
")",
";",
"$",
"map",
"[",
"$",
"groupCount",
"]",
"=",
"$",
"route",
";",
"}",
"return",
"[",
"\"~^(?|\"",
".",
"implode",
"(",
"\"|\"",
",",
"$",
"regex",
")",
".",
"\")$~\"",
",",
"$",
"map",
"]",
";",
"}"
] |
Group several dynamic routes patterns into one big regex and maps
the routes to the pattern positions in the big regex.
@param Route[] $routes
@return array
|
[
"Group",
"several",
"dynamic",
"routes",
"patterns",
"into",
"one",
"big",
"regex",
"and",
"maps",
"the",
"routes",
"to",
"the",
"pattern",
"positions",
"in",
"the",
"big",
"regex",
"."
] |
train
|
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Matcher.php#L148-L161
|
codeburnerframework/router
|
src/Matcher.php
|
Matcher.parsePlaceholders
|
protected function parsePlaceholders($pattern)
{
$params = [];
$parser = $this->parser;
preg_match_all("~" . $parser::DYNAMIC_REGEX . "~x", $pattern, $matches, PREG_SET_ORDER);
foreach ((array) $matches as $key => $match) {
$pattern = str_replace($match[0], isset($match[2]) ? "({$match[2]})" : "([^/]+)", $pattern);
$params[$key] = $match[1];
}
return [$pattern, $params];
}
|
php
|
protected function parsePlaceholders($pattern)
{
$params = [];
$parser = $this->parser;
preg_match_all("~" . $parser::DYNAMIC_REGEX . "~x", $pattern, $matches, PREG_SET_ORDER);
foreach ((array) $matches as $key => $match) {
$pattern = str_replace($match[0], isset($match[2]) ? "({$match[2]})" : "([^/]+)", $pattern);
$params[$key] = $match[1];
}
return [$pattern, $params];
}
|
[
"protected",
"function",
"parsePlaceholders",
"(",
"$",
"pattern",
")",
"{",
"$",
"params",
"=",
"[",
"]",
";",
"$",
"parser",
"=",
"$",
"this",
"->",
"parser",
";",
"preg_match_all",
"(",
"\"~\"",
".",
"$",
"parser",
"::",
"DYNAMIC_REGEX",
".",
"\"~x\"",
",",
"$",
"pattern",
",",
"$",
"matches",
",",
"PREG_SET_ORDER",
")",
";",
"foreach",
"(",
"(",
"array",
")",
"$",
"matches",
"as",
"$",
"key",
"=>",
"$",
"match",
")",
"{",
"$",
"pattern",
"=",
"str_replace",
"(",
"$",
"match",
"[",
"0",
"]",
",",
"isset",
"(",
"$",
"match",
"[",
"2",
"]",
")",
"?",
"\"({$match[2]})\"",
":",
"\"([^/]+)\"",
",",
"$",
"pattern",
")",
";",
"$",
"params",
"[",
"$",
"key",
"]",
"=",
"$",
"match",
"[",
"1",
"]",
";",
"}",
"return",
"[",
"$",
"pattern",
",",
"$",
"params",
"]",
";",
"}"
] |
Parse an route pattern seeking for parameters and build the route regex.
@param string $pattern
@return array 0 => new route regex, 1 => map of parameter names
|
[
"Parse",
"an",
"route",
"pattern",
"seeking",
"for",
"parameters",
"and",
"build",
"the",
"route",
"regex",
"."
] |
train
|
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Matcher.php#L170-L183
|
codeburnerframework/router
|
src/Matcher.php
|
Matcher.parsePath
|
protected function parsePath($path)
{
$path = parse_url(substr(strstr(";" . $path, ";" . $this->basepath), strlen(";" . $this->basepath)), PHP_URL_PATH);
if ($path === false) {
throw new Exception("Seriously malformed URL passed to route matcher.");
}
return $path;
}
|
php
|
protected function parsePath($path)
{
$path = parse_url(substr(strstr(";" . $path, ";" . $this->basepath), strlen(";" . $this->basepath)), PHP_URL_PATH);
if ($path === false) {
throw new Exception("Seriously malformed URL passed to route matcher.");
}
return $path;
}
|
[
"protected",
"function",
"parsePath",
"(",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"parse_url",
"(",
"substr",
"(",
"strstr",
"(",
"\";\"",
".",
"$",
"path",
",",
"\";\"",
".",
"$",
"this",
"->",
"basepath",
")",
",",
"strlen",
"(",
"\";\"",
".",
"$",
"this",
"->",
"basepath",
")",
")",
",",
"PHP_URL_PATH",
")",
";",
"if",
"(",
"$",
"path",
"===",
"false",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Seriously malformed URL passed to route matcher.\"",
")",
";",
"}",
"return",
"$",
"path",
";",
"}"
] |
Get only the path of a given url.
@param string $path The given URL
@throws Exception
@return string
|
[
"Get",
"only",
"the",
"path",
"of",
"a",
"given",
"url",
"."
] |
train
|
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Matcher.php#L194-L203
|
codeburnerframework/router
|
src/Matcher.php
|
Matcher.matchSimilarRoute
|
protected function matchSimilarRoute($httpMethod, $path)
{
$dm = [];
if (($sm = $this->checkStaticRouteInOtherMethods($httpMethod, $path))
|| ($dm = $this->checkDynamicRouteInOtherMethods($httpMethod, $path))) {
throw new MethodNotAllowedException($httpMethod, $path, array_merge((array) $sm, (array) $dm));
}
throw new NotFoundException;
}
|
php
|
protected function matchSimilarRoute($httpMethod, $path)
{
$dm = [];
if (($sm = $this->checkStaticRouteInOtherMethods($httpMethod, $path))
|| ($dm = $this->checkDynamicRouteInOtherMethods($httpMethod, $path))) {
throw new MethodNotAllowedException($httpMethod, $path, array_merge((array) $sm, (array) $dm));
}
throw new NotFoundException;
}
|
[
"protected",
"function",
"matchSimilarRoute",
"(",
"$",
"httpMethod",
",",
"$",
"path",
")",
"{",
"$",
"dm",
"=",
"[",
"]",
";",
"if",
"(",
"(",
"$",
"sm",
"=",
"$",
"this",
"->",
"checkStaticRouteInOtherMethods",
"(",
"$",
"httpMethod",
",",
"$",
"path",
")",
")",
"||",
"(",
"$",
"dm",
"=",
"$",
"this",
"->",
"checkDynamicRouteInOtherMethods",
"(",
"$",
"httpMethod",
",",
"$",
"path",
")",
")",
")",
"{",
"throw",
"new",
"MethodNotAllowedException",
"(",
"$",
"httpMethod",
",",
"$",
"path",
",",
"array_merge",
"(",
"(",
"array",
")",
"$",
"sm",
",",
"(",
"array",
")",
"$",
"dm",
")",
")",
";",
"}",
"throw",
"new",
"NotFoundException",
";",
"}"
] |
Generate an HTTP error request with method not allowed or not found.
@param string $httpMethod
@param string $path
@throws NotFoundException
@throws MethodNotAllowedException
|
[
"Generate",
"an",
"HTTP",
"error",
"request",
"with",
"method",
"not",
"allowed",
"or",
"not",
"found",
"."
] |
train
|
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Matcher.php#L215-L225
|
codeburnerframework/router
|
src/Matcher.php
|
Matcher.checkStaticRouteInOtherMethods
|
protected function checkStaticRouteInOtherMethods($targetHttpMethod, $path)
{
return array_filter($this->getHttpMethodsBut($targetHttpMethod), function ($httpMethod) use ($path) {
return (bool) $this->collector->findStaticRoute($httpMethod, $path);
});
}
|
php
|
protected function checkStaticRouteInOtherMethods($targetHttpMethod, $path)
{
return array_filter($this->getHttpMethodsBut($targetHttpMethod), function ($httpMethod) use ($path) {
return (bool) $this->collector->findStaticRoute($httpMethod, $path);
});
}
|
[
"protected",
"function",
"checkStaticRouteInOtherMethods",
"(",
"$",
"targetHttpMethod",
",",
"$",
"path",
")",
"{",
"return",
"array_filter",
"(",
"$",
"this",
"->",
"getHttpMethodsBut",
"(",
"$",
"targetHttpMethod",
")",
",",
"function",
"(",
"$",
"httpMethod",
")",
"use",
"(",
"$",
"path",
")",
"{",
"return",
"(",
"bool",
")",
"$",
"this",
"->",
"collector",
"->",
"findStaticRoute",
"(",
"$",
"httpMethod",
",",
"$",
"path",
")",
";",
"}",
")",
";",
"}"
] |
Verify if a static route match in another method than the requested.
@param string $targetHttpMethod The HTTP method that must not be checked
@param string $path The Path that must be matched.
@return array
|
[
"Verify",
"if",
"a",
"static",
"route",
"match",
"in",
"another",
"method",
"than",
"the",
"requested",
"."
] |
train
|
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Matcher.php#L236-L241
|
codeburnerframework/router
|
src/Matcher.php
|
Matcher.checkDynamicRouteInOtherMethods
|
protected function checkDynamicRouteInOtherMethods($targetHttpMethod, $path)
{
return array_filter($this->getHttpMethodsBut($targetHttpMethod), function ($httpMethod) use ($path) {
return (bool) $this->matchDynamicRoute($httpMethod, $path);
});
}
|
php
|
protected function checkDynamicRouteInOtherMethods($targetHttpMethod, $path)
{
return array_filter($this->getHttpMethodsBut($targetHttpMethod), function ($httpMethod) use ($path) {
return (bool) $this->matchDynamicRoute($httpMethod, $path);
});
}
|
[
"protected",
"function",
"checkDynamicRouteInOtherMethods",
"(",
"$",
"targetHttpMethod",
",",
"$",
"path",
")",
"{",
"return",
"array_filter",
"(",
"$",
"this",
"->",
"getHttpMethodsBut",
"(",
"$",
"targetHttpMethod",
")",
",",
"function",
"(",
"$",
"httpMethod",
")",
"use",
"(",
"$",
"path",
")",
"{",
"return",
"(",
"bool",
")",
"$",
"this",
"->",
"matchDynamicRoute",
"(",
"$",
"httpMethod",
",",
"$",
"path",
")",
";",
"}",
")",
";",
"}"
] |
Verify if a dynamic route match in another method than the requested.
@param string $targetHttpMethod The HTTP method that must not be checked
@param string $path The Path that must be matched.
@return array
|
[
"Verify",
"if",
"a",
"dynamic",
"route",
"match",
"in",
"another",
"method",
"than",
"the",
"requested",
"."
] |
train
|
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Matcher.php#L252-L257
|
gregorybesson/PlaygroundCore
|
src/Controller/Frontend/SwitchLocaleController.php
|
SwitchLocaleController.switchAction
|
public function switchAction()
{
$lang = $this->getEvent()->getRouteMatch()->getParam('lang');
$context = $this->getEvent()->getRouteMatch()->getParam('area');
$redirect = (!empty($this->getEvent()->getRouteMatch()->getParam('redirect')))? urldecode($this->getEvent()->getRouteMatch()->getParam('redirect')) : '/'.$lang;
$cookie = new \Zend\Http\Header\SetCookie('pg_locale_'.$context, $lang, time() + 60*60*24*365, '/');
$this->getResponse()->getHeaders()->addHeader($cookie);
return $this->redirect()->toUrl($redirect);
}
|
php
|
public function switchAction()
{
$lang = $this->getEvent()->getRouteMatch()->getParam('lang');
$context = $this->getEvent()->getRouteMatch()->getParam('area');
$redirect = (!empty($this->getEvent()->getRouteMatch()->getParam('redirect')))? urldecode($this->getEvent()->getRouteMatch()->getParam('redirect')) : '/'.$lang;
$cookie = new \Zend\Http\Header\SetCookie('pg_locale_'.$context, $lang, time() + 60*60*24*365, '/');
$this->getResponse()->getHeaders()->addHeader($cookie);
return $this->redirect()->toUrl($redirect);
}
|
[
"public",
"function",
"switchAction",
"(",
")",
"{",
"$",
"lang",
"=",
"$",
"this",
"->",
"getEvent",
"(",
")",
"->",
"getRouteMatch",
"(",
")",
"->",
"getParam",
"(",
"'lang'",
")",
";",
"$",
"context",
"=",
"$",
"this",
"->",
"getEvent",
"(",
")",
"->",
"getRouteMatch",
"(",
")",
"->",
"getParam",
"(",
"'area'",
")",
";",
"$",
"redirect",
"=",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"getEvent",
"(",
")",
"->",
"getRouteMatch",
"(",
")",
"->",
"getParam",
"(",
"'redirect'",
")",
")",
")",
"?",
"urldecode",
"(",
"$",
"this",
"->",
"getEvent",
"(",
")",
"->",
"getRouteMatch",
"(",
")",
"->",
"getParam",
"(",
"'redirect'",
")",
")",
":",
"'/'",
".",
"$",
"lang",
";",
"$",
"cookie",
"=",
"new",
"\\",
"Zend",
"\\",
"Http",
"\\",
"Header",
"\\",
"SetCookie",
"(",
"'pg_locale_'",
".",
"$",
"context",
",",
"$",
"lang",
",",
"time",
"(",
")",
"+",
"60",
"*",
"60",
"*",
"24",
"*",
"365",
",",
"'/'",
")",
";",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"getHeaders",
"(",
")",
"->",
"addHeader",
"(",
"$",
"cookie",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
")",
"->",
"toUrl",
"(",
"$",
"redirect",
")",
";",
"}"
] |
switchAction : permet de switcher de langue en fonction d'un context (back/front)
locale : locale pour switch
context : (back/front)
referer : retour à la page
@return Redirect $redirect redirect to referer
|
[
"switchAction",
":",
"permet",
"de",
"switcher",
"de",
"langue",
"en",
"fonction",
"d",
"un",
"context",
"(",
"back",
"/",
"front",
")",
"locale",
":",
"locale",
"pour",
"switch",
"context",
":",
"(",
"back",
"/",
"front",
")",
"referer",
":",
"retour",
"à",
"la",
"page"
] |
train
|
https://github.com/gregorybesson/PlaygroundCore/blob/f8dfa4c7660b54354933b3c28c0cf35304a649df/src/Controller/Frontend/SwitchLocaleController.php#L34-L44
|
okvpn/fixture-bundle
|
src/Tools/FixtureDatabaseChecker.php
|
FixtureDatabaseChecker.tablesExist
|
public static function tablesExist(Connection $connection, $tables)
{
$result = false;
if (!empty($tables)) {
try {
$connection->connect();
$result = $connection->getSchemaManager()->tablesExist($tables);
} catch (\PDOException $e) {
} catch (DBALException $e) {
}
}
return $result;
}
|
php
|
public static function tablesExist(Connection $connection, $tables)
{
$result = false;
if (!empty($tables)) {
try {
$connection->connect();
$result = $connection->getSchemaManager()->tablesExist($tables);
} catch (\PDOException $e) {
} catch (DBALException $e) {
}
}
return $result;
}
|
[
"public",
"static",
"function",
"tablesExist",
"(",
"Connection",
"$",
"connection",
",",
"$",
"tables",
")",
"{",
"$",
"result",
"=",
"false",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"tables",
")",
")",
"{",
"try",
"{",
"$",
"connection",
"->",
"connect",
"(",
")",
";",
"$",
"result",
"=",
"$",
"connection",
"->",
"getSchemaManager",
"(",
")",
"->",
"tablesExist",
"(",
"$",
"tables",
")",
";",
"}",
"catch",
"(",
"\\",
"PDOException",
"$",
"e",
")",
"{",
"}",
"catch",
"(",
"DBALException",
"$",
"e",
")",
"{",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
@param Connection $connection
@param string[]|string|null $tables
@return bool
@internal
|
[
"@param",
"Connection",
"$connection",
"@param",
"string",
"[]",
"|string|null",
"$tables"
] |
train
|
https://github.com/okvpn/fixture-bundle/blob/243b5e4dff9773e97fa447280e929c936a5d66ae/src/Tools/FixtureDatabaseChecker.php#L17-L30
|
JustBlackBird/jms-serializer-strict-json
|
src/Exception/TypeMismatchException.php
|
TypeMismatchException.fromValue
|
public static function fromValue(
$expected_type,
$actual_value,
DeserializationContext $context = null
) {
if (null !== $context && count($context->getCurrentPath()) > 0) {
$property = sprintf('property "%s" to be ', implode('.', $context->getCurrentPath()));
} else {
$property = '';
}
return new static(sprintf(
'Expected %s%s, but got %s: %s',
$property,
$expected_type,
gettype($actual_value),
json_encode($actual_value)
));
}
|
php
|
public static function fromValue(
$expected_type,
$actual_value,
DeserializationContext $context = null
) {
if (null !== $context && count($context->getCurrentPath()) > 0) {
$property = sprintf('property "%s" to be ', implode('.', $context->getCurrentPath()));
} else {
$property = '';
}
return new static(sprintf(
'Expected %s%s, but got %s: %s',
$property,
$expected_type,
gettype($actual_value),
json_encode($actual_value)
));
}
|
[
"public",
"static",
"function",
"fromValue",
"(",
"$",
"expected_type",
",",
"$",
"actual_value",
",",
"DeserializationContext",
"$",
"context",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"context",
"&&",
"count",
"(",
"$",
"context",
"->",
"getCurrentPath",
"(",
")",
")",
">",
"0",
")",
"{",
"$",
"property",
"=",
"sprintf",
"(",
"'property \"%s\" to be '",
",",
"implode",
"(",
"'.'",
",",
"$",
"context",
"->",
"getCurrentPath",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"$",
"property",
"=",
"''",
";",
"}",
"return",
"new",
"static",
"(",
"sprintf",
"(",
"'Expected %s%s, but got %s: %s'",
",",
"$",
"property",
",",
"$",
"expected_type",
",",
"gettype",
"(",
"$",
"actual_value",
")",
",",
"json_encode",
"(",
"$",
"actual_value",
")",
")",
")",
";",
"}"
] |
A handy method for building exception instance.
@param string $expected_type
@param mixed $actual_value
@param DeserializationContext|null $context
@return TypeMismatchException
|
[
"A",
"handy",
"method",
"for",
"building",
"exception",
"instance",
"."
] |
train
|
https://github.com/JustBlackBird/jms-serializer-strict-json/blob/db1d1473ccb0de32dfb12ec89c89e028a515d61e/src/Exception/TypeMismatchException.php#L33-L51
|
tequila/mongodb-php-lib
|
src/Traits/ExecuteCommandTrait.php
|
ExecuteCommandTrait.executeCommand
|
private function executeCommand(array $command, array $options)
{
return $this
->getCommandExecutor()
->executeCommand(
$this->manager,
$this->databaseName,
$command,
$options
);
}
|
php
|
private function executeCommand(array $command, array $options)
{
return $this
->getCommandExecutor()
->executeCommand(
$this->manager,
$this->databaseName,
$command,
$options
);
}
|
[
"private",
"function",
"executeCommand",
"(",
"array",
"$",
"command",
",",
"array",
"$",
"options",
")",
"{",
"return",
"$",
"this",
"->",
"getCommandExecutor",
"(",
")",
"->",
"executeCommand",
"(",
"$",
"this",
"->",
"manager",
",",
"$",
"this",
"->",
"databaseName",
",",
"$",
"command",
",",
"$",
"options",
")",
";",
"}"
] |
@param array $command
@param array $options
@return Cursor
|
[
"@param",
"array",
"$command",
"@param",
"array",
"$options"
] |
train
|
https://github.com/tequila/mongodb-php-lib/blob/49a25f45268df358f5ceb40a655d9a7ddc6db4f7/src/Traits/ExecuteCommandTrait.php#L15-L25
|
avto-dev/app-version-laravel
|
src/AppVersionServiceProvider.php
|
AppVersionServiceProvider.register
|
public function register()
{
$this->initializeConfigs();
$this->registerAppVersionManager();
$this->registerHelpers();
$this->registerBlade();
if ($this->app->runningInConsole()) {
$this->registerArtisanCommands();
}
}
|
php
|
public function register()
{
$this->initializeConfigs();
$this->registerAppVersionManager();
$this->registerHelpers();
$this->registerBlade();
if ($this->app->runningInConsole()) {
$this->registerArtisanCommands();
}
}
|
[
"public",
"function",
"register",
"(",
")",
"{",
"$",
"this",
"->",
"initializeConfigs",
"(",
")",
";",
"$",
"this",
"->",
"registerAppVersionManager",
"(",
")",
";",
"$",
"this",
"->",
"registerHelpers",
"(",
")",
";",
"$",
"this",
"->",
"registerBlade",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"app",
"->",
"runningInConsole",
"(",
")",
")",
"{",
"$",
"this",
"->",
"registerArtisanCommands",
"(",
")",
";",
"}",
"}"
] |
Register any application services.
@return void
|
[
"Register",
"any",
"application",
"services",
"."
] |
train
|
https://github.com/avto-dev/app-version-laravel/blob/5cbf9df5981cadd2d5148c49c834cc17fb903c3f/src/AppVersionServiceProvider.php#L44-L57
|
avto-dev/app-version-laravel
|
src/AppVersionServiceProvider.php
|
AppVersionServiceProvider.registerAppVersionManager
|
protected function registerAppVersionManager()
{
$this->app->singleton(AppVersionManager::class, function (Application $app) {
$config = (array) $app
->make('config')
->get(static::getConfigRootKeyName());
return new AppVersionManager($config);
});
$this->app->bind(AppVersionManagerContract::class, AppVersionManager::class);
$this->app->bind(static::VERSION_MANAGER_ALIAS, AppVersionManagerContract::class);
}
|
php
|
protected function registerAppVersionManager()
{
$this->app->singleton(AppVersionManager::class, function (Application $app) {
$config = (array) $app
->make('config')
->get(static::getConfigRootKeyName());
return new AppVersionManager($config);
});
$this->app->bind(AppVersionManagerContract::class, AppVersionManager::class);
$this->app->bind(static::VERSION_MANAGER_ALIAS, AppVersionManagerContract::class);
}
|
[
"protected",
"function",
"registerAppVersionManager",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"AppVersionManager",
"::",
"class",
",",
"function",
"(",
"Application",
"$",
"app",
")",
"{",
"$",
"config",
"=",
"(",
"array",
")",
"$",
"app",
"->",
"make",
"(",
"'config'",
")",
"->",
"get",
"(",
"static",
"::",
"getConfigRootKeyName",
"(",
")",
")",
";",
"return",
"new",
"AppVersionManager",
"(",
"$",
"config",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"app",
"->",
"bind",
"(",
"AppVersionManagerContract",
"::",
"class",
",",
"AppVersionManager",
"::",
"class",
")",
";",
"$",
"this",
"->",
"app",
"->",
"bind",
"(",
"static",
"::",
"VERSION_MANAGER_ALIAS",
",",
"AppVersionManagerContract",
"::",
"class",
")",
";",
"}"
] |
Register version manager instance.
@return void
|
[
"Register",
"version",
"manager",
"instance",
"."
] |
train
|
https://github.com/avto-dev/app-version-laravel/blob/5cbf9df5981cadd2d5148c49c834cc17fb903c3f/src/AppVersionServiceProvider.php#L64-L76
|
avto-dev/app-version-laravel
|
src/AppVersionServiceProvider.php
|
AppVersionServiceProvider.registerBlade
|
protected function registerBlade()
{
$this->app->afterResolving('blade.compiler', function (BladeCompiler $blade) {
$blade->directive('app_version', function () {
return "<?php echo resolve('" . AppVersionManagerContract::class . "')->formatted(); ?>";
});
$blade->directive('app_build', function () {
return "<?php echo resolve('" . AppVersionManagerContract::class . "')->build(); ?>";
});
$blade->directive('app_version_hash', function ($length = 6) {
return "<?php echo resolve('" . AppVersionManagerContract::class . "')->hashed({$length}); ?>";
});
});
}
|
php
|
protected function registerBlade()
{
$this->app->afterResolving('blade.compiler', function (BladeCompiler $blade) {
$blade->directive('app_version', function () {
return "<?php echo resolve('" . AppVersionManagerContract::class . "')->formatted(); ?>";
});
$blade->directive('app_build', function () {
return "<?php echo resolve('" . AppVersionManagerContract::class . "')->build(); ?>";
});
$blade->directive('app_version_hash', function ($length = 6) {
return "<?php echo resolve('" . AppVersionManagerContract::class . "')->hashed({$length}); ?>";
});
});
}
|
[
"protected",
"function",
"registerBlade",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"afterResolving",
"(",
"'blade.compiler'",
",",
"function",
"(",
"BladeCompiler",
"$",
"blade",
")",
"{",
"$",
"blade",
"->",
"directive",
"(",
"'app_version'",
",",
"function",
"(",
")",
"{",
"return",
"\"<?php echo resolve('\"",
".",
"AppVersionManagerContract",
"::",
"class",
".",
"\"')->formatted(); ?>\"",
";",
"}",
")",
";",
"$",
"blade",
"->",
"directive",
"(",
"'app_build'",
",",
"function",
"(",
")",
"{",
"return",
"\"<?php echo resolve('\"",
".",
"AppVersionManagerContract",
"::",
"class",
".",
"\"')->build(); ?>\"",
";",
"}",
")",
";",
"$",
"blade",
"->",
"directive",
"(",
"'app_version_hash'",
",",
"function",
"(",
"$",
"length",
"=",
"6",
")",
"{",
"return",
"\"<?php echo resolve('\"",
".",
"AppVersionManagerContract",
"::",
"class",
".",
"\"')->hashed({$length}); ?>\"",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] |
Register Blade directives.
|
[
"Register",
"Blade",
"directives",
"."
] |
train
|
https://github.com/avto-dev/app-version-laravel/blob/5cbf9df5981cadd2d5148c49c834cc17fb903c3f/src/AppVersionServiceProvider.php#L81-L96
|
avto-dev/app-version-laravel
|
src/AppVersionServiceProvider.php
|
AppVersionServiceProvider.initializeConfigs
|
protected function initializeConfigs()
{
$this->mergeConfigFrom(static::getConfigPath(), static::getConfigRootKeyName());
$this->publishes([
realpath(static::getConfigPath()) => config_path(basename(static::getConfigPath())),
], 'config');
}
|
php
|
protected function initializeConfigs()
{
$this->mergeConfigFrom(static::getConfigPath(), static::getConfigRootKeyName());
$this->publishes([
realpath(static::getConfigPath()) => config_path(basename(static::getConfigPath())),
], 'config');
}
|
[
"protected",
"function",
"initializeConfigs",
"(",
")",
"{",
"$",
"this",
"->",
"mergeConfigFrom",
"(",
"static",
"::",
"getConfigPath",
"(",
")",
",",
"static",
"::",
"getConfigRootKeyName",
"(",
")",
")",
";",
"$",
"this",
"->",
"publishes",
"(",
"[",
"realpath",
"(",
"static",
"::",
"getConfigPath",
"(",
")",
")",
"=>",
"config_path",
"(",
"basename",
"(",
"static",
"::",
"getConfigPath",
"(",
")",
")",
")",
",",
"]",
",",
"'config'",
")",
";",
"}"
] |
Initialize configs.
@return void
|
[
"Initialize",
"configs",
"."
] |
train
|
https://github.com/avto-dev/app-version-laravel/blob/5cbf9df5981cadd2d5148c49c834cc17fb903c3f/src/AppVersionServiceProvider.php#L113-L120
|
contao-bootstrap/buttons
|
src/Netzmacht/Bootstrap/Buttons/ContentElement/ButtonsElement.php
|
ButtonsElement.compile
|
protected function compile()
{
if (!$this->bootstrap_buttonStyle) {
$this->bootstrap_buttonStyle = 'btn-default';
}
$buttons = Factory::createFromFieldset($this->bootstrap_buttons);
$buttons->eachChild(array($this, 'addButtonStyle'));
$this->Template->buttons = $buttons;
}
|
php
|
protected function compile()
{
if (!$this->bootstrap_buttonStyle) {
$this->bootstrap_buttonStyle = 'btn-default';
}
$buttons = Factory::createFromFieldset($this->bootstrap_buttons);
$buttons->eachChild(array($this, 'addButtonStyle'));
$this->Template->buttons = $buttons;
}
|
[
"protected",
"function",
"compile",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"bootstrap_buttonStyle",
")",
"{",
"$",
"this",
"->",
"bootstrap_buttonStyle",
"=",
"'btn-default'",
";",
"}",
"$",
"buttons",
"=",
"Factory",
"::",
"createFromFieldset",
"(",
"$",
"this",
"->",
"bootstrap_buttons",
")",
";",
"$",
"buttons",
"->",
"eachChild",
"(",
"array",
"(",
"$",
"this",
",",
"'addButtonStyle'",
")",
")",
";",
"$",
"this",
"->",
"Template",
"->",
"buttons",
"=",
"$",
"buttons",
";",
"}"
] |
Compile the button toolbar.
@return void
|
[
"Compile",
"the",
"button",
"toolbar",
"."
] |
train
|
https://github.com/contao-bootstrap/buttons/blob/f573a24c19ec059aae528a12ba46dfc993844201/src/Netzmacht/Bootstrap/Buttons/ContentElement/ButtonsElement.php#L35-L45
|
contao-bootstrap/buttons
|
src/Netzmacht/Bootstrap/Buttons/ContentElement/ButtonsElement.php
|
ButtonsElement.addButtonStyle
|
public function addButtonStyle($child)
{
if ($child instanceof Group || $child instanceof Toolbar) {
$child->eachChild(array($this, 'addButtonStyle'));
} else {
$class = $child->getAttribute('class');
$class = array_filter($class, function ($item) {
return strpos($item, 'btn-') !== false;
});
if (!$class && $this->bootstrap_buttonStyle) {
$child->addClass($this->bootstrap_buttonStyle);
}
}
}
|
php
|
public function addButtonStyle($child)
{
if ($child instanceof Group || $child instanceof Toolbar) {
$child->eachChild(array($this, 'addButtonStyle'));
} else {
$class = $child->getAttribute('class');
$class = array_filter($class, function ($item) {
return strpos($item, 'btn-') !== false;
});
if (!$class && $this->bootstrap_buttonStyle) {
$child->addClass($this->bootstrap_buttonStyle);
}
}
}
|
[
"public",
"function",
"addButtonStyle",
"(",
"$",
"child",
")",
"{",
"if",
"(",
"$",
"child",
"instanceof",
"Group",
"||",
"$",
"child",
"instanceof",
"Toolbar",
")",
"{",
"$",
"child",
"->",
"eachChild",
"(",
"array",
"(",
"$",
"this",
",",
"'addButtonStyle'",
")",
")",
";",
"}",
"else",
"{",
"$",
"class",
"=",
"$",
"child",
"->",
"getAttribute",
"(",
"'class'",
")",
";",
"$",
"class",
"=",
"array_filter",
"(",
"$",
"class",
",",
"function",
"(",
"$",
"item",
")",
"{",
"return",
"strpos",
"(",
"$",
"item",
",",
"'btn-'",
")",
"!==",
"false",
";",
"}",
")",
";",
"if",
"(",
"!",
"$",
"class",
"&&",
"$",
"this",
"->",
"bootstrap_buttonStyle",
")",
"{",
"$",
"child",
"->",
"addClass",
"(",
"$",
"this",
"->",
"bootstrap_buttonStyle",
")",
";",
"}",
"}",
"}"
] |
Add button style.
@param mixed $child Current child.
@return void
|
[
"Add",
"button",
"style",
"."
] |
train
|
https://github.com/contao-bootstrap/buttons/blob/f573a24c19ec059aae528a12ba46dfc993844201/src/Netzmacht/Bootstrap/Buttons/ContentElement/ButtonsElement.php#L54-L68
|
datasift/datasift-php
|
examples/consume-stream.php
|
EventHandler.onInteraction
|
public function onInteraction($consumer, $interaction, $hash)
{
if (!isset($interaction['interaction']['content'])) {
$interaction['interaction']['content'] = 'No interaction.content for this interaction';
}
echo $hash.': '.$interaction['interaction']['content'].PHP_EOL.'--'.PHP_EOL;
}
|
php
|
public function onInteraction($consumer, $interaction, $hash)
{
if (!isset($interaction['interaction']['content'])) {
$interaction['interaction']['content'] = 'No interaction.content for this interaction';
}
echo $hash.': '.$interaction['interaction']['content'].PHP_EOL.'--'.PHP_EOL;
}
|
[
"public",
"function",
"onInteraction",
"(",
"$",
"consumer",
",",
"$",
"interaction",
",",
"$",
"hash",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"interaction",
"[",
"'interaction'",
"]",
"[",
"'content'",
"]",
")",
")",
"{",
"$",
"interaction",
"[",
"'interaction'",
"]",
"[",
"'content'",
"]",
"=",
"'No interaction.content for this interaction'",
";",
"}",
"echo",
"$",
"hash",
".",
"': '",
".",
"$",
"interaction",
"[",
"'interaction'",
"]",
"[",
"'content'",
"]",
".",
"PHP_EOL",
".",
"'--'",
".",
"PHP_EOL",
";",
"}"
] |
Handle incoming data.
@param DataSift_StreamConsumer $consumer The consumer object.
@param array $interaction The interaction data.
@param string $hash The stream hash.
|
[
"Handle",
"incoming",
"data",
"."
] |
train
|
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/examples/consume-stream.php#L62-L68
|
stubbles/stubbles-webapp-core
|
src/main/php/session/storage/NativeSessionStorage.php
|
NativeSessionStorage.putValue
|
public function putValue(string $key, $value): SessionStorage
{
$this->init();
$_SESSION[$key] = $value;
return $this;
}
|
php
|
public function putValue(string $key, $value): SessionStorage
{
$this->init();
$_SESSION[$key] = $value;
return $this;
}
|
[
"public",
"function",
"putValue",
"(",
"string",
"$",
"key",
",",
"$",
"value",
")",
":",
"SessionStorage",
"{",
"$",
"this",
"->",
"init",
"(",
")",
";",
"$",
"_SESSION",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"return",
"$",
"this",
";",
"}"
] |
stores a value associated with the key
@param string $key key to store value under
@param mixed $value data to store
@return \stubbles\webapp\session\storage\SessionStorage
|
[
"stores",
"a",
"value",
"associated",
"with",
"the",
"key"
] |
train
|
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/session/storage/NativeSessionStorage.php#L149-L154
|
nathancox/silverstripe-hasoneautocompletefield
|
src/forms/HasOneAutocompleteField.php
|
HasOneAutocompleteField.search
|
public function search(HTTPRequest $request)
{
// Check form field state
if($this->isDisabled() || $this->isReadonly()) {
return $this->httpError(403);
}
$query = $request->getVar('query');
// use callbacks if they're set, otherwise used this class's methods for search and processing
if ($this->getSearchCallback()) {
$results = call_user_func($this->getSearchCallback(), $query, $this);
} else {
$results = $this->getResults($query);
}
if ($this->getProcessCallback()) {
$json = call_user_func($this->getProcessCallback(), $results, $this);
} else {
$json = $this->processResults($results);
}
return Convert::array2json($json);
}
|
php
|
public function search(HTTPRequest $request)
{
// Check form field state
if($this->isDisabled() || $this->isReadonly()) {
return $this->httpError(403);
}
$query = $request->getVar('query');
// use callbacks if they're set, otherwise used this class's methods for search and processing
if ($this->getSearchCallback()) {
$results = call_user_func($this->getSearchCallback(), $query, $this);
} else {
$results = $this->getResults($query);
}
if ($this->getProcessCallback()) {
$json = call_user_func($this->getProcessCallback(), $results, $this);
} else {
$json = $this->processResults($results);
}
return Convert::array2json($json);
}
|
[
"public",
"function",
"search",
"(",
"HTTPRequest",
"$",
"request",
")",
"{",
"// Check form field state",
"if",
"(",
"$",
"this",
"->",
"isDisabled",
"(",
")",
"||",
"$",
"this",
"->",
"isReadonly",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"httpError",
"(",
"403",
")",
";",
"}",
"$",
"query",
"=",
"$",
"request",
"->",
"getVar",
"(",
"'query'",
")",
";",
"// use callbacks if they're set, otherwise used this class's methods for search and processing",
"if",
"(",
"$",
"this",
"->",
"getSearchCallback",
"(",
")",
")",
"{",
"$",
"results",
"=",
"call_user_func",
"(",
"$",
"this",
"->",
"getSearchCallback",
"(",
")",
",",
"$",
"query",
",",
"$",
"this",
")",
";",
"}",
"else",
"{",
"$",
"results",
"=",
"$",
"this",
"->",
"getResults",
"(",
"$",
"query",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"getProcessCallback",
"(",
")",
")",
"{",
"$",
"json",
"=",
"call_user_func",
"(",
"$",
"this",
"->",
"getProcessCallback",
"(",
")",
",",
"$",
"results",
",",
"$",
"this",
")",
";",
"}",
"else",
"{",
"$",
"json",
"=",
"$",
"this",
"->",
"processResults",
"(",
"$",
"results",
")",
";",
"}",
"return",
"Convert",
"::",
"array2json",
"(",
"$",
"json",
")",
";",
"}"
] |
The action that handles AJAX search requests
@param SS_HTTPRequest $request
@return json
|
[
"The",
"action",
"that",
"handles",
"AJAX",
"search",
"requests"
] |
train
|
https://github.com/nathancox/silverstripe-hasoneautocompletefield/blob/862a971723dfc053ddb9c155defa32ab2bcd870e/src/forms/HasOneAutocompleteField.php#L83-L106
|
nathancox/silverstripe-hasoneautocompletefield
|
src/forms/HasOneAutocompleteField.php
|
HasOneAutocompleteField.getResults
|
protected function getResults($query)
{
$searchFields = ($this->getSearchFields() ?: singleton($this->sourceObject)->stat('searchable_fields'));
if(!$searchFields) {
throw new Exception(
sprintf('HasOneAutocompleteField: No searchable fields could be found for class "%s"',
$this->sourceObject));
}
$params = [];
$sort = [];
foreach($searchFields as $searchField) {
$name = (strpos($searchField, ':') !== FALSE) ? $searchField : "$searchField:PartialMatch:nocase";
$params[$name] = $query;
$sort[$searchField] = "ASC";
}
$results = DataList::create($this->sourceObject)
->filterAny($params)
->sort($sort)
->limit($this->getResultsLimit());
return $results;
}
|
php
|
protected function getResults($query)
{
$searchFields = ($this->getSearchFields() ?: singleton($this->sourceObject)->stat('searchable_fields'));
if(!$searchFields) {
throw new Exception(
sprintf('HasOneAutocompleteField: No searchable fields could be found for class "%s"',
$this->sourceObject));
}
$params = [];
$sort = [];
foreach($searchFields as $searchField) {
$name = (strpos($searchField, ':') !== FALSE) ? $searchField : "$searchField:PartialMatch:nocase";
$params[$name] = $query;
$sort[$searchField] = "ASC";
}
$results = DataList::create($this->sourceObject)
->filterAny($params)
->sort($sort)
->limit($this->getResultsLimit());
return $results;
}
|
[
"protected",
"function",
"getResults",
"(",
"$",
"query",
")",
"{",
"$",
"searchFields",
"=",
"(",
"$",
"this",
"->",
"getSearchFields",
"(",
")",
"?",
":",
"singleton",
"(",
"$",
"this",
"->",
"sourceObject",
")",
"->",
"stat",
"(",
"'searchable_fields'",
")",
")",
";",
"if",
"(",
"!",
"$",
"searchFields",
")",
"{",
"throw",
"new",
"Exception",
"(",
"sprintf",
"(",
"'HasOneAutocompleteField: No searchable fields could be found for class \"%s\"'",
",",
"$",
"this",
"->",
"sourceObject",
")",
")",
";",
"}",
"$",
"params",
"=",
"[",
"]",
";",
"$",
"sort",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"searchFields",
"as",
"$",
"searchField",
")",
"{",
"$",
"name",
"=",
"(",
"strpos",
"(",
"$",
"searchField",
",",
"':'",
")",
"!==",
"FALSE",
")",
"?",
"$",
"searchField",
":",
"\"$searchField:PartialMatch:nocase\"",
";",
"$",
"params",
"[",
"$",
"name",
"]",
"=",
"$",
"query",
";",
"$",
"sort",
"[",
"$",
"searchField",
"]",
"=",
"\"ASC\"",
";",
"}",
"$",
"results",
"=",
"DataList",
"::",
"create",
"(",
"$",
"this",
"->",
"sourceObject",
")",
"->",
"filterAny",
"(",
"$",
"params",
")",
"->",
"sort",
"(",
"$",
"sort",
")",
"->",
"limit",
"(",
"$",
"this",
"->",
"getResultsLimit",
"(",
")",
")",
";",
"return",
"$",
"results",
";",
"}"
] |
Takes the search term and returns a DataList
@param string $query
@return DataList
|
[
"Takes",
"the",
"search",
"term",
"and",
"returns",
"a",
"DataList"
] |
train
|
https://github.com/nathancox/silverstripe-hasoneautocompletefield/blob/862a971723dfc053ddb9c155defa32ab2bcd870e/src/forms/HasOneAutocompleteField.php#L113-L138
|
nathancox/silverstripe-hasoneautocompletefield
|
src/forms/HasOneAutocompleteField.php
|
HasOneAutocompleteField.processResults
|
protected function processResults($results)
{
$json = array();
foreach($results as $result) {
$name = $result->{$this->labelField};
$json[$result->ID] = array(
'name' => $name,
'currentString' => $this->getCurrentItemText($result)
);
}
return $json;
}
|
php
|
protected function processResults($results)
{
$json = array();
foreach($results as $result) {
$name = $result->{$this->labelField};
$json[$result->ID] = array(
'name' => $name,
'currentString' => $this->getCurrentItemText($result)
);
}
return $json;
}
|
[
"protected",
"function",
"processResults",
"(",
"$",
"results",
")",
"{",
"$",
"json",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"results",
"as",
"$",
"result",
")",
"{",
"$",
"name",
"=",
"$",
"result",
"->",
"{",
"$",
"this",
"->",
"labelField",
"}",
";",
"$",
"json",
"[",
"$",
"result",
"->",
"ID",
"]",
"=",
"array",
"(",
"'name'",
"=>",
"$",
"name",
",",
"'currentString'",
"=>",
"$",
"this",
"->",
"getCurrentItemText",
"(",
"$",
"result",
")",
")",
";",
"}",
"return",
"$",
"json",
";",
"}"
] |
Takes the DataList of search results and returns the json to be sent to the front end.
@param DataList
@return json
|
[
"Takes",
"the",
"DataList",
"of",
"search",
"results",
"and",
"returns",
"the",
"json",
"to",
"be",
"sent",
"to",
"the",
"front",
"end",
"."
] |
train
|
https://github.com/nathancox/silverstripe-hasoneautocompletefield/blob/862a971723dfc053ddb9c155defa32ab2bcd870e/src/forms/HasOneAutocompleteField.php#L145-L158
|
nathancox/silverstripe-hasoneautocompletefield
|
src/forms/HasOneAutocompleteField.php
|
HasOneAutocompleteField.getItem
|
function getItem()
{
$sourceObject = $this->sourceObject;
if ($this->value !== null) {
$item = $sourceObject::get()->byID($this->value);
} else {
$item = $sourceObject::create();
}
return $item;
}
|
php
|
function getItem()
{
$sourceObject = $this->sourceObject;
if ($this->value !== null) {
$item = $sourceObject::get()->byID($this->value);
} else {
$item = $sourceObject::create();
}
return $item;
}
|
[
"function",
"getItem",
"(",
")",
"{",
"$",
"sourceObject",
"=",
"$",
"this",
"->",
"sourceObject",
";",
"if",
"(",
"$",
"this",
"->",
"value",
"!==",
"null",
")",
"{",
"$",
"item",
"=",
"$",
"sourceObject",
"::",
"get",
"(",
")",
"->",
"byID",
"(",
"$",
"this",
"->",
"value",
")",
";",
"}",
"else",
"{",
"$",
"item",
"=",
"$",
"sourceObject",
"::",
"create",
"(",
")",
";",
"}",
"return",
"$",
"item",
";",
"}"
] |
Get the currently selected object
@return DataObject
|
[
"Get",
"the",
"currently",
"selected",
"object"
] |
train
|
https://github.com/nathancox/silverstripe-hasoneautocompletefield/blob/862a971723dfc053ddb9c155defa32ab2bcd870e/src/forms/HasOneAutocompleteField.php#L302-L311
|
nathancox/silverstripe-hasoneautocompletefield
|
src/forms/HasOneAutocompleteField.php
|
HasOneAutocompleteField.getCurrentItemText
|
function getCurrentItemText($item = null)
{
$text = $this->getDefaultText();
if (is_null($item)) {
$item = $this->getItem();
}
if ($item && $item->ID > 0) {
$labelField = $this->labelField;
if (isset($item->$labelField)) {
$text = $item->$labelField;
} else {
user_error("PageSearchField can't find field called ".$labelField."on ".$item->ClassName, E_USER_ERROR);
}
if (method_exists($item, "Link")) {
$text = "<a href='{$item->Link()}' target='_blank'>".$text.'</a>';
}
}
return $text;
}
|
php
|
function getCurrentItemText($item = null)
{
$text = $this->getDefaultText();
if (is_null($item)) {
$item = $this->getItem();
}
if ($item && $item->ID > 0) {
$labelField = $this->labelField;
if (isset($item->$labelField)) {
$text = $item->$labelField;
} else {
user_error("PageSearchField can't find field called ".$labelField."on ".$item->ClassName, E_USER_ERROR);
}
if (method_exists($item, "Link")) {
$text = "<a href='{$item->Link()}' target='_blank'>".$text.'</a>';
}
}
return $text;
}
|
[
"function",
"getCurrentItemText",
"(",
"$",
"item",
"=",
"null",
")",
"{",
"$",
"text",
"=",
"$",
"this",
"->",
"getDefaultText",
"(",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"item",
")",
")",
"{",
"$",
"item",
"=",
"$",
"this",
"->",
"getItem",
"(",
")",
";",
"}",
"if",
"(",
"$",
"item",
"&&",
"$",
"item",
"->",
"ID",
">",
"0",
")",
"{",
"$",
"labelField",
"=",
"$",
"this",
"->",
"labelField",
";",
"if",
"(",
"isset",
"(",
"$",
"item",
"->",
"$",
"labelField",
")",
")",
"{",
"$",
"text",
"=",
"$",
"item",
"->",
"$",
"labelField",
";",
"}",
"else",
"{",
"user_error",
"(",
"\"PageSearchField can't find field called \"",
".",
"$",
"labelField",
".",
"\"on \"",
".",
"$",
"item",
"->",
"ClassName",
",",
"E_USER_ERROR",
")",
";",
"}",
"if",
"(",
"method_exists",
"(",
"$",
"item",
",",
"\"Link\"",
")",
")",
"{",
"$",
"text",
"=",
"\"<a href='{$item->Link()}' target='_blank'>\"",
".",
"$",
"text",
".",
"'</a>'",
";",
"}",
"}",
"return",
"$",
"text",
";",
"}"
] |
Return the text to be dislayed next to the "Edit" button indicating the currently selected item.
By default is displays $labelField and wraps it in a link if the object has the Link() method.
@param DataObjext $item
@return string
|
[
"Return",
"the",
"text",
"to",
"be",
"dislayed",
"next",
"to",
"the",
"Edit",
"button",
"indicating",
"the",
"currently",
"selected",
"item",
".",
"By",
"default",
"is",
"displays",
"$labelField",
"and",
"wraps",
"it",
"in",
"a",
"link",
"if",
"the",
"object",
"has",
"the",
"Link",
"()",
"method",
"."
] |
train
|
https://github.com/nathancox/silverstripe-hasoneautocompletefield/blob/862a971723dfc053ddb9c155defa32ab2bcd870e/src/forms/HasOneAutocompleteField.php#L320-L342
|
dragosprotung/stc-core
|
src/Workout/SportGuesser.php
|
SportGuesser.guess
|
public static function guess(string $code) : string
{
switch (strtolower(trim($code))) {
case SportMapperInterface::RUNNING:
case 'run':
return SportMapperInterface::RUNNING;
case SportMapperInterface::CYCLING_SPORT:
case 'cycling':
return SportMapperInterface::CYCLING_SPORT;
case SportMapperInterface::CYCLING_TRANSPORT:
return SportMapperInterface::CYCLING_TRANSPORT;
case SportMapperInterface::SWIMMING:
return SportMapperInterface::SWIMMING;
default:
return SportMapperInterface::OTHER;
}
}
|
php
|
public static function guess(string $code) : string
{
switch (strtolower(trim($code))) {
case SportMapperInterface::RUNNING:
case 'run':
return SportMapperInterface::RUNNING;
case SportMapperInterface::CYCLING_SPORT:
case 'cycling':
return SportMapperInterface::CYCLING_SPORT;
case SportMapperInterface::CYCLING_TRANSPORT:
return SportMapperInterface::CYCLING_TRANSPORT;
case SportMapperInterface::SWIMMING:
return SportMapperInterface::SWIMMING;
default:
return SportMapperInterface::OTHER;
}
}
|
[
"public",
"static",
"function",
"guess",
"(",
"string",
"$",
"code",
")",
":",
"string",
"{",
"switch",
"(",
"strtolower",
"(",
"trim",
"(",
"$",
"code",
")",
")",
")",
"{",
"case",
"SportMapperInterface",
"::",
"RUNNING",
":",
"case",
"'run'",
":",
"return",
"SportMapperInterface",
"::",
"RUNNING",
";",
"case",
"SportMapperInterface",
"::",
"CYCLING_SPORT",
":",
"case",
"'cycling'",
":",
"return",
"SportMapperInterface",
"::",
"CYCLING_SPORT",
";",
"case",
"SportMapperInterface",
"::",
"CYCLING_TRANSPORT",
":",
"return",
"SportMapperInterface",
"::",
"CYCLING_TRANSPORT",
";",
"case",
"SportMapperInterface",
"::",
"SWIMMING",
":",
"return",
"SportMapperInterface",
"::",
"SWIMMING",
";",
"default",
":",
"return",
"SportMapperInterface",
"::",
"OTHER",
";",
"}",
"}"
] |
Get the sport code from the tracker sport code.
@param string $code The code from the tracker.
@return string
|
[
"Get",
"the",
"sport",
"code",
"from",
"the",
"tracker",
"sport",
"code",
"."
] |
train
|
https://github.com/dragosprotung/stc-core/blob/9783e3414294f4ee555a1d538d2807269deeb9e7/src/Workout/SportGuesser.php#L18-L34
|
czim/laravel-pxlcms
|
src/Sluggable/SluggableTrait.php
|
SluggableTrait.bootSluggableTrait
|
public static function bootSluggableTrait()
{
// cache config for this model
static::$slugsTable = config('pxlcms.slugs.table', 'cms_slugs');
static::$slugsColumn = config('pxlcms.slugs.column', 'slug');
static::$slugsEntryKey = config('pxlcms.slugs.keys.entry', 'entry_id');
static::$slugsModuleKey = config('pxlcms.slugs.keys.module', 'module_id');
static::$slugsLanguageKey = config('pxlcms.slugs.keys.language', 'language_id');
static::$slugsActiveColumn = config('pxlcms.slugs.active_column', false);
}
|
php
|
public static function bootSluggableTrait()
{
// cache config for this model
static::$slugsTable = config('pxlcms.slugs.table', 'cms_slugs');
static::$slugsColumn = config('pxlcms.slugs.column', 'slug');
static::$slugsEntryKey = config('pxlcms.slugs.keys.entry', 'entry_id');
static::$slugsModuleKey = config('pxlcms.slugs.keys.module', 'module_id');
static::$slugsLanguageKey = config('pxlcms.slugs.keys.language', 'language_id');
static::$slugsActiveColumn = config('pxlcms.slugs.active_column', false);
}
|
[
"public",
"static",
"function",
"bootSluggableTrait",
"(",
")",
"{",
"// cache config for this model",
"static",
"::",
"$",
"slugsTable",
"=",
"config",
"(",
"'pxlcms.slugs.table'",
",",
"'cms_slugs'",
")",
";",
"static",
"::",
"$",
"slugsColumn",
"=",
"config",
"(",
"'pxlcms.slugs.column'",
",",
"'slug'",
")",
";",
"static",
"::",
"$",
"slugsEntryKey",
"=",
"config",
"(",
"'pxlcms.slugs.keys.entry'",
",",
"'entry_id'",
")",
";",
"static",
"::",
"$",
"slugsModuleKey",
"=",
"config",
"(",
"'pxlcms.slugs.keys.module'",
",",
"'module_id'",
")",
";",
"static",
"::",
"$",
"slugsLanguageKey",
"=",
"config",
"(",
"'pxlcms.slugs.keys.language'",
",",
"'language_id'",
")",
";",
"static",
"::",
"$",
"slugsActiveColumn",
"=",
"config",
"(",
"'pxlcms.slugs.active_column'",
",",
"false",
")",
";",
"}"
] |
Caches config on model boot
|
[
"Caches",
"config",
"on",
"model",
"boot"
] |
train
|
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Sluggable/SluggableTrait.php#L32-L41
|
czim/laravel-pxlcms
|
src/Sluggable/SluggableTrait.php
|
SluggableTrait.scopeWhereSlug
|
public function scopeWhereSlug($scope, $slug, $locale = null, $forHasQuery = false)
{
/** @var CmsModel|SluggableTrait $model */
$model = new static;
if ($model->storeSlugLocally()) {
return $this->CviebrockScopeWhereSlug($scope, $slug);
}
// build scope with join to slugs table ..
$scope = $scope->join(
static::$slugsTable,
function($join) use ($model, $locale) {
$idKey = $this->isTranslationModel()
? config('pxlcms.translatable.translation_foreign_key')
: $this->getKeyName();
$join->on($model->getTable() . '.' . $idKey, '=', static::$slugsTable . '.' . static::$slugsEntryKey);
$join->on(static::$slugsTable . '.' . static::$slugsModuleKey, '=', DB::raw( (int) $model->getModuleNumber()));
if ( ! empty($locale) && $model->isTranslationModel()) {
$languageId = $model->lookUpLanguageIdForLocale($locale);
$join->on(static::$slugsTable . '.' . static::$slugsLanguageKey, '=', DB::raw( (int) $languageId));
}
}
);
return $scope->where(static::$slugsTable . '.' . static::$slugsColumn, $slug)
->select($this->getTable() . '.' . ($forHasQuery ? 'id' : '*'));
}
|
php
|
public function scopeWhereSlug($scope, $slug, $locale = null, $forHasQuery = false)
{
/** @var CmsModel|SluggableTrait $model */
$model = new static;
if ($model->storeSlugLocally()) {
return $this->CviebrockScopeWhereSlug($scope, $slug);
}
// build scope with join to slugs table ..
$scope = $scope->join(
static::$slugsTable,
function($join) use ($model, $locale) {
$idKey = $this->isTranslationModel()
? config('pxlcms.translatable.translation_foreign_key')
: $this->getKeyName();
$join->on($model->getTable() . '.' . $idKey, '=', static::$slugsTable . '.' . static::$slugsEntryKey);
$join->on(static::$slugsTable . '.' . static::$slugsModuleKey, '=', DB::raw( (int) $model->getModuleNumber()));
if ( ! empty($locale) && $model->isTranslationModel()) {
$languageId = $model->lookUpLanguageIdForLocale($locale);
$join->on(static::$slugsTable . '.' . static::$slugsLanguageKey, '=', DB::raw( (int) $languageId));
}
}
);
return $scope->where(static::$slugsTable . '.' . static::$slugsColumn, $slug)
->select($this->getTable() . '.' . ($forHasQuery ? 'id' : '*'));
}
|
[
"public",
"function",
"scopeWhereSlug",
"(",
"$",
"scope",
",",
"$",
"slug",
",",
"$",
"locale",
"=",
"null",
",",
"$",
"forHasQuery",
"=",
"false",
")",
"{",
"/** @var CmsModel|SluggableTrait $model */",
"$",
"model",
"=",
"new",
"static",
";",
"if",
"(",
"$",
"model",
"->",
"storeSlugLocally",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"CviebrockScopeWhereSlug",
"(",
"$",
"scope",
",",
"$",
"slug",
")",
";",
"}",
"// build scope with join to slugs table ..",
"$",
"scope",
"=",
"$",
"scope",
"->",
"join",
"(",
"static",
"::",
"$",
"slugsTable",
",",
"function",
"(",
"$",
"join",
")",
"use",
"(",
"$",
"model",
",",
"$",
"locale",
")",
"{",
"$",
"idKey",
"=",
"$",
"this",
"->",
"isTranslationModel",
"(",
")",
"?",
"config",
"(",
"'pxlcms.translatable.translation_foreign_key'",
")",
":",
"$",
"this",
"->",
"getKeyName",
"(",
")",
";",
"$",
"join",
"->",
"on",
"(",
"$",
"model",
"->",
"getTable",
"(",
")",
".",
"'.'",
".",
"$",
"idKey",
",",
"'='",
",",
"static",
"::",
"$",
"slugsTable",
".",
"'.'",
".",
"static",
"::",
"$",
"slugsEntryKey",
")",
";",
"$",
"join",
"->",
"on",
"(",
"static",
"::",
"$",
"slugsTable",
".",
"'.'",
".",
"static",
"::",
"$",
"slugsModuleKey",
",",
"'='",
",",
"DB",
"::",
"raw",
"(",
"(",
"int",
")",
"$",
"model",
"->",
"getModuleNumber",
"(",
")",
")",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"locale",
")",
"&&",
"$",
"model",
"->",
"isTranslationModel",
"(",
")",
")",
"{",
"$",
"languageId",
"=",
"$",
"model",
"->",
"lookUpLanguageIdForLocale",
"(",
"$",
"locale",
")",
";",
"$",
"join",
"->",
"on",
"(",
"static",
"::",
"$",
"slugsTable",
".",
"'.'",
".",
"static",
"::",
"$",
"slugsLanguageKey",
",",
"'='",
",",
"DB",
"::",
"raw",
"(",
"(",
"int",
")",
"$",
"languageId",
")",
")",
";",
"}",
"}",
")",
";",
"return",
"$",
"scope",
"->",
"where",
"(",
"static",
"::",
"$",
"slugsTable",
".",
"'.'",
".",
"static",
"::",
"$",
"slugsColumn",
",",
"$",
"slug",
")",
"->",
"select",
"(",
"$",
"this",
"->",
"getTable",
"(",
")",
".",
"'.'",
".",
"(",
"$",
"forHasQuery",
"?",
"'id'",
":",
"'*'",
")",
")",
";",
"}"
] |
Query scope for finding a model by its slug.
@param Builder $scope
@param string $slug
@param string $locale if not set, matches for any locale
@param bool $forHasQuery if true, the scope is part of a has relation subquery
@return mixed
|
[
"Query",
"scope",
"for",
"finding",
"a",
"model",
"by",
"its",
"slug",
"."
] |
train
|
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Sluggable/SluggableTrait.php#L91-L122
|
czim/laravel-pxlcms
|
src/Sluggable/SluggableTrait.php
|
SluggableTrait.setSlug
|
protected function setSlug($slug)
{
$config = $this->getSluggableConfig();
$save_to = $config['save_to'];
if ($this->storeSlugLocally()) {
$this->setAttribute($save_to, $slug);
return;
}
$this->setSlugInCmsTable($slug);
}
|
php
|
protected function setSlug($slug)
{
$config = $this->getSluggableConfig();
$save_to = $config['save_to'];
if ($this->storeSlugLocally()) {
$this->setAttribute($save_to, $slug);
return;
}
$this->setSlugInCmsTable($slug);
}
|
[
"protected",
"function",
"setSlug",
"(",
"$",
"slug",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"getSluggableConfig",
"(",
")",
";",
"$",
"save_to",
"=",
"$",
"config",
"[",
"'save_to'",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"storeSlugLocally",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setAttribute",
"(",
"$",
"save_to",
",",
"$",
"slug",
")",
";",
"return",
";",
"}",
"$",
"this",
"->",
"setSlugInCmsTable",
"(",
"$",
"slug",
")",
";",
"}"
] |
Set the slug manually.
@param string $slug
|
[
"Set",
"the",
"slug",
"manually",
"."
] |
train
|
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Sluggable/SluggableTrait.php#L130-L141
|
czim/laravel-pxlcms
|
src/Sluggable/SluggableTrait.php
|
SluggableTrait.needsSlugging
|
protected function needsSlugging()
{
/** @var CmsModel|SluggableTrait $this */
if ($this->storeSlugLocally()) {
return $this->CviebrockNeedsSlugging();
}
$config = $this->getSluggableConfig();
$on_update = $config['on_update'];
// check stored slug in shared table
if ( ! $this->getSlugFromCmsTable()) return true;
return ( ! $this->exists || $on_update);
}
|
php
|
protected function needsSlugging()
{
/** @var CmsModel|SluggableTrait $this */
if ($this->storeSlugLocally()) {
return $this->CviebrockNeedsSlugging();
}
$config = $this->getSluggableConfig();
$on_update = $config['on_update'];
// check stored slug in shared table
if ( ! $this->getSlugFromCmsTable()) return true;
return ( ! $this->exists || $on_update);
}
|
[
"protected",
"function",
"needsSlugging",
"(",
")",
"{",
"/** @var CmsModel|SluggableTrait $this */",
"if",
"(",
"$",
"this",
"->",
"storeSlugLocally",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"CviebrockNeedsSlugging",
"(",
")",
";",
"}",
"$",
"config",
"=",
"$",
"this",
"->",
"getSluggableConfig",
"(",
")",
";",
"$",
"on_update",
"=",
"$",
"config",
"[",
"'on_update'",
"]",
";",
"// check stored slug in shared table",
"if",
"(",
"!",
"$",
"this",
"->",
"getSlugFromCmsTable",
"(",
")",
")",
"return",
"true",
";",
"return",
"(",
"!",
"$",
"this",
"->",
"exists",
"||",
"$",
"on_update",
")",
";",
"}"
] |
Determines whether the model needs slugging.
@return bool
|
[
"Determines",
"whether",
"the",
"model",
"needs",
"slugging",
"."
] |
train
|
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Sluggable/SluggableTrait.php#L148-L163
|
czim/laravel-pxlcms
|
src/Sluggable/SluggableTrait.php
|
SluggableTrait.getExistingSlugs
|
protected function getExistingSlugs($slug)
{
// check for existing slugs in the slugs table or locally?
if ($this->storeSlugLocally()) {
return $this->cviebrockGetExistingSlugs($slug);
}
return $this->getAllSlugsForModuleFromCmsTable($slug);
}
|
php
|
protected function getExistingSlugs($slug)
{
// check for existing slugs in the slugs table or locally?
if ($this->storeSlugLocally()) {
return $this->cviebrockGetExistingSlugs($slug);
}
return $this->getAllSlugsForModuleFromCmsTable($slug);
}
|
[
"protected",
"function",
"getExistingSlugs",
"(",
"$",
"slug",
")",
"{",
"// check for existing slugs in the slugs table or locally?",
"if",
"(",
"$",
"this",
"->",
"storeSlugLocally",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"cviebrockGetExistingSlugs",
"(",
"$",
"slug",
")",
";",
"}",
"return",
"$",
"this",
"->",
"getAllSlugsForModuleFromCmsTable",
"(",
"$",
"slug",
")",
";",
"}"
] |
Get all existing slugs that are similar to the given slug.
@param string $slug
@return array
|
[
"Get",
"all",
"existing",
"slugs",
"that",
"are",
"similar",
"to",
"the",
"given",
"slug",
"."
] |
train
|
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Sluggable/SluggableTrait.php#L171-L179
|
czim/laravel-pxlcms
|
src/Sluggable/SluggableTrait.php
|
SluggableTrait.getSlugRecordFromCmsTable
|
protected function getSlugRecordFromCmsTable()
{
/** @var CmsModel|SluggableTrait $this */
$languageId = $this->storeSlugForLanguageId();
$entryId = $this->isTranslationModel()
? $this->getAttribute(config('pxlcms.translatable.translation_foreign_key'))
: $this->getKey();
$existing = DB::table(static::$slugsTable)
->select([ 'id', static::$slugsColumn . ' as slug' ])
->where(static::$slugsModuleKey, $this->getModuleNumber())
->where(static::$slugsEntryKey, $entryId);
// if language is null, we need to take into account that some weird
// cms hook setups will use '0' or '' (and do not have nullable language columns)
if (is_null($languageId)) {
$existing = $existing->where(function($query) {
return $query->whereNull(static::$slugsLanguageKey)
->orWhere(static::$slugsLanguageKey, 0)
->orWhere(static::$slugsLanguageKey, '');
});
} else {
$existing = $existing->where(static::$slugsLanguageKey, $languageId);
}
$existing = $existing->limit(1)
->first();
if (empty($existing)) return null;
return $existing;
}
|
php
|
protected function getSlugRecordFromCmsTable()
{
/** @var CmsModel|SluggableTrait $this */
$languageId = $this->storeSlugForLanguageId();
$entryId = $this->isTranslationModel()
? $this->getAttribute(config('pxlcms.translatable.translation_foreign_key'))
: $this->getKey();
$existing = DB::table(static::$slugsTable)
->select([ 'id', static::$slugsColumn . ' as slug' ])
->where(static::$slugsModuleKey, $this->getModuleNumber())
->where(static::$slugsEntryKey, $entryId);
// if language is null, we need to take into account that some weird
// cms hook setups will use '0' or '' (and do not have nullable language columns)
if (is_null($languageId)) {
$existing = $existing->where(function($query) {
return $query->whereNull(static::$slugsLanguageKey)
->orWhere(static::$slugsLanguageKey, 0)
->orWhere(static::$slugsLanguageKey, '');
});
} else {
$existing = $existing->where(static::$slugsLanguageKey, $languageId);
}
$existing = $existing->limit(1)
->first();
if (empty($existing)) return null;
return $existing;
}
|
[
"protected",
"function",
"getSlugRecordFromCmsTable",
"(",
")",
"{",
"/** @var CmsModel|SluggableTrait $this */",
"$",
"languageId",
"=",
"$",
"this",
"->",
"storeSlugForLanguageId",
"(",
")",
";",
"$",
"entryId",
"=",
"$",
"this",
"->",
"isTranslationModel",
"(",
")",
"?",
"$",
"this",
"->",
"getAttribute",
"(",
"config",
"(",
"'pxlcms.translatable.translation_foreign_key'",
")",
")",
":",
"$",
"this",
"->",
"getKey",
"(",
")",
";",
"$",
"existing",
"=",
"DB",
"::",
"table",
"(",
"static",
"::",
"$",
"slugsTable",
")",
"->",
"select",
"(",
"[",
"'id'",
",",
"static",
"::",
"$",
"slugsColumn",
".",
"' as slug'",
"]",
")",
"->",
"where",
"(",
"static",
"::",
"$",
"slugsModuleKey",
",",
"$",
"this",
"->",
"getModuleNumber",
"(",
")",
")",
"->",
"where",
"(",
"static",
"::",
"$",
"slugsEntryKey",
",",
"$",
"entryId",
")",
";",
"// if language is null, we need to take into account that some weird",
"// cms hook setups will use '0' or '' (and do not have nullable language columns)",
"if",
"(",
"is_null",
"(",
"$",
"languageId",
")",
")",
"{",
"$",
"existing",
"=",
"$",
"existing",
"->",
"where",
"(",
"function",
"(",
"$",
"query",
")",
"{",
"return",
"$",
"query",
"->",
"whereNull",
"(",
"static",
"::",
"$",
"slugsLanguageKey",
")",
"->",
"orWhere",
"(",
"static",
"::",
"$",
"slugsLanguageKey",
",",
"0",
")",
"->",
"orWhere",
"(",
"static",
"::",
"$",
"slugsLanguageKey",
",",
"''",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"$",
"existing",
"=",
"$",
"existing",
"->",
"where",
"(",
"static",
"::",
"$",
"slugsLanguageKey",
",",
"$",
"languageId",
")",
";",
"}",
"$",
"existing",
"=",
"$",
"existing",
"->",
"limit",
"(",
"1",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"existing",
")",
")",
"return",
"null",
";",
"return",
"$",
"existing",
";",
"}"
] |
Returns current slug from CMS slugs table
@return object|null
|
[
"Returns",
"current",
"slug",
"from",
"CMS",
"slugs",
"table"
] |
train
|
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Sluggable/SluggableTrait.php#L186-L222
|
czim/laravel-pxlcms
|
src/Sluggable/SluggableTrait.php
|
SluggableTrait.findRecordIdForSlugFromCmsTable
|
public function findRecordIdForSlugFromCmsTable($slug, $locale = null, $limitToLanguage = false)
{
/** @var CmsModel|SluggableTrait $this */
$existing = DB::table(static::$slugsTable)
->select([ static::$slugsEntryKey . ' as entry' ])
->where(static::$slugsModuleKey, $this->getModuleNumber())
->where(static::$slugsColumn, $slug);
if ($locale || $limitToLanguage) {
if ($locale) {
$existing->where(static::$slugsLanguageKey, $this->lookUpLanguageIdForLocale($locale));
} else {
$existing->where(static::$slugsLanguageKey, $this->storeSlugForLanguageId());
}
}
$existing = $existing->orderBy('id', 'asc')
->limit(1)
->first();
if (empty($existing)) return null;
return $existing->entry;
}
|
php
|
public function findRecordIdForSlugFromCmsTable($slug, $locale = null, $limitToLanguage = false)
{
/** @var CmsModel|SluggableTrait $this */
$existing = DB::table(static::$slugsTable)
->select([ static::$slugsEntryKey . ' as entry' ])
->where(static::$slugsModuleKey, $this->getModuleNumber())
->where(static::$slugsColumn, $slug);
if ($locale || $limitToLanguage) {
if ($locale) {
$existing->where(static::$slugsLanguageKey, $this->lookUpLanguageIdForLocale($locale));
} else {
$existing->where(static::$slugsLanguageKey, $this->storeSlugForLanguageId());
}
}
$existing = $existing->orderBy('id', 'asc')
->limit(1)
->first();
if (empty($existing)) return null;
return $existing->entry;
}
|
[
"public",
"function",
"findRecordIdForSlugFromCmsTable",
"(",
"$",
"slug",
",",
"$",
"locale",
"=",
"null",
",",
"$",
"limitToLanguage",
"=",
"false",
")",
"{",
"/** @var CmsModel|SluggableTrait $this */",
"$",
"existing",
"=",
"DB",
"::",
"table",
"(",
"static",
"::",
"$",
"slugsTable",
")",
"->",
"select",
"(",
"[",
"static",
"::",
"$",
"slugsEntryKey",
".",
"' as entry'",
"]",
")",
"->",
"where",
"(",
"static",
"::",
"$",
"slugsModuleKey",
",",
"$",
"this",
"->",
"getModuleNumber",
"(",
")",
")",
"->",
"where",
"(",
"static",
"::",
"$",
"slugsColumn",
",",
"$",
"slug",
")",
";",
"if",
"(",
"$",
"locale",
"||",
"$",
"limitToLanguage",
")",
"{",
"if",
"(",
"$",
"locale",
")",
"{",
"$",
"existing",
"->",
"where",
"(",
"static",
"::",
"$",
"slugsLanguageKey",
",",
"$",
"this",
"->",
"lookUpLanguageIdForLocale",
"(",
"$",
"locale",
")",
")",
";",
"}",
"else",
"{",
"$",
"existing",
"->",
"where",
"(",
"static",
"::",
"$",
"slugsLanguageKey",
",",
"$",
"this",
"->",
"storeSlugForLanguageId",
"(",
")",
")",
";",
"}",
"}",
"$",
"existing",
"=",
"$",
"existing",
"->",
"orderBy",
"(",
"'id'",
",",
"'asc'",
")",
"->",
"limit",
"(",
"1",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"existing",
")",
")",
"return",
"null",
";",
"return",
"$",
"existing",
"->",
"entry",
";",
"}"
] |
Returns the entry/model ID for a given slug
@param string $slug
@param string $locale the locale to limit for (if null, set limitToLanguage)
@param bool $limitToLanguage if set, limits search to current language
@return int|null
|
[
"Returns",
"the",
"entry",
"/",
"model",
"ID",
"for",
"a",
"given",
"slug"
] |
train
|
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Sluggable/SluggableTrait.php#L232-L257
|
czim/laravel-pxlcms
|
src/Sluggable/SluggableTrait.php
|
SluggableTrait.getAllSlugsForModuleFromCmsTable
|
protected function getAllSlugsForModuleFromCmsTable($likeSlug = null, $limitToLanguage = true)
{
/** @var CmsModel|SluggableTrait $this */
$config = $this->getSluggableConfig();
$includeTrashed = $config['include_trashed'];
$separator = $config['separator'];
$existing = DB::table(static::$slugsTable)
->select([ 'id', static::$slugsColumn . ' as slug' ])
->where(static::$slugsModuleKey, $this->getModuleNumber())
->where(function ($query) use ($likeSlug, $separator) {
$query->where(static::$slugsColumn, $likeSlug);
$query->orWhere(static::$slugsColumn, 'LIKE', $likeSlug . $separator . '%');
});
if ( ! $includeTrashed && static::$slugsActiveColumn) {
$existing->where(static::$slugsActiveColumn, true);
}
if ($limitToLanguage) {
$existing->where(static::$slugsLanguageKey, $this->storeSlugForLanguageId());
}
$list = $existing->lists(static::$slugsColumn, static::$slugsEntryKey);
// Laravel 5.0/5.1 check
return $list instanceof Collection ? $list->all() : $list;
}
|
php
|
protected function getAllSlugsForModuleFromCmsTable($likeSlug = null, $limitToLanguage = true)
{
/** @var CmsModel|SluggableTrait $this */
$config = $this->getSluggableConfig();
$includeTrashed = $config['include_trashed'];
$separator = $config['separator'];
$existing = DB::table(static::$slugsTable)
->select([ 'id', static::$slugsColumn . ' as slug' ])
->where(static::$slugsModuleKey, $this->getModuleNumber())
->where(function ($query) use ($likeSlug, $separator) {
$query->where(static::$slugsColumn, $likeSlug);
$query->orWhere(static::$slugsColumn, 'LIKE', $likeSlug . $separator . '%');
});
if ( ! $includeTrashed && static::$slugsActiveColumn) {
$existing->where(static::$slugsActiveColumn, true);
}
if ($limitToLanguage) {
$existing->where(static::$slugsLanguageKey, $this->storeSlugForLanguageId());
}
$list = $existing->lists(static::$slugsColumn, static::$slugsEntryKey);
// Laravel 5.0/5.1 check
return $list instanceof Collection ? $list->all() : $list;
}
|
[
"protected",
"function",
"getAllSlugsForModuleFromCmsTable",
"(",
"$",
"likeSlug",
"=",
"null",
",",
"$",
"limitToLanguage",
"=",
"true",
")",
"{",
"/** @var CmsModel|SluggableTrait $this */",
"$",
"config",
"=",
"$",
"this",
"->",
"getSluggableConfig",
"(",
")",
";",
"$",
"includeTrashed",
"=",
"$",
"config",
"[",
"'include_trashed'",
"]",
";",
"$",
"separator",
"=",
"$",
"config",
"[",
"'separator'",
"]",
";",
"$",
"existing",
"=",
"DB",
"::",
"table",
"(",
"static",
"::",
"$",
"slugsTable",
")",
"->",
"select",
"(",
"[",
"'id'",
",",
"static",
"::",
"$",
"slugsColumn",
".",
"' as slug'",
"]",
")",
"->",
"where",
"(",
"static",
"::",
"$",
"slugsModuleKey",
",",
"$",
"this",
"->",
"getModuleNumber",
"(",
")",
")",
"->",
"where",
"(",
"function",
"(",
"$",
"query",
")",
"use",
"(",
"$",
"likeSlug",
",",
"$",
"separator",
")",
"{",
"$",
"query",
"->",
"where",
"(",
"static",
"::",
"$",
"slugsColumn",
",",
"$",
"likeSlug",
")",
";",
"$",
"query",
"->",
"orWhere",
"(",
"static",
"::",
"$",
"slugsColumn",
",",
"'LIKE'",
",",
"$",
"likeSlug",
".",
"$",
"separator",
".",
"'%'",
")",
";",
"}",
")",
";",
"if",
"(",
"!",
"$",
"includeTrashed",
"&&",
"static",
"::",
"$",
"slugsActiveColumn",
")",
"{",
"$",
"existing",
"->",
"where",
"(",
"static",
"::",
"$",
"slugsActiveColumn",
",",
"true",
")",
";",
"}",
"if",
"(",
"$",
"limitToLanguage",
")",
"{",
"$",
"existing",
"->",
"where",
"(",
"static",
"::",
"$",
"slugsLanguageKey",
",",
"$",
"this",
"->",
"storeSlugForLanguageId",
"(",
")",
")",
";",
"}",
"$",
"list",
"=",
"$",
"existing",
"->",
"lists",
"(",
"static",
"::",
"$",
"slugsColumn",
",",
"static",
"::",
"$",
"slugsEntryKey",
")",
";",
"// Laravel 5.0/5.1 check",
"return",
"$",
"list",
"instanceof",
"Collection",
"?",
"$",
"list",
"->",
"all",
"(",
")",
":",
"$",
"list",
";",
"}"
] |
Returns current slugs for this module from CMS slugs table
@param string $likeSlug if set, only returns slugs that are like the string
@param bool $limitToLanguage if true, only returns matches within the language
@return null|object
|
[
"Returns",
"current",
"slugs",
"for",
"this",
"module",
"from",
"CMS",
"slugs",
"table"
] |
train
|
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Sluggable/SluggableTrait.php#L266-L297
|
czim/laravel-pxlcms
|
src/Sluggable/SluggableTrait.php
|
SluggableTrait.setSlugInCmsTable
|
protected function setSlugInCmsTable($slug)
{
/** @var CmsModel|SluggableTrait $this */
$existing = $this->getSlugRecordFromCmsTable();
$languageId = $this->storeSlugForLanguageId();
// update if exists
if ($existing) {
DB::table(static::$slugsTable)
->where('id', $existing->id)
->update([ static::$slugsColumn => $slug ]);
return;
}
// if the model has no id, cannot store slug for it
if ( ! $this->exists) return;
$entryId = $this->isTranslationModel()
? $this->getAttribute(config('pxlcms.translatable.translation_foreign_key'))
: $this->getKey();
// create new entry
DB::table(static::$slugsTable)
->insert([
static::$slugsColumn => $slug,
static::$slugsModuleKey => $this->getModuleNumber(),
static::$slugsEntryKey => $entryId,
static::$slugsLanguageKey => $languageId,
]);
}
|
php
|
protected function setSlugInCmsTable($slug)
{
/** @var CmsModel|SluggableTrait $this */
$existing = $this->getSlugRecordFromCmsTable();
$languageId = $this->storeSlugForLanguageId();
// update if exists
if ($existing) {
DB::table(static::$slugsTable)
->where('id', $existing->id)
->update([ static::$slugsColumn => $slug ]);
return;
}
// if the model has no id, cannot store slug for it
if ( ! $this->exists) return;
$entryId = $this->isTranslationModel()
? $this->getAttribute(config('pxlcms.translatable.translation_foreign_key'))
: $this->getKey();
// create new entry
DB::table(static::$slugsTable)
->insert([
static::$slugsColumn => $slug,
static::$slugsModuleKey => $this->getModuleNumber(),
static::$slugsEntryKey => $entryId,
static::$slugsLanguageKey => $languageId,
]);
}
|
[
"protected",
"function",
"setSlugInCmsTable",
"(",
"$",
"slug",
")",
"{",
"/** @var CmsModel|SluggableTrait $this */",
"$",
"existing",
"=",
"$",
"this",
"->",
"getSlugRecordFromCmsTable",
"(",
")",
";",
"$",
"languageId",
"=",
"$",
"this",
"->",
"storeSlugForLanguageId",
"(",
")",
";",
"// update if exists",
"if",
"(",
"$",
"existing",
")",
"{",
"DB",
"::",
"table",
"(",
"static",
"::",
"$",
"slugsTable",
")",
"->",
"where",
"(",
"'id'",
",",
"$",
"existing",
"->",
"id",
")",
"->",
"update",
"(",
"[",
"static",
"::",
"$",
"slugsColumn",
"=>",
"$",
"slug",
"]",
")",
";",
"return",
";",
"}",
"// if the model has no id, cannot store slug for it",
"if",
"(",
"!",
"$",
"this",
"->",
"exists",
")",
"return",
";",
"$",
"entryId",
"=",
"$",
"this",
"->",
"isTranslationModel",
"(",
")",
"?",
"$",
"this",
"->",
"getAttribute",
"(",
"config",
"(",
"'pxlcms.translatable.translation_foreign_key'",
")",
")",
":",
"$",
"this",
"->",
"getKey",
"(",
")",
";",
"// create new entry",
"DB",
"::",
"table",
"(",
"static",
"::",
"$",
"slugsTable",
")",
"->",
"insert",
"(",
"[",
"static",
"::",
"$",
"slugsColumn",
"=>",
"$",
"slug",
",",
"static",
"::",
"$",
"slugsModuleKey",
"=>",
"$",
"this",
"->",
"getModuleNumber",
"(",
")",
",",
"static",
"::",
"$",
"slugsEntryKey",
"=>",
"$",
"entryId",
",",
"static",
"::",
"$",
"slugsLanguageKey",
"=>",
"$",
"languageId",
",",
"]",
")",
";",
"}"
] |
Update / store slug in dedicated table
@param string $slug
|
[
"Update",
"/",
"store",
"slug",
"in",
"dedicated",
"table"
] |
train
|
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Sluggable/SluggableTrait.php#L317-L348
|
czim/laravel-pxlcms
|
src/Sluggable/SluggableTrait.php
|
SluggableTrait.storeSlugForLanguageId
|
protected function storeSlugForLanguageId()
{
/** @var CmsModel|SluggableTrait $this */
$config = $this->getSluggableConfig();
$languageKey = array_get($config, 'language_key');
$localeKey = array_get($config, 'locale_key');
if ($languageKey) {
return $this->getAttribute($languageKey);
}
if ($localeKey) {
return $this->lookupLanguageIdForLocale( $this->getAttribute($localeKey) );
}
return null;
}
|
php
|
protected function storeSlugForLanguageId()
{
/** @var CmsModel|SluggableTrait $this */
$config = $this->getSluggableConfig();
$languageKey = array_get($config, 'language_key');
$localeKey = array_get($config, 'locale_key');
if ($languageKey) {
return $this->getAttribute($languageKey);
}
if ($localeKey) {
return $this->lookupLanguageIdForLocale( $this->getAttribute($localeKey) );
}
return null;
}
|
[
"protected",
"function",
"storeSlugForLanguageId",
"(",
")",
"{",
"/** @var CmsModel|SluggableTrait $this */",
"$",
"config",
"=",
"$",
"this",
"->",
"getSluggableConfig",
"(",
")",
";",
"$",
"languageKey",
"=",
"array_get",
"(",
"$",
"config",
",",
"'language_key'",
")",
";",
"$",
"localeKey",
"=",
"array_get",
"(",
"$",
"config",
",",
"'locale_key'",
")",
";",
"if",
"(",
"$",
"languageKey",
")",
"{",
"return",
"$",
"this",
"->",
"getAttribute",
"(",
"$",
"languageKey",
")",
";",
"}",
"if",
"(",
"$",
"localeKey",
")",
"{",
"return",
"$",
"this",
"->",
"lookupLanguageIdForLocale",
"(",
"$",
"this",
"->",
"getAttribute",
"(",
"$",
"localeKey",
")",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Returns the language_id to store slugs for
@return string
|
[
"Returns",
"the",
"language_id",
"to",
"store",
"slugs",
"for"
] |
train
|
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Sluggable/SluggableTrait.php#L365-L382
|
GokulSrinivas/Sangria
|
src/Sangria/LDAPAuth.php
|
LDAPAuth.auth
|
public static function auth($user_name, $user_pass)
{
try
{
$ldap_server_address = __SANGRIA_LDAP_SERVER_ADDR__;
$ldapconn = \ldap_connect($ldap_server_address)
or $this->throwException("Could not connect to LDAP Server");
\ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
\ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0);
$ldapbind = @ldap_bind($ldapconn,$user_name,$user_pass);
if($ldapbind)
{
return true;
}
return false;
}
catch(SangriaException $e)
{
echo $e->getMessage();
return false;
}
}
|
php
|
public static function auth($user_name, $user_pass)
{
try
{
$ldap_server_address = __SANGRIA_LDAP_SERVER_ADDR__;
$ldapconn = \ldap_connect($ldap_server_address)
or $this->throwException("Could not connect to LDAP Server");
\ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
\ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0);
$ldapbind = @ldap_bind($ldapconn,$user_name,$user_pass);
if($ldapbind)
{
return true;
}
return false;
}
catch(SangriaException $e)
{
echo $e->getMessage();
return false;
}
}
|
[
"public",
"static",
"function",
"auth",
"(",
"$",
"user_name",
",",
"$",
"user_pass",
")",
"{",
"try",
"{",
"$",
"ldap_server_address",
"=",
"__SANGRIA_LDAP_SERVER_ADDR__",
";",
"$",
"ldapconn",
"=",
"\\",
"ldap_connect",
"(",
"$",
"ldap_server_address",
")",
"or",
"$",
"this",
"->",
"throwException",
"(",
"\"Could not connect to LDAP Server\"",
")",
";",
"\\",
"ldap_set_option",
"(",
"$",
"ldapconn",
",",
"LDAP_OPT_PROTOCOL_VERSION",
",",
"3",
")",
";",
"\\",
"ldap_set_option",
"(",
"$",
"ldapconn",
",",
"LDAP_OPT_REFERRALS",
",",
"0",
")",
";",
"$",
"ldapbind",
"=",
"@",
"ldap_bind",
"(",
"$",
"ldapconn",
",",
"$",
"user_name",
",",
"$",
"user_pass",
")",
";",
"if",
"(",
"$",
"ldapbind",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}",
"catch",
"(",
"SangriaException",
"$",
"e",
")",
"{",
"echo",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"return",
"false",
";",
"}",
"}"
] |
[auth Tries to authenticate a user with an LDAP server]
@param string $user_name [username]
@param string $user_pass [password]
@return boolean [true if authenticated, false if not]
|
[
"[",
"auth",
"Tries",
"to",
"authenticate",
"a",
"user",
"with",
"an",
"LDAP",
"server",
"]"
] |
train
|
https://github.com/GokulSrinivas/Sangria/blob/e69076655da30ef74b9b6f4a7b7317b3d37d5710/src/Sangria/LDAPAuth.php#L25-L50
|
Wonail/wocenter
|
actions/FlushCache.php
|
FlushCache.flushCache
|
protected function flushCache(Module $current = null)
{
$message = '';
if ($current === null) {
$current = Yii::$app;
}
$modules = $current->getModules();
foreach ($modules as $moduleName => $module) {
if (is_array($module)) {
$module = $current->getModule($moduleName, true);
}
if ($module instanceof Module) {
$message .= $this->flushCache($module);
}
}
$components = $current->getComponents();
foreach ($components as $componentName => $component) {
if (is_array($component) && $componentName != 'user') {
$component = $current->get($componentName);
}
if ($component instanceof Cache) {
$message .= $component->flush() ?
'<p>' . Yii::t(
'wocenter/app', '{currentModuleName}: {componentName} is flushed.', [
'currentModuleName' => $current->className(),
'componentName' => $component->className(),
]
) . '</p>' :
'';
}
}
return $message;
}
|
php
|
protected function flushCache(Module $current = null)
{
$message = '';
if ($current === null) {
$current = Yii::$app;
}
$modules = $current->getModules();
foreach ($modules as $moduleName => $module) {
if (is_array($module)) {
$module = $current->getModule($moduleName, true);
}
if ($module instanceof Module) {
$message .= $this->flushCache($module);
}
}
$components = $current->getComponents();
foreach ($components as $componentName => $component) {
if (is_array($component) && $componentName != 'user') {
$component = $current->get($componentName);
}
if ($component instanceof Cache) {
$message .= $component->flush() ?
'<p>' . Yii::t(
'wocenter/app', '{currentModuleName}: {componentName} is flushed.', [
'currentModuleName' => $current->className(),
'componentName' => $component->className(),
]
) . '</p>' :
'';
}
}
return $message;
}
|
[
"protected",
"function",
"flushCache",
"(",
"Module",
"$",
"current",
"=",
"null",
")",
"{",
"$",
"message",
"=",
"''",
";",
"if",
"(",
"$",
"current",
"===",
"null",
")",
"{",
"$",
"current",
"=",
"Yii",
"::",
"$",
"app",
";",
"}",
"$",
"modules",
"=",
"$",
"current",
"->",
"getModules",
"(",
")",
";",
"foreach",
"(",
"$",
"modules",
"as",
"$",
"moduleName",
"=>",
"$",
"module",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"module",
")",
")",
"{",
"$",
"module",
"=",
"$",
"current",
"->",
"getModule",
"(",
"$",
"moduleName",
",",
"true",
")",
";",
"}",
"if",
"(",
"$",
"module",
"instanceof",
"Module",
")",
"{",
"$",
"message",
".=",
"$",
"this",
"->",
"flushCache",
"(",
"$",
"module",
")",
";",
"}",
"}",
"$",
"components",
"=",
"$",
"current",
"->",
"getComponents",
"(",
")",
";",
"foreach",
"(",
"$",
"components",
"as",
"$",
"componentName",
"=>",
"$",
"component",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"component",
")",
"&&",
"$",
"componentName",
"!=",
"'user'",
")",
"{",
"$",
"component",
"=",
"$",
"current",
"->",
"get",
"(",
"$",
"componentName",
")",
";",
"}",
"if",
"(",
"$",
"component",
"instanceof",
"Cache",
")",
"{",
"$",
"message",
".=",
"$",
"component",
"->",
"flush",
"(",
")",
"?",
"'<p>'",
".",
"Yii",
"::",
"t",
"(",
"'wocenter/app'",
",",
"'{currentModuleName}: {componentName} is flushed.'",
",",
"[",
"'currentModuleName'",
"=>",
"$",
"current",
"->",
"className",
"(",
")",
",",
"'componentName'",
"=>",
"$",
"component",
"->",
"className",
"(",
")",
",",
"]",
")",
".",
"'</p>'",
":",
"''",
";",
"}",
"}",
"return",
"$",
"message",
";",
"}"
] |
Recursive flush all app cache
@param null|Module $current Current Module
@return string execute message
|
[
"Recursive",
"flush",
"all",
"app",
"cache"
] |
train
|
https://github.com/Wonail/wocenter/blob/186c15aad008d32fbf5ad75256cf01581dccf9e6/actions/FlushCache.php#L40-L73
|
Wonail/wocenter
|
actions/FlushCache.php
|
FlushCache.flushAssets
|
protected function flushAssets()
{
$message = '';
$except = [Yii::getAlias('@webroot/assets/.gitignore'), Yii::getAlias('@webroot/assets/index.html')];
$dir = Yii::getAlias('@webroot/assets');
$it = new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS);
/* @var RecursiveDirectoryIterator[] $files */
$files = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
$hasErrors = false;
if (stristr(PHP_OS, 'WIN') === false) {
foreach ($files as $file) {
if (!in_array($file->getRealPath(), $except)) {
if ($file->isDir() && $file->isLink() === false) {
$result = @rmdir($file->getRealPath());
} elseif ($file->isLink() === true) {
$result = @unlink($file->getPath() . DIRECTORY_SEPARATOR . $file->getFilename());
} else {
$result = @unlink($file->getRealPath());
}
if (!$result) {
$hasErrors = true;
}
}
}
}
$message .= $hasErrors ?
'<p>' . Yii::t('wocenter/app', 'Some assets are not flushed.') . '</p>' :
'<p>' . Yii::t('wocenter/app', 'Assets are flushed.') . '</p>';
return $message;
}
|
php
|
protected function flushAssets()
{
$message = '';
$except = [Yii::getAlias('@webroot/assets/.gitignore'), Yii::getAlias('@webroot/assets/index.html')];
$dir = Yii::getAlias('@webroot/assets');
$it = new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS);
/* @var RecursiveDirectoryIterator[] $files */
$files = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
$hasErrors = false;
if (stristr(PHP_OS, 'WIN') === false) {
foreach ($files as $file) {
if (!in_array($file->getRealPath(), $except)) {
if ($file->isDir() && $file->isLink() === false) {
$result = @rmdir($file->getRealPath());
} elseif ($file->isLink() === true) {
$result = @unlink($file->getPath() . DIRECTORY_SEPARATOR . $file->getFilename());
} else {
$result = @unlink($file->getRealPath());
}
if (!$result) {
$hasErrors = true;
}
}
}
}
$message .= $hasErrors ?
'<p>' . Yii::t('wocenter/app', 'Some assets are not flushed.') . '</p>' :
'<p>' . Yii::t('wocenter/app', 'Assets are flushed.') . '</p>';
return $message;
}
|
[
"protected",
"function",
"flushAssets",
"(",
")",
"{",
"$",
"message",
"=",
"''",
";",
"$",
"except",
"=",
"[",
"Yii",
"::",
"getAlias",
"(",
"'@webroot/assets/.gitignore'",
")",
",",
"Yii",
"::",
"getAlias",
"(",
"'@webroot/assets/index.html'",
")",
"]",
";",
"$",
"dir",
"=",
"Yii",
"::",
"getAlias",
"(",
"'@webroot/assets'",
")",
";",
"$",
"it",
"=",
"new",
"RecursiveDirectoryIterator",
"(",
"$",
"dir",
",",
"RecursiveDirectoryIterator",
"::",
"SKIP_DOTS",
")",
";",
"/* @var RecursiveDirectoryIterator[] $files */",
"$",
"files",
"=",
"new",
"RecursiveIteratorIterator",
"(",
"$",
"it",
",",
"RecursiveIteratorIterator",
"::",
"CHILD_FIRST",
")",
";",
"$",
"hasErrors",
"=",
"false",
";",
"if",
"(",
"stristr",
"(",
"PHP_OS",
",",
"'WIN'",
")",
"===",
"false",
")",
"{",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"file",
"->",
"getRealPath",
"(",
")",
",",
"$",
"except",
")",
")",
"{",
"if",
"(",
"$",
"file",
"->",
"isDir",
"(",
")",
"&&",
"$",
"file",
"->",
"isLink",
"(",
")",
"===",
"false",
")",
"{",
"$",
"result",
"=",
"@",
"rmdir",
"(",
"$",
"file",
"->",
"getRealPath",
"(",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"file",
"->",
"isLink",
"(",
")",
"===",
"true",
")",
"{",
"$",
"result",
"=",
"@",
"unlink",
"(",
"$",
"file",
"->",
"getPath",
"(",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"file",
"->",
"getFilename",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"@",
"unlink",
"(",
"$",
"file",
"->",
"getRealPath",
"(",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"result",
")",
"{",
"$",
"hasErrors",
"=",
"true",
";",
"}",
"}",
"}",
"}",
"$",
"message",
".=",
"$",
"hasErrors",
"?",
"'<p>'",
".",
"Yii",
"::",
"t",
"(",
"'wocenter/app'",
",",
"'Some assets are not flushed.'",
")",
".",
"'</p>'",
":",
"'<p>'",
".",
"Yii",
"::",
"t",
"(",
"'wocenter/app'",
",",
"'Assets are flushed.'",
")",
".",
"'</p>'",
";",
"return",
"$",
"message",
";",
"}"
] |
Flush webroot/assets/
@return string execute message
|
[
"Flush",
"webroot",
"/",
"assets",
"/"
] |
train
|
https://github.com/Wonail/wocenter/blob/186c15aad008d32fbf5ad75256cf01581dccf9e6/actions/FlushCache.php#L80-L110
|
phramework/jsonapi
|
src/Viewers/JSONAPI.php
|
JSONAPI.view
|
public function view($parameters)
{
self::header();
if (!is_object($parameters)) {
$parameters = (object)$parameters;
}
//Include JSON API version object
$parameters->jsonapi = (object)[
'version' => '1.0'
];
echo json_encode($parameters);
}
|
php
|
public function view($parameters)
{
self::header();
if (!is_object($parameters)) {
$parameters = (object)$parameters;
}
//Include JSON API version object
$parameters->jsonapi = (object)[
'version' => '1.0'
];
echo json_encode($parameters);
}
|
[
"public",
"function",
"view",
"(",
"$",
"parameters",
")",
"{",
"self",
"::",
"header",
"(",
")",
";",
"if",
"(",
"!",
"is_object",
"(",
"$",
"parameters",
")",
")",
"{",
"$",
"parameters",
"=",
"(",
"object",
")",
"$",
"parameters",
";",
"}",
"//Include JSON API version object",
"$",
"parameters",
"->",
"jsonapi",
"=",
"(",
"object",
")",
"[",
"'version'",
"=>",
"'1.0'",
"]",
";",
"echo",
"json_encode",
"(",
"$",
"parameters",
")",
";",
"}"
] |
Send output
@param object|array $parameters Output to display as json
|
[
"Send",
"output"
] |
train
|
https://github.com/phramework/jsonapi/blob/af20882a8b6f6e5be9c8e09e5b87f6c23a4b0726/src/Viewers/JSONAPI.php#L39-L53
|
JoffreyPoreeCoding/MongoDB-ODM
|
src/Tools/ArrayModifier.php
|
ArrayModifier.clearNullValues
|
public static function clearNullValues(&$array)
{
foreach ($array as $key => &$value) {
if (null === $value) {
unset($array[$key]);
} else if (is_array($value)) {
self::clearNullValues($value);
if (empty($value)) {
unset($array[$key]);
}
}
}
return $array;
}
|
php
|
public static function clearNullValues(&$array)
{
foreach ($array as $key => &$value) {
if (null === $value) {
unset($array[$key]);
} else if (is_array($value)) {
self::clearNullValues($value);
if (empty($value)) {
unset($array[$key]);
}
}
}
return $array;
}
|
[
"public",
"static",
"function",
"clearNullValues",
"(",
"&",
"$",
"array",
")",
"{",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"&",
"$",
"value",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"value",
")",
"{",
"unset",
"(",
"$",
"array",
"[",
"$",
"key",
"]",
")",
";",
"}",
"else",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"self",
"::",
"clearNullValues",
"(",
"$",
"value",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"unset",
"(",
"$",
"array",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"}",
"return",
"$",
"array",
";",
"}"
] |
Clear all null values of an array (and sub-arrays)
@param array $array Array to clear
@return array Array cleaned
|
[
"Clear",
"all",
"null",
"values",
"of",
"an",
"array",
"(",
"and",
"sub",
"-",
"arrays",
")"
] |
train
|
https://github.com/JoffreyPoreeCoding/MongoDB-ODM/blob/56fd7ab28c22f276573a89d56bb93c8d74ad7f74/src/Tools/ArrayModifier.php#L20-L34
|
JoffreyPoreeCoding/MongoDB-ODM
|
src/Tools/ArrayModifier.php
|
ArrayModifier.aggregate
|
public static function aggregate($array, $specialKeys = self::SPECIALS_KEYS, $prefix = '')
{
$new = [];
foreach ($array as $key => $value) {
$newKey = (!empty($prefix)) ? $prefix . '.' . $key : $key;
if (!in_array($key, $specialKeys, true) && !in_array($key, array_keys($specialKeys), true)) {
if (is_a($value, "stdClass")) {
$value = (array) $value;
}
if (is_array($value)) {
$new += self::aggregate($value, $specialKeys, $newKey);
} else {
$new[$newKey] = $value;
}
} else {
if (array_key_exists($key, $specialKeys) && is_callable($specialKeys[$key])) {
$new = call_user_func($specialKeys[$key], $prefix, $key, $value, $new);
}
}
}
return $new;
}
|
php
|
public static function aggregate($array, $specialKeys = self::SPECIALS_KEYS, $prefix = '')
{
$new = [];
foreach ($array as $key => $value) {
$newKey = (!empty($prefix)) ? $prefix . '.' . $key : $key;
if (!in_array($key, $specialKeys, true) && !in_array($key, array_keys($specialKeys), true)) {
if (is_a($value, "stdClass")) {
$value = (array) $value;
}
if (is_array($value)) {
$new += self::aggregate($value, $specialKeys, $newKey);
} else {
$new[$newKey] = $value;
}
} else {
if (array_key_exists($key, $specialKeys) && is_callable($specialKeys[$key])) {
$new = call_user_func($specialKeys[$key], $prefix, $key, $value, $new);
}
}
}
return $new;
}
|
[
"public",
"static",
"function",
"aggregate",
"(",
"$",
"array",
",",
"$",
"specialKeys",
"=",
"self",
"::",
"SPECIALS_KEYS",
",",
"$",
"prefix",
"=",
"''",
")",
"{",
"$",
"new",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"newKey",
"=",
"(",
"!",
"empty",
"(",
"$",
"prefix",
")",
")",
"?",
"$",
"prefix",
".",
"'.'",
".",
"$",
"key",
":",
"$",
"key",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"key",
",",
"$",
"specialKeys",
",",
"true",
")",
"&&",
"!",
"in_array",
"(",
"$",
"key",
",",
"array_keys",
"(",
"$",
"specialKeys",
")",
",",
"true",
")",
")",
"{",
"if",
"(",
"is_a",
"(",
"$",
"value",
",",
"\"stdClass\"",
")",
")",
"{",
"$",
"value",
"=",
"(",
"array",
")",
"$",
"value",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"new",
"+=",
"self",
"::",
"aggregate",
"(",
"$",
"value",
",",
"$",
"specialKeys",
",",
"$",
"newKey",
")",
";",
"}",
"else",
"{",
"$",
"new",
"[",
"$",
"newKey",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"specialKeys",
")",
"&&",
"is_callable",
"(",
"$",
"specialKeys",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"new",
"=",
"call_user_func",
"(",
"$",
"specialKeys",
"[",
"$",
"key",
"]",
",",
"$",
"prefix",
",",
"$",
"key",
",",
"$",
"value",
",",
"$",
"new",
")",
";",
"}",
"}",
"}",
"return",
"$",
"new",
";",
"}"
] |
Aggregate an array to dot notation
@param array $array Input array
@param array $specialKeys array of key to not aggregate
@param string $prefix prefix
@return array
|
[
"Aggregate",
"an",
"array",
"to",
"dot",
"notation"
] |
train
|
https://github.com/JoffreyPoreeCoding/MongoDB-ODM/blob/56fd7ab28c22f276573a89d56bb93c8d74ad7f74/src/Tools/ArrayModifier.php#L44-L67
|
JoffreyPoreeCoding/MongoDB-ODM
|
src/Tools/ArrayModifier.php
|
ArrayModifier.disaggregate
|
public static function disaggregate($array)
{
$new = [];
foreach ($array as $key => $val) {
if (false !== strpos($key, ".")) {
list($realKey, $aggregated) = explode(".", $key, 2);
$values = self::getDisaggregatedValues(preg_grep("/^$realKey/", array_keys($array)), $array);
$new[$realKey] = self::disaggregate($values);
} else {
$new[$key] = $val;
}
}
return $new;
}
|
php
|
public static function disaggregate($array)
{
$new = [];
foreach ($array as $key => $val) {
if (false !== strpos($key, ".")) {
list($realKey, $aggregated) = explode(".", $key, 2);
$values = self::getDisaggregatedValues(preg_grep("/^$realKey/", array_keys($array)), $array);
$new[$realKey] = self::disaggregate($values);
} else {
$new[$key] = $val;
}
}
return $new;
}
|
[
"public",
"static",
"function",
"disaggregate",
"(",
"$",
"array",
")",
"{",
"$",
"new",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"false",
"!==",
"strpos",
"(",
"$",
"key",
",",
"\".\"",
")",
")",
"{",
"list",
"(",
"$",
"realKey",
",",
"$",
"aggregated",
")",
"=",
"explode",
"(",
"\".\"",
",",
"$",
"key",
",",
"2",
")",
";",
"$",
"values",
"=",
"self",
"::",
"getDisaggregatedValues",
"(",
"preg_grep",
"(",
"\"/^$realKey/\"",
",",
"array_keys",
"(",
"$",
"array",
")",
")",
",",
"$",
"array",
")",
";",
"$",
"new",
"[",
"$",
"realKey",
"]",
"=",
"self",
"::",
"disaggregate",
"(",
"$",
"values",
")",
";",
"}",
"else",
"{",
"$",
"new",
"[",
"$",
"key",
"]",
"=",
"$",
"val",
";",
"}",
"}",
"return",
"$",
"new",
";",
"}"
] |
Disaggreate a dot notation array to an multi-dimensionnal array
@param array $array Dot notation array
@return void
|
[
"Disaggreate",
"a",
"dot",
"notation",
"array",
"to",
"an",
"multi",
"-",
"dimensionnal",
"array"
] |
train
|
https://github.com/JoffreyPoreeCoding/MongoDB-ODM/blob/56fd7ab28c22f276573a89d56bb93c8d74ad7f74/src/Tools/ArrayModifier.php#L75-L89
|
JoffreyPoreeCoding/MongoDB-ODM
|
src/Tools/ArrayModifier.php
|
ArrayModifier.getDisaggregatedValues
|
private static function getDisaggregatedValues($keys, $array)
{
$values = [];
foreach ($keys as $key) {
$realKey = explode(".", $key, 2)[1];
$values[$realKey] = $array[$key];
}
return $values;
}
|
php
|
private static function getDisaggregatedValues($keys, $array)
{
$values = [];
foreach ($keys as $key) {
$realKey = explode(".", $key, 2)[1];
$values[$realKey] = $array[$key];
}
return $values;
}
|
[
"private",
"static",
"function",
"getDisaggregatedValues",
"(",
"$",
"keys",
",",
"$",
"array",
")",
"{",
"$",
"values",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"$",
"realKey",
"=",
"explode",
"(",
"\".\"",
",",
"$",
"key",
",",
"2",
")",
"[",
"1",
"]",
";",
"$",
"values",
"[",
"$",
"realKey",
"]",
"=",
"$",
"array",
"[",
"$",
"key",
"]",
";",
"}",
"return",
"$",
"values",
";",
"}"
] |
Get values of disaggregated array
@param array $keys Key
@param array $array Array to disaggegate
@return array
|
[
"Get",
"values",
"of",
"disaggregated",
"array"
] |
train
|
https://github.com/JoffreyPoreeCoding/MongoDB-ODM/blob/56fd7ab28c22f276573a89d56bb93c8d74ad7f74/src/Tools/ArrayModifier.php#L98-L106
|
acasademont/wurfl
|
WURFL/Handlers/Handler.php
|
WURFL_Handlers_Handler.filter
|
public function filter($userAgent, $deviceID)
{
if ($this->canHandle($userAgent)) {
$this->updateUserAgentsWithDeviceIDMap($userAgent, $deviceID);
return null;
}
if (isset($this->nextHandler)) {
return $this->nextHandler->filter($userAgent, $deviceID);
}
return null;
}
|
php
|
public function filter($userAgent, $deviceID)
{
if ($this->canHandle($userAgent)) {
$this->updateUserAgentsWithDeviceIDMap($userAgent, $deviceID);
return null;
}
if (isset($this->nextHandler)) {
return $this->nextHandler->filter($userAgent, $deviceID);
}
return null;
}
|
[
"public",
"function",
"filter",
"(",
"$",
"userAgent",
",",
"$",
"deviceID",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"canHandle",
"(",
"$",
"userAgent",
")",
")",
"{",
"$",
"this",
"->",
"updateUserAgentsWithDeviceIDMap",
"(",
"$",
"userAgent",
",",
"$",
"deviceID",
")",
";",
"return",
"null",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"nextHandler",
")",
")",
"{",
"return",
"$",
"this",
"->",
"nextHandler",
"->",
"filter",
"(",
"$",
"userAgent",
",",
"$",
"deviceID",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Classifies the given $userAgent and specified $deviceID
@param string $userAgent
@param string $deviceID
@return null
|
[
"Classifies",
"the",
"given",
"$userAgent",
"and",
"specified",
"$deviceID"
] |
train
|
https://github.com/acasademont/wurfl/blob/0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2/WURFL/Handlers/Handler.php#L130-L140
|
acasademont/wurfl
|
WURFL/Handlers/Handler.php
|
WURFL_Handlers_Handler.persistData
|
public function persistData()
{
// we sort the array first, useful for doing ris match
if (!empty($this->userAgentsWithDeviceID)) {
ksort($this->userAgentsWithDeviceID);
$this->persistenceProvider->save($this->getPrefix(), $this->userAgentsWithDeviceID);
}
}
|
php
|
public function persistData()
{
// we sort the array first, useful for doing ris match
if (!empty($this->userAgentsWithDeviceID)) {
ksort($this->userAgentsWithDeviceID);
$this->persistenceProvider->save($this->getPrefix(), $this->userAgentsWithDeviceID);
}
}
|
[
"public",
"function",
"persistData",
"(",
")",
"{",
"// we sort the array first, useful for doing ris match",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"userAgentsWithDeviceID",
")",
")",
"{",
"ksort",
"(",
"$",
"this",
"->",
"userAgentsWithDeviceID",
")",
";",
"$",
"this",
"->",
"persistenceProvider",
"->",
"save",
"(",
"$",
"this",
"->",
"getPrefix",
"(",
")",
",",
"$",
"this",
"->",
"userAgentsWithDeviceID",
")",
";",
"}",
"}"
] |
Saves the classified user agents in the persistence provider
|
[
"Saves",
"the",
"classified",
"user",
"agents",
"in",
"the",
"persistence",
"provider"
] |
train
|
https://github.com/acasademont/wurfl/blob/0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2/WURFL/Handlers/Handler.php#L179-L186
|
acasademont/wurfl
|
WURFL/Handlers/Handler.php
|
WURFL_Handlers_Handler.getUserAgentsWithDeviceId
|
public function getUserAgentsWithDeviceId()
{
if (!isset($this->userAgentsWithDeviceID)) {
$this->userAgentsWithDeviceID = $this->persistenceProvider->load($this->getPrefix());
}
return $this->userAgentsWithDeviceID;
}
|
php
|
public function getUserAgentsWithDeviceId()
{
if (!isset($this->userAgentsWithDeviceID)) {
$this->userAgentsWithDeviceID = $this->persistenceProvider->load($this->getPrefix());
}
return $this->userAgentsWithDeviceID;
}
|
[
"public",
"function",
"getUserAgentsWithDeviceId",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"userAgentsWithDeviceID",
")",
")",
"{",
"$",
"this",
"->",
"userAgentsWithDeviceID",
"=",
"$",
"this",
"->",
"persistenceProvider",
"->",
"load",
"(",
"$",
"this",
"->",
"getPrefix",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"userAgentsWithDeviceID",
";",
"}"
] |
Returns a list of User Agents with their Device IDs
@return array User agents and device IDs
|
[
"Returns",
"a",
"list",
"of",
"User",
"Agents",
"with",
"their",
"Device",
"IDs"
] |
train
|
https://github.com/acasademont/wurfl/blob/0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2/WURFL/Handlers/Handler.php#L192-L198
|
acasademont/wurfl
|
WURFL/Handlers/Handler.php
|
WURFL_Handlers_Handler.match
|
public function match(WURFL_Request_GenericRequest $request)
{
if ($this->canHandle($request->userAgentNormalized)) {
return $this->applyMatch($request);
}
if (isset($this->nextHandler)) {
return $this->nextHandler->match($request);
}
return WURFL_Constants::GENERIC;
}
|
php
|
public function match(WURFL_Request_GenericRequest $request)
{
if ($this->canHandle($request->userAgentNormalized)) {
return $this->applyMatch($request);
}
if (isset($this->nextHandler)) {
return $this->nextHandler->match($request);
}
return WURFL_Constants::GENERIC;
}
|
[
"public",
"function",
"match",
"(",
"WURFL_Request_GenericRequest",
"$",
"request",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"canHandle",
"(",
"$",
"request",
"->",
"userAgentNormalized",
")",
")",
"{",
"return",
"$",
"this",
"->",
"applyMatch",
"(",
"$",
"request",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"nextHandler",
")",
")",
"{",
"return",
"$",
"this",
"->",
"nextHandler",
"->",
"match",
"(",
"$",
"request",
")",
";",
"}",
"return",
"WURFL_Constants",
"::",
"GENERIC",
";",
"}"
] |
Finds the device id for the given request - if it is not found it
delegates to the next available handler
@param WURFL_Request_GenericRequest $request
@return string WURFL Device ID for matching device
|
[
"Finds",
"the",
"device",
"id",
"for",
"the",
"given",
"request",
"-",
"if",
"it",
"is",
"not",
"found",
"it",
"delegates",
"to",
"the",
"next",
"available",
"handler"
] |
train
|
https://github.com/acasademont/wurfl/blob/0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2/WURFL/Handlers/Handler.php#L211-L222
|
acasademont/wurfl
|
WURFL/Handlers/Handler.php
|
WURFL_Handlers_Handler.applyMatch
|
public function applyMatch(WURFL_Request_GenericRequest $request)
{
$class_name = get_class($this);
$request->matchInfo->matcher = $class_name;
$start_time = microtime(true);
$request->matchInfo->cleaned_user_agent = $request->userAgentNormalized;
$userAgent = $this->normalizeUserAgent($request->userAgentNormalized);
$request->matchInfo->normalized_user_agent = $userAgent;
$this->logger->debug("START: Matching For " . $userAgent);
// Get The data associated with this current handler
$this->userAgentsWithDeviceID = $this->persistenceProvider->load($this->getPrefix());
if (!is_array($this->userAgentsWithDeviceID)) {
$this->userAgentsWithDeviceID = array();
}
$deviceID = null;
// Start with an Exact match
$request->matchInfo->matcher_history .= "$class_name(exact),";
$request->matchInfo->match_type = 'exact';
$deviceID = $this->applyExactMatch($userAgent);
// Try with the conclusive Match
if ($this->isBlankOrGeneric($deviceID)) {
$request->matchInfo->matcher_history .= "$class_name(conclusive),";
$this->logger->debug("$this->prefix :Applying Conclusive Match for ua: $userAgent");
$deviceID = $this->applyConclusiveMatch($userAgent);
// Try with recovery match
if ($this->isBlankOrGeneric($deviceID)) {
// Log the ua and the ua profile
//$this->logger->debug($request);
$request->matchInfo->match_type = 'recovery';
$request->matchInfo->matcher_history .= "$class_name(recovery),";
$this->logger->debug("$this->prefix :Applying Recovery Match for ua: $userAgent");
$deviceID = $this->applyRecoveryMatch($userAgent);
// Try with catch all recovery Match
if ($this->isBlankOrGeneric($deviceID)) {
$request->matchInfo->match_type = 'recovery-catchall';
$request->matchInfo->matcher_history .= "$class_name(recovery-catchall),";
$this->logger->debug("$this->prefix :Applying Catch All Recovery Match for ua: $userAgent");
$deviceID = $this->applyRecoveryCatchAllMatch($userAgent);
// All attempts to match have failed
if ($this->isBlankOrGeneric($deviceID)) {
$request->matchInfo->match_type = 'none';
if ($request->userAgentProfile) {
$deviceID = WURFL_Constants::GENERIC_MOBILE;
} else {
$deviceID = WURFL_Constants::GENERIC;
}
}
}
}
}
$this->logger->debug("END: Matching For " . $userAgent);
$request->matchInfo->lookup_time = microtime(true) - $start_time;
return $deviceID;
}
|
php
|
public function applyMatch(WURFL_Request_GenericRequest $request)
{
$class_name = get_class($this);
$request->matchInfo->matcher = $class_name;
$start_time = microtime(true);
$request->matchInfo->cleaned_user_agent = $request->userAgentNormalized;
$userAgent = $this->normalizeUserAgent($request->userAgentNormalized);
$request->matchInfo->normalized_user_agent = $userAgent;
$this->logger->debug("START: Matching For " . $userAgent);
// Get The data associated with this current handler
$this->userAgentsWithDeviceID = $this->persistenceProvider->load($this->getPrefix());
if (!is_array($this->userAgentsWithDeviceID)) {
$this->userAgentsWithDeviceID = array();
}
$deviceID = null;
// Start with an Exact match
$request->matchInfo->matcher_history .= "$class_name(exact),";
$request->matchInfo->match_type = 'exact';
$deviceID = $this->applyExactMatch($userAgent);
// Try with the conclusive Match
if ($this->isBlankOrGeneric($deviceID)) {
$request->matchInfo->matcher_history .= "$class_name(conclusive),";
$this->logger->debug("$this->prefix :Applying Conclusive Match for ua: $userAgent");
$deviceID = $this->applyConclusiveMatch($userAgent);
// Try with recovery match
if ($this->isBlankOrGeneric($deviceID)) {
// Log the ua and the ua profile
//$this->logger->debug($request);
$request->matchInfo->match_type = 'recovery';
$request->matchInfo->matcher_history .= "$class_name(recovery),";
$this->logger->debug("$this->prefix :Applying Recovery Match for ua: $userAgent");
$deviceID = $this->applyRecoveryMatch($userAgent);
// Try with catch all recovery Match
if ($this->isBlankOrGeneric($deviceID)) {
$request->matchInfo->match_type = 'recovery-catchall';
$request->matchInfo->matcher_history .= "$class_name(recovery-catchall),";
$this->logger->debug("$this->prefix :Applying Catch All Recovery Match for ua: $userAgent");
$deviceID = $this->applyRecoveryCatchAllMatch($userAgent);
// All attempts to match have failed
if ($this->isBlankOrGeneric($deviceID)) {
$request->matchInfo->match_type = 'none';
if ($request->userAgentProfile) {
$deviceID = WURFL_Constants::GENERIC_MOBILE;
} else {
$deviceID = WURFL_Constants::GENERIC;
}
}
}
}
}
$this->logger->debug("END: Matching For " . $userAgent);
$request->matchInfo->lookup_time = microtime(true) - $start_time;
return $deviceID;
}
|
[
"public",
"function",
"applyMatch",
"(",
"WURFL_Request_GenericRequest",
"$",
"request",
")",
"{",
"$",
"class_name",
"=",
"get_class",
"(",
"$",
"this",
")",
";",
"$",
"request",
"->",
"matchInfo",
"->",
"matcher",
"=",
"$",
"class_name",
";",
"$",
"start_time",
"=",
"microtime",
"(",
"true",
")",
";",
"$",
"request",
"->",
"matchInfo",
"->",
"cleaned_user_agent",
"=",
"$",
"request",
"->",
"userAgentNormalized",
";",
"$",
"userAgent",
"=",
"$",
"this",
"->",
"normalizeUserAgent",
"(",
"$",
"request",
"->",
"userAgentNormalized",
")",
";",
"$",
"request",
"->",
"matchInfo",
"->",
"normalized_user_agent",
"=",
"$",
"userAgent",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"\"START: Matching For \"",
".",
"$",
"userAgent",
")",
";",
"// Get The data associated with this current handler",
"$",
"this",
"->",
"userAgentsWithDeviceID",
"=",
"$",
"this",
"->",
"persistenceProvider",
"->",
"load",
"(",
"$",
"this",
"->",
"getPrefix",
"(",
")",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"this",
"->",
"userAgentsWithDeviceID",
")",
")",
"{",
"$",
"this",
"->",
"userAgentsWithDeviceID",
"=",
"array",
"(",
")",
";",
"}",
"$",
"deviceID",
"=",
"null",
";",
"// Start with an Exact match",
"$",
"request",
"->",
"matchInfo",
"->",
"matcher_history",
".=",
"\"$class_name(exact),\"",
";",
"$",
"request",
"->",
"matchInfo",
"->",
"match_type",
"=",
"'exact'",
";",
"$",
"deviceID",
"=",
"$",
"this",
"->",
"applyExactMatch",
"(",
"$",
"userAgent",
")",
";",
"// Try with the conclusive Match",
"if",
"(",
"$",
"this",
"->",
"isBlankOrGeneric",
"(",
"$",
"deviceID",
")",
")",
"{",
"$",
"request",
"->",
"matchInfo",
"->",
"matcher_history",
".=",
"\"$class_name(conclusive),\"",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"\"$this->prefix :Applying Conclusive Match for ua: $userAgent\"",
")",
";",
"$",
"deviceID",
"=",
"$",
"this",
"->",
"applyConclusiveMatch",
"(",
"$",
"userAgent",
")",
";",
"// Try with recovery match",
"if",
"(",
"$",
"this",
"->",
"isBlankOrGeneric",
"(",
"$",
"deviceID",
")",
")",
"{",
"// Log the ua and the ua profile",
"//$this->logger->debug($request);",
"$",
"request",
"->",
"matchInfo",
"->",
"match_type",
"=",
"'recovery'",
";",
"$",
"request",
"->",
"matchInfo",
"->",
"matcher_history",
".=",
"\"$class_name(recovery),\"",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"\"$this->prefix :Applying Recovery Match for ua: $userAgent\"",
")",
";",
"$",
"deviceID",
"=",
"$",
"this",
"->",
"applyRecoveryMatch",
"(",
"$",
"userAgent",
")",
";",
"// Try with catch all recovery Match",
"if",
"(",
"$",
"this",
"->",
"isBlankOrGeneric",
"(",
"$",
"deviceID",
")",
")",
"{",
"$",
"request",
"->",
"matchInfo",
"->",
"match_type",
"=",
"'recovery-catchall'",
";",
"$",
"request",
"->",
"matchInfo",
"->",
"matcher_history",
".=",
"\"$class_name(recovery-catchall),\"",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"\"$this->prefix :Applying Catch All Recovery Match for ua: $userAgent\"",
")",
";",
"$",
"deviceID",
"=",
"$",
"this",
"->",
"applyRecoveryCatchAllMatch",
"(",
"$",
"userAgent",
")",
";",
"// All attempts to match have failed",
"if",
"(",
"$",
"this",
"->",
"isBlankOrGeneric",
"(",
"$",
"deviceID",
")",
")",
"{",
"$",
"request",
"->",
"matchInfo",
"->",
"match_type",
"=",
"'none'",
";",
"if",
"(",
"$",
"request",
"->",
"userAgentProfile",
")",
"{",
"$",
"deviceID",
"=",
"WURFL_Constants",
"::",
"GENERIC_MOBILE",
";",
"}",
"else",
"{",
"$",
"deviceID",
"=",
"WURFL_Constants",
"::",
"GENERIC",
";",
"}",
"}",
"}",
"}",
"}",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"\"END: Matching For \"",
".",
"$",
"userAgent",
")",
";",
"$",
"request",
"->",
"matchInfo",
"->",
"lookup_time",
"=",
"microtime",
"(",
"true",
")",
"-",
"$",
"start_time",
";",
"return",
"$",
"deviceID",
";",
"}"
] |
Template method to apply matching system to user agent
@param WURFL_Request_GenericRequest $request
@return string Device ID
|
[
"Template",
"method",
"to",
"apply",
"matching",
"system",
"to",
"user",
"agent"
] |
train
|
https://github.com/acasademont/wurfl/blob/0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2/WURFL/Handlers/Handler.php#L230-L288
|
acasademont/wurfl
|
WURFL/Handlers/Handler.php
|
WURFL_Handlers_Handler.lookForMatchingUserAgent
|
public function lookForMatchingUserAgent($userAgent)
{
$tolerance = WURFL_Handlers_Utils::firstSlash($userAgent);
return WURFL_Handlers_Utils::risMatch(array_keys($this->userAgentsWithDeviceID), $userAgent, $tolerance);
}
|
php
|
public function lookForMatchingUserAgent($userAgent)
{
$tolerance = WURFL_Handlers_Utils::firstSlash($userAgent);
return WURFL_Handlers_Utils::risMatch(array_keys($this->userAgentsWithDeviceID), $userAgent, $tolerance);
}
|
[
"public",
"function",
"lookForMatchingUserAgent",
"(",
"$",
"userAgent",
")",
"{",
"$",
"tolerance",
"=",
"WURFL_Handlers_Utils",
"::",
"firstSlash",
"(",
"$",
"userAgent",
")",
";",
"return",
"WURFL_Handlers_Utils",
"::",
"risMatch",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"userAgentsWithDeviceID",
")",
",",
"$",
"userAgent",
",",
"$",
"tolerance",
")",
";",
"}"
] |
Find a matching WURFL device from the given $userAgent. Override this method to give an alternative way to do the matching
@param string $userAgent
@return string
|
[
"Find",
"a",
"matching",
"WURFL",
"device",
"from",
"the",
"given",
"$userAgent",
".",
"Override",
"this",
"method",
"to",
"give",
"an",
"alternative",
"way",
"to",
"do",
"the",
"matching"
] |
train
|
https://github.com/acasademont/wurfl/blob/0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2/WURFL/Handlers/Handler.php#L328-L332
|
acasademont/wurfl
|
WURFL/Handlers/Handler.php
|
WURFL_Handlers_Handler.applyRecoveryCatchAllMatch
|
public function applyRecoveryCatchAllMatch($userAgent)
{
if (WURFL_Handlers_Utils::isDesktopBrowserHeavyDutyAnalysis($userAgent)) {
return WURFL_Constants::GENERIC_WEB_BROWSER;
}
if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'CoreMedia')) {
return 'apple_iphone_coremedia_ver1';
}
if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'Windows CE')) {
return 'generic_ms_mobile';
}
if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'UP.Browser/7.2')) {
return 'opwv_v72_generic';
}
if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'UP.Browser/7')) {
return 'opwv_v7_generic';
}
if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'UP.Browser/6.2')) {
return 'opwv_v62_generic';
}
if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'UP.Browser/6')) {
return 'opwv_v6_generic';
}
if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'UP.Browser/5')) {
return 'upgui_generic';
}
if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'UP.Browser/4')) {
return 'uptext_generic';
}
if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'UP.Browser/3')) {
return 'uptext_generic';
}
// Series 60
if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'Series60')) {
return 'nokia_generic_series60';
}
// Access/Net Front
if (WURFL_Handlers_Utils::checkIfContainsAnyOf($userAgent, array('NetFront/3.0', 'ACS-NF/3.0'))) {
return 'generic_netfront_ver3';
}
if (WURFL_Handlers_Utils::checkIfContainsAnyOf($userAgent, array('NetFront/3.1', 'ACS-NF/3.1'))) {
return 'generic_netfront_ver3_1';
}
if (WURFL_Handlers_Utils::checkIfContainsAnyOf($userAgent, array('NetFront/3.2', 'ACS-NF/3.2'))) {
return 'generic_netfront_ver3_2';
}
if (WURFL_Handlers_Utils::checkIfContainsAnyOf($userAgent, array('NetFront/3.3', 'ACS-NF/3.3'))) {
return 'generic_netfront_ver3_3';
}
if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'NetFront/3.4')) {
return 'generic_netfront_ver3_4';
}
if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'NetFront/3.5')) {
return 'generic_netfront_ver3_5';
}
if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'NetFront/4.0')) {
return 'generic_netfront_ver4_0';
}
// Contains Mozilla/, but not at the beginning of the UA
// ie: MOTORAZR V8/R601_G_80.41.17R Mozilla/4.0 (compatible; MSIE 6.0 Linux; MOTORAZR V88.50) Profile/MIDP-2.0 Configuration/CLDC-1.1 Opera 8.50[zh]
if (strpos($userAgent, 'Mozilla/') > 0) {
return WURFL_Constants::GENERIC_XHTML;
}
if (WURFL_Handlers_Utils::checkIfContainsAnyOf($userAgent, array('Obigo', 'AU-MIC/2', 'AU-MIC-', 'AU-OBIGO/', 'Teleca Q03B1'))) {
return WURFL_Constants::GENERIC_XHTML;
}
// DoCoMo
if (WURFL_Handlers_Utils::checkIfStartsWithAnyOf($userAgent, array('DoCoMo', 'KDDI'))) {
return 'docomo_generic_jap_ver1';
}
if (WURFL_Handlers_Utils::isMobileBrowser($userAgent)) {
return WURFL_Constants::GENERIC_MOBILE;
}
return WURFL_Constants::GENERIC;
}
|
php
|
public function applyRecoveryCatchAllMatch($userAgent)
{
if (WURFL_Handlers_Utils::isDesktopBrowserHeavyDutyAnalysis($userAgent)) {
return WURFL_Constants::GENERIC_WEB_BROWSER;
}
if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'CoreMedia')) {
return 'apple_iphone_coremedia_ver1';
}
if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'Windows CE')) {
return 'generic_ms_mobile';
}
if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'UP.Browser/7.2')) {
return 'opwv_v72_generic';
}
if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'UP.Browser/7')) {
return 'opwv_v7_generic';
}
if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'UP.Browser/6.2')) {
return 'opwv_v62_generic';
}
if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'UP.Browser/6')) {
return 'opwv_v6_generic';
}
if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'UP.Browser/5')) {
return 'upgui_generic';
}
if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'UP.Browser/4')) {
return 'uptext_generic';
}
if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'UP.Browser/3')) {
return 'uptext_generic';
}
// Series 60
if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'Series60')) {
return 'nokia_generic_series60';
}
// Access/Net Front
if (WURFL_Handlers_Utils::checkIfContainsAnyOf($userAgent, array('NetFront/3.0', 'ACS-NF/3.0'))) {
return 'generic_netfront_ver3';
}
if (WURFL_Handlers_Utils::checkIfContainsAnyOf($userAgent, array('NetFront/3.1', 'ACS-NF/3.1'))) {
return 'generic_netfront_ver3_1';
}
if (WURFL_Handlers_Utils::checkIfContainsAnyOf($userAgent, array('NetFront/3.2', 'ACS-NF/3.2'))) {
return 'generic_netfront_ver3_2';
}
if (WURFL_Handlers_Utils::checkIfContainsAnyOf($userAgent, array('NetFront/3.3', 'ACS-NF/3.3'))) {
return 'generic_netfront_ver3_3';
}
if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'NetFront/3.4')) {
return 'generic_netfront_ver3_4';
}
if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'NetFront/3.5')) {
return 'generic_netfront_ver3_5';
}
if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'NetFront/4.0')) {
return 'generic_netfront_ver4_0';
}
// Contains Mozilla/, but not at the beginning of the UA
// ie: MOTORAZR V8/R601_G_80.41.17R Mozilla/4.0 (compatible; MSIE 6.0 Linux; MOTORAZR V88.50) Profile/MIDP-2.0 Configuration/CLDC-1.1 Opera 8.50[zh]
if (strpos($userAgent, 'Mozilla/') > 0) {
return WURFL_Constants::GENERIC_XHTML;
}
if (WURFL_Handlers_Utils::checkIfContainsAnyOf($userAgent, array('Obigo', 'AU-MIC/2', 'AU-MIC-', 'AU-OBIGO/', 'Teleca Q03B1'))) {
return WURFL_Constants::GENERIC_XHTML;
}
// DoCoMo
if (WURFL_Handlers_Utils::checkIfStartsWithAnyOf($userAgent, array('DoCoMo', 'KDDI'))) {
return 'docomo_generic_jap_ver1';
}
if (WURFL_Handlers_Utils::isMobileBrowser($userAgent)) {
return WURFL_Constants::GENERIC_MOBILE;
}
return WURFL_Constants::GENERIC;
}
|
[
"public",
"function",
"applyRecoveryCatchAllMatch",
"(",
"$",
"userAgent",
")",
"{",
"if",
"(",
"WURFL_Handlers_Utils",
"::",
"isDesktopBrowserHeavyDutyAnalysis",
"(",
"$",
"userAgent",
")",
")",
"{",
"return",
"WURFL_Constants",
"::",
"GENERIC_WEB_BROWSER",
";",
"}",
"if",
"(",
"WURFL_Handlers_Utils",
"::",
"checkIfContains",
"(",
"$",
"userAgent",
",",
"'CoreMedia'",
")",
")",
"{",
"return",
"'apple_iphone_coremedia_ver1'",
";",
"}",
"if",
"(",
"WURFL_Handlers_Utils",
"::",
"checkIfContains",
"(",
"$",
"userAgent",
",",
"'Windows CE'",
")",
")",
"{",
"return",
"'generic_ms_mobile'",
";",
"}",
"if",
"(",
"WURFL_Handlers_Utils",
"::",
"checkIfContains",
"(",
"$",
"userAgent",
",",
"'UP.Browser/7.2'",
")",
")",
"{",
"return",
"'opwv_v72_generic'",
";",
"}",
"if",
"(",
"WURFL_Handlers_Utils",
"::",
"checkIfContains",
"(",
"$",
"userAgent",
",",
"'UP.Browser/7'",
")",
")",
"{",
"return",
"'opwv_v7_generic'",
";",
"}",
"if",
"(",
"WURFL_Handlers_Utils",
"::",
"checkIfContains",
"(",
"$",
"userAgent",
",",
"'UP.Browser/6.2'",
")",
")",
"{",
"return",
"'opwv_v62_generic'",
";",
"}",
"if",
"(",
"WURFL_Handlers_Utils",
"::",
"checkIfContains",
"(",
"$",
"userAgent",
",",
"'UP.Browser/6'",
")",
")",
"{",
"return",
"'opwv_v6_generic'",
";",
"}",
"if",
"(",
"WURFL_Handlers_Utils",
"::",
"checkIfContains",
"(",
"$",
"userAgent",
",",
"'UP.Browser/5'",
")",
")",
"{",
"return",
"'upgui_generic'",
";",
"}",
"if",
"(",
"WURFL_Handlers_Utils",
"::",
"checkIfContains",
"(",
"$",
"userAgent",
",",
"'UP.Browser/4'",
")",
")",
"{",
"return",
"'uptext_generic'",
";",
"}",
"if",
"(",
"WURFL_Handlers_Utils",
"::",
"checkIfContains",
"(",
"$",
"userAgent",
",",
"'UP.Browser/3'",
")",
")",
"{",
"return",
"'uptext_generic'",
";",
"}",
"// Series 60",
"if",
"(",
"WURFL_Handlers_Utils",
"::",
"checkIfContains",
"(",
"$",
"userAgent",
",",
"'Series60'",
")",
")",
"{",
"return",
"'nokia_generic_series60'",
";",
"}",
"// Access/Net Front",
"if",
"(",
"WURFL_Handlers_Utils",
"::",
"checkIfContainsAnyOf",
"(",
"$",
"userAgent",
",",
"array",
"(",
"'NetFront/3.0'",
",",
"'ACS-NF/3.0'",
")",
")",
")",
"{",
"return",
"'generic_netfront_ver3'",
";",
"}",
"if",
"(",
"WURFL_Handlers_Utils",
"::",
"checkIfContainsAnyOf",
"(",
"$",
"userAgent",
",",
"array",
"(",
"'NetFront/3.1'",
",",
"'ACS-NF/3.1'",
")",
")",
")",
"{",
"return",
"'generic_netfront_ver3_1'",
";",
"}",
"if",
"(",
"WURFL_Handlers_Utils",
"::",
"checkIfContainsAnyOf",
"(",
"$",
"userAgent",
",",
"array",
"(",
"'NetFront/3.2'",
",",
"'ACS-NF/3.2'",
")",
")",
")",
"{",
"return",
"'generic_netfront_ver3_2'",
";",
"}",
"if",
"(",
"WURFL_Handlers_Utils",
"::",
"checkIfContainsAnyOf",
"(",
"$",
"userAgent",
",",
"array",
"(",
"'NetFront/3.3'",
",",
"'ACS-NF/3.3'",
")",
")",
")",
"{",
"return",
"'generic_netfront_ver3_3'",
";",
"}",
"if",
"(",
"WURFL_Handlers_Utils",
"::",
"checkIfContains",
"(",
"$",
"userAgent",
",",
"'NetFront/3.4'",
")",
")",
"{",
"return",
"'generic_netfront_ver3_4'",
";",
"}",
"if",
"(",
"WURFL_Handlers_Utils",
"::",
"checkIfContains",
"(",
"$",
"userAgent",
",",
"'NetFront/3.5'",
")",
")",
"{",
"return",
"'generic_netfront_ver3_5'",
";",
"}",
"if",
"(",
"WURFL_Handlers_Utils",
"::",
"checkIfContains",
"(",
"$",
"userAgent",
",",
"'NetFront/4.0'",
")",
")",
"{",
"return",
"'generic_netfront_ver4_0'",
";",
"}",
"// Contains Mozilla/, but not at the beginning of the UA",
"// ie: MOTORAZR V8/R601_G_80.41.17R Mozilla/4.0 (compatible; MSIE 6.0 Linux; MOTORAZR V88.50) Profile/MIDP-2.0 Configuration/CLDC-1.1 Opera 8.50[zh]",
"if",
"(",
"strpos",
"(",
"$",
"userAgent",
",",
"'Mozilla/'",
")",
">",
"0",
")",
"{",
"return",
"WURFL_Constants",
"::",
"GENERIC_XHTML",
";",
"}",
"if",
"(",
"WURFL_Handlers_Utils",
"::",
"checkIfContainsAnyOf",
"(",
"$",
"userAgent",
",",
"array",
"(",
"'Obigo'",
",",
"'AU-MIC/2'",
",",
"'AU-MIC-'",
",",
"'AU-OBIGO/'",
",",
"'Teleca Q03B1'",
")",
")",
")",
"{",
"return",
"WURFL_Constants",
"::",
"GENERIC_XHTML",
";",
"}",
"// DoCoMo",
"if",
"(",
"WURFL_Handlers_Utils",
"::",
"checkIfStartsWithAnyOf",
"(",
"$",
"userAgent",
",",
"array",
"(",
"'DoCoMo'",
",",
"'KDDI'",
")",
")",
")",
"{",
"return",
"'docomo_generic_jap_ver1'",
";",
"}",
"if",
"(",
"WURFL_Handlers_Utils",
"::",
"isMobileBrowser",
"(",
"$",
"userAgent",
")",
")",
"{",
"return",
"WURFL_Constants",
"::",
"GENERIC_MOBILE",
";",
"}",
"return",
"WURFL_Constants",
"::",
"GENERIC",
";",
"}"
] |
Applies Catch-All match
@param string $userAgent
@return string WURFL deviceID
|
[
"Applies",
"Catch",
"-",
"All",
"match"
] |
train
|
https://github.com/acasademont/wurfl/blob/0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2/WURFL/Handlers/Handler.php#L369-L445
|
AbuseIO/parser-spamcop
|
src/Spamcop.php
|
Spamcop.parse
|
public function parse()
{
$reports = [ ];
if ($this->parsedMail->getHeader('subject') == "[SpamCop] summary report") {
$this->feedName = 'summary';
$reports = $this->parseSummaryReport();
} elseif ($this->parsedMail->getHeader('subject') == "[SpamCop] Alert") {
$this->feedName = 'alert';
$reports = $this->parseAlerts();
} elseif ((strpos($this->parsedMail->getHeader('from'), "@reports.spamcop.net") !== false) &&
($this->arfMail !== false)
) {
$this->feedName = 'spamreport';
$reports = $this->parseSpamReportArf();
} elseif ((strpos($this->parsedMail->getHeader('from'), "@reports.spamcop.net") !== false) &&
(strpos($this->parsedMail->getMessageBody(), '[ Offending message ]'))
) {
$this->feedName = 'spamreport';
$reports = $this->parseSpamReportCustom();
} else {
$this->warningCount++;
}
foreach ($reports as $report) {
// If feed is known and enabled, validate data and save report
if ($this->isKnownFeed() && $this->isEnabledFeed()) {
// Sanity check
if ($this->hasRequiredFields($report) === true) {
// incident has all requirements met, filter and add!
$report = $this->applyFilters($report);
if (!empty($report['Spam-URL'])) {
$url = $report['Spam-URL'];
}
if (!empty($report['Reported-URI'])) {
$url = $report['Reported-URI'];
}
if (!empty($url)) {
$urlData = getUrldata($url);
if (!empty($urlData['host']) && !empty($urlData['path'])) {
$this->feedName = 'spamvertizedreport';
}
}
$incident = new Incident();
$incident->source = config("{$this->configBase}.parser.name");
$incident->source_id = false;
$incident->ip = $report['Source-IP'];
$incident->domain = empty($url) ? false : getDomain($url);
$incident->class = config("{$this->configBase}.feeds.{$this->feedName}.class");
$incident->type = config("{$this->configBase}.feeds.{$this->feedName}.type");
$incident->timestamp = strtotime($report['Received-Date']);
$incident->information = json_encode($report);
$this->incidents[] = $incident;
}
}
}
return $this->success();
}
|
php
|
public function parse()
{
$reports = [ ];
if ($this->parsedMail->getHeader('subject') == "[SpamCop] summary report") {
$this->feedName = 'summary';
$reports = $this->parseSummaryReport();
} elseif ($this->parsedMail->getHeader('subject') == "[SpamCop] Alert") {
$this->feedName = 'alert';
$reports = $this->parseAlerts();
} elseif ((strpos($this->parsedMail->getHeader('from'), "@reports.spamcop.net") !== false) &&
($this->arfMail !== false)
) {
$this->feedName = 'spamreport';
$reports = $this->parseSpamReportArf();
} elseif ((strpos($this->parsedMail->getHeader('from'), "@reports.spamcop.net") !== false) &&
(strpos($this->parsedMail->getMessageBody(), '[ Offending message ]'))
) {
$this->feedName = 'spamreport';
$reports = $this->parseSpamReportCustom();
} else {
$this->warningCount++;
}
foreach ($reports as $report) {
// If feed is known and enabled, validate data and save report
if ($this->isKnownFeed() && $this->isEnabledFeed()) {
// Sanity check
if ($this->hasRequiredFields($report) === true) {
// incident has all requirements met, filter and add!
$report = $this->applyFilters($report);
if (!empty($report['Spam-URL'])) {
$url = $report['Spam-URL'];
}
if (!empty($report['Reported-URI'])) {
$url = $report['Reported-URI'];
}
if (!empty($url)) {
$urlData = getUrldata($url);
if (!empty($urlData['host']) && !empty($urlData['path'])) {
$this->feedName = 'spamvertizedreport';
}
}
$incident = new Incident();
$incident->source = config("{$this->configBase}.parser.name");
$incident->source_id = false;
$incident->ip = $report['Source-IP'];
$incident->domain = empty($url) ? false : getDomain($url);
$incident->class = config("{$this->configBase}.feeds.{$this->feedName}.class");
$incident->type = config("{$this->configBase}.feeds.{$this->feedName}.type");
$incident->timestamp = strtotime($report['Received-Date']);
$incident->information = json_encode($report);
$this->incidents[] = $incident;
}
}
}
return $this->success();
}
|
[
"public",
"function",
"parse",
"(",
")",
"{",
"$",
"reports",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"parsedMail",
"->",
"getHeader",
"(",
"'subject'",
")",
"==",
"\"[SpamCop] summary report\"",
")",
"{",
"$",
"this",
"->",
"feedName",
"=",
"'summary'",
";",
"$",
"reports",
"=",
"$",
"this",
"->",
"parseSummaryReport",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"parsedMail",
"->",
"getHeader",
"(",
"'subject'",
")",
"==",
"\"[SpamCop] Alert\"",
")",
"{",
"$",
"this",
"->",
"feedName",
"=",
"'alert'",
";",
"$",
"reports",
"=",
"$",
"this",
"->",
"parseAlerts",
"(",
")",
";",
"}",
"elseif",
"(",
"(",
"strpos",
"(",
"$",
"this",
"->",
"parsedMail",
"->",
"getHeader",
"(",
"'from'",
")",
",",
"\"@reports.spamcop.net\"",
")",
"!==",
"false",
")",
"&&",
"(",
"$",
"this",
"->",
"arfMail",
"!==",
"false",
")",
")",
"{",
"$",
"this",
"->",
"feedName",
"=",
"'spamreport'",
";",
"$",
"reports",
"=",
"$",
"this",
"->",
"parseSpamReportArf",
"(",
")",
";",
"}",
"elseif",
"(",
"(",
"strpos",
"(",
"$",
"this",
"->",
"parsedMail",
"->",
"getHeader",
"(",
"'from'",
")",
",",
"\"@reports.spamcop.net\"",
")",
"!==",
"false",
")",
"&&",
"(",
"strpos",
"(",
"$",
"this",
"->",
"parsedMail",
"->",
"getMessageBody",
"(",
")",
",",
"'[ Offending message ]'",
")",
")",
")",
"{",
"$",
"this",
"->",
"feedName",
"=",
"'spamreport'",
";",
"$",
"reports",
"=",
"$",
"this",
"->",
"parseSpamReportCustom",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"warningCount",
"++",
";",
"}",
"foreach",
"(",
"$",
"reports",
"as",
"$",
"report",
")",
"{",
"// If feed is known and enabled, validate data and save report",
"if",
"(",
"$",
"this",
"->",
"isKnownFeed",
"(",
")",
"&&",
"$",
"this",
"->",
"isEnabledFeed",
"(",
")",
")",
"{",
"// Sanity check",
"if",
"(",
"$",
"this",
"->",
"hasRequiredFields",
"(",
"$",
"report",
")",
"===",
"true",
")",
"{",
"// incident has all requirements met, filter and add!",
"$",
"report",
"=",
"$",
"this",
"->",
"applyFilters",
"(",
"$",
"report",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"report",
"[",
"'Spam-URL'",
"]",
")",
")",
"{",
"$",
"url",
"=",
"$",
"report",
"[",
"'Spam-URL'",
"]",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"report",
"[",
"'Reported-URI'",
"]",
")",
")",
"{",
"$",
"url",
"=",
"$",
"report",
"[",
"'Reported-URI'",
"]",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"url",
")",
")",
"{",
"$",
"urlData",
"=",
"getUrldata",
"(",
"$",
"url",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"urlData",
"[",
"'host'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"urlData",
"[",
"'path'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"feedName",
"=",
"'spamvertizedreport'",
";",
"}",
"}",
"$",
"incident",
"=",
"new",
"Incident",
"(",
")",
";",
"$",
"incident",
"->",
"source",
"=",
"config",
"(",
"\"{$this->configBase}.parser.name\"",
")",
";",
"$",
"incident",
"->",
"source_id",
"=",
"false",
";",
"$",
"incident",
"->",
"ip",
"=",
"$",
"report",
"[",
"'Source-IP'",
"]",
";",
"$",
"incident",
"->",
"domain",
"=",
"empty",
"(",
"$",
"url",
")",
"?",
"false",
":",
"getDomain",
"(",
"$",
"url",
")",
";",
"$",
"incident",
"->",
"class",
"=",
"config",
"(",
"\"{$this->configBase}.feeds.{$this->feedName}.class\"",
")",
";",
"$",
"incident",
"->",
"type",
"=",
"config",
"(",
"\"{$this->configBase}.feeds.{$this->feedName}.type\"",
")",
";",
"$",
"incident",
"->",
"timestamp",
"=",
"strtotime",
"(",
"$",
"report",
"[",
"'Received-Date'",
"]",
")",
";",
"$",
"incident",
"->",
"information",
"=",
"json_encode",
"(",
"$",
"report",
")",
";",
"$",
"this",
"->",
"incidents",
"[",
"]",
"=",
"$",
"incident",
";",
"}",
"}",
"}",
"return",
"$",
"this",
"->",
"success",
"(",
")",
";",
"}"
] |
Parse attachments
@return array Returns array with failed or success data
(See parser-common/src/Parser.php) for more info.
|
[
"Parse",
"attachments"
] |
train
|
https://github.com/AbuseIO/parser-spamcop/blob/6745d54bfee747b66af6e7332a59d554de3d8253/src/Spamcop.php#L31-L98
|
AbuseIO/parser-spamcop
|
src/Spamcop.php
|
Spamcop.parseSummaryReport
|
public function parseSummaryReport()
{
$reports = [ ];
preg_match_all(
"/^\s*".
"(?<ip>[a-f0-9:\.]+)\s+".
"(?<date>\w+\s+\d+\s\d+)h\/".
"(?<days>\d+)\s+".
"(?<trap>\d+)\s+".
"(?<user>\d+)\s+".
"(?<mole>\d+)\s+".
"(?<simp>\d+)".
"/m",
$this->parsedMail->getMessageBody(),
$matches,
PREG_SET_ORDER
);
if (is_array($matches) && count($matches) > 0) {
foreach ($matches as $match) {
$report = [
'Source-IP' => $match['ip'],
'Received-Date' => $match['date'] . ':00',
'Duration-Days' => $match['days'],
];
foreach (['trap', 'user', 'mole', 'simp'] as $field) {
$report[ucfirst($field) ."-Report"] = $match[$field];
}
$reports[] = $report;
}
}
return $reports;
}
|
php
|
public function parseSummaryReport()
{
$reports = [ ];
preg_match_all(
"/^\s*".
"(?<ip>[a-f0-9:\.]+)\s+".
"(?<date>\w+\s+\d+\s\d+)h\/".
"(?<days>\d+)\s+".
"(?<trap>\d+)\s+".
"(?<user>\d+)\s+".
"(?<mole>\d+)\s+".
"(?<simp>\d+)".
"/m",
$this->parsedMail->getMessageBody(),
$matches,
PREG_SET_ORDER
);
if (is_array($matches) && count($matches) > 0) {
foreach ($matches as $match) {
$report = [
'Source-IP' => $match['ip'],
'Received-Date' => $match['date'] . ':00',
'Duration-Days' => $match['days'],
];
foreach (['trap', 'user', 'mole', 'simp'] as $field) {
$report[ucfirst($field) ."-Report"] = $match[$field];
}
$reports[] = $report;
}
}
return $reports;
}
|
[
"public",
"function",
"parseSummaryReport",
"(",
")",
"{",
"$",
"reports",
"=",
"[",
"]",
";",
"preg_match_all",
"(",
"\"/^\\s*\"",
".",
"\"(?<ip>[a-f0-9:\\.]+)\\s+\"",
".",
"\"(?<date>\\w+\\s+\\d+\\s\\d+)h\\/\"",
".",
"\"(?<days>\\d+)\\s+\"",
".",
"\"(?<trap>\\d+)\\s+\"",
".",
"\"(?<user>\\d+)\\s+\"",
".",
"\"(?<mole>\\d+)\\s+\"",
".",
"\"(?<simp>\\d+)\"",
".",
"\"/m\"",
",",
"$",
"this",
"->",
"parsedMail",
"->",
"getMessageBody",
"(",
")",
",",
"$",
"matches",
",",
"PREG_SET_ORDER",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"matches",
")",
"&&",
"count",
"(",
"$",
"matches",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"matches",
"as",
"$",
"match",
")",
"{",
"$",
"report",
"=",
"[",
"'Source-IP'",
"=>",
"$",
"match",
"[",
"'ip'",
"]",
",",
"'Received-Date'",
"=>",
"$",
"match",
"[",
"'date'",
"]",
".",
"':00'",
",",
"'Duration-Days'",
"=>",
"$",
"match",
"[",
"'days'",
"]",
",",
"]",
";",
"foreach",
"(",
"[",
"'trap'",
",",
"'user'",
",",
"'mole'",
",",
"'simp'",
"]",
"as",
"$",
"field",
")",
"{",
"$",
"report",
"[",
"ucfirst",
"(",
"$",
"field",
")",
".",
"\"-Report\"",
"]",
"=",
"$",
"match",
"[",
"$",
"field",
"]",
";",
"}",
"$",
"reports",
"[",
"]",
"=",
"$",
"report",
";",
"}",
"}",
"return",
"$",
"reports",
";",
"}"
] |
This is a spamcop formatted summery with a multiple incidents
@return array $reports
|
[
"This",
"is",
"a",
"spamcop",
"formatted",
"summery",
"with",
"a",
"multiple",
"incidents"
] |
train
|
https://github.com/AbuseIO/parser-spamcop/blob/6745d54bfee747b66af6e7332a59d554de3d8253/src/Spamcop.php#L105-L141
|
AbuseIO/parser-spamcop
|
src/Spamcop.php
|
Spamcop.parseAlerts
|
public function parseAlerts()
{
$reports = [ ];
preg_match_all(
'/\s*(?<ip>[a-f0-9:\.]+)/',
// Someone from spamcop found it funny to prefix IPv6 addresses, so lets strip that off
str_replace('IPv6 ', '', $this->parsedMail->getMessageBody()),
$matches
);
$received = $this->parsedMail->getHeaders()['date'];
if (strtotime(date('d-m-Y H:i:s', strtotime($received))) !== (int)strtotime($received)) {
$received = date('d-m-Y H:i:s');
}
if (is_array($matches) && !empty($matches['ip']) && count($matches['ip']) > 0) {
foreach ($matches['ip'] as $ip) {
$reports[] = [
'Source-IP' => $ip,
'Received-Date' => $received,
'Note' => 'A spamtrap hit notification was received.'.
' These notifications do not provide any evidence.'
];
}
}
return $reports;
}
|
php
|
public function parseAlerts()
{
$reports = [ ];
preg_match_all(
'/\s*(?<ip>[a-f0-9:\.]+)/',
// Someone from spamcop found it funny to prefix IPv6 addresses, so lets strip that off
str_replace('IPv6 ', '', $this->parsedMail->getMessageBody()),
$matches
);
$received = $this->parsedMail->getHeaders()['date'];
if (strtotime(date('d-m-Y H:i:s', strtotime($received))) !== (int)strtotime($received)) {
$received = date('d-m-Y H:i:s');
}
if (is_array($matches) && !empty($matches['ip']) && count($matches['ip']) > 0) {
foreach ($matches['ip'] as $ip) {
$reports[] = [
'Source-IP' => $ip,
'Received-Date' => $received,
'Note' => 'A spamtrap hit notification was received.'.
' These notifications do not provide any evidence.'
];
}
}
return $reports;
}
|
[
"public",
"function",
"parseAlerts",
"(",
")",
"{",
"$",
"reports",
"=",
"[",
"]",
";",
"preg_match_all",
"(",
"'/\\s*(?<ip>[a-f0-9:\\.]+)/'",
",",
"// Someone from spamcop found it funny to prefix IPv6 addresses, so lets strip that off",
"str_replace",
"(",
"'IPv6 '",
",",
"''",
",",
"$",
"this",
"->",
"parsedMail",
"->",
"getMessageBody",
"(",
")",
")",
",",
"$",
"matches",
")",
";",
"$",
"received",
"=",
"$",
"this",
"->",
"parsedMail",
"->",
"getHeaders",
"(",
")",
"[",
"'date'",
"]",
";",
"if",
"(",
"strtotime",
"(",
"date",
"(",
"'d-m-Y H:i:s'",
",",
"strtotime",
"(",
"$",
"received",
")",
")",
")",
"!==",
"(",
"int",
")",
"strtotime",
"(",
"$",
"received",
")",
")",
"{",
"$",
"received",
"=",
"date",
"(",
"'d-m-Y H:i:s'",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"matches",
")",
"&&",
"!",
"empty",
"(",
"$",
"matches",
"[",
"'ip'",
"]",
")",
"&&",
"count",
"(",
"$",
"matches",
"[",
"'ip'",
"]",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"matches",
"[",
"'ip'",
"]",
"as",
"$",
"ip",
")",
"{",
"$",
"reports",
"[",
"]",
"=",
"[",
"'Source-IP'",
"=>",
"$",
"ip",
",",
"'Received-Date'",
"=>",
"$",
"received",
",",
"'Note'",
"=>",
"'A spamtrap hit notification was received.'",
".",
"' These notifications do not provide any evidence.'",
"]",
";",
"}",
"}",
"return",
"$",
"reports",
";",
"}"
] |
This is a spamcop formatted alert with a multiple incidents
@return array $reports
|
[
"This",
"is",
"a",
"spamcop",
"formatted",
"alert",
"with",
"a",
"multiple",
"incidents"
] |
train
|
https://github.com/AbuseIO/parser-spamcop/blob/6745d54bfee747b66af6e7332a59d554de3d8253/src/Spamcop.php#L149-L179
|
AbuseIO/parser-spamcop
|
src/Spamcop.php
|
Spamcop.parseSpamReportCustom
|
public function parseSpamReportCustom()
{
$reports = [ ];
$body = $this->parsedMail->getMessageBody();
// Grab the message part from the body
preg_match(
'/(\[ SpamCop V[0-9\.\]\ ]*+)\r?\n(?<message>.*)\r?\n\[ Offending message \]/s',
$body,
$matches
);
if (!empty($matches['message'])) {
$report['message'] = $matches['message'];
}
// Grab the Evidence from the body
preg_match(
'/(\[ Offending message \]*+)\r?\n(?<evidence>.*)/s',
$body,
$matches
);
if (!empty($matches['evidence'])) {
$parsedEvidence = new MimeParser();
$parsedEvidence->setText($matches['evidence']);
$report['evidence'] = $parsedEvidence->getHeaders();
}
// Now parse the data from both extracts
if (!empty($report['message']) && !empty($report['evidence'])) {
preg_match(
'/Email from (?<ip>[a-f0-9:\.]+) \/ (?<date>.*)/',
$report['message'],
$matches
);
if (!empty($matches['ip']) && !empty($matches['date'])) {
$report['Source-IP'] = $matches['ip'];
$report['Received-Date'] = $matches['date'];
$reports[] = $report;
}
/*
* Why would you use a single format while you can use different formats huh Spamcop?
* For spamvertized we need to do some magic to build the report correctly
* "(?<mole>\d+)\s+".
*/
$report['message'] = str_replace('\r', '', $report['message']);
preg_match(
'/Spamvertised web site:\s'.
'(?<url>.*)\\n'.
'(?<reply>.*)\n'.
'(?<resolved>.*) is (?<ip>.*); (?<date>.*)\n'.
'/',
$report['message'],
$matches
);
if (!empty($matches['ip']) && !empty($matches['date']) && !empty($matches['url'])) {
$report['Source-IP'] = $matches['ip'];
$report['Received-Date'] = $matches['date'];
$report['Report-URL'] = $matches['reply'];
$report['Spam-URL'] = $matches['url'];
$reports[] = $report;
}
} else {
$this->warningCount++;
}
return $reports;
}
|
php
|
public function parseSpamReportCustom()
{
$reports = [ ];
$body = $this->parsedMail->getMessageBody();
// Grab the message part from the body
preg_match(
'/(\[ SpamCop V[0-9\.\]\ ]*+)\r?\n(?<message>.*)\r?\n\[ Offending message \]/s',
$body,
$matches
);
if (!empty($matches['message'])) {
$report['message'] = $matches['message'];
}
// Grab the Evidence from the body
preg_match(
'/(\[ Offending message \]*+)\r?\n(?<evidence>.*)/s',
$body,
$matches
);
if (!empty($matches['evidence'])) {
$parsedEvidence = new MimeParser();
$parsedEvidence->setText($matches['evidence']);
$report['evidence'] = $parsedEvidence->getHeaders();
}
// Now parse the data from both extracts
if (!empty($report['message']) && !empty($report['evidence'])) {
preg_match(
'/Email from (?<ip>[a-f0-9:\.]+) \/ (?<date>.*)/',
$report['message'],
$matches
);
if (!empty($matches['ip']) && !empty($matches['date'])) {
$report['Source-IP'] = $matches['ip'];
$report['Received-Date'] = $matches['date'];
$reports[] = $report;
}
/*
* Why would you use a single format while you can use different formats huh Spamcop?
* For spamvertized we need to do some magic to build the report correctly
* "(?<mole>\d+)\s+".
*/
$report['message'] = str_replace('\r', '', $report['message']);
preg_match(
'/Spamvertised web site:\s'.
'(?<url>.*)\\n'.
'(?<reply>.*)\n'.
'(?<resolved>.*) is (?<ip>.*); (?<date>.*)\n'.
'/',
$report['message'],
$matches
);
if (!empty($matches['ip']) && !empty($matches['date']) && !empty($matches['url'])) {
$report['Source-IP'] = $matches['ip'];
$report['Received-Date'] = $matches['date'];
$report['Report-URL'] = $matches['reply'];
$report['Spam-URL'] = $matches['url'];
$reports[] = $report;
}
} else {
$this->warningCount++;
}
return $reports;
}
|
[
"public",
"function",
"parseSpamReportCustom",
"(",
")",
"{",
"$",
"reports",
"=",
"[",
"]",
";",
"$",
"body",
"=",
"$",
"this",
"->",
"parsedMail",
"->",
"getMessageBody",
"(",
")",
";",
"// Grab the message part from the body",
"preg_match",
"(",
"'/(\\[ SpamCop V[0-9\\.\\]\\ ]*+)\\r?\\n(?<message>.*)\\r?\\n\\[ Offending message \\]/s'",
",",
"$",
"body",
",",
"$",
"matches",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"matches",
"[",
"'message'",
"]",
")",
")",
"{",
"$",
"report",
"[",
"'message'",
"]",
"=",
"$",
"matches",
"[",
"'message'",
"]",
";",
"}",
"// Grab the Evidence from the body",
"preg_match",
"(",
"'/(\\[ Offending message \\]*+)\\r?\\n(?<evidence>.*)/s'",
",",
"$",
"body",
",",
"$",
"matches",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"matches",
"[",
"'evidence'",
"]",
")",
")",
"{",
"$",
"parsedEvidence",
"=",
"new",
"MimeParser",
"(",
")",
";",
"$",
"parsedEvidence",
"->",
"setText",
"(",
"$",
"matches",
"[",
"'evidence'",
"]",
")",
";",
"$",
"report",
"[",
"'evidence'",
"]",
"=",
"$",
"parsedEvidence",
"->",
"getHeaders",
"(",
")",
";",
"}",
"// Now parse the data from both extracts",
"if",
"(",
"!",
"empty",
"(",
"$",
"report",
"[",
"'message'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"report",
"[",
"'evidence'",
"]",
")",
")",
"{",
"preg_match",
"(",
"'/Email from (?<ip>[a-f0-9:\\.]+) \\/ (?<date>.*)/'",
",",
"$",
"report",
"[",
"'message'",
"]",
",",
"$",
"matches",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"matches",
"[",
"'ip'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"matches",
"[",
"'date'",
"]",
")",
")",
"{",
"$",
"report",
"[",
"'Source-IP'",
"]",
"=",
"$",
"matches",
"[",
"'ip'",
"]",
";",
"$",
"report",
"[",
"'Received-Date'",
"]",
"=",
"$",
"matches",
"[",
"'date'",
"]",
";",
"$",
"reports",
"[",
"]",
"=",
"$",
"report",
";",
"}",
"/*\n * Why would you use a single format while you can use different formats huh Spamcop?\n * For spamvertized we need to do some magic to build the report correctly\n * \"(?<mole>\\d+)\\s+\".\n */",
"$",
"report",
"[",
"'message'",
"]",
"=",
"str_replace",
"(",
"'\\r'",
",",
"''",
",",
"$",
"report",
"[",
"'message'",
"]",
")",
";",
"preg_match",
"(",
"'/Spamvertised web site:\\s'",
".",
"'(?<url>.*)\\\\n'",
".",
"'(?<reply>.*)\\n'",
".",
"'(?<resolved>.*) is (?<ip>.*); (?<date>.*)\\n'",
".",
"'/'",
",",
"$",
"report",
"[",
"'message'",
"]",
",",
"$",
"matches",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"matches",
"[",
"'ip'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"matches",
"[",
"'date'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"matches",
"[",
"'url'",
"]",
")",
")",
"{",
"$",
"report",
"[",
"'Source-IP'",
"]",
"=",
"$",
"matches",
"[",
"'ip'",
"]",
";",
"$",
"report",
"[",
"'Received-Date'",
"]",
"=",
"$",
"matches",
"[",
"'date'",
"]",
";",
"$",
"report",
"[",
"'Report-URL'",
"]",
"=",
"$",
"matches",
"[",
"'reply'",
"]",
";",
"$",
"report",
"[",
"'Spam-URL'",
"]",
"=",
"$",
"matches",
"[",
"'url'",
"]",
";",
"$",
"reports",
"[",
"]",
"=",
"$",
"report",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"warningCount",
"++",
";",
"}",
"return",
"$",
"reports",
";",
"}"
] |
This is a spamcop formatted mail with a single incident
@return array $reports
|
[
"This",
"is",
"a",
"spamcop",
"formatted",
"mail",
"with",
"a",
"single",
"incident"
] |
train
|
https://github.com/AbuseIO/parser-spamcop/blob/6745d54bfee747b66af6e7332a59d554de3d8253/src/Spamcop.php#L187-L261
|
AbuseIO/parser-spamcop
|
src/Spamcop.php
|
Spamcop.parseSpamReportArf
|
public function parseSpamReportArf()
{
$reports = [ ];
//Seriously spamcop? Newlines arent in the CL specifications
$this->arfMail['report'] = str_replace("\r", "", $this->arfMail['report']);
preg_match_all('/([\w\-]+): (.*)[ ]*\r?\n/', $this->arfMail['report'], $regs);
$report = array_combine($regs[1], $regs[2]);
//Valueable information put in the body instead of the report, thnx for that Spamcop
if (strpos($this->arfMail['message'], 'Comments from recipient') !== false) {
preg_match(
"/Comments from recipient.*\s]\n(.*)\n\n\nThis/s",
str_replace(array("\r", "> "), "", $this->arfMail['message']),
$match
);
$report['recipient_comment'] = str_replace("\n", " ", $match[1]);
}
// Add the headers from evidence into infoblob
$parsedEvidence = new MimeParser();
$parsedEvidence->setText($this->arfMail['evidence']);
$headers = $parsedEvidence->getHeaders();
foreach ($headers as $key => $value) {
if (is_array($value) || is_object(($value))) {
foreach ($value as $index => $subvalue) {
$report['headers']["${key}${index}"] = "$subvalue";
}
} else {
$report['headers']["$key"] = $value;
}
}
/*
* Sometimes Spamcop has a trouble adding the correct fields. The IP is pretty
* normal to add. In a last attempt we will try to fetch the IP from the body ourselves
*/
if (empty($report['Source-IP'])) {
preg_match(
"/Email from (?<ip>[a-f0-9:\.]+) \/ " . preg_quote($report['Received-Date']) . "/s",
$this->arfMail['message'],
$regs
);
if (!empty($regs['ip']) && !filter_var($regs['ip'], FILTER_VALIDATE_IP) === false) {
$report['Source-IP'] = $regs['ip'];
}
preg_match(
"/from: (?<ip>[a-f0-9:\.]+)\r?\n?\r\n/s",
$this->parsedMail->getMessageBody(),
$regs
);
if (!empty($regs['ip']) && !filter_var($regs['ip'], FILTER_VALIDATE_IP) === false) {
$report['Source-IP'] = $regs['ip'];
}
}
$reports[] = $report;
return $reports;
}
|
php
|
public function parseSpamReportArf()
{
$reports = [ ];
//Seriously spamcop? Newlines arent in the CL specifications
$this->arfMail['report'] = str_replace("\r", "", $this->arfMail['report']);
preg_match_all('/([\w\-]+): (.*)[ ]*\r?\n/', $this->arfMail['report'], $regs);
$report = array_combine($regs[1], $regs[2]);
//Valueable information put in the body instead of the report, thnx for that Spamcop
if (strpos($this->arfMail['message'], 'Comments from recipient') !== false) {
preg_match(
"/Comments from recipient.*\s]\n(.*)\n\n\nThis/s",
str_replace(array("\r", "> "), "", $this->arfMail['message']),
$match
);
$report['recipient_comment'] = str_replace("\n", " ", $match[1]);
}
// Add the headers from evidence into infoblob
$parsedEvidence = new MimeParser();
$parsedEvidence->setText($this->arfMail['evidence']);
$headers = $parsedEvidence->getHeaders();
foreach ($headers as $key => $value) {
if (is_array($value) || is_object(($value))) {
foreach ($value as $index => $subvalue) {
$report['headers']["${key}${index}"] = "$subvalue";
}
} else {
$report['headers']["$key"] = $value;
}
}
/*
* Sometimes Spamcop has a trouble adding the correct fields. The IP is pretty
* normal to add. In a last attempt we will try to fetch the IP from the body ourselves
*/
if (empty($report['Source-IP'])) {
preg_match(
"/Email from (?<ip>[a-f0-9:\.]+) \/ " . preg_quote($report['Received-Date']) . "/s",
$this->arfMail['message'],
$regs
);
if (!empty($regs['ip']) && !filter_var($regs['ip'], FILTER_VALIDATE_IP) === false) {
$report['Source-IP'] = $regs['ip'];
}
preg_match(
"/from: (?<ip>[a-f0-9:\.]+)\r?\n?\r\n/s",
$this->parsedMail->getMessageBody(),
$regs
);
if (!empty($regs['ip']) && !filter_var($regs['ip'], FILTER_VALIDATE_IP) === false) {
$report['Source-IP'] = $regs['ip'];
}
}
$reports[] = $report;
return $reports;
}
|
[
"public",
"function",
"parseSpamReportArf",
"(",
")",
"{",
"$",
"reports",
"=",
"[",
"]",
";",
"//Seriously spamcop? Newlines arent in the CL specifications",
"$",
"this",
"->",
"arfMail",
"[",
"'report'",
"]",
"=",
"str_replace",
"(",
"\"\\r\"",
",",
"\"\"",
",",
"$",
"this",
"->",
"arfMail",
"[",
"'report'",
"]",
")",
";",
"preg_match_all",
"(",
"'/([\\w\\-]+): (.*)[ ]*\\r?\\n/'",
",",
"$",
"this",
"->",
"arfMail",
"[",
"'report'",
"]",
",",
"$",
"regs",
")",
";",
"$",
"report",
"=",
"array_combine",
"(",
"$",
"regs",
"[",
"1",
"]",
",",
"$",
"regs",
"[",
"2",
"]",
")",
";",
"//Valueable information put in the body instead of the report, thnx for that Spamcop",
"if",
"(",
"strpos",
"(",
"$",
"this",
"->",
"arfMail",
"[",
"'message'",
"]",
",",
"'Comments from recipient'",
")",
"!==",
"false",
")",
"{",
"preg_match",
"(",
"\"/Comments from recipient.*\\s]\\n(.*)\\n\\n\\nThis/s\"",
",",
"str_replace",
"(",
"array",
"(",
"\"\\r\"",
",",
"\"> \"",
")",
",",
"\"\"",
",",
"$",
"this",
"->",
"arfMail",
"[",
"'message'",
"]",
")",
",",
"$",
"match",
")",
";",
"$",
"report",
"[",
"'recipient_comment'",
"]",
"=",
"str_replace",
"(",
"\"\\n\"",
",",
"\" \"",
",",
"$",
"match",
"[",
"1",
"]",
")",
";",
"}",
"// Add the headers from evidence into infoblob",
"$",
"parsedEvidence",
"=",
"new",
"MimeParser",
"(",
")",
";",
"$",
"parsedEvidence",
"->",
"setText",
"(",
"$",
"this",
"->",
"arfMail",
"[",
"'evidence'",
"]",
")",
";",
"$",
"headers",
"=",
"$",
"parsedEvidence",
"->",
"getHeaders",
"(",
")",
";",
"foreach",
"(",
"$",
"headers",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
"||",
"is_object",
"(",
"(",
"$",
"value",
")",
")",
")",
"{",
"foreach",
"(",
"$",
"value",
"as",
"$",
"index",
"=>",
"$",
"subvalue",
")",
"{",
"$",
"report",
"[",
"'headers'",
"]",
"[",
"\"${key}${index}\"",
"]",
"=",
"\"$subvalue\"",
";",
"}",
"}",
"else",
"{",
"$",
"report",
"[",
"'headers'",
"]",
"[",
"\"$key\"",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"/*\n * Sometimes Spamcop has a trouble adding the correct fields. The IP is pretty\n * normal to add. In a last attempt we will try to fetch the IP from the body ourselves\n */",
"if",
"(",
"empty",
"(",
"$",
"report",
"[",
"'Source-IP'",
"]",
")",
")",
"{",
"preg_match",
"(",
"\"/Email from (?<ip>[a-f0-9:\\.]+) \\/ \"",
".",
"preg_quote",
"(",
"$",
"report",
"[",
"'Received-Date'",
"]",
")",
".",
"\"/s\"",
",",
"$",
"this",
"->",
"arfMail",
"[",
"'message'",
"]",
",",
"$",
"regs",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"regs",
"[",
"'ip'",
"]",
")",
"&&",
"!",
"filter_var",
"(",
"$",
"regs",
"[",
"'ip'",
"]",
",",
"FILTER_VALIDATE_IP",
")",
"===",
"false",
")",
"{",
"$",
"report",
"[",
"'Source-IP'",
"]",
"=",
"$",
"regs",
"[",
"'ip'",
"]",
";",
"}",
"preg_match",
"(",
"\"/from: (?<ip>[a-f0-9:\\.]+)\\r?\\n?\\r\\n/s\"",
",",
"$",
"this",
"->",
"parsedMail",
"->",
"getMessageBody",
"(",
")",
",",
"$",
"regs",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"regs",
"[",
"'ip'",
"]",
")",
"&&",
"!",
"filter_var",
"(",
"$",
"regs",
"[",
"'ip'",
"]",
",",
"FILTER_VALIDATE_IP",
")",
"===",
"false",
")",
"{",
"$",
"report",
"[",
"'Source-IP'",
"]",
"=",
"$",
"regs",
"[",
"'ip'",
"]",
";",
"}",
"}",
"$",
"reports",
"[",
"]",
"=",
"$",
"report",
";",
"return",
"$",
"reports",
";",
"}"
] |
This is a ARF mail with a single incident
@return array $reports
|
[
"This",
"is",
"a",
"ARF",
"mail",
"with",
"a",
"single",
"incident"
] |
train
|
https://github.com/AbuseIO/parser-spamcop/blob/6745d54bfee747b66af6e7332a59d554de3d8253/src/Spamcop.php#L269-L333
|
vincentchalamon/VinceCmsSonataAdminBundle
|
Controller/MenuController.php
|
MenuController.upAction
|
public function upAction(Request $request)
{
/** @var MenuRepository $repo */
$repo = $this->get('vince_cms.repository.menu');
/** @var Menu $menu */
$menu = $repo->find($request->get('id'));
if ($menu->getParent()) {
$repo->moveUp($menu);
}
return $this->redirect($this->generateUrl('admin_my_cms_menu_list'));
}
|
php
|
public function upAction(Request $request)
{
/** @var MenuRepository $repo */
$repo = $this->get('vince_cms.repository.menu');
/** @var Menu $menu */
$menu = $repo->find($request->get('id'));
if ($menu->getParent()) {
$repo->moveUp($menu);
}
return $this->redirect($this->generateUrl('admin_my_cms_menu_list'));
}
|
[
"public",
"function",
"upAction",
"(",
"Request",
"$",
"request",
")",
"{",
"/** @var MenuRepository $repo */",
"$",
"repo",
"=",
"$",
"this",
"->",
"get",
"(",
"'vince_cms.repository.menu'",
")",
";",
"/** @var Menu $menu */",
"$",
"menu",
"=",
"$",
"repo",
"->",
"find",
"(",
"$",
"request",
"->",
"get",
"(",
"'id'",
")",
")",
";",
"if",
"(",
"$",
"menu",
"->",
"getParent",
"(",
")",
")",
"{",
"$",
"repo",
"->",
"moveUp",
"(",
"$",
"menu",
")",
";",
"}",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'admin_my_cms_menu_list'",
")",
")",
";",
"}"
] |
Move menu up
@author Vincent Chalamon <[email protected]>
@param Request $request
@return \Symfony\Component\HttpFoundation\RedirectResponse
|
[
"Move",
"menu",
"up"
] |
train
|
https://github.com/vincentchalamon/VinceCmsSonataAdminBundle/blob/edc768061734a92ba116488dd7b61ad40af21ceb/Controller/MenuController.php#L31-L42
|
vincentchalamon/VinceCmsSonataAdminBundle
|
Controller/MenuController.php
|
MenuController.downAction
|
public function downAction(Request $request)
{
/** @var MenuRepository $repo */
$repo = $this->get('vince_cms.repository.menu');
/** @var Menu $menu */
$menu = $repo->find($request->get('id'));
if ($menu->getParent()) {
$repo->moveDown($menu);
}
return $this->redirect($this->generateUrl('admin_my_cms_menu_list'));
}
|
php
|
public function downAction(Request $request)
{
/** @var MenuRepository $repo */
$repo = $this->get('vince_cms.repository.menu');
/** @var Menu $menu */
$menu = $repo->find($request->get('id'));
if ($menu->getParent()) {
$repo->moveDown($menu);
}
return $this->redirect($this->generateUrl('admin_my_cms_menu_list'));
}
|
[
"public",
"function",
"downAction",
"(",
"Request",
"$",
"request",
")",
"{",
"/** @var MenuRepository $repo */",
"$",
"repo",
"=",
"$",
"this",
"->",
"get",
"(",
"'vince_cms.repository.menu'",
")",
";",
"/** @var Menu $menu */",
"$",
"menu",
"=",
"$",
"repo",
"->",
"find",
"(",
"$",
"request",
"->",
"get",
"(",
"'id'",
")",
")",
";",
"if",
"(",
"$",
"menu",
"->",
"getParent",
"(",
")",
")",
"{",
"$",
"repo",
"->",
"moveDown",
"(",
"$",
"menu",
")",
";",
"}",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'admin_my_cms_menu_list'",
")",
")",
";",
"}"
] |
Move menu down
@author Vincent Chalamon <[email protected]>
@param Request $request
@return \Symfony\Component\HttpFoundation\RedirectResponse
|
[
"Move",
"menu",
"down"
] |
train
|
https://github.com/vincentchalamon/VinceCmsSonataAdminBundle/blob/edc768061734a92ba116488dd7b61ad40af21ceb/Controller/MenuController.php#L53-L64
|
crossjoin/Css
|
src/Crossjoin/Css/Format/Rule/TraitIsValid.php
|
TraitIsValid.setIsValid
|
public function setIsValid($isValid)
{
if (is_bool($isValid)) {
$this->isValid = $isValid;
} else {
throw new \InvalidArgumentException(
"Invalid value '" . $isValid . "' for argument 'isValid' given."
);
}
return $this;
}
|
php
|
public function setIsValid($isValid)
{
if (is_bool($isValid)) {
$this->isValid = $isValid;
} else {
throw new \InvalidArgumentException(
"Invalid value '" . $isValid . "' for argument 'isValid' given."
);
}
return $this;
}
|
[
"public",
"function",
"setIsValid",
"(",
"$",
"isValid",
")",
"{",
"if",
"(",
"is_bool",
"(",
"$",
"isValid",
")",
")",
"{",
"$",
"this",
"->",
"isValid",
"=",
"$",
"isValid",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Invalid value '\"",
".",
"$",
"isValid",
".",
"\"' for argument 'isValid' given.\"",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Sets the validation status.
@param bool $isValid
@return $this
|
[
"Sets",
"the",
"validation",
"status",
"."
] |
train
|
https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Format/Rule/TraitIsValid.php#L22-L33
|
crossjoin/Css
|
src/Crossjoin/Css/Format/Rule/TraitIsValid.php
|
TraitIsValid.addValidationError
|
public function addValidationError($errorMessage)
{
if (is_string($errorMessage)) {
$this->validationErrors[] = $errorMessage;
} else {
throw new \InvalidArgumentException(
"Invalid type '" . gettype($errorMessage). "' for argument 'errorMessage' given."
);
}
return $this;
}
|
php
|
public function addValidationError($errorMessage)
{
if (is_string($errorMessage)) {
$this->validationErrors[] = $errorMessage;
} else {
throw new \InvalidArgumentException(
"Invalid type '" . gettype($errorMessage). "' for argument 'errorMessage' given."
);
}
return $this;
}
|
[
"public",
"function",
"addValidationError",
"(",
"$",
"errorMessage",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"errorMessage",
")",
")",
"{",
"$",
"this",
"->",
"validationErrors",
"[",
"]",
"=",
"$",
"errorMessage",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Invalid type '\"",
".",
"gettype",
"(",
"$",
"errorMessage",
")",
".",
"\"' for argument 'errorMessage' given.\"",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Adds a validation error message.
@param string $errorMessage
@return $this
|
[
"Adds",
"a",
"validation",
"error",
"message",
"."
] |
train
|
https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Format/Rule/TraitIsValid.php#L51-L62
|
activecollab/databasestructure
|
src/Field/Composite/ParentField.php
|
ParentField.getFields
|
public function getFields()
{
$type_field = (new ScalarStringField($this->type_field_name));
$id_field = (new IntegerField($this->name, 0))->size($this->getSize())->unsigned();
if ($this->isRequired()) {
$type_field->required();
$id_field->required();
}
return [$type_field, $id_field];
}
|
php
|
public function getFields()
{
$type_field = (new ScalarStringField($this->type_field_name));
$id_field = (new IntegerField($this->name, 0))->size($this->getSize())->unsigned();
if ($this->isRequired()) {
$type_field->required();
$id_field->required();
}
return [$type_field, $id_field];
}
|
[
"public",
"function",
"getFields",
"(",
")",
"{",
"$",
"type_field",
"=",
"(",
"new",
"ScalarStringField",
"(",
"$",
"this",
"->",
"type_field_name",
")",
")",
";",
"$",
"id_field",
"=",
"(",
"new",
"IntegerField",
"(",
"$",
"this",
"->",
"name",
",",
"0",
")",
")",
"->",
"size",
"(",
"$",
"this",
"->",
"getSize",
"(",
")",
")",
"->",
"unsigned",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isRequired",
"(",
")",
")",
"{",
"$",
"type_field",
"->",
"required",
"(",
")",
";",
"$",
"id_field",
"->",
"required",
"(",
")",
";",
"}",
"return",
"[",
"$",
"type_field",
",",
"$",
"id_field",
"]",
";",
"}"
] |
{@inheritdoc}
|
[
"{"
] |
train
|
https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Field/Composite/ParentField.php#L88-L99
|
activecollab/databasestructure
|
src/Field/Composite/ParentField.php
|
ParentField.getBaseClassMethods
|
public function getBaseClassMethods($indent, array &$result)
{
$type_getter_name = 'get' . Inflector::classify($this->type_field_name);
$type_setter_name = 'set' . Inflector::classify($this->type_field_name);
$id_getter_name = 'get' . Inflector::classify($this->name);
$id_setter_name = 'set' . Inflector::classify($this->name);
$instance_getter_name = 'get' . Inflector::classify($this->relation_name);
$instance_setter_name = 'set' . Inflector::classify($this->relation_name);
$type_hint = '\\' . ObjectInterface::class;
$methods = [];
$methods[] = '/**';
$methods[] = ' * @param bool' . str_pad('$use_cache', strlen($type_hint) + 7, ' ', STR_PAD_LEFT);
$methods[] = ' * @return ' . $type_hint;
$methods[] = ' */';
$methods[] = 'public function ' . $instance_getter_name . '($use_cache = true)';
$methods[] = '{';
$methods[] = ' if ($id = $this->' . $id_getter_name . '()) {';
$methods[] = ' return $this->pool->getById($this->' . $type_getter_name . '(), $id, $use_cache);';
$methods[] = ' } else {';
$methods[] = ' return null;';
$methods[] = ' }';
$methods[] = '}';
$methods[] = '';
if ($this->isRequired()) {
$methods[] = '/**';
$methods[] = ' * Set ' . $this->relation_name . '.';
$methods[] = ' *';
$methods[] = ' * @param ' . $type_hint . ' $value';
$methods[] = ' * @return $this';
$methods[] = ' */';
$methods[] = 'public function &' . $instance_setter_name . '(\\' . ObjectInterface::class . ' $value)';
$methods[] = '{';
$methods[] = ' if ($value instanceof \\' . ObjectInterface::class . ' && $value->isLoaded()) {';
$methods[] = ' $this->' . $type_setter_name . '(get_class($value));';
$methods[] = ' $this->' . $id_setter_name . '($value->getId());';
$methods[] = ' } else {';
$methods[] = ' throw new \InvalidArgumentException(' . var_export("Instance of '" . ObjectInterface::class . "' expected", true) . ');';
$methods[] = ' }';
$methods[] = '';
$methods[] = ' return $this;';
$methods[] = '}';
} else {
$methods[] = '/**';
$methods[] = ' * Set ' . $this->relation_name . '.';
$methods[] = ' *';
$methods[] = ' * @param ' . $type_hint . ' $value';
$methods[] = ' * @return $this';
$methods[] = ' */';
$methods[] = 'public function &' . $instance_setter_name . '(\\' . ObjectInterface::class . ' $value = null)';
$methods[] = '{';
$methods[] = ' if ($value instanceof \\' . ObjectInterface::class . ') {';
$methods[] = ' if ($value->isLoaded()) {';
$methods[] = ' $this->' . $type_setter_name . '(get_class($value));';
$methods[] = ' $this->' . $id_setter_name . '($value->getId());';
$methods[] = ' } else {';
$methods[] = ' throw new \InvalidArgumentException(' . var_export("Instance of '" . ObjectInterface::class . "' expected", true) . ');';
$methods[] = ' }';
$methods[] = ' } else {';
$methods[] = ' $this->' . $type_setter_name . '(null);';
$methods[] = ' $this->' . $id_setter_name . '(0);';
$methods[] = ' }';
$methods[] = '';
$methods[] = ' return $this;';
$methods[] = '}';
}
foreach ($methods as $line) {
if ($line) {
$result[] = "$indent$line";
} else {
$result[] = '';
}
}
}
|
php
|
public function getBaseClassMethods($indent, array &$result)
{
$type_getter_name = 'get' . Inflector::classify($this->type_field_name);
$type_setter_name = 'set' . Inflector::classify($this->type_field_name);
$id_getter_name = 'get' . Inflector::classify($this->name);
$id_setter_name = 'set' . Inflector::classify($this->name);
$instance_getter_name = 'get' . Inflector::classify($this->relation_name);
$instance_setter_name = 'set' . Inflector::classify($this->relation_name);
$type_hint = '\\' . ObjectInterface::class;
$methods = [];
$methods[] = '/**';
$methods[] = ' * @param bool' . str_pad('$use_cache', strlen($type_hint) + 7, ' ', STR_PAD_LEFT);
$methods[] = ' * @return ' . $type_hint;
$methods[] = ' */';
$methods[] = 'public function ' . $instance_getter_name . '($use_cache = true)';
$methods[] = '{';
$methods[] = ' if ($id = $this->' . $id_getter_name . '()) {';
$methods[] = ' return $this->pool->getById($this->' . $type_getter_name . '(), $id, $use_cache);';
$methods[] = ' } else {';
$methods[] = ' return null;';
$methods[] = ' }';
$methods[] = '}';
$methods[] = '';
if ($this->isRequired()) {
$methods[] = '/**';
$methods[] = ' * Set ' . $this->relation_name . '.';
$methods[] = ' *';
$methods[] = ' * @param ' . $type_hint . ' $value';
$methods[] = ' * @return $this';
$methods[] = ' */';
$methods[] = 'public function &' . $instance_setter_name . '(\\' . ObjectInterface::class . ' $value)';
$methods[] = '{';
$methods[] = ' if ($value instanceof \\' . ObjectInterface::class . ' && $value->isLoaded()) {';
$methods[] = ' $this->' . $type_setter_name . '(get_class($value));';
$methods[] = ' $this->' . $id_setter_name . '($value->getId());';
$methods[] = ' } else {';
$methods[] = ' throw new \InvalidArgumentException(' . var_export("Instance of '" . ObjectInterface::class . "' expected", true) . ');';
$methods[] = ' }';
$methods[] = '';
$methods[] = ' return $this;';
$methods[] = '}';
} else {
$methods[] = '/**';
$methods[] = ' * Set ' . $this->relation_name . '.';
$methods[] = ' *';
$methods[] = ' * @param ' . $type_hint . ' $value';
$methods[] = ' * @return $this';
$methods[] = ' */';
$methods[] = 'public function &' . $instance_setter_name . '(\\' . ObjectInterface::class . ' $value = null)';
$methods[] = '{';
$methods[] = ' if ($value instanceof \\' . ObjectInterface::class . ') {';
$methods[] = ' if ($value->isLoaded()) {';
$methods[] = ' $this->' . $type_setter_name . '(get_class($value));';
$methods[] = ' $this->' . $id_setter_name . '($value->getId());';
$methods[] = ' } else {';
$methods[] = ' throw new \InvalidArgumentException(' . var_export("Instance of '" . ObjectInterface::class . "' expected", true) . ');';
$methods[] = ' }';
$methods[] = ' } else {';
$methods[] = ' $this->' . $type_setter_name . '(null);';
$methods[] = ' $this->' . $id_setter_name . '(0);';
$methods[] = ' }';
$methods[] = '';
$methods[] = ' return $this;';
$methods[] = '}';
}
foreach ($methods as $line) {
if ($line) {
$result[] = "$indent$line";
} else {
$result[] = '';
}
}
}
|
[
"public",
"function",
"getBaseClassMethods",
"(",
"$",
"indent",
",",
"array",
"&",
"$",
"result",
")",
"{",
"$",
"type_getter_name",
"=",
"'get'",
".",
"Inflector",
"::",
"classify",
"(",
"$",
"this",
"->",
"type_field_name",
")",
";",
"$",
"type_setter_name",
"=",
"'set'",
".",
"Inflector",
"::",
"classify",
"(",
"$",
"this",
"->",
"type_field_name",
")",
";",
"$",
"id_getter_name",
"=",
"'get'",
".",
"Inflector",
"::",
"classify",
"(",
"$",
"this",
"->",
"name",
")",
";",
"$",
"id_setter_name",
"=",
"'set'",
".",
"Inflector",
"::",
"classify",
"(",
"$",
"this",
"->",
"name",
")",
";",
"$",
"instance_getter_name",
"=",
"'get'",
".",
"Inflector",
"::",
"classify",
"(",
"$",
"this",
"->",
"relation_name",
")",
";",
"$",
"instance_setter_name",
"=",
"'set'",
".",
"Inflector",
"::",
"classify",
"(",
"$",
"this",
"->",
"relation_name",
")",
";",
"$",
"type_hint",
"=",
"'\\\\'",
".",
"ObjectInterface",
"::",
"class",
";",
"$",
"methods",
"=",
"[",
"]",
";",
"$",
"methods",
"[",
"]",
"=",
"'/**'",
";",
"$",
"methods",
"[",
"]",
"=",
"' * @param bool'",
".",
"str_pad",
"(",
"'$use_cache'",
",",
"strlen",
"(",
"$",
"type_hint",
")",
"+",
"7",
",",
"' '",
",",
"STR_PAD_LEFT",
")",
";",
"$",
"methods",
"[",
"]",
"=",
"' * @return '",
".",
"$",
"type_hint",
";",
"$",
"methods",
"[",
"]",
"=",
"' */'",
";",
"$",
"methods",
"[",
"]",
"=",
"'public function '",
".",
"$",
"instance_getter_name",
".",
"'($use_cache = true)'",
";",
"$",
"methods",
"[",
"]",
"=",
"'{'",
";",
"$",
"methods",
"[",
"]",
"=",
"' if ($id = $this->'",
".",
"$",
"id_getter_name",
".",
"'()) {'",
";",
"$",
"methods",
"[",
"]",
"=",
"' return $this->pool->getById($this->'",
".",
"$",
"type_getter_name",
".",
"'(), $id, $use_cache);'",
";",
"$",
"methods",
"[",
"]",
"=",
"' } else {'",
";",
"$",
"methods",
"[",
"]",
"=",
"' return null;'",
";",
"$",
"methods",
"[",
"]",
"=",
"' }'",
";",
"$",
"methods",
"[",
"]",
"=",
"'}'",
";",
"$",
"methods",
"[",
"]",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"isRequired",
"(",
")",
")",
"{",
"$",
"methods",
"[",
"]",
"=",
"'/**'",
";",
"$",
"methods",
"[",
"]",
"=",
"' * Set '",
".",
"$",
"this",
"->",
"relation_name",
".",
"'.'",
";",
"$",
"methods",
"[",
"]",
"=",
"' *'",
";",
"$",
"methods",
"[",
"]",
"=",
"' * @param '",
".",
"$",
"type_hint",
".",
"' $value'",
";",
"$",
"methods",
"[",
"]",
"=",
"' * @return $this'",
";",
"$",
"methods",
"[",
"]",
"=",
"' */'",
";",
"$",
"methods",
"[",
"]",
"=",
"'public function &'",
".",
"$",
"instance_setter_name",
".",
"'(\\\\'",
".",
"ObjectInterface",
"::",
"class",
".",
"' $value)'",
";",
"$",
"methods",
"[",
"]",
"=",
"'{'",
";",
"$",
"methods",
"[",
"]",
"=",
"' if ($value instanceof \\\\'",
".",
"ObjectInterface",
"::",
"class",
".",
"' && $value->isLoaded()) {'",
";",
"$",
"methods",
"[",
"]",
"=",
"' $this->'",
".",
"$",
"type_setter_name",
".",
"'(get_class($value));'",
";",
"$",
"methods",
"[",
"]",
"=",
"' $this->'",
".",
"$",
"id_setter_name",
".",
"'($value->getId());'",
";",
"$",
"methods",
"[",
"]",
"=",
"' } else {'",
";",
"$",
"methods",
"[",
"]",
"=",
"' throw new \\InvalidArgumentException('",
".",
"var_export",
"(",
"\"Instance of '\"",
".",
"ObjectInterface",
"::",
"class",
".",
"\"' expected\"",
",",
"true",
")",
".",
"');'",
";",
"$",
"methods",
"[",
"]",
"=",
"' }'",
";",
"$",
"methods",
"[",
"]",
"=",
"''",
";",
"$",
"methods",
"[",
"]",
"=",
"' return $this;'",
";",
"$",
"methods",
"[",
"]",
"=",
"'}'",
";",
"}",
"else",
"{",
"$",
"methods",
"[",
"]",
"=",
"'/**'",
";",
"$",
"methods",
"[",
"]",
"=",
"' * Set '",
".",
"$",
"this",
"->",
"relation_name",
".",
"'.'",
";",
"$",
"methods",
"[",
"]",
"=",
"' *'",
";",
"$",
"methods",
"[",
"]",
"=",
"' * @param '",
".",
"$",
"type_hint",
".",
"' $value'",
";",
"$",
"methods",
"[",
"]",
"=",
"' * @return $this'",
";",
"$",
"methods",
"[",
"]",
"=",
"' */'",
";",
"$",
"methods",
"[",
"]",
"=",
"'public function &'",
".",
"$",
"instance_setter_name",
".",
"'(\\\\'",
".",
"ObjectInterface",
"::",
"class",
".",
"' $value = null)'",
";",
"$",
"methods",
"[",
"]",
"=",
"'{'",
";",
"$",
"methods",
"[",
"]",
"=",
"' if ($value instanceof \\\\'",
".",
"ObjectInterface",
"::",
"class",
".",
"') {'",
";",
"$",
"methods",
"[",
"]",
"=",
"' if ($value->isLoaded()) {'",
";",
"$",
"methods",
"[",
"]",
"=",
"' $this->'",
".",
"$",
"type_setter_name",
".",
"'(get_class($value));'",
";",
"$",
"methods",
"[",
"]",
"=",
"' $this->'",
".",
"$",
"id_setter_name",
".",
"'($value->getId());'",
";",
"$",
"methods",
"[",
"]",
"=",
"' } else {'",
";",
"$",
"methods",
"[",
"]",
"=",
"' throw new \\InvalidArgumentException('",
".",
"var_export",
"(",
"\"Instance of '\"",
".",
"ObjectInterface",
"::",
"class",
".",
"\"' expected\"",
",",
"true",
")",
".",
"');'",
";",
"$",
"methods",
"[",
"]",
"=",
"' }'",
";",
"$",
"methods",
"[",
"]",
"=",
"' } else {'",
";",
"$",
"methods",
"[",
"]",
"=",
"' $this->'",
".",
"$",
"type_setter_name",
".",
"'(null);'",
";",
"$",
"methods",
"[",
"]",
"=",
"' $this->'",
".",
"$",
"id_setter_name",
".",
"'(0);'",
";",
"$",
"methods",
"[",
"]",
"=",
"' }'",
";",
"$",
"methods",
"[",
"]",
"=",
"''",
";",
"$",
"methods",
"[",
"]",
"=",
"' return $this;'",
";",
"$",
"methods",
"[",
"]",
"=",
"'}'",
";",
"}",
"foreach",
"(",
"$",
"methods",
"as",
"$",
"line",
")",
"{",
"if",
"(",
"$",
"line",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"\"$indent$line\"",
";",
"}",
"else",
"{",
"$",
"result",
"[",
"]",
"=",
"''",
";",
"}",
"}",
"}"
] |
Return methods that this field needs to inject in base class.
@param string $indent
@param array $result
|
[
"Return",
"methods",
"that",
"this",
"field",
"needs",
"to",
"inject",
"in",
"base",
"class",
"."
] |
train
|
https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Field/Composite/ParentField.php#L107-L186
|
activecollab/databasestructure
|
src/Field/Composite/ParentField.php
|
ParentField.onAddedToType
|
public function onAddedToType(TypeInterface &$type)
{
parent::onAddedToType($type);
if ($this->getAddIndex()) {
$type->addIndex(new Index($this->relation_name, [$this->type_field_name, $this->name]));
$type->addIndex(new Index($this->name));
}
$type->serialize($this->type_field_name, $this->name);
}
|
php
|
public function onAddedToType(TypeInterface &$type)
{
parent::onAddedToType($type);
if ($this->getAddIndex()) {
$type->addIndex(new Index($this->relation_name, [$this->type_field_name, $this->name]));
$type->addIndex(new Index($this->name));
}
$type->serialize($this->type_field_name, $this->name);
}
|
[
"public",
"function",
"onAddedToType",
"(",
"TypeInterface",
"&",
"$",
"type",
")",
"{",
"parent",
"::",
"onAddedToType",
"(",
"$",
"type",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getAddIndex",
"(",
")",
")",
"{",
"$",
"type",
"->",
"addIndex",
"(",
"new",
"Index",
"(",
"$",
"this",
"->",
"relation_name",
",",
"[",
"$",
"this",
"->",
"type_field_name",
",",
"$",
"this",
"->",
"name",
"]",
")",
")",
";",
"$",
"type",
"->",
"addIndex",
"(",
"new",
"Index",
"(",
"$",
"this",
"->",
"name",
")",
")",
";",
"}",
"$",
"type",
"->",
"serialize",
"(",
"$",
"this",
"->",
"type_field_name",
",",
"$",
"this",
"->",
"name",
")",
";",
"}"
] |
{@inheritdoc}
|
[
"{"
] |
train
|
https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Field/Composite/ParentField.php#L191-L201
|
phpalchemy/cerberus
|
src/Alchemy/Component/Cerberus/Model/Base/LogQuery.php
|
LogQuery.filterByDateTime
|
public function filterByDateTime($dateTime = null, $comparison = null)
{
if (is_array($dateTime)) {
$useMinMax = false;
if (isset($dateTime['min'])) {
$this->addUsingAlias(LogTableMap::COL_DATE_TIME, $dateTime['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($dateTime['max'])) {
$this->addUsingAlias(LogTableMap::COL_DATE_TIME, $dateTime['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(LogTableMap::COL_DATE_TIME, $dateTime, $comparison);
}
|
php
|
public function filterByDateTime($dateTime = null, $comparison = null)
{
if (is_array($dateTime)) {
$useMinMax = false;
if (isset($dateTime['min'])) {
$this->addUsingAlias(LogTableMap::COL_DATE_TIME, $dateTime['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($dateTime['max'])) {
$this->addUsingAlias(LogTableMap::COL_DATE_TIME, $dateTime['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(LogTableMap::COL_DATE_TIME, $dateTime, $comparison);
}
|
[
"public",
"function",
"filterByDateTime",
"(",
"$",
"dateTime",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"dateTime",
")",
")",
"{",
"$",
"useMinMax",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"dateTime",
"[",
"'min'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"LogTableMap",
"::",
"COL_DATE_TIME",
",",
"$",
"dateTime",
"[",
"'min'",
"]",
",",
"Criteria",
"::",
"GREATER_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"dateTime",
"[",
"'max'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"LogTableMap",
"::",
"COL_DATE_TIME",
",",
"$",
"dateTime",
"[",
"'max'",
"]",
",",
"Criteria",
"::",
"LESS_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"useMinMax",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"LogTableMap",
"::",
"COL_DATE_TIME",
",",
"$",
"dateTime",
",",
"$",
"comparison",
")",
";",
"}"
] |
Filter the query on the date_time column
Example usage:
<code>
$query->filterByDateTime('2011-03-14'); // WHERE date_time = '2011-03-14'
$query->filterByDateTime('now'); // WHERE date_time = '2011-03-14'
$query->filterByDateTime(array('max' => 'yesterday')); // WHERE date_time > '2011-03-13'
</code>
@param mixed $dateTime The value to use as filter.
Values can be integers (unix timestamps), DateTime objects, or strings.
Empty strings are treated as NULL.
Use scalar values for equality.
Use array values for in_array() equivalent.
Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildLogQuery The current query, for fluid interface
|
[
"Filter",
"the",
"query",
"on",
"the",
"date_time",
"column"
] |
train
|
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/LogQuery.php#L346-L367
|
phpalchemy/cerberus
|
src/Alchemy/Component/Cerberus/Model/Base/LogQuery.php
|
LogQuery.filterByLogText
|
public function filterByLogText($logText = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($logText)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $logText)) {
$logText = str_replace('*', '%', $logText);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(LogTableMap::COL_LOG_TEXT, $logText, $comparison);
}
|
php
|
public function filterByLogText($logText = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($logText)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $logText)) {
$logText = str_replace('*', '%', $logText);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(LogTableMap::COL_LOG_TEXT, $logText, $comparison);
}
|
[
"public",
"function",
"filterByLogText",
"(",
"$",
"logText",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"logText",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"logText",
")",
")",
"{",
"$",
"logText",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"logText",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"LogTableMap",
"::",
"COL_LOG_TEXT",
",",
"$",
"logText",
",",
"$",
"comparison",
")",
";",
"}"
] |
Filter the query on the log_text column
Example usage:
<code>
$query->filterByLogText('fooValue'); // WHERE log_text = 'fooValue'
$query->filterByLogText('%fooValue%'); // WHERE log_text LIKE '%fooValue%'
</code>
@param string $logText The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildLogQuery The current query, for fluid interface
|
[
"Filter",
"the",
"query",
"on",
"the",
"log_text",
"column"
] |
train
|
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/LogQuery.php#L384-L396
|
phpalchemy/cerberus
|
src/Alchemy/Component/Cerberus/Model/Base/LogQuery.php
|
LogQuery.filterByUserId
|
public function filterByUserId($userId = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($userId)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $userId)) {
$userId = str_replace('*', '%', $userId);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(LogTableMap::COL_USER_ID, $userId, $comparison);
}
|
php
|
public function filterByUserId($userId = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($userId)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $userId)) {
$userId = str_replace('*', '%', $userId);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(LogTableMap::COL_USER_ID, $userId, $comparison);
}
|
[
"public",
"function",
"filterByUserId",
"(",
"$",
"userId",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"userId",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"userId",
")",
")",
"{",
"$",
"userId",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"userId",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"LogTableMap",
"::",
"COL_USER_ID",
",",
"$",
"userId",
",",
"$",
"comparison",
")",
";",
"}"
] |
Filter the query on the user_id column
Example usage:
<code>
$query->filterByUserId('fooValue'); // WHERE user_id = 'fooValue'
$query->filterByUserId('%fooValue%'); // WHERE user_id LIKE '%fooValue%'
</code>
@param string $userId The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildLogQuery The current query, for fluid interface
|
[
"Filter",
"the",
"query",
"on",
"the",
"user_id",
"column"
] |
train
|
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/LogQuery.php#L413-L425
|
phpalchemy/cerberus
|
src/Alchemy/Component/Cerberus/Model/Base/LogQuery.php
|
LogQuery.filterByUsername
|
public function filterByUsername($username = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($username)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $username)) {
$username = str_replace('*', '%', $username);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(LogTableMap::COL_USERNAME, $username, $comparison);
}
|
php
|
public function filterByUsername($username = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($username)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $username)) {
$username = str_replace('*', '%', $username);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(LogTableMap::COL_USERNAME, $username, $comparison);
}
|
[
"public",
"function",
"filterByUsername",
"(",
"$",
"username",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"username",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"username",
")",
")",
"{",
"$",
"username",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"username",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"LogTableMap",
"::",
"COL_USERNAME",
",",
"$",
"username",
",",
"$",
"comparison",
")",
";",
"}"
] |
Filter the query on the username column
Example usage:
<code>
$query->filterByUsername('fooValue'); // WHERE username = 'fooValue'
$query->filterByUsername('%fooValue%'); // WHERE username LIKE '%fooValue%'
</code>
@param string $username The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildLogQuery The current query, for fluid interface
|
[
"Filter",
"the",
"query",
"on",
"the",
"username",
"column"
] |
train
|
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/LogQuery.php#L442-L454
|
phpalchemy/cerberus
|
src/Alchemy/Component/Cerberus/Model/Base/LogQuery.php
|
LogQuery.filterBySessionId
|
public function filterBySessionId($sessionId = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($sessionId)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $sessionId)) {
$sessionId = str_replace('*', '%', $sessionId);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(LogTableMap::COL_SESSION_ID, $sessionId, $comparison);
}
|
php
|
public function filterBySessionId($sessionId = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($sessionId)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $sessionId)) {
$sessionId = str_replace('*', '%', $sessionId);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(LogTableMap::COL_SESSION_ID, $sessionId, $comparison);
}
|
[
"public",
"function",
"filterBySessionId",
"(",
"$",
"sessionId",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"sessionId",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"sessionId",
")",
")",
"{",
"$",
"sessionId",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"sessionId",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"LogTableMap",
"::",
"COL_SESSION_ID",
",",
"$",
"sessionId",
",",
"$",
"comparison",
")",
";",
"}"
] |
Filter the query on the session_id column
Example usage:
<code>
$query->filterBySessionId('fooValue'); // WHERE session_id = 'fooValue'
$query->filterBySessionId('%fooValue%'); // WHERE session_id LIKE '%fooValue%'
</code>
@param string $sessionId The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildLogQuery The current query, for fluid interface
|
[
"Filter",
"the",
"query",
"on",
"the",
"session_id",
"column"
] |
train
|
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/LogQuery.php#L471-L483
|
phpalchemy/cerberus
|
src/Alchemy/Component/Cerberus/Model/Base/LogQuery.php
|
LogQuery.filterByClientAgent
|
public function filterByClientAgent($clientAgent = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($clientAgent)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $clientAgent)) {
$clientAgent = str_replace('*', '%', $clientAgent);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(LogTableMap::COL_CLIENT_AGENT, $clientAgent, $comparison);
}
|
php
|
public function filterByClientAgent($clientAgent = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($clientAgent)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $clientAgent)) {
$clientAgent = str_replace('*', '%', $clientAgent);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(LogTableMap::COL_CLIENT_AGENT, $clientAgent, $comparison);
}
|
[
"public",
"function",
"filterByClientAgent",
"(",
"$",
"clientAgent",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"clientAgent",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"clientAgent",
")",
")",
"{",
"$",
"clientAgent",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"clientAgent",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"LogTableMap",
"::",
"COL_CLIENT_AGENT",
",",
"$",
"clientAgent",
",",
"$",
"comparison",
")",
";",
"}"
] |
Filter the query on the client_agent column
Example usage:
<code>
$query->filterByClientAgent('fooValue'); // WHERE client_agent = 'fooValue'
$query->filterByClientAgent('%fooValue%'); // WHERE client_agent LIKE '%fooValue%'
</code>
@param string $clientAgent The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildLogQuery The current query, for fluid interface
|
[
"Filter",
"the",
"query",
"on",
"the",
"client_agent",
"column"
] |
train
|
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/LogQuery.php#L558-L570
|
phpalchemy/cerberus
|
src/Alchemy/Component/Cerberus/Model/Base/LogQuery.php
|
LogQuery.filterByClientPlatform
|
public function filterByClientPlatform($clientPlatform = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($clientPlatform)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $clientPlatform)) {
$clientPlatform = str_replace('*', '%', $clientPlatform);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(LogTableMap::COL_CLIENT_PLATFORM, $clientPlatform, $comparison);
}
|
php
|
public function filterByClientPlatform($clientPlatform = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($clientPlatform)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $clientPlatform)) {
$clientPlatform = str_replace('*', '%', $clientPlatform);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(LogTableMap::COL_CLIENT_PLATFORM, $clientPlatform, $comparison);
}
|
[
"public",
"function",
"filterByClientPlatform",
"(",
"$",
"clientPlatform",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"clientPlatform",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"clientPlatform",
")",
")",
"{",
"$",
"clientPlatform",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"clientPlatform",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"LogTableMap",
"::",
"COL_CLIENT_PLATFORM",
",",
"$",
"clientPlatform",
",",
"$",
"comparison",
")",
";",
"}"
] |
Filter the query on the client_platform column
Example usage:
<code>
$query->filterByClientPlatform('fooValue'); // WHERE client_platform = 'fooValue'
$query->filterByClientPlatform('%fooValue%'); // WHERE client_platform LIKE '%fooValue%'
</code>
@param string $clientPlatform The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildLogQuery The current query, for fluid interface
|
[
"Filter",
"the",
"query",
"on",
"the",
"client_platform",
"column"
] |
train
|
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/LogQuery.php#L587-L599
|
phpalchemy/cerberus
|
src/Alchemy/Component/Cerberus/Model/Base/LogQuery.php
|
LogQuery.prune
|
public function prune($log = null)
{
if ($log) {
$this->addUsingAlias(LogTableMap::COL_ID, $log->getId(), Criteria::NOT_EQUAL);
}
return $this;
}
|
php
|
public function prune($log = null)
{
if ($log) {
$this->addUsingAlias(LogTableMap::COL_ID, $log->getId(), Criteria::NOT_EQUAL);
}
return $this;
}
|
[
"public",
"function",
"prune",
"(",
"$",
"log",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"log",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"LogTableMap",
"::",
"COL_ID",
",",
"$",
"log",
"->",
"getId",
"(",
")",
",",
"Criteria",
"::",
"NOT_EQUAL",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Exclude object from result
@param ChildLog $log Object to remove from the list of results
@return $this|ChildLogQuery The current query, for fluid interface
|
[
"Exclude",
"object",
"from",
"result"
] |
train
|
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/LogQuery.php#L608-L615
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.