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
|
---|---|---|---|---|---|---|---|---|---|---|
webtown-php/KunstmaanExtensionBundle | src/Command/UserEditCommand.php | UserEditCommand.getChoiceBySelection | protected function getChoiceBySelection($selection)
{
preg_match('/^[^(]+\(([^\)]+)\)$/', $selection, $matches);
if (count($matches) < 2) {
return;
}
$username = $matches[1];
foreach ($this->choices as $item) {
if ($item->getUsername() === $username) {
return $item;
}
}
return;
} | php | protected function getChoiceBySelection($selection)
{
preg_match('/^[^(]+\(([^\)]+)\)$/', $selection, $matches);
if (count($matches) < 2) {
return;
}
$username = $matches[1];
foreach ($this->choices as $item) {
if ($item->getUsername() === $username) {
return $item;
}
}
return;
} | [
"protected",
"function",
"getChoiceBySelection",
"(",
"$",
"selection",
")",
"{",
"preg_match",
"(",
"'/^[^(]+\\(([^\\)]+)\\)$/'",
",",
"$",
"selection",
",",
"$",
"matches",
")",
";",
"if",
"(",
"count",
"(",
"$",
"matches",
")",
"<",
"2",
")",
"{",
"return",
";",
"}",
"$",
"username",
"=",
"$",
"matches",
"[",
"1",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"choices",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"item",
"->",
"getUsername",
"(",
")",
"===",
"$",
"username",
")",
"{",
"return",
"$",
"item",
";",
"}",
"}",
"return",
";",
"}"
] | Find User by username
@param string $username
@return User | [
"Find",
"User",
"by",
"username"
] | train | https://github.com/webtown-php/KunstmaanExtensionBundle/blob/86c656c131295fe1f3f7694fd4da1e5e454076b9/src/Command/UserEditCommand.php#L212-L226 |
webtown-php/KunstmaanExtensionBundle | src/Command/UserEditCommand.php | UserEditCommand.getChoiceByUsernameOrEmail | protected function getChoiceByUsernameOrEmail($selection)
{
foreach ($this->choices as $item) {
if ($item->getUsername() === $selection) {
return $item;
}
if ($item->getEmail() === $selection) {
return $item;
}
}
return;
} | php | protected function getChoiceByUsernameOrEmail($selection)
{
foreach ($this->choices as $item) {
if ($item->getUsername() === $selection) {
return $item;
}
if ($item->getEmail() === $selection) {
return $item;
}
}
return;
} | [
"protected",
"function",
"getChoiceByUsernameOrEmail",
"(",
"$",
"selection",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"choices",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"item",
"->",
"getUsername",
"(",
")",
"===",
"$",
"selection",
")",
"{",
"return",
"$",
"item",
";",
"}",
"if",
"(",
"$",
"item",
"->",
"getEmail",
"(",
")",
"===",
"$",
"selection",
")",
"{",
"return",
"$",
"item",
";",
"}",
"}",
"return",
";",
"}"
] | Find User by username or email
@param string $username
@return User | [
"Find",
"User",
"by",
"username",
"or",
"email"
] | train | https://github.com/webtown-php/KunstmaanExtensionBundle/blob/86c656c131295fe1f3f7694fd4da1e5e454076b9/src/Command/UserEditCommand.php#L235-L247 |
webtown-php/KunstmaanExtensionBundle | src/Command/UserEditCommand.php | UserEditCommand.getNewValues | protected function getNewValues(User $user)
{
$newProps = new UserUpdater();
$this->logger->section('Editing user ' . $user->getEmail() . ' (' . $user->getUsername() . ')');
$this->logger->comment('leave empty to keep unchanged');
$newProps->setUsername($this->ask(new Question('Username', $user->getUsername())));
$newProps->setEmail($this->ask(new Question('E-mail address', $user->getEmail())));
$password = $this->ask(new Question('Password', '***'));
// replace default *** value if empty is given
$newProps->setPassword($password !== '***' ? $password : '');
return $newProps;
} | php | protected function getNewValues(User $user)
{
$newProps = new UserUpdater();
$this->logger->section('Editing user ' . $user->getEmail() . ' (' . $user->getUsername() . ')');
$this->logger->comment('leave empty to keep unchanged');
$newProps->setUsername($this->ask(new Question('Username', $user->getUsername())));
$newProps->setEmail($this->ask(new Question('E-mail address', $user->getEmail())));
$password = $this->ask(new Question('Password', '***'));
// replace default *** value if empty is given
$newProps->setPassword($password !== '***' ? $password : '');
return $newProps;
} | [
"protected",
"function",
"getNewValues",
"(",
"User",
"$",
"user",
")",
"{",
"$",
"newProps",
"=",
"new",
"UserUpdater",
"(",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"section",
"(",
"'Editing user '",
".",
"$",
"user",
"->",
"getEmail",
"(",
")",
".",
"' ('",
".",
"$",
"user",
"->",
"getUsername",
"(",
")",
".",
"')'",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"comment",
"(",
"'leave empty to keep unchanged'",
")",
";",
"$",
"newProps",
"->",
"setUsername",
"(",
"$",
"this",
"->",
"ask",
"(",
"new",
"Question",
"(",
"'Username'",
",",
"$",
"user",
"->",
"getUsername",
"(",
")",
")",
")",
")",
";",
"$",
"newProps",
"->",
"setEmail",
"(",
"$",
"this",
"->",
"ask",
"(",
"new",
"Question",
"(",
"'E-mail address'",
",",
"$",
"user",
"->",
"getEmail",
"(",
")",
")",
")",
")",
";",
"$",
"password",
"=",
"$",
"this",
"->",
"ask",
"(",
"new",
"Question",
"(",
"'Password'",
",",
"'***'",
")",
")",
";",
"// replace default *** value if empty is given",
"$",
"newProps",
"->",
"setPassword",
"(",
"$",
"password",
"!==",
"'***'",
"?",
"$",
"password",
":",
"''",
")",
";",
"return",
"$",
"newProps",
";",
"}"
] | Ask for new user properties
@param User $user
@return UserUpdater | [
"Ask",
"for",
"new",
"user",
"properties"
] | train | https://github.com/webtown-php/KunstmaanExtensionBundle/blob/86c656c131295fe1f3f7694fd4da1e5e454076b9/src/Command/UserEditCommand.php#L268-L280 |
okitcom/ok-lib-php | src/Client.php | Client.curl | protected function curl($url, $req = array(), $auth = TRUE, $method = "GET", $json = true) {
$header = [];
if ($json) {
$header[] = 'Content-Type: application/json';
$header[] = 'Accept: application/json';
} else {
$header[] = 'Accept: text/html,application/json,image/webp,image/apng,*/*';
}
static $ch = null;
if (is_null($ch)) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; PHP client; '.php_uname('s').'; PHP/'.phpversion().')');
}
curl_setopt($ch, CURLOPT_HTTPGET, 1);
if (Client::DEBUG) {
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
echo 'Request: ' . $method . "\t" . $this->base_url . $url . "\n";
}
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, NULL);
if ($method == "GET") {
$post_data = http_build_query($req, '', '&');
curl_setopt($ch, CURLOPT_URL, $this->base_url . $url .'?'.$post_data);
} else if ($method == "POST") {
curl_setopt($ch, CURLOPT_URL, $this->base_url . $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($req));
} else {
$post_data = http_build_query($req, '', '&');
curl_setopt($ch, CURLOPT_URL, $this->base_url . $url .'?'.$post_data);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
}
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
//curl_setopt($ch, CURLINFO_HEADER_OUT, true);
if ($auth) {
if ($this->credentials->getPrivateKey() == null) {
throw new NetworkException("No credentials found.", -2);
}
curl_setopt($ch, CURLOPT_USERPWD, $this->credentials->getPrivateKey().':');
}
if(curl_errno($ch)) {
throw new NetworkException("CURL error: " . curl_error($ch), -1);
}
// run the query
$res = curl_exec($ch);
if (Client::DEBUG) {
$headerSent = curl_getinfo($ch, CURLINFO_HEADER_OUT ); // request headers
echo "=== Request headers: ===\n";
print_r($headerSent);
if ($method == "POST") {
echo "=== POST fields ===\n";
echo json_encode($req) . "\n\n";
}
echo "=== Response: ===\n";
echo $res;
}
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($code >= 400) {
// Status code
// Decode into error object
throw new NetworkException($res, $code);
}
if ($code == 0) {
throw new NetworkException("No network connection", -1);
}
//print_r(curl_getinfo($ch));
return $res;
} | php | protected function curl($url, $req = array(), $auth = TRUE, $method = "GET", $json = true) {
$header = [];
if ($json) {
$header[] = 'Content-Type: application/json';
$header[] = 'Accept: application/json';
} else {
$header[] = 'Accept: text/html,application/json,image/webp,image/apng,*/*';
}
static $ch = null;
if (is_null($ch)) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; PHP client; '.php_uname('s').'; PHP/'.phpversion().')');
}
curl_setopt($ch, CURLOPT_HTTPGET, 1);
if (Client::DEBUG) {
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
echo 'Request: ' . $method . "\t" . $this->base_url . $url . "\n";
}
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, NULL);
if ($method == "GET") {
$post_data = http_build_query($req, '', '&');
curl_setopt($ch, CURLOPT_URL, $this->base_url . $url .'?'.$post_data);
} else if ($method == "POST") {
curl_setopt($ch, CURLOPT_URL, $this->base_url . $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($req));
} else {
$post_data = http_build_query($req, '', '&');
curl_setopt($ch, CURLOPT_URL, $this->base_url . $url .'?'.$post_data);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
}
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
//curl_setopt($ch, CURLINFO_HEADER_OUT, true);
if ($auth) {
if ($this->credentials->getPrivateKey() == null) {
throw new NetworkException("No credentials found.", -2);
}
curl_setopt($ch, CURLOPT_USERPWD, $this->credentials->getPrivateKey().':');
}
if(curl_errno($ch)) {
throw new NetworkException("CURL error: " . curl_error($ch), -1);
}
// run the query
$res = curl_exec($ch);
if (Client::DEBUG) {
$headerSent = curl_getinfo($ch, CURLINFO_HEADER_OUT ); // request headers
echo "=== Request headers: ===\n";
print_r($headerSent);
if ($method == "POST") {
echo "=== POST fields ===\n";
echo json_encode($req) . "\n\n";
}
echo "=== Response: ===\n";
echo $res;
}
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($code >= 400) {
// Status code
// Decode into error object
throw new NetworkException($res, $code);
}
if ($code == 0) {
throw new NetworkException("No network connection", -1);
}
//print_r(curl_getinfo($ch));
return $res;
} | [
"protected",
"function",
"curl",
"(",
"$",
"url",
",",
"$",
"req",
"=",
"array",
"(",
")",
",",
"$",
"auth",
"=",
"TRUE",
",",
"$",
"method",
"=",
"\"GET\"",
",",
"$",
"json",
"=",
"true",
")",
"{",
"$",
"header",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"json",
")",
"{",
"$",
"header",
"[",
"]",
"=",
"'Content-Type: application/json'",
";",
"$",
"header",
"[",
"]",
"=",
"'Accept: application/json'",
";",
"}",
"else",
"{",
"$",
"header",
"[",
"]",
"=",
"'Accept: text/html,application/json,image/webp,image/apng,*/*'",
";",
"}",
"static",
"$",
"ch",
"=",
"null",
";",
"if",
"(",
"is_null",
"(",
"$",
"ch",
")",
")",
"{",
"$",
"ch",
"=",
"curl_init",
"(",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_RETURNTRANSFER",
",",
"true",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_USERAGENT",
",",
"'Mozilla/4.0 (compatible; PHP client; '",
".",
"php_uname",
"(",
"'s'",
")",
".",
"'; PHP/'",
".",
"phpversion",
"(",
")",
".",
"')'",
")",
";",
"}",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_HTTPGET",
",",
"1",
")",
";",
"if",
"(",
"Client",
"::",
"DEBUG",
")",
"{",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLINFO_HEADER_OUT",
",",
"true",
")",
";",
"echo",
"'Request: '",
".",
"$",
"method",
".",
"\"\\t\"",
".",
"$",
"this",
"->",
"base_url",
".",
"$",
"url",
".",
"\"\\n\"",
";",
"}",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_CUSTOMREQUEST",
",",
"NULL",
")",
";",
"if",
"(",
"$",
"method",
"==",
"\"GET\"",
")",
"{",
"$",
"post_data",
"=",
"http_build_query",
"(",
"$",
"req",
",",
"''",
",",
"'&'",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_URL",
",",
"$",
"this",
"->",
"base_url",
".",
"$",
"url",
".",
"'?'",
".",
"$",
"post_data",
")",
";",
"}",
"else",
"if",
"(",
"$",
"method",
"==",
"\"POST\"",
")",
"{",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_URL",
",",
"$",
"this",
"->",
"base_url",
".",
"$",
"url",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_POST",
",",
"1",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_POSTFIELDS",
",",
"json_encode",
"(",
"$",
"req",
")",
")",
";",
"}",
"else",
"{",
"$",
"post_data",
"=",
"http_build_query",
"(",
"$",
"req",
",",
"''",
",",
"'&'",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_URL",
",",
"$",
"this",
"->",
"base_url",
".",
"$",
"url",
".",
"'?'",
".",
"$",
"post_data",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_CUSTOMREQUEST",
",",
"$",
"method",
")",
";",
"}",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_SSL_VERIFYPEER",
",",
"FALSE",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_HTTPHEADER",
",",
"$",
"header",
")",
";",
"//curl_setopt($ch, CURLINFO_HEADER_OUT, true);",
"if",
"(",
"$",
"auth",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"credentials",
"->",
"getPrivateKey",
"(",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"NetworkException",
"(",
"\"No credentials found.\"",
",",
"-",
"2",
")",
";",
"}",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_USERPWD",
",",
"$",
"this",
"->",
"credentials",
"->",
"getPrivateKey",
"(",
")",
".",
"':'",
")",
";",
"}",
"if",
"(",
"curl_errno",
"(",
"$",
"ch",
")",
")",
"{",
"throw",
"new",
"NetworkException",
"(",
"\"CURL error: \"",
".",
"curl_error",
"(",
"$",
"ch",
")",
",",
"-",
"1",
")",
";",
"}",
"// run the query",
"$",
"res",
"=",
"curl_exec",
"(",
"$",
"ch",
")",
";",
"if",
"(",
"Client",
"::",
"DEBUG",
")",
"{",
"$",
"headerSent",
"=",
"curl_getinfo",
"(",
"$",
"ch",
",",
"CURLINFO_HEADER_OUT",
")",
";",
"// request headers",
"echo",
"\"=== Request headers: ===\\n\"",
";",
"print_r",
"(",
"$",
"headerSent",
")",
";",
"if",
"(",
"$",
"method",
"==",
"\"POST\"",
")",
"{",
"echo",
"\"=== POST fields ===\\n\"",
";",
"echo",
"json_encode",
"(",
"$",
"req",
")",
".",
"\"\\n\\n\"",
";",
"}",
"echo",
"\"=== Response: ===\\n\"",
";",
"echo",
"$",
"res",
";",
"}",
"$",
"code",
"=",
"curl_getinfo",
"(",
"$",
"ch",
",",
"CURLINFO_HTTP_CODE",
")",
";",
"if",
"(",
"$",
"code",
">=",
"400",
")",
"{",
"// Status code",
"// Decode into error object",
"throw",
"new",
"NetworkException",
"(",
"$",
"res",
",",
"$",
"code",
")",
";",
"}",
"if",
"(",
"$",
"code",
"==",
"0",
")",
"{",
"throw",
"new",
"NetworkException",
"(",
"\"No network connection\"",
",",
"-",
"1",
")",
";",
"}",
"//print_r(curl_getinfo($ch));",
"return",
"$",
"res",
";",
"}"
] | Calls a url on the OK service
@param $url
@param mixed $req Query parameters
@param bool $auth Should use authentication for request
@param string $method HTTP Method, either GET or POST
@param bool $json whether this request should use json
@return mixed|string
@throws NetworkException | [
"Calls",
"a",
"url",
"on",
"the",
"OK",
"service"
] | train | https://github.com/okitcom/ok-lib-php/blob/1f441f3d216af7c952788e864bfe66bc4f089467/src/Client.php#L83-L160 |
yoanm/symfony-jsonrpc-http-server-doc | src/DependencyInjection/JsonRpcHttpServerDocExtension.php | JsonRpcHttpServerDocExtension.load | public function load(array $configs, ContainerBuilder $container)
{
$this->compileAndProcessConfigurations($configs, $container);
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.sdk.infra.yaml');
$loader->load('services.private.yaml');
$loader->load('services.public.yaml');
} | php | public function load(array $configs, ContainerBuilder $container)
{
$this->compileAndProcessConfigurations($configs, $container);
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.sdk.infra.yaml');
$loader->load('services.private.yaml');
$loader->load('services.public.yaml');
} | [
"public",
"function",
"load",
"(",
"array",
"$",
"configs",
",",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"this",
"->",
"compileAndProcessConfigurations",
"(",
"$",
"configs",
",",
"$",
"container",
")",
";",
"$",
"loader",
"=",
"new",
"YamlFileLoader",
"(",
"$",
"container",
",",
"new",
"FileLocator",
"(",
"__DIR__",
".",
"'/../Resources/config'",
")",
")",
";",
"$",
"loader",
"->",
"load",
"(",
"'services.sdk.infra.yaml'",
")",
";",
"$",
"loader",
"->",
"load",
"(",
"'services.private.yaml'",
")",
";",
"$",
"loader",
"->",
"load",
"(",
"'services.public.yaml'",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/yoanm/symfony-jsonrpc-http-server-doc/blob/7a59862f74fef29d0e2ad017188977419503ad94/src/DependencyInjection/JsonRpcHttpServerDocExtension.php#L27-L36 |
askupasoftware/amarkal | Extensions/WordPress/Admin/Notifier.php | Notifier.notify | static function notify( $message, $type, $page = null )
{
global $pagenow;
if( ( null != $page && $page == $pagenow ) ||
null == $page)
{
add_action( 'admin_notices', create_function( '',"echo '<div class=\"".$type."\"><p>".$message."</p></div>';" ) );
}
} | php | static function notify( $message, $type, $page = null )
{
global $pagenow;
if( ( null != $page && $page == $pagenow ) ||
null == $page)
{
add_action( 'admin_notices', create_function( '',"echo '<div class=\"".$type."\"><p>".$message."</p></div>';" ) );
}
} | [
"static",
"function",
"notify",
"(",
"$",
"message",
",",
"$",
"type",
",",
"$",
"page",
"=",
"null",
")",
"{",
"global",
"$",
"pagenow",
";",
"if",
"(",
"(",
"null",
"!=",
"$",
"page",
"&&",
"$",
"page",
"==",
"$",
"pagenow",
")",
"||",
"null",
"==",
"$",
"page",
")",
"{",
"add_action",
"(",
"'admin_notices'",
",",
"create_function",
"(",
"''",
",",
"\"echo '<div class=\\\"\"",
".",
"$",
"type",
".",
"\"\\\"><p>\"",
".",
"$",
"message",
".",
"\"</p></div>';\"",
")",
")",
";",
"}",
"}"
] | Register an admin notification.
@global string $pagenow The current admin page.
@param string $message The message to print.
@param string $type The type of notification [self::ERROR|self::SUCCESS].
@param string $page (optional) A specific admin page in which the
notification should appear. If no page is specified
the message will be visible in all admin pages. | [
"Register",
"an",
"admin",
"notification",
"."
] | train | https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Extensions/WordPress/Admin/Notifier.php#L39-L47 |
joseph-walker/vector | src/Lib/Objects.php | Objects.__setProp | protected static function __setProp($key, $val, $obj)
{
$newObj = clone $obj;
/** @noinspection PhpVariableVariableInspection */
$newObj->$key = $val;
return $newObj;
} | php | protected static function __setProp($key, $val, $obj)
{
$newObj = clone $obj;
/** @noinspection PhpVariableVariableInspection */
$newObj->$key = $val;
return $newObj;
} | [
"protected",
"static",
"function",
"__setProp",
"(",
"$",
"key",
",",
"$",
"val",
",",
"$",
"obj",
")",
"{",
"$",
"newObj",
"=",
"clone",
"$",
"obj",
";",
"/** @noinspection PhpVariableVariableInspection */",
"$",
"newObj",
"->",
"$",
"key",
"=",
"$",
"val",
";",
"return",
"$",
"newObj",
";",
"}"
] | Set Property
Sets a property on the object
@example
Object::setValue('value', new stdClass(), 'hi!');
// object(stdClass)#1 (1) {
// ["value"]=>
// string(3) "hi!"
// }
@type String -> a -> Object a -> Object a
@param String $key Property to set
@param mixed $val Value
@param Object $obj Object
@return Object $obj Object | [
"Set",
"Property"
] | train | https://github.com/joseph-walker/vector/blob/e349aa2e9e0535b1993f9fffc0476e7fd8e113fc/src/Lib/Objects.php#L36-L43 |
joseph-walker/vector | src/Lib/Objects.php | Objects.__assign | protected static function __assign($props, $objOriginal)
{
$obj = clone $objOriginal;
/** @noinspection PhpParamsInspection */
return Arrays::foldl(
function ($obj, $setter) {
return $setter($obj);
},
$obj,
Arrays::mapIndexed(Lambda::flip(self::setProp()), $props)
);
} | php | protected static function __assign($props, $objOriginal)
{
$obj = clone $objOriginal;
/** @noinspection PhpParamsInspection */
return Arrays::foldl(
function ($obj, $setter) {
return $setter($obj);
},
$obj,
Arrays::mapIndexed(Lambda::flip(self::setProp()), $props)
);
} | [
"protected",
"static",
"function",
"__assign",
"(",
"$",
"props",
",",
"$",
"objOriginal",
")",
"{",
"$",
"obj",
"=",
"clone",
"$",
"objOriginal",
";",
"/** @noinspection PhpParamsInspection */",
"return",
"Arrays",
"::",
"foldl",
"(",
"function",
"(",
"$",
"obj",
",",
"$",
"setter",
")",
"{",
"return",
"$",
"setter",
"(",
"$",
"obj",
")",
";",
"}",
",",
"$",
"obj",
",",
"Arrays",
"::",
"mapIndexed",
"(",
"Lambda",
"::",
"flip",
"(",
"self",
"::",
"setProp",
"(",
")",
")",
",",
"$",
"props",
")",
")",
";",
"}"
] | Assign Properties
Set/Update properties on the object using a key/value array
@example
Object::assign(['value' => 'hi!'], new stdClass);
// object(stdClass)#1 (1) {
// ["value"]=>
// string(3) "hi!"
// }
@type array props -> Object objOriginal -> Object objUpdated
@param $props
@param $objOriginal
@return mixed | [
"Assign",
"Properties"
] | train | https://github.com/joseph-walker/vector/blob/e349aa2e9e0535b1993f9fffc0476e7fd8e113fc/src/Lib/Objects.php#L63-L75 |
yuncms/framework | src/admin/models/AdminBizRuleSearch.php | AdminBizRuleSearch.search | public function search($params)
{
/* @var \yii\rbac\DbManager $authManager */
$authManager = Yii::$app->authManager;
$models = [];
$included = !($this->load($params) && $this->validate() && trim($this->name) !== '');
foreach ($authManager->getRules() as $name => $item) {
if ($name != RouteRule::RULE_NAME && ($included || stripos($item->name, $this->name) !== false)) {
$models[$name] = new AdminBizRule($item);
}
}
return new ArrayDataProvider([
'allModels' => $models,
]);
} | php | public function search($params)
{
/* @var \yii\rbac\DbManager $authManager */
$authManager = Yii::$app->authManager;
$models = [];
$included = !($this->load($params) && $this->validate() && trim($this->name) !== '');
foreach ($authManager->getRules() as $name => $item) {
if ($name != RouteRule::RULE_NAME && ($included || stripos($item->name, $this->name) !== false)) {
$models[$name] = new AdminBizRule($item);
}
}
return new ArrayDataProvider([
'allModels' => $models,
]);
} | [
"public",
"function",
"search",
"(",
"$",
"params",
")",
"{",
"/* @var \\yii\\rbac\\DbManager $authManager */",
"$",
"authManager",
"=",
"Yii",
"::",
"$",
"app",
"->",
"authManager",
";",
"$",
"models",
"=",
"[",
"]",
";",
"$",
"included",
"=",
"!",
"(",
"$",
"this",
"->",
"load",
"(",
"$",
"params",
")",
"&&",
"$",
"this",
"->",
"validate",
"(",
")",
"&&",
"trim",
"(",
"$",
"this",
"->",
"name",
")",
"!==",
"''",
")",
";",
"foreach",
"(",
"$",
"authManager",
"->",
"getRules",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"name",
"!=",
"RouteRule",
"::",
"RULE_NAME",
"&&",
"(",
"$",
"included",
"||",
"stripos",
"(",
"$",
"item",
"->",
"name",
",",
"$",
"this",
"->",
"name",
")",
"!==",
"false",
")",
")",
"{",
"$",
"models",
"[",
"$",
"name",
"]",
"=",
"new",
"AdminBizRule",
"(",
"$",
"item",
")",
";",
"}",
"}",
"return",
"new",
"ArrayDataProvider",
"(",
"[",
"'allModels'",
"=>",
"$",
"models",
",",
"]",
")",
";",
"}"
] | Search BizRule
@param array $params
@return \yii\data\ActiveDataProvider|\yii\data\ArrayDataProvider | [
"Search",
"BizRule"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/admin/models/AdminBizRuleSearch.php#L47-L62 |
factorio-item-browser/export-data | src/Registry/EntityRegistry.php | EntityRegistry.set | public function set(EntityInterface $entity): string
{
$hash = $entity->calculateHash();
$content = $this->encodeContent($entity->writeData());
$this->saveContent($hash, $content);
return $hash;
} | php | public function set(EntityInterface $entity): string
{
$hash = $entity->calculateHash();
$content = $this->encodeContent($entity->writeData());
$this->saveContent($hash, $content);
return $hash;
} | [
"public",
"function",
"set",
"(",
"EntityInterface",
"$",
"entity",
")",
":",
"string",
"{",
"$",
"hash",
"=",
"$",
"entity",
"->",
"calculateHash",
"(",
")",
";",
"$",
"content",
"=",
"$",
"this",
"->",
"encodeContent",
"(",
"$",
"entity",
"->",
"writeData",
"(",
")",
")",
";",
"$",
"this",
"->",
"saveContent",
"(",
"$",
"hash",
",",
"$",
"content",
")",
";",
"return",
"$",
"hash",
";",
"}"
] | Sets the specified entity into the registry.
@param EntityInterface $entity
@return string The hash used to save the entity. | [
"Sets",
"the",
"specified",
"entity",
"into",
"the",
"registry",
"."
] | train | https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Registry/EntityRegistry.php#L51-L57 |
factorio-item-browser/export-data | src/Registry/EntityRegistry.php | EntityRegistry.get | public function get(string $hash): ?EntityInterface
{
$result = null;
$content = $this->loadContent($hash);
if ($content !== null) {
$result = $this->createEntityFromContent($content);
}
return $result;
} | php | public function get(string $hash): ?EntityInterface
{
$result = null;
$content = $this->loadContent($hash);
if ($content !== null) {
$result = $this->createEntityFromContent($content);
}
return $result;
} | [
"public",
"function",
"get",
"(",
"string",
"$",
"hash",
")",
":",
"?",
"EntityInterface",
"{",
"$",
"result",
"=",
"null",
";",
"$",
"content",
"=",
"$",
"this",
"->",
"loadContent",
"(",
"$",
"hash",
")",
";",
"if",
"(",
"$",
"content",
"!==",
"null",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"createEntityFromContent",
"(",
"$",
"content",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Returns the entity with the specified hash.
@param string $hash
@return EntityInterface|null | [
"Returns",
"the",
"entity",
"with",
"the",
"specified",
"hash",
"."
] | train | https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Registry/EntityRegistry.php#L64-L72 |
factorio-item-browser/export-data | src/Registry/EntityRegistry.php | EntityRegistry.createEntityFromContent | protected function createEntityFromContent(string $content): EntityInterface
{
$result = $this->createEntity();
$result->readData(new DataContainer($this->decodeContent($content)));
return $result;
} | php | protected function createEntityFromContent(string $content): EntityInterface
{
$result = $this->createEntity();
$result->readData(new DataContainer($this->decodeContent($content)));
return $result;
} | [
"protected",
"function",
"createEntityFromContent",
"(",
"string",
"$",
"content",
")",
":",
"EntityInterface",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"createEntity",
"(",
")",
";",
"$",
"result",
"->",
"readData",
"(",
"new",
"DataContainer",
"(",
"$",
"this",
"->",
"decodeContent",
"(",
"$",
"content",
")",
")",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Creates an entity from the specified content.
@param string $content
@return EntityInterface | [
"Creates",
"an",
"entity",
"from",
"the",
"specified",
"content",
"."
] | train | https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Registry/EntityRegistry.php#L97-L102 |
redaigbaria/oauth2 | src/Entity/SessionEntity.php | SessionEntity.associateScope | public function associateScope(ScopeEntity $scope)
{
if (!isset($this->scopes[$scope->getId()])) {
$this->scopes[$scope->getId()] = $scope;
}
return $this;
} | php | public function associateScope(ScopeEntity $scope)
{
if (!isset($this->scopes[$scope->getId()])) {
$this->scopes[$scope->getId()] = $scope;
}
return $this;
} | [
"public",
"function",
"associateScope",
"(",
"ScopeEntity",
"$",
"scope",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"scopes",
"[",
"$",
"scope",
"->",
"getId",
"(",
")",
"]",
")",
")",
"{",
"$",
"this",
"->",
"scopes",
"[",
"$",
"scope",
"->",
"getId",
"(",
")",
"]",
"=",
"$",
"scope",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Associate a scope
@param \League\OAuth2\Server\Entity\ScopeEntity $scope
@return self | [
"Associate",
"a",
"scope"
] | train | https://github.com/redaigbaria/oauth2/blob/54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a/src/Entity/SessionEntity.php#L130-L137 |
redaigbaria/oauth2 | src/Entity/SessionEntity.php | SessionEntity.hasScope | public function hasScope($scope)
{
if ($this->scopes === null) {
$this->getScopes();
}
return isset($this->scopes[$scope]);
} | php | public function hasScope($scope)
{
if ($this->scopes === null) {
$this->getScopes();
}
return isset($this->scopes[$scope]);
} | [
"public",
"function",
"hasScope",
"(",
"$",
"scope",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"scopes",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"getScopes",
"(",
")",
";",
"}",
"return",
"isset",
"(",
"$",
"this",
"->",
"scopes",
"[",
"$",
"scope",
"]",
")",
";",
"}"
] | Check if access token has an associated scope
@param string $scope Scope to check
@return bool | [
"Check",
"if",
"access",
"token",
"has",
"an",
"associated",
"scope"
] | train | https://github.com/redaigbaria/oauth2/blob/54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a/src/Entity/SessionEntity.php#L146-L153 |
redaigbaria/oauth2 | src/Entity/SessionEntity.php | SessionEntity.getScopes | public function getScopes()
{
if ($this->scopes === null) {
$this->scopes = $this->formatScopes($this->server->getSessionStorage()->getScopes($this));
}
return $this->scopes;
} | php | public function getScopes()
{
if ($this->scopes === null) {
$this->scopes = $this->formatScopes($this->server->getSessionStorage()->getScopes($this));
}
return $this->scopes;
} | [
"public",
"function",
"getScopes",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"scopes",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"scopes",
"=",
"$",
"this",
"->",
"formatScopes",
"(",
"$",
"this",
"->",
"server",
"->",
"getSessionStorage",
"(",
")",
"->",
"getScopes",
"(",
"$",
"this",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"scopes",
";",
"}"
] | Return all scopes associated with the session
@return \League\OAuth2\Server\Entity\ScopeEntity[] | [
"Return",
"all",
"scopes",
"associated",
"with",
"the",
"session"
] | train | https://github.com/redaigbaria/oauth2/blob/54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a/src/Entity/SessionEntity.php#L160-L167 |
redaigbaria/oauth2 | src/Entity/SessionEntity.php | SessionEntity.formatScopes | private function formatScopes($unformatted = [])
{
$scopes = [];
if (is_array($unformatted)) {
foreach ($unformatted as $scope) {
if ($scope instanceof ScopeEntity) {
$scopes[$scope->getId()] = $scope;
}
}
}
return $scopes;
} | php | private function formatScopes($unformatted = [])
{
$scopes = [];
if (is_array($unformatted)) {
foreach ($unformatted as $scope) {
if ($scope instanceof ScopeEntity) {
$scopes[$scope->getId()] = $scope;
}
}
}
return $scopes;
} | [
"private",
"function",
"formatScopes",
"(",
"$",
"unformatted",
"=",
"[",
"]",
")",
"{",
"$",
"scopes",
"=",
"[",
"]",
";",
"if",
"(",
"is_array",
"(",
"$",
"unformatted",
")",
")",
"{",
"foreach",
"(",
"$",
"unformatted",
"as",
"$",
"scope",
")",
"{",
"if",
"(",
"$",
"scope",
"instanceof",
"ScopeEntity",
")",
"{",
"$",
"scopes",
"[",
"$",
"scope",
"->",
"getId",
"(",
")",
"]",
"=",
"$",
"scope",
";",
"}",
"}",
"}",
"return",
"$",
"scopes",
";",
"}"
] | Format the local scopes array
@param \League\OAuth2\Server\Entity\Scope[]
@return array | [
"Format",
"the",
"local",
"scopes",
"array"
] | train | https://github.com/redaigbaria/oauth2/blob/54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a/src/Entity/SessionEntity.php#L176-L188 |
redaigbaria/oauth2 | src/Entity/SessionEntity.php | SessionEntity.getClient | public function getClient()
{
if ($this->client instanceof ClientEntity) {
return $this->client;
}
$this->client = $this->server->getClientStorage()->getBySession($this);
return $this->client;
} | php | public function getClient()
{
if ($this->client instanceof ClientEntity) {
return $this->client;
}
$this->client = $this->server->getClientStorage()->getBySession($this);
return $this->client;
} | [
"public",
"function",
"getClient",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"client",
"instanceof",
"ClientEntity",
")",
"{",
"return",
"$",
"this",
"->",
"client",
";",
"}",
"$",
"this",
"->",
"client",
"=",
"$",
"this",
"->",
"server",
"->",
"getClientStorage",
"(",
")",
"->",
"getBySession",
"(",
"$",
"this",
")",
";",
"return",
"$",
"this",
"->",
"client",
";",
"}"
] | Return the session client
@return \League\OAuth2\Server\Entity\ClientEntity | [
"Return",
"the",
"session",
"client"
] | train | https://github.com/redaigbaria/oauth2/blob/54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a/src/Entity/SessionEntity.php#L237-L246 |
redaigbaria/oauth2 | src/Entity/SessionEntity.php | SessionEntity.setOwner | public function setOwner($type, $id)
{
$this->ownerType = $type;
$this->ownerId = $id;
$this->server->getEventEmitter()->emit(new SessionOwnerEvent($this));
return $this;
} | php | public function setOwner($type, $id)
{
$this->ownerType = $type;
$this->ownerId = $id;
$this->server->getEventEmitter()->emit(new SessionOwnerEvent($this));
return $this;
} | [
"public",
"function",
"setOwner",
"(",
"$",
"type",
",",
"$",
"id",
")",
"{",
"$",
"this",
"->",
"ownerType",
"=",
"$",
"type",
";",
"$",
"this",
"->",
"ownerId",
"=",
"$",
"id",
";",
"$",
"this",
"->",
"server",
"->",
"getEventEmitter",
"(",
")",
"->",
"emit",
"(",
"new",
"SessionOwnerEvent",
"(",
"$",
"this",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set the session owner
@param string $type The type of the owner (e.g. user, app)
@param string $id The identifier of the owner
@return self | [
"Set",
"the",
"session",
"owner"
] | train | https://github.com/redaigbaria/oauth2/blob/54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a/src/Entity/SessionEntity.php#L256-L264 |
redaigbaria/oauth2 | src/Entity/SessionEntity.php | SessionEntity.save | public function save()
{
// Save the session and get an identifier
$id = $this->server->getSessionStorage()->create(
$this->getOwnerType(),
$this->getOwnerId(),
$this->getClient()->getId(),
$this->getClient()->getRedirectUri()
);
$this->setId($id);
// Associate the scope with the session
foreach ($this->getScopes() as $scope) {
$this->server->getSessionStorage()->associateScope($this, $scope);
}
} | php | public function save()
{
// Save the session and get an identifier
$id = $this->server->getSessionStorage()->create(
$this->getOwnerType(),
$this->getOwnerId(),
$this->getClient()->getId(),
$this->getClient()->getRedirectUri()
);
$this->setId($id);
// Associate the scope with the session
foreach ($this->getScopes() as $scope) {
$this->server->getSessionStorage()->associateScope($this, $scope);
}
} | [
"public",
"function",
"save",
"(",
")",
"{",
"// Save the session and get an identifier",
"$",
"id",
"=",
"$",
"this",
"->",
"server",
"->",
"getSessionStorage",
"(",
")",
"->",
"create",
"(",
"$",
"this",
"->",
"getOwnerType",
"(",
")",
",",
"$",
"this",
"->",
"getOwnerId",
"(",
")",
",",
"$",
"this",
"->",
"getClient",
"(",
")",
"->",
"getId",
"(",
")",
",",
"$",
"this",
"->",
"getClient",
"(",
")",
"->",
"getRedirectUri",
"(",
")",
")",
";",
"$",
"this",
"->",
"setId",
"(",
"$",
"id",
")",
";",
"// Associate the scope with the session",
"foreach",
"(",
"$",
"this",
"->",
"getScopes",
"(",
")",
"as",
"$",
"scope",
")",
"{",
"$",
"this",
"->",
"server",
"->",
"getSessionStorage",
"(",
")",
"->",
"associateScope",
"(",
"$",
"this",
",",
"$",
"scope",
")",
";",
"}",
"}"
] | Save the session
@return void | [
"Save",
"the",
"session"
] | train | https://github.com/redaigbaria/oauth2/blob/54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a/src/Entity/SessionEntity.php#L291-L307 |
ufocoder/yii2-SyncSocial | src/actions/SyncAction.php | SyncAction.run | public function run( $service ) {
$flagConnect = $this->synchronizer->isConnected( $service );
if ( $flagConnect ) {
$resultSync = $this->synchronizer->syncService( $service );
$successMessage = $resultSync['count'] == 0
? Yii::t( 'SyncSocial', 'Service was successfully synchronized! There\'s no new records!', [
'count' => $resultSync['count']
] )
: Yii::t( 'SyncSocial', 'Service was successfully synchronized! {count} record(s) was added!', [
'count' => $resultSync['count']
] );
return $this->redirectWithMessages(
$resultSync['flag'],
$successMessage,
Yii::t( 'SyncSocial', 'There is a error in service synchronization' )
);
} else {
Yii::$app->session->setFlash( 'warning', Yii::t( 'SyncSocial', 'Service is not connected' ) );
return $this->controller->redirect( $this->failedUrl );
}
} | php | public function run( $service ) {
$flagConnect = $this->synchronizer->isConnected( $service );
if ( $flagConnect ) {
$resultSync = $this->synchronizer->syncService( $service );
$successMessage = $resultSync['count'] == 0
? Yii::t( 'SyncSocial', 'Service was successfully synchronized! There\'s no new records!', [
'count' => $resultSync['count']
] )
: Yii::t( 'SyncSocial', 'Service was successfully synchronized! {count} record(s) was added!', [
'count' => $resultSync['count']
] );
return $this->redirectWithMessages(
$resultSync['flag'],
$successMessage,
Yii::t( 'SyncSocial', 'There is a error in service synchronization' )
);
} else {
Yii::$app->session->setFlash( 'warning', Yii::t( 'SyncSocial', 'Service is not connected' ) );
return $this->controller->redirect( $this->failedUrl );
}
} | [
"public",
"function",
"run",
"(",
"$",
"service",
")",
"{",
"$",
"flagConnect",
"=",
"$",
"this",
"->",
"synchronizer",
"->",
"isConnected",
"(",
"$",
"service",
")",
";",
"if",
"(",
"$",
"flagConnect",
")",
"{",
"$",
"resultSync",
"=",
"$",
"this",
"->",
"synchronizer",
"->",
"syncService",
"(",
"$",
"service",
")",
";",
"$",
"successMessage",
"=",
"$",
"resultSync",
"[",
"'count'",
"]",
"==",
"0",
"?",
"Yii",
"::",
"t",
"(",
"'SyncSocial'",
",",
"'Service was successfully synchronized! There\\'s no new records!'",
",",
"[",
"'count'",
"=>",
"$",
"resultSync",
"[",
"'count'",
"]",
"]",
")",
":",
"Yii",
"::",
"t",
"(",
"'SyncSocial'",
",",
"'Service was successfully synchronized! {count} record(s) was added!'",
",",
"[",
"'count'",
"=>",
"$",
"resultSync",
"[",
"'count'",
"]",
"]",
")",
";",
"return",
"$",
"this",
"->",
"redirectWithMessages",
"(",
"$",
"resultSync",
"[",
"'flag'",
"]",
",",
"$",
"successMessage",
",",
"Yii",
"::",
"t",
"(",
"'SyncSocial'",
",",
"'There is a error in service synchronization'",
")",
")",
";",
"}",
"else",
"{",
"Yii",
"::",
"$",
"app",
"->",
"session",
"->",
"setFlash",
"(",
"'warning'",
",",
"Yii",
"::",
"t",
"(",
"'SyncSocial'",
",",
"'Service is not connected'",
")",
")",
";",
"return",
"$",
"this",
"->",
"controller",
"->",
"redirect",
"(",
"$",
"this",
"->",
"failedUrl",
")",
";",
"}",
"}"
] | @param $service
@return \yii\web\Response | [
"@param",
"$service"
] | train | https://github.com/ufocoder/yii2-SyncSocial/blob/2dbaaec2dad782c52fdd5b648a31ba7fe2a75e1b/src/actions/SyncAction.php#L18-L44 |
webforge-labs/psc-cms | lib/Psc/UI/DropBox2.php | DropBox2.convertButtons | protected function convertButtons() {
$buttons = array();
$snippets = array();
if (isset($this->assignedValues)) {
foreach ($this->assignedValues as $item) {
if ($item instanceof \Psc\UI\ButtonInterface) {
$button = $item;
} elseif ($item instanceof \Psc\CMS\Entity) {
$button = $this->entityMeta->getAdapter($item)
->setButtonMode(Buttonable::CLICK | Buttonable::DRAG)
->getDropBoxButton();
} else {
throw new \InvalidArgumentException(Code::varInfo($item).' kann nicht in einen Button umgewandelt werden');
}
if ($button instanceof \Psc\JS\JooseSnippetWidget) {
$button->disableAutoLoad();
// das bevor getJooseSnippet() machen damit widgetSelector im snippet geht
// aber NACH disableAutoLoad()
$button->html()->addClass('assigned-item');
$snippets[] = $button->getJooseSnippet();
} else {
$button->html()->addClass('assigned-item');
}
$buttons[] = $button;
}
}
return array($buttons, $snippets);
} | php | protected function convertButtons() {
$buttons = array();
$snippets = array();
if (isset($this->assignedValues)) {
foreach ($this->assignedValues as $item) {
if ($item instanceof \Psc\UI\ButtonInterface) {
$button = $item;
} elseif ($item instanceof \Psc\CMS\Entity) {
$button = $this->entityMeta->getAdapter($item)
->setButtonMode(Buttonable::CLICK | Buttonable::DRAG)
->getDropBoxButton();
} else {
throw new \InvalidArgumentException(Code::varInfo($item).' kann nicht in einen Button umgewandelt werden');
}
if ($button instanceof \Psc\JS\JooseSnippetWidget) {
$button->disableAutoLoad();
// das bevor getJooseSnippet() machen damit widgetSelector im snippet geht
// aber NACH disableAutoLoad()
$button->html()->addClass('assigned-item');
$snippets[] = $button->getJooseSnippet();
} else {
$button->html()->addClass('assigned-item');
}
$buttons[] = $button;
}
}
return array($buttons, $snippets);
} | [
"protected",
"function",
"convertButtons",
"(",
")",
"{",
"$",
"buttons",
"=",
"array",
"(",
")",
";",
"$",
"snippets",
"=",
"array",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"assignedValues",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"assignedValues",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"item",
"instanceof",
"\\",
"Psc",
"\\",
"UI",
"\\",
"ButtonInterface",
")",
"{",
"$",
"button",
"=",
"$",
"item",
";",
"}",
"elseif",
"(",
"$",
"item",
"instanceof",
"\\",
"Psc",
"\\",
"CMS",
"\\",
"Entity",
")",
"{",
"$",
"button",
"=",
"$",
"this",
"->",
"entityMeta",
"->",
"getAdapter",
"(",
"$",
"item",
")",
"->",
"setButtonMode",
"(",
"Buttonable",
"::",
"CLICK",
"|",
"Buttonable",
"::",
"DRAG",
")",
"->",
"getDropBoxButton",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"Code",
"::",
"varInfo",
"(",
"$",
"item",
")",
".",
"' kann nicht in einen Button umgewandelt werden'",
")",
";",
"}",
"if",
"(",
"$",
"button",
"instanceof",
"\\",
"Psc",
"\\",
"JS",
"\\",
"JooseSnippetWidget",
")",
"{",
"$",
"button",
"->",
"disableAutoLoad",
"(",
")",
";",
"// das bevor getJooseSnippet() machen damit widgetSelector im snippet geht",
"// aber NACH disableAutoLoad()",
"$",
"button",
"->",
"html",
"(",
")",
"->",
"addClass",
"(",
"'assigned-item'",
")",
";",
"$",
"snippets",
"[",
"]",
"=",
"$",
"button",
"->",
"getJooseSnippet",
"(",
")",
";",
"}",
"else",
"{",
"$",
"button",
"->",
"html",
"(",
")",
"->",
"addClass",
"(",
"'assigned-item'",
")",
";",
"}",
"$",
"buttons",
"[",
"]",
"=",
"$",
"button",
";",
"}",
"}",
"return",
"array",
"(",
"$",
"buttons",
",",
"$",
"snippets",
")",
";",
"}"
] | Wandelt die assignedValues in Buttons um
die JooseSnippets werden gesammelt, wenn sie extrahierbar sind
@return list($buttons, $snippets) | [
"Wandelt",
"die",
"assignedValues",
"in",
"Buttons",
"um"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/UI/DropBox2.php#L115-L150 |
atkrad/data-tables | src/Render.php | Render.getConfig | protected function getConfig()
{
if (!$this->table->getDataSource() instanceof Dom) {
$this->prepareColumnsConfig();
}
$this->prepareExtensionsConfig();
$config = [];
$config += $this->table->getProperties();
return json_encode($config);
} | php | protected function getConfig()
{
if (!$this->table->getDataSource() instanceof Dom) {
$this->prepareColumnsConfig();
}
$this->prepareExtensionsConfig();
$config = [];
$config += $this->table->getProperties();
return json_encode($config);
} | [
"protected",
"function",
"getConfig",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"table",
"->",
"getDataSource",
"(",
")",
"instanceof",
"Dom",
")",
"{",
"$",
"this",
"->",
"prepareColumnsConfig",
"(",
")",
";",
"}",
"$",
"this",
"->",
"prepareExtensionsConfig",
"(",
")",
";",
"$",
"config",
"=",
"[",
"]",
";",
"$",
"config",
"+=",
"$",
"this",
"->",
"table",
"->",
"getProperties",
"(",
")",
";",
"return",
"json_encode",
"(",
"$",
"config",
")",
";",
"}"
] | Get config
@return string | [
"Get",
"config"
] | train | https://github.com/atkrad/data-tables/blob/5afcc337ab624ca626e29d9674459c5105982b16/src/Render.php#L120-L131 |
atkrad/data-tables | src/Render.php | Render.prepareColumnsConfig | protected function prepareColumnsConfig()
{
$columns = [];
foreach ($this->table->getColumns() as $column) {
$columns[] = $column->getProperties();
}
$this->table->setColumns($columns);
} | php | protected function prepareColumnsConfig()
{
$columns = [];
foreach ($this->table->getColumns() as $column) {
$columns[] = $column->getProperties();
}
$this->table->setColumns($columns);
} | [
"protected",
"function",
"prepareColumnsConfig",
"(",
")",
"{",
"$",
"columns",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"table",
"->",
"getColumns",
"(",
")",
"as",
"$",
"column",
")",
"{",
"$",
"columns",
"[",
"]",
"=",
"$",
"column",
"->",
"getProperties",
"(",
")",
";",
"}",
"$",
"this",
"->",
"table",
"->",
"setColumns",
"(",
"$",
"columns",
")",
";",
"}"
] | Prepare columns config | [
"Prepare",
"columns",
"config"
] | train | https://github.com/atkrad/data-tables/blob/5afcc337ab624ca626e29d9674459c5105982b16/src/Render.php#L136-L145 |
atkrad/data-tables | src/Render.php | Render.prepareExtensionsConfig | protected function prepareExtensionsConfig()
{
foreach ($this->table->getExtensions() as $extension) {
$properties = $extension->getProperties();
if (isset($properties)) {
$this->table->setProperty($extension->getPropertyName(), $properties);
}
}
} | php | protected function prepareExtensionsConfig()
{
foreach ($this->table->getExtensions() as $extension) {
$properties = $extension->getProperties();
if (isset($properties)) {
$this->table->setProperty($extension->getPropertyName(), $properties);
}
}
} | [
"protected",
"function",
"prepareExtensionsConfig",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"table",
"->",
"getExtensions",
"(",
")",
"as",
"$",
"extension",
")",
"{",
"$",
"properties",
"=",
"$",
"extension",
"->",
"getProperties",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"properties",
")",
")",
"{",
"$",
"this",
"->",
"table",
"->",
"setProperty",
"(",
"$",
"extension",
"->",
"getPropertyName",
"(",
")",
",",
"$",
"properties",
")",
";",
"}",
"}",
"}"
] | Prepare extensions config | [
"Prepare",
"extensions",
"config"
] | train | https://github.com/atkrad/data-tables/blob/5afcc337ab624ca626e29d9674459c5105982b16/src/Render.php#L150-L158 |
CakeCMS/Core | src/Path/Path.php | Path.dirs | public function dirs($resource, $recursive = false, $filter = null)
{
return $this->ls($resource, self::LS_MODE_DIR, $recursive, $filter);
} | php | public function dirs($resource, $recursive = false, $filter = null)
{
return $this->ls($resource, self::LS_MODE_DIR, $recursive, $filter);
} | [
"public",
"function",
"dirs",
"(",
"$",
"resource",
",",
"$",
"recursive",
"=",
"false",
",",
"$",
"filter",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"ls",
"(",
"$",
"resource",
",",
"self",
"::",
"LS_MODE_DIR",
",",
"$",
"recursive",
",",
"$",
"filter",
")",
";",
"}"
] | Get a list of directories from a resource.
@param string $resource
@param bool $recursive
@param null $filter
@return mixed | [
"Get",
"a",
"list",
"of",
"directories",
"from",
"a",
"resource",
"."
] | train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Path/Path.php#L50-L53 |
CakeCMS/Core | src/Path/Path.php | Path.url | public function url($source, $full = true)
{
$stamp = Configure::read('Asset.timestamp');
$url = parent::url($source, $full);
if ($url !== null && $stamp && strpos($url, '?') === false) {
$fullPath = $this->get($source);
$url .= '?' . @filemtime($fullPath);
}
return $url;
} | php | public function url($source, $full = true)
{
$stamp = Configure::read('Asset.timestamp');
$url = parent::url($source, $full);
if ($url !== null && $stamp && strpos($url, '?') === false) {
$fullPath = $this->get($source);
$url .= '?' . @filemtime($fullPath);
}
return $url;
} | [
"public",
"function",
"url",
"(",
"$",
"source",
",",
"$",
"full",
"=",
"true",
")",
"{",
"$",
"stamp",
"=",
"Configure",
"::",
"read",
"(",
"'Asset.timestamp'",
")",
";",
"$",
"url",
"=",
"parent",
"::",
"url",
"(",
"$",
"source",
",",
"$",
"full",
")",
";",
"if",
"(",
"$",
"url",
"!==",
"null",
"&&",
"$",
"stamp",
"&&",
"strpos",
"(",
"$",
"url",
",",
"'?'",
")",
"===",
"false",
")",
"{",
"$",
"fullPath",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"source",
")",
";",
"$",
"url",
".=",
"'?'",
".",
"@",
"filemtime",
"(",
"$",
"fullPath",
")",
";",
"}",
"return",
"$",
"url",
";",
"}"
] | Get url to a file.
@param string $source
@param bool $full
@return null|string | [
"Get",
"url",
"to",
"a",
"file",
"."
] | train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Path/Path.php#L62-L73 |
CakeCMS/Core | src/Path/Path.php | Path.getInstance | public static function getInstance($key = 'default')
{
if ((string) $key = '') {
throw new Exception('Invalid object key');
}
if (!Arr::key($key, self::$_objects)) {
self::$_objects[$key] = new self();
}
return self::$_objects[$key];
} | php | public static function getInstance($key = 'default')
{
if ((string) $key = '') {
throw new Exception('Invalid object key');
}
if (!Arr::key($key, self::$_objects)) {
self::$_objects[$key] = new self();
}
return self::$_objects[$key];
} | [
"public",
"static",
"function",
"getInstance",
"(",
"$",
"key",
"=",
"'default'",
")",
"{",
"if",
"(",
"(",
"string",
")",
"$",
"key",
"=",
"''",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Invalid object key'",
")",
";",
"}",
"if",
"(",
"!",
"Arr",
"::",
"key",
"(",
"$",
"key",
",",
"self",
"::",
"$",
"_objects",
")",
")",
"{",
"self",
"::",
"$",
"_objects",
"[",
"$",
"key",
"]",
"=",
"new",
"self",
"(",
")",
";",
"}",
"return",
"self",
"::",
"$",
"_objects",
"[",
"$",
"key",
"]",
";",
"}"
] | Get path instance.
@param string $key
@return Path
@throws Exception | [
"Get",
"path",
"instance",
"."
] | train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Path/Path.php#L82-L93 |
CakeCMS/Core | src/Path/Path.php | Path.ls | public function ls($resource, $mode = self::LS_MODE_FILE, $recursive = false, $filter = null)
{
$files = [];
list (, $paths, $path) = $this->_parse($resource);
foreach ((array) $paths as $_path) {
if (file_exists($_path . '/' . $path)) {
foreach ($this->_list(FS::clean($_path . '/' . $path), '', $mode, $recursive, $filter) as $file) {
if (!Arr::in($file, $files)) {
$files[] = $file;
}
}
}
}
return $files;
} | php | public function ls($resource, $mode = self::LS_MODE_FILE, $recursive = false, $filter = null)
{
$files = [];
list (, $paths, $path) = $this->_parse($resource);
foreach ((array) $paths as $_path) {
if (file_exists($_path . '/' . $path)) {
foreach ($this->_list(FS::clean($_path . '/' . $path), '', $mode, $recursive, $filter) as $file) {
if (!Arr::in($file, $files)) {
$files[] = $file;
}
}
}
}
return $files;
} | [
"public",
"function",
"ls",
"(",
"$",
"resource",
",",
"$",
"mode",
"=",
"self",
"::",
"LS_MODE_FILE",
",",
"$",
"recursive",
"=",
"false",
",",
"$",
"filter",
"=",
"null",
")",
"{",
"$",
"files",
"=",
"[",
"]",
";",
"list",
"(",
",",
"$",
"paths",
",",
"$",
"path",
")",
"=",
"$",
"this",
"->",
"_parse",
"(",
"$",
"resource",
")",
";",
"foreach",
"(",
"(",
"array",
")",
"$",
"paths",
"as",
"$",
"_path",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"_path",
".",
"'/'",
".",
"$",
"path",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_list",
"(",
"FS",
"::",
"clean",
"(",
"$",
"_path",
".",
"'/'",
".",
"$",
"path",
")",
",",
"''",
",",
"$",
"mode",
",",
"$",
"recursive",
",",
"$",
"filter",
")",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"Arr",
"::",
"in",
"(",
"$",
"file",
",",
"$",
"files",
")",
")",
"{",
"$",
"files",
"[",
"]",
"=",
"$",
"file",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"files",
";",
"}"
] | Get a list of files or diretories from a resource.
@param string $resource
@param string $mode
@param bool $recursive
@param null $filter
@return array
@SuppressWarnings(PHPMD.ShortMethodName) | [
"Get",
"a",
"list",
"of",
"files",
"or",
"diretories",
"from",
"a",
"resource",
"."
] | train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Path/Path.php#L105-L121 |
CakeCMS/Core | src/Path/Path.php | Path._list | protected function _list($path, $prefix = '', $mode = 'file', $recursive = false, $filter = null)
{
$files = [];
$ignore = ['.', '..', '.DS_Store', '.svn', '.git', '.gitignore', '.gitmodules', 'cgi-bin'];
if ($scan = @scandir($path)) {
foreach ($scan as $file) {
// continue if ignore match
if (Arr::in($file, $ignore)) {
continue;
}
if (is_dir($path . '/' . $file)) {
// add dir
if ($mode === 'dir') {
// continue if no regex filter match
if ($filter && !preg_match($filter, $file)) {
continue;
}
$files[] = $prefix . $file;
}
// continue if not recursive
if (!$recursive) {
continue;
}
// read subdirectory
$files = array_merge(
$files,
$this->_list($path . '/' . $file, $prefix . $file . '/', $mode, $recursive, $filter)
);
} else {
// add file
if ($mode === 'file') {
// continue if no regex filter match
if ($filter && !preg_match($filter, $file)) {
continue;
}
$files[] = $prefix.$file;
}
}
}
}
return $files;
} | php | protected function _list($path, $prefix = '', $mode = 'file', $recursive = false, $filter = null)
{
$files = [];
$ignore = ['.', '..', '.DS_Store', '.svn', '.git', '.gitignore', '.gitmodules', 'cgi-bin'];
if ($scan = @scandir($path)) {
foreach ($scan as $file) {
// continue if ignore match
if (Arr::in($file, $ignore)) {
continue;
}
if (is_dir($path . '/' . $file)) {
// add dir
if ($mode === 'dir') {
// continue if no regex filter match
if ($filter && !preg_match($filter, $file)) {
continue;
}
$files[] = $prefix . $file;
}
// continue if not recursive
if (!$recursive) {
continue;
}
// read subdirectory
$files = array_merge(
$files,
$this->_list($path . '/' . $file, $prefix . $file . '/', $mode, $recursive, $filter)
);
} else {
// add file
if ($mode === 'file') {
// continue if no regex filter match
if ($filter && !preg_match($filter, $file)) {
continue;
}
$files[] = $prefix.$file;
}
}
}
}
return $files;
} | [
"protected",
"function",
"_list",
"(",
"$",
"path",
",",
"$",
"prefix",
"=",
"''",
",",
"$",
"mode",
"=",
"'file'",
",",
"$",
"recursive",
"=",
"false",
",",
"$",
"filter",
"=",
"null",
")",
"{",
"$",
"files",
"=",
"[",
"]",
";",
"$",
"ignore",
"=",
"[",
"'.'",
",",
"'..'",
",",
"'.DS_Store'",
",",
"'.svn'",
",",
"'.git'",
",",
"'.gitignore'",
",",
"'.gitmodules'",
",",
"'cgi-bin'",
"]",
";",
"if",
"(",
"$",
"scan",
"=",
"@",
"scandir",
"(",
"$",
"path",
")",
")",
"{",
"foreach",
"(",
"$",
"scan",
"as",
"$",
"file",
")",
"{",
"// continue if ignore match",
"if",
"(",
"Arr",
"::",
"in",
"(",
"$",
"file",
",",
"$",
"ignore",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"is_dir",
"(",
"$",
"path",
".",
"'/'",
".",
"$",
"file",
")",
")",
"{",
"// add dir",
"if",
"(",
"$",
"mode",
"===",
"'dir'",
")",
"{",
"// continue if no regex filter match",
"if",
"(",
"$",
"filter",
"&&",
"!",
"preg_match",
"(",
"$",
"filter",
",",
"$",
"file",
")",
")",
"{",
"continue",
";",
"}",
"$",
"files",
"[",
"]",
"=",
"$",
"prefix",
".",
"$",
"file",
";",
"}",
"// continue if not recursive",
"if",
"(",
"!",
"$",
"recursive",
")",
"{",
"continue",
";",
"}",
"// read subdirectory",
"$",
"files",
"=",
"array_merge",
"(",
"$",
"files",
",",
"$",
"this",
"->",
"_list",
"(",
"$",
"path",
".",
"'/'",
".",
"$",
"file",
",",
"$",
"prefix",
".",
"$",
"file",
".",
"'/'",
",",
"$",
"mode",
",",
"$",
"recursive",
",",
"$",
"filter",
")",
")",
";",
"}",
"else",
"{",
"// add file",
"if",
"(",
"$",
"mode",
"===",
"'file'",
")",
"{",
"// continue if no regex filter match",
"if",
"(",
"$",
"filter",
"&&",
"!",
"preg_match",
"(",
"$",
"filter",
",",
"$",
"file",
")",
")",
"{",
"continue",
";",
"}",
"$",
"files",
"[",
"]",
"=",
"$",
"prefix",
".",
"$",
"file",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"files",
";",
"}"
] | Get the list of files or directories in a given path.
@param string $path
@param string $prefix
@param string $mode
@param bool $recursive
@param null $filter
@return array
@SuppressWarnings(PHPMD.CyclomaticComplexity) | [
"Get",
"the",
"list",
"of",
"files",
"or",
"directories",
"in",
"a",
"given",
"path",
"."
] | train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Path/Path.php#L134-L183 |
dandisy/laravel-generator | src/Generators/ModelGenerator.php | ModelGenerator.getPHPDocType | private function getPHPDocType($db_type, $relation = null)
{
switch ($db_type) {
case 'datetime':
return 'string|\Carbon\Carbon';
case 'text':
return 'string';
case '1t1':
case 'mt1':
return '\\'.$this->commandData->config->nsModel.'\\'.$relation->inputs[0].' '.camel_case($relation->inputs[0]);
case '1tm':
return '\Illuminate\Database\Eloquent\Collection'.' '.$relation->inputs[0];
case 'mtm':
case 'hmt':
return '\Illuminate\Database\Eloquent\Collection'.' '.camel_case($relation->inputs[1]);
default:
return $db_type;
}
} | php | private function getPHPDocType($db_type, $relation = null)
{
switch ($db_type) {
case 'datetime':
return 'string|\Carbon\Carbon';
case 'text':
return 'string';
case '1t1':
case 'mt1':
return '\\'.$this->commandData->config->nsModel.'\\'.$relation->inputs[0].' '.camel_case($relation->inputs[0]);
case '1tm':
return '\Illuminate\Database\Eloquent\Collection'.' '.$relation->inputs[0];
case 'mtm':
case 'hmt':
return '\Illuminate\Database\Eloquent\Collection'.' '.camel_case($relation->inputs[1]);
default:
return $db_type;
}
} | [
"private",
"function",
"getPHPDocType",
"(",
"$",
"db_type",
",",
"$",
"relation",
"=",
"null",
")",
"{",
"switch",
"(",
"$",
"db_type",
")",
"{",
"case",
"'datetime'",
":",
"return",
"'string|\\Carbon\\Carbon'",
";",
"case",
"'text'",
":",
"return",
"'string'",
";",
"case",
"'1t1'",
":",
"case",
"'mt1'",
":",
"return",
"'\\\\'",
".",
"$",
"this",
"->",
"commandData",
"->",
"config",
"->",
"nsModel",
".",
"'\\\\'",
".",
"$",
"relation",
"->",
"inputs",
"[",
"0",
"]",
".",
"' '",
".",
"camel_case",
"(",
"$",
"relation",
"->",
"inputs",
"[",
"0",
"]",
")",
";",
"case",
"'1tm'",
":",
"return",
"'\\Illuminate\\Database\\Eloquent\\Collection'",
".",
"' '",
".",
"$",
"relation",
"->",
"inputs",
"[",
"0",
"]",
";",
"case",
"'mtm'",
":",
"case",
"'hmt'",
":",
"return",
"'\\Illuminate\\Database\\Eloquent\\Collection'",
".",
"' '",
".",
"camel_case",
"(",
"$",
"relation",
"->",
"inputs",
"[",
"1",
"]",
")",
";",
"default",
":",
"return",
"$",
"db_type",
";",
"}",
"}"
] | @param $db_type
@param GeneratorFieldRelation|null $relation
@return string | [
"@param",
"$db_type",
"@param",
"GeneratorFieldRelation|null",
"$relation"
] | train | https://github.com/dandisy/laravel-generator/blob/742797c8483bc88b54b6302a516a9a85eeb8579b/src/Generators/ModelGenerator.php#L152-L170 |
webforge-labs/psc-cms | lib/Psc/Doctrine/EntityRelationMeta.php | EntityRelationMeta.getPropertyName | public function getPropertyName() {
if (isset($this->propertyName))
return $this->propertyName;
if ($this->valueType === self::COLLECTION_VALUED) {
// plural muss nach außen, sonst machen wir aus OIDs => oiDs , soll aber oids sein
return Inflector::plural($this->inflector->propertyName($this->getName()));
} else {
return $this->inflector->propertyName($this->getName());
}
} | php | public function getPropertyName() {
if (isset($this->propertyName))
return $this->propertyName;
if ($this->valueType === self::COLLECTION_VALUED) {
// plural muss nach außen, sonst machen wir aus OIDs => oiDs , soll aber oids sein
return Inflector::plural($this->inflector->propertyName($this->getName()));
} else {
return $this->inflector->propertyName($this->getName());
}
} | [
"public",
"function",
"getPropertyName",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"propertyName",
")",
")",
"return",
"$",
"this",
"->",
"propertyName",
";",
"if",
"(",
"$",
"this",
"->",
"valueType",
"===",
"self",
"::",
"COLLECTION_VALUED",
")",
"{",
"// plural muss nach außen, sonst machen wir aus OIDs => oiDs , soll aber oids sein",
"return",
"Inflector",
"::",
"plural",
"(",
"$",
"this",
"->",
"inflector",
"->",
"propertyName",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"inflector",
"->",
"propertyName",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
")",
";",
"}",
"}"
] | Gibt den PHP-Property-Namen für die Entity-Klasse zurück | [
"Gibt",
"den",
"PHP",
"-",
"Property",
"-",
"Namen",
"für",
"die",
"Entity",
"-",
"Klasse",
"zurück"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Doctrine/EntityRelationMeta.php#L96-L106 |
webforge-labs/psc-cms | lib/Psc/Doctrine/EntityRelationMeta.php | EntityRelationMeta.getParamName | public function getParamName() {
if (isset($this->paramName)) {
return $this->paramName;
}
return $this->inflector->propertyName($this->getName());
} | php | public function getParamName() {
if (isset($this->paramName)) {
return $this->paramName;
}
return $this->inflector->propertyName($this->getName());
} | [
"public",
"function",
"getParamName",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"paramName",
")",
")",
"{",
"return",
"$",
"this",
"->",
"paramName",
";",
"}",
"return",
"$",
"this",
"->",
"inflector",
"->",
"propertyName",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
")",
";",
"}"
] | Gibt den PHP Parameter Namen für das Relation Interface
das ist quasi der selbe wie der ProperytName jedoch ist dieser immer singular
OID => oid
OIDMeta => oidMeta
SomeClassName => someClassName
@return string immer in Singular und in property-kleinschreibweise | [
"Gibt",
"den",
"PHP",
"Parameter",
"Namen",
"für",
"das",
"Relation",
"Interface"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Doctrine/EntityRelationMeta.php#L118-L124 |
webforge-labs/psc-cms | lib/Psc/Doctrine/EntityRelationMeta.php | EntityRelationMeta.getMethodName | public function getMethodName($singularOrPlural = 'singular') {
if (!isset($singularOrPlural)) {
$singularOrPlural = $this->getValueType() === self::COLLECTION_VALUED ? 'plural' : 'singular';
}
if (!isset($this->methodName)) {
$this->methodName = array(
$this->getName(),
Inflector::plural($this->getName())
);
}
return $singularOrPlural === 'singular' ? $this->methodName[0] : $this->methodName[1];
} | php | public function getMethodName($singularOrPlural = 'singular') {
if (!isset($singularOrPlural)) {
$singularOrPlural = $this->getValueType() === self::COLLECTION_VALUED ? 'plural' : 'singular';
}
if (!isset($this->methodName)) {
$this->methodName = array(
$this->getName(),
Inflector::plural($this->getName())
);
}
return $singularOrPlural === 'singular' ? $this->methodName[0] : $this->methodName[1];
} | [
"public",
"function",
"getMethodName",
"(",
"$",
"singularOrPlural",
"=",
"'singular'",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"singularOrPlural",
")",
")",
"{",
"$",
"singularOrPlural",
"=",
"$",
"this",
"->",
"getValueType",
"(",
")",
"===",
"self",
"::",
"COLLECTION_VALUED",
"?",
"'plural'",
":",
"'singular'",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"methodName",
")",
")",
"{",
"$",
"this",
"->",
"methodName",
"=",
"array",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
",",
"Inflector",
"::",
"plural",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
")",
")",
";",
"}",
"return",
"$",
"singularOrPlural",
"===",
"'singular'",
"?",
"$",
"this",
"->",
"methodName",
"[",
"0",
"]",
":",
"$",
"this",
"->",
"methodName",
"[",
"1",
"]",
";",
"}"
] | Gibt den Namen für die Methoden des Relation Interfaces zurück
z.B. wird dann verwendet als
OID addOID, removeOID, getOIDs
OIDMeta addOIDMeta, setOIDMeta
SomeClassName addSomeClassName, removeSomeClassName, setSomeClassNames
usw
@return string | [
"Gibt",
"den",
"Namen",
"für",
"die",
"Methoden",
"des",
"Relation",
"Interfaces",
"zurück"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Doctrine/EntityRelationMeta.php#L137-L150 |
webforge-labs/psc-cms | lib/Psc/Doctrine/EntityRelationMeta.php | EntityRelationMeta.setAlias | public function setAlias($name) {
$fc = mb_substr($name,0,1);
if (!$fc === mb_strtoupper($fc)) {
throw new \InvalidArgumentException('SetAlias braucht als Parameter den Alias als wäre er ein großgeschriebener KlassenName. '.Code::varInfo($name));
}
$this->alias = $name;
return $this;
} | php | public function setAlias($name) {
$fc = mb_substr($name,0,1);
if (!$fc === mb_strtoupper($fc)) {
throw new \InvalidArgumentException('SetAlias braucht als Parameter den Alias als wäre er ein großgeschriebener KlassenName. '.Code::varInfo($name));
}
$this->alias = $name;
return $this;
} | [
"public",
"function",
"setAlias",
"(",
"$",
"name",
")",
"{",
"$",
"fc",
"=",
"mb_substr",
"(",
"$",
"name",
",",
"0",
",",
"1",
")",
";",
"if",
"(",
"!",
"$",
"fc",
"===",
"mb_strtoupper",
"(",
"$",
"fc",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'SetAlias braucht als Parameter den Alias als wäre er ein großgeschriebener KlassenName. '.C",
"o",
"de::",
"va",
"rInfo($",
"n",
"a",
"me))",
";",
"",
"",
"}",
"$",
"this",
"->",
"alias",
"=",
"$",
"name",
";",
"return",
"$",
"this",
";",
"}"
] | Setzt Param, Property und Method Name mit dem Alias
@param string $name der Alias in Klassen-GroßSchreibweise z.b. HeadlineSound | [
"Setzt",
"Param",
"Property",
"und",
"Method",
"Name",
"mit",
"dem",
"Alias"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Doctrine/EntityRelationMeta.php#L176-L184 |
webforge-labs/psc-cms | lib/Psc/Doctrine/EntityRelationMeta.php | EntityRelationMeta.getPropertyType | public function getPropertyType() {
if ($this->valueType === self::COLLECTION_VALUED) {
return new PersistentCollectionType($this->gClass);
} else {
return new EntityType($this->gClass);
}
} | php | public function getPropertyType() {
if ($this->valueType === self::COLLECTION_VALUED) {
return new PersistentCollectionType($this->gClass);
} else {
return new EntityType($this->gClass);
}
} | [
"public",
"function",
"getPropertyType",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"valueType",
"===",
"self",
"::",
"COLLECTION_VALUED",
")",
"{",
"return",
"new",
"PersistentCollectionType",
"(",
"$",
"this",
"->",
"gClass",
")",
";",
"}",
"else",
"{",
"return",
"new",
"EntityType",
"(",
"$",
"this",
"->",
"gClass",
")",
";",
"}",
"}"
] | Gibt den Typ des Properties in der Entity-Klasse zurück
@return Webforge\Types\Type | [
"Gibt",
"den",
"Typ",
"des",
"Properties",
"in",
"der",
"Entity",
"-",
"Klasse",
"zurück"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Doctrine/EntityRelationMeta.php#L195-L201 |
uthando-cms/uthando-dompdf | src/UthandoDomPdf/View/Strategy/PdfStrategy.php | PdfStrategy.attach | public function attach(EventManagerInterface $events, $priority = 1)
{
$this->listeners[] = $events->attach(ViewEvent::EVENT_RENDERER, array($this, 'selectRenderer'), $priority);
$this->listeners[] = $events->attach(ViewEvent::EVENT_RESPONSE, array($this, 'injectResponse'), $priority);
} | php | public function attach(EventManagerInterface $events, $priority = 1)
{
$this->listeners[] = $events->attach(ViewEvent::EVENT_RENDERER, array($this, 'selectRenderer'), $priority);
$this->listeners[] = $events->attach(ViewEvent::EVENT_RESPONSE, array($this, 'injectResponse'), $priority);
} | [
"public",
"function",
"attach",
"(",
"EventManagerInterface",
"$",
"events",
",",
"$",
"priority",
"=",
"1",
")",
"{",
"$",
"this",
"->",
"listeners",
"[",
"]",
"=",
"$",
"events",
"->",
"attach",
"(",
"ViewEvent",
"::",
"EVENT_RENDERER",
",",
"array",
"(",
"$",
"this",
",",
"'selectRenderer'",
")",
",",
"$",
"priority",
")",
";",
"$",
"this",
"->",
"listeners",
"[",
"]",
"=",
"$",
"events",
"->",
"attach",
"(",
"ViewEvent",
"::",
"EVENT_RESPONSE",
",",
"array",
"(",
"$",
"this",
",",
"'injectResponse'",
")",
",",
"$",
"priority",
")",
";",
"}"
] | Attach the aggregate to the specified event manager
@param EventManagerInterface $events
@param int $priority
@return void | [
"Attach",
"the",
"aggregate",
"to",
"the",
"specified",
"event",
"manager"
] | train | https://github.com/uthando-cms/uthando-dompdf/blob/60a750058c2db9ed167476192b20c7f544c32007/src/UthandoDomPdf/View/Strategy/PdfStrategy.php#L52-L56 |
uthando-cms/uthando-dompdf | src/UthandoDomPdf/View/Strategy/PdfStrategy.php | PdfStrategy.selectRenderer | public function selectRenderer(ViewEvent $e)
{
$model = $e->getModel();
if ($model instanceof Model\PdfModel) {
return $this->renderer;
}
return;
} | php | public function selectRenderer(ViewEvent $e)
{
$model = $e->getModel();
if ($model instanceof Model\PdfModel) {
return $this->renderer;
}
return;
} | [
"public",
"function",
"selectRenderer",
"(",
"ViewEvent",
"$",
"e",
")",
"{",
"$",
"model",
"=",
"$",
"e",
"->",
"getModel",
"(",
")",
";",
"if",
"(",
"$",
"model",
"instanceof",
"Model",
"\\",
"PdfModel",
")",
"{",
"return",
"$",
"this",
"->",
"renderer",
";",
"}",
"return",
";",
"}"
] | Detect if we should use the PdfRenderer based on model type
@param ViewEvent $e
@return null|PdfRenderer | [
"Detect",
"if",
"we",
"should",
"use",
"the",
"PdfRenderer",
"based",
"on",
"model",
"type"
] | train | https://github.com/uthando-cms/uthando-dompdf/blob/60a750058c2db9ed167476192b20c7f544c32007/src/UthandoDomPdf/View/Strategy/PdfStrategy.php#L64-L73 |
VincentChalnot/SidusAdminBundle | DataGrid/DataGridHelper.php | DataGridHelper.getDataGridConfigCode | public function getDataGridConfigCode(Action $action): string
{
// Check if datagrid code is set in options
return $action->getOption(
'datagrid',
$action->getAdmin()->getOption(
'datagrid',
$action->getAdmin()->getCode() // Fallback to admin code
)
);
} | php | public function getDataGridConfigCode(Action $action): string
{
// Check if datagrid code is set in options
return $action->getOption(
'datagrid',
$action->getAdmin()->getOption(
'datagrid',
$action->getAdmin()->getCode() // Fallback to admin code
)
);
} | [
"public",
"function",
"getDataGridConfigCode",
"(",
"Action",
"$",
"action",
")",
":",
"string",
"{",
"// Check if datagrid code is set in options",
"return",
"$",
"action",
"->",
"getOption",
"(",
"'datagrid'",
",",
"$",
"action",
"->",
"getAdmin",
"(",
")",
"->",
"getOption",
"(",
"'datagrid'",
",",
"$",
"action",
"->",
"getAdmin",
"(",
")",
"->",
"getCode",
"(",
")",
"// Fallback to admin code",
")",
")",
";",
"}"
] | @param Action $action
@return string | [
"@param",
"Action",
"$action"
] | train | https://github.com/VincentChalnot/SidusAdminBundle/blob/3366f3f1525435860cf275ed2f1f0b58cf6eea18/DataGrid/DataGridHelper.php#L61-L71 |
VincentChalnot/SidusAdminBundle | DataGrid/DataGridHelper.php | DataGridHelper.getDataGrid | public function getDataGrid(Action $action): DataGrid
{
return $this->dataGridRegistry->getDataGrid($this->getDataGridConfigCode($action));
} | php | public function getDataGrid(Action $action): DataGrid
{
return $this->dataGridRegistry->getDataGrid($this->getDataGridConfigCode($action));
} | [
"public",
"function",
"getDataGrid",
"(",
"Action",
"$",
"action",
")",
":",
"DataGrid",
"{",
"return",
"$",
"this",
"->",
"dataGridRegistry",
"->",
"getDataGrid",
"(",
"$",
"this",
"->",
"getDataGridConfigCode",
"(",
"$",
"action",
")",
")",
";",
"}"
] | @param Action $action
@return DataGrid | [
"@param",
"Action",
"$action"
] | train | https://github.com/VincentChalnot/SidusAdminBundle/blob/3366f3f1525435860cf275ed2f1f0b58cf6eea18/DataGrid/DataGridHelper.php#L78-L81 |
VincentChalnot/SidusAdminBundle | DataGrid/DataGridHelper.php | DataGridHelper.bindDataGridRequest | public function bindDataGridRequest(
Action $action,
Request $request,
DataGrid $dataGrid = null,
array $formOptions = []
): DataGrid {
$dataGrid = $this->buildDataGridForm($action, $request, $dataGrid, $formOptions);
$dataGrid->handleRequest($request);
return $dataGrid;
} | php | public function bindDataGridRequest(
Action $action,
Request $request,
DataGrid $dataGrid = null,
array $formOptions = []
): DataGrid {
$dataGrid = $this->buildDataGridForm($action, $request, $dataGrid, $formOptions);
$dataGrid->handleRequest($request);
return $dataGrid;
} | [
"public",
"function",
"bindDataGridRequest",
"(",
"Action",
"$",
"action",
",",
"Request",
"$",
"request",
",",
"DataGrid",
"$",
"dataGrid",
"=",
"null",
",",
"array",
"$",
"formOptions",
"=",
"[",
"]",
")",
":",
"DataGrid",
"{",
"$",
"dataGrid",
"=",
"$",
"this",
"->",
"buildDataGridForm",
"(",
"$",
"action",
",",
"$",
"request",
",",
"$",
"dataGrid",
",",
"$",
"formOptions",
")",
";",
"$",
"dataGrid",
"->",
"handleRequest",
"(",
"$",
"request",
")",
";",
"return",
"$",
"dataGrid",
";",
"}"
] | @param Action $action
@param Request $request
@param DataGrid|null $dataGrid
@param array $formOptions
@return DataGrid | [
"@param",
"Action",
"$action",
"@param",
"Request",
"$request",
"@param",
"DataGrid|null",
"$dataGrid",
"@param",
"array",
"$formOptions"
] | train | https://github.com/VincentChalnot/SidusAdminBundle/blob/3366f3f1525435860cf275ed2f1f0b58cf6eea18/DataGrid/DataGridHelper.php#L91-L101 |
VincentChalnot/SidusAdminBundle | DataGrid/DataGridHelper.php | DataGridHelper.buildDataGridForm | public function buildDataGridForm(
Action $action,
Request $request,
DataGrid $dataGrid = null,
array $formOptions = []
): DataGrid {
if (null === $dataGrid) {
$dataGrid = $this->getDataGrid($action);
}
$formOptions = array_merge(
[
'method' => $this->method,
'csrf_protection' => false,
'action' => $this->routingHelper->getCurrentUri($action, $request),
'validation_groups' => ['filters'],
],
$formOptions
);
// Create form with filters
$builder = $this->formFactory->createBuilder(FormType::class, null, $formOptions);
$dataGrid->buildForm($builder);
return $dataGrid;
} | php | public function buildDataGridForm(
Action $action,
Request $request,
DataGrid $dataGrid = null,
array $formOptions = []
): DataGrid {
if (null === $dataGrid) {
$dataGrid = $this->getDataGrid($action);
}
$formOptions = array_merge(
[
'method' => $this->method,
'csrf_protection' => false,
'action' => $this->routingHelper->getCurrentUri($action, $request),
'validation_groups' => ['filters'],
],
$formOptions
);
// Create form with filters
$builder = $this->formFactory->createBuilder(FormType::class, null, $formOptions);
$dataGrid->buildForm($builder);
return $dataGrid;
} | [
"public",
"function",
"buildDataGridForm",
"(",
"Action",
"$",
"action",
",",
"Request",
"$",
"request",
",",
"DataGrid",
"$",
"dataGrid",
"=",
"null",
",",
"array",
"$",
"formOptions",
"=",
"[",
"]",
")",
":",
"DataGrid",
"{",
"if",
"(",
"null",
"===",
"$",
"dataGrid",
")",
"{",
"$",
"dataGrid",
"=",
"$",
"this",
"->",
"getDataGrid",
"(",
"$",
"action",
")",
";",
"}",
"$",
"formOptions",
"=",
"array_merge",
"(",
"[",
"'method'",
"=>",
"$",
"this",
"->",
"method",
",",
"'csrf_protection'",
"=>",
"false",
",",
"'action'",
"=>",
"$",
"this",
"->",
"routingHelper",
"->",
"getCurrentUri",
"(",
"$",
"action",
",",
"$",
"request",
")",
",",
"'validation_groups'",
"=>",
"[",
"'filters'",
"]",
",",
"]",
",",
"$",
"formOptions",
")",
";",
"// Create form with filters",
"$",
"builder",
"=",
"$",
"this",
"->",
"formFactory",
"->",
"createBuilder",
"(",
"FormType",
"::",
"class",
",",
"null",
",",
"$",
"formOptions",
")",
";",
"$",
"dataGrid",
"->",
"buildForm",
"(",
"$",
"builder",
")",
";",
"return",
"$",
"dataGrid",
";",
"}"
] | @param Action $action
@param Request $request
@param DataGrid|null $dataGrid
@param array $formOptions
@return DataGrid | [
"@param",
"Action",
"$action",
"@param",
"Request",
"$request",
"@param",
"DataGrid|null",
"$dataGrid",
"@param",
"array",
"$formOptions"
] | train | https://github.com/VincentChalnot/SidusAdminBundle/blob/3366f3f1525435860cf275ed2f1f0b58cf6eea18/DataGrid/DataGridHelper.php#L111-L135 |
zodream/thirdparty | src/API/Search.php | Search.putBaiDu | public function putBaiDu(array $urls) {
return $this->getBaiDu()->setHeader([
'Content-Type' => 'text/plain'
])->parameters($this->merge([
'urls' => $urls
]))->encode(function ($data) {
return implode("\n", $data['urls']);
})->json();
} | php | public function putBaiDu(array $urls) {
return $this->getBaiDu()->setHeader([
'Content-Type' => 'text/plain'
])->parameters($this->merge([
'urls' => $urls
]))->encode(function ($data) {
return implode("\n", $data['urls']);
})->json();
} | [
"public",
"function",
"putBaiDu",
"(",
"array",
"$",
"urls",
")",
"{",
"return",
"$",
"this",
"->",
"getBaiDu",
"(",
")",
"->",
"setHeader",
"(",
"[",
"'Content-Type'",
"=>",
"'text/plain'",
"]",
")",
"->",
"parameters",
"(",
"$",
"this",
"->",
"merge",
"(",
"[",
"'urls'",
"=>",
"$",
"urls",
"]",
")",
")",
"->",
"encode",
"(",
"function",
"(",
"$",
"data",
")",
"{",
"return",
"implode",
"(",
"\"\\n\"",
",",
"$",
"data",
"[",
"'urls'",
"]",
")",
";",
"}",
")",
"->",
"json",
"(",
")",
";",
"}"
] | INITIATIVE PUT URLS TO BAIDU
@param array $urls
@return array
@throws \Exception | [
"INITIATIVE",
"PUT",
"URLS",
"TO",
"BAIDU"
] | train | https://github.com/zodream/thirdparty/blob/b9d39087913850f1c5c7c9165105fec22a128f8f/src/API/Search.php#L29-L37 |
phpmob/changmin | src/PhpMob/ChangMinBundle/Twig/Extension/SortByExtension.php | SortByExtension.sortBy | public function sortBy($array, $field, $order = 'ASC')
{
if ($array instanceof Collection) {
$array = $array->toArray();
}
if (1 >= count($array)) {
return $array;
}
usort(
$array,
function ($firstElement, $secondElement) use ($field, $order) {
$accessor = PropertyAccess::createPropertyAccessor();
$firstProperty = (string)$accessor->getValue($firstElement, $field);
$secondProperty = (string)$accessor->getValue($secondElement, $field);
$result = strcasecmp($firstProperty, $secondProperty);
if ('DESC' === $order) {
$result *= -1;
}
return $result;
}
);
return $array;
} | php | public function sortBy($array, $field, $order = 'ASC')
{
if ($array instanceof Collection) {
$array = $array->toArray();
}
if (1 >= count($array)) {
return $array;
}
usort(
$array,
function ($firstElement, $secondElement) use ($field, $order) {
$accessor = PropertyAccess::createPropertyAccessor();
$firstProperty = (string)$accessor->getValue($firstElement, $field);
$secondProperty = (string)$accessor->getValue($secondElement, $field);
$result = strcasecmp($firstProperty, $secondProperty);
if ('DESC' === $order) {
$result *= -1;
}
return $result;
}
);
return $array;
} | [
"public",
"function",
"sortBy",
"(",
"$",
"array",
",",
"$",
"field",
",",
"$",
"order",
"=",
"'ASC'",
")",
"{",
"if",
"(",
"$",
"array",
"instanceof",
"Collection",
")",
"{",
"$",
"array",
"=",
"$",
"array",
"->",
"toArray",
"(",
")",
";",
"}",
"if",
"(",
"1",
">=",
"count",
"(",
"$",
"array",
")",
")",
"{",
"return",
"$",
"array",
";",
"}",
"usort",
"(",
"$",
"array",
",",
"function",
"(",
"$",
"firstElement",
",",
"$",
"secondElement",
")",
"use",
"(",
"$",
"field",
",",
"$",
"order",
")",
"{",
"$",
"accessor",
"=",
"PropertyAccess",
"::",
"createPropertyAccessor",
"(",
")",
";",
"$",
"firstProperty",
"=",
"(",
"string",
")",
"$",
"accessor",
"->",
"getValue",
"(",
"$",
"firstElement",
",",
"$",
"field",
")",
";",
"$",
"secondProperty",
"=",
"(",
"string",
")",
"$",
"accessor",
"->",
"getValue",
"(",
"$",
"secondElement",
",",
"$",
"field",
")",
";",
"$",
"result",
"=",
"strcasecmp",
"(",
"$",
"firstProperty",
",",
"$",
"secondProperty",
")",
";",
"if",
"(",
"'DESC'",
"===",
"$",
"order",
")",
"{",
"$",
"result",
"*=",
"-",
"1",
";",
"}",
"return",
"$",
"result",
";",
"}",
")",
";",
"return",
"$",
"array",
";",
"}"
] | @param array|Collection $array
@param string $field
@param string $order
@return array
@throws NoSuchPropertyException | [
"@param",
"array|Collection",
"$array",
"@param",
"string",
"$field",
"@param",
"string",
"$order"
] | train | https://github.com/phpmob/changmin/blob/bfebb1561229094d1c138574abab75f2f1d17d66/src/PhpMob/ChangMinBundle/Twig/Extension/SortByExtension.php#L44-L71 |
parsnick/steak | src/Boot/RegisterCoreBindings.php | RegisterCoreBindings.boot | public function boot(Container $app)
{
$app->singleton('files', Filesystem::class);
$app->singleton('events', function ($app) {
return new Dispatcher($app);
});
$app->bind(Builder::class, function ($app) {
return new Builder($app, $app['config']['build.pipeline']);
});
$app->bind(Factory::class, function ($app)
{
$engineResolver = $app->make(EngineResolver::class);
$viewFinder = $app->make(FileViewFinder::class, [
$app['files'],
[
$app['config']['source.directory']
]
]);
return new Factory($engineResolver, $viewFinder, $app['events']);
});
$this->bindAliasesForPipeline($app);
} | php | public function boot(Container $app)
{
$app->singleton('files', Filesystem::class);
$app->singleton('events', function ($app) {
return new Dispatcher($app);
});
$app->bind(Builder::class, function ($app) {
return new Builder($app, $app['config']['build.pipeline']);
});
$app->bind(Factory::class, function ($app)
{
$engineResolver = $app->make(EngineResolver::class);
$viewFinder = $app->make(FileViewFinder::class, [
$app['files'],
[
$app['config']['source.directory']
]
]);
return new Factory($engineResolver, $viewFinder, $app['events']);
});
$this->bindAliasesForPipeline($app);
} | [
"public",
"function",
"boot",
"(",
"Container",
"$",
"app",
")",
"{",
"$",
"app",
"->",
"singleton",
"(",
"'files'",
",",
"Filesystem",
"::",
"class",
")",
";",
"$",
"app",
"->",
"singleton",
"(",
"'events'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"Dispatcher",
"(",
"$",
"app",
")",
";",
"}",
")",
";",
"$",
"app",
"->",
"bind",
"(",
"Builder",
"::",
"class",
",",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"Builder",
"(",
"$",
"app",
",",
"$",
"app",
"[",
"'config'",
"]",
"[",
"'build.pipeline'",
"]",
")",
";",
"}",
")",
";",
"$",
"app",
"->",
"bind",
"(",
"Factory",
"::",
"class",
",",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"engineResolver",
"=",
"$",
"app",
"->",
"make",
"(",
"EngineResolver",
"::",
"class",
")",
";",
"$",
"viewFinder",
"=",
"$",
"app",
"->",
"make",
"(",
"FileViewFinder",
"::",
"class",
",",
"[",
"$",
"app",
"[",
"'files'",
"]",
",",
"[",
"$",
"app",
"[",
"'config'",
"]",
"[",
"'source.directory'",
"]",
"]",
"]",
")",
";",
"return",
"new",
"Factory",
"(",
"$",
"engineResolver",
",",
"$",
"viewFinder",
",",
"$",
"app",
"[",
"'events'",
"]",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"bindAliasesForPipeline",
"(",
"$",
"app",
")",
";",
"}"
] | Set up required container bindings.
@param Container $app | [
"Set",
"up",
"required",
"container",
"bindings",
"."
] | train | https://github.com/parsnick/steak/blob/461869189a640938438187330f6c50aca97c5ccc/src/Boot/RegisterCoreBindings.php#L22-L49 |
chocoboxxf/yii2-alidayu-sdk | src/Alidayu.php | Alidayu.AxbBind | public function AxbBind($phoneA, $phoneB, $endDate, $otherCall = false, $needRecord = false)
{
// 公共参数
$data = [
'app_key' => $this->appKey,
'timestamp' => $this->getTimestamp(),
'format' => $this->format,
'v' => $this->appVersion,
'sign_method' => $this->signMethod,
'method' => Alidayu::API_ALIBABA_ALIQIN_SECRET_AXB_BIND,
];
// 入参
$data['partner_key'] = $this->partnerKey;
$data['phone_no_a'] = $phoneA;
$data['end_date'] = $endDate;
$data['enable_other_call'] = $otherCall ? 'true' : 'false';
$data['need_record'] = $needRecord ? 'true' : 'false';
$data['phone_no_b'] = $phoneB;
// 签名
$signature = $this->getSignature($data, $this->signMethod);
$data['sign'] = $signature;
// 请求
return $this->post('', $data);
} | php | public function AxbBind($phoneA, $phoneB, $endDate, $otherCall = false, $needRecord = false)
{
// 公共参数
$data = [
'app_key' => $this->appKey,
'timestamp' => $this->getTimestamp(),
'format' => $this->format,
'v' => $this->appVersion,
'sign_method' => $this->signMethod,
'method' => Alidayu::API_ALIBABA_ALIQIN_SECRET_AXB_BIND,
];
// 入参
$data['partner_key'] = $this->partnerKey;
$data['phone_no_a'] = $phoneA;
$data['end_date'] = $endDate;
$data['enable_other_call'] = $otherCall ? 'true' : 'false';
$data['need_record'] = $needRecord ? 'true' : 'false';
$data['phone_no_b'] = $phoneB;
// 签名
$signature = $this->getSignature($data, $this->signMethod);
$data['sign'] = $signature;
// 请求
return $this->post('', $data);
} | [
"public",
"function",
"AxbBind",
"(",
"$",
"phoneA",
",",
"$",
"phoneB",
",",
"$",
"endDate",
",",
"$",
"otherCall",
"=",
"false",
",",
"$",
"needRecord",
"=",
"false",
")",
"{",
"// 公共参数",
"$",
"data",
"=",
"[",
"'app_key'",
"=>",
"$",
"this",
"->",
"appKey",
",",
"'timestamp'",
"=>",
"$",
"this",
"->",
"getTimestamp",
"(",
")",
",",
"'format'",
"=>",
"$",
"this",
"->",
"format",
",",
"'v'",
"=>",
"$",
"this",
"->",
"appVersion",
",",
"'sign_method'",
"=>",
"$",
"this",
"->",
"signMethod",
",",
"'method'",
"=>",
"Alidayu",
"::",
"API_ALIBABA_ALIQIN_SECRET_AXB_BIND",
",",
"]",
";",
"// 入参",
"$",
"data",
"[",
"'partner_key'",
"]",
"=",
"$",
"this",
"->",
"partnerKey",
";",
"$",
"data",
"[",
"'phone_no_a'",
"]",
"=",
"$",
"phoneA",
";",
"$",
"data",
"[",
"'end_date'",
"]",
"=",
"$",
"endDate",
";",
"$",
"data",
"[",
"'enable_other_call'",
"]",
"=",
"$",
"otherCall",
"?",
"'true'",
":",
"'false'",
";",
"$",
"data",
"[",
"'need_record'",
"]",
"=",
"$",
"needRecord",
"?",
"'true'",
":",
"'false'",
";",
"$",
"data",
"[",
"'phone_no_b'",
"]",
"=",
"$",
"phoneB",
";",
"// 签名",
"$",
"signature",
"=",
"$",
"this",
"->",
"getSignature",
"(",
"$",
"data",
",",
"$",
"this",
"->",
"signMethod",
")",
";",
"$",
"data",
"[",
"'sign'",
"]",
"=",
"$",
"signature",
";",
"// 请求",
"return",
"$",
"this",
"->",
"post",
"(",
"''",
",",
"$",
"data",
")",
";",
"}"
] | AXB(AXN)一次绑定接口
绑定接口用于实现真实号码和虚拟号码之间的绑定关系,只有在完成绑定以后用户才可以使用虚拟号码的基本通信能力。
@param string $phoneA 号码A
@param string $phoneB 号码B(AXB模式下必填,AXN模式下任意填写)
@param string $endDate 到期自动解绑时间(YYYY-mm-dd HH:MM:SS)
@param bool|false $otherCall 第三方是否可拨打X转接到号码A
@param bool|false $needRecord 是否需要录音
@return mixed
@throws GuzzleException | [
"AXB",
"(",
"AXN",
")",
"一次绑定接口",
"绑定接口用于实现真实号码和虚拟号码之间的绑定关系,只有在完成绑定以后用户才可以使用虚拟号码的基本通信能力。"
] | train | https://github.com/chocoboxxf/yii2-alidayu-sdk/blob/47cbc4f5ac1e9378ae4ec4765bdd8802cac9e22f/src/Alidayu.php#L136-L161 |
chocoboxxf/yii2-alidayu-sdk | src/Alidayu.php | Alidayu.AxbBindSecond | public function AxbBindSecond($subsId, $phoneB, $endDate, $otherCall = false, $needRecord = false)
{
// 公共参数
$data = [
'app_key' => $this->appKey,
'timestamp' => $this->getTimestamp(),
'format' => $this->format,
'v' => $this->appVersion,
'sign_method' => $this->signMethod,
'method' => Alidayu::API_ALIBABA_ALIQIN_SECRET_AXB_BIND_SECOND,
];
// 入参
$data['partner_key'] = $this->partnerKey;
$data['subs_id'] = $subsId;
$data['phone_no_b'] = $phoneB;
$data['end_date'] = $endDate;
$data['enable_other_call'] = $otherCall ? 'true' : 'false';
$data['need_record'] = $needRecord ? 'true' : 'false';
// 签名
$signature = $this->getSignature($data, $this->signMethod);
$data['sign'] = $signature;
// 请求
return $this->post('', $data);
} | php | public function AxbBindSecond($subsId, $phoneB, $endDate, $otherCall = false, $needRecord = false)
{
// 公共参数
$data = [
'app_key' => $this->appKey,
'timestamp' => $this->getTimestamp(),
'format' => $this->format,
'v' => $this->appVersion,
'sign_method' => $this->signMethod,
'method' => Alidayu::API_ALIBABA_ALIQIN_SECRET_AXB_BIND_SECOND,
];
// 入参
$data['partner_key'] = $this->partnerKey;
$data['subs_id'] = $subsId;
$data['phone_no_b'] = $phoneB;
$data['end_date'] = $endDate;
$data['enable_other_call'] = $otherCall ? 'true' : 'false';
$data['need_record'] = $needRecord ? 'true' : 'false';
// 签名
$signature = $this->getSignature($data, $this->signMethod);
$data['sign'] = $signature;
// 请求
return $this->post('', $data);
} | [
"public",
"function",
"AxbBindSecond",
"(",
"$",
"subsId",
",",
"$",
"phoneB",
",",
"$",
"endDate",
",",
"$",
"otherCall",
"=",
"false",
",",
"$",
"needRecord",
"=",
"false",
")",
"{",
"// 公共参数",
"$",
"data",
"=",
"[",
"'app_key'",
"=>",
"$",
"this",
"->",
"appKey",
",",
"'timestamp'",
"=>",
"$",
"this",
"->",
"getTimestamp",
"(",
")",
",",
"'format'",
"=>",
"$",
"this",
"->",
"format",
",",
"'v'",
"=>",
"$",
"this",
"->",
"appVersion",
",",
"'sign_method'",
"=>",
"$",
"this",
"->",
"signMethod",
",",
"'method'",
"=>",
"Alidayu",
"::",
"API_ALIBABA_ALIQIN_SECRET_AXB_BIND_SECOND",
",",
"]",
";",
"// 入参",
"$",
"data",
"[",
"'partner_key'",
"]",
"=",
"$",
"this",
"->",
"partnerKey",
";",
"$",
"data",
"[",
"'subs_id'",
"]",
"=",
"$",
"subsId",
";",
"$",
"data",
"[",
"'phone_no_b'",
"]",
"=",
"$",
"phoneB",
";",
"$",
"data",
"[",
"'end_date'",
"]",
"=",
"$",
"endDate",
";",
"$",
"data",
"[",
"'enable_other_call'",
"]",
"=",
"$",
"otherCall",
"?",
"'true'",
":",
"'false'",
";",
"$",
"data",
"[",
"'need_record'",
"]",
"=",
"$",
"needRecord",
"?",
"'true'",
":",
"'false'",
";",
"// 签名",
"$",
"signature",
"=",
"$",
"this",
"->",
"getSignature",
"(",
"$",
"data",
",",
"$",
"this",
"->",
"signMethod",
")",
";",
"$",
"data",
"[",
"'sign'",
"]",
"=",
"$",
"signature",
";",
"// 请求",
"return",
"$",
"this",
"->",
"post",
"(",
"''",
",",
"$",
"data",
")",
";",
"}"
] | AXN二次绑定接口
二次绑定接口用户确认,AX与B之间的关系,在一次绑定接口调用的基础上,再通过调用二次绑定接口,最终形成A与B之间的关系。
@param string $subsId 绑定关系ID
@param string $phoneB 号码B
@param string $endDate 到期自动解绑时间(YYYY-mm-dd HH:MM:SS)
@param bool|false $otherCall 第三方是否可拨打X转接到号码A
@param bool|false $needRecord 是否需要录音
@return mixed
@throws GuzzleException | [
"AXN二次绑定接口",
"二次绑定接口用户确认,AX与B之间的关系,在一次绑定接口调用的基础上,再通过调用二次绑定接口,最终形成A与B之间的关系。"
] | train | https://github.com/chocoboxxf/yii2-alidayu-sdk/blob/47cbc4f5ac1e9378ae4ec4765bdd8802cac9e22f/src/Alidayu.php#L174-L199 |
chocoboxxf/yii2-alidayu-sdk | src/Alidayu.php | Alidayu.AxbUnbind | public function AxbUnbind($subsId)
{
// 公共参数
$data = [
'app_key' => $this->appKey,
'timestamp' => $this->getTimestamp(),
'format' => $this->format,
'v' => $this->appVersion,
'sign_method' => $this->signMethod,
'method' => Alidayu::API_ALIBABA_ALIQIN_SECRET_AXB_UNBIND,
];
// 入参
$data['partner_key'] = $this->partnerKey;
$data['subs_id'] = $subsId;
// 签名
$signature = $this->getSignature($data, $this->signMethod);
$data['sign'] = $signature;
// 请求
return $this->post('', $data);
} | php | public function AxbUnbind($subsId)
{
// 公共参数
$data = [
'app_key' => $this->appKey,
'timestamp' => $this->getTimestamp(),
'format' => $this->format,
'v' => $this->appVersion,
'sign_method' => $this->signMethod,
'method' => Alidayu::API_ALIBABA_ALIQIN_SECRET_AXB_UNBIND,
];
// 入参
$data['partner_key'] = $this->partnerKey;
$data['subs_id'] = $subsId;
// 签名
$signature = $this->getSignature($data, $this->signMethod);
$data['sign'] = $signature;
// 请求
return $this->post('', $data);
} | [
"public",
"function",
"AxbUnbind",
"(",
"$",
"subsId",
")",
"{",
"// 公共参数",
"$",
"data",
"=",
"[",
"'app_key'",
"=>",
"$",
"this",
"->",
"appKey",
",",
"'timestamp'",
"=>",
"$",
"this",
"->",
"getTimestamp",
"(",
")",
",",
"'format'",
"=>",
"$",
"this",
"->",
"format",
",",
"'v'",
"=>",
"$",
"this",
"->",
"appVersion",
",",
"'sign_method'",
"=>",
"$",
"this",
"->",
"signMethod",
",",
"'method'",
"=>",
"Alidayu",
"::",
"API_ALIBABA_ALIQIN_SECRET_AXB_UNBIND",
",",
"]",
";",
"// 入参",
"$",
"data",
"[",
"'partner_key'",
"]",
"=",
"$",
"this",
"->",
"partnerKey",
";",
"$",
"data",
"[",
"'subs_id'",
"]",
"=",
"$",
"subsId",
";",
"// 签名",
"$",
"signature",
"=",
"$",
"this",
"->",
"getSignature",
"(",
"$",
"data",
",",
"$",
"this",
"->",
"signMethod",
")",
";",
"$",
"data",
"[",
"'sign'",
"]",
"=",
"$",
"signature",
";",
"// 请求",
"return",
"$",
"this",
"->",
"post",
"(",
"''",
",",
"$",
"data",
")",
";",
"}"
] | AXB(AXN)关系解绑接口
通过该接口,实现AXB三元关系的解绑,解绑过后,再通过呼叫X,将不能找到A或者B。
@param string $subsId 绑定关系ID
@return mixed
@throws GuzzleException | [
"AXB",
"(",
"AXN",
")",
"关系解绑接口",
"通过该接口,实现AXB三元关系的解绑,解绑过后,再通过呼叫X,将不能找到A或者B。"
] | train | https://github.com/chocoboxxf/yii2-alidayu-sdk/blob/47cbc4f5ac1e9378ae4ec4765bdd8802cac9e22f/src/Alidayu.php#L208-L229 |
chocoboxxf/yii2-alidayu-sdk | src/Alidayu.php | Alidayu.smsSend | public function smsSend($recNum, $templateCode, $signName, $smsType = 'normal', $param = [], $extend = '')
{
// 公共参数
$data = [
'app_key' => $this->appKey,
'timestamp' => $this->getTimestamp(),
'format' => $this->format,
'v' => $this->appVersion,
'sign_method' => $this->signMethod,
'method' => Alidayu::API_ALIBABA_ALIQIN_FC_SMS_NUM_SEND,
];
// 入参
$data['rec_num'] = $recNum;
$data['sms_template_code'] = $templateCode;
$data['sms_free_sign_name'] = $signName;
$data['sms_type'] = $smsType;
if (count($param) > 0) {
$data['sms_param'] = json_encode($param);
}
if ($extend !== '') {
$data['extend'] = $extend;
}
// 签名
$signature = $this->getSignature($data, $this->signMethod);
$data['sign'] = $signature;
// 请求
return $this->post('', $data);
} | php | public function smsSend($recNum, $templateCode, $signName, $smsType = 'normal', $param = [], $extend = '')
{
// 公共参数
$data = [
'app_key' => $this->appKey,
'timestamp' => $this->getTimestamp(),
'format' => $this->format,
'v' => $this->appVersion,
'sign_method' => $this->signMethod,
'method' => Alidayu::API_ALIBABA_ALIQIN_FC_SMS_NUM_SEND,
];
// 入参
$data['rec_num'] = $recNum;
$data['sms_template_code'] = $templateCode;
$data['sms_free_sign_name'] = $signName;
$data['sms_type'] = $smsType;
if (count($param) > 0) {
$data['sms_param'] = json_encode($param);
}
if ($extend !== '') {
$data['extend'] = $extend;
}
// 签名
$signature = $this->getSignature($data, $this->signMethod);
$data['sign'] = $signature;
// 请求
return $this->post('', $data);
} | [
"public",
"function",
"smsSend",
"(",
"$",
"recNum",
",",
"$",
"templateCode",
",",
"$",
"signName",
",",
"$",
"smsType",
"=",
"'normal'",
",",
"$",
"param",
"=",
"[",
"]",
",",
"$",
"extend",
"=",
"''",
")",
"{",
"// 公共参数",
"$",
"data",
"=",
"[",
"'app_key'",
"=>",
"$",
"this",
"->",
"appKey",
",",
"'timestamp'",
"=>",
"$",
"this",
"->",
"getTimestamp",
"(",
")",
",",
"'format'",
"=>",
"$",
"this",
"->",
"format",
",",
"'v'",
"=>",
"$",
"this",
"->",
"appVersion",
",",
"'sign_method'",
"=>",
"$",
"this",
"->",
"signMethod",
",",
"'method'",
"=>",
"Alidayu",
"::",
"API_ALIBABA_ALIQIN_FC_SMS_NUM_SEND",
",",
"]",
";",
"// 入参",
"$",
"data",
"[",
"'rec_num'",
"]",
"=",
"$",
"recNum",
";",
"$",
"data",
"[",
"'sms_template_code'",
"]",
"=",
"$",
"templateCode",
";",
"$",
"data",
"[",
"'sms_free_sign_name'",
"]",
"=",
"$",
"signName",
";",
"$",
"data",
"[",
"'sms_type'",
"]",
"=",
"$",
"smsType",
";",
"if",
"(",
"count",
"(",
"$",
"param",
")",
">",
"0",
")",
"{",
"$",
"data",
"[",
"'sms_param'",
"]",
"=",
"json_encode",
"(",
"$",
"param",
")",
";",
"}",
"if",
"(",
"$",
"extend",
"!==",
"''",
")",
"{",
"$",
"data",
"[",
"'extend'",
"]",
"=",
"$",
"extend",
";",
"}",
"// 签名",
"$",
"signature",
"=",
"$",
"this",
"->",
"getSignature",
"(",
"$",
"data",
",",
"$",
"this",
"->",
"signMethod",
")",
";",
"$",
"data",
"[",
"'sign'",
"]",
"=",
"$",
"signature",
";",
"// 请求",
"return",
"$",
"this",
"->",
"post",
"(",
"''",
",",
"$",
"data",
")",
";",
"}"
] | 短信发送
@param string $recNum 短信接收号码。支持单个或多个手机号码,群发短信需传入多个号码,以英文逗号分隔,一次调用最多传入200个号码。
@param string $templateCode 短信模板ID,传入的模板必须是在阿里大于“管理中心-短信模板管理”中的可用模板。
@param string $signName 短信签名,传入的短信签名必须是在阿里大于“管理中心-短信签名管理”中的可用签名。
@param string $smsType 短信类型,传入值请填写normal
@param array $param 短信模板变量,传参规则{"key":"value"},key的名字须和申请模板中的变量名一致,多个变量之间以逗号隔开。
@param string $extend 公共回传参数,在“消息返回”中会透传回该参数
@return mixed
@throws GuzzleException | [
"短信发送"
] | train | https://github.com/chocoboxxf/yii2-alidayu-sdk/blob/47cbc4f5ac1e9378ae4ec4765bdd8802cac9e22f/src/Alidayu.php#L242-L271 |
chocoboxxf/yii2-alidayu-sdk | src/Alidayu.php | Alidayu.smsQuery | public function smsQuery($recNum, $queryDate, $currentPage = 1, $pageSize = 50, $bizId = '')
{
// 公共参数
$data = [
'app_key' => $this->appKey,
'timestamp' => $this->getTimestamp(),
'format' => $this->format,
'v' => $this->appVersion,
'sign_method' => $this->signMethod,
'method' => Alidayu::API_ALIBABA_ALIQIN_FC_SMS_NUM_QUERY,
];
// 入参
$data['rec_num'] = $recNum;
$data['query_date'] = $queryDate;
$data['current_page'] = $currentPage;
$data['page_size'] = $pageSize;
if ($bizId !== '') {
$data['biz_id'] = $bizId;
}
// 签名
$signature = $this->getSignature($data, $this->signMethod);
$data['sign'] = $signature;
// 请求
return $this->post('', $data);
} | php | public function smsQuery($recNum, $queryDate, $currentPage = 1, $pageSize = 50, $bizId = '')
{
// 公共参数
$data = [
'app_key' => $this->appKey,
'timestamp' => $this->getTimestamp(),
'format' => $this->format,
'v' => $this->appVersion,
'sign_method' => $this->signMethod,
'method' => Alidayu::API_ALIBABA_ALIQIN_FC_SMS_NUM_QUERY,
];
// 入参
$data['rec_num'] = $recNum;
$data['query_date'] = $queryDate;
$data['current_page'] = $currentPage;
$data['page_size'] = $pageSize;
if ($bizId !== '') {
$data['biz_id'] = $bizId;
}
// 签名
$signature = $this->getSignature($data, $this->signMethod);
$data['sign'] = $signature;
// 请求
return $this->post('', $data);
} | [
"public",
"function",
"smsQuery",
"(",
"$",
"recNum",
",",
"$",
"queryDate",
",",
"$",
"currentPage",
"=",
"1",
",",
"$",
"pageSize",
"=",
"50",
",",
"$",
"bizId",
"=",
"''",
")",
"{",
"// 公共参数",
"$",
"data",
"=",
"[",
"'app_key'",
"=>",
"$",
"this",
"->",
"appKey",
",",
"'timestamp'",
"=>",
"$",
"this",
"->",
"getTimestamp",
"(",
")",
",",
"'format'",
"=>",
"$",
"this",
"->",
"format",
",",
"'v'",
"=>",
"$",
"this",
"->",
"appVersion",
",",
"'sign_method'",
"=>",
"$",
"this",
"->",
"signMethod",
",",
"'method'",
"=>",
"Alidayu",
"::",
"API_ALIBABA_ALIQIN_FC_SMS_NUM_QUERY",
",",
"]",
";",
"// 入参",
"$",
"data",
"[",
"'rec_num'",
"]",
"=",
"$",
"recNum",
";",
"$",
"data",
"[",
"'query_date'",
"]",
"=",
"$",
"queryDate",
";",
"$",
"data",
"[",
"'current_page'",
"]",
"=",
"$",
"currentPage",
";",
"$",
"data",
"[",
"'page_size'",
"]",
"=",
"$",
"pageSize",
";",
"if",
"(",
"$",
"bizId",
"!==",
"''",
")",
"{",
"$",
"data",
"[",
"'biz_id'",
"]",
"=",
"$",
"bizId",
";",
"}",
"// 签名",
"$",
"signature",
"=",
"$",
"this",
"->",
"getSignature",
"(",
"$",
"data",
",",
"$",
"this",
"->",
"signMethod",
")",
";",
"$",
"data",
"[",
"'sign'",
"]",
"=",
"$",
"signature",
";",
"// 请求",
"return",
"$",
"this",
"->",
"post",
"(",
"''",
",",
"$",
"data",
")",
";",
"}"
] | 短信发送记录查询
@param string $recNum 短信接收号码
@param string $queryDate 短信发送日期,支持近30天记录查询,格式yyyyMMdd
@param int $currentPage 分页参数,页码
@param int $pageSize 分页参数,每页数量。最大值50
@param string $bizId 短信发送流水,同发送结果中model值
@return mixed
@throws GuzzleException | [
"短信发送记录查询"
] | train | https://github.com/chocoboxxf/yii2-alidayu-sdk/blob/47cbc4f5ac1e9378ae4ec4765bdd8802cac9e22f/src/Alidayu.php#L283-L309 |
chocoboxxf/yii2-alidayu-sdk | src/Alidayu.php | Alidayu.ttsSingleCall | public function ttsSingleCall($calledNum, $ttsCode, $calledShowNum, $param = [], $extend = '')
{
// 公共参数
$data = [
'app_key' => $this->appKey,
'timestamp' => $this->getTimestamp(),
'format' => $this->format,
'v' => $this->appVersion,
'sign_method' => $this->signMethod,
'method' => Alidayu::API_ALIBABA_ALIQIN_FC_TTS_NUM_SINGLECALL,
];
// 入参
$data['called_num'] = $calledNum;
$data['tts_code'] = $ttsCode;
$data['called_show_num'] = $calledShowNum;
if (count($param) > 0) {
$data['tts_param'] = json_encode($param);
}
if ($extend !== '') {
$data['extend'] = $extend;
}
// 签名
$signature = $this->getSignature($data, $this->signMethod);
$data['sign'] = $signature;
// 请求
return $this->post('', $data);
} | php | public function ttsSingleCall($calledNum, $ttsCode, $calledShowNum, $param = [], $extend = '')
{
// 公共参数
$data = [
'app_key' => $this->appKey,
'timestamp' => $this->getTimestamp(),
'format' => $this->format,
'v' => $this->appVersion,
'sign_method' => $this->signMethod,
'method' => Alidayu::API_ALIBABA_ALIQIN_FC_TTS_NUM_SINGLECALL,
];
// 入参
$data['called_num'] = $calledNum;
$data['tts_code'] = $ttsCode;
$data['called_show_num'] = $calledShowNum;
if (count($param) > 0) {
$data['tts_param'] = json_encode($param);
}
if ($extend !== '') {
$data['extend'] = $extend;
}
// 签名
$signature = $this->getSignature($data, $this->signMethod);
$data['sign'] = $signature;
// 请求
return $this->post('', $data);
} | [
"public",
"function",
"ttsSingleCall",
"(",
"$",
"calledNum",
",",
"$",
"ttsCode",
",",
"$",
"calledShowNum",
",",
"$",
"param",
"=",
"[",
"]",
",",
"$",
"extend",
"=",
"''",
")",
"{",
"// 公共参数",
"$",
"data",
"=",
"[",
"'app_key'",
"=>",
"$",
"this",
"->",
"appKey",
",",
"'timestamp'",
"=>",
"$",
"this",
"->",
"getTimestamp",
"(",
")",
",",
"'format'",
"=>",
"$",
"this",
"->",
"format",
",",
"'v'",
"=>",
"$",
"this",
"->",
"appVersion",
",",
"'sign_method'",
"=>",
"$",
"this",
"->",
"signMethod",
",",
"'method'",
"=>",
"Alidayu",
"::",
"API_ALIBABA_ALIQIN_FC_TTS_NUM_SINGLECALL",
",",
"]",
";",
"// 入参",
"$",
"data",
"[",
"'called_num'",
"]",
"=",
"$",
"calledNum",
";",
"$",
"data",
"[",
"'tts_code'",
"]",
"=",
"$",
"ttsCode",
";",
"$",
"data",
"[",
"'called_show_num'",
"]",
"=",
"$",
"calledShowNum",
";",
"if",
"(",
"count",
"(",
"$",
"param",
")",
">",
"0",
")",
"{",
"$",
"data",
"[",
"'tts_param'",
"]",
"=",
"json_encode",
"(",
"$",
"param",
")",
";",
"}",
"if",
"(",
"$",
"extend",
"!==",
"''",
")",
"{",
"$",
"data",
"[",
"'extend'",
"]",
"=",
"$",
"extend",
";",
"}",
"// 签名",
"$",
"signature",
"=",
"$",
"this",
"->",
"getSignature",
"(",
"$",
"data",
",",
"$",
"this",
"->",
"signMethod",
")",
";",
"$",
"data",
"[",
"'sign'",
"]",
"=",
"$",
"signature",
";",
"// 请求",
"return",
"$",
"this",
"->",
"post",
"(",
"''",
",",
"$",
"data",
")",
";",
"}"
] | 文本转语音通知
@param string $calledNum 被叫号码,支持国内手机号与固话号码
@param string $ttsCode TTS模板ID,传入的模板必须是在阿里大于“管理中心-语音TTS模板管理”中的可用模板
@param string $calledShowNum 被叫号显,传入的显示号码必须是阿里大于“管理中心-号码管理”中申请或购买的号码
@param array $param 文本转语音(TTS)模板变量,传参规则{"key":"value"},key的名字须和TTS模板中的变量名一致
@param string $extend 公共回传参数,在“消息返回”中会透传回该参数
@return mixed
@throws GuzzleException | [
"文本转语音通知"
] | train | https://github.com/chocoboxxf/yii2-alidayu-sdk/blob/47cbc4f5ac1e9378ae4ec4765bdd8802cac9e22f/src/Alidayu.php#L321-L349 |
chocoboxxf/yii2-alidayu-sdk | src/Alidayu.php | Alidayu.getSignature | public function getSignature($params = [], $method = Alidayu::SIGN_METHOD_HMAC)
{
$rawQuery = [];
ksort($params);
foreach ($params as $k => $v) {
$rawQuery[] = sprintf('%s%s', $k, $v);
}
$rawText = implode('', $rawQuery);
$signature = '';
if ($method === Alidayu::SIGN_METHOD_MD5) {
$signature = md5($this->appSecret . $rawText . $this->appSecret);
} elseif ($method === Alidayu::SIGN_METHOD_HMAC) {
$signature = hash_hmac('md5', $rawText, $this->appSecret);
}
return strtoupper($signature);
} | php | public function getSignature($params = [], $method = Alidayu::SIGN_METHOD_HMAC)
{
$rawQuery = [];
ksort($params);
foreach ($params as $k => $v) {
$rawQuery[] = sprintf('%s%s', $k, $v);
}
$rawText = implode('', $rawQuery);
$signature = '';
if ($method === Alidayu::SIGN_METHOD_MD5) {
$signature = md5($this->appSecret . $rawText . $this->appSecret);
} elseif ($method === Alidayu::SIGN_METHOD_HMAC) {
$signature = hash_hmac('md5', $rawText, $this->appSecret);
}
return strtoupper($signature);
} | [
"public",
"function",
"getSignature",
"(",
"$",
"params",
"=",
"[",
"]",
",",
"$",
"method",
"=",
"Alidayu",
"::",
"SIGN_METHOD_HMAC",
")",
"{",
"$",
"rawQuery",
"=",
"[",
"]",
";",
"ksort",
"(",
"$",
"params",
")",
";",
"foreach",
"(",
"$",
"params",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"rawQuery",
"[",
"]",
"=",
"sprintf",
"(",
"'%s%s'",
",",
"$",
"k",
",",
"$",
"v",
")",
";",
"}",
"$",
"rawText",
"=",
"implode",
"(",
"''",
",",
"$",
"rawQuery",
")",
";",
"$",
"signature",
"=",
"''",
";",
"if",
"(",
"$",
"method",
"===",
"Alidayu",
"::",
"SIGN_METHOD_MD5",
")",
"{",
"$",
"signature",
"=",
"md5",
"(",
"$",
"this",
"->",
"appSecret",
".",
"$",
"rawText",
".",
"$",
"this",
"->",
"appSecret",
")",
";",
"}",
"elseif",
"(",
"$",
"method",
"===",
"Alidayu",
"::",
"SIGN_METHOD_HMAC",
")",
"{",
"$",
"signature",
"=",
"hash_hmac",
"(",
"'md5'",
",",
"$",
"rawText",
",",
"$",
"this",
"->",
"appSecret",
")",
";",
"}",
"return",
"strtoupper",
"(",
"$",
"signature",
")",
";",
"}"
] | 生成sign签名
@param array $params 入参
@param string $method 签名方式:md5或hmac-md5
@return string | [
"生成sign签名"
] | train | https://github.com/chocoboxxf/yii2-alidayu-sdk/blob/47cbc4f5ac1e9378ae4ec4765bdd8802cac9e22f/src/Alidayu.php#L357-L372 |
chocoboxxf/yii2-alidayu-sdk | src/Alidayu.php | Alidayu.post | public function post($url, $data, $headers = [])
{
$request = new Request('POST', $url, $headers);
$response = $this->apiClient->send(
$request,
[
'form_params' => $data,
]
);
$result = json_decode($response->getBody(), true);
return $result;
} | php | public function post($url, $data, $headers = [])
{
$request = new Request('POST', $url, $headers);
$response = $this->apiClient->send(
$request,
[
'form_params' => $data,
]
);
$result = json_decode($response->getBody(), true);
return $result;
} | [
"public",
"function",
"post",
"(",
"$",
"url",
",",
"$",
"data",
",",
"$",
"headers",
"=",
"[",
"]",
")",
"{",
"$",
"request",
"=",
"new",
"Request",
"(",
"'POST'",
",",
"$",
"url",
",",
"$",
"headers",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"apiClient",
"->",
"send",
"(",
"$",
"request",
",",
"[",
"'form_params'",
"=>",
"$",
"data",
",",
"]",
")",
";",
"$",
"result",
"=",
"json_decode",
"(",
"$",
"response",
"->",
"getBody",
"(",
")",
",",
"true",
")",
";",
"return",
"$",
"result",
";",
"}"
] | post请求
@param string $url 接口相对路径
@param array $data 接口传参
@param array $headers HTTP Header
@return mixed
@throws GuzzleException | [
"post请求"
] | train | https://github.com/chocoboxxf/yii2-alidayu-sdk/blob/47cbc4f5ac1e9378ae4ec4765bdd8802cac9e22f/src/Alidayu.php#L391-L402 |
webforge-labs/psc-cms | lib/PHPWord/PHPWord/Shared/ZipStreamWrapper.php | PHPWord_Shared_ZipStreamWrapper.stream_open | public function stream_open($path, $mode, $options, &$opened_path) {
// Check for mode
if ($mode{0} != 'r') {
throw new Exception('Mode ' . $mode . ' is not supported. Only read mode is supported.');
}
// Parse URL
$url = @parse_url($path);
// Fix URL
if (!is_array($url)) {
$url['host'] = substr($path, strlen('zip://'));
$url['path'] = '';
}
if (strpos($url['host'], '#') !== false) {
if (!isset($url['fragment'])) {
$url['fragment'] = substr($url['host'], strpos($url['host'], '#') + 1) . $url['path'];
$url['host'] = substr($url['host'], 0, strpos($url['host'], '#'));
unset($url['path']);
}
} else {
$url['host'] = $url['host'] . $url['path'];
unset($url['path']);
}
// Open archive
$this->_archive = new ZipArchive();
$this->_archive->open($url['host']);
$this->_fileNameInArchive = $url['fragment'];
$this->_position = 0;
$this->_data = $this->_archive->getFromName( $this->_fileNameInArchive );
return true;
} | php | public function stream_open($path, $mode, $options, &$opened_path) {
// Check for mode
if ($mode{0} != 'r') {
throw new Exception('Mode ' . $mode . ' is not supported. Only read mode is supported.');
}
// Parse URL
$url = @parse_url($path);
// Fix URL
if (!is_array($url)) {
$url['host'] = substr($path, strlen('zip://'));
$url['path'] = '';
}
if (strpos($url['host'], '#') !== false) {
if (!isset($url['fragment'])) {
$url['fragment'] = substr($url['host'], strpos($url['host'], '#') + 1) . $url['path'];
$url['host'] = substr($url['host'], 0, strpos($url['host'], '#'));
unset($url['path']);
}
} else {
$url['host'] = $url['host'] . $url['path'];
unset($url['path']);
}
// Open archive
$this->_archive = new ZipArchive();
$this->_archive->open($url['host']);
$this->_fileNameInArchive = $url['fragment'];
$this->_position = 0;
$this->_data = $this->_archive->getFromName( $this->_fileNameInArchive );
return true;
} | [
"public",
"function",
"stream_open",
"(",
"$",
"path",
",",
"$",
"mode",
",",
"$",
"options",
",",
"&",
"$",
"opened_path",
")",
"{",
"// Check for mode",
"if",
"(",
"$",
"mode",
"{",
"0",
"}",
"!=",
"'r'",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Mode '",
".",
"$",
"mode",
".",
"' is not supported. Only read mode is supported.'",
")",
";",
"}",
"// Parse URL",
"$",
"url",
"=",
"@",
"parse_url",
"(",
"$",
"path",
")",
";",
"// Fix URL",
"if",
"(",
"!",
"is_array",
"(",
"$",
"url",
")",
")",
"{",
"$",
"url",
"[",
"'host'",
"]",
"=",
"substr",
"(",
"$",
"path",
",",
"strlen",
"(",
"'zip://'",
")",
")",
";",
"$",
"url",
"[",
"'path'",
"]",
"=",
"''",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"url",
"[",
"'host'",
"]",
",",
"'#'",
")",
"!==",
"false",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"url",
"[",
"'fragment'",
"]",
")",
")",
"{",
"$",
"url",
"[",
"'fragment'",
"]",
"=",
"substr",
"(",
"$",
"url",
"[",
"'host'",
"]",
",",
"strpos",
"(",
"$",
"url",
"[",
"'host'",
"]",
",",
"'#'",
")",
"+",
"1",
")",
".",
"$",
"url",
"[",
"'path'",
"]",
";",
"$",
"url",
"[",
"'host'",
"]",
"=",
"substr",
"(",
"$",
"url",
"[",
"'host'",
"]",
",",
"0",
",",
"strpos",
"(",
"$",
"url",
"[",
"'host'",
"]",
",",
"'#'",
")",
")",
";",
"unset",
"(",
"$",
"url",
"[",
"'path'",
"]",
")",
";",
"}",
"}",
"else",
"{",
"$",
"url",
"[",
"'host'",
"]",
"=",
"$",
"url",
"[",
"'host'",
"]",
".",
"$",
"url",
"[",
"'path'",
"]",
";",
"unset",
"(",
"$",
"url",
"[",
"'path'",
"]",
")",
";",
"}",
"// Open archive",
"$",
"this",
"->",
"_archive",
"=",
"new",
"ZipArchive",
"(",
")",
";",
"$",
"this",
"->",
"_archive",
"->",
"open",
"(",
"$",
"url",
"[",
"'host'",
"]",
")",
";",
"$",
"this",
"->",
"_fileNameInArchive",
"=",
"$",
"url",
"[",
"'fragment'",
"]",
";",
"$",
"this",
"->",
"_position",
"=",
"0",
";",
"$",
"this",
"->",
"_data",
"=",
"$",
"this",
"->",
"_archive",
"->",
"getFromName",
"(",
"$",
"this",
"->",
"_fileNameInArchive",
")",
";",
"return",
"true",
";",
"}"
] | Open stream | [
"Open",
"stream"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Shared/ZipStreamWrapper.php#L73-L107 |
Chill-project/Main | Controller/PermissionsGroupController.php | PermissionsGroupController.createCreateForm | private function createCreateForm(PermissionsGroup $permissionsGroup)
{
$form = $this->createForm(new PermissionsGroupType(), $permissionsGroup, array(
'action' => $this->generateUrl('admin_permissionsgroup_create'),
'method' => 'POST',
));
$form->add('submit', 'submit', array('label' => 'Create'));
return $form;
} | php | private function createCreateForm(PermissionsGroup $permissionsGroup)
{
$form = $this->createForm(new PermissionsGroupType(), $permissionsGroup, array(
'action' => $this->generateUrl('admin_permissionsgroup_create'),
'method' => 'POST',
));
$form->add('submit', 'submit', array('label' => 'Create'));
return $form;
} | [
"private",
"function",
"createCreateForm",
"(",
"PermissionsGroup",
"$",
"permissionsGroup",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"PermissionsGroupType",
"(",
")",
",",
"$",
"permissionsGroup",
",",
"array",
"(",
"'action'",
"=>",
"$",
"this",
"->",
"generateUrl",
"(",
"'admin_permissionsgroup_create'",
")",
",",
"'method'",
"=>",
"'POST'",
",",
")",
")",
";",
"$",
"form",
"->",
"add",
"(",
"'submit'",
",",
"'submit'",
",",
"array",
"(",
"'label'",
"=>",
"'Create'",
")",
")",
";",
"return",
"$",
"form",
";",
"}"
] | Creates a form to create a PermissionsGroup entity.
@param PermissionsGroup $permissionsGroup The entity
@return \Symfony\Component\Form\Form The form | [
"Creates",
"a",
"form",
"to",
"create",
"a",
"PermissionsGroup",
"entity",
"."
] | train | https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/PermissionsGroupController.php#L68-L78 |
Chill-project/Main | Controller/PermissionsGroupController.php | PermissionsGroupController.newAction | public function newAction()
{
$permissionsGroup = new PermissionsGroup();
$form = $this->createCreateForm($permissionsGroup);
return $this->render('ChillMainBundle:PermissionsGroup:new.html.twig', array(
'entity' => $permissionsGroup,
'form' => $form->createView(),
));
} | php | public function newAction()
{
$permissionsGroup = new PermissionsGroup();
$form = $this->createCreateForm($permissionsGroup);
return $this->render('ChillMainBundle:PermissionsGroup:new.html.twig', array(
'entity' => $permissionsGroup,
'form' => $form->createView(),
));
} | [
"public",
"function",
"newAction",
"(",
")",
"{",
"$",
"permissionsGroup",
"=",
"new",
"PermissionsGroup",
"(",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createCreateForm",
"(",
"$",
"permissionsGroup",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"'ChillMainBundle:PermissionsGroup:new.html.twig'",
",",
"array",
"(",
"'entity'",
"=>",
"$",
"permissionsGroup",
",",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
")",
")",
";",
"}"
] | Displays a form to create a new PermissionsGroup entity. | [
"Displays",
"a",
"form",
"to",
"create",
"a",
"new",
"PermissionsGroup",
"entity",
"."
] | train | https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/PermissionsGroupController.php#L84-L93 |
Chill-project/Main | Controller/PermissionsGroupController.php | PermissionsGroupController.showAction | public function showAction($id)
{
$em = $this->getDoctrine()->getManager();
$permissionsGroup = $em->getRepository('ChillMainBundle:PermissionsGroup')->find($id);
if (!$permissionsGroup) {
throw $this->createNotFoundException('Unable to find PermissionsGroup entity.');
}
$translatableStringHelper = $this->get('chill.main.helper.translatable_string');
$roleScopes = $permissionsGroup->getRoleScopes()->toArray();
usort($roleScopes,
function(RoleScope $a, RoleScope $b) use ($translatableStringHelper) {
if ($a->getScope() === NULL) {
return 1;
}
if ($b->getScope() === NULL) {
return +1;
}
return strcmp(
$translatableStringHelper->localize($a->getScope()->getName()),
$translatableStringHelper->localize($b->getScope()->getName())
);
});
return $this->render('ChillMainBundle:PermissionsGroup:show.html.twig', array(
'entity' => $permissionsGroup,
'role_scopes' => $roleScopes,
'expanded_roles' => $this->getExpandedRoles($roleScopes)
));
} | php | public function showAction($id)
{
$em = $this->getDoctrine()->getManager();
$permissionsGroup = $em->getRepository('ChillMainBundle:PermissionsGroup')->find($id);
if (!$permissionsGroup) {
throw $this->createNotFoundException('Unable to find PermissionsGroup entity.');
}
$translatableStringHelper = $this->get('chill.main.helper.translatable_string');
$roleScopes = $permissionsGroup->getRoleScopes()->toArray();
usort($roleScopes,
function(RoleScope $a, RoleScope $b) use ($translatableStringHelper) {
if ($a->getScope() === NULL) {
return 1;
}
if ($b->getScope() === NULL) {
return +1;
}
return strcmp(
$translatableStringHelper->localize($a->getScope()->getName()),
$translatableStringHelper->localize($b->getScope()->getName())
);
});
return $this->render('ChillMainBundle:PermissionsGroup:show.html.twig', array(
'entity' => $permissionsGroup,
'role_scopes' => $roleScopes,
'expanded_roles' => $this->getExpandedRoles($roleScopes)
));
} | [
"public",
"function",
"showAction",
"(",
"$",
"id",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"permissionsGroup",
"=",
"$",
"em",
"->",
"getRepository",
"(",
"'ChillMainBundle:PermissionsGroup'",
")",
"->",
"find",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"$",
"permissionsGroup",
")",
"{",
"throw",
"$",
"this",
"->",
"createNotFoundException",
"(",
"'Unable to find PermissionsGroup entity.'",
")",
";",
"}",
"$",
"translatableStringHelper",
"=",
"$",
"this",
"->",
"get",
"(",
"'chill.main.helper.translatable_string'",
")",
";",
"$",
"roleScopes",
"=",
"$",
"permissionsGroup",
"->",
"getRoleScopes",
"(",
")",
"->",
"toArray",
"(",
")",
";",
"usort",
"(",
"$",
"roleScopes",
",",
"function",
"(",
"RoleScope",
"$",
"a",
",",
"RoleScope",
"$",
"b",
")",
"use",
"(",
"$",
"translatableStringHelper",
")",
"{",
"if",
"(",
"$",
"a",
"->",
"getScope",
"(",
")",
"===",
"NULL",
")",
"{",
"return",
"1",
";",
"}",
"if",
"(",
"$",
"b",
"->",
"getScope",
"(",
")",
"===",
"NULL",
")",
"{",
"return",
"+",
"1",
";",
"}",
"return",
"strcmp",
"(",
"$",
"translatableStringHelper",
"->",
"localize",
"(",
"$",
"a",
"->",
"getScope",
"(",
")",
"->",
"getName",
"(",
")",
")",
",",
"$",
"translatableStringHelper",
"->",
"localize",
"(",
"$",
"b",
"->",
"getScope",
"(",
")",
"->",
"getName",
"(",
")",
")",
")",
";",
"}",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"'ChillMainBundle:PermissionsGroup:show.html.twig'",
",",
"array",
"(",
"'entity'",
"=>",
"$",
"permissionsGroup",
",",
"'role_scopes'",
"=>",
"$",
"roleScopes",
",",
"'expanded_roles'",
"=>",
"$",
"this",
"->",
"getExpandedRoles",
"(",
"$",
"roleScopes",
")",
")",
")",
";",
"}"
] | Finds and displays a PermissionsGroup entity. | [
"Finds",
"and",
"displays",
"a",
"PermissionsGroup",
"entity",
"."
] | train | https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/PermissionsGroupController.php#L99-L131 |
Chill-project/Main | Controller/PermissionsGroupController.php | PermissionsGroupController.getExpandedRoles | private function getExpandedRoles(array $roleScopes)
{
$expandedRoles = array();
foreach ($roleScopes as $roleScope) {
if (!array_key_exists($roleScope->getRole(), $expandedRoles)) {
$expandedRoles[$roleScope->getRole()] =
array_map(
function(RoleInterface $role) {
return $role->getRole();
},
$this->get('security.role_hierarchy')
->getReachableRoles(
array(new Role($roleScope->getRole()))
)
);
}
}
return $expandedRoles;
} | php | private function getExpandedRoles(array $roleScopes)
{
$expandedRoles = array();
foreach ($roleScopes as $roleScope) {
if (!array_key_exists($roleScope->getRole(), $expandedRoles)) {
$expandedRoles[$roleScope->getRole()] =
array_map(
function(RoleInterface $role) {
return $role->getRole();
},
$this->get('security.role_hierarchy')
->getReachableRoles(
array(new Role($roleScope->getRole()))
)
);
}
}
return $expandedRoles;
} | [
"private",
"function",
"getExpandedRoles",
"(",
"array",
"$",
"roleScopes",
")",
"{",
"$",
"expandedRoles",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"roleScopes",
"as",
"$",
"roleScope",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"roleScope",
"->",
"getRole",
"(",
")",
",",
"$",
"expandedRoles",
")",
")",
"{",
"$",
"expandedRoles",
"[",
"$",
"roleScope",
"->",
"getRole",
"(",
")",
"]",
"=",
"array_map",
"(",
"function",
"(",
"RoleInterface",
"$",
"role",
")",
"{",
"return",
"$",
"role",
"->",
"getRole",
"(",
")",
";",
"}",
",",
"$",
"this",
"->",
"get",
"(",
"'security.role_hierarchy'",
")",
"->",
"getReachableRoles",
"(",
"array",
"(",
"new",
"Role",
"(",
"$",
"roleScope",
"->",
"getRole",
"(",
")",
")",
")",
")",
")",
";",
"}",
"}",
"return",
"$",
"expandedRoles",
";",
"}"
] | expand roleScopes to be easily shown in template
@param array $roleScopes
@return array | [
"expand",
"roleScopes",
"to",
"be",
"easily",
"shown",
"in",
"template"
] | train | https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/PermissionsGroupController.php#L139-L158 |
Chill-project/Main | Controller/PermissionsGroupController.php | PermissionsGroupController.editAction | public function editAction($id)
{
$em = $this->getDoctrine()->getManager();
$permissionsGroup = $em->getRepository('ChillMainBundle:PermissionsGroup')->find($id);
if (!$permissionsGroup) {
throw $this->createNotFoundException('Unable to find PermissionsGroup entity.');
}
$editForm = $this->createEditForm($permissionsGroup);
$deleteRoleScopesForm = array();
foreach ($permissionsGroup->getRoleScopes() as $roleScope) {
$deleteRoleScopesForm[$roleScope->getId()] = $this->createDeleteRoleScopeForm(
$permissionsGroup, $roleScope);
}
$addRoleScopesForm = $this->createAddRoleScopeForm($permissionsGroup);
return $this->render('ChillMainBundle:PermissionsGroup:edit.html.twig', array(
'entity' => $permissionsGroup,
'edit_form' => $editForm->createView(),
'expanded_roles' => $this->getExpandedRoles($permissionsGroup->getRoleScopes()->toArray()),
'delete_role_scopes_form' => array_map( function($form) {
return $form->createView();
}, $deleteRoleScopesForm),
'add_role_scopes_form' => $addRoleScopesForm->createView()
));
} | php | public function editAction($id)
{
$em = $this->getDoctrine()->getManager();
$permissionsGroup = $em->getRepository('ChillMainBundle:PermissionsGroup')->find($id);
if (!$permissionsGroup) {
throw $this->createNotFoundException('Unable to find PermissionsGroup entity.');
}
$editForm = $this->createEditForm($permissionsGroup);
$deleteRoleScopesForm = array();
foreach ($permissionsGroup->getRoleScopes() as $roleScope) {
$deleteRoleScopesForm[$roleScope->getId()] = $this->createDeleteRoleScopeForm(
$permissionsGroup, $roleScope);
}
$addRoleScopesForm = $this->createAddRoleScopeForm($permissionsGroup);
return $this->render('ChillMainBundle:PermissionsGroup:edit.html.twig', array(
'entity' => $permissionsGroup,
'edit_form' => $editForm->createView(),
'expanded_roles' => $this->getExpandedRoles($permissionsGroup->getRoleScopes()->toArray()),
'delete_role_scopes_form' => array_map( function($form) {
return $form->createView();
}, $deleteRoleScopesForm),
'add_role_scopes_form' => $addRoleScopesForm->createView()
));
} | [
"public",
"function",
"editAction",
"(",
"$",
"id",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"permissionsGroup",
"=",
"$",
"em",
"->",
"getRepository",
"(",
"'ChillMainBundle:PermissionsGroup'",
")",
"->",
"find",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"$",
"permissionsGroup",
")",
"{",
"throw",
"$",
"this",
"->",
"createNotFoundException",
"(",
"'Unable to find PermissionsGroup entity.'",
")",
";",
"}",
"$",
"editForm",
"=",
"$",
"this",
"->",
"createEditForm",
"(",
"$",
"permissionsGroup",
")",
";",
"$",
"deleteRoleScopesForm",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"permissionsGroup",
"->",
"getRoleScopes",
"(",
")",
"as",
"$",
"roleScope",
")",
"{",
"$",
"deleteRoleScopesForm",
"[",
"$",
"roleScope",
"->",
"getId",
"(",
")",
"]",
"=",
"$",
"this",
"->",
"createDeleteRoleScopeForm",
"(",
"$",
"permissionsGroup",
",",
"$",
"roleScope",
")",
";",
"}",
"$",
"addRoleScopesForm",
"=",
"$",
"this",
"->",
"createAddRoleScopeForm",
"(",
"$",
"permissionsGroup",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"'ChillMainBundle:PermissionsGroup:edit.html.twig'",
",",
"array",
"(",
"'entity'",
"=>",
"$",
"permissionsGroup",
",",
"'edit_form'",
"=>",
"$",
"editForm",
"->",
"createView",
"(",
")",
",",
"'expanded_roles'",
"=>",
"$",
"this",
"->",
"getExpandedRoles",
"(",
"$",
"permissionsGroup",
"->",
"getRoleScopes",
"(",
")",
"->",
"toArray",
"(",
")",
")",
",",
"'delete_role_scopes_form'",
"=>",
"array_map",
"(",
"function",
"(",
"$",
"form",
")",
"{",
"return",
"$",
"form",
"->",
"createView",
"(",
")",
";",
"}",
",",
"$",
"deleteRoleScopesForm",
")",
",",
"'add_role_scopes_form'",
"=>",
"$",
"addRoleScopesForm",
"->",
"createView",
"(",
")",
")",
")",
";",
"}"
] | Displays a form to edit an existing PermissionsGroup entity. | [
"Displays",
"a",
"form",
"to",
"edit",
"an",
"existing",
"PermissionsGroup",
"entity",
"."
] | train | https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/PermissionsGroupController.php#L164-L194 |
Chill-project/Main | Controller/PermissionsGroupController.php | PermissionsGroupController.createEditForm | private function createEditForm(PermissionsGroup $permissionsGroup)
{
$form = $this->createForm(new PermissionsGroupType(), $permissionsGroup, array(
'action' => $this->generateUrl('admin_permissionsgroup_update', array('id' => $permissionsGroup->getId())),
'method' => 'PUT',
));
$form->add('submit', 'submit', array('label' => 'Update'));
return $form;
} | php | private function createEditForm(PermissionsGroup $permissionsGroup)
{
$form = $this->createForm(new PermissionsGroupType(), $permissionsGroup, array(
'action' => $this->generateUrl('admin_permissionsgroup_update', array('id' => $permissionsGroup->getId())),
'method' => 'PUT',
));
$form->add('submit', 'submit', array('label' => 'Update'));
return $form;
} | [
"private",
"function",
"createEditForm",
"(",
"PermissionsGroup",
"$",
"permissionsGroup",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"PermissionsGroupType",
"(",
")",
",",
"$",
"permissionsGroup",
",",
"array",
"(",
"'action'",
"=>",
"$",
"this",
"->",
"generateUrl",
"(",
"'admin_permissionsgroup_update'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"permissionsGroup",
"->",
"getId",
"(",
")",
")",
")",
",",
"'method'",
"=>",
"'PUT'",
",",
")",
")",
";",
"$",
"form",
"->",
"add",
"(",
"'submit'",
",",
"'submit'",
",",
"array",
"(",
"'label'",
"=>",
"'Update'",
")",
")",
";",
"return",
"$",
"form",
";",
"}"
] | Creates a form to edit a PermissionsGroup entity.
@param PermissionsGroup $permissionsGroup The entity
@return \Symfony\Component\Form\Form The form | [
"Creates",
"a",
"form",
"to",
"edit",
"a",
"PermissionsGroup",
"entity",
"."
] | train | https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/PermissionsGroupController.php#L203-L213 |
Chill-project/Main | Controller/PermissionsGroupController.php | PermissionsGroupController.updateAction | public function updateAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager();
$permissionsGroup = $em->getRepository('ChillMainBundle:PermissionsGroup')->find($id);
if (!$permissionsGroup) {
throw $this->createNotFoundException('Unable to find PermissionsGroup entity.');
}
$editForm = $this->createEditForm($permissionsGroup);
$editForm->handleRequest($request);
if ($editForm->isValid()) {
$em->flush();
return $this->redirect($this->generateUrl('admin_permissionsgroup_edit', array('id' => $id)));
}
$deleteRoleScopesForm = array();
foreach ($permissionsGroup->getRoleScopes() as $roleScope) {
$deleteRoleScopesForm[$roleScope->getId()] = $this->createDeleteRoleScopeForm(
$permissionsGroup, $roleScope);
}
$addRoleScopesForm = $this->createAddRoleScopeForm($permissionsGroup);
return $this->render('ChillMainBundle:PermissionsGroup:edit.html.twig', array(
'entity' => $permissionsGroup,
'edit_form' => $editForm->createView(),
'expanded_roles' => $this->getExpandedRoles($permissionsGroup->getRoleScopes()->toArray()),
'delete_role_scopes_form' => array_map( function($form) {
return $form->createView();
}, $deleteRoleScopesForm),
'add_role_scopes_form' => $addRoleScopesForm->createView()
));
} | php | public function updateAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager();
$permissionsGroup = $em->getRepository('ChillMainBundle:PermissionsGroup')->find($id);
if (!$permissionsGroup) {
throw $this->createNotFoundException('Unable to find PermissionsGroup entity.');
}
$editForm = $this->createEditForm($permissionsGroup);
$editForm->handleRequest($request);
if ($editForm->isValid()) {
$em->flush();
return $this->redirect($this->generateUrl('admin_permissionsgroup_edit', array('id' => $id)));
}
$deleteRoleScopesForm = array();
foreach ($permissionsGroup->getRoleScopes() as $roleScope) {
$deleteRoleScopesForm[$roleScope->getId()] = $this->createDeleteRoleScopeForm(
$permissionsGroup, $roleScope);
}
$addRoleScopesForm = $this->createAddRoleScopeForm($permissionsGroup);
return $this->render('ChillMainBundle:PermissionsGroup:edit.html.twig', array(
'entity' => $permissionsGroup,
'edit_form' => $editForm->createView(),
'expanded_roles' => $this->getExpandedRoles($permissionsGroup->getRoleScopes()->toArray()),
'delete_role_scopes_form' => array_map( function($form) {
return $form->createView();
}, $deleteRoleScopesForm),
'add_role_scopes_form' => $addRoleScopesForm->createView()
));
} | [
"public",
"function",
"updateAction",
"(",
"Request",
"$",
"request",
",",
"$",
"id",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"permissionsGroup",
"=",
"$",
"em",
"->",
"getRepository",
"(",
"'ChillMainBundle:PermissionsGroup'",
")",
"->",
"find",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"$",
"permissionsGroup",
")",
"{",
"throw",
"$",
"this",
"->",
"createNotFoundException",
"(",
"'Unable to find PermissionsGroup entity.'",
")",
";",
"}",
"$",
"editForm",
"=",
"$",
"this",
"->",
"createEditForm",
"(",
"$",
"permissionsGroup",
")",
";",
"$",
"editForm",
"->",
"handleRequest",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"editForm",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'admin_permissionsgroup_edit'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"id",
")",
")",
")",
";",
"}",
"$",
"deleteRoleScopesForm",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"permissionsGroup",
"->",
"getRoleScopes",
"(",
")",
"as",
"$",
"roleScope",
")",
"{",
"$",
"deleteRoleScopesForm",
"[",
"$",
"roleScope",
"->",
"getId",
"(",
")",
"]",
"=",
"$",
"this",
"->",
"createDeleteRoleScopeForm",
"(",
"$",
"permissionsGroup",
",",
"$",
"roleScope",
")",
";",
"}",
"$",
"addRoleScopesForm",
"=",
"$",
"this",
"->",
"createAddRoleScopeForm",
"(",
"$",
"permissionsGroup",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"'ChillMainBundle:PermissionsGroup:edit.html.twig'",
",",
"array",
"(",
"'entity'",
"=>",
"$",
"permissionsGroup",
",",
"'edit_form'",
"=>",
"$",
"editForm",
"->",
"createView",
"(",
")",
",",
"'expanded_roles'",
"=>",
"$",
"this",
"->",
"getExpandedRoles",
"(",
"$",
"permissionsGroup",
"->",
"getRoleScopes",
"(",
")",
"->",
"toArray",
"(",
")",
")",
",",
"'delete_role_scopes_form'",
"=>",
"array_map",
"(",
"function",
"(",
"$",
"form",
")",
"{",
"return",
"$",
"form",
"->",
"createView",
"(",
")",
";",
"}",
",",
"$",
"deleteRoleScopesForm",
")",
",",
"'add_role_scopes_form'",
"=>",
"$",
"addRoleScopesForm",
"->",
"createView",
"(",
")",
")",
")",
";",
"}"
] | Edits an existing PermissionsGroup entity. | [
"Edits",
"an",
"existing",
"PermissionsGroup",
"entity",
"."
] | train | https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/PermissionsGroupController.php#L219-L257 |
Chill-project/Main | Controller/PermissionsGroupController.php | PermissionsGroupController.getPersistentRoleScopeBy | protected function getPersistentRoleScopeBy($role, Scope $scope = null)
{
$em = $this->getDoctrine()->getManager();
$roleScope = $em->getRepository('ChillMainBundle:RoleScope')
->findOneBy(array('role' => $role, 'scope' => $scope));
if ($roleScope === NULL) {
$roleScope = (new RoleScope())
->setRole($role)
->setScope($scope)
;
$em->persist($roleScope);
}
return $roleScope;
} | php | protected function getPersistentRoleScopeBy($role, Scope $scope = null)
{
$em = $this->getDoctrine()->getManager();
$roleScope = $em->getRepository('ChillMainBundle:RoleScope')
->findOneBy(array('role' => $role, 'scope' => $scope));
if ($roleScope === NULL) {
$roleScope = (new RoleScope())
->setRole($role)
->setScope($scope)
;
$em->persist($roleScope);
}
return $roleScope;
} | [
"protected",
"function",
"getPersistentRoleScopeBy",
"(",
"$",
"role",
",",
"Scope",
"$",
"scope",
"=",
"null",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"roleScope",
"=",
"$",
"em",
"->",
"getRepository",
"(",
"'ChillMainBundle:RoleScope'",
")",
"->",
"findOneBy",
"(",
"array",
"(",
"'role'",
"=>",
"$",
"role",
",",
"'scope'",
"=>",
"$",
"scope",
")",
")",
";",
"if",
"(",
"$",
"roleScope",
"===",
"NULL",
")",
"{",
"$",
"roleScope",
"=",
"(",
"new",
"RoleScope",
"(",
")",
")",
"->",
"setRole",
"(",
"$",
"role",
")",
"->",
"setScope",
"(",
"$",
"scope",
")",
";",
"$",
"em",
"->",
"persist",
"(",
"$",
"roleScope",
")",
";",
"}",
"return",
"$",
"roleScope",
";",
"}"
] | get a role scope by his parameters. The role scope is persisted if it
doesn't exists in database.
@param Scope $scope
@param string $role
@return RoleScope | [
"get",
"a",
"role",
"scope",
"by",
"his",
"parameters",
".",
"The",
"role",
"scope",
"is",
"persisted",
"if",
"it",
"doesn",
"t",
"exists",
"in",
"database",
"."
] | train | https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/PermissionsGroupController.php#L267-L284 |
Chill-project/Main | Controller/PermissionsGroupController.php | PermissionsGroupController.deleteLinkRoleScopeAction | public function deleteLinkRoleScopeAction($pgid, $rsid)
{
$em = $this->getDoctrine()->getManager();
$permissionsGroup = $em->getRepository('ChillMainBundle:PermissionsGroup')->find($pgid);
$roleScope = $em->getRepository('ChillMainBundle:RoleScope')->find($rsid);
if (!$permissionsGroup) {
throw $this->createNotFoundException('Unable to find PermissionsGroup entity.');
}
if (!$roleScope) {
throw $this->createNotFoundException('Unable to find RoleScope entity');
}
try {
$permissionsGroup->removeRoleScope($roleScope);
} catch (\RuntimeException $ex) {
$this->addFlash('notice',
$this->get('translator')->trans("The role '%role%' and circle "
. "'%scope%' is not associated with this permission group", array(
'%role%' => $this->get('translator')->trans($roleScope->getRole()),
'%scope%' => $this->get('chill.main.helper.translatable_string')
->localize($roleScope->getScope()->getName())
)));
return $this->redirect($this->generateUrl('admin_permissionsgroup_edit',
array('id' => $pgid)));
}
$em->flush();
$this->addFlash('notice',
$this->get('translator')->trans("The role '%role%' on circle "
. "'%scope%' has been removed", array(
'%role%' => $this->get('translator')->trans($roleScope->getRole()),
'%scope%' => $this->get('chill.main.helper.translatable_string')
->localize($roleScope->getScope()->getName())
)));
return $this->redirect($this->generateUrl('admin_permissionsgroup_edit',
array('id' => $pgid)));
} | php | public function deleteLinkRoleScopeAction($pgid, $rsid)
{
$em = $this->getDoctrine()->getManager();
$permissionsGroup = $em->getRepository('ChillMainBundle:PermissionsGroup')->find($pgid);
$roleScope = $em->getRepository('ChillMainBundle:RoleScope')->find($rsid);
if (!$permissionsGroup) {
throw $this->createNotFoundException('Unable to find PermissionsGroup entity.');
}
if (!$roleScope) {
throw $this->createNotFoundException('Unable to find RoleScope entity');
}
try {
$permissionsGroup->removeRoleScope($roleScope);
} catch (\RuntimeException $ex) {
$this->addFlash('notice',
$this->get('translator')->trans("The role '%role%' and circle "
. "'%scope%' is not associated with this permission group", array(
'%role%' => $this->get('translator')->trans($roleScope->getRole()),
'%scope%' => $this->get('chill.main.helper.translatable_string')
->localize($roleScope->getScope()->getName())
)));
return $this->redirect($this->generateUrl('admin_permissionsgroup_edit',
array('id' => $pgid)));
}
$em->flush();
$this->addFlash('notice',
$this->get('translator')->trans("The role '%role%' on circle "
. "'%scope%' has been removed", array(
'%role%' => $this->get('translator')->trans($roleScope->getRole()),
'%scope%' => $this->get('chill.main.helper.translatable_string')
->localize($roleScope->getScope()->getName())
)));
return $this->redirect($this->generateUrl('admin_permissionsgroup_edit',
array('id' => $pgid)));
} | [
"public",
"function",
"deleteLinkRoleScopeAction",
"(",
"$",
"pgid",
",",
"$",
"rsid",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"permissionsGroup",
"=",
"$",
"em",
"->",
"getRepository",
"(",
"'ChillMainBundle:PermissionsGroup'",
")",
"->",
"find",
"(",
"$",
"pgid",
")",
";",
"$",
"roleScope",
"=",
"$",
"em",
"->",
"getRepository",
"(",
"'ChillMainBundle:RoleScope'",
")",
"->",
"find",
"(",
"$",
"rsid",
")",
";",
"if",
"(",
"!",
"$",
"permissionsGroup",
")",
"{",
"throw",
"$",
"this",
"->",
"createNotFoundException",
"(",
"'Unable to find PermissionsGroup entity.'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"roleScope",
")",
"{",
"throw",
"$",
"this",
"->",
"createNotFoundException",
"(",
"'Unable to find RoleScope entity'",
")",
";",
"}",
"try",
"{",
"$",
"permissionsGroup",
"->",
"removeRoleScope",
"(",
"$",
"roleScope",
")",
";",
"}",
"catch",
"(",
"\\",
"RuntimeException",
"$",
"ex",
")",
"{",
"$",
"this",
"->",
"addFlash",
"(",
"'notice'",
",",
"$",
"this",
"->",
"get",
"(",
"'translator'",
")",
"->",
"trans",
"(",
"\"The role '%role%' and circle \"",
".",
"\"'%scope%' is not associated with this permission group\"",
",",
"array",
"(",
"'%role%'",
"=>",
"$",
"this",
"->",
"get",
"(",
"'translator'",
")",
"->",
"trans",
"(",
"$",
"roleScope",
"->",
"getRole",
"(",
")",
")",
",",
"'%scope%'",
"=>",
"$",
"this",
"->",
"get",
"(",
"'chill.main.helper.translatable_string'",
")",
"->",
"localize",
"(",
"$",
"roleScope",
"->",
"getScope",
"(",
")",
"->",
"getName",
"(",
")",
")",
")",
")",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'admin_permissionsgroup_edit'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"pgid",
")",
")",
")",
";",
"}",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"$",
"this",
"->",
"addFlash",
"(",
"'notice'",
",",
"$",
"this",
"->",
"get",
"(",
"'translator'",
")",
"->",
"trans",
"(",
"\"The role '%role%' on circle \"",
".",
"\"'%scope%' has been removed\"",
",",
"array",
"(",
"'%role%'",
"=>",
"$",
"this",
"->",
"get",
"(",
"'translator'",
")",
"->",
"trans",
"(",
"$",
"roleScope",
"->",
"getRole",
"(",
")",
")",
",",
"'%scope%'",
"=>",
"$",
"this",
"->",
"get",
"(",
"'chill.main.helper.translatable_string'",
")",
"->",
"localize",
"(",
"$",
"roleScope",
"->",
"getScope",
"(",
")",
"->",
"getName",
"(",
")",
")",
")",
")",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'admin_permissionsgroup_edit'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"pgid",
")",
")",
")",
";",
"}"
] | remove an association between permissionsGroup and roleScope
@param int $pgid permissionsGroup id
@param int $rsid roleScope id
@return redirection to edit form | [
"remove",
"an",
"association",
"between",
"permissionsGroup",
"and",
"roleScope"
] | train | https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/PermissionsGroupController.php#L293-L335 |
Chill-project/Main | Controller/PermissionsGroupController.php | PermissionsGroupController.createDeleteRoleScopeForm | private function createDeleteRoleScopeForm(PermissionsGroup $permissionsGroup,
RoleScope $roleScope)
{
return $this->createFormBuilder()
->setAction($this->generateUrl('admin_permissionsgroup_delete_role_scope',
array('pgid' => $permissionsGroup->getId(), 'rsid' => $roleScope->getId())))
->setMethod('DELETE')
->add('submit', 'submit', array('label' => 'Delete'))
->getForm()
;
} | php | private function createDeleteRoleScopeForm(PermissionsGroup $permissionsGroup,
RoleScope $roleScope)
{
return $this->createFormBuilder()
->setAction($this->generateUrl('admin_permissionsgroup_delete_role_scope',
array('pgid' => $permissionsGroup->getId(), 'rsid' => $roleScope->getId())))
->setMethod('DELETE')
->add('submit', 'submit', array('label' => 'Delete'))
->getForm()
;
} | [
"private",
"function",
"createDeleteRoleScopeForm",
"(",
"PermissionsGroup",
"$",
"permissionsGroup",
",",
"RoleScope",
"$",
"roleScope",
")",
"{",
"return",
"$",
"this",
"->",
"createFormBuilder",
"(",
")",
"->",
"setAction",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'admin_permissionsgroup_delete_role_scope'",
",",
"array",
"(",
"'pgid'",
"=>",
"$",
"permissionsGroup",
"->",
"getId",
"(",
")",
",",
"'rsid'",
"=>",
"$",
"roleScope",
"->",
"getId",
"(",
")",
")",
")",
")",
"->",
"setMethod",
"(",
"'DELETE'",
")",
"->",
"add",
"(",
"'submit'",
",",
"'submit'",
",",
"array",
"(",
"'label'",
"=>",
"'Delete'",
")",
")",
"->",
"getForm",
"(",
")",
";",
"}"
] | Creates a form to delete a link to roleScope.
@param mixed $permissionsGroup The entity id
@return \Symfony\Component\Form\Form The form | [
"Creates",
"a",
"form",
"to",
"delete",
"a",
"link",
"to",
"roleScope",
"."
] | train | https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/PermissionsGroupController.php#L416-L426 |
Chill-project/Main | Controller/PermissionsGroupController.php | PermissionsGroupController.createAddRoleScopeForm | private function createAddRoleScopeForm(PermissionsGroup $permissionsGroup)
{
return $this->createFormBuilder()
->setAction($this->generateUrl('admin_permissionsgroup_add_role_scope',
array('id' => $permissionsGroup->getId())))
->setMethod('PUT')
->add('composed_role_scope', 'composed_role_scope')
->add('submit', 'submit', array('label' => 'Add permission'))
->getForm()
;
} | php | private function createAddRoleScopeForm(PermissionsGroup $permissionsGroup)
{
return $this->createFormBuilder()
->setAction($this->generateUrl('admin_permissionsgroup_add_role_scope',
array('id' => $permissionsGroup->getId())))
->setMethod('PUT')
->add('composed_role_scope', 'composed_role_scope')
->add('submit', 'submit', array('label' => 'Add permission'))
->getForm()
;
} | [
"private",
"function",
"createAddRoleScopeForm",
"(",
"PermissionsGroup",
"$",
"permissionsGroup",
")",
"{",
"return",
"$",
"this",
"->",
"createFormBuilder",
"(",
")",
"->",
"setAction",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'admin_permissionsgroup_add_role_scope'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"permissionsGroup",
"->",
"getId",
"(",
")",
")",
")",
")",
"->",
"setMethod",
"(",
"'PUT'",
")",
"->",
"add",
"(",
"'composed_role_scope'",
",",
"'composed_role_scope'",
")",
"->",
"add",
"(",
"'submit'",
",",
"'submit'",
",",
"array",
"(",
"'label'",
"=>",
"'Add permission'",
")",
")",
"->",
"getForm",
"(",
")",
";",
"}"
] | creates a form to add a role scope to permissionsgroup
@param PermissionsGroup $permissionsGroup
@return \Symfony\Component\Form\Form The form | [
"creates",
"a",
"form",
"to",
"add",
"a",
"role",
"scope",
"to",
"permissionsgroup"
] | train | https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/PermissionsGroupController.php#L434-L444 |
qcubed/orm | src/Query/Clause/GroupBy.php | GroupBy.collapseNodes | protected function collapseNodes($mixParameterArray)
{
$objNodeArray = array();
foreach ($mixParameterArray as $mixParameter) {
if (is_array($mixParameter)) {
$objNodeArray = array_merge($objNodeArray, $mixParameter);
} else {
array_push($objNodeArray, $mixParameter);
}
}
$objFinalNodeArray = array();
foreach ($objNodeArray as $objNode) {
/** @var Node\NodeBase $objNode */
if ($objNode instanceof Node\Association) {
throw new Caller('GroupBy clause parameter cannot be an association table node.', 3);
} else {
if (!($objNode instanceof Node\NodeBase)) {
throw new Caller('GroupBy clause parameters must all be QQNode objects.', 3);
}
}
if (!$objNode->_ParentNode) {
throw new InvalidCast('Unable to cast "' . $objNode->_Name . '" table to Column-based QQNode', 4);
}
if ($objNode->_PrimaryKeyNode) {
array_push($objFinalNodeArray,
$objNode->_PrimaryKeyNode); // if a table node, use the primary key of the table instead
} else {
array_push($objFinalNodeArray, $objNode);
}
}
if (count($objFinalNodeArray)) {
return $objFinalNodeArray;
} else {
throw new Caller('No parameters passed in to Expand clause', 3);
}
} | php | protected function collapseNodes($mixParameterArray)
{
$objNodeArray = array();
foreach ($mixParameterArray as $mixParameter) {
if (is_array($mixParameter)) {
$objNodeArray = array_merge($objNodeArray, $mixParameter);
} else {
array_push($objNodeArray, $mixParameter);
}
}
$objFinalNodeArray = array();
foreach ($objNodeArray as $objNode) {
/** @var Node\NodeBase $objNode */
if ($objNode instanceof Node\Association) {
throw new Caller('GroupBy clause parameter cannot be an association table node.', 3);
} else {
if (!($objNode instanceof Node\NodeBase)) {
throw new Caller('GroupBy clause parameters must all be QQNode objects.', 3);
}
}
if (!$objNode->_ParentNode) {
throw new InvalidCast('Unable to cast "' . $objNode->_Name . '" table to Column-based QQNode', 4);
}
if ($objNode->_PrimaryKeyNode) {
array_push($objFinalNodeArray,
$objNode->_PrimaryKeyNode); // if a table node, use the primary key of the table instead
} else {
array_push($objFinalNodeArray, $objNode);
}
}
if (count($objFinalNodeArray)) {
return $objFinalNodeArray;
} else {
throw new Caller('No parameters passed in to Expand clause', 3);
}
} | [
"protected",
"function",
"collapseNodes",
"(",
"$",
"mixParameterArray",
")",
"{",
"$",
"objNodeArray",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"mixParameterArray",
"as",
"$",
"mixParameter",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"mixParameter",
")",
")",
"{",
"$",
"objNodeArray",
"=",
"array_merge",
"(",
"$",
"objNodeArray",
",",
"$",
"mixParameter",
")",
";",
"}",
"else",
"{",
"array_push",
"(",
"$",
"objNodeArray",
",",
"$",
"mixParameter",
")",
";",
"}",
"}",
"$",
"objFinalNodeArray",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"objNodeArray",
"as",
"$",
"objNode",
")",
"{",
"/** @var Node\\NodeBase $objNode */",
"if",
"(",
"$",
"objNode",
"instanceof",
"Node",
"\\",
"Association",
")",
"{",
"throw",
"new",
"Caller",
"(",
"'GroupBy clause parameter cannot be an association table node.'",
",",
"3",
")",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"(",
"$",
"objNode",
"instanceof",
"Node",
"\\",
"NodeBase",
")",
")",
"{",
"throw",
"new",
"Caller",
"(",
"'GroupBy clause parameters must all be QQNode objects.'",
",",
"3",
")",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"objNode",
"->",
"_ParentNode",
")",
"{",
"throw",
"new",
"InvalidCast",
"(",
"'Unable to cast \"'",
".",
"$",
"objNode",
"->",
"_Name",
".",
"'\" table to Column-based QQNode'",
",",
"4",
")",
";",
"}",
"if",
"(",
"$",
"objNode",
"->",
"_PrimaryKeyNode",
")",
"{",
"array_push",
"(",
"$",
"objFinalNodeArray",
",",
"$",
"objNode",
"->",
"_PrimaryKeyNode",
")",
";",
"// if a table node, use the primary key of the table instead",
"}",
"else",
"{",
"array_push",
"(",
"$",
"objFinalNodeArray",
",",
"$",
"objNode",
")",
";",
"}",
"}",
"if",
"(",
"count",
"(",
"$",
"objFinalNodeArray",
")",
")",
"{",
"return",
"$",
"objFinalNodeArray",
";",
"}",
"else",
"{",
"throw",
"new",
"Caller",
"(",
"'No parameters passed in to Expand clause'",
",",
"3",
")",
";",
"}",
"}"
] | CollapseNodes makes sure a node list is vetted, and turned into a node list.
This also allows table nodes to be used in certain column node contexts, in which it will
substitute the primary key node in this situation.
@param $mixParameterArray
@return Node\Column[]
@throws Caller
@throws InvalidCast | [
"CollapseNodes",
"makes",
"sure",
"a",
"node",
"list",
"is",
"vetted",
"and",
"turned",
"into",
"a",
"node",
"list",
".",
"This",
"also",
"allows",
"table",
"nodes",
"to",
"be",
"used",
"in",
"certain",
"column",
"node",
"contexts",
"in",
"which",
"it",
"will",
"substitute",
"the",
"primary",
"key",
"node",
"in",
"this",
"situation",
"."
] | train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Query/Clause/GroupBy.php#L38-L77 |
aedart/laravel-helpers | src/Traits/Queue/QueueTrait.php | QueueTrait.getQueue | public function getQueue(): ?Queue
{
if (!$this->hasQueue()) {
$this->setQueue($this->getDefaultQueue());
}
return $this->queue;
} | php | public function getQueue(): ?Queue
{
if (!$this->hasQueue()) {
$this->setQueue($this->getDefaultQueue());
}
return $this->queue;
} | [
"public",
"function",
"getQueue",
"(",
")",
":",
"?",
"Queue",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasQueue",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setQueue",
"(",
"$",
"this",
"->",
"getDefaultQueue",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"queue",
";",
"}"
] | Get queue
If no queue has been set, this method will
set and return a default queue, if any such
value is available
@see getDefaultQueue()
@return Queue|null queue or null if none queue has been set | [
"Get",
"queue"
] | train | https://github.com/aedart/laravel-helpers/blob/8b81a2d6658f3f8cb62b6be2c34773aaa2df219a/src/Traits/Queue/QueueTrait.php#L53-L59 |
aedart/laravel-helpers | src/Traits/Queue/QueueTrait.php | QueueTrait.getDefaultQueue | public function getDefaultQueue(): ?Queue
{
// By default, the Queue Facade does not return the
// any actual database connection, but rather an
// instance of \Illuminate\Queue\QueueManager.
// Therefore, we make sure only to obtain its
// "connection", to make sure that its only the connection
// instance that we obtain.
$manager = QueueFacade::getFacadeRoot();
if (isset($manager)) {
return $manager->connection();
}
return $manager;
} | php | public function getDefaultQueue(): ?Queue
{
// By default, the Queue Facade does not return the
// any actual database connection, but rather an
// instance of \Illuminate\Queue\QueueManager.
// Therefore, we make sure only to obtain its
// "connection", to make sure that its only the connection
// instance that we obtain.
$manager = QueueFacade::getFacadeRoot();
if (isset($manager)) {
return $manager->connection();
}
return $manager;
} | [
"public",
"function",
"getDefaultQueue",
"(",
")",
":",
"?",
"Queue",
"{",
"// By default, the Queue Facade does not return the",
"// any actual database connection, but rather an",
"// instance of \\Illuminate\\Queue\\QueueManager.",
"// Therefore, we make sure only to obtain its",
"// \"connection\", to make sure that its only the connection",
"// instance that we obtain.",
"$",
"manager",
"=",
"QueueFacade",
"::",
"getFacadeRoot",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"manager",
")",
")",
"{",
"return",
"$",
"manager",
"->",
"connection",
"(",
")",
";",
"}",
"return",
"$",
"manager",
";",
"}"
] | Get a default queue value, if any is available
@return Queue|null A default queue value or Null if no default value is available | [
"Get",
"a",
"default",
"queue",
"value",
"if",
"any",
"is",
"available"
] | train | https://github.com/aedart/laravel-helpers/blob/8b81a2d6658f3f8cb62b6be2c34773aaa2df219a/src/Traits/Queue/QueueTrait.php#L76-L89 |
SAREhub/PHP_Commons | src/SAREhub/Commons/Misc/SqliteHashStorage.php | SqliteHashStorage.insertMulti | public function insertMulti(array $hashes)
{
$valuesString = '';
foreach ($hashes as $id => $hash) {
$valuesString .= "('$id','$hash'),";
}
$this->storage->exec("INSERT INTO " . $this->tableName . "(id, hash) VALUES " . rtrim($valuesString, ','));
} | php | public function insertMulti(array $hashes)
{
$valuesString = '';
foreach ($hashes as $id => $hash) {
$valuesString .= "('$id','$hash'),";
}
$this->storage->exec("INSERT INTO " . $this->tableName . "(id, hash) VALUES " . rtrim($valuesString, ','));
} | [
"public",
"function",
"insertMulti",
"(",
"array",
"$",
"hashes",
")",
"{",
"$",
"valuesString",
"=",
"''",
";",
"foreach",
"(",
"$",
"hashes",
"as",
"$",
"id",
"=>",
"$",
"hash",
")",
"{",
"$",
"valuesString",
".=",
"\"('$id','$hash'),\"",
";",
"}",
"$",
"this",
"->",
"storage",
"->",
"exec",
"(",
"\"INSERT INTO \"",
".",
"$",
"this",
"->",
"tableName",
".",
"\"(id, hash) VALUES \"",
".",
"rtrim",
"(",
"$",
"valuesString",
",",
"','",
")",
")",
";",
"}"
] | Inserts hashes in batch for better performance
@param array $hashes 'id' => 'hash' | [
"Inserts",
"hashes",
"in",
"batch",
"for",
"better",
"performance"
] | train | https://github.com/SAREhub/PHP_Commons/blob/4e1769ab6411a584112df1151dcc90e6b82fe2bb/src/SAREhub/Commons/Misc/SqliteHashStorage.php#L83-L91 |
SAREhub/PHP_Commons | src/SAREhub/Commons/Misc/SqliteHashStorage.php | SqliteHashStorage.updateMulti | public function updateMulti(array $hashes)
{
$startSql = "UPDATE " . $this->tableName;
$this->storage->exec('BEGIN TRANSACTION');
foreach ($hashes as $id => $hash) {
$this->storage->exec($startSql . " SET hash='$hash' WHERE id='$id'");
}
$this->storage->exec('END TRANSACTION');
} | php | public function updateMulti(array $hashes)
{
$startSql = "UPDATE " . $this->tableName;
$this->storage->exec('BEGIN TRANSACTION');
foreach ($hashes as $id => $hash) {
$this->storage->exec($startSql . " SET hash='$hash' WHERE id='$id'");
}
$this->storage->exec('END TRANSACTION');
} | [
"public",
"function",
"updateMulti",
"(",
"array",
"$",
"hashes",
")",
"{",
"$",
"startSql",
"=",
"\"UPDATE \"",
".",
"$",
"this",
"->",
"tableName",
";",
"$",
"this",
"->",
"storage",
"->",
"exec",
"(",
"'BEGIN TRANSACTION'",
")",
";",
"foreach",
"(",
"$",
"hashes",
"as",
"$",
"id",
"=>",
"$",
"hash",
")",
"{",
"$",
"this",
"->",
"storage",
"->",
"exec",
"(",
"$",
"startSql",
".",
"\" SET hash='$hash' WHERE id='$id'\"",
")",
";",
"}",
"$",
"this",
"->",
"storage",
"->",
"exec",
"(",
"'END TRANSACTION'",
")",
";",
"}"
] | Updating hashes in batch for better performance
@param array $hashes 'id' => 'hash' | [
"Updating",
"hashes",
"in",
"batch",
"for",
"better",
"performance"
] | train | https://github.com/SAREhub/PHP_Commons/blob/4e1769ab6411a584112df1151dcc90e6b82fe2bb/src/SAREhub/Commons/Misc/SqliteHashStorage.php#L97-L105 |
webforge-labs/psc-cms | lib/PHPWord/PHPWord/Style.php | PHPWord_Style.addParagraphStyle | public static function addParagraphStyle($styleName, $styles) {
if(!array_key_exists($styleName, self::$_styleElements)) {
$style = new PHPWord_Style_Paragraph();
foreach($styles as $key => $value) {
if(substr($key, 0, 1) != '_') {
$key = '_'.$key;
}
$style->setStyleValue($key, $value);
}
self::$_styleElements[$styleName] = $style;
}
} | php | public static function addParagraphStyle($styleName, $styles) {
if(!array_key_exists($styleName, self::$_styleElements)) {
$style = new PHPWord_Style_Paragraph();
foreach($styles as $key => $value) {
if(substr($key, 0, 1) != '_') {
$key = '_'.$key;
}
$style->setStyleValue($key, $value);
}
self::$_styleElements[$styleName] = $style;
}
} | [
"public",
"static",
"function",
"addParagraphStyle",
"(",
"$",
"styleName",
",",
"$",
"styles",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"styleName",
",",
"self",
"::",
"$",
"_styleElements",
")",
")",
"{",
"$",
"style",
"=",
"new",
"PHPWord_Style_Paragraph",
"(",
")",
";",
"foreach",
"(",
"$",
"styles",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"key",
",",
"0",
",",
"1",
")",
"!=",
"'_'",
")",
"{",
"$",
"key",
"=",
"'_'",
".",
"$",
"key",
";",
"}",
"$",
"style",
"->",
"setStyleValue",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"self",
"::",
"$",
"_styleElements",
"[",
"$",
"styleName",
"]",
"=",
"$",
"style",
";",
"}",
"}"
] | Add a paragraph style
@param string $styleName
@param array $styles | [
"Add",
"a",
"paragraph",
"style"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Style.php#L52-L64 |
webforge-labs/psc-cms | lib/PHPWord/PHPWord/Style.php | PHPWord_Style.addFontStyle | public static function addFontStyle($styleName, $styleFont, $styleParagraph = null) {
if(!array_key_exists($styleName, self::$_styleElements)) {
$font = new PHPWord_Style_Font('text', $styleParagraph);
foreach($styleFont as $key => $value) {
if(substr($key, 0, 1) != '_') {
$key = '_'.$key;
}
$font->setStyleValue($key, $value);
}
self::$_styleElements[$styleName] = $font;
}
} | php | public static function addFontStyle($styleName, $styleFont, $styleParagraph = null) {
if(!array_key_exists($styleName, self::$_styleElements)) {
$font = new PHPWord_Style_Font('text', $styleParagraph);
foreach($styleFont as $key => $value) {
if(substr($key, 0, 1) != '_') {
$key = '_'.$key;
}
$font->setStyleValue($key, $value);
}
self::$_styleElements[$styleName] = $font;
}
} | [
"public",
"static",
"function",
"addFontStyle",
"(",
"$",
"styleName",
",",
"$",
"styleFont",
",",
"$",
"styleParagraph",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"styleName",
",",
"self",
"::",
"$",
"_styleElements",
")",
")",
"{",
"$",
"font",
"=",
"new",
"PHPWord_Style_Font",
"(",
"'text'",
",",
"$",
"styleParagraph",
")",
";",
"foreach",
"(",
"$",
"styleFont",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"key",
",",
"0",
",",
"1",
")",
"!=",
"'_'",
")",
"{",
"$",
"key",
"=",
"'_'",
".",
"$",
"key",
";",
"}",
"$",
"font",
"->",
"setStyleValue",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"self",
"::",
"$",
"_styleElements",
"[",
"$",
"styleName",
"]",
"=",
"$",
"font",
";",
"}",
"}"
] | Add a font style
@param string $styleName
@param array $styleFont
@param array $styleParagraph | [
"Add",
"a",
"font",
"style"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Style.php#L73-L84 |
webforge-labs/psc-cms | lib/PHPWord/PHPWord/Style.php | PHPWord_Style.addLinkStyle | public static function addLinkStyle($styleName, $styles) {
if(!array_key_exists($styleName, self::$_styleElements)) {
$style = new PHPWord_Style_Font('link');
foreach($styles as $key => $value) {
if(substr($key, 0, 1) != '_') {
$key = '_'.$key;
}
$style->setStyleValue($key, $value);
}
self::$_styleElements[$styleName] = $style;
}
} | php | public static function addLinkStyle($styleName, $styles) {
if(!array_key_exists($styleName, self::$_styleElements)) {
$style = new PHPWord_Style_Font('link');
foreach($styles as $key => $value) {
if(substr($key, 0, 1) != '_') {
$key = '_'.$key;
}
$style->setStyleValue($key, $value);
}
self::$_styleElements[$styleName] = $style;
}
} | [
"public",
"static",
"function",
"addLinkStyle",
"(",
"$",
"styleName",
",",
"$",
"styles",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"styleName",
",",
"self",
"::",
"$",
"_styleElements",
")",
")",
"{",
"$",
"style",
"=",
"new",
"PHPWord_Style_Font",
"(",
"'link'",
")",
";",
"foreach",
"(",
"$",
"styles",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"key",
",",
"0",
",",
"1",
")",
"!=",
"'_'",
")",
"{",
"$",
"key",
"=",
"'_'",
".",
"$",
"key",
";",
"}",
"$",
"style",
"->",
"setStyleValue",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"self",
"::",
"$",
"_styleElements",
"[",
"$",
"styleName",
"]",
"=",
"$",
"style",
";",
"}",
"}"
] | Add a link style
@param string $styleName
@param array $styles | [
"Add",
"a",
"link",
"style"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Style.php#L92-L104 |
webforge-labs/psc-cms | lib/PHPWord/PHPWord/Style.php | PHPWord_Style.addTableStyle | public static function addTableStyle($styleName, $styleTable, $styleFirstRow = null, $styleLastRow = null) {
if(!array_key_exists($styleName, self::$_styleElements)) {
$style = new PHPWord_Style_TableFull($styleTable, $styleFirstRow, $styleLastRow);
self::$_styleElements[$styleName] = $style;
}
} | php | public static function addTableStyle($styleName, $styleTable, $styleFirstRow = null, $styleLastRow = null) {
if(!array_key_exists($styleName, self::$_styleElements)) {
$style = new PHPWord_Style_TableFull($styleTable, $styleFirstRow, $styleLastRow);
self::$_styleElements[$styleName] = $style;
}
} | [
"public",
"static",
"function",
"addTableStyle",
"(",
"$",
"styleName",
",",
"$",
"styleTable",
",",
"$",
"styleFirstRow",
"=",
"null",
",",
"$",
"styleLastRow",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"styleName",
",",
"self",
"::",
"$",
"_styleElements",
")",
")",
"{",
"$",
"style",
"=",
"new",
"PHPWord_Style_TableFull",
"(",
"$",
"styleTable",
",",
"$",
"styleFirstRow",
",",
"$",
"styleLastRow",
")",
";",
"self",
"::",
"$",
"_styleElements",
"[",
"$",
"styleName",
"]",
"=",
"$",
"style",
";",
"}",
"}"
] | Add a table style
@param string $styleName
@param array $styles | [
"Add",
"a",
"table",
"style"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Style.php#L112-L118 |
struzik-vladislav/php-error-handler | src/ErrorHandler.php | ErrorHandler.handle | public function handle($errno, $errstr, $errfile, $errline)
{
if (!$this->processorsStack) {
return null;
}
foreach ($this->processorsStack as $processor) {
if (!($processor->getErrorTypes() & $errno)) {
continue;
}
$lastResult = $processor->handle($errno, $errstr, $errfile, $errline);
}
return isset($lastResult) ? $lastResult : null;
} | php | public function handle($errno, $errstr, $errfile, $errline)
{
if (!$this->processorsStack) {
return null;
}
foreach ($this->processorsStack as $processor) {
if (!($processor->getErrorTypes() & $errno)) {
continue;
}
$lastResult = $processor->handle($errno, $errstr, $errfile, $errline);
}
return isset($lastResult) ? $lastResult : null;
} | [
"public",
"function",
"handle",
"(",
"$",
"errno",
",",
"$",
"errstr",
",",
"$",
"errfile",
",",
"$",
"errline",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"processorsStack",
")",
"{",
"return",
"null",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"processorsStack",
"as",
"$",
"processor",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"processor",
"->",
"getErrorTypes",
"(",
")",
"&",
"$",
"errno",
")",
")",
"{",
"continue",
";",
"}",
"$",
"lastResult",
"=",
"$",
"processor",
"->",
"handle",
"(",
"$",
"errno",
",",
"$",
"errstr",
",",
"$",
"errfile",
",",
"$",
"errline",
")",
";",
"}",
"return",
"isset",
"(",
"$",
"lastResult",
")",
"?",
"$",
"lastResult",
":",
"null",
";",
"}"
] | Error handler.
@param int $errno level of the error raised
@param string $errstr error message
@param string $errfile filename that the error was raised
@param int $errline line number the error was raised
@return mixed | [
"Error",
"handler",
"."
] | train | https://github.com/struzik-vladislav/php-error-handler/blob/87fa9f56edca7011f78e00659bb094b4fe713ebe/src/ErrorHandler.php#L28-L43 |
struzik-vladislav/php-error-handler | src/ErrorHandler.php | ErrorHandler.setProcessorsStack | public function setProcessorsStack(array $stack)
{
$this->processorsStack = [];
foreach (array_reverse($stack) as $processor) {
$this->pushProcessor($processor);
}
return $this;
} | php | public function setProcessorsStack(array $stack)
{
$this->processorsStack = [];
foreach (array_reverse($stack) as $processor) {
$this->pushProcessor($processor);
}
return $this;
} | [
"public",
"function",
"setProcessorsStack",
"(",
"array",
"$",
"stack",
")",
"{",
"$",
"this",
"->",
"processorsStack",
"=",
"[",
"]",
";",
"foreach",
"(",
"array_reverse",
"(",
"$",
"stack",
")",
"as",
"$",
"processor",
")",
"{",
"$",
"this",
"->",
"pushProcessor",
"(",
"$",
"processor",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Setting the processors stack as array.
@param ProcessorInterface[] $stack processors stack
@return ErrorHandler | [
"Setting",
"the",
"processors",
"stack",
"as",
"array",
"."
] | train | https://github.com/struzik-vladislav/php-error-handler/blob/87fa9f56edca7011f78e00659bb094b4fe713ebe/src/ErrorHandler.php#L102-L110 |
webforge-labs/psc-cms | lib/Psc/CMS/Action.php | Action.getEntityMeta | public function getEntityMeta(EntityMetaProvider $entityMetaProvider = NULL) {
if (!isset($this->entityMeta) && $this->type === self::SPECIFIC) {
if (!isset($entityMetaProvider)) throw new \LogicException('Missing Parameter 1 (EntityMetaProvider) for '.__FUNCTION__);
$this->entityMeta = $entityMetaProvider->getEntityMeta($this->entity->getEntityName());
}
return $this->entityMeta;
} | php | public function getEntityMeta(EntityMetaProvider $entityMetaProvider = NULL) {
if (!isset($this->entityMeta) && $this->type === self::SPECIFIC) {
if (!isset($entityMetaProvider)) throw new \LogicException('Missing Parameter 1 (EntityMetaProvider) for '.__FUNCTION__);
$this->entityMeta = $entityMetaProvider->getEntityMeta($this->entity->getEntityName());
}
return $this->entityMeta;
} | [
"public",
"function",
"getEntityMeta",
"(",
"EntityMetaProvider",
"$",
"entityMetaProvider",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"entityMeta",
")",
"&&",
"$",
"this",
"->",
"type",
"===",
"self",
"::",
"SPECIFIC",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"entityMetaProvider",
")",
")",
"throw",
"new",
"\\",
"LogicException",
"(",
"'Missing Parameter 1 (EntityMetaProvider) for '",
".",
"__FUNCTION__",
")",
";",
"$",
"this",
"->",
"entityMeta",
"=",
"$",
"entityMetaProvider",
"->",
"getEntityMeta",
"(",
"$",
"this",
"->",
"entity",
"->",
"getEntityName",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"entityMeta",
";",
"}"
] | Returns the EntityMeta for specific or general type
Attention: When type is specific $dc is not optional!
@return Psc\CMS\EntityMeta | [
"Returns",
"the",
"EntityMeta",
"for",
"specific",
"or",
"general",
"type"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/Action.php#L48-L56 |
joomlatools/joomlatools-platform-legacy | code/exception/exception.php | JException.get | public function get($property, $default = null)
{
JLog::add('JException::get is deprecated.', JLog::WARNING, 'deprecated');
if (isset($this->$property))
{
return $this->$property;
}
return $default;
} | php | public function get($property, $default = null)
{
JLog::add('JException::get is deprecated.', JLog::WARNING, 'deprecated');
if (isset($this->$property))
{
return $this->$property;
}
return $default;
} | [
"public",
"function",
"get",
"(",
"$",
"property",
",",
"$",
"default",
"=",
"null",
")",
"{",
"JLog",
"::",
"add",
"(",
"'JException::get is deprecated.'",
",",
"JLog",
"::",
"WARNING",
",",
"'deprecated'",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"$",
"property",
")",
")",
"{",
"return",
"$",
"this",
"->",
"$",
"property",
";",
"}",
"return",
"$",
"default",
";",
"}"
] | Returns a property of the object or the default value if the property is not set.
@param string $property The name of the property
@param mixed $default The default value
@return mixed The value of the property or null
@deprecated 12.1
@see JException::getProperties()
@since 11.1 | [
"Returns",
"a",
"property",
"of",
"the",
"object",
"or",
"the",
"default",
"value",
"if",
"the",
"property",
"is",
"not",
"set",
"."
] | train | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/exception/exception.php#L219-L229 |
joomlatools/joomlatools-platform-legacy | code/exception/exception.php | JException.getProperties | public function getProperties($public = true)
{
JLog::add('JException::getProperties is deprecated.', JLog::WARNING, 'deprecated');
$vars = get_object_vars($this);
if ($public)
{
foreach ($vars as $key => $value)
{
if ('_' == substr($key, 0, 1))
{
unset($vars[$key]);
}
}
}
return $vars;
} | php | public function getProperties($public = true)
{
JLog::add('JException::getProperties is deprecated.', JLog::WARNING, 'deprecated');
$vars = get_object_vars($this);
if ($public)
{
foreach ($vars as $key => $value)
{
if ('_' == substr($key, 0, 1))
{
unset($vars[$key]);
}
}
}
return $vars;
} | [
"public",
"function",
"getProperties",
"(",
"$",
"public",
"=",
"true",
")",
"{",
"JLog",
"::",
"add",
"(",
"'JException::getProperties is deprecated.'",
",",
"JLog",
"::",
"WARNING",
",",
"'deprecated'",
")",
";",
"$",
"vars",
"=",
"get_object_vars",
"(",
"$",
"this",
")",
";",
"if",
"(",
"$",
"public",
")",
"{",
"foreach",
"(",
"$",
"vars",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"'_'",
"==",
"substr",
"(",
"$",
"key",
",",
"0",
",",
"1",
")",
")",
"{",
"unset",
"(",
"$",
"vars",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"}",
"return",
"$",
"vars",
";",
"}"
] | Returns an associative array of object properties
@param boolean $public If true, returns only the public properties
@return array Object properties
@deprecated 12.1
@see JException::get()
@since 11.1 | [
"Returns",
"an",
"associative",
"array",
"of",
"object",
"properties"
] | train | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/exception/exception.php#L242-L260 |
joomlatools/joomlatools-platform-legacy | code/exception/exception.php | JException.set | public function set($property, $value = null)
{
JLog::add('JException::set is deprecated.', JLog::WARNING, 'deprecated');
$previous = isset($this->$property) ? $this->$property : null;
$this->$property = $value;
return $previous;
} | php | public function set($property, $value = null)
{
JLog::add('JException::set is deprecated.', JLog::WARNING, 'deprecated');
$previous = isset($this->$property) ? $this->$property : null;
$this->$property = $value;
return $previous;
} | [
"public",
"function",
"set",
"(",
"$",
"property",
",",
"$",
"value",
"=",
"null",
")",
"{",
"JLog",
"::",
"add",
"(",
"'JException::set is deprecated.'",
",",
"JLog",
"::",
"WARNING",
",",
"'deprecated'",
")",
";",
"$",
"previous",
"=",
"isset",
"(",
"$",
"this",
"->",
"$",
"property",
")",
"?",
"$",
"this",
"->",
"$",
"property",
":",
"null",
";",
"$",
"this",
"->",
"$",
"property",
"=",
"$",
"value",
";",
"return",
"$",
"previous",
";",
"}"
] | Modifies a property of the object, creating it if it does not already exist.
@param string $property The name of the property
@param mixed $value The value of the property to set
@return mixed Previous value of the property
@deprecated 12.1
@see JException::setProperties()
@since 11.1 | [
"Modifies",
"a",
"property",
"of",
"the",
"object",
"creating",
"it",
"if",
"it",
"does",
"not",
"already",
"exist",
"."
] | train | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/exception/exception.php#L331-L339 |
joomlatools/joomlatools-platform-legacy | code/exception/exception.php | JException.setProperties | public function setProperties($properties)
{
JLog::add('JException::setProperties is deprecated.', JLog::WARNING, 'deprecated');
// Cast to an array
$properties = (array) $properties;
if (is_array($properties))
{
foreach ($properties as $k => $v)
{
$this->$k = $v;
}
return true;
}
return false;
} | php | public function setProperties($properties)
{
JLog::add('JException::setProperties is deprecated.', JLog::WARNING, 'deprecated');
// Cast to an array
$properties = (array) $properties;
if (is_array($properties))
{
foreach ($properties as $k => $v)
{
$this->$k = $v;
}
return true;
}
return false;
} | [
"public",
"function",
"setProperties",
"(",
"$",
"properties",
")",
"{",
"JLog",
"::",
"add",
"(",
"'JException::setProperties is deprecated.'",
",",
"JLog",
"::",
"WARNING",
",",
"'deprecated'",
")",
";",
"// Cast to an array",
"$",
"properties",
"=",
"(",
"array",
")",
"$",
"properties",
";",
"if",
"(",
"is_array",
"(",
"$",
"properties",
")",
")",
"{",
"foreach",
"(",
"$",
"properties",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"this",
"->",
"$",
"k",
"=",
"$",
"v",
";",
"}",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Set the object properties based on a named array/hash
@param mixed $properties Either and associative array or another object
@return boolean
@deprecated 12.1
@see JException::set()
@since 11.1 | [
"Set",
"the",
"object",
"properties",
"based",
"on",
"a",
"named",
"array",
"/",
"hash"
] | train | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/exception/exception.php#L352-L370 |
joomlatools/joomlatools-platform-legacy | code/exception/exception.php | JException.setError | public function setError($error)
{
JLog::add('JException::setErrors is deprecated.', JLog::WARNING, 'deprecated');
array_push($this->_errors, $error);
} | php | public function setError($error)
{
JLog::add('JException::setErrors is deprecated.', JLog::WARNING, 'deprecated');
array_push($this->_errors, $error);
} | [
"public",
"function",
"setError",
"(",
"$",
"error",
")",
"{",
"JLog",
"::",
"add",
"(",
"'JException::setErrors is deprecated.'",
",",
"JLog",
"::",
"WARNING",
",",
"'deprecated'",
")",
";",
"array_push",
"(",
"$",
"this",
"->",
"_errors",
",",
"$",
"error",
")",
";",
"}"
] | Add an error message
@param string $error Error message
@return void
@since 11.1
@deprecated 12.1 | [
"Add",
"an",
"error",
"message"
] | train | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/exception/exception.php#L383-L388 |
ChadSikorra/php-simple-enum | src/Enums/EnumTrait.php | EnumTrait.isValidValue | public static function isValidValue($value, $strict = false)
{
static::initialize();
return (array_search($value, static::$constants, $strict) !== false);
} | php | public static function isValidValue($value, $strict = false)
{
static::initialize();
return (array_search($value, static::$constants, $strict) !== false);
} | [
"public",
"static",
"function",
"isValidValue",
"(",
"$",
"value",
",",
"$",
"strict",
"=",
"false",
")",
"{",
"static",
"::",
"initialize",
"(",
")",
";",
"return",
"(",
"array_search",
"(",
"$",
"value",
",",
"static",
"::",
"$",
"constants",
",",
"$",
"strict",
")",
"!==",
"false",
")",
";",
"}"
] | Check if a specific enum exists by value.
@param $value
@param bool $strict
@return bool | [
"Check",
"if",
"a",
"specific",
"enum",
"exists",
"by",
"value",
"."
] | train | https://github.com/ChadSikorra/php-simple-enum/blob/781f87ae9f4cc75fb2edab6517c6471c0181e93b/src/Enums/EnumTrait.php#L101-L106 |
ChadSikorra/php-simple-enum | src/Enums/EnumTrait.php | EnumTrait.getValueName | public static function getValueName($value, $strict = false)
{
if (!static::isValidValue($value)) {
throw new \InvalidArgumentException('No enum name was found for the value supplied.');
}
return array_search($value, static::$constants, $strict);
} | php | public static function getValueName($value, $strict = false)
{
if (!static::isValidValue($value)) {
throw new \InvalidArgumentException('No enum name was found for the value supplied.');
}
return array_search($value, static::$constants, $strict);
} | [
"public",
"static",
"function",
"getValueName",
"(",
"$",
"value",
",",
"$",
"strict",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"static",
"::",
"isValidValue",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'No enum name was found for the value supplied.'",
")",
";",
"}",
"return",
"array_search",
"(",
"$",
"value",
",",
"static",
"::",
"$",
"constants",
",",
"$",
"strict",
")",
";",
"}"
] | Get the enum name from its value.
@param mixed $value
@param bool $strict
@return string | [
"Get",
"the",
"enum",
"name",
"from",
"its",
"value",
"."
] | train | https://github.com/ChadSikorra/php-simple-enum/blob/781f87ae9f4cc75fb2edab6517c6471c0181e93b/src/Enums/EnumTrait.php#L115-L122 |
ChadSikorra/php-simple-enum | src/Enums/EnumTrait.php | EnumTrait.getNameValue | public static function getNameValue($name)
{
static::initialize();
if (!static::isValidName($name)) {
throw new \InvalidArgumentException(sprintf(
'The enum name "%s" is not valid. Expected one of: %s',
$name,
implode(', ', static::names())
));
}
return static::$constants[static::$lcKeyMap[strtolower($name)]];
} | php | public static function getNameValue($name)
{
static::initialize();
if (!static::isValidName($name)) {
throw new \InvalidArgumentException(sprintf(
'The enum name "%s" is not valid. Expected one of: %s',
$name,
implode(', ', static::names())
));
}
return static::$constants[static::$lcKeyMap[strtolower($name)]];
} | [
"public",
"static",
"function",
"getNameValue",
"(",
"$",
"name",
")",
"{",
"static",
"::",
"initialize",
"(",
")",
";",
"if",
"(",
"!",
"static",
"::",
"isValidName",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The enum name \"%s\" is not valid. Expected one of: %s'",
",",
"$",
"name",
",",
"implode",
"(",
"', '",
",",
"static",
"::",
"names",
"(",
")",
")",
")",
")",
";",
"}",
"return",
"static",
"::",
"$",
"constants",
"[",
"static",
"::",
"$",
"lcKeyMap",
"[",
"strtolower",
"(",
"$",
"name",
")",
"]",
"]",
";",
"}"
] | Get the enum value from its name.
@param string $name
@return mixed | [
"Get",
"the",
"enum",
"value",
"from",
"its",
"name",
"."
] | train | https://github.com/ChadSikorra/php-simple-enum/blob/781f87ae9f4cc75fb2edab6517c6471c0181e93b/src/Enums/EnumTrait.php#L130-L143 |
ChadSikorra/php-simple-enum | src/Enums/EnumTrait.php | EnumTrait.initialize | protected static function initialize()
{
$class = static::class;
if (static::$constants === null) {
static::$constants = (new \ReflectionClass($class))->getConstants();
foreach (static::names() as $name) {
static::$lcKeyMap[strtolower($name)] = $name;
}
}
} | php | protected static function initialize()
{
$class = static::class;
if (static::$constants === null) {
static::$constants = (new \ReflectionClass($class))->getConstants();
foreach (static::names() as $name) {
static::$lcKeyMap[strtolower($name)] = $name;
}
}
} | [
"protected",
"static",
"function",
"initialize",
"(",
")",
"{",
"$",
"class",
"=",
"static",
"::",
"class",
";",
"if",
"(",
"static",
"::",
"$",
"constants",
"===",
"null",
")",
"{",
"static",
"::",
"$",
"constants",
"=",
"(",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"class",
")",
")",
"->",
"getConstants",
"(",
")",
";",
"foreach",
"(",
"static",
"::",
"names",
"(",
")",
"as",
"$",
"name",
")",
"{",
"static",
"::",
"$",
"lcKeyMap",
"[",
"strtolower",
"(",
"$",
"name",
")",
"]",
"=",
"$",
"name",
";",
"}",
"}",
"}"
] | Cache the enum array statically so we only have to do reflection a single time. | [
"Cache",
"the",
"enum",
"array",
"statically",
"so",
"we",
"only",
"have",
"to",
"do",
"reflection",
"a",
"single",
"time",
"."
] | train | https://github.com/ChadSikorra/php-simple-enum/blob/781f87ae9f4cc75fb2edab6517c6471c0181e93b/src/Enums/EnumTrait.php#L148-L159 |
barebone-php/barebone-core | lib/View.php | View.instance | public static function instance()
{
if (null === self::$_instance) {
self::$_instance = new Blade(
APP_ROOT . 'views',
PROJECT_ROOT . 'tmp' . DS . 'cache'
);
}
return self::$_instance;
} | php | public static function instance()
{
if (null === self::$_instance) {
self::$_instance = new Blade(
APP_ROOT . 'views',
PROJECT_ROOT . 'tmp' . DS . 'cache'
);
}
return self::$_instance;
} | [
"public",
"static",
"function",
"instance",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"self",
"::",
"$",
"_instance",
")",
"{",
"self",
"::",
"$",
"_instance",
"=",
"new",
"Blade",
"(",
"APP_ROOT",
".",
"'views'",
",",
"PROJECT_ROOT",
".",
"'tmp'",
".",
"DS",
".",
"'cache'",
")",
";",
"}",
"return",
"self",
"::",
"$",
"_instance",
";",
"}"
] | Instantiate Blade Renderer
@return Blade | [
"Instantiate",
"Blade",
"Renderer"
] | train | https://github.com/barebone-php/barebone-core/blob/7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc/lib/View.php#L46-L55 |
barebone-php/barebone-core | lib/View.php | View.render | public static function render($template, $data = [])
{
// @var \Illuminate\View\Factory $factory
$factory = self::instance()->view();
// @var \Illuminate\Contracts\View\View $view
$view = $factory->make($template, $data);
return $view->render();
} | php | public static function render($template, $data = [])
{
// @var \Illuminate\View\Factory $factory
$factory = self::instance()->view();
// @var \Illuminate\Contracts\View\View $view
$view = $factory->make($template, $data);
return $view->render();
} | [
"public",
"static",
"function",
"render",
"(",
"$",
"template",
",",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"// @var \\Illuminate\\View\\Factory $factory",
"$",
"factory",
"=",
"self",
"::",
"instance",
"(",
")",
"->",
"view",
"(",
")",
";",
"// @var \\Illuminate\\Contracts\\View\\View $view",
"$",
"view",
"=",
"$",
"factory",
"->",
"make",
"(",
"$",
"template",
",",
"$",
"data",
")",
";",
"return",
"$",
"view",
"->",
"render",
"(",
")",
";",
"}"
] | Render Blade template file with Data
@param string $template Relative path to a ".blade.php" file
@param array $data Associative array of variables names and values.
@return string HTML string | [
"Render",
"Blade",
"template",
"file",
"with",
"Data"
] | train | https://github.com/barebone-php/barebone-core/blob/7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc/lib/View.php#L65-L74 |
barebone-php/barebone-core | lib/View.php | View.renderJSON | public static function renderJSON($data = [], $flags = null)
{
if (is_null($flags)) {
$flags = JSON_HEX_TAG | JSON_HEX_APOS
| JSON_HEX_AMP | JSON_HEX_QUOT
| JSON_UNESCAPED_SLASHES;
}
json_encode(null); // clear json_last_error()
$result = json_encode($data, $flags);
if (JSON_ERROR_NONE !== json_last_error()) {
throw new InvalidArgumentException(
sprintf(
'Unable to encode data to JSON in %s: %s', __CLASS__,
json_last_error_msg()
)
);
}
return $result;
} | php | public static function renderJSON($data = [], $flags = null)
{
if (is_null($flags)) {
$flags = JSON_HEX_TAG | JSON_HEX_APOS
| JSON_HEX_AMP | JSON_HEX_QUOT
| JSON_UNESCAPED_SLASHES;
}
json_encode(null); // clear json_last_error()
$result = json_encode($data, $flags);
if (JSON_ERROR_NONE !== json_last_error()) {
throw new InvalidArgumentException(
sprintf(
'Unable to encode data to JSON in %s: %s', __CLASS__,
json_last_error_msg()
)
);
}
return $result;
} | [
"public",
"static",
"function",
"renderJSON",
"(",
"$",
"data",
"=",
"[",
"]",
",",
"$",
"flags",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"flags",
")",
")",
"{",
"$",
"flags",
"=",
"JSON_HEX_TAG",
"|",
"JSON_HEX_APOS",
"|",
"JSON_HEX_AMP",
"|",
"JSON_HEX_QUOT",
"|",
"JSON_UNESCAPED_SLASHES",
";",
"}",
"json_encode",
"(",
"null",
")",
";",
"// clear json_last_error()",
"$",
"result",
"=",
"json_encode",
"(",
"$",
"data",
",",
"$",
"flags",
")",
";",
"if",
"(",
"JSON_ERROR_NONE",
"!==",
"json_last_error",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Unable to encode data to JSON in %s: %s'",
",",
"__CLASS__",
",",
"json_last_error_msg",
"(",
")",
")",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Json Encode String with given flags
@param array $data Associative array of variables names and values.
@param integer $flags json_encode options
@throws InvalidArgumentException
@return string JSON string | [
"Json",
"Encode",
"String",
"with",
"given",
"flags"
] | train | https://github.com/barebone-php/barebone-core/blob/7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc/lib/View.php#L85-L106 |
inc2734/wp-share-buttons | src/App/Shortcode/Pinterest.php | Pinterest._shortcode | public function _shortcode( $attributes ) {
if ( ! isset( $attributes['post_id'] ) ) {
return;
}
$attributes = shortcode_atts(
[
'type' => 'balloon',
'post_id' => '',
],
$attributes
);
if ( 'official' === $attributes['type'] ) {
$file = 'official';
} else {
$file = 'pinterest';
}
return $this->render(
'pinterest/' . $file,
[
'type' => $attributes['type'],
'post_id' => $attributes['post_id'],
]
);
} | php | public function _shortcode( $attributes ) {
if ( ! isset( $attributes['post_id'] ) ) {
return;
}
$attributes = shortcode_atts(
[
'type' => 'balloon',
'post_id' => '',
],
$attributes
);
if ( 'official' === $attributes['type'] ) {
$file = 'official';
} else {
$file = 'pinterest';
}
return $this->render(
'pinterest/' . $file,
[
'type' => $attributes['type'],
'post_id' => $attributes['post_id'],
]
);
} | [
"public",
"function",
"_shortcode",
"(",
"$",
"attributes",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"attributes",
"[",
"'post_id'",
"]",
")",
")",
"{",
"return",
";",
"}",
"$",
"attributes",
"=",
"shortcode_atts",
"(",
"[",
"'type'",
"=>",
"'balloon'",
",",
"'post_id'",
"=>",
"''",
",",
"]",
",",
"$",
"attributes",
")",
";",
"if",
"(",
"'official'",
"===",
"$",
"attributes",
"[",
"'type'",
"]",
")",
"{",
"$",
"file",
"=",
"'official'",
";",
"}",
"else",
"{",
"$",
"file",
"=",
"'pinterest'",
";",
"}",
"return",
"$",
"this",
"->",
"render",
"(",
"'pinterest/'",
".",
"$",
"file",
",",
"[",
"'type'",
"=>",
"$",
"attributes",
"[",
"'type'",
"]",
",",
"'post_id'",
"=>",
"$",
"attributes",
"[",
"'post_id'",
"]",
",",
"]",
")",
";",
"}"
] | Register shortcode
@param array $attributes
@return void | [
"Register",
"shortcode"
] | train | https://github.com/inc2734/wp-share-buttons/blob/cd032893ca083a343f5871e855cce68f4ede3a17/src/App/Shortcode/Pinterest.php#L23-L49 |
rayrutjes/domain-foundation | src/Persistence/Pdo/EventStore/PdoEventStore.php | PdoEventStore.append | public function append(Contract $aggregateRootType, EventStream $eventStream)
{
$statement = $this->insertQuery->prepare();
try {
while ($eventStream->hasNext()) {
$event = $eventStream->next();
$statement->bindValue(':aggregate_id', $event->aggregateRootIdentifier()->toString());
$statement->bindValue(':aggregate_type', $aggregateRootType->toString());
$statement->bindValue(':aggregate_version', $event->sequenceNumber());
$statement->bindValue(':event_id', $event->identifier()->toString());
$statement->bindValue(':event_payload', $this->eventSerializer->serializePayload($event));
$statement->bindValue(':event_payload_type', $event->payloadType()->toString());
$statement->bindValue(':event_metadata', $this->eventSerializer->serializeMetadata($event));
$statement->bindValue(':event_metadata_type', $event->metadataType()->toString());
$statement->execute();
$statement->closeCursor();
}
} catch (\PDOException $exception) {
// 23000 being the primary key duplicate entry error code.
if ($exception->errorInfo[0] === '23000') {
throw new ConcurrencyException('Concurrent modification detected.');
}
throw $exception;
}
} | php | public function append(Contract $aggregateRootType, EventStream $eventStream)
{
$statement = $this->insertQuery->prepare();
try {
while ($eventStream->hasNext()) {
$event = $eventStream->next();
$statement->bindValue(':aggregate_id', $event->aggregateRootIdentifier()->toString());
$statement->bindValue(':aggregate_type', $aggregateRootType->toString());
$statement->bindValue(':aggregate_version', $event->sequenceNumber());
$statement->bindValue(':event_id', $event->identifier()->toString());
$statement->bindValue(':event_payload', $this->eventSerializer->serializePayload($event));
$statement->bindValue(':event_payload_type', $event->payloadType()->toString());
$statement->bindValue(':event_metadata', $this->eventSerializer->serializeMetadata($event));
$statement->bindValue(':event_metadata_type', $event->metadataType()->toString());
$statement->execute();
$statement->closeCursor();
}
} catch (\PDOException $exception) {
// 23000 being the primary key duplicate entry error code.
if ($exception->errorInfo[0] === '23000') {
throw new ConcurrencyException('Concurrent modification detected.');
}
throw $exception;
}
} | [
"public",
"function",
"append",
"(",
"Contract",
"$",
"aggregateRootType",
",",
"EventStream",
"$",
"eventStream",
")",
"{",
"$",
"statement",
"=",
"$",
"this",
"->",
"insertQuery",
"->",
"prepare",
"(",
")",
";",
"try",
"{",
"while",
"(",
"$",
"eventStream",
"->",
"hasNext",
"(",
")",
")",
"{",
"$",
"event",
"=",
"$",
"eventStream",
"->",
"next",
"(",
")",
";",
"$",
"statement",
"->",
"bindValue",
"(",
"':aggregate_id'",
",",
"$",
"event",
"->",
"aggregateRootIdentifier",
"(",
")",
"->",
"toString",
"(",
")",
")",
";",
"$",
"statement",
"->",
"bindValue",
"(",
"':aggregate_type'",
",",
"$",
"aggregateRootType",
"->",
"toString",
"(",
")",
")",
";",
"$",
"statement",
"->",
"bindValue",
"(",
"':aggregate_version'",
",",
"$",
"event",
"->",
"sequenceNumber",
"(",
")",
")",
";",
"$",
"statement",
"->",
"bindValue",
"(",
"':event_id'",
",",
"$",
"event",
"->",
"identifier",
"(",
")",
"->",
"toString",
"(",
")",
")",
";",
"$",
"statement",
"->",
"bindValue",
"(",
"':event_payload'",
",",
"$",
"this",
"->",
"eventSerializer",
"->",
"serializePayload",
"(",
"$",
"event",
")",
")",
";",
"$",
"statement",
"->",
"bindValue",
"(",
"':event_payload_type'",
",",
"$",
"event",
"->",
"payloadType",
"(",
")",
"->",
"toString",
"(",
")",
")",
";",
"$",
"statement",
"->",
"bindValue",
"(",
"':event_metadata'",
",",
"$",
"this",
"->",
"eventSerializer",
"->",
"serializeMetadata",
"(",
"$",
"event",
")",
")",
";",
"$",
"statement",
"->",
"bindValue",
"(",
"':event_metadata_type'",
",",
"$",
"event",
"->",
"metadataType",
"(",
")",
"->",
"toString",
"(",
")",
")",
";",
"$",
"statement",
"->",
"execute",
"(",
")",
";",
"$",
"statement",
"->",
"closeCursor",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"\\",
"PDOException",
"$",
"exception",
")",
"{",
"// 23000 being the primary key duplicate entry error code.",
"if",
"(",
"$",
"exception",
"->",
"errorInfo",
"[",
"0",
"]",
"===",
"'23000'",
")",
"{",
"throw",
"new",
"ConcurrencyException",
"(",
"'Concurrent modification detected.'",
")",
";",
"}",
"throw",
"$",
"exception",
";",
"}",
"}"
] | @param Contract $aggregateRootType
@param EventStream $eventStream
@throws \Exception | [
"@param",
"Contract",
"$aggregateRootType",
"@param",
"EventStream",
"$eventStream"
] | train | https://github.com/rayrutjes/domain-foundation/blob/2bce7cd6a6612f718e70e3176589c1abf39d1a3e/src/Persistence/Pdo/EventStore/PdoEventStore.php#L72-L100 |
rayrutjes/domain-foundation | src/Persistence/Pdo/EventStore/PdoEventStore.php | PdoEventStore.read | public function read(Contract $aggregateRootType, AggregateRootIdentifier $aggregateRootIdentifier)
{
$statement = $this->selectQuery->prepare();
$statement->bindValue(':aggregate_id', $aggregateRootIdentifier->toString());
$statement->bindValue(':aggregate_type', $aggregateRootType->toString());
$statement->execute();
$records = $statement->fetchAll(\PDO::FETCH_ASSOC);
$statement->closeCursor();
return new PdoReadRecordEventStream(
$aggregateRootIdentifier,
$records,
$this->eventSerializer
);
} | php | public function read(Contract $aggregateRootType, AggregateRootIdentifier $aggregateRootIdentifier)
{
$statement = $this->selectQuery->prepare();
$statement->bindValue(':aggregate_id', $aggregateRootIdentifier->toString());
$statement->bindValue(':aggregate_type', $aggregateRootType->toString());
$statement->execute();
$records = $statement->fetchAll(\PDO::FETCH_ASSOC);
$statement->closeCursor();
return new PdoReadRecordEventStream(
$aggregateRootIdentifier,
$records,
$this->eventSerializer
);
} | [
"public",
"function",
"read",
"(",
"Contract",
"$",
"aggregateRootType",
",",
"AggregateRootIdentifier",
"$",
"aggregateRootIdentifier",
")",
"{",
"$",
"statement",
"=",
"$",
"this",
"->",
"selectQuery",
"->",
"prepare",
"(",
")",
";",
"$",
"statement",
"->",
"bindValue",
"(",
"':aggregate_id'",
",",
"$",
"aggregateRootIdentifier",
"->",
"toString",
"(",
")",
")",
";",
"$",
"statement",
"->",
"bindValue",
"(",
"':aggregate_type'",
",",
"$",
"aggregateRootType",
"->",
"toString",
"(",
")",
")",
";",
"$",
"statement",
"->",
"execute",
"(",
")",
";",
"$",
"records",
"=",
"$",
"statement",
"->",
"fetchAll",
"(",
"\\",
"PDO",
"::",
"FETCH_ASSOC",
")",
";",
"$",
"statement",
"->",
"closeCursor",
"(",
")",
";",
"return",
"new",
"PdoReadRecordEventStream",
"(",
"$",
"aggregateRootIdentifier",
",",
"$",
"records",
",",
"$",
"this",
"->",
"eventSerializer",
")",
";",
"}"
] | @param Contract $aggregateRootType
@param AggregateRootIdentifier $aggregateRootIdentifier
@return EventStream | [
"@param",
"Contract",
"$aggregateRootType",
"@param",
"AggregateRootIdentifier",
"$aggregateRootIdentifier"
] | train | https://github.com/rayrutjes/domain-foundation/blob/2bce7cd6a6612f718e70e3176589c1abf39d1a3e/src/Persistence/Pdo/EventStore/PdoEventStore.php#L108-L125 |
boekkooi/tactician-amqp | src/Middleware/Transaction/InMemoryMiddleware.php | InMemoryMiddleware.execute | public function execute($command, callable $next)
{
if ($this->transactionLevel > 0) {
$this->storeMessages();
}
++$this->transactionLevel;
end($this->transactionMessages);
$savepoint = key($this->transactionMessages);
$savepoint = $savepoint === null ? 0 : ++$savepoint;
try {
$returnValue = $next($command);
$this->storeMessages();
--$this->transactionLevel;
} catch (\Exception $e) {
$this->capturer->clear();
array_splice($this->transactionMessages, $savepoint);
--$this->transactionLevel;
throw $e;
} catch (\Error $e) {
$this->capturer->clear();
array_splice($this->transactionMessages, $savepoint);
--$this->transactionLevel;
throw $e;
}
if ($this->transactionLevel === 0) {
$this->publish();
}
return $returnValue;
} | php | public function execute($command, callable $next)
{
if ($this->transactionLevel > 0) {
$this->storeMessages();
}
++$this->transactionLevel;
end($this->transactionMessages);
$savepoint = key($this->transactionMessages);
$savepoint = $savepoint === null ? 0 : ++$savepoint;
try {
$returnValue = $next($command);
$this->storeMessages();
--$this->transactionLevel;
} catch (\Exception $e) {
$this->capturer->clear();
array_splice($this->transactionMessages, $savepoint);
--$this->transactionLevel;
throw $e;
} catch (\Error $e) {
$this->capturer->clear();
array_splice($this->transactionMessages, $savepoint);
--$this->transactionLevel;
throw $e;
}
if ($this->transactionLevel === 0) {
$this->publish();
}
return $returnValue;
} | [
"public",
"function",
"execute",
"(",
"$",
"command",
",",
"callable",
"$",
"next",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"transactionLevel",
">",
"0",
")",
"{",
"$",
"this",
"->",
"storeMessages",
"(",
")",
";",
"}",
"++",
"$",
"this",
"->",
"transactionLevel",
";",
"end",
"(",
"$",
"this",
"->",
"transactionMessages",
")",
";",
"$",
"savepoint",
"=",
"key",
"(",
"$",
"this",
"->",
"transactionMessages",
")",
";",
"$",
"savepoint",
"=",
"$",
"savepoint",
"===",
"null",
"?",
"0",
":",
"++",
"$",
"savepoint",
";",
"try",
"{",
"$",
"returnValue",
"=",
"$",
"next",
"(",
"$",
"command",
")",
";",
"$",
"this",
"->",
"storeMessages",
"(",
")",
";",
"--",
"$",
"this",
"->",
"transactionLevel",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"capturer",
"->",
"clear",
"(",
")",
";",
"array_splice",
"(",
"$",
"this",
"->",
"transactionMessages",
",",
"$",
"savepoint",
")",
";",
"--",
"$",
"this",
"->",
"transactionLevel",
";",
"throw",
"$",
"e",
";",
"}",
"catch",
"(",
"\\",
"Error",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"capturer",
"->",
"clear",
"(",
")",
";",
"array_splice",
"(",
"$",
"this",
"->",
"transactionMessages",
",",
"$",
"savepoint",
")",
";",
"--",
"$",
"this",
"->",
"transactionLevel",
";",
"throw",
"$",
"e",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"transactionLevel",
"===",
"0",
")",
"{",
"$",
"this",
"->",
"publish",
"(",
")",
";",
"}",
"return",
"$",
"returnValue",
";",
"}"
] | Executes the given command and optionally returns a value
@param object $command
@param callable $next
@return mixed
@throws \Error
@throws \Exception | [
"Executes",
"the",
"given",
"command",
"and",
"optionally",
"returns",
"a",
"value"
] | train | https://github.com/boekkooi/tactician-amqp/blob/55cbb8b9e20aab7891e6a6090b248377c599360e/src/Middleware/Transaction/InMemoryMiddleware.php#L51-L88 |
webforge-labs/psc-cms | lib/Psc/CMS/Controller/BaseController.php | BaseController.getTodo | public function getTodo($todoAlias = NULL) {
if ($todoAlias === NULL) return $this->todo;
if (array_key_exists($todoAlias,$this->todoMap)) {
return $this->todoMap[$todoAlias];
} else {
throw new InvalidTodoException('Kein Alias für '.Code::varInfo($todoAlias).' gefunden. Ist dieser String ein Schlüssel in der todoMap?');
}
} | php | public function getTodo($todoAlias = NULL) {
if ($todoAlias === NULL) return $this->todo;
if (array_key_exists($todoAlias,$this->todoMap)) {
return $this->todoMap[$todoAlias];
} else {
throw new InvalidTodoException('Kein Alias für '.Code::varInfo($todoAlias).' gefunden. Ist dieser String ein Schlüssel in der todoMap?');
}
} | [
"public",
"function",
"getTodo",
"(",
"$",
"todoAlias",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"todoAlias",
"===",
"NULL",
")",
"return",
"$",
"this",
"->",
"todo",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"todoAlias",
",",
"$",
"this",
"->",
"todoMap",
")",
")",
"{",
"return",
"$",
"this",
"->",
"todoMap",
"[",
"$",
"todoAlias",
"]",
";",
"}",
"else",
"{",
"throw",
"new",
"InvalidTodoException",
"(",
"'Kein Alias für '.",
"C",
"ode:",
":v",
"arInfo(",
"$",
"t",
"odoAlias)",
".",
"'",
" gefunden. Ist dieser String ein Schlüssel in der todoMap?');",
"",
"",
"}",
"}"
] | Wenn kein Parameter übergeben wird gibt es den aktuellen TODO zurück
wenn gesetzt wird die Konstante für den todoString zurückgegeben
@param string $todoString
@return const | [
"Wenn",
"kein",
"Parameter",
"übergeben",
"wird",
"gibt",
"es",
"den",
"aktuellen",
"TODO",
"zurück",
"wenn",
"gesetzt",
"wird",
"die",
"Konstante",
"für",
"den",
"todoString",
"zurückgegeben"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/Controller/BaseController.php#L72-L80 |
webforge-labs/psc-cms | lib/Psc/CMS/Controller/BaseController.php | BaseController.getTodoURL | public function getTodoURL($todo=NULL, $flags = 0x000000) {
return $this->getURL($this->getTodoQueryVars($todo),$flags);
} | php | public function getTodoURL($todo=NULL, $flags = 0x000000) {
return $this->getURL($this->getTodoQueryVars($todo),$flags);
} | [
"public",
"function",
"getTodoURL",
"(",
"$",
"todo",
"=",
"NULL",
",",
"$",
"flags",
"=",
"0x000000",
")",
"{",
"return",
"$",
"this",
"->",
"getURL",
"(",
"$",
"this",
"->",
"getTodoQueryVars",
"(",
"$",
"todo",
")",
",",
"$",
"flags",
")",
";",
"}"
] | Gibt die URL für eine Action des Controllers zurück
dies kann z.b. für form action="" benutzt werden
@param const $todo wenn NULL wird dies die aktuelle Action/ Default Action | [
"Gibt",
"die",
"URL",
"für",
"eine",
"Action",
"des",
"Controllers",
"zurück"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/Controller/BaseController.php#L171-L173 |
webforge-labs/psc-cms | lib/Psc/CMS/Controller/BaseController.php | BaseController.assertTodo | protected function assertTodo($todo = NULL) {
if (func_num_args() == 0) {
$todo = $this->todo;
}
if ($todo != NULL && !$this->validateTodo($todo)) {
throw new InvalidTodoException('Todo: '.Code::varInfo($todo).' ist nicht in der todoMap');
}
} | php | protected function assertTodo($todo = NULL) {
if (func_num_args() == 0) {
$todo = $this->todo;
}
if ($todo != NULL && !$this->validateTodo($todo)) {
throw new InvalidTodoException('Todo: '.Code::varInfo($todo).' ist nicht in der todoMap');
}
} | [
"protected",
"function",
"assertTodo",
"(",
"$",
"todo",
"=",
"NULL",
")",
"{",
"if",
"(",
"func_num_args",
"(",
")",
"==",
"0",
")",
"{",
"$",
"todo",
"=",
"$",
"this",
"->",
"todo",
";",
"}",
"if",
"(",
"$",
"todo",
"!=",
"NULL",
"&&",
"!",
"$",
"this",
"->",
"validateTodo",
"(",
"$",
"todo",
")",
")",
"{",
"throw",
"new",
"InvalidTodoException",
"(",
"'Todo: '",
".",
"Code",
"::",
"varInfo",
"(",
"$",
"todo",
")",
".",
"' ist nicht in der todoMap'",
")",
";",
"}",
"}"
] | Überprüft das Todo (oder das im Objekt gesetzte) und schmeisst eine invalidTodoException, wenn ddas todo gesetzt + falsch ist | [
"Überprüft",
"das",
"Todo",
"(",
"oder",
"das",
"im",
"Objekt",
"gesetzte",
")",
"und",
"schmeisst",
"eine",
"invalidTodoException",
"wenn",
"ddas",
"todo",
"gesetzt",
"+",
"falsch",
"ist"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/Controller/BaseController.php#L192-L200 |
PortaText/php-sdk | src/PortaText/Command/Api/Contacts.php | Contacts.setAll | public function setAll($variables)
{
$vars = array();
foreach ($variables as $k => $v) {
$vars[] = array('key' => $k, 'value' => $v);
}
return $this->setArgument("variables", $vars);
} | php | public function setAll($variables)
{
$vars = array();
foreach ($variables as $k => $v) {
$vars[] = array('key' => $k, 'value' => $v);
}
return $this->setArgument("variables", $vars);
} | [
"public",
"function",
"setAll",
"(",
"$",
"variables",
")",
"{",
"$",
"vars",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"variables",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"vars",
"[",
"]",
"=",
"array",
"(",
"'key'",
"=>",
"$",
"k",
",",
"'value'",
"=>",
"$",
"v",
")",
";",
"}",
"return",
"$",
"this",
"->",
"setArgument",
"(",
"\"variables\"",
",",
"$",
"vars",
")",
";",
"}"
] | Sets all the given variables.
@param array $variables variables.
@return PortaText\Command\ICommand | [
"Sets",
"all",
"the",
"given",
"variables",
"."
] | train | https://github.com/PortaText/php-sdk/blob/dbe04ef043db5b251953f9de57aa4d0f1785dfcc/src/PortaText/Command/Api/Contacts.php#L87-L94 |
PortaText/php-sdk | src/PortaText/Command/Api/Contacts.php | Contacts.getEndpoint | protected function getEndpoint($method)
{
$number = $this->getArgument("number");
$this->delArgument("number");
$endpoint = "contacts";
if (!is_null($number)) {
$endpoint .= "/$number/variables";
}
$name = $this->getArgument("name");
if (!is_null($name)) {
$endpoint .= "/$name";
$this->delArgument("name");
}
$queryString = array();
$withContactLists = $this->getArgument("with_contact_lists");
if (!is_null($withContactLists)) {
$queryString['with_contact_lists'] = "true";
$this->delArgument("with_contact_lists");
}
$page = $this->getArgument("page");
if (!is_null($page)) {
$queryString['page'] = $page;
$this->delArgument("page");
}
if (!empty($queryString)) {
$queryString = http_build_query($queryString);
return "$endpoint?$queryString";
}
return $endpoint;
} | php | protected function getEndpoint($method)
{
$number = $this->getArgument("number");
$this->delArgument("number");
$endpoint = "contacts";
if (!is_null($number)) {
$endpoint .= "/$number/variables";
}
$name = $this->getArgument("name");
if (!is_null($name)) {
$endpoint .= "/$name";
$this->delArgument("name");
}
$queryString = array();
$withContactLists = $this->getArgument("with_contact_lists");
if (!is_null($withContactLists)) {
$queryString['with_contact_lists'] = "true";
$this->delArgument("with_contact_lists");
}
$page = $this->getArgument("page");
if (!is_null($page)) {
$queryString['page'] = $page;
$this->delArgument("page");
}
if (!empty($queryString)) {
$queryString = http_build_query($queryString);
return "$endpoint?$queryString";
}
return $endpoint;
} | [
"protected",
"function",
"getEndpoint",
"(",
"$",
"method",
")",
"{",
"$",
"number",
"=",
"$",
"this",
"->",
"getArgument",
"(",
"\"number\"",
")",
";",
"$",
"this",
"->",
"delArgument",
"(",
"\"number\"",
")",
";",
"$",
"endpoint",
"=",
"\"contacts\"",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"number",
")",
")",
"{",
"$",
"endpoint",
".=",
"\"/$number/variables\"",
";",
"}",
"$",
"name",
"=",
"$",
"this",
"->",
"getArgument",
"(",
"\"name\"",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"name",
")",
")",
"{",
"$",
"endpoint",
".=",
"\"/$name\"",
";",
"$",
"this",
"->",
"delArgument",
"(",
"\"name\"",
")",
";",
"}",
"$",
"queryString",
"=",
"array",
"(",
")",
";",
"$",
"withContactLists",
"=",
"$",
"this",
"->",
"getArgument",
"(",
"\"with_contact_lists\"",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"withContactLists",
")",
")",
"{",
"$",
"queryString",
"[",
"'with_contact_lists'",
"]",
"=",
"\"true\"",
";",
"$",
"this",
"->",
"delArgument",
"(",
"\"with_contact_lists\"",
")",
";",
"}",
"$",
"page",
"=",
"$",
"this",
"->",
"getArgument",
"(",
"\"page\"",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"page",
")",
")",
"{",
"$",
"queryString",
"[",
"'page'",
"]",
"=",
"$",
"page",
";",
"$",
"this",
"->",
"delArgument",
"(",
"\"page\"",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"queryString",
")",
")",
"{",
"$",
"queryString",
"=",
"http_build_query",
"(",
"$",
"queryString",
")",
";",
"return",
"\"$endpoint?$queryString\"",
";",
"}",
"return",
"$",
"endpoint",
";",
"}"
] | Returns a string with the endpoint for the given command.
@param string $method Method for this command.
@return string | [
"Returns",
"a",
"string",
"with",
"the",
"endpoint",
"for",
"the",
"given",
"command",
"."
] | train | https://github.com/PortaText/php-sdk/blob/dbe04ef043db5b251953f9de57aa4d0f1785dfcc/src/PortaText/Command/Api/Contacts.php#L127-L156 |
nexusnetsoftgmbh/nexuscli | src/Nexus/DockerClient/Business/Model/DockerCompose.php | DockerCompose.execute | public function execute(string $command): string
{
return $this->shellFacade->runCommand($this->command . ' ' . $command);
} | php | public function execute(string $command): string
{
return $this->shellFacade->runCommand($this->command . ' ' . $command);
} | [
"public",
"function",
"execute",
"(",
"string",
"$",
"command",
")",
":",
"string",
"{",
"return",
"$",
"this",
"->",
"shellFacade",
"->",
"runCommand",
"(",
"$",
"this",
"->",
"command",
".",
"' '",
".",
"$",
"command",
")",
";",
"}"
] | @param string $command
@return string | [
"@param",
"string",
"$command"
] | train | https://github.com/nexusnetsoftgmbh/nexuscli/blob/8416b43d31ad56ea379ae2b0bf85d456e78ba67a/src/Nexus/DockerClient/Business/Model/DockerCompose.php#L39-L42 |
atkrad/data-tables | src/Extension/ColVis.php | ColVis.setLabel | public function setLabel($label)
{
$hash = sha1($label);
$this->properties['label'] = $hash;
$this->callbacks[$hash] = $label;
return $this;
} | php | public function setLabel($label)
{
$hash = sha1($label);
$this->properties['label'] = $hash;
$this->callbacks[$hash] = $label;
return $this;
} | [
"public",
"function",
"setLabel",
"(",
"$",
"label",
")",
"{",
"$",
"hash",
"=",
"sha1",
"(",
"$",
"label",
")",
";",
"$",
"this",
"->",
"properties",
"[",
"'label'",
"]",
"=",
"$",
"hash",
";",
"$",
"this",
"->",
"callbacks",
"[",
"$",
"hash",
"]",
"=",
"$",
"label",
";",
"return",
"$",
"this",
";",
"}"
] | Allows customisation of the labels used for the buttons (useful for stripping HTML for example).
Input parameters:
1) int: The column index being operated on
2) string: The title detected by DataTables' automatic methods.
3) node: The TH element for the column
Return parameter: string: The value to use for the button table
@param callback $label Allows customisation of the labels used for the buttons.
@return ColVis
@see http://datatables.net/extensions/colvis/options | [
"Allows",
"customisation",
"of",
"the",
"labels",
"used",
"for",
"the",
"buttons",
"(",
"useful",
"for",
"stripping",
"HTML",
"for",
"example",
")",
"."
] | train | https://github.com/atkrad/data-tables/blob/5afcc337ab624ca626e29d9674459c5105982b16/src/Extension/ColVis.php#L150-L157 |
atkrad/data-tables | src/Extension/ColVis.php | ColVis.setStateChange | public function setStateChange($stateChange)
{
$hash = sha1($stateChange);
$this->properties['stateChange'] = $hash;
$this->callbacks[$hash] = $stateChange;
return $this;
} | php | public function setStateChange($stateChange)
{
$hash = sha1($stateChange);
$this->properties['stateChange'] = $hash;
$this->callbacks[$hash] = $stateChange;
return $this;
} | [
"public",
"function",
"setStateChange",
"(",
"$",
"stateChange",
")",
"{",
"$",
"hash",
"=",
"sha1",
"(",
"$",
"stateChange",
")",
";",
"$",
"this",
"->",
"properties",
"[",
"'stateChange'",
"]",
"=",
"$",
"hash",
";",
"$",
"this",
"->",
"callbacks",
"[",
"$",
"hash",
"]",
"=",
"$",
"stateChange",
";",
"return",
"$",
"this",
";",
"}"
] | Set callback function to let you know when the state has changed.
@param callback $stateChange Callback function to let you know when the state has changed.
@return ColVis
@see http://datatables.net/extensions/colvis/options | [
"Set",
"callback",
"function",
"to",
"let",
"you",
"know",
"when",
"the",
"state",
"has",
"changed",
"."
] | train | https://github.com/atkrad/data-tables/blob/5afcc337ab624ca626e29d9674459c5105982b16/src/Extension/ColVis.php#L167-L174 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.