id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
sequence | docstring
stringlengths 3
47.2k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
4,300 | IVIR3zaM/ObjectArrayTools | src/Traits/SerializableTrait.php | SerializableTrait.unserialize | public function unserialize($serialized)
{
$list = unserialize($serialized);
if (is_array($list)) {
foreach ($list as $index => $value) {
$this[$index] = $value;
}
}
} | php | public function unserialize($serialized)
{
$list = unserialize($serialized);
if (is_array($list)) {
foreach ($list as $index => $value) {
$this[$index] = $value;
}
}
} | [
"public",
"function",
"unserialize",
"(",
"$",
"serialized",
")",
"{",
"$",
"list",
"=",
"unserialize",
"(",
"$",
"serialized",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"list",
")",
")",
"{",
"foreach",
"(",
"$",
"list",
"as",
"$",
"index",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"[",
"$",
"index",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"}"
] | unserialize and serialized array and make this object base on that
@param string $serialized array data | [
"unserialize",
"and",
"serialized",
"array",
"and",
"make",
"this",
"object",
"base",
"on",
"that"
] | 31c12fc6f8a40a36873c074409ae4299b35f9177 | https://github.com/IVIR3zaM/ObjectArrayTools/blob/31c12fc6f8a40a36873c074409ae4299b35f9177/src/Traits/SerializableTrait.php#L33-L41 |
4,301 | meridius/helpers | src/StringHelper.php | StringHelper.toCamelCase | public static function toCamelCase($string) {
static $canUse = null;
if (is_null($canUse)) {
$canUse = method_exists(Strings::class, 'firstLower'); // Nette/Utils >= 2.3 only
}
$pascal = self::toPascalCase($string);
return $canUse
? Strings::firstLower($pascal)
: Strings::lower(Strings::substring($pascal, 0, 1)) . Strings::substring($pascal, 1);
} | php | public static function toCamelCase($string) {
static $canUse = null;
if (is_null($canUse)) {
$canUse = method_exists(Strings::class, 'firstLower'); // Nette/Utils >= 2.3 only
}
$pascal = self::toPascalCase($string);
return $canUse
? Strings::firstLower($pascal)
: Strings::lower(Strings::substring($pascal, 0, 1)) . Strings::substring($pascal, 1);
} | [
"public",
"static",
"function",
"toCamelCase",
"(",
"$",
"string",
")",
"{",
"static",
"$",
"canUse",
"=",
"null",
";",
"if",
"(",
"is_null",
"(",
"$",
"canUse",
")",
")",
"{",
"$",
"canUse",
"=",
"method_exists",
"(",
"Strings",
"::",
"class",
",",
"'firstLower'",
")",
";",
"// Nette/Utils >= 2.3 only",
"}",
"$",
"pascal",
"=",
"self",
"::",
"toPascalCase",
"(",
"$",
"string",
")",
";",
"return",
"$",
"canUse",
"?",
"Strings",
"::",
"firstLower",
"(",
"$",
"pascal",
")",
":",
"Strings",
"::",
"lower",
"(",
"Strings",
"::",
"substring",
"(",
"$",
"pascal",
",",
"0",
",",
"1",
")",
")",
".",
"Strings",
"::",
"substring",
"(",
"$",
"pascal",
",",
"1",
")",
";",
"}"
] | Converts the given string to "camelCase".
@param string $string
@return string | [
"Converts",
"the",
"given",
"string",
"to",
"camelCase",
"."
] | 108dac43a0bb90d95ebcf8e6f5a21f37221764f1 | https://github.com/meridius/helpers/blob/108dac43a0bb90d95ebcf8e6f5a21f37221764f1/src/StringHelper.php#L62-L71 |
4,302 | Webiny/Login | src/Webiny/Login/Login.php | Login.rateLimitReached | public function rateLimitReached()
{
if ($this->isIpWhitelisted()) {
return false; // we cannot block whitelisted IPs
}
if ($this->isIpBlacklisted()) {
return true;
}
$rateLimit = $this->config->get('BlockThreshold', 0);
if ($rateLimit < 1) {
return false; // rate limit not used
}
// get the last record that's on the end of the rate limit window
$rc = LoginRateControlEntity::find(['ip' => $this->ip], ['-timestamp'], 1, $rateLimit);
if (!$rc) {
return false;
}
$blockTtl = $this->config->get('BlockTimelimit', 1) * 60; // defined in minutes, cast to seconds
if ((time() - $blockTtl) > 60) {
return false;
}
return true;
} | php | public function rateLimitReached()
{
if ($this->isIpWhitelisted()) {
return false; // we cannot block whitelisted IPs
}
if ($this->isIpBlacklisted()) {
return true;
}
$rateLimit = $this->config->get('BlockThreshold', 0);
if ($rateLimit < 1) {
return false; // rate limit not used
}
// get the last record that's on the end of the rate limit window
$rc = LoginRateControlEntity::find(['ip' => $this->ip], ['-timestamp'], 1, $rateLimit);
if (!$rc) {
return false;
}
$blockTtl = $this->config->get('BlockTimelimit', 1) * 60; // defined in minutes, cast to seconds
if ((time() - $blockTtl) > 60) {
return false;
}
return true;
} | [
"public",
"function",
"rateLimitReached",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isIpWhitelisted",
"(",
")",
")",
"{",
"return",
"false",
";",
"// we cannot block whitelisted IPs",
"}",
"if",
"(",
"$",
"this",
"->",
"isIpBlacklisted",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"$",
"rateLimit",
"=",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'BlockThreshold'",
",",
"0",
")",
";",
"if",
"(",
"$",
"rateLimit",
"<",
"1",
")",
"{",
"return",
"false",
";",
"// rate limit not used",
"}",
"// get the last record that's on the end of the rate limit window",
"$",
"rc",
"=",
"LoginRateControlEntity",
"::",
"find",
"(",
"[",
"'ip'",
"=>",
"$",
"this",
"->",
"ip",
"]",
",",
"[",
"'-timestamp'",
"]",
",",
"1",
",",
"$",
"rateLimit",
")",
";",
"if",
"(",
"!",
"$",
"rc",
")",
"{",
"return",
"false",
";",
"}",
"$",
"blockTtl",
"=",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'BlockTimelimit'",
",",
"1",
")",
"*",
"60",
";",
"// defined in minutes, cast to seconds",
"if",
"(",
"(",
"time",
"(",
")",
"-",
"$",
"blockTtl",
")",
">",
"60",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Check if current IP should be blocked from login page | [
"Check",
"if",
"current",
"IP",
"should",
"be",
"blocked",
"from",
"login",
"page"
] | 0941286f2a43730fcd9fe899039913719fb5dc9e | https://github.com/Webiny/Login/blob/0941286f2a43730fcd9fe899039913719fb5dc9e/src/Webiny/Login/Login.php#L90-L117 |
4,303 | Webiny/Login | src/Webiny/Login/Login.php | Login.generateDeviceValidationToken | public function generateDeviceValidationToken($username)
{
$this->username = $username;
$validationToken = $this->crypt()->generateRandomString(6, '0123456789');
$devices = $this->getMeta()->allowedDevices;
$devices[] = [
'device' => $this->getDeviceFingerprint(),
'created' => 0,
'token' => '',
'validationToken' => $validationToken,
'confirmed' => false
];
$this->getMeta()->allowedDevices = $devices;
$this->getMeta()->save();
return $validationToken;
} | php | public function generateDeviceValidationToken($username)
{
$this->username = $username;
$validationToken = $this->crypt()->generateRandomString(6, '0123456789');
$devices = $this->getMeta()->allowedDevices;
$devices[] = [
'device' => $this->getDeviceFingerprint(),
'created' => 0,
'token' => '',
'validationToken' => $validationToken,
'confirmed' => false
];
$this->getMeta()->allowedDevices = $devices;
$this->getMeta()->save();
return $validationToken;
} | [
"public",
"function",
"generateDeviceValidationToken",
"(",
"$",
"username",
")",
"{",
"$",
"this",
"->",
"username",
"=",
"$",
"username",
";",
"$",
"validationToken",
"=",
"$",
"this",
"->",
"crypt",
"(",
")",
"->",
"generateRandomString",
"(",
"6",
",",
"'0123456789'",
")",
";",
"$",
"devices",
"=",
"$",
"this",
"->",
"getMeta",
"(",
")",
"->",
"allowedDevices",
";",
"$",
"devices",
"[",
"]",
"=",
"[",
"'device'",
"=>",
"$",
"this",
"->",
"getDeviceFingerprint",
"(",
")",
",",
"'created'",
"=>",
"0",
",",
"'token'",
"=>",
"''",
",",
"'validationToken'",
"=>",
"$",
"validationToken",
",",
"'confirmed'",
"=>",
"false",
"]",
";",
"$",
"this",
"->",
"getMeta",
"(",
")",
"->",
"allowedDevices",
"=",
"$",
"devices",
";",
"$",
"this",
"->",
"getMeta",
"(",
")",
"->",
"save",
"(",
")",
";",
"return",
"$",
"validationToken",
";",
"}"
] | Generates a unique token to authenticate the current device for the given username.
@param $username
@return string
@throws LoginException
@throws \Webiny\Component\Crypt\CryptException | [
"Generates",
"a",
"unique",
"token",
"to",
"authenticate",
"the",
"current",
"device",
"for",
"the",
"given",
"username",
"."
] | 0941286f2a43730fcd9fe899039913719fb5dc9e | https://github.com/Webiny/Login/blob/0941286f2a43730fcd9fe899039913719fb5dc9e/src/Webiny/Login/Login.php#L157-L176 |
4,304 | Webiny/Login | src/Webiny/Login/Login.php | Login.validateDeviceConfirmationToken | public function validateDeviceConfirmationToken($username, $token)
{
$this->username = $username;
if ($this->rateLimitReached()) {
throw new LoginException('The current user session is block from login page.', 1);
}
$allowedList = $this->getMeta()->allowedDevices->val();
if (!is_array($allowedList)) {
return false;
}
$newAllowedList = $allowedList;
$deviceId = $this->getDeviceFingerprint();
$i = 0;
foreach ($allowedList as $al) {
if ($al['confirmed'] == false && $al['device'] == $deviceId && $token == $al['validationToken']) {
$token = $this->crypt()->generateUserReadableString(32);
$newAllowedList[$i]['confirmed'] = true;
$newAllowedList[$i]['created'] = time();
$newAllowedList[$i]['token'] = $token;
$this->getMeta()->allowedDevices = $newAllowedList;
$this->getMeta()->save();
return $token;
}
$i++;
}
// validation cleanup (if validation was unsuccessful, we need to delete the token, a new one needs to be requested)
$newAllowedList = [];
foreach ($allowedList as $al) {
if ($al['confirmed'] != false) {
$newAllowedList[] = $al;
}
}
$this->getMeta()->allowedDevices = $newAllowedList;
$this->getMeta()->save();
// increment login count
$this->incrementLoginAttempts();
return false;
} | php | public function validateDeviceConfirmationToken($username, $token)
{
$this->username = $username;
if ($this->rateLimitReached()) {
throw new LoginException('The current user session is block from login page.', 1);
}
$allowedList = $this->getMeta()->allowedDevices->val();
if (!is_array($allowedList)) {
return false;
}
$newAllowedList = $allowedList;
$deviceId = $this->getDeviceFingerprint();
$i = 0;
foreach ($allowedList as $al) {
if ($al['confirmed'] == false && $al['device'] == $deviceId && $token == $al['validationToken']) {
$token = $this->crypt()->generateUserReadableString(32);
$newAllowedList[$i]['confirmed'] = true;
$newAllowedList[$i]['created'] = time();
$newAllowedList[$i]['token'] = $token;
$this->getMeta()->allowedDevices = $newAllowedList;
$this->getMeta()->save();
return $token;
}
$i++;
}
// validation cleanup (if validation was unsuccessful, we need to delete the token, a new one needs to be requested)
$newAllowedList = [];
foreach ($allowedList as $al) {
if ($al['confirmed'] != false) {
$newAllowedList[] = $al;
}
}
$this->getMeta()->allowedDevices = $newAllowedList;
$this->getMeta()->save();
// increment login count
$this->incrementLoginAttempts();
return false;
} | [
"public",
"function",
"validateDeviceConfirmationToken",
"(",
"$",
"username",
",",
"$",
"token",
")",
"{",
"$",
"this",
"->",
"username",
"=",
"$",
"username",
";",
"if",
"(",
"$",
"this",
"->",
"rateLimitReached",
"(",
")",
")",
"{",
"throw",
"new",
"LoginException",
"(",
"'The current user session is block from login page.'",
",",
"1",
")",
";",
"}",
"$",
"allowedList",
"=",
"$",
"this",
"->",
"getMeta",
"(",
")",
"->",
"allowedDevices",
"->",
"val",
"(",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"allowedList",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"newAllowedList",
"=",
"$",
"allowedList",
";",
"$",
"deviceId",
"=",
"$",
"this",
"->",
"getDeviceFingerprint",
"(",
")",
";",
"$",
"i",
"=",
"0",
";",
"foreach",
"(",
"$",
"allowedList",
"as",
"$",
"al",
")",
"{",
"if",
"(",
"$",
"al",
"[",
"'confirmed'",
"]",
"==",
"false",
"&&",
"$",
"al",
"[",
"'device'",
"]",
"==",
"$",
"deviceId",
"&&",
"$",
"token",
"==",
"$",
"al",
"[",
"'validationToken'",
"]",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"crypt",
"(",
")",
"->",
"generateUserReadableString",
"(",
"32",
")",
";",
"$",
"newAllowedList",
"[",
"$",
"i",
"]",
"[",
"'confirmed'",
"]",
"=",
"true",
";",
"$",
"newAllowedList",
"[",
"$",
"i",
"]",
"[",
"'created'",
"]",
"=",
"time",
"(",
")",
";",
"$",
"newAllowedList",
"[",
"$",
"i",
"]",
"[",
"'token'",
"]",
"=",
"$",
"token",
";",
"$",
"this",
"->",
"getMeta",
"(",
")",
"->",
"allowedDevices",
"=",
"$",
"newAllowedList",
";",
"$",
"this",
"->",
"getMeta",
"(",
")",
"->",
"save",
"(",
")",
";",
"return",
"$",
"token",
";",
"}",
"$",
"i",
"++",
";",
"}",
"// validation cleanup (if validation was unsuccessful, we need to delete the token, a new one needs to be requested)",
"$",
"newAllowedList",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"allowedList",
"as",
"$",
"al",
")",
"{",
"if",
"(",
"$",
"al",
"[",
"'confirmed'",
"]",
"!=",
"false",
")",
"{",
"$",
"newAllowedList",
"[",
"]",
"=",
"$",
"al",
";",
"}",
"}",
"$",
"this",
"->",
"getMeta",
"(",
")",
"->",
"allowedDevices",
"=",
"$",
"newAllowedList",
";",
"$",
"this",
"->",
"getMeta",
"(",
")",
"->",
"save",
"(",
")",
";",
"// increment login count",
"$",
"this",
"->",
"incrementLoginAttempts",
"(",
")",
";",
"return",
"false",
";",
"}"
] | Checks if the provided token matches a device validation token in the database for the given username.
If token matches, the given device is now allowed access.
@param $username
@param $token
@return bool|string
@throws LoginException
@throws \Webiny\Component\Crypt\CryptException | [
"Checks",
"if",
"the",
"provided",
"token",
"matches",
"a",
"device",
"validation",
"token",
"in",
"the",
"database",
"for",
"the",
"given",
"username",
".",
"If",
"token",
"matches",
"the",
"given",
"device",
"is",
"now",
"allowed",
"access",
"."
] | 0941286f2a43730fcd9fe899039913719fb5dc9e | https://github.com/Webiny/Login/blob/0941286f2a43730fcd9fe899039913719fb5dc9e/src/Webiny/Login/Login.php#L189-L235 |
4,305 | Webiny/Login | src/Webiny/Login/Login.php | Login.setUserBlockedStatus | public function setUserBlockedStatus($username, $blocked = true)
{
$this->username = $username;
$this->getMeta()->blocked = $blocked;
$this->getMeta()->save();
} | php | public function setUserBlockedStatus($username, $blocked = true)
{
$this->username = $username;
$this->getMeta()->blocked = $blocked;
$this->getMeta()->save();
} | [
"public",
"function",
"setUserBlockedStatus",
"(",
"$",
"username",
",",
"$",
"blocked",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"username",
"=",
"$",
"username",
";",
"$",
"this",
"->",
"getMeta",
"(",
")",
"->",
"blocked",
"=",
"$",
"blocked",
";",
"$",
"this",
"->",
"getMeta",
"(",
")",
"->",
"save",
"(",
")",
";",
"}"
] | Change the `blocked` user account status flag.
@param $username
@param bool $blocked
@throws LoginException | [
"Change",
"the",
"blocked",
"user",
"account",
"status",
"flag",
"."
] | 0941286f2a43730fcd9fe899039913719fb5dc9e | https://github.com/Webiny/Login/blob/0941286f2a43730fcd9fe899039913719fb5dc9e/src/Webiny/Login/Login.php#L305-L310 |
4,306 | Webiny/Login | src/Webiny/Login/Login.php | Login.setUserAccountConfirmationStatus | public function setUserAccountConfirmationStatus($username, $confirmed = true)
{
$this->username = $username;
$this->getMeta()->confirmed = $confirmed;
$this->getMeta()->save();
} | php | public function setUserAccountConfirmationStatus($username, $confirmed = true)
{
$this->username = $username;
$this->getMeta()->confirmed = $confirmed;
$this->getMeta()->save();
} | [
"public",
"function",
"setUserAccountConfirmationStatus",
"(",
"$",
"username",
",",
"$",
"confirmed",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"username",
"=",
"$",
"username",
";",
"$",
"this",
"->",
"getMeta",
"(",
")",
"->",
"confirmed",
"=",
"$",
"confirmed",
";",
"$",
"this",
"->",
"getMeta",
"(",
")",
"->",
"save",
"(",
")",
";",
"}"
] | Change the `confirmed` user account status flag.
@param $username
@param bool $confirmed
@throws LoginException | [
"Change",
"the",
"confirmed",
"user",
"account",
"status",
"flag",
"."
] | 0941286f2a43730fcd9fe899039913719fb5dc9e | https://github.com/Webiny/Login/blob/0941286f2a43730fcd9fe899039913719fb5dc9e/src/Webiny/Login/Login.php#L362-L367 |
4,307 | Webiny/Login | src/Webiny/Login/Login.php | Login.getUser | public function getUser($authToken, $deviceToken = '')
{
$user = null;
// 1. get user from firewall
$this->security($this->fwName)->getToken()->setTokenString($authToken);
try {
$user = $this->security($this->fwName)->getUser();
} catch (TokenException $e) {
if ($e->getCode() === TokenException::TOKEN_EXPIRED) {
throw new LoginException('The current auth session is no longer valid.', 7);
}
}
if (!$user->isAuthenticated()) {
throw new LoginException('User is not authenticated', 6);
}
// 2. extract username
$this->username = $user->getUsername();
// do the checks
if ($this->isAccountBlocked($this->username)) {
$this->security->firewall($this->fwName)->processLogout();
throw new LoginException('User account is blocked.', 2);
}
if (!$this->isAccountActive($this->username)) {
$this->security->firewall($this->fwName)->processLogout();
throw new LoginException('User hasn\'t confirmed his account.', 4);
}
if ($this->config->get('ValidateDevice', false)) {
// validate the device
if (!$this->isDeviceSessionValid($deviceToken)) {
$this->security->firewall($this->fwName)->processLogout();
//todo: invalidate session in login meta
throw new LoginException('The device session is no longer valid.', 8);
}
}
// is session still valid
if (!$this->isSessionValid($authToken)) {
$this->security->firewall($this->fwName)->processLogout();
throw new LoginException('The current auth session is no longer valid.', 7);
}
// return User
return $user;
} | php | public function getUser($authToken, $deviceToken = '')
{
$user = null;
// 1. get user from firewall
$this->security($this->fwName)->getToken()->setTokenString($authToken);
try {
$user = $this->security($this->fwName)->getUser();
} catch (TokenException $e) {
if ($e->getCode() === TokenException::TOKEN_EXPIRED) {
throw new LoginException('The current auth session is no longer valid.', 7);
}
}
if (!$user->isAuthenticated()) {
throw new LoginException('User is not authenticated', 6);
}
// 2. extract username
$this->username = $user->getUsername();
// do the checks
if ($this->isAccountBlocked($this->username)) {
$this->security->firewall($this->fwName)->processLogout();
throw new LoginException('User account is blocked.', 2);
}
if (!$this->isAccountActive($this->username)) {
$this->security->firewall($this->fwName)->processLogout();
throw new LoginException('User hasn\'t confirmed his account.', 4);
}
if ($this->config->get('ValidateDevice', false)) {
// validate the device
if (!$this->isDeviceSessionValid($deviceToken)) {
$this->security->firewall($this->fwName)->processLogout();
//todo: invalidate session in login meta
throw new LoginException('The device session is no longer valid.', 8);
}
}
// is session still valid
if (!$this->isSessionValid($authToken)) {
$this->security->firewall($this->fwName)->processLogout();
throw new LoginException('The current auth session is no longer valid.', 7);
}
// return User
return $user;
} | [
"public",
"function",
"getUser",
"(",
"$",
"authToken",
",",
"$",
"deviceToken",
"=",
"''",
")",
"{",
"$",
"user",
"=",
"null",
";",
"// 1. get user from firewall",
"$",
"this",
"->",
"security",
"(",
"$",
"this",
"->",
"fwName",
")",
"->",
"getToken",
"(",
")",
"->",
"setTokenString",
"(",
"$",
"authToken",
")",
";",
"try",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"security",
"(",
"$",
"this",
"->",
"fwName",
")",
"->",
"getUser",
"(",
")",
";",
"}",
"catch",
"(",
"TokenException",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"e",
"->",
"getCode",
"(",
")",
"===",
"TokenException",
"::",
"TOKEN_EXPIRED",
")",
"{",
"throw",
"new",
"LoginException",
"(",
"'The current auth session is no longer valid.'",
",",
"7",
")",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"user",
"->",
"isAuthenticated",
"(",
")",
")",
"{",
"throw",
"new",
"LoginException",
"(",
"'User is not authenticated'",
",",
"6",
")",
";",
"}",
"// 2. extract username",
"$",
"this",
"->",
"username",
"=",
"$",
"user",
"->",
"getUsername",
"(",
")",
";",
"// do the checks",
"if",
"(",
"$",
"this",
"->",
"isAccountBlocked",
"(",
"$",
"this",
"->",
"username",
")",
")",
"{",
"$",
"this",
"->",
"security",
"->",
"firewall",
"(",
"$",
"this",
"->",
"fwName",
")",
"->",
"processLogout",
"(",
")",
";",
"throw",
"new",
"LoginException",
"(",
"'User account is blocked.'",
",",
"2",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"isAccountActive",
"(",
"$",
"this",
"->",
"username",
")",
")",
"{",
"$",
"this",
"->",
"security",
"->",
"firewall",
"(",
"$",
"this",
"->",
"fwName",
")",
"->",
"processLogout",
"(",
")",
";",
"throw",
"new",
"LoginException",
"(",
"'User hasn\\'t confirmed his account.'",
",",
"4",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'ValidateDevice'",
",",
"false",
")",
")",
"{",
"// validate the device",
"if",
"(",
"!",
"$",
"this",
"->",
"isDeviceSessionValid",
"(",
"$",
"deviceToken",
")",
")",
"{",
"$",
"this",
"->",
"security",
"->",
"firewall",
"(",
"$",
"this",
"->",
"fwName",
")",
"->",
"processLogout",
"(",
")",
";",
"//todo: invalidate session in login meta",
"throw",
"new",
"LoginException",
"(",
"'The device session is no longer valid.'",
",",
"8",
")",
";",
"}",
"}",
"// is session still valid",
"if",
"(",
"!",
"$",
"this",
"->",
"isSessionValid",
"(",
"$",
"authToken",
")",
")",
"{",
"$",
"this",
"->",
"security",
"->",
"firewall",
"(",
"$",
"this",
"->",
"fwName",
")",
"->",
"processLogout",
"(",
")",
";",
"throw",
"new",
"LoginException",
"(",
"'The current auth session is no longer valid.'",
",",
"7",
")",
";",
"}",
"// return User",
"return",
"$",
"user",
";",
"}"
] | Returns User object for the provided auth token and device token.
If user is not found, or session is invalid, an exception is thrown.
@param $authToken
@param $deviceToken
@return bool|\Webiny\Component\Security\User\AbstractUser
@throws LoginException
@throws \Webiny\Component\Security\Authentication\FirewallException
@throws \Webiny\Component\Security\SecurityException | [
"Returns",
"User",
"object",
"for",
"the",
"provided",
"auth",
"token",
"and",
"device",
"token",
".",
"If",
"user",
"is",
"not",
"found",
"or",
"session",
"is",
"invalid",
"an",
"exception",
"is",
"thrown",
"."
] | 0941286f2a43730fcd9fe899039913719fb5dc9e | https://github.com/Webiny/Login/blob/0941286f2a43730fcd9fe899039913719fb5dc9e/src/Webiny/Login/Login.php#L505-L552 |
4,308 | Webiny/Login | src/Webiny/Login/Login.php | Login.getDeviceFingerprint | private function getDeviceFingerprint()
{
$server = $this->httpRequest()->server();
$did = '';
//$did .= $server->httpAccept();
//$did .= '|' . $server->httpAcceptCharset();
//$did .= '|' . $server->httpAcceptEncoding();
$did .= '|' . $server->httpAcceptLanguage();
// append browser details
if (empty($server->httpUserAgent())) {
throw new LoginException('Unable to process the request without a user agent', 100);
}
$platform = 'unknown';
$ub = 'unknown';
// get the platform
$ua = $server->httpUserAgent();
if (preg_match('/linux/i', $ua)) {
$platform = 'linux';
} elseif (preg_match('/macintosh|mac os x/i', $ua)) {
$platform = 'mac';
} elseif (preg_match('/windows|win32/i', $ua)) {
$platform = 'windows';
}
// get browser name
if (preg_match('/MSIE/i', $ua) && !preg_match('/Opera/i', $ua)) {
$ub = "MSIE";
} elseif (preg_match('/Firefox/i', $ua)) {
$ub = "Firefox";
} elseif (preg_match('/Chrome/i', $ua)) {
$ub = "Chrome";
} elseif (preg_match('/Safari/i', $ua)) {
$ub = "Safari";
} elseif (preg_match('/Opera/i', $ua)) {
$ub = "Opera";
} elseif (preg_match('/Netscape/i', $ua)) {
$ub = "Netscape";
}
$did .= '|' . $platform;
$did .= '|' . $ub;
return md5($did);
} | php | private function getDeviceFingerprint()
{
$server = $this->httpRequest()->server();
$did = '';
//$did .= $server->httpAccept();
//$did .= '|' . $server->httpAcceptCharset();
//$did .= '|' . $server->httpAcceptEncoding();
$did .= '|' . $server->httpAcceptLanguage();
// append browser details
if (empty($server->httpUserAgent())) {
throw new LoginException('Unable to process the request without a user agent', 100);
}
$platform = 'unknown';
$ub = 'unknown';
// get the platform
$ua = $server->httpUserAgent();
if (preg_match('/linux/i', $ua)) {
$platform = 'linux';
} elseif (preg_match('/macintosh|mac os x/i', $ua)) {
$platform = 'mac';
} elseif (preg_match('/windows|win32/i', $ua)) {
$platform = 'windows';
}
// get browser name
if (preg_match('/MSIE/i', $ua) && !preg_match('/Opera/i', $ua)) {
$ub = "MSIE";
} elseif (preg_match('/Firefox/i', $ua)) {
$ub = "Firefox";
} elseif (preg_match('/Chrome/i', $ua)) {
$ub = "Chrome";
} elseif (preg_match('/Safari/i', $ua)) {
$ub = "Safari";
} elseif (preg_match('/Opera/i', $ua)) {
$ub = "Opera";
} elseif (preg_match('/Netscape/i', $ua)) {
$ub = "Netscape";
}
$did .= '|' . $platform;
$did .= '|' . $ub;
return md5($did);
} | [
"private",
"function",
"getDeviceFingerprint",
"(",
")",
"{",
"$",
"server",
"=",
"$",
"this",
"->",
"httpRequest",
"(",
")",
"->",
"server",
"(",
")",
";",
"$",
"did",
"=",
"''",
";",
"//$did .= $server->httpAccept();",
"//$did .= '|' . $server->httpAcceptCharset();",
"//$did .= '|' . $server->httpAcceptEncoding();",
"$",
"did",
".=",
"'|'",
".",
"$",
"server",
"->",
"httpAcceptLanguage",
"(",
")",
";",
"// append browser details",
"if",
"(",
"empty",
"(",
"$",
"server",
"->",
"httpUserAgent",
"(",
")",
")",
")",
"{",
"throw",
"new",
"LoginException",
"(",
"'Unable to process the request without a user agent'",
",",
"100",
")",
";",
"}",
"$",
"platform",
"=",
"'unknown'",
";",
"$",
"ub",
"=",
"'unknown'",
";",
"// get the platform",
"$",
"ua",
"=",
"$",
"server",
"->",
"httpUserAgent",
"(",
")",
";",
"if",
"(",
"preg_match",
"(",
"'/linux/i'",
",",
"$",
"ua",
")",
")",
"{",
"$",
"platform",
"=",
"'linux'",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/macintosh|mac os x/i'",
",",
"$",
"ua",
")",
")",
"{",
"$",
"platform",
"=",
"'mac'",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/windows|win32/i'",
",",
"$",
"ua",
")",
")",
"{",
"$",
"platform",
"=",
"'windows'",
";",
"}",
"// get browser name",
"if",
"(",
"preg_match",
"(",
"'/MSIE/i'",
",",
"$",
"ua",
")",
"&&",
"!",
"preg_match",
"(",
"'/Opera/i'",
",",
"$",
"ua",
")",
")",
"{",
"$",
"ub",
"=",
"\"MSIE\"",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/Firefox/i'",
",",
"$",
"ua",
")",
")",
"{",
"$",
"ub",
"=",
"\"Firefox\"",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/Chrome/i'",
",",
"$",
"ua",
")",
")",
"{",
"$",
"ub",
"=",
"\"Chrome\"",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/Safari/i'",
",",
"$",
"ua",
")",
")",
"{",
"$",
"ub",
"=",
"\"Safari\"",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/Opera/i'",
",",
"$",
"ua",
")",
")",
"{",
"$",
"ub",
"=",
"\"Opera\"",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/Netscape/i'",
",",
"$",
"ua",
")",
")",
"{",
"$",
"ub",
"=",
"\"Netscape\"",
";",
"}",
"$",
"did",
".=",
"'|'",
".",
"$",
"platform",
";",
"$",
"did",
".=",
"'|'",
".",
"$",
"ub",
";",
"return",
"md5",
"(",
"$",
"did",
")",
";",
"}"
] | Generates a device fingerprint.
@return string
@throws LoginException | [
"Generates",
"a",
"device",
"fingerprint",
"."
] | 0941286f2a43730fcd9fe899039913719fb5dc9e | https://github.com/Webiny/Login/blob/0941286f2a43730fcd9fe899039913719fb5dc9e/src/Webiny/Login/Login.php#L605-L652 |
4,309 | Webiny/Login | src/Webiny/Login/Login.php | Login.isSessionValid | private function isSessionValid($session)
{
$sessions = $this->getMeta()->sessions;
$sessionTtl = $this->getSessionTtl();
foreach ($sessions as $s) {
if ($s['sid'] == $session && ($s['created'] + $sessionTtl) > time()) {
return true;
}
}
return false;
} | php | private function isSessionValid($session)
{
$sessions = $this->getMeta()->sessions;
$sessionTtl = $this->getSessionTtl();
foreach ($sessions as $s) {
if ($s['sid'] == $session && ($s['created'] + $sessionTtl) > time()) {
return true;
}
}
return false;
} | [
"private",
"function",
"isSessionValid",
"(",
"$",
"session",
")",
"{",
"$",
"sessions",
"=",
"$",
"this",
"->",
"getMeta",
"(",
")",
"->",
"sessions",
";",
"$",
"sessionTtl",
"=",
"$",
"this",
"->",
"getSessionTtl",
"(",
")",
";",
"foreach",
"(",
"$",
"sessions",
"as",
"$",
"s",
")",
"{",
"if",
"(",
"$",
"s",
"[",
"'sid'",
"]",
"==",
"$",
"session",
"&&",
"(",
"$",
"s",
"[",
"'created'",
"]",
"+",
"$",
"sessionTtl",
")",
">",
"time",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Checks if the given session is still valid.
@param $session
@return bool
@throws LoginException | [
"Checks",
"if",
"the",
"given",
"session",
"is",
"still",
"valid",
"."
] | 0941286f2a43730fcd9fe899039913719fb5dc9e | https://github.com/Webiny/Login/blob/0941286f2a43730fcd9fe899039913719fb5dc9e/src/Webiny/Login/Login.php#L691-L703 |
4,310 | Webiny/Login | src/Webiny/Login/Login.php | Login.isDeviceSessionValid | private function isDeviceSessionValid($deviceToken)
{
$devices = $this->getMeta()->allowedDevices;
$deviceTtl = $this->config->get('DeviceTtl', $this->defaultDeviceTtl);
$currentDeviceFingerprint = $this->getDeviceFingerprint();
foreach ($devices as $d) {
if ($d['token'] == $deviceToken && ($d['created'] + (86400 * $deviceTtl)) > time() && $d['device'] == $currentDeviceFingerprint) {
return true;
}
}
return false;
} | php | private function isDeviceSessionValid($deviceToken)
{
$devices = $this->getMeta()->allowedDevices;
$deviceTtl = $this->config->get('DeviceTtl', $this->defaultDeviceTtl);
$currentDeviceFingerprint = $this->getDeviceFingerprint();
foreach ($devices as $d) {
if ($d['token'] == $deviceToken && ($d['created'] + (86400 * $deviceTtl)) > time() && $d['device'] == $currentDeviceFingerprint) {
return true;
}
}
return false;
} | [
"private",
"function",
"isDeviceSessionValid",
"(",
"$",
"deviceToken",
")",
"{",
"$",
"devices",
"=",
"$",
"this",
"->",
"getMeta",
"(",
")",
"->",
"allowedDevices",
";",
"$",
"deviceTtl",
"=",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'DeviceTtl'",
",",
"$",
"this",
"->",
"defaultDeviceTtl",
")",
";",
"$",
"currentDeviceFingerprint",
"=",
"$",
"this",
"->",
"getDeviceFingerprint",
"(",
")",
";",
"foreach",
"(",
"$",
"devices",
"as",
"$",
"d",
")",
"{",
"if",
"(",
"$",
"d",
"[",
"'token'",
"]",
"==",
"$",
"deviceToken",
"&&",
"(",
"$",
"d",
"[",
"'created'",
"]",
"+",
"(",
"86400",
"*",
"$",
"deviceTtl",
")",
")",
">",
"time",
"(",
")",
"&&",
"$",
"d",
"[",
"'device'",
"]",
"==",
"$",
"currentDeviceFingerprint",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Check if the given device token is still valid.
@param $deviceToken
@return bool
@throws LoginException | [
"Check",
"if",
"the",
"given",
"device",
"token",
"is",
"still",
"valid",
"."
] | 0941286f2a43730fcd9fe899039913719fb5dc9e | https://github.com/Webiny/Login/blob/0941286f2a43730fcd9fe899039913719fb5dc9e/src/Webiny/Login/Login.php#L713-L727 |
4,311 | Webiny/Login | src/Webiny/Login/Login.php | Login.incrementLoginAttempts | private function incrementLoginAttempts()
{
$rc = new LoginRateControlEntity();
$rc->ip = $this->ip;
$rc->username = $this->username;
$rc->timestamp = time();
$rc->save();
} | php | private function incrementLoginAttempts()
{
$rc = new LoginRateControlEntity();
$rc->ip = $this->ip;
$rc->username = $this->username;
$rc->timestamp = time();
$rc->save();
} | [
"private",
"function",
"incrementLoginAttempts",
"(",
")",
"{",
"$",
"rc",
"=",
"new",
"LoginRateControlEntity",
"(",
")",
";",
"$",
"rc",
"->",
"ip",
"=",
"$",
"this",
"->",
"ip",
";",
"$",
"rc",
"->",
"username",
"=",
"$",
"this",
"->",
"username",
";",
"$",
"rc",
"->",
"timestamp",
"=",
"time",
"(",
")",
";",
"$",
"rc",
"->",
"save",
"(",
")",
";",
"}"
] | Increments the number of login attempts for the current username and IP. | [
"Increments",
"the",
"number",
"of",
"login",
"attempts",
"for",
"the",
"current",
"username",
"and",
"IP",
"."
] | 0941286f2a43730fcd9fe899039913719fb5dc9e | https://github.com/Webiny/Login/blob/0941286f2a43730fcd9fe899039913719fb5dc9e/src/Webiny/Login/Login.php#L732-L739 |
4,312 | Webiny/Login | src/Webiny/Login/Login.php | Login.resetRateLimit | private function resetRateLimit()
{
// clear the logs for the current ip/username combo
LoginRateControlEntity::find(['ip' => $this->ip, 'username' => $this->username])->delete();
// delete all records older than 30 days
$ts = time() - (30 * 86400);
LoginRateControlEntity::find([
'timestamp' => [
'$lt' => [$ts]
]
])->delete();
} | php | private function resetRateLimit()
{
// clear the logs for the current ip/username combo
LoginRateControlEntity::find(['ip' => $this->ip, 'username' => $this->username])->delete();
// delete all records older than 30 days
$ts = time() - (30 * 86400);
LoginRateControlEntity::find([
'timestamp' => [
'$lt' => [$ts]
]
])->delete();
} | [
"private",
"function",
"resetRateLimit",
"(",
")",
"{",
"// clear the logs for the current ip/username combo",
"LoginRateControlEntity",
"::",
"find",
"(",
"[",
"'ip'",
"=>",
"$",
"this",
"->",
"ip",
",",
"'username'",
"=>",
"$",
"this",
"->",
"username",
"]",
")",
"->",
"delete",
"(",
")",
";",
"// delete all records older than 30 days",
"$",
"ts",
"=",
"time",
"(",
")",
"-",
"(",
"30",
"*",
"86400",
")",
";",
"LoginRateControlEntity",
"::",
"find",
"(",
"[",
"'timestamp'",
"=>",
"[",
"'$lt'",
"=>",
"[",
"$",
"ts",
"]",
"]",
"]",
")",
"->",
"delete",
"(",
")",
";",
"}"
] | Resets the rate limit for the current ip and username.
It also clears the records that are older than 30 days. | [
"Resets",
"the",
"rate",
"limit",
"for",
"the",
"current",
"ip",
"and",
"username",
".",
"It",
"also",
"clears",
"the",
"records",
"that",
"are",
"older",
"than",
"30",
"days",
"."
] | 0941286f2a43730fcd9fe899039913719fb5dc9e | https://github.com/Webiny/Login/blob/0941286f2a43730fcd9fe899039913719fb5dc9e/src/Webiny/Login/Login.php#L745-L757 |
4,313 | Webiny/Login | src/Webiny/Login/Login.php | Login.isIpWhitelisted | private function isIpWhitelisted()
{
$whitelist = $this->config->get('RateLimitWhitelist', [], true);
if (in_array($this->ip, $whitelist)) {
return true;
}
return false;
} | php | private function isIpWhitelisted()
{
$whitelist = $this->config->get('RateLimitWhitelist', [], true);
if (in_array($this->ip, $whitelist)) {
return true;
}
return false;
} | [
"private",
"function",
"isIpWhitelisted",
"(",
")",
"{",
"$",
"whitelist",
"=",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'RateLimitWhitelist'",
",",
"[",
"]",
",",
"true",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"this",
"->",
"ip",
",",
"$",
"whitelist",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Checks if the current ip is whitelisted.
@return bool | [
"Checks",
"if",
"the",
"current",
"ip",
"is",
"whitelisted",
"."
] | 0941286f2a43730fcd9fe899039913719fb5dc9e | https://github.com/Webiny/Login/blob/0941286f2a43730fcd9fe899039913719fb5dc9e/src/Webiny/Login/Login.php#L764-L772 |
4,314 | Webiny/Login | src/Webiny/Login/Login.php | Login.isIpBlacklisted | private function isIpBlacklisted()
{
$blacklist = $this->config->get('RateLimitBlacklist', [], true);
if (in_array($this->ip, $blacklist)) {
return true;
}
return false;
} | php | private function isIpBlacklisted()
{
$blacklist = $this->config->get('RateLimitBlacklist', [], true);
if (in_array($this->ip, $blacklist)) {
return true;
}
return false;
} | [
"private",
"function",
"isIpBlacklisted",
"(",
")",
"{",
"$",
"blacklist",
"=",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'RateLimitBlacklist'",
",",
"[",
"]",
",",
"true",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"this",
"->",
"ip",
",",
"$",
"blacklist",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Checks if the current ip is black listed.
@return bool | [
"Checks",
"if",
"the",
"current",
"ip",
"is",
"black",
"listed",
"."
] | 0941286f2a43730fcd9fe899039913719fb5dc9e | https://github.com/Webiny/Login/blob/0941286f2a43730fcd9fe899039913719fb5dc9e/src/Webiny/Login/Login.php#L779-L787 |
4,315 | Webiny/Login | src/Webiny/Login/Login.php | Login.storeUserSession | private function storeUserSession($session)
{
// get all sessions
$sessions = $this->getMeta()->sessions->val();
if (!is_array($sessions)) {
$sessions = [];
}
// delete the old sessions
$newSessions = [];
$ttl = $this->getSessionTtl();
foreach ($sessions as $s) {
if (($s['created'] + $ttl) > time()) {
$newSessions[] = $s;
}
}
// append the new session
$newSessions[] = ['sid' => $session, 'created' => time(), 'ip' => $this->ip];
// update the last login date
$this->getMeta()->lastLogin = time();
// append a new login attempt
$this->getMeta()->loginAttempts[] = ['ip' => $this->ip, 'timestamp' => time()];
// update the entity
$this->getMeta()->sessions = $newSessions;
$this->getMeta()->save();
} | php | private function storeUserSession($session)
{
// get all sessions
$sessions = $this->getMeta()->sessions->val();
if (!is_array($sessions)) {
$sessions = [];
}
// delete the old sessions
$newSessions = [];
$ttl = $this->getSessionTtl();
foreach ($sessions as $s) {
if (($s['created'] + $ttl) > time()) {
$newSessions[] = $s;
}
}
// append the new session
$newSessions[] = ['sid' => $session, 'created' => time(), 'ip' => $this->ip];
// update the last login date
$this->getMeta()->lastLogin = time();
// append a new login attempt
$this->getMeta()->loginAttempts[] = ['ip' => $this->ip, 'timestamp' => time()];
// update the entity
$this->getMeta()->sessions = $newSessions;
$this->getMeta()->save();
} | [
"private",
"function",
"storeUserSession",
"(",
"$",
"session",
")",
"{",
"// get all sessions",
"$",
"sessions",
"=",
"$",
"this",
"->",
"getMeta",
"(",
")",
"->",
"sessions",
"->",
"val",
"(",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"sessions",
")",
")",
"{",
"$",
"sessions",
"=",
"[",
"]",
";",
"}",
"// delete the old sessions",
"$",
"newSessions",
"=",
"[",
"]",
";",
"$",
"ttl",
"=",
"$",
"this",
"->",
"getSessionTtl",
"(",
")",
";",
"foreach",
"(",
"$",
"sessions",
"as",
"$",
"s",
")",
"{",
"if",
"(",
"(",
"$",
"s",
"[",
"'created'",
"]",
"+",
"$",
"ttl",
")",
">",
"time",
"(",
")",
")",
"{",
"$",
"newSessions",
"[",
"]",
"=",
"$",
"s",
";",
"}",
"}",
"// append the new session",
"$",
"newSessions",
"[",
"]",
"=",
"[",
"'sid'",
"=>",
"$",
"session",
",",
"'created'",
"=>",
"time",
"(",
")",
",",
"'ip'",
"=>",
"$",
"this",
"->",
"ip",
"]",
";",
"// update the last login date",
"$",
"this",
"->",
"getMeta",
"(",
")",
"->",
"lastLogin",
"=",
"time",
"(",
")",
";",
"// append a new login attempt",
"$",
"this",
"->",
"getMeta",
"(",
")",
"->",
"loginAttempts",
"[",
"]",
"=",
"[",
"'ip'",
"=>",
"$",
"this",
"->",
"ip",
",",
"'timestamp'",
"=>",
"time",
"(",
")",
"]",
";",
"// update the entity",
"$",
"this",
"->",
"getMeta",
"(",
")",
"->",
"sessions",
"=",
"$",
"newSessions",
";",
"$",
"this",
"->",
"getMeta",
"(",
")",
"->",
"save",
"(",
")",
";",
"}"
] | Stores a new active session for the current user.
@param string $session
@throws LoginException | [
"Stores",
"a",
"new",
"active",
"session",
"for",
"the",
"current",
"user",
"."
] | 0941286f2a43730fcd9fe899039913719fb5dc9e | https://github.com/Webiny/Login/blob/0941286f2a43730fcd9fe899039913719fb5dc9e/src/Webiny/Login/Login.php#L796-L825 |
4,316 | scarwu/NanoCLI | src/NanoCLI/Loader.php | Loader.set | public static function set($namespace, $path)
{
$namespace = trim($namespace, '\\');
$path = rtrim($path, '/');
if (!isset(self::$_namespace_list[$namespace])) {
self::$_namespace_list[$namespace] = [];
}
self::$_namespace_list[$namespace][] = $path;
} | php | public static function set($namespace, $path)
{
$namespace = trim($namespace, '\\');
$path = rtrim($path, '/');
if (!isset(self::$_namespace_list[$namespace])) {
self::$_namespace_list[$namespace] = [];
}
self::$_namespace_list[$namespace][] = $path;
} | [
"public",
"static",
"function",
"set",
"(",
"$",
"namespace",
",",
"$",
"path",
")",
"{",
"$",
"namespace",
"=",
"trim",
"(",
"$",
"namespace",
",",
"'\\\\'",
")",
";",
"$",
"path",
"=",
"rtrim",
"(",
"$",
"path",
",",
"'/'",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"_namespace_list",
"[",
"$",
"namespace",
"]",
")",
")",
"{",
"self",
"::",
"$",
"_namespace_list",
"[",
"$",
"namespace",
"]",
"=",
"[",
"]",
";",
"}",
"self",
"::",
"$",
"_namespace_list",
"[",
"$",
"namespace",
"]",
"[",
"]",
"=",
"$",
"path",
";",
"}"
] | Set Command Path
@param string
@param string | [
"Set",
"Command",
"Path"
] | 6527015baff924b9f50680ae3797d619eaaf56ea | https://github.com/scarwu/NanoCLI/blob/6527015baff924b9f50680ae3797d619eaaf56ea/src/NanoCLI/Loader.php#L63-L73 |
4,317 | atelierspierrot/library | src/Library/Helper/Html.php | Html.getId | public static function getId($reference = null, $base_id = null)
{
if (empty($reference)) {
$reference = uniqid();
}
if (isset(self::$dom_id_register[$reference])) {
return self::$dom_id_register[$reference];
}
return self::getNewId($reference, $base_id);
} | php | public static function getId($reference = null, $base_id = null)
{
if (empty($reference)) {
$reference = uniqid();
}
if (isset(self::$dom_id_register[$reference])) {
return self::$dom_id_register[$reference];
}
return self::getNewId($reference, $base_id);
} | [
"public",
"static",
"function",
"getId",
"(",
"$",
"reference",
"=",
"null",
",",
"$",
"base_id",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"reference",
")",
")",
"{",
"$",
"reference",
"=",
"uniqid",
"(",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"dom_id_register",
"[",
"$",
"reference",
"]",
")",
")",
"{",
"return",
"self",
"::",
"$",
"dom_id_register",
"[",
"$",
"reference",
"]",
";",
"}",
"return",
"self",
"::",
"getNewId",
"(",
"$",
"reference",
",",
"$",
"base_id",
")",
";",
"}"
] | Get a DOM unique ID
@param string $reference A reference used to store the ID (and retrieve it - by default, a uniqid)
@param string|bool $base_id A string that will be used to construct the ID, if set to `true`, the reference will be used as `$base_id`)
@return string The unique ID created or the existing one for the reference if so | [
"Get",
"a",
"DOM",
"unique",
"ID"
] | a2988a11370d13c7e0dc47f9d2d81c664c30b8dd | https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Helper/Html.php#L67-L76 |
4,318 | atelierspierrot/library | src/Library/Helper/Html.php | Html.getNewId | public static function getNewId($reference = null, $base_id = null)
{
if (empty($reference)) {
$reference = uniqid();
}
if (true===$base_id) {
$base_id = $reference;
}
if (!is_null($base_id)) {
$new_id = $base_id;
while(in_array($new_id, self::$dom_id_register)) {
$new_id = $base_id.'_'.uniqid();
}
} else {
$new_id = uniqid();
while(in_array($new_id, self::$dom_id_register)) {
$new_id = uniqid();
}
}
self::$dom_id_register[$reference] = $new_id;
return $new_id;
} | php | public static function getNewId($reference = null, $base_id = null)
{
if (empty($reference)) {
$reference = uniqid();
}
if (true===$base_id) {
$base_id = $reference;
}
if (!is_null($base_id)) {
$new_id = $base_id;
while(in_array($new_id, self::$dom_id_register)) {
$new_id = $base_id.'_'.uniqid();
}
} else {
$new_id = uniqid();
while(in_array($new_id, self::$dom_id_register)) {
$new_id = uniqid();
}
}
self::$dom_id_register[$reference] = $new_id;
return $new_id;
} | [
"public",
"static",
"function",
"getNewId",
"(",
"$",
"reference",
"=",
"null",
",",
"$",
"base_id",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"reference",
")",
")",
"{",
"$",
"reference",
"=",
"uniqid",
"(",
")",
";",
"}",
"if",
"(",
"true",
"===",
"$",
"base_id",
")",
"{",
"$",
"base_id",
"=",
"$",
"reference",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"base_id",
")",
")",
"{",
"$",
"new_id",
"=",
"$",
"base_id",
";",
"while",
"(",
"in_array",
"(",
"$",
"new_id",
",",
"self",
"::",
"$",
"dom_id_register",
")",
")",
"{",
"$",
"new_id",
"=",
"$",
"base_id",
".",
"'_'",
".",
"uniqid",
"(",
")",
";",
"}",
"}",
"else",
"{",
"$",
"new_id",
"=",
"uniqid",
"(",
")",
";",
"while",
"(",
"in_array",
"(",
"$",
"new_id",
",",
"self",
"::",
"$",
"dom_id_register",
")",
")",
"{",
"$",
"new_id",
"=",
"uniqid",
"(",
")",
";",
"}",
"}",
"self",
"::",
"$",
"dom_id_register",
"[",
"$",
"reference",
"]",
"=",
"$",
"new_id",
";",
"return",
"$",
"new_id",
";",
"}"
] | Create and get a new DOM unique ID
@param string $reference A reference used to store the ID (and retrieve it - by default, a uniqid)
@param string|bool $base_id A string that will be used to construct the ID, if set to `true`, the reference will be used as `$base_id`)
@return string The unique ID created | [
"Create",
"and",
"get",
"a",
"new",
"DOM",
"unique",
"ID"
] | a2988a11370d13c7e0dc47f9d2d81c664c30b8dd | https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Helper/Html.php#L85-L106 |
4,319 | atelierspierrot/library | src/Library/Helper/Html.php | Html.writeHtmlTag | public static function writeHtmlTag($tag_name, $content = '', $attrs = array(), $intag_close = false)
{
$str = '<'.$tag_name.self::parseAttributes( $attrs );
if (empty($content) && true===$intag_close) {
$str .= self::$html_tag_closure;
} else {
$str .= '>'.(is_string($content) ? $content : '').'</'.$tag_name.'>';
}
return $str;
} | php | public static function writeHtmlTag($tag_name, $content = '', $attrs = array(), $intag_close = false)
{
$str = '<'.$tag_name.self::parseAttributes( $attrs );
if (empty($content) && true===$intag_close) {
$str .= self::$html_tag_closure;
} else {
$str .= '>'.(is_string($content) ? $content : '').'</'.$tag_name.'>';
}
return $str;
} | [
"public",
"static",
"function",
"writeHtmlTag",
"(",
"$",
"tag_name",
",",
"$",
"content",
"=",
"''",
",",
"$",
"attrs",
"=",
"array",
"(",
")",
",",
"$",
"intag_close",
"=",
"false",
")",
"{",
"$",
"str",
"=",
"'<'",
".",
"$",
"tag_name",
".",
"self",
"::",
"parseAttributes",
"(",
"$",
"attrs",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"content",
")",
"&&",
"true",
"===",
"$",
"intag_close",
")",
"{",
"$",
"str",
".=",
"self",
"::",
"$",
"html_tag_closure",
";",
"}",
"else",
"{",
"$",
"str",
".=",
"'>'",
".",
"(",
"is_string",
"(",
"$",
"content",
")",
"?",
"$",
"content",
":",
"''",
")",
".",
"'</'",
".",
"$",
"tag_name",
".",
"'>'",
";",
"}",
"return",
"$",
"str",
";",
"}"
] | Build an HTML string for a specific tag with attributes
@param string $tag_name The tag name
@param string $content The tag content
@param array $attrs An attributes array
@param bool $intag_close Can this kind of tag be directly closed (default is `false`)
@return string The HTML string for the tag | [
"Build",
"an",
"HTML",
"string",
"for",
"a",
"specific",
"tag",
"with",
"attributes"
] | a2988a11370d13c7e0dc47f9d2d81c664c30b8dd | https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Helper/Html.php#L133-L142 |
4,320 | atelierspierrot/library | src/Library/Helper/Html.php | Html.parseAttributes | public static function parseAttributes(array $attrs = array())
{
$str = '';
foreach($attrs as $var=>$val) {
$str .= ' '.$var.'="'.(is_array($val) ? join(' ', $val) : $val).'"';
}
return $str;
} | php | public static function parseAttributes(array $attrs = array())
{
$str = '';
foreach($attrs as $var=>$val) {
$str .= ' '.$var.'="'.(is_array($val) ? join(' ', $val) : $val).'"';
}
return $str;
} | [
"public",
"static",
"function",
"parseAttributes",
"(",
"array",
"$",
"attrs",
"=",
"array",
"(",
")",
")",
"{",
"$",
"str",
"=",
"''",
";",
"foreach",
"(",
"$",
"attrs",
"as",
"$",
"var",
"=>",
"$",
"val",
")",
"{",
"$",
"str",
".=",
"' '",
".",
"$",
"var",
".",
"'=\"'",
".",
"(",
"is_array",
"(",
"$",
"val",
")",
"?",
"join",
"(",
"' '",
",",
"$",
"val",
")",
":",
"$",
"val",
")",
".",
"'\"'",
";",
"}",
"return",
"$",
"str",
";",
"}"
] | Build an attributes HTML string from an array like `variable => value` pairs
@param array $attrs The attributes array
@return string The attributes string ready for HTML insertion | [
"Build",
"an",
"attributes",
"HTML",
"string",
"from",
"an",
"array",
"like",
"variable",
"=",
">",
"value",
"pairs"
] | a2988a11370d13c7e0dc47f9d2d81c664c30b8dd | https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Helper/Html.php#L150-L157 |
4,321 | atelierspierrot/library | src/Library/Helper/Html.php | Html.javascriptProtect | public static function javascriptProtect($str = '', $protect_quotes = false)
{
$str = preg_replace('/\s\s+/', ' ', $str);
$str = htmlentities($str);
if (true===$protect_quotes) {
$str = str_replace("'", "\'", $str);
$str = str_replace('"', '\"', $str);
}
return $str;
} | php | public static function javascriptProtect($str = '', $protect_quotes = false)
{
$str = preg_replace('/\s\s+/', ' ', $str);
$str = htmlentities($str);
if (true===$protect_quotes) {
$str = str_replace("'", "\'", $str);
$str = str_replace('"', '\"', $str);
}
return $str;
} | [
"public",
"static",
"function",
"javascriptProtect",
"(",
"$",
"str",
"=",
"''",
",",
"$",
"protect_quotes",
"=",
"false",
")",
"{",
"$",
"str",
"=",
"preg_replace",
"(",
"'/\\s\\s+/'",
",",
"' '",
",",
"$",
"str",
")",
";",
"$",
"str",
"=",
"htmlentities",
"(",
"$",
"str",
")",
";",
"if",
"(",
"true",
"===",
"$",
"protect_quotes",
")",
"{",
"$",
"str",
"=",
"str_replace",
"(",
"\"'\"",
",",
"\"\\'\"",
",",
"$",
"str",
")",
";",
"$",
"str",
"=",
"str_replace",
"(",
"'\"'",
",",
"'\\\"'",
",",
"$",
"str",
")",
";",
"}",
"return",
"$",
"str",
";",
"}"
] | Build an HTML string to use in javascripts attributes or functions
@param string $str The HTML string to protect
@param bool $protect_quotes Protect all quotes (simple and double) with a slash
@return string The HTML string ready for javascript insertion | [
"Build",
"an",
"HTML",
"string",
"to",
"use",
"in",
"javascripts",
"attributes",
"or",
"functions"
] | a2988a11370d13c7e0dc47f9d2d81c664c30b8dd | https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Helper/Html.php#L166-L175 |
4,322 | aedart/model | src/Traits/Strings/MacAddressTrait.php | MacAddressTrait.getMacAddress | public function getMacAddress() : ?string
{
if ( ! $this->hasMacAddress()) {
$this->setMacAddress($this->getDefaultMacAddress());
}
return $this->macAddress;
} | php | public function getMacAddress() : ?string
{
if ( ! $this->hasMacAddress()) {
$this->setMacAddress($this->getDefaultMacAddress());
}
return $this->macAddress;
} | [
"public",
"function",
"getMacAddress",
"(",
")",
":",
"?",
"string",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasMacAddress",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setMacAddress",
"(",
"$",
"this",
"->",
"getDefaultMacAddress",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"macAddress",
";",
"}"
] | Get mac address
If no "mac address" value has been set, this method will
set and return a default "mac address" value,
if any such value is available
@see getDefaultMacAddress()
@return string|null mac address or null if no mac address has been set | [
"Get",
"mac",
"address"
] | 9a562c1c53a276d01ace0ab71f5305458bea542f | https://github.com/aedart/model/blob/9a562c1c53a276d01ace0ab71f5305458bea542f/src/Traits/Strings/MacAddressTrait.php#L48-L54 |
4,323 | sndatabase/core | src/ConnectionString.php | ConnectionString.setFetchMode | public function setFetchMode($mode, $complement_info = null, array $ctor_args = array()) {
$fetchMode = new FetchMode($mode, $complement_info, $ctor_args);
$this->attributes[DB::ATTR_DEFAULT_FETCH_MODE] = serialize($fetchMode);
} | php | public function setFetchMode($mode, $complement_info = null, array $ctor_args = array()) {
$fetchMode = new FetchMode($mode, $complement_info, $ctor_args);
$this->attributes[DB::ATTR_DEFAULT_FETCH_MODE] = serialize($fetchMode);
} | [
"public",
"function",
"setFetchMode",
"(",
"$",
"mode",
",",
"$",
"complement_info",
"=",
"null",
",",
"array",
"$",
"ctor_args",
"=",
"array",
"(",
")",
")",
"{",
"$",
"fetchMode",
"=",
"new",
"FetchMode",
"(",
"$",
"mode",
",",
"$",
"complement_info",
",",
"$",
"ctor_args",
")",
";",
"$",
"this",
"->",
"attributes",
"[",
"DB",
"::",
"ATTR_DEFAULT_FETCH_MODE",
"]",
"=",
"serialize",
"(",
"$",
"fetchMode",
")",
";",
"}"
] | Sets default fetch mode
@param int $mode Fetch mode
@param mixed $complement_info For some fetch modes : additionnal information
@param array $ctor_args For DB::FETCH_CLASS : constructor argument list
@see FetchMode | [
"Sets",
"default",
"fetch",
"mode"
] | 8645b71f1cb437a845fcf12ae742655dd874b229 | https://github.com/sndatabase/core/blob/8645b71f1cb437a845fcf12ae742655dd874b229/src/ConnectionString.php#L136-L139 |
4,324 | joomlatools/joomlatools-platform-categories | administrator/components/com_categories/models/category.php | CategoriesModelCategory.canDelete | protected function canDelete($record)
{
if (empty($record->id) || $record->published != -2)
{
return false;
}
return JFactory::getUser()->authorise('core.delete', $record->extension . '.category.' . (int) $record->id);
} | php | protected function canDelete($record)
{
if (empty($record->id) || $record->published != -2)
{
return false;
}
return JFactory::getUser()->authorise('core.delete', $record->extension . '.category.' . (int) $record->id);
} | [
"protected",
"function",
"canDelete",
"(",
"$",
"record",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"record",
"->",
"id",
")",
"||",
"$",
"record",
"->",
"published",
"!=",
"-",
"2",
")",
"{",
"return",
"false",
";",
"}",
"return",
"JFactory",
"::",
"getUser",
"(",
")",
"->",
"authorise",
"(",
"'core.delete'",
",",
"$",
"record",
"->",
"extension",
".",
"'.category.'",
".",
"(",
"int",
")",
"$",
"record",
"->",
"id",
")",
";",
"}"
] | Method to test whether a record can be deleted.
@param object $record A record object.
@return boolean True if allowed to delete the record. Defaults to the permission set in the component.
@since 1.6 | [
"Method",
"to",
"test",
"whether",
"a",
"record",
"can",
"be",
"deleted",
"."
] | 9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350 | https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/administrator/components/com_categories/models/category.php#L47-L55 |
4,325 | joomlatools/joomlatools-platform-categories | administrator/components/com_categories/models/category.php | CategoriesModelCategory.canEditState | protected function canEditState($record)
{
$user = JFactory::getUser();
// Check for existing category.
if (!empty($record->id))
{
return $user->authorise('core.edit.state', $record->extension . '.category.' . (int) $record->id);
}
// New category, so check against the parent.
if (!empty($record->parent_id))
{
return $user->authorise('core.edit.state', $record->extension . '.category.' . (int) $record->parent_id);
}
// Default to component settings if neither category nor parent known.
return $user->authorise('core.edit.state', $record->extension);
} | php | protected function canEditState($record)
{
$user = JFactory::getUser();
// Check for existing category.
if (!empty($record->id))
{
return $user->authorise('core.edit.state', $record->extension . '.category.' . (int) $record->id);
}
// New category, so check against the parent.
if (!empty($record->parent_id))
{
return $user->authorise('core.edit.state', $record->extension . '.category.' . (int) $record->parent_id);
}
// Default to component settings if neither category nor parent known.
return $user->authorise('core.edit.state', $record->extension);
} | [
"protected",
"function",
"canEditState",
"(",
"$",
"record",
")",
"{",
"$",
"user",
"=",
"JFactory",
"::",
"getUser",
"(",
")",
";",
"// Check for existing category.",
"if",
"(",
"!",
"empty",
"(",
"$",
"record",
"->",
"id",
")",
")",
"{",
"return",
"$",
"user",
"->",
"authorise",
"(",
"'core.edit.state'",
",",
"$",
"record",
"->",
"extension",
".",
"'.category.'",
".",
"(",
"int",
")",
"$",
"record",
"->",
"id",
")",
";",
"}",
"// New category, so check against the parent.",
"if",
"(",
"!",
"empty",
"(",
"$",
"record",
"->",
"parent_id",
")",
")",
"{",
"return",
"$",
"user",
"->",
"authorise",
"(",
"'core.edit.state'",
",",
"$",
"record",
"->",
"extension",
".",
"'.category.'",
".",
"(",
"int",
")",
"$",
"record",
"->",
"parent_id",
")",
";",
"}",
"// Default to component settings if neither category nor parent known.",
"return",
"$",
"user",
"->",
"authorise",
"(",
"'core.edit.state'",
",",
"$",
"record",
"->",
"extension",
")",
";",
"}"
] | Method to test whether a record can have its state changed.
@param object $record A record object.
@return boolean True if allowed to change the state of the record. Defaults to the permission set in the component.
@since 1.6 | [
"Method",
"to",
"test",
"whether",
"a",
"record",
"can",
"have",
"its",
"state",
"changed",
"."
] | 9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350 | https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/administrator/components/com_categories/models/category.php#L66-L84 |
4,326 | joomlatools/joomlatools-platform-categories | administrator/components/com_categories/models/category.php | CategoriesModelCategory.populateState | protected function populateState()
{
$app = JFactory::getApplication('administrator');
$parentId = $app->input->getInt('parent_id');
$this->setState('category.parent_id', $parentId);
// Load the User state.
$pk = $app->input->getInt('id');
$this->setState($this->getName() . '.id', $pk);
$extension = $app->input->get('extension', 'com_content');
$this->setState('category.extension', $extension);
$parts = explode('.', $extension);
// Extract the component name
$this->setState('category.component', $parts[0]);
// Extract the optional section name
$this->setState('category.section', (count($parts) > 1) ? $parts[1] : null);
// Load the parameters.
$params = JComponentHelper::getParams('com_categories');
$this->setState('params', $params);
} | php | protected function populateState()
{
$app = JFactory::getApplication('administrator');
$parentId = $app->input->getInt('parent_id');
$this->setState('category.parent_id', $parentId);
// Load the User state.
$pk = $app->input->getInt('id');
$this->setState($this->getName() . '.id', $pk);
$extension = $app->input->get('extension', 'com_content');
$this->setState('category.extension', $extension);
$parts = explode('.', $extension);
// Extract the component name
$this->setState('category.component', $parts[0]);
// Extract the optional section name
$this->setState('category.section', (count($parts) > 1) ? $parts[1] : null);
// Load the parameters.
$params = JComponentHelper::getParams('com_categories');
$this->setState('params', $params);
} | [
"protected",
"function",
"populateState",
"(",
")",
"{",
"$",
"app",
"=",
"JFactory",
"::",
"getApplication",
"(",
"'administrator'",
")",
";",
"$",
"parentId",
"=",
"$",
"app",
"->",
"input",
"->",
"getInt",
"(",
"'parent_id'",
")",
";",
"$",
"this",
"->",
"setState",
"(",
"'category.parent_id'",
",",
"$",
"parentId",
")",
";",
"// Load the User state.",
"$",
"pk",
"=",
"$",
"app",
"->",
"input",
"->",
"getInt",
"(",
"'id'",
")",
";",
"$",
"this",
"->",
"setState",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
".",
"'.id'",
",",
"$",
"pk",
")",
";",
"$",
"extension",
"=",
"$",
"app",
"->",
"input",
"->",
"get",
"(",
"'extension'",
",",
"'com_content'",
")",
";",
"$",
"this",
"->",
"setState",
"(",
"'category.extension'",
",",
"$",
"extension",
")",
";",
"$",
"parts",
"=",
"explode",
"(",
"'.'",
",",
"$",
"extension",
")",
";",
"// Extract the component name",
"$",
"this",
"->",
"setState",
"(",
"'category.component'",
",",
"$",
"parts",
"[",
"0",
"]",
")",
";",
"// Extract the optional section name",
"$",
"this",
"->",
"setState",
"(",
"'category.section'",
",",
"(",
"count",
"(",
"$",
"parts",
")",
">",
"1",
")",
"?",
"$",
"parts",
"[",
"1",
"]",
":",
"null",
")",
";",
"// Load the parameters.",
"$",
"params",
"=",
"JComponentHelper",
"::",
"getParams",
"(",
"'com_categories'",
")",
";",
"$",
"this",
"->",
"setState",
"(",
"'params'",
",",
"$",
"params",
")",
";",
"}"
] | Auto-populate the model state.
Note. Calling getState in this method will result in recursion.
@return void
@since 1.6 | [
"Auto",
"-",
"populate",
"the",
"model",
"state",
"."
] | 9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350 | https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/administrator/components/com_categories/models/category.php#L111-L135 |
4,327 | joomlatools/joomlatools-platform-categories | administrator/components/com_categories/models/category.php | CategoriesModelCategory.getItem | public function getItem($pk = null)
{
if ($result = parent::getItem($pk))
{
// Prime required properties.
if (empty($result->id))
{
$result->parent_id = $this->getState('category.parent_id');
$result->extension = $this->getState('category.extension');
}
// Convert the metadata field to an array.
$registry = new Registry;
$registry->loadString($result->metadata);
$result->metadata = $registry->toArray();
// Convert the created and modified dates to local user time for display in the form.
$tz = new DateTimeZone(JFactory::getApplication()->get('offset'));
if ((int) $result->created_time)
{
$date = new JDate($result->created_time);
$date->setTimezone($tz);
$result->created_time = $date->toSql(true);
}
else
{
$result->created_time = null;
}
if ((int) $result->modified_time)
{
$date = new JDate($result->modified_time);
$date->setTimezone($tz);
$result->modified_time = $date->toSql(true);
}
else
{
$result->modified_time = null;
}
}
$assoc = $this->getAssoc();
if ($assoc)
{
if ($result->id != null)
{
$result->associations = ArrayHelper::toInteger(CategoriesHelper::getAssociations($result->id, $result->extension));
}
else
{
$result->associations = array();
}
}
return $result;
} | php | public function getItem($pk = null)
{
if ($result = parent::getItem($pk))
{
// Prime required properties.
if (empty($result->id))
{
$result->parent_id = $this->getState('category.parent_id');
$result->extension = $this->getState('category.extension');
}
// Convert the metadata field to an array.
$registry = new Registry;
$registry->loadString($result->metadata);
$result->metadata = $registry->toArray();
// Convert the created and modified dates to local user time for display in the form.
$tz = new DateTimeZone(JFactory::getApplication()->get('offset'));
if ((int) $result->created_time)
{
$date = new JDate($result->created_time);
$date->setTimezone($tz);
$result->created_time = $date->toSql(true);
}
else
{
$result->created_time = null;
}
if ((int) $result->modified_time)
{
$date = new JDate($result->modified_time);
$date->setTimezone($tz);
$result->modified_time = $date->toSql(true);
}
else
{
$result->modified_time = null;
}
}
$assoc = $this->getAssoc();
if ($assoc)
{
if ($result->id != null)
{
$result->associations = ArrayHelper::toInteger(CategoriesHelper::getAssociations($result->id, $result->extension));
}
else
{
$result->associations = array();
}
}
return $result;
} | [
"public",
"function",
"getItem",
"(",
"$",
"pk",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"result",
"=",
"parent",
"::",
"getItem",
"(",
"$",
"pk",
")",
")",
"{",
"// Prime required properties.",
"if",
"(",
"empty",
"(",
"$",
"result",
"->",
"id",
")",
")",
"{",
"$",
"result",
"->",
"parent_id",
"=",
"$",
"this",
"->",
"getState",
"(",
"'category.parent_id'",
")",
";",
"$",
"result",
"->",
"extension",
"=",
"$",
"this",
"->",
"getState",
"(",
"'category.extension'",
")",
";",
"}",
"// Convert the metadata field to an array.",
"$",
"registry",
"=",
"new",
"Registry",
";",
"$",
"registry",
"->",
"loadString",
"(",
"$",
"result",
"->",
"metadata",
")",
";",
"$",
"result",
"->",
"metadata",
"=",
"$",
"registry",
"->",
"toArray",
"(",
")",
";",
"// Convert the created and modified dates to local user time for display in the form.",
"$",
"tz",
"=",
"new",
"DateTimeZone",
"(",
"JFactory",
"::",
"getApplication",
"(",
")",
"->",
"get",
"(",
"'offset'",
")",
")",
";",
"if",
"(",
"(",
"int",
")",
"$",
"result",
"->",
"created_time",
")",
"{",
"$",
"date",
"=",
"new",
"JDate",
"(",
"$",
"result",
"->",
"created_time",
")",
";",
"$",
"date",
"->",
"setTimezone",
"(",
"$",
"tz",
")",
";",
"$",
"result",
"->",
"created_time",
"=",
"$",
"date",
"->",
"toSql",
"(",
"true",
")",
";",
"}",
"else",
"{",
"$",
"result",
"->",
"created_time",
"=",
"null",
";",
"}",
"if",
"(",
"(",
"int",
")",
"$",
"result",
"->",
"modified_time",
")",
"{",
"$",
"date",
"=",
"new",
"JDate",
"(",
"$",
"result",
"->",
"modified_time",
")",
";",
"$",
"date",
"->",
"setTimezone",
"(",
"$",
"tz",
")",
";",
"$",
"result",
"->",
"modified_time",
"=",
"$",
"date",
"->",
"toSql",
"(",
"true",
")",
";",
"}",
"else",
"{",
"$",
"result",
"->",
"modified_time",
"=",
"null",
";",
"}",
"}",
"$",
"assoc",
"=",
"$",
"this",
"->",
"getAssoc",
"(",
")",
";",
"if",
"(",
"$",
"assoc",
")",
"{",
"if",
"(",
"$",
"result",
"->",
"id",
"!=",
"null",
")",
"{",
"$",
"result",
"->",
"associations",
"=",
"ArrayHelper",
"::",
"toInteger",
"(",
"CategoriesHelper",
"::",
"getAssociations",
"(",
"$",
"result",
"->",
"id",
",",
"$",
"result",
"->",
"extension",
")",
")",
";",
"}",
"else",
"{",
"$",
"result",
"->",
"associations",
"=",
"array",
"(",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Method to get a category.
@param integer $pk An optional id of the object to get, otherwise the id from the model state is used.
@return mixed Category data object on success, false on failure.
@since 1.6 | [
"Method",
"to",
"get",
"a",
"category",
"."
] | 9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350 | https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/administrator/components/com_categories/models/category.php#L146-L203 |
4,328 | joomlatools/joomlatools-platform-categories | administrator/components/com_categories/models/category.php | CategoriesModelCategory.getForm | public function getForm($data = array(), $loadData = true)
{
$extension = $this->getState('category.extension');
$jinput = JFactory::getApplication()->input;
// A workaround to get the extension into the model for save requests.
if (empty($extension) && isset($data['extension']))
{
$extension = $data['extension'];
$parts = explode('.', $extension);
$this->setState('category.extension', $extension);
$this->setState('category.component', $parts[0]);
$this->setState('category.section', @$parts[1]);
}
// Get the form.
$form = $this->loadForm('com_categories.category' . $extension, 'category', array('control' => 'jform', 'load_data' => $loadData));
if (empty($form))
{
return false;
}
// Modify the form based on Edit State access controls.
if (empty($data['extension']))
{
$data['extension'] = $extension;
}
$user = JFactory::getUser();
if (!$user->authorise('core.edit.state', $extension . '.category.' . $jinput->get('id')))
{
// Disable fields for display.
$form->setFieldAttribute('ordering', 'disabled', 'true');
$form->setFieldAttribute('published', 'disabled', 'true');
// Disable fields while saving.
// The controller has already verified this is a record you can edit.
$form->setFieldAttribute('ordering', 'filter', 'unset');
$form->setFieldAttribute('published', 'filter', 'unset');
}
return $form;
} | php | public function getForm($data = array(), $loadData = true)
{
$extension = $this->getState('category.extension');
$jinput = JFactory::getApplication()->input;
// A workaround to get the extension into the model for save requests.
if (empty($extension) && isset($data['extension']))
{
$extension = $data['extension'];
$parts = explode('.', $extension);
$this->setState('category.extension', $extension);
$this->setState('category.component', $parts[0]);
$this->setState('category.section', @$parts[1]);
}
// Get the form.
$form = $this->loadForm('com_categories.category' . $extension, 'category', array('control' => 'jform', 'load_data' => $loadData));
if (empty($form))
{
return false;
}
// Modify the form based on Edit State access controls.
if (empty($data['extension']))
{
$data['extension'] = $extension;
}
$user = JFactory::getUser();
if (!$user->authorise('core.edit.state', $extension . '.category.' . $jinput->get('id')))
{
// Disable fields for display.
$form->setFieldAttribute('ordering', 'disabled', 'true');
$form->setFieldAttribute('published', 'disabled', 'true');
// Disable fields while saving.
// The controller has already verified this is a record you can edit.
$form->setFieldAttribute('ordering', 'filter', 'unset');
$form->setFieldAttribute('published', 'filter', 'unset');
}
return $form;
} | [
"public",
"function",
"getForm",
"(",
"$",
"data",
"=",
"array",
"(",
")",
",",
"$",
"loadData",
"=",
"true",
")",
"{",
"$",
"extension",
"=",
"$",
"this",
"->",
"getState",
"(",
"'category.extension'",
")",
";",
"$",
"jinput",
"=",
"JFactory",
"::",
"getApplication",
"(",
")",
"->",
"input",
";",
"// A workaround to get the extension into the model for save requests.",
"if",
"(",
"empty",
"(",
"$",
"extension",
")",
"&&",
"isset",
"(",
"$",
"data",
"[",
"'extension'",
"]",
")",
")",
"{",
"$",
"extension",
"=",
"$",
"data",
"[",
"'extension'",
"]",
";",
"$",
"parts",
"=",
"explode",
"(",
"'.'",
",",
"$",
"extension",
")",
";",
"$",
"this",
"->",
"setState",
"(",
"'category.extension'",
",",
"$",
"extension",
")",
";",
"$",
"this",
"->",
"setState",
"(",
"'category.component'",
",",
"$",
"parts",
"[",
"0",
"]",
")",
";",
"$",
"this",
"->",
"setState",
"(",
"'category.section'",
",",
"@",
"$",
"parts",
"[",
"1",
"]",
")",
";",
"}",
"// Get the form.",
"$",
"form",
"=",
"$",
"this",
"->",
"loadForm",
"(",
"'com_categories.category'",
".",
"$",
"extension",
",",
"'category'",
",",
"array",
"(",
"'control'",
"=>",
"'jform'",
",",
"'load_data'",
"=>",
"$",
"loadData",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"form",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Modify the form based on Edit State access controls.",
"if",
"(",
"empty",
"(",
"$",
"data",
"[",
"'extension'",
"]",
")",
")",
"{",
"$",
"data",
"[",
"'extension'",
"]",
"=",
"$",
"extension",
";",
"}",
"$",
"user",
"=",
"JFactory",
"::",
"getUser",
"(",
")",
";",
"if",
"(",
"!",
"$",
"user",
"->",
"authorise",
"(",
"'core.edit.state'",
",",
"$",
"extension",
".",
"'.category.'",
".",
"$",
"jinput",
"->",
"get",
"(",
"'id'",
")",
")",
")",
"{",
"// Disable fields for display.",
"$",
"form",
"->",
"setFieldAttribute",
"(",
"'ordering'",
",",
"'disabled'",
",",
"'true'",
")",
";",
"$",
"form",
"->",
"setFieldAttribute",
"(",
"'published'",
",",
"'disabled'",
",",
"'true'",
")",
";",
"// Disable fields while saving.",
"// The controller has already verified this is a record you can edit.",
"$",
"form",
"->",
"setFieldAttribute",
"(",
"'ordering'",
",",
"'filter'",
",",
"'unset'",
")",
";",
"$",
"form",
"->",
"setFieldAttribute",
"(",
"'published'",
",",
"'filter'",
",",
"'unset'",
")",
";",
"}",
"return",
"$",
"form",
";",
"}"
] | Method to get the row form.
@param array $data Data for the form.
@param boolean $loadData True if the form is to load its own data (default case), false if not.
@return JForm|boolean A JForm object on success, false on failure
@since 1.6 | [
"Method",
"to",
"get",
"the",
"row",
"form",
"."
] | 9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350 | https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/administrator/components/com_categories/models/category.php#L215-L260 |
4,329 | joomlatools/joomlatools-platform-categories | administrator/components/com_categories/models/category.php | CategoriesModelCategory.loadFormData | protected function loadFormData()
{
// Check the session for previously entered form data.
$app = JFactory::getApplication();
$data = $app->getUserState('com_categories.edit.' . $this->getName() . '.data', array());
if (empty($data))
{
$data = $this->getItem();
// Pre-select some filters (Status, Language, Access) in edit form if those have been selected in Category Manager
if (!$data->id)
{
// Check for which extension the Category Manager is used and get selected fields
$extension = substr($app->getUserState('com_categories.categories.filter.extension'), 4);
$filters = (array) $app->getUserState('com_categories.categories.' . $extension . '.filter');
$data->set(
'published',
$app->input->getInt(
'published',
((isset($filters['published']) && $filters['published'] !== '') ? $filters['published'] : null)
)
);
$data->set('language', $app->input->getString('language', (!empty($filters['language']) ? $filters['language'] : null)));
$data->set(
'access',
$app->input->getInt('access', (!empty($filters['access']) ? $filters['access'] : JFactory::getConfig()->get('access')))
);
}
}
$this->preprocessData('com_categories.category', $data);
return $data;
} | php | protected function loadFormData()
{
// Check the session for previously entered form data.
$app = JFactory::getApplication();
$data = $app->getUserState('com_categories.edit.' . $this->getName() . '.data', array());
if (empty($data))
{
$data = $this->getItem();
// Pre-select some filters (Status, Language, Access) in edit form if those have been selected in Category Manager
if (!$data->id)
{
// Check for which extension the Category Manager is used and get selected fields
$extension = substr($app->getUserState('com_categories.categories.filter.extension'), 4);
$filters = (array) $app->getUserState('com_categories.categories.' . $extension . '.filter');
$data->set(
'published',
$app->input->getInt(
'published',
((isset($filters['published']) && $filters['published'] !== '') ? $filters['published'] : null)
)
);
$data->set('language', $app->input->getString('language', (!empty($filters['language']) ? $filters['language'] : null)));
$data->set(
'access',
$app->input->getInt('access', (!empty($filters['access']) ? $filters['access'] : JFactory::getConfig()->get('access')))
);
}
}
$this->preprocessData('com_categories.category', $data);
return $data;
} | [
"protected",
"function",
"loadFormData",
"(",
")",
"{",
"// Check the session for previously entered form data.",
"$",
"app",
"=",
"JFactory",
"::",
"getApplication",
"(",
")",
";",
"$",
"data",
"=",
"$",
"app",
"->",
"getUserState",
"(",
"'com_categories.edit.'",
".",
"$",
"this",
"->",
"getName",
"(",
")",
".",
"'.data'",
",",
"array",
"(",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"data",
")",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getItem",
"(",
")",
";",
"// Pre-select some filters (Status, Language, Access) in edit form if those have been selected in Category Manager",
"if",
"(",
"!",
"$",
"data",
"->",
"id",
")",
"{",
"// Check for which extension the Category Manager is used and get selected fields",
"$",
"extension",
"=",
"substr",
"(",
"$",
"app",
"->",
"getUserState",
"(",
"'com_categories.categories.filter.extension'",
")",
",",
"4",
")",
";",
"$",
"filters",
"=",
"(",
"array",
")",
"$",
"app",
"->",
"getUserState",
"(",
"'com_categories.categories.'",
".",
"$",
"extension",
".",
"'.filter'",
")",
";",
"$",
"data",
"->",
"set",
"(",
"'published'",
",",
"$",
"app",
"->",
"input",
"->",
"getInt",
"(",
"'published'",
",",
"(",
"(",
"isset",
"(",
"$",
"filters",
"[",
"'published'",
"]",
")",
"&&",
"$",
"filters",
"[",
"'published'",
"]",
"!==",
"''",
")",
"?",
"$",
"filters",
"[",
"'published'",
"]",
":",
"null",
")",
")",
")",
";",
"$",
"data",
"->",
"set",
"(",
"'language'",
",",
"$",
"app",
"->",
"input",
"->",
"getString",
"(",
"'language'",
",",
"(",
"!",
"empty",
"(",
"$",
"filters",
"[",
"'language'",
"]",
")",
"?",
"$",
"filters",
"[",
"'language'",
"]",
":",
"null",
")",
")",
")",
";",
"$",
"data",
"->",
"set",
"(",
"'access'",
",",
"$",
"app",
"->",
"input",
"->",
"getInt",
"(",
"'access'",
",",
"(",
"!",
"empty",
"(",
"$",
"filters",
"[",
"'access'",
"]",
")",
"?",
"$",
"filters",
"[",
"'access'",
"]",
":",
"JFactory",
"::",
"getConfig",
"(",
")",
"->",
"get",
"(",
"'access'",
")",
")",
")",
")",
";",
"}",
"}",
"$",
"this",
"->",
"preprocessData",
"(",
"'com_categories.category'",
",",
"$",
"data",
")",
";",
"return",
"$",
"data",
";",
"}"
] | Method to get the data that should be injected in the form.
@return mixed The data for the form.
@since 1.6 | [
"Method",
"to",
"get",
"the",
"data",
"that",
"should",
"be",
"injected",
"in",
"the",
"form",
"."
] | 9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350 | https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/administrator/components/com_categories/models/category.php#L284-L319 |
4,330 | joomlatools/joomlatools-platform-categories | administrator/components/com_categories/models/category.php | CategoriesModelCategory.publish | public function publish(&$pks, $value = 1)
{
if (parent::publish($pks, $value))
{
$dispatcher = JEventDispatcher::getInstance();
$extension = JFactory::getApplication()->input->get('extension');
// Include the content plugins for the change of category state event.
JPluginHelper::importPlugin('content');
// Trigger the onCategoryChangeState event.
$dispatcher->trigger('onCategoryChangeState', array($extension, $pks, $value));
return true;
}
} | php | public function publish(&$pks, $value = 1)
{
if (parent::publish($pks, $value))
{
$dispatcher = JEventDispatcher::getInstance();
$extension = JFactory::getApplication()->input->get('extension');
// Include the content plugins for the change of category state event.
JPluginHelper::importPlugin('content');
// Trigger the onCategoryChangeState event.
$dispatcher->trigger('onCategoryChangeState', array($extension, $pks, $value));
return true;
}
} | [
"public",
"function",
"publish",
"(",
"&",
"$",
"pks",
",",
"$",
"value",
"=",
"1",
")",
"{",
"if",
"(",
"parent",
"::",
"publish",
"(",
"$",
"pks",
",",
"$",
"value",
")",
")",
"{",
"$",
"dispatcher",
"=",
"JEventDispatcher",
"::",
"getInstance",
"(",
")",
";",
"$",
"extension",
"=",
"JFactory",
"::",
"getApplication",
"(",
")",
"->",
"input",
"->",
"get",
"(",
"'extension'",
")",
";",
"// Include the content plugins for the change of category state event.",
"JPluginHelper",
"::",
"importPlugin",
"(",
"'content'",
")",
";",
"// Trigger the onCategoryChangeState event.",
"$",
"dispatcher",
"->",
"trigger",
"(",
"'onCategoryChangeState'",
",",
"array",
"(",
"$",
"extension",
",",
"$",
"pks",
",",
"$",
"value",
")",
")",
";",
"return",
"true",
";",
"}",
"}"
] | Method to change the published state of one or more records.
@param array &$pks A list of the primary keys to change.
@param integer $value The value of the published state.
@return boolean True on success.
@since 2.5 | [
"Method",
"to",
"change",
"the",
"published",
"state",
"of",
"one",
"or",
"more",
"records",
"."
] | 9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350 | https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/administrator/components/com_categories/models/category.php#L670-L685 |
4,331 | joomlatools/joomlatools-platform-categories | administrator/components/com_categories/models/category.php | CategoriesModelCategory.rebuild | public function rebuild()
{
// Get an instance of the table object.
$table = $this->getTable();
if (!$table->rebuild())
{
$this->setError($table->getError());
return false;
}
// Clear the cache
$this->cleanCache();
return true;
} | php | public function rebuild()
{
// Get an instance of the table object.
$table = $this->getTable();
if (!$table->rebuild())
{
$this->setError($table->getError());
return false;
}
// Clear the cache
$this->cleanCache();
return true;
} | [
"public",
"function",
"rebuild",
"(",
")",
"{",
"// Get an instance of the table object.",
"$",
"table",
"=",
"$",
"this",
"->",
"getTable",
"(",
")",
";",
"if",
"(",
"!",
"$",
"table",
"->",
"rebuild",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setError",
"(",
"$",
"table",
"->",
"getError",
"(",
")",
")",
";",
"return",
"false",
";",
"}",
"// Clear the cache",
"$",
"this",
"->",
"cleanCache",
"(",
")",
";",
"return",
"true",
";",
"}"
] | Method rebuild the entire nested set tree.
@return boolean False on failure or error, true otherwise.
@since 1.6 | [
"Method",
"rebuild",
"the",
"entire",
"nested",
"set",
"tree",
"."
] | 9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350 | https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/administrator/components/com_categories/models/category.php#L694-L710 |
4,332 | joomlatools/joomlatools-platform-categories | administrator/components/com_categories/models/category.php | CategoriesModelCategory.saveorder | public function saveorder($idArray = null, $lft_array = null)
{
// Get an instance of the table object.
$table = $this->getTable();
if (!$table->saveorder($idArray, $lft_array))
{
$this->setError($table->getError());
return false;
}
// Clear the cache
$this->cleanCache();
return true;
} | php | public function saveorder($idArray = null, $lft_array = null)
{
// Get an instance of the table object.
$table = $this->getTable();
if (!$table->saveorder($idArray, $lft_array))
{
$this->setError($table->getError());
return false;
}
// Clear the cache
$this->cleanCache();
return true;
} | [
"public",
"function",
"saveorder",
"(",
"$",
"idArray",
"=",
"null",
",",
"$",
"lft_array",
"=",
"null",
")",
"{",
"// Get an instance of the table object.",
"$",
"table",
"=",
"$",
"this",
"->",
"getTable",
"(",
")",
";",
"if",
"(",
"!",
"$",
"table",
"->",
"saveorder",
"(",
"$",
"idArray",
",",
"$",
"lft_array",
")",
")",
"{",
"$",
"this",
"->",
"setError",
"(",
"$",
"table",
"->",
"getError",
"(",
")",
")",
";",
"return",
"false",
";",
"}",
"// Clear the cache",
"$",
"this",
"->",
"cleanCache",
"(",
")",
";",
"return",
"true",
";",
"}"
] | Method to save the reordered nested set tree.
First we save the new order values in the lft values of the changed ids.
Then we invoke the table rebuild to implement the new ordering.
@param array $idArray An array of primary key ids.
@param integer $lft_array The lft value
@return boolean False on failure or error, True otherwise
@since 1.6 | [
"Method",
"to",
"save",
"the",
"reordered",
"nested",
"set",
"tree",
".",
"First",
"we",
"save",
"the",
"new",
"order",
"values",
"in",
"the",
"lft",
"values",
"of",
"the",
"changed",
"ids",
".",
"Then",
"we",
"invoke",
"the",
"table",
"rebuild",
"to",
"implement",
"the",
"new",
"ordering",
"."
] | 9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350 | https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/administrator/components/com_categories/models/category.php#L724-L740 |
4,333 | joomlatools/joomlatools-platform-categories | administrator/components/com_categories/models/category.php | CategoriesModelCategory.cleanCache | protected function cleanCache($group = null, $client_id = 0)
{
$extension = JFactory::getApplication()->input->get('extension');
switch ($extension)
{
case 'com_content':
parent::cleanCache('com_content');
parent::cleanCache('mod_articles_archive');
parent::cleanCache('mod_articles_categories');
parent::cleanCache('mod_articles_category');
parent::cleanCache('mod_articles_latest');
parent::cleanCache('mod_articles_news');
parent::cleanCache('mod_articles_popular');
break;
default:
parent::cleanCache($extension);
break;
}
} | php | protected function cleanCache($group = null, $client_id = 0)
{
$extension = JFactory::getApplication()->input->get('extension');
switch ($extension)
{
case 'com_content':
parent::cleanCache('com_content');
parent::cleanCache('mod_articles_archive');
parent::cleanCache('mod_articles_categories');
parent::cleanCache('mod_articles_category');
parent::cleanCache('mod_articles_latest');
parent::cleanCache('mod_articles_news');
parent::cleanCache('mod_articles_popular');
break;
default:
parent::cleanCache($extension);
break;
}
} | [
"protected",
"function",
"cleanCache",
"(",
"$",
"group",
"=",
"null",
",",
"$",
"client_id",
"=",
"0",
")",
"{",
"$",
"extension",
"=",
"JFactory",
"::",
"getApplication",
"(",
")",
"->",
"input",
"->",
"get",
"(",
"'extension'",
")",
";",
"switch",
"(",
"$",
"extension",
")",
"{",
"case",
"'com_content'",
":",
"parent",
"::",
"cleanCache",
"(",
"'com_content'",
")",
";",
"parent",
"::",
"cleanCache",
"(",
"'mod_articles_archive'",
")",
";",
"parent",
"::",
"cleanCache",
"(",
"'mod_articles_categories'",
")",
";",
"parent",
"::",
"cleanCache",
"(",
"'mod_articles_category'",
")",
";",
"parent",
"::",
"cleanCache",
"(",
"'mod_articles_latest'",
")",
";",
"parent",
"::",
"cleanCache",
"(",
"'mod_articles_news'",
")",
";",
"parent",
"::",
"cleanCache",
"(",
"'mod_articles_popular'",
")",
";",
"break",
";",
"default",
":",
"parent",
"::",
"cleanCache",
"(",
"$",
"extension",
")",
";",
"break",
";",
"}",
"}"
] | Custom clean the cache of com_content and content modules
@param string $group Cache group name.
@param integer $client_id Application client id.
@return void
@since 1.6 | [
"Custom",
"clean",
"the",
"cache",
"of",
"com_content",
"and",
"content",
"modules"
] | 9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350 | https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/administrator/components/com_categories/models/category.php#L1109-L1128 |
4,334 | joomlatools/joomlatools-platform-categories | administrator/components/com_categories/models/category.php | CategoriesModelCategory.generateNewTitle | protected function generateNewTitle($parent_id, $alias, $title)
{
// Alter the title & alias
$table = $this->getTable();
while ($table->load(array('alias' => $alias, 'parent_id' => $parent_id)))
{
$title = JString::increment($title);
$alias = JString::increment($alias, 'dash');
}
return array($title, $alias);
} | php | protected function generateNewTitle($parent_id, $alias, $title)
{
// Alter the title & alias
$table = $this->getTable();
while ($table->load(array('alias' => $alias, 'parent_id' => $parent_id)))
{
$title = JString::increment($title);
$alias = JString::increment($alias, 'dash');
}
return array($title, $alias);
} | [
"protected",
"function",
"generateNewTitle",
"(",
"$",
"parent_id",
",",
"$",
"alias",
",",
"$",
"title",
")",
"{",
"// Alter the title & alias",
"$",
"table",
"=",
"$",
"this",
"->",
"getTable",
"(",
")",
";",
"while",
"(",
"$",
"table",
"->",
"load",
"(",
"array",
"(",
"'alias'",
"=>",
"$",
"alias",
",",
"'parent_id'",
"=>",
"$",
"parent_id",
")",
")",
")",
"{",
"$",
"title",
"=",
"JString",
"::",
"increment",
"(",
"$",
"title",
")",
";",
"$",
"alias",
"=",
"JString",
"::",
"increment",
"(",
"$",
"alias",
",",
"'dash'",
")",
";",
"}",
"return",
"array",
"(",
"$",
"title",
",",
"$",
"alias",
")",
";",
"}"
] | Method to change the title & alias.
@param integer $parent_id The id of the parent.
@param string $alias The alias.
@param string $title The title.
@return array Contains the modified title and alias.
@since 1.7 | [
"Method",
"to",
"change",
"the",
"title",
"&",
"alias",
"."
] | 9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350 | https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/administrator/components/com_categories/models/category.php#L1141-L1153 |
4,335 | joomlatools/joomlatools-platform-categories | administrator/components/com_categories/models/category.php | CategoriesModelCategory.getAssoc | public function getAssoc()
{
static $assoc = null;
if (!is_null($assoc))
{
return $assoc;
}
$extension = $this->getState('category.extension');
$assoc = JLanguageAssociations::isEnabled();
$extension = explode('.', $extension);
$component = array_shift($extension);
$cname = str_replace('com_', '', $component);
if (!$assoc || !$component || !$cname)
{
$assoc = false;
}
else
{
$hname = $cname . 'HelperAssociation';
JLoader::register($hname, JPATH_SITE . '/components/' . $component . '/helpers/association.php');
$assoc = class_exists($hname) && !empty($hname::$category_association);
}
return $assoc;
} | php | public function getAssoc()
{
static $assoc = null;
if (!is_null($assoc))
{
return $assoc;
}
$extension = $this->getState('category.extension');
$assoc = JLanguageAssociations::isEnabled();
$extension = explode('.', $extension);
$component = array_shift($extension);
$cname = str_replace('com_', '', $component);
if (!$assoc || !$component || !$cname)
{
$assoc = false;
}
else
{
$hname = $cname . 'HelperAssociation';
JLoader::register($hname, JPATH_SITE . '/components/' . $component . '/helpers/association.php');
$assoc = class_exists($hname) && !empty($hname::$category_association);
}
return $assoc;
} | [
"public",
"function",
"getAssoc",
"(",
")",
"{",
"static",
"$",
"assoc",
"=",
"null",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"assoc",
")",
")",
"{",
"return",
"$",
"assoc",
";",
"}",
"$",
"extension",
"=",
"$",
"this",
"->",
"getState",
"(",
"'category.extension'",
")",
";",
"$",
"assoc",
"=",
"JLanguageAssociations",
"::",
"isEnabled",
"(",
")",
";",
"$",
"extension",
"=",
"explode",
"(",
"'.'",
",",
"$",
"extension",
")",
";",
"$",
"component",
"=",
"array_shift",
"(",
"$",
"extension",
")",
";",
"$",
"cname",
"=",
"str_replace",
"(",
"'com_'",
",",
"''",
",",
"$",
"component",
")",
";",
"if",
"(",
"!",
"$",
"assoc",
"||",
"!",
"$",
"component",
"||",
"!",
"$",
"cname",
")",
"{",
"$",
"assoc",
"=",
"false",
";",
"}",
"else",
"{",
"$",
"hname",
"=",
"$",
"cname",
".",
"'HelperAssociation'",
";",
"JLoader",
"::",
"register",
"(",
"$",
"hname",
",",
"JPATH_SITE",
".",
"'/components/'",
".",
"$",
"component",
".",
"'/helpers/association.php'",
")",
";",
"$",
"assoc",
"=",
"class_exists",
"(",
"$",
"hname",
")",
"&&",
"!",
"empty",
"(",
"$",
"hname",
"::",
"$",
"category_association",
")",
";",
"}",
"return",
"$",
"assoc",
";",
"}"
] | Method to determine if a category association is available.
@return boolean True if a category association is available; false otherwise. | [
"Method",
"to",
"determine",
"if",
"a",
"category",
"association",
"is",
"available",
"."
] | 9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350 | https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/administrator/components/com_categories/models/category.php#L1160-L1189 |
4,336 | unclecheese/silverstripe-green | code/DesignModule.php | DesignModule.getMainTemplateFile | public function getMainTemplateFile()
{
$main = $this->getPath() . '/main.ss';
if(file_exists($main)) {
return $main;
}
$main = (string) $this->getConfiguration()->main_template;
if($main) {
return SSViewer::getTemplateFileByType($main, 'main');
}
return false;
} | php | public function getMainTemplateFile()
{
$main = $this->getPath() . '/main.ss';
if(file_exists($main)) {
return $main;
}
$main = (string) $this->getConfiguration()->main_template;
if($main) {
return SSViewer::getTemplateFileByType($main, 'main');
}
return false;
} | [
"public",
"function",
"getMainTemplateFile",
"(",
")",
"{",
"$",
"main",
"=",
"$",
"this",
"->",
"getPath",
"(",
")",
".",
"'/main.ss'",
";",
"if",
"(",
"file_exists",
"(",
"$",
"main",
")",
")",
"{",
"return",
"$",
"main",
";",
"}",
"$",
"main",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"getConfiguration",
"(",
")",
"->",
"main_template",
";",
"if",
"(",
"$",
"main",
")",
"{",
"return",
"SSViewer",
"::",
"getTemplateFileByType",
"(",
"$",
"main",
",",
"'main'",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Gets the absolute path to the main template file
@return string | [
"Gets",
"the",
"absolute",
"path",
"to",
"the",
"main",
"template",
"file"
] | 4395dcef5f4efd5a2c67e0bba3ab5cc583e3fdd4 | https://github.com/unclecheese/silverstripe-green/blob/4395dcef5f4efd5a2c67e0bba3ab5cc583e3fdd4/code/DesignModule.php#L99-L113 |
4,337 | unclecheese/silverstripe-green | code/DesignModule.php | DesignModule.getDataSource | public function getDataSource()
{
foreach (self::$data_file_names as $name) {
$path = $this->getPath() . '/' . $name;
if (file_exists($path)) {
return new DataSource($path);
}
}
return false;
} | php | public function getDataSource()
{
foreach (self::$data_file_names as $name) {
$path = $this->getPath() . '/' . $name;
if (file_exists($path)) {
return new DataSource($path);
}
}
return false;
} | [
"public",
"function",
"getDataSource",
"(",
")",
"{",
"foreach",
"(",
"self",
"::",
"$",
"data_file_names",
"as",
"$",
"name",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"getPath",
"(",
")",
".",
"'/'",
".",
"$",
"name",
";",
"if",
"(",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"return",
"new",
"DataSource",
"(",
"$",
"path",
")",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Gets the data source as an object
@return bool|DataSource | [
"Gets",
"the",
"data",
"source",
"as",
"an",
"object"
] | 4395dcef5f4efd5a2c67e0bba3ab5cc583e3fdd4 | https://github.com/unclecheese/silverstripe-green/blob/4395dcef5f4efd5a2c67e0bba3ab5cc583e3fdd4/code/DesignModule.php#L135-L145 |
4,338 | unclecheese/silverstripe-green | code/DesignModule.php | DesignModule.loadRequirements | public function loadRequirements()
{
foreach ($this->getStylesheets() as $css) {
Requirements::css($this->getRelativePath().'/'.basename($css));
}
foreach ($this->getJavascripts() as $js) {
Requirements::javascript($this->getRelativePath().'/'.basename($js));
}
} | php | public function loadRequirements()
{
foreach ($this->getStylesheets() as $css) {
Requirements::css($this->getRelativePath().'/'.basename($css));
}
foreach ($this->getJavascripts() as $js) {
Requirements::javascript($this->getRelativePath().'/'.basename($js));
}
} | [
"public",
"function",
"loadRequirements",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getStylesheets",
"(",
")",
"as",
"$",
"css",
")",
"{",
"Requirements",
"::",
"css",
"(",
"$",
"this",
"->",
"getRelativePath",
"(",
")",
".",
"'/'",
".",
"basename",
"(",
"$",
"css",
")",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"getJavascripts",
"(",
")",
"as",
"$",
"js",
")",
"{",
"Requirements",
"::",
"javascript",
"(",
"$",
"this",
"->",
"getRelativePath",
"(",
")",
".",
"'/'",
".",
"basename",
"(",
"$",
"js",
")",
")",
";",
"}",
"}"
] | Loads all of the JS and CSS | [
"Loads",
"all",
"of",
"the",
"JS",
"and",
"CSS"
] | 4395dcef5f4efd5a2c67e0bba3ab5cc583e3fdd4 | https://github.com/unclecheese/silverstripe-green/blob/4395dcef5f4efd5a2c67e0bba3ab5cc583e3fdd4/code/DesignModule.php#L192-L200 |
4,339 | indigophp-archive/codeception-fuel-module | fuel/fuel/packages/auth/classes/auth/driver.php | Auth_Driver.instance | public static function instance($instance = null)
{
if ($instance === true)
{
return static::$_instances;
}
elseif ($instance !== null)
{
if ( ! array_key_exists($instance, static::$_instances))
{
return false;
}
return static::$_instances[$instance];
}
return static::$_instance;
} | php | public static function instance($instance = null)
{
if ($instance === true)
{
return static::$_instances;
}
elseif ($instance !== null)
{
if ( ! array_key_exists($instance, static::$_instances))
{
return false;
}
return static::$_instances[$instance];
}
return static::$_instance;
} | [
"public",
"static",
"function",
"instance",
"(",
"$",
"instance",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"instance",
"===",
"true",
")",
"{",
"return",
"static",
"::",
"$",
"_instances",
";",
"}",
"elseif",
"(",
"$",
"instance",
"!==",
"null",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"instance",
",",
"static",
"::",
"$",
"_instances",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"static",
"::",
"$",
"_instances",
"[",
"$",
"instance",
"]",
";",
"}",
"return",
"static",
"::",
"$",
"_instance",
";",
"}"
] | Return a specific driver, or the default instance
@param string driver id
@return Auth_Driver | [
"Return",
"a",
"specific",
"driver",
"or",
"the",
"default",
"instance"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/auth/classes/auth/driver.php#L44-L61 |
4,340 | CatLabInteractive/laravel-gatekeeper | src/CatLab/Gatekeeper/Laravel/Models/Gate.php | Gate.check | public function check($ability, $arguments = [])
{
if (!is_array($arguments)) {
$arguments = [ $arguments ];
}
array_unshift($arguments, $ability);
return call_user_func_array([ $this->gatekeeper, 'check'], $arguments);
} | php | public function check($ability, $arguments = [])
{
if (!is_array($arguments)) {
$arguments = [ $arguments ];
}
array_unshift($arguments, $ability);
return call_user_func_array([ $this->gatekeeper, 'check'], $arguments);
} | [
"public",
"function",
"check",
"(",
"$",
"ability",
",",
"$",
"arguments",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"arguments",
")",
")",
"{",
"$",
"arguments",
"=",
"[",
"$",
"arguments",
"]",
";",
"}",
"array_unshift",
"(",
"$",
"arguments",
",",
"$",
"ability",
")",
";",
"return",
"call_user_func_array",
"(",
"[",
"$",
"this",
"->",
"gatekeeper",
",",
"'check'",
"]",
",",
"$",
"arguments",
")",
";",
"}"
] | Determine if the given ability should be granted.
@param string $ability
@param array|mixed $arguments
@return bool | [
"Determine",
"if",
"the",
"given",
"ability",
"should",
"be",
"granted",
"."
] | 104e4fcfe8b8a7998ddda6efc4749b2a99182816 | https://github.com/CatLabInteractive/laravel-gatekeeper/blob/104e4fcfe8b8a7998ddda6efc4749b2a99182816/src/CatLab/Gatekeeper/Laravel/Models/Gate.php#L128-L136 |
4,341 | mainio/c5pkg_controller_extensions | src/Mainio/C5/ControllerExtensions/Controller/Extension/FlashMessagesExtension.php | FlashMessagesExtension.setFlash | protected function setFlash($key, $value)
{
$flashbag = Session::getFlashBag();
$flashbag->set($key, $value);
} | php | protected function setFlash($key, $value)
{
$flashbag = Session::getFlashBag();
$flashbag->set($key, $value);
} | [
"protected",
"function",
"setFlash",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"flashbag",
"=",
"Session",
"::",
"getFlashBag",
"(",
")",
";",
"$",
"flashbag",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}"
] | Sets the flash variable to the session flashbag.
@param $key string
@param $value mixed | [
"Sets",
"the",
"flash",
"variable",
"to",
"the",
"session",
"flashbag",
"."
] | b3775bb6a79dcc91ce8b71be4bf5c9dd5fa66446 | https://github.com/mainio/c5pkg_controller_extensions/blob/b3775bb6a79dcc91ce8b71be4bf5c9dd5fa66446/src/Mainio/C5/ControllerExtensions/Controller/Extension/FlashMessagesExtension.php#L18-L22 |
4,342 | mainio/c5pkg_controller_extensions | src/Mainio/C5/ControllerExtensions/Controller/Extension/FlashMessagesExtension.php | FlashMessagesExtension.assignFlash | protected function assignFlash($key, $viewKey)
{
if (count($msg = $this->getFlash($key)) > 0) {
$this->set($viewKey, implode(", ", $msg));
}
} | php | protected function assignFlash($key, $viewKey)
{
if (count($msg = $this->getFlash($key)) > 0) {
$this->set($viewKey, implode(", ", $msg));
}
} | [
"protected",
"function",
"assignFlash",
"(",
"$",
"key",
",",
"$",
"viewKey",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"msg",
"=",
"$",
"this",
"->",
"getFlash",
"(",
"$",
"key",
")",
")",
">",
"0",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"$",
"viewKey",
",",
"implode",
"(",
"\", \"",
",",
"$",
"msg",
")",
")",
";",
"}",
"}"
] | Sets the flash message from the flashbag to a variable available in the
view.
@param $key string
@param $viewKey string | [
"Sets",
"the",
"flash",
"message",
"from",
"the",
"flashbag",
"to",
"a",
"variable",
"available",
"in",
"the",
"view",
"."
] | b3775bb6a79dcc91ce8b71be4bf5c9dd5fa66446 | https://github.com/mainio/c5pkg_controller_extensions/blob/b3775bb6a79dcc91ce8b71be4bf5c9dd5fa66446/src/Mainio/C5/ControllerExtensions/Controller/Extension/FlashMessagesExtension.php#L44-L49 |
4,343 | loopsframework/base | src/Loops/Page.php | Page.__getLoopsId | protected function __getLoopsId($refkey = NULL) {
$classname = get_class($this);
if($refkey) {
$reflection = new ReflectionClass($classname);
if($reflection->hasProperty($refkey)) {
$classname = $reflection->getProperty($refkey)->getDeclaringClass()->getName();
}
}
if($page_parameter = $this->parameter) {
$parts = $newparts = explode("\\", $classname);
while($parameter = array_shift($page_parameter)) {
$pos = array_search("_", $parts);
if($pos == FALSE) {
break;
}
$parts[$pos] = "";
$newparts[$pos] = $parameter;
}
$loopsid = implode("-", $newparts);
}
else {
$loopsid = str_replace("\\", "-", $classname);
}
return $loopsid;
} | php | protected function __getLoopsId($refkey = NULL) {
$classname = get_class($this);
if($refkey) {
$reflection = new ReflectionClass($classname);
if($reflection->hasProperty($refkey)) {
$classname = $reflection->getProperty($refkey)->getDeclaringClass()->getName();
}
}
if($page_parameter = $this->parameter) {
$parts = $newparts = explode("\\", $classname);
while($parameter = array_shift($page_parameter)) {
$pos = array_search("_", $parts);
if($pos == FALSE) {
break;
}
$parts[$pos] = "";
$newparts[$pos] = $parameter;
}
$loopsid = implode("-", $newparts);
}
else {
$loopsid = str_replace("\\", "-", $classname);
}
return $loopsid;
} | [
"protected",
"function",
"__getLoopsId",
"(",
"$",
"refkey",
"=",
"NULL",
")",
"{",
"$",
"classname",
"=",
"get_class",
"(",
"$",
"this",
")",
";",
"if",
"(",
"$",
"refkey",
")",
"{",
"$",
"reflection",
"=",
"new",
"ReflectionClass",
"(",
"$",
"classname",
")",
";",
"if",
"(",
"$",
"reflection",
"->",
"hasProperty",
"(",
"$",
"refkey",
")",
")",
"{",
"$",
"classname",
"=",
"$",
"reflection",
"->",
"getProperty",
"(",
"$",
"refkey",
")",
"->",
"getDeclaringClass",
"(",
")",
"->",
"getName",
"(",
")",
";",
"}",
"}",
"if",
"(",
"$",
"page_parameter",
"=",
"$",
"this",
"->",
"parameter",
")",
"{",
"$",
"parts",
"=",
"$",
"newparts",
"=",
"explode",
"(",
"\"\\\\\"",
",",
"$",
"classname",
")",
";",
"while",
"(",
"$",
"parameter",
"=",
"array_shift",
"(",
"$",
"page_parameter",
")",
")",
"{",
"$",
"pos",
"=",
"array_search",
"(",
"\"_\"",
",",
"$",
"parts",
")",
";",
"if",
"(",
"$",
"pos",
"==",
"FALSE",
")",
"{",
"break",
";",
"}",
"$",
"parts",
"[",
"$",
"pos",
"]",
"=",
"\"\"",
";",
"$",
"newparts",
"[",
"$",
"pos",
"]",
"=",
"$",
"parameter",
";",
"}",
"$",
"loopsid",
"=",
"implode",
"(",
"\"-\"",
",",
"$",
"newparts",
")",
";",
"}",
"else",
"{",
"$",
"loopsid",
"=",
"str_replace",
"(",
"\"\\\\\"",
",",
"\"-\"",
",",
"$",
"classname",
")",
";",
"}",
"return",
"$",
"loopsid",
";",
"}"
] | Take page element inheritance into account when generating the loopsid.
Normally the Loops id of a page element is generated by replacing all "\" (backslash) with "-" (dash)
of the pages classname.
Namespace parts that are underscores, as well if the classname is an underscore will be replaced with
the parameters that were used to create the page.
If the argument refkey is set, a part of the Loops id of a child element is requested. (See documentation
of "Loops\Element")
The part of the Loops id is generated and based on which property the child elemement is stored. The
declaring classname is used, this may be the name of a parent class.
Example:
In this example, the Loops id of property $form will not change, regardless which of the three classes are instantiated.
<code>
namespace Pages;
use Loops\Page;
use Loops\Annotations\Element\Form;
class Testpage extends Page {
/**
* \@Form
{@*}
protected $form; //Loops id of this element will (always) be "Pages-Testpage-form"
}
class Subtestpage extends Testpage {
/**
* \@Form
{@*}
protected $other_form; //Loops id of this element will be "Pages-Subtestpage-other_form"
}
class _ extends Testpage {
/**
* \@Form
{@*}
protected $other_form; //Loops id of this element will be "Pages-*-other_form" where * is replaced by the first parameter of the argument $parameter in the constructor
}
</code>
@param | [
"Take",
"page",
"element",
"inheritance",
"into",
"account",
"when",
"generating",
"the",
"loopsid",
"."
] | 5a15172ed4e543d7d5ecd8bd65e31f26bab3d192 | https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Page.php#L116-L147 |
4,344 | eriknyk/smarty | libs/sysplugins/smarty_internal_template.php | Smarty_Internal_Template.writeCachedContent | public function writeCachedContent($content)
{
if ($this->source->recompiled || !($this->caching == Smarty::CACHING_LIFETIME_CURRENT || $this->caching == Smarty::CACHING_LIFETIME_SAVED)) {
// don't write cache file
return false;
}
$this->properties['cache_lifetime'] = $this->cache_lifetime;
$this->properties['unifunc'] = 'content_' . str_replace('.', '_', uniqid('', true));
$content = $this->createTemplateCodeFrame($content, true);
$_smarty_tpl = $this;
eval("?>" . $content);
$this->cached->valid = true;
$this->cached->processed = true;
return $this->cached->write($this, $content);
} | php | public function writeCachedContent($content)
{
if ($this->source->recompiled || !($this->caching == Smarty::CACHING_LIFETIME_CURRENT || $this->caching == Smarty::CACHING_LIFETIME_SAVED)) {
// don't write cache file
return false;
}
$this->properties['cache_lifetime'] = $this->cache_lifetime;
$this->properties['unifunc'] = 'content_' . str_replace('.', '_', uniqid('', true));
$content = $this->createTemplateCodeFrame($content, true);
$_smarty_tpl = $this;
eval("?>" . $content);
$this->cached->valid = true;
$this->cached->processed = true;
return $this->cached->write($this, $content);
} | [
"public",
"function",
"writeCachedContent",
"(",
"$",
"content",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"source",
"->",
"recompiled",
"||",
"!",
"(",
"$",
"this",
"->",
"caching",
"==",
"Smarty",
"::",
"CACHING_LIFETIME_CURRENT",
"||",
"$",
"this",
"->",
"caching",
"==",
"Smarty",
"::",
"CACHING_LIFETIME_SAVED",
")",
")",
"{",
"// don't write cache file",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"properties",
"[",
"'cache_lifetime'",
"]",
"=",
"$",
"this",
"->",
"cache_lifetime",
";",
"$",
"this",
"->",
"properties",
"[",
"'unifunc'",
"]",
"=",
"'content_'",
".",
"str_replace",
"(",
"'.'",
",",
"'_'",
",",
"uniqid",
"(",
"''",
",",
"true",
")",
")",
";",
"$",
"content",
"=",
"$",
"this",
"->",
"createTemplateCodeFrame",
"(",
"$",
"content",
",",
"true",
")",
";",
"$",
"_smarty_tpl",
"=",
"$",
"this",
";",
"eval",
"(",
"\"?>\"",
".",
"$",
"content",
")",
";",
"$",
"this",
"->",
"cached",
"->",
"valid",
"=",
"true",
";",
"$",
"this",
"->",
"cached",
"->",
"processed",
"=",
"true",
";",
"return",
"$",
"this",
"->",
"cached",
"->",
"write",
"(",
"$",
"this",
",",
"$",
"content",
")",
";",
"}"
] | Writes the cached template output
@return bool | [
"Writes",
"the",
"cached",
"template",
"output"
] | deee7829e0889ce7ad971cc3e394b41a86a99488 | https://github.com/eriknyk/smarty/blob/deee7829e0889ce7ad971cc3e394b41a86a99488/libs/sysplugins/smarty_internal_template.php#L217-L231 |
4,345 | prooph/link-sql-connector | src/Service/DbalConnectionCollection.php | DbalConnectionCollection.toArray | public function toArray()
{
$connections = array();
/** @var $connection DbalConnection */
foreach ($this as $key => $connection)
{
$connections[$key] = $connection->config();
}
return $connections;
} | php | public function toArray()
{
$connections = array();
/** @var $connection DbalConnection */
foreach ($this as $key => $connection)
{
$connections[$key] = $connection->config();
}
return $connections;
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"$",
"connections",
"=",
"array",
"(",
")",
";",
"/** @var $connection DbalConnection */",
"foreach",
"(",
"$",
"this",
"as",
"$",
"key",
"=>",
"$",
"connection",
")",
"{",
"$",
"connections",
"[",
"$",
"key",
"]",
"=",
"$",
"connection",
"->",
"config",
"(",
")",
";",
"}",
"return",
"$",
"connections",
";",
"}"
] | Only returns connection configs indexed by dbname
@return array | [
"Only",
"returns",
"connection",
"configs",
"indexed",
"by",
"dbname"
] | 8846d6abf18c2df809e150794f12efdfbe467933 | https://github.com/prooph/link-sql-connector/blob/8846d6abf18c2df809e150794f12efdfbe467933/src/Service/DbalConnectionCollection.php#L66-L77 |
4,346 | bartfeenstra/dependency-retriever | src/Factory/SimpleFactory.php | SimpleFactory.addDependencyRetriever | public function addDependencyRetriever(Retriever $dependencyRetriever)
{
if (!array_key_exists($dependencyRetriever->getName(), $this->dependencyRetrievers)) {
$this->dependencyRetrievers[$dependencyRetriever->getName()] = $dependencyRetriever;
}
} | php | public function addDependencyRetriever(Retriever $dependencyRetriever)
{
if (!array_key_exists($dependencyRetriever->getName(), $this->dependencyRetrievers)) {
$this->dependencyRetrievers[$dependencyRetriever->getName()] = $dependencyRetriever;
}
} | [
"public",
"function",
"addDependencyRetriever",
"(",
"Retriever",
"$",
"dependencyRetriever",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"dependencyRetriever",
"->",
"getName",
"(",
")",
",",
"$",
"this",
"->",
"dependencyRetrievers",
")",
")",
"{",
"$",
"this",
"->",
"dependencyRetrievers",
"[",
"$",
"dependencyRetriever",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"dependencyRetriever",
";",
"}",
"}"
] | Adds another dependency retriever.
The newly added retriever will receive a lower priority than any
existing retrievers. If a retriever with the same name already exists,
it is kept.
@param \BartFeenstra\DependencyRetriever\Retriever\Retriever $dependencyRetriever | [
"Adds",
"another",
"dependency",
"retriever",
"."
] | 385b242535dcf19cd6152b45e5c9035d8e7ac5b3 | https://github.com/bartfeenstra/dependency-retriever/blob/385b242535dcf19cd6152b45e5c9035d8e7ac5b3/src/Factory/SimpleFactory.php#L56-L61 |
4,347 | Sowapps/orpheus-entitydescriptor | src/EntityDescriptor/FieldDescriptor.php | FieldDescriptor.arg | public function arg($key) {
return isset($this->args->$key) ? $this->args->$key : null;
} | php | public function arg($key) {
return isset($this->args->$key) ? $this->args->$key : null;
} | [
"public",
"function",
"arg",
"(",
"$",
"key",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"args",
"->",
"$",
"key",
")",
"?",
"$",
"this",
"->",
"args",
"->",
"$",
"key",
":",
"null",
";",
"}"
] | Get arg value for this field
@param $key string The argument key
@return string|integer|NULL The argument value | [
"Get",
"arg",
"value",
"for",
"this",
"field"
] | b9cc04c42e7955b11f37a70ee7cd2a518f5983b2 | https://github.com/Sowapps/orpheus-entitydescriptor/blob/b9cc04c42e7955b11f37a70ee7cd2a518f5983b2/src/EntityDescriptor/FieldDescriptor.php#L84-L86 |
4,348 | Sowapps/orpheus-entitydescriptor | src/EntityDescriptor/FieldDescriptor.php | FieldDescriptor.parseType | public static function parseType($fieldName, $desc) {
if( is_array($desc) ) {
$typeDesc = $desc['type'];
} else {
$typeDesc = $desc;
$desc = array();
}
$parse = EntityDescriptor::parseType($fieldName, $typeDesc);
/* Field : String name, TypeDescriptor type, Array args, default, writable, nullable */
$field = new static($fieldName, $parse->type);
$TYPE = $field->getType();
$field->args = $TYPE->parseArgs($parse->args);
$field->default = $parse->default;
// Type's default
$field->writable = $TYPE->isWritable();
$field->nullable = $TYPE->isNullable();
// Default if no type's default
if( !isset($field->writable) ) {
$field->writable = true;
}
if( !isset($field->nullable) ) {
$field->nullable = false;
}
// Field flags
if( isset($desc['writable']) ) {
$field->writable = !empty($desc['writable']);
} else if( $field->writable ) {
$field->writable = !in_array('readonly', $parse->flags);
} else {
$field->writable = in_array('writable', $parse->flags);
}
if( isset($desc['nullable']) ) {
$field->nullable = !empty($desc['nullable']);
} else if( $field->nullable ) {
$field->nullable = !in_array('notnull', $parse->flags);
} else {
$field->nullable = in_array('nullable', $parse->flags);
}
return $field;
} | php | public static function parseType($fieldName, $desc) {
if( is_array($desc) ) {
$typeDesc = $desc['type'];
} else {
$typeDesc = $desc;
$desc = array();
}
$parse = EntityDescriptor::parseType($fieldName, $typeDesc);
/* Field : String name, TypeDescriptor type, Array args, default, writable, nullable */
$field = new static($fieldName, $parse->type);
$TYPE = $field->getType();
$field->args = $TYPE->parseArgs($parse->args);
$field->default = $parse->default;
// Type's default
$field->writable = $TYPE->isWritable();
$field->nullable = $TYPE->isNullable();
// Default if no type's default
if( !isset($field->writable) ) {
$field->writable = true;
}
if( !isset($field->nullable) ) {
$field->nullable = false;
}
// Field flags
if( isset($desc['writable']) ) {
$field->writable = !empty($desc['writable']);
} else if( $field->writable ) {
$field->writable = !in_array('readonly', $parse->flags);
} else {
$field->writable = in_array('writable', $parse->flags);
}
if( isset($desc['nullable']) ) {
$field->nullable = !empty($desc['nullable']);
} else if( $field->nullable ) {
$field->nullable = !in_array('notnull', $parse->flags);
} else {
$field->nullable = in_array('nullable', $parse->flags);
}
return $field;
} | [
"public",
"static",
"function",
"parseType",
"(",
"$",
"fieldName",
",",
"$",
"desc",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"desc",
")",
")",
"{",
"$",
"typeDesc",
"=",
"$",
"desc",
"[",
"'type'",
"]",
";",
"}",
"else",
"{",
"$",
"typeDesc",
"=",
"$",
"desc",
";",
"$",
"desc",
"=",
"array",
"(",
")",
";",
"}",
"$",
"parse",
"=",
"EntityDescriptor",
"::",
"parseType",
"(",
"$",
"fieldName",
",",
"$",
"typeDesc",
")",
";",
"/* Field : String name, TypeDescriptor type, Array args, default, writable, nullable */",
"$",
"field",
"=",
"new",
"static",
"(",
"$",
"fieldName",
",",
"$",
"parse",
"->",
"type",
")",
";",
"$",
"TYPE",
"=",
"$",
"field",
"->",
"getType",
"(",
")",
";",
"$",
"field",
"->",
"args",
"=",
"$",
"TYPE",
"->",
"parseArgs",
"(",
"$",
"parse",
"->",
"args",
")",
";",
"$",
"field",
"->",
"default",
"=",
"$",
"parse",
"->",
"default",
";",
"// Type's default",
"$",
"field",
"->",
"writable",
"=",
"$",
"TYPE",
"->",
"isWritable",
"(",
")",
";",
"$",
"field",
"->",
"nullable",
"=",
"$",
"TYPE",
"->",
"isNullable",
"(",
")",
";",
"// Default if no type's default",
"if",
"(",
"!",
"isset",
"(",
"$",
"field",
"->",
"writable",
")",
")",
"{",
"$",
"field",
"->",
"writable",
"=",
"true",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"field",
"->",
"nullable",
")",
")",
"{",
"$",
"field",
"->",
"nullable",
"=",
"false",
";",
"}",
"// Field flags",
"if",
"(",
"isset",
"(",
"$",
"desc",
"[",
"'writable'",
"]",
")",
")",
"{",
"$",
"field",
"->",
"writable",
"=",
"!",
"empty",
"(",
"$",
"desc",
"[",
"'writable'",
"]",
")",
";",
"}",
"else",
"if",
"(",
"$",
"field",
"->",
"writable",
")",
"{",
"$",
"field",
"->",
"writable",
"=",
"!",
"in_array",
"(",
"'readonly'",
",",
"$",
"parse",
"->",
"flags",
")",
";",
"}",
"else",
"{",
"$",
"field",
"->",
"writable",
"=",
"in_array",
"(",
"'writable'",
",",
"$",
"parse",
"->",
"flags",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"desc",
"[",
"'nullable'",
"]",
")",
")",
"{",
"$",
"field",
"->",
"nullable",
"=",
"!",
"empty",
"(",
"$",
"desc",
"[",
"'nullable'",
"]",
")",
";",
"}",
"else",
"if",
"(",
"$",
"field",
"->",
"nullable",
")",
"{",
"$",
"field",
"->",
"nullable",
"=",
"!",
"in_array",
"(",
"'notnull'",
",",
"$",
"parse",
"->",
"flags",
")",
";",
"}",
"else",
"{",
"$",
"field",
"->",
"nullable",
"=",
"in_array",
"(",
"'nullable'",
",",
"$",
"parse",
"->",
"flags",
")",
";",
"}",
"return",
"$",
"field",
";",
"}"
] | Parse field type configuration from file string
@param string $fieldName
@param string|string[] $desc
@return FieldDescriptor The parsed field descriptor | [
"Parse",
"field",
"type",
"configuration",
"from",
"file",
"string"
] | b9cc04c42e7955b11f37a70ee7cd2a518f5983b2 | https://github.com/Sowapps/orpheus-entitydescriptor/blob/b9cc04c42e7955b11f37a70ee7cd2a518f5983b2/src/EntityDescriptor/FieldDescriptor.php#L129-L172 |
4,349 | Sowapps/orpheus-entitydescriptor | src/EntityDescriptor/FieldDescriptor.php | FieldDescriptor.buildIDField | public static function buildIDField($name) {
$field = new static($name, 'ref');
$TYPE = $field->getType();
$field->args = $TYPE->parseArgs(array());
$field->default = null;
$field->writable = false;
$field->nullable = false;
return $field;
} | php | public static function buildIDField($name) {
$field = new static($name, 'ref');
$TYPE = $field->getType();
$field->args = $TYPE->parseArgs(array());
$field->default = null;
$field->writable = false;
$field->nullable = false;
return $field;
} | [
"public",
"static",
"function",
"buildIDField",
"(",
"$",
"name",
")",
"{",
"$",
"field",
"=",
"new",
"static",
"(",
"$",
"name",
",",
"'ref'",
")",
";",
"$",
"TYPE",
"=",
"$",
"field",
"->",
"getType",
"(",
")",
";",
"$",
"field",
"->",
"args",
"=",
"$",
"TYPE",
"->",
"parseArgs",
"(",
"array",
"(",
")",
")",
";",
"$",
"field",
"->",
"default",
"=",
"null",
";",
"$",
"field",
"->",
"writable",
"=",
"false",
";",
"$",
"field",
"->",
"nullable",
"=",
"false",
";",
"return",
"$",
"field",
";",
"}"
] | Build ID field for an entity
@param string $name
@return \Orpheus\EntityDescriptor\FieldDescriptor | [
"Build",
"ID",
"field",
"for",
"an",
"entity"
] | b9cc04c42e7955b11f37a70ee7cd2a518f5983b2 | https://github.com/Sowapps/orpheus-entitydescriptor/blob/b9cc04c42e7955b11f37a70ee7cd2a518f5983b2/src/EntityDescriptor/FieldDescriptor.php#L180-L188 |
4,350 | fabsgc/framework | Core/Template/Template.php | Template.extend | public static function extend($method) {
if (is_array($method)) {
if (count($method) == 2 && method_exists($method[0], $method[1])) {
array_push(self::$_extends, ['class' => $method[0], 'method' => $method[1]]);
}
else {
throw new MissingTemplateException('You c\'ant extend the template engine with the method : "' . $method[0] . '"');
}
}
else {
$trace = debug_backtrace();
if (isset($trace[1])) {
array_push(self::$_extends, ['class' => '\\' . $trace[1]['class'], 'method' => $method]);
}
else {
throw new MissingTemplateException('Can\'t reach the method "' . $method . '"');
}
}
} | php | public static function extend($method) {
if (is_array($method)) {
if (count($method) == 2 && method_exists($method[0], $method[1])) {
array_push(self::$_extends, ['class' => $method[0], 'method' => $method[1]]);
}
else {
throw new MissingTemplateException('You c\'ant extend the template engine with the method : "' . $method[0] . '"');
}
}
else {
$trace = debug_backtrace();
if (isset($trace[1])) {
array_push(self::$_extends, ['class' => '\\' . $trace[1]['class'], 'method' => $method]);
}
else {
throw new MissingTemplateException('Can\'t reach the method "' . $method . '"');
}
}
} | [
"public",
"static",
"function",
"extend",
"(",
"$",
"method",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"method",
")",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"method",
")",
"==",
"2",
"&&",
"method_exists",
"(",
"$",
"method",
"[",
"0",
"]",
",",
"$",
"method",
"[",
"1",
"]",
")",
")",
"{",
"array_push",
"(",
"self",
"::",
"$",
"_extends",
",",
"[",
"'class'",
"=>",
"$",
"method",
"[",
"0",
"]",
",",
"'method'",
"=>",
"$",
"method",
"[",
"1",
"]",
"]",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"MissingTemplateException",
"(",
"'You c\\'ant extend the template engine with the method : \"'",
".",
"$",
"method",
"[",
"0",
"]",
".",
"'\"'",
")",
";",
"}",
"}",
"else",
"{",
"$",
"trace",
"=",
"debug_backtrace",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"trace",
"[",
"1",
"]",
")",
")",
"{",
"array_push",
"(",
"self",
"::",
"$",
"_extends",
",",
"[",
"'class'",
"=>",
"'\\\\'",
".",
"$",
"trace",
"[",
"1",
"]",
"[",
"'class'",
"]",
",",
"'method'",
"=>",
"$",
"method",
"]",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"MissingTemplateException",
"(",
"'Can\\'t reach the method \"'",
".",
"$",
"method",
".",
"'\"'",
")",
";",
"}",
"}",
"}"
] | permit to extend the template engine with custom functions
@access public
@param $method mixed array,string
@throws MissingTemplateException
@return void
@since 3.0
@package Gcs\Framework\Core\Template | [
"permit",
"to",
"extend",
"the",
"template",
"engine",
"with",
"custom",
"functions"
] | 45e58182aba6a3c6381970a1fd3c17662cff2168 | https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Template/Template.php#L218-L237 |
4,351 | fabsgc/framework | Core/Template/Template.php | Template._compile | protected function _compile($content, $type = self::TPL_COMPILE_ALL) {
switch ($type) {
case self::TPL_COMPILE_ALL:
return $this->_parser->parse($content);
break;
case self::TPL_COMPILE_INCLUDE:
return $this->_parser->parseNoTemplate($content);
break;
case self::TPL_COMPILE_LANG:
return $this->_parser->parseLang($content);
break;
}
return '';
} | php | protected function _compile($content, $type = self::TPL_COMPILE_ALL) {
switch ($type) {
case self::TPL_COMPILE_ALL:
return $this->_parser->parse($content);
break;
case self::TPL_COMPILE_INCLUDE:
return $this->_parser->parseNoTemplate($content);
break;
case self::TPL_COMPILE_LANG:
return $this->_parser->parseLang($content);
break;
}
return '';
} | [
"protected",
"function",
"_compile",
"(",
"$",
"content",
",",
"$",
"type",
"=",
"self",
"::",
"TPL_COMPILE_ALL",
")",
"{",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"self",
"::",
"TPL_COMPILE_ALL",
":",
"return",
"$",
"this",
"->",
"_parser",
"->",
"parse",
"(",
"$",
"content",
")",
";",
"break",
";",
"case",
"self",
"::",
"TPL_COMPILE_INCLUDE",
":",
"return",
"$",
"this",
"->",
"_parser",
"->",
"parseNoTemplate",
"(",
"$",
"content",
")",
";",
"break",
";",
"case",
"self",
"::",
"TPL_COMPILE_LANG",
":",
"return",
"$",
"this",
"->",
"_parser",
"->",
"parseLang",
"(",
"$",
"content",
")",
";",
"break",
";",
"}",
"return",
"''",
";",
"}"
] | compile the template instance
@param $content string
@param $type int
@return mixed
@since 3.0
@package Gcs\Framework\Core\Template | [
"compile",
"the",
"template",
"instance"
] | 45e58182aba6a3c6381970a1fd3c17662cff2168 | https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Template/Template.php#L328-L344 |
4,352 | helionogueir/database | core/routine/Database.class.php | Database.mount | public function mount(Info $info): PDO {
$trouble = false;
$pdo = null;
switch ($info->getDsn()) {
case "mysql":
$pdo = (new MySql())->connect($info);
break;
default :
$trouble = true;
break;
}
if ($trouble) {
Lang::addRoot(Environment::PACKAGE, Environment::PATH);
throw new Exception(Lang::get("database:database:invalid", "helionogueir/database"));
}
return $pdo;
} | php | public function mount(Info $info): PDO {
$trouble = false;
$pdo = null;
switch ($info->getDsn()) {
case "mysql":
$pdo = (new MySql())->connect($info);
break;
default :
$trouble = true;
break;
}
if ($trouble) {
Lang::addRoot(Environment::PACKAGE, Environment::PATH);
throw new Exception(Lang::get("database:database:invalid", "helionogueir/database"));
}
return $pdo;
} | [
"public",
"function",
"mount",
"(",
"Info",
"$",
"info",
")",
":",
"PDO",
"{",
"$",
"trouble",
"=",
"false",
";",
"$",
"pdo",
"=",
"null",
";",
"switch",
"(",
"$",
"info",
"->",
"getDsn",
"(",
")",
")",
"{",
"case",
"\"mysql\"",
":",
"$",
"pdo",
"=",
"(",
"new",
"MySql",
"(",
")",
")",
"->",
"connect",
"(",
"$",
"info",
")",
";",
"break",
";",
"default",
":",
"$",
"trouble",
"=",
"true",
";",
"break",
";",
"}",
"if",
"(",
"$",
"trouble",
")",
"{",
"Lang",
"::",
"addRoot",
"(",
"Environment",
"::",
"PACKAGE",
",",
"Environment",
"::",
"PATH",
")",
";",
"throw",
"new",
"Exception",
"(",
"Lang",
"::",
"get",
"(",
"\"database:database:invalid\"",
",",
"\"helionogueir/database\"",
")",
")",
";",
"}",
"return",
"$",
"pdo",
";",
"}"
] | - Mount database by object
@param helionogueir\database\routine\database\Info $info Database info connection
@return null | [
"-",
"Mount",
"database",
"by",
"object"
] | 685606726cd90cc730c419681383e2cb6c4150f3 | https://github.com/helionogueir/database/blob/685606726cd90cc730c419681383e2cb6c4150f3/core/routine/Database.class.php#L24-L40 |
4,353 | Briareos/mongodb-odm | lib/Doctrine/ODM/MongoDB/SchemaManager.php | SchemaManager.updateIndexes | public function updateIndexes($timeout = null)
{
foreach ($this->metadataFactory->getAllMetadata() as $class) {
if ($class->isMappedSuperclass || $class->isEmbeddedDocument) {
continue;
}
$this->updateDocumentIndexes($class->name, $timeout);
}
} | php | public function updateIndexes($timeout = null)
{
foreach ($this->metadataFactory->getAllMetadata() as $class) {
if ($class->isMappedSuperclass || $class->isEmbeddedDocument) {
continue;
}
$this->updateDocumentIndexes($class->name, $timeout);
}
} | [
"public",
"function",
"updateIndexes",
"(",
"$",
"timeout",
"=",
"null",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"metadataFactory",
"->",
"getAllMetadata",
"(",
")",
"as",
"$",
"class",
")",
"{",
"if",
"(",
"$",
"class",
"->",
"isMappedSuperclass",
"||",
"$",
"class",
"->",
"isEmbeddedDocument",
")",
"{",
"continue",
";",
"}",
"$",
"this",
"->",
"updateDocumentIndexes",
"(",
"$",
"class",
"->",
"name",
",",
"$",
"timeout",
")",
";",
"}",
"}"
] | Ensure indexes exist for all mapped document classes.
Indexes that exist in MongoDB but not the document metadata will be
deleted.
@param integer $timeout Timeout (ms) for acknowledged index creation | [
"Ensure",
"indexes",
"exist",
"for",
"all",
"mapped",
"document",
"classes",
"."
] | 29e28bed9a265efd7d05473b0a909fb7c83f76e0 | https://github.com/Briareos/mongodb-odm/blob/29e28bed9a265efd7d05473b0a909fb7c83f76e0/lib/Doctrine/ODM/MongoDB/SchemaManager.php#L72-L80 |
4,354 | Briareos/mongodb-odm | lib/Doctrine/ODM/MongoDB/SchemaManager.php | SchemaManager.deleteIndexes | public function deleteIndexes()
{
foreach ($this->metadataFactory->getAllMetadata() as $class) {
if ($class->isMappedSuperclass || $class->isEmbeddedDocument) {
continue;
}
$this->deleteDocumentIndexes($class->name);
}
} | php | public function deleteIndexes()
{
foreach ($this->metadataFactory->getAllMetadata() as $class) {
if ($class->isMappedSuperclass || $class->isEmbeddedDocument) {
continue;
}
$this->deleteDocumentIndexes($class->name);
}
} | [
"public",
"function",
"deleteIndexes",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"metadataFactory",
"->",
"getAllMetadata",
"(",
")",
"as",
"$",
"class",
")",
"{",
"if",
"(",
"$",
"class",
"->",
"isMappedSuperclass",
"||",
"$",
"class",
"->",
"isEmbeddedDocument",
")",
"{",
"continue",
";",
"}",
"$",
"this",
"->",
"deleteDocumentIndexes",
"(",
"$",
"class",
"->",
"name",
")",
";",
"}",
"}"
] | Delete indexes for all documents that can be loaded with the
metadata factory. | [
"Delete",
"indexes",
"for",
"all",
"documents",
"that",
"can",
"be",
"loaded",
"with",
"the",
"metadata",
"factory",
"."
] | 29e28bed9a265efd7d05473b0a909fb7c83f76e0 | https://github.com/Briareos/mongodb-odm/blob/29e28bed9a265efd7d05473b0a909fb7c83f76e0/lib/Doctrine/ODM/MongoDB/SchemaManager.php#L270-L278 |
4,355 | Briareos/mongodb-odm | lib/Doctrine/ODM/MongoDB/SchemaManager.php | SchemaManager.dropCollections | public function dropCollections()
{
foreach ($this->metadataFactory->getAllMetadata() as $class) {
if ($class->isMappedSuperclass || $class->isEmbeddedDocument) {
continue;
}
$this->dropDocumentCollection($class->name);
}
} | php | public function dropCollections()
{
foreach ($this->metadataFactory->getAllMetadata() as $class) {
if ($class->isMappedSuperclass || $class->isEmbeddedDocument) {
continue;
}
$this->dropDocumentCollection($class->name);
}
} | [
"public",
"function",
"dropCollections",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"metadataFactory",
"->",
"getAllMetadata",
"(",
")",
"as",
"$",
"class",
")",
"{",
"if",
"(",
"$",
"class",
"->",
"isMappedSuperclass",
"||",
"$",
"class",
"->",
"isEmbeddedDocument",
")",
"{",
"continue",
";",
"}",
"$",
"this",
"->",
"dropDocumentCollection",
"(",
"$",
"class",
"->",
"name",
")",
";",
"}",
"}"
] | Drop all the mapped document collections in the metadata factory. | [
"Drop",
"all",
"the",
"mapped",
"document",
"collections",
"in",
"the",
"metadata",
"factory",
"."
] | 29e28bed9a265efd7d05473b0a909fb7c83f76e0 | https://github.com/Briareos/mongodb-odm/blob/29e28bed9a265efd7d05473b0a909fb7c83f76e0/lib/Doctrine/ODM/MongoDB/SchemaManager.php#L340-L348 |
4,356 | Briareos/mongodb-odm | lib/Doctrine/ODM/MongoDB/SchemaManager.php | SchemaManager.dropDatabases | public function dropDatabases()
{
foreach ($this->metadataFactory->getAllMetadata() as $class) {
if ($class->isMappedSuperclass || $class->isEmbeddedDocument) {
continue;
}
$this->dropDocumentDatabase($class->name);
}
} | php | public function dropDatabases()
{
foreach ($this->metadataFactory->getAllMetadata() as $class) {
if ($class->isMappedSuperclass || $class->isEmbeddedDocument) {
continue;
}
$this->dropDocumentDatabase($class->name);
}
} | [
"public",
"function",
"dropDatabases",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"metadataFactory",
"->",
"getAllMetadata",
"(",
")",
"as",
"$",
"class",
")",
"{",
"if",
"(",
"$",
"class",
"->",
"isMappedSuperclass",
"||",
"$",
"class",
"->",
"isEmbeddedDocument",
")",
"{",
"continue",
";",
"}",
"$",
"this",
"->",
"dropDocumentDatabase",
"(",
"$",
"class",
"->",
"name",
")",
";",
"}",
"}"
] | Drop all the mapped document databases in the metadata factory. | [
"Drop",
"all",
"the",
"mapped",
"document",
"databases",
"in",
"the",
"metadata",
"factory",
"."
] | 29e28bed9a265efd7d05473b0a909fb7c83f76e0 | https://github.com/Briareos/mongodb-odm/blob/29e28bed9a265efd7d05473b0a909fb7c83f76e0/lib/Doctrine/ODM/MongoDB/SchemaManager.php#L370-L378 |
4,357 | Briareos/mongodb-odm | lib/Doctrine/ODM/MongoDB/SchemaManager.php | SchemaManager.createDatabases | public function createDatabases()
{
foreach ($this->metadataFactory->getAllMetadata() as $class) {
if ($class->isMappedSuperclass || $class->isEmbeddedDocument) {
continue;
}
$this->createDocumentDatabase($class->name);
}
} | php | public function createDatabases()
{
foreach ($this->metadataFactory->getAllMetadata() as $class) {
if ($class->isMappedSuperclass || $class->isEmbeddedDocument) {
continue;
}
$this->createDocumentDatabase($class->name);
}
} | [
"public",
"function",
"createDatabases",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"metadataFactory",
"->",
"getAllMetadata",
"(",
")",
"as",
"$",
"class",
")",
"{",
"if",
"(",
"$",
"class",
"->",
"isMappedSuperclass",
"||",
"$",
"class",
"->",
"isEmbeddedDocument",
")",
"{",
"continue",
";",
"}",
"$",
"this",
"->",
"createDocumentDatabase",
"(",
"$",
"class",
"->",
"name",
")",
";",
"}",
"}"
] | Create all the mapped document databases in the metadata factory. | [
"Create",
"all",
"the",
"mapped",
"document",
"databases",
"in",
"the",
"metadata",
"factory",
"."
] | 29e28bed9a265efd7d05473b0a909fb7c83f76e0 | https://github.com/Briareos/mongodb-odm/blob/29e28bed9a265efd7d05473b0a909fb7c83f76e0/lib/Doctrine/ODM/MongoDB/SchemaManager.php#L398-L406 |
4,358 | Briareos/mongodb-odm | lib/Doctrine/ODM/MongoDB/SchemaManager.php | SchemaManager.createDocumentDatabase | public function createDocumentDatabase($documentName)
{
$class = $this->dm->getClassMetadata($documentName);
if ($class->isMappedSuperclass || $class->isEmbeddedDocument) {
throw new \InvalidArgumentException('Cannot delete document indexes for mapped super classes or embedded documents.');
}
$this->dm->getDocumentDatabase($documentName)->execute("function() { return true; }");
} | php | public function createDocumentDatabase($documentName)
{
$class = $this->dm->getClassMetadata($documentName);
if ($class->isMappedSuperclass || $class->isEmbeddedDocument) {
throw new \InvalidArgumentException('Cannot delete document indexes for mapped super classes or embedded documents.');
}
$this->dm->getDocumentDatabase($documentName)->execute("function() { return true; }");
} | [
"public",
"function",
"createDocumentDatabase",
"(",
"$",
"documentName",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"dm",
"->",
"getClassMetadata",
"(",
"$",
"documentName",
")",
";",
"if",
"(",
"$",
"class",
"->",
"isMappedSuperclass",
"||",
"$",
"class",
"->",
"isEmbeddedDocument",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Cannot delete document indexes for mapped super classes or embedded documents.'",
")",
";",
"}",
"$",
"this",
"->",
"dm",
"->",
"getDocumentDatabase",
"(",
"$",
"documentName",
")",
"->",
"execute",
"(",
"\"function() { return true; }\"",
")",
";",
"}"
] | Create the document database for a mapped class.
@param string $documentName
@throws \InvalidArgumentException | [
"Create",
"the",
"document",
"database",
"for",
"a",
"mapped",
"class",
"."
] | 29e28bed9a265efd7d05473b0a909fb7c83f76e0 | https://github.com/Briareos/mongodb-odm/blob/29e28bed9a265efd7d05473b0a909fb7c83f76e0/lib/Doctrine/ODM/MongoDB/SchemaManager.php#L414-L421 |
4,359 | YiMAproject/yima-base | src/yimaBase/Mvc/Listener/RouteListener.php | RouteListener.onRoute | public function onRoute($e)
{
$request = $e->getRequest();
$router = $e->getRouter();
$routeMatch = $router->match($request);
if (!$routeMatch instanceof RouteMatch)
throw new RouteNotFoundException();
$e->setRouteMatch($routeMatch);
return $routeMatch;
} | php | public function onRoute($e)
{
$request = $e->getRequest();
$router = $e->getRouter();
$routeMatch = $router->match($request);
if (!$routeMatch instanceof RouteMatch)
throw new RouteNotFoundException();
$e->setRouteMatch($routeMatch);
return $routeMatch;
} | [
"public",
"function",
"onRoute",
"(",
"$",
"e",
")",
"{",
"$",
"request",
"=",
"$",
"e",
"->",
"getRequest",
"(",
")",
";",
"$",
"router",
"=",
"$",
"e",
"->",
"getRouter",
"(",
")",
";",
"$",
"routeMatch",
"=",
"$",
"router",
"->",
"match",
"(",
"$",
"request",
")",
";",
"if",
"(",
"!",
"$",
"routeMatch",
"instanceof",
"RouteMatch",
")",
"throw",
"new",
"RouteNotFoundException",
"(",
")",
";",
"$",
"e",
"->",
"setRouteMatch",
"(",
"$",
"routeMatch",
")",
";",
"return",
"$",
"routeMatch",
";",
"}"
] | Listen to the "route" event and attempt to route the request
If no matches are returned, triggers "dispatch.error" in order to
create a 404 response.
Seeds the event with the route match on completion.
@param MvcEvent $e
@throws RouteNotFoundException
@return null|RouteMatch | [
"Listen",
"to",
"the",
"route",
"event",
"and",
"attempt",
"to",
"route",
"the",
"request"
] | 1dc91a3b5f0794e586f43808f52ae8d8cfa2633f | https://github.com/YiMAproject/yima-base/blob/1dc91a3b5f0794e586f43808f52ae8d8cfa2633f/src/yimaBase/Mvc/Listener/RouteListener.php#L66-L78 |
4,360 | droid-php/droid-mysql | src/Db/Client.php | Client.execute | public function execute($statement, $params = array())
{
$preparedStmt = null;
$result = false;
try {
$preparedStmt = $this->getConnection()->prepare($statement);
} catch (PDOException $e) {
throw new ClientException(
'Failed to prepare MySQL statement.',
null,
$e
);
}
foreach ($params as $name => $paramInfo) {
if (is_string($paramInfo)) {
$preparedStmt->bindValue($name, $paramInfo, PDO::PARAM_STR);
} elseif (is_array($paramInfo)) {
list($value, $type) = $paramInfo;
$preparedStmt->bindValue($name, $value, $type);
}
}
try {
$result = $preparedStmt->execute();
} catch (PDOException $e) {
throw new ClientException(
'Failed to execute MySQL statement.',
null,
$e
);
}
return $result;
} | php | public function execute($statement, $params = array())
{
$preparedStmt = null;
$result = false;
try {
$preparedStmt = $this->getConnection()->prepare($statement);
} catch (PDOException $e) {
throw new ClientException(
'Failed to prepare MySQL statement.',
null,
$e
);
}
foreach ($params as $name => $paramInfo) {
if (is_string($paramInfo)) {
$preparedStmt->bindValue($name, $paramInfo, PDO::PARAM_STR);
} elseif (is_array($paramInfo)) {
list($value, $type) = $paramInfo;
$preparedStmt->bindValue($name, $value, $type);
}
}
try {
$result = $preparedStmt->execute();
} catch (PDOException $e) {
throw new ClientException(
'Failed to execute MySQL statement.',
null,
$e
);
}
return $result;
} | [
"public",
"function",
"execute",
"(",
"$",
"statement",
",",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"preparedStmt",
"=",
"null",
";",
"$",
"result",
"=",
"false",
";",
"try",
"{",
"$",
"preparedStmt",
"=",
"$",
"this",
"->",
"getConnection",
"(",
")",
"->",
"prepare",
"(",
"$",
"statement",
")",
";",
"}",
"catch",
"(",
"PDOException",
"$",
"e",
")",
"{",
"throw",
"new",
"ClientException",
"(",
"'Failed to prepare MySQL statement.'",
",",
"null",
",",
"$",
"e",
")",
";",
"}",
"foreach",
"(",
"$",
"params",
"as",
"$",
"name",
"=>",
"$",
"paramInfo",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"paramInfo",
")",
")",
"{",
"$",
"preparedStmt",
"->",
"bindValue",
"(",
"$",
"name",
",",
"$",
"paramInfo",
",",
"PDO",
"::",
"PARAM_STR",
")",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"paramInfo",
")",
")",
"{",
"list",
"(",
"$",
"value",
",",
"$",
"type",
")",
"=",
"$",
"paramInfo",
";",
"$",
"preparedStmt",
"->",
"bindValue",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"type",
")",
";",
"}",
"}",
"try",
"{",
"$",
"result",
"=",
"$",
"preparedStmt",
"->",
"execute",
"(",
")",
";",
"}",
"catch",
"(",
"PDOException",
"$",
"e",
")",
"{",
"throw",
"new",
"ClientException",
"(",
"'Failed to execute MySQL statement.'",
",",
"null",
",",
"$",
"e",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Execute a statement, returning boolean true on success.
@param string $statement
@param array $params The keys of the array are the one-indexed parameter
number or the colon-prefixed parameter name. The
values are either a string or an array containing
the value and the data type (i.e. PDO::PARAM_*).
@return boolean
@throws \Droid\Plugin\Mysql\Db\ClientException | [
"Execute",
"a",
"statement",
"returning",
"boolean",
"true",
"on",
"success",
"."
] | d363ec067495073469a25b48b97d460b6fba938a | https://github.com/droid-php/droid-mysql/blob/d363ec067495073469a25b48b97d460b6fba938a/src/Db/Client.php#L66-L101 |
4,361 | droid-php/droid-mysql | src/Db/Client.php | Client.getSingleResult | public function getSingleResult($statement, $params = array())
{
$result = $this->getResults($statement, $params);
if (!sizeof($result)) {
return null;
}
return $result[0];
} | php | public function getSingleResult($statement, $params = array())
{
$result = $this->getResults($statement, $params);
if (!sizeof($result)) {
return null;
}
return $result[0];
} | [
"public",
"function",
"getSingleResult",
"(",
"$",
"statement",
",",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"getResults",
"(",
"$",
"statement",
",",
"$",
"params",
")",
";",
"if",
"(",
"!",
"sizeof",
"(",
"$",
"result",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"result",
"[",
"0",
"]",
";",
"}"
] | Execute a statement, returning one row of results or null.
@param string $statement
@param array $params
@return null|array
@throws \Droid\Plugin\Mysql\Db\ClientException | [
"Execute",
"a",
"statement",
"returning",
"one",
"row",
"of",
"results",
"or",
"null",
"."
] | d363ec067495073469a25b48b97d460b6fba938a | https://github.com/droid-php/droid-mysql/blob/d363ec067495073469a25b48b97d460b6fba938a/src/Db/Client.php#L173-L182 |
4,362 | mailsender/core | src/MailSenders/PHPMailSender.php | PHPMailSender.send | public function send(IMail $mail): void
{
$emailContent = $this->mailService->getContent($mail);
//Server settings
$this->phpMailer->SMTPDebug = 0; // Enable verbose debug output
$this->phpMailer->isSMTP(); // Set mailer to use SMTP
$this->phpMailer->Host = $this->host; // Specify main and backup SMTP servers
$this->phpMailer->SMTPAuth = true; // Enable SMTP authentication
$this->phpMailer->Username = $this->username; // SMTP username
$this->phpMailer->Password = $this->password; // SMTP password
$this->phpMailer->SMTPSecure = $this->smtpSecure; // Enable TLS encryption, `ssl` also accepted
$this->phpMailer->Port = $this->port; // TCP port to connect to
$this->phpMailer->CharSet = $mail->getCharset();
//Recipients
$this->phpMailer->setFrom($mail->getSender()->getEmail(), $mail->getSender()->getName());
// TODO: budeme posilat jeden mail vzdy na jednu mailovou adresu?
$this->phpMailer->addAddress($mail->getRecipient()->getEmail(), $mail->getRecipient()->getName()); // Add a recipient
// TODO: Kopie se nebudou nikdy posilat? Mame jen skryté kopie.
foreach ($mail->getBccRecipients() as $bccRecipient)
{
$this->phpMailer->addBCC($bccRecipient->getEmail());
}
//Attachments
foreach ($mail->getAttachments() as $attachment)
{
$this->phpMailer->addAttachment($attachment->getPath() . '/' . $attachment->getFileName()); // Add attachments
}
// TODO: Budeme chtit prejmenovavat prilohy?
// $this->phpMailer->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
//Content
$this->phpMailer->isHTML();
$this->phpMailer->Subject = $mail->getSubject();
$this->phpMailer->msgHTML($emailContent);
$this->phpMailer->send();
foreach ($mail->getAttachments() as $attachment)
{
if($attachment->isDeleteAfterSend())
{
unlink($attachment->getPath() . '/' . $attachment->getFileName());
}
}
} | php | public function send(IMail $mail): void
{
$emailContent = $this->mailService->getContent($mail);
//Server settings
$this->phpMailer->SMTPDebug = 0; // Enable verbose debug output
$this->phpMailer->isSMTP(); // Set mailer to use SMTP
$this->phpMailer->Host = $this->host; // Specify main and backup SMTP servers
$this->phpMailer->SMTPAuth = true; // Enable SMTP authentication
$this->phpMailer->Username = $this->username; // SMTP username
$this->phpMailer->Password = $this->password; // SMTP password
$this->phpMailer->SMTPSecure = $this->smtpSecure; // Enable TLS encryption, `ssl` also accepted
$this->phpMailer->Port = $this->port; // TCP port to connect to
$this->phpMailer->CharSet = $mail->getCharset();
//Recipients
$this->phpMailer->setFrom($mail->getSender()->getEmail(), $mail->getSender()->getName());
// TODO: budeme posilat jeden mail vzdy na jednu mailovou adresu?
$this->phpMailer->addAddress($mail->getRecipient()->getEmail(), $mail->getRecipient()->getName()); // Add a recipient
// TODO: Kopie se nebudou nikdy posilat? Mame jen skryté kopie.
foreach ($mail->getBccRecipients() as $bccRecipient)
{
$this->phpMailer->addBCC($bccRecipient->getEmail());
}
//Attachments
foreach ($mail->getAttachments() as $attachment)
{
$this->phpMailer->addAttachment($attachment->getPath() . '/' . $attachment->getFileName()); // Add attachments
}
// TODO: Budeme chtit prejmenovavat prilohy?
// $this->phpMailer->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
//Content
$this->phpMailer->isHTML();
$this->phpMailer->Subject = $mail->getSubject();
$this->phpMailer->msgHTML($emailContent);
$this->phpMailer->send();
foreach ($mail->getAttachments() as $attachment)
{
if($attachment->isDeleteAfterSend())
{
unlink($attachment->getPath() . '/' . $attachment->getFileName());
}
}
} | [
"public",
"function",
"send",
"(",
"IMail",
"$",
"mail",
")",
":",
"void",
"{",
"$",
"emailContent",
"=",
"$",
"this",
"->",
"mailService",
"->",
"getContent",
"(",
"$",
"mail",
")",
";",
"//Server settings",
"$",
"this",
"->",
"phpMailer",
"->",
"SMTPDebug",
"=",
"0",
";",
"// Enable verbose debug output",
"$",
"this",
"->",
"phpMailer",
"->",
"isSMTP",
"(",
")",
";",
"// Set mailer to use SMTP",
"$",
"this",
"->",
"phpMailer",
"->",
"Host",
"=",
"$",
"this",
"->",
"host",
";",
"// Specify main and backup SMTP servers",
"$",
"this",
"->",
"phpMailer",
"->",
"SMTPAuth",
"=",
"true",
";",
"// Enable SMTP authentication",
"$",
"this",
"->",
"phpMailer",
"->",
"Username",
"=",
"$",
"this",
"->",
"username",
";",
"// SMTP username",
"$",
"this",
"->",
"phpMailer",
"->",
"Password",
"=",
"$",
"this",
"->",
"password",
";",
"// SMTP password",
"$",
"this",
"->",
"phpMailer",
"->",
"SMTPSecure",
"=",
"$",
"this",
"->",
"smtpSecure",
";",
"// Enable TLS encryption, `ssl` also accepted",
"$",
"this",
"->",
"phpMailer",
"->",
"Port",
"=",
"$",
"this",
"->",
"port",
";",
"// TCP port to connect to",
"$",
"this",
"->",
"phpMailer",
"->",
"CharSet",
"=",
"$",
"mail",
"->",
"getCharset",
"(",
")",
";",
"//Recipients",
"$",
"this",
"->",
"phpMailer",
"->",
"setFrom",
"(",
"$",
"mail",
"->",
"getSender",
"(",
")",
"->",
"getEmail",
"(",
")",
",",
"$",
"mail",
"->",
"getSender",
"(",
")",
"->",
"getName",
"(",
")",
")",
";",
"// TODO: budeme posilat jeden mail vzdy na jednu mailovou adresu?",
"$",
"this",
"->",
"phpMailer",
"->",
"addAddress",
"(",
"$",
"mail",
"->",
"getRecipient",
"(",
")",
"->",
"getEmail",
"(",
")",
",",
"$",
"mail",
"->",
"getRecipient",
"(",
")",
"->",
"getName",
"(",
")",
")",
";",
"// Add a recipient",
"// TODO: Kopie se nebudou nikdy posilat? Mame jen skryté kopie.",
"foreach",
"(",
"$",
"mail",
"->",
"getBccRecipients",
"(",
")",
"as",
"$",
"bccRecipient",
")",
"{",
"$",
"this",
"->",
"phpMailer",
"->",
"addBCC",
"(",
"$",
"bccRecipient",
"->",
"getEmail",
"(",
")",
")",
";",
"}",
"//Attachments",
"foreach",
"(",
"$",
"mail",
"->",
"getAttachments",
"(",
")",
"as",
"$",
"attachment",
")",
"{",
"$",
"this",
"->",
"phpMailer",
"->",
"addAttachment",
"(",
"$",
"attachment",
"->",
"getPath",
"(",
")",
".",
"'/'",
".",
"$",
"attachment",
"->",
"getFileName",
"(",
")",
")",
";",
"// Add attachments",
"}",
"// TODO: Budeme chtit prejmenovavat prilohy?",
"//\t\t$this->phpMailer->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name",
"//Content",
"$",
"this",
"->",
"phpMailer",
"->",
"isHTML",
"(",
")",
";",
"$",
"this",
"->",
"phpMailer",
"->",
"Subject",
"=",
"$",
"mail",
"->",
"getSubject",
"(",
")",
";",
"$",
"this",
"->",
"phpMailer",
"->",
"msgHTML",
"(",
"$",
"emailContent",
")",
";",
"$",
"this",
"->",
"phpMailer",
"->",
"send",
"(",
")",
";",
"foreach",
"(",
"$",
"mail",
"->",
"getAttachments",
"(",
")",
"as",
"$",
"attachment",
")",
"{",
"if",
"(",
"$",
"attachment",
"->",
"isDeleteAfterSend",
"(",
")",
")",
"{",
"unlink",
"(",
"$",
"attachment",
"->",
"getPath",
"(",
")",
".",
"'/'",
".",
"$",
"attachment",
"->",
"getFileName",
"(",
")",
")",
";",
"}",
"}",
"}"
] | Send created IMail entity.
@param IMail $mail
@throws \PHPMailer\PHPMailer\Exception | [
"Send",
"created",
"IMail",
"entity",
"."
] | 27683a45fb45045c0c958b727f467a5bacc427bc | https://github.com/mailsender/core/blob/27683a45fb45045c0c958b727f467a5bacc427bc/src/MailSenders/PHPMailSender.php#L78-L126 |
4,363 | agalbourdin/agl-core | src/Registry/Registry.php | Registry.set | public static function set($pKey, $pValue)
{
if (array_key_exists($pKey, self::$_registry)) {
throw new Exception("The registry key '$pKey' already exists");
}
return self::$_registry[$pKey] = $pValue;
} | php | public static function set($pKey, $pValue)
{
if (array_key_exists($pKey, self::$_registry)) {
throw new Exception("The registry key '$pKey' already exists");
}
return self::$_registry[$pKey] = $pValue;
} | [
"public",
"static",
"function",
"set",
"(",
"$",
"pKey",
",",
"$",
"pValue",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"pKey",
",",
"self",
"::",
"$",
"_registry",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"The registry key '$pKey' already exists\"",
")",
";",
"}",
"return",
"self",
"::",
"$",
"_registry",
"[",
"$",
"pKey",
"]",
"=",
"$",
"pValue",
";",
"}"
] | Add an entrey to the registry.
@param string $pKey
@param mixed $value
@return bool | [
"Add",
"an",
"entrey",
"to",
"the",
"registry",
"."
] | 1db556f9a49488aa9fab6887fefb7141a79ad97d | https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Registry/Registry.php#L30-L37 |
4,364 | agalbourdin/agl-core | src/Registry/Registry.php | Registry.get | public static function get($pKey)
{
if (array_key_exists($pKey, self::$_registry)) {
return self::$_registry[$pKey];
}
return NULL;
} | php | public static function get($pKey)
{
if (array_key_exists($pKey, self::$_registry)) {
return self::$_registry[$pKey];
}
return NULL;
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"pKey",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"pKey",
",",
"self",
"::",
"$",
"_registry",
")",
")",
"{",
"return",
"self",
"::",
"$",
"_registry",
"[",
"$",
"pKey",
"]",
";",
"}",
"return",
"NULL",
";",
"}"
] | Get a value from the registry.
@param string $pKey
@return mixed | [
"Get",
"a",
"value",
"from",
"the",
"registry",
"."
] | 1db556f9a49488aa9fab6887fefb7141a79ad97d | https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Registry/Registry.php#L45-L52 |
4,365 | agalbourdin/agl-core | src/Registry/Registry.php | Registry.remove | public static function remove($pKey)
{
if (! array_key_exists($pKey, self::$_registry)) {
throw new Exception("The registry key '$pKey' doesn't exist");
}
if (is_object(self::$_registry[$pKey]) and method_exists(self::$_registry[$pKey], '__destruct')) {
self::$_registry[$pKey]->__destruct();
}
unset(self::$_registry[$pKey]);
return true;
} | php | public static function remove($pKey)
{
if (! array_key_exists($pKey, self::$_registry)) {
throw new Exception("The registry key '$pKey' doesn't exist");
}
if (is_object(self::$_registry[$pKey]) and method_exists(self::$_registry[$pKey], '__destruct')) {
self::$_registry[$pKey]->__destruct();
}
unset(self::$_registry[$pKey]);
return true;
} | [
"public",
"static",
"function",
"remove",
"(",
"$",
"pKey",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"pKey",
",",
"self",
"::",
"$",
"_registry",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"The registry key '$pKey' doesn't exist\"",
")",
";",
"}",
"if",
"(",
"is_object",
"(",
"self",
"::",
"$",
"_registry",
"[",
"$",
"pKey",
"]",
")",
"and",
"method_exists",
"(",
"self",
"::",
"$",
"_registry",
"[",
"$",
"pKey",
"]",
",",
"'__destruct'",
")",
")",
"{",
"self",
"::",
"$",
"_registry",
"[",
"$",
"pKey",
"]",
"->",
"__destruct",
"(",
")",
";",
"}",
"unset",
"(",
"self",
"::",
"$",
"_registry",
"[",
"$",
"pKey",
"]",
")",
";",
"return",
"true",
";",
"}"
] | Remove an entry from the registry.
@param string $pKey
@return bool | [
"Remove",
"an",
"entry",
"from",
"the",
"registry",
"."
] | 1db556f9a49488aa9fab6887fefb7141a79ad97d | https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Registry/Registry.php#L60-L73 |
4,366 | yujin1st/yii2-user | rbac/Rbac.php | Rbac.initRolesForClass | private function initRolesForClass($access) {
$auth = Yii::$app->authManager;
$descriptions = $access->descriptions();
foreach ($descriptions as $permissionName => $description) {
$permission = $auth->getPermission($permissionName);
if (!$permission) {
$permission = $auth->createPermission($permissionName);
$permission->description = $descriptions[$permissionName];
$auth->add($permission);
}
}
$rolesPermissions = $access->rolesPermissions();
$rolesTitles = $access->rolesTitles();
foreach ($rolesPermissions as $roleName => $permissions) {
$role = $auth->getRole($roleName);
if (!$role) {
$role = $auth->createRole($roleName);
$role->description = $rolesTitles[$roleName];
$auth->add($role);
}
$oldPermissions = $auth->getPermissionsByRole($roleName);
foreach ($permissions as $permissionName) {
if (!isset($oldPermissions[$permissionName])) {
$permission = $auth->getPermission($permissionName);
$auth->addChild($role, $permission);
}
}
}
} | php | private function initRolesForClass($access) {
$auth = Yii::$app->authManager;
$descriptions = $access->descriptions();
foreach ($descriptions as $permissionName => $description) {
$permission = $auth->getPermission($permissionName);
if (!$permission) {
$permission = $auth->createPermission($permissionName);
$permission->description = $descriptions[$permissionName];
$auth->add($permission);
}
}
$rolesPermissions = $access->rolesPermissions();
$rolesTitles = $access->rolesTitles();
foreach ($rolesPermissions as $roleName => $permissions) {
$role = $auth->getRole($roleName);
if (!$role) {
$role = $auth->createRole($roleName);
$role->description = $rolesTitles[$roleName];
$auth->add($role);
}
$oldPermissions = $auth->getPermissionsByRole($roleName);
foreach ($permissions as $permissionName) {
if (!isset($oldPermissions[$permissionName])) {
$permission = $auth->getPermission($permissionName);
$auth->addChild($role, $permission);
}
}
}
} | [
"private",
"function",
"initRolesForClass",
"(",
"$",
"access",
")",
"{",
"$",
"auth",
"=",
"Yii",
"::",
"$",
"app",
"->",
"authManager",
";",
"$",
"descriptions",
"=",
"$",
"access",
"->",
"descriptions",
"(",
")",
";",
"foreach",
"(",
"$",
"descriptions",
"as",
"$",
"permissionName",
"=>",
"$",
"description",
")",
"{",
"$",
"permission",
"=",
"$",
"auth",
"->",
"getPermission",
"(",
"$",
"permissionName",
")",
";",
"if",
"(",
"!",
"$",
"permission",
")",
"{",
"$",
"permission",
"=",
"$",
"auth",
"->",
"createPermission",
"(",
"$",
"permissionName",
")",
";",
"$",
"permission",
"->",
"description",
"=",
"$",
"descriptions",
"[",
"$",
"permissionName",
"]",
";",
"$",
"auth",
"->",
"add",
"(",
"$",
"permission",
")",
";",
"}",
"}",
"$",
"rolesPermissions",
"=",
"$",
"access",
"->",
"rolesPermissions",
"(",
")",
";",
"$",
"rolesTitles",
"=",
"$",
"access",
"->",
"rolesTitles",
"(",
")",
";",
"foreach",
"(",
"$",
"rolesPermissions",
"as",
"$",
"roleName",
"=>",
"$",
"permissions",
")",
"{",
"$",
"role",
"=",
"$",
"auth",
"->",
"getRole",
"(",
"$",
"roleName",
")",
";",
"if",
"(",
"!",
"$",
"role",
")",
"{",
"$",
"role",
"=",
"$",
"auth",
"->",
"createRole",
"(",
"$",
"roleName",
")",
";",
"$",
"role",
"->",
"description",
"=",
"$",
"rolesTitles",
"[",
"$",
"roleName",
"]",
";",
"$",
"auth",
"->",
"add",
"(",
"$",
"role",
")",
";",
"}",
"$",
"oldPermissions",
"=",
"$",
"auth",
"->",
"getPermissionsByRole",
"(",
"$",
"roleName",
")",
";",
"foreach",
"(",
"$",
"permissions",
"as",
"$",
"permissionName",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"oldPermissions",
"[",
"$",
"permissionName",
"]",
")",
")",
"{",
"$",
"permission",
"=",
"$",
"auth",
"->",
"getPermission",
"(",
"$",
"permissionName",
")",
";",
"$",
"auth",
"->",
"addChild",
"(",
"$",
"role",
",",
"$",
"permission",
")",
";",
"}",
"}",
"}",
"}"
] | init roles for extension class
@param $access AccessInterface | [
"init",
"roles",
"for",
"extension",
"class"
] | b404c77acf4a96f0cdf9bb0af5c8d62bcae3946f | https://github.com/yujin1st/yii2-user/blob/b404c77acf4a96f0cdf9bb0af5c8d62bcae3946f/rbac/Rbac.php#L24-L56 |
4,367 | yujin1st/yii2-user | rbac/Rbac.php | Rbac.initRolesAndActions | public function initRolesAndActions() {
$classes = $this->loadClasses();
foreach ($classes as $item) {
$this->initRolesForClass($item);
}
} | php | public function initRolesAndActions() {
$classes = $this->loadClasses();
foreach ($classes as $item) {
$this->initRolesForClass($item);
}
} | [
"public",
"function",
"initRolesAndActions",
"(",
")",
"{",
"$",
"classes",
"=",
"$",
"this",
"->",
"loadClasses",
"(",
")",
";",
"foreach",
"(",
"$",
"classes",
"as",
"$",
"item",
")",
"{",
"$",
"this",
"->",
"initRolesForClass",
"(",
"$",
"item",
")",
";",
"}",
"}"
] | Collecting and initialising roles over all app | [
"Collecting",
"and",
"initialising",
"roles",
"over",
"all",
"app"
] | b404c77acf4a96f0cdf9bb0af5c8d62bcae3946f | https://github.com/yujin1st/yii2-user/blob/b404c77acf4a96f0cdf9bb0af5c8d62bcae3946f/rbac/Rbac.php#L61-L66 |
4,368 | yujin1st/yii2-user | rbac/Rbac.php | Rbac.setAdminRole | public function setAdminRole($user) {
$classes = $this->loadClasses();
$auth = Yii::$app->authManager;
$auth->revokeAll($user->id);
foreach ($classes as $item) {
foreach ($item->adminRoles() as $role) {
$auth->assign($auth->getRole($role), $user->id);
}
}
} | php | public function setAdminRole($user) {
$classes = $this->loadClasses();
$auth = Yii::$app->authManager;
$auth->revokeAll($user->id);
foreach ($classes as $item) {
foreach ($item->adminRoles() as $role) {
$auth->assign($auth->getRole($role), $user->id);
}
}
} | [
"public",
"function",
"setAdminRole",
"(",
"$",
"user",
")",
"{",
"$",
"classes",
"=",
"$",
"this",
"->",
"loadClasses",
"(",
")",
";",
"$",
"auth",
"=",
"Yii",
"::",
"$",
"app",
"->",
"authManager",
";",
"$",
"auth",
"->",
"revokeAll",
"(",
"$",
"user",
"->",
"id",
")",
";",
"foreach",
"(",
"$",
"classes",
"as",
"$",
"item",
")",
"{",
"foreach",
"(",
"$",
"item",
"->",
"adminRoles",
"(",
")",
"as",
"$",
"role",
")",
"{",
"$",
"auth",
"->",
"assign",
"(",
"$",
"auth",
"->",
"getRole",
"(",
"$",
"role",
")",
",",
"$",
"user",
"->",
"id",
")",
";",
"}",
"}",
"}"
] | Set admin roles to user
@param $user User | [
"Set",
"admin",
"roles",
"to",
"user"
] | b404c77acf4a96f0cdf9bb0af5c8d62bcae3946f | https://github.com/yujin1st/yii2-user/blob/b404c77acf4a96f0cdf9bb0af5c8d62bcae3946f/rbac/Rbac.php#L83-L95 |
4,369 | open-orchestra/open-orchestra-front-bundle | FrontBundle/Controller/BlockController.php | BlockController.showAction | public function showAction(Request $request, $siteId, $nodeId, $blockId)
{
try {
$block = $this->get('open_orchestra_model.repository.block')->findById($blockId);
$response = $this->get('open_orchestra_display.display_block_manager')->show($block);
$this->tagResponse($block, $nodeId, $siteId, $request->getLocale());
return $response;
} catch (\Exception $e) {
throw new DisplayBlockException($e->getMessage(), $e->getCode(), $e);
}
} | php | public function showAction(Request $request, $siteId, $nodeId, $blockId)
{
try {
$block = $this->get('open_orchestra_model.repository.block')->findById($blockId);
$response = $this->get('open_orchestra_display.display_block_manager')->show($block);
$this->tagResponse($block, $nodeId, $siteId, $request->getLocale());
return $response;
} catch (\Exception $e) {
throw new DisplayBlockException($e->getMessage(), $e->getCode(), $e);
}
} | [
"public",
"function",
"showAction",
"(",
"Request",
"$",
"request",
",",
"$",
"siteId",
",",
"$",
"nodeId",
",",
"$",
"blockId",
")",
"{",
"try",
"{",
"$",
"block",
"=",
"$",
"this",
"->",
"get",
"(",
"'open_orchestra_model.repository.block'",
")",
"->",
"findById",
"(",
"$",
"blockId",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"get",
"(",
"'open_orchestra_display.display_block_manager'",
")",
"->",
"show",
"(",
"$",
"block",
")",
";",
"$",
"this",
"->",
"tagResponse",
"(",
"$",
"block",
",",
"$",
"nodeId",
",",
"$",
"siteId",
",",
"$",
"request",
"->",
"getLocale",
"(",
")",
")",
";",
"return",
"$",
"response",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"DisplayBlockException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
"->",
"getCode",
"(",
")",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Display the response linked to a block
@param Request $request
@param string $siteId
@param string $nodeId
@param string $blockId
@Config\Route("/block/{siteId}/{nodeId}/{blockId}/{_locale}", name="open_orchestra_front_block")
@Config\Method({"GET", "POST"})
@throws DisplayBlockException
@return Response | [
"Display",
"the",
"response",
"linked",
"to",
"a",
"block"
] | 3c2cf3998af03e7a69fb6475b71d9c7d65b058bb | https://github.com/open-orchestra/open-orchestra-front-bundle/blob/3c2cf3998af03e7a69fb6475b71d9c7d65b058bb/FrontBundle/Controller/BlockController.php#L31-L43 |
4,370 | e1himself/axis-service-container-plugin | lib/Axis/S1/ServiceContainer/Config/Configurator.php | Configurator.execute | public function execute()
{
$config = $this->getConfiguration();
$code = '';
$code .= $this->generateContainerInitializationCode($config);
$code .= $this->generateFactoriesInitializationCode($config);
return $code;
} | php | public function execute()
{
$config = $this->getConfiguration();
$code = '';
$code .= $this->generateContainerInitializationCode($config);
$code .= $this->generateFactoriesInitializationCode($config);
return $code;
} | [
"public",
"function",
"execute",
"(",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"getConfiguration",
"(",
")",
";",
"$",
"code",
"=",
"''",
";",
"$",
"code",
".=",
"$",
"this",
"->",
"generateContainerInitializationCode",
"(",
"$",
"config",
")",
";",
"$",
"code",
".=",
"$",
"this",
"->",
"generateFactoriesInitializationCode",
"(",
"$",
"config",
")",
";",
"return",
"$",
"code",
";",
"}"
] | Generates configuration cache code
@return string Generated code | [
"Generates",
"configuration",
"cache",
"code"
] | ba1eff8ecf4a77e1cf9ae145e6c761e7170ebe7c | https://github.com/e1himself/axis-service-container-plugin/blob/ba1eff8ecf4a77e1cf9ae145e6c761e7170ebe7c/lib/Axis/S1/ServiceContainer/Config/Configurator.php#L24-L31 |
4,371 | SamsonIT/DataViewBundle | DataView/DataViewView.php | DataViewView.getData | public function getData()
{
if ($this->vars['compound'] && $this->vars['value'] !== null) {
return array_map(function (DataViewView $view) {
return $view->getData();
}, $this->children);
}
return $this->vars['value'];
} | php | public function getData()
{
if ($this->vars['compound'] && $this->vars['value'] !== null) {
return array_map(function (DataViewView $view) {
return $view->getData();
}, $this->children);
}
return $this->vars['value'];
} | [
"public",
"function",
"getData",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"vars",
"[",
"'compound'",
"]",
"&&",
"$",
"this",
"->",
"vars",
"[",
"'value'",
"]",
"!==",
"null",
")",
"{",
"return",
"array_map",
"(",
"function",
"(",
"DataViewView",
"$",
"view",
")",
"{",
"return",
"$",
"view",
"->",
"getData",
"(",
")",
";",
"}",
",",
"$",
"this",
"->",
"children",
")",
";",
"}",
"return",
"$",
"this",
"->",
"vars",
"[",
"'value'",
"]",
";",
"}"
] | This is the method that will actually fetch the data off the view object
@return array | [
"This",
"is",
"the",
"method",
"that",
"will",
"actually",
"fetch",
"the",
"data",
"off",
"the",
"view",
"object"
] | 572ea9a31f065f35035b55fa9db7333a49443025 | https://github.com/SamsonIT/DataViewBundle/blob/572ea9a31f065f35035b55fa9db7333a49443025/DataView/DataViewView.php#L15-L24 |
4,372 | JumpGateio/Menu | src/JumpGate/Menu/Container.php | Container.getMenu | public function getMenu($menuName)
{
$menu = $this->getMenuObject($menuName);
if ($menu) {
return $menu;
} else {
return $this->add($menuName);
}
} | php | public function getMenu($menuName)
{
$menu = $this->getMenuObject($menuName);
if ($menu) {
return $menu;
} else {
return $this->add($menuName);
}
} | [
"public",
"function",
"getMenu",
"(",
"$",
"menuName",
")",
"{",
"$",
"menu",
"=",
"$",
"this",
"->",
"getMenuObject",
"(",
"$",
"menuName",
")",
";",
"if",
"(",
"$",
"menu",
")",
"{",
"return",
"$",
"menu",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"add",
"(",
"$",
"menuName",
")",
";",
"}",
"}"
] | Get a menu you have created.
@param $menuName
@return mixed | [
"Get",
"a",
"menu",
"you",
"have",
"created",
"."
] | 53e339cc0a070e3b8a8332fe32850699663fa215 | https://github.com/JumpGateio/Menu/blob/53e339cc0a070e3b8a8332fe32850699663fa215/src/JumpGate/Menu/Container.php#L28-L36 |
4,373 | JumpGateio/Menu | src/JumpGate/Menu/Container.php | Container.render | public function render($menuName)
{
// We set active at the last possible moment.
$this->updateActive();
$menu = $this->getMenuObject($menuName);
if (! $menu) {
throw new \Exception("Menu {$menuName} not found.");
}
return $menu;
} | php | public function render($menuName)
{
// We set active at the last possible moment.
$this->updateActive();
$menu = $this->getMenuObject($menuName);
if (! $menu) {
throw new \Exception("Menu {$menuName} not found.");
}
return $menu;
} | [
"public",
"function",
"render",
"(",
"$",
"menuName",
")",
"{",
"// We set active at the last possible moment.",
"$",
"this",
"->",
"updateActive",
"(",
")",
";",
"$",
"menu",
"=",
"$",
"this",
"->",
"getMenuObject",
"(",
"$",
"menuName",
")",
";",
"if",
"(",
"!",
"$",
"menu",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Menu {$menuName} not found.\"",
")",
";",
"}",
"return",
"$",
"menu",
";",
"}"
] | Update the active and order values and then return the object.
@param $menuName
@return Menu
@throws \Exception | [
"Update",
"the",
"active",
"and",
"order",
"values",
"and",
"then",
"return",
"the",
"object",
"."
] | 53e339cc0a070e3b8a8332fe32850699663fa215 | https://github.com/JumpGateio/Menu/blob/53e339cc0a070e3b8a8332fe32850699663fa215/src/JumpGate/Menu/Container.php#L82-L94 |
4,374 | JumpGateio/Menu | src/JumpGate/Menu/Container.php | Container.updateActive | private function updateActive()
{
$this->each(function ($item) {
if (isset($item->links)) {
$this->makeActive($item);
}
});
} | php | private function updateActive()
{
$this->each(function ($item) {
if (isset($item->links)) {
$this->makeActive($item);
}
});
} | [
"private",
"function",
"updateActive",
"(",
")",
"{",
"$",
"this",
"->",
"each",
"(",
"function",
"(",
"$",
"item",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"item",
"->",
"links",
")",
")",
"{",
"$",
"this",
"->",
"makeActive",
"(",
"$",
"item",
")",
";",
"}",
"}",
")",
";",
"}"
] | Use the active param and set the link to active | [
"Use",
"the",
"active",
"param",
"and",
"set",
"the",
"link",
"to",
"active"
] | 53e339cc0a070e3b8a8332fe32850699663fa215 | https://github.com/JumpGateio/Menu/blob/53e339cc0a070e3b8a8332fe32850699663fa215/src/JumpGate/Menu/Container.php#L143-L150 |
4,375 | JumpGateio/Menu | src/JumpGate/Menu/Container.php | Container.makeActive | private function makeActive($item, $parent = null)
{
$item->links->each(function ($link) use ($item, $parent) {
if ($link->slug == $this->active) {
$this->makeParentActive($parent);
$this->makeParentActive($item);
$link->setActive(true);
}
if (isset($link->links)) {
$this->makeActive($link, $item);
}
});
} | php | private function makeActive($item, $parent = null)
{
$item->links->each(function ($link) use ($item, $parent) {
if ($link->slug == $this->active) {
$this->makeParentActive($parent);
$this->makeParentActive($item);
$link->setActive(true);
}
if (isset($link->links)) {
$this->makeActive($link, $item);
}
});
} | [
"private",
"function",
"makeActive",
"(",
"$",
"item",
",",
"$",
"parent",
"=",
"null",
")",
"{",
"$",
"item",
"->",
"links",
"->",
"each",
"(",
"function",
"(",
"$",
"link",
")",
"use",
"(",
"$",
"item",
",",
"$",
"parent",
")",
"{",
"if",
"(",
"$",
"link",
"->",
"slug",
"==",
"$",
"this",
"->",
"active",
")",
"{",
"$",
"this",
"->",
"makeParentActive",
"(",
"$",
"parent",
")",
";",
"$",
"this",
"->",
"makeParentActive",
"(",
"$",
"item",
")",
";",
"$",
"link",
"->",
"setActive",
"(",
"true",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"link",
"->",
"links",
")",
")",
"{",
"$",
"this",
"->",
"makeActive",
"(",
"$",
"link",
",",
"$",
"item",
")",
";",
"}",
"}",
")",
";",
"}"
] | Loop through the links and check for active.
Sets the item and it's parents as active when told to. | [
"Loop",
"through",
"the",
"links",
"and",
"check",
"for",
"active",
".",
"Sets",
"the",
"item",
"and",
"it",
"s",
"parents",
"as",
"active",
"when",
"told",
"to",
"."
] | 53e339cc0a070e3b8a8332fe32850699663fa215 | https://github.com/JumpGateio/Menu/blob/53e339cc0a070e3b8a8332fe32850699663fa215/src/JumpGate/Menu/Container.php#L156-L170 |
4,376 | JumpGateio/Menu | src/JumpGate/Menu/Container.php | Container.makeParentActive | private function makeParentActive($parent)
{
if (! is_null($parent)
&& method_exists($parent, 'activeParentage')
&& $parent->activeParentage()
) {
$parent->setActive(true);
}
} | php | private function makeParentActive($parent)
{
if (! is_null($parent)
&& method_exists($parent, 'activeParentage')
&& $parent->activeParentage()
) {
$parent->setActive(true);
}
} | [
"private",
"function",
"makeParentActive",
"(",
"$",
"parent",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"parent",
")",
"&&",
"method_exists",
"(",
"$",
"parent",
",",
"'activeParentage'",
")",
"&&",
"$",
"parent",
"->",
"activeParentage",
"(",
")",
")",
"{",
"$",
"parent",
"->",
"setActive",
"(",
"true",
")",
";",
"}",
"}"
] | Set the parent item as active if able to do so. | [
"Set",
"the",
"parent",
"item",
"as",
"active",
"if",
"able",
"to",
"do",
"so",
"."
] | 53e339cc0a070e3b8a8332fe32850699663fa215 | https://github.com/JumpGateio/Menu/blob/53e339cc0a070e3b8a8332fe32850699663fa215/src/JumpGate/Menu/Container.php#L175-L183 |
4,377 | gigaai/resolver | src/Resolver.php | Resolver.resolve | public function resolve($closure)
{
if (is_array($closure)) {
$reflection = new \ReflectionMethod($closure[0], $closure[1]);
} else {
$reflection = new \ReflectionFunction($closure);
}
$arguments = $reflection->getParameters();
$arguments = array_map(function ($argument) {
return isset($this->bindMaps[$argument->name]) ? $this->bindMaps[$argument->name] : null;
}, $arguments);
return @call_user_func_array($closure, $arguments);
} | php | public function resolve($closure)
{
if (is_array($closure)) {
$reflection = new \ReflectionMethod($closure[0], $closure[1]);
} else {
$reflection = new \ReflectionFunction($closure);
}
$arguments = $reflection->getParameters();
$arguments = array_map(function ($argument) {
return isset($this->bindMaps[$argument->name]) ? $this->bindMaps[$argument->name] : null;
}, $arguments);
return @call_user_func_array($closure, $arguments);
} | [
"public",
"function",
"resolve",
"(",
"$",
"closure",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"closure",
")",
")",
"{",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionMethod",
"(",
"$",
"closure",
"[",
"0",
"]",
",",
"$",
"closure",
"[",
"1",
"]",
")",
";",
"}",
"else",
"{",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionFunction",
"(",
"$",
"closure",
")",
";",
"}",
"$",
"arguments",
"=",
"$",
"reflection",
"->",
"getParameters",
"(",
")",
";",
"$",
"arguments",
"=",
"array_map",
"(",
"function",
"(",
"$",
"argument",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"bindMaps",
"[",
"$",
"argument",
"->",
"name",
"]",
")",
"?",
"$",
"this",
"->",
"bindMaps",
"[",
"$",
"argument",
"->",
"name",
"]",
":",
"null",
";",
"}",
",",
"$",
"arguments",
")",
";",
"return",
"@",
"call_user_func_array",
"(",
"$",
"closure",
",",
"$",
"arguments",
")",
";",
"}"
] | Resolve the closure and do the magic here
@param Closure $closure
@return mixed | [
"Resolve",
"the",
"closure",
"and",
"do",
"the",
"magic",
"here"
] | 1e6e0996da4ae5e6755b72565eadef197d551f36 | https://github.com/gigaai/resolver/blob/1e6e0996da4ae5e6755b72565eadef197d551f36/src/Resolver.php#L41-L56 |
4,378 | netcore/module-category | Translations/CategoryTranslation.php | CategoryTranslation.getFullSlug | public function getFullSlug() : string
{
$categories = Category::with('ancestors')->ancestorsAndSelf($this->category->id);
$slug = "";
foreach ($categories as $category) {
$translation = $category->translations->where('locale', $this->locale)->first();
$slug .= $translation->slug . '/';
}
$slug = substr($slug, 0, -1);
return $slug;
} | php | public function getFullSlug() : string
{
$categories = Category::with('ancestors')->ancestorsAndSelf($this->category->id);
$slug = "";
foreach ($categories as $category) {
$translation = $category->translations->where('locale', $this->locale)->first();
$slug .= $translation->slug . '/';
}
$slug = substr($slug, 0, -1);
return $slug;
} | [
"public",
"function",
"getFullSlug",
"(",
")",
":",
"string",
"{",
"$",
"categories",
"=",
"Category",
"::",
"with",
"(",
"'ancestors'",
")",
"->",
"ancestorsAndSelf",
"(",
"$",
"this",
"->",
"category",
"->",
"id",
")",
";",
"$",
"slug",
"=",
"\"\"",
";",
"foreach",
"(",
"$",
"categories",
"as",
"$",
"category",
")",
"{",
"$",
"translation",
"=",
"$",
"category",
"->",
"translations",
"->",
"where",
"(",
"'locale'",
",",
"$",
"this",
"->",
"locale",
")",
"->",
"first",
"(",
")",
";",
"$",
"slug",
".=",
"$",
"translation",
"->",
"slug",
".",
"'/'",
";",
"}",
"$",
"slug",
"=",
"substr",
"(",
"$",
"slug",
",",
"0",
",",
"-",
"1",
")",
";",
"return",
"$",
"slug",
";",
"}"
] | Get full slug of the category
@return string | [
"Get",
"full",
"slug",
"of",
"the",
"category"
] | 61a4fc2525774f8ddea730ad9f6f06644552adf7 | https://github.com/netcore/module-category/blob/61a4fc2525774f8ddea730ad9f6f06644552adf7/Translations/CategoryTranslation.php#L108-L122 |
4,379 | Celarius/nofuzz-framework | src/Database/PdoConnection.php | PdoConnection.getDsn | public function getDsn(): string
{
# Build the DSN
$_dsn = $this->driver.':host='.$this->host.';port='.$this->port.';dbname='.$this->schema.';charset='.$this->charset;
# Set it
$this->setDsn($_dsn);
return $this->pdo_dsn;
} | php | public function getDsn(): string
{
# Build the DSN
$_dsn = $this->driver.':host='.$this->host.';port='.$this->port.';dbname='.$this->schema.';charset='.$this->charset;
# Set it
$this->setDsn($_dsn);
return $this->pdo_dsn;
} | [
"public",
"function",
"getDsn",
"(",
")",
":",
"string",
"{",
"# Build the DSN",
"$",
"_dsn",
"=",
"$",
"this",
"->",
"driver",
".",
"':host='",
".",
"$",
"this",
"->",
"host",
".",
"';port='",
".",
"$",
"this",
"->",
"port",
".",
"';dbname='",
".",
"$",
"this",
"->",
"schema",
".",
"';charset='",
".",
"$",
"this",
"->",
"charset",
";",
"# Set it",
"$",
"this",
"->",
"setDsn",
"(",
"$",
"_dsn",
")",
";",
"return",
"$",
"this",
"->",
"pdo_dsn",
";",
"}"
] | Get DSN - Return the default formatted DSN
This method needs to be overridden in DB Driver specific files
@return string [description] | [
"Get",
"DSN",
"-",
"Return",
"the",
"default",
"formatted",
"DSN"
] | 867c5150baa431e8f800624a26ba80e95eebd4e5 | https://github.com/Celarius/nofuzz-framework/blob/867c5150baa431e8f800624a26ba80e95eebd4e5/src/Database/PdoConnection.php#L166-L174 |
4,380 | heyday/symfony-autoinject | src/AutoInject.php | AutoInject.addInterfaceProvider | private function addInterfaceProvider($interface, Reference $reference)
{
if (empty($this->interfaceProviders[$interface])) {
$this->interfaceProviders[$interface]= [];
}
$this->interfaceProviders[$interface][] = $reference;
} | php | private function addInterfaceProvider($interface, Reference $reference)
{
if (empty($this->interfaceProviders[$interface])) {
$this->interfaceProviders[$interface]= [];
}
$this->interfaceProviders[$interface][] = $reference;
} | [
"private",
"function",
"addInterfaceProvider",
"(",
"$",
"interface",
",",
"Reference",
"$",
"reference",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"interfaceProviders",
"[",
"$",
"interface",
"]",
")",
")",
"{",
"$",
"this",
"->",
"interfaceProviders",
"[",
"$",
"interface",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"this",
"->",
"interfaceProviders",
"[",
"$",
"interface",
"]",
"[",
"]",
"=",
"$",
"reference",
";",
"}"
] | Add an interface provider to the list
@param string $interface
@param Reference $reference | [
"Add",
"an",
"interface",
"provider",
"to",
"the",
"list"
] | 41f0f48e3f2e60ed0c2148748fd7a71d914d6d16 | https://github.com/heyday/symfony-autoinject/blob/41f0f48e3f2e60ed0c2148748fd7a71d914d6d16/src/AutoInject.php#L344-L351 |
4,381 | heyday/symfony-autoinject | src/AutoInject.php | AutoInject.addClassProvider | private function addClassProvider($class, Reference $reference)
{
if (empty($this->classProviders[$class])) {
$this->classProviders[$class] = [];
}
$this->classProviders[$class][] = $reference;
} | php | private function addClassProvider($class, Reference $reference)
{
if (empty($this->classProviders[$class])) {
$this->classProviders[$class] = [];
}
$this->classProviders[$class][] = $reference;
} | [
"private",
"function",
"addClassProvider",
"(",
"$",
"class",
",",
"Reference",
"$",
"reference",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"classProviders",
"[",
"$",
"class",
"]",
")",
")",
"{",
"$",
"this",
"->",
"classProviders",
"[",
"$",
"class",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"this",
"->",
"classProviders",
"[",
"$",
"class",
"]",
"[",
"]",
"=",
"$",
"reference",
";",
"}"
] | Add a class provider to the list
@param string $class
@param Reference $reference | [
"Add",
"a",
"class",
"provider",
"to",
"the",
"list"
] | 41f0f48e3f2e60ed0c2148748fd7a71d914d6d16 | https://github.com/heyday/symfony-autoinject/blob/41f0f48e3f2e60ed0c2148748fd7a71d914d6d16/src/AutoInject.php#L358-L365 |
4,382 | heyday/symfony-autoinject | src/AutoInject.php | AutoInject.getProvider | private function getProvider($identifier)
{
if (isset($this->interfaceProviders[$identifier])) {
$this->assertSingleInterfaceProvider($identifier);
return reset($this->interfaceProviders[$identifier]);
} elseif (isset($this->classProviders[$identifier])) {
$this->assertSingleClassProvider($identifier);
return reset($this->classProviders[$identifier]);
} else {
return false;
}
} | php | private function getProvider($identifier)
{
if (isset($this->interfaceProviders[$identifier])) {
$this->assertSingleInterfaceProvider($identifier);
return reset($this->interfaceProviders[$identifier]);
} elseif (isset($this->classProviders[$identifier])) {
$this->assertSingleClassProvider($identifier);
return reset($this->classProviders[$identifier]);
} else {
return false;
}
} | [
"private",
"function",
"getProvider",
"(",
"$",
"identifier",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"interfaceProviders",
"[",
"$",
"identifier",
"]",
")",
")",
"{",
"$",
"this",
"->",
"assertSingleInterfaceProvider",
"(",
"$",
"identifier",
")",
";",
"return",
"reset",
"(",
"$",
"this",
"->",
"interfaceProviders",
"[",
"$",
"identifier",
"]",
")",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"this",
"->",
"classProviders",
"[",
"$",
"identifier",
"]",
")",
")",
"{",
"$",
"this",
"->",
"assertSingleClassProvider",
"(",
"$",
"identifier",
")",
";",
"return",
"reset",
"(",
"$",
"this",
"->",
"classProviders",
"[",
"$",
"identifier",
"]",
")",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] | Get a provider for an identifier
using this method when there are multiple providers for an
identifier will cause an exception to be thrown
@param $identifier
@return mixed
@throws \InvalidArgumentException | [
"Get",
"a",
"provider",
"for",
"an",
"identifier",
"using",
"this",
"method",
"when",
"there",
"are",
"multiple",
"providers",
"for",
"an",
"identifier",
"will",
"cause",
"an",
"exception",
"to",
"be",
"thrown"
] | 41f0f48e3f2e60ed0c2148748fd7a71d914d6d16 | https://github.com/heyday/symfony-autoinject/blob/41f0f48e3f2e60ed0c2148748fd7a71d914d6d16/src/AutoInject.php#L375-L386 |
4,383 | heyday/symfony-autoinject | src/AutoInject.php | AutoInject.getProviders | private function getProviders($identifier)
{
if (isset($this->interfaceProviders[$identifier])) {
return $this->interfaceProviders[$identifier];
} elseif (isset($this->classProviders[$identifier])) {
return $this->classProviders[$identifier];
} else {
return [];
}
} | php | private function getProviders($identifier)
{
if (isset($this->interfaceProviders[$identifier])) {
return $this->interfaceProviders[$identifier];
} elseif (isset($this->classProviders[$identifier])) {
return $this->classProviders[$identifier];
} else {
return [];
}
} | [
"private",
"function",
"getProviders",
"(",
"$",
"identifier",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"interfaceProviders",
"[",
"$",
"identifier",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"interfaceProviders",
"[",
"$",
"identifier",
"]",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"this",
"->",
"classProviders",
"[",
"$",
"identifier",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"classProviders",
"[",
"$",
"identifier",
"]",
";",
"}",
"else",
"{",
"return",
"[",
"]",
";",
"}",
"}"
] | Get all providers for a specified identifier
@param $identifier
@return Reference[] | [
"Get",
"all",
"providers",
"for",
"a",
"specified",
"identifier"
] | 41f0f48e3f2e60ed0c2148748fd7a71d914d6d16 | https://github.com/heyday/symfony-autoinject/blob/41f0f48e3f2e60ed0c2148748fd7a71d914d6d16/src/AutoInject.php#L393-L402 |
4,384 | heyday/symfony-autoinject | src/AutoInject.php | AutoInject.isMethodIncluded | private function isMethodIncluded($methodName, $attr)
{
if (empty($attr[self::CONFIG_INCLUDE]) || !is_array($attr[self::CONFIG_INCLUDE])) {
return true;
}
return in_array($methodName, $attr[self::CONFIG_INCLUDE]);
} | php | private function isMethodIncluded($methodName, $attr)
{
if (empty($attr[self::CONFIG_INCLUDE]) || !is_array($attr[self::CONFIG_INCLUDE])) {
return true;
}
return in_array($methodName, $attr[self::CONFIG_INCLUDE]);
} | [
"private",
"function",
"isMethodIncluded",
"(",
"$",
"methodName",
",",
"$",
"attr",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"attr",
"[",
"self",
"::",
"CONFIG_INCLUDE",
"]",
")",
"||",
"!",
"is_array",
"(",
"$",
"attr",
"[",
"self",
"::",
"CONFIG_INCLUDE",
"]",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"in_array",
"(",
"$",
"methodName",
",",
"$",
"attr",
"[",
"self",
"::",
"CONFIG_INCLUDE",
"]",
")",
";",
"}"
] | Checks if a method is in the include list
@param $methodName
@param $attr
@return bool | [
"Checks",
"if",
"a",
"method",
"is",
"in",
"the",
"include",
"list"
] | 41f0f48e3f2e60ed0c2148748fd7a71d914d6d16 | https://github.com/heyday/symfony-autoinject/blob/41f0f48e3f2e60ed0c2148748fd7a71d914d6d16/src/AutoInject.php#L452-L459 |
4,385 | heyday/symfony-autoinject | src/AutoInject.php | AutoInject.isMethodExcluded | private function isMethodExcluded($methodName, $attr)
{
if (empty($attr[self::CONFIG_EXCLUDE]) || !is_array($attr[self::CONFIG_EXCLUDE])) {
return false;
}
return in_array($methodName, $attr[self::CONFIG_EXCLUDE]);
} | php | private function isMethodExcluded($methodName, $attr)
{
if (empty($attr[self::CONFIG_EXCLUDE]) || !is_array($attr[self::CONFIG_EXCLUDE])) {
return false;
}
return in_array($methodName, $attr[self::CONFIG_EXCLUDE]);
} | [
"private",
"function",
"isMethodExcluded",
"(",
"$",
"methodName",
",",
"$",
"attr",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"attr",
"[",
"self",
"::",
"CONFIG_EXCLUDE",
"]",
")",
"||",
"!",
"is_array",
"(",
"$",
"attr",
"[",
"self",
"::",
"CONFIG_EXCLUDE",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"in_array",
"(",
"$",
"methodName",
",",
"$",
"attr",
"[",
"self",
"::",
"CONFIG_EXCLUDE",
"]",
")",
";",
"}"
] | Checks if a method is in the exclude list
@param $methodName
@param $attr
@return bool | [
"Checks",
"if",
"a",
"method",
"is",
"in",
"the",
"exclude",
"list"
] | 41f0f48e3f2e60ed0c2148748fd7a71d914d6d16 | https://github.com/heyday/symfony-autoinject/blob/41f0f48e3f2e60ed0c2148748fd7a71d914d6d16/src/AutoInject.php#L467-L474 |
4,386 | heyday/symfony-autoinject | src/AutoInject.php | AutoInject.hasConfig | private function hasConfig($config, $attr)
{
return (isset($attr[self::CONFIG_ALL]) && $attr[self::CONFIG_ALL]) || (isset($attr[$config]) && $attr[$config]);
} | php | private function hasConfig($config, $attr)
{
return (isset($attr[self::CONFIG_ALL]) && $attr[self::CONFIG_ALL]) || (isset($attr[$config]) && $attr[$config]);
} | [
"private",
"function",
"hasConfig",
"(",
"$",
"config",
",",
"$",
"attr",
")",
"{",
"return",
"(",
"isset",
"(",
"$",
"attr",
"[",
"self",
"::",
"CONFIG_ALL",
"]",
")",
"&&",
"$",
"attr",
"[",
"self",
"::",
"CONFIG_ALL",
"]",
")",
"||",
"(",
"isset",
"(",
"$",
"attr",
"[",
"$",
"config",
"]",
")",
"&&",
"$",
"attr",
"[",
"$",
"config",
"]",
")",
";",
"}"
] | Tests whether ot not a config option has been provided in the tag
If the "all" setting is present, this will return true
@param string $config
@param array $attr
@return bool | [
"Tests",
"whether",
"ot",
"not",
"a",
"config",
"option",
"has",
"been",
"provided",
"in",
"the",
"tag",
"If",
"the",
"all",
"setting",
"is",
"present",
"this",
"will",
"return",
"true"
] | 41f0f48e3f2e60ed0c2148748fd7a71d914d6d16 | https://github.com/heyday/symfony-autoinject/blob/41f0f48e3f2e60ed0c2148748fd7a71d914d6d16/src/AutoInject.php#L483-L486 |
4,387 | Cyberrebell/ZF2DoctrineCrudHandler | library/ZF2DoctrineCrudHandler/src/ZF2DoctrineCrudHandler/Handler/AbstractCrudHandler.php | AbstractCrudHandler.setupTitle | protected function setupTitle() {
if ($this->title === null) {
$segments = explode('\\', $this->entityNamespace);
$this->title = end($segments);
}
$this->viewModel->setVariable('title', $this->title);
} | php | protected function setupTitle() {
if ($this->title === null) {
$segments = explode('\\', $this->entityNamespace);
$this->title = end($segments);
}
$this->viewModel->setVariable('title', $this->title);
} | [
"protected",
"function",
"setupTitle",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"title",
"===",
"null",
")",
"{",
"$",
"segments",
"=",
"explode",
"(",
"'\\\\'",
",",
"$",
"this",
"->",
"entityNamespace",
")",
";",
"$",
"this",
"->",
"title",
"=",
"end",
"(",
"$",
"segments",
")",
";",
"}",
"$",
"this",
"->",
"viewModel",
"->",
"setVariable",
"(",
"'title'",
",",
"$",
"this",
"->",
"title",
")",
";",
"}"
] | Set Title into ViewModel, extract Entity-Classname if no title set
@return null | [
"Set",
"Title",
"into",
"ViewModel",
"extract",
"Entity",
"-",
"Classname",
"if",
"no",
"title",
"set"
] | 9ed9b1ae8d7a2a051a1f4638be1dfeefa150d8bb | https://github.com/Cyberrebell/ZF2DoctrineCrudHandler/blob/9ed9b1ae8d7a2a051a1f4638be1dfeefa150d8bb/library/ZF2DoctrineCrudHandler/src/ZF2DoctrineCrudHandler/Handler/AbstractCrudHandler.php#L138-L144 |
4,388 | phlexible/phlexible | src/Phlexible/Bundle/MetaSetBundle/Controller/SetsController.php | SetsController.listAction | public function listAction()
{
$metaSetManager = $this->get('phlexible_meta_set.meta_set_manager');
$metaSet = $metaSetManager->findAll();
$data = [];
foreach ($metaSet as $set) {
/* @var $set MetaSetInterface */
$data[] = [
'id' => $set->getId(),
'name' => $set->getName(),
'createdAt' => $set->getCreatedAt() ? $set->getCreatedAt()->format('Y-m-d H:i:s') : null,
'createUser' => $set->getCreateUser(),
'modifiedAt' => $set->getModifiedAt() ? $set->getModifiedAt()->format('Y-m-d H:i:s') : null,
'modifyUser' => $set->getModifyUser(),
'revision' => $set->getRevision(),
];
}
return new JsonResponse(['sets' => $data]);
} | php | public function listAction()
{
$metaSetManager = $this->get('phlexible_meta_set.meta_set_manager');
$metaSet = $metaSetManager->findAll();
$data = [];
foreach ($metaSet as $set) {
/* @var $set MetaSetInterface */
$data[] = [
'id' => $set->getId(),
'name' => $set->getName(),
'createdAt' => $set->getCreatedAt() ? $set->getCreatedAt()->format('Y-m-d H:i:s') : null,
'createUser' => $set->getCreateUser(),
'modifiedAt' => $set->getModifiedAt() ? $set->getModifiedAt()->format('Y-m-d H:i:s') : null,
'modifyUser' => $set->getModifyUser(),
'revision' => $set->getRevision(),
];
}
return new JsonResponse(['sets' => $data]);
} | [
"public",
"function",
"listAction",
"(",
")",
"{",
"$",
"metaSetManager",
"=",
"$",
"this",
"->",
"get",
"(",
"'phlexible_meta_set.meta_set_manager'",
")",
";",
"$",
"metaSet",
"=",
"$",
"metaSetManager",
"->",
"findAll",
"(",
")",
";",
"$",
"data",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"metaSet",
"as",
"$",
"set",
")",
"{",
"/* @var $set MetaSetInterface */",
"$",
"data",
"[",
"]",
"=",
"[",
"'id'",
"=>",
"$",
"set",
"->",
"getId",
"(",
")",
",",
"'name'",
"=>",
"$",
"set",
"->",
"getName",
"(",
")",
",",
"'createdAt'",
"=>",
"$",
"set",
"->",
"getCreatedAt",
"(",
")",
"?",
"$",
"set",
"->",
"getCreatedAt",
"(",
")",
"->",
"format",
"(",
"'Y-m-d H:i:s'",
")",
":",
"null",
",",
"'createUser'",
"=>",
"$",
"set",
"->",
"getCreateUser",
"(",
")",
",",
"'modifiedAt'",
"=>",
"$",
"set",
"->",
"getModifiedAt",
"(",
")",
"?",
"$",
"set",
"->",
"getModifiedAt",
"(",
")",
"->",
"format",
"(",
"'Y-m-d H:i:s'",
")",
":",
"null",
",",
"'modifyUser'",
"=>",
"$",
"set",
"->",
"getModifyUser",
"(",
")",
",",
"'revision'",
"=>",
"$",
"set",
"->",
"getRevision",
"(",
")",
",",
"]",
";",
"}",
"return",
"new",
"JsonResponse",
"(",
"[",
"'sets'",
"=>",
"$",
"data",
"]",
")",
";",
"}"
] | List sets.
@return JsonResponse
@Route("/list", name="metasets_sets_list") | [
"List",
"sets",
"."
] | 132f24924c9bb0dbb6c1ea84db0a463f97fa3893 | https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/MetaSetBundle/Controller/SetsController.php#L38-L59 |
4,389 | phlexible/phlexible | src/Phlexible/Bundle/MetaSetBundle/Controller/SetsController.php | SetsController.fieldsAction | public function fieldsAction(Request $request)
{
$id = $request->get('id');
$metaSetManager = $this->get('phlexible_meta_set.meta_set_manager');
$metaSet = $metaSetManager->find($id);
$fields = $metaSet->getFields();
$data = [];
foreach ($fields as $field) {
$data[] = [
'id' => $field->getId(),
'key' => $field->getName(),
'type' => $field->getType(),
'required' => $field->isRequired(),
'synchronized' => $field->isSynchronized(),
'readonly' => $field->isReadonly(),
'options' => $field->getOptions(),
];
}
return new JsonResponse(['values' => $data]);
} | php | public function fieldsAction(Request $request)
{
$id = $request->get('id');
$metaSetManager = $this->get('phlexible_meta_set.meta_set_manager');
$metaSet = $metaSetManager->find($id);
$fields = $metaSet->getFields();
$data = [];
foreach ($fields as $field) {
$data[] = [
'id' => $field->getId(),
'key' => $field->getName(),
'type' => $field->getType(),
'required' => $field->isRequired(),
'synchronized' => $field->isSynchronized(),
'readonly' => $field->isReadonly(),
'options' => $field->getOptions(),
];
}
return new JsonResponse(['values' => $data]);
} | [
"public",
"function",
"fieldsAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"id",
"=",
"$",
"request",
"->",
"get",
"(",
"'id'",
")",
";",
"$",
"metaSetManager",
"=",
"$",
"this",
"->",
"get",
"(",
"'phlexible_meta_set.meta_set_manager'",
")",
";",
"$",
"metaSet",
"=",
"$",
"metaSetManager",
"->",
"find",
"(",
"$",
"id",
")",
";",
"$",
"fields",
"=",
"$",
"metaSet",
"->",
"getFields",
"(",
")",
";",
"$",
"data",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
")",
"{",
"$",
"data",
"[",
"]",
"=",
"[",
"'id'",
"=>",
"$",
"field",
"->",
"getId",
"(",
")",
",",
"'key'",
"=>",
"$",
"field",
"->",
"getName",
"(",
")",
",",
"'type'",
"=>",
"$",
"field",
"->",
"getType",
"(",
")",
",",
"'required'",
"=>",
"$",
"field",
"->",
"isRequired",
"(",
")",
",",
"'synchronized'",
"=>",
"$",
"field",
"->",
"isSynchronized",
"(",
")",
",",
"'readonly'",
"=>",
"$",
"field",
"->",
"isReadonly",
"(",
")",
",",
"'options'",
"=>",
"$",
"field",
"->",
"getOptions",
"(",
")",
",",
"]",
";",
"}",
"return",
"new",
"JsonResponse",
"(",
"[",
"'values'",
"=>",
"$",
"data",
"]",
")",
";",
"}"
] | List fields.
@param Request $request
@return JsonResponse
@Route("/fields", name="metasets_sets_fields") | [
"List",
"fields",
"."
] | 132f24924c9bb0dbb6c1ea84db0a463f97fa3893 | https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/MetaSetBundle/Controller/SetsController.php#L69-L91 |
4,390 | phlexible/phlexible | src/Phlexible/Bundle/MetaSetBundle/Controller/SetsController.php | SetsController.createAction | public function createAction(Request $request)
{
$name = $request->get('name', 'new_set');
$metaSetManager = $this->get('phlexible_meta_set.meta_set_manager');
if ($metaSetManager->findOneByName($name)) {
return new ResultResponse(false, 'Name already in use.');
}
$metaSet = $metaSetManager->createMetaSet();
$metaSet
->setId(UuidUtil::generate())
->setName($name)
->setCreateUser($this->getUser()->getDisplayName())
->setCreatedAt(new \DateTime())
->setModifyUser($this->getUser()->getDisplayName())
->setModifiedAt(new \DateTime());
$metaSetManager->updateMetaSet($metaSet);
return new ResultResponse(true, "Meta Set {$metaSet->getName()} created.");
} | php | public function createAction(Request $request)
{
$name = $request->get('name', 'new_set');
$metaSetManager = $this->get('phlexible_meta_set.meta_set_manager');
if ($metaSetManager->findOneByName($name)) {
return new ResultResponse(false, 'Name already in use.');
}
$metaSet = $metaSetManager->createMetaSet();
$metaSet
->setId(UuidUtil::generate())
->setName($name)
->setCreateUser($this->getUser()->getDisplayName())
->setCreatedAt(new \DateTime())
->setModifyUser($this->getUser()->getDisplayName())
->setModifiedAt(new \DateTime());
$metaSetManager->updateMetaSet($metaSet);
return new ResultResponse(true, "Meta Set {$metaSet->getName()} created.");
} | [
"public",
"function",
"createAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"name",
"=",
"$",
"request",
"->",
"get",
"(",
"'name'",
",",
"'new_set'",
")",
";",
"$",
"metaSetManager",
"=",
"$",
"this",
"->",
"get",
"(",
"'phlexible_meta_set.meta_set_manager'",
")",
";",
"if",
"(",
"$",
"metaSetManager",
"->",
"findOneByName",
"(",
"$",
"name",
")",
")",
"{",
"return",
"new",
"ResultResponse",
"(",
"false",
",",
"'Name already in use.'",
")",
";",
"}",
"$",
"metaSet",
"=",
"$",
"metaSetManager",
"->",
"createMetaSet",
"(",
")",
";",
"$",
"metaSet",
"->",
"setId",
"(",
"UuidUtil",
"::",
"generate",
"(",
")",
")",
"->",
"setName",
"(",
"$",
"name",
")",
"->",
"setCreateUser",
"(",
"$",
"this",
"->",
"getUser",
"(",
")",
"->",
"getDisplayName",
"(",
")",
")",
"->",
"setCreatedAt",
"(",
"new",
"\\",
"DateTime",
"(",
")",
")",
"->",
"setModifyUser",
"(",
"$",
"this",
"->",
"getUser",
"(",
")",
"->",
"getDisplayName",
"(",
")",
")",
"->",
"setModifiedAt",
"(",
"new",
"\\",
"DateTime",
"(",
")",
")",
";",
"$",
"metaSetManager",
"->",
"updateMetaSet",
"(",
"$",
"metaSet",
")",
";",
"return",
"new",
"ResultResponse",
"(",
"true",
",",
"\"Meta Set {$metaSet->getName()} created.\"",
")",
";",
"}"
] | Create set.
@param Request $request
@return ResultResponse
@Route("/create", name="metasets_sets_create") | [
"Create",
"set",
"."
] | 132f24924c9bb0dbb6c1ea84db0a463f97fa3893 | https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/MetaSetBundle/Controller/SetsController.php#L101-L123 |
4,391 | phlexible/phlexible | src/Phlexible/Bundle/MetaSetBundle/Controller/SetsController.php | SetsController.renameAction | public function renameAction(Request $request)
{
$id = $request->get('id');
$name = $request->get('name');
$metaSetManager = $this->get('phlexible_meta_set.meta_set_manager');
if ($metaSetManager->findOneByName($name)) {
return new ResultResponse(false, 'Name already in use.');
}
$metaSet = $metaSetManager->find($id);
$oldName = $metaSet->getName();
$metaSet->setName($name);
$metaSetManager->updateMetaSet($metaSet);
return new ResultResponse(true, "Meta Set $oldName renamed to $name.");
} | php | public function renameAction(Request $request)
{
$id = $request->get('id');
$name = $request->get('name');
$metaSetManager = $this->get('phlexible_meta_set.meta_set_manager');
if ($metaSetManager->findOneByName($name)) {
return new ResultResponse(false, 'Name already in use.');
}
$metaSet = $metaSetManager->find($id);
$oldName = $metaSet->getName();
$metaSet->setName($name);
$metaSetManager->updateMetaSet($metaSet);
return new ResultResponse(true, "Meta Set $oldName renamed to $name.");
} | [
"public",
"function",
"renameAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"id",
"=",
"$",
"request",
"->",
"get",
"(",
"'id'",
")",
";",
"$",
"name",
"=",
"$",
"request",
"->",
"get",
"(",
"'name'",
")",
";",
"$",
"metaSetManager",
"=",
"$",
"this",
"->",
"get",
"(",
"'phlexible_meta_set.meta_set_manager'",
")",
";",
"if",
"(",
"$",
"metaSetManager",
"->",
"findOneByName",
"(",
"$",
"name",
")",
")",
"{",
"return",
"new",
"ResultResponse",
"(",
"false",
",",
"'Name already in use.'",
")",
";",
"}",
"$",
"metaSet",
"=",
"$",
"metaSetManager",
"->",
"find",
"(",
"$",
"id",
")",
";",
"$",
"oldName",
"=",
"$",
"metaSet",
"->",
"getName",
"(",
")",
";",
"$",
"metaSet",
"->",
"setName",
"(",
"$",
"name",
")",
";",
"$",
"metaSetManager",
"->",
"updateMetaSet",
"(",
"$",
"metaSet",
")",
";",
"return",
"new",
"ResultResponse",
"(",
"true",
",",
"\"Meta Set $oldName renamed to $name.\"",
")",
";",
"}"
] | Rename set.
@param Request $request
@return ResultResponse
@Route("/rename", name="metasets_sets_rename") | [
"Rename",
"set",
"."
] | 132f24924c9bb0dbb6c1ea84db0a463f97fa3893 | https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/MetaSetBundle/Controller/SetsController.php#L133-L151 |
4,392 | phlexible/phlexible | src/Phlexible/Bundle/MetaSetBundle/Controller/SetsController.php | SetsController.saveAction | public function saveAction(Request $request)
{
$id = $request->get('id');
$data = $request->get('data');
$data = json_decode($data, true);
$metaSetManager = $this->get('phlexible_meta_set.meta_set_manager');
$metaSet = $metaSetManager->find($id);
$metaSet->setRevision($metaSet->getRevision() + 1);
$fields = [];
foreach ($metaSet->getFields() as $field) {
$fields[$field->getId()] = $field;
}
foreach ($data as $item) {
if (!empty($item['options'])) {
$options = [];
foreach (explode(',', $item['options']) as $key => $value) {
$options[$key] = trim($value);
}
$item['options'] = implode(',', $options);
}
if (isset($fields[$item['id']])) {
$field = $fields[$item['id']];
unset($fields[$item['id']]);
} else {
$field = $metaSetManager->createMetaSetField()
->setId(UuidUtil::generate());
}
$field
->setName($item['key'])
->setMetaSet($metaSet)
->setType($item['type'])
->setRequired(!empty($item['required']) ? 1 : 0)
->setSynchronized(!empty($item['synchronized']) ? 1 : 0)
->setReadonly(!empty($item['readonly']) ? 1 : 0)
->setOptions(!empty($item['options']) ? $item['options'] : null);
$metaSet->addField($field);
}
$metaSet
->setModifyUser($this->getUser()->getDisplayName())
->setModifiedAt(new \DateTime());
foreach ($fields as $field) {
$metaSet->removeField($field);
}
$metaSetManager->updateMetaSet($metaSet);
return new ResultResponse(true, "Fields saved for set {$metaSet->getName()}.");
} | php | public function saveAction(Request $request)
{
$id = $request->get('id');
$data = $request->get('data');
$data = json_decode($data, true);
$metaSetManager = $this->get('phlexible_meta_set.meta_set_manager');
$metaSet = $metaSetManager->find($id);
$metaSet->setRevision($metaSet->getRevision() + 1);
$fields = [];
foreach ($metaSet->getFields() as $field) {
$fields[$field->getId()] = $field;
}
foreach ($data as $item) {
if (!empty($item['options'])) {
$options = [];
foreach (explode(',', $item['options']) as $key => $value) {
$options[$key] = trim($value);
}
$item['options'] = implode(',', $options);
}
if (isset($fields[$item['id']])) {
$field = $fields[$item['id']];
unset($fields[$item['id']]);
} else {
$field = $metaSetManager->createMetaSetField()
->setId(UuidUtil::generate());
}
$field
->setName($item['key'])
->setMetaSet($metaSet)
->setType($item['type'])
->setRequired(!empty($item['required']) ? 1 : 0)
->setSynchronized(!empty($item['synchronized']) ? 1 : 0)
->setReadonly(!empty($item['readonly']) ? 1 : 0)
->setOptions(!empty($item['options']) ? $item['options'] : null);
$metaSet->addField($field);
}
$metaSet
->setModifyUser($this->getUser()->getDisplayName())
->setModifiedAt(new \DateTime());
foreach ($fields as $field) {
$metaSet->removeField($field);
}
$metaSetManager->updateMetaSet($metaSet);
return new ResultResponse(true, "Fields saved for set {$metaSet->getName()}.");
} | [
"public",
"function",
"saveAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"id",
"=",
"$",
"request",
"->",
"get",
"(",
"'id'",
")",
";",
"$",
"data",
"=",
"$",
"request",
"->",
"get",
"(",
"'data'",
")",
";",
"$",
"data",
"=",
"json_decode",
"(",
"$",
"data",
",",
"true",
")",
";",
"$",
"metaSetManager",
"=",
"$",
"this",
"->",
"get",
"(",
"'phlexible_meta_set.meta_set_manager'",
")",
";",
"$",
"metaSet",
"=",
"$",
"metaSetManager",
"->",
"find",
"(",
"$",
"id",
")",
";",
"$",
"metaSet",
"->",
"setRevision",
"(",
"$",
"metaSet",
"->",
"getRevision",
"(",
")",
"+",
"1",
")",
";",
"$",
"fields",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"metaSet",
"->",
"getFields",
"(",
")",
"as",
"$",
"field",
")",
"{",
"$",
"fields",
"[",
"$",
"field",
"->",
"getId",
"(",
")",
"]",
"=",
"$",
"field",
";",
"}",
"foreach",
"(",
"$",
"data",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"item",
"[",
"'options'",
"]",
")",
")",
"{",
"$",
"options",
"=",
"[",
"]",
";",
"foreach",
"(",
"explode",
"(",
"','",
",",
"$",
"item",
"[",
"'options'",
"]",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"options",
"[",
"$",
"key",
"]",
"=",
"trim",
"(",
"$",
"value",
")",
";",
"}",
"$",
"item",
"[",
"'options'",
"]",
"=",
"implode",
"(",
"','",
",",
"$",
"options",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"fields",
"[",
"$",
"item",
"[",
"'id'",
"]",
"]",
")",
")",
"{",
"$",
"field",
"=",
"$",
"fields",
"[",
"$",
"item",
"[",
"'id'",
"]",
"]",
";",
"unset",
"(",
"$",
"fields",
"[",
"$",
"item",
"[",
"'id'",
"]",
"]",
")",
";",
"}",
"else",
"{",
"$",
"field",
"=",
"$",
"metaSetManager",
"->",
"createMetaSetField",
"(",
")",
"->",
"setId",
"(",
"UuidUtil",
"::",
"generate",
"(",
")",
")",
";",
"}",
"$",
"field",
"->",
"setName",
"(",
"$",
"item",
"[",
"'key'",
"]",
")",
"->",
"setMetaSet",
"(",
"$",
"metaSet",
")",
"->",
"setType",
"(",
"$",
"item",
"[",
"'type'",
"]",
")",
"->",
"setRequired",
"(",
"!",
"empty",
"(",
"$",
"item",
"[",
"'required'",
"]",
")",
"?",
"1",
":",
"0",
")",
"->",
"setSynchronized",
"(",
"!",
"empty",
"(",
"$",
"item",
"[",
"'synchronized'",
"]",
")",
"?",
"1",
":",
"0",
")",
"->",
"setReadonly",
"(",
"!",
"empty",
"(",
"$",
"item",
"[",
"'readonly'",
"]",
")",
"?",
"1",
":",
"0",
")",
"->",
"setOptions",
"(",
"!",
"empty",
"(",
"$",
"item",
"[",
"'options'",
"]",
")",
"?",
"$",
"item",
"[",
"'options'",
"]",
":",
"null",
")",
";",
"$",
"metaSet",
"->",
"addField",
"(",
"$",
"field",
")",
";",
"}",
"$",
"metaSet",
"->",
"setModifyUser",
"(",
"$",
"this",
"->",
"getUser",
"(",
")",
"->",
"getDisplayName",
"(",
")",
")",
"->",
"setModifiedAt",
"(",
"new",
"\\",
"DateTime",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
")",
"{",
"$",
"metaSet",
"->",
"removeField",
"(",
"$",
"field",
")",
";",
"}",
"$",
"metaSetManager",
"->",
"updateMetaSet",
"(",
"$",
"metaSet",
")",
";",
"return",
"new",
"ResultResponse",
"(",
"true",
",",
"\"Fields saved for set {$metaSet->getName()}.\"",
")",
";",
"}"
] | Save set.
@param Request $request
@return ResultResponse
@Route("/save", name="metasets_sets_save") | [
"Save",
"set",
"."
] | 132f24924c9bb0dbb6c1ea84db0a463f97fa3893 | https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/MetaSetBundle/Controller/SetsController.php#L161-L217 |
4,393 | digit-soft/re-action-promise | src/SharedData.php | SharedData.getData | public function getData($key, $defaultValue = null) {
$key = $this->processKey($key);
if (!$this->hasData($key)) {
return $defaultValue;
}
if (is_array($this->shared[$key]) && isset($this->shared[$key]['#value'])) {
return $this->shared[$key]['#value'];
}
return $this->shared[$key];
} | php | public function getData($key, $defaultValue = null) {
$key = $this->processKey($key);
if (!$this->hasData($key)) {
return $defaultValue;
}
if (is_array($this->shared[$key]) && isset($this->shared[$key]['#value'])) {
return $this->shared[$key]['#value'];
}
return $this->shared[$key];
} | [
"public",
"function",
"getData",
"(",
"$",
"key",
",",
"$",
"defaultValue",
"=",
"null",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"processKey",
"(",
"$",
"key",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"hasData",
"(",
"$",
"key",
")",
")",
"{",
"return",
"$",
"defaultValue",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"shared",
"[",
"$",
"key",
"]",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"shared",
"[",
"$",
"key",
"]",
"[",
"'#value'",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"shared",
"[",
"$",
"key",
"]",
"[",
"'#value'",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"shared",
"[",
"$",
"key",
"]",
";",
"}"
] | Get data by key
@param string $key
@param mixed $defaultValue
@return mixed|null | [
"Get",
"data",
"by",
"key"
] | 9a16b9ca95eeafd3ebcc0a1e8e76ad958c48bac1 | https://github.com/digit-soft/re-action-promise/blob/9a16b9ca95eeafd3ebcc0a1e8e76ad958c48bac1/src/SharedData.php#L36-L45 |
4,394 | digit-soft/re-action-promise | src/SharedData.php | SharedData.hasData | public function hasData($key) {
$key = $this->processKey($key);
return isset($this->shared[$key]);
} | php | public function hasData($key) {
$key = $this->processKey($key);
return isset($this->shared[$key]);
} | [
"public",
"function",
"hasData",
"(",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"processKey",
"(",
"$",
"key",
")",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"shared",
"[",
"$",
"key",
"]",
")",
";",
"}"
] | Check that data is set
@param string $key
@return bool | [
"Check",
"that",
"data",
"is",
"set"
] | 9a16b9ca95eeafd3ebcc0a1e8e76ad958c48bac1 | https://github.com/digit-soft/re-action-promise/blob/9a16b9ca95eeafd3ebcc0a1e8e76ad958c48bac1/src/SharedData.php#L52-L55 |
4,395 | digit-soft/re-action-promise | src/SharedData.php | SharedData.mergeDataEntry | protected function mergeDataEntry($value, $key) {
if (!isset($this->shared[$key])) {
$this->shared[$key] = $value;
} elseif (isset($this->shared[$key]['#merged'])) {
$this->shared[$key]['#value'][] = $value;
} else {
$oldValue = $this->shared[$key];
$this->shared[$key] = [
'#merged' => true,
'#value' => [$oldValue, $value]
];
}
} | php | protected function mergeDataEntry($value, $key) {
if (!isset($this->shared[$key])) {
$this->shared[$key] = $value;
} elseif (isset($this->shared[$key]['#merged'])) {
$this->shared[$key]['#value'][] = $value;
} else {
$oldValue = $this->shared[$key];
$this->shared[$key] = [
'#merged' => true,
'#value' => [$oldValue, $value]
];
}
} | [
"protected",
"function",
"mergeDataEntry",
"(",
"$",
"value",
",",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"shared",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"this",
"->",
"shared",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"this",
"->",
"shared",
"[",
"$",
"key",
"]",
"[",
"'#merged'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"shared",
"[",
"$",
"key",
"]",
"[",
"'#value'",
"]",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"oldValue",
"=",
"$",
"this",
"->",
"shared",
"[",
"$",
"key",
"]",
";",
"$",
"this",
"->",
"shared",
"[",
"$",
"key",
"]",
"=",
"[",
"'#merged'",
"=>",
"true",
",",
"'#value'",
"=>",
"[",
"$",
"oldValue",
",",
"$",
"value",
"]",
"]",
";",
"}",
"}"
] | Merge data entry with new one
@param mixed $value
@param string $key
@internal | [
"Merge",
"data",
"entry",
"with",
"new",
"one"
] | 9a16b9ca95eeafd3ebcc0a1e8e76ad958c48bac1 | https://github.com/digit-soft/re-action-promise/blob/9a16b9ca95eeafd3ebcc0a1e8e76ad958c48bac1/src/SharedData.php#L205-L217 |
4,396 | digit-soft/re-action-promise | src/SharedData.php | SharedData.getSharedFromArgs | public static function getSharedFromArgs($arguments = [], $key = null, $defaultValue = null) {
if ($key === null) {
return null;
}
/** @var SharedDataInterface $instance */
if (($instance = static::instanceFromArguments($arguments)) === null) {
return null;
}
return $instance->getData($key, $defaultValue);
} | php | public static function getSharedFromArgs($arguments = [], $key = null, $defaultValue = null) {
if ($key === null) {
return null;
}
/** @var SharedDataInterface $instance */
if (($instance = static::instanceFromArguments($arguments)) === null) {
return null;
}
return $instance->getData($key, $defaultValue);
} | [
"public",
"static",
"function",
"getSharedFromArgs",
"(",
"$",
"arguments",
"=",
"[",
"]",
",",
"$",
"key",
"=",
"null",
",",
"$",
"defaultValue",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"key",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"/** @var SharedDataInterface $instance */",
"if",
"(",
"(",
"$",
"instance",
"=",
"static",
"::",
"instanceFromArguments",
"(",
"$",
"arguments",
")",
")",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"instance",
"->",
"getData",
"(",
"$",
"key",
",",
"$",
"defaultValue",
")",
";",
"}"
] | Get data from function arguments shared instance
@param array $arguments
@param string $key
@param mixed $defaultValue
@return mixed|null | [
"Get",
"data",
"from",
"function",
"arguments",
"shared",
"instance"
] | 9a16b9ca95eeafd3ebcc0a1e8e76ad958c48bac1 | https://github.com/digit-soft/re-action-promise/blob/9a16b9ca95eeafd3ebcc0a1e8e76ad958c48bac1/src/SharedData.php#L226-L235 |
4,397 | digit-soft/re-action-promise | src/SharedData.php | SharedData.addSharedToArgs | public static function addSharedToArgs($arguments = [], $value, $key = null) {
/** @var SharedDataInterface $instance */
if (($instance = static::instanceFromArguments($arguments)) === null) {
return null;
}
return $instance->addData($value, $key);
} | php | public static function addSharedToArgs($arguments = [], $value, $key = null) {
/** @var SharedDataInterface $instance */
if (($instance = static::instanceFromArguments($arguments)) === null) {
return null;
}
return $instance->addData($value, $key);
} | [
"public",
"static",
"function",
"addSharedToArgs",
"(",
"$",
"arguments",
"=",
"[",
"]",
",",
"$",
"value",
",",
"$",
"key",
"=",
"null",
")",
"{",
"/** @var SharedDataInterface $instance */",
"if",
"(",
"(",
"$",
"instance",
"=",
"static",
"::",
"instanceFromArguments",
"(",
"$",
"arguments",
")",
")",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"instance",
"->",
"addData",
"(",
"$",
"value",
",",
"$",
"key",
")",
";",
"}"
] | Add data to chain instance from function arguments
@param array $arguments
@param mixed $value
@param string $key
@return SharedDataInterface|null | [
"Add",
"data",
"to",
"chain",
"instance",
"from",
"function",
"arguments"
] | 9a16b9ca95eeafd3ebcc0a1e8e76ad958c48bac1 | https://github.com/digit-soft/re-action-promise/blob/9a16b9ca95eeafd3ebcc0a1e8e76ad958c48bac1/src/SharedData.php#L244-L250 |
4,398 | digit-soft/re-action-promise | src/SharedData.php | SharedData.instanceFromArguments | public static function instanceFromArguments($arguments = []) {
$arguments = array_values($arguments);
$argumentsCount = count($arguments);
for ($i = 0; $i < $argumentsCount; $i++) {
if (is_object($arguments[$i]) && $arguments[$i] instanceof SharedDataInterface) {
return $arguments[$i];
}
}
return null;
} | php | public static function instanceFromArguments($arguments = []) {
$arguments = array_values($arguments);
$argumentsCount = count($arguments);
for ($i = 0; $i < $argumentsCount; $i++) {
if (is_object($arguments[$i]) && $arguments[$i] instanceof SharedDataInterface) {
return $arguments[$i];
}
}
return null;
} | [
"public",
"static",
"function",
"instanceFromArguments",
"(",
"$",
"arguments",
"=",
"[",
"]",
")",
"{",
"$",
"arguments",
"=",
"array_values",
"(",
"$",
"arguments",
")",
";",
"$",
"argumentsCount",
"=",
"count",
"(",
"$",
"arguments",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"argumentsCount",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"arguments",
"[",
"$",
"i",
"]",
")",
"&&",
"$",
"arguments",
"[",
"$",
"i",
"]",
"instanceof",
"SharedDataInterface",
")",
"{",
"return",
"$",
"arguments",
"[",
"$",
"i",
"]",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Get instance from function arguments
@param array $arguments
@return SharedDataInterface|null | [
"Get",
"instance",
"from",
"function",
"arguments"
] | 9a16b9ca95eeafd3ebcc0a1e8e76ad958c48bac1 | https://github.com/digit-soft/re-action-promise/blob/9a16b9ca95eeafd3ebcc0a1e8e76ad958c48bac1/src/SharedData.php#L257-L266 |
4,399 | SergioMadness/framework | framework/components/eventhandler/BasicObjectDecorator.php | BasicObjectDecorator.invoke | public function invoke($methodName, array $arguments = [])
{
$this->trigger(self::EVENT_BEFORE_METHOD);
$result = call_user_func_array([$this->o, $methodName], $arguments);
$this->trigger(self::EVENT_AFTER_METHOD);
return $result;
} | php | public function invoke($methodName, array $arguments = [])
{
$this->trigger(self::EVENT_BEFORE_METHOD);
$result = call_user_func_array([$this->o, $methodName], $arguments);
$this->trigger(self::EVENT_AFTER_METHOD);
return $result;
} | [
"public",
"function",
"invoke",
"(",
"$",
"methodName",
",",
"array",
"$",
"arguments",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"trigger",
"(",
"self",
"::",
"EVENT_BEFORE_METHOD",
")",
";",
"$",
"result",
"=",
"call_user_func_array",
"(",
"[",
"$",
"this",
"->",
"o",
",",
"$",
"methodName",
"]",
",",
"$",
"arguments",
")",
";",
"$",
"this",
"->",
"trigger",
"(",
"self",
"::",
"EVENT_AFTER_METHOD",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Invoke method in decorated object
@param string $methodName
@param array $arguments
@return mixed | [
"Invoke",
"method",
"in",
"decorated",
"object"
] | a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e | https://github.com/SergioMadness/framework/blob/a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e/framework/components/eventhandler/BasicObjectDecorator.php#L52-L58 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.