repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_code_tokens
sequencelengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
sequencelengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
barebone-php/barebone-core | lib/Router.php | Router.map | public static function map($methods, $path, $callback)
{
foreach ($methods as $httpMethod) {
self::instance()->addRoute(
$httpMethod, $path, self::callback($callback)
);
}
} | php | public static function map($methods, $path, $callback)
{
foreach ($methods as $httpMethod) {
self::instance()->addRoute(
$httpMethod, $path, self::callback($callback)
);
}
} | [
"public",
"static",
"function",
"map",
"(",
"$",
"methods",
",",
"$",
"path",
",",
"$",
"callback",
")",
"{",
"foreach",
"(",
"$",
"methods",
"as",
"$",
"httpMethod",
")",
"{",
"self",
"::",
"instance",
"(",
")",
"->",
"addRoute",
"(",
"$",
"httpMethod",
",",
"$",
"path",
",",
"self",
"::",
"callback",
"(",
"$",
"callback",
")",
")",
";",
"}",
"}"
] | Route that handles all HTTP request methods
@param array $methods List of HTTP methods to support, i.e: [GET,POST,EDIT]
@param string $path URL segments and placeholders
@param mixed $callback "MyController:method" or array(class,method)
@return void | [
"Route",
"that",
"handles",
"all",
"HTTP",
"request",
"methods"
] | train | https://github.com/barebone-php/barebone-core/blob/7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc/lib/Router.php#L271-L278 |
le-yo/rapidussd | src/Http/Controllers/UssdController.php | UssdController.index | public function index()
{
error_reporting(0);
header('Content-type: text/plain');
set_time_limit(100);
//get inputs
$sessionId = $_REQUEST["sessionId"];
$serviceCode = $_REQUEST["serviceCode"];
$phoneNumber = $_REQUEST["phoneNumber"];
$text = $_REQUEST["text"]; //
$data = ['phone' => $phoneNumber, 'text' => $text, 'service_code' => $serviceCode, 'session_id' => $sessionId];
// print_r($data);
// exit;
//log USSD request
ussd_logs::create($data);
//verify that the user exists
$no = substr($phoneNumber, -9);
$user = ussd_user::where('phone', "0" . $no)->orWhere('phone', "254" . $no)->first();
if (!$user) {
//if user phone doesn't exist, we check out if they have been registered to mifos
$usr = array();
$usr['phone'] = "0".$no;
$usr['session'] = 0;
$usr['progress'] = 0;
$usr['confirm_from'] = 0;
$usr['menu_item_id'] = 0;
$user = ussd_user::create($usr);
}
if (self::user_is_starting($text)) {
//lets get the home menu
//reset user
self::resetUser($user);
//user authentication
$message = '';
$response = self::getMenuAndItems($user,1);
//get the home menu
self::sendResponse($response, 1, $user);
} else {
//message is the latest stuff
$result = explode("*", $text);
if (empty($result)) {
$message = $text;
} else {
end($result);
// move the internal pointer to the end of the array
$message = current($result);
}
switch ($user->session) {
case 0 :
//neutral user
break;
case 1 :
$response = self::continueUssdMenuProcess($user, $message);
//echo "Main Menu";
break;
case 2 :
//confirm USSD Process
$response = self::confirmUssdProcess($user, $message);
break;
case 3 :
//Go back menu
$response = self::confirmGoBack($user, $message);
break;
case 4 :
//Go back menu
$response = self::confirmGoBack($user, $message);
break;
default:
break;
}
self::sendResponse($response, 1, $user);
}
} | php | public function index()
{
error_reporting(0);
header('Content-type: text/plain');
set_time_limit(100);
//get inputs
$sessionId = $_REQUEST["sessionId"];
$serviceCode = $_REQUEST["serviceCode"];
$phoneNumber = $_REQUEST["phoneNumber"];
$text = $_REQUEST["text"]; //
$data = ['phone' => $phoneNumber, 'text' => $text, 'service_code' => $serviceCode, 'session_id' => $sessionId];
// print_r($data);
// exit;
//log USSD request
ussd_logs::create($data);
//verify that the user exists
$no = substr($phoneNumber, -9);
$user = ussd_user::where('phone', "0" . $no)->orWhere('phone', "254" . $no)->first();
if (!$user) {
//if user phone doesn't exist, we check out if they have been registered to mifos
$usr = array();
$usr['phone'] = "0".$no;
$usr['session'] = 0;
$usr['progress'] = 0;
$usr['confirm_from'] = 0;
$usr['menu_item_id'] = 0;
$user = ussd_user::create($usr);
}
if (self::user_is_starting($text)) {
//lets get the home menu
//reset user
self::resetUser($user);
//user authentication
$message = '';
$response = self::getMenuAndItems($user,1);
//get the home menu
self::sendResponse($response, 1, $user);
} else {
//message is the latest stuff
$result = explode("*", $text);
if (empty($result)) {
$message = $text;
} else {
end($result);
// move the internal pointer to the end of the array
$message = current($result);
}
switch ($user->session) {
case 0 :
//neutral user
break;
case 1 :
$response = self::continueUssdMenuProcess($user, $message);
//echo "Main Menu";
break;
case 2 :
//confirm USSD Process
$response = self::confirmUssdProcess($user, $message);
break;
case 3 :
//Go back menu
$response = self::confirmGoBack($user, $message);
break;
case 4 :
//Go back menu
$response = self::confirmGoBack($user, $message);
break;
default:
break;
}
self::sendResponse($response, 1, $user);
}
} | [
"public",
"function",
"index",
"(",
")",
"{",
"error_reporting",
"(",
"0",
")",
";",
"header",
"(",
"'Content-type: text/plain'",
")",
";",
"set_time_limit",
"(",
"100",
")",
";",
"//get inputs",
"$",
"sessionId",
"=",
"$",
"_REQUEST",
"[",
"\"sessionId\"",
"]",
";",
"$",
"serviceCode",
"=",
"$",
"_REQUEST",
"[",
"\"serviceCode\"",
"]",
";",
"$",
"phoneNumber",
"=",
"$",
"_REQUEST",
"[",
"\"phoneNumber\"",
"]",
";",
"$",
"text",
"=",
"$",
"_REQUEST",
"[",
"\"text\"",
"]",
";",
"//",
"$",
"data",
"=",
"[",
"'phone'",
"=>",
"$",
"phoneNumber",
",",
"'text'",
"=>",
"$",
"text",
",",
"'service_code'",
"=>",
"$",
"serviceCode",
",",
"'session_id'",
"=>",
"$",
"sessionId",
"]",
";",
"// print_r($data);",
"// exit;",
"//log USSD request",
"ussd_logs",
"::",
"create",
"(",
"$",
"data",
")",
";",
"//verify that the user exists",
"$",
"no",
"=",
"substr",
"(",
"$",
"phoneNumber",
",",
"-",
"9",
")",
";",
"$",
"user",
"=",
"ussd_user",
"::",
"where",
"(",
"'phone'",
",",
"\"0\"",
".",
"$",
"no",
")",
"->",
"orWhere",
"(",
"'phone'",
",",
"\"254\"",
".",
"$",
"no",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"!",
"$",
"user",
")",
"{",
"//if user phone doesn't exist, we check out if they have been registered to mifos",
"$",
"usr",
"=",
"array",
"(",
")",
";",
"$",
"usr",
"[",
"'phone'",
"]",
"=",
"\"0\"",
".",
"$",
"no",
";",
"$",
"usr",
"[",
"'session'",
"]",
"=",
"0",
";",
"$",
"usr",
"[",
"'progress'",
"]",
"=",
"0",
";",
"$",
"usr",
"[",
"'confirm_from'",
"]",
"=",
"0",
";",
"$",
"usr",
"[",
"'menu_item_id'",
"]",
"=",
"0",
";",
"$",
"user",
"=",
"ussd_user",
"::",
"create",
"(",
"$",
"usr",
")",
";",
"}",
"if",
"(",
"self",
"::",
"user_is_starting",
"(",
"$",
"text",
")",
")",
"{",
"//lets get the home menu",
"//reset user",
"self",
"::",
"resetUser",
"(",
"$",
"user",
")",
";",
"//user authentication",
"$",
"message",
"=",
"''",
";",
"$",
"response",
"=",
"self",
"::",
"getMenuAndItems",
"(",
"$",
"user",
",",
"1",
")",
";",
"//get the home menu",
"self",
"::",
"sendResponse",
"(",
"$",
"response",
",",
"1",
",",
"$",
"user",
")",
";",
"}",
"else",
"{",
"//message is the latest stuff",
"$",
"result",
"=",
"explode",
"(",
"\"*\"",
",",
"$",
"text",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"result",
")",
")",
"{",
"$",
"message",
"=",
"$",
"text",
";",
"}",
"else",
"{",
"end",
"(",
"$",
"result",
")",
";",
"// move the internal pointer to the end of the array",
"$",
"message",
"=",
"current",
"(",
"$",
"result",
")",
";",
"}",
"switch",
"(",
"$",
"user",
"->",
"session",
")",
"{",
"case",
"0",
":",
"//neutral user",
"break",
";",
"case",
"1",
":",
"$",
"response",
"=",
"self",
"::",
"continueUssdMenuProcess",
"(",
"$",
"user",
",",
"$",
"message",
")",
";",
"//echo \"Main Menu\";",
"break",
";",
"case",
"2",
":",
"//confirm USSD Process",
"$",
"response",
"=",
"self",
"::",
"confirmUssdProcess",
"(",
"$",
"user",
",",
"$",
"message",
")",
";",
"break",
";",
"case",
"3",
":",
"//Go back menu",
"$",
"response",
"=",
"self",
"::",
"confirmGoBack",
"(",
"$",
"user",
",",
"$",
"message",
")",
";",
"break",
";",
"case",
"4",
":",
"//Go back menu",
"$",
"response",
"=",
"self",
"::",
"confirmGoBack",
"(",
"$",
"user",
",",
"$",
"message",
")",
";",
"break",
";",
"default",
":",
"break",
";",
"}",
"self",
"::",
"sendResponse",
"(",
"$",
"response",
",",
"1",
",",
"$",
"user",
")",
";",
"}",
"}"
] | Display a listing of the resource.
@return \Illuminate\Http\Response | [
"Display",
"a",
"listing",
"of",
"the",
"resource",
"."
] | train | https://github.com/le-yo/rapidussd/blob/37e97a469b31f5a788a8088ed7c4f7b29e040e09/src/Http/Controllers/UssdController.php#L22-L109 |
le-yo/rapidussd | src/Http/Controllers/UssdController.php | UssdController.confirmGoBack | public function confirmGoBack($user, $message)
{
if (self::validationVariations($message, 1, "yes")) {
//go back to the main menu
self::resetUser($user);
$user->menu_id = 2;
$user->session = 1;
$user->progress = 1;
$user->save();
//get home menu
$menu = ussd_menu::find(2);
$menu_items = self::getMenuItems($menu->id);
$i = 1;
$response = $menu->title . PHP_EOL;
foreach ($menu_items as $key => $value) {
$response = $response . $i . ": " . $value->description . PHP_EOL;
$i++;
}
self::sendResponse($response, 1, $user);
exit;
} elseif (self::validationVariations($message, 2, "no")) {
$response = "Thank you for using our service";
self::sendResponse($response, 3, $user);
} else {
$response = '';
self::sendResponse($response, 2, $user);
exit;
}
} | php | public function confirmGoBack($user, $message)
{
if (self::validationVariations($message, 1, "yes")) {
//go back to the main menu
self::resetUser($user);
$user->menu_id = 2;
$user->session = 1;
$user->progress = 1;
$user->save();
//get home menu
$menu = ussd_menu::find(2);
$menu_items = self::getMenuItems($menu->id);
$i = 1;
$response = $menu->title . PHP_EOL;
foreach ($menu_items as $key => $value) {
$response = $response . $i . ": " . $value->description . PHP_EOL;
$i++;
}
self::sendResponse($response, 1, $user);
exit;
} elseif (self::validationVariations($message, 2, "no")) {
$response = "Thank you for using our service";
self::sendResponse($response, 3, $user);
} else {
$response = '';
self::sendResponse($response, 2, $user);
exit;
}
} | [
"public",
"function",
"confirmGoBack",
"(",
"$",
"user",
",",
"$",
"message",
")",
"{",
"if",
"(",
"self",
"::",
"validationVariations",
"(",
"$",
"message",
",",
"1",
",",
"\"yes\"",
")",
")",
"{",
"//go back to the main menu",
"self",
"::",
"resetUser",
"(",
"$",
"user",
")",
";",
"$",
"user",
"->",
"menu_id",
"=",
"2",
";",
"$",
"user",
"->",
"session",
"=",
"1",
";",
"$",
"user",
"->",
"progress",
"=",
"1",
";",
"$",
"user",
"->",
"save",
"(",
")",
";",
"//get home menu",
"$",
"menu",
"=",
"ussd_menu",
"::",
"find",
"(",
"2",
")",
";",
"$",
"menu_items",
"=",
"self",
"::",
"getMenuItems",
"(",
"$",
"menu",
"->",
"id",
")",
";",
"$",
"i",
"=",
"1",
";",
"$",
"response",
"=",
"$",
"menu",
"->",
"title",
".",
"PHP_EOL",
";",
"foreach",
"(",
"$",
"menu_items",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"response",
"=",
"$",
"response",
".",
"$",
"i",
".",
"\": \"",
".",
"$",
"value",
"->",
"description",
".",
"PHP_EOL",
";",
"$",
"i",
"++",
";",
"}",
"self",
"::",
"sendResponse",
"(",
"$",
"response",
",",
"1",
",",
"$",
"user",
")",
";",
"exit",
";",
"}",
"elseif",
"(",
"self",
"::",
"validationVariations",
"(",
"$",
"message",
",",
"2",
",",
"\"no\"",
")",
")",
"{",
"$",
"response",
"=",
"\"Thank you for using our service\"",
";",
"self",
"::",
"sendResponse",
"(",
"$",
"response",
",",
"3",
",",
"$",
"user",
")",
";",
"}",
"else",
"{",
"$",
"response",
"=",
"''",
";",
"self",
"::",
"sendResponse",
"(",
"$",
"response",
",",
"2",
",",
"$",
"user",
")",
";",
"exit",
";",
"}",
"}"
] | confirm go back | [
"confirm",
"go",
"back"
] | train | https://github.com/le-yo/rapidussd/blob/37e97a469b31f5a788a8088ed7c4f7b29e040e09/src/Http/Controllers/UssdController.php#L112-L145 |
le-yo/rapidussd | src/Http/Controllers/UssdController.php | UssdController.confirmUssdProcess | public function confirmUssdProcess($user, $message)
{
$menu = ussd_menu::find($user->menu_id);
if (self::validationVariations($message, 1, "yes")) {
//if confirmed
if (self::postUssdConfirmationProcess($user)) {
$response = $menu->confirmation_message;
} else {
$response = "We had a problem processing your request. Please contact Watu Credit Customer Care on 0790 000 999";
}
self::resetUser($user);
self::sendResponse($response, 2, $user);
} elseif (self::validationVariations($message, 2, "no")) {
$response = self::nextMenuSwitch($user, $menu);
return $response;
} else {
//not confirmed
$response = "We could not understand your response";
//restart the process
$output = self::confirmBatch($user, $menu);
$response = $response . PHP_EOL . $output;
return $response;
}
} | php | public function confirmUssdProcess($user, $message)
{
$menu = ussd_menu::find($user->menu_id);
if (self::validationVariations($message, 1, "yes")) {
//if confirmed
if (self::postUssdConfirmationProcess($user)) {
$response = $menu->confirmation_message;
} else {
$response = "We had a problem processing your request. Please contact Watu Credit Customer Care on 0790 000 999";
}
self::resetUser($user);
self::sendResponse($response, 2, $user);
} elseif (self::validationVariations($message, 2, "no")) {
$response = self::nextMenuSwitch($user, $menu);
return $response;
} else {
//not confirmed
$response = "We could not understand your response";
//restart the process
$output = self::confirmBatch($user, $menu);
$response = $response . PHP_EOL . $output;
return $response;
}
} | [
"public",
"function",
"confirmUssdProcess",
"(",
"$",
"user",
",",
"$",
"message",
")",
"{",
"$",
"menu",
"=",
"ussd_menu",
"::",
"find",
"(",
"$",
"user",
"->",
"menu_id",
")",
";",
"if",
"(",
"self",
"::",
"validationVariations",
"(",
"$",
"message",
",",
"1",
",",
"\"yes\"",
")",
")",
"{",
"//if confirmed",
"if",
"(",
"self",
"::",
"postUssdConfirmationProcess",
"(",
"$",
"user",
")",
")",
"{",
"$",
"response",
"=",
"$",
"menu",
"->",
"confirmation_message",
";",
"}",
"else",
"{",
"$",
"response",
"=",
"\"We had a problem processing your request. Please contact Watu Credit Customer Care on 0790 000 999\"",
";",
"}",
"self",
"::",
"resetUser",
"(",
"$",
"user",
")",
";",
"self",
"::",
"sendResponse",
"(",
"$",
"response",
",",
"2",
",",
"$",
"user",
")",
";",
"}",
"elseif",
"(",
"self",
"::",
"validationVariations",
"(",
"$",
"message",
",",
"2",
",",
"\"no\"",
")",
")",
"{",
"$",
"response",
"=",
"self",
"::",
"nextMenuSwitch",
"(",
"$",
"user",
",",
"$",
"menu",
")",
";",
"return",
"$",
"response",
";",
"}",
"else",
"{",
"//not confirmed",
"$",
"response",
"=",
"\"We could not understand your response\"",
";",
"//restart the process",
"$",
"output",
"=",
"self",
"::",
"confirmBatch",
"(",
"$",
"user",
",",
"$",
"menu",
")",
";",
"$",
"response",
"=",
"$",
"response",
".",
"PHP_EOL",
".",
"$",
"output",
";",
"return",
"$",
"response",
";",
"}",
"}"
] | confirmUssdProcess | [
"confirmUssdProcess"
] | train | https://github.com/le-yo/rapidussd/blob/37e97a469b31f5a788a8088ed7c4f7b29e040e09/src/Http/Controllers/UssdController.php#L149-L179 |
le-yo/rapidussd | src/Http/Controllers/UssdController.php | UssdController.postUssdConfirmationProcess | public function postUssdConfirmationProcess($user)
{
switch ($user->confirm_from) {
case 1:
$no = substr($user->phone, -9);
$data['email'] = "0".$no."@agin.com";
User::create($data);
return true;
break;
default :
return true;
break;
}
} | php | public function postUssdConfirmationProcess($user)
{
switch ($user->confirm_from) {
case 1:
$no = substr($user->phone, -9);
$data['email'] = "0".$no."@agin.com";
User::create($data);
return true;
break;
default :
return true;
break;
}
} | [
"public",
"function",
"postUssdConfirmationProcess",
"(",
"$",
"user",
")",
"{",
"switch",
"(",
"$",
"user",
"->",
"confirm_from",
")",
"{",
"case",
"1",
":",
"$",
"no",
"=",
"substr",
"(",
"$",
"user",
"->",
"phone",
",",
"-",
"9",
")",
";",
"$",
"data",
"[",
"'email'",
"]",
"=",
"\"0\"",
".",
"$",
"no",
".",
"\"@agin.com\"",
";",
"User",
"::",
"create",
"(",
"$",
"data",
")",
";",
"return",
"true",
";",
"break",
";",
"default",
":",
"return",
"true",
";",
"break",
";",
"}",
"}"
] | post ussd confirmation, define your processes | [
"post",
"ussd",
"confirmation",
"define",
"your",
"processes"
] | train | https://github.com/le-yo/rapidussd/blob/37e97a469b31f5a788a8088ed7c4f7b29e040e09/src/Http/Controllers/UssdController.php#L183-L201 |
le-yo/rapidussd | src/Http/Controllers/UssdController.php | UssdController.confirmBatch | public function confirmBatch($user, $menu)
{
//confirm this stuff
$menu_items = self::getMenuItems($user->menu_id);
$confirmation = "Confirm: " . $menu->title;
$amount = 0;
foreach ($menu_items as $key => $value) {
$response = ussd_response::whereUserIdAndMenuIdAndMenuItemId($user->id, $user->menu_id, $value->id)->orderBy('id', 'DESC')->first();
$confirmation = $confirmation . PHP_EOL . $value->confirmation_phrase . ": " . $response->response;
$amount = $response->response;
}
$response = $confirmation . PHP_EOL . "1. Yes" . PHP_EOL . "2. No";
$user->session = 2;
$user->confirm_from = $user->menu_id;
$user->save();
return $response;
} | php | public function confirmBatch($user, $menu)
{
//confirm this stuff
$menu_items = self::getMenuItems($user->menu_id);
$confirmation = "Confirm: " . $menu->title;
$amount = 0;
foreach ($menu_items as $key => $value) {
$response = ussd_response::whereUserIdAndMenuIdAndMenuItemId($user->id, $user->menu_id, $value->id)->orderBy('id', 'DESC')->first();
$confirmation = $confirmation . PHP_EOL . $value->confirmation_phrase . ": " . $response->response;
$amount = $response->response;
}
$response = $confirmation . PHP_EOL . "1. Yes" . PHP_EOL . "2. No";
$user->session = 2;
$user->confirm_from = $user->menu_id;
$user->save();
return $response;
} | [
"public",
"function",
"confirmBatch",
"(",
"$",
"user",
",",
"$",
"menu",
")",
"{",
"//confirm this stuff",
"$",
"menu_items",
"=",
"self",
"::",
"getMenuItems",
"(",
"$",
"user",
"->",
"menu_id",
")",
";",
"$",
"confirmation",
"=",
"\"Confirm: \"",
".",
"$",
"menu",
"->",
"title",
";",
"$",
"amount",
"=",
"0",
";",
"foreach",
"(",
"$",
"menu_items",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"response",
"=",
"ussd_response",
"::",
"whereUserIdAndMenuIdAndMenuItemId",
"(",
"$",
"user",
"->",
"id",
",",
"$",
"user",
"->",
"menu_id",
",",
"$",
"value",
"->",
"id",
")",
"->",
"orderBy",
"(",
"'id'",
",",
"'DESC'",
")",
"->",
"first",
"(",
")",
";",
"$",
"confirmation",
"=",
"$",
"confirmation",
".",
"PHP_EOL",
".",
"$",
"value",
"->",
"confirmation_phrase",
".",
"\": \"",
".",
"$",
"response",
"->",
"response",
";",
"$",
"amount",
"=",
"$",
"response",
"->",
"response",
";",
"}",
"$",
"response",
"=",
"$",
"confirmation",
".",
"PHP_EOL",
".",
"\"1. Yes\"",
".",
"PHP_EOL",
".",
"\"2. No\"",
";",
"$",
"user",
"->",
"session",
"=",
"2",
";",
"$",
"user",
"->",
"confirm_from",
"=",
"$",
"user",
"->",
"menu_id",
";",
"$",
"user",
"->",
"save",
"(",
")",
";",
"return",
"$",
"response",
";",
"}"
] | confirm batch | [
"confirm",
"batch"
] | train | https://github.com/le-yo/rapidussd/blob/37e97a469b31f5a788a8088ed7c4f7b29e040e09/src/Http/Controllers/UssdController.php#L205-L226 |
le-yo/rapidussd | src/Http/Controllers/UssdController.php | UssdController.continueUssdMenuProcess | public function continueUssdMenuProcess($user,$message){
$menu = ussd_menu::find($user->menu_id);
//check the user menu
switch ($menu->type) {
case 0:
//authentication mini app
break;
case 1:
//continue to another menu
$response = self::continueUssdMenu($user,$message,$menu);
break;
case 2:
//continue to a processs
$response = self::continueSingleProcess($user,$message,$menu);
break;
case 3:
//infomation mini app
//
self::infoMiniApp($user,$menu);
break;
default :
self::resetUser($user);
$response = "An error occurred";
break;
}
return $response;
} | php | public function continueUssdMenuProcess($user,$message){
$menu = ussd_menu::find($user->menu_id);
//check the user menu
switch ($menu->type) {
case 0:
//authentication mini app
break;
case 1:
//continue to another menu
$response = self::continueUssdMenu($user,$message,$menu);
break;
case 2:
//continue to a processs
$response = self::continueSingleProcess($user,$message,$menu);
break;
case 3:
//infomation mini app
//
self::infoMiniApp($user,$menu);
break;
default :
self::resetUser($user);
$response = "An error occurred";
break;
}
return $response;
} | [
"public",
"function",
"continueUssdMenuProcess",
"(",
"$",
"user",
",",
"$",
"message",
")",
"{",
"$",
"menu",
"=",
"ussd_menu",
"::",
"find",
"(",
"$",
"user",
"->",
"menu_id",
")",
";",
"//check the user menu",
"switch",
"(",
"$",
"menu",
"->",
"type",
")",
"{",
"case",
"0",
":",
"//authentication mini app",
"break",
";",
"case",
"1",
":",
"//continue to another menu",
"$",
"response",
"=",
"self",
"::",
"continueUssdMenu",
"(",
"$",
"user",
",",
"$",
"message",
",",
"$",
"menu",
")",
";",
"break",
";",
"case",
"2",
":",
"//continue to a processs",
"$",
"response",
"=",
"self",
"::",
"continueSingleProcess",
"(",
"$",
"user",
",",
"$",
"message",
",",
"$",
"menu",
")",
";",
"break",
";",
"case",
"3",
":",
"//infomation mini app",
"//",
"self",
"::",
"infoMiniApp",
"(",
"$",
"user",
",",
"$",
"menu",
")",
";",
"break",
";",
"default",
":",
"self",
"::",
"resetUser",
"(",
"$",
"user",
")",
";",
"$",
"response",
"=",
"\"An error occurred\"",
";",
"break",
";",
"}",
"return",
"$",
"response",
";",
"}"
] | continue USSD Menu Progress | [
"continue",
"USSD",
"Menu",
"Progress"
] | train | https://github.com/le-yo/rapidussd/blob/37e97a469b31f5a788a8088ed7c4f7b29e040e09/src/Http/Controllers/UssdController.php#L231-L262 |
le-yo/rapidussd | src/Http/Controllers/UssdController.php | UssdController.infoMiniApp | public function infoMiniApp($user,$menu){
echo "infoMiniAppbased on menu_id";
exit;
switch ($menu->id) {
case 4:
//get the loan balance
break;
case 5:
break;
case 6:
default :
$response = $menu->confirmation_message;
$notify = new NotifyController();
//$notify->sendSms($user->phone_no,$response);
//self::resetUser($user);
self::sendResponse($response,2,$user);
break;
}
} | php | public function infoMiniApp($user,$menu){
echo "infoMiniAppbased on menu_id";
exit;
switch ($menu->id) {
case 4:
//get the loan balance
break;
case 5:
break;
case 6:
default :
$response = $menu->confirmation_message;
$notify = new NotifyController();
//$notify->sendSms($user->phone_no,$response);
//self::resetUser($user);
self::sendResponse($response,2,$user);
break;
}
} | [
"public",
"function",
"infoMiniApp",
"(",
"$",
"user",
",",
"$",
"menu",
")",
"{",
"echo",
"\"infoMiniAppbased on menu_id\"",
";",
"exit",
";",
"switch",
"(",
"$",
"menu",
"->",
"id",
")",
"{",
"case",
"4",
":",
"//get the loan balance",
"break",
";",
"case",
"5",
":",
"break",
";",
"case",
"6",
":",
"default",
":",
"$",
"response",
"=",
"$",
"menu",
"->",
"confirmation_message",
";",
"$",
"notify",
"=",
"new",
"NotifyController",
"(",
")",
";",
"//$notify->sendSms($user->phone_no,$response);",
"//self::resetUser($user);",
"self",
"::",
"sendResponse",
"(",
"$",
"response",
",",
"2",
",",
"$",
"user",
")",
";",
"break",
";",
"}",
"}"
] | info mini app | [
"info",
"mini",
"app"
] | train | https://github.com/le-yo/rapidussd/blob/37e97a469b31f5a788a8088ed7c4f7b29e040e09/src/Http/Controllers/UssdController.php#L265-L291 |
le-yo/rapidussd | src/Http/Controllers/UssdController.php | UssdController.continueSingleProcess | public function continueSingleProcess($user,$message,$menu){
//validate input to be numeric
$menuItem = ussd_menu_items::whereMenuIdAndStep($menu->id,$user->progress)->first();
$message = str_replace(",","",$message);
switch ($menu->id) {
default :
self::storeUssdResponse($user,$message);
//check if we have another step
$step = $user->progress + 1;
$menuItem = ussd_menu_items::whereMenuIdAndStep($menu->id,$step)->first();
if($menuItem){
$user->menu_item_id = $menuItem->id;
$user->menu_id = $menu->id;
$user->progress = $step;
$user->save();
return $menuItem -> description;
}else{
$response = self::confirmBatch($user,$menu);
return $response;
}
break;
}
return $response;
} | php | public function continueSingleProcess($user,$message,$menu){
//validate input to be numeric
$menuItem = ussd_menu_items::whereMenuIdAndStep($menu->id,$user->progress)->first();
$message = str_replace(",","",$message);
switch ($menu->id) {
default :
self::storeUssdResponse($user,$message);
//check if we have another step
$step = $user->progress + 1;
$menuItem = ussd_menu_items::whereMenuIdAndStep($menu->id,$step)->first();
if($menuItem){
$user->menu_item_id = $menuItem->id;
$user->menu_id = $menu->id;
$user->progress = $step;
$user->save();
return $menuItem -> description;
}else{
$response = self::confirmBatch($user,$menu);
return $response;
}
break;
}
return $response;
} | [
"public",
"function",
"continueSingleProcess",
"(",
"$",
"user",
",",
"$",
"message",
",",
"$",
"menu",
")",
"{",
"//validate input to be numeric",
"$",
"menuItem",
"=",
"ussd_menu_items",
"::",
"whereMenuIdAndStep",
"(",
"$",
"menu",
"->",
"id",
",",
"$",
"user",
"->",
"progress",
")",
"->",
"first",
"(",
")",
";",
"$",
"message",
"=",
"str_replace",
"(",
"\",\"",
",",
"\"\"",
",",
"$",
"message",
")",
";",
"switch",
"(",
"$",
"menu",
"->",
"id",
")",
"{",
"default",
":",
"self",
"::",
"storeUssdResponse",
"(",
"$",
"user",
",",
"$",
"message",
")",
";",
"//check if we have another step",
"$",
"step",
"=",
"$",
"user",
"->",
"progress",
"+",
"1",
";",
"$",
"menuItem",
"=",
"ussd_menu_items",
"::",
"whereMenuIdAndStep",
"(",
"$",
"menu",
"->",
"id",
",",
"$",
"step",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"$",
"menuItem",
")",
"{",
"$",
"user",
"->",
"menu_item_id",
"=",
"$",
"menuItem",
"->",
"id",
";",
"$",
"user",
"->",
"menu_id",
"=",
"$",
"menu",
"->",
"id",
";",
"$",
"user",
"->",
"progress",
"=",
"$",
"step",
";",
"$",
"user",
"->",
"save",
"(",
")",
";",
"return",
"$",
"menuItem",
"->",
"description",
";",
"}",
"else",
"{",
"$",
"response",
"=",
"self",
"::",
"confirmBatch",
"(",
"$",
"user",
",",
"$",
"menu",
")",
";",
"return",
"$",
"response",
";",
"}",
"break",
";",
"}",
"return",
"$",
"response",
";",
"}"
] | continuation | [
"continuation"
] | train | https://github.com/le-yo/rapidussd/blob/37e97a469b31f5a788a8088ed7c4f7b29e040e09/src/Http/Controllers/UssdController.php#L293-L320 |
le-yo/rapidussd | src/Http/Controllers/UssdController.php | UssdController.continueUssdMenu | public function continueUssdMenu($user,$message,$menu){
//verify response
$menu_items = self::getMenuItems($user->menu_id);
$i = 1;
$choice = "";
$next_menu_id = 0;
foreach ($menu_items as $key => $value) {
if(self::validationVariations(trim($message),$i,$value->description)){
$choice = $value->id;
$next_menu_id = $value->next_menu_id;
break;
}
$i++;
}
if(empty($choice)){
//get error, we could not understand your response
$response = "We could not understand your response". PHP_EOL;
$i = 1;
$response = $menu->title.PHP_EOL;
foreach ($menu_items as $key => $value) {
$response = $response . $i . ": " . $value->description . PHP_EOL;
$i++;
}
return $response;
//save the response
}else{
//there is a selected choice
$menu = ussd_menu::find($next_menu_id);
//next menu switch
$response = self::nextMenuSwitch($user,$menu);
return $response;
}
} | php | public function continueUssdMenu($user,$message,$menu){
//verify response
$menu_items = self::getMenuItems($user->menu_id);
$i = 1;
$choice = "";
$next_menu_id = 0;
foreach ($menu_items as $key => $value) {
if(self::validationVariations(trim($message),$i,$value->description)){
$choice = $value->id;
$next_menu_id = $value->next_menu_id;
break;
}
$i++;
}
if(empty($choice)){
//get error, we could not understand your response
$response = "We could not understand your response". PHP_EOL;
$i = 1;
$response = $menu->title.PHP_EOL;
foreach ($menu_items as $key => $value) {
$response = $response . $i . ": " . $value->description . PHP_EOL;
$i++;
}
return $response;
//save the response
}else{
//there is a selected choice
$menu = ussd_menu::find($next_menu_id);
//next menu switch
$response = self::nextMenuSwitch($user,$menu);
return $response;
}
} | [
"public",
"function",
"continueUssdMenu",
"(",
"$",
"user",
",",
"$",
"message",
",",
"$",
"menu",
")",
"{",
"//verify response",
"$",
"menu_items",
"=",
"self",
"::",
"getMenuItems",
"(",
"$",
"user",
"->",
"menu_id",
")",
";",
"$",
"i",
"=",
"1",
";",
"$",
"choice",
"=",
"\"\"",
";",
"$",
"next_menu_id",
"=",
"0",
";",
"foreach",
"(",
"$",
"menu_items",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"self",
"::",
"validationVariations",
"(",
"trim",
"(",
"$",
"message",
")",
",",
"$",
"i",
",",
"$",
"value",
"->",
"description",
")",
")",
"{",
"$",
"choice",
"=",
"$",
"value",
"->",
"id",
";",
"$",
"next_menu_id",
"=",
"$",
"value",
"->",
"next_menu_id",
";",
"break",
";",
"}",
"$",
"i",
"++",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"choice",
")",
")",
"{",
"//get error, we could not understand your response",
"$",
"response",
"=",
"\"We could not understand your response\"",
".",
"PHP_EOL",
";",
"$",
"i",
"=",
"1",
";",
"$",
"response",
"=",
"$",
"menu",
"->",
"title",
".",
"PHP_EOL",
";",
"foreach",
"(",
"$",
"menu_items",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"response",
"=",
"$",
"response",
".",
"$",
"i",
".",
"\": \"",
".",
"$",
"value",
"->",
"description",
".",
"PHP_EOL",
";",
"$",
"i",
"++",
";",
"}",
"return",
"$",
"response",
";",
"//save the response",
"}",
"else",
"{",
"//there is a selected choice",
"$",
"menu",
"=",
"ussd_menu",
"::",
"find",
"(",
"$",
"next_menu_id",
")",
";",
"//next menu switch",
"$",
"response",
"=",
"self",
"::",
"nextMenuSwitch",
"(",
"$",
"user",
",",
"$",
"menu",
")",
";",
"return",
"$",
"response",
";",
"}",
"}"
] | continue USSD Menu | [
"continue",
"USSD",
"Menu"
] | train | https://github.com/le-yo/rapidussd/blob/37e97a469b31f5a788a8088ed7c4f7b29e040e09/src/Http/Controllers/UssdController.php#L323-L361 |
le-yo/rapidussd | src/Http/Controllers/UssdController.php | UssdController.storeUssdResponse | public function storeUssdResponse($user,$message){
$data = ['user_id'=>$user->id,'menu_id'=>$user->menu_id,'menu_item_id'=>$user->menu_item_id,'response'=>$message];
return ussd_response::create($data);
} | php | public function storeUssdResponse($user,$message){
$data = ['user_id'=>$user->id,'menu_id'=>$user->menu_id,'menu_item_id'=>$user->menu_item_id,'response'=>$message];
return ussd_response::create($data);
} | [
"public",
"function",
"storeUssdResponse",
"(",
"$",
"user",
",",
"$",
"message",
")",
"{",
"$",
"data",
"=",
"[",
"'user_id'",
"=>",
"$",
"user",
"->",
"id",
",",
"'menu_id'",
"=>",
"$",
"user",
"->",
"menu_id",
",",
"'menu_item_id'",
"=>",
"$",
"user",
"->",
"menu_item_id",
",",
"'response'",
"=>",
"$",
"message",
"]",
";",
"return",
"ussd_response",
"::",
"create",
"(",
"$",
"data",
")",
";",
"}"
] | store USSD response | [
"store",
"USSD",
"response"
] | train | https://github.com/le-yo/rapidussd/blob/37e97a469b31f5a788a8088ed7c4f7b29e040e09/src/Http/Controllers/UssdController.php#L421-L427 |
le-yo/rapidussd | src/Http/Controllers/UssdController.php | UssdController.singleProcess | public function singleProcess($menu, $user,$step) {
$menuItem = ussd_menu_items::whereMenuIdAndStep($menu->id,$step)->first();
if ($menuItem) {
//update user data and next request and send back
$user->menu_item_id = $menuItem->id;
$user->menu_id = $menu->id;
$user->progress = $step;
$user->session = 1;
$user->save();
return $menuItem -> description;
}
} | php | public function singleProcess($menu, $user,$step) {
$menuItem = ussd_menu_items::whereMenuIdAndStep($menu->id,$step)->first();
if ($menuItem) {
//update user data and next request and send back
$user->menu_item_id = $menuItem->id;
$user->menu_id = $menu->id;
$user->progress = $step;
$user->session = 1;
$user->save();
return $menuItem -> description;
}
} | [
"public",
"function",
"singleProcess",
"(",
"$",
"menu",
",",
"$",
"user",
",",
"$",
"step",
")",
"{",
"$",
"menuItem",
"=",
"ussd_menu_items",
"::",
"whereMenuIdAndStep",
"(",
"$",
"menu",
"->",
"id",
",",
"$",
"step",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"$",
"menuItem",
")",
"{",
"//update user data and next request and send back",
"$",
"user",
"->",
"menu_item_id",
"=",
"$",
"menuItem",
"->",
"id",
";",
"$",
"user",
"->",
"menu_id",
"=",
"$",
"menu",
"->",
"id",
";",
"$",
"user",
"->",
"progress",
"=",
"$",
"step",
";",
"$",
"user",
"->",
"session",
"=",
"1",
";",
"$",
"user",
"->",
"save",
"(",
")",
";",
"return",
"$",
"menuItem",
"->",
"description",
";",
"}",
"}"
] | single process | [
"single",
"process"
] | train | https://github.com/le-yo/rapidussd/blob/37e97a469b31f5a788a8088ed7c4f7b29e040e09/src/Http/Controllers/UssdController.php#L431-L446 |
le-yo/rapidussd | src/Http/Controllers/UssdController.php | UssdController.getMenuAndItems | public function getMenuAndItems($user,$menu_id){
//get main menu
$user->menu_id = $menu_id;
$user->session = 1;
$user->progress = 1;
$user->save();
//get home menu
$menu = ussd_menu::find($menu_id);
$menu_items = self::getMenuItems($menu_id);
$i = 1;
$response = $menu->title.PHP_EOL;
foreach ($menu_items as $key => $value) {
$response = $response . $i . ": " . $value->description . PHP_EOL;
$i++;
}
return $response;
} | php | public function getMenuAndItems($user,$menu_id){
//get main menu
$user->menu_id = $menu_id;
$user->session = 1;
$user->progress = 1;
$user->save();
//get home menu
$menu = ussd_menu::find($menu_id);
$menu_items = self::getMenuItems($menu_id);
$i = 1;
$response = $menu->title.PHP_EOL;
foreach ($menu_items as $key => $value) {
$response = $response . $i . ": " . $value->description . PHP_EOL;
$i++;
}
return $response;
} | [
"public",
"function",
"getMenuAndItems",
"(",
"$",
"user",
",",
"$",
"menu_id",
")",
"{",
"//get main menu",
"$",
"user",
"->",
"menu_id",
"=",
"$",
"menu_id",
";",
"$",
"user",
"->",
"session",
"=",
"1",
";",
"$",
"user",
"->",
"progress",
"=",
"1",
";",
"$",
"user",
"->",
"save",
"(",
")",
";",
"//get home menu",
"$",
"menu",
"=",
"ussd_menu",
"::",
"find",
"(",
"$",
"menu_id",
")",
";",
"$",
"menu_items",
"=",
"self",
"::",
"getMenuItems",
"(",
"$",
"menu_id",
")",
";",
"$",
"i",
"=",
"1",
";",
"$",
"response",
"=",
"$",
"menu",
"->",
"title",
".",
"PHP_EOL",
";",
"foreach",
"(",
"$",
"menu_items",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"response",
"=",
"$",
"response",
".",
"$",
"i",
".",
"\": \"",
".",
"$",
"value",
"->",
"description",
".",
"PHP_EOL",
";",
"$",
"i",
"++",
";",
"}",
"return",
"$",
"response",
";",
"}"
] | Show the form for creating a new resource.
@return \Illuminate\Http\Response | [
"Show",
"the",
"form",
"for",
"creating",
"a",
"new",
"resource",
"."
] | train | https://github.com/le-yo/rapidussd/blob/37e97a469b31f5a788a8088ed7c4f7b29e040e09/src/Http/Controllers/UssdController.php#L473-L493 |
CakeCMS/Core | src/View/Helper/JsHelper.php | JsHelper.getBuffer | public function getBuffer(array $options = [])
{
$docEol = $this->Document->eol;
$options = Hash::merge(['safe' => true], $options);
if (Arr::key('block', $options)) {
unset($options['block']);
}
if (count($this->_buffers)) {
$scripts = $docEol .
'jQuery (function($) {' . $docEol .
implode($docEol, $this->_buffers) . $docEol .
'});' . $docEol;
return $this->Html->scriptBlock($scripts, $options) . $docEol;
}
return null;
} | php | public function getBuffer(array $options = [])
{
$docEol = $this->Document->eol;
$options = Hash::merge(['safe' => true], $options);
if (Arr::key('block', $options)) {
unset($options['block']);
}
if (count($this->_buffers)) {
$scripts = $docEol .
'jQuery (function($) {' . $docEol .
implode($docEol, $this->_buffers) . $docEol .
'});' . $docEol;
return $this->Html->scriptBlock($scripts, $options) . $docEol;
}
return null;
} | [
"public",
"function",
"getBuffer",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"docEol",
"=",
"$",
"this",
"->",
"Document",
"->",
"eol",
";",
"$",
"options",
"=",
"Hash",
"::",
"merge",
"(",
"[",
"'safe'",
"=>",
"true",
"]",
",",
"$",
"options",
")",
";",
"if",
"(",
"Arr",
"::",
"key",
"(",
"'block'",
",",
"$",
"options",
")",
")",
"{",
"unset",
"(",
"$",
"options",
"[",
"'block'",
"]",
")",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"_buffers",
")",
")",
"{",
"$",
"scripts",
"=",
"$",
"docEol",
".",
"'jQuery (function($) {'",
".",
"$",
"docEol",
".",
"implode",
"(",
"$",
"docEol",
",",
"$",
"this",
"->",
"_buffers",
")",
".",
"$",
"docEol",
".",
"'});'",
".",
"$",
"docEol",
";",
"return",
"$",
"this",
"->",
"Html",
"->",
"scriptBlock",
"(",
"$",
"scripts",
",",
"$",
"options",
")",
".",
"$",
"docEol",
";",
"}",
"return",
"null",
";",
"}"
] | Get all holds in buffer scripts.
@param array $options
@return null|string | [
"Get",
"all",
"holds",
"in",
"buffer",
"scripts",
"."
] | train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/JsHelper.php#L69-L88 |
CakeCMS/Core | src/View/Helper/JsHelper.php | JsHelper.setBuffer | public function setBuffer($script, $top = false)
{
$script = trim($script);
if ($top) {
array_unshift($this->_buffers, $script);
} else {
array_push($this->_buffers, $script);
}
return $this;
} | php | public function setBuffer($script, $top = false)
{
$script = trim($script);
if ($top) {
array_unshift($this->_buffers, $script);
} else {
array_push($this->_buffers, $script);
}
return $this;
} | [
"public",
"function",
"setBuffer",
"(",
"$",
"script",
",",
"$",
"top",
"=",
"false",
")",
"{",
"$",
"script",
"=",
"trim",
"(",
"$",
"script",
")",
";",
"if",
"(",
"$",
"top",
")",
"{",
"array_unshift",
"(",
"$",
"this",
"->",
"_buffers",
",",
"$",
"script",
")",
";",
"}",
"else",
"{",
"array_push",
"(",
"$",
"this",
"->",
"_buffers",
",",
"$",
"script",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Setup buffer script.
@param string $script
@param bool|false $top
@return $this | [
"Setup",
"buffer",
"script",
"."
] | train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/JsHelper.php#L97-L107 |
CakeCMS/Core | src/View/Helper/JsHelper.php | JsHelper.widget | public function widget($jSelector, $widgetName, array $params = [], $return = false)
{
static $included = [];
$jSelector = is_array($jSelector) ? implode(', ', $jSelector) : $jSelector;
$hash = $jSelector . ' /// ' . $widgetName;
if (!Arr::key($hash, $included)) {
$included[$hash] = true;
$widgetName = str_replace('.', '', $widgetName);
$initScript = '$("' . $jSelector . '").' . $widgetName . '(' . json_encode($params) . ');';
if ($return) {
return $this->Html->scriptBlock("\tjQuery(function($){" . $initScript . "});");
}
$this->setBuffer($initScript);
}
return null;
} | php | public function widget($jSelector, $widgetName, array $params = [], $return = false)
{
static $included = [];
$jSelector = is_array($jSelector) ? implode(', ', $jSelector) : $jSelector;
$hash = $jSelector . ' /// ' . $widgetName;
if (!Arr::key($hash, $included)) {
$included[$hash] = true;
$widgetName = str_replace('.', '', $widgetName);
$initScript = '$("' . $jSelector . '").' . $widgetName . '(' . json_encode($params) . ');';
if ($return) {
return $this->Html->scriptBlock("\tjQuery(function($){" . $initScript . "});");
}
$this->setBuffer($initScript);
}
return null;
} | [
"public",
"function",
"widget",
"(",
"$",
"jSelector",
",",
"$",
"widgetName",
",",
"array",
"$",
"params",
"=",
"[",
"]",
",",
"$",
"return",
"=",
"false",
")",
"{",
"static",
"$",
"included",
"=",
"[",
"]",
";",
"$",
"jSelector",
"=",
"is_array",
"(",
"$",
"jSelector",
")",
"?",
"implode",
"(",
"', '",
",",
"$",
"jSelector",
")",
":",
"$",
"jSelector",
";",
"$",
"hash",
"=",
"$",
"jSelector",
".",
"' /// '",
".",
"$",
"widgetName",
";",
"if",
"(",
"!",
"Arr",
"::",
"key",
"(",
"$",
"hash",
",",
"$",
"included",
")",
")",
"{",
"$",
"included",
"[",
"$",
"hash",
"]",
"=",
"true",
";",
"$",
"widgetName",
"=",
"str_replace",
"(",
"'.'",
",",
"''",
",",
"$",
"widgetName",
")",
";",
"$",
"initScript",
"=",
"'$(\"'",
".",
"$",
"jSelector",
".",
"'\").'",
".",
"$",
"widgetName",
".",
"'('",
".",
"json_encode",
"(",
"$",
"params",
")",
".",
"');'",
";",
"if",
"(",
"$",
"return",
")",
"{",
"return",
"$",
"this",
"->",
"Html",
"->",
"scriptBlock",
"(",
"\"\\tjQuery(function($){\"",
".",
"$",
"initScript",
".",
"\"});\"",
")",
";",
"}",
"$",
"this",
"->",
"setBuffer",
"(",
"$",
"initScript",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Initialize java script widget.
@param string $jSelector
@param string $widgetName
@param array $params
@param bool $return
@return string|null | [
"Initialize",
"java",
"script",
"widget",
"."
] | train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/JsHelper.php#L118-L139 |
CakeCMS/Core | src/View/Helper/JsHelper.php | JsHelper._setScriptVars | protected function _setScriptVars()
{
$request = $this->request;
$vars = [
'baseUrl' => Router::fullBaseUrl(),
'alert' => [
'ok' => __d('alert', 'Ok'),
'cancel' => __d('alert', 'Cancel'),
'sure' => __d('alert', 'Are you sure?'),
],
'request' => [
'url' => $request->getPath(),
'params' => [
'pass' => $request->getParam('pass'),
'theme' => $request->getParam('theme'),
'action' => $request->getParam('action'),
'prefix' => $request->getParam('prefix'),
'plugin' => $request->getParam('plugin'),
'controller' => $request->getParam('controller'),
],
'query' => $this->request->getQueryParams(),
'base' => $request->getAttribute('base'),
'here' => $request->getRequestTarget(),
]
];
$this->Html->scriptBlock('window.CMS = ' . json_encode($vars), ['block' => 'css_bottom']);
} | php | protected function _setScriptVars()
{
$request = $this->request;
$vars = [
'baseUrl' => Router::fullBaseUrl(),
'alert' => [
'ok' => __d('alert', 'Ok'),
'cancel' => __d('alert', 'Cancel'),
'sure' => __d('alert', 'Are you sure?'),
],
'request' => [
'url' => $request->getPath(),
'params' => [
'pass' => $request->getParam('pass'),
'theme' => $request->getParam('theme'),
'action' => $request->getParam('action'),
'prefix' => $request->getParam('prefix'),
'plugin' => $request->getParam('plugin'),
'controller' => $request->getParam('controller'),
],
'query' => $this->request->getQueryParams(),
'base' => $request->getAttribute('base'),
'here' => $request->getRequestTarget(),
]
];
$this->Html->scriptBlock('window.CMS = ' . json_encode($vars), ['block' => 'css_bottom']);
} | [
"protected",
"function",
"_setScriptVars",
"(",
")",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"request",
";",
"$",
"vars",
"=",
"[",
"'baseUrl'",
"=>",
"Router",
"::",
"fullBaseUrl",
"(",
")",
",",
"'alert'",
"=>",
"[",
"'ok'",
"=>",
"__d",
"(",
"'alert'",
",",
"'Ok'",
")",
",",
"'cancel'",
"=>",
"__d",
"(",
"'alert'",
",",
"'Cancel'",
")",
",",
"'sure'",
"=>",
"__d",
"(",
"'alert'",
",",
"'Are you sure?'",
")",
",",
"]",
",",
"'request'",
"=>",
"[",
"'url'",
"=>",
"$",
"request",
"->",
"getPath",
"(",
")",
",",
"'params'",
"=>",
"[",
"'pass'",
"=>",
"$",
"request",
"->",
"getParam",
"(",
"'pass'",
")",
",",
"'theme'",
"=>",
"$",
"request",
"->",
"getParam",
"(",
"'theme'",
")",
",",
"'action'",
"=>",
"$",
"request",
"->",
"getParam",
"(",
"'action'",
")",
",",
"'prefix'",
"=>",
"$",
"request",
"->",
"getParam",
"(",
"'prefix'",
")",
",",
"'plugin'",
"=>",
"$",
"request",
"->",
"getParam",
"(",
"'plugin'",
")",
",",
"'controller'",
"=>",
"$",
"request",
"->",
"getParam",
"(",
"'controller'",
")",
",",
"]",
",",
"'query'",
"=>",
"$",
"this",
"->",
"request",
"->",
"getQueryParams",
"(",
")",
",",
"'base'",
"=>",
"$",
"request",
"->",
"getAttribute",
"(",
"'base'",
")",
",",
"'here'",
"=>",
"$",
"request",
"->",
"getRequestTarget",
"(",
")",
",",
"]",
"]",
";",
"$",
"this",
"->",
"Html",
"->",
"scriptBlock",
"(",
"'window.CMS = '",
".",
"json_encode",
"(",
"$",
"vars",
")",
",",
"[",
"'block'",
"=>",
"'css_bottom'",
"]",
")",
";",
"}"
] | Setup java script variables from server.
@return void | [
"Setup",
"java",
"script",
"variables",
"from",
"server",
"."
] | train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/JsHelper.php#L146-L173 |
alanpich/slender | src/Core/ModuleLoader/Factory.php | Factory.create | public function create(\Slender\App $app)
{
$loader = new ModuleLoader();
$loader->setResolver($app['module-resolver']);
$loader->setConfig($app['settings']);
$loader->setClassLoader($app['autoloader']);
return $loader;
} | php | public function create(\Slender\App $app)
{
$loader = new ModuleLoader();
$loader->setResolver($app['module-resolver']);
$loader->setConfig($app['settings']);
$loader->setClassLoader($app['autoloader']);
return $loader;
} | [
"public",
"function",
"create",
"(",
"\\",
"Slender",
"\\",
"App",
"$",
"app",
")",
"{",
"$",
"loader",
"=",
"new",
"ModuleLoader",
"(",
")",
";",
"$",
"loader",
"->",
"setResolver",
"(",
"$",
"app",
"[",
"'module-resolver'",
"]",
")",
";",
"$",
"loader",
"->",
"setConfig",
"(",
"$",
"app",
"[",
"'settings'",
"]",
")",
";",
"$",
"loader",
"->",
"setClassLoader",
"(",
"$",
"app",
"[",
"'autoloader'",
"]",
")",
";",
"return",
"$",
"loader",
";",
"}"
] | Create a ModuleLoader instance
@param \Slender\App $app Slender Application instance
@return ModuleLoader | [
"Create",
"a",
"ModuleLoader",
"instance"
] | train | https://github.com/alanpich/slender/blob/247f5c08af20cda95b116eb5d9f6f623d61e8a8a/src/Core/ModuleLoader/Factory.php#L52-L60 |
SachaMorard/phalcon-console | Library/Phalcon/Commands/CommandsListener.php | CommandsListener.beforeCommand | public function beforeCommand(Event $event, Command $command)
{
$parameters = $command->parseParameters([], ['h' => 'help']);
if (
count($parameters) < ($command->getRequiredParams() + 1) ||
$command->isReceivedOption(['help', 'h', '?']) ||
in_array($command->getOption(1), ['help', 'h', '?'])
) {
$command->getHelp();
return false;
}
if( !defined('BASE_PATH') ) {
throw new CommandsException('Commands need a BASE_PATH constant defined.');
}
if ($command->canBeExternal() == false) {
$path = $command->getOption('directory');
if (!file_exists($path.'.phalcon')) {
throw new CommandsException('This command should be invoked inside a Phalcon project directory.');
}
}
return true;
} | php | public function beforeCommand(Event $event, Command $command)
{
$parameters = $command->parseParameters([], ['h' => 'help']);
if (
count($parameters) < ($command->getRequiredParams() + 1) ||
$command->isReceivedOption(['help', 'h', '?']) ||
in_array($command->getOption(1), ['help', 'h', '?'])
) {
$command->getHelp();
return false;
}
if( !defined('BASE_PATH') ) {
throw new CommandsException('Commands need a BASE_PATH constant defined.');
}
if ($command->canBeExternal() == false) {
$path = $command->getOption('directory');
if (!file_exists($path.'.phalcon')) {
throw new CommandsException('This command should be invoked inside a Phalcon project directory.');
}
}
return true;
} | [
"public",
"function",
"beforeCommand",
"(",
"Event",
"$",
"event",
",",
"Command",
"$",
"command",
")",
"{",
"$",
"parameters",
"=",
"$",
"command",
"->",
"parseParameters",
"(",
"[",
"]",
",",
"[",
"'h'",
"=>",
"'help'",
"]",
")",
";",
"if",
"(",
"count",
"(",
"$",
"parameters",
")",
"<",
"(",
"$",
"command",
"->",
"getRequiredParams",
"(",
")",
"+",
"1",
")",
"||",
"$",
"command",
"->",
"isReceivedOption",
"(",
"[",
"'help'",
",",
"'h'",
",",
"'?'",
"]",
")",
"||",
"in_array",
"(",
"$",
"command",
"->",
"getOption",
"(",
"1",
")",
",",
"[",
"'help'",
",",
"'h'",
",",
"'?'",
"]",
")",
")",
"{",
"$",
"command",
"->",
"getHelp",
"(",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"defined",
"(",
"'BASE_PATH'",
")",
")",
"{",
"throw",
"new",
"CommandsException",
"(",
"'Commands need a BASE_PATH constant defined.'",
")",
";",
"}",
"if",
"(",
"$",
"command",
"->",
"canBeExternal",
"(",
")",
"==",
"false",
")",
"{",
"$",
"path",
"=",
"$",
"command",
"->",
"getOption",
"(",
"'directory'",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"path",
".",
"'.phalcon'",
")",
")",
"{",
"throw",
"new",
"CommandsException",
"(",
"'This command should be invoked inside a Phalcon project directory.'",
")",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Before command executing
@param Event $event
@param Command $command
@return bool
@throws CommandsException | [
"Before",
"command",
"executing"
] | train | https://github.com/SachaMorard/phalcon-console/blob/a7922e4c488ea19bc0ecce793e6f01cf9cf3c0c3/Library/Phalcon/Commands/CommandsListener.php#L41-L67 |
onigoetz/imagecache | src/Image.php | Image.getInfo | public function getInfo()
{
$this->info = [
'width' => $this->getWidth(),
'height' => $this->getHeight(),
'file_size' => $this->getFileSize(),
];
return $this->info;
} | php | public function getInfo()
{
$this->info = [
'width' => $this->getWidth(),
'height' => $this->getHeight(),
'file_size' => $this->getFileSize(),
];
return $this->info;
} | [
"public",
"function",
"getInfo",
"(",
")",
"{",
"$",
"this",
"->",
"info",
"=",
"[",
"'width'",
"=>",
"$",
"this",
"->",
"getWidth",
"(",
")",
",",
"'height'",
"=>",
"$",
"this",
"->",
"getHeight",
"(",
")",
",",
"'file_size'",
"=>",
"$",
"this",
"->",
"getFileSize",
"(",
")",
",",
"]",
";",
"return",
"$",
"this",
"->",
"info",
";",
"}"
] | Get details about an image.
@return bool|array false, if the file could not be found or is not an image. Otherwise, a keyed array containing information about the image:
- "width": Width, in pixels.
- "height": Height, in pixels.
- "file_size": File size in bytes. | [
"Get",
"details",
"about",
"an",
"image",
"."
] | train | https://github.com/onigoetz/imagecache/blob/8e22c11def1733819183e8296bab3c8a4ffc1d9c/src/Image.php#L106-L115 |
onigoetz/imagecache | src/Image.php | Image.scale_and_crop | public function scale_and_crop($width, $height)
{
if ($width === null) {
throw new \LogicException('"width" must not be null for "scale_and_crop"');
}
if ($height === null) {
throw new \LogicException('"height" must not be null for "scale_and_crop"');
}
$scale = max($width / $this->getWidth(), $height / $this->getHeight());
$w = ceil($this->getWidth() * $scale);
$h = ceil($this->getHeight() * $scale);
$x = ($w - $width) / 2;
$y = ($h - $height) / 2;
$this->resize($w, $h);
$this->crop($x, $y, $width, $height);
} | php | public function scale_and_crop($width, $height)
{
if ($width === null) {
throw new \LogicException('"width" must not be null for "scale_and_crop"');
}
if ($height === null) {
throw new \LogicException('"height" must not be null for "scale_and_crop"');
}
$scale = max($width / $this->getWidth(), $height / $this->getHeight());
$w = ceil($this->getWidth() * $scale);
$h = ceil($this->getHeight() * $scale);
$x = ($w - $width) / 2;
$y = ($h - $height) / 2;
$this->resize($w, $h);
$this->crop($x, $y, $width, $height);
} | [
"public",
"function",
"scale_and_crop",
"(",
"$",
"width",
",",
"$",
"height",
")",
"{",
"if",
"(",
"$",
"width",
"===",
"null",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'\"width\" must not be null for \"scale_and_crop\"'",
")",
";",
"}",
"if",
"(",
"$",
"height",
"===",
"null",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'\"height\" must not be null for \"scale_and_crop\"'",
")",
";",
"}",
"$",
"scale",
"=",
"max",
"(",
"$",
"width",
"/",
"$",
"this",
"->",
"getWidth",
"(",
")",
",",
"$",
"height",
"/",
"$",
"this",
"->",
"getHeight",
"(",
")",
")",
";",
"$",
"w",
"=",
"ceil",
"(",
"$",
"this",
"->",
"getWidth",
"(",
")",
"*",
"$",
"scale",
")",
";",
"$",
"h",
"=",
"ceil",
"(",
"$",
"this",
"->",
"getHeight",
"(",
")",
"*",
"$",
"scale",
")",
";",
"$",
"x",
"=",
"(",
"$",
"w",
"-",
"$",
"width",
")",
"/",
"2",
";",
"$",
"y",
"=",
"(",
"$",
"h",
"-",
"$",
"height",
")",
"/",
"2",
";",
"$",
"this",
"->",
"resize",
"(",
"$",
"w",
",",
"$",
"h",
")",
";",
"$",
"this",
"->",
"crop",
"(",
"$",
"x",
",",
"$",
"y",
",",
"$",
"width",
",",
"$",
"height",
")",
";",
"}"
] | Scales an image to the exact width and height given.
This function achieves the target aspect ratio by cropping the original image
equally on both sides, or equally on the top and bottom. This function is
useful to create uniform sized avatars from larger images.
The resulting image always has the exact target dimensions.
@param int $width The target width, in pixels.
@param int $height The target height, in pixels.
@throws \LogicException if the parameters are wrong
@see resize()
@see crop() | [
"Scales",
"an",
"image",
"to",
"the",
"exact",
"width",
"and",
"height",
"given",
"."
] | train | https://github.com/onigoetz/imagecache/blob/8e22c11def1733819183e8296bab3c8a4ffc1d9c/src/Image.php#L134-L152 |
onigoetz/imagecache | src/Image.php | Image.scale | public function scale($width = null, $height = null)
{
if ($width === null && $height === null) {
throw new \LogicException('one of "width" or "height" must be set for "scale"');
}
if ($width !== null && $height !== null) {
$this->resize($width, $height);
return;
}
if ($width !== null) {
$this->image->widen($width);
return;
}
$this->image->heighten($height);
} | php | public function scale($width = null, $height = null)
{
if ($width === null && $height === null) {
throw new \LogicException('one of "width" or "height" must be set for "scale"');
}
if ($width !== null && $height !== null) {
$this->resize($width, $height);
return;
}
if ($width !== null) {
$this->image->widen($width);
return;
}
$this->image->heighten($height);
} | [
"public",
"function",
"scale",
"(",
"$",
"width",
"=",
"null",
",",
"$",
"height",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"width",
"===",
"null",
"&&",
"$",
"height",
"===",
"null",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'one of \"width\" or \"height\" must be set for \"scale\"'",
")",
";",
"}",
"if",
"(",
"$",
"width",
"!==",
"null",
"&&",
"$",
"height",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"resize",
"(",
"$",
"width",
",",
"$",
"height",
")",
";",
"return",
";",
"}",
"if",
"(",
"$",
"width",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"image",
"->",
"widen",
"(",
"$",
"width",
")",
";",
"return",
";",
"}",
"$",
"this",
"->",
"image",
"->",
"heighten",
"(",
"$",
"height",
")",
";",
"}"
] | Scales an image to the given width and height while maintaining aspect ratio.
The resulting image can be smaller for one or both target dimensions.
@param int $width
The target width, in pixels. This value is omitted then the scaling will
based only on the height value.
@param int $height
The target height, in pixels. This value is omitted then the scaling will
based only on the width value. | [
"Scales",
"an",
"image",
"to",
"the",
"given",
"width",
"and",
"height",
"while",
"maintaining",
"aspect",
"ratio",
"."
] | train | https://github.com/onigoetz/imagecache/blob/8e22c11def1733819183e8296bab3c8a4ffc1d9c/src/Image.php#L166-L183 |
onigoetz/imagecache | src/Image.php | Image.rotate | public function rotate($degrees, $background = null, $random = false)
{
if ($background) {
$background = trim($background);
} else {
$background = "ffffff";
}
if ($random) {
$deg = abs((float) $degrees);
$degrees = rand(-1 * $deg, $deg);
}
$this->image->rotate($degrees, $background);
} | php | public function rotate($degrees, $background = null, $random = false)
{
if ($background) {
$background = trim($background);
} else {
$background = "ffffff";
}
if ($random) {
$deg = abs((float) $degrees);
$degrees = rand(-1 * $deg, $deg);
}
$this->image->rotate($degrees, $background);
} | [
"public",
"function",
"rotate",
"(",
"$",
"degrees",
",",
"$",
"background",
"=",
"null",
",",
"$",
"random",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"background",
")",
"{",
"$",
"background",
"=",
"trim",
"(",
"$",
"background",
")",
";",
"}",
"else",
"{",
"$",
"background",
"=",
"\"ffffff\"",
";",
"}",
"if",
"(",
"$",
"random",
")",
"{",
"$",
"deg",
"=",
"abs",
"(",
"(",
"float",
")",
"$",
"degrees",
")",
";",
"$",
"degrees",
"=",
"rand",
"(",
"-",
"1",
"*",
"$",
"deg",
",",
"$",
"deg",
")",
";",
"}",
"$",
"this",
"->",
"image",
"->",
"rotate",
"(",
"$",
"degrees",
",",
"$",
"background",
")",
";",
"}"
] | Rotate an image by the given number of degrees.
@param int $degrees The number of (clockwise) degrees to rotate the image.
@param string|null $background hexadecimal background color
@param bool $random | [
"Rotate",
"an",
"image",
"by",
"the",
"given",
"number",
"of",
"degrees",
"."
] | train | https://github.com/onigoetz/imagecache/blob/8e22c11def1733819183e8296bab3c8a4ffc1d9c/src/Image.php#L203-L217 |
onigoetz/imagecache | src/Image.php | Image.crop | public function crop($xoffset, $yoffset, $width, $height)
{
if ($xoffset === null) {
throw new \LogicException('"xoffset" must not be null for "crop"');
}
if ($yoffset === null) {
throw new \LogicException('"yoffset" must not be null for "crop"');
}
if ($width === null) {
throw new \LogicException('"width" must not be null for "crop"');
}
if ($height === null) {
throw new \LogicException('"height" must not be null for "crop"');
}
$this->image->crop($width, $height, $xoffset, $yoffset);
} | php | public function crop($xoffset, $yoffset, $width, $height)
{
if ($xoffset === null) {
throw new \LogicException('"xoffset" must not be null for "crop"');
}
if ($yoffset === null) {
throw new \LogicException('"yoffset" must not be null for "crop"');
}
if ($width === null) {
throw new \LogicException('"width" must not be null for "crop"');
}
if ($height === null) {
throw new \LogicException('"height" must not be null for "crop"');
}
$this->image->crop($width, $height, $xoffset, $yoffset);
} | [
"public",
"function",
"crop",
"(",
"$",
"xoffset",
",",
"$",
"yoffset",
",",
"$",
"width",
",",
"$",
"height",
")",
"{",
"if",
"(",
"$",
"xoffset",
"===",
"null",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'\"xoffset\" must not be null for \"crop\"'",
")",
";",
"}",
"if",
"(",
"$",
"yoffset",
"===",
"null",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'\"yoffset\" must not be null for \"crop\"'",
")",
";",
"}",
"if",
"(",
"$",
"width",
"===",
"null",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'\"width\" must not be null for \"crop\"'",
")",
";",
"}",
"if",
"(",
"$",
"height",
"===",
"null",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'\"height\" must not be null for \"crop\"'",
")",
";",
"}",
"$",
"this",
"->",
"image",
"->",
"crop",
"(",
"$",
"width",
",",
"$",
"height",
",",
"$",
"xoffset",
",",
"$",
"yoffset",
")",
";",
"}"
] | Crop an image to the rectangle specified by the given rectangle.
@param int $xoffset
The top left coordinate, in pixels, of the crop area (x axis value).
@param int $yoffset
The top left coordinate, in pixels, of the crop area (y axis value).
@param int $width
The target width, in pixels.
@param int $height
The target height, in pixels.
@throws \LogicException if the parameters are wrong | [
"Crop",
"an",
"image",
"to",
"the",
"rectangle",
"specified",
"by",
"the",
"given",
"rectangle",
"."
] | train | https://github.com/onigoetz/imagecache/blob/8e22c11def1733819183e8296bab3c8a4ffc1d9c/src/Image.php#L233-L252 |
onigoetz/imagecache | src/Image.php | Image.save | public function save($destination = null)
{
if (empty($destination)) {
$destination = $this->source;
}
$this->image->save($destination);
// Clear the cached file size and refresh the image information.
clearstatcache();
chmod($destination, 0644);
return new self($destination);
} | php | public function save($destination = null)
{
if (empty($destination)) {
$destination = $this->source;
}
$this->image->save($destination);
// Clear the cached file size and refresh the image information.
clearstatcache();
chmod($destination, 0644);
return new self($destination);
} | [
"public",
"function",
"save",
"(",
"$",
"destination",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"destination",
")",
")",
"{",
"$",
"destination",
"=",
"$",
"this",
"->",
"source",
";",
"}",
"$",
"this",
"->",
"image",
"->",
"save",
"(",
"$",
"destination",
")",
";",
"// Clear the cached file size and refresh the image information.",
"clearstatcache",
"(",
")",
";",
"chmod",
"(",
"$",
"destination",
",",
"0644",
")",
";",
"return",
"new",
"self",
"(",
"$",
"destination",
")",
";",
"}"
] | Close the image and save the changes to a file.
@param string|null $destination Destination path where the image should be saved. If it is empty the original image file will be overwritten.
@throws \RuntimeException
@return Image image or false, based on success. | [
"Close",
"the",
"image",
"and",
"save",
"the",
"changes",
"to",
"a",
"file",
"."
] | train | https://github.com/onigoetz/imagecache/blob/8e22c11def1733819183e8296bab3c8a4ffc1d9c/src/Image.php#L269-L283 |
aedart/laravel-helpers | src/Traits/Events/EventTrait.php | EventTrait.getEvent | public function getEvent(): ?Dispatcher
{
if (!$this->hasEvent()) {
$this->setEvent($this->getDefaultEvent());
}
return $this->event;
} | php | public function getEvent(): ?Dispatcher
{
if (!$this->hasEvent()) {
$this->setEvent($this->getDefaultEvent());
}
return $this->event;
} | [
"public",
"function",
"getEvent",
"(",
")",
":",
"?",
"Dispatcher",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasEvent",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setEvent",
"(",
"$",
"this",
"->",
"getDefaultEvent",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"event",
";",
"}"
] | Get event
If no event has been set, this method will
set and return a default event, if any such
value is available
@see getDefaultEvent()
@return Dispatcher|null event or null if none event has been set | [
"Get",
"event"
] | train | https://github.com/aedart/laravel-helpers/blob/8b81a2d6658f3f8cb62b6be2c34773aaa2df219a/src/Traits/Events/EventTrait.php#L53-L59 |
FuriosoJack/LaraException | src/ExceptionFather.php | ExceptionFather.isJsonRequest | private function isJsonRequest(): bool
{
if((request()->hasHeader('Content-Type') && 'application/json' == request()->header('Content-Type')) || (request()->hasHeader('accept') && request()->header('accept') == 'application/json') ){
return true;
}
return false;
} | php | private function isJsonRequest(): bool
{
if((request()->hasHeader('Content-Type') && 'application/json' == request()->header('Content-Type')) || (request()->hasHeader('accept') && request()->header('accept') == 'application/json') ){
return true;
}
return false;
} | [
"private",
"function",
"isJsonRequest",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"(",
"request",
"(",
")",
"->",
"hasHeader",
"(",
"'Content-Type'",
")",
"&&",
"'application/json'",
"==",
"request",
"(",
")",
"->",
"header",
"(",
"'Content-Type'",
")",
")",
"||",
"(",
"request",
"(",
")",
"->",
"hasHeader",
"(",
"'accept'",
")",
"&&",
"request",
"(",
")",
"->",
"header",
"(",
"'accept'",
")",
"==",
"'application/json'",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Valida si en los headers existe el application/json
@return bool | [
"Valida",
"si",
"en",
"los",
"headers",
"existe",
"el",
"application",
"/",
"json"
] | train | https://github.com/FuriosoJack/LaraException/blob/b30ec2ed3331d99fca4d0ae47c8710a522bd0c19/src/ExceptionFather.php#L180-L187 |
FuriosoJack/LaraException | src/ExceptionFather.php | ExceptionFather.buildException | private function buildException()
{
if($this->isJsonRequest()){
$this->setException(new ExceptionJson($this->message,$this->debugCode,$this->details,$this->errors));
}else{
$exception = new ExceptionView($this->message,$this->debugCode,$this->details,$this->errors);
$exception->setViewPath($this->getVewPath());
$exception->setRedirectPath($this->getRedirect());
$this->setException($exception);
}
} | php | private function buildException()
{
if($this->isJsonRequest()){
$this->setException(new ExceptionJson($this->message,$this->debugCode,$this->details,$this->errors));
}else{
$exception = new ExceptionView($this->message,$this->debugCode,$this->details,$this->errors);
$exception->setViewPath($this->getVewPath());
$exception->setRedirectPath($this->getRedirect());
$this->setException($exception);
}
} | [
"private",
"function",
"buildException",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isJsonRequest",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setException",
"(",
"new",
"ExceptionJson",
"(",
"$",
"this",
"->",
"message",
",",
"$",
"this",
"->",
"debugCode",
",",
"$",
"this",
"->",
"details",
",",
"$",
"this",
"->",
"errors",
")",
")",
";",
"}",
"else",
"{",
"$",
"exception",
"=",
"new",
"ExceptionView",
"(",
"$",
"this",
"->",
"message",
",",
"$",
"this",
"->",
"debugCode",
",",
"$",
"this",
"->",
"details",
",",
"$",
"this",
"->",
"errors",
")",
";",
"$",
"exception",
"->",
"setViewPath",
"(",
"$",
"this",
"->",
"getVewPath",
"(",
")",
")",
";",
"$",
"exception",
"->",
"setRedirectPath",
"(",
"$",
"this",
"->",
"getRedirect",
"(",
")",
")",
";",
"$",
"this",
"->",
"setException",
"(",
"$",
"exception",
")",
";",
"}",
"}"
] | Se encarga de construir el objeto de la excepcion | [
"Se",
"encarga",
"de",
"construir",
"el",
"objeto",
"de",
"la",
"excepcion"
] | train | https://github.com/FuriosoJack/LaraException/blob/b30ec2ed3331d99fca4d0ae47c8710a522bd0c19/src/ExceptionFather.php#L203-L213 |
FuriosoJack/LaraException | src/ExceptionFather.php | ExceptionFather.build | public function build(int $httpCode = 200)
{
//Lo primero que todo
$this->buildException();
if($this->log){
$this->renderLog();
}
if(!$this->showDetails){
$this->getException()->setDetails(null);
}
if(!$this->showErrors){
$this->getException()->setErrors(null);
}
$this->getException()->setHttpCode($httpCode);
throw $this->getException();
} | php | public function build(int $httpCode = 200)
{
//Lo primero que todo
$this->buildException();
if($this->log){
$this->renderLog();
}
if(!$this->showDetails){
$this->getException()->setDetails(null);
}
if(!$this->showErrors){
$this->getException()->setErrors(null);
}
$this->getException()->setHttpCode($httpCode);
throw $this->getException();
} | [
"public",
"function",
"build",
"(",
"int",
"$",
"httpCode",
"=",
"200",
")",
"{",
"//Lo primero que todo",
"$",
"this",
"->",
"buildException",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"log",
")",
"{",
"$",
"this",
"->",
"renderLog",
"(",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"showDetails",
")",
"{",
"$",
"this",
"->",
"getException",
"(",
")",
"->",
"setDetails",
"(",
"null",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"showErrors",
")",
"{",
"$",
"this",
"->",
"getException",
"(",
")",
"->",
"setErrors",
"(",
"null",
")",
";",
"}",
"$",
"this",
"->",
"getException",
"(",
")",
"->",
"setHttpCode",
"(",
"$",
"httpCode",
")",
";",
"throw",
"$",
"this",
"->",
"getException",
"(",
")",
";",
"}"
] | Se encarga de le ejecucion para la contruccion de la escepcion
@throws ExceptionJSON
@throws ExceptionVIEW | [
"Se",
"encarga",
"de",
"le",
"ejecucion",
"para",
"la",
"contruccion",
"de",
"la",
"escepcion"
] | train | https://github.com/FuriosoJack/LaraException/blob/b30ec2ed3331d99fca4d0ae47c8710a522bd0c19/src/ExceptionFather.php#L243-L263 |
Articus/DataTransfer | src/Articus/DataTransfer/Service.php | Service.transfer | public function transfer($fromObjectOrArray, &$toObjectOrArray, $mapper = null, $fromSubset = '', $toSubset = '')
{
$result = [];
$data = null;
//Extract data array
switch (true)
{
case is_object($fromObjectOrArray):
$fromMetadata = $this->metadataReader->getMetadata(get_class($fromObjectOrArray), $fromSubset);
$fromHydrator = $this->getHydrator($fromMetadata);
$data = $fromHydrator->extract($fromObjectOrArray);
break;
case is_array($fromObjectOrArray):
$data = &$fromObjectOrArray;
break;
default:
throw new \InvalidArgumentException('Data transfer is possible only from object or array.');
}
//Map data array
if (is_callable($mapper) || ($mapper instanceof Mapper\MapperInterface))
{
$data = $mapper($data);
if (!is_array($data))
{
throw new \LogicException(
sprintf('Invalid mapping: expecting array result, not %s.', gettype($data))
);
}
}
//Validate and hydrate data array
switch (true)
{
case is_object($toObjectOrArray):
$toMetadata = $this->metadataReader->getMetadata(get_class($toObjectOrArray), $toSubset);
$toHydrator = $this->getHydrator($toMetadata);
$validator = $this->getValidator($toMetadata);
$result = $validator->validate(self::arrayTransfer($toHydrator->extract($toObjectOrArray), $data));
if (empty($result))
{
$toObjectOrArray = $toHydrator->hydrate($data, $toObjectOrArray);
}
break;
case is_array($toObjectOrArray):
$toObjectOrArray = self::arrayTransfer($toObjectOrArray, $data);
break;
default:
throw new \InvalidArgumentException('Data transfer is possible only to object or array.');
}
return $result;
} | php | public function transfer($fromObjectOrArray, &$toObjectOrArray, $mapper = null, $fromSubset = '', $toSubset = '')
{
$result = [];
$data = null;
//Extract data array
switch (true)
{
case is_object($fromObjectOrArray):
$fromMetadata = $this->metadataReader->getMetadata(get_class($fromObjectOrArray), $fromSubset);
$fromHydrator = $this->getHydrator($fromMetadata);
$data = $fromHydrator->extract($fromObjectOrArray);
break;
case is_array($fromObjectOrArray):
$data = &$fromObjectOrArray;
break;
default:
throw new \InvalidArgumentException('Data transfer is possible only from object or array.');
}
//Map data array
if (is_callable($mapper) || ($mapper instanceof Mapper\MapperInterface))
{
$data = $mapper($data);
if (!is_array($data))
{
throw new \LogicException(
sprintf('Invalid mapping: expecting array result, not %s.', gettype($data))
);
}
}
//Validate and hydrate data array
switch (true)
{
case is_object($toObjectOrArray):
$toMetadata = $this->metadataReader->getMetadata(get_class($toObjectOrArray), $toSubset);
$toHydrator = $this->getHydrator($toMetadata);
$validator = $this->getValidator($toMetadata);
$result = $validator->validate(self::arrayTransfer($toHydrator->extract($toObjectOrArray), $data));
if (empty($result))
{
$toObjectOrArray = $toHydrator->hydrate($data, $toObjectOrArray);
}
break;
case is_array($toObjectOrArray):
$toObjectOrArray = self::arrayTransfer($toObjectOrArray, $data);
break;
default:
throw new \InvalidArgumentException('Data transfer is possible only to object or array.');
}
return $result;
} | [
"public",
"function",
"transfer",
"(",
"$",
"fromObjectOrArray",
",",
"&",
"$",
"toObjectOrArray",
",",
"$",
"mapper",
"=",
"null",
",",
"$",
"fromSubset",
"=",
"''",
",",
"$",
"toSubset",
"=",
"''",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"$",
"data",
"=",
"null",
";",
"//Extract data array",
"switch",
"(",
"true",
")",
"{",
"case",
"is_object",
"(",
"$",
"fromObjectOrArray",
")",
":",
"$",
"fromMetadata",
"=",
"$",
"this",
"->",
"metadataReader",
"->",
"getMetadata",
"(",
"get_class",
"(",
"$",
"fromObjectOrArray",
")",
",",
"$",
"fromSubset",
")",
";",
"$",
"fromHydrator",
"=",
"$",
"this",
"->",
"getHydrator",
"(",
"$",
"fromMetadata",
")",
";",
"$",
"data",
"=",
"$",
"fromHydrator",
"->",
"extract",
"(",
"$",
"fromObjectOrArray",
")",
";",
"break",
";",
"case",
"is_array",
"(",
"$",
"fromObjectOrArray",
")",
":",
"$",
"data",
"=",
"&",
"$",
"fromObjectOrArray",
";",
"break",
";",
"default",
":",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Data transfer is possible only from object or array.'",
")",
";",
"}",
"//Map data array",
"if",
"(",
"is_callable",
"(",
"$",
"mapper",
")",
"||",
"(",
"$",
"mapper",
"instanceof",
"Mapper",
"\\",
"MapperInterface",
")",
")",
"{",
"$",
"data",
"=",
"$",
"mapper",
"(",
"$",
"data",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'Invalid mapping: expecting array result, not %s.'",
",",
"gettype",
"(",
"$",
"data",
")",
")",
")",
";",
"}",
"}",
"//Validate and hydrate data array",
"switch",
"(",
"true",
")",
"{",
"case",
"is_object",
"(",
"$",
"toObjectOrArray",
")",
":",
"$",
"toMetadata",
"=",
"$",
"this",
"->",
"metadataReader",
"->",
"getMetadata",
"(",
"get_class",
"(",
"$",
"toObjectOrArray",
")",
",",
"$",
"toSubset",
")",
";",
"$",
"toHydrator",
"=",
"$",
"this",
"->",
"getHydrator",
"(",
"$",
"toMetadata",
")",
";",
"$",
"validator",
"=",
"$",
"this",
"->",
"getValidator",
"(",
"$",
"toMetadata",
")",
";",
"$",
"result",
"=",
"$",
"validator",
"->",
"validate",
"(",
"self",
"::",
"arrayTransfer",
"(",
"$",
"toHydrator",
"->",
"extract",
"(",
"$",
"toObjectOrArray",
")",
",",
"$",
"data",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"result",
")",
")",
"{",
"$",
"toObjectOrArray",
"=",
"$",
"toHydrator",
"->",
"hydrate",
"(",
"$",
"data",
",",
"$",
"toObjectOrArray",
")",
";",
"}",
"break",
";",
"case",
"is_array",
"(",
"$",
"toObjectOrArray",
")",
":",
"$",
"toObjectOrArray",
"=",
"self",
"::",
"arrayTransfer",
"(",
"$",
"toObjectOrArray",
",",
"$",
"data",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Data transfer is possible only to object or array.'",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Transfers data from source to destination safely.
@param array|object $fromObjectOrArray
@param array|object $toObjectOrArray
@param Mapper\MapperInterface|callable $mapper
@param string $fromSubset
@param string $toSubset
@return array - validation messages if transfer failed | [
"Transfers",
"data",
"from",
"source",
"to",
"destination",
"safely",
"."
] | train | https://github.com/Articus/DataTransfer/blob/c119666fa042f7e9f311c3bc1e9a1d0468b9992d/src/Articus/DataTransfer/Service.php#L116-L170 |
Articus/DataTransfer | src/Articus/DataTransfer/Service.php | Service.getHydrator | public function getHydrator(Metadata $metadata)
{
if (!isset($this->hydrators[$metadata->className][$metadata->subset]))
{
$hydrator = new Hydrator();
$hydrator
->setStrategyPluginManager($this->strategyPluginManager)
->setMetadata($metadata)
;
$this->hydrators[$metadata->className][$metadata->subset] = $hydrator;
}
return $this->hydrators[$metadata->className][$metadata->subset];
} | php | public function getHydrator(Metadata $metadata)
{
if (!isset($this->hydrators[$metadata->className][$metadata->subset]))
{
$hydrator = new Hydrator();
$hydrator
->setStrategyPluginManager($this->strategyPluginManager)
->setMetadata($metadata)
;
$this->hydrators[$metadata->className][$metadata->subset] = $hydrator;
}
return $this->hydrators[$metadata->className][$metadata->subset];
} | [
"public",
"function",
"getHydrator",
"(",
"Metadata",
"$",
"metadata",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"hydrators",
"[",
"$",
"metadata",
"->",
"className",
"]",
"[",
"$",
"metadata",
"->",
"subset",
"]",
")",
")",
"{",
"$",
"hydrator",
"=",
"new",
"Hydrator",
"(",
")",
";",
"$",
"hydrator",
"->",
"setStrategyPluginManager",
"(",
"$",
"this",
"->",
"strategyPluginManager",
")",
"->",
"setMetadata",
"(",
"$",
"metadata",
")",
";",
"$",
"this",
"->",
"hydrators",
"[",
"$",
"metadata",
"->",
"className",
"]",
"[",
"$",
"metadata",
"->",
"subset",
"]",
"=",
"$",
"hydrator",
";",
"}",
"return",
"$",
"this",
"->",
"hydrators",
"[",
"$",
"metadata",
"->",
"className",
"]",
"[",
"$",
"metadata",
"->",
"subset",
"]",
";",
"}"
] | Returns hydrator required by metadata
@param Metadata $metadata
@return Hydrator | [
"Returns",
"hydrator",
"required",
"by",
"metadata"
] | train | https://github.com/Articus/DataTransfer/blob/c119666fa042f7e9f311c3bc1e9a1d0468b9992d/src/Articus/DataTransfer/Service.php#L177-L189 |
Articus/DataTransfer | src/Articus/DataTransfer/Service.php | Service.getValidator | public function getValidator(Metadata $metadata)
{
if (!isset($this->validators[$metadata->className][$metadata->subset]))
{
$validator = new Validator();
$validator
->setValidatorPluginManager($this->validatorPluginManager)
->setMetadata($metadata)
;
$this->validators[$metadata->className][$metadata->subset] = $validator;
}
return $this->validators[$metadata->className][$metadata->subset];
} | php | public function getValidator(Metadata $metadata)
{
if (!isset($this->validators[$metadata->className][$metadata->subset]))
{
$validator = new Validator();
$validator
->setValidatorPluginManager($this->validatorPluginManager)
->setMetadata($metadata)
;
$this->validators[$metadata->className][$metadata->subset] = $validator;
}
return $this->validators[$metadata->className][$metadata->subset];
} | [
"public",
"function",
"getValidator",
"(",
"Metadata",
"$",
"metadata",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"validators",
"[",
"$",
"metadata",
"->",
"className",
"]",
"[",
"$",
"metadata",
"->",
"subset",
"]",
")",
")",
"{",
"$",
"validator",
"=",
"new",
"Validator",
"(",
")",
";",
"$",
"validator",
"->",
"setValidatorPluginManager",
"(",
"$",
"this",
"->",
"validatorPluginManager",
")",
"->",
"setMetadata",
"(",
"$",
"metadata",
")",
";",
"$",
"this",
"->",
"validators",
"[",
"$",
"metadata",
"->",
"className",
"]",
"[",
"$",
"metadata",
"->",
"subset",
"]",
"=",
"$",
"validator",
";",
"}",
"return",
"$",
"this",
"->",
"validators",
"[",
"$",
"metadata",
"->",
"className",
"]",
"[",
"$",
"metadata",
"->",
"subset",
"]",
";",
"}"
] | Returns validator required by metadata
@param Metadata $metadata
@return Validator | [
"Returns",
"validator",
"required",
"by",
"metadata"
] | train | https://github.com/Articus/DataTransfer/blob/c119666fa042f7e9f311c3bc1e9a1d0468b9992d/src/Articus/DataTransfer/Service.php#L196-L208 |
Articus/DataTransfer | src/Articus/DataTransfer/Service.php | Service.arrayTransfer | static public function arrayTransfer(array $a, array $b)
{
if (ArrayUtils::isList($b, ArrayUtils::isList($a)))
{
$a = $b;
}
else
{
foreach ($b as $key => $value)
{
if (array_key_exists($key, $a) && is_array($value) && is_array($a[$key]))
{
$a[$key] = self::arrayTransfer($a[$key], $value);
}
else
{
$a[$key] = $value;
}
}
}
return $a;
} | php | static public function arrayTransfer(array $a, array $b)
{
if (ArrayUtils::isList($b, ArrayUtils::isList($a)))
{
$a = $b;
}
else
{
foreach ($b as $key => $value)
{
if (array_key_exists($key, $a) && is_array($value) && is_array($a[$key]))
{
$a[$key] = self::arrayTransfer($a[$key], $value);
}
else
{
$a[$key] = $value;
}
}
}
return $a;
} | [
"static",
"public",
"function",
"arrayTransfer",
"(",
"array",
"$",
"a",
",",
"array",
"$",
"b",
")",
"{",
"if",
"(",
"ArrayUtils",
"::",
"isList",
"(",
"$",
"b",
",",
"ArrayUtils",
"::",
"isList",
"(",
"$",
"a",
")",
")",
")",
"{",
"$",
"a",
"=",
"$",
"b",
";",
"}",
"else",
"{",
"foreach",
"(",
"$",
"b",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"a",
")",
"&&",
"is_array",
"(",
"$",
"value",
")",
"&&",
"is_array",
"(",
"$",
"a",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"a",
"[",
"$",
"key",
"]",
"=",
"self",
"::",
"arrayTransfer",
"(",
"$",
"a",
"[",
"$",
"key",
"]",
",",
"$",
"value",
")",
";",
"}",
"else",
"{",
"$",
"a",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"}",
"return",
"$",
"a",
";",
"}"
] | Simple data transfer from one array to the other
@param array $a
@param array $b
@return array | [
"Simple",
"data",
"transfer",
"from",
"one",
"array",
"to",
"the",
"other"
] | train | https://github.com/Articus/DataTransfer/blob/c119666fa042f7e9f311c3bc1e9a1d0468b9992d/src/Articus/DataTransfer/Service.php#L216-L237 |
zodream/thirdparty | src/API/Microsoft.php | Microsoft.faceScore | public function faceScore($img) {
/**
* {"Host":"","Url":""}
*/
$data = $this->getUpload()->parameters($img)->json();
$this->set(array(
'MsgId' => time().'063',
'CreateTime' => time(),
'Content[imageUrl]' => $data['Host'].$data['Url']
));
return $this->getFaceScore()
->parameters($this->get())->json();
} | php | public function faceScore($img) {
/**
* {"Host":"","Url":""}
*/
$data = $this->getUpload()->parameters($img)->json();
$this->set(array(
'MsgId' => time().'063',
'CreateTime' => time(),
'Content[imageUrl]' => $data['Host'].$data['Url']
));
return $this->getFaceScore()
->parameters($this->get())->json();
} | [
"public",
"function",
"faceScore",
"(",
"$",
"img",
")",
"{",
"/**\n * {\"Host\":\"\",\"Url\":\"\"}\n */",
"$",
"data",
"=",
"$",
"this",
"->",
"getUpload",
"(",
")",
"->",
"parameters",
"(",
"$",
"img",
")",
"->",
"json",
"(",
")",
";",
"$",
"this",
"->",
"set",
"(",
"array",
"(",
"'MsgId'",
"=>",
"time",
"(",
")",
".",
"'063'",
",",
"'CreateTime'",
"=>",
"time",
"(",
")",
",",
"'Content[imageUrl]'",
"=>",
"$",
"data",
"[",
"'Host'",
"]",
".",
"$",
"data",
"[",
"'Url'",
"]",
")",
")",
";",
"return",
"$",
"this",
"->",
"getFaceScore",
"(",
")",
"->",
"parameters",
"(",
"$",
"this",
"->",
"get",
"(",
")",
")",
"->",
"json",
"(",
")",
";",
"}"
] | 颜值测试
@param string $img base64_encode
@return array
@throws \Exception | [
"颜值测试"
] | train | https://github.com/zodream/thirdparty/blob/b9d39087913850f1c5c7c9165105fec22a128f8f/src/API/Microsoft.php#L34-L46 |
spiral-modules/phpFastCache-bridge | source/PhpFastCacheModule.php | PhpFastCacheModule.publish | public function publish(PublisherInterface $publisher, DirectoriesInterface $directories)
{
$publisher->publish(
__DIR__ . '/config/cache.php',
$directories->directory('config') . Config::CONFIG . '.php',
PublisherInterface::FOLLOW
);
} | php | public function publish(PublisherInterface $publisher, DirectoriesInterface $directories)
{
$publisher->publish(
__DIR__ . '/config/cache.php',
$directories->directory('config') . Config::CONFIG . '.php',
PublisherInterface::FOLLOW
);
} | [
"public",
"function",
"publish",
"(",
"PublisherInterface",
"$",
"publisher",
",",
"DirectoriesInterface",
"$",
"directories",
")",
"{",
"$",
"publisher",
"->",
"publish",
"(",
"__DIR__",
".",
"'/config/cache.php'",
",",
"$",
"directories",
"->",
"directory",
"(",
"'config'",
")",
".",
"Config",
"::",
"CONFIG",
".",
"'.php'",
",",
"PublisherInterface",
"::",
"FOLLOW",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/spiral-modules/phpFastCache-bridge/blob/d4ffa95daf9e04b79f50486cba6c9857918c2b79/source/PhpFastCacheModule.php#L23-L30 |
PeekAndPoke/psi | src/Psi/Str/IsStartingWith.php | IsStartingWith.match | public function match($needle, $haystack)
{
$len = strlen($needle);
/** @noinspection SubStrUsedAsStrPosInspection */
return $len === 0 || substr($haystack, 0, $len) === $needle;
} | php | public function match($needle, $haystack)
{
$len = strlen($needle);
/** @noinspection SubStrUsedAsStrPosInspection */
return $len === 0 || substr($haystack, 0, $len) === $needle;
} | [
"public",
"function",
"match",
"(",
"$",
"needle",
",",
"$",
"haystack",
")",
"{",
"$",
"len",
"=",
"strlen",
"(",
"$",
"needle",
")",
";",
"/** @noinspection SubStrUsedAsStrPosInspection */",
"return",
"$",
"len",
"===",
"0",
"||",
"substr",
"(",
"$",
"haystack",
",",
"0",
",",
"$",
"len",
")",
"===",
"$",
"needle",
";",
"}"
] | @param string $needle
@param string $haystack
@return bool | [
"@param",
"string",
"$needle",
"@param",
"string",
"$haystack"
] | train | https://github.com/PeekAndPoke/psi/blob/cfd45d995d3a2c2ea6ba5b1ce7b5fcc71179456f/src/Psi/Str/IsStartingWith.php#L21-L27 |
PeekAndPoke/psi | src/DefaultSolver.php | DefaultSolver.solve | public function solve(\Iterator $operations, \Iterator $items)
{
// search for all UnaryOperations
$tempResult = $items;
$unaryChain = new \ArrayIterator();
foreach ($operations as $operation) {
// collect all unary operators
if ($operation instanceof IntermediateOperation) {
$unaryChain->append($operation);
} else {
// execute all the collected unary operations
if ($unaryChain->count() > 0) {
$tempResult = $this->solveIntermediateOperationChain($unaryChain, $tempResult);
$unaryChain = new \ArrayIterator();
}
// execute full set operations (like sort)
if ($operation instanceof FullSetOperation) {
$tempResult = $operation->apply($tempResult);
}
}
}
// resolve the rest of the unary operation
if ($unaryChain->count() > 0) {
$tempResult = $this->solveIntermediateOperationChain($unaryChain, $tempResult);
}
return $tempResult;
} | php | public function solve(\Iterator $operations, \Iterator $items)
{
// search for all UnaryOperations
$tempResult = $items;
$unaryChain = new \ArrayIterator();
foreach ($operations as $operation) {
// collect all unary operators
if ($operation instanceof IntermediateOperation) {
$unaryChain->append($operation);
} else {
// execute all the collected unary operations
if ($unaryChain->count() > 0) {
$tempResult = $this->solveIntermediateOperationChain($unaryChain, $tempResult);
$unaryChain = new \ArrayIterator();
}
// execute full set operations (like sort)
if ($operation instanceof FullSetOperation) {
$tempResult = $operation->apply($tempResult);
}
}
}
// resolve the rest of the unary operation
if ($unaryChain->count() > 0) {
$tempResult = $this->solveIntermediateOperationChain($unaryChain, $tempResult);
}
return $tempResult;
} | [
"public",
"function",
"solve",
"(",
"\\",
"Iterator",
"$",
"operations",
",",
"\\",
"Iterator",
"$",
"items",
")",
"{",
"// search for all UnaryOperations",
"$",
"tempResult",
"=",
"$",
"items",
";",
"$",
"unaryChain",
"=",
"new",
"\\",
"ArrayIterator",
"(",
")",
";",
"foreach",
"(",
"$",
"operations",
"as",
"$",
"operation",
")",
"{",
"// collect all unary operators",
"if",
"(",
"$",
"operation",
"instanceof",
"IntermediateOperation",
")",
"{",
"$",
"unaryChain",
"->",
"append",
"(",
"$",
"operation",
")",
";",
"}",
"else",
"{",
"// execute all the collected unary operations",
"if",
"(",
"$",
"unaryChain",
"->",
"count",
"(",
")",
">",
"0",
")",
"{",
"$",
"tempResult",
"=",
"$",
"this",
"->",
"solveIntermediateOperationChain",
"(",
"$",
"unaryChain",
",",
"$",
"tempResult",
")",
";",
"$",
"unaryChain",
"=",
"new",
"\\",
"ArrayIterator",
"(",
")",
";",
"}",
"// execute full set operations (like sort)",
"if",
"(",
"$",
"operation",
"instanceof",
"FullSetOperation",
")",
"{",
"$",
"tempResult",
"=",
"$",
"operation",
"->",
"apply",
"(",
"$",
"tempResult",
")",
";",
"}",
"}",
"}",
"// resolve the rest of the unary operation",
"if",
"(",
"$",
"unaryChain",
"->",
"count",
"(",
")",
">",
"0",
")",
"{",
"$",
"tempResult",
"=",
"$",
"this",
"->",
"solveIntermediateOperationChain",
"(",
"$",
"unaryChain",
",",
"$",
"tempResult",
")",
";",
"}",
"return",
"$",
"tempResult",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/PeekAndPoke/psi/blob/cfd45d995d3a2c2ea6ba5b1ce7b5fcc71179456f/src/DefaultSolver.php#L20-L52 |
PeekAndPoke/psi | src/DefaultSolver.php | DefaultSolver.solveIntermediateOperationChain | private function solveIntermediateOperationChain(\Iterator $operatorChain, \Iterator $input)
{
$results = new \ArrayIterator();
$input->rewind();
$context = new Solver\IntermediateContext();
$continueWithNextItem = true;
while ($continueWithNextItem && $input->valid()) {
$result = $input->current();
$context->outUseItem = true;
// do the whole intermediate operation chain for the current input
$operatorChain->rewind();
while ($context->outUseItem && $operatorChain->valid()) {
/** @var IntermediateOperation $current */
$current = $operatorChain->current();
// apply intermediate operations
$result = $current->apply($result, $input->key(), $context);
// track the continuation flags
$continueWithNextItem = $continueWithNextItem && $context->outCanContinue;
// iterate
$operatorChain->next();
}
if ($context->outUseItem) {
$results->offsetSet($input->key(), $result);
}
// goto next item
$input->next();
}
return $results;
} | php | private function solveIntermediateOperationChain(\Iterator $operatorChain, \Iterator $input)
{
$results = new \ArrayIterator();
$input->rewind();
$context = new Solver\IntermediateContext();
$continueWithNextItem = true;
while ($continueWithNextItem && $input->valid()) {
$result = $input->current();
$context->outUseItem = true;
// do the whole intermediate operation chain for the current input
$operatorChain->rewind();
while ($context->outUseItem && $operatorChain->valid()) {
/** @var IntermediateOperation $current */
$current = $operatorChain->current();
// apply intermediate operations
$result = $current->apply($result, $input->key(), $context);
// track the continuation flags
$continueWithNextItem = $continueWithNextItem && $context->outCanContinue;
// iterate
$operatorChain->next();
}
if ($context->outUseItem) {
$results->offsetSet($input->key(), $result);
}
// goto next item
$input->next();
}
return $results;
} | [
"private",
"function",
"solveIntermediateOperationChain",
"(",
"\\",
"Iterator",
"$",
"operatorChain",
",",
"\\",
"Iterator",
"$",
"input",
")",
"{",
"$",
"results",
"=",
"new",
"\\",
"ArrayIterator",
"(",
")",
";",
"$",
"input",
"->",
"rewind",
"(",
")",
";",
"$",
"context",
"=",
"new",
"Solver",
"\\",
"IntermediateContext",
"(",
")",
";",
"$",
"continueWithNextItem",
"=",
"true",
";",
"while",
"(",
"$",
"continueWithNextItem",
"&&",
"$",
"input",
"->",
"valid",
"(",
")",
")",
"{",
"$",
"result",
"=",
"$",
"input",
"->",
"current",
"(",
")",
";",
"$",
"context",
"->",
"outUseItem",
"=",
"true",
";",
"// do the whole intermediate operation chain for the current input",
"$",
"operatorChain",
"->",
"rewind",
"(",
")",
";",
"while",
"(",
"$",
"context",
"->",
"outUseItem",
"&&",
"$",
"operatorChain",
"->",
"valid",
"(",
")",
")",
"{",
"/** @var IntermediateOperation $current */",
"$",
"current",
"=",
"$",
"operatorChain",
"->",
"current",
"(",
")",
";",
"// apply intermediate operations",
"$",
"result",
"=",
"$",
"current",
"->",
"apply",
"(",
"$",
"result",
",",
"$",
"input",
"->",
"key",
"(",
")",
",",
"$",
"context",
")",
";",
"// track the continuation flags",
"$",
"continueWithNextItem",
"=",
"$",
"continueWithNextItem",
"&&",
"$",
"context",
"->",
"outCanContinue",
";",
"// iterate",
"$",
"operatorChain",
"->",
"next",
"(",
")",
";",
"}",
"if",
"(",
"$",
"context",
"->",
"outUseItem",
")",
"{",
"$",
"results",
"->",
"offsetSet",
"(",
"$",
"input",
"->",
"key",
"(",
")",
",",
"$",
"result",
")",
";",
"}",
"// goto next item",
"$",
"input",
"->",
"next",
"(",
")",
";",
"}",
"return",
"$",
"results",
";",
"}"
] | @param \Iterator $operatorChain
@param \Iterator $input
@return \ArrayIterator | [
"@param",
"\\",
"Iterator",
"$operatorChain",
"@param",
"\\",
"Iterator",
"$input"
] | train | https://github.com/PeekAndPoke/psi/blob/cfd45d995d3a2c2ea6ba5b1ce7b5fcc71179456f/src/DefaultSolver.php#L60-L99 |
slashworks/control-bundle | src/Slashworks/AppBundle/Form/Type/LicenseType.php | LicenseType.buildForm | public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('max_clients',null,array('read_only' => true));
$builder->add('domain',null,array('read_only' => true));
$builder->add('valid_until',null,array('read_only' => true));
$builder->add('serial');
} | php | public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('max_clients',null,array('read_only' => true));
$builder->add('domain',null,array('read_only' => true));
$builder->add('valid_until',null,array('read_only' => true));
$builder->add('serial');
} | [
"public",
"function",
"buildForm",
"(",
"FormBuilderInterface",
"$",
"builder",
",",
"array",
"$",
"options",
")",
"{",
"$",
"builder",
"->",
"add",
"(",
"'max_clients'",
",",
"null",
",",
"array",
"(",
"'read_only'",
"=>",
"true",
")",
")",
";",
"$",
"builder",
"->",
"add",
"(",
"'domain'",
",",
"null",
",",
"array",
"(",
"'read_only'",
"=>",
"true",
")",
")",
";",
"$",
"builder",
"->",
"add",
"(",
"'valid_until'",
",",
"null",
",",
"array",
"(",
"'read_only'",
"=>",
"true",
")",
")",
";",
"$",
"builder",
"->",
"add",
"(",
"'serial'",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Form/Type/LicenseType.php#L47-L54 |
steeffeen/FancyManiaLinks | FML/Components/CheckBoxDesign.php | CheckBoxDesign.setImageUrl | public function setImageUrl($imageUrl)
{
$this->style = null;
$this->subStyle = null;
$this->imageUrl = (string)$imageUrl;
return $this;
} | php | public function setImageUrl($imageUrl)
{
$this->style = null;
$this->subStyle = null;
$this->imageUrl = (string)$imageUrl;
return $this;
} | [
"public",
"function",
"setImageUrl",
"(",
"$",
"imageUrl",
")",
"{",
"$",
"this",
"->",
"style",
"=",
"null",
";",
"$",
"this",
"->",
"subStyle",
"=",
"null",
";",
"$",
"this",
"->",
"imageUrl",
"=",
"(",
"string",
")",
"$",
"imageUrl",
";",
"return",
"$",
"this",
";",
"}"
] | Set the image url
@api
@param string $imageUrl Image url
@return static | [
"Set",
"the",
"image",
"url"
] | train | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Components/CheckBoxDesign.php#L125-L131 |
steeffeen/FancyManiaLinks | FML/Components/CheckBoxDesign.php | CheckBoxDesign.applyToQuad | public function applyToQuad(Quad $quad)
{
if ($this->imageUrl) {
$quad->setImageUrl($this->imageUrl);
} else if ($this->style) {
$quad->setStyles($this->style, $this->subStyle);
}
return $this;
} | php | public function applyToQuad(Quad $quad)
{
if ($this->imageUrl) {
$quad->setImageUrl($this->imageUrl);
} else if ($this->style) {
$quad->setStyles($this->style, $this->subStyle);
}
return $this;
} | [
"public",
"function",
"applyToQuad",
"(",
"Quad",
"$",
"quad",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"imageUrl",
")",
"{",
"$",
"quad",
"->",
"setImageUrl",
"(",
"$",
"this",
"->",
"imageUrl",
")",
";",
"}",
"else",
"if",
"(",
"$",
"this",
"->",
"style",
")",
"{",
"$",
"quad",
"->",
"setStyles",
"(",
"$",
"this",
"->",
"style",
",",
"$",
"this",
"->",
"subStyle",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Apply the Design to the given Quad
@api
@param Quad $quad CheckBox Quad
@return static | [
"Apply",
"the",
"Design",
"to",
"the",
"given",
"Quad"
] | train | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Components/CheckBoxDesign.php#L140-L148 |
slashworks/control-bundle | src/Slashworks/AppBundle/Controller/RemoteAppController.php | RemoteAppController.indexDataAction | public function indexDataAction(Request $request)
{
$aRemoteApps = RemoteAppQuery::create()->find();
$sResult = $this->renderView('SlashworksAppBundle:RemoteApp:data.json.twig', array(
'entities' => $aRemoteApps,
));
$response = new Response($sResult);
$response->headers->set('Content-Type', 'application/json');
return $response;
} | php | public function indexDataAction(Request $request)
{
$aRemoteApps = RemoteAppQuery::create()->find();
$sResult = $this->renderView('SlashworksAppBundle:RemoteApp:data.json.twig', array(
'entities' => $aRemoteApps,
));
$response = new Response($sResult);
$response->headers->set('Content-Type', 'application/json');
return $response;
} | [
"public",
"function",
"indexDataAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"aRemoteApps",
"=",
"RemoteAppQuery",
"::",
"create",
"(",
")",
"->",
"find",
"(",
")",
";",
"$",
"sResult",
"=",
"$",
"this",
"->",
"renderView",
"(",
"'SlashworksAppBundle:RemoteApp:data.json.twig'",
",",
"array",
"(",
"'entities'",
"=>",
"$",
"aRemoteApps",
",",
")",
")",
";",
"$",
"response",
"=",
"new",
"Response",
"(",
"$",
"sResult",
")",
";",
"$",
"response",
"->",
"headers",
"->",
"set",
"(",
"'Content-Type'",
",",
"'application/json'",
")",
";",
"return",
"$",
"response",
";",
"}"
] | Get data as json for remoteapp-list
@param \Symfony\Component\HttpFoundation\Request $request
@return \Slashworks\AppBundle\Controller\Response | [
"Get",
"data",
"as",
"json",
"for",
"remoteapp",
"-",
"list"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Controller/RemoteAppController.php#L77-L90 |
slashworks/control-bundle | src/Slashworks/AppBundle/Controller/RemoteAppController.php | RemoteAppController.detailsAction | public function detailsAction($id)
{
$aRemoteApps = RemoteAppQuery::create()->findOneById($id);
$aRemoteAppHistory = $aRemoteApps->getRemoteHistoryContaoAsArray();
return $this->render('SlashworksAppBundle:RemoteApp:details.html.twig', array(
'remoteapp' => $aRemoteApps,
'remoteappHistory' => $aRemoteAppHistory
));
} | php | public function detailsAction($id)
{
$aRemoteApps = RemoteAppQuery::create()->findOneById($id);
$aRemoteAppHistory = $aRemoteApps->getRemoteHistoryContaoAsArray();
return $this->render('SlashworksAppBundle:RemoteApp:details.html.twig', array(
'remoteapp' => $aRemoteApps,
'remoteappHistory' => $aRemoteAppHistory
));
} | [
"public",
"function",
"detailsAction",
"(",
"$",
"id",
")",
"{",
"$",
"aRemoteApps",
"=",
"RemoteAppQuery",
"::",
"create",
"(",
")",
"->",
"findOneById",
"(",
"$",
"id",
")",
";",
"$",
"aRemoteAppHistory",
"=",
"$",
"aRemoteApps",
"->",
"getRemoteHistoryContaoAsArray",
"(",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"'SlashworksAppBundle:RemoteApp:details.html.twig'",
",",
"array",
"(",
"'remoteapp'",
"=>",
"$",
"aRemoteApps",
",",
"'remoteappHistory'",
"=>",
"$",
"aRemoteAppHistory",
")",
")",
";",
"}"
] | show details for remoteapp
@param $id
@return \Symfony\Component\HttpFoundation\Response | [
"show",
"details",
"for",
"remoteapp"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Controller/RemoteAppController.php#L100-L110 |
slashworks/control-bundle | src/Slashworks/AppBundle/Controller/RemoteAppController.php | RemoteAppController.generateInitialApiZipAction | public function generateInitialApiZipAction($id)
{
/** @var RemoteApp $oRemoteApp */
$oRemoteApp = RemoteAppQuery::create()->findOneById($id);
if (!$this->check4Client($oRemoteApp->getCustomerId())) {
throw new AccessDeniedException();
}
if ($oRemoteApp === null) {
throw $this->createNotFoundException('Unable to find RemoteApp entity.');
}
// get lico url
$sLico = SystemSettings::get("lico");
// build url and make call
$lico = $sLico . "/api/generate/module/" . base64_encode($this->_getSiteURL()) . "/" . base64_encode($oRemoteApp->getDomain());
$sData = @file_get_contents($lico);
$sPublicKey = "";
foreach ($http_response_header as $sHead) {
if (stristr($sHead, "pk:")) {
$sPublicKey = substr($sHead, strpos($sHead, "-"));
$oRemoteApp->setPublicKey($sPublicKey);
$oRemoteApp->save();
}
}
// unzip file ,add private key and rezip for download
if (!empty($sPublicKey) && !empty($sData)) {
// unzip enerated module to add public control key
$aFiles = UnzipFile::read($sData);
$sAppPath = $this->getParameter('kernel.root_dir');
$sVendorPath = $sAppPath."/../vendor/slashworks/control-bundle/src/Slashworks/";
$sKeyPath = $sVendorPath."AppBundle/Resources/private/api/keys/server/";
// add control key
$aFiles[] = array(
"name" => "control.key",
"dir" => "server/private",
"mtime" => time(),
"data" => file_get_contents($sKeyPath . "public.key")
);
$oZip = new Zip();
Zip::$temp = $sVendorPath . "/AppBundle/Resources/private/tmp/";
foreach ($aFiles as $aFile) {
$oZip->addFile($aFile['data'], $aFile['dir'] . "/" . $aFile['name']);
}
$sFileName = "swControl";
$oZip->sendZip($sFileName . "_api.zip", "application/zip", $sFileName . ".zip");
} else {
$aData = json_decode($sData, true);
if (empty($aData)) {
$this->get('logger')->error($this->get("translator")->trans("license.update.failed_lico"), array("Method" => __METHOD__, "RemoteApp" => $oRemoteApp->getName(), "RemoteURL" => $oRemoteApp->getFullApiUrl()));
$sHtml = "<script>alert('" . $this->get("translator")->trans("license.update.failed_lico") . "');</script>";
} else {
if (isset($aData['message'])) {
$this->get('logger')->error( $aData['message'], array("Method" => __METHOD__, "RemoteApp" => $oRemoteApp->getName(), "RemoteURL" => $oRemoteApp->getFullApiUrl()));
$sHtml = "<script>alert('" . $aData['message'] . "');</script>";
} else {
$this->get('logger')->error($this->get("translator")->trans("license.update.failed_lico"), array("Method" => __METHOD__, "RemoteApp" => $oRemoteApp->getName(), "RemoteURL" => $oRemoteApp->getFullApiUrl()));
$sHtml = "<script>alert('" . $this->get("translator")->trans("license.update.failed_lico") . "');</script>";
}
}
echo $sHtml;
}
die();
} | php | public function generateInitialApiZipAction($id)
{
/** @var RemoteApp $oRemoteApp */
$oRemoteApp = RemoteAppQuery::create()->findOneById($id);
if (!$this->check4Client($oRemoteApp->getCustomerId())) {
throw new AccessDeniedException();
}
if ($oRemoteApp === null) {
throw $this->createNotFoundException('Unable to find RemoteApp entity.');
}
// get lico url
$sLico = SystemSettings::get("lico");
// build url and make call
$lico = $sLico . "/api/generate/module/" . base64_encode($this->_getSiteURL()) . "/" . base64_encode($oRemoteApp->getDomain());
$sData = @file_get_contents($lico);
$sPublicKey = "";
foreach ($http_response_header as $sHead) {
if (stristr($sHead, "pk:")) {
$sPublicKey = substr($sHead, strpos($sHead, "-"));
$oRemoteApp->setPublicKey($sPublicKey);
$oRemoteApp->save();
}
}
// unzip file ,add private key and rezip for download
if (!empty($sPublicKey) && !empty($sData)) {
// unzip enerated module to add public control key
$aFiles = UnzipFile::read($sData);
$sAppPath = $this->getParameter('kernel.root_dir');
$sVendorPath = $sAppPath."/../vendor/slashworks/control-bundle/src/Slashworks/";
$sKeyPath = $sVendorPath."AppBundle/Resources/private/api/keys/server/";
// add control key
$aFiles[] = array(
"name" => "control.key",
"dir" => "server/private",
"mtime" => time(),
"data" => file_get_contents($sKeyPath . "public.key")
);
$oZip = new Zip();
Zip::$temp = $sVendorPath . "/AppBundle/Resources/private/tmp/";
foreach ($aFiles as $aFile) {
$oZip->addFile($aFile['data'], $aFile['dir'] . "/" . $aFile['name']);
}
$sFileName = "swControl";
$oZip->sendZip($sFileName . "_api.zip", "application/zip", $sFileName . ".zip");
} else {
$aData = json_decode($sData, true);
if (empty($aData)) {
$this->get('logger')->error($this->get("translator")->trans("license.update.failed_lico"), array("Method" => __METHOD__, "RemoteApp" => $oRemoteApp->getName(), "RemoteURL" => $oRemoteApp->getFullApiUrl()));
$sHtml = "<script>alert('" . $this->get("translator")->trans("license.update.failed_lico") . "');</script>";
} else {
if (isset($aData['message'])) {
$this->get('logger')->error( $aData['message'], array("Method" => __METHOD__, "RemoteApp" => $oRemoteApp->getName(), "RemoteURL" => $oRemoteApp->getFullApiUrl()));
$sHtml = "<script>alert('" . $aData['message'] . "');</script>";
} else {
$this->get('logger')->error($this->get("translator")->trans("license.update.failed_lico"), array("Method" => __METHOD__, "RemoteApp" => $oRemoteApp->getName(), "RemoteURL" => $oRemoteApp->getFullApiUrl()));
$sHtml = "<script>alert('" . $this->get("translator")->trans("license.update.failed_lico") . "');</script>";
}
}
echo $sHtml;
}
die();
} | [
"public",
"function",
"generateInitialApiZipAction",
"(",
"$",
"id",
")",
"{",
"/** @var RemoteApp $oRemoteApp */",
"$",
"oRemoteApp",
"=",
"RemoteAppQuery",
"::",
"create",
"(",
")",
"->",
"findOneById",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"check4Client",
"(",
"$",
"oRemoteApp",
"->",
"getCustomerId",
"(",
")",
")",
")",
"{",
"throw",
"new",
"AccessDeniedException",
"(",
")",
";",
"}",
"if",
"(",
"$",
"oRemoteApp",
"===",
"null",
")",
"{",
"throw",
"$",
"this",
"->",
"createNotFoundException",
"(",
"'Unable to find RemoteApp entity.'",
")",
";",
"}",
"// get lico url",
"$",
"sLico",
"=",
"SystemSettings",
"::",
"get",
"(",
"\"lico\"",
")",
";",
"// build url and make call",
"$",
"lico",
"=",
"$",
"sLico",
".",
"\"/api/generate/module/\"",
".",
"base64_encode",
"(",
"$",
"this",
"->",
"_getSiteURL",
"(",
")",
")",
".",
"\"/\"",
".",
"base64_encode",
"(",
"$",
"oRemoteApp",
"->",
"getDomain",
"(",
")",
")",
";",
"$",
"sData",
"=",
"@",
"file_get_contents",
"(",
"$",
"lico",
")",
";",
"$",
"sPublicKey",
"=",
"\"\"",
";",
"foreach",
"(",
"$",
"http_response_header",
"as",
"$",
"sHead",
")",
"{",
"if",
"(",
"stristr",
"(",
"$",
"sHead",
",",
"\"pk:\"",
")",
")",
"{",
"$",
"sPublicKey",
"=",
"substr",
"(",
"$",
"sHead",
",",
"strpos",
"(",
"$",
"sHead",
",",
"\"-\"",
")",
")",
";",
"$",
"oRemoteApp",
"->",
"setPublicKey",
"(",
"$",
"sPublicKey",
")",
";",
"$",
"oRemoteApp",
"->",
"save",
"(",
")",
";",
"}",
"}",
"// unzip file ,add private key and rezip for download",
"if",
"(",
"!",
"empty",
"(",
"$",
"sPublicKey",
")",
"&&",
"!",
"empty",
"(",
"$",
"sData",
")",
")",
"{",
"// unzip enerated module to add public control key",
"$",
"aFiles",
"=",
"UnzipFile",
"::",
"read",
"(",
"$",
"sData",
")",
";",
"$",
"sAppPath",
"=",
"$",
"this",
"->",
"getParameter",
"(",
"'kernel.root_dir'",
")",
";",
"$",
"sVendorPath",
"=",
"$",
"sAppPath",
".",
"\"/../vendor/slashworks/control-bundle/src/Slashworks/\"",
";",
"$",
"sKeyPath",
"=",
"$",
"sVendorPath",
".",
"\"AppBundle/Resources/private/api/keys/server/\"",
";",
"// add control key",
"$",
"aFiles",
"[",
"]",
"=",
"array",
"(",
"\"name\"",
"=>",
"\"control.key\"",
",",
"\"dir\"",
"=>",
"\"server/private\"",
",",
"\"mtime\"",
"=>",
"time",
"(",
")",
",",
"\"data\"",
"=>",
"file_get_contents",
"(",
"$",
"sKeyPath",
".",
"\"public.key\"",
")",
")",
";",
"$",
"oZip",
"=",
"new",
"Zip",
"(",
")",
";",
"Zip",
"::",
"$",
"temp",
"=",
"$",
"sVendorPath",
".",
"\"/AppBundle/Resources/private/tmp/\"",
";",
"foreach",
"(",
"$",
"aFiles",
"as",
"$",
"aFile",
")",
"{",
"$",
"oZip",
"->",
"addFile",
"(",
"$",
"aFile",
"[",
"'data'",
"]",
",",
"$",
"aFile",
"[",
"'dir'",
"]",
".",
"\"/\"",
".",
"$",
"aFile",
"[",
"'name'",
"]",
")",
";",
"}",
"$",
"sFileName",
"=",
"\"swControl\"",
";",
"$",
"oZip",
"->",
"sendZip",
"(",
"$",
"sFileName",
".",
"\"_api.zip\"",
",",
"\"application/zip\"",
",",
"$",
"sFileName",
".",
"\".zip\"",
")",
";",
"}",
"else",
"{",
"$",
"aData",
"=",
"json_decode",
"(",
"$",
"sData",
",",
"true",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"aData",
")",
")",
"{",
"$",
"this",
"->",
"get",
"(",
"'logger'",
")",
"->",
"error",
"(",
"$",
"this",
"->",
"get",
"(",
"\"translator\"",
")",
"->",
"trans",
"(",
"\"license.update.failed_lico\"",
")",
",",
"array",
"(",
"\"Method\"",
"=>",
"__METHOD__",
",",
"\"RemoteApp\"",
"=>",
"$",
"oRemoteApp",
"->",
"getName",
"(",
")",
",",
"\"RemoteURL\"",
"=>",
"$",
"oRemoteApp",
"->",
"getFullApiUrl",
"(",
")",
")",
")",
";",
"$",
"sHtml",
"=",
"\"<script>alert('\"",
".",
"$",
"this",
"->",
"get",
"(",
"\"translator\"",
")",
"->",
"trans",
"(",
"\"license.update.failed_lico\"",
")",
".",
"\"');</script>\"",
";",
"}",
"else",
"{",
"if",
"(",
"isset",
"(",
"$",
"aData",
"[",
"'message'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"get",
"(",
"'logger'",
")",
"->",
"error",
"(",
"$",
"aData",
"[",
"'message'",
"]",
",",
"array",
"(",
"\"Method\"",
"=>",
"__METHOD__",
",",
"\"RemoteApp\"",
"=>",
"$",
"oRemoteApp",
"->",
"getName",
"(",
")",
",",
"\"RemoteURL\"",
"=>",
"$",
"oRemoteApp",
"->",
"getFullApiUrl",
"(",
")",
")",
")",
";",
"$",
"sHtml",
"=",
"\"<script>alert('\"",
".",
"$",
"aData",
"[",
"'message'",
"]",
".",
"\"');</script>\"",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"get",
"(",
"'logger'",
")",
"->",
"error",
"(",
"$",
"this",
"->",
"get",
"(",
"\"translator\"",
")",
"->",
"trans",
"(",
"\"license.update.failed_lico\"",
")",
",",
"array",
"(",
"\"Method\"",
"=>",
"__METHOD__",
",",
"\"RemoteApp\"",
"=>",
"$",
"oRemoteApp",
"->",
"getName",
"(",
")",
",",
"\"RemoteURL\"",
"=>",
"$",
"oRemoteApp",
"->",
"getFullApiUrl",
"(",
")",
")",
")",
";",
"$",
"sHtml",
"=",
"\"<script>alert('\"",
".",
"$",
"this",
"->",
"get",
"(",
"\"translator\"",
")",
"->",
"trans",
"(",
"\"license.update.failed_lico\"",
")",
".",
"\"');</script>\"",
";",
"}",
"}",
"echo",
"$",
"sHtml",
";",
"}",
"die",
"(",
")",
";",
"}"
] | get initial module from licenseserver
@param $id
@throws \Exception
@throws \PropelException
@throws \Slashworks\AppBundle\Controller\AccessDeniedException
@throws \Slashworks\libs\Exception | [
"get",
"initial",
"module",
"from",
"licenseserver"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Controller/RemoteAppController.php#L123-L196 |
slashworks/control-bundle | src/Slashworks/AppBundle/Controller/RemoteAppController.php | RemoteAppController.initInstallCallAction | public function initInstallCallAction($id)
{
$oRemoteApp = RemoteAppQuery::create()->findOneById($id);
$sResult = array(
"success" => false,
"message" => ""
);
try {
$this->get("API");
Api::$_container = $this->container;
$mResult = Api::call("doInstall", array(), $oRemoteApp->getUpdateUrl(), $oRemoteApp->getPublicKey(), $oRemoteApp);
if (!empty($mResult)) {
if (!isset($mResult['result']['result'])) {
$this->get('logger')->error("[INIT ERROR] ".print_r($mResult,true));
throw new \Exception($this->get("translator")->trans("remote_app.api.init.error"));
}
if ($mResult['result']['result'] == true) {
$sResult['success'] = true;
$sResult['message'] = $this->get("translator")->trans("remote_app.api.update.successful");
$this->get('logger')->info("Api-Call successful", array("Method" => __METHOD__, "RemoteApp" => $oRemoteApp->getName()));
$oRemoteApp->setWebsiteHash($mResult['result']['website_hash']);
$oRemoteApp->save();
} else {
$this->get('logger')->error("Unknown error in ".__FILE__." on line ".__LINE__." - Result: ".json_encode($mResult), array("Method" => __METHOD__, "RemoteApp" => $oRemoteApp->getName(), "RemoteURL" => $oRemoteApp->getFullApiUrl()));
throw new \Exception("error in " . __FILE__ . " on line " . __LINE__);
}
}
} catch (\Exception $e) {
$this->get('logger')->error($e->getMessage(), array("Method" => __METHOD__, "RemoteApp" => $oRemoteApp->getName(), "RemoteURL" => $oRemoteApp->getFullApiUrl()));
$sResult['success'] = false;
$sResult['message'] = $e->getMessage();
}
$response = new Response(json_encode($sResult));
$response->headers->set('Content-Type', 'application/json');
return $response;
} | php | public function initInstallCallAction($id)
{
$oRemoteApp = RemoteAppQuery::create()->findOneById($id);
$sResult = array(
"success" => false,
"message" => ""
);
try {
$this->get("API");
Api::$_container = $this->container;
$mResult = Api::call("doInstall", array(), $oRemoteApp->getUpdateUrl(), $oRemoteApp->getPublicKey(), $oRemoteApp);
if (!empty($mResult)) {
if (!isset($mResult['result']['result'])) {
$this->get('logger')->error("[INIT ERROR] ".print_r($mResult,true));
throw new \Exception($this->get("translator")->trans("remote_app.api.init.error"));
}
if ($mResult['result']['result'] == true) {
$sResult['success'] = true;
$sResult['message'] = $this->get("translator")->trans("remote_app.api.update.successful");
$this->get('logger')->info("Api-Call successful", array("Method" => __METHOD__, "RemoteApp" => $oRemoteApp->getName()));
$oRemoteApp->setWebsiteHash($mResult['result']['website_hash']);
$oRemoteApp->save();
} else {
$this->get('logger')->error("Unknown error in ".__FILE__." on line ".__LINE__." - Result: ".json_encode($mResult), array("Method" => __METHOD__, "RemoteApp" => $oRemoteApp->getName(), "RemoteURL" => $oRemoteApp->getFullApiUrl()));
throw new \Exception("error in " . __FILE__ . " on line " . __LINE__);
}
}
} catch (\Exception $e) {
$this->get('logger')->error($e->getMessage(), array("Method" => __METHOD__, "RemoteApp" => $oRemoteApp->getName(), "RemoteURL" => $oRemoteApp->getFullApiUrl()));
$sResult['success'] = false;
$sResult['message'] = $e->getMessage();
}
$response = new Response(json_encode($sResult));
$response->headers->set('Content-Type', 'application/json');
return $response;
} | [
"public",
"function",
"initInstallCallAction",
"(",
"$",
"id",
")",
"{",
"$",
"oRemoteApp",
"=",
"RemoteAppQuery",
"::",
"create",
"(",
")",
"->",
"findOneById",
"(",
"$",
"id",
")",
";",
"$",
"sResult",
"=",
"array",
"(",
"\"success\"",
"=>",
"false",
",",
"\"message\"",
"=>",
"\"\"",
")",
";",
"try",
"{",
"$",
"this",
"->",
"get",
"(",
"\"API\"",
")",
";",
"Api",
"::",
"$",
"_container",
"=",
"$",
"this",
"->",
"container",
";",
"$",
"mResult",
"=",
"Api",
"::",
"call",
"(",
"\"doInstall\"",
",",
"array",
"(",
")",
",",
"$",
"oRemoteApp",
"->",
"getUpdateUrl",
"(",
")",
",",
"$",
"oRemoteApp",
"->",
"getPublicKey",
"(",
")",
",",
"$",
"oRemoteApp",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"mResult",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"mResult",
"[",
"'result'",
"]",
"[",
"'result'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"get",
"(",
"'logger'",
")",
"->",
"error",
"(",
"\"[INIT ERROR] \"",
".",
"print_r",
"(",
"$",
"mResult",
",",
"true",
")",
")",
";",
"throw",
"new",
"\\",
"Exception",
"(",
"$",
"this",
"->",
"get",
"(",
"\"translator\"",
")",
"->",
"trans",
"(",
"\"remote_app.api.init.error\"",
")",
")",
";",
"}",
"if",
"(",
"$",
"mResult",
"[",
"'result'",
"]",
"[",
"'result'",
"]",
"==",
"true",
")",
"{",
"$",
"sResult",
"[",
"'success'",
"]",
"=",
"true",
";",
"$",
"sResult",
"[",
"'message'",
"]",
"=",
"$",
"this",
"->",
"get",
"(",
"\"translator\"",
")",
"->",
"trans",
"(",
"\"remote_app.api.update.successful\"",
")",
";",
"$",
"this",
"->",
"get",
"(",
"'logger'",
")",
"->",
"info",
"(",
"\"Api-Call successful\"",
",",
"array",
"(",
"\"Method\"",
"=>",
"__METHOD__",
",",
"\"RemoteApp\"",
"=>",
"$",
"oRemoteApp",
"->",
"getName",
"(",
")",
")",
")",
";",
"$",
"oRemoteApp",
"->",
"setWebsiteHash",
"(",
"$",
"mResult",
"[",
"'result'",
"]",
"[",
"'website_hash'",
"]",
")",
";",
"$",
"oRemoteApp",
"->",
"save",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"get",
"(",
"'logger'",
")",
"->",
"error",
"(",
"\"Unknown error in \"",
".",
"__FILE__",
".",
"\" on line \"",
".",
"__LINE__",
".",
"\" - Result: \"",
".",
"json_encode",
"(",
"$",
"mResult",
")",
",",
"array",
"(",
"\"Method\"",
"=>",
"__METHOD__",
",",
"\"RemoteApp\"",
"=>",
"$",
"oRemoteApp",
"->",
"getName",
"(",
")",
",",
"\"RemoteURL\"",
"=>",
"$",
"oRemoteApp",
"->",
"getFullApiUrl",
"(",
")",
")",
")",
";",
"throw",
"new",
"\\",
"Exception",
"(",
"\"error in \"",
".",
"__FILE__",
".",
"\" on line \"",
".",
"__LINE__",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"get",
"(",
"'logger'",
")",
"->",
"error",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"array",
"(",
"\"Method\"",
"=>",
"__METHOD__",
",",
"\"RemoteApp\"",
"=>",
"$",
"oRemoteApp",
"->",
"getName",
"(",
")",
",",
"\"RemoteURL\"",
"=>",
"$",
"oRemoteApp",
"->",
"getFullApiUrl",
"(",
")",
")",
")",
";",
"$",
"sResult",
"[",
"'success'",
"]",
"=",
"false",
";",
"$",
"sResult",
"[",
"'message'",
"]",
"=",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"}",
"$",
"response",
"=",
"new",
"Response",
"(",
"json_encode",
"(",
"$",
"sResult",
")",
")",
";",
"$",
"response",
"->",
"headers",
"->",
"set",
"(",
"'Content-Type'",
",",
"'application/json'",
")",
";",
"return",
"$",
"response",
";",
"}"
] | initiate installation of complete monitoring module
@param $id
@return \Symfony\Component\HttpFoundation\Response
@throws \Exception | [
"initiate",
"installation",
"of",
"complete",
"monitoring",
"module"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Controller/RemoteAppController.php#L222-L264 |
slashworks/control-bundle | src/Slashworks/AppBundle/Controller/RemoteAppController.php | RemoteAppController.runSingleApiCallAction | public function runSingleApiCallAction($id)
{
$sLico = SystemSettings::get("lico");
$iLvdc = SystemSettings::get("lvdc");
if ($iLvdc < strtotime("-7 days")) {
$aRemoteApps = RemoteAppQuery::create()->filterByWebsiteHash(null, \Criteria::ISNOTNULL);
$lico = $sLico . "/api/lvdc/" . base64_encode($this->_getSiteURL()) . "/" . $aRemoteApps->count();
try {
$res = @file_get_contents($lico);
if ($res === false) {
throw new \Exception($this->get("translator")->trans("license.update.failed_lico"));
}
$oResult = json_decode($res);
if ($oResult->valid !== true) {
$aResponse = array(
"error" => true,
"message" => $oResult->message
);
} else {
SystemSettings::set("lvdc", time());
}
} catch (\Exception $e) {
$aResponse = array(
"error" => true,
"message" => $e->getMessage()
);
}
}
try {
if (!isset($aResponse)) {
$command = new ApiCommand();
$command->setContainer($this->container);
$input = new ArgvInput(array(
'control:remote:cron',
'--app=' . $id,
'--force'
));
$output = new BufferedOutput();
// Run the command
$retval = $command->run($input, $output);
$oRemoteApp = RemoteAppQuery::create()->findOneById($id);
$sJsonData = $this->renderView('SlashworksAppBundle:RemoteApp:data.json.twig', array('entities' => array($oRemoteApp)));
$aData = json_decode($sJsonData, true);
$sReturn = $output->fetch();
$aReturn = json_decode($sReturn, true);
if($aReturn !== false){
if(is_array($aReturn)){
if($aReturn['status'] === false) {
$this->get('logger')->error($aReturn['message'], array("Method" => __METHOD__, "RemoteApp" => $oRemoteApp->getName(), "RemoteURL" => $oRemoteApp->getFullApiUrl()));
$aResponse = $aReturn;
}elseif($aReturn['status'] === true) {
$this->get('logger')->info("Api-Call successful", array("Method" => __METHOD__, "RemoteApp" => $oRemoteApp->getName()));
$aResponse = $aData;
} else {
$this->get('logger')->error("Unknown error in ".__FILE__." on line ".__LINE__, array("Method" => __METHOD__, "RemoteApp" => $oRemoteApp->getName(), "RemoteURL" => $oRemoteApp->getFullApiUrl()));
$aResponse = array("error" => true);
}
}
}else {
if (!$retval) {
$this->get('logger')->info("Api-Call successful", array("Method" => __METHOD__, "RemoteApp" => $oRemoteApp->getName()));
$aResponse = $aData;
} else {
$this->get('logger')->error("Unknown error in ".__FILE__." on line ".__LINE__, array("Method" => __METHOD__, "RemoteApp" => $oRemoteApp->getName(), "RemoteURL" => $oRemoteApp->getFullApiUrl()));
$aResponse = array("error" => true);
}
}
}
} catch (\Exception $e) {
$this->get('logger')->error($e->getMessage());
$aResponse = array(
"error" => true,
"message" => $e->getMessage()
);
}
$response = new Response(json_encode($aResponse));
$response->headers->set('Content-Type', 'application/json');
return $response;
} | php | public function runSingleApiCallAction($id)
{
$sLico = SystemSettings::get("lico");
$iLvdc = SystemSettings::get("lvdc");
if ($iLvdc < strtotime("-7 days")) {
$aRemoteApps = RemoteAppQuery::create()->filterByWebsiteHash(null, \Criteria::ISNOTNULL);
$lico = $sLico . "/api/lvdc/" . base64_encode($this->_getSiteURL()) . "/" . $aRemoteApps->count();
try {
$res = @file_get_contents($lico);
if ($res === false) {
throw new \Exception($this->get("translator")->trans("license.update.failed_lico"));
}
$oResult = json_decode($res);
if ($oResult->valid !== true) {
$aResponse = array(
"error" => true,
"message" => $oResult->message
);
} else {
SystemSettings::set("lvdc", time());
}
} catch (\Exception $e) {
$aResponse = array(
"error" => true,
"message" => $e->getMessage()
);
}
}
try {
if (!isset($aResponse)) {
$command = new ApiCommand();
$command->setContainer($this->container);
$input = new ArgvInput(array(
'control:remote:cron',
'--app=' . $id,
'--force'
));
$output = new BufferedOutput();
// Run the command
$retval = $command->run($input, $output);
$oRemoteApp = RemoteAppQuery::create()->findOneById($id);
$sJsonData = $this->renderView('SlashworksAppBundle:RemoteApp:data.json.twig', array('entities' => array($oRemoteApp)));
$aData = json_decode($sJsonData, true);
$sReturn = $output->fetch();
$aReturn = json_decode($sReturn, true);
if($aReturn !== false){
if(is_array($aReturn)){
if($aReturn['status'] === false) {
$this->get('logger')->error($aReturn['message'], array("Method" => __METHOD__, "RemoteApp" => $oRemoteApp->getName(), "RemoteURL" => $oRemoteApp->getFullApiUrl()));
$aResponse = $aReturn;
}elseif($aReturn['status'] === true) {
$this->get('logger')->info("Api-Call successful", array("Method" => __METHOD__, "RemoteApp" => $oRemoteApp->getName()));
$aResponse = $aData;
} else {
$this->get('logger')->error("Unknown error in ".__FILE__." on line ".__LINE__, array("Method" => __METHOD__, "RemoteApp" => $oRemoteApp->getName(), "RemoteURL" => $oRemoteApp->getFullApiUrl()));
$aResponse = array("error" => true);
}
}
}else {
if (!$retval) {
$this->get('logger')->info("Api-Call successful", array("Method" => __METHOD__, "RemoteApp" => $oRemoteApp->getName()));
$aResponse = $aData;
} else {
$this->get('logger')->error("Unknown error in ".__FILE__." on line ".__LINE__, array("Method" => __METHOD__, "RemoteApp" => $oRemoteApp->getName(), "RemoteURL" => $oRemoteApp->getFullApiUrl()));
$aResponse = array("error" => true);
}
}
}
} catch (\Exception $e) {
$this->get('logger')->error($e->getMessage());
$aResponse = array(
"error" => true,
"message" => $e->getMessage()
);
}
$response = new Response(json_encode($aResponse));
$response->headers->set('Content-Type', 'application/json');
return $response;
} | [
"public",
"function",
"runSingleApiCallAction",
"(",
"$",
"id",
")",
"{",
"$",
"sLico",
"=",
"SystemSettings",
"::",
"get",
"(",
"\"lico\"",
")",
";",
"$",
"iLvdc",
"=",
"SystemSettings",
"::",
"get",
"(",
"\"lvdc\"",
")",
";",
"if",
"(",
"$",
"iLvdc",
"<",
"strtotime",
"(",
"\"-7 days\"",
")",
")",
"{",
"$",
"aRemoteApps",
"=",
"RemoteAppQuery",
"::",
"create",
"(",
")",
"->",
"filterByWebsiteHash",
"(",
"null",
",",
"\\",
"Criteria",
"::",
"ISNOTNULL",
")",
";",
"$",
"lico",
"=",
"$",
"sLico",
".",
"\"/api/lvdc/\"",
".",
"base64_encode",
"(",
"$",
"this",
"->",
"_getSiteURL",
"(",
")",
")",
".",
"\"/\"",
".",
"$",
"aRemoteApps",
"->",
"count",
"(",
")",
";",
"try",
"{",
"$",
"res",
"=",
"@",
"file_get_contents",
"(",
"$",
"lico",
")",
";",
"if",
"(",
"$",
"res",
"===",
"false",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"$",
"this",
"->",
"get",
"(",
"\"translator\"",
")",
"->",
"trans",
"(",
"\"license.update.failed_lico\"",
")",
")",
";",
"}",
"$",
"oResult",
"=",
"json_decode",
"(",
"$",
"res",
")",
";",
"if",
"(",
"$",
"oResult",
"->",
"valid",
"!==",
"true",
")",
"{",
"$",
"aResponse",
"=",
"array",
"(",
"\"error\"",
"=>",
"true",
",",
"\"message\"",
"=>",
"$",
"oResult",
"->",
"message",
")",
";",
"}",
"else",
"{",
"SystemSettings",
"::",
"set",
"(",
"\"lvdc\"",
",",
"time",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"aResponse",
"=",
"array",
"(",
"\"error\"",
"=>",
"true",
",",
"\"message\"",
"=>",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"try",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"aResponse",
")",
")",
"{",
"$",
"command",
"=",
"new",
"ApiCommand",
"(",
")",
";",
"$",
"command",
"->",
"setContainer",
"(",
"$",
"this",
"->",
"container",
")",
";",
"$",
"input",
"=",
"new",
"ArgvInput",
"(",
"array",
"(",
"'control:remote:cron'",
",",
"'--app='",
".",
"$",
"id",
",",
"'--force'",
")",
")",
";",
"$",
"output",
"=",
"new",
"BufferedOutput",
"(",
")",
";",
"// Run the command",
"$",
"retval",
"=",
"$",
"command",
"->",
"run",
"(",
"$",
"input",
",",
"$",
"output",
")",
";",
"$",
"oRemoteApp",
"=",
"RemoteAppQuery",
"::",
"create",
"(",
")",
"->",
"findOneById",
"(",
"$",
"id",
")",
";",
"$",
"sJsonData",
"=",
"$",
"this",
"->",
"renderView",
"(",
"'SlashworksAppBundle:RemoteApp:data.json.twig'",
",",
"array",
"(",
"'entities'",
"=>",
"array",
"(",
"$",
"oRemoteApp",
")",
")",
")",
";",
"$",
"aData",
"=",
"json_decode",
"(",
"$",
"sJsonData",
",",
"true",
")",
";",
"$",
"sReturn",
"=",
"$",
"output",
"->",
"fetch",
"(",
")",
";",
"$",
"aReturn",
"=",
"json_decode",
"(",
"$",
"sReturn",
",",
"true",
")",
";",
"if",
"(",
"$",
"aReturn",
"!==",
"false",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"aReturn",
")",
")",
"{",
"if",
"(",
"$",
"aReturn",
"[",
"'status'",
"]",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"get",
"(",
"'logger'",
")",
"->",
"error",
"(",
"$",
"aReturn",
"[",
"'message'",
"]",
",",
"array",
"(",
"\"Method\"",
"=>",
"__METHOD__",
",",
"\"RemoteApp\"",
"=>",
"$",
"oRemoteApp",
"->",
"getName",
"(",
")",
",",
"\"RemoteURL\"",
"=>",
"$",
"oRemoteApp",
"->",
"getFullApiUrl",
"(",
")",
")",
")",
";",
"$",
"aResponse",
"=",
"$",
"aReturn",
";",
"}",
"elseif",
"(",
"$",
"aReturn",
"[",
"'status'",
"]",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"get",
"(",
"'logger'",
")",
"->",
"info",
"(",
"\"Api-Call successful\"",
",",
"array",
"(",
"\"Method\"",
"=>",
"__METHOD__",
",",
"\"RemoteApp\"",
"=>",
"$",
"oRemoteApp",
"->",
"getName",
"(",
")",
")",
")",
";",
"$",
"aResponse",
"=",
"$",
"aData",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"get",
"(",
"'logger'",
")",
"->",
"error",
"(",
"\"Unknown error in \"",
".",
"__FILE__",
".",
"\" on line \"",
".",
"__LINE__",
",",
"array",
"(",
"\"Method\"",
"=>",
"__METHOD__",
",",
"\"RemoteApp\"",
"=>",
"$",
"oRemoteApp",
"->",
"getName",
"(",
")",
",",
"\"RemoteURL\"",
"=>",
"$",
"oRemoteApp",
"->",
"getFullApiUrl",
"(",
")",
")",
")",
";",
"$",
"aResponse",
"=",
"array",
"(",
"\"error\"",
"=>",
"true",
")",
";",
"}",
"}",
"}",
"else",
"{",
"if",
"(",
"!",
"$",
"retval",
")",
"{",
"$",
"this",
"->",
"get",
"(",
"'logger'",
")",
"->",
"info",
"(",
"\"Api-Call successful\"",
",",
"array",
"(",
"\"Method\"",
"=>",
"__METHOD__",
",",
"\"RemoteApp\"",
"=>",
"$",
"oRemoteApp",
"->",
"getName",
"(",
")",
")",
")",
";",
"$",
"aResponse",
"=",
"$",
"aData",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"get",
"(",
"'logger'",
")",
"->",
"error",
"(",
"\"Unknown error in \"",
".",
"__FILE__",
".",
"\" on line \"",
".",
"__LINE__",
",",
"array",
"(",
"\"Method\"",
"=>",
"__METHOD__",
",",
"\"RemoteApp\"",
"=>",
"$",
"oRemoteApp",
"->",
"getName",
"(",
")",
",",
"\"RemoteURL\"",
"=>",
"$",
"oRemoteApp",
"->",
"getFullApiUrl",
"(",
")",
")",
")",
";",
"$",
"aResponse",
"=",
"array",
"(",
"\"error\"",
"=>",
"true",
")",
";",
"}",
"}",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"get",
"(",
"'logger'",
")",
"->",
"error",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"$",
"aResponse",
"=",
"array",
"(",
"\"error\"",
"=>",
"true",
",",
"\"message\"",
"=>",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"$",
"response",
"=",
"new",
"Response",
"(",
"json_encode",
"(",
"$",
"aResponse",
")",
")",
";",
"$",
"response",
"->",
"headers",
"->",
"set",
"(",
"'Content-Type'",
",",
"'application/json'",
")",
";",
"return",
"$",
"response",
";",
"}"
] | run single api call for one remote app
@param $id
@return \Symfony\Component\HttpFoundation\Response
@throws \Exception
@throws \PropelException | [
"run",
"single",
"api",
"call",
"for",
"one",
"remote",
"app"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Controller/RemoteAppController.php#L319-L412 |
slashworks/control-bundle | src/Slashworks/AppBundle/Controller/RemoteAppController.php | RemoteAppController.createAction | public function createAction(Request $request)
{
$oRemoteApp = new RemoteApp();
$form = $this->createCreateForm($oRemoteApp);
$form->handleRequest($request);
if ($form->isValid()) {
$sDomain = $oRemoteApp->getDomain();
if(substr($sDomain,-1,1) !== "/"){
$sDomain .= "/";
$oRemoteApp->setDomain($sDomain);
}
$sModulePath = $oRemoteApp->getApiUrl();
if(substr($sModulePath,0,1) === "/"){
$sModulePath = substr($sModulePath,1);
$oRemoteApp->setApiUrl($sModulePath);
}
$oRemoteApp->save();
return $this->redirect($this->generateUrl('remote_app'));
}
return $this->render('SlashworksAppBundle:RemoteApp:new.html.twig', array(
'entity' => $oRemoteApp,
'form' => $form->createView(),
));
} | php | public function createAction(Request $request)
{
$oRemoteApp = new RemoteApp();
$form = $this->createCreateForm($oRemoteApp);
$form->handleRequest($request);
if ($form->isValid()) {
$sDomain = $oRemoteApp->getDomain();
if(substr($sDomain,-1,1) !== "/"){
$sDomain .= "/";
$oRemoteApp->setDomain($sDomain);
}
$sModulePath = $oRemoteApp->getApiUrl();
if(substr($sModulePath,0,1) === "/"){
$sModulePath = substr($sModulePath,1);
$oRemoteApp->setApiUrl($sModulePath);
}
$oRemoteApp->save();
return $this->redirect($this->generateUrl('remote_app'));
}
return $this->render('SlashworksAppBundle:RemoteApp:new.html.twig', array(
'entity' => $oRemoteApp,
'form' => $form->createView(),
));
} | [
"public",
"function",
"createAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"oRemoteApp",
"=",
"new",
"RemoteApp",
"(",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createCreateForm",
"(",
"$",
"oRemoteApp",
")",
";",
"$",
"form",
"->",
"handleRequest",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"sDomain",
"=",
"$",
"oRemoteApp",
"->",
"getDomain",
"(",
")",
";",
"if",
"(",
"substr",
"(",
"$",
"sDomain",
",",
"-",
"1",
",",
"1",
")",
"!==",
"\"/\"",
")",
"{",
"$",
"sDomain",
".=",
"\"/\"",
";",
"$",
"oRemoteApp",
"->",
"setDomain",
"(",
"$",
"sDomain",
")",
";",
"}",
"$",
"sModulePath",
"=",
"$",
"oRemoteApp",
"->",
"getApiUrl",
"(",
")",
";",
"if",
"(",
"substr",
"(",
"$",
"sModulePath",
",",
"0",
",",
"1",
")",
"===",
"\"/\"",
")",
"{",
"$",
"sModulePath",
"=",
"substr",
"(",
"$",
"sModulePath",
",",
"1",
")",
";",
"$",
"oRemoteApp",
"->",
"setApiUrl",
"(",
"$",
"sModulePath",
")",
";",
"}",
"$",
"oRemoteApp",
"->",
"save",
"(",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'remote_app'",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"render",
"(",
"'SlashworksAppBundle:RemoteApp:new.html.twig'",
",",
"array",
"(",
"'entity'",
"=>",
"$",
"oRemoteApp",
",",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
")",
")",
";",
"}"
] | Create new remote app
@param \Symfony\Component\HttpFoundation\Request $request
@return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
@throws \Exception
@throws \PropelException | [
"Create",
"new",
"remote",
"app"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Controller/RemoteAppController.php#L424-L454 |
slashworks/control-bundle | src/Slashworks/AppBundle/Controller/RemoteAppController.php | RemoteAppController.newAction | public function newAction()
{
$oRemoteApp = new RemoteApp();
$oRemoteApp->setApiUrl("swControl/");
$oRemoteApp->setActivated(true);
$oRemoteApp->setIncludelog(true);
$oRemoteApp->setNotificationRecipient($this->getUser()->getEmail());
$oRemoteApp->setNotificationSender($this->getUser()->getEmail());
$oRemoteApp->setNotificationChange(true);
$oRemoteApp->setNotificationError(true);
$form = $this->createCreateForm($oRemoteApp);
return $this->render('SlashworksAppBundle:RemoteApp:new.html.twig', array(
'entity' => $oRemoteApp,
'form' => $form->createView(),
));
} | php | public function newAction()
{
$oRemoteApp = new RemoteApp();
$oRemoteApp->setApiUrl("swControl/");
$oRemoteApp->setActivated(true);
$oRemoteApp->setIncludelog(true);
$oRemoteApp->setNotificationRecipient($this->getUser()->getEmail());
$oRemoteApp->setNotificationSender($this->getUser()->getEmail());
$oRemoteApp->setNotificationChange(true);
$oRemoteApp->setNotificationError(true);
$form = $this->createCreateForm($oRemoteApp);
return $this->render('SlashworksAppBundle:RemoteApp:new.html.twig', array(
'entity' => $oRemoteApp,
'form' => $form->createView(),
));
} | [
"public",
"function",
"newAction",
"(",
")",
"{",
"$",
"oRemoteApp",
"=",
"new",
"RemoteApp",
"(",
")",
";",
"$",
"oRemoteApp",
"->",
"setApiUrl",
"(",
"\"swControl/\"",
")",
";",
"$",
"oRemoteApp",
"->",
"setActivated",
"(",
"true",
")",
";",
"$",
"oRemoteApp",
"->",
"setIncludelog",
"(",
"true",
")",
";",
"$",
"oRemoteApp",
"->",
"setNotificationRecipient",
"(",
"$",
"this",
"->",
"getUser",
"(",
")",
"->",
"getEmail",
"(",
")",
")",
";",
"$",
"oRemoteApp",
"->",
"setNotificationSender",
"(",
"$",
"this",
"->",
"getUser",
"(",
")",
"->",
"getEmail",
"(",
")",
")",
";",
"$",
"oRemoteApp",
"->",
"setNotificationChange",
"(",
"true",
")",
";",
"$",
"oRemoteApp",
"->",
"setNotificationError",
"(",
"true",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createCreateForm",
"(",
"$",
"oRemoteApp",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"'SlashworksAppBundle:RemoteApp:new.html.twig'",
",",
"array",
"(",
"'entity'",
"=>",
"$",
"oRemoteApp",
",",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
")",
")",
";",
"}"
] | Displays a form to create a new RemoteApp entity.
@return \Symfony\Component\HttpFoundation\Response | [
"Displays",
"a",
"form",
"to",
"create",
"a",
"new",
"RemoteApp",
"entity",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Controller/RemoteAppController.php#L462-L479 |
slashworks/control-bundle | src/Slashworks/AppBundle/Controller/RemoteAppController.php | RemoteAppController.editAction | public function editAction($id)
{
/** @var RemoteApp $oRemoteApp */
$oRemoteApp = RemoteAppQuery::create()->findOneById($id);
if (count($oRemoteApp) === 0) {
throw $this->createNotFoundException('Unable to find RemoteApp entity.');
}
$editForm = $this->createEditForm($oRemoteApp);
$deleteForm = $this->createDeleteForm($id);
return $this->render('SlashworksAppBundle:RemoteApp:edit.html.twig', array(
'entity' => $oRemoteApp,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
));
} | php | public function editAction($id)
{
/** @var RemoteApp $oRemoteApp */
$oRemoteApp = RemoteAppQuery::create()->findOneById($id);
if (count($oRemoteApp) === 0) {
throw $this->createNotFoundException('Unable to find RemoteApp entity.');
}
$editForm = $this->createEditForm($oRemoteApp);
$deleteForm = $this->createDeleteForm($id);
return $this->render('SlashworksAppBundle:RemoteApp:edit.html.twig', array(
'entity' => $oRemoteApp,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
));
} | [
"public",
"function",
"editAction",
"(",
"$",
"id",
")",
"{",
"/** @var RemoteApp $oRemoteApp */",
"$",
"oRemoteApp",
"=",
"RemoteAppQuery",
"::",
"create",
"(",
")",
"->",
"findOneById",
"(",
"$",
"id",
")",
";",
"if",
"(",
"count",
"(",
"$",
"oRemoteApp",
")",
"===",
"0",
")",
"{",
"throw",
"$",
"this",
"->",
"createNotFoundException",
"(",
"'Unable to find RemoteApp entity.'",
")",
";",
"}",
"$",
"editForm",
"=",
"$",
"this",
"->",
"createEditForm",
"(",
"$",
"oRemoteApp",
")",
";",
"$",
"deleteForm",
"=",
"$",
"this",
"->",
"createDeleteForm",
"(",
"$",
"id",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"'SlashworksAppBundle:RemoteApp:edit.html.twig'",
",",
"array",
"(",
"'entity'",
"=>",
"$",
"oRemoteApp",
",",
"'edit_form'",
"=>",
"$",
"editForm",
"->",
"createView",
"(",
")",
",",
"'delete_form'",
"=>",
"$",
"deleteForm",
"->",
"createView",
"(",
")",
",",
")",
")",
";",
"}"
] | Displays a form to edit an existing RemoteApp entity.
@param $id
@return \Symfony\Component\HttpFoundation\Response | [
"Displays",
"a",
"form",
"to",
"edit",
"an",
"existing",
"RemoteApp",
"entity",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Controller/RemoteAppController.php#L489-L507 |
slashworks/control-bundle | src/Slashworks/AppBundle/Controller/RemoteAppController.php | RemoteAppController.updateAction | public function updateAction(Request $request, $id)
{
/** @var RemoteApp $oRemoteApp */
$oRemoteApp = RemoteAppQuery::create()->findOneById($id);
if (count($oRemoteApp) === 0) {
throw $this->createNotFoundException('Unable to find RemoteApp entity.');
}
$deleteForm = $this->createDeleteForm($id);
$editForm = $this->createEditForm($oRemoteApp);
$editForm->handleRequest($request);
if ($editForm->isValid()) {
$sDomain = $oRemoteApp->getDomain();
if(substr($sDomain,-1,1) !== "/"){
$sDomain .= "/";
$oRemoteApp->setDomain($sDomain);
}
$sModulePath = $oRemoteApp->getApiUrl();
if(substr($sModulePath,0,1) === "/"){
$sModulePath = substr($sModulePath,1);
$oRemoteApp->setApiUrl($sModulePath);
}
$oRemoteApp->save();
return $this->redirect($this->generateUrl('remote_app'));
}
return $this->render('SlashworksAppBundle:RemoteApp:edit.html.twig', array(
'entity' => $oRemoteApp,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
));
} | php | public function updateAction(Request $request, $id)
{
/** @var RemoteApp $oRemoteApp */
$oRemoteApp = RemoteAppQuery::create()->findOneById($id);
if (count($oRemoteApp) === 0) {
throw $this->createNotFoundException('Unable to find RemoteApp entity.');
}
$deleteForm = $this->createDeleteForm($id);
$editForm = $this->createEditForm($oRemoteApp);
$editForm->handleRequest($request);
if ($editForm->isValid()) {
$sDomain = $oRemoteApp->getDomain();
if(substr($sDomain,-1,1) !== "/"){
$sDomain .= "/";
$oRemoteApp->setDomain($sDomain);
}
$sModulePath = $oRemoteApp->getApiUrl();
if(substr($sModulePath,0,1) === "/"){
$sModulePath = substr($sModulePath,1);
$oRemoteApp->setApiUrl($sModulePath);
}
$oRemoteApp->save();
return $this->redirect($this->generateUrl('remote_app'));
}
return $this->render('SlashworksAppBundle:RemoteApp:edit.html.twig', array(
'entity' => $oRemoteApp,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
));
} | [
"public",
"function",
"updateAction",
"(",
"Request",
"$",
"request",
",",
"$",
"id",
")",
"{",
"/** @var RemoteApp $oRemoteApp */",
"$",
"oRemoteApp",
"=",
"RemoteAppQuery",
"::",
"create",
"(",
")",
"->",
"findOneById",
"(",
"$",
"id",
")",
";",
"if",
"(",
"count",
"(",
"$",
"oRemoteApp",
")",
"===",
"0",
")",
"{",
"throw",
"$",
"this",
"->",
"createNotFoundException",
"(",
"'Unable to find RemoteApp entity.'",
")",
";",
"}",
"$",
"deleteForm",
"=",
"$",
"this",
"->",
"createDeleteForm",
"(",
"$",
"id",
")",
";",
"$",
"editForm",
"=",
"$",
"this",
"->",
"createEditForm",
"(",
"$",
"oRemoteApp",
")",
";",
"$",
"editForm",
"->",
"handleRequest",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"editForm",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"sDomain",
"=",
"$",
"oRemoteApp",
"->",
"getDomain",
"(",
")",
";",
"if",
"(",
"substr",
"(",
"$",
"sDomain",
",",
"-",
"1",
",",
"1",
")",
"!==",
"\"/\"",
")",
"{",
"$",
"sDomain",
".=",
"\"/\"",
";",
"$",
"oRemoteApp",
"->",
"setDomain",
"(",
"$",
"sDomain",
")",
";",
"}",
"$",
"sModulePath",
"=",
"$",
"oRemoteApp",
"->",
"getApiUrl",
"(",
")",
";",
"if",
"(",
"substr",
"(",
"$",
"sModulePath",
",",
"0",
",",
"1",
")",
"===",
"\"/\"",
")",
"{",
"$",
"sModulePath",
"=",
"substr",
"(",
"$",
"sModulePath",
",",
"1",
")",
";",
"$",
"oRemoteApp",
"->",
"setApiUrl",
"(",
"$",
"sModulePath",
")",
";",
"}",
"$",
"oRemoteApp",
"->",
"save",
"(",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'remote_app'",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"render",
"(",
"'SlashworksAppBundle:RemoteApp:edit.html.twig'",
",",
"array",
"(",
"'entity'",
"=>",
"$",
"oRemoteApp",
",",
"'edit_form'",
"=>",
"$",
"editForm",
"->",
"createView",
"(",
")",
",",
"'delete_form'",
"=>",
"$",
"deleteForm",
"->",
"createView",
"(",
")",
",",
")",
")",
";",
"}"
] | Update existing remote app
@param \Symfony\Component\HttpFoundation\Request $request
@param $id
@return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
@throws \Exception
@throws \PropelException | [
"Update",
"existing",
"remote",
"app"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Controller/RemoteAppController.php#L520-L558 |
slashworks/control-bundle | src/Slashworks/AppBundle/Controller/RemoteAppController.php | RemoteAppController.deleteAction | public function deleteAction(Request $request, $id)
{
/** @var RemoteApp $oRemoteApp */
$oRemoteApp = RemoteAppQuery::create()->findOneById($id);
if ($oRemoteApp === null) {
throw $this->createNotFoundException('Unable to find RemoteApp entity.');
}
// get history-entries for remoteapp to delete
$aHistories = RemoteHistoryContaoQuery::create()->findByRemoteAppId($oRemoteApp->getId());
foreach ($aHistories as $oHistory) {
$oHistory->delete();
}
$oRemoteApp->delete();
return $this->redirect($this->generateUrl('remote_app'));
} | php | public function deleteAction(Request $request, $id)
{
/** @var RemoteApp $oRemoteApp */
$oRemoteApp = RemoteAppQuery::create()->findOneById($id);
if ($oRemoteApp === null) {
throw $this->createNotFoundException('Unable to find RemoteApp entity.');
}
// get history-entries for remoteapp to delete
$aHistories = RemoteHistoryContaoQuery::create()->findByRemoteAppId($oRemoteApp->getId());
foreach ($aHistories as $oHistory) {
$oHistory->delete();
}
$oRemoteApp->delete();
return $this->redirect($this->generateUrl('remote_app'));
} | [
"public",
"function",
"deleteAction",
"(",
"Request",
"$",
"request",
",",
"$",
"id",
")",
"{",
"/** @var RemoteApp $oRemoteApp */",
"$",
"oRemoteApp",
"=",
"RemoteAppQuery",
"::",
"create",
"(",
")",
"->",
"findOneById",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"oRemoteApp",
"===",
"null",
")",
"{",
"throw",
"$",
"this",
"->",
"createNotFoundException",
"(",
"'Unable to find RemoteApp entity.'",
")",
";",
"}",
"// get history-entries for remoteapp to delete",
"$",
"aHistories",
"=",
"RemoteHistoryContaoQuery",
"::",
"create",
"(",
")",
"->",
"findByRemoteAppId",
"(",
"$",
"oRemoteApp",
"->",
"getId",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"aHistories",
"as",
"$",
"oHistory",
")",
"{",
"$",
"oHistory",
"->",
"delete",
"(",
")",
";",
"}",
"$",
"oRemoteApp",
"->",
"delete",
"(",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'remote_app'",
")",
")",
";",
"}"
] | Delete remote app
@param \Symfony\Component\HttpFoundation\Request $request
@param $id
@return \Symfony\Component\HttpFoundation\RedirectResponse
@throws \Exception
@throws \PropelException | [
"Delete",
"remote",
"app"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Controller/RemoteAppController.php#L571-L590 |
slashworks/control-bundle | src/Slashworks/AppBundle/Controller/RemoteAppController.php | RemoteAppController.lastLogAction | public function lastLogAction($id)
{
$oLog = ApiLogQuery::create()->findOneByRemoteAppId($id);
$oRemoteApp = RemoteAppQuery::create()->findOneById($id);
return $this->render('SlashworksAppBundle:RemoteApp:log.html.twig', array(
'oLog' => $oLog,
'remote_app' => $oRemoteApp,
));
} | php | public function lastLogAction($id)
{
$oLog = ApiLogQuery::create()->findOneByRemoteAppId($id);
$oRemoteApp = RemoteAppQuery::create()->findOneById($id);
return $this->render('SlashworksAppBundle:RemoteApp:log.html.twig', array(
'oLog' => $oLog,
'remote_app' => $oRemoteApp,
));
} | [
"public",
"function",
"lastLogAction",
"(",
"$",
"id",
")",
"{",
"$",
"oLog",
"=",
"ApiLogQuery",
"::",
"create",
"(",
")",
"->",
"findOneByRemoteAppId",
"(",
"$",
"id",
")",
";",
"$",
"oRemoteApp",
"=",
"RemoteAppQuery",
"::",
"create",
"(",
")",
"->",
"findOneById",
"(",
"$",
"id",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"'SlashworksAppBundle:RemoteApp:log.html.twig'",
",",
"array",
"(",
"'oLog'",
"=>",
"$",
"oLog",
",",
"'remote_app'",
"=>",
"$",
"oRemoteApp",
",",
")",
")",
";",
"}"
] | Shows last api-log entry
@param $id
@return \Symfony\Component\HttpFoundation\Response | [
"Shows",
"last",
"api",
"-",
"log",
"entry"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Controller/RemoteAppController.php#L600-L610 |
slashworks/control-bundle | src/Slashworks/AppBundle/Controller/RemoteAppController.php | RemoteAppController.createCreateForm | private function createCreateForm(RemoteApp $oRemoteApp)
{
$form = $this->createForm(new RemoteAppType(), $oRemoteApp, array(
'action' => $this->generateUrl('remote_app_create'),
'method' => 'POST',
));
$form->add('submit', 'submit', array('label' => 'Create'));
return $form;
} | php | private function createCreateForm(RemoteApp $oRemoteApp)
{
$form = $this->createForm(new RemoteAppType(), $oRemoteApp, array(
'action' => $this->generateUrl('remote_app_create'),
'method' => 'POST',
));
$form->add('submit', 'submit', array('label' => 'Create'));
return $form;
} | [
"private",
"function",
"createCreateForm",
"(",
"RemoteApp",
"$",
"oRemoteApp",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"RemoteAppType",
"(",
")",
",",
"$",
"oRemoteApp",
",",
"array",
"(",
"'action'",
"=>",
"$",
"this",
"->",
"generateUrl",
"(",
"'remote_app_create'",
")",
",",
"'method'",
"=>",
"'POST'",
",",
")",
")",
";",
"$",
"form",
"->",
"add",
"(",
"'submit'",
",",
"'submit'",
",",
"array",
"(",
"'label'",
"=>",
"'Create'",
")",
")",
";",
"return",
"$",
"form",
";",
"}"
] | Creates a form to create a RemoteApp entity.
@param RemoteApp $oRemoteApp The entity
@return \Symfony\Component\Form\Form The form | [
"Creates",
"a",
"form",
"to",
"create",
"a",
"RemoteApp",
"entity",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Controller/RemoteAppController.php#L620-L631 |
slashworks/control-bundle | src/Slashworks/AppBundle/Controller/RemoteAppController.php | RemoteAppController.createEditForm | private function createEditForm(RemoteApp $oRemoteApp)
{
$form = $this->createForm(new RemoteAppType(), $oRemoteApp, array(
'action' => $this->generateUrl('remote_app_update', array('id' => $oRemoteApp->getId())),
'method' => 'PUT',
));
$form->add('submit', 'submit', array('label' => 'Update'));
return $form;
} | php | private function createEditForm(RemoteApp $oRemoteApp)
{
$form = $this->createForm(new RemoteAppType(), $oRemoteApp, array(
'action' => $this->generateUrl('remote_app_update', array('id' => $oRemoteApp->getId())),
'method' => 'PUT',
));
$form->add('submit', 'submit', array('label' => 'Update'));
return $form;
} | [
"private",
"function",
"createEditForm",
"(",
"RemoteApp",
"$",
"oRemoteApp",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"RemoteAppType",
"(",
")",
",",
"$",
"oRemoteApp",
",",
"array",
"(",
"'action'",
"=>",
"$",
"this",
"->",
"generateUrl",
"(",
"'remote_app_update'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"oRemoteApp",
"->",
"getId",
"(",
")",
")",
")",
",",
"'method'",
"=>",
"'PUT'",
",",
")",
")",
";",
"$",
"form",
"->",
"add",
"(",
"'submit'",
",",
"'submit'",
",",
"array",
"(",
"'label'",
"=>",
"'Update'",
")",
")",
";",
"return",
"$",
"form",
";",
"}"
] | @param \Slashworks\AppBundle\Model\RemoteApp $oRemoteApp
@return \Symfony\Component\Form\Form | [
"@param",
"\\",
"Slashworks",
"\\",
"AppBundle",
"\\",
"Model",
"\\",
"RemoteApp",
"$oRemoteApp"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Controller/RemoteAppController.php#L639-L650 |
iocaste/microservice-foundation | src/Transformer/Paginates.php | Paginates.paginatedCollection | protected function paginatedCollection($builder, $transformer, string $key = 'data', $perPage = 14): array
{
$paginator = $builder->paginate($perPage);
return [
$key => fractal(
$paginator->getCollection(),
$transformer,
new DataArraySerializer()
)->withResourceName(false)->toArray(),
'meta' => [
'service' => env('APP_SERVICE_NAME'),
'entity' => $transformer->getEntity(),
'pagination' => [
'total' => $paginator->total(),
'count' => $paginator->count(),
'per_page' => $paginator->perPage(),
'current_page' => $paginator->currentPage(),
'last_page' => $paginator->lastPage(),
'first_page_url' => $paginator->url(1),
'last_page_url' => $paginator->url($paginator->lastPage()),
'next_page_url' => $paginator->nextPageUrl(),
'prev_page_url' => $paginator->previousPageUrl(),
'from' => $paginator->firstItem(),
'to' => $paginator->lastItem(),
'has_more' => $paginator->hasMorePages(),
],
],
];
} | php | protected function paginatedCollection($builder, $transformer, string $key = 'data', $perPage = 14): array
{
$paginator = $builder->paginate($perPage);
return [
$key => fractal(
$paginator->getCollection(),
$transformer,
new DataArraySerializer()
)->withResourceName(false)->toArray(),
'meta' => [
'service' => env('APP_SERVICE_NAME'),
'entity' => $transformer->getEntity(),
'pagination' => [
'total' => $paginator->total(),
'count' => $paginator->count(),
'per_page' => $paginator->perPage(),
'current_page' => $paginator->currentPage(),
'last_page' => $paginator->lastPage(),
'first_page_url' => $paginator->url(1),
'last_page_url' => $paginator->url($paginator->lastPage()),
'next_page_url' => $paginator->nextPageUrl(),
'prev_page_url' => $paginator->previousPageUrl(),
'from' => $paginator->firstItem(),
'to' => $paginator->lastItem(),
'has_more' => $paginator->hasMorePages(),
],
],
];
} | [
"protected",
"function",
"paginatedCollection",
"(",
"$",
"builder",
",",
"$",
"transformer",
",",
"string",
"$",
"key",
"=",
"'data'",
",",
"$",
"perPage",
"=",
"14",
")",
":",
"array",
"{",
"$",
"paginator",
"=",
"$",
"builder",
"->",
"paginate",
"(",
"$",
"perPage",
")",
";",
"return",
"[",
"$",
"key",
"=>",
"fractal",
"(",
"$",
"paginator",
"->",
"getCollection",
"(",
")",
",",
"$",
"transformer",
",",
"new",
"DataArraySerializer",
"(",
")",
")",
"->",
"withResourceName",
"(",
"false",
")",
"->",
"toArray",
"(",
")",
",",
"'meta'",
"=>",
"[",
"'service'",
"=>",
"env",
"(",
"'APP_SERVICE_NAME'",
")",
",",
"'entity'",
"=>",
"$",
"transformer",
"->",
"getEntity",
"(",
")",
",",
"'pagination'",
"=>",
"[",
"'total'",
"=>",
"$",
"paginator",
"->",
"total",
"(",
")",
",",
"'count'",
"=>",
"$",
"paginator",
"->",
"count",
"(",
")",
",",
"'per_page'",
"=>",
"$",
"paginator",
"->",
"perPage",
"(",
")",
",",
"'current_page'",
"=>",
"$",
"paginator",
"->",
"currentPage",
"(",
")",
",",
"'last_page'",
"=>",
"$",
"paginator",
"->",
"lastPage",
"(",
")",
",",
"'first_page_url'",
"=>",
"$",
"paginator",
"->",
"url",
"(",
"1",
")",
",",
"'last_page_url'",
"=>",
"$",
"paginator",
"->",
"url",
"(",
"$",
"paginator",
"->",
"lastPage",
"(",
")",
")",
",",
"'next_page_url'",
"=>",
"$",
"paginator",
"->",
"nextPageUrl",
"(",
")",
",",
"'prev_page_url'",
"=>",
"$",
"paginator",
"->",
"previousPageUrl",
"(",
")",
",",
"'from'",
"=>",
"$",
"paginator",
"->",
"firstItem",
"(",
")",
",",
"'to'",
"=>",
"$",
"paginator",
"->",
"lastItem",
"(",
")",
",",
"'has_more'",
"=>",
"$",
"paginator",
"->",
"hasMorePages",
"(",
")",
",",
"]",
",",
"]",
",",
"]",
";",
"}"
] | @param $builder
@param $transformer
@param string $key
@param int $perPage
@return array | [
"@param",
"$builder",
"@param",
"$transformer",
"@param",
"string",
"$key",
"@param",
"int",
"$perPage"
] | train | https://github.com/iocaste/microservice-foundation/blob/274a154de4299e8a57314bab972e09f6d8cdae9e/src/Transformer/Paginates.php#L20-L50 |
iocaste/microservice-foundation | src/Transformer/Paginates.php | Paginates.respondWithCollection | protected function respondWithCollection($builder, $transformer, string $key = 'data'): JsonResponse
{
if (to_boolean($this->request->get('paginate', true)) === false) {
$collection = fractal()->collection($builder)
->transformWith($transformer)
->withResourceName($key)
->toArray();
$collection['meta'] = [
'service' => env('APP_SERVICE_NAME'),
'entity' => $transformer->getEntity()
];
} else {
$collection = $this->paginatedCollection(
$builder,
$transformer,
$key,
$this->request->get('per_page', 20)
);
}
$collection['meta'] = $collection['meta'] ?? [];
$collection['meta']['service'] = env('APP_SERVICE_NAME');
$collection['meta']['entity'] = $transformer->getEntity();
return $this->respondWithSuccess(
$collection
);
} | php | protected function respondWithCollection($builder, $transformer, string $key = 'data'): JsonResponse
{
if (to_boolean($this->request->get('paginate', true)) === false) {
$collection = fractal()->collection($builder)
->transformWith($transformer)
->withResourceName($key)
->toArray();
$collection['meta'] = [
'service' => env('APP_SERVICE_NAME'),
'entity' => $transformer->getEntity()
];
} else {
$collection = $this->paginatedCollection(
$builder,
$transformer,
$key,
$this->request->get('per_page', 20)
);
}
$collection['meta'] = $collection['meta'] ?? [];
$collection['meta']['service'] = env('APP_SERVICE_NAME');
$collection['meta']['entity'] = $transformer->getEntity();
return $this->respondWithSuccess(
$collection
);
} | [
"protected",
"function",
"respondWithCollection",
"(",
"$",
"builder",
",",
"$",
"transformer",
",",
"string",
"$",
"key",
"=",
"'data'",
")",
":",
"JsonResponse",
"{",
"if",
"(",
"to_boolean",
"(",
"$",
"this",
"->",
"request",
"->",
"get",
"(",
"'paginate'",
",",
"true",
")",
")",
"===",
"false",
")",
"{",
"$",
"collection",
"=",
"fractal",
"(",
")",
"->",
"collection",
"(",
"$",
"builder",
")",
"->",
"transformWith",
"(",
"$",
"transformer",
")",
"->",
"withResourceName",
"(",
"$",
"key",
")",
"->",
"toArray",
"(",
")",
";",
"$",
"collection",
"[",
"'meta'",
"]",
"=",
"[",
"'service'",
"=>",
"env",
"(",
"'APP_SERVICE_NAME'",
")",
",",
"'entity'",
"=>",
"$",
"transformer",
"->",
"getEntity",
"(",
")",
"]",
";",
"}",
"else",
"{",
"$",
"collection",
"=",
"$",
"this",
"->",
"paginatedCollection",
"(",
"$",
"builder",
",",
"$",
"transformer",
",",
"$",
"key",
",",
"$",
"this",
"->",
"request",
"->",
"get",
"(",
"'per_page'",
",",
"20",
")",
")",
";",
"}",
"$",
"collection",
"[",
"'meta'",
"]",
"=",
"$",
"collection",
"[",
"'meta'",
"]",
"??",
"[",
"]",
";",
"$",
"collection",
"[",
"'meta'",
"]",
"[",
"'service'",
"]",
"=",
"env",
"(",
"'APP_SERVICE_NAME'",
")",
";",
"$",
"collection",
"[",
"'meta'",
"]",
"[",
"'entity'",
"]",
"=",
"$",
"transformer",
"->",
"getEntity",
"(",
")",
";",
"return",
"$",
"this",
"->",
"respondWithSuccess",
"(",
"$",
"collection",
")",
";",
"}"
] | @param $builder
@param $transformer
@param string $key
@return JsonResponse | [
"@param",
"$builder",
"@param",
"$transformer",
"@param",
"string",
"$key"
] | train | https://github.com/iocaste/microservice-foundation/blob/274a154de4299e8a57314bab972e09f6d8cdae9e/src/Transformer/Paginates.php#L59-L87 |
Chill-project/Main | DataFixtures/ORM/LoadLanguages.php | LoadLanguages.prepareName | private function prepareName($languageCode) {
foreach ($this->container->getParameter('chill_main.available_languages') as $lang) {
$names[$lang] = Intl::getLanguageBundle()->getLanguageName($languageCode);
}
return $names;
} | php | private function prepareName($languageCode) {
foreach ($this->container->getParameter('chill_main.available_languages') as $lang) {
$names[$lang] = Intl::getLanguageBundle()->getLanguageName($languageCode);
}
return $names;
} | [
"private",
"function",
"prepareName",
"(",
"$",
"languageCode",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"container",
"->",
"getParameter",
"(",
"'chill_main.available_languages'",
")",
"as",
"$",
"lang",
")",
"{",
"$",
"names",
"[",
"$",
"lang",
"]",
"=",
"Intl",
"::",
"getLanguageBundle",
"(",
")",
"->",
"getLanguageName",
"(",
"$",
"languageCode",
")",
";",
"}",
"return",
"$",
"names",
";",
"}"
] | prepare names for languages
@param string $languageCode
@return string[] languages name indexed by available language code | [
"prepare",
"names",
"for",
"languages"
] | train | https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/DataFixtures/ORM/LoadLanguages.php#L71-L77 |
lode/fem | src/email.php | email.login | public static function login($config=null) {
if (empty(self::$config) || $config) {
self::load_config($config);
}
$transport = new \Swift_SmtpTransport(self::$config['host'], self::$config['port'], self::$config['ssl']);
$transport->setUsername(self::$config['user']);
$transport->setPassword(self::$config['pass']);
self::$mailer = new \Swift_Mailer($transport);
} | php | public static function login($config=null) {
if (empty(self::$config) || $config) {
self::load_config($config);
}
$transport = new \Swift_SmtpTransport(self::$config['host'], self::$config['port'], self::$config['ssl']);
$transport->setUsername(self::$config['user']);
$transport->setPassword(self::$config['pass']);
self::$mailer = new \Swift_Mailer($transport);
} | [
"public",
"static",
"function",
"login",
"(",
"$",
"config",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"self",
"::",
"$",
"config",
")",
"||",
"$",
"config",
")",
"{",
"self",
"::",
"load_config",
"(",
"$",
"config",
")",
";",
"}",
"$",
"transport",
"=",
"new",
"\\",
"Swift_SmtpTransport",
"(",
"self",
"::",
"$",
"config",
"[",
"'host'",
"]",
",",
"self",
"::",
"$",
"config",
"[",
"'port'",
"]",
",",
"self",
"::",
"$",
"config",
"[",
"'ssl'",
"]",
")",
";",
"$",
"transport",
"->",
"setUsername",
"(",
"self",
"::",
"$",
"config",
"[",
"'user'",
"]",
")",
";",
"$",
"transport",
"->",
"setPassword",
"(",
"self",
"::",
"$",
"config",
"[",
"'pass'",
"]",
")",
";",
"self",
"::",
"$",
"mailer",
"=",
"new",
"\\",
"Swift_Mailer",
"(",
"$",
"transport",
")",
";",
"}"
] | connects to the database, defined by ::load_config()
makes sure we have a strict and unicode aware connection
@param array $config optional, containing 'host', 'port', 'ssl', 'user', 'pass', 'from', 'name' values
@return void | [
"connects",
"to",
"the",
"database",
"defined",
"by",
"::",
"load_config",
"()",
"makes",
"sure",
"we",
"have",
"a",
"strict",
"and",
"unicode",
"aware",
"connection"
] | train | https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/email.php#L17-L27 |
lode/fem | src/email.php | email.send | public static function send($recipient, $subject, $body, $options=[]) {
if (empty(self::$mailer)) {
self::login();
}
if (ENVIRONMENT != 'production') {
$recipient = self::protect_emailaddress($recipient);
if (isset($options['cc'])) {
$options['cc'] = self::protect_emailaddress($options['cc']);
}
if (isset($options['bcc'])) {
$options['bcc'] = self::protect_emailaddress($options['bcc']);
}
if (isset($options['reply_to'])) {
$options['reply_to'] = self::protect_emailaddress($options['reply_to']);
}
$subject = '['.ENVIRONMENT.'] '.$subject;
}
$sender = [self::$config['from'] => self::$config['name']];
$message = new \Swift_Message();
$message->setFrom($sender);
$message->setTo($recipient);
$message->setSubject($subject);
$message->setBody($body);
if (isset($options['cc'])) {
$message->setCc($options['cc']);
}
if (isset($options['bcc'])) {
$message->setBcc($options['bcc']);
}
if (isset($options['reply_to'])) {
$message->setReplyTo($options['reply_to']);
}
if (isset($options['attachment'])) {
$attachment = \Swift_Attachment::fromPath($options['attachment']['path'], $options['attachment']['mime']);
$message->attach($attachment);
}
self::$mailer->send($message);
} | php | public static function send($recipient, $subject, $body, $options=[]) {
if (empty(self::$mailer)) {
self::login();
}
if (ENVIRONMENT != 'production') {
$recipient = self::protect_emailaddress($recipient);
if (isset($options['cc'])) {
$options['cc'] = self::protect_emailaddress($options['cc']);
}
if (isset($options['bcc'])) {
$options['bcc'] = self::protect_emailaddress($options['bcc']);
}
if (isset($options['reply_to'])) {
$options['reply_to'] = self::protect_emailaddress($options['reply_to']);
}
$subject = '['.ENVIRONMENT.'] '.$subject;
}
$sender = [self::$config['from'] => self::$config['name']];
$message = new \Swift_Message();
$message->setFrom($sender);
$message->setTo($recipient);
$message->setSubject($subject);
$message->setBody($body);
if (isset($options['cc'])) {
$message->setCc($options['cc']);
}
if (isset($options['bcc'])) {
$message->setBcc($options['bcc']);
}
if (isset($options['reply_to'])) {
$message->setReplyTo($options['reply_to']);
}
if (isset($options['attachment'])) {
$attachment = \Swift_Attachment::fromPath($options['attachment']['path'], $options['attachment']['mime']);
$message->attach($attachment);
}
self::$mailer->send($message);
} | [
"public",
"static",
"function",
"send",
"(",
"$",
"recipient",
",",
"$",
"subject",
",",
"$",
"body",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"empty",
"(",
"self",
"::",
"$",
"mailer",
")",
")",
"{",
"self",
"::",
"login",
"(",
")",
";",
"}",
"if",
"(",
"ENVIRONMENT",
"!=",
"'production'",
")",
"{",
"$",
"recipient",
"=",
"self",
"::",
"protect_emailaddress",
"(",
"$",
"recipient",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'cc'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'cc'",
"]",
"=",
"self",
"::",
"protect_emailaddress",
"(",
"$",
"options",
"[",
"'cc'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'bcc'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'bcc'",
"]",
"=",
"self",
"::",
"protect_emailaddress",
"(",
"$",
"options",
"[",
"'bcc'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'reply_to'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'reply_to'",
"]",
"=",
"self",
"::",
"protect_emailaddress",
"(",
"$",
"options",
"[",
"'reply_to'",
"]",
")",
";",
"}",
"$",
"subject",
"=",
"'['",
".",
"ENVIRONMENT",
".",
"'] '",
".",
"$",
"subject",
";",
"}",
"$",
"sender",
"=",
"[",
"self",
"::",
"$",
"config",
"[",
"'from'",
"]",
"=>",
"self",
"::",
"$",
"config",
"[",
"'name'",
"]",
"]",
";",
"$",
"message",
"=",
"new",
"\\",
"Swift_Message",
"(",
")",
";",
"$",
"message",
"->",
"setFrom",
"(",
"$",
"sender",
")",
";",
"$",
"message",
"->",
"setTo",
"(",
"$",
"recipient",
")",
";",
"$",
"message",
"->",
"setSubject",
"(",
"$",
"subject",
")",
";",
"$",
"message",
"->",
"setBody",
"(",
"$",
"body",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'cc'",
"]",
")",
")",
"{",
"$",
"message",
"->",
"setCc",
"(",
"$",
"options",
"[",
"'cc'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'bcc'",
"]",
")",
")",
"{",
"$",
"message",
"->",
"setBcc",
"(",
"$",
"options",
"[",
"'bcc'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'reply_to'",
"]",
")",
")",
"{",
"$",
"message",
"->",
"setReplyTo",
"(",
"$",
"options",
"[",
"'reply_to'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'attachment'",
"]",
")",
")",
"{",
"$",
"attachment",
"=",
"\\",
"Swift_Attachment",
"::",
"fromPath",
"(",
"$",
"options",
"[",
"'attachment'",
"]",
"[",
"'path'",
"]",
",",
"$",
"options",
"[",
"'attachment'",
"]",
"[",
"'mime'",
"]",
")",
";",
"$",
"message",
"->",
"attach",
"(",
"$",
"attachment",
")",
";",
"}",
"self",
"::",
"$",
"mailer",
"->",
"send",
"(",
"$",
"message",
")",
";",
"}"
] | sends an email directly
@todo allow for html emails as well
@param mixed $recipient string or [email => name]
@param string $subject
@param string $message plain text only for now
@param array $options array with optional 'cc', 'bcc', 'reply_to', 'attachment' options
'attachment' is expected to be an array with 'path' and 'mime' keys
@return void | [
"sends",
"an",
"email",
"directly"
] | train | https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/email.php#L41-L84 |
lode/fem | src/email.php | email.validate | public static function validate($emailaddress) {
try {
$message = new \Swift_Message();
$message->setTo($emailaddress);
}
catch (\Swift_RfcComplianceException $e) {
return false;
}
return true;
} | php | public static function validate($emailaddress) {
try {
$message = new \Swift_Message();
$message->setTo($emailaddress);
}
catch (\Swift_RfcComplianceException $e) {
return false;
}
return true;
} | [
"public",
"static",
"function",
"validate",
"(",
"$",
"emailaddress",
")",
"{",
"try",
"{",
"$",
"message",
"=",
"new",
"\\",
"Swift_Message",
"(",
")",
";",
"$",
"message",
"->",
"setTo",
"(",
"$",
"emailaddress",
")",
";",
"}",
"catch",
"(",
"\\",
"Swift_RfcComplianceException",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | check email addresses validity
@param string $emailaddress
@return boolean | [
"check",
"email",
"addresses",
"validity"
] | train | https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/email.php#L92-L102 |
lode/fem | src/email.php | email.protect_emailaddress | public static function protect_emailaddress($emailaddress, $catchall_address=null) {
if (empty($catchall_address)) {
if (empty(self::$config)) {
self::load_config();
}
$catchall_address = self::$config['from'];
}
$recipient_name = null;
if (is_array($emailaddress)) {
$recipient_name = current($emailaddress);
$emailaddress = key($emailaddress);
}
if (self::validate($emailaddress) == false) {
$exception = bootstrap::get_library('exception');
throw new $exception('can not convert invalid email address');
}
$emailaddress_key = preg_replace('{[^a-zA-Z0-9_]}', '_', $emailaddress);
$emailaddress = str_replace('@', '+'.$emailaddress_key.'@', $catchall_address);
if ($recipient_name) {
$emailaddress = array($emailaddress => $recipient_name);
}
return $emailaddress;
} | php | public static function protect_emailaddress($emailaddress, $catchall_address=null) {
if (empty($catchall_address)) {
if (empty(self::$config)) {
self::load_config();
}
$catchall_address = self::$config['from'];
}
$recipient_name = null;
if (is_array($emailaddress)) {
$recipient_name = current($emailaddress);
$emailaddress = key($emailaddress);
}
if (self::validate($emailaddress) == false) {
$exception = bootstrap::get_library('exception');
throw new $exception('can not convert invalid email address');
}
$emailaddress_key = preg_replace('{[^a-zA-Z0-9_]}', '_', $emailaddress);
$emailaddress = str_replace('@', '+'.$emailaddress_key.'@', $catchall_address);
if ($recipient_name) {
$emailaddress = array($emailaddress => $recipient_name);
}
return $emailaddress;
} | [
"public",
"static",
"function",
"protect_emailaddress",
"(",
"$",
"emailaddress",
",",
"$",
"catchall_address",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"catchall_address",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"self",
"::",
"$",
"config",
")",
")",
"{",
"self",
"::",
"load_config",
"(",
")",
";",
"}",
"$",
"catchall_address",
"=",
"self",
"::",
"$",
"config",
"[",
"'from'",
"]",
";",
"}",
"$",
"recipient_name",
"=",
"null",
";",
"if",
"(",
"is_array",
"(",
"$",
"emailaddress",
")",
")",
"{",
"$",
"recipient_name",
"=",
"current",
"(",
"$",
"emailaddress",
")",
";",
"$",
"emailaddress",
"=",
"key",
"(",
"$",
"emailaddress",
")",
";",
"}",
"if",
"(",
"self",
"::",
"validate",
"(",
"$",
"emailaddress",
")",
"==",
"false",
")",
"{",
"$",
"exception",
"=",
"bootstrap",
"::",
"get_library",
"(",
"'exception'",
")",
";",
"throw",
"new",
"$",
"exception",
"(",
"'can not convert invalid email address'",
")",
";",
"}",
"$",
"emailaddress_key",
"=",
"preg_replace",
"(",
"'{[^a-zA-Z0-9_]}'",
",",
"'_'",
",",
"$",
"emailaddress",
")",
";",
"$",
"emailaddress",
"=",
"str_replace",
"(",
"'@'",
",",
"'+'",
".",
"$",
"emailaddress_key",
".",
"'@'",
",",
"$",
"catchall_address",
")",
";",
"if",
"(",
"$",
"recipient_name",
")",
"{",
"$",
"emailaddress",
"=",
"array",
"(",
"$",
"emailaddress",
"=>",
"$",
"recipient_name",
")",
";",
"}",
"return",
"$",
"emailaddress",
";",
"}"
] | protect email addresses from going to real people on non-production environments
it returns the website's sender address with the original one as '+alias'
@param string $emailaddress i.e. [email protected]
@param string $catchall_address i.e. [email protected]
@return string i.e. [email protected] | [
"protect",
"email",
"addresses",
"from",
"going",
"to",
"real",
"people",
"on",
"non",
"-",
"production",
"environments"
] | train | https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/email.php#L113-L142 |
lode/fem | src/email.php | email.load_config | protected static function load_config($config=null) {
if ($config) {
self::$config = $config;
return;
}
$config_file = ROOT_DIR.'config/email.ini';
if (file_exists($config_file) == false) {
$exception = bootstrap::get_library('exception');
throw new $exception('no email config found');
}
self::$config = parse_ini_file($config_file);
// decode the password
self::$config['pass'] = base64_decode(self::$config['pass']);
} | php | protected static function load_config($config=null) {
if ($config) {
self::$config = $config;
return;
}
$config_file = ROOT_DIR.'config/email.ini';
if (file_exists($config_file) == false) {
$exception = bootstrap::get_library('exception');
throw new $exception('no email config found');
}
self::$config = parse_ini_file($config_file);
// decode the password
self::$config['pass'] = base64_decode(self::$config['pass']);
} | [
"protected",
"static",
"function",
"load_config",
"(",
"$",
"config",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"config",
")",
"{",
"self",
"::",
"$",
"config",
"=",
"$",
"config",
";",
"return",
";",
"}",
"$",
"config_file",
"=",
"ROOT_DIR",
".",
"'config/email.ini'",
";",
"if",
"(",
"file_exists",
"(",
"$",
"config_file",
")",
"==",
"false",
")",
"{",
"$",
"exception",
"=",
"bootstrap",
"::",
"get_library",
"(",
"'exception'",
")",
";",
"throw",
"new",
"$",
"exception",
"(",
"'no email config found'",
")",
";",
"}",
"self",
"::",
"$",
"config",
"=",
"parse_ini_file",
"(",
"$",
"config_file",
")",
";",
"// decode the password",
"self",
"::",
"$",
"config",
"[",
"'pass'",
"]",
"=",
"base64_decode",
"(",
"self",
"::",
"$",
"config",
"[",
"'pass'",
"]",
")",
";",
"}"
] | collects the config for connecting from a ini file
@note the password is expected to be in a base64 encoded format
to help against shoulder surfing
@note sets self::$config with 'host', 'port', 'ssl', 'user', 'pass', 'from', 'name' values | [
"collects",
"the",
"config",
"for",
"connecting",
"from",
"a",
"ini",
"file"
] | train | https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/email.php#L152-L168 |
ClanCats/Core | src/classes/CCHTTP.php | CCHTTP.header | public function header( $key, $value = null ) {
$key = explode( '-', $key );
foreach( $key as $k => $v ) {
$key[$k] = ucfirst( strtolower($v));
}
$key = implode( '-', $key );
if ( !is_null( $value ) ) {
$this->_headers[$key] = $value;
}
return $this->_headers[$key];
} | php | public function header( $key, $value = null ) {
$key = explode( '-', $key );
foreach( $key as $k => $v ) {
$key[$k] = ucfirst( strtolower($v));
}
$key = implode( '-', $key );
if ( !is_null( $value ) ) {
$this->_headers[$key] = $value;
}
return $this->_headers[$key];
} | [
"public",
"function",
"header",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"null",
")",
"{",
"$",
"key",
"=",
"explode",
"(",
"'-'",
",",
"$",
"key",
")",
";",
"foreach",
"(",
"$",
"key",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"key",
"[",
"$",
"k",
"]",
"=",
"ucfirst",
"(",
"strtolower",
"(",
"$",
"v",
")",
")",
";",
"}",
"$",
"key",
"=",
"implode",
"(",
"'-'",
",",
"$",
"key",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"value",
")",
")",
"{",
"$",
"this",
"->",
"_headers",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"this",
"->",
"_headers",
"[",
"$",
"key",
"]",
";",
"}"
] | header getter and setter
@param string $key
@param mixed $value | [
"header",
"getter",
"and",
"setter"
] | train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCHTTP.php#L134-L147 |
ClanCats/Core | src/classes/CCHTTP.php | CCHTTP.request | public function request( $what = 'both' ) {
/*
* prepare curl
*/
$ch = curl_init( $this->url );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
//curl_setopt( $ch, CURLOPT_VERBOSE, 1 );
curl_setopt( $ch, CURLOPT_HEADER, 1 );
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1 );
/*
* prepare the headers
*/
$headers = array();
foreach( $this->_headers as $key => $header ) {
$headers[] = $key.': '.$header;
}
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
/*
* post data
*/
if ( $this->type == static::post || $this->type == static::put ) {
curl_setopt( $ch, CURLOPT_POST, 1 );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $post_data );
}
/*
* execute that request
*/
$response = curl_exec( $ch );
if( $response === false ) {
//echo 'Curl error: ' . curl_error($ch);
return false;
}
$header_size = curl_getinfo( $ch, CURLINFO_HEADER_SIZE );
$header = substr( $response, 0, $header_size );
$body = substr( $response, $header_size );
// close it
curl_close($ch);
// format the header
$arr_header = array();
$header = explode( "\n", $header );
foreach( $header as $item ) {
$head_part = explode( ":", $item );
if ( $this->_normalize_header_keys ) {
$arr_header[strtolower( trim($head_part[0]) )] = trim($head_part[1]);
}
else {
$arr_header[trim($head_part[0])] = trim($head_part[1]);
}
}
/*
* return it
*/
if ( $what == 'both' ) {
$return = new \stdClass;
$return->body = $body;
$return->header = $arr_header;
}
elseif ( $what == 'body' ) {
$return = $body;
}
elseif ( $what == 'header' ) {
$return = $arr_header;
}
else {
throw new CCException( 'CCHTTP - param 1 in request function is invalid! Allowed are: both, header, body' );
}
return $return;
} | php | public function request( $what = 'both' ) {
/*
* prepare curl
*/
$ch = curl_init( $this->url );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
//curl_setopt( $ch, CURLOPT_VERBOSE, 1 );
curl_setopt( $ch, CURLOPT_HEADER, 1 );
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1 );
/*
* prepare the headers
*/
$headers = array();
foreach( $this->_headers as $key => $header ) {
$headers[] = $key.': '.$header;
}
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
/*
* post data
*/
if ( $this->type == static::post || $this->type == static::put ) {
curl_setopt( $ch, CURLOPT_POST, 1 );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $post_data );
}
/*
* execute that request
*/
$response = curl_exec( $ch );
if( $response === false ) {
//echo 'Curl error: ' . curl_error($ch);
return false;
}
$header_size = curl_getinfo( $ch, CURLINFO_HEADER_SIZE );
$header = substr( $response, 0, $header_size );
$body = substr( $response, $header_size );
// close it
curl_close($ch);
// format the header
$arr_header = array();
$header = explode( "\n", $header );
foreach( $header as $item ) {
$head_part = explode( ":", $item );
if ( $this->_normalize_header_keys ) {
$arr_header[strtolower( trim($head_part[0]) )] = trim($head_part[1]);
}
else {
$arr_header[trim($head_part[0])] = trim($head_part[1]);
}
}
/*
* return it
*/
if ( $what == 'both' ) {
$return = new \stdClass;
$return->body = $body;
$return->header = $arr_header;
}
elseif ( $what == 'body' ) {
$return = $body;
}
elseif ( $what == 'header' ) {
$return = $arr_header;
}
else {
throw new CCException( 'CCHTTP - param 1 in request function is invalid! Allowed are: both, header, body' );
}
return $return;
} | [
"public",
"function",
"request",
"(",
"$",
"what",
"=",
"'both'",
")",
"{",
"/*\n\t\t * prepare curl\n\t\t */",
"$",
"ch",
"=",
"curl_init",
"(",
"$",
"this",
"->",
"url",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_RETURNTRANSFER",
",",
"1",
")",
";",
"//curl_setopt( $ch, CURLOPT_VERBOSE, 1 );",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_HEADER",
",",
"1",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_FOLLOWLOCATION",
",",
"1",
")",
";",
"/*\n\t\t * prepare the headers\n\t\t */",
"$",
"headers",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"_headers",
"as",
"$",
"key",
"=>",
"$",
"header",
")",
"{",
"$",
"headers",
"[",
"]",
"=",
"$",
"key",
".",
"': '",
".",
"$",
"header",
";",
"}",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_HTTPHEADER",
",",
"$",
"headers",
")",
";",
"/*\n\t\t * post data\n\t\t */",
"if",
"(",
"$",
"this",
"->",
"type",
"==",
"static",
"::",
"post",
"||",
"$",
"this",
"->",
"type",
"==",
"static",
"::",
"put",
")",
"{",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_POST",
",",
"1",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_POSTFIELDS",
",",
"$",
"post_data",
")",
";",
"}",
"/*\n\t\t * execute that request\n\t\t */",
"$",
"response",
"=",
"curl_exec",
"(",
"$",
"ch",
")",
";",
"if",
"(",
"$",
"response",
"===",
"false",
")",
"{",
"//echo 'Curl error: ' . curl_error($ch); ",
"return",
"false",
";",
"}",
"$",
"header_size",
"=",
"curl_getinfo",
"(",
"$",
"ch",
",",
"CURLINFO_HEADER_SIZE",
")",
";",
"$",
"header",
"=",
"substr",
"(",
"$",
"response",
",",
"0",
",",
"$",
"header_size",
")",
";",
"$",
"body",
"=",
"substr",
"(",
"$",
"response",
",",
"$",
"header_size",
")",
";",
"// close it",
"curl_close",
"(",
"$",
"ch",
")",
";",
"// format the header",
"$",
"arr_header",
"=",
"array",
"(",
")",
";",
"$",
"header",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"header",
")",
";",
"foreach",
"(",
"$",
"header",
"as",
"$",
"item",
")",
"{",
"$",
"head_part",
"=",
"explode",
"(",
"\":\"",
",",
"$",
"item",
")",
";",
"if",
"(",
"$",
"this",
"->",
"_normalize_header_keys",
")",
"{",
"$",
"arr_header",
"[",
"strtolower",
"(",
"trim",
"(",
"$",
"head_part",
"[",
"0",
"]",
")",
")",
"]",
"=",
"trim",
"(",
"$",
"head_part",
"[",
"1",
"]",
")",
";",
"}",
"else",
"{",
"$",
"arr_header",
"[",
"trim",
"(",
"$",
"head_part",
"[",
"0",
"]",
")",
"]",
"=",
"trim",
"(",
"$",
"head_part",
"[",
"1",
"]",
")",
";",
"}",
"}",
"/*\n\t\t * return it\n\t\t */",
"if",
"(",
"$",
"what",
"==",
"'both'",
")",
"{",
"$",
"return",
"=",
"new",
"\\",
"stdClass",
";",
"$",
"return",
"->",
"body",
"=",
"$",
"body",
";",
"$",
"return",
"->",
"header",
"=",
"$",
"arr_header",
";",
"}",
"elseif",
"(",
"$",
"what",
"==",
"'body'",
")",
"{",
"$",
"return",
"=",
"$",
"body",
";",
"}",
"elseif",
"(",
"$",
"what",
"==",
"'header'",
")",
"{",
"$",
"return",
"=",
"$",
"arr_header",
";",
"}",
"else",
"{",
"throw",
"new",
"CCException",
"(",
"'CCHTTP - param 1 in request function is invalid! Allowed are: both, header, body'",
")",
";",
"}",
"return",
"$",
"return",
";",
"}"
] | and finally execute the request
returns false if the request fails
@param string $what | both, header, body
@return mixed | [
"and",
"finally",
"execute",
"the",
"request"
] | train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCHTTP.php#L157-L231 |
yuncms/framework | src/base/ApplicationTrait.php | ApplicationTrait.sendMail | public function sendMail($to, $subject, $view, $params = []): bool
{
if (empty($to)) {
return false;
}
/** @var \yii\mail\MailerInterface $mailer */
$mailer = $this->getMailer();
return $mailer->compose(['html' => $view, 'text' => $view], $params)->setTo($to)->setSubject($subject)->send();
} | php | public function sendMail($to, $subject, $view, $params = []): bool
{
if (empty($to)) {
return false;
}
/** @var \yii\mail\MailerInterface $mailer */
$mailer = $this->getMailer();
return $mailer->compose(['html' => $view, 'text' => $view], $params)->setTo($to)->setSubject($subject)->send();
} | [
"public",
"function",
"sendMail",
"(",
"$",
"to",
",",
"$",
"subject",
",",
"$",
"view",
",",
"$",
"params",
"=",
"[",
"]",
")",
":",
"bool",
"{",
"if",
"(",
"empty",
"(",
"$",
"to",
")",
")",
"{",
"return",
"false",
";",
"}",
"/** @var \\yii\\mail\\MailerInterface $mailer */",
"$",
"mailer",
"=",
"$",
"this",
"->",
"getMailer",
"(",
")",
";",
"return",
"$",
"mailer",
"->",
"compose",
"(",
"[",
"'html'",
"=>",
"$",
"view",
",",
"'text'",
"=>",
"$",
"view",
"]",
",",
"$",
"params",
")",
"->",
"setTo",
"(",
"$",
"to",
")",
"->",
"setSubject",
"(",
"$",
"subject",
")",
"->",
"send",
"(",
")",
";",
"}"
] | 给用户发送邮件
@param string $to 收件箱
@param string $subject 标题
@param string $view 视图
@param array $params 参数
@return boolean | [
"给用户发送邮件"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/base/ApplicationTrait.php#L149-L157 |
vorbind/influx-analytics | src/Import/ImportAnalytics.php | ImportAnalytics.execute | public function execute($now) {
try {
$metrics = $this->reader->getMetricsConfig();
foreach ($metrics as $metric => $config) {
if (!$this->isMetricValid($config)) {
print("Metric configuration is not valid!");
throw new Exception("Metric configuration is not valid!");
}
$rps = array_keys($config["mysql"]["query"]);
foreach($rps as $rp) {
print("Import metric[$metric] for rp[$rp]\n");
$this->importMetric($now, $metric, $config, $rp);
}
}
} catch (Exception $e) {
printf("Error importing data:" . $e->getMessage(), PHP_EOL);
}
} | php | public function execute($now) {
try {
$metrics = $this->reader->getMetricsConfig();
foreach ($metrics as $metric => $config) {
if (!$this->isMetricValid($config)) {
print("Metric configuration is not valid!");
throw new Exception("Metric configuration is not valid!");
}
$rps = array_keys($config["mysql"]["query"]);
foreach($rps as $rp) {
print("Import metric[$metric] for rp[$rp]\n");
$this->importMetric($now, $metric, $config, $rp);
}
}
} catch (Exception $e) {
printf("Error importing data:" . $e->getMessage(), PHP_EOL);
}
} | [
"public",
"function",
"execute",
"(",
"$",
"now",
")",
"{",
"try",
"{",
"$",
"metrics",
"=",
"$",
"this",
"->",
"reader",
"->",
"getMetricsConfig",
"(",
")",
";",
"foreach",
"(",
"$",
"metrics",
"as",
"$",
"metric",
"=>",
"$",
"config",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isMetricValid",
"(",
"$",
"config",
")",
")",
"{",
"print",
"(",
"\"Metric configuration is not valid!\"",
")",
";",
"throw",
"new",
"Exception",
"(",
"\"Metric configuration is not valid!\"",
")",
";",
"}",
"$",
"rps",
"=",
"array_keys",
"(",
"$",
"config",
"[",
"\"mysql\"",
"]",
"[",
"\"query\"",
"]",
")",
";",
"foreach",
"(",
"$",
"rps",
"as",
"$",
"rp",
")",
"{",
"print",
"(",
"\"Import metric[$metric] for rp[$rp]\\n\"",
")",
";",
"$",
"this",
"->",
"importMetric",
"(",
"$",
"now",
",",
"$",
"metric",
",",
"$",
"config",
",",
"$",
"rp",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"printf",
"(",
"\"Error importing data:\"",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"PHP_EOL",
")",
";",
"}",
"}"
] | Execute import | [
"Execute",
"import"
] | train | https://github.com/vorbind/influx-analytics/blob/8c0c150351f045ccd3d57063f2b3b50a2c926e3e/src/Import/ImportAnalytics.php#L59-L77 |
vorbind/influx-analytics | src/Import/ImportAnalytics.php | ImportAnalytics.importMetric | protected function importMetric($now, $metric, $config, $rp) {
$offset = 0;
$limit = 100;
while (true) {
$query = sprintf($config["mysql"]["query"][$rp], $limit, $offset);
$rows = $this->mapper->getRows($query);
if (count($rows) <= 0) {
break;
}
foreach ($rows as $row) {
$tags = array_intersect_key($row, $config["influx"]["tags"]);
if(!$this->areTagsValid($tags) || !$this->isUtcValid($tags["utc"], $now, $rp)) {
print("Utc[" . $tags["utc"] . "] is not valid, now[$now], rp[$rp]\n");
} else {
$value = $tags["value"];
$utc = $tags["utc"];
unset($tags["value"]);
unset($tags["utc"]);
$this->analytics->save($metric, $tags, intval($value), $utc, $rp);
}
}
$offset += $limit;
usleep(300000);
}
} | php | protected function importMetric($now, $metric, $config, $rp) {
$offset = 0;
$limit = 100;
while (true) {
$query = sprintf($config["mysql"]["query"][$rp], $limit, $offset);
$rows = $this->mapper->getRows($query);
if (count($rows) <= 0) {
break;
}
foreach ($rows as $row) {
$tags = array_intersect_key($row, $config["influx"]["tags"]);
if(!$this->areTagsValid($tags) || !$this->isUtcValid($tags["utc"], $now, $rp)) {
print("Utc[" . $tags["utc"] . "] is not valid, now[$now], rp[$rp]\n");
} else {
$value = $tags["value"];
$utc = $tags["utc"];
unset($tags["value"]);
unset($tags["utc"]);
$this->analytics->save($metric, $tags, intval($value), $utc, $rp);
}
}
$offset += $limit;
usleep(300000);
}
} | [
"protected",
"function",
"importMetric",
"(",
"$",
"now",
",",
"$",
"metric",
",",
"$",
"config",
",",
"$",
"rp",
")",
"{",
"$",
"offset",
"=",
"0",
";",
"$",
"limit",
"=",
"100",
";",
"while",
"(",
"true",
")",
"{",
"$",
"query",
"=",
"sprintf",
"(",
"$",
"config",
"[",
"\"mysql\"",
"]",
"[",
"\"query\"",
"]",
"[",
"$",
"rp",
"]",
",",
"$",
"limit",
",",
"$",
"offset",
")",
";",
"$",
"rows",
"=",
"$",
"this",
"->",
"mapper",
"->",
"getRows",
"(",
"$",
"query",
")",
";",
"if",
"(",
"count",
"(",
"$",
"rows",
")",
"<=",
"0",
")",
"{",
"break",
";",
"}",
"foreach",
"(",
"$",
"rows",
"as",
"$",
"row",
")",
"{",
"$",
"tags",
"=",
"array_intersect_key",
"(",
"$",
"row",
",",
"$",
"config",
"[",
"\"influx\"",
"]",
"[",
"\"tags\"",
"]",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"areTagsValid",
"(",
"$",
"tags",
")",
"||",
"!",
"$",
"this",
"->",
"isUtcValid",
"(",
"$",
"tags",
"[",
"\"utc\"",
"]",
",",
"$",
"now",
",",
"$",
"rp",
")",
")",
"{",
"print",
"(",
"\"Utc[\"",
".",
"$",
"tags",
"[",
"\"utc\"",
"]",
".",
"\"] is not valid, now[$now], rp[$rp]\\n\"",
")",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"$",
"tags",
"[",
"\"value\"",
"]",
";",
"$",
"utc",
"=",
"$",
"tags",
"[",
"\"utc\"",
"]",
";",
"unset",
"(",
"$",
"tags",
"[",
"\"value\"",
"]",
")",
";",
"unset",
"(",
"$",
"tags",
"[",
"\"utc\"",
"]",
")",
";",
"$",
"this",
"->",
"analytics",
"->",
"save",
"(",
"$",
"metric",
",",
"$",
"tags",
",",
"intval",
"(",
"$",
"value",
")",
",",
"$",
"utc",
",",
"$",
"rp",
")",
";",
"}",
"}",
"$",
"offset",
"+=",
"$",
"limit",
";",
"usleep",
"(",
"300000",
")",
";",
"}",
"}"
] | Import metric
@param string $now
@param string $metric
@param array $config
@param string $rp | [
"Import",
"metric"
] | train | https://github.com/vorbind/influx-analytics/blob/8c0c150351f045ccd3d57063f2b3b50a2c926e3e/src/Import/ImportAnalytics.php#L87-L114 |
vorbind/influx-analytics | src/Import/ImportAnalytics.php | ImportAnalytics.isUtcValid | protected function isUtcValid($utc, $now, $rp) {
if( 'forever' == $rp) {
$nowDate = date('Y-m-d', strtotime($now));
if(strtotime($utc) >= strtotime($nowDate)) {
return false;
}
}
if( 'years_5' == $rp) {
$min = date('i', strtotime($now));
$minutes = $min > 45 ? 45 : ( $min > 30 ? 30 : ( $min > 15 ? 15 : '00') );
$nowLimit = date('Y-m-d', strtotime($now)) . "T" . date('H', strtotime($now)) . ":$minutes:00Z";
if(strtotime($utc) >= strtotime($nowLimit)) {
return false;
}
}
return true;
} | php | protected function isUtcValid($utc, $now, $rp) {
if( 'forever' == $rp) {
$nowDate = date('Y-m-d', strtotime($now));
if(strtotime($utc) >= strtotime($nowDate)) {
return false;
}
}
if( 'years_5' == $rp) {
$min = date('i', strtotime($now));
$minutes = $min > 45 ? 45 : ( $min > 30 ? 30 : ( $min > 15 ? 15 : '00') );
$nowLimit = date('Y-m-d', strtotime($now)) . "T" . date('H', strtotime($now)) . ":$minutes:00Z";
if(strtotime($utc) >= strtotime($nowLimit)) {
return false;
}
}
return true;
} | [
"protected",
"function",
"isUtcValid",
"(",
"$",
"utc",
",",
"$",
"now",
",",
"$",
"rp",
")",
"{",
"if",
"(",
"'forever'",
"==",
"$",
"rp",
")",
"{",
"$",
"nowDate",
"=",
"date",
"(",
"'Y-m-d'",
",",
"strtotime",
"(",
"$",
"now",
")",
")",
";",
"if",
"(",
"strtotime",
"(",
"$",
"utc",
")",
">=",
"strtotime",
"(",
"$",
"nowDate",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"if",
"(",
"'years_5'",
"==",
"$",
"rp",
")",
"{",
"$",
"min",
"=",
"date",
"(",
"'i'",
",",
"strtotime",
"(",
"$",
"now",
")",
")",
";",
"$",
"minutes",
"=",
"$",
"min",
">",
"45",
"?",
"45",
":",
"(",
"$",
"min",
">",
"30",
"?",
"30",
":",
"(",
"$",
"min",
">",
"15",
"?",
"15",
":",
"'00'",
")",
")",
";",
"$",
"nowLimit",
"=",
"date",
"(",
"'Y-m-d'",
",",
"strtotime",
"(",
"$",
"now",
")",
")",
".",
"\"T\"",
".",
"date",
"(",
"'H'",
",",
"strtotime",
"(",
"$",
"now",
")",
")",
".",
"\":$minutes:00Z\"",
";",
"if",
"(",
"strtotime",
"(",
"$",
"utc",
")",
">=",
"strtotime",
"(",
"$",
"nowLimit",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Is valid utc
@param string $utc
@param string $now
@param string $rp
@return boolean | [
"Is",
"valid",
"utc"
] | train | https://github.com/vorbind/influx-analytics/blob/8c0c150351f045ccd3d57063f2b3b50a2c926e3e/src/Import/ImportAnalytics.php#L124-L140 |
vorbind/influx-analytics | src/Import/ImportAnalytics.php | ImportAnalytics.isMetricValid | protected function isMetricValid($metric) {
if (!isset($metric) || !is_array($metric)
|| !isset($metric["influx"]) || !isset($metric["influx"]["tags"])
|| !isset($metric["mysql"]) || !isset($metric["mysql"]["query"])) {
return false;
}
return true;
} | php | protected function isMetricValid($metric) {
if (!isset($metric) || !is_array($metric)
|| !isset($metric["influx"]) || !isset($metric["influx"]["tags"])
|| !isset($metric["mysql"]) || !isset($metric["mysql"]["query"])) {
return false;
}
return true;
} | [
"protected",
"function",
"isMetricValid",
"(",
"$",
"metric",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"metric",
")",
"||",
"!",
"is_array",
"(",
"$",
"metric",
")",
"||",
"!",
"isset",
"(",
"$",
"metric",
"[",
"\"influx\"",
"]",
")",
"||",
"!",
"isset",
"(",
"$",
"metric",
"[",
"\"influx\"",
"]",
"[",
"\"tags\"",
"]",
")",
"||",
"!",
"isset",
"(",
"$",
"metric",
"[",
"\"mysql\"",
"]",
")",
"||",
"!",
"isset",
"(",
"$",
"metric",
"[",
"\"mysql\"",
"]",
"[",
"\"query\"",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Check if metric is valid
@param array $metric
@return boolean | [
"Check",
"if",
"metric",
"is",
"valid"
] | train | https://github.com/vorbind/influx-analytics/blob/8c0c150351f045ccd3d57063f2b3b50a2c926e3e/src/Import/ImportAnalytics.php#L148-L155 |
webforge-labs/psc-cms | lib/Psc/Code/Generate/DocBlock.php | DocBlock.addSimpleAnnotation | public function addSimpleAnnotation($name, Array $values = array()) {
if (isset($this->body)) $this->body .= "\n";
$this->body .= S::expand((string) $name, '@', S::START);
if (count($values) > 0) {
$this->body .= '(';
foreach ($values as $key => $value) {
if (is_string($value)) {
$this->body .= sprintf('%s="%s", ',$key,str_replace('"','""',$value));
} elseif (is_integer($value)) {
$this->body .= sprintf('%s=%d, ',$key,$value);
} elseif (is_array($value)) {
throw new Exception('Ich kann keine verschachtelten Arrays');
} else {
throw new Exception('Ich kann noch nichts anderes');
}
}
$this->body = mb_substr($this->body,0,-2);
$this->body .= ')';
}
return $this;
} | php | public function addSimpleAnnotation($name, Array $values = array()) {
if (isset($this->body)) $this->body .= "\n";
$this->body .= S::expand((string) $name, '@', S::START);
if (count($values) > 0) {
$this->body .= '(';
foreach ($values as $key => $value) {
if (is_string($value)) {
$this->body .= sprintf('%s="%s", ',$key,str_replace('"','""',$value));
} elseif (is_integer($value)) {
$this->body .= sprintf('%s=%d, ',$key,$value);
} elseif (is_array($value)) {
throw new Exception('Ich kann keine verschachtelten Arrays');
} else {
throw new Exception('Ich kann noch nichts anderes');
}
}
$this->body = mb_substr($this->body,0,-2);
$this->body .= ')';
}
return $this;
} | [
"public",
"function",
"addSimpleAnnotation",
"(",
"$",
"name",
",",
"Array",
"$",
"values",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"body",
")",
")",
"$",
"this",
"->",
"body",
".=",
"\"\\n\"",
";",
"$",
"this",
"->",
"body",
".=",
"S",
"::",
"expand",
"(",
"(",
"string",
")",
"$",
"name",
",",
"'@'",
",",
"S",
"::",
"START",
")",
";",
"if",
"(",
"count",
"(",
"$",
"values",
")",
">",
"0",
")",
"{",
"$",
"this",
"->",
"body",
".=",
"'('",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"$",
"this",
"->",
"body",
".=",
"sprintf",
"(",
"'%s=\"%s\", '",
",",
"$",
"key",
",",
"str_replace",
"(",
"'\"'",
",",
"'\"\"'",
",",
"$",
"value",
")",
")",
";",
"}",
"elseif",
"(",
"is_integer",
"(",
"$",
"value",
")",
")",
"{",
"$",
"this",
"->",
"body",
".=",
"sprintf",
"(",
"'%s=%d, '",
",",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Ich kann keine verschachtelten Arrays'",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"'Ich kann noch nichts anderes'",
")",
";",
"}",
"}",
"$",
"this",
"->",
"body",
"=",
"mb_substr",
"(",
"$",
"this",
"->",
"body",
",",
"0",
",",
"-",
"2",
")",
";",
"$",
"this",
"->",
"body",
".=",
"')'",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Wie man hier sehen kann, ist des natürlich Käse
aber ich hab keine Lust auf den ganzen Annotation-Rumble
(siehe Annotation.php)
@TODO ding dong (Annotation Writer schreiben) | [
"Wie",
"man",
"hier",
"sehen",
"kann",
"ist",
"des",
"natürlich",
"Käse",
"aber",
"ich",
"hab",
"keine",
"Lust",
"auf",
"den",
"ganzen",
"Annotation",
"-",
"Rumble",
"(",
"siehe",
"Annotation",
".",
"php",
")"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Code/Generate/DocBlock.php#L33-L55 |
webforge-labs/psc-cms | lib/Psc/Code/Generate/DocBlock.php | DocBlock.getAnnotations | public function getAnnotations($filterFQN = NULL) {
if (isset($filterFQN)) {
return array_filter($this->annotations, function ($annotation) use ($filterFQN) {
return $annotation->getAnnotationName() === $filterFQN;
});
}
return $this->annotations;
} | php | public function getAnnotations($filterFQN = NULL) {
if (isset($filterFQN)) {
return array_filter($this->annotations, function ($annotation) use ($filterFQN) {
return $annotation->getAnnotationName() === $filterFQN;
});
}
return $this->annotations;
} | [
"public",
"function",
"getAnnotations",
"(",
"$",
"filterFQN",
"=",
"NULL",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"filterFQN",
")",
")",
"{",
"return",
"array_filter",
"(",
"$",
"this",
"->",
"annotations",
",",
"function",
"(",
"$",
"annotation",
")",
"use",
"(",
"$",
"filterFQN",
")",
"{",
"return",
"$",
"annotation",
"->",
"getAnnotationName",
"(",
")",
"===",
"$",
"filterFQN",
";",
"}",
")",
";",
"}",
"return",
"$",
"this",
"->",
"annotations",
";",
"}"
] | Gibt Annotations des DocBlocks als Array zurück
wird ein FQN übergeben werden alle Annotations dieser Klasse zurückgegeben
@return array | [
"Gibt",
"Annotations",
"des",
"DocBlocks",
"als",
"Array",
"zurück"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Code/Generate/DocBlock.php#L183-L191 |
picamator/CacheManager | src/CacheManager.php | CacheManager.save | public function save(SearchCriteriaInterface $searchCriteria, array $data) : bool
{
return $this->operationSave->save($searchCriteria, $data);
} | php | public function save(SearchCriteriaInterface $searchCriteria, array $data) : bool
{
return $this->operationSave->save($searchCriteria, $data);
} | [
"public",
"function",
"save",
"(",
"SearchCriteriaInterface",
"$",
"searchCriteria",
",",
"array",
"$",
"data",
")",
":",
"bool",
"{",
"return",
"$",
"this",
"->",
"operationSave",
"->",
"save",
"(",
"$",
"searchCriteria",
",",
"$",
"data",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/picamator/CacheManager/blob/5e5493910610b65ae31a362786d7963ba3e33806/src/CacheManager.php#L54-L57 |
picamator/CacheManager | src/Cache/KeyGenerator.php | KeyGenerator.generate | public function generate(int $id, SearchCriteriaInterface $searchCriteria) : string
{
$data = [
$searchCriteria->getContextName(),
$searchCriteria->getEntityName(),
$id,
];
$data = array_filter($data);
$result = implode(self::$keySeparator, $data);
return $result;
} | php | public function generate(int $id, SearchCriteriaInterface $searchCriteria) : string
{
$data = [
$searchCriteria->getContextName(),
$searchCriteria->getEntityName(),
$id,
];
$data = array_filter($data);
$result = implode(self::$keySeparator, $data);
return $result;
} | [
"public",
"function",
"generate",
"(",
"int",
"$",
"id",
",",
"SearchCriteriaInterface",
"$",
"searchCriteria",
")",
":",
"string",
"{",
"$",
"data",
"=",
"[",
"$",
"searchCriteria",
"->",
"getContextName",
"(",
")",
",",
"$",
"searchCriteria",
"->",
"getEntityName",
"(",
")",
",",
"$",
"id",
",",
"]",
";",
"$",
"data",
"=",
"array_filter",
"(",
"$",
"data",
")",
";",
"$",
"result",
"=",
"implode",
"(",
"self",
"::",
"$",
"keySeparator",
",",
"$",
"data",
")",
";",
"return",
"$",
"result",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/picamator/CacheManager/blob/5e5493910610b65ae31a362786d7963ba3e33806/src/Cache/KeyGenerator.php#L25-L36 |
picamator/CacheManager | src/Cache/KeyGenerator.php | KeyGenerator.generateList | public function generateList(SearchCriteriaInterface $searchCriteria) : array
{
$result = [];
foreach ($searchCriteria->getIdList() as $item) {
$result[] = $this->generate($item, $searchCriteria);
}
return $result;
} | php | public function generateList(SearchCriteriaInterface $searchCriteria) : array
{
$result = [];
foreach ($searchCriteria->getIdList() as $item) {
$result[] = $this->generate($item, $searchCriteria);
}
return $result;
} | [
"public",
"function",
"generateList",
"(",
"SearchCriteriaInterface",
"$",
"searchCriteria",
")",
":",
"array",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"searchCriteria",
"->",
"getIdList",
"(",
")",
"as",
"$",
"item",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"this",
"->",
"generate",
"(",
"$",
"item",
",",
"$",
"searchCriteria",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/picamator/CacheManager/blob/5e5493910610b65ae31a362786d7963ba3e33806/src/Cache/KeyGenerator.php#L41-L49 |
maximebf/events | src/Events/EventDispatcher.php | EventDispatcher.on | public function on($pattern, $callback = null, $priority = 0, $important = false)
{
if ($pattern instanceof EventListener) {
$listener = $pattern;
} else if (is_string($pattern) && preg_match('#/.+/[a-zA-Z]*#', $pattern)) {
$listener = new RegexpListener($pattern, $callback);
} else if (is_callable($pattern) && $callback === null) {
$listener = new SimpleListener($pattern);
} else if (is_object($pattern) && $callback === null) {
$listener = new ClassListener($pattern);
} else if (is_string($pattern) && $callback !== null) {
if (strpos($pattern, '*') !== false) {
$listener = new WildcardListener($pattern, $callback);
} else {
$listener = new NameListener($pattern, $callback);
}
} else if (is_array($pattern) && $callback === null) {
foreach ($pattern as $p => $cb) {
if (is_numeric($p)) {
$p = $cb;
$cb = null;
}
$this->on($p, $cb, $priority, $important);
}
return $this;
} else {
throw new EventException("No listeners can be created using the specified parameters");
}
return $this->addListener($listener, $priority, $important);
} | php | public function on($pattern, $callback = null, $priority = 0, $important = false)
{
if ($pattern instanceof EventListener) {
$listener = $pattern;
} else if (is_string($pattern) && preg_match('#/.+/[a-zA-Z]*#', $pattern)) {
$listener = new RegexpListener($pattern, $callback);
} else if (is_callable($pattern) && $callback === null) {
$listener = new SimpleListener($pattern);
} else if (is_object($pattern) && $callback === null) {
$listener = new ClassListener($pattern);
} else if (is_string($pattern) && $callback !== null) {
if (strpos($pattern, '*') !== false) {
$listener = new WildcardListener($pattern, $callback);
} else {
$listener = new NameListener($pattern, $callback);
}
} else if (is_array($pattern) && $callback === null) {
foreach ($pattern as $p => $cb) {
if (is_numeric($p)) {
$p = $cb;
$cb = null;
}
$this->on($p, $cb, $priority, $important);
}
return $this;
} else {
throw new EventException("No listeners can be created using the specified parameters");
}
return $this->addListener($listener, $priority, $important);
} | [
"public",
"function",
"on",
"(",
"$",
"pattern",
",",
"$",
"callback",
"=",
"null",
",",
"$",
"priority",
"=",
"0",
",",
"$",
"important",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"pattern",
"instanceof",
"EventListener",
")",
"{",
"$",
"listener",
"=",
"$",
"pattern",
";",
"}",
"else",
"if",
"(",
"is_string",
"(",
"$",
"pattern",
")",
"&&",
"preg_match",
"(",
"'#/.+/[a-zA-Z]*#'",
",",
"$",
"pattern",
")",
")",
"{",
"$",
"listener",
"=",
"new",
"RegexpListener",
"(",
"$",
"pattern",
",",
"$",
"callback",
")",
";",
"}",
"else",
"if",
"(",
"is_callable",
"(",
"$",
"pattern",
")",
"&&",
"$",
"callback",
"===",
"null",
")",
"{",
"$",
"listener",
"=",
"new",
"SimpleListener",
"(",
"$",
"pattern",
")",
";",
"}",
"else",
"if",
"(",
"is_object",
"(",
"$",
"pattern",
")",
"&&",
"$",
"callback",
"===",
"null",
")",
"{",
"$",
"listener",
"=",
"new",
"ClassListener",
"(",
"$",
"pattern",
")",
";",
"}",
"else",
"if",
"(",
"is_string",
"(",
"$",
"pattern",
")",
"&&",
"$",
"callback",
"!==",
"null",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"pattern",
",",
"'*'",
")",
"!==",
"false",
")",
"{",
"$",
"listener",
"=",
"new",
"WildcardListener",
"(",
"$",
"pattern",
",",
"$",
"callback",
")",
";",
"}",
"else",
"{",
"$",
"listener",
"=",
"new",
"NameListener",
"(",
"$",
"pattern",
",",
"$",
"callback",
")",
";",
"}",
"}",
"else",
"if",
"(",
"is_array",
"(",
"$",
"pattern",
")",
"&&",
"$",
"callback",
"===",
"null",
")",
"{",
"foreach",
"(",
"$",
"pattern",
"as",
"$",
"p",
"=>",
"$",
"cb",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"p",
")",
")",
"{",
"$",
"p",
"=",
"$",
"cb",
";",
"$",
"cb",
"=",
"null",
";",
"}",
"$",
"this",
"->",
"on",
"(",
"$",
"p",
",",
"$",
"cb",
",",
"$",
"priority",
",",
"$",
"important",
")",
";",
"}",
"return",
"$",
"this",
";",
"}",
"else",
"{",
"throw",
"new",
"EventException",
"(",
"\"No listeners can be created using the specified parameters\"",
")",
";",
"}",
"return",
"$",
"this",
"->",
"addListener",
"(",
"$",
"listener",
",",
"$",
"priority",
",",
"$",
"important",
")",
";",
"}"
] | Creates and adds an event listener depending of the type of $pattern and $callback
@param string $pattern Either a regexp, a callback, an object, an event name or an array
@param function $callback Needed if $pattern is a regexp or an event name
@param integer $priority Listener's priority, higher is more important
@param boolean $important Whether this listener is more important than other ones of the same priority
@return EventDispatcher | [
"Creates",
"and",
"adds",
"an",
"event",
"listener",
"depending",
"of",
"the",
"type",
"of",
"$pattern",
"and",
"$callback"
] | train | https://github.com/maximebf/events/blob/b9861c260ee9eaabb9aa986bab76a2e039eb871f/src/Events/EventDispatcher.php#L38-L67 |
maximebf/events | src/Events/EventDispatcher.php | EventDispatcher.addListener | public function addListener(EventListener $listener, $priority = 0, $important = false)
{
if ($listener === $this) {
throw new EventException("Adding self as listener in 'Events\EventDispatcher' would cause an infinite loop");
}
$priority = -$priority;
while (isset($this->listeners[$priority])) {
$priority += $important ? -1 : 1;
}
$this->listeners[$priority] = $listener;
ksort($this->listeners);
$this->processStackedEvents();
return $this;
} | php | public function addListener(EventListener $listener, $priority = 0, $important = false)
{
if ($listener === $this) {
throw new EventException("Adding self as listener in 'Events\EventDispatcher' would cause an infinite loop");
}
$priority = -$priority;
while (isset($this->listeners[$priority])) {
$priority += $important ? -1 : 1;
}
$this->listeners[$priority] = $listener;
ksort($this->listeners);
$this->processStackedEvents();
return $this;
} | [
"public",
"function",
"addListener",
"(",
"EventListener",
"$",
"listener",
",",
"$",
"priority",
"=",
"0",
",",
"$",
"important",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"listener",
"===",
"$",
"this",
")",
"{",
"throw",
"new",
"EventException",
"(",
"\"Adding self as listener in 'Events\\EventDispatcher' would cause an infinite loop\"",
")",
";",
"}",
"$",
"priority",
"=",
"-",
"$",
"priority",
";",
"while",
"(",
"isset",
"(",
"$",
"this",
"->",
"listeners",
"[",
"$",
"priority",
"]",
")",
")",
"{",
"$",
"priority",
"+=",
"$",
"important",
"?",
"-",
"1",
":",
"1",
";",
"}",
"$",
"this",
"->",
"listeners",
"[",
"$",
"priority",
"]",
"=",
"$",
"listener",
";",
"ksort",
"(",
"$",
"this",
"->",
"listeners",
")",
";",
"$",
"this",
"->",
"processStackedEvents",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Adds a new listener
@param EventListener $listener
@param integer $priority Listener's priority, higher is more important
@param boolean $important Whether this listener is more important than other ones of the same priority | [
"Adds",
"a",
"new",
"listener"
] | train | https://github.com/maximebf/events/blob/b9861c260ee9eaabb9aa986bab76a2e039eb871f/src/Events/EventDispatcher.php#L76-L89 |
maximebf/events | src/Events/EventDispatcher.php | EventDispatcher.removeListener | public function removeListener(EventListener $listener)
{
if (($i = array_search($listener, $this->listeners)) !== false) {
unset($this->listeners[$i]);
}
return $this;
} | php | public function removeListener(EventListener $listener)
{
if (($i = array_search($listener, $this->listeners)) !== false) {
unset($this->listeners[$i]);
}
return $this;
} | [
"public",
"function",
"removeListener",
"(",
"EventListener",
"$",
"listener",
")",
"{",
"if",
"(",
"(",
"$",
"i",
"=",
"array_search",
"(",
"$",
"listener",
",",
"$",
"this",
"->",
"listeners",
")",
")",
"!==",
"false",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"listeners",
"[",
"$",
"i",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Removes a listener
@param EventListener $listener
@return EventDispatcher | [
"Removes",
"a",
"listener"
] | train | https://github.com/maximebf/events/blob/b9861c260ee9eaabb9aa986bab76a2e039eb871f/src/Events/EventDispatcher.php#L109-L115 |
maximebf/events | src/Events/EventDispatcher.php | EventDispatcher.hasListener | public function hasListener(EventListener $listener)
{
foreach ($this->listeners as $l) {
if ($l === $listener) {
return true;
}
}
return false;
} | php | public function hasListener(EventListener $listener)
{
foreach ($this->listeners as $l) {
if ($l === $listener) {
return true;
}
}
return false;
} | [
"public",
"function",
"hasListener",
"(",
"EventListener",
"$",
"listener",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"listeners",
"as",
"$",
"l",
")",
"{",
"if",
"(",
"$",
"l",
"===",
"$",
"listener",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Checks if $listener has been added
@param EventListener $listener
@return boolean | [
"Checks",
"if",
"$listener",
"has",
"been",
"added"
] | train | https://github.com/maximebf/events/blob/b9861c260ee9eaabb9aa986bab76a2e039eb871f/src/Events/EventDispatcher.php#L134-L142 |
maximebf/events | src/Events/EventDispatcher.php | EventDispatcher.notify | public function notify(Event $event)
{
$processed = false;
foreach ($this->listeners as $listener) {
if ($listener->match($event)) {
$listener->handle($event);
$processed = true;
if ($event->isPropagationStopped()) {
break;
}
}
}
return $processed;
} | php | public function notify(Event $event)
{
$processed = false;
foreach ($this->listeners as $listener) {
if ($listener->match($event)) {
$listener->handle($event);
$processed = true;
if ($event->isPropagationStopped()) {
break;
}
}
}
return $processed;
} | [
"public",
"function",
"notify",
"(",
"Event",
"$",
"event",
")",
"{",
"$",
"processed",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"listeners",
"as",
"$",
"listener",
")",
"{",
"if",
"(",
"$",
"listener",
"->",
"match",
"(",
"$",
"event",
")",
")",
"{",
"$",
"listener",
"->",
"handle",
"(",
"$",
"event",
")",
";",
"$",
"processed",
"=",
"true",
";",
"if",
"(",
"$",
"event",
"->",
"isPropagationStopped",
"(",
")",
")",
"{",
"break",
";",
"}",
"}",
"}",
"return",
"$",
"processed",
";",
"}"
] | Notifies the listeners of an event
@param Event $event
@return boolean Whether a listener handled the event | [
"Notifies",
"the",
"listeners",
"of",
"an",
"event"
] | train | https://github.com/maximebf/events/blob/b9861c260ee9eaabb9aa986bab76a2e039eb871f/src/Events/EventDispatcher.php#L160-L173 |
maximebf/events | src/Events/EventDispatcher.php | EventDispatcher.notifyUntil | public function notifyUntil(Event $event, $callback = null)
{
if ($this->notify($event)) {
if ($callback) {
$callback();
}
return true;
}
$this->stackedEvents[] = array($event, $callback);
return false;
} | php | public function notifyUntil(Event $event, $callback = null)
{
if ($this->notify($event)) {
if ($callback) {
$callback();
}
return true;
}
$this->stackedEvents[] = array($event, $callback);
return false;
} | [
"public",
"function",
"notifyUntil",
"(",
"Event",
"$",
"event",
",",
"$",
"callback",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"notify",
"(",
"$",
"event",
")",
")",
"{",
"if",
"(",
"$",
"callback",
")",
"{",
"$",
"callback",
"(",
")",
";",
"}",
"return",
"true",
";",
"}",
"$",
"this",
"->",
"stackedEvents",
"[",
"]",
"=",
"array",
"(",
"$",
"event",
",",
"$",
"callback",
")",
";",
"return",
"false",
";",
"}"
] | Notifies the listeners of an event. Won't stop until the event has been handled by a listener.
@param Event $event
@param callback $callback Will be called once the event has been processed
@return bool | [
"Notifies",
"the",
"listeners",
"of",
"an",
"event",
".",
"Won",
"t",
"stop",
"until",
"the",
"event",
"has",
"been",
"handled",
"by",
"a",
"listener",
"."
] | train | https://github.com/maximebf/events/blob/b9861c260ee9eaabb9aa986bab76a2e039eb871f/src/Events/EventDispatcher.php#L182-L192 |
maximebf/events | src/Events/EventDispatcher.php | EventDispatcher.processStackedEvents | protected function processStackedEvents()
{
$i = 0;
while ($i < count($this->stackedEvents)) {
list($event, $callback) = $this->stackedEvents[$i];
if ($this->notify($event)) {
if ($callback) {
$callback();
}
unset($this->stackedEvents[$i]);
continue;
}
$i++;
}
} | php | protected function processStackedEvents()
{
$i = 0;
while ($i < count($this->stackedEvents)) {
list($event, $callback) = $this->stackedEvents[$i];
if ($this->notify($event)) {
if ($callback) {
$callback();
}
unset($this->stackedEvents[$i]);
continue;
}
$i++;
}
} | [
"protected",
"function",
"processStackedEvents",
"(",
")",
"{",
"$",
"i",
"=",
"0",
";",
"while",
"(",
"$",
"i",
"<",
"count",
"(",
"$",
"this",
"->",
"stackedEvents",
")",
")",
"{",
"list",
"(",
"$",
"event",
",",
"$",
"callback",
")",
"=",
"$",
"this",
"->",
"stackedEvents",
"[",
"$",
"i",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"notify",
"(",
"$",
"event",
")",
")",
"{",
"if",
"(",
"$",
"callback",
")",
"{",
"$",
"callback",
"(",
")",
";",
"}",
"unset",
"(",
"$",
"this",
"->",
"stackedEvents",
"[",
"$",
"i",
"]",
")",
";",
"continue",
";",
"}",
"$",
"i",
"++",
";",
"}",
"}"
] | Processes events that were notified using {@see notifyUntil()} but havn't been processed yet | [
"Processes",
"events",
"that",
"were",
"notified",
"using",
"{"
] | train | https://github.com/maximebf/events/blob/b9861c260ee9eaabb9aa986bab76a2e039eb871f/src/Events/EventDispatcher.php#L197-L211 |
simple-php-mvc/simple-php-mvc | src/MVC/Module/Module.php | Module.getModuleExtension | public function getModuleExtension()
{
if (null === $this->extension) {
$class = $this->getModuleExtensionClass();
if (class_exists($class)) {
$extension = new $class();
// check naming convention
$basename = preg_replace('/Module$/', '', $this->getName());
$expectedAlias = Container::underscore($basename);
if ($expectedAlias != $extension->getAlias()) {
throw new \LogicException(sprintf(
'Users will expect the alias of the default extension of a bundle to be the underscored version of the bundle name ("%s"). You can override "Bundle::getContainerExtension()" if you want to use "%s" or another alias.',
$expectedAlias, $extension->getAlias()
));
}
$this->extension = $extension;
} else {
$this->extension = false;
}
}
if ($this->extension) {
return $this->extension;
}
} | php | public function getModuleExtension()
{
if (null === $this->extension) {
$class = $this->getModuleExtensionClass();
if (class_exists($class)) {
$extension = new $class();
// check naming convention
$basename = preg_replace('/Module$/', '', $this->getName());
$expectedAlias = Container::underscore($basename);
if ($expectedAlias != $extension->getAlias()) {
throw new \LogicException(sprintf(
'Users will expect the alias of the default extension of a bundle to be the underscored version of the bundle name ("%s"). You can override "Bundle::getContainerExtension()" if you want to use "%s" or another alias.',
$expectedAlias, $extension->getAlias()
));
}
$this->extension = $extension;
} else {
$this->extension = false;
}
}
if ($this->extension) {
return $this->extension;
}
} | [
"public",
"function",
"getModuleExtension",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"extension",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"getModuleExtensionClass",
"(",
")",
";",
"if",
"(",
"class_exists",
"(",
"$",
"class",
")",
")",
"{",
"$",
"extension",
"=",
"new",
"$",
"class",
"(",
")",
";",
"// check naming convention",
"$",
"basename",
"=",
"preg_replace",
"(",
"'/Module$/'",
",",
"''",
",",
"$",
"this",
"->",
"getName",
"(",
")",
")",
";",
"$",
"expectedAlias",
"=",
"Container",
"::",
"underscore",
"(",
"$",
"basename",
")",
";",
"if",
"(",
"$",
"expectedAlias",
"!=",
"$",
"extension",
"->",
"getAlias",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'Users will expect the alias of the default extension of a bundle to be the underscored version of the bundle name (\"%s\"). You can override \"Bundle::getContainerExtension()\" if you want to use \"%s\" or another alias.'",
",",
"$",
"expectedAlias",
",",
"$",
"extension",
"->",
"getAlias",
"(",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"extension",
"=",
"$",
"extension",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"extension",
"=",
"false",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"extension",
")",
"{",
"return",
"$",
"this",
"->",
"extension",
";",
"}",
"}"
] | Returns the module's extension.
@return ExtensionInterface|null The container extension
@throws \LogicException | [
"Returns",
"the",
"module",
"s",
"extension",
"."
] | train | https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/Module/Module.php#L34-L60 |
simple-php-mvc/simple-php-mvc | src/MVC/Module/Module.php | Module.registerCommands | public function registerCommands(Application $application)
{
if (!is_dir($dir = $this->getPath() . '/Command')) {
return;
}
$explorer = new Explorer($dir);
$explorer->setSearchPattern('/[a-zA-Z0-9]Command\.php$/i');
$prefixNS = $this->getNamespace() . '\\Command';
foreach ($explorer->getFiles() as $file) {
$namespace = $prefixNS;
$class = $namespace . '\\' . $file->getBasename('.php');
$r = new \ReflectionClass($class);
if ($r->isSubclassOf('Symfony\\Component\\Console\\Command\\Command') && !$r->isAbstract() && !$r->getConstructor()->getNumberOfRequiredParameters()) {
$application->add($r->newInstance());
}
}
} | php | public function registerCommands(Application $application)
{
if (!is_dir($dir = $this->getPath() . '/Command')) {
return;
}
$explorer = new Explorer($dir);
$explorer->setSearchPattern('/[a-zA-Z0-9]Command\.php$/i');
$prefixNS = $this->getNamespace() . '\\Command';
foreach ($explorer->getFiles() as $file) {
$namespace = $prefixNS;
$class = $namespace . '\\' . $file->getBasename('.php');
$r = new \ReflectionClass($class);
if ($r->isSubclassOf('Symfony\\Component\\Console\\Command\\Command') && !$r->isAbstract() && !$r->getConstructor()->getNumberOfRequiredParameters()) {
$application->add($r->newInstance());
}
}
} | [
"public",
"function",
"registerCommands",
"(",
"Application",
"$",
"application",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"dir",
"=",
"$",
"this",
"->",
"getPath",
"(",
")",
".",
"'/Command'",
")",
")",
"{",
"return",
";",
"}",
"$",
"explorer",
"=",
"new",
"Explorer",
"(",
"$",
"dir",
")",
";",
"$",
"explorer",
"->",
"setSearchPattern",
"(",
"'/[a-zA-Z0-9]Command\\.php$/i'",
")",
";",
"$",
"prefixNS",
"=",
"$",
"this",
"->",
"getNamespace",
"(",
")",
".",
"'\\\\Command'",
";",
"foreach",
"(",
"$",
"explorer",
"->",
"getFiles",
"(",
")",
"as",
"$",
"file",
")",
"{",
"$",
"namespace",
"=",
"$",
"prefixNS",
";",
"$",
"class",
"=",
"$",
"namespace",
".",
"'\\\\'",
".",
"$",
"file",
"->",
"getBasename",
"(",
"'.php'",
")",
";",
"$",
"r",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"if",
"(",
"$",
"r",
"->",
"isSubclassOf",
"(",
"'Symfony\\\\Component\\\\Console\\\\Command\\\\Command'",
")",
"&&",
"!",
"$",
"r",
"->",
"isAbstract",
"(",
")",
"&&",
"!",
"$",
"r",
"->",
"getConstructor",
"(",
")",
"->",
"getNumberOfRequiredParameters",
"(",
")",
")",
"{",
"$",
"application",
"->",
"add",
"(",
"$",
"r",
"->",
"newInstance",
"(",
")",
")",
";",
"}",
"}",
"}"
] | Register commands
@param Application $application
@return void | [
"Register",
"commands"
] | train | https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/Module/Module.php#L137-L154 |
simple-php-mvc/simple-php-mvc | src/MVC/Module/Module.php | Module.registerTemplatesPathTwig | public function registerTemplatesPathTwig(MVC $mvc)
{
$viewsPath = $this->getPath() . '/Resources/views';
if (file_exists(dirname($viewsPath)) && file_exists($viewsPath)) {
$mvc->getCvpp('twig.loader.filesystem')->addPath($viewsPath);
}
} | php | public function registerTemplatesPathTwig(MVC $mvc)
{
$viewsPath = $this->getPath() . '/Resources/views';
if (file_exists(dirname($viewsPath)) && file_exists($viewsPath)) {
$mvc->getCvpp('twig.loader.filesystem')->addPath($viewsPath);
}
} | [
"public",
"function",
"registerTemplatesPathTwig",
"(",
"MVC",
"$",
"mvc",
")",
"{",
"$",
"viewsPath",
"=",
"$",
"this",
"->",
"getPath",
"(",
")",
".",
"'/Resources/views'",
";",
"if",
"(",
"file_exists",
"(",
"dirname",
"(",
"$",
"viewsPath",
")",
")",
"&&",
"file_exists",
"(",
"$",
"viewsPath",
")",
")",
"{",
"$",
"mvc",
"->",
"getCvpp",
"(",
"'twig.loader.filesystem'",
")",
"->",
"addPath",
"(",
"$",
"viewsPath",
")",
";",
"}",
"}"
] | Register Templates Path Twig
@param MVC $mvc | [
"Register",
"Templates",
"Path",
"Twig"
] | train | https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/Module/Module.php#L161-L167 |
phossa2/config | src/Config/Loader/CachedConfigLoader.php | CachedConfigLoader.load | public function load(
/*# string */ $group,
/*# string */ $environment = ''
)/*# : array */ {
$data = [];
if (!$this->loaded) {
$this->loaded = true;
$data = (array) Reader::readFile($this->cache_file, 'serialized');
}
return $data;
} | php | public function load(
/*# string */ $group,
/*# string */ $environment = ''
)/*# : array */ {
$data = [];
if (!$this->loaded) {
$this->loaded = true;
$data = (array) Reader::readFile($this->cache_file, 'serialized');
}
return $data;
} | [
"public",
"function",
"load",
"(",
"/*# string */",
"$",
"group",
",",
"/*# string */",
"$",
"environment",
"=",
"''",
")",
"/*# : array */",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"loaded",
")",
"{",
"$",
"this",
"->",
"loaded",
"=",
"true",
";",
"$",
"data",
"=",
"(",
"array",
")",
"Reader",
"::",
"readFile",
"(",
"$",
"this",
"->",
"cache_file",
",",
"'serialized'",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/phossa2/config/blob/7c046fd2c97633b69545b4745d8bffe28e19b1df/src/Config/Loader/CachedConfigLoader.php#L64-L74 |
kattsoftware/phassets | src/Phassets/Filters/JSqueezeFilter.php | JSqueezeFilter.filter | public function filter(Asset $asset)
{
if ($asset->getOutputExtension() !== 'js') {
throw new PhassetsInternalException('Only .js files can be filtered by ' . __CLASS__);
}
$asset->setContents((new JSqueeze())->squeeze($asset->getContents()));
} | php | public function filter(Asset $asset)
{
if ($asset->getOutputExtension() !== 'js') {
throw new PhassetsInternalException('Only .js files can be filtered by ' . __CLASS__);
}
$asset->setContents((new JSqueeze())->squeeze($asset->getContents()));
} | [
"public",
"function",
"filter",
"(",
"Asset",
"$",
"asset",
")",
"{",
"if",
"(",
"$",
"asset",
"->",
"getOutputExtension",
"(",
")",
"!==",
"'js'",
")",
"{",
"throw",
"new",
"PhassetsInternalException",
"(",
"'Only .js files can be filtered by '",
".",
"__CLASS__",
")",
";",
"}",
"$",
"asset",
"->",
"setContents",
"(",
"(",
"new",
"JSqueeze",
"(",
")",
")",
"->",
"squeeze",
"(",
"$",
"asset",
"->",
"getContents",
"(",
")",
")",
")",
";",
"}"
] | Process the Asset received and using Asset::setContents(), update
the contents accordingly. If it fails, will throw PhassetsInternalException
@param Asset $asset Asset instance which will be updated via setContents()
@throws PhassetsInternalException in case of failure | [
"Process",
"the",
"Asset",
"received",
"and",
"using",
"Asset",
"::",
"setContents",
"()",
"update",
"the",
"contents",
"accordingly",
".",
"If",
"it",
"fails",
"will",
"throw",
"PhassetsInternalException"
] | train | https://github.com/kattsoftware/phassets/blob/cc982cf1941eb5776287d64f027218bd4835ed2b/src/Phassets/Filters/JSqueezeFilter.php#L36-L43 |
afrittella/back-project | src/database/migrations/2017_02_22_173128_create_menus_table.php | CreateMenusTable.up | public function up()
{
Schema::create($this->table_menus, function(Blueprint $table) {
$table->increments('id');
$table->string('name')->index();
$table->string('permission')->nullable()->index();
$table->string('title');
$table->string('description')->nullable();
$table->string('route')->nullable();
$table->string('icon')->nullable();
$table->boolean('is_active')->default(1);
$table->boolean('is_protected')->default(0);
NestedSet::columns($table);
$table->timestamps();
});
} | php | public function up()
{
Schema::create($this->table_menus, function(Blueprint $table) {
$table->increments('id');
$table->string('name')->index();
$table->string('permission')->nullable()->index();
$table->string('title');
$table->string('description')->nullable();
$table->string('route')->nullable();
$table->string('icon')->nullable();
$table->boolean('is_active')->default(1);
$table->boolean('is_protected')->default(0);
NestedSet::columns($table);
$table->timestamps();
});
} | [
"public",
"function",
"up",
"(",
")",
"{",
"Schema",
"::",
"create",
"(",
"$",
"this",
"->",
"table_menus",
",",
"function",
"(",
"Blueprint",
"$",
"table",
")",
"{",
"$",
"table",
"->",
"increments",
"(",
"'id'",
")",
";",
"$",
"table",
"->",
"string",
"(",
"'name'",
")",
"->",
"index",
"(",
")",
";",
"$",
"table",
"->",
"string",
"(",
"'permission'",
")",
"->",
"nullable",
"(",
")",
"->",
"index",
"(",
")",
";",
"$",
"table",
"->",
"string",
"(",
"'title'",
")",
";",
"$",
"table",
"->",
"string",
"(",
"'description'",
")",
"->",
"nullable",
"(",
")",
";",
"$",
"table",
"->",
"string",
"(",
"'route'",
")",
"->",
"nullable",
"(",
")",
";",
"$",
"table",
"->",
"string",
"(",
"'icon'",
")",
"->",
"nullable",
"(",
")",
";",
"$",
"table",
"->",
"boolean",
"(",
"'is_active'",
")",
"->",
"default",
"(",
"1",
")",
";",
"$",
"table",
"->",
"boolean",
"(",
"'is_protected'",
")",
"->",
"default",
"(",
"0",
")",
";",
"NestedSet",
"::",
"columns",
"(",
"$",
"table",
")",
";",
"$",
"table",
"->",
"timestamps",
"(",
")",
";",
"}",
")",
";",
"}"
] | Run the migrations.
@return void | [
"Run",
"the",
"migrations",
"."
] | train | https://github.com/afrittella/back-project/blob/e1aa2e3ee03d453033f75a4b16f073c60b5f32d1/src/database/migrations/2017_02_22_173128_create_menus_table.php#L22-L39 |
sparwelt/imgix-lib | src/Components/CdnConfigurationParser.php | CdnConfigurationParser.parseArray | public static function parseArray(array $arrayConfiguration)
{
$parsedCdns = [];
foreach ($arrayConfiguration as $cdn) {
self::validateFileds($cdn);
$parsedCdns[] = new CdnConfiguration(
$cdn['cdn_domains'],
isset($cdn['source_domains']) ? $cdn['source_domains'] : [],
isset($cdn['path_patterns']) ? $cdn['path_patterns'] : [],
isset($cdn['sign_key']) ? $cdn['sign_key'] : null,
isset($cdn['shard_strategy']) ? $cdn['shard_strategy'] : 'crc',
isset($cdn['use_ssl']) ? $cdn['use_ssl'] : true,
isset($cdn['default_query_params']) ? $cdn['default_query_params'] : [],
isset($cdn['generate_filter_params']) ? $cdn['generate_filter_params'] : true
);
}
return $parsedCdns;
} | php | public static function parseArray(array $arrayConfiguration)
{
$parsedCdns = [];
foreach ($arrayConfiguration as $cdn) {
self::validateFileds($cdn);
$parsedCdns[] = new CdnConfiguration(
$cdn['cdn_domains'],
isset($cdn['source_domains']) ? $cdn['source_domains'] : [],
isset($cdn['path_patterns']) ? $cdn['path_patterns'] : [],
isset($cdn['sign_key']) ? $cdn['sign_key'] : null,
isset($cdn['shard_strategy']) ? $cdn['shard_strategy'] : 'crc',
isset($cdn['use_ssl']) ? $cdn['use_ssl'] : true,
isset($cdn['default_query_params']) ? $cdn['default_query_params'] : [],
isset($cdn['generate_filter_params']) ? $cdn['generate_filter_params'] : true
);
}
return $parsedCdns;
} | [
"public",
"static",
"function",
"parseArray",
"(",
"array",
"$",
"arrayConfiguration",
")",
"{",
"$",
"parsedCdns",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"arrayConfiguration",
"as",
"$",
"cdn",
")",
"{",
"self",
"::",
"validateFileds",
"(",
"$",
"cdn",
")",
";",
"$",
"parsedCdns",
"[",
"]",
"=",
"new",
"CdnConfiguration",
"(",
"$",
"cdn",
"[",
"'cdn_domains'",
"]",
",",
"isset",
"(",
"$",
"cdn",
"[",
"'source_domains'",
"]",
")",
"?",
"$",
"cdn",
"[",
"'source_domains'",
"]",
":",
"[",
"]",
",",
"isset",
"(",
"$",
"cdn",
"[",
"'path_patterns'",
"]",
")",
"?",
"$",
"cdn",
"[",
"'path_patterns'",
"]",
":",
"[",
"]",
",",
"isset",
"(",
"$",
"cdn",
"[",
"'sign_key'",
"]",
")",
"?",
"$",
"cdn",
"[",
"'sign_key'",
"]",
":",
"null",
",",
"isset",
"(",
"$",
"cdn",
"[",
"'shard_strategy'",
"]",
")",
"?",
"$",
"cdn",
"[",
"'shard_strategy'",
"]",
":",
"'crc'",
",",
"isset",
"(",
"$",
"cdn",
"[",
"'use_ssl'",
"]",
")",
"?",
"$",
"cdn",
"[",
"'use_ssl'",
"]",
":",
"true",
",",
"isset",
"(",
"$",
"cdn",
"[",
"'default_query_params'",
"]",
")",
"?",
"$",
"cdn",
"[",
"'default_query_params'",
"]",
":",
"[",
"]",
",",
"isset",
"(",
"$",
"cdn",
"[",
"'generate_filter_params'",
"]",
")",
"?",
"$",
"cdn",
"[",
"'generate_filter_params'",
"]",
":",
"true",
")",
";",
"}",
"return",
"$",
"parsedCdns",
";",
"}"
] | @param array $arrayConfiguration
@return CdnConfiguration[]
@throws \Sparwelt\ImgixLib\Exception\ConfigurationException | [
"@param",
"array",
"$arrayConfiguration"
] | train | https://github.com/sparwelt/imgix-lib/blob/330e1db2bed71bc283e5a2da6246528f240939ec/src/Components/CdnConfigurationParser.php#L23-L43 |
sparwelt/imgix-lib | src/Components/CdnConfigurationParser.php | CdnConfigurationParser.validateFileds | private static function validateFileds($cdn)
{
if (!isset($cdn['cdn_domains'])) {
throw new ConfigurationException(sprintf('Missing "cdn_domains" for configuration %s', serialize($cdn)));
}
if (!is_array($cdn['cdn_domains'])) {
throw new ConfigurationException(
sprintf('Array value expected for "cdn_domains" for configuration %s', serialize($cdn))
);
}
if (isset($cdn['path_patterns']) && !is_array($cdn['path_patterns'])) {
throw new ConfigurationException(
sprintf('Array value expected for "path_patterns" for configuration %s', serialize($cdn))
);
}
if (isset($cdn['path_patterns'])) {
foreach ($cdn['path_patterns'] as $pattern) {
if (!self::isValidRegex($pattern)) {
throw new ConfigurationException(sprintf('Invalid regex pattern: %s', $pattern));
}
}
}
if (isset($cdn['sign_key']) && !is_string($cdn['sign_key'])) {
throw new ConfigurationException(
sprintf('String value expected for "sign_key" for configuration %s', serialize($cdn))
);
}
if (isset($cdn['shard_strategy']) && (!is_string($cdn['shard_strategy'])
|| !in_array($cdn['shard_strategy'], ['crc', 'cycle'])
)) {
throw new ConfigurationException(
sprintf('Allowed values for "shard_strategy" are "crc" or "cycle" in configuration %s', serialize($cdn))
);
}
if (isset($cdn['default_query_params']) && (!is_array($cdn['default_query_params']))) {
throw new ConfigurationException(
sprintf('Array value expected for "default_query_params" are "crc" or "cycle" in configuration %s', serialize($cdn))
);
}
if (isset($cdn['default_query_params']) && Utils::isMatrix($cdn['default_query_params'])) {
throw new ConfigurationException(
sprintf('Monodimensional array expected, matrix given as "default_query_parameters" in configuration: %s', serialize($cdn))
);
}
if (isset($cdn['generate_filter_params']) && !is_bool($cdn['generate_filter_params'])) {
throw new ConfigurationException(
sprintf('Boolean expected for "generate_filter_params" in configuration: %s', serialize($cdn))
);
}
} | php | private static function validateFileds($cdn)
{
if (!isset($cdn['cdn_domains'])) {
throw new ConfigurationException(sprintf('Missing "cdn_domains" for configuration %s', serialize($cdn)));
}
if (!is_array($cdn['cdn_domains'])) {
throw new ConfigurationException(
sprintf('Array value expected for "cdn_domains" for configuration %s', serialize($cdn))
);
}
if (isset($cdn['path_patterns']) && !is_array($cdn['path_patterns'])) {
throw new ConfigurationException(
sprintf('Array value expected for "path_patterns" for configuration %s', serialize($cdn))
);
}
if (isset($cdn['path_patterns'])) {
foreach ($cdn['path_patterns'] as $pattern) {
if (!self::isValidRegex($pattern)) {
throw new ConfigurationException(sprintf('Invalid regex pattern: %s', $pattern));
}
}
}
if (isset($cdn['sign_key']) && !is_string($cdn['sign_key'])) {
throw new ConfigurationException(
sprintf('String value expected for "sign_key" for configuration %s', serialize($cdn))
);
}
if (isset($cdn['shard_strategy']) && (!is_string($cdn['shard_strategy'])
|| !in_array($cdn['shard_strategy'], ['crc', 'cycle'])
)) {
throw new ConfigurationException(
sprintf('Allowed values for "shard_strategy" are "crc" or "cycle" in configuration %s', serialize($cdn))
);
}
if (isset($cdn['default_query_params']) && (!is_array($cdn['default_query_params']))) {
throw new ConfigurationException(
sprintf('Array value expected for "default_query_params" are "crc" or "cycle" in configuration %s', serialize($cdn))
);
}
if (isset($cdn['default_query_params']) && Utils::isMatrix($cdn['default_query_params'])) {
throw new ConfigurationException(
sprintf('Monodimensional array expected, matrix given as "default_query_parameters" in configuration: %s', serialize($cdn))
);
}
if (isset($cdn['generate_filter_params']) && !is_bool($cdn['generate_filter_params'])) {
throw new ConfigurationException(
sprintf('Boolean expected for "generate_filter_params" in configuration: %s', serialize($cdn))
);
}
} | [
"private",
"static",
"function",
"validateFileds",
"(",
"$",
"cdn",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"cdn",
"[",
"'cdn_domains'",
"]",
")",
")",
"{",
"throw",
"new",
"ConfigurationException",
"(",
"sprintf",
"(",
"'Missing \"cdn_domains\" for configuration %s'",
",",
"serialize",
"(",
"$",
"cdn",
")",
")",
")",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"cdn",
"[",
"'cdn_domains'",
"]",
")",
")",
"{",
"throw",
"new",
"ConfigurationException",
"(",
"sprintf",
"(",
"'Array value expected for \"cdn_domains\" for configuration %s'",
",",
"serialize",
"(",
"$",
"cdn",
")",
")",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"cdn",
"[",
"'path_patterns'",
"]",
")",
"&&",
"!",
"is_array",
"(",
"$",
"cdn",
"[",
"'path_patterns'",
"]",
")",
")",
"{",
"throw",
"new",
"ConfigurationException",
"(",
"sprintf",
"(",
"'Array value expected for \"path_patterns\" for configuration %s'",
",",
"serialize",
"(",
"$",
"cdn",
")",
")",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"cdn",
"[",
"'path_patterns'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"cdn",
"[",
"'path_patterns'",
"]",
"as",
"$",
"pattern",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"isValidRegex",
"(",
"$",
"pattern",
")",
")",
"{",
"throw",
"new",
"ConfigurationException",
"(",
"sprintf",
"(",
"'Invalid regex pattern: %s'",
",",
"$",
"pattern",
")",
")",
";",
"}",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"cdn",
"[",
"'sign_key'",
"]",
")",
"&&",
"!",
"is_string",
"(",
"$",
"cdn",
"[",
"'sign_key'",
"]",
")",
")",
"{",
"throw",
"new",
"ConfigurationException",
"(",
"sprintf",
"(",
"'String value expected for \"sign_key\" for configuration %s'",
",",
"serialize",
"(",
"$",
"cdn",
")",
")",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"cdn",
"[",
"'shard_strategy'",
"]",
")",
"&&",
"(",
"!",
"is_string",
"(",
"$",
"cdn",
"[",
"'shard_strategy'",
"]",
")",
"||",
"!",
"in_array",
"(",
"$",
"cdn",
"[",
"'shard_strategy'",
"]",
",",
"[",
"'crc'",
",",
"'cycle'",
"]",
")",
")",
")",
"{",
"throw",
"new",
"ConfigurationException",
"(",
"sprintf",
"(",
"'Allowed values for \"shard_strategy\" are \"crc\" or \"cycle\" in configuration %s'",
",",
"serialize",
"(",
"$",
"cdn",
")",
")",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"cdn",
"[",
"'default_query_params'",
"]",
")",
"&&",
"(",
"!",
"is_array",
"(",
"$",
"cdn",
"[",
"'default_query_params'",
"]",
")",
")",
")",
"{",
"throw",
"new",
"ConfigurationException",
"(",
"sprintf",
"(",
"'Array value expected for \"default_query_params\" are \"crc\" or \"cycle\" in configuration %s'",
",",
"serialize",
"(",
"$",
"cdn",
")",
")",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"cdn",
"[",
"'default_query_params'",
"]",
")",
"&&",
"Utils",
"::",
"isMatrix",
"(",
"$",
"cdn",
"[",
"'default_query_params'",
"]",
")",
")",
"{",
"throw",
"new",
"ConfigurationException",
"(",
"sprintf",
"(",
"'Monodimensional array expected, matrix given as \"default_query_parameters\" in configuration: %s'",
",",
"serialize",
"(",
"$",
"cdn",
")",
")",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"cdn",
"[",
"'generate_filter_params'",
"]",
")",
"&&",
"!",
"is_bool",
"(",
"$",
"cdn",
"[",
"'generate_filter_params'",
"]",
")",
")",
"{",
"throw",
"new",
"ConfigurationException",
"(",
"sprintf",
"(",
"'Boolean expected for \"generate_filter_params\" in configuration: %s'",
",",
"serialize",
"(",
"$",
"cdn",
")",
")",
")",
";",
"}",
"}"
] | @param array $cdn
@throws \Sparwelt\ImgixLib\Exception\ConfigurationException | [
"@param",
"array",
"$cdn"
] | train | https://github.com/sparwelt/imgix-lib/blob/330e1db2bed71bc283e5a2da6246528f240939ec/src/Components/CdnConfigurationParser.php#L50-L107 |
sparwelt/imgix-lib | src/Components/CdnConfigurationParser.php | CdnConfigurationParser.isValidRegex | private static function isValidRegex($pattern)
{
try {
return preg_match(sprintf('~%s~', $pattern), null) !== false;
} catch (\Exception $e) {
return false;
}
} | php | private static function isValidRegex($pattern)
{
try {
return preg_match(sprintf('~%s~', $pattern), null) !== false;
} catch (\Exception $e) {
return false;
}
} | [
"private",
"static",
"function",
"isValidRegex",
"(",
"$",
"pattern",
")",
"{",
"try",
"{",
"return",
"preg_match",
"(",
"sprintf",
"(",
"'~%s~'",
",",
"$",
"pattern",
")",
",",
"null",
")",
"!==",
"false",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}"
] | @param string $pattern
@return bool | [
"@param",
"string",
"$pattern"
] | train | https://github.com/sparwelt/imgix-lib/blob/330e1db2bed71bc283e5a2da6246528f240939ec/src/Components/CdnConfigurationParser.php#L114-L121 |
phpmob/changmin | src/PhpMob/CmsBundle/DependencyInjection/Configuration.php | Configuration.getConfigTreeBuilder | public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('phpmob_cms');
$rootNode
->children()
->scalarNode('driver')->defaultValue(SyliusResourceBundle::DRIVER_DOCTRINE_ORM)->end()
->arrayNode('translation')
->addDefaultsIfNotSet()
->children()
->arrayNode('domains')
->addDefaultChildrenIfNoneSet()
->prototype('scalar')->defaultValue('messages')->end()
->validate()
->always(function ($v) {
return array_replace(['messages'], $v);
})
->end()
->end()
->end()
->end()
->end()
;
return $treeBuilder;
} | php | public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('phpmob_cms');
$rootNode
->children()
->scalarNode('driver')->defaultValue(SyliusResourceBundle::DRIVER_DOCTRINE_ORM)->end()
->arrayNode('translation')
->addDefaultsIfNotSet()
->children()
->arrayNode('domains')
->addDefaultChildrenIfNoneSet()
->prototype('scalar')->defaultValue('messages')->end()
->validate()
->always(function ($v) {
return array_replace(['messages'], $v);
})
->end()
->end()
->end()
->end()
->end()
;
return $treeBuilder;
} | [
"public",
"function",
"getConfigTreeBuilder",
"(",
")",
"{",
"$",
"treeBuilder",
"=",
"new",
"TreeBuilder",
"(",
")",
";",
"$",
"rootNode",
"=",
"$",
"treeBuilder",
"->",
"root",
"(",
"'phpmob_cms'",
")",
";",
"$",
"rootNode",
"->",
"children",
"(",
")",
"->",
"scalarNode",
"(",
"'driver'",
")",
"->",
"defaultValue",
"(",
"SyliusResourceBundle",
"::",
"DRIVER_DOCTRINE_ORM",
")",
"->",
"end",
"(",
")",
"->",
"arrayNode",
"(",
"'translation'",
")",
"->",
"addDefaultsIfNotSet",
"(",
")",
"->",
"children",
"(",
")",
"->",
"arrayNode",
"(",
"'domains'",
")",
"->",
"addDefaultChildrenIfNoneSet",
"(",
")",
"->",
"prototype",
"(",
"'scalar'",
")",
"->",
"defaultValue",
"(",
"'messages'",
")",
"->",
"end",
"(",
")",
"->",
"validate",
"(",
")",
"->",
"always",
"(",
"function",
"(",
"$",
"v",
")",
"{",
"return",
"array_replace",
"(",
"[",
"'messages'",
"]",
",",
"$",
"v",
")",
";",
"}",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
";",
"return",
"$",
"treeBuilder",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/phpmob/changmin/blob/bfebb1561229094d1c138574abab75f2f1d17d66/src/PhpMob/CmsBundle/DependencyInjection/Configuration.php#L26-L52 |
qcubed/orm | src/Query/Node/NodeBase.php | NodeBase.setAlias | public function setAlias($strAlias)
{
if ($this->strFullAlias) {
throw new \Exception ("You cannot set an alias on a node after you have used it in a query. See the examples doc. You must set the alias while creating the node.");
}
try {
// Changing the alias of the node. Must change pointers to the node too.
$strNewAlias = Type::cast($strAlias, Type::STRING);
if ($this->objParentNode) {
assert(is_object($this->objParentNode));
unset($this->objParentNode->objChildNodeArray[$this->strAlias]);
$this->objParentNode->objChildNodeArray[$strNewAlias] = $this;
}
$this->strAlias = $strNewAlias;
} catch (Caller $objExc) {
$objExc->incrementOffset();
throw $objExc;
}
} | php | public function setAlias($strAlias)
{
if ($this->strFullAlias) {
throw new \Exception ("You cannot set an alias on a node after you have used it in a query. See the examples doc. You must set the alias while creating the node.");
}
try {
// Changing the alias of the node. Must change pointers to the node too.
$strNewAlias = Type::cast($strAlias, Type::STRING);
if ($this->objParentNode) {
assert(is_object($this->objParentNode));
unset($this->objParentNode->objChildNodeArray[$this->strAlias]);
$this->objParentNode->objChildNodeArray[$strNewAlias] = $this;
}
$this->strAlias = $strNewAlias;
} catch (Caller $objExc) {
$objExc->incrementOffset();
throw $objExc;
}
} | [
"public",
"function",
"setAlias",
"(",
"$",
"strAlias",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"strFullAlias",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"You cannot set an alias on a node after you have used it in a query. See the examples doc. You must set the alias while creating the node.\"",
")",
";",
"}",
"try",
"{",
"// Changing the alias of the node. Must change pointers to the node too.",
"$",
"strNewAlias",
"=",
"Type",
"::",
"cast",
"(",
"$",
"strAlias",
",",
"Type",
"::",
"STRING",
")",
";",
"if",
"(",
"$",
"this",
"->",
"objParentNode",
")",
"{",
"assert",
"(",
"is_object",
"(",
"$",
"this",
"->",
"objParentNode",
")",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"objParentNode",
"->",
"objChildNodeArray",
"[",
"$",
"this",
"->",
"strAlias",
"]",
")",
";",
"$",
"this",
"->",
"objParentNode",
"->",
"objChildNodeArray",
"[",
"$",
"strNewAlias",
"]",
"=",
"$",
"this",
";",
"}",
"$",
"this",
"->",
"strAlias",
"=",
"$",
"strNewAlias",
";",
"}",
"catch",
"(",
"Caller",
"$",
"objExc",
")",
"{",
"$",
"objExc",
"->",
"incrementOffset",
"(",
")",
";",
"throw",
"$",
"objExc",
";",
"}",
"}"
] | Change the alias of the node, primarily for joining the same table more than once.
@param string $strAlias
@throws Caller
@throws \Exception | [
"Change",
"the",
"alias",
"of",
"the",
"node",
"primarily",
"for",
"joining",
"the",
"same",
"table",
"more",
"than",
"once",
"."
] | train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Query/Node/NodeBase.php#L95-L113 |
qcubed/orm | src/Query/Node/NodeBase.php | NodeBase.fullAlias | public function fullAlias()
{
if ($this->strFullAlias) {
return $this->strFullAlias;
} else {
assert(!empty($this->strAlias)); // Alias should always be set by default
if ($this->objParentNode) {
assert(is_object($this->objParentNode));
return $this->objParentNode->fullAlias() . '__' . $this->strAlias;
} else {
return $this->strAlias;
}
}
} | php | public function fullAlias()
{
if ($this->strFullAlias) {
return $this->strFullAlias;
} else {
assert(!empty($this->strAlias)); // Alias should always be set by default
if ($this->objParentNode) {
assert(is_object($this->objParentNode));
return $this->objParentNode->fullAlias() . '__' . $this->strAlias;
} else {
return $this->strAlias;
}
}
} | [
"public",
"function",
"fullAlias",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"strFullAlias",
")",
"{",
"return",
"$",
"this",
"->",
"strFullAlias",
";",
"}",
"else",
"{",
"assert",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"strAlias",
")",
")",
";",
"// Alias should always be set by default",
"if",
"(",
"$",
"this",
"->",
"objParentNode",
")",
"{",
"assert",
"(",
"is_object",
"(",
"$",
"this",
"->",
"objParentNode",
")",
")",
";",
"return",
"$",
"this",
"->",
"objParentNode",
"->",
"fullAlias",
"(",
")",
".",
"'__'",
".",
"$",
"this",
"->",
"strAlias",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"strAlias",
";",
"}",
"}",
"}"
] | Aid to generating full aliases. Recursively gets and sets the parent alias, eventually creating, caching and returning
an alias for itself.
@return string | [
"Aid",
"to",
"generating",
"full",
"aliases",
".",
"Recursively",
"gets",
"and",
"sets",
"the",
"parent",
"alias",
"eventually",
"creating",
"caching",
"and",
"returning",
"an",
"alias",
"for",
"itself",
"."
] | train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Query/Node/NodeBase.php#L120-L133 |
qcubed/orm | src/Query/Node/NodeBase.php | NodeBase._MergeExpansionNode | public function _MergeExpansionNode(NodeBase $objNewNode)
{
if (!$objNewNode || empty($objNewNode->objChildNodeArray)) {
return;
}
if ($objNewNode->strName != $this->strName) {
throw new Caller('Expansion node tables must match.');
}
if (!$this->objChildNodeArray) {
$this->objChildNodeArray = $objNewNode->objChildNodeArray;
} else {
$objChildNode = reset($objNewNode->objChildNodeArray);
if (isset ($this->objChildNodeArray[$objChildNode->strAlias])) {
if ($objChildNode->blnExpandAsArray) {
$this->objChildNodeArray[$objChildNode->strAlias]->blnExpandAsArray = true;
// assume this is a leaf node, so don't follow any more.
} else {
$this->objChildNodeArray[$objChildNode->strAlias]->_MergeExpansionNode($objChildNode);
}
} else {
$this->objChildNodeArray[$objChildNode->strAlias] = $objChildNode;
}
}
} | php | public function _MergeExpansionNode(NodeBase $objNewNode)
{
if (!$objNewNode || empty($objNewNode->objChildNodeArray)) {
return;
}
if ($objNewNode->strName != $this->strName) {
throw new Caller('Expansion node tables must match.');
}
if (!$this->objChildNodeArray) {
$this->objChildNodeArray = $objNewNode->objChildNodeArray;
} else {
$objChildNode = reset($objNewNode->objChildNodeArray);
if (isset ($this->objChildNodeArray[$objChildNode->strAlias])) {
if ($objChildNode->blnExpandAsArray) {
$this->objChildNodeArray[$objChildNode->strAlias]->blnExpandAsArray = true;
// assume this is a leaf node, so don't follow any more.
} else {
$this->objChildNodeArray[$objChildNode->strAlias]->_MergeExpansionNode($objChildNode);
}
} else {
$this->objChildNodeArray[$objChildNode->strAlias] = $objChildNode;
}
}
} | [
"public",
"function",
"_MergeExpansionNode",
"(",
"NodeBase",
"$",
"objNewNode",
")",
"{",
"if",
"(",
"!",
"$",
"objNewNode",
"||",
"empty",
"(",
"$",
"objNewNode",
"->",
"objChildNodeArray",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"objNewNode",
"->",
"strName",
"!=",
"$",
"this",
"->",
"strName",
")",
"{",
"throw",
"new",
"Caller",
"(",
"'Expansion node tables must match.'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"objChildNodeArray",
")",
"{",
"$",
"this",
"->",
"objChildNodeArray",
"=",
"$",
"objNewNode",
"->",
"objChildNodeArray",
";",
"}",
"else",
"{",
"$",
"objChildNode",
"=",
"reset",
"(",
"$",
"objNewNode",
"->",
"objChildNodeArray",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"objChildNodeArray",
"[",
"$",
"objChildNode",
"->",
"strAlias",
"]",
")",
")",
"{",
"if",
"(",
"$",
"objChildNode",
"->",
"blnExpandAsArray",
")",
"{",
"$",
"this",
"->",
"objChildNodeArray",
"[",
"$",
"objChildNode",
"->",
"strAlias",
"]",
"->",
"blnExpandAsArray",
"=",
"true",
";",
"// assume this is a leaf node, so don't follow any more.",
"}",
"else",
"{",
"$",
"this",
"->",
"objChildNodeArray",
"[",
"$",
"objChildNode",
"->",
"strAlias",
"]",
"->",
"_MergeExpansionNode",
"(",
"$",
"objChildNode",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"objChildNodeArray",
"[",
"$",
"objChildNode",
"->",
"strAlias",
"]",
"=",
"$",
"objChildNode",
";",
"}",
"}",
"}"
] | Merges a node tree into this node, building the child nodes. The node being received
is assumed to be specially built node such that only one child node exists, if any,
and the last node in the chain is designated as array expansion. The goal of all of this
is to set up a node chain where intermediate nodes can be designated as being array
expansion nodes, as well as the leaf nodes.
@param NodeBase $objNewNode
@throws Caller | [
"Merges",
"a",
"node",
"tree",
"into",
"this",
"node",
"building",
"the",
"child",
"nodes",
".",
"The",
"node",
"being",
"received",
"is",
"assumed",
"to",
"be",
"specially",
"built",
"node",
"such",
"that",
"only",
"one",
"child",
"node",
"exists",
"if",
"any",
"and",
"the",
"last",
"node",
"in",
"the",
"chain",
"is",
"designated",
"as",
"array",
"expansion",
".",
"The",
"goal",
"of",
"all",
"of",
"this",
"is",
"to",
"set",
"up",
"a",
"node",
"chain",
"where",
"intermediate",
"nodes",
"can",
"be",
"designated",
"as",
"being",
"array",
"expansion",
"nodes",
"as",
"well",
"as",
"the",
"leaf",
"nodes",
"."
] | train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Query/Node/NodeBase.php#L163-L187 |
qcubed/orm | src/Query/Node/NodeBase.php | NodeBase.putSelectFields | public function putSelectFields($objBuilder, $strPrefix = null, $objSelect = null)
{
if ($strPrefix) {
$strTableName = $strPrefix;
$strAliasPrefix = $strPrefix . '__';
} else {
$strTableName = $this->strTableName;
$strAliasPrefix = '';
}
if ($objSelect) {
if (!$objSelect->skipPrimaryKey() && !$objBuilder->Distinct) {
$strFields = $this->primaryKeyFields();
foreach ($strFields as $strField) {
$objBuilder->addSelectItem($strTableName, $strField, $strAliasPrefix . $strField);
}
}
$objSelect->addSelectItems($objBuilder, $strTableName, $strAliasPrefix);
} else {
$strFields = $this->fields();
foreach ($strFields as $strField) {
$objBuilder->addSelectItem($strTableName, $strField, $strAliasPrefix . $strField);
}
}
} | php | public function putSelectFields($objBuilder, $strPrefix = null, $objSelect = null)
{
if ($strPrefix) {
$strTableName = $strPrefix;
$strAliasPrefix = $strPrefix . '__';
} else {
$strTableName = $this->strTableName;
$strAliasPrefix = '';
}
if ($objSelect) {
if (!$objSelect->skipPrimaryKey() && !$objBuilder->Distinct) {
$strFields = $this->primaryKeyFields();
foreach ($strFields as $strField) {
$objBuilder->addSelectItem($strTableName, $strField, $strAliasPrefix . $strField);
}
}
$objSelect->addSelectItems($objBuilder, $strTableName, $strAliasPrefix);
} else {
$strFields = $this->fields();
foreach ($strFields as $strField) {
$objBuilder->addSelectItem($strTableName, $strField, $strAliasPrefix . $strField);
}
}
} | [
"public",
"function",
"putSelectFields",
"(",
"$",
"objBuilder",
",",
"$",
"strPrefix",
"=",
"null",
",",
"$",
"objSelect",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"strPrefix",
")",
"{",
"$",
"strTableName",
"=",
"$",
"strPrefix",
";",
"$",
"strAliasPrefix",
"=",
"$",
"strPrefix",
".",
"'__'",
";",
"}",
"else",
"{",
"$",
"strTableName",
"=",
"$",
"this",
"->",
"strTableName",
";",
"$",
"strAliasPrefix",
"=",
"''",
";",
"}",
"if",
"(",
"$",
"objSelect",
")",
"{",
"if",
"(",
"!",
"$",
"objSelect",
"->",
"skipPrimaryKey",
"(",
")",
"&&",
"!",
"$",
"objBuilder",
"->",
"Distinct",
")",
"{",
"$",
"strFields",
"=",
"$",
"this",
"->",
"primaryKeyFields",
"(",
")",
";",
"foreach",
"(",
"$",
"strFields",
"as",
"$",
"strField",
")",
"{",
"$",
"objBuilder",
"->",
"addSelectItem",
"(",
"$",
"strTableName",
",",
"$",
"strField",
",",
"$",
"strAliasPrefix",
".",
"$",
"strField",
")",
";",
"}",
"}",
"$",
"objSelect",
"->",
"addSelectItems",
"(",
"$",
"objBuilder",
",",
"$",
"strTableName",
",",
"$",
"strAliasPrefix",
")",
";",
"}",
"else",
"{",
"$",
"strFields",
"=",
"$",
"this",
"->",
"fields",
"(",
")",
";",
"foreach",
"(",
"$",
"strFields",
"as",
"$",
"strField",
")",
"{",
"$",
"objBuilder",
"->",
"addSelectItem",
"(",
"$",
"strTableName",
",",
"$",
"strField",
",",
"$",
"strAliasPrefix",
".",
"$",
"strField",
")",
";",
"}",
"}",
"}"
] | Puts the "Select" clause fields for this node into builder.
@param Builder $objBuilder
@param null|string $strPrefix
@param null|Select $objSelect | [
"Puts",
"the",
"Select",
"clause",
"fields",
"for",
"this",
"node",
"into",
"builder",
"."
] | train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Query/Node/NodeBase.php#L196-L220 |
afrittella/back-project | src/app/Repositories/Roles.php | Roles.transform | public function transform($data = [], $options = [])
{
if (empty($data)) {
$data = $this->all();
}
// Table header
$head = [
'columns' => [
trans('back-project::roles.name'),
trans('back-project::roles.permissions'),
trans('back-project::crud.actions'),
]
];
$body = [];
foreach ($data as $row):
$actions = [];
if ($row->name !== 'administrator' and $row->name !== 'user') {
$actions = [
'edit' => ['url' => route('bp.roles.edit', [$row['id']])], //url('/admin/users/edit', [$row['id']])],
'delete' => ['url' => route('bp.roles.delete', [$row['id']])]
];
}
$body[] = [
'columns' => [
['content' => $row->name],
['content' => implode('<br>', $row->permissions->pluck('name')->toArray())],
['content' => false, 'actions' => $actions],
]
];
endforeach;
return [
'head' => $head,
'body' => $body
];
} | php | public function transform($data = [], $options = [])
{
if (empty($data)) {
$data = $this->all();
}
// Table header
$head = [
'columns' => [
trans('back-project::roles.name'),
trans('back-project::roles.permissions'),
trans('back-project::crud.actions'),
]
];
$body = [];
foreach ($data as $row):
$actions = [];
if ($row->name !== 'administrator' and $row->name !== 'user') {
$actions = [
'edit' => ['url' => route('bp.roles.edit', [$row['id']])], //url('/admin/users/edit', [$row['id']])],
'delete' => ['url' => route('bp.roles.delete', [$row['id']])]
];
}
$body[] = [
'columns' => [
['content' => $row->name],
['content' => implode('<br>', $row->permissions->pluck('name')->toArray())],
['content' => false, 'actions' => $actions],
]
];
endforeach;
return [
'head' => $head,
'body' => $body
];
} | [
"public",
"function",
"transform",
"(",
"$",
"data",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"data",
")",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"all",
"(",
")",
";",
"}",
"// Table header",
"$",
"head",
"=",
"[",
"'columns'",
"=>",
"[",
"trans",
"(",
"'back-project::roles.name'",
")",
",",
"trans",
"(",
"'back-project::roles.permissions'",
")",
",",
"trans",
"(",
"'back-project::crud.actions'",
")",
",",
"]",
"]",
";",
"$",
"body",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"row",
")",
":",
"$",
"actions",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"row",
"->",
"name",
"!==",
"'administrator'",
"and",
"$",
"row",
"->",
"name",
"!==",
"'user'",
")",
"{",
"$",
"actions",
"=",
"[",
"'edit'",
"=>",
"[",
"'url'",
"=>",
"route",
"(",
"'bp.roles.edit'",
",",
"[",
"$",
"row",
"[",
"'id'",
"]",
"]",
")",
"]",
",",
"//url('/admin/users/edit', [$row['id']])],",
"'delete'",
"=>",
"[",
"'url'",
"=>",
"route",
"(",
"'bp.roles.delete'",
",",
"[",
"$",
"row",
"[",
"'id'",
"]",
"]",
")",
"]",
"]",
";",
"}",
"$",
"body",
"[",
"]",
"=",
"[",
"'columns'",
"=>",
"[",
"[",
"'content'",
"=>",
"$",
"row",
"->",
"name",
"]",
",",
"[",
"'content'",
"=>",
"implode",
"(",
"'<br>'",
",",
"$",
"row",
"->",
"permissions",
"->",
"pluck",
"(",
"'name'",
")",
"->",
"toArray",
"(",
")",
")",
"]",
",",
"[",
"'content'",
"=>",
"false",
",",
"'actions'",
"=>",
"$",
"actions",
"]",
",",
"]",
"]",
";",
"endforeach",
";",
"return",
"[",
"'head'",
"=>",
"$",
"head",
",",
"'body'",
"=>",
"$",
"body",
"]",
";",
"}"
] | Transform data in a table array for view
@param $data
@param array $options
@return array | [
"Transform",
"data",
"in",
"a",
"table",
"array",
"for",
"view"
] | train | https://github.com/afrittella/back-project/blob/e1aa2e3ee03d453033f75a4b16f073c60b5f32d1/src/app/Repositories/Roles.php#L37-L77 |
phore/phore-micro-app | src/Type/Request.php | Request.GetRemoteAddr | protected static function GetRemoteAddr()
{
$ipSet = new IPSet(IPSet::PRIVATE_NETS);
if ( ! $ipSet->match($_SERVER["REMOTE_ADDR"])) {
return $_SERVER["REMOTE_ADDR"]; // Remote ADDR is Public Address: Use this! (We want Load-Balancers with private IPs only!)
}
if (isset ($_SERVER["HTTP_X_FORWARDED_FOR"])) {
$forwardsRev = array_reverse($forwards = explode(",", $_SERVER["HTTP_X_FORWARDED_FOR"]));
for ($i=0; $i<count ($forwardsRev); $i++) {
if ( ! $ipSet->match(trim ($forwardsRev[$i]))) {
return $forwardsRev[$i]; // Return first non-private IP from last to first
}
}
return $forwards[0]; // Return first IP if no public IP found.
}
return $_SERVER["REMOTE_ADDR"]; // Return the private Remote-ADDR
} | php | protected static function GetRemoteAddr()
{
$ipSet = new IPSet(IPSet::PRIVATE_NETS);
if ( ! $ipSet->match($_SERVER["REMOTE_ADDR"])) {
return $_SERVER["REMOTE_ADDR"]; // Remote ADDR is Public Address: Use this! (We want Load-Balancers with private IPs only!)
}
if (isset ($_SERVER["HTTP_X_FORWARDED_FOR"])) {
$forwardsRev = array_reverse($forwards = explode(",", $_SERVER["HTTP_X_FORWARDED_FOR"]));
for ($i=0; $i<count ($forwardsRev); $i++) {
if ( ! $ipSet->match(trim ($forwardsRev[$i]))) {
return $forwardsRev[$i]; // Return first non-private IP from last to first
}
}
return $forwards[0]; // Return first IP if no public IP found.
}
return $_SERVER["REMOTE_ADDR"]; // Return the private Remote-ADDR
} | [
"protected",
"static",
"function",
"GetRemoteAddr",
"(",
")",
"{",
"$",
"ipSet",
"=",
"new",
"IPSet",
"(",
"IPSet",
"::",
"PRIVATE_NETS",
")",
";",
"if",
"(",
"!",
"$",
"ipSet",
"->",
"match",
"(",
"$",
"_SERVER",
"[",
"\"REMOTE_ADDR\"",
"]",
")",
")",
"{",
"return",
"$",
"_SERVER",
"[",
"\"REMOTE_ADDR\"",
"]",
";",
"// Remote ADDR is Public Address: Use this! (We want Load-Balancers with private IPs only!)",
"}",
"if",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"\"HTTP_X_FORWARDED_FOR\"",
"]",
")",
")",
"{",
"$",
"forwardsRev",
"=",
"array_reverse",
"(",
"$",
"forwards",
"=",
"explode",
"(",
"\",\"",
",",
"$",
"_SERVER",
"[",
"\"HTTP_X_FORWARDED_FOR\"",
"]",
")",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"forwardsRev",
")",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"$",
"ipSet",
"->",
"match",
"(",
"trim",
"(",
"$",
"forwardsRev",
"[",
"$",
"i",
"]",
")",
")",
")",
"{",
"return",
"$",
"forwardsRev",
"[",
"$",
"i",
"]",
";",
"// Return first non-private IP from last to first",
"}",
"}",
"return",
"$",
"forwards",
"[",
"0",
"]",
";",
"// Return first IP if no public IP found.",
"}",
"return",
"$",
"_SERVER",
"[",
"\"REMOTE_ADDR\"",
"]",
";",
"// Return the private Remote-ADDR",
"}"
] | ***SECURITY RELEVANT FUNCTION***
Think twice before changing things here.
Injecting X-Forwarded-For Headers from outside must be prohibited to
not circumvent IP Network restrictions!
@return string | [
"***",
"SECURITY",
"RELEVANT",
"FUNCTION",
"***"
] | train | https://github.com/phore/phore-micro-app/blob/6cf87a647b8b0be05afbfe6bd020650e98558c23/src/Type/Request.php#L39-L55 |
phore/phore-micro-app | src/Type/Request.php | Request.getJsonBody | public function getJsonBody($json_options=null) : array
{
try {
return phore_json_decode($bodyRaw = $this->getBody());
} catch (\InvalidArgumentException $e) {
throw new \InvalidArgumentException("Cannot json-decode body: '$bodyRaw'", 0, $e);
}
} | php | public function getJsonBody($json_options=null) : array
{
try {
return phore_json_decode($bodyRaw = $this->getBody());
} catch (\InvalidArgumentException $e) {
throw new \InvalidArgumentException("Cannot json-decode body: '$bodyRaw'", 0, $e);
}
} | [
"public",
"function",
"getJsonBody",
"(",
"$",
"json_options",
"=",
"null",
")",
":",
"array",
"{",
"try",
"{",
"return",
"phore_json_decode",
"(",
"$",
"bodyRaw",
"=",
"$",
"this",
"->",
"getBody",
"(",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"InvalidArgumentException",
"$",
"e",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Cannot json-decode body: '$bodyRaw'\"",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] | json-decode the body
@return array | [
"json",
"-",
"decode",
"the",
"body"
] | train | https://github.com/phore/phore-micro-app/blob/6cf87a647b8b0be05afbfe6bd020650e98558c23/src/Type/Request.php#L74-L81 |
maniaplanet/maniaplanet-ws-sdk | libraries/Maniaplanet/WebServices/ManiaHome.php | ManiaHome.postNotification | function postNotification(Notification $n)
{
if($n->receiverName)
{
if($n->isPrivate)
{
return $this->manialinkPublisher->postPrivateNotification($n->message, $n->receiverName);
}
return $this->manialinkPublisher->postPersonalNotification($n->message, $n->link, $n->iconStyle, $n->iconSubStyle);
}
return $this->manialinkPublisher->postPublicNotification($n->message, $n->link, $n->iconStyle, $n->iconSubStyle);
} | php | function postNotification(Notification $n)
{
if($n->receiverName)
{
if($n->isPrivate)
{
return $this->manialinkPublisher->postPrivateNotification($n->message, $n->receiverName);
}
return $this->manialinkPublisher->postPersonalNotification($n->message, $n->link, $n->iconStyle, $n->iconSubStyle);
}
return $this->manialinkPublisher->postPublicNotification($n->message, $n->link, $n->iconStyle, $n->iconSubStyle);
} | [
"function",
"postNotification",
"(",
"Notification",
"$",
"n",
")",
"{",
"if",
"(",
"$",
"n",
"->",
"receiverName",
")",
"{",
"if",
"(",
"$",
"n",
"->",
"isPrivate",
")",
"{",
"return",
"$",
"this",
"->",
"manialinkPublisher",
"->",
"postPrivateNotification",
"(",
"$",
"n",
"->",
"message",
",",
"$",
"n",
"->",
"receiverName",
")",
";",
"}",
"return",
"$",
"this",
"->",
"manialinkPublisher",
"->",
"postPersonalNotification",
"(",
"$",
"n",
"->",
"message",
",",
"$",
"n",
"->",
"link",
",",
"$",
"n",
"->",
"iconStyle",
",",
"$",
"n",
"->",
"iconSubStyle",
")",
";",
"}",
"return",
"$",
"this",
"->",
"manialinkPublisher",
"->",
"postPublicNotification",
"(",
"$",
"n",
"->",
"message",
",",
"$",
"n",
"->",
"link",
",",
"$",
"n",
"->",
"iconStyle",
",",
"$",
"n",
"->",
"iconSubStyle",
")",
";",
"}"
] | Please use the other methods which are more robust
@deprecated since version 3.1.0 | [
"Please",
"use",
"the",
"other",
"methods",
"which",
"are",
"more",
"robust"
] | train | https://github.com/maniaplanet/maniaplanet-ws-sdk/blob/027a458388035fe66f2f56ff3ea1f85eff2a5a4e/libraries/Maniaplanet/WebServices/ManiaHome.php#L47-L58 |
maniaplanet/maniaplanet-ws-sdk | libraries/Maniaplanet/WebServices/ManiaHome.php | ManiaHome.postPublicNotification | function postPublicNotification(Notification $n)
{
return $this->manialinkPublisher->postPublicNotification($n->message, $n->link, $n->iconStyle, $n->iconSubStyle);
} | php | function postPublicNotification(Notification $n)
{
return $this->manialinkPublisher->postPublicNotification($n->message, $n->link, $n->iconStyle, $n->iconSubStyle);
} | [
"function",
"postPublicNotification",
"(",
"Notification",
"$",
"n",
")",
"{",
"return",
"$",
"this",
"->",
"manialinkPublisher",
"->",
"postPublicNotification",
"(",
"$",
"n",
"->",
"message",
",",
"$",
"n",
"->",
"link",
",",
"$",
"n",
"->",
"iconStyle",
",",
"$",
"n",
"->",
"iconSubStyle",
")",
";",
"}"
] | Send a public notification to every player that bookmarked your Manialink.
@param Notification $n
@deprecated since version 3.1.0 | [
"Send",
"a",
"public",
"notification",
"to",
"every",
"player",
"that",
"bookmarked",
"your",
"Manialink",
"."
] | train | https://github.com/maniaplanet/maniaplanet-ws-sdk/blob/027a458388035fe66f2f56ff3ea1f85eff2a5a4e/libraries/Maniaplanet/WebServices/ManiaHome.php#L65-L68 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.