id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
228,900
|
Ardakilic/laravel-mutlucell-sms
|
src/Ardakilic/Mutlucell/Mutlucell.php
|
Mutlucell.send
|
public function send($receiver, $message = '', $date = '', $senderID = '')
{
//Checks the $message and $senderID, and initializes it
$this->preChecks($message, $senderID);
//Pre-checks act3
if ($receiver == null || !strlen(trim($receiver))) {
//no receiver
return 102;
}
//Sending for future date
$dateStr = '';
if (strlen($date)) {
$dateStr = ' tarih="' . $date . '"';
}
$xml = '<?xml version="1.0" encoding="UTF-8"?>' . '<smspack ka="' . $this->config['auth']['username'] . '" pwd="' . $this->config['auth']['password'] . '"' . $dateStr . ' org="' . $this->senderID . '" charset="' . $this->config['charset'] . '"' . ($this->config['append_unsubscribe_link'] ? ' addLinkToEnd="true"' : '') . '>';
$xml .= '<mesaj>' . '<metin>' . $this->message . '</metin>' . '<nums>' . $receiver . '</nums>' . '</mesaj>';
$xml .= '</smspack>';
return $this->postXML($xml, 'https://smsgw.mutlucell.com/smsgw-ws/sndblkex');
}
|
php
|
public function send($receiver, $message = '', $date = '', $senderID = '')
{
//Checks the $message and $senderID, and initializes it
$this->preChecks($message, $senderID);
//Pre-checks act3
if ($receiver == null || !strlen(trim($receiver))) {
//no receiver
return 102;
}
//Sending for future date
$dateStr = '';
if (strlen($date)) {
$dateStr = ' tarih="' . $date . '"';
}
$xml = '<?xml version="1.0" encoding="UTF-8"?>' . '<smspack ka="' . $this->config['auth']['username'] . '" pwd="' . $this->config['auth']['password'] . '"' . $dateStr . ' org="' . $this->senderID . '" charset="' . $this->config['charset'] . '"' . ($this->config['append_unsubscribe_link'] ? ' addLinkToEnd="true"' : '') . '>';
$xml .= '<mesaj>' . '<metin>' . $this->message . '</metin>' . '<nums>' . $receiver . '</nums>' . '</mesaj>';
$xml .= '</smspack>';
return $this->postXML($xml, 'https://smsgw.mutlucell.com/smsgw-ws/sndblkex');
}
|
[
"public",
"function",
"send",
"(",
"$",
"receiver",
",",
"$",
"message",
"=",
"''",
",",
"$",
"date",
"=",
"''",
",",
"$",
"senderID",
"=",
"''",
")",
"{",
"//Checks the $message and $senderID, and initializes it",
"$",
"this",
"->",
"preChecks",
"(",
"$",
"message",
",",
"$",
"senderID",
")",
";",
"//Pre-checks act3",
"if",
"(",
"$",
"receiver",
"==",
"null",
"||",
"!",
"strlen",
"(",
"trim",
"(",
"$",
"receiver",
")",
")",
")",
"{",
"//no receiver",
"return",
"102",
";",
"}",
"//Sending for future date",
"$",
"dateStr",
"=",
"''",
";",
"if",
"(",
"strlen",
"(",
"$",
"date",
")",
")",
"{",
"$",
"dateStr",
"=",
"' tarih=\"'",
".",
"$",
"date",
".",
"'\"'",
";",
"}",
"$",
"xml",
"=",
"'<?xml version=\"1.0\" encoding=\"UTF-8\"?>'",
".",
"'<smspack ka=\"'",
".",
"$",
"this",
"->",
"config",
"[",
"'auth'",
"]",
"[",
"'username'",
"]",
".",
"'\" pwd=\"'",
".",
"$",
"this",
"->",
"config",
"[",
"'auth'",
"]",
"[",
"'password'",
"]",
".",
"'\"'",
".",
"$",
"dateStr",
".",
"' org=\"'",
".",
"$",
"this",
"->",
"senderID",
".",
"'\" charset=\"'",
".",
"$",
"this",
"->",
"config",
"[",
"'charset'",
"]",
".",
"'\"'",
".",
"(",
"$",
"this",
"->",
"config",
"[",
"'append_unsubscribe_link'",
"]",
"?",
"' addLinkToEnd=\"true\"'",
":",
"''",
")",
".",
"'>'",
";",
"$",
"xml",
".=",
"'<mesaj>'",
".",
"'<metin>'",
".",
"$",
"this",
"->",
"message",
".",
"'</metin>'",
".",
"'<nums>'",
".",
"$",
"receiver",
".",
"'</nums>'",
".",
"'</mesaj>'",
";",
"$",
"xml",
".=",
"'</smspack>'",
";",
"return",
"$",
"this",
"->",
"postXML",
"(",
"$",
"xml",
",",
"'https://smsgw.mutlucell.com/smsgw-ws/sndblkex'",
")",
";",
"}"
] |
Sends a single SMS to a single person
@param string $receiver receiver number
@param string $message message to be sent
@param string $date delivery date
@param string $senderID originator/sender id (may be a text or number)
@return string status API response
|
[
"Sends",
"a",
"single",
"SMS",
"to",
"a",
"single",
"person"
] |
a6b5208b6cffe7c33b1fe9fb670e8e16a86b4b11
|
https://github.com/Ardakilic/laravel-mutlucell-sms/blob/a6b5208b6cffe7c33b1fe9fb670e8e16a86b4b11/src/Ardakilic/Mutlucell/Mutlucell.php#L114-L138
|
228,901
|
Ardakilic/laravel-mutlucell-sms
|
src/Ardakilic/Mutlucell/Mutlucell.php
|
Mutlucell.sendMulti
|
public function sendMulti($reciversMessage, $date = '', $senderID = '')
{
//Pre-checks act1
if ($senderID == null || !strlen(trim($senderID))) {
$senderID = $this->config['default_sender'];
}
//Sending for future date
$dateStr = '';
if (strlen($date)) {
$dateStr = ' tarih="' . $date . '"';
}
$xml = '<?xml version="1.0" encoding="UTF-8"?>' . '<smspack ka="' . $this->config['auth']['username'] . '" pwd="' . $this->config['auth']['password'] . '"' . $dateStr . ' org="' . $senderID . '" charset="' . $this->config['charset'] . '"' . ($this->config['append_unsubscribe_link'] ? ' addLinkToEnd="true"' : '') . '>';
foreach ($reciversMessage as $eachMessageBlock) {
$number = $eachMessageBlock[0];
$message = $eachMessageBlock[1];
$xml .= '<mesaj>' . '<metin>' . $message . '</metin>' . '<nums>' . $number . '</nums>' . '</mesaj>';
}
$xml .= '</smspack>';
return $this->postXML($xml, 'https://smsgw.mutlucell.com/smsgw-ws/sndblkex');
}
|
php
|
public function sendMulti($reciversMessage, $date = '', $senderID = '')
{
//Pre-checks act1
if ($senderID == null || !strlen(trim($senderID))) {
$senderID = $this->config['default_sender'];
}
//Sending for future date
$dateStr = '';
if (strlen($date)) {
$dateStr = ' tarih="' . $date . '"';
}
$xml = '<?xml version="1.0" encoding="UTF-8"?>' . '<smspack ka="' . $this->config['auth']['username'] . '" pwd="' . $this->config['auth']['password'] . '"' . $dateStr . ' org="' . $senderID . '" charset="' . $this->config['charset'] . '"' . ($this->config['append_unsubscribe_link'] ? ' addLinkToEnd="true"' : '') . '>';
foreach ($reciversMessage as $eachMessageBlock) {
$number = $eachMessageBlock[0];
$message = $eachMessageBlock[1];
$xml .= '<mesaj>' . '<metin>' . $message . '</metin>' . '<nums>' . $number . '</nums>' . '</mesaj>';
}
$xml .= '</smspack>';
return $this->postXML($xml, 'https://smsgw.mutlucell.com/smsgw-ws/sndblkex');
}
|
[
"public",
"function",
"sendMulti",
"(",
"$",
"reciversMessage",
",",
"$",
"date",
"=",
"''",
",",
"$",
"senderID",
"=",
"''",
")",
"{",
"//Pre-checks act1",
"if",
"(",
"$",
"senderID",
"==",
"null",
"||",
"!",
"strlen",
"(",
"trim",
"(",
"$",
"senderID",
")",
")",
")",
"{",
"$",
"senderID",
"=",
"$",
"this",
"->",
"config",
"[",
"'default_sender'",
"]",
";",
"}",
"//Sending for future date",
"$",
"dateStr",
"=",
"''",
";",
"if",
"(",
"strlen",
"(",
"$",
"date",
")",
")",
"{",
"$",
"dateStr",
"=",
"' tarih=\"'",
".",
"$",
"date",
".",
"'\"'",
";",
"}",
"$",
"xml",
"=",
"'<?xml version=\"1.0\" encoding=\"UTF-8\"?>'",
".",
"'<smspack ka=\"'",
".",
"$",
"this",
"->",
"config",
"[",
"'auth'",
"]",
"[",
"'username'",
"]",
".",
"'\" pwd=\"'",
".",
"$",
"this",
"->",
"config",
"[",
"'auth'",
"]",
"[",
"'password'",
"]",
".",
"'\"'",
".",
"$",
"dateStr",
".",
"' org=\"'",
".",
"$",
"senderID",
".",
"'\" charset=\"'",
".",
"$",
"this",
"->",
"config",
"[",
"'charset'",
"]",
".",
"'\"'",
".",
"(",
"$",
"this",
"->",
"config",
"[",
"'append_unsubscribe_link'",
"]",
"?",
"' addLinkToEnd=\"true\"'",
":",
"''",
")",
".",
"'>'",
";",
"foreach",
"(",
"$",
"reciversMessage",
"as",
"$",
"eachMessageBlock",
")",
"{",
"$",
"number",
"=",
"$",
"eachMessageBlock",
"[",
"0",
"]",
";",
"$",
"message",
"=",
"$",
"eachMessageBlock",
"[",
"1",
"]",
";",
"$",
"xml",
".=",
"'<mesaj>'",
".",
"'<metin>'",
".",
"$",
"message",
".",
"'</metin>'",
".",
"'<nums>'",
".",
"$",
"number",
".",
"'</nums>'",
".",
"'</mesaj>'",
";",
"}",
"$",
"xml",
".=",
"'</smspack>'",
";",
"return",
"$",
"this",
"->",
"postXML",
"(",
"$",
"xml",
",",
"'https://smsgw.mutlucell.com/smsgw-ws/sndblkex'",
")",
";",
"}"
] |
Sends multiple SMSes to various people with various content
@param array $reciversMessage recipents and message
@param string $date delivery date
@param string $senderID originator/sender id (may be a text or number)
@return string status API response
|
[
"Sends",
"multiple",
"SMSes",
"to",
"various",
"people",
"with",
"various",
"content"
] |
a6b5208b6cffe7c33b1fe9fb670e8e16a86b4b11
|
https://github.com/Ardakilic/laravel-mutlucell-sms/blob/a6b5208b6cffe7c33b1fe9fb670e8e16a86b4b11/src/Ardakilic/Mutlucell/Mutlucell.php#L148-L173
|
228,902
|
Ardakilic/laravel-mutlucell-sms
|
src/Ardakilic/Mutlucell/Mutlucell.php
|
Mutlucell.checkBalance
|
public function checkBalance()
{
$xml = '<?xml version="1.0" encoding="UTF-8"?>' . '<smskredi ka="' . $this->config['auth']['username'] . '" pwd="' . $this->config['auth']['password'] . '" />';
$response = $this->postXML($xml, 'https://smsgw.mutlucell.com/smsgw-ws/gtcrdtex');
//Data will be like $1986.0,
//since 1st character is $, and it is float (srsly, why?) we will strip it and make it integer
return intval(substr($response, 1));
}
|
php
|
public function checkBalance()
{
$xml = '<?xml version="1.0" encoding="UTF-8"?>' . '<smskredi ka="' . $this->config['auth']['username'] . '" pwd="' . $this->config['auth']['password'] . '" />';
$response = $this->postXML($xml, 'https://smsgw.mutlucell.com/smsgw-ws/gtcrdtex');
//Data will be like $1986.0,
//since 1st character is $, and it is float (srsly, why?) we will strip it and make it integer
return intval(substr($response, 1));
}
|
[
"public",
"function",
"checkBalance",
"(",
")",
"{",
"$",
"xml",
"=",
"'<?xml version=\"1.0\" encoding=\"UTF-8\"?>'",
".",
"'<smskredi ka=\"'",
".",
"$",
"this",
"->",
"config",
"[",
"'auth'",
"]",
"[",
"'username'",
"]",
".",
"'\" pwd=\"'",
".",
"$",
"this",
"->",
"config",
"[",
"'auth'",
"]",
"[",
"'password'",
"]",
".",
"'\" />'",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"postXML",
"(",
"$",
"xml",
",",
"'https://smsgw.mutlucell.com/smsgw-ws/gtcrdtex'",
")",
";",
"//Data will be like $1986.0,",
"//since 1st character is $, and it is float (srsly, why?) we will strip it and make it integer",
"return",
"intval",
"(",
"substr",
"(",
"$",
"response",
",",
"1",
")",
")",
";",
"}"
] |
Balance Checker
Shows how much SMS you have left
@return integer number of SMSes left for the account
|
[
"Balance",
"Checker",
"Shows",
"how",
"much",
"SMS",
"you",
"have",
"left"
] |
a6b5208b6cffe7c33b1fe9fb670e8e16a86b4b11
|
https://github.com/Ardakilic/laravel-mutlucell-sms/blob/a6b5208b6cffe7c33b1fe9fb670e8e16a86b4b11/src/Ardakilic/Mutlucell/Mutlucell.php#L258-L267
|
228,903
|
Ardakilic/laravel-mutlucell-sms
|
src/Ardakilic/Mutlucell/Mutlucell.php
|
Mutlucell.parseOutput
|
public function parseOutput($output)
{
//if error code is returned, api OR the app will return an integer error code
if ($this->isnum($output)) {
switch ($output) {
case 20:
return $this->lang['reports']['20'];
break;
case 21:
return $this->lang['reports']['21'];
break;
case 22:
return $this->lang['reports']['22'];
break;
case 23:
return $this->lang['reports']['23'];
break;
case 24:
return $this->lang['reports']['24'];
break;
case 25:
return $this->lang['reports']['25'];
break;
case 30:
return $this->lang['reports']['30'];
break;
//In-app messages:
case 100:
return $this->lang['app'][0];
break;
case 101:
return $this->lang['app'][1];
break;
case 102:
return $this->lang['app'][2];
break;
default:
return $this->lang['reports']['999'];
break;
}
//returns from Mutlucell
} elseif (preg_match('/(\$[0-9]+\#[0-9]+\.[0-9]+)/i', $output)) {
//returned output is formatted like $ID#STATUS
//E.g: $1234567#1.0
$output = explode('#', $output);
$status = $output[1];
if ($status == '0.0') {
return $this->lang['app']['101'];
} else {
return $this->lang['app']['100'];
}
//Unknown error
} else {
return $output;
}
}
|
php
|
public function parseOutput($output)
{
//if error code is returned, api OR the app will return an integer error code
if ($this->isnum($output)) {
switch ($output) {
case 20:
return $this->lang['reports']['20'];
break;
case 21:
return $this->lang['reports']['21'];
break;
case 22:
return $this->lang['reports']['22'];
break;
case 23:
return $this->lang['reports']['23'];
break;
case 24:
return $this->lang['reports']['24'];
break;
case 25:
return $this->lang['reports']['25'];
break;
case 30:
return $this->lang['reports']['30'];
break;
//In-app messages:
case 100:
return $this->lang['app'][0];
break;
case 101:
return $this->lang['app'][1];
break;
case 102:
return $this->lang['app'][2];
break;
default:
return $this->lang['reports']['999'];
break;
}
//returns from Mutlucell
} elseif (preg_match('/(\$[0-9]+\#[0-9]+\.[0-9]+)/i', $output)) {
//returned output is formatted like $ID#STATUS
//E.g: $1234567#1.0
$output = explode('#', $output);
$status = $output[1];
if ($status == '0.0') {
return $this->lang['app']['101'];
} else {
return $this->lang['app']['100'];
}
//Unknown error
} else {
return $output;
}
}
|
[
"public",
"function",
"parseOutput",
"(",
"$",
"output",
")",
"{",
"//if error code is returned, api OR the app will return an integer error code",
"if",
"(",
"$",
"this",
"->",
"isnum",
"(",
"$",
"output",
")",
")",
"{",
"switch",
"(",
"$",
"output",
")",
"{",
"case",
"20",
":",
"return",
"$",
"this",
"->",
"lang",
"[",
"'reports'",
"]",
"[",
"'20'",
"]",
";",
"break",
";",
"case",
"21",
":",
"return",
"$",
"this",
"->",
"lang",
"[",
"'reports'",
"]",
"[",
"'21'",
"]",
";",
"break",
";",
"case",
"22",
":",
"return",
"$",
"this",
"->",
"lang",
"[",
"'reports'",
"]",
"[",
"'22'",
"]",
";",
"break",
";",
"case",
"23",
":",
"return",
"$",
"this",
"->",
"lang",
"[",
"'reports'",
"]",
"[",
"'23'",
"]",
";",
"break",
";",
"case",
"24",
":",
"return",
"$",
"this",
"->",
"lang",
"[",
"'reports'",
"]",
"[",
"'24'",
"]",
";",
"break",
";",
"case",
"25",
":",
"return",
"$",
"this",
"->",
"lang",
"[",
"'reports'",
"]",
"[",
"'25'",
"]",
";",
"break",
";",
"case",
"30",
":",
"return",
"$",
"this",
"->",
"lang",
"[",
"'reports'",
"]",
"[",
"'30'",
"]",
";",
"break",
";",
"//In-app messages:",
"case",
"100",
":",
"return",
"$",
"this",
"->",
"lang",
"[",
"'app'",
"]",
"[",
"0",
"]",
";",
"break",
";",
"case",
"101",
":",
"return",
"$",
"this",
"->",
"lang",
"[",
"'app'",
"]",
"[",
"1",
"]",
";",
"break",
";",
"case",
"102",
":",
"return",
"$",
"this",
"->",
"lang",
"[",
"'app'",
"]",
"[",
"2",
"]",
";",
"break",
";",
"default",
":",
"return",
"$",
"this",
"->",
"lang",
"[",
"'reports'",
"]",
"[",
"'999'",
"]",
";",
"break",
";",
"}",
"//returns from Mutlucell",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/(\\$[0-9]+\\#[0-9]+\\.[0-9]+)/i'",
",",
"$",
"output",
")",
")",
"{",
"//returned output is formatted like $ID#STATUS",
"//E.g: $1234567#1.0",
"$",
"output",
"=",
"explode",
"(",
"'#'",
",",
"$",
"output",
")",
";",
"$",
"status",
"=",
"$",
"output",
"[",
"1",
"]",
";",
"if",
"(",
"$",
"status",
"==",
"'0.0'",
")",
"{",
"return",
"$",
"this",
"->",
"lang",
"[",
"'app'",
"]",
"[",
"'101'",
"]",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"lang",
"[",
"'app'",
"]",
"[",
"'100'",
"]",
";",
"}",
"//Unknown error",
"}",
"else",
"{",
"return",
"$",
"output",
";",
"}",
"}"
] |
Parse the output
@param string $output API's response
@return string status code
|
[
"Parse",
"the",
"output"
] |
a6b5208b6cffe7c33b1fe9fb670e8e16a86b4b11
|
https://github.com/Ardakilic/laravel-mutlucell-sms/blob/a6b5208b6cffe7c33b1fe9fb670e8e16a86b4b11/src/Ardakilic/Mutlucell/Mutlucell.php#L286-L357
|
228,904
|
Ardakilic/laravel-mutlucell-sms
|
src/Ardakilic/Mutlucell/Mutlucell.php
|
Mutlucell.getStatus
|
public function getStatus($output)
{
//if error code is returned, API will return an integer error code
if ($this->isnum($output)) {
return false;
//returns from Mutlucell
} elseif (preg_match('/(\$[0-9]+\#[0-9]+\.[0-9]+)/i', $output)) {
//returned output is formatted like $ID#STATUS
//E.g: $1234567#1.0
$output = explode('#', $output);
$status = $output[1];
if ($status == '0.0') {
return false;
} else {
return true;
}
//Unknown error
} else {
return false;
}
}
|
php
|
public function getStatus($output)
{
//if error code is returned, API will return an integer error code
if ($this->isnum($output)) {
return false;
//returns from Mutlucell
} elseif (preg_match('/(\$[0-9]+\#[0-9]+\.[0-9]+)/i', $output)) {
//returned output is formatted like $ID#STATUS
//E.g: $1234567#1.0
$output = explode('#', $output);
$status = $output[1];
if ($status == '0.0') {
return false;
} else {
return true;
}
//Unknown error
} else {
return false;
}
}
|
[
"public",
"function",
"getStatus",
"(",
"$",
"output",
")",
"{",
"//if error code is returned, API will return an integer error code",
"if",
"(",
"$",
"this",
"->",
"isnum",
"(",
"$",
"output",
")",
")",
"{",
"return",
"false",
";",
"//returns from Mutlucell",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/(\\$[0-9]+\\#[0-9]+\\.[0-9]+)/i'",
",",
"$",
"output",
")",
")",
"{",
"//returned output is formatted like $ID#STATUS",
"//E.g: $1234567#1.0",
"$",
"output",
"=",
"explode",
"(",
"'#'",
",",
"$",
"output",
")",
";",
"$",
"status",
"=",
"$",
"output",
"[",
"1",
"]",
";",
"if",
"(",
"$",
"status",
"==",
"'0.0'",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"return",
"true",
";",
"}",
"//Unknown error",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Gets the SMS's status
@param string $output API's response
@return boolean
|
[
"Gets",
"the",
"SMS",
"s",
"status"
] |
a6b5208b6cffe7c33b1fe9fb670e8e16a86b4b11
|
https://github.com/Ardakilic/laravel-mutlucell-sms/blob/a6b5208b6cffe7c33b1fe9fb670e8e16a86b4b11/src/Ardakilic/Mutlucell/Mutlucell.php#L364-L388
|
228,905
|
Ardakilic/laravel-mutlucell-sms
|
src/Ardakilic/Mutlucell/Mutlucell.php
|
Mutlucell.preChecks
|
protected function preChecks($message, $senderID)
{
//TODO a better method for this
//Pre-checks act1
if ($senderID == null || !strlen(trim($senderID))) {
$this->senderID = $this->config['default_sender'];
} else {
$this->senderID = $senderID;
}
//Pre-checks act2
if ($message == null || !strlen(trim($message))) {
$this->message = '&'; //Error character for sms
} else {
$this->message = $message;
}
}
|
php
|
protected function preChecks($message, $senderID)
{
//TODO a better method for this
//Pre-checks act1
if ($senderID == null || !strlen(trim($senderID))) {
$this->senderID = $this->config['default_sender'];
} else {
$this->senderID = $senderID;
}
//Pre-checks act2
if ($message == null || !strlen(trim($message))) {
$this->message = '&'; //Error character for sms
} else {
$this->message = $message;
}
}
|
[
"protected",
"function",
"preChecks",
"(",
"$",
"message",
",",
"$",
"senderID",
")",
"{",
"//TODO a better method for this",
"//Pre-checks act1",
"if",
"(",
"$",
"senderID",
"==",
"null",
"||",
"!",
"strlen",
"(",
"trim",
"(",
"$",
"senderID",
")",
")",
")",
"{",
"$",
"this",
"->",
"senderID",
"=",
"$",
"this",
"->",
"config",
"[",
"'default_sender'",
"]",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"senderID",
"=",
"$",
"senderID",
";",
"}",
"//Pre-checks act2",
"if",
"(",
"$",
"message",
"==",
"null",
"||",
"!",
"strlen",
"(",
"trim",
"(",
"$",
"message",
")",
")",
")",
"{",
"$",
"this",
"->",
"message",
"=",
"'&'",
";",
"//Error character for sms",
"}",
"else",
"{",
"$",
"this",
"->",
"message",
"=",
"$",
"message",
";",
"}",
"}"
] |
Prechecks to prevent multiple usage
@param string $message message to be sent
@param string $senderID originator ID
|
[
"Prechecks",
"to",
"prevent",
"multiple",
"usage"
] |
a6b5208b6cffe7c33b1fe9fb670e8e16a86b4b11
|
https://github.com/Ardakilic/laravel-mutlucell-sms/blob/a6b5208b6cffe7c33b1fe9fb670e8e16a86b4b11/src/Ardakilic/Mutlucell/Mutlucell.php#L395-L411
|
228,906
|
rkeet/zf-doctrine-form
|
src/Form/AbstractForm.php
|
AbstractForm.addSubmitButton
|
public function addSubmitButton($value = 'Save', array $classes = null)
{
$this->add(
[
'name' => 'submit',
'type' => Submit::class,
'attributes' => [
'value' => $value,
'class' => (! is_null($classes) ? join(' ', $classes) : 'btn btn-primary'),
],
]
);
}
|
php
|
public function addSubmitButton($value = 'Save', array $classes = null)
{
$this->add(
[
'name' => 'submit',
'type' => Submit::class,
'attributes' => [
'value' => $value,
'class' => (! is_null($classes) ? join(' ', $classes) : 'btn btn-primary'),
],
]
);
}
|
[
"public",
"function",
"addSubmitButton",
"(",
"$",
"value",
"=",
"'Save'",
",",
"array",
"$",
"classes",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"add",
"(",
"[",
"'name'",
"=>",
"'submit'",
",",
"'type'",
"=>",
"Submit",
"::",
"class",
",",
"'attributes'",
"=>",
"[",
"'value'",
"=>",
"$",
"value",
",",
"'class'",
"=>",
"(",
"!",
"is_null",
"(",
"$",
"classes",
")",
"?",
"join",
"(",
"' '",
",",
"$",
"classes",
")",
":",
"'btn btn-primary'",
")",
",",
"]",
",",
"]",
")",
";",
"}"
] |
Used to add a submit button to the Form.
Overwrite default usage of this function by adding your own element with 'name' => 'submit' to your Form.
@param string $value
@param array|null $classes
|
[
"Used",
"to",
"add",
"a",
"submit",
"button",
"to",
"the",
"Form",
"."
] |
925e38ffca7c4729c2f87f46c7cb8cacbd6efdc0
|
https://github.com/rkeet/zf-doctrine-form/blob/925e38ffca7c4729c2f87f46c7cb8cacbd6efdc0/src/Form/AbstractForm.php#L90-L102
|
228,907
|
rkeet/zf-doctrine-form
|
src/Form/AbstractForm.php
|
AbstractForm.get
|
public function get($elementOrFieldset)
{
if ($elementOrFieldset === 'csrf') {
// Find CSRF element
foreach ($this->elements as $formElement) {
if ($formElement instanceof Csrf) {
return $formElement;
}
}
}
return parent::get($elementOrFieldset);
}
|
php
|
public function get($elementOrFieldset)
{
if ($elementOrFieldset === 'csrf') {
// Find CSRF element
foreach ($this->elements as $formElement) {
if ($formElement instanceof Csrf) {
return $formElement;
}
}
}
return parent::get($elementOrFieldset);
}
|
[
"public",
"function",
"get",
"(",
"$",
"elementOrFieldset",
")",
"{",
"if",
"(",
"$",
"elementOrFieldset",
"===",
"'csrf'",
")",
"{",
"// Find CSRF element",
"foreach",
"(",
"$",
"this",
"->",
"elements",
"as",
"$",
"formElement",
")",
"{",
"if",
"(",
"$",
"formElement",
"instanceof",
"Csrf",
")",
"{",
"return",
"$",
"formElement",
";",
"}",
"}",
"}",
"return",
"parent",
"::",
"get",
"(",
"$",
"elementOrFieldset",
")",
";",
"}"
] |
Retrieve a named element or fieldset
Extends Zend\Form with CSRF fields that can be retrieved by the name "CSRF"
but are resolved to their unique name
@param string $elementOrFieldset
@throws InvalidElementException
@return ElementInterface
|
[
"Retrieve",
"a",
"named",
"element",
"or",
"fieldset"
] |
925e38ffca7c4729c2f87f46c7cb8cacbd6efdc0
|
https://github.com/rkeet/zf-doctrine-form/blob/925e38ffca7c4729c2f87f46c7cb8cacbd6efdc0/src/Form/AbstractForm.php#L115-L127
|
228,908
|
slickframework/slick
|
src/Slick/Common/BaseMethods.php
|
BaseMethods._getter
|
protected function _getter($name)
{
// @codingStandardsIgnoreEnd
$normalized = lcfirst($name);
$property = "_{$normalized}";
if (property_exists($this, $property)) {
/** @var AnnotationsList $annotations */
$annotations = $this->inspector->getPropertyAnnotations($property);
if (
!$annotations->hasAnnotation('@readwrite') &&
!$annotations->hasAnnotation('@read')
) {
$className = get_class($this);
throw new Exception\WriteOnlyException(
"Trying to read the values of a write only property."
." {$className}::\${$property} has annotation @write."
);
}
return $this->$property;
}
return null;
}
|
php
|
protected function _getter($name)
{
// @codingStandardsIgnoreEnd
$normalized = lcfirst($name);
$property = "_{$normalized}";
if (property_exists($this, $property)) {
/** @var AnnotationsList $annotations */
$annotations = $this->inspector->getPropertyAnnotations($property);
if (
!$annotations->hasAnnotation('@readwrite') &&
!$annotations->hasAnnotation('@read')
) {
$className = get_class($this);
throw new Exception\WriteOnlyException(
"Trying to read the values of a write only property."
." {$className}::\${$property} has annotation @write."
);
}
return $this->$property;
}
return null;
}
|
[
"protected",
"function",
"_getter",
"(",
"$",
"name",
")",
"{",
"// @codingStandardsIgnoreEnd",
"$",
"normalized",
"=",
"lcfirst",
"(",
"$",
"name",
")",
";",
"$",
"property",
"=",
"\"_{$normalized}\"",
";",
"if",
"(",
"property_exists",
"(",
"$",
"this",
",",
"$",
"property",
")",
")",
"{",
"/** @var AnnotationsList $annotations */",
"$",
"annotations",
"=",
"$",
"this",
"->",
"inspector",
"->",
"getPropertyAnnotations",
"(",
"$",
"property",
")",
";",
"if",
"(",
"!",
"$",
"annotations",
"->",
"hasAnnotation",
"(",
"'@readwrite'",
")",
"&&",
"!",
"$",
"annotations",
"->",
"hasAnnotation",
"(",
"'@read'",
")",
")",
"{",
"$",
"className",
"=",
"get_class",
"(",
"$",
"this",
")",
";",
"throw",
"new",
"Exception",
"\\",
"WriteOnlyException",
"(",
"\"Trying to read the values of a write only property.\"",
".",
"\" {$className}::\\${$property} has annotation @write.\"",
")",
";",
"}",
"return",
"$",
"this",
"->",
"$",
"property",
";",
"}",
"return",
"null",
";",
"}"
] |
Retrieves the value a property with the given name.
@param string $name The property name to get the value.
@return mixed The property value.
@throws Exception\WriteOnlyException If the property being accessed
has the annotation @write
|
[
"Retrieves",
"the",
"value",
"a",
"property",
"with",
"the",
"given",
"name",
"."
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Common/BaseMethods.php#L137-L159
|
228,909
|
slickframework/slick
|
src/Slick/Common/BaseMethods.php
|
BaseMethods._is
|
protected function _is($name)
{
// @codingStandardsIgnoreEnd
$normalized = lcfirst($name);
$property = "_{$normalized}";
if (property_exists($this, $property)) {
/** @var AnnotationsList $annotations */
$annotations = $this->inspector->getPropertyAnnotations($property);
if (
!$annotations->hasAnnotation('@readwrite') &&
!$annotations->hasAnnotation('@read')
) {
$className = get_class($this);
throw new Exception\WriteOnlyException(
"Trying to read the values of a write only property."
." {$className}::\${$property} has annotation @write."
);
}
return (boolean) $this->$property;
}
return false;
}
|
php
|
protected function _is($name)
{
// @codingStandardsIgnoreEnd
$normalized = lcfirst($name);
$property = "_{$normalized}";
if (property_exists($this, $property)) {
/** @var AnnotationsList $annotations */
$annotations = $this->inspector->getPropertyAnnotations($property);
if (
!$annotations->hasAnnotation('@readwrite') &&
!$annotations->hasAnnotation('@read')
) {
$className = get_class($this);
throw new Exception\WriteOnlyException(
"Trying to read the values of a write only property."
." {$className}::\${$property} has annotation @write."
);
}
return (boolean) $this->$property;
}
return false;
}
|
[
"protected",
"function",
"_is",
"(",
"$",
"name",
")",
"{",
"// @codingStandardsIgnoreEnd",
"$",
"normalized",
"=",
"lcfirst",
"(",
"$",
"name",
")",
";",
"$",
"property",
"=",
"\"_{$normalized}\"",
";",
"if",
"(",
"property_exists",
"(",
"$",
"this",
",",
"$",
"property",
")",
")",
"{",
"/** @var AnnotationsList $annotations */",
"$",
"annotations",
"=",
"$",
"this",
"->",
"inspector",
"->",
"getPropertyAnnotations",
"(",
"$",
"property",
")",
";",
"if",
"(",
"!",
"$",
"annotations",
"->",
"hasAnnotation",
"(",
"'@readwrite'",
")",
"&&",
"!",
"$",
"annotations",
"->",
"hasAnnotation",
"(",
"'@read'",
")",
")",
"{",
"$",
"className",
"=",
"get_class",
"(",
"$",
"this",
")",
";",
"throw",
"new",
"Exception",
"\\",
"WriteOnlyException",
"(",
"\"Trying to read the values of a write only property.\"",
".",
"\" {$className}::\\${$property} has annotation @write.\"",
")",
";",
"}",
"return",
"(",
"boolean",
")",
"$",
"this",
"->",
"$",
"property",
";",
"}",
"return",
"false",
";",
"}"
] |
Retrieves the boolean value a property with the given name.
@param string $name The property name to get the value.
@return boolean The boolean value of the requested property.
@throws Exception\WriteOnlyException If property being accessed has
the annotation @write
|
[
"Retrieves",
"the",
"boolean",
"value",
"a",
"property",
"with",
"the",
"given",
"name",
"."
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Common/BaseMethods.php#L218-L242
|
228,910
|
slickframework/slick
|
src/Slick/Common/BaseMethods.php
|
BaseMethods.__isset
|
public function __isset($name)
{
$normalized = lcfirst($name);
$property = "_{$normalized}";
if (property_exists($this, $property)) {
return true;
}
return false;
}
|
php
|
public function __isset($name)
{
$normalized = lcfirst($name);
$property = "_{$normalized}";
if (property_exists($this, $property)) {
return true;
}
return false;
}
|
[
"public",
"function",
"__isset",
"(",
"$",
"name",
")",
"{",
"$",
"normalized",
"=",
"lcfirst",
"(",
"$",
"name",
")",
";",
"$",
"property",
"=",
"\"_{$normalized}\"",
";",
"if",
"(",
"property_exists",
"(",
"$",
"this",
",",
"$",
"property",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Checks if a given property name exists and can be accessed
@param string $name The property name
@return bool True if a property with the provided name exists,
false otherwise
|
[
"Checks",
"if",
"a",
"given",
"property",
"name",
"exists",
"and",
"can",
"be",
"accessed"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Common/BaseMethods.php#L293-L301
|
228,911
|
cornernote/yii-audit-module
|
audit/commands/AuditErrorEmailCommand.php
|
AuditErrorEmailCommand.actionIndex
|
public function actionIndex()
{
/** @var AuditModule $audit */
$audit = Yii::app()->getModule('audit');
$data = $audit->getDbConnection()->createCommand("SELECT id FROM " . AuditError::model()->tableName() . " WHERE status=:new_status")->query(array(
':new_status' => 'new',
));
while ($data && ($row = $data->read()) !== false) {
$auditError = AuditError::model()->findByPk($row['id']);
$message = Yii::t('app', '<b>:message</b><br />in <i>:file</i> on line <i>:line</i>.<br/>:link.', array(
':message' => $auditError->message,
':file' => $auditError->file,
':line' => $auditError->line,
':link' => CHtml::link(Yii::t('audit', 'view'), Yii::app()->createAbsoluteUrl('audit/error/view', array('id' => $auditError->id), $this->secureUrl ? 'https' : 'http')),
));
Yii::app()->emailManager->email($this->email, $auditError->type . ' (' . $auditError->hash . ')', $message);
$auditError->status = 'emailed';
$auditError->save(false, array('status'));
}
}
|
php
|
public function actionIndex()
{
/** @var AuditModule $audit */
$audit = Yii::app()->getModule('audit');
$data = $audit->getDbConnection()->createCommand("SELECT id FROM " . AuditError::model()->tableName() . " WHERE status=:new_status")->query(array(
':new_status' => 'new',
));
while ($data && ($row = $data->read()) !== false) {
$auditError = AuditError::model()->findByPk($row['id']);
$message = Yii::t('app', '<b>:message</b><br />in <i>:file</i> on line <i>:line</i>.<br/>:link.', array(
':message' => $auditError->message,
':file' => $auditError->file,
':line' => $auditError->line,
':link' => CHtml::link(Yii::t('audit', 'view'), Yii::app()->createAbsoluteUrl('audit/error/view', array('id' => $auditError->id), $this->secureUrl ? 'https' : 'http')),
));
Yii::app()->emailManager->email($this->email, $auditError->type . ' (' . $auditError->hash . ')', $message);
$auditError->status = 'emailed';
$auditError->save(false, array('status'));
}
}
|
[
"public",
"function",
"actionIndex",
"(",
")",
"{",
"/** @var AuditModule $audit */",
"$",
"audit",
"=",
"Yii",
"::",
"app",
"(",
")",
"->",
"getModule",
"(",
"'audit'",
")",
";",
"$",
"data",
"=",
"$",
"audit",
"->",
"getDbConnection",
"(",
")",
"->",
"createCommand",
"(",
"\"SELECT id FROM \"",
".",
"AuditError",
"::",
"model",
"(",
")",
"->",
"tableName",
"(",
")",
".",
"\" WHERE status=:new_status\"",
")",
"->",
"query",
"(",
"array",
"(",
"':new_status'",
"=>",
"'new'",
",",
")",
")",
";",
"while",
"(",
"$",
"data",
"&&",
"(",
"$",
"row",
"=",
"$",
"data",
"->",
"read",
"(",
")",
")",
"!==",
"false",
")",
"{",
"$",
"auditError",
"=",
"AuditError",
"::",
"model",
"(",
")",
"->",
"findByPk",
"(",
"$",
"row",
"[",
"'id'",
"]",
")",
";",
"$",
"message",
"=",
"Yii",
"::",
"t",
"(",
"'app'",
",",
"'<b>:message</b><br />in <i>:file</i> on line <i>:line</i>.<br/>:link.'",
",",
"array",
"(",
"':message'",
"=>",
"$",
"auditError",
"->",
"message",
",",
"':file'",
"=>",
"$",
"auditError",
"->",
"file",
",",
"':line'",
"=>",
"$",
"auditError",
"->",
"line",
",",
"':link'",
"=>",
"CHtml",
"::",
"link",
"(",
"Yii",
"::",
"t",
"(",
"'audit'",
",",
"'view'",
")",
",",
"Yii",
"::",
"app",
"(",
")",
"->",
"createAbsoluteUrl",
"(",
"'audit/error/view'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"auditError",
"->",
"id",
")",
",",
"$",
"this",
"->",
"secureUrl",
"?",
"'https'",
":",
"'http'",
")",
")",
",",
")",
")",
";",
"Yii",
"::",
"app",
"(",
")",
"->",
"emailManager",
"->",
"email",
"(",
"$",
"this",
"->",
"email",
",",
"$",
"auditError",
"->",
"type",
".",
"' ('",
".",
"$",
"auditError",
"->",
"hash",
".",
"')'",
",",
"$",
"message",
")",
";",
"$",
"auditError",
"->",
"status",
"=",
"'emailed'",
";",
"$",
"auditError",
"->",
"save",
"(",
"false",
",",
"array",
"(",
"'status'",
")",
")",
";",
"}",
"}"
] |
Send error emails.
Requires yii-email-module
|
[
"Send",
"error",
"emails",
".",
"Requires",
"yii",
"-",
"email",
"-",
"module"
] |
07362f79741b5343d22bb9bb516d840072a097d4
|
https://github.com/cornernote/yii-audit-module/blob/07362f79741b5343d22bb9bb516d840072a097d4/audit/commands/AuditErrorEmailCommand.php#L31-L50
|
228,912
|
lekoala/silverstripe-form-extras
|
code/FormExtraMulti.php
|
FormExtraMulti.classForCurrentStep
|
public static function classForCurrentStep()
{
$step = self::getCurrentStep();
if (!$step) {
$step = 1;
}
if (Controller::has_curr()) {
$requestStep = Controller::curr()->getRequest()->getVar('step');
if ($requestStep) {
$step = $requestStep;
}
}
return str_replace(self::classNameNumber(), $step, get_called_class());
}
|
php
|
public static function classForCurrentStep()
{
$step = self::getCurrentStep();
if (!$step) {
$step = 1;
}
if (Controller::has_curr()) {
$requestStep = Controller::curr()->getRequest()->getVar('step');
if ($requestStep) {
$step = $requestStep;
}
}
return str_replace(self::classNameNumber(), $step, get_called_class());
}
|
[
"public",
"static",
"function",
"classForCurrentStep",
"(",
")",
"{",
"$",
"step",
"=",
"self",
"::",
"getCurrentStep",
"(",
")",
";",
"if",
"(",
"!",
"$",
"step",
")",
"{",
"$",
"step",
"=",
"1",
";",
"}",
"if",
"(",
"Controller",
"::",
"has_curr",
"(",
")",
")",
"{",
"$",
"requestStep",
"=",
"Controller",
"::",
"curr",
"(",
")",
"->",
"getRequest",
"(",
")",
"->",
"getVar",
"(",
"'step'",
")",
";",
"if",
"(",
"$",
"requestStep",
")",
"{",
"$",
"step",
"=",
"$",
"requestStep",
";",
"}",
"}",
"return",
"str_replace",
"(",
"self",
"::",
"classNameNumber",
"(",
")",
",",
"$",
"step",
",",
"get_called_class",
"(",
")",
")",
";",
"}"
] |
Get class name for current step based on this class name
@return string
|
[
"Get",
"class",
"name",
"for",
"current",
"step",
"based",
"on",
"this",
"class",
"name"
] |
e0c1200792af8e6cea916e1999c73cf8408c6dd2
|
https://github.com/lekoala/silverstripe-form-extras/blob/e0c1200792af8e6cea916e1999c73cf8408c6dd2/code/FormExtraMulti.php#L47-L60
|
228,913
|
lekoala/silverstripe-form-extras
|
code/FormExtraMulti.php
|
FormExtraMulti.AllSteps
|
public function AllSteps()
{
$num = self::classNameNumber();
if (!$num) {
return;
}
$n = 1;
$curr = self::getCurrentStep();
if (!$curr) {
$curr = 1;
}
if (!Controller::has_curr()) {
return;
}
$c = Controller::curr();
$class = str_replace($num, $n, get_called_class());
$steps = new ArrayList();
$baseAction = parent::FormAction();
while (class_exists($class)) {
$isCurrent = $isCompleted = false;
$cssClass = $n == $curr ? 'current' : 'link';
if ($n == 1) {
$isCurrent = true;
$cssClass .= ' first';
}
if ($class::isLastStep()) {
$cssClass .= ' last';
}
if ($n < $curr) {
$isCompleted = true;
$cssClass .= ' completed';
}
$link = $baseAction . '/gotoStep/?step=' . $n;
$steps->push(new ArrayData(array(
'Title' => $class::getStepTitle(),
'Number' => $n,
'Link' => $link,
'Class' => $cssClass,
'IsCurrent' => $isCurrent,
'IsCompleted' => $isCompleted,
)));
$n++;
$class = str_replace(self::classNameNumber(), $n, get_called_class());
}
return $steps;
}
|
php
|
public function AllSteps()
{
$num = self::classNameNumber();
if (!$num) {
return;
}
$n = 1;
$curr = self::getCurrentStep();
if (!$curr) {
$curr = 1;
}
if (!Controller::has_curr()) {
return;
}
$c = Controller::curr();
$class = str_replace($num, $n, get_called_class());
$steps = new ArrayList();
$baseAction = parent::FormAction();
while (class_exists($class)) {
$isCurrent = $isCompleted = false;
$cssClass = $n == $curr ? 'current' : 'link';
if ($n == 1) {
$isCurrent = true;
$cssClass .= ' first';
}
if ($class::isLastStep()) {
$cssClass .= ' last';
}
if ($n < $curr) {
$isCompleted = true;
$cssClass .= ' completed';
}
$link = $baseAction . '/gotoStep/?step=' . $n;
$steps->push(new ArrayData(array(
'Title' => $class::getStepTitle(),
'Number' => $n,
'Link' => $link,
'Class' => $cssClass,
'IsCurrent' => $isCurrent,
'IsCompleted' => $isCompleted,
)));
$n++;
$class = str_replace(self::classNameNumber(), $n, get_called_class());
}
return $steps;
}
|
[
"public",
"function",
"AllSteps",
"(",
")",
"{",
"$",
"num",
"=",
"self",
"::",
"classNameNumber",
"(",
")",
";",
"if",
"(",
"!",
"$",
"num",
")",
"{",
"return",
";",
"}",
"$",
"n",
"=",
"1",
";",
"$",
"curr",
"=",
"self",
"::",
"getCurrentStep",
"(",
")",
";",
"if",
"(",
"!",
"$",
"curr",
")",
"{",
"$",
"curr",
"=",
"1",
";",
"}",
"if",
"(",
"!",
"Controller",
"::",
"has_curr",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"c",
"=",
"Controller",
"::",
"curr",
"(",
")",
";",
"$",
"class",
"=",
"str_replace",
"(",
"$",
"num",
",",
"$",
"n",
",",
"get_called_class",
"(",
")",
")",
";",
"$",
"steps",
"=",
"new",
"ArrayList",
"(",
")",
";",
"$",
"baseAction",
"=",
"parent",
"::",
"FormAction",
"(",
")",
";",
"while",
"(",
"class_exists",
"(",
"$",
"class",
")",
")",
"{",
"$",
"isCurrent",
"=",
"$",
"isCompleted",
"=",
"false",
";",
"$",
"cssClass",
"=",
"$",
"n",
"==",
"$",
"curr",
"?",
"'current'",
":",
"'link'",
";",
"if",
"(",
"$",
"n",
"==",
"1",
")",
"{",
"$",
"isCurrent",
"=",
"true",
";",
"$",
"cssClass",
".=",
"' first'",
";",
"}",
"if",
"(",
"$",
"class",
"::",
"isLastStep",
"(",
")",
")",
"{",
"$",
"cssClass",
".=",
"' last'",
";",
"}",
"if",
"(",
"$",
"n",
"<",
"$",
"curr",
")",
"{",
"$",
"isCompleted",
"=",
"true",
";",
"$",
"cssClass",
".=",
"' completed'",
";",
"}",
"$",
"link",
"=",
"$",
"baseAction",
".",
"'/gotoStep/?step='",
".",
"$",
"n",
";",
"$",
"steps",
"->",
"push",
"(",
"new",
"ArrayData",
"(",
"array",
"(",
"'Title'",
"=>",
"$",
"class",
"::",
"getStepTitle",
"(",
")",
",",
"'Number'",
"=>",
"$",
"n",
",",
"'Link'",
"=>",
"$",
"link",
",",
"'Class'",
"=>",
"$",
"cssClass",
",",
"'IsCurrent'",
"=>",
"$",
"isCurrent",
",",
"'IsCompleted'",
"=>",
"$",
"isCompleted",
",",
")",
")",
")",
";",
"$",
"n",
"++",
";",
"$",
"class",
"=",
"str_replace",
"(",
"self",
"::",
"classNameNumber",
"(",
")",
",",
"$",
"n",
",",
"get_called_class",
"(",
")",
")",
";",
"}",
"return",
"$",
"steps",
";",
"}"
] |
Get all steps as an ArrayList. To be used for your templates.
@return ArrayList
|
[
"Get",
"all",
"steps",
"as",
"an",
"ArrayList",
".",
"To",
"be",
"used",
"for",
"your",
"templates",
"."
] |
e0c1200792af8e6cea916e1999c73cf8408c6dd2
|
https://github.com/lekoala/silverstripe-form-extras/blob/e0c1200792af8e6cea916e1999c73cf8408c6dd2/code/FormExtraMulti.php#L66-L113
|
228,914
|
lekoala/silverstripe-form-extras
|
code/FormExtraMulti.php
|
FormExtraMulti.setMaxStep
|
public static function setMaxStep($value)
{
Session::set(self::classNameWithoutNumber() . '.maxStep', (int) $value);
return Session::save();
}
|
php
|
public static function setMaxStep($value)
{
Session::set(self::classNameWithoutNumber() . '.maxStep', (int) $value);
return Session::save();
}
|
[
"public",
"static",
"function",
"setMaxStep",
"(",
"$",
"value",
")",
"{",
"Session",
"::",
"set",
"(",
"self",
"::",
"classNameWithoutNumber",
"(",
")",
".",
"'.maxStep'",
",",
"(",
"int",
")",
"$",
"value",
")",
";",
"return",
"Session",
"::",
"save",
"(",
")",
";",
"}"
] |
Set max step
@param int $value
@return string
|
[
"Set",
"max",
"step"
] |
e0c1200792af8e6cea916e1999c73cf8408c6dd2
|
https://github.com/lekoala/silverstripe-form-extras/blob/e0c1200792af8e6cea916e1999c73cf8408c6dd2/code/FormExtraMulti.php#L138-L142
|
228,915
|
lekoala/silverstripe-form-extras
|
code/FormExtraMulti.php
|
FormExtraMulti.setCurrentStep
|
public static function setCurrentStep($value)
{
$value = (int) $value;
if ($value > self::getMaxStep()) {
self::setMaxStep($value);
}
Session::set(self::classNameWithoutNumber() . '.step', $value);
return Session::save();
}
|
php
|
public static function setCurrentStep($value)
{
$value = (int) $value;
if ($value > self::getMaxStep()) {
self::setMaxStep($value);
}
Session::set(self::classNameWithoutNumber() . '.step', $value);
return Session::save();
}
|
[
"public",
"static",
"function",
"setCurrentStep",
"(",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"(",
"int",
")",
"$",
"value",
";",
"if",
"(",
"$",
"value",
">",
"self",
"::",
"getMaxStep",
"(",
")",
")",
"{",
"self",
"::",
"setMaxStep",
"(",
"$",
"value",
")",
";",
"}",
"Session",
"::",
"set",
"(",
"self",
"::",
"classNameWithoutNumber",
"(",
")",
".",
"'.step'",
",",
"$",
"value",
")",
";",
"return",
"Session",
"::",
"save",
"(",
")",
";",
"}"
] |
Set current step
@param int $value
@return string
|
[
"Set",
"current",
"step"
] |
e0c1200792af8e6cea916e1999c73cf8408c6dd2
|
https://github.com/lekoala/silverstripe-form-extras/blob/e0c1200792af8e6cea916e1999c73cf8408c6dd2/code/FormExtraMulti.php#L158-L166
|
228,916
|
lekoala/silverstripe-form-extras
|
code/FormExtraMulti.php
|
FormExtraMulti.isLastStep
|
public static function isLastStep()
{
$n = self::classNameNumber();
$n1 = $n + 1;
$class = str_replace($n, $n1, get_called_class());
return !class_exists($class);
}
|
php
|
public static function isLastStep()
{
$n = self::classNameNumber();
$n1 = $n + 1;
$class = str_replace($n, $n1, get_called_class());
return !class_exists($class);
}
|
[
"public",
"static",
"function",
"isLastStep",
"(",
")",
"{",
"$",
"n",
"=",
"self",
"::",
"classNameNumber",
"(",
")",
";",
"$",
"n1",
"=",
"$",
"n",
"+",
"1",
";",
"$",
"class",
"=",
"str_replace",
"(",
"$",
"n",
",",
"$",
"n1",
",",
"get_called_class",
"(",
")",
")",
";",
"return",
"!",
"class_exists",
"(",
"$",
"class",
")",
";",
"}"
] |
Check if this is the last step
@return bool
|
[
"Check",
"if",
"this",
"is",
"the",
"last",
"step"
] |
e0c1200792af8e6cea916e1999c73cf8408c6dd2
|
https://github.com/lekoala/silverstripe-form-extras/blob/e0c1200792af8e6cea916e1999c73cf8408c6dd2/code/FormExtraMulti.php#L188-L194
|
228,917
|
lekoala/silverstripe-form-extras
|
code/FormExtraMulti.php
|
FormExtraMulti.gotoStep
|
public function gotoStep()
{
$step = $this->Controller()->getRequest()->getVar('step');
if ($step > 0 && $step <= self::getMaxStep()) {
self::setCurrentStep($step);
}
return $this->Controller()->redirectBack();
}
|
php
|
public function gotoStep()
{
$step = $this->Controller()->getRequest()->getVar('step');
if ($step > 0 && $step <= self::getMaxStep()) {
self::setCurrentStep($step);
}
return $this->Controller()->redirectBack();
}
|
[
"public",
"function",
"gotoStep",
"(",
")",
"{",
"$",
"step",
"=",
"$",
"this",
"->",
"Controller",
"(",
")",
"->",
"getRequest",
"(",
")",
"->",
"getVar",
"(",
"'step'",
")",
";",
"if",
"(",
"$",
"step",
">",
"0",
"&&",
"$",
"step",
"<=",
"self",
"::",
"getMaxStep",
"(",
")",
")",
"{",
"self",
"::",
"setCurrentStep",
"(",
"$",
"step",
")",
";",
"}",
"return",
"$",
"this",
"->",
"Controller",
"(",
")",
"->",
"redirectBack",
"(",
")",
";",
"}"
] |
Goto a step
@return SS_HTTPResponse
|
[
"Goto",
"a",
"step"
] |
e0c1200792af8e6cea916e1999c73cf8408c6dd2
|
https://github.com/lekoala/silverstripe-form-extras/blob/e0c1200792af8e6cea916e1999c73cf8408c6dd2/code/FormExtraMulti.php#L231-L238
|
228,918
|
lekoala/silverstripe-form-extras
|
code/FormExtraMulti.php
|
FormExtraMulti.definePrevNextActions
|
protected function definePrevNextActions($doSet = false)
{
$actions = new FieldList();
$prevClass = 'FormAction';
// do not validate if used in conjonction with zenvalidator
if (class_exists('FormActionNoValidation')) {
$prevClass = 'FormActionNoValidation';
}
$prev = null;
if (self::classNameNumber() > 1) {
$prev = new $prevClass('doPrev', _t('FormExtra.doPrev', 'Previous'));
$prev->addExtraClass('step-prev');
$prev->setUseButtonTag(true);
}
$label = _t('FormExtra.doNext', 'Next');
$actions->push($next = new FormAction('doNext', $label));
$next->setUseButtonTag(true);
$next->addExtraClass('step-next');
if (!$prev) {
$next->addExtraClass('step-next-single');
}
if (self::isLastStep()) {
$next->setTitle(_t('FormExtra.doFinish', 'Finish'));
$next->addExtraClass('step-last');
}
if ($prev) {
$actions->push($prev);
}
$this->addExtraClass('form-steps');
if (!$doSet) {
$this->setActions($actions);
$actions->setForm($this);
}
return $actions;
}
|
php
|
protected function definePrevNextActions($doSet = false)
{
$actions = new FieldList();
$prevClass = 'FormAction';
// do not validate if used in conjonction with zenvalidator
if (class_exists('FormActionNoValidation')) {
$prevClass = 'FormActionNoValidation';
}
$prev = null;
if (self::classNameNumber() > 1) {
$prev = new $prevClass('doPrev', _t('FormExtra.doPrev', 'Previous'));
$prev->addExtraClass('step-prev');
$prev->setUseButtonTag(true);
}
$label = _t('FormExtra.doNext', 'Next');
$actions->push($next = new FormAction('doNext', $label));
$next->setUseButtonTag(true);
$next->addExtraClass('step-next');
if (!$prev) {
$next->addExtraClass('step-next-single');
}
if (self::isLastStep()) {
$next->setTitle(_t('FormExtra.doFinish', 'Finish'));
$next->addExtraClass('step-last');
}
if ($prev) {
$actions->push($prev);
}
$this->addExtraClass('form-steps');
if (!$doSet) {
$this->setActions($actions);
$actions->setForm($this);
}
return $actions;
}
|
[
"protected",
"function",
"definePrevNextActions",
"(",
"$",
"doSet",
"=",
"false",
")",
"{",
"$",
"actions",
"=",
"new",
"FieldList",
"(",
")",
";",
"$",
"prevClass",
"=",
"'FormAction'",
";",
"// do not validate if used in conjonction with zenvalidator",
"if",
"(",
"class_exists",
"(",
"'FormActionNoValidation'",
")",
")",
"{",
"$",
"prevClass",
"=",
"'FormActionNoValidation'",
";",
"}",
"$",
"prev",
"=",
"null",
";",
"if",
"(",
"self",
"::",
"classNameNumber",
"(",
")",
">",
"1",
")",
"{",
"$",
"prev",
"=",
"new",
"$",
"prevClass",
"(",
"'doPrev'",
",",
"_t",
"(",
"'FormExtra.doPrev'",
",",
"'Previous'",
")",
")",
";",
"$",
"prev",
"->",
"addExtraClass",
"(",
"'step-prev'",
")",
";",
"$",
"prev",
"->",
"setUseButtonTag",
"(",
"true",
")",
";",
"}",
"$",
"label",
"=",
"_t",
"(",
"'FormExtra.doNext'",
",",
"'Next'",
")",
";",
"$",
"actions",
"->",
"push",
"(",
"$",
"next",
"=",
"new",
"FormAction",
"(",
"'doNext'",
",",
"$",
"label",
")",
")",
";",
"$",
"next",
"->",
"setUseButtonTag",
"(",
"true",
")",
";",
"$",
"next",
"->",
"addExtraClass",
"(",
"'step-next'",
")",
";",
"if",
"(",
"!",
"$",
"prev",
")",
"{",
"$",
"next",
"->",
"addExtraClass",
"(",
"'step-next-single'",
")",
";",
"}",
"if",
"(",
"self",
"::",
"isLastStep",
"(",
")",
")",
"{",
"$",
"next",
"->",
"setTitle",
"(",
"_t",
"(",
"'FormExtra.doFinish'",
",",
"'Finish'",
")",
")",
";",
"$",
"next",
"->",
"addExtraClass",
"(",
"'step-last'",
")",
";",
"}",
"if",
"(",
"$",
"prev",
")",
"{",
"$",
"actions",
"->",
"push",
"(",
"$",
"prev",
")",
";",
"}",
"$",
"this",
"->",
"addExtraClass",
"(",
"'form-steps'",
")",
";",
"if",
"(",
"!",
"$",
"doSet",
")",
"{",
"$",
"this",
"->",
"setActions",
"(",
"$",
"actions",
")",
";",
"$",
"actions",
"->",
"setForm",
"(",
"$",
"this",
")",
";",
"}",
"return",
"$",
"actions",
";",
"}"
] |
Call this instead of manually creating your actions
You can easily rename actions by calling $actions->fieldByName('action_doNext')->setTitle('...')
@param bool $doSet
@return FieldList
|
[
"Call",
"this",
"instead",
"of",
"manually",
"creating",
"your",
"actions"
] |
e0c1200792af8e6cea916e1999c73cf8408c6dd2
|
https://github.com/lekoala/silverstripe-form-extras/blob/e0c1200792af8e6cea916e1999c73cf8408c6dd2/code/FormExtraMulti.php#L284-L326
|
228,919
|
lekoala/silverstripe-form-extras
|
code/FormExtraMulti.php
|
FormExtraMulti.definePrevNextSaveActions
|
protected function definePrevNextSaveActions($doSet = false)
{
$actions = $this->definePrevNextActions($doSet);
$cls = 'FormAction';
// do not validate if used in conjonction with zenvalidator
if (class_exists('FormActionNoValidation')) {
$cls = 'FormActionNoValidation';
}
$save = new $cls('doSave', _t('FormExtra.doSave', 'Save'));
$save->addExtraClass('step-save');
$actions->push($save);
// remove single class
$next = $actions->fieldByName('action_doNext');
if ($next) {
$next->removeExtraClass('step-next-single');
}
if (!$doSet) {
$this->setActions($actions);
$actions->setForm($this);
}
return $actions;
}
|
php
|
protected function definePrevNextSaveActions($doSet = false)
{
$actions = $this->definePrevNextActions($doSet);
$cls = 'FormAction';
// do not validate if used in conjonction with zenvalidator
if (class_exists('FormActionNoValidation')) {
$cls = 'FormActionNoValidation';
}
$save = new $cls('doSave', _t('FormExtra.doSave', 'Save'));
$save->addExtraClass('step-save');
$actions->push($save);
// remove single class
$next = $actions->fieldByName('action_doNext');
if ($next) {
$next->removeExtraClass('step-next-single');
}
if (!$doSet) {
$this->setActions($actions);
$actions->setForm($this);
}
return $actions;
}
|
[
"protected",
"function",
"definePrevNextSaveActions",
"(",
"$",
"doSet",
"=",
"false",
")",
"{",
"$",
"actions",
"=",
"$",
"this",
"->",
"definePrevNextActions",
"(",
"$",
"doSet",
")",
";",
"$",
"cls",
"=",
"'FormAction'",
";",
"// do not validate if used in conjonction with zenvalidator",
"if",
"(",
"class_exists",
"(",
"'FormActionNoValidation'",
")",
")",
"{",
"$",
"cls",
"=",
"'FormActionNoValidation'",
";",
"}",
"$",
"save",
"=",
"new",
"$",
"cls",
"(",
"'doSave'",
",",
"_t",
"(",
"'FormExtra.doSave'",
",",
"'Save'",
")",
")",
";",
"$",
"save",
"->",
"addExtraClass",
"(",
"'step-save'",
")",
";",
"$",
"actions",
"->",
"push",
"(",
"$",
"save",
")",
";",
"// remove single class",
"$",
"next",
"=",
"$",
"actions",
"->",
"fieldByName",
"(",
"'action_doNext'",
")",
";",
"if",
"(",
"$",
"next",
")",
"{",
"$",
"next",
"->",
"removeExtraClass",
"(",
"'step-next-single'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"doSet",
")",
"{",
"$",
"this",
"->",
"setActions",
"(",
"$",
"actions",
")",
";",
"$",
"actions",
"->",
"setForm",
"(",
"$",
"this",
")",
";",
"}",
"return",
"$",
"actions",
";",
"}"
] |
Same as definePrevNext + a save button
@param bool $doSet
@return FieldList
|
[
"Same",
"as",
"definePrevNext",
"+",
"a",
"save",
"button"
] |
e0c1200792af8e6cea916e1999c73cf8408c6dd2
|
https://github.com/lekoala/silverstripe-form-extras/blob/e0c1200792af8e6cea916e1999c73cf8408c6dd2/code/FormExtraMulti.php#L334-L360
|
228,920
|
jacobstr/matura
|
lib/Core/InvocationContext.php
|
InvocationContext.getAndAssertActiveBlock
|
public static function getAndAssertActiveBlock($type)
{
$active_block = static::getActive();
$current = get_class($active_block->activeBlock());
if ( !is_a($active_block->activeBlock(), $type)) {
throw new Exception("Improperly nested block. Expected a $type, got a $current");
}
return $active_block;
}
|
php
|
public static function getAndAssertActiveBlock($type)
{
$active_block = static::getActive();
$current = get_class($active_block->activeBlock());
if ( !is_a($active_block->activeBlock(), $type)) {
throw new Exception("Improperly nested block. Expected a $type, got a $current");
}
return $active_block;
}
|
[
"public",
"static",
"function",
"getAndAssertActiveBlock",
"(",
"$",
"type",
")",
"{",
"$",
"active_block",
"=",
"static",
"::",
"getActive",
"(",
")",
";",
"$",
"current",
"=",
"get_class",
"(",
"$",
"active_block",
"->",
"activeBlock",
"(",
")",
")",
";",
"if",
"(",
"!",
"is_a",
"(",
"$",
"active_block",
"->",
"activeBlock",
"(",
")",
",",
"$",
"type",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Improperly nested block. Expected a $type, got a $current\"",
")",
";",
"}",
"return",
"$",
"active_block",
";",
"}"
] |
Obtains the current active block and asserts that it is a given type. Used
to enforce block nested rules for the DSL.
|
[
"Obtains",
"the",
"current",
"active",
"block",
"and",
"asserts",
"that",
"it",
"is",
"a",
"given",
"type",
".",
"Used",
"to",
"enforce",
"block",
"nested",
"rules",
"for",
"the",
"DSL",
"."
] |
393e0f3676f502454cc6823cac8ce9cef2ea7bff
|
https://github.com/jacobstr/matura/blob/393e0f3676f502454cc6823cac8ce9cef2ea7bff/lib/Core/InvocationContext.php#L111-L119
|
228,921
|
laravelcity/laravel-categories
|
src/Models/HtmlMethods.php
|
HtmlMethods.getRootCategories
|
public function getRootCategories ()
{
return self::where('parent' , 0)
->where('slug' , '<>' , config('Categories::category.default_category.slug'))
->orderby('id' , 'desc')
->where('model_type' , $this->modelType)
->get();
}
|
php
|
public function getRootCategories ()
{
return self::where('parent' , 0)
->where('slug' , '<>' , config('Categories::category.default_category.slug'))
->orderby('id' , 'desc')
->where('model_type' , $this->modelType)
->get();
}
|
[
"public",
"function",
"getRootCategories",
"(",
")",
"{",
"return",
"self",
"::",
"where",
"(",
"'parent'",
",",
"0",
")",
"->",
"where",
"(",
"'slug'",
",",
"'<>'",
",",
"config",
"(",
"'Categories::category.default_category.slug'",
")",
")",
"->",
"orderby",
"(",
"'id'",
",",
"'desc'",
")",
"->",
"where",
"(",
"'model_type'",
",",
"$",
"this",
"->",
"modelType",
")",
"->",
"get",
"(",
")",
";",
"}"
] |
get root categories => parent=0
@return Collection
|
[
"get",
"root",
"categories",
"=",
">",
"parent",
"=",
"0"
] |
b5c1baf8cbb51377fef090fc9ddaa0946bf42a68
|
https://github.com/laravelcity/laravel-categories/blob/b5c1baf8cbb51377fef090fc9ddaa0946bf42a68/src/Models/HtmlMethods.php#L12-L19
|
228,922
|
laravelcity/laravel-categories
|
src/Models/HtmlMethods.php
|
HtmlMethods.categoryLists
|
public function categoryLists ($categories=[],$parent=false)
{
$data = [];
$categories=(count($categories)==0 && !$parent)?$this->rootCategories():$categories;
if(count($categories)>0){
foreach ($categories as $category) {
$data[] = [
'id' => $category->id ,
'title' => $category->title ,
'slug' => $category->slug ,
'parent' => $category->parent ,
'children' => $this->categoryLists($category->child(),true) ,
];
}
}
return $data;
}
|
php
|
public function categoryLists ($categories=[],$parent=false)
{
$data = [];
$categories=(count($categories)==0 && !$parent)?$this->rootCategories():$categories;
if(count($categories)>0){
foreach ($categories as $category) {
$data[] = [
'id' => $category->id ,
'title' => $category->title ,
'slug' => $category->slug ,
'parent' => $category->parent ,
'children' => $this->categoryLists($category->child(),true) ,
];
}
}
return $data;
}
|
[
"public",
"function",
"categoryLists",
"(",
"$",
"categories",
"=",
"[",
"]",
",",
"$",
"parent",
"=",
"false",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"$",
"categories",
"=",
"(",
"count",
"(",
"$",
"categories",
")",
"==",
"0",
"&&",
"!",
"$",
"parent",
")",
"?",
"$",
"this",
"->",
"rootCategories",
"(",
")",
":",
"$",
"categories",
";",
"if",
"(",
"count",
"(",
"$",
"categories",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"categories",
"as",
"$",
"category",
")",
"{",
"$",
"data",
"[",
"]",
"=",
"[",
"'id'",
"=>",
"$",
"category",
"->",
"id",
",",
"'title'",
"=>",
"$",
"category",
"->",
"title",
",",
"'slug'",
"=>",
"$",
"category",
"->",
"slug",
",",
"'parent'",
"=>",
"$",
"category",
"->",
"parent",
",",
"'children'",
"=>",
"$",
"this",
"->",
"categoryLists",
"(",
"$",
"category",
"->",
"child",
"(",
")",
",",
"true",
")",
",",
"]",
";",
"}",
"}",
"return",
"$",
"data",
";",
"}"
] |
get array list of categories with child
@param Collection $categories
@return array
|
[
"get",
"array",
"list",
"of",
"categories",
"with",
"child"
] |
b5c1baf8cbb51377fef090fc9ddaa0946bf42a68
|
https://github.com/laravelcity/laravel-categories/blob/b5c1baf8cbb51377fef090fc9ddaa0946bf42a68/src/Models/HtmlMethods.php#L26-L43
|
228,923
|
laravelcity/laravel-categories
|
src/Models/HtmlMethods.php
|
HtmlMethods.categoryOption
|
public function categoryOption ($categories , $value = null)
{
$options = "";
if ($categories) {
foreach ($categories as $category) {
$line = $this->makeLineForDepth($this->getDepth($category->parent));
$selected = $value == $category->id ? 'selected' : '';
$options .= "<option $selected value='{$category->id}'>$line {$category->title}</option>";
$options .= $this->categoryOption($category->child());
}
}
return $options;
}
|
php
|
public function categoryOption ($categories , $value = null)
{
$options = "";
if ($categories) {
foreach ($categories as $category) {
$line = $this->makeLineForDepth($this->getDepth($category->parent));
$selected = $value == $category->id ? 'selected' : '';
$options .= "<option $selected value='{$category->id}'>$line {$category->title}</option>";
$options .= $this->categoryOption($category->child());
}
}
return $options;
}
|
[
"public",
"function",
"categoryOption",
"(",
"$",
"categories",
",",
"$",
"value",
"=",
"null",
")",
"{",
"$",
"options",
"=",
"\"\"",
";",
"if",
"(",
"$",
"categories",
")",
"{",
"foreach",
"(",
"$",
"categories",
"as",
"$",
"category",
")",
"{",
"$",
"line",
"=",
"$",
"this",
"->",
"makeLineForDepth",
"(",
"$",
"this",
"->",
"getDepth",
"(",
"$",
"category",
"->",
"parent",
")",
")",
";",
"$",
"selected",
"=",
"$",
"value",
"==",
"$",
"category",
"->",
"id",
"?",
"'selected'",
":",
"''",
";",
"$",
"options",
".=",
"\"<option $selected value='{$category->id}'>$line {$category->title}</option>\"",
";",
"$",
"options",
".=",
"$",
"this",
"->",
"categoryOption",
"(",
"$",
"category",
"->",
"child",
"(",
")",
")",
";",
"}",
"}",
"return",
"$",
"options",
";",
"}"
] |
get html option with child
@param Collection $categories
@return string
|
[
"get",
"html",
"option",
"with",
"child"
] |
b5c1baf8cbb51377fef090fc9ddaa0946bf42a68
|
https://github.com/laravelcity/laravel-categories/blob/b5c1baf8cbb51377fef090fc9ddaa0946bf42a68/src/Models/HtmlMethods.php#L50-L62
|
228,924
|
laravelcity/laravel-categories
|
src/Models/HtmlMethods.php
|
HtmlMethods.getOptionListCategories
|
public function getOptionListCategories ($value , $attributes = null , $select = true)
{
$options = $this->categoryOption($this->getRootCategories($this->modelType) , $value);
$attrs = $this->makeAttributesForOption($attributes);
$newOption = "<option selected value='0'>" . trans('Categories::category.no-parent-category') . " </option>" . $options;
if ($select == true)
return "<select $attrs>$newOption</select>";
else
return $newOption;
}
|
php
|
public function getOptionListCategories ($value , $attributes = null , $select = true)
{
$options = $this->categoryOption($this->getRootCategories($this->modelType) , $value);
$attrs = $this->makeAttributesForOption($attributes);
$newOption = "<option selected value='0'>" . trans('Categories::category.no-parent-category') . " </option>" . $options;
if ($select == true)
return "<select $attrs>$newOption</select>";
else
return $newOption;
}
|
[
"public",
"function",
"getOptionListCategories",
"(",
"$",
"value",
",",
"$",
"attributes",
"=",
"null",
",",
"$",
"select",
"=",
"true",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"categoryOption",
"(",
"$",
"this",
"->",
"getRootCategories",
"(",
"$",
"this",
"->",
"modelType",
")",
",",
"$",
"value",
")",
";",
"$",
"attrs",
"=",
"$",
"this",
"->",
"makeAttributesForOption",
"(",
"$",
"attributes",
")",
";",
"$",
"newOption",
"=",
"\"<option selected value='0'>\"",
".",
"trans",
"(",
"'Categories::category.no-parent-category'",
")",
".",
"\" </option>\"",
".",
"$",
"options",
";",
"if",
"(",
"$",
"select",
"==",
"true",
")",
"return",
"\"<select $attrs>$newOption</select>\"",
";",
"else",
"return",
"$",
"newOption",
";",
"}"
] |
get html select or options
@param string $model_type
@param array $attributes
@param boolean $select
@return string
|
[
"get",
"html",
"select",
"or",
"options"
] |
b5c1baf8cbb51377fef090fc9ddaa0946bf42a68
|
https://github.com/laravelcity/laravel-categories/blob/b5c1baf8cbb51377fef090fc9ddaa0946bf42a68/src/Models/HtmlMethods.php#L98-L107
|
228,925
|
laravelcity/laravel-categories
|
src/Models/HtmlMethods.php
|
HtmlMethods.makeLineForDepth
|
public function makeLineForDepth ($depth = 0 , $symbol = ' - ')
{
$line = '';
if ($depth > 0) {
for ($i = 1; $i <= $depth; $i++)
$line .= $symbol;
}
return $line;
}
|
php
|
public function makeLineForDepth ($depth = 0 , $symbol = ' - ')
{
$line = '';
if ($depth > 0) {
for ($i = 1; $i <= $depth; $i++)
$line .= $symbol;
}
return $line;
}
|
[
"public",
"function",
"makeLineForDepth",
"(",
"$",
"depth",
"=",
"0",
",",
"$",
"symbol",
"=",
"' - '",
")",
"{",
"$",
"line",
"=",
"''",
";",
"if",
"(",
"$",
"depth",
">",
"0",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<=",
"$",
"depth",
";",
"$",
"i",
"++",
")",
"$",
"line",
".=",
"$",
"symbol",
";",
"}",
"return",
"$",
"line",
";",
"}"
] |
make line style with depth for before title
@param int $depth
@param string $symbol
@return string
|
[
"make",
"line",
"style",
"with",
"depth",
"for",
"before",
"title"
] |
b5c1baf8cbb51377fef090fc9ddaa0946bf42a68
|
https://github.com/laravelcity/laravel-categories/blob/b5c1baf8cbb51377fef090fc9ddaa0946bf42a68/src/Models/HtmlMethods.php#L133-L141
|
228,926
|
laravelcity/laravel-categories
|
src/Models/HtmlMethods.php
|
HtmlMethods.makeAttributesForOption
|
public function makeAttributesForOption ($attributes)
{
$attrs = '';
if ($attributes) {
foreach ($attributes as $key => $value) {
$attrs .= "$key='" . $value . "'";
}
}
return $attrs;
}
|
php
|
public function makeAttributesForOption ($attributes)
{
$attrs = '';
if ($attributes) {
foreach ($attributes as $key => $value) {
$attrs .= "$key='" . $value . "'";
}
}
return $attrs;
}
|
[
"public",
"function",
"makeAttributesForOption",
"(",
"$",
"attributes",
")",
"{",
"$",
"attrs",
"=",
"''",
";",
"if",
"(",
"$",
"attributes",
")",
"{",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"attrs",
".=",
"\"$key='\"",
".",
"$",
"value",
".",
"\"'\"",
";",
"}",
"}",
"return",
"$",
"attrs",
";",
"}"
] |
make attr for html select
@param array $attributes
@return string
|
[
"make",
"attr",
"for",
"html",
"select"
] |
b5c1baf8cbb51377fef090fc9ddaa0946bf42a68
|
https://github.com/laravelcity/laravel-categories/blob/b5c1baf8cbb51377fef090fc9ddaa0946bf42a68/src/Models/HtmlMethods.php#L148-L157
|
228,927
|
laravelcity/laravel-categories
|
src/Models/HtmlMethods.php
|
HtmlMethods.getDepth
|
public function getDepth ($parent = 0)
{
$counter = 0;
$r = true;
while ($r) {
$category = self::where('id' , $parent)->first();
if ($category) {
$counter++;
$parent = $category->parent;
if ($category->parent == 0) {
break;
}
} else
break;
}
return $counter;
}
|
php
|
public function getDepth ($parent = 0)
{
$counter = 0;
$r = true;
while ($r) {
$category = self::where('id' , $parent)->first();
if ($category) {
$counter++;
$parent = $category->parent;
if ($category->parent == 0) {
break;
}
} else
break;
}
return $counter;
}
|
[
"public",
"function",
"getDepth",
"(",
"$",
"parent",
"=",
"0",
")",
"{",
"$",
"counter",
"=",
"0",
";",
"$",
"r",
"=",
"true",
";",
"while",
"(",
"$",
"r",
")",
"{",
"$",
"category",
"=",
"self",
"::",
"where",
"(",
"'id'",
",",
"$",
"parent",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"$",
"category",
")",
"{",
"$",
"counter",
"++",
";",
"$",
"parent",
"=",
"$",
"category",
"->",
"parent",
";",
"if",
"(",
"$",
"category",
"->",
"parent",
"==",
"0",
")",
"{",
"break",
";",
"}",
"}",
"else",
"break",
";",
"}",
"return",
"$",
"counter",
";",
"}"
] |
get category depth
@param $parent => int
@return int
|
[
"get",
"category",
"depth"
] |
b5c1baf8cbb51377fef090fc9ddaa0946bf42a68
|
https://github.com/laravelcity/laravel-categories/blob/b5c1baf8cbb51377fef090fc9ddaa0946bf42a68/src/Models/HtmlMethods.php#L164-L181
|
228,928
|
slickframework/slick
|
src/Slick/Database/Schema/Loader.php
|
Loader.load
|
public function load()
{
$this->_checkAdapter();
if (!class_exists($this->getClass())) {
throw new InvalidArgumentException(
"The loader class '{$this->getClass()}' is not defined."
);
}
$reflexion = new ReflectionClass($this->getClass());
/** @var LoaderInterface $loader */
$args = [['adapter' => $this->_adapter]];
$loader = $reflexion->newInstanceArgs($args);
$className = '\Slick\Database\Schema\LoaderInterface';
if (!($loader instanceof LoaderInterface)) {
throw new InvalidArgumentException(
"The loader class '{$this->getClass()}' does not " .
"implement {$className}."
);
}
return $loader->getSchema();
}
|
php
|
public function load()
{
$this->_checkAdapter();
if (!class_exists($this->getClass())) {
throw new InvalidArgumentException(
"The loader class '{$this->getClass()}' is not defined."
);
}
$reflexion = new ReflectionClass($this->getClass());
/** @var LoaderInterface $loader */
$args = [['adapter' => $this->_adapter]];
$loader = $reflexion->newInstanceArgs($args);
$className = '\Slick\Database\Schema\LoaderInterface';
if (!($loader instanceof LoaderInterface)) {
throw new InvalidArgumentException(
"The loader class '{$this->getClass()}' does not " .
"implement {$className}."
);
}
return $loader->getSchema();
}
|
[
"public",
"function",
"load",
"(",
")",
"{",
"$",
"this",
"->",
"_checkAdapter",
"(",
")",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"this",
"->",
"getClass",
"(",
")",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"The loader class '{$this->getClass()}' is not defined.\"",
")",
";",
"}",
"$",
"reflexion",
"=",
"new",
"ReflectionClass",
"(",
"$",
"this",
"->",
"getClass",
"(",
")",
")",
";",
"/** @var LoaderInterface $loader */",
"$",
"args",
"=",
"[",
"[",
"'adapter'",
"=>",
"$",
"this",
"->",
"_adapter",
"]",
"]",
";",
"$",
"loader",
"=",
"$",
"reflexion",
"->",
"newInstanceArgs",
"(",
"$",
"args",
")",
";",
"$",
"className",
"=",
"'\\Slick\\Database\\Schema\\LoaderInterface'",
";",
"if",
"(",
"!",
"(",
"$",
"loader",
"instanceof",
"LoaderInterface",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"The loader class '{$this->getClass()}' does not \"",
".",
"\"implement {$className}.\"",
")",
";",
"}",
"return",
"$",
"loader",
"->",
"getSchema",
"(",
")",
";",
"}"
] |
Queries the database and retrieves the schema object that maps it
@return SchemaInterface
@throws InvalidArgumentException If the adapter is not defined
@throws InvalidArgumentException If the loader class is not defined
|
[
"Queries",
"the",
"database",
"and",
"retrieves",
"the",
"schema",
"object",
"that",
"maps",
"it"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Schema/Loader.php#L95-L120
|
228,929
|
slickframework/slick
|
src/Slick/Database/Schema/Loader.php
|
Loader._checkAdapter
|
protected function _checkAdapter()
{
$notDefined = !is_object($this->_adapter);
$isAdapter = $this->_adapter instanceof AdapterInterface;
if ($notDefined || !$isAdapter) {
throw new InvalidArgumentException(
"You need to set the database adapter for this schema loader."
);
}
}
|
php
|
protected function _checkAdapter()
{
$notDefined = !is_object($this->_adapter);
$isAdapter = $this->_adapter instanceof AdapterInterface;
if ($notDefined || !$isAdapter) {
throw new InvalidArgumentException(
"You need to set the database adapter for this schema loader."
);
}
}
|
[
"protected",
"function",
"_checkAdapter",
"(",
")",
"{",
"$",
"notDefined",
"=",
"!",
"is_object",
"(",
"$",
"this",
"->",
"_adapter",
")",
";",
"$",
"isAdapter",
"=",
"$",
"this",
"->",
"_adapter",
"instanceof",
"AdapterInterface",
";",
"if",
"(",
"$",
"notDefined",
"||",
"!",
"$",
"isAdapter",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"You need to set the database adapter for this schema loader.\"",
")",
";",
"}",
"}"
] |
Checks if the adapter is defined
@throws InvalidArgumentException If the adapter is not defined
|
[
"Checks",
"if",
"the",
"adapter",
"is",
"defined"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Schema/Loader.php#L140-L150
|
228,930
|
slickframework/slick
|
src/Slick/Mvc/Scaffold.php
|
Scaffold.getScaffoldController
|
public static function getScaffoldController(
Controller $instance, $options = [])
{
$options = array_merge(
[
'controller' => $instance,
'request' => $instance->request,
'response' => $instance->response,
'view' => $instance->view,
'layout' => $instance->layout,
'basePath' => $instance->basePath
],
$options
);
return new static($options);
}
|
php
|
public static function getScaffoldController(
Controller $instance, $options = [])
{
$options = array_merge(
[
'controller' => $instance,
'request' => $instance->request,
'response' => $instance->response,
'view' => $instance->view,
'layout' => $instance->layout,
'basePath' => $instance->basePath
],
$options
);
return new static($options);
}
|
[
"public",
"static",
"function",
"getScaffoldController",
"(",
"Controller",
"$",
"instance",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"=",
"array_merge",
"(",
"[",
"'controller'",
"=>",
"$",
"instance",
",",
"'request'",
"=>",
"$",
"instance",
"->",
"request",
",",
"'response'",
"=>",
"$",
"instance",
"->",
"response",
",",
"'view'",
"=>",
"$",
"instance",
"->",
"view",
",",
"'layout'",
"=>",
"$",
"instance",
"->",
"layout",
",",
"'basePath'",
"=>",
"$",
"instance",
"->",
"basePath",
"]",
",",
"$",
"options",
")",
";",
"return",
"new",
"static",
"(",
"$",
"options",
")",
";",
"}"
] |
Creates a new scaffold controller
@param Controller $instance
@param array $options
@return self
|
[
"Creates",
"a",
"new",
"scaffold",
"controller"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Mvc/Scaffold.php#L108-L124
|
228,931
|
slickframework/slick
|
src/Slick/Mvc/Scaffold.php
|
Scaffold.getModelName
|
public function getModelName()
{
if (is_null($this->_modelName)) {
$this->setModelName('Models\\' .
ucfirst($this->get('modelSingular'))
);
}
return $this->_modelName;
}
|
php
|
public function getModelName()
{
if (is_null($this->_modelName)) {
$this->setModelName('Models\\' .
ucfirst($this->get('modelSingular'))
);
}
return $this->_modelName;
}
|
[
"public",
"function",
"getModelName",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_modelName",
")",
")",
"{",
"$",
"this",
"->",
"setModelName",
"(",
"'Models\\\\'",
".",
"ucfirst",
"(",
"$",
"this",
"->",
"get",
"(",
"'modelSingular'",
")",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_modelName",
";",
"}"
] |
Returns the model class name
@return string
|
[
"Returns",
"the",
"model",
"class",
"name"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Mvc/Scaffold.php#L131-L139
|
228,932
|
slickframework/slick
|
src/Slick/Mvc/Scaffold.php
|
Scaffold.setModelName
|
public function setModelName($name)
{
$this->_modelName = $name;
$nameParts = explode("\\", $name);
$controllerName = end($nameParts);
$nameParts = Text::camelCaseToSeparator($controllerName, '#');
$nameParts = explode('#', $nameParts);
$final = Text::plural(strtolower(array_pop($nameParts)));
$nameParts[] = ucfirst($final);
$this->set('modelPlural', lcfirst(implode('', $nameParts)));
$this->set('modelSingular', lcfirst($controllerName));
return $this;
}
|
php
|
public function setModelName($name)
{
$this->_modelName = $name;
$nameParts = explode("\\", $name);
$controllerName = end($nameParts);
$nameParts = Text::camelCaseToSeparator($controllerName, '#');
$nameParts = explode('#', $nameParts);
$final = Text::plural(strtolower(array_pop($nameParts)));
$nameParts[] = ucfirst($final);
$this->set('modelPlural', lcfirst(implode('', $nameParts)));
$this->set('modelSingular', lcfirst($controllerName));
return $this;
}
|
[
"public",
"function",
"setModelName",
"(",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"_modelName",
"=",
"$",
"name",
";",
"$",
"nameParts",
"=",
"explode",
"(",
"\"\\\\\"",
",",
"$",
"name",
")",
";",
"$",
"controllerName",
"=",
"end",
"(",
"$",
"nameParts",
")",
";",
"$",
"nameParts",
"=",
"Text",
"::",
"camelCaseToSeparator",
"(",
"$",
"controllerName",
",",
"'#'",
")",
";",
"$",
"nameParts",
"=",
"explode",
"(",
"'#'",
",",
"$",
"nameParts",
")",
";",
"$",
"final",
"=",
"Text",
"::",
"plural",
"(",
"strtolower",
"(",
"array_pop",
"(",
"$",
"nameParts",
")",
")",
")",
";",
"$",
"nameParts",
"[",
"]",
"=",
"ucfirst",
"(",
"$",
"final",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'modelPlural'",
",",
"lcfirst",
"(",
"implode",
"(",
"''",
",",
"$",
"nameParts",
")",
")",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'modelSingular'",
",",
"lcfirst",
"(",
"$",
"controllerName",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets model name
@param string $name
@return self
|
[
"Sets",
"model",
"name"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Mvc/Scaffold.php#L148-L161
|
228,933
|
slickframework/slick
|
src/Slick/Mvc/Scaffold.php
|
Scaffold.getDescriptor
|
public function getDescriptor()
{
if (is_null($this->_descriptor)) {
$this->_descriptor = new Descriptor(
[
'descriptor' => Manager::getInstance()
->get($this->getModelName())
]
);
}
return $this->_descriptor;
}
|
php
|
public function getDescriptor()
{
if (is_null($this->_descriptor)) {
$this->_descriptor = new Descriptor(
[
'descriptor' => Manager::getInstance()
->get($this->getModelName())
]
);
}
return $this->_descriptor;
}
|
[
"public",
"function",
"getDescriptor",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_descriptor",
")",
")",
"{",
"$",
"this",
"->",
"_descriptor",
"=",
"new",
"Descriptor",
"(",
"[",
"'descriptor'",
"=>",
"Manager",
"::",
"getInstance",
"(",
")",
"->",
"get",
"(",
"$",
"this",
"->",
"getModelName",
"(",
")",
")",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_descriptor",
";",
"}"
] |
Returns model descriptor
@return Descriptor
|
[
"Returns",
"model",
"descriptor"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Mvc/Scaffold.php#L168-L179
|
228,934
|
slickframework/slick
|
src/Slick/Mvc/Scaffold.php
|
Scaffold.index
|
public function index()
{
$pagination = new Pagination();
$pattern = StaticFilter::filter(
'text',
$this->getController()->request->getQuery('pattern', null)
);
$this->view = 'scaffold/index';
$descriptor = $this->getDescriptor();
/** @var Select $query */
$query = call_user_func_array([$this->getModelName(), 'find'], []);
$field = $descriptor->getDisplayField();
$tableName = $descriptor->getDescriptor()->getEntity()->getTableName();
$query->where(
[
"{$tableName}.{$field} LIKE :pattern" => [
':pattern' => "%{$pattern}%"
]
]
);
$pagination->setTotal($query->count());
$query->limit(
$pagination->rowsPerPage,
$pagination->offset
);
$records = $query->all();
$this->set(compact('pagination', 'records', 'pattern', 'descriptor'));
}
|
php
|
public function index()
{
$pagination = new Pagination();
$pattern = StaticFilter::filter(
'text',
$this->getController()->request->getQuery('pattern', null)
);
$this->view = 'scaffold/index';
$descriptor = $this->getDescriptor();
/** @var Select $query */
$query = call_user_func_array([$this->getModelName(), 'find'], []);
$field = $descriptor->getDisplayField();
$tableName = $descriptor->getDescriptor()->getEntity()->getTableName();
$query->where(
[
"{$tableName}.{$field} LIKE :pattern" => [
':pattern' => "%{$pattern}%"
]
]
);
$pagination->setTotal($query->count());
$query->limit(
$pagination->rowsPerPage,
$pagination->offset
);
$records = $query->all();
$this->set(compact('pagination', 'records', 'pattern', 'descriptor'));
}
|
[
"public",
"function",
"index",
"(",
")",
"{",
"$",
"pagination",
"=",
"new",
"Pagination",
"(",
")",
";",
"$",
"pattern",
"=",
"StaticFilter",
"::",
"filter",
"(",
"'text'",
",",
"$",
"this",
"->",
"getController",
"(",
")",
"->",
"request",
"->",
"getQuery",
"(",
"'pattern'",
",",
"null",
")",
")",
";",
"$",
"this",
"->",
"view",
"=",
"'scaffold/index'",
";",
"$",
"descriptor",
"=",
"$",
"this",
"->",
"getDescriptor",
"(",
")",
";",
"/** @var Select $query */",
"$",
"query",
"=",
"call_user_func_array",
"(",
"[",
"$",
"this",
"->",
"getModelName",
"(",
")",
",",
"'find'",
"]",
",",
"[",
"]",
")",
";",
"$",
"field",
"=",
"$",
"descriptor",
"->",
"getDisplayField",
"(",
")",
";",
"$",
"tableName",
"=",
"$",
"descriptor",
"->",
"getDescriptor",
"(",
")",
"->",
"getEntity",
"(",
")",
"->",
"getTableName",
"(",
")",
";",
"$",
"query",
"->",
"where",
"(",
"[",
"\"{$tableName}.{$field} LIKE :pattern\"",
"=>",
"[",
"':pattern'",
"=>",
"\"%{$pattern}%\"",
"]",
"]",
")",
";",
"$",
"pagination",
"->",
"setTotal",
"(",
"$",
"query",
"->",
"count",
"(",
")",
")",
";",
"$",
"query",
"->",
"limit",
"(",
"$",
"pagination",
"->",
"rowsPerPage",
",",
"$",
"pagination",
"->",
"offset",
")",
";",
"$",
"records",
"=",
"$",
"query",
"->",
"all",
"(",
")",
";",
"$",
"this",
"->",
"set",
"(",
"compact",
"(",
"'pagination'",
",",
"'records'",
",",
"'pattern'",
",",
"'descriptor'",
")",
")",
";",
"}"
] |
Handles the request to display index page
|
[
"Handles",
"the",
"request",
"to",
"display",
"index",
"page"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Mvc/Scaffold.php#L184-L212
|
228,935
|
slickframework/slick
|
src/Slick/Mvc/Scaffold.php
|
Scaffold.show
|
public function show($recordId = 0)
{
$this->view = 'scaffold/show';
$recordId = StaticFilter::filter('number', $recordId);
$record = call_user_func_array(
[$this->getModelName(), 'get'],
[$recordId]
);
if (is_null($record)) {
$this->addWarningMessage(
"The {$this->get('modelSingular')} with the provided key ".
"does not exists."
);
$this->redirect($this->get('modelPlural'));
return;
}
$descriptor = $this->getDescriptor();
$this->set(compact('record', 'descriptor'));
}
|
php
|
public function show($recordId = 0)
{
$this->view = 'scaffold/show';
$recordId = StaticFilter::filter('number', $recordId);
$record = call_user_func_array(
[$this->getModelName(), 'get'],
[$recordId]
);
if (is_null($record)) {
$this->addWarningMessage(
"The {$this->get('modelSingular')} with the provided key ".
"does not exists."
);
$this->redirect($this->get('modelPlural'));
return;
}
$descriptor = $this->getDescriptor();
$this->set(compact('record', 'descriptor'));
}
|
[
"public",
"function",
"show",
"(",
"$",
"recordId",
"=",
"0",
")",
"{",
"$",
"this",
"->",
"view",
"=",
"'scaffold/show'",
";",
"$",
"recordId",
"=",
"StaticFilter",
"::",
"filter",
"(",
"'number'",
",",
"$",
"recordId",
")",
";",
"$",
"record",
"=",
"call_user_func_array",
"(",
"[",
"$",
"this",
"->",
"getModelName",
"(",
")",
",",
"'get'",
"]",
",",
"[",
"$",
"recordId",
"]",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"record",
")",
")",
"{",
"$",
"this",
"->",
"addWarningMessage",
"(",
"\"The {$this->get('modelSingular')} with the provided key \"",
".",
"\"does not exists.\"",
")",
";",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"get",
"(",
"'modelPlural'",
")",
")",
";",
"return",
";",
"}",
"$",
"descriptor",
"=",
"$",
"this",
"->",
"getDescriptor",
"(",
")",
";",
"$",
"this",
"->",
"set",
"(",
"compact",
"(",
"'record'",
",",
"'descriptor'",
")",
")",
";",
"}"
] |
Handles the request to display show page
@param int $recordId
|
[
"Handles",
"the",
"request",
"to",
"display",
"show",
"page"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Mvc/Scaffold.php#L219-L240
|
228,936
|
slickframework/slick
|
src/Slick/Mvc/Scaffold.php
|
Scaffold.add
|
public function add()
{
$this->view = 'scaffold/add';
$form = new Form(
"add-{$this->get('modelSingular')}", $this->getDescriptor()
);
if ($this->request->isPost()) {
$form->setData($this->request->getPost());
if ($form->isValid()) {
try {
$modelClass = $this->getModelName();
/** @var Model $model */
$model = new $modelClass($form->getValues());
$model->save();
$name = ucfirst($this->get('modelSingular'));
$this->addSuccessMessage(
"{$name} successfully created."
);
$pmk = $model->getPrimaryKey();
$this->redirect(
$this->_basePath .'/'.
$this->get('modelPlural').'/show/'.$model->$pmk
);
return;
} catch (Database\Exception $exp) {
$this->addErrorMessage(
"Error while saving {$this->get('modelSingular')}} " .
"data: {$exp->getMessage()}"
);
}
} else {
$this->addErrorMessage(
"Cannot save {$this->get('modelSingular')}. " .
"Please correct the errors bellow."
);
}
}
$descriptor = $this->getDescriptor();
$this->set(compact('form', 'descriptor'));
}
|
php
|
public function add()
{
$this->view = 'scaffold/add';
$form = new Form(
"add-{$this->get('modelSingular')}", $this->getDescriptor()
);
if ($this->request->isPost()) {
$form->setData($this->request->getPost());
if ($form->isValid()) {
try {
$modelClass = $this->getModelName();
/** @var Model $model */
$model = new $modelClass($form->getValues());
$model->save();
$name = ucfirst($this->get('modelSingular'));
$this->addSuccessMessage(
"{$name} successfully created."
);
$pmk = $model->getPrimaryKey();
$this->redirect(
$this->_basePath .'/'.
$this->get('modelPlural').'/show/'.$model->$pmk
);
return;
} catch (Database\Exception $exp) {
$this->addErrorMessage(
"Error while saving {$this->get('modelSingular')}} " .
"data: {$exp->getMessage()}"
);
}
} else {
$this->addErrorMessage(
"Cannot save {$this->get('modelSingular')}. " .
"Please correct the errors bellow."
);
}
}
$descriptor = $this->getDescriptor();
$this->set(compact('form', 'descriptor'));
}
|
[
"public",
"function",
"add",
"(",
")",
"{",
"$",
"this",
"->",
"view",
"=",
"'scaffold/add'",
";",
"$",
"form",
"=",
"new",
"Form",
"(",
"\"add-{$this->get('modelSingular')}\"",
",",
"$",
"this",
"->",
"getDescriptor",
"(",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"request",
"->",
"isPost",
"(",
")",
")",
"{",
"$",
"form",
"->",
"setData",
"(",
"$",
"this",
"->",
"request",
"->",
"getPost",
"(",
")",
")",
";",
"if",
"(",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"try",
"{",
"$",
"modelClass",
"=",
"$",
"this",
"->",
"getModelName",
"(",
")",
";",
"/** @var Model $model */",
"$",
"model",
"=",
"new",
"$",
"modelClass",
"(",
"$",
"form",
"->",
"getValues",
"(",
")",
")",
";",
"$",
"model",
"->",
"save",
"(",
")",
";",
"$",
"name",
"=",
"ucfirst",
"(",
"$",
"this",
"->",
"get",
"(",
"'modelSingular'",
")",
")",
";",
"$",
"this",
"->",
"addSuccessMessage",
"(",
"\"{$name} successfully created.\"",
")",
";",
"$",
"pmk",
"=",
"$",
"model",
"->",
"getPrimaryKey",
"(",
")",
";",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"_basePath",
".",
"'/'",
".",
"$",
"this",
"->",
"get",
"(",
"'modelPlural'",
")",
".",
"'/show/'",
".",
"$",
"model",
"->",
"$",
"pmk",
")",
";",
"return",
";",
"}",
"catch",
"(",
"Database",
"\\",
"Exception",
"$",
"exp",
")",
"{",
"$",
"this",
"->",
"addErrorMessage",
"(",
"\"Error while saving {$this->get('modelSingular')}} \"",
".",
"\"data: {$exp->getMessage()}\"",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"addErrorMessage",
"(",
"\"Cannot save {$this->get('modelSingular')}. \"",
".",
"\"Please correct the errors bellow.\"",
")",
";",
"}",
"}",
"$",
"descriptor",
"=",
"$",
"this",
"->",
"getDescriptor",
"(",
")",
";",
"$",
"this",
"->",
"set",
"(",
"compact",
"(",
"'form'",
",",
"'descriptor'",
")",
")",
";",
"}"
] |
Handles the request to add page
|
[
"Handles",
"the",
"request",
"to",
"add",
"page"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Mvc/Scaffold.php#L245-L284
|
228,937
|
slickframework/slick
|
src/Slick/Mvc/Scaffold.php
|
Scaffold.edit
|
public function edit($recordId = 0)
{
$this->view = 'scaffold/edit';
$recordId = StaticFilter::filter('number', $recordId);
/** @var Model $record */
$record = call_user_func_array(
[$this->getModelName(), 'get'],
[$recordId]
);
if (is_null($record)) {
$this->addWarningMessage(
"The {$this->get('modelSingular')} with the provided key ".
"does not exists."
);
$this->redirect($this->_basePath .'/'.$this->get('modelPlural'));
return;
}
$form = new Form(
"edit-{$this->get('modelSingular')}", $this->getDescriptor()
);
if ($this->request->isPost()) {
$form->setData($this->request->getPost());
if ($form->isValid()) {
try {
$modelClass = $this->getModelName();
/** @var Model $model */
$model = new $modelClass($form->getValues());
$model->save();
$name = ucfirst($this->get('modelSingular'));
$this->addSuccessMessage(
"{$name} successfully updated."
);
$pmk = $model->getPrimaryKey();
$this->redirect(
$this->_basePath .'/'.
$this->get('modelPlural').'/show/'.$model->$pmk
);
return;
} catch (Database\Exception $exp) {
$this->addErrorMessage(
"Error while saving {$this->get('modelSingular')}} " .
"data: {$exp->getMessage()}"
);
}
} else {
$this->addErrorMessage(
"Cannot save {$this->get('modelSingular')}. " .
"Please correct the errors bellow."
);
}
} else {
$form->setData($record->asArray());
}
$descriptor = $this->getDescriptor();
$this->set(compact('form', 'record', 'descriptor'));
}
|
php
|
public function edit($recordId = 0)
{
$this->view = 'scaffold/edit';
$recordId = StaticFilter::filter('number', $recordId);
/** @var Model $record */
$record = call_user_func_array(
[$this->getModelName(), 'get'],
[$recordId]
);
if (is_null($record)) {
$this->addWarningMessage(
"The {$this->get('modelSingular')} with the provided key ".
"does not exists."
);
$this->redirect($this->_basePath .'/'.$this->get('modelPlural'));
return;
}
$form = new Form(
"edit-{$this->get('modelSingular')}", $this->getDescriptor()
);
if ($this->request->isPost()) {
$form->setData($this->request->getPost());
if ($form->isValid()) {
try {
$modelClass = $this->getModelName();
/** @var Model $model */
$model = new $modelClass($form->getValues());
$model->save();
$name = ucfirst($this->get('modelSingular'));
$this->addSuccessMessage(
"{$name} successfully updated."
);
$pmk = $model->getPrimaryKey();
$this->redirect(
$this->_basePath .'/'.
$this->get('modelPlural').'/show/'.$model->$pmk
);
return;
} catch (Database\Exception $exp) {
$this->addErrorMessage(
"Error while saving {$this->get('modelSingular')}} " .
"data: {$exp->getMessage()}"
);
}
} else {
$this->addErrorMessage(
"Cannot save {$this->get('modelSingular')}. " .
"Please correct the errors bellow."
);
}
} else {
$form->setData($record->asArray());
}
$descriptor = $this->getDescriptor();
$this->set(compact('form', 'record', 'descriptor'));
}
|
[
"public",
"function",
"edit",
"(",
"$",
"recordId",
"=",
"0",
")",
"{",
"$",
"this",
"->",
"view",
"=",
"'scaffold/edit'",
";",
"$",
"recordId",
"=",
"StaticFilter",
"::",
"filter",
"(",
"'number'",
",",
"$",
"recordId",
")",
";",
"/** @var Model $record */",
"$",
"record",
"=",
"call_user_func_array",
"(",
"[",
"$",
"this",
"->",
"getModelName",
"(",
")",
",",
"'get'",
"]",
",",
"[",
"$",
"recordId",
"]",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"record",
")",
")",
"{",
"$",
"this",
"->",
"addWarningMessage",
"(",
"\"The {$this->get('modelSingular')} with the provided key \"",
".",
"\"does not exists.\"",
")",
";",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"_basePath",
".",
"'/'",
".",
"$",
"this",
"->",
"get",
"(",
"'modelPlural'",
")",
")",
";",
"return",
";",
"}",
"$",
"form",
"=",
"new",
"Form",
"(",
"\"edit-{$this->get('modelSingular')}\"",
",",
"$",
"this",
"->",
"getDescriptor",
"(",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"request",
"->",
"isPost",
"(",
")",
")",
"{",
"$",
"form",
"->",
"setData",
"(",
"$",
"this",
"->",
"request",
"->",
"getPost",
"(",
")",
")",
";",
"if",
"(",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"try",
"{",
"$",
"modelClass",
"=",
"$",
"this",
"->",
"getModelName",
"(",
")",
";",
"/** @var Model $model */",
"$",
"model",
"=",
"new",
"$",
"modelClass",
"(",
"$",
"form",
"->",
"getValues",
"(",
")",
")",
";",
"$",
"model",
"->",
"save",
"(",
")",
";",
"$",
"name",
"=",
"ucfirst",
"(",
"$",
"this",
"->",
"get",
"(",
"'modelSingular'",
")",
")",
";",
"$",
"this",
"->",
"addSuccessMessage",
"(",
"\"{$name} successfully updated.\"",
")",
";",
"$",
"pmk",
"=",
"$",
"model",
"->",
"getPrimaryKey",
"(",
")",
";",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"_basePath",
".",
"'/'",
".",
"$",
"this",
"->",
"get",
"(",
"'modelPlural'",
")",
".",
"'/show/'",
".",
"$",
"model",
"->",
"$",
"pmk",
")",
";",
"return",
";",
"}",
"catch",
"(",
"Database",
"\\",
"Exception",
"$",
"exp",
")",
"{",
"$",
"this",
"->",
"addErrorMessage",
"(",
"\"Error while saving {$this->get('modelSingular')}} \"",
".",
"\"data: {$exp->getMessage()}\"",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"addErrorMessage",
"(",
"\"Cannot save {$this->get('modelSingular')}. \"",
".",
"\"Please correct the errors bellow.\"",
")",
";",
"}",
"}",
"else",
"{",
"$",
"form",
"->",
"setData",
"(",
"$",
"record",
"->",
"asArray",
"(",
")",
")",
";",
"}",
"$",
"descriptor",
"=",
"$",
"this",
"->",
"getDescriptor",
"(",
")",
";",
"$",
"this",
"->",
"set",
"(",
"compact",
"(",
"'form'",
",",
"'record'",
",",
"'descriptor'",
")",
")",
";",
"}"
] |
Handles the request to edit page
@param int $recordId
|
[
"Handles",
"the",
"request",
"to",
"edit",
"page"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Mvc/Scaffold.php#L291-L351
|
228,938
|
slickframework/slick
|
src/Slick/Mvc/Scaffold.php
|
Scaffold.delete
|
public function delete()
{
if ($this->request->isPost()) {
$recordId = StaticFilter::filter(
'text',
$this->request->getPost('id')
);
$record = call_user_func_array(
[$this->getModelName(), 'get'],
[$recordId]
);
if (is_null($record)) {
$this->addWarningMessage(
"The {$this->get('modelSingular')} with the provided key ".
"does not exists."
);
} else {
if ($record->delete()) {
$this->addSuccessMessage(
"The {$this->get('modelSingular')} was successfully " .
"deleted."
);
}
}
}
return $this->redirect($this->_basePath .'/'.$this->get('modelPlural'));
}
|
php
|
public function delete()
{
if ($this->request->isPost()) {
$recordId = StaticFilter::filter(
'text',
$this->request->getPost('id')
);
$record = call_user_func_array(
[$this->getModelName(), 'get'],
[$recordId]
);
if (is_null($record)) {
$this->addWarningMessage(
"The {$this->get('modelSingular')} with the provided key ".
"does not exists."
);
} else {
if ($record->delete()) {
$this->addSuccessMessage(
"The {$this->get('modelSingular')} was successfully " .
"deleted."
);
}
}
}
return $this->redirect($this->_basePath .'/'.$this->get('modelPlural'));
}
|
[
"public",
"function",
"delete",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"request",
"->",
"isPost",
"(",
")",
")",
"{",
"$",
"recordId",
"=",
"StaticFilter",
"::",
"filter",
"(",
"'text'",
",",
"$",
"this",
"->",
"request",
"->",
"getPost",
"(",
"'id'",
")",
")",
";",
"$",
"record",
"=",
"call_user_func_array",
"(",
"[",
"$",
"this",
"->",
"getModelName",
"(",
")",
",",
"'get'",
"]",
",",
"[",
"$",
"recordId",
"]",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"record",
")",
")",
"{",
"$",
"this",
"->",
"addWarningMessage",
"(",
"\"The {$this->get('modelSingular')} with the provided key \"",
".",
"\"does not exists.\"",
")",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"record",
"->",
"delete",
"(",
")",
")",
"{",
"$",
"this",
"->",
"addSuccessMessage",
"(",
"\"The {$this->get('modelSingular')} was successfully \"",
".",
"\"deleted.\"",
")",
";",
"}",
"}",
"}",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"_basePath",
".",
"'/'",
".",
"$",
"this",
"->",
"get",
"(",
"'modelPlural'",
")",
")",
";",
"}"
] |
Handles the request to delete a record
|
[
"Handles",
"the",
"request",
"to",
"delete",
"a",
"record"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Mvc/Scaffold.php#L356-L384
|
228,939
|
slickframework/slick
|
src/Slick/Common/Base.php
|
Base.unserialize
|
public function unserialize($serialized)
{
$data = unserialize($serialized);
$this->inspector = new Inspector($this);
foreach ($data as $key => $value) {
$this->$key = $value;
}
return $this;
}
|
php
|
public function unserialize($serialized)
{
$data = unserialize($serialized);
$this->inspector = new Inspector($this);
foreach ($data as $key => $value) {
$this->$key = $value;
}
return $this;
}
|
[
"public",
"function",
"unserialize",
"(",
"$",
"serialized",
")",
"{",
"$",
"data",
"=",
"unserialize",
"(",
"$",
"serialized",
")",
";",
"$",
"this",
"->",
"inspector",
"=",
"new",
"Inspector",
"(",
"$",
"this",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"$",
"key",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Creates a new object from serialized data
@param string $serialized
@return self
|
[
"Creates",
"a",
"new",
"object",
"from",
"serialized",
"data"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Common/Base.php#L134-L142
|
228,940
|
cornernote/yii-audit-module
|
audit/components/AuditErrorHandler.php
|
AuditErrorHandler.init
|
public function init()
{
// init the audit module
Yii::app()->getModule('audit');
// catch fatal errors
if ($this->catchFatalErrors) {
register_shutdown_function(array($this, 'handleFatalError'));
//Yii::app()->onEndRequest[] = array($this, 'handleFatalError');
if (substr(php_sapi_name(), 0, 3) != 'cli') {
ob_start(array($this, 'handleFatalBuffer'));
}
}
// track the request
if ($this->trackAllRequests)
$this->getAuditRequest();
// call parent
parent::init();
}
|
php
|
public function init()
{
// init the audit module
Yii::app()->getModule('audit');
// catch fatal errors
if ($this->catchFatalErrors) {
register_shutdown_function(array($this, 'handleFatalError'));
//Yii::app()->onEndRequest[] = array($this, 'handleFatalError');
if (substr(php_sapi_name(), 0, 3) != 'cli') {
ob_start(array($this, 'handleFatalBuffer'));
}
}
// track the request
if ($this->trackAllRequests)
$this->getAuditRequest();
// call parent
parent::init();
}
|
[
"public",
"function",
"init",
"(",
")",
"{",
"// init the audit module",
"Yii",
"::",
"app",
"(",
")",
"->",
"getModule",
"(",
"'audit'",
")",
";",
"// catch fatal errors",
"if",
"(",
"$",
"this",
"->",
"catchFatalErrors",
")",
"{",
"register_shutdown_function",
"(",
"array",
"(",
"$",
"this",
",",
"'handleFatalError'",
")",
")",
";",
"//Yii::app()->onEndRequest[] = array($this, 'handleFatalError');",
"if",
"(",
"substr",
"(",
"php_sapi_name",
"(",
")",
",",
"0",
",",
"3",
")",
"!=",
"'cli'",
")",
"{",
"ob_start",
"(",
"array",
"(",
"$",
"this",
",",
"'handleFatalBuffer'",
")",
")",
";",
"}",
"}",
"// track the request",
"if",
"(",
"$",
"this",
"->",
"trackAllRequests",
")",
"$",
"this",
"->",
"getAuditRequest",
"(",
")",
";",
"// call parent",
"parent",
"::",
"init",
"(",
")",
";",
"}"
] |
Init the error handler, register a shutdown function to catch fatal errors and track the request.
@return mixed
|
[
"Init",
"the",
"error",
"handler",
"register",
"a",
"shutdown",
"function",
"to",
"catch",
"fatal",
"errors",
"and",
"track",
"the",
"request",
"."
] |
07362f79741b5343d22bb9bb516d840072a097d4
|
https://github.com/cornernote/yii-audit-module/blob/07362f79741b5343d22bb9bb516d840072a097d4/audit/components/AuditErrorHandler.php#L78-L98
|
228,941
|
cornernote/yii-audit-module
|
audit/components/AuditErrorHandler.php
|
AuditErrorHandler.handleFatalError
|
public function handleFatalError()
{
$e = error_get_last();
if ($e !== null && in_array($e['type'], $this->fatalErrorTypes)) {
$event = new CErrorEvent($this, 500, 'Fatal error: ' . $e['message'], $e['file'], $e['line']);
$this->handle($event);
//Yii::app()->end(1); // end with abnormal ending
}
}
|
php
|
public function handleFatalError()
{
$e = error_get_last();
if ($e !== null && in_array($e['type'], $this->fatalErrorTypes)) {
$event = new CErrorEvent($this, 500, 'Fatal error: ' . $e['message'], $e['file'], $e['line']);
$this->handle($event);
//Yii::app()->end(1); // end with abnormal ending
}
}
|
[
"public",
"function",
"handleFatalError",
"(",
")",
"{",
"$",
"e",
"=",
"error_get_last",
"(",
")",
";",
"if",
"(",
"$",
"e",
"!==",
"null",
"&&",
"in_array",
"(",
"$",
"e",
"[",
"'type'",
"]",
",",
"$",
"this",
"->",
"fatalErrorTypes",
")",
")",
"{",
"$",
"event",
"=",
"new",
"CErrorEvent",
"(",
"$",
"this",
",",
"500",
",",
"'Fatal error: '",
".",
"$",
"e",
"[",
"'message'",
"]",
",",
"$",
"e",
"[",
"'file'",
"]",
",",
"$",
"e",
"[",
"'line'",
"]",
")",
";",
"$",
"this",
"->",
"handle",
"(",
"$",
"event",
")",
";",
"//Yii::app()->end(1); // end with abnormal ending",
"}",
"}"
] |
Fatal error handler
|
[
"Fatal",
"error",
"handler"
] |
07362f79741b5343d22bb9bb516d840072a097d4
|
https://github.com/cornernote/yii-audit-module/blob/07362f79741b5343d22bb9bb516d840072a097d4/audit/components/AuditErrorHandler.php#L103-L111
|
228,942
|
cornernote/yii-audit-module
|
audit/components/AuditErrorHandler.php
|
AuditErrorHandler.handleFatalBuffer
|
public function handleFatalBuffer($buffer)
{
$e = error_get_last();
return ($e !== null && in_array($e['type'], $this->fatalErrorTypes)) ? '' : $buffer;
}
|
php
|
public function handleFatalBuffer($buffer)
{
$e = error_get_last();
return ($e !== null && in_array($e['type'], $this->fatalErrorTypes)) ? '' : $buffer;
}
|
[
"public",
"function",
"handleFatalBuffer",
"(",
"$",
"buffer",
")",
"{",
"$",
"e",
"=",
"error_get_last",
"(",
")",
";",
"return",
"(",
"$",
"e",
"!==",
"null",
"&&",
"in_array",
"(",
"$",
"e",
"[",
"'type'",
"]",
",",
"$",
"this",
"->",
"fatalErrorTypes",
")",
")",
"?",
"''",
":",
"$",
"buffer",
";",
"}"
] |
Clears the output buffer that was set in init if there was a fatal error.
@param $buffer
@return string
|
[
"Clears",
"the",
"output",
"buffer",
"that",
"was",
"set",
"in",
"init",
"if",
"there",
"was",
"a",
"fatal",
"error",
"."
] |
07362f79741b5343d22bb9bb516d840072a097d4
|
https://github.com/cornernote/yii-audit-module/blob/07362f79741b5343d22bb9bb516d840072a097d4/audit/components/AuditErrorHandler.php#L118-L122
|
228,943
|
cornernote/yii-audit-module
|
audit/components/AuditErrorHandler.php
|
AuditErrorHandler.handle
|
public function handle($event)
{
if ($event instanceof CExceptionEvent)
$this->logExceptionEvent($event);
else
$this->logErrorEvent($event);
parent::handle($event);
}
|
php
|
public function handle($event)
{
if ($event instanceof CExceptionEvent)
$this->logExceptionEvent($event);
else
$this->logErrorEvent($event);
parent::handle($event);
}
|
[
"public",
"function",
"handle",
"(",
"$",
"event",
")",
"{",
"if",
"(",
"$",
"event",
"instanceof",
"CExceptionEvent",
")",
"$",
"this",
"->",
"logExceptionEvent",
"(",
"$",
"event",
")",
";",
"else",
"$",
"this",
"->",
"logErrorEvent",
"(",
"$",
"event",
")",
";",
"parent",
"::",
"handle",
"(",
"$",
"event",
")",
";",
"}"
] |
Log the pretty html stack dump before the parent handles the error.
@param CErrorEvent|CExceptionEvent $event
|
[
"Log",
"the",
"pretty",
"html",
"stack",
"dump",
"before",
"the",
"parent",
"handles",
"the",
"error",
"."
] |
07362f79741b5343d22bb9bb516d840072a097d4
|
https://github.com/cornernote/yii-audit-module/blob/07362f79741b5343d22bb9bb516d840072a097d4/audit/components/AuditErrorHandler.php#L128-L135
|
228,944
|
cornernote/yii-audit-module
|
audit/components/AuditErrorHandler.php
|
AuditErrorHandler.endAuditRequest
|
public function endAuditRequest()
{
$auditRequest = $this->getAuditRequest();
if (!in_array('response_headers', $this->auditRequestIgnoreFields) && function_exists('headers_list')) {
$auditRequest->response_headers = headers_list();
}
if ($auditRequest->response_headers) {
foreach ($auditRequest->response_headers as $header) {
if (strpos(strtolower($header), 'location:') === 0) {
$auditRequest->redirect = trim(substr($header, 9));
}
}
$auditRequest->response_headers = $this->removeValuesWithPasswordKeys($auditRequest->response_headers);
$auditRequest->response_headers = AuditHelper::pack($auditRequest->response_headers);
}
$auditRequest->user_id = Yii::app()->user->id;
$auditRequest->memory_usage = memory_get_usage();
$auditRequest->memory_peak = memory_get_peak_usage();
$auditRequest->audit_field_count = $auditRequest->auditFieldCount;
$auditRequest->end_time = microtime(true);
$auditRequest->total_time = $auditRequest->end_time - $auditRequest->start_time;
$auditRequest->save(false);
}
|
php
|
public function endAuditRequest()
{
$auditRequest = $this->getAuditRequest();
if (!in_array('response_headers', $this->auditRequestIgnoreFields) && function_exists('headers_list')) {
$auditRequest->response_headers = headers_list();
}
if ($auditRequest->response_headers) {
foreach ($auditRequest->response_headers as $header) {
if (strpos(strtolower($header), 'location:') === 0) {
$auditRequest->redirect = trim(substr($header, 9));
}
}
$auditRequest->response_headers = $this->removeValuesWithPasswordKeys($auditRequest->response_headers);
$auditRequest->response_headers = AuditHelper::pack($auditRequest->response_headers);
}
$auditRequest->user_id = Yii::app()->user->id;
$auditRequest->memory_usage = memory_get_usage();
$auditRequest->memory_peak = memory_get_peak_usage();
$auditRequest->audit_field_count = $auditRequest->auditFieldCount;
$auditRequest->end_time = microtime(true);
$auditRequest->total_time = $auditRequest->end_time - $auditRequest->start_time;
$auditRequest->save(false);
}
|
[
"public",
"function",
"endAuditRequest",
"(",
")",
"{",
"$",
"auditRequest",
"=",
"$",
"this",
"->",
"getAuditRequest",
"(",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"'response_headers'",
",",
"$",
"this",
"->",
"auditRequestIgnoreFields",
")",
"&&",
"function_exists",
"(",
"'headers_list'",
")",
")",
"{",
"$",
"auditRequest",
"->",
"response_headers",
"=",
"headers_list",
"(",
")",
";",
"}",
"if",
"(",
"$",
"auditRequest",
"->",
"response_headers",
")",
"{",
"foreach",
"(",
"$",
"auditRequest",
"->",
"response_headers",
"as",
"$",
"header",
")",
"{",
"if",
"(",
"strpos",
"(",
"strtolower",
"(",
"$",
"header",
")",
",",
"'location:'",
")",
"===",
"0",
")",
"{",
"$",
"auditRequest",
"->",
"redirect",
"=",
"trim",
"(",
"substr",
"(",
"$",
"header",
",",
"9",
")",
")",
";",
"}",
"}",
"$",
"auditRequest",
"->",
"response_headers",
"=",
"$",
"this",
"->",
"removeValuesWithPasswordKeys",
"(",
"$",
"auditRequest",
"->",
"response_headers",
")",
";",
"$",
"auditRequest",
"->",
"response_headers",
"=",
"AuditHelper",
"::",
"pack",
"(",
"$",
"auditRequest",
"->",
"response_headers",
")",
";",
"}",
"$",
"auditRequest",
"->",
"user_id",
"=",
"Yii",
"::",
"app",
"(",
")",
"->",
"user",
"->",
"id",
";",
"$",
"auditRequest",
"->",
"memory_usage",
"=",
"memory_get_usage",
"(",
")",
";",
"$",
"auditRequest",
"->",
"memory_peak",
"=",
"memory_get_peak_usage",
"(",
")",
";",
"$",
"auditRequest",
"->",
"audit_field_count",
"=",
"$",
"auditRequest",
"->",
"auditFieldCount",
";",
"$",
"auditRequest",
"->",
"end_time",
"=",
"microtime",
"(",
"true",
")",
";",
"$",
"auditRequest",
"->",
"total_time",
"=",
"$",
"auditRequest",
"->",
"end_time",
"-",
"$",
"auditRequest",
"->",
"start_time",
";",
"$",
"auditRequest",
"->",
"save",
"(",
"false",
")",
";",
"}"
] |
Callback to update the AuditRequest at the end of the Yii request.
@see getAuditRequest()
|
[
"Callback",
"to",
"update",
"the",
"AuditRequest",
"at",
"the",
"end",
"of",
"the",
"Yii",
"request",
"."
] |
07362f79741b5343d22bb9bb516d840072a097d4
|
https://github.com/cornernote/yii-audit-module/blob/07362f79741b5343d22bb9bb516d840072a097d4/audit/components/AuditErrorHandler.php#L473-L496
|
228,945
|
cornernote/yii-audit-module
|
audit/components/AuditErrorHandler.php
|
AuditErrorHandler.getCurrentLink
|
private function getCurrentLink()
{
if (Yii::app() instanceof CWebApplication) {
return Yii::app()->getRequest()->getHostInfo() . Yii::app()->getRequest()->getUrl();
}
$link = 'yiic ';
if (isset($_SERVER['argv'])) {
$argv = $_SERVER['argv'];
array_shift($argv);
$link .= implode(' ', $argv);
}
return trim($link);
}
|
php
|
private function getCurrentLink()
{
if (Yii::app() instanceof CWebApplication) {
return Yii::app()->getRequest()->getHostInfo() . Yii::app()->getRequest()->getUrl();
}
$link = 'yiic ';
if (isset($_SERVER['argv'])) {
$argv = $_SERVER['argv'];
array_shift($argv);
$link .= implode(' ', $argv);
}
return trim($link);
}
|
[
"private",
"function",
"getCurrentLink",
"(",
")",
"{",
"if",
"(",
"Yii",
"::",
"app",
"(",
")",
"instanceof",
"CWebApplication",
")",
"{",
"return",
"Yii",
"::",
"app",
"(",
")",
"->",
"getRequest",
"(",
")",
"->",
"getHostInfo",
"(",
")",
".",
"Yii",
"::",
"app",
"(",
")",
"->",
"getRequest",
"(",
")",
"->",
"getUrl",
"(",
")",
";",
"}",
"$",
"link",
"=",
"'yiic '",
";",
"if",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'argv'",
"]",
")",
")",
"{",
"$",
"argv",
"=",
"$",
"_SERVER",
"[",
"'argv'",
"]",
";",
"array_shift",
"(",
"$",
"argv",
")",
";",
"$",
"link",
".=",
"implode",
"(",
"' '",
",",
"$",
"argv",
")",
";",
"}",
"return",
"trim",
"(",
"$",
"link",
")",
";",
"}"
] |
Gets a link to the current page or yiic script that is being run.
@return string
|
[
"Gets",
"a",
"link",
"to",
"the",
"current",
"page",
"or",
"yiic",
"script",
"that",
"is",
"being",
"run",
"."
] |
07362f79741b5343d22bb9bb516d840072a097d4
|
https://github.com/cornernote/yii-audit-module/blob/07362f79741b5343d22bb9bb516d840072a097d4/audit/components/AuditErrorHandler.php#L513-L525
|
228,946
|
cornernote/yii-audit-module
|
audit/components/AuditErrorHandler.php
|
AuditErrorHandler.removeValuesWithPasswordKeys
|
private function removeValuesWithPasswordKeys($array, &$passwordRemoved = false)
{
foreach ($array as $key => $value) {
if (is_array($value)) {
$value = $this->removeValuesWithPasswordKeys($value, $removedChild);
if ($removedChild) {
$array[$key] = $value;
$passwordRemoved = true;
}
} else {
foreach ($this->auditRequestIgnoreKeys as $ignoreKey) {
if (stripos($key, $ignoreKey) !== false) {
$array[$key] = '*password removed*';
$passwordRemoved = true;
continue;
}
}
}
}
return $array;
}
|
php
|
private function removeValuesWithPasswordKeys($array, &$passwordRemoved = false)
{
foreach ($array as $key => $value) {
if (is_array($value)) {
$value = $this->removeValuesWithPasswordKeys($value, $removedChild);
if ($removedChild) {
$array[$key] = $value;
$passwordRemoved = true;
}
} else {
foreach ($this->auditRequestIgnoreKeys as $ignoreKey) {
if (stripos($key, $ignoreKey) !== false) {
$array[$key] = '*password removed*';
$passwordRemoved = true;
continue;
}
}
}
}
return $array;
}
|
[
"private",
"function",
"removeValuesWithPasswordKeys",
"(",
"$",
"array",
",",
"&",
"$",
"passwordRemoved",
"=",
"false",
")",
"{",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"removeValuesWithPasswordKeys",
"(",
"$",
"value",
",",
"$",
"removedChild",
")",
";",
"if",
"(",
"$",
"removedChild",
")",
"{",
"$",
"array",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"$",
"passwordRemoved",
"=",
"true",
";",
"}",
"}",
"else",
"{",
"foreach",
"(",
"$",
"this",
"->",
"auditRequestIgnoreKeys",
"as",
"$",
"ignoreKey",
")",
"{",
"if",
"(",
"stripos",
"(",
"$",
"key",
",",
"$",
"ignoreKey",
")",
"!==",
"false",
")",
"{",
"$",
"array",
"[",
"$",
"key",
"]",
"=",
"'*password removed*'",
";",
"$",
"passwordRemoved",
"=",
"true",
";",
"continue",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"array",
";",
"}"
] |
Removes passwords from the given array.
@param $array
@param bool $passwordRemoved gets set to true if passwords were removed.
@return array
|
[
"Removes",
"passwords",
"from",
"the",
"given",
"array",
"."
] |
07362f79741b5343d22bb9bb516d840072a097d4
|
https://github.com/cornernote/yii-audit-module/blob/07362f79741b5343d22bb9bb516d840072a097d4/audit/components/AuditErrorHandler.php#L534-L554
|
228,947
|
cornernote/yii-audit-module
|
audit/components/AuditErrorHandler.php
|
AuditErrorHandler.getShrinkedSession
|
private function getShrinkedSession()
{
$serialized = '';
if (isset($_SESSION)) {
$serialized = serialize($_SESSION);
}
if (strlen($serialized) > 64000) {
$sessionCopy = $_SESSION;
$ignoredKeys = array();
foreach ($_SESSION as $key => $value) {
$size = strlen(serialize($value));
if ($size > 1000) {
unset($sessionCopy[$key]);
$ignoredKeys[$key] = $key;
}
}
$sessionCopy['__ignored_keys_in_audit'] = $ignoredKeys;
$serialized = serialize($sessionCopy);
}
return unserialize($serialized);
}
|
php
|
private function getShrinkedSession()
{
$serialized = '';
if (isset($_SESSION)) {
$serialized = serialize($_SESSION);
}
if (strlen($serialized) > 64000) {
$sessionCopy = $_SESSION;
$ignoredKeys = array();
foreach ($_SESSION as $key => $value) {
$size = strlen(serialize($value));
if ($size > 1000) {
unset($sessionCopy[$key]);
$ignoredKeys[$key] = $key;
}
}
$sessionCopy['__ignored_keys_in_audit'] = $ignoredKeys;
$serialized = serialize($sessionCopy);
}
return unserialize($serialized);
}
|
[
"private",
"function",
"getShrinkedSession",
"(",
")",
"{",
"$",
"serialized",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"_SESSION",
")",
")",
"{",
"$",
"serialized",
"=",
"serialize",
"(",
"$",
"_SESSION",
")",
";",
"}",
"if",
"(",
"strlen",
"(",
"$",
"serialized",
")",
">",
"64000",
")",
"{",
"$",
"sessionCopy",
"=",
"$",
"_SESSION",
";",
"$",
"ignoredKeys",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"_SESSION",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"size",
"=",
"strlen",
"(",
"serialize",
"(",
"$",
"value",
")",
")",
";",
"if",
"(",
"$",
"size",
">",
"1000",
")",
"{",
"unset",
"(",
"$",
"sessionCopy",
"[",
"$",
"key",
"]",
")",
";",
"$",
"ignoredKeys",
"[",
"$",
"key",
"]",
"=",
"$",
"key",
";",
"}",
"}",
"$",
"sessionCopy",
"[",
"'__ignored_keys_in_audit'",
"]",
"=",
"$",
"ignoredKeys",
";",
"$",
"serialized",
"=",
"serialize",
"(",
"$",
"sessionCopy",
")",
";",
"}",
"return",
"unserialize",
"(",
"$",
"serialized",
")",
";",
"}"
] |
Shrinks the session of huge datafields to prevent too much data being stored.
@return mixed
|
[
"Shrinks",
"the",
"session",
"of",
"huge",
"datafields",
"to",
"prevent",
"too",
"much",
"data",
"being",
"stored",
"."
] |
07362f79741b5343d22bb9bb516d840072a097d4
|
https://github.com/cornernote/yii-audit-module/blob/07362f79741b5343d22bb9bb516d840072a097d4/audit/components/AuditErrorHandler.php#L561-L581
|
228,948
|
slickframework/slick
|
src/Slick/Form/Form.php
|
Form.AddElement
|
public function AddElement($name, $data)
{
$this->factory->addElement($this, $name, $data);
return $this;
}
|
php
|
public function AddElement($name, $data)
{
$this->factory->addElement($this, $name, $data);
return $this;
}
|
[
"public",
"function",
"AddElement",
"(",
"$",
"name",
",",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"factory",
"->",
"addElement",
"(",
"$",
"this",
",",
"$",
"name",
",",
"$",
"data",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds an element to the form using the built in factory
@param string $name Element name
@param array $data Factory data
@return Form A self instance for method call chain
@throws Exception\UnknownElementException
|
[
"Adds",
"an",
"element",
"to",
"the",
"form",
"using",
"the",
"built",
"in",
"factory"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Form/Form.php#L113-L117
|
228,949
|
slickframework/slick
|
src/Slick/Form/Form.php
|
Form.setEventManager
|
public function setEventManager(EventManagerInterface $eventManager)
{
$eventManager->setIdentifiers(
array(
__CLASS__,
get_called_class(),
$this->getName()
)
);
$this->_events = $eventManager;
return $this;
}
|
php
|
public function setEventManager(EventManagerInterface $eventManager)
{
$eventManager->setIdentifiers(
array(
__CLASS__,
get_called_class(),
$this->getName()
)
);
$this->_events = $eventManager;
return $this;
}
|
[
"public",
"function",
"setEventManager",
"(",
"EventManagerInterface",
"$",
"eventManager",
")",
"{",
"$",
"eventManager",
"->",
"setIdentifiers",
"(",
"array",
"(",
"__CLASS__",
",",
"get_called_class",
"(",
")",
",",
"$",
"this",
"->",
"getName",
"(",
")",
")",
")",
";",
"$",
"this",
"->",
"_events",
"=",
"$",
"eventManager",
";",
"return",
"$",
"this",
";",
"}"
] |
Inject an EventManager instance
@param EventManagerInterface $eventManager
@return Form
|
[
"Inject",
"an",
"EventManager",
"instance"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Form/Form.php#L152-L163
|
228,950
|
slickframework/slick
|
src/Slick/Form/Form.php
|
Form.render
|
public function render()
{
$this->getEventManager()->trigger(
'formBeforeRender',
$this,
array(
)
);
$output = parent::render();
$this->getEventManager()->trigger(
'formAfterRender',
$this,
array(
'output' => &$output
)
);
return $output;
}
|
php
|
public function render()
{
$this->getEventManager()->trigger(
'formBeforeRender',
$this,
array(
)
);
$output = parent::render();
$this->getEventManager()->trigger(
'formAfterRender',
$this,
array(
'output' => &$output
)
);
return $output;
}
|
[
"public",
"function",
"render",
"(",
")",
"{",
"$",
"this",
"->",
"getEventManager",
"(",
")",
"->",
"trigger",
"(",
"'formBeforeRender'",
",",
"$",
"this",
",",
"array",
"(",
")",
")",
";",
"$",
"output",
"=",
"parent",
"::",
"render",
"(",
")",
";",
"$",
"this",
"->",
"getEventManager",
"(",
")",
"->",
"trigger",
"(",
"'formAfterRender'",
",",
"$",
"this",
",",
"array",
"(",
"'output'",
"=>",
"&",
"$",
"output",
")",
")",
";",
"return",
"$",
"output",
";",
"}"
] |
Renders the form as HTML string
@return string The HTML output string
|
[
"Renders",
"the",
"form",
"as",
"HTML",
"string"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Form/Form.php#L311-L329
|
228,951
|
Danzabar/phalcon-cli
|
src/Input/Input.php
|
Input.mock
|
public function mock($str)
{
fputs($this->inputStream, $str);
rewind($this->inputStream);
return $this;
}
|
php
|
public function mock($str)
{
fputs($this->inputStream, $str);
rewind($this->inputStream);
return $this;
}
|
[
"public",
"function",
"mock",
"(",
"$",
"str",
")",
"{",
"fputs",
"(",
"$",
"this",
"->",
"inputStream",
",",
"$",
"str",
")",
";",
"rewind",
"(",
"$",
"this",
"->",
"inputStream",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Mock an input string
@return Input
|
[
"Mock",
"an",
"input",
"string"
] |
0d6293d5d899158705f8e3a31886d176e595ee38
|
https://github.com/Danzabar/phalcon-cli/blob/0d6293d5d899158705f8e3a31886d176e595ee38/src/Input/Input.php#L53-L59
|
228,952
|
slickframework/slick
|
src/Slick/Database/Sql/Dialect/Standard/AlterTableSqlTemplate.php
|
AlterTableSqlTemplate._constraintsStatement
|
protected function _constraintsStatement()
{
$cons = $this->_sql->getConstraints();
if (empty($cons)) {
return null;
}
return $this->_parseConstraints();
}
|
php
|
protected function _constraintsStatement()
{
$cons = $this->_sql->getConstraints();
if (empty($cons)) {
return null;
}
return $this->_parseConstraints();
}
|
[
"protected",
"function",
"_constraintsStatement",
"(",
")",
"{",
"$",
"cons",
"=",
"$",
"this",
"->",
"_sql",
"->",
"getConstraints",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"cons",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"_parseConstraints",
"(",
")",
";",
"}"
] |
Parse column list for SQL add constraint statement
@return null|string
|
[
"Parse",
"column",
"list",
"for",
"SQL",
"add",
"constraint",
"statement"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Sql/Dialect/Standard/AlterTableSqlTemplate.php#L84-L92
|
228,953
|
slickframework/slick
|
src/Slick/Database/Sql/Dialect/Standard/AlterTableSqlTemplate.php
|
AlterTableSqlTemplate._droppedColumnsStatement
|
protected function _droppedColumnsStatement()
{
$columns = $this->_sql->getDroppedColumns();
if (empty($columns)) {
return null;
}
return implode(', ', array_keys($columns));
}
|
php
|
protected function _droppedColumnsStatement()
{
$columns = $this->_sql->getDroppedColumns();
if (empty($columns)) {
return null;
}
return implode(', ', array_keys($columns));
}
|
[
"protected",
"function",
"_droppedColumnsStatement",
"(",
")",
"{",
"$",
"columns",
"=",
"$",
"this",
"->",
"_sql",
"->",
"getDroppedColumns",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"columns",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"implode",
"(",
"', '",
",",
"array_keys",
"(",
"$",
"columns",
")",
")",
";",
"}"
] |
Parse column list for SQL drop column statement
@return null|string
|
[
"Parse",
"column",
"list",
"for",
"SQL",
"drop",
"column",
"statement"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Sql/Dialect/Standard/AlterTableSqlTemplate.php#L114-L122
|
228,954
|
slickframework/slick
|
src/Slick/Database/Sql/Dialect/Standard/AlterTableSqlTemplate.php
|
AlterTableSqlTemplate._addColumnsStatement
|
protected function _addColumnsStatement()
{
$columns = $this->_sql->getColumns();
if (empty($columns)) {
return null;
}
return $this->_parseColumns();
}
|
php
|
protected function _addColumnsStatement()
{
$columns = $this->_sql->getColumns();
if (empty($columns)) {
return null;
}
return $this->_parseColumns();
}
|
[
"protected",
"function",
"_addColumnsStatement",
"(",
")",
"{",
"$",
"columns",
"=",
"$",
"this",
"->",
"_sql",
"->",
"getColumns",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"columns",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"_parseColumns",
"(",
")",
";",
"}"
] |
Parse column list for SQL add column statement
@return null|string
|
[
"Parse",
"column",
"list",
"for",
"SQL",
"add",
"column",
"statement"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Sql/Dialect/Standard/AlterTableSqlTemplate.php#L144-L152
|
228,955
|
slickframework/slick
|
src/Slick/Orm/Relation/HasAndBelongsToMany.php
|
HasAndBelongsToMany.getRelatedForeignKey
|
public function getRelatedForeignKey()
{
if (is_null($this->_relatedForeignKey)) {
$tblName = Entity\Manager::getInstance()
->get($this->_relatedEntity)
->getEntity()->getTableName();
$name = Text::singular($tblName);
$this->setRelatedForeignKey("{$name}_id");
}
return $this->_relatedForeignKey;
}
|
php
|
public function getRelatedForeignKey()
{
if (is_null($this->_relatedForeignKey)) {
$tblName = Entity\Manager::getInstance()
->get($this->_relatedEntity)
->getEntity()->getTableName();
$name = Text::singular($tblName);
$this->setRelatedForeignKey("{$name}_id");
}
return $this->_relatedForeignKey;
}
|
[
"public",
"function",
"getRelatedForeignKey",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_relatedForeignKey",
")",
")",
"{",
"$",
"tblName",
"=",
"Entity",
"\\",
"Manager",
"::",
"getInstance",
"(",
")",
"->",
"get",
"(",
"$",
"this",
"->",
"_relatedEntity",
")",
"->",
"getEntity",
"(",
")",
"->",
"getTableName",
"(",
")",
";",
"$",
"name",
"=",
"Text",
"::",
"singular",
"(",
"$",
"tblName",
")",
";",
"$",
"this",
"->",
"setRelatedForeignKey",
"(",
"\"{$name}_id\"",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_relatedForeignKey",
";",
"}"
] |
Returns related foreign key. If its not set tries to infer it from
related table name.
@return string
|
[
"Returns",
"related",
"foreign",
"key",
".",
"If",
"its",
"not",
"set",
"tries",
"to",
"infer",
"it",
"from",
"related",
"table",
"name",
"."
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Orm/Relation/HasAndBelongsToMany.php#L61-L71
|
228,956
|
slickframework/slick
|
src/Slick/Orm/Relation/HasAndBelongsToMany.php
|
HasAndBelongsToMany.getRelationTable
|
public function getRelationTable()
{
if (is_null($this->_relationTable)) {
$names = [
$this->getEntity()->getTableName(),
Entity\Manager::getInstance()
->get($this->_relatedEntity)
->getEntity()->getTableName()
];
asort($names);
$this->setRelationTable(implode('_', $names));
}
return $this->_relationTable;
}
|
php
|
public function getRelationTable()
{
if (is_null($this->_relationTable)) {
$names = [
$this->getEntity()->getTableName(),
Entity\Manager::getInstance()
->get($this->_relatedEntity)
->getEntity()->getTableName()
];
asort($names);
$this->setRelationTable(implode('_', $names));
}
return $this->_relationTable;
}
|
[
"public",
"function",
"getRelationTable",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_relationTable",
")",
")",
"{",
"$",
"names",
"=",
"[",
"$",
"this",
"->",
"getEntity",
"(",
")",
"->",
"getTableName",
"(",
")",
",",
"Entity",
"\\",
"Manager",
"::",
"getInstance",
"(",
")",
"->",
"get",
"(",
"$",
"this",
"->",
"_relatedEntity",
")",
"->",
"getEntity",
"(",
")",
"->",
"getTableName",
"(",
")",
"]",
";",
"asort",
"(",
"$",
"names",
")",
";",
"$",
"this",
"->",
"setRelationTable",
"(",
"implode",
"(",
"'_'",
",",
"$",
"names",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_relationTable",
";",
"}"
] |
Returns relation table name. If its not set tries to infer it from
related table names.
@return string
|
[
"Returns",
"relation",
"table",
"name",
".",
"If",
"its",
"not",
"set",
"tries",
"to",
"infer",
"it",
"from",
"related",
"table",
"names",
"."
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Orm/Relation/HasAndBelongsToMany.php#L79-L92
|
228,957
|
slickframework/slick
|
src/Slick/Orm/Relation/HasAndBelongsToMany.php
|
HasAndBelongsToMany.setEntity
|
public function setEntity(Entity $entity)
{
/** @var SharedEventManager $events */
$events = $this->getContainer()->get('sharedEventManager');
$name = $entity->getClassName();
$events->attach(
$name,
Delete::BEFORE_DELETE,
[$this, 'beforeDelete']
);
$events->attach(
$name,
Save::AFTER_SAVE,
[$this, 'afterSave']
);
$this->getContainer()->set('sharedEventManager', $events);
return parent::setEntity($entity);
}
|
php
|
public function setEntity(Entity $entity)
{
/** @var SharedEventManager $events */
$events = $this->getContainer()->get('sharedEventManager');
$name = $entity->getClassName();
$events->attach(
$name,
Delete::BEFORE_DELETE,
[$this, 'beforeDelete']
);
$events->attach(
$name,
Save::AFTER_SAVE,
[$this, 'afterSave']
);
$this->getContainer()->set('sharedEventManager', $events);
return parent::setEntity($entity);
}
|
[
"public",
"function",
"setEntity",
"(",
"Entity",
"$",
"entity",
")",
"{",
"/** @var SharedEventManager $events */",
"$",
"events",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'sharedEventManager'",
")",
";",
"$",
"name",
"=",
"$",
"entity",
"->",
"getClassName",
"(",
")",
";",
"$",
"events",
"->",
"attach",
"(",
"$",
"name",
",",
"Delete",
"::",
"BEFORE_DELETE",
",",
"[",
"$",
"this",
",",
"'beforeDelete'",
"]",
")",
";",
"$",
"events",
"->",
"attach",
"(",
"$",
"name",
",",
"Save",
"::",
"AFTER_SAVE",
",",
"[",
"$",
"this",
",",
"'afterSave'",
"]",
")",
";",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"set",
"(",
"'sharedEventManager'",
",",
"$",
"events",
")",
";",
"return",
"parent",
"::",
"setEntity",
"(",
"$",
"entity",
")",
";",
"}"
] |
Sets the entity that defines the relation. Sets the triggers
for before delete event.
@param Entity $entity
@return self
|
[
"Sets",
"the",
"entity",
"that",
"defines",
"the",
"relation",
".",
"Sets",
"the",
"triggers",
"for",
"before",
"delete",
"event",
"."
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Orm/Relation/HasAndBelongsToMany.php#L149-L166
|
228,958
|
slickframework/slick
|
src/Slick/Orm/Relation/HasAndBelongsToMany.php
|
HasAndBelongsToMany.beforeDelete
|
public function beforeDelete(Delete $event)
{
$pmkVal = $event->primaryKey;
$entFrk = $this->getForeignKey();
Sql::createSql($this->getEntity()->getAdapter())
->delete($this->getRelationTable())
->where(
[
"{$entFrk} = :id" => [
":id" => $pmkVal
]
]
)
->execute();
}
|
php
|
public function beforeDelete(Delete $event)
{
$pmkVal = $event->primaryKey;
$entFrk = $this->getForeignKey();
Sql::createSql($this->getEntity()->getAdapter())
->delete($this->getRelationTable())
->where(
[
"{$entFrk} = :id" => [
":id" => $pmkVal
]
]
)
->execute();
}
|
[
"public",
"function",
"beforeDelete",
"(",
"Delete",
"$",
"event",
")",
"{",
"$",
"pmkVal",
"=",
"$",
"event",
"->",
"primaryKey",
";",
"$",
"entFrk",
"=",
"$",
"this",
"->",
"getForeignKey",
"(",
")",
";",
"Sql",
"::",
"createSql",
"(",
"$",
"this",
"->",
"getEntity",
"(",
")",
"->",
"getAdapter",
"(",
")",
")",
"->",
"delete",
"(",
"$",
"this",
"->",
"getRelationTable",
"(",
")",
")",
"->",
"where",
"(",
"[",
"\"{$entFrk} = :id\"",
"=>",
"[",
"\":id\"",
"=>",
"$",
"pmkVal",
"]",
"]",
")",
"->",
"execute",
"(",
")",
";",
"}"
] |
Deletes all relational data on deleting entity
@param Delete $event
|
[
"Deletes",
"all",
"relational",
"data",
"on",
"deleting",
"entity"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Orm/Relation/HasAndBelongsToMany.php#L173-L187
|
228,959
|
slickframework/slick
|
src/Slick/Orm/Relation/HasAndBelongsToMany.php
|
HasAndBelongsToMany.afterSave
|
public function afterSave(Save $event)
{
/** @var Entity $entity */
$entity = $event->getTarget();
$entity->loadRelations = false;
$prop = $this->getPropertyName();
$relPrk = Entity\Manager::getInstance()->get($this->getRelatedEntity())
->getEntity()->getPrimaryKey();
$entPrk = $entity->getPrimaryKey();
if (isset($entity->$prop) && is_array($entity->$prop)) {
$this->beforeDelete(new Delete(['primaryKey' => $entity->$entPrk]));
foreach ($entity->$prop as $object) {
$relVal = $object;
if ($object instanceof Entity) {
$relVal = $object->$relPrk;
}
Sql::createSql($entity->getAdapter())
->insert($this->getRelationTable())
->set(
[
$this->getForeignKey() => $entity->$entPrk,
$this->getRelatedForeignKey() => $relVal
]
)
->execute();
}
}
$entity->loadRelations = true;
}
|
php
|
public function afterSave(Save $event)
{
/** @var Entity $entity */
$entity = $event->getTarget();
$entity->loadRelations = false;
$prop = $this->getPropertyName();
$relPrk = Entity\Manager::getInstance()->get($this->getRelatedEntity())
->getEntity()->getPrimaryKey();
$entPrk = $entity->getPrimaryKey();
if (isset($entity->$prop) && is_array($entity->$prop)) {
$this->beforeDelete(new Delete(['primaryKey' => $entity->$entPrk]));
foreach ($entity->$prop as $object) {
$relVal = $object;
if ($object instanceof Entity) {
$relVal = $object->$relPrk;
}
Sql::createSql($entity->getAdapter())
->insert($this->getRelationTable())
->set(
[
$this->getForeignKey() => $entity->$entPrk,
$this->getRelatedForeignKey() => $relVal
]
)
->execute();
}
}
$entity->loadRelations = true;
}
|
[
"public",
"function",
"afterSave",
"(",
"Save",
"$",
"event",
")",
"{",
"/** @var Entity $entity */",
"$",
"entity",
"=",
"$",
"event",
"->",
"getTarget",
"(",
")",
";",
"$",
"entity",
"->",
"loadRelations",
"=",
"false",
";",
"$",
"prop",
"=",
"$",
"this",
"->",
"getPropertyName",
"(",
")",
";",
"$",
"relPrk",
"=",
"Entity",
"\\",
"Manager",
"::",
"getInstance",
"(",
")",
"->",
"get",
"(",
"$",
"this",
"->",
"getRelatedEntity",
"(",
")",
")",
"->",
"getEntity",
"(",
")",
"->",
"getPrimaryKey",
"(",
")",
";",
"$",
"entPrk",
"=",
"$",
"entity",
"->",
"getPrimaryKey",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"entity",
"->",
"$",
"prop",
")",
"&&",
"is_array",
"(",
"$",
"entity",
"->",
"$",
"prop",
")",
")",
"{",
"$",
"this",
"->",
"beforeDelete",
"(",
"new",
"Delete",
"(",
"[",
"'primaryKey'",
"=>",
"$",
"entity",
"->",
"$",
"entPrk",
"]",
")",
")",
";",
"foreach",
"(",
"$",
"entity",
"->",
"$",
"prop",
"as",
"$",
"object",
")",
"{",
"$",
"relVal",
"=",
"$",
"object",
";",
"if",
"(",
"$",
"object",
"instanceof",
"Entity",
")",
"{",
"$",
"relVal",
"=",
"$",
"object",
"->",
"$",
"relPrk",
";",
"}",
"Sql",
"::",
"createSql",
"(",
"$",
"entity",
"->",
"getAdapter",
"(",
")",
")",
"->",
"insert",
"(",
"$",
"this",
"->",
"getRelationTable",
"(",
")",
")",
"->",
"set",
"(",
"[",
"$",
"this",
"->",
"getForeignKey",
"(",
")",
"=>",
"$",
"entity",
"->",
"$",
"entPrk",
",",
"$",
"this",
"->",
"getRelatedForeignKey",
"(",
")",
"=>",
"$",
"relVal",
"]",
")",
"->",
"execute",
"(",
")",
";",
"}",
"}",
"$",
"entity",
"->",
"loadRelations",
"=",
"true",
";",
"}"
] |
Handles the after save event
@param Save $event
|
[
"Handles",
"the",
"after",
"save",
"event"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Orm/Relation/HasAndBelongsToMany.php#L194-L224
|
228,960
|
slickframework/slick
|
src/Slick/Form/Element/SelectMultiple.php
|
SelectMultiple.getTemplate
|
public function getTemplate()
{
if (is_null($this->_template)) {
$this->_template = new \Slick\Form\Template\SelectMultiple();
}
return $this->_template;
}
|
php
|
public function getTemplate()
{
if (is_null($this->_template)) {
$this->_template = new \Slick\Form\Template\SelectMultiple();
}
return $this->_template;
}
|
[
"public",
"function",
"getTemplate",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_template",
")",
")",
"{",
"$",
"this",
"->",
"_template",
"=",
"new",
"\\",
"Slick",
"\\",
"Form",
"\\",
"Template",
"\\",
"SelectMultiple",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_template",
";",
"}"
] |
lazy loads a default template for this element
@return AbstractTemplate
|
[
"lazy",
"loads",
"a",
"default",
"template",
"for",
"this",
"element"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Form/Element/SelectMultiple.php#L38-L44
|
228,961
|
lekoala/silverstripe-form-extras
|
code/fields/TableField.php
|
TableField.ColumnsList
|
public function ColumnsList()
{
$list = new ArrayList();
foreach ($this->columns as $key => $column) {
$header = $this->array_get($column, self::KEY_HEADER);
$required = $this->array_get($column, self::KEY_REQUIRED);
$type = $this->array_get($column, self::KEY_TYPE,
self::TYPE_TEXT);
$values = $this->array_get($column, self::KEY_OPTIONS);
$valuesList = null;
$size = null;
if ($type == self::TYPE_CURRENCY) {
$type = 'text';
$size = 7;
}
if ($values && is_array($values)) {
$valuesList = new ArrayList();
foreach ($values as $k => $v) {
$valuesList->push(new ArrayData(array('Name' => $k, 'Value' => $v)));
}
}
$rowData = array(
'Key' => $key,
'Size' => $size,
'Header' => $header,
'Values' => $valuesList,
'Type' => $type,
'Required' => $required ? 'true' : 'false'
);
$list->push(new ArrayData($rowData));
}
return $list;
}
|
php
|
public function ColumnsList()
{
$list = new ArrayList();
foreach ($this->columns as $key => $column) {
$header = $this->array_get($column, self::KEY_HEADER);
$required = $this->array_get($column, self::KEY_REQUIRED);
$type = $this->array_get($column, self::KEY_TYPE,
self::TYPE_TEXT);
$values = $this->array_get($column, self::KEY_OPTIONS);
$valuesList = null;
$size = null;
if ($type == self::TYPE_CURRENCY) {
$type = 'text';
$size = 7;
}
if ($values && is_array($values)) {
$valuesList = new ArrayList();
foreach ($values as $k => $v) {
$valuesList->push(new ArrayData(array('Name' => $k, 'Value' => $v)));
}
}
$rowData = array(
'Key' => $key,
'Size' => $size,
'Header' => $header,
'Values' => $valuesList,
'Type' => $type,
'Required' => $required ? 'true' : 'false'
);
$list->push(new ArrayData($rowData));
}
return $list;
}
|
[
"public",
"function",
"ColumnsList",
"(",
")",
"{",
"$",
"list",
"=",
"new",
"ArrayList",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"columns",
"as",
"$",
"key",
"=>",
"$",
"column",
")",
"{",
"$",
"header",
"=",
"$",
"this",
"->",
"array_get",
"(",
"$",
"column",
",",
"self",
"::",
"KEY_HEADER",
")",
";",
"$",
"required",
"=",
"$",
"this",
"->",
"array_get",
"(",
"$",
"column",
",",
"self",
"::",
"KEY_REQUIRED",
")",
";",
"$",
"type",
"=",
"$",
"this",
"->",
"array_get",
"(",
"$",
"column",
",",
"self",
"::",
"KEY_TYPE",
",",
"self",
"::",
"TYPE_TEXT",
")",
";",
"$",
"values",
"=",
"$",
"this",
"->",
"array_get",
"(",
"$",
"column",
",",
"self",
"::",
"KEY_OPTIONS",
")",
";",
"$",
"valuesList",
"=",
"null",
";",
"$",
"size",
"=",
"null",
";",
"if",
"(",
"$",
"type",
"==",
"self",
"::",
"TYPE_CURRENCY",
")",
"{",
"$",
"type",
"=",
"'text'",
";",
"$",
"size",
"=",
"7",
";",
"}",
"if",
"(",
"$",
"values",
"&&",
"is_array",
"(",
"$",
"values",
")",
")",
"{",
"$",
"valuesList",
"=",
"new",
"ArrayList",
"(",
")",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"valuesList",
"->",
"push",
"(",
"new",
"ArrayData",
"(",
"array",
"(",
"'Name'",
"=>",
"$",
"k",
",",
"'Value'",
"=>",
"$",
"v",
")",
")",
")",
";",
"}",
"}",
"$",
"rowData",
"=",
"array",
"(",
"'Key'",
"=>",
"$",
"key",
",",
"'Size'",
"=>",
"$",
"size",
",",
"'Header'",
"=>",
"$",
"header",
",",
"'Values'",
"=>",
"$",
"valuesList",
",",
"'Type'",
"=>",
"$",
"type",
",",
"'Required'",
"=>",
"$",
"required",
"?",
"'true'",
":",
"'false'",
")",
";",
"$",
"list",
"->",
"push",
"(",
"new",
"ArrayData",
"(",
"$",
"rowData",
")",
")",
";",
"}",
"return",
"$",
"list",
";",
"}"
] |
Return an array list of columns
@return \ArrayList
|
[
"Return",
"an",
"array",
"list",
"of",
"columns"
] |
e0c1200792af8e6cea916e1999c73cf8408c6dd2
|
https://github.com/lekoala/silverstripe-form-extras/blob/e0c1200792af8e6cea916e1999c73cf8408c6dd2/code/fields/TableField.php#L46-L83
|
228,962
|
cornernote/yii-audit-module
|
audit/components/AuditActiveRecord.php
|
AuditActiveRecord.getMetaData
|
public function getMetaData()
{
$metaData = parent::getMetaData();
if ($metaData)
return $metaData;
$className = get_class($this);
if (empty(self::$_md[$className])) { // override this from the parent to force it to get the new MetaData
self::$_md[$className] = null;
self::$_md[$className] = new CActiveRecordMetaData($this);
}
return self::$_md[$className];
}
|
php
|
public function getMetaData()
{
$metaData = parent::getMetaData();
if ($metaData)
return $metaData;
$className = get_class($this);
if (empty(self::$_md[$className])) { // override this from the parent to force it to get the new MetaData
self::$_md[$className] = null;
self::$_md[$className] = new CActiveRecordMetaData($this);
}
return self::$_md[$className];
}
|
[
"public",
"function",
"getMetaData",
"(",
")",
"{",
"$",
"metaData",
"=",
"parent",
"::",
"getMetaData",
"(",
")",
";",
"if",
"(",
"$",
"metaData",
")",
"return",
"$",
"metaData",
";",
"$",
"className",
"=",
"get_class",
"(",
"$",
"this",
")",
";",
"if",
"(",
"empty",
"(",
"self",
"::",
"$",
"_md",
"[",
"$",
"className",
"]",
")",
")",
"{",
"// override this from the parent to force it to get the new MetaData",
"self",
"::",
"$",
"_md",
"[",
"$",
"className",
"]",
"=",
"null",
";",
"self",
"::",
"$",
"_md",
"[",
"$",
"className",
"]",
"=",
"new",
"CActiveRecordMetaData",
"(",
"$",
"this",
")",
";",
"}",
"return",
"self",
"::",
"$",
"_md",
"[",
"$",
"className",
"]",
";",
"}"
] |
Returns the meta-data for this AR
@return CActiveRecordMetaData the meta for this AR class.
|
[
"Returns",
"the",
"meta",
"-",
"data",
"for",
"this",
"AR"
] |
07362f79741b5343d22bb9bb516d840072a097d4
|
https://github.com/cornernote/yii-audit-module/blob/07362f79741b5343d22bb9bb516d840072a097d4/audit/components/AuditActiveRecord.php#L47-L58
|
228,963
|
cornernote/yii-audit-module
|
audit/components/AuditActiveRecord.php
|
AuditActiveRecord.tableName
|
public function tableName()
{
$audit = Yii::app()->getModule('audit');
if (!empty($audit->modelMap[get_class($this)]['tableName']))
return $audit->modelMap[get_class($this)]['tableName'];
return strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', get_class($this)));
}
|
php
|
public function tableName()
{
$audit = Yii::app()->getModule('audit');
if (!empty($audit->modelMap[get_class($this)]['tableName']))
return $audit->modelMap[get_class($this)]['tableName'];
return strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', get_class($this)));
}
|
[
"public",
"function",
"tableName",
"(",
")",
"{",
"$",
"audit",
"=",
"Yii",
"::",
"app",
"(",
")",
"->",
"getModule",
"(",
"'audit'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"audit",
"->",
"modelMap",
"[",
"get_class",
"(",
"$",
"this",
")",
"]",
"[",
"'tableName'",
"]",
")",
")",
"return",
"$",
"audit",
"->",
"modelMap",
"[",
"get_class",
"(",
"$",
"this",
")",
"]",
"[",
"'tableName'",
"]",
";",
"return",
"strtolower",
"(",
"preg_replace",
"(",
"'/([a-z])([A-Z])/'",
",",
"'$1_$2'",
",",
"get_class",
"(",
"$",
"this",
")",
")",
")",
";",
"}"
] |
Guess the table name based on the class
@return string the associated database table name
|
[
"Guess",
"the",
"table",
"name",
"based",
"on",
"the",
"class"
] |
07362f79741b5343d22bb9bb516d840072a097d4
|
https://github.com/cornernote/yii-audit-module/blob/07362f79741b5343d22bb9bb516d840072a097d4/audit/components/AuditActiveRecord.php#L86-L92
|
228,964
|
Danzabar/phalcon-cli
|
src/Tasks/Helpers.php
|
Helpers.getRegisteredHelper
|
public function getRegisteredHelper($name)
{
if (array_key_exists($name, $this->helpers)) {
return $this->helpers[$name];
}
throw new Exceptions\RegisteredHelperClassNotFoundException($name);
}
|
php
|
public function getRegisteredHelper($name)
{
if (array_key_exists($name, $this->helpers)) {
return $this->helpers[$name];
}
throw new Exceptions\RegisteredHelperClassNotFoundException($name);
}
|
[
"public",
"function",
"getRegisteredHelper",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"helpers",
")",
")",
"{",
"return",
"$",
"this",
"->",
"helpers",
"[",
"$",
"name",
"]",
";",
"}",
"throw",
"new",
"Exceptions",
"\\",
"RegisteredHelperClassNotFoundException",
"(",
"$",
"name",
")",
";",
"}"
] |
Returns the class name specified against a registered helper class
@return String
|
[
"Returns",
"the",
"class",
"name",
"specified",
"against",
"a",
"registered",
"helper",
"class"
] |
0d6293d5d899158705f8e3a31886d176e595ee38
|
https://github.com/Danzabar/phalcon-cli/blob/0d6293d5d899158705f8e3a31886d176e595ee38/src/Tasks/Helpers.php#L66-L73
|
228,965
|
Danzabar/phalcon-cli
|
src/Tasks/Helpers.php
|
Helpers.load
|
public function load($name)
{
$helper = $this->getRegisteredHelper($name);
$reflection = new \ReflectionClass($helper);
$class = $reflection->newInstance($this->di);
return $class;
}
|
php
|
public function load($name)
{
$helper = $this->getRegisteredHelper($name);
$reflection = new \ReflectionClass($helper);
$class = $reflection->newInstance($this->di);
return $class;
}
|
[
"public",
"function",
"load",
"(",
"$",
"name",
")",
"{",
"$",
"helper",
"=",
"$",
"this",
"->",
"getRegisteredHelper",
"(",
"$",
"name",
")",
";",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"helper",
")",
";",
"$",
"class",
"=",
"$",
"reflection",
"->",
"newInstance",
"(",
"$",
"this",
"->",
"di",
")",
";",
"return",
"$",
"class",
";",
"}"
] |
Creates and returns an instance of the helper
@return Object
|
[
"Creates",
"and",
"returns",
"an",
"instance",
"of",
"the",
"helper"
] |
0d6293d5d899158705f8e3a31886d176e595ee38
|
https://github.com/Danzabar/phalcon-cli/blob/0d6293d5d899158705f8e3a31886d176e595ee38/src/Tasks/Helpers.php#L80-L88
|
228,966
|
slickframework/slick
|
src/Slick/Orm/Sql/Select.php
|
Select.all
|
public function all()
{
$events = $this->_entity->getEventManager();
$event = new SelectEvent(
[
'sqlQuery' => &$this,
'params' => [],
'action' => SelectEvent::FIND_ALL,
'singleItem' => false
]
);
$events->trigger(SelectEvent::BEFORE_SELECT, $this->_entity, $event);
$result = parent::all();
$event->data = $result;
$events->trigger(SelectEvent::AFTER_SELECT, $this->_entity, $event);
$class = $this->_entity->getClassName();
$recordList = new RecordList();
foreach ($event->data as $row) {
$recordList[] = new $class($row);
}
return $recordList;
}
|
php
|
public function all()
{
$events = $this->_entity->getEventManager();
$event = new SelectEvent(
[
'sqlQuery' => &$this,
'params' => [],
'action' => SelectEvent::FIND_ALL,
'singleItem' => false
]
);
$events->trigger(SelectEvent::BEFORE_SELECT, $this->_entity, $event);
$result = parent::all();
$event->data = $result;
$events->trigger(SelectEvent::AFTER_SELECT, $this->_entity, $event);
$class = $this->_entity->getClassName();
$recordList = new RecordList();
foreach ($event->data as $row) {
$recordList[] = new $class($row);
}
return $recordList;
}
|
[
"public",
"function",
"all",
"(",
")",
"{",
"$",
"events",
"=",
"$",
"this",
"->",
"_entity",
"->",
"getEventManager",
"(",
")",
";",
"$",
"event",
"=",
"new",
"SelectEvent",
"(",
"[",
"'sqlQuery'",
"=>",
"&",
"$",
"this",
",",
"'params'",
"=>",
"[",
"]",
",",
"'action'",
"=>",
"SelectEvent",
"::",
"FIND_ALL",
",",
"'singleItem'",
"=>",
"false",
"]",
")",
";",
"$",
"events",
"->",
"trigger",
"(",
"SelectEvent",
"::",
"BEFORE_SELECT",
",",
"$",
"this",
"->",
"_entity",
",",
"$",
"event",
")",
";",
"$",
"result",
"=",
"parent",
"::",
"all",
"(",
")",
";",
"$",
"event",
"->",
"data",
"=",
"$",
"result",
";",
"$",
"events",
"->",
"trigger",
"(",
"SelectEvent",
"::",
"AFTER_SELECT",
",",
"$",
"this",
"->",
"_entity",
",",
"$",
"event",
")",
";",
"$",
"class",
"=",
"$",
"this",
"->",
"_entity",
"->",
"getClassName",
"(",
")",
";",
"$",
"recordList",
"=",
"new",
"RecordList",
"(",
")",
";",
"foreach",
"(",
"$",
"event",
"->",
"data",
"as",
"$",
"row",
")",
"{",
"$",
"recordList",
"[",
"]",
"=",
"new",
"$",
"class",
"(",
"$",
"row",
")",
";",
"}",
"return",
"$",
"recordList",
";",
"}"
] |
Return all the records for the current query
@return \Slick\Database\RecordList|Entity[]
|
[
"Return",
"all",
"the",
"records",
"for",
"the",
"current",
"query"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Orm/Sql/Select.php#L53-L74
|
228,967
|
slickframework/slick
|
src/Slick/Orm/Sql/Select.php
|
Select.first
|
public function first()
{
$events = $this->_entity->getEventManager();
$event = new SelectEvent(
[
'sqlQuery' => &$this,
'params' => [],
'action' => SelectEvent::FIND_FIRST,
'singleItem' => true
]
);
$events->trigger(SelectEvent::BEFORE_SELECT, $this->_entity, $event);
$row = parent::first();
$event->data = $row;
$events->trigger(SelectEvent::AFTER_SELECT, $this->_entity, $event);
$class = $this->_entity->getClassName();
return new $class($row);
}
|
php
|
public function first()
{
$events = $this->_entity->getEventManager();
$event = new SelectEvent(
[
'sqlQuery' => &$this,
'params' => [],
'action' => SelectEvent::FIND_FIRST,
'singleItem' => true
]
);
$events->trigger(SelectEvent::BEFORE_SELECT, $this->_entity, $event);
$row = parent::first();
$event->data = $row;
$events->trigger(SelectEvent::AFTER_SELECT, $this->_entity, $event);
$class = $this->_entity->getClassName();
return new $class($row);
}
|
[
"public",
"function",
"first",
"(",
")",
"{",
"$",
"events",
"=",
"$",
"this",
"->",
"_entity",
"->",
"getEventManager",
"(",
")",
";",
"$",
"event",
"=",
"new",
"SelectEvent",
"(",
"[",
"'sqlQuery'",
"=>",
"&",
"$",
"this",
",",
"'params'",
"=>",
"[",
"]",
",",
"'action'",
"=>",
"SelectEvent",
"::",
"FIND_FIRST",
",",
"'singleItem'",
"=>",
"true",
"]",
")",
";",
"$",
"events",
"->",
"trigger",
"(",
"SelectEvent",
"::",
"BEFORE_SELECT",
",",
"$",
"this",
"->",
"_entity",
",",
"$",
"event",
")",
";",
"$",
"row",
"=",
"parent",
"::",
"first",
"(",
")",
";",
"$",
"event",
"->",
"data",
"=",
"$",
"row",
";",
"$",
"events",
"->",
"trigger",
"(",
"SelectEvent",
"::",
"AFTER_SELECT",
",",
"$",
"this",
"->",
"_entity",
",",
"$",
"event",
")",
";",
"$",
"class",
"=",
"$",
"this",
"->",
"_entity",
"->",
"getClassName",
"(",
")",
";",
"return",
"new",
"$",
"class",
"(",
"$",
"row",
")",
";",
"}"
] |
Returns the first record for the current query
@return Entity
|
[
"Returns",
"the",
"first",
"record",
"for",
"the",
"current",
"query"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Orm/Sql/Select.php#L81-L98
|
228,968
|
slickframework/slick
|
src/Slick/Form/Template/AbstractTemplate.php
|
AbstractTemplate.getTemplate
|
public function getTemplate()
{
if (is_null($this->_template)) {
Template::appendPath(dirname(__FILE__).'/Views');
$temp = new Template();
$this->_template = $temp->initialize();
}
return $this->_template;
}
|
php
|
public function getTemplate()
{
if (is_null($this->_template)) {
Template::appendPath(dirname(__FILE__).'/Views');
$temp = new Template();
$this->_template = $temp->initialize();
}
return $this->_template;
}
|
[
"public",
"function",
"getTemplate",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_template",
")",
")",
"{",
"Template",
"::",
"appendPath",
"(",
"dirname",
"(",
"__FILE__",
")",
".",
"'/Views'",
")",
";",
"$",
"temp",
"=",
"new",
"Template",
"(",
")",
";",
"$",
"this",
"->",
"_template",
"=",
"$",
"temp",
"->",
"initialize",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_template",
";",
"}"
] |
Returns current template interface
@return EngineInterface
|
[
"Returns",
"current",
"template",
"interface"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Form/Template/AbstractTemplate.php#L94-L102
|
228,969
|
Danzabar/phalcon-cli
|
src/Tasks/TaskPrepper.php
|
TaskPrepper.load
|
public function load($className)
{
// Create reflection
$this->reflection = new \ReflectionClass($className);
// Read annotations
$this->reader = $this->annotation->get($className);
// Save the class name
$this->className = $className;
return $this;
}
|
php
|
public function load($className)
{
// Create reflection
$this->reflection = new \ReflectionClass($className);
// Read annotations
$this->reader = $this->annotation->get($className);
// Save the class name
$this->className = $className;
return $this;
}
|
[
"public",
"function",
"load",
"(",
"$",
"className",
")",
"{",
"// Create reflection",
"$",
"this",
"->",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"className",
")",
";",
"// Read annotations",
"$",
"this",
"->",
"reader",
"=",
"$",
"this",
"->",
"annotation",
"->",
"get",
"(",
"$",
"className",
")",
";",
"// Save the class name",
"$",
"this",
"->",
"className",
"=",
"$",
"className",
";",
"return",
"$",
"this",
";",
"}"
] |
Loads the command and creates a reflection entity for it.
@return TaskPrepper
|
[
"Loads",
"the",
"command",
"and",
"creates",
"a",
"reflection",
"entity",
"for",
"it",
"."
] |
0d6293d5d899158705f8e3a31886d176e595ee38
|
https://github.com/Danzabar/phalcon-cli/blob/0d6293d5d899158705f8e3a31886d176e595ee38/src/Tasks/TaskPrepper.php#L94-L106
|
228,970
|
Danzabar/phalcon-cli
|
src/Tasks/TaskPrepper.php
|
TaskPrepper.describe
|
public function describe()
{
$methods = array();
$methodAnnotations = $this->reader->getMethodsAnnotations();
foreach ($this->reflection->getMethods() as $method) {
$name = $method->getName();
if (isset($methodAnnotations[$name])) {
if ($methodAnnotations[$name]->has('Action') || $methodAnnotations[$name]->has('action')) {
$methods[] = $method->getName();
}
}
}
$name = $this->className;
$description = '';
if ($this->reflection->hasProperty('name')) {
$prop = $this->reflection->getProperty('name');
$prop->setAccessible(true);
$name = $prop->getValue($this->reflection->newInstance());
}
if ($this->reflection->hasProperty('description')) {
$prop = $this->reflection->getProperty('description');
$prop->setAccessible(true);
$description = $prop->getValue($this->reflection->newInstance());
}
return array(
'name' => $name,
'description' => $description,
'class' => $this->className,
'actions' => $methods
);
}
|
php
|
public function describe()
{
$methods = array();
$methodAnnotations = $this->reader->getMethodsAnnotations();
foreach ($this->reflection->getMethods() as $method) {
$name = $method->getName();
if (isset($methodAnnotations[$name])) {
if ($methodAnnotations[$name]->has('Action') || $methodAnnotations[$name]->has('action')) {
$methods[] = $method->getName();
}
}
}
$name = $this->className;
$description = '';
if ($this->reflection->hasProperty('name')) {
$prop = $this->reflection->getProperty('name');
$prop->setAccessible(true);
$name = $prop->getValue($this->reflection->newInstance());
}
if ($this->reflection->hasProperty('description')) {
$prop = $this->reflection->getProperty('description');
$prop->setAccessible(true);
$description = $prop->getValue($this->reflection->newInstance());
}
return array(
'name' => $name,
'description' => $description,
'class' => $this->className,
'actions' => $methods
);
}
|
[
"public",
"function",
"describe",
"(",
")",
"{",
"$",
"methods",
"=",
"array",
"(",
")",
";",
"$",
"methodAnnotations",
"=",
"$",
"this",
"->",
"reader",
"->",
"getMethodsAnnotations",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"reflection",
"->",
"getMethods",
"(",
")",
"as",
"$",
"method",
")",
"{",
"$",
"name",
"=",
"$",
"method",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"methodAnnotations",
"[",
"$",
"name",
"]",
")",
")",
"{",
"if",
"(",
"$",
"methodAnnotations",
"[",
"$",
"name",
"]",
"->",
"has",
"(",
"'Action'",
")",
"||",
"$",
"methodAnnotations",
"[",
"$",
"name",
"]",
"->",
"has",
"(",
"'action'",
")",
")",
"{",
"$",
"methods",
"[",
"]",
"=",
"$",
"method",
"->",
"getName",
"(",
")",
";",
"}",
"}",
"}",
"$",
"name",
"=",
"$",
"this",
"->",
"className",
";",
"$",
"description",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"reflection",
"->",
"hasProperty",
"(",
"'name'",
")",
")",
"{",
"$",
"prop",
"=",
"$",
"this",
"->",
"reflection",
"->",
"getProperty",
"(",
"'name'",
")",
";",
"$",
"prop",
"->",
"setAccessible",
"(",
"true",
")",
";",
"$",
"name",
"=",
"$",
"prop",
"->",
"getValue",
"(",
"$",
"this",
"->",
"reflection",
"->",
"newInstance",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"reflection",
"->",
"hasProperty",
"(",
"'description'",
")",
")",
"{",
"$",
"prop",
"=",
"$",
"this",
"->",
"reflection",
"->",
"getProperty",
"(",
"'description'",
")",
";",
"$",
"prop",
"->",
"setAccessible",
"(",
"true",
")",
";",
"$",
"description",
"=",
"$",
"prop",
"->",
"getValue",
"(",
"$",
"this",
"->",
"reflection",
"->",
"newInstance",
"(",
")",
")",
";",
"}",
"return",
"array",
"(",
"'name'",
"=>",
"$",
"name",
",",
"'description'",
"=>",
"$",
"description",
",",
"'class'",
"=>",
"$",
"this",
"->",
"className",
",",
"'actions'",
"=>",
"$",
"methods",
")",
";",
"}"
] |
Describes a task for the library
@return Array
|
[
"Describes",
"a",
"task",
"for",
"the",
"library"
] |
0d6293d5d899158705f8e3a31886d176e595ee38
|
https://github.com/Danzabar/phalcon-cli/blob/0d6293d5d899158705f8e3a31886d176e595ee38/src/Tasks/TaskPrepper.php#L113-L149
|
228,971
|
Danzabar/phalcon-cli
|
src/Tasks/TaskPrepper.php
|
TaskPrepper.prep
|
public function prep($action = null)
{
$method = $this->getSetupMethod($action);
if (!is_null($method)) {
$method->invokeArgs($this->reflection->newInstance(), array('action' => $action));
}
$this->sortParams();
}
|
php
|
public function prep($action = null)
{
$method = $this->getSetupMethod($action);
if (!is_null($method)) {
$method->invokeArgs($this->reflection->newInstance(), array('action' => $action));
}
$this->sortParams();
}
|
[
"public",
"function",
"prep",
"(",
"$",
"action",
"=",
"null",
")",
"{",
"$",
"method",
"=",
"$",
"this",
"->",
"getSetupMethod",
"(",
"$",
"action",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"method",
")",
")",
"{",
"$",
"method",
"->",
"invokeArgs",
"(",
"$",
"this",
"->",
"reflection",
"->",
"newInstance",
"(",
")",
",",
"array",
"(",
"'action'",
"=>",
"$",
"action",
")",
")",
";",
"}",
"$",
"this",
"->",
"sortParams",
"(",
")",
";",
"}"
] |
Looks for defined arguments and options and validates them
@return void
|
[
"Looks",
"for",
"defined",
"arguments",
"and",
"options",
"and",
"validates",
"them"
] |
0d6293d5d899158705f8e3a31886d176e595ee38
|
https://github.com/Danzabar/phalcon-cli/blob/0d6293d5d899158705f8e3a31886d176e595ee38/src/Tasks/TaskPrepper.php#L156-L165
|
228,972
|
Danzabar/phalcon-cli
|
src/Tasks/TaskPrepper.php
|
TaskPrepper.getSetupMethod
|
public function getSetupMethod($action)
{
if ($this->reflection->hasMethod('setup'.ucwords($action))) {
return $this->reflection->getMethod('setup'.ucwords($action));
} elseif ($this->reflection->hasMethod('setup')) {
return $this->reflection->getMethod('setup');
}
return null;
}
|
php
|
public function getSetupMethod($action)
{
if ($this->reflection->hasMethod('setup'.ucwords($action))) {
return $this->reflection->getMethod('setup'.ucwords($action));
} elseif ($this->reflection->hasMethod('setup')) {
return $this->reflection->getMethod('setup');
}
return null;
}
|
[
"public",
"function",
"getSetupMethod",
"(",
"$",
"action",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"reflection",
"->",
"hasMethod",
"(",
"'setup'",
".",
"ucwords",
"(",
"$",
"action",
")",
")",
")",
"{",
"return",
"$",
"this",
"->",
"reflection",
"->",
"getMethod",
"(",
"'setup'",
".",
"ucwords",
"(",
"$",
"action",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"reflection",
"->",
"hasMethod",
"(",
"'setup'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"reflection",
"->",
"getMethod",
"(",
"'setup'",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Gets the setup method used by the task
@return ReflectionMethod|NULL
|
[
"Gets",
"the",
"setup",
"method",
"used",
"by",
"the",
"task"
] |
0d6293d5d899158705f8e3a31886d176e595ee38
|
https://github.com/Danzabar/phalcon-cli/blob/0d6293d5d899158705f8e3a31886d176e595ee38/src/Tasks/TaskPrepper.php#L172-L182
|
228,973
|
Danzabar/phalcon-cli
|
src/Tasks/TaskPrepper.php
|
TaskPrepper.sortArguments
|
public function sortArguments()
{
$arguments = array();
$expectedArguments = $this->di->get('argument')->getExpectedOrder();
foreach ($expectedArguments as $pos => $key) {
if (array_key_exists($pos, $this->arguments)) {
$arguments[$key] = $this->di->get('argument')->validate($key, $this->arguments[$pos]);
} else {
$this->di->get('argument')->validate($key, null);
}
}
$this->di->get('argument')->load($arguments);
}
|
php
|
public function sortArguments()
{
$arguments = array();
$expectedArguments = $this->di->get('argument')->getExpectedOrder();
foreach ($expectedArguments as $pos => $key) {
if (array_key_exists($pos, $this->arguments)) {
$arguments[$key] = $this->di->get('argument')->validate($key, $this->arguments[$pos]);
} else {
$this->di->get('argument')->validate($key, null);
}
}
$this->di->get('argument')->load($arguments);
}
|
[
"public",
"function",
"sortArguments",
"(",
")",
"{",
"$",
"arguments",
"=",
"array",
"(",
")",
";",
"$",
"expectedArguments",
"=",
"$",
"this",
"->",
"di",
"->",
"get",
"(",
"'argument'",
")",
"->",
"getExpectedOrder",
"(",
")",
";",
"foreach",
"(",
"$",
"expectedArguments",
"as",
"$",
"pos",
"=>",
"$",
"key",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"pos",
",",
"$",
"this",
"->",
"arguments",
")",
")",
"{",
"$",
"arguments",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"di",
"->",
"get",
"(",
"'argument'",
")",
"->",
"validate",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"arguments",
"[",
"$",
"pos",
"]",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"di",
"->",
"get",
"(",
"'argument'",
")",
"->",
"validate",
"(",
"$",
"key",
",",
"null",
")",
";",
"}",
"}",
"$",
"this",
"->",
"di",
"->",
"get",
"(",
"'argument'",
")",
"->",
"load",
"(",
"$",
"arguments",
")",
";",
"}"
] |
Sorts out arguments into their correct orders
@return void
|
[
"Sorts",
"out",
"arguments",
"into",
"their",
"correct",
"orders"
] |
0d6293d5d899158705f8e3a31886d176e595ee38
|
https://github.com/Danzabar/phalcon-cli/blob/0d6293d5d899158705f8e3a31886d176e595ee38/src/Tasks/TaskPrepper.php#L201-L216
|
228,974
|
Danzabar/phalcon-cli
|
src/Tasks/TaskPrepper.php
|
TaskPrepper.sortOptions
|
public function sortOptions()
{
$options = array();
$expectedOptions = $this->di->get('option')->getExpectedOrder();
foreach ($expectedOptions as $pos => $key) {
if (array_key_exists($pos, $this->options)) {
$options[$key] = $this->di->get('option')->validate($key, $this->options[$pos]);
} else {
$this->di->get('option')->validate($key, null);
}
}
$this->di->get('option')->load($options);
}
|
php
|
public function sortOptions()
{
$options = array();
$expectedOptions = $this->di->get('option')->getExpectedOrder();
foreach ($expectedOptions as $pos => $key) {
if (array_key_exists($pos, $this->options)) {
$options[$key] = $this->di->get('option')->validate($key, $this->options[$pos]);
} else {
$this->di->get('option')->validate($key, null);
}
}
$this->di->get('option')->load($options);
}
|
[
"public",
"function",
"sortOptions",
"(",
")",
"{",
"$",
"options",
"=",
"array",
"(",
")",
";",
"$",
"expectedOptions",
"=",
"$",
"this",
"->",
"di",
"->",
"get",
"(",
"'option'",
")",
"->",
"getExpectedOrder",
"(",
")",
";",
"foreach",
"(",
"$",
"expectedOptions",
"as",
"$",
"pos",
"=>",
"$",
"key",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"pos",
",",
"$",
"this",
"->",
"options",
")",
")",
"{",
"$",
"options",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"di",
"->",
"get",
"(",
"'option'",
")",
"->",
"validate",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"options",
"[",
"$",
"pos",
"]",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"di",
"->",
"get",
"(",
"'option'",
")",
"->",
"validate",
"(",
"$",
"key",
",",
"null",
")",
";",
"}",
"}",
"$",
"this",
"->",
"di",
"->",
"get",
"(",
"'option'",
")",
"->",
"load",
"(",
"$",
"options",
")",
";",
"}"
] |
Sorts out options into correct orders
@return void
|
[
"Sorts",
"out",
"options",
"into",
"correct",
"orders"
] |
0d6293d5d899158705f8e3a31886d176e595ee38
|
https://github.com/Danzabar/phalcon-cli/blob/0d6293d5d899158705f8e3a31886d176e595ee38/src/Tasks/TaskPrepper.php#L223-L238
|
228,975
|
Danzabar/phalcon-cli
|
src/Tasks/TaskPrepper.php
|
TaskPrepper.loadParams
|
public function loadParams(array $params)
{
$this->arguments = array();
$this->options = array();
foreach ($params as $param) {
if (strpos($param, '-') !== false) {
$this->options[] = $this->extractOption($param);
} else {
$this->arguments[] = $param;
}
}
return $this;
}
|
php
|
public function loadParams(array $params)
{
$this->arguments = array();
$this->options = array();
foreach ($params as $param) {
if (strpos($param, '-') !== false) {
$this->options[] = $this->extractOption($param);
} else {
$this->arguments[] = $param;
}
}
return $this;
}
|
[
"public",
"function",
"loadParams",
"(",
"array",
"$",
"params",
")",
"{",
"$",
"this",
"->",
"arguments",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"options",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"params",
"as",
"$",
"param",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"param",
",",
"'-'",
")",
"!==",
"false",
")",
"{",
"$",
"this",
"->",
"options",
"[",
"]",
"=",
"$",
"this",
"->",
"extractOption",
"(",
"$",
"param",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"arguments",
"[",
"]",
"=",
"$",
"param",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Loads params and splits them into arguments and options
@return void
|
[
"Loads",
"params",
"and",
"splits",
"them",
"into",
"arguments",
"and",
"options"
] |
0d6293d5d899158705f8e3a31886d176e595ee38
|
https://github.com/Danzabar/phalcon-cli/blob/0d6293d5d899158705f8e3a31886d176e595ee38/src/Tasks/TaskPrepper.php#L245-L259
|
228,976
|
Danzabar/phalcon-cli
|
src/Tasks/TaskPrepper.php
|
TaskPrepper.extractOption
|
public function extractOption($str)
{
// If this has an = it has a value, else its a flag.
if (strpos($str, '=')) {
$extraction = explode('=', $str);
return trim(str_replace(array('\'', '"'), '', $extraction[1]));
}
return true;
}
|
php
|
public function extractOption($str)
{
// If this has an = it has a value, else its a flag.
if (strpos($str, '=')) {
$extraction = explode('=', $str);
return trim(str_replace(array('\'', '"'), '', $extraction[1]));
}
return true;
}
|
[
"public",
"function",
"extractOption",
"(",
"$",
"str",
")",
"{",
"// If this has an = it has a value, else its a flag.",
"if",
"(",
"strpos",
"(",
"$",
"str",
",",
"'='",
")",
")",
"{",
"$",
"extraction",
"=",
"explode",
"(",
"'='",
",",
"$",
"str",
")",
";",
"return",
"trim",
"(",
"str_replace",
"(",
"array",
"(",
"'\\''",
",",
"'\"'",
")",
",",
"''",
",",
"$",
"extraction",
"[",
"1",
"]",
")",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
extracts the option value from an option, or boolean
@return String|Boolean
|
[
"extracts",
"the",
"option",
"value",
"from",
"an",
"option",
"or",
"boolean"
] |
0d6293d5d899158705f8e3a31886d176e595ee38
|
https://github.com/Danzabar/phalcon-cli/blob/0d6293d5d899158705f8e3a31886d176e595ee38/src/Tasks/TaskPrepper.php#L266-L276
|
228,977
|
slickframework/slick
|
src/Slick/Mvc/Model/Manager.php
|
Manager.get
|
public function get(SlickOrmDescriptor $descriptor)
{
$name = $descriptor->getEntity()->getClassName();
if (!isset($this->_models[$name])) {
$this->_models[$name] = new Descriptor(
['descriptor' => $descriptor]
);
}
return $this->_models[$name];
}
|
php
|
public function get(SlickOrmDescriptor $descriptor)
{
$name = $descriptor->getEntity()->getClassName();
if (!isset($this->_models[$name])) {
$this->_models[$name] = new Descriptor(
['descriptor' => $descriptor]
);
}
return $this->_models[$name];
}
|
[
"public",
"function",
"get",
"(",
"SlickOrmDescriptor",
"$",
"descriptor",
")",
"{",
"$",
"name",
"=",
"$",
"descriptor",
"->",
"getEntity",
"(",
")",
"->",
"getClassName",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_models",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"_models",
"[",
"$",
"name",
"]",
"=",
"new",
"Descriptor",
"(",
"[",
"'descriptor'",
"=>",
"$",
"descriptor",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_models",
"[",
"$",
"name",
"]",
";",
"}"
] |
Return a model descriptor for given entity descriptor
@param SlickOrmDescriptor $descriptor
@return \Slick\Mvc\Model\Descriptor
|
[
"Return",
"a",
"model",
"descriptor",
"for",
"given",
"entity",
"descriptor"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Mvc/Model/Manager.php#L53-L62
|
228,978
|
slickframework/slick
|
src/Slick/FileSystem/Node.php
|
Node.delete
|
public function delete()
{
if ($this->details->isDir()) {
return @rmdir($this->details->getRealPath());
}
return @unlink($this->details->getRealPath());
}
|
php
|
public function delete()
{
if ($this->details->isDir()) {
return @rmdir($this->details->getRealPath());
}
return @unlink($this->details->getRealPath());
}
|
[
"public",
"function",
"delete",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"details",
"->",
"isDir",
"(",
")",
")",
"{",
"return",
"@",
"rmdir",
"(",
"$",
"this",
"->",
"details",
"->",
"getRealPath",
"(",
")",
")",
";",
"}",
"return",
"@",
"unlink",
"(",
"$",
"this",
"->",
"details",
"->",
"getRealPath",
"(",
")",
")",
";",
"}"
] |
Deletes current node.
@return boolean True if current node was deleted successfully.
|
[
"Deletes",
"current",
"node",
"."
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/FileSystem/Node.php#L45-L51
|
228,979
|
slickframework/slick
|
src/Slick/Di/Definition/ObjectDefinition.php
|
ObjectDefinition.getMethod
|
public function getMethod($name)
{
return (isset($this->_methods[$name])) ? $this->_methods[$name] : null;
}
|
php
|
public function getMethod($name)
{
return (isset($this->_methods[$name])) ? $this->_methods[$name] : null;
}
|
[
"public",
"function",
"getMethod",
"(",
"$",
"name",
")",
"{",
"return",
"(",
"isset",
"(",
"$",
"this",
"->",
"_methods",
"[",
"$",
"name",
"]",
")",
")",
"?",
"$",
"this",
"->",
"_methods",
"[",
"$",
"name",
"]",
":",
"null",
";",
"}"
] |
Returns the method with provided name
@param string $name
@return null|MethodInjection
|
[
"Returns",
"the",
"method",
"with",
"provided",
"name"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Di/Definition/ObjectDefinition.php#L195-L198
|
228,980
|
laravelcity/laravel-categories
|
src/Database/Migrations/2017_09_07_095956_create_table_categories.php
|
CreateTableCategories.makeOtherFields
|
public function makeOtherFields (Blueprint $table)
{
if (count(config('categories.other_fields')) > 0) {
foreach (config('categories.other_fields') as $filed) {
if (isset($filed['values']) && $filed['values'] != null) {
if (isset($filed['nullable']) && $filed['nullable'] != false)
$table->{$filed['type']}($filed['column'] , $filed['values'])->default($filed['default'])->nullable();
else
$table->{$filed['type']}($filed['column'] , $filed['values'])->default($filed['default']);
} else {
if (isset($filed['nullable']) && $filed['nullable'] != false)
$table->{$filed['type']}($filed['column'])->default($filed['default'])->nullable();
else
$table->{$filed['type']}($filed['column'])->default($filed['default']);
}
}
}
}
|
php
|
public function makeOtherFields (Blueprint $table)
{
if (count(config('categories.other_fields')) > 0) {
foreach (config('categories.other_fields') as $filed) {
if (isset($filed['values']) && $filed['values'] != null) {
if (isset($filed['nullable']) && $filed['nullable'] != false)
$table->{$filed['type']}($filed['column'] , $filed['values'])->default($filed['default'])->nullable();
else
$table->{$filed['type']}($filed['column'] , $filed['values'])->default($filed['default']);
} else {
if (isset($filed['nullable']) && $filed['nullable'] != false)
$table->{$filed['type']}($filed['column'])->default($filed['default'])->nullable();
else
$table->{$filed['type']}($filed['column'])->default($filed['default']);
}
}
}
}
|
[
"public",
"function",
"makeOtherFields",
"(",
"Blueprint",
"$",
"table",
")",
"{",
"if",
"(",
"count",
"(",
"config",
"(",
"'categories.other_fields'",
")",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"config",
"(",
"'categories.other_fields'",
")",
"as",
"$",
"filed",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"filed",
"[",
"'values'",
"]",
")",
"&&",
"$",
"filed",
"[",
"'values'",
"]",
"!=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"filed",
"[",
"'nullable'",
"]",
")",
"&&",
"$",
"filed",
"[",
"'nullable'",
"]",
"!=",
"false",
")",
"$",
"table",
"->",
"{",
"$",
"filed",
"[",
"'type'",
"]",
"}",
"(",
"$",
"filed",
"[",
"'column'",
"]",
",",
"$",
"filed",
"[",
"'values'",
"]",
")",
"->",
"default",
"(",
"$",
"filed",
"[",
"'default'",
"]",
")",
"->",
"nullable",
"(",
")",
";",
"else",
"$",
"table",
"->",
"{",
"$",
"filed",
"[",
"'type'",
"]",
"}",
"(",
"$",
"filed",
"[",
"'column'",
"]",
",",
"$",
"filed",
"[",
"'values'",
"]",
")",
"->",
"default",
"(",
"$",
"filed",
"[",
"'default'",
"]",
")",
";",
"}",
"else",
"{",
"if",
"(",
"isset",
"(",
"$",
"filed",
"[",
"'nullable'",
"]",
")",
"&&",
"$",
"filed",
"[",
"'nullable'",
"]",
"!=",
"false",
")",
"$",
"table",
"->",
"{",
"$",
"filed",
"[",
"'type'",
"]",
"}",
"(",
"$",
"filed",
"[",
"'column'",
"]",
")",
"->",
"default",
"(",
"$",
"filed",
"[",
"'default'",
"]",
")",
"->",
"nullable",
"(",
")",
";",
"else",
"$",
"table",
"->",
"{",
"$",
"filed",
"[",
"'type'",
"]",
"}",
"(",
"$",
"filed",
"[",
"'column'",
"]",
")",
"->",
"default",
"(",
"$",
"filed",
"[",
"'default'",
"]",
")",
";",
"}",
"}",
"}",
"}"
] |
set new fields to category table
|
[
"set",
"new",
"fields",
"to",
"category",
"table"
] |
b5c1baf8cbb51377fef090fc9ddaa0946bf42a68
|
https://github.com/laravelcity/laravel-categories/blob/b5c1baf8cbb51377fef090fc9ddaa0946bf42a68/src/Database/Migrations/2017_09_07_095956_create_table_categories.php#L68-L90
|
228,981
|
slickframework/slick
|
src/Slick/Cache/Driver/AbstractDriver.php
|
AbstractDriver.getKeys
|
public function getKeys($pattern = null)
{
$keys = $this->get('__stored_keys__', []);
if (is_null($pattern)) {
return $keys;
}
$matches = [];
$pattern = $this->_normalizePattern($pattern);
foreach ($keys as $key) {
if (preg_match($pattern, $key)) {
$matches[] = $key;
}
}
return $matches;
}
|
php
|
public function getKeys($pattern = null)
{
$keys = $this->get('__stored_keys__', []);
if (is_null($pattern)) {
return $keys;
}
$matches = [];
$pattern = $this->_normalizePattern($pattern);
foreach ($keys as $key) {
if (preg_match($pattern, $key)) {
$matches[] = $key;
}
}
return $matches;
}
|
[
"public",
"function",
"getKeys",
"(",
"$",
"pattern",
"=",
"null",
")",
"{",
"$",
"keys",
"=",
"$",
"this",
"->",
"get",
"(",
"'__stored_keys__'",
",",
"[",
"]",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"pattern",
")",
")",
"{",
"return",
"$",
"keys",
";",
"}",
"$",
"matches",
"=",
"[",
"]",
";",
"$",
"pattern",
"=",
"$",
"this",
"->",
"_normalizePattern",
"(",
"$",
"pattern",
")",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"key",
")",
")",
"{",
"$",
"matches",
"[",
"]",
"=",
"$",
"key",
";",
"}",
"}",
"return",
"$",
"matches",
";",
"}"
] |
Return current keys in use
@param string|null $pattern
@return string[]
|
[
"Return",
"current",
"keys",
"in",
"use"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Cache/Driver/AbstractDriver.php#L60-L76
|
228,982
|
slickframework/slick
|
src/Slick/Cache/Driver/AbstractDriver.php
|
AbstractDriver._addKey
|
protected function _addKey($key)
{
if ($key == '__stored_keys__') {
return $this;
}
$keys = $this->get('__stored_keys__', []);
if (!in_array($key, $keys)) {
array_push($keys, $key);
}
$this->set('__stored_keys__', $keys, 24*60*60);
return $this;
}
|
php
|
protected function _addKey($key)
{
if ($key == '__stored_keys__') {
return $this;
}
$keys = $this->get('__stored_keys__', []);
if (!in_array($key, $keys)) {
array_push($keys, $key);
}
$this->set('__stored_keys__', $keys, 24*60*60);
return $this;
}
|
[
"protected",
"function",
"_addKey",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"key",
"==",
"'__stored_keys__'",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"keys",
"=",
"$",
"this",
"->",
"get",
"(",
"'__stored_keys__'",
",",
"[",
"]",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"key",
",",
"$",
"keys",
")",
")",
"{",
"array_push",
"(",
"$",
"keys",
",",
"$",
"key",
")",
";",
"}",
"$",
"this",
"->",
"set",
"(",
"'__stored_keys__'",
",",
"$",
"keys",
",",
"24",
"*",
"60",
"*",
"60",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds a key to the list of keys used
@param string $key
@return AbstractDriver A self instance for chain calls
|
[
"Adds",
"a",
"key",
"to",
"the",
"list",
"of",
"keys",
"used"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Cache/Driver/AbstractDriver.php#L85-L97
|
228,983
|
slickframework/slick
|
src/Slick/Database/Sql/Dialect/Standard/CreateTableSqlTemplate.php
|
CreateTableSqlTemplate._parseColumn
|
protected function _parseColumn(Column\ColumnInterface $column)
{
$method = static::$_columnMethods[get_class($column)];
return call_user_func_array([$this, $method], array($column));
}
|
php
|
protected function _parseColumn(Column\ColumnInterface $column)
{
$method = static::$_columnMethods[get_class($column)];
return call_user_func_array([$this, $method], array($column));
}
|
[
"protected",
"function",
"_parseColumn",
"(",
"Column",
"\\",
"ColumnInterface",
"$",
"column",
")",
"{",
"$",
"method",
"=",
"static",
"::",
"$",
"_columnMethods",
"[",
"get_class",
"(",
"$",
"column",
")",
"]",
";",
"return",
"call_user_func_array",
"(",
"[",
"$",
"this",
",",
"$",
"method",
"]",
",",
"array",
"(",
"$",
"column",
")",
")",
";",
"}"
] |
Parses a given column and returns the SQL statement for it
@param Column\ColumnInterface $column
@return string
|
[
"Parses",
"a",
"given",
"column",
"and",
"returns",
"the",
"SQL",
"statement",
"for",
"it"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Sql/Dialect/Standard/CreateTableSqlTemplate.php#L108-L112
|
228,984
|
slickframework/slick
|
src/Slick/Database/Sql/Dialect/Standard/CreateTableSqlTemplate.php
|
CreateTableSqlTemplate._parseConstraints
|
protected function _parseConstraints()
{
$parts = [];
foreach ($this->_sql->getConstraints() as $constraint) {
$cons = $this->_parseConstraint($constraint);
if ($cons) {
$parts[] = $cons;
}
}
return implode(', ', $parts);
}
|
php
|
protected function _parseConstraints()
{
$parts = [];
foreach ($this->_sql->getConstraints() as $constraint) {
$cons = $this->_parseConstraint($constraint);
if ($cons) {
$parts[] = $cons;
}
}
return implode(', ', $parts);
}
|
[
"protected",
"function",
"_parseConstraints",
"(",
")",
"{",
"$",
"parts",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"_sql",
"->",
"getConstraints",
"(",
")",
"as",
"$",
"constraint",
")",
"{",
"$",
"cons",
"=",
"$",
"this",
"->",
"_parseConstraint",
"(",
"$",
"constraint",
")",
";",
"if",
"(",
"$",
"cons",
")",
"{",
"$",
"parts",
"[",
"]",
"=",
"$",
"cons",
";",
"}",
"}",
"return",
"implode",
"(",
"', '",
",",
"$",
"parts",
")",
";",
"}"
] |
Parse constraint list for SQL create statement
@return string
|
[
"Parse",
"constraint",
"list",
"for",
"SQL",
"create",
"statement"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Sql/Dialect/Standard/CreateTableSqlTemplate.php#L119-L129
|
228,985
|
slickframework/slick
|
src/Slick/Database/Sql/Dialect/Standard/CreateTableSqlTemplate.php
|
CreateTableSqlTemplate._parseConstraint
|
protected function _parseConstraint(Constraint\ConstraintInterface $cons)
{
$method = static::$_constraintMethods[get_class($cons)];
return call_user_func_array([$this, $method], array($cons));
}
|
php
|
protected function _parseConstraint(Constraint\ConstraintInterface $cons)
{
$method = static::$_constraintMethods[get_class($cons)];
return call_user_func_array([$this, $method], array($cons));
}
|
[
"protected",
"function",
"_parseConstraint",
"(",
"Constraint",
"\\",
"ConstraintInterface",
"$",
"cons",
")",
"{",
"$",
"method",
"=",
"static",
"::",
"$",
"_constraintMethods",
"[",
"get_class",
"(",
"$",
"cons",
")",
"]",
";",
"return",
"call_user_func_array",
"(",
"[",
"$",
"this",
",",
"$",
"method",
"]",
",",
"array",
"(",
"$",
"cons",
")",
")",
";",
"}"
] |
Parses a given constraint and returns the SQL statement for it
@param Constraint\ConstraintInterface $cons
@return string
|
[
"Parses",
"a",
"given",
"constraint",
"and",
"returns",
"the",
"SQL",
"statement",
"for",
"it"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Sql/Dialect/Standard/CreateTableSqlTemplate.php#L137-L141
|
228,986
|
slickframework/slick
|
src/Slick/Database/Sql/Dialect/Standard/CreateTableSqlTemplate.php
|
CreateTableSqlTemplate._getFKConstraint
|
protected function _getFKConstraint(Constraint\ForeignKey $cons)
{
$onDelete = '';
if ($cons->getOnDelete()) {
$onDelete = " ON DELETE {$cons->getOnDelete()}";
}
$onUpdated = '';
if ($cons->getOnUpdate()) {
$onUpdated = " ON UPDATE {$cons->getOnUpdate()}";
}
return sprintf(
'CONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s(%s)%s%s',
$cons->getName(),
$cons->getColumn(),
$cons->getReferenceTable(),
$cons->getReferenceColumn(),
$onDelete,
$onUpdated
);
}
|
php
|
protected function _getFKConstraint(Constraint\ForeignKey $cons)
{
$onDelete = '';
if ($cons->getOnDelete()) {
$onDelete = " ON DELETE {$cons->getOnDelete()}";
}
$onUpdated = '';
if ($cons->getOnUpdate()) {
$onUpdated = " ON UPDATE {$cons->getOnUpdate()}";
}
return sprintf(
'CONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s(%s)%s%s',
$cons->getName(),
$cons->getColumn(),
$cons->getReferenceTable(),
$cons->getReferenceColumn(),
$onDelete,
$onUpdated
);
}
|
[
"protected",
"function",
"_getFKConstraint",
"(",
"Constraint",
"\\",
"ForeignKey",
"$",
"cons",
")",
"{",
"$",
"onDelete",
"=",
"''",
";",
"if",
"(",
"$",
"cons",
"->",
"getOnDelete",
"(",
")",
")",
"{",
"$",
"onDelete",
"=",
"\" ON DELETE {$cons->getOnDelete()}\"",
";",
"}",
"$",
"onUpdated",
"=",
"''",
";",
"if",
"(",
"$",
"cons",
"->",
"getOnUpdate",
"(",
")",
")",
"{",
"$",
"onUpdated",
"=",
"\" ON UPDATE {$cons->getOnUpdate()}\"",
";",
"}",
"return",
"sprintf",
"(",
"'CONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s(%s)%s%s'",
",",
"$",
"cons",
"->",
"getName",
"(",
")",
",",
"$",
"cons",
"->",
"getColumn",
"(",
")",
",",
"$",
"cons",
"->",
"getReferenceTable",
"(",
")",
",",
"$",
"cons",
"->",
"getReferenceColumn",
"(",
")",
",",
"$",
"onDelete",
",",
"$",
"onUpdated",
")",
";",
"}"
] |
Parse a Foreign Key constraint to its SQL representation
@param Constraint\ForeignKey $cons
@return string
|
[
"Parse",
"a",
"Foreign",
"Key",
"constraint",
"to",
"its",
"SQL",
"representation"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Sql/Dialect/Standard/CreateTableSqlTemplate.php#L149-L168
|
228,987
|
slickframework/slick
|
src/Slick/Database/Sql/Dialect/Standard/CreateTableSqlTemplate.php
|
CreateTableSqlTemplate._getBlobColumn
|
protected function _getBlobColumn(Column\Blob $column)
{
return sprintf(
'%s BLOB%s%s',
$column->getName(),
$this->_columnLength($column),
$this->_nullableColumn($column)
);
}
|
php
|
protected function _getBlobColumn(Column\Blob $column)
{
return sprintf(
'%s BLOB%s%s',
$column->getName(),
$this->_columnLength($column),
$this->_nullableColumn($column)
);
}
|
[
"protected",
"function",
"_getBlobColumn",
"(",
"Column",
"\\",
"Blob",
"$",
"column",
")",
"{",
"return",
"sprintf",
"(",
"'%s BLOB%s%s'",
",",
"$",
"column",
"->",
"getName",
"(",
")",
",",
"$",
"this",
"->",
"_columnLength",
"(",
"$",
"column",
")",
",",
"$",
"this",
"->",
"_nullableColumn",
"(",
"$",
"column",
")",
")",
";",
"}"
] |
Parses a Blob column to its SQL representation
@param Column\Blob $column
@return string
|
[
"Parses",
"a",
"Blob",
"column",
"to",
"its",
"SQL",
"representation"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Sql/Dialect/Standard/CreateTableSqlTemplate.php#L207-L215
|
228,988
|
slickframework/slick
|
src/Slick/Database/Sql/Dialect/Standard/CreateTableSqlTemplate.php
|
CreateTableSqlTemplate._getDateTimeColumn
|
protected function _getDateTimeColumn(Column\DateTime $column)
{
return sprintf(
'%s TIMESTAMP%s',
$column->getName(),
$this->_nullableColumn($column)
);
}
|
php
|
protected function _getDateTimeColumn(Column\DateTime $column)
{
return sprintf(
'%s TIMESTAMP%s',
$column->getName(),
$this->_nullableColumn($column)
);
}
|
[
"protected",
"function",
"_getDateTimeColumn",
"(",
"Column",
"\\",
"DateTime",
"$",
"column",
")",
"{",
"return",
"sprintf",
"(",
"'%s TIMESTAMP%s'",
",",
"$",
"column",
"->",
"getName",
"(",
")",
",",
"$",
"this",
"->",
"_nullableColumn",
"(",
"$",
"column",
")",
")",
";",
"}"
] |
Parses a DateTime column to its SQL representation
@param Column\DateTime $column
@return string
|
[
"Parses",
"a",
"DateTime",
"column",
"to",
"its",
"SQL",
"representation"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Sql/Dialect/Standard/CreateTableSqlTemplate.php#L223-L230
|
228,989
|
slickframework/slick
|
src/Slick/Database/Sql/Dialect/Standard/CreateTableSqlTemplate.php
|
CreateTableSqlTemplate._getFloatColumn
|
protected function _getFloatColumn(Column\Float $column)
{
if (is_null($column->getDecimal())) {
return sprintf(
'%s FLOAT(%s)',
$column->getName(),
$column->getDigits()
);
}
return sprintf(
'%s DECIMAL(%s, %s)',
$column->getName(),
$column->getDigits(),
$column->getDecimal()
);
}
|
php
|
protected function _getFloatColumn(Column\Float $column)
{
if (is_null($column->getDecimal())) {
return sprintf(
'%s FLOAT(%s)',
$column->getName(),
$column->getDigits()
);
}
return sprintf(
'%s DECIMAL(%s, %s)',
$column->getName(),
$column->getDigits(),
$column->getDecimal()
);
}
|
[
"protected",
"function",
"_getFloatColumn",
"(",
"Column",
"\\",
"Float",
"$",
"column",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"column",
"->",
"getDecimal",
"(",
")",
")",
")",
"{",
"return",
"sprintf",
"(",
"'%s FLOAT(%s)'",
",",
"$",
"column",
"->",
"getName",
"(",
")",
",",
"$",
"column",
"->",
"getDigits",
"(",
")",
")",
";",
"}",
"return",
"sprintf",
"(",
"'%s DECIMAL(%s, %s)'",
",",
"$",
"column",
"->",
"getName",
"(",
")",
",",
"$",
"column",
"->",
"getDigits",
"(",
")",
",",
"$",
"column",
"->",
"getDecimal",
"(",
")",
")",
";",
"}"
] |
Parses a Float column to its SQL representation
@param Column\Float $column
@return string
|
[
"Parses",
"a",
"Float",
"column",
"to",
"its",
"SQL",
"representation"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Sql/Dialect/Standard/CreateTableSqlTemplate.php#L238-L254
|
228,990
|
slickframework/slick
|
src/Slick/Database/Sql/Dialect/Standard/CreateTableSqlTemplate.php
|
CreateTableSqlTemplate._getVarcharColumn
|
protected function _getVarcharColumn(Column\Varchar $column)
{
return sprintf(
'%s VARCHAR%s NOT NULL',
$column->getName(),
$this->_columnLength($column)
);
}
|
php
|
protected function _getVarcharColumn(Column\Varchar $column)
{
return sprintf(
'%s VARCHAR%s NOT NULL',
$column->getName(),
$this->_columnLength($column)
);
}
|
[
"protected",
"function",
"_getVarcharColumn",
"(",
"Column",
"\\",
"Varchar",
"$",
"column",
")",
"{",
"return",
"sprintf",
"(",
"'%s VARCHAR%s NOT NULL'",
",",
"$",
"column",
"->",
"getName",
"(",
")",
",",
"$",
"this",
"->",
"_columnLength",
"(",
"$",
"column",
")",
")",
";",
"}"
] |
Parses a varchar column to its SQL representation
@param Column\Varchar $column
@return string
|
[
"Parses",
"a",
"varchar",
"column",
"to",
"its",
"SQL",
"representation"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Database/Sql/Dialect/Standard/CreateTableSqlTemplate.php#L276-L283
|
228,991
|
PrestaShop/decimal
|
src/Number.php
|
Number.getIntegerPart
|
public function getIntegerPart()
{
if ('0' === $this->coefficient) {
return $this->coefficient;
}
if (0 === $this->exponent) {
return $this->coefficient;
}
if ($this->exponent >= strlen($this->coefficient)) {
return '0';
}
return substr($this->coefficient, 0, -$this->exponent);
}
|
php
|
public function getIntegerPart()
{
if ('0' === $this->coefficient) {
return $this->coefficient;
}
if (0 === $this->exponent) {
return $this->coefficient;
}
if ($this->exponent >= strlen($this->coefficient)) {
return '0';
}
return substr($this->coefficient, 0, -$this->exponent);
}
|
[
"public",
"function",
"getIntegerPart",
"(",
")",
"{",
"if",
"(",
"'0'",
"===",
"$",
"this",
"->",
"coefficient",
")",
"{",
"return",
"$",
"this",
"->",
"coefficient",
";",
"}",
"if",
"(",
"0",
"===",
"$",
"this",
"->",
"exponent",
")",
"{",
"return",
"$",
"this",
"->",
"coefficient",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"exponent",
">=",
"strlen",
"(",
"$",
"this",
"->",
"coefficient",
")",
")",
"{",
"return",
"'0'",
";",
"}",
"return",
"substr",
"(",
"$",
"this",
"->",
"coefficient",
",",
"0",
",",
"-",
"$",
"this",
"->",
"exponent",
")",
";",
"}"
] |
Returns the integer part of the number.
Note that this does NOT include the sign.
@return string
|
[
"Returns",
"the",
"integer",
"part",
"of",
"the",
"number",
".",
"Note",
"that",
"this",
"does",
"NOT",
"include",
"the",
"sign",
"."
] |
42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f
|
https://github.com/PrestaShop/decimal/blob/42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f/src/Number.php#L89-L104
|
228,992
|
PrestaShop/decimal
|
src/Number.php
|
Number.getFractionalPart
|
public function getFractionalPart()
{
if (0 === $this->exponent || '0' === $this->coefficient) {
return '0';
}
if ($this->exponent > strlen($this->coefficient)) {
return str_pad($this->coefficient, $this->exponent, '0', STR_PAD_LEFT);
}
return substr($this->coefficient, -$this->exponent);
}
|
php
|
public function getFractionalPart()
{
if (0 === $this->exponent || '0' === $this->coefficient) {
return '0';
}
if ($this->exponent > strlen($this->coefficient)) {
return str_pad($this->coefficient, $this->exponent, '0', STR_PAD_LEFT);
}
return substr($this->coefficient, -$this->exponent);
}
|
[
"public",
"function",
"getFractionalPart",
"(",
")",
"{",
"if",
"(",
"0",
"===",
"$",
"this",
"->",
"exponent",
"||",
"'0'",
"===",
"$",
"this",
"->",
"coefficient",
")",
"{",
"return",
"'0'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"exponent",
">",
"strlen",
"(",
"$",
"this",
"->",
"coefficient",
")",
")",
"{",
"return",
"str_pad",
"(",
"$",
"this",
"->",
"coefficient",
",",
"$",
"this",
"->",
"exponent",
",",
"'0'",
",",
"STR_PAD_LEFT",
")",
";",
"}",
"return",
"substr",
"(",
"$",
"this",
"->",
"coefficient",
",",
"-",
"$",
"this",
"->",
"exponent",
")",
";",
"}"
] |
Returns the fractional part of the number.
Note that this does NOT include the sign.
@return string
|
[
"Returns",
"the",
"fractional",
"part",
"of",
"the",
"number",
".",
"Note",
"that",
"this",
"does",
"NOT",
"include",
"the",
"sign",
"."
] |
42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f
|
https://github.com/PrestaShop/decimal/blob/42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f/src/Number.php#L112-L123
|
228,993
|
PrestaShop/decimal
|
src/Number.php
|
Number.equals
|
public function equals(self $number)
{
return (
$this->isNegative === $number->isNegative
&& $this->coefficient === $number->getCoefficient()
&& $this->exponent === $number->getExponent()
);
}
|
php
|
public function equals(self $number)
{
return (
$this->isNegative === $number->isNegative
&& $this->coefficient === $number->getCoefficient()
&& $this->exponent === $number->getExponent()
);
}
|
[
"public",
"function",
"equals",
"(",
"self",
"$",
"number",
")",
"{",
"return",
"(",
"$",
"this",
"->",
"isNegative",
"===",
"$",
"number",
"->",
"isNegative",
"&&",
"$",
"this",
"->",
"coefficient",
"===",
"$",
"number",
"->",
"getCoefficient",
"(",
")",
"&&",
"$",
"this",
"->",
"exponent",
"===",
"$",
"number",
"->",
"getExponent",
"(",
")",
")",
";",
"}"
] |
Indicates if this number equals another one
@param self $number
@return bool
|
[
"Indicates",
"if",
"this",
"number",
"equals",
"another",
"one"
] |
42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f
|
https://github.com/PrestaShop/decimal/blob/42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f/src/Number.php#L424-L431
|
228,994
|
PrestaShop/decimal
|
src/Number.php
|
Number.initFromString
|
private function initFromString($number)
{
if (!preg_match("/^(?<sign>[-+])?(?<integerPart>\d+)(?:\.(?<fractionalPart>\d+))?$/", $number, $parts)) {
throw new \InvalidArgumentException(
sprintf('"%s" cannot be interpreted as a number', print_r($number, true))
);
}
$this->isNegative = ('-' === $parts['sign']);
// extract the integer part and remove leading zeroes and plus sign
$integerPart = ltrim($parts['integerPart'], '0');
$fractionalPart = '';
if (array_key_exists('fractionalPart', $parts)) {
// extract the fractional part and remove trailing zeroes
$fractionalPart = rtrim($parts['fractionalPart'], '0');
}
$this->exponent = strlen($fractionalPart);
$this->coefficient = $integerPart . $fractionalPart;
// when coefficient is '0' or a sequence of '0'
if ('' === $this->coefficient) {
$this->coefficient = '0';
}
}
|
php
|
private function initFromString($number)
{
if (!preg_match("/^(?<sign>[-+])?(?<integerPart>\d+)(?:\.(?<fractionalPart>\d+))?$/", $number, $parts)) {
throw new \InvalidArgumentException(
sprintf('"%s" cannot be interpreted as a number', print_r($number, true))
);
}
$this->isNegative = ('-' === $parts['sign']);
// extract the integer part and remove leading zeroes and plus sign
$integerPart = ltrim($parts['integerPart'], '0');
$fractionalPart = '';
if (array_key_exists('fractionalPart', $parts)) {
// extract the fractional part and remove trailing zeroes
$fractionalPart = rtrim($parts['fractionalPart'], '0');
}
$this->exponent = strlen($fractionalPart);
$this->coefficient = $integerPart . $fractionalPart;
// when coefficient is '0' or a sequence of '0'
if ('' === $this->coefficient) {
$this->coefficient = '0';
}
}
|
[
"private",
"function",
"initFromString",
"(",
"$",
"number",
")",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"\"/^(?<sign>[-+])?(?<integerPart>\\d+)(?:\\.(?<fractionalPart>\\d+))?$/\"",
",",
"$",
"number",
",",
"$",
"parts",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'\"%s\" cannot be interpreted as a number'",
",",
"print_r",
"(",
"$",
"number",
",",
"true",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"isNegative",
"=",
"(",
"'-'",
"===",
"$",
"parts",
"[",
"'sign'",
"]",
")",
";",
"// extract the integer part and remove leading zeroes and plus sign",
"$",
"integerPart",
"=",
"ltrim",
"(",
"$",
"parts",
"[",
"'integerPart'",
"]",
",",
"'0'",
")",
";",
"$",
"fractionalPart",
"=",
"''",
";",
"if",
"(",
"array_key_exists",
"(",
"'fractionalPart'",
",",
"$",
"parts",
")",
")",
"{",
"// extract the fractional part and remove trailing zeroes",
"$",
"fractionalPart",
"=",
"rtrim",
"(",
"$",
"parts",
"[",
"'fractionalPart'",
"]",
",",
"'0'",
")",
";",
"}",
"$",
"this",
"->",
"exponent",
"=",
"strlen",
"(",
"$",
"fractionalPart",
")",
";",
"$",
"this",
"->",
"coefficient",
"=",
"$",
"integerPart",
".",
"$",
"fractionalPart",
";",
"// when coefficient is '0' or a sequence of '0'",
"if",
"(",
"''",
"===",
"$",
"this",
"->",
"coefficient",
")",
"{",
"$",
"this",
"->",
"coefficient",
"=",
"'0'",
";",
"}",
"}"
] |
Initializes the number using a string
@param string $number
|
[
"Initializes",
"the",
"number",
"using",
"a",
"string"
] |
42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f
|
https://github.com/PrestaShop/decimal/blob/42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f/src/Number.php#L463-L489
|
228,995
|
PrestaShop/decimal
|
src/Number.php
|
Number.initFromScientificNotation
|
private function initFromScientificNotation($coefficient, $exponent)
{
if ($exponent < 0) {
throw new \InvalidArgumentException(
sprintf('Invalid value for exponent. Expected a positive integer or 0, but got "%s"', $coefficient)
);
}
if (!preg_match("/^(?<sign>[-+])?(?<integerPart>\d+)$/", $coefficient, $parts)) {
throw new \InvalidArgumentException(
sprintf('"%s" cannot be interpreted as a number', $coefficient)
);
}
$this->isNegative = ('-' === $parts['sign']);
$this->exponent = (int) $exponent;
// trim leading zeroes
$this->coefficient = ltrim($parts['integerPart'], '0');
// when coefficient is '0' or a sequence of '0'
if ('' === $this->coefficient) {
$this->exponent = 0;
$this->coefficient = '0';
return;
}
$this->removeTrailingZeroesIfNeeded();
}
|
php
|
private function initFromScientificNotation($coefficient, $exponent)
{
if ($exponent < 0) {
throw new \InvalidArgumentException(
sprintf('Invalid value for exponent. Expected a positive integer or 0, but got "%s"', $coefficient)
);
}
if (!preg_match("/^(?<sign>[-+])?(?<integerPart>\d+)$/", $coefficient, $parts)) {
throw new \InvalidArgumentException(
sprintf('"%s" cannot be interpreted as a number', $coefficient)
);
}
$this->isNegative = ('-' === $parts['sign']);
$this->exponent = (int) $exponent;
// trim leading zeroes
$this->coefficient = ltrim($parts['integerPart'], '0');
// when coefficient is '0' or a sequence of '0'
if ('' === $this->coefficient) {
$this->exponent = 0;
$this->coefficient = '0';
return;
}
$this->removeTrailingZeroesIfNeeded();
}
|
[
"private",
"function",
"initFromScientificNotation",
"(",
"$",
"coefficient",
",",
"$",
"exponent",
")",
"{",
"if",
"(",
"$",
"exponent",
"<",
"0",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Invalid value for exponent. Expected a positive integer or 0, but got \"%s\"'",
",",
"$",
"coefficient",
")",
")",
";",
"}",
"if",
"(",
"!",
"preg_match",
"(",
"\"/^(?<sign>[-+])?(?<integerPart>\\d+)$/\"",
",",
"$",
"coefficient",
",",
"$",
"parts",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'\"%s\" cannot be interpreted as a number'",
",",
"$",
"coefficient",
")",
")",
";",
"}",
"$",
"this",
"->",
"isNegative",
"=",
"(",
"'-'",
"===",
"$",
"parts",
"[",
"'sign'",
"]",
")",
";",
"$",
"this",
"->",
"exponent",
"=",
"(",
"int",
")",
"$",
"exponent",
";",
"// trim leading zeroes",
"$",
"this",
"->",
"coefficient",
"=",
"ltrim",
"(",
"$",
"parts",
"[",
"'integerPart'",
"]",
",",
"'0'",
")",
";",
"// when coefficient is '0' or a sequence of '0'",
"if",
"(",
"''",
"===",
"$",
"this",
"->",
"coefficient",
")",
"{",
"$",
"this",
"->",
"exponent",
"=",
"0",
";",
"$",
"this",
"->",
"coefficient",
"=",
"'0'",
";",
"return",
";",
"}",
"$",
"this",
"->",
"removeTrailingZeroesIfNeeded",
"(",
")",
";",
"}"
] |
Initializes the number using a coefficient and exponent
@param string $coefficient
@param int $exponent
|
[
"Initializes",
"the",
"number",
"using",
"a",
"coefficient",
"and",
"exponent"
] |
42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f
|
https://github.com/PrestaShop/decimal/blob/42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f/src/Number.php#L497-L524
|
228,996
|
PrestaShop/decimal
|
src/Number.php
|
Number.removeTrailingZeroesIfNeeded
|
private function removeTrailingZeroesIfNeeded()
{
$exponent = $this->getExponent();
$coefficient = $this->getCoefficient();
// trim trailing zeroes from the fractional part
// for example 1000e-1 => 100.0
if (0 < $exponent && '0' === substr($coefficient, -1)) {
$fractionalPart = $this->getFractionalPart();
$trailingZeroesToRemove = 0;
for ($i = $exponent - 1; $i >= 0; $i--) {
if ('0' !== $fractionalPart[$i]) {
break;
}
$trailingZeroesToRemove++;
}
if ($trailingZeroesToRemove > 0) {
$this->coefficient = substr($coefficient, 0, -$trailingZeroesToRemove);
$this->exponent = $exponent - $trailingZeroesToRemove;
}
}
}
|
php
|
private function removeTrailingZeroesIfNeeded()
{
$exponent = $this->getExponent();
$coefficient = $this->getCoefficient();
// trim trailing zeroes from the fractional part
// for example 1000e-1 => 100.0
if (0 < $exponent && '0' === substr($coefficient, -1)) {
$fractionalPart = $this->getFractionalPart();
$trailingZeroesToRemove = 0;
for ($i = $exponent - 1; $i >= 0; $i--) {
if ('0' !== $fractionalPart[$i]) {
break;
}
$trailingZeroesToRemove++;
}
if ($trailingZeroesToRemove > 0) {
$this->coefficient = substr($coefficient, 0, -$trailingZeroesToRemove);
$this->exponent = $exponent - $trailingZeroesToRemove;
}
}
}
|
[
"private",
"function",
"removeTrailingZeroesIfNeeded",
"(",
")",
"{",
"$",
"exponent",
"=",
"$",
"this",
"->",
"getExponent",
"(",
")",
";",
"$",
"coefficient",
"=",
"$",
"this",
"->",
"getCoefficient",
"(",
")",
";",
"// trim trailing zeroes from the fractional part",
"// for example 1000e-1 => 100.0",
"if",
"(",
"0",
"<",
"$",
"exponent",
"&&",
"'0'",
"===",
"substr",
"(",
"$",
"coefficient",
",",
"-",
"1",
")",
")",
"{",
"$",
"fractionalPart",
"=",
"$",
"this",
"->",
"getFractionalPart",
"(",
")",
";",
"$",
"trailingZeroesToRemove",
"=",
"0",
";",
"for",
"(",
"$",
"i",
"=",
"$",
"exponent",
"-",
"1",
";",
"$",
"i",
">=",
"0",
";",
"$",
"i",
"--",
")",
"{",
"if",
"(",
"'0'",
"!==",
"$",
"fractionalPart",
"[",
"$",
"i",
"]",
")",
"{",
"break",
";",
"}",
"$",
"trailingZeroesToRemove",
"++",
";",
"}",
"if",
"(",
"$",
"trailingZeroesToRemove",
">",
"0",
")",
"{",
"$",
"this",
"->",
"coefficient",
"=",
"substr",
"(",
"$",
"coefficient",
",",
"0",
",",
"-",
"$",
"trailingZeroesToRemove",
")",
";",
"$",
"this",
"->",
"exponent",
"=",
"$",
"exponent",
"-",
"$",
"trailingZeroesToRemove",
";",
"}",
"}",
"}"
] |
Removes trailing zeroes from the fractional part and adjusts the exponent accordingly
|
[
"Removes",
"trailing",
"zeroes",
"from",
"the",
"fractional",
"part",
"and",
"adjusts",
"the",
"exponent",
"accordingly"
] |
42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f
|
https://github.com/PrestaShop/decimal/blob/42e9bc8c2ec533dc2a247f9321b8f3ed55c5341f/src/Number.php#L529-L551
|
228,997
|
slickframework/slick
|
src/Slick/Mvc/Application.php
|
Application.getRouter
|
public function getRouter()
{
if (is_null($this->_router)) {
$this->_router = new Router($this);
}
return $this->_router;
}
|
php
|
public function getRouter()
{
if (is_null($this->_router)) {
$this->_router = new Router($this);
}
return $this->_router;
}
|
[
"public",
"function",
"getRouter",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_router",
")",
")",
"{",
"$",
"this",
"->",
"_router",
"=",
"new",
"Router",
"(",
"$",
"this",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_router",
";",
"}"
] |
Lazy loads the router object
@return Router
|
[
"Lazy",
"loads",
"the",
"router",
"object"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Mvc/Application.php#L217-L223
|
228,998
|
slickframework/slick
|
src/Slick/Mvc/Application.php
|
Application.setEventManager
|
public function setEventManager(EventManagerInterface $events)
{
$events->setIdentifiers(array(
__CLASS__,
get_class($this)
));
$events->setSharedManager(
$this->getContainer()->get("sharedEventManager")
);
$this->_events = $events;
return $this;
}
|
php
|
public function setEventManager(EventManagerInterface $events)
{
$events->setIdentifiers(array(
__CLASS__,
get_class($this)
));
$events->setSharedManager(
$this->getContainer()->get("sharedEventManager")
);
$this->_events = $events;
return $this;
}
|
[
"public",
"function",
"setEventManager",
"(",
"EventManagerInterface",
"$",
"events",
")",
"{",
"$",
"events",
"->",
"setIdentifiers",
"(",
"array",
"(",
"__CLASS__",
",",
"get_class",
"(",
"$",
"this",
")",
")",
")",
";",
"$",
"events",
"->",
"setSharedManager",
"(",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"get",
"(",
"\"sharedEventManager\"",
")",
")",
";",
"$",
"this",
"->",
"_events",
"=",
"$",
"events",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets event manager
@param EventManagerInterface $events
@return self
|
[
"Sets",
"event",
"manager"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Mvc/Application.php#L254-L265
|
228,999
|
slickframework/slick
|
src/Slick/Mvc/Application.php
|
Application.getConfiguration
|
public function getConfiguration()
{
if (is_null($this->_configuration)) {
$config = $this->getContainer()->get('configuration');
$this->_configuration = $config;
}
return $this->_configuration;
}
|
php
|
public function getConfiguration()
{
if (is_null($this->_configuration)) {
$config = $this->getContainer()->get('configuration');
$this->_configuration = $config;
}
return $this->_configuration;
}
|
[
"public",
"function",
"getConfiguration",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_configuration",
")",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'configuration'",
")",
";",
"$",
"this",
"->",
"_configuration",
"=",
"$",
"config",
";",
"}",
"return",
"$",
"this",
"->",
"_configuration",
";",
"}"
] |
Returns the configuration settings
@return DriverInterface
|
[
"Returns",
"the",
"configuration",
"settings"
] |
77f56b81020ce8c10f25f7d918661ccd9a918a37
|
https://github.com/slickframework/slick/blob/77f56b81020ce8c10f25f7d918661ccd9a918a37/src/Slick/Mvc/Application.php#L285-L292
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.